|
1 |
| -; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes |
2 |
| -; RUN: opt -argpromotion -verify -dse -S %s -o - | FileCheck %s |
| 1 | +; RUN: opt -argpromotion -S %s -o - | FileCheck %s |
| 2 | +; RUN: opt -passes=argpromotion -S %s -o - | FileCheck %s |
3 | 3 |
|
4 | 4 | ; Fix for PR33641. ArgumentPromotion removed the argument to bar but left the call to
|
5 | 5 | ; dbg.value which still used the removed argument.
|
6 | 6 |
|
7 | 7 | ; The %p argument should be removed, and the use of it in dbg.value should be
|
8 | 8 | ; changed to undef.
|
9 | 9 |
|
10 |
| -%p_t = type i16* |
11 |
| -%fun_t = type void (%p_t)* |
12 |
| - |
| 10 | +%fun_t = type void (i16*)* |
13 | 11 | define void @foo() {
|
14 |
| -; CHECK-LABEL: define {{[^@]+}}@foo() |
15 |
| -; CHECK-NEXT: ret void |
16 |
| -; |
17 |
| - %tmp = alloca %fun_t |
18 |
| - store %fun_t @bar, %fun_t* %tmp |
| 12 | + %a = alloca i16 |
| 13 | + call void @bar(i16* %a) |
19 | 14 | ret void
|
20 | 15 | }
|
21 | 16 |
|
22 |
| -define internal void @bar(%p_t %p) { |
23 |
| -; CHECK-LABEL: define {{[^@]+}}@bar() |
| 17 | +define internal void @bar(i16* %p) { |
| 18 | +; CHECK-LABEL: define {{.*}}void @bar() |
24 | 19 | ; CHECK-NEXT: call void @llvm.dbg.value(metadata i16* undef, metadata !3, metadata !DIExpression()), !dbg !5
|
25 |
| -; CHECK-NEXT: ret void |
26 |
| -; |
27 |
| - call void @llvm.dbg.value(metadata %p_t %p, metadata !4, metadata !5), !dbg !6 |
28 |
| - ret void |
29 |
| -} |
30 |
| - |
31 |
| -declare void @llvm.dbg.value(metadata, metadata, metadata) |
32 |
| - |
33 |
| - |
34 |
| -; Test case where the promoted argument has uses in @callee and we need to |
35 |
| -; retain a reference to the original function, because it is stored in @storer. |
36 |
| -define void @storer({i32, i32}* %ptr) { |
37 |
| -; CHECK-LABEL: define {{[^@]+}}@storer |
38 |
| -; CHECK-SAME: ({ i32, i32 }* [[PTR:%.*]]) |
39 |
| -; CHECK-NEXT: ret void |
40 |
| -; |
41 |
| - %tmp = alloca i32 ({i32, i32}*)* |
42 |
| - store i32 ({i32, i32}*)* @callee, i32 ({i32, i32}*)** %tmp |
| 20 | + call void @llvm.dbg.value(metadata i16* %p, metadata !3, metadata !DIExpression()), !dbg !5 |
43 | 21 | ret void
|
44 | 22 | }
|
45 | 23 |
|
46 |
| -define i32 @caller() { |
47 |
| -; CHECK-LABEL: define {{[^@]+}}@caller() |
48 |
| -; CHECK-NEXT: [[TMP:%.*]] = alloca { i32, i32 }, align 8 |
49 |
| -; CHECK-NEXT: [[F_1:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[TMP]], i32 0, i32 1 |
50 |
| -; CHECK-NEXT: store i32 10, i32* [[F_1]], align 4 |
51 |
| -; CHECK-NEXT: [[TMP_IDX:%.*]] = getelementptr { i32, i32 }, { i32, i32 }* [[TMP]], i64 0, i32 1 |
52 |
| -; CHECK-NEXT: [[TMP_IDX_VAL:%.*]] = load i32, i32* [[TMP_IDX]], align 4 |
53 |
| -; CHECK-NEXT: [[RES:%.*]] = call i32 @callee(i32 [[TMP_IDX_VAL]]) |
54 |
| -; CHECK-NEXT: ret i32 [[RES]] |
55 |
| -; |
56 |
| - %tmp = alloca {i32, i32} |
57 |
| - %f.1 = getelementptr {i32, i32}, {i32, i32}* %tmp, i32 0, i32 1 |
58 |
| - store i32 10, i32* %f.1 |
59 |
| - %res = call i32 @callee({i32, i32}* %tmp) |
60 |
| - ret i32 %res |
61 |
| -} |
62 |
| - |
63 |
| -define internal i32 @callee({i32, i32}* %ptr) !dbg !7 { |
64 |
| -; CHECK-LABEL: define {{[^@]+}}@callee |
65 |
| -; CHECK-SAME: (i32 [[PTR_0_1_VAL:%.*]]) !dbg !6 |
66 |
| -; CHECK-NEXT: call void @llvm.dbg.value(metadata { i32, i32 }* undef, metadata !7, metadata !DIExpression()), !dbg !8 |
67 |
| -; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[PTR_0_1_VAL]], metadata !7, metadata !DIExpression()), !dbg !8 |
68 |
| -; CHECK-NEXT: ret i32 [[PTR_0_1_VAL]] |
69 |
| -; |
70 |
| - call void @llvm.dbg.value(metadata {i32, i32}* %ptr, metadata !8, metadata !9), !dbg !10 |
71 |
| - %f.1 = getelementptr {i32, i32}, {i32, i32}* %ptr, i32 0, i32 1 |
72 |
| - %l.1 = load i32, i32* %f.1 |
73 |
| - call void @llvm.dbg.value(metadata i32 %l.1, metadata !8, metadata !9), !dbg !10 |
74 |
| - ret i32 %l.1 |
75 |
| -} |
76 |
| - |
| 24 | +declare void @llvm.dbg.value(metadata, metadata, metadata) #0 |
77 | 25 |
|
| 26 | +attributes #0 = { nofree nosync nounwind readnone speculatable willreturn } |
78 | 27 |
|
79 | 28 | !llvm.dbg.cu = !{!0}
|
80 | 29 | !llvm.module.flags = !{!2}
|
81 | 30 |
|
82 |
| -!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1) |
| 31 | +!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) |
83 | 32 | !1 = !DIFile(filename: "test.c", directory: "")
|
84 | 33 | !2 = !{i32 2, !"Debug Info Version", i32 3}
|
85 |
| -!3 = distinct !DISubprogram(name: "bar", unit: !0) |
86 |
| -!4 = !DILocalVariable(name: "p", scope: !3) |
87 |
| -!5 = !DIExpression() |
88 |
| -!6 = !DILocation(line: 1, column: 1, scope: !3) |
89 |
| -!7 = distinct !DISubprogram(name: "callee", unit: !0) |
90 |
| -!8 = !DILocalVariable(name: "c", scope: !7) |
91 |
| -!9 = !DIExpression() |
92 |
| -!10 = !DILocation(line: 2, column: 2, scope: !7) |
| 34 | +!3 = !DILocalVariable(name: "p", scope: !4) |
| 35 | +!4 = distinct !DISubprogram(name: "bar", scope: null, spFlags: DISPFlagDefinition, unit: !0) |
| 36 | +!5 = !DILocation(line: 1, column: 1, scope: !4) |
0 commit comments