brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · 1f9846e Raw
37 lines · plain
1; RUN: opt < %s -aa-pipeline=basic-aa -passes=gvn,instcombine -S | FileCheck %s2 3declare ptr @test(ptr nocapture)4 5define i32 @test2() {6; CHECK: ret i32 07       %P = alloca i328       %Q = call ptr @test(ptr %P)9       %a = load i32, ptr %P10       store i32 4, ptr %Q   ;; cannot clobber P since it is nocapture.11       %b = load i32, ptr %P12       %c = sub i32 %a, %b13       ret i32 %c14}15 16declare void @test3(ptr %p, ptr %q) nounwind17 18define i32 @test4(ptr noalias nocapture %p) nounwind {19; CHECK: call void @test320; CHECK: store i32 0, ptr %p21; CHECK: store i32 1, ptr %x22; CHECK: %y = load i32, ptr %p23; CHECK: ret i32 %y24entry:25       %q = alloca ptr26       ; Here test3 might store %p to %q. This doesn't violate %p's nocapture27       ; attribute since the copy doesn't outlive the function.28       call void @test3(ptr %q, ptr %p) nounwind29       store i32 0, ptr %p30       %x = load ptr, ptr %q31       ; This store might write to %p and so we can't eliminate the subsequent32       ; load33       store i32 1, ptr %x34       %y = load i32, ptr %p35       ret i32 %y36}37