brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · b2ea20a Raw
40 lines · plain
1; RUN: opt -passes=called-value-propagation -S < %s | FileCheck %s2 3target triple = "aarch64"4 5@global_function = internal unnamed_addr global ptr null, align 86@global_scalar = internal unnamed_addr global i64 zeroinitializer7 8; This test checks that we propagate the functions through a select9; instruction, and attach !callees metadata to the call. Such metadata can10; enable optimizations of this code sequence.11;12; For example, since both of the targeted functions have the "norecurse"13; attribute, the function attributes pass can be made to infer that14; "@test_select" is also norecurse. This would allow the globals optimizer to15; localize "@global_scalar". The function could then be further simplified to16; always return the constant "1", eliminating the load and store instructions.17;18; CHECK: call void %tmp0(), !callees ![[MD:[0-9]+]]19; CHECK: ![[MD]] = !{ptr @norecurse_1, ptr @norecurse_2}20;21define i64 @test_select_entry(i1 %flag) {22entry:23  %tmp0 = call i64 @test_select(i1 %flag)24  ret i64 %tmp025}26 27define internal i64 @test_select(i1 %flag) {28entry:29  %tmp0 = select i1 %flag, ptr @norecurse_1, ptr @norecurse_230  store i64 1, ptr @global_scalar31  call void %tmp0()32  %tmp1 = load i64, ptr @global_scalar33  ret i64 %tmp134}35 36declare void @norecurse_1() #037declare void @norecurse_2() #038 39attributes #0 = { norecurse }40