summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Bitcode/Writer/ValueEnumerator.cpp12
-rw-r--r--test/Assembler/functionlocal-metadata.ll2
2 files changed, 10 insertions, 4 deletions
diff --git a/lib/Bitcode/Writer/ValueEnumerator.cpp b/lib/Bitcode/Writer/ValueEnumerator.cpp
index c46d735e8c..3eacc5e2be 100644
--- a/lib/Bitcode/Writer/ValueEnumerator.cpp
+++ b/lib/Bitcode/Writer/ValueEnumerator.cpp
@@ -408,21 +408,25 @@ void ValueEnumerator::incorporateFunction(const Function &F) {
FirstInstID = Values.size();
+ SmallVector<MDNode *, 8> FunctionLocalMDs;
// Add all of the instructions.
for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB) {
for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I!=E; ++I) {
for (User::const_op_iterator OI = I->op_begin(), E = I->op_end();
OI != E; ++OI) {
if (MDNode *MD = dyn_cast<MDNode>(*OI))
- if (!MD->isFunctionLocal())
- // These were already enumerated during ValueEnumerator creation.
- continue;
- EnumerateOperandType(*OI);
+ if (MD->isFunctionLocal())
+ // Enumerate metadata after the instructions they might refer to.
+ FunctionLocalMDs.push_back(MD);
}
if (!I->getType()->isVoidTy())
EnumerateValue(I);
}
}
+
+ // Add all of the function-local metadata.
+ for (unsigned i = 0, e = FunctionLocalMDs.size(); i != e; ++i)
+ EnumerateOperandType(FunctionLocalMDs[i]);
}
void ValueEnumerator::purgeFunction() {
diff --git a/test/Assembler/functionlocal-metadata.ll b/test/Assembler/functionlocal-metadata.ll
index 16bc9d06c1..216587d98a 100644
--- a/test/Assembler/functionlocal-metadata.ll
+++ b/test/Assembler/functionlocal-metadata.ll
@@ -2,6 +2,8 @@
define void @Foo(i32 %a, i32 %b) {
entry:
+ call void @llvm.dbg.value(metadata !{ i32* %1 }, i64 16, metadata !"bar")
+; CHECK: call void @llvm.dbg.value(metadata !{i32* %1}, i64 16, metadata !"bar")
%0 = add i32 %a, 1 ; <i32> [#uses=1]
%two = add i32 %b, %0 ; <i32> [#uses=0]
%1 = alloca i32 ; <i32*> [#uses=1]