llvm.org GIT mirror llvm / af6ce14
Fix (and test) function-local metadata that occurs before the instruction that it refers to; fix is to not enumerate operands of function-local metadata until after all instructions have been enumerated git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95269 91177308-0d34-0410-b5e6-96231b3b80d8 Victor Hernandez 10 years ago
2 changed file(s) with 10 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
407407
408408 FirstInstID = Values.size();
409409
410 SmallVector FunctionLocalMDs;
410411 // Add all of the instructions.
411412 for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
412413 for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
413414 for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
414415 OI != E; ++OI) {
415416 if (MDNode *MD = dyn_cast(*OI))
416 if (!MD->isFunctionLocal())
417 // These were already enumerated during ValueEnumerator creation.
418 continue;
419 EnumerateOperandType(*OI);
417 if (MD->isFunctionLocal())
418 // Enumerate metadata after the instructions they might refer to.
419 FunctionLocalMDs.push_back(MD);
420420 }
421421 if (!I->getType()->isVoidTy())
422422 EnumerateValue(I);
423423 }
424424 }
425
426 // Add all of the function-local metadata.
427 for (unsigned i = 0, e = FunctionLocalMDs.size(); i != e; ++i)
428 EnumerateOperandType(FunctionLocalMDs[i]);
425429 }
426430
427431 void ValueEnumerator::purgeFunction() {
11
22 define void @Foo(i32 %a, i32 %b) {
33 entry:
4 call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"bar")
5 ; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"bar")
46 %0 = add i32 %a, 1 ; [#uses=1]
57 %two = add i32 %b, %0 ; [#uses=0]
68 %1 = alloca i32 ; [#uses=1]