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 3 4declare void @sink(i32) 5 6define 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 11; 12 %1 = load ptr, ptr %X, align 8 13 %2 = load i32, ptr %1, align 8 14 call void @sink(i32 %2) 15 ret void 16} 17 18%struct.pair = type { i32, i32 } 19 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. 23define 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 29; 30 %1 = alloca ptr, align 8 31 store ptr %P, ptr %1, align 8 ; to protect from promotion 32 ret void 33} 34 35define 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 43; 44 call void @test(ptr %Y), !dbg !1 45 46 call void @test_byval(ptr byval(%struct.pair) align 4 %P), !dbg !6 47 ret void 48} 49 50 51!llvm.module.flags = !{!0} 52!llvm.dbg.cu = !{!3} 53 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) 60