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(ptr %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 ptr, ptr %X, align 8
13 %2 = load i32, ptr %1, align 8
14 call void @sink(i32 %2)
18 %struct.pair = type { i32, i32 }
20 ; Do not promote because there is a store of the pointer %P itself. Even if %P
21 ; had been promoted as a byval argument, the result would have been not
22 ; optimizable for SROA.
23 define internal void @test_byval(ptr byval(%struct.pair) align 4 %P) {
24 ; CHECK-LABEL: define {{[^@]+}}@test_byval
25 ; CHECK-SAME: (ptr byval([[STRUCT_PAIR:%.*]]) align 4 [[P:%.*]]) {
26 ; CHECK-NEXT: [[TMP1:%.*]] = alloca ptr, align 8
27 ; CHECK-NEXT: store ptr [[P]], ptr [[TMP1]], align 8
28 ; CHECK-NEXT: ret void
30 %1 = alloca ptr, align 8
31 store ptr %P, ptr %1, align 8 ; to protect from promotion
35 define void @caller(ptr %Y, ptr %P) {
36 ; CHECK-LABEL: define {{[^@]+}}@caller
37 ; CHECK-SAME: (ptr [[Y:%.*]], ptr [[P:%.*]]) {
38 ; CHECK-NEXT: [[Y_VAL:%.*]] = load ptr, ptr [[Y]], align 8, !dbg [[DBG4:![0-9]+]]
39 ; CHECK-NEXT: [[Y_VAL_VAL:%.*]] = load i32, ptr [[Y_VAL]], align 8, !dbg [[DBG4]]
40 ; CHECK-NEXT: call void @test(i32 [[Y_VAL_VAL]]), !dbg [[DBG4]]
41 ; CHECK-NEXT: call void @test_byval(ptr byval([[STRUCT_PAIR:%.*]]) align 4 [[P]]), !dbg [[DBG5:![0-9]+]]
42 ; CHECK-NEXT: ret void
44 call void @test(ptr %Y), !dbg !1
46 call void @test_byval(ptr byval(%struct.pair) align 4 %P), !dbg !6
51 !llvm.module.flags = !{!0}
54 !0 = !{i32 2, !"Debug Info Version", i32 3}
55 !1 = !DILocation(line: 8, scope: !2)
56 !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)
57 !3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: LineTablesOnly, file: !5)
58 !5 = !DIFile(filename: "test.c", directory: "")
59 !6 = !DILocation(line: 9, scope: !2)