1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2 ; RUN: opt < %s -passes=argpromotion -S | FileCheck %s
4 declare void @sink(i32)
6 define internal void @test(i32** %X) !dbg !2 {
7 ; CHECK-LABEL: define {{[^@]+}}@test
8 ; CHECK-SAME: (i32 [[X_0_VAL_0_VAL:%.*]]) !dbg [[DBG3:![0-9]+]] {
9 ; CHECK-NEXT: call void @sink(i32 [[X_0_VAL_0_VAL]])
10 ; CHECK-NEXT: ret void
12 %1 = load i32*, i32** %X, align 8
13 %2 = load i32, i32* %1, align 8
14 call void @sink(i32 %2)
18 %struct.pair = type { i32, i32 }
20 define internal void @test_byval(%struct.pair* byval(%struct.pair) align 4 %P) {
21 ; CHECK-LABEL: define {{[^@]+}}@test_byval
22 ; CHECK-SAME: (i32 [[P_0:%.*]], i32 [[P_1:%.*]]) {
23 ; CHECK-NEXT: [[P:%.*]] = alloca [[STRUCT_PAIR:%.*]], align 4
24 ; CHECK-NEXT: [[DOT0:%.*]] = getelementptr [[STRUCT_PAIR]], [[STRUCT_PAIR]]* [[P]], i32 0, i32 0
25 ; CHECK-NEXT: store i32 [[P_0]], i32* [[DOT0]], align 4
26 ; CHECK-NEXT: [[DOT1:%.*]] = getelementptr [[STRUCT_PAIR]], [[STRUCT_PAIR]]* [[P]], i32 0, i32 1
27 ; CHECK-NEXT: store i32 [[P_1]], i32* [[DOT1]], align 4
28 ; CHECK-NEXT: [[SINK:%.*]] = alloca i32*, align 8
29 ; CHECK-NEXT: [[DOT2:%.*]] = getelementptr [[STRUCT_PAIR]], [[STRUCT_PAIR]]* [[P]], i32 0, i32 0
30 ; CHECK-NEXT: store i32* [[DOT2]], i32** [[SINK]], align 8
31 ; CHECK-NEXT: ret void
33 %1 = alloca i32*, align 8
34 %2 = getelementptr %struct.pair, %struct.pair* %P, i32 0, i32 0
35 store i32* %2, i32** %1, align 8 ; to protect from "usual" promotion
39 define void @caller(i32** %Y, %struct.pair* %P) {
40 ; CHECK-LABEL: define {{[^@]+}}@caller
41 ; CHECK-SAME: (i32** [[Y:%.*]], %struct.pair* [[P:%.*]]) {
42 ; CHECK-NEXT: [[Y_VAL:%.*]] = load i32*, i32** [[Y]], align 8, !dbg [[DBG4:![0-9]+]]
43 ; CHECK-NEXT: [[Y_VAL_VAL:%.*]] = load i32, i32* [[Y_VAL]], align 8, !dbg [[DBG4]]
44 ; CHECK-NEXT: call void @test(i32 [[Y_VAL_VAL]]), !dbg [[DBG4]]
45 ; CHECK-NEXT: [[P_0:%.*]] = getelementptr [[STRUCT_PAIR:%.*]], %struct.pair* [[P]], i32 0, i32 0, !dbg [[DBG5:![0-9]+]]
46 ; CHECK-NEXT: [[P_0_VAL:%.*]] = load i32, i32* [[P_0]], align 4, !dbg [[DBG5]]
47 ; CHECK-NEXT: [[P_1:%.*]] = getelementptr [[STRUCT_PAIR]], %struct.pair* [[P]], i32 0, i32 1, !dbg [[DBG5]]
48 ; CHECK-NEXT: [[P_1_VAL:%.*]] = load i32, i32* [[P_1]], align 4, !dbg [[DBG5]]
49 ; CHECK-NEXT: call void @test_byval(i32 [[P_0_VAL]], i32 [[P_1_VAL]]), !dbg [[DBG5]]
50 ; CHECK-NEXT: ret void
52 call void @test(i32** %Y), !dbg !1
54 call void @test_byval(%struct.pair* byval(%struct.pair) align 4 %P), !dbg !6
59 !llvm.module.flags = !{!0}
62 !0 = !{i32 2, !"Debug Info Version", i32 3}
63 !1 = !DILocation(line: 8, scope: !2)
64 !2 = distinct !DISubprogram(name: "test", file: !5, line: 3, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !3, scopeLine: 3, scope: null)
65 !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: LineTablesOnly, file: !5)
66 !5 = !DIFile(filename: "test.c", directory: "")
67 !6 = !DILocation(line: 9, scope: !2)