1; RUN: opt -called-value-propagation -S < %s | FileCheck %s 2 3target triple = "aarch64-unknown-linux-gnueabi" 4 5@global_function = internal unnamed_addr global void ()* null, align 8 6@global_array = common unnamed_addr global i64* null, align 8 7 8; This test checks that we propagate the functions through an internal global 9; variable, and attach !callees metadata to the call. Such metadata can enable 10; optimizations of this code sequence. 11; 12; For example, since both of the targeted functions have the "nounwind" and 13; "readnone" function attributes, LICM can be made to move the call and the 14; function pointer load outside the loop. This would then enable the loop 15; vectorizer to vectorize the sum reduction. 16; 17; CHECK: call void %tmp0(), !callees ![[MD:[0-9]+]] 18; CHECK: ![[MD]] = !{void ()* @invariant_1, void ()* @invariant_2} 19; 20define i64 @test_memory_entry(i64 %n, i1 %flag) { 21entry: 22 br i1 %flag, label %then, label %else 23 24then: 25 store void ()* @invariant_1, void ()** @global_function 26 br label %merge 27 28else: 29 store void ()* @invariant_2, void ()** @global_function 30 br label %merge 31 32merge: 33 %tmp1 = call i64 @test_memory(i64 %n) 34 ret i64 %tmp1 35} 36 37define internal i64 @test_memory(i64 %n) { 38entry: 39 %array = load i64*, i64** @global_array 40 br label %for.body 41 42for.body: 43 %i = phi i64 [ 0, %entry ], [ %i.next, %for.body ] 44 %r = phi i64 [ 0, %entry ], [ %tmp3, %for.body ] 45 %tmp0 = load void ()*, void ()** @global_function 46 call void %tmp0() 47 %tmp1 = getelementptr inbounds i64, i64* %array, i64 %i 48 %tmp2 = load i64, i64* %tmp1 49 %tmp3 = add i64 %tmp2, %r 50 %i.next = add nuw nsw i64 %i, 1 51 %cond = icmp slt i64 %i.next, %n 52 br i1 %cond, label %for.body, label %for.end 53 54for.end: 55 %tmp4 = phi i64 [ %tmp3, %for.body ] 56 ret i64 %tmp4 57} 58 59declare void @invariant_1() #0 60declare void @invariant_2() #0 61 62attributes #0 = { nounwind readnone } 63