llvm.org GIT mirror llvm / 2d97abd
Temporarily revert "ArgumentPromotion should copy all metadata to new Function" and the dependent patch "Refine ArgPromotion metadata handling" as they're causing segfaults in argument promotion. This reverts commits r354032 and r353537. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355060 91177308-0d34-0410-b5e6-96231b3b80d8 Eric Christopher 6 months ago
3 changed file(s) with 9 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
215215 Function *NF = Function::Create(NFTy, F->getLinkage(), F->getAddressSpace(),
216216 F->getName());
217217 NF->copyAttributesFrom(F);
218 NF->copyMetadata(F, 0);
219 F->clearMetadata();
218
219 // Patch the pointer to LLVM function in debug info descriptor.
220 NF->setSubprogram(F->getSubprogram());
221 F->setSubprogram(nullptr);
220222
221223 LLVM_DEBUG(dbgs() << "ARG PROMOTION: Promoting to:" << *NF << "\n"
222224 << "From: " << *F);
471473 std::advance(I2, ArgIndices.size());
472474 }
473475
474 assert(F->isDeclaration());
475476 return NF;
476477 }
477478
+0
-31
test/Transforms/ArgumentPromotion/dbg2.ll less more
None ; 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)
0 ; RUN: opt -argpromotion -mem2reg -S < %s | FileCheck %s
11 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
22
3 ; Checks if !prof metadata is correct after argpromotion
3 ; Checks if !prof metadata is corret in deadargelim.
44
55 define void @caller() #0 {
66 %x = alloca i32
77 store i32 42, i32* %x
8 call void @promote_i32_ptr(i32* %x), !prof !6
9 ; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]+]]
8 call void @promote_i32_ptr(i32* %x), !prof !0
9 ; CHECK: call void @promote_i32_ptr(i32 42), !prof ![[PROF:[0-9]]]
1010 ret void
1111 }
1212
13 ; CHECK: define internal void @promote_i32_ptr(i32 %xp.val) !dbg ![[DBG:[0-9]+]] !prof ![[FUNCPROF:[0-9]+]]
14 define internal void @promote_i32_ptr(i32* %xp) !dbg !7 !prof !12 {
13 define internal void @promote_i32_ptr(i32* %xp) {
1514 %x = load i32, i32* %xp
1615 call void @use_i32(i32 %x)
1716 ret void
1918
2019 declare void @use_i32(i32)
2120
22 !llvm.dbg.cu = !{!0}
23 !llvm.module.flags = !{!3, !4, !5}
24
25 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (trunk 353186) (llvm/trunk 353190)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
26 !1 = !DIFile(filename: "profile.cc", directory: ".")
27 !2 = !{}
28 !3 = !{i32 2, !"Dwarf Version", i32 4}
29 !4 = !{i32 2, !"Debug Info Version", i32 3}
30 !5 = !{i32 1, !"wchar_size", i32 4}
3121 ; CHECK: ![[PROF]] = !{!"branch_weights", i32 30}
32 !6 = !{!"branch_weights", i32 30}
33 ; CHECK: ![[DBG]] = distinct !DISubprogram(name: "promote_i32_ptr"
34 !7 = distinct !DISubprogram(name: "promote_i32_ptr", linkageName: "_ZL15promote_i32_ptrPi", scope: !1, file: !1, line: 2, type: !8, scopeLine: 2, flags: DIFlagPrototyped, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition, unit: !0, retainedNodes: !2)
35 !8 = !DISubroutineType(types: !9)
36 !9 = !{null, !10}
37 !10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64)
38 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
39 ; CHECK: ![[FUNCPROF]] = !{!"function_entry_count", i64 331}
40 !12 = !{!"function_entry_count", i64 331}
22 !0 = !{!"branch_weights", i32 30}