llvm.org GIT mirror llvm / 978f4b0
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354032 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 7 months ago
2 changed file(s) with 33 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
216216 F->getName());
217217 NF->copyAttributesFrom(F);
218218 NF->copyMetadata(F, 0);
219 F->clearMetadata();
219220
220221 LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
221222 << "From: " << *F);
470471 std::advance(I2, ArgIndices.size());
471472 }
472473
474 assert(F->isDeclaration());
473475 return NF;
474476 }
475477
0 ; RUN: opt < %s -argpromotion -instcombine -S | FileCheck %s
1
2 %f_ty = type void (i8*)*
3
4 define void @foo() {
5 entry:
6 %f_p = getelementptr inbounds %f_ty, %f_ty* null, i32 0
7 store %f_ty @bar, %f_ty* %f_p, align 1
8 ret void
9 }
10
11 define internal void @bar(i8*) !dbg !1 {
12 entry:
13 ret void
14 }
15
16 ; The new copy should get the !dbg metadata
17 ; CHECK: define internal void @bar() !dbg
18 ; The old copy should now be a declaration without any !dbg metadata
19 ; CHECK-NOT: declare dso_local void @0(i8*) !dbg
20 ; CHECK: declare dso_local void @0(i8*)
21
22 !llvm.dbg.cu = !{}
23 !llvm.module.flags = !{!0}
24
25 !0 = !{i32 2, !"Debug Info Version", i32 3}
26 !1 = distinct !DISubprogram(name: "bar", scope: !2, file: !2, line: 14, type: !3, scopeLine: 14, spFlags: DISPFlagDefinition, unit: !5)
27 !2 = !DIFile(filename: "foo.c", directory: "/bar")
28 !3 = !DISubroutineType(types: !4)
29 !4 = !{}
30 !5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "My Compiler", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, nameTableKind: None)