1 ; RUN: opt -S -inline < %s | FileCheck %s
2 ; RUN: opt -S -O3 < %s | FileCheck %s
3 ; RUN: opt -S -inline -inline-threshold=1 < %s | FileCheck %s
5 %struct.A = type <{ i32 (...)**, i32, [4 x i8] }>
7 ; This test checks if value returned from the launder is considered aliasing
8 ; with its argument. Due to bug caused by handling launder in capture tracking
9 ; sometimes it would be considered noalias.
10 ; CHECK-LABEL: define i32 @bar(%struct.A* noalias
11 define i32 @bar(%struct.A* noalias) {
13 %2 = bitcast %struct.A* %0 to i8*
14 %3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %2)
15 %4 = getelementptr inbounds i8, i8* %3, i64 8
16 %5 = bitcast i8* %4 to i32*
17 store i32 42, i32* %5, align 8
18 %6 = getelementptr inbounds %struct.A, %struct.A* %0, i64 0, i32 1
19 %7 = load i32, i32* %6, align 8
23 ; CHECK-LABEL: define i32 @foo(%struct.A* noalias
24 define i32 @foo(%struct.A* noalias) {
25 ; CHECK-NOT: call i32 @bar(
27 %2 = tail call i32 @bar(%struct.A* %0)
32 ; This test checks if invariant group intrinsics have zero cost for inlining.
33 ; CHECK-LABEL: define i8* @caller(i8*
34 define i8* @caller(i8* %p) {
35 ; CHECK-NOT: call i8* @lot_of_launders_and_strips
36 %a1 = call i8* @lot_of_launders_and_strips(i8* %p)
37 %a2 = call i8* @lot_of_launders_and_strips(i8* %a1)
38 %a3 = call i8* @lot_of_launders_and_strips(i8* %a2)
39 %a4 = call i8* @lot_of_launders_and_strips(i8* %a3)
43 define i8* @lot_of_launders_and_strips(i8* %p) {
44 %a1 = call i8* @llvm.launder.invariant.group.p0i8(i8* %p)
45 %a2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a1)
46 %a3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a2)
47 %a4 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a3)
49 %s1 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a4)
50 %s2 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s1)
51 %s3 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s2)
52 %s4 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s3)
58 declare i8* @llvm.launder.invariant.group.p0i8(i8*)
59 declare i8* @llvm.strip.invariant.group.p0i8(i8*)