1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=2 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4; RUN: opt -attributor-cgscc -enable-new-pm=0 -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
6
7declare void @sink(i32)
8
9define internal void @test(i32** %X) !dbg !2 {
10; CHECK-LABEL: define {{[^@]+}}@test
11; CHECK-SAME: (i32** nocapture nonnull readonly align 8 dereferenceable(8) [[X:%.*]]) [[DBG3:!dbg !.*]] {
12; CHECK-NEXT:    [[TMP1:%.*]] = load i32*, i32** [[X]], align 8
13; CHECK-NEXT:    [[TMP2:%.*]] = load i32, i32* [[TMP1]], align 8
14; CHECK-NEXT:    call void @sink(i32 [[TMP2]])
15; CHECK-NEXT:    ret void
16;
17  %1 = load i32*, i32** %X, align 8
18  %2 = load i32, i32* %1, align 8
19  call void @sink(i32 %2)
20  ret void
21}
22
23%struct.pair = type { i32, i32 }
24
25define internal void @test_byval(%struct.pair* byval(%struct.pair) %P) {
26; CHECK-LABEL: define {{[^@]+}}@test_byval() {
27; CHECK-NEXT:    call void @sink(i32 noundef 0)
28; CHECK-NEXT:    ret void
29;
30  call void @sink(i32 0)
31  ret void
32}
33
34define void @caller(i32** %Y, %struct.pair* %P) {
35; IS__TUNIT____-LABEL: define {{[^@]+}}@caller
36; IS__TUNIT____-SAME: (i32** nocapture readonly [[Y:%.*]], %struct.pair* nocapture nofree readnone [[P:%.*]]) {
37; IS__TUNIT____-NEXT:    call void @test(i32** nocapture readonly align 8 [[Y]]), [[DBG4:!dbg !.*]]
38; IS__TUNIT____-NEXT:    call void @test_byval(), [[DBG5:!dbg !.*]]
39; IS__TUNIT____-NEXT:    ret void
40;
41; IS__CGSCC____-LABEL: define {{[^@]+}}@caller
42; IS__CGSCC____-SAME: (i32** nocapture nonnull readonly align 8 dereferenceable(8) [[Y:%.*]], %struct.pair* nocapture nofree readnone [[P:%.*]]) {
43; IS__CGSCC____-NEXT:    call void @test(i32** nocapture nonnull readonly align 8 dereferenceable(8) [[Y]]), [[DBG4:!dbg !.*]]
44; IS__CGSCC____-NEXT:    call void @test_byval(), [[DBG5:!dbg !.*]]
45; IS__CGSCC____-NEXT:    ret void
46;
47  call void @test(i32** %Y), !dbg !1
48
49  call void @test_byval(%struct.pair* %P), !dbg !6
50  ret void
51}
52
53
54!llvm.module.flags = !{!0}
55!llvm.dbg.cu = !{!3}
56
57!0 = !{i32 2, !"Debug Info Version", i32 3}
58!1 = !DILocation(line: 8, scope: !2)
59!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)
60!3 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: LineTablesOnly, file: !5)
61!5 = !DIFile(filename: "test.c", directory: "")
62!6 = !DILocation(line: 9, scope: !2)
63