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 4; PR2498 5 6; This test tries to convince CHECK about promoting the load from %A + 2, 7; because there is a load of %A in the entry block 8define internal i32 @callee(i1 %C, ptr %A) { 9; 10; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 11; CHECK-LABEL: define {{[^@]+}}@callee 12; CHECK-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] { 13; CHECK-NEXT: entry: 14; CHECK-NEXT: [[A_0:%.*]] = load i32, ptr [[A]], align 4 15; CHECK-NEXT: br label [[F:%.*]] 16; CHECK: T: 17; CHECK-NEXT: unreachable 18; CHECK: F: 19; CHECK-NEXT: [[A_2:%.*]] = getelementptr i32, ptr [[A]], i32 2 20; CHECK-NEXT: [[R:%.*]] = load i32, ptr [[A_2]], align 4 21; CHECK-NEXT: ret i32 [[R]] 22; 23entry: 24 ; Unconditonally load the element at %A 25 %A.0 = load i32, ptr %A 26 br i1 %C, label %T, label %F 27 28T: 29 ret i32 %A.0 30 31F: 32 ; Load the element at offset two from %A. This should not be promoted! 33 %A.2 = getelementptr i32, ptr %A, i32 2 34 %R = load i32, ptr %A.2 35 ret i32 %R 36} 37 38define i32 @foo(ptr %A) { 39; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 40; TUNIT-LABEL: define {{[^@]+}}@foo 41; TUNIT-SAME: (ptr nofree readonly captures(none) [[A:%.*]]) #[[ATTR0]] { 42; TUNIT-NEXT: [[X:%.*]] = call i32 @callee(ptr nofree noundef readonly align 4 captures(none) [[A]]) #[[ATTR1:[0-9]+]] 43; TUNIT-NEXT: ret i32 [[X]] 44; 45; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: read) 46; CGSCC-LABEL: define {{[^@]+}}@foo 47; CGSCC-SAME: (ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A:%.*]]) #[[ATTR1:[0-9]+]] { 48; CGSCC-NEXT: [[X:%.*]] = call i32 @callee(ptr nofree noundef nonnull readonly align 4 captures(none) dereferenceable(4) [[A]]) #[[ATTR2:[0-9]+]] 49; CGSCC-NEXT: ret i32 [[X]] 50; 51 %X = call i32 @callee(i1 false, ptr %A) ; <i32> [#uses=1] 52 ret i32 %X 53} 54 55;. 56; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) } 57; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn memory(read) } 58;. 59; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) } 60; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: read) } 61; CGSCC: attributes #[[ATTR2]] = { nofree willreturn memory(read) } 62;. 63