diff options
author | Chris Lattner <sabre@nondot.org> | 2004-07-22 05:51:13 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-07-22 05:51:13 +0000 |
commit | 93c9587fbbbc0a6b6a64df9ea6184b7fdf8eba35 (patch) | |
tree | c3a36786aca89b85bdf981533788105e661d1631 | |
parent | 9545a1797b99cad119d2dfaa975f6e95c745b62a (diff) | |
download | external_llvm-93c9587fbbbc0a6b6a64df9ea6184b7fdf8eba35.zip external_llvm-93c9587fbbbc0a6b6a64df9ea6184b7fdf8eba35.tar.gz external_llvm-93c9587fbbbc0a6b6a64df9ea6184b7fdf8eba35.tar.bz2 |
Update GC intrinsics to take a pointer to the object as well as a pointer
to the field being updated. Patch contributed by Tobias Nurmiranta
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15097 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Transforms/Scalar/LowerGC.cpp | 13 | ||||
-rw-r--r-- | runtime/GC/GCInterface.h | 4 | ||||
-rw-r--r-- | runtime/GC/SemiSpace/semispace.c | 4 |
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/Transforms/Scalar/LowerGC.cpp b/lib/Transforms/Scalar/LowerGC.cpp index 0c03b91..2e03807 100644 --- a/lib/Transforms/Scalar/LowerGC.cpp +++ b/lib/Transforms/Scalar/LowerGC.cpp @@ -109,10 +109,10 @@ bool LowerGC::doInitialization(Module &M) { // If the program is using read/write barriers, find the implementations of // them from the GC runtime library. if (GCReadInt) // Make: sbyte* %llvm_gc_read(sbyte**) - GCRead = M.getOrInsertFunction("llvm_gc_read", VoidPtr, VoidPtrPtr, 0); + GCRead = M.getOrInsertFunction("llvm_gc_read", VoidPtr, VoidPtr, VoidPtrPtr, 0); if (GCWriteInt) // Make: void %llvm_gc_write(sbyte*, sbyte**) GCWrite = M.getOrInsertFunction("llvm_gc_write", Type::VoidTy, - VoidPtr, VoidPtrPtr, 0); + VoidPtr, VoidPtr, VoidPtrPtr, 0); // If the program has GC roots, get or create the global root list. if (GCRootInt) { @@ -182,14 +182,17 @@ bool LowerGC::runOnFunction(Function &F) { CI->setOperand(0, GCWrite); // Insert casts of the operands as needed. Coerce(CI, 1, VoidPtr); - Coerce(CI, 2, VoidPtrPtr); + Coerce(CI, 2, VoidPtr); + Coerce(CI, 3, VoidPtrPtr); } else { - Coerce(CI, 1, VoidPtrPtr); + Coerce(CI, 1, VoidPtr); + Coerce(CI, 2, VoidPtrPtr); if (CI->getType() == VoidPtr) { CI->setOperand(0, GCRead); } else { // Create a whole new call to replace the old one. - CallInst *NC = new CallInst(GCRead, CI->getOperand(1), + CallInst *NC = new CallInst(GCRead, CI->getOperand(1), + CI->getOperand(2), CI->getName(), CI); Value *NV = new CastInst(NC, CI->getType(), "", CI); CI->replaceAllUsesWith(NV); diff --git a/runtime/GC/GCInterface.h b/runtime/GC/GCInterface.h index e2a9b68..e83abe0 100644 --- a/runtime/GC/GCInterface.h +++ b/runtime/GC/GCInterface.h @@ -38,11 +38,11 @@ void llvm_gc_collect(); /* llvm_gc_read - This function should be implemented to include any read * barrier code that is needed by the garbage collector. */ -void *llvm_gc_read(void **P); +void *llvm_gc_read(void *ObjPtr, void **FieldPtr); /* llvm_gc_write - This function should be implemented to include any write * barrier code that is needed by the garbage collector. */ -void llvm_gc_write(void *V, void **P); +void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr); #endif diff --git a/runtime/GC/SemiSpace/semispace.c b/runtime/GC/SemiSpace/semispace.c index df60b62..cb5864b 100644 --- a/runtime/GC/SemiSpace/semispace.c +++ b/runtime/GC/SemiSpace/semispace.c @@ -89,8 +89,8 @@ void llvm_gc_collect() { } /* We use no read/write barriers */ -void *llvm_gc_read(void **P) { return *P; } -void llvm_gc_write(void *V, void **P) { *P = V; } +void *llvm_gc_read(void *ObjPtr, void **FieldPtr) { return *FieldPtr; } +void llvm_gc_write(void *V, void *ObjPtr, void **FieldPtr) { *FieldPtr = V; } /*===----------------------------------------------------------------------===** |