llvm.org GIT mirror llvm / 4e9c473
Fix a gcroot lowering bug. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41668 91177308-0d34-0410-b5e6-96231b3b80d8 Evan Cheng 13 years ago
2 changed file(s) with 15 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
261261 cast(GCRootInt->getFunctionType()->getParamType(0));
262262 Constant *Null = ConstantPointerNull::get(PtrLocTy);
263263
264 // Initialize all of the gcroot records now, and eliminate them as we go.
264 // Initialize all of the gcroot records now.
265265 for (unsigned i = 0, e = GCRoots.size(); i != e; ++i) {
266266 // Initialize the meta-data pointer.
267267 Par[2] = ConstantInt::get(Type::Int32Ty, i);
281281 new StoreInst(Constant::getNullValue(PtrLocTy->getElementType()),
282282 GCRoots[i]->getOperand(1), GCRoots[i]);
283283 new StoreInst(GCRoots[i]->getOperand(1), RootPtrPtr, GCRoots[i]);
284 GCRoots[i]->getParent()->getInstList().erase(GCRoots[i]);
285284 }
286285
287286 // Now that the record is all initialized, store the pointer into the global
288287 // pointer.
289288 Value *C = new BitCastInst(AI, PointerType::get(MainRootRecordType), "", IP);
290289 new StoreInst(C, RootChain, IP);
290
291 // Eliminate all the gcroot records now.
292 for (unsigned i = 0, e = GCRoots.size(); i != e; ++i)
293 GCRoots[i]->getParent()->getInstList().erase(GCRoots[i]);
291294
292295 // On exit from the function we have to remove the entry from the GC root
293296 // chain. Doing this is straight-forward for return and unwind instructions:
0 ; RUN: llvm-as < %s | llc
1
2 %Env = type opaque*
3
4 define void @.main(%Env) {
5 call void @llvm.gcroot( %Env* null, %Env null )
6 unreachable
7 }
8
9 declare void @llvm.gcroot(%Env*, %Env)