summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2019-02-14 14:14:24 +0000
committerTeresa Johnson <tejohnson@google.com>2019-02-14 14:14:24 +0000
commitc374a800e7f84f701bf2fceb39c35d0909603c1e (patch)
tree1ec333748c684a5a07b2ae23f1e039efccbc756f
parent6ab83b7db642050db27c0734f89edd309da0e641 (diff)
downloadbcm5719-llvm-c374a800e7f84f701bf2fceb39c35d0909603c1e.tar.gz
bcm5719-llvm-c374a800e7f84f701bf2fceb39c35d0909603c1e.zip
Refine ArgPromotion metadata handling
Summary: In r353537 we now copy all metadata to the new function, with the old being removed when the old function is eliminated. In some cases the old function is dropped to a declaration (seems to only occur with the old PM). Go ahead and clear all metadata from the old function to handle that case, since verification will complain otherwise. This is consistent with what was being done for debug metadata before r353537. Reviewers: davidxl, uabelho Subscribers: jdoerfert, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D58215 llvm-svn: 354032
-rw-r--r--llvm/lib/Transforms/IPO/ArgumentPromotion.cpp2
-rw-r--r--llvm/test/Transforms/ArgumentPromotion/dbg2.ll31
2 files changed, 33 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 30763f26971..feda27424c2 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -217,6 +217,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
F->getName());
NF->copyAttributesFrom(F);
NF->copyMetadata(F, 0);
+ F->clearMetadata();
LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
<< "From: " << *F);
@@ -471,6 +472,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
std::advance(I2, ArgIndices.size());
}
+ assert(F->isDeclaration());
return NF;
}
diff --git a/llvm/test/Transforms/ArgumentPromotion/dbg2.ll b/llvm/test/Transforms/ArgumentPromotion/dbg2.ll
new file mode 100644
index 00000000000..ecec7d7a5dc
--- /dev/null
+++ b/llvm/test/Transforms/ArgumentPromotion/dbg2.ll
@@ -0,0 +1,31 @@
+; RUN: opt < %s -argpromotion -instcombine -S | FileCheck %s
+
+%f_ty = type void (i8*)*
+
+define void @foo() {
+entry:
+ %f_p = getelementptr inbounds %f_ty, %f_ty* null, i32 0
+ store %f_ty @bar, %f_ty* %f_p, align 1
+ ret void
+}
+
+define internal void @bar(i8*) !dbg !1 {
+entry:
+ ret void
+}
+
+; The new copy should get the !dbg metadata
+; CHECK: define internal void @bar() !dbg
+; The old copy should now be a declaration without any !dbg metadata
+; CHECK-NOT: declare dso_local void @0(i8*) !dbg
+; CHECK: declare dso_local void @0(i8*)
+
+!llvm.dbg.cu = !{}
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 2, !"Debug Info Version", i32 3}
+!1 = distinct !DISubprogram(name: "bar", scope: !2, file: !2, line: 14, type: !3, scopeLine: 14, spFlags: DISPFlagDefinition, unit: !5)
+!2 = !DIFile(filename: "foo.c", directory: "/bar")
+!3 = !DISubroutineType(types: !4)
+!4 = !{}
+!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "My Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, nameTableKind: None)
OpenPOWER on IntegriCloud