1 ; RUN: opt -S -passes=inline < %s | FileCheck %s
2 ; RUN: opt -S -O3 < %s | FileCheck %s
3 ; RUN: opt -S -passes=inline -inline-threshold=1 < %s | FileCheck %s
5 %struct.A = type <{ ptr, 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 {{(noundef )?}}i32 @bar(ptr noalias
11 define i32 @bar(ptr noalias) {
13 %2 = call ptr @llvm.launder.invariant.group.p0(ptr %0)
14 %3 = getelementptr inbounds i8, ptr %2, i64 8
15 store i32 42, ptr %3, align 8
16 %4 = getelementptr inbounds %struct.A, ptr %0, i64 0, i32 1
17 %5 = load i32, ptr %4, align 8
21 ; CHECK-LABEL: define {{(noundef )?}}i32 @foo(ptr noalias
22 define i32 @foo(ptr noalias) {
23 ; CHECK-NOT: call i32 @bar(
25 %2 = tail call i32 @bar(ptr %0)
30 ; This test checks if invariant group intrinsics have zero cost for inlining.
31 ; CHECK-LABEL: define ptr @caller(ptr
32 define ptr @caller(ptr %p) {
33 ; CHECK-NOT: call ptr @lot_of_launders_and_strips
34 %a1 = call ptr @lot_of_launders_and_strips(ptr %p)
35 %a2 = call ptr @lot_of_launders_and_strips(ptr %a1)
36 %a3 = call ptr @lot_of_launders_and_strips(ptr %a2)
37 %a4 = call ptr @lot_of_launders_and_strips(ptr %a3)
41 define ptr @lot_of_launders_and_strips(ptr %p) {
42 %a1 = call ptr @llvm.launder.invariant.group.p0(ptr %p)
43 %a2 = call ptr @llvm.launder.invariant.group.p0(ptr %a1)
44 %a3 = call ptr @llvm.launder.invariant.group.p0(ptr %a2)
45 %a4 = call ptr @llvm.launder.invariant.group.p0(ptr %a3)
47 %s1 = call ptr @llvm.strip.invariant.group.p0(ptr %a4)
48 %s2 = call ptr @llvm.strip.invariant.group.p0(ptr %s1)
49 %s3 = call ptr @llvm.strip.invariant.group.p0(ptr %s2)
50 %s4 = call ptr @llvm.strip.invariant.group.p0(ptr %s3)
56 declare ptr @llvm.launder.invariant.group.p0(ptr)
57 declare ptr @llvm.strip.invariant.group.p0(ptr)