[llvm-commits] [llvm] r103428 - in /llvm/trunk: lib/VMCore/AsmWriter.cpp test/Feature/metadata.ll
Chris Lattner
sabre at nondot.org
Mon May 10 13:53:17 PDT 2010
Author: lattner
Date: Mon May 10 15:53:17 2010
New Revision: 103428
URL: http://llvm.org/viewvc/llvm-project?rev=103428&view=rev
Log:
fix PR7105 by enumerating MDNodes on all @llvm.foo
function calls, not just recognized intrinsics.
Added:
llvm/trunk/test/Feature/metadata.ll
Modified:
llvm/trunk/lib/VMCore/AsmWriter.cpp
Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=103428&r1=103427&r2=103428&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Mon May 10 15:53:17 2010
@@ -677,11 +677,16 @@
if (!I->getType()->isVoidTy() && !I->hasName())
CreateFunctionSlot(I);
- // Intrinsics can directly use metadata.
- if (isa<IntrinsicInst>(I))
- for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
- if (MDNode *N = dyn_cast_or_null<MDNode>(I->getOperand(i)))
- CreateMetadataSlot(N);
+ // Intrinsics can directly use metadata. We allow direct calls to any
+ // llvm.foo function here, because the target may not be linked into the
+ // optimizer.
+ if (const CallInst *CI = dyn_cast<CallInst>(I)) {
+ if (Function *F = CI->getCalledFunction())
+ if (F->getName().startswith("llvm."))
+ for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
+ if (MDNode *N = dyn_cast_or_null<MDNode>(I->getOperand(i)))
+ CreateMetadataSlot(N);
+ }
// Process metadata attached with this instruction.
I->getAllMetadata(MDForInst);
Added: llvm/trunk/test/Feature/metadata.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Feature/metadata.ll?rev=103428&view=auto
==============================================================================
--- llvm/trunk/test/Feature/metadata.ll (added)
+++ llvm/trunk/test/Feature/metadata.ll Mon May 10 15:53:17 2010
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | llvm-dis | llvm-as | llvm-dis
+; PR7105
+
+define void @foo() {
+ call void @llvm.zonk(metadata !1, i64 0, metadata !1)
+ ret void
+}
+
+declare void @llvm.zonk(metadata, i64, metadata) nounwind readnone
+
+!named = !{!0}
+!0 = metadata !{i8** null}
+!1 = metadata !{i8* null}
More information about the llvm-commits
mailing list