xref: /llvm-project/llvm/test/Transforms/Attributor/ArgumentPromotion/profile.ll (revision cd3a4c31bc9694d160de54c6a4daa53e152cb463)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal  -attributor-annotate-decl-cs  -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal  -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
5
6; Checks if !prof metadata is corret in deadargelim.
7
8define void @caller() #0 {
9; TUNIT-LABEL: define {{[^@]+}}@caller() {
10; TUNIT-NEXT:    [[X:%.*]] = alloca i32, align 4
11; TUNIT-NEXT:    store i32 42, ptr [[X]], align 4
12; TUNIT-NEXT:    [[TMP1:%.*]] = load i32, ptr [[X]], align 4
13; TUNIT-NEXT:    call void @promote_i32_ptr(i32 [[TMP1]]), !prof [[PROF0:![0-9]+]]
14; TUNIT-NEXT:    ret void
15;
16; CGSCC-LABEL: define {{[^@]+}}@caller() {
17; CGSCC-NEXT:    call void @promote_i32_ptr(i32 noundef 42), !prof [[PROF0:![0-9]+]]
18; CGSCC-NEXT:    ret void
19;
20  %x = alloca i32
21  store i32 42, ptr %x
22  call void @promote_i32_ptr(ptr %x), !prof !0
23  ret void
24}
25
26define internal void @promote_i32_ptr(ptr %xp) {
27; CHECK: Function Attrs: memory(readwrite, argmem: none)
28; CHECK-LABEL: define {{[^@]+}}@promote_i32_ptr
29; CHECK-SAME: (i32 [[TMP0:%.*]]) #[[ATTR0:[0-9]+]] {
30; CHECK-NEXT:    [[XP_PRIV:%.*]] = alloca i32, align 4
31; CHECK-NEXT:    store i32 [[TMP0]], ptr [[XP_PRIV]], align 4
32; CHECK-NEXT:    [[X:%.*]] = load i32, ptr [[XP_PRIV]], align 4
33; CHECK-NEXT:    call void @use_i32(i32 [[X]])
34; CHECK-NEXT:    ret void
35;
36  %x = load i32, ptr %xp
37  call void @use_i32(i32 %x)
38  ret void
39}
40
41declare void @use_i32(i32)
42
43!0 = !{!"branch_weights", i32 30}
44;.
45; TUNIT: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }
46;.
47; CGSCC: attributes #[[ATTR0]] = { memory(readwrite, argmem: none) }
48;.
49; TUNIT: [[PROF0]] = !{!"branch_weights", i32 30}
50;.
51; CGSCC: [[PROF0]] = !{!"branch_weights", i32 30}
52;.
53