[PATCH] D58215: Refine ArgPromotion metadata handling
Teresa Johnson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 13 21:30:07 PST 2019
tejohnson updated this revision to Diff 186797.
tejohnson added a comment.
Add assert
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58215/new/
https://reviews.llvm.org/D58215
Files:
lib/Transforms/IPO/ArgumentPromotion.cpp
test/Transforms/ArgumentPromotion/dbg2.ll
Index: test/Transforms/ArgumentPromotion/dbg2.ll
===================================================================
--- /dev/null
+++ 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)
Index: lib/Transforms/IPO/ArgumentPromotion.cpp
===================================================================
--- lib/Transforms/IPO/ArgumentPromotion.cpp
+++ lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -217,6 +217,7 @@
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 @@
std::advance(I2, ArgIndices.size());
}
+ assert(F->isDeclaration());
return NF;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58215.186797.patch
Type: text/x-patch
Size: 1848 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190214/b2b2c7bc/attachment.bin>
More information about the llvm-commits
mailing list