58 lines · plain
1; RUN: opt -S -passes=inline < %s | FileCheck %s2; RUN: opt -S -O3 < %s | FileCheck %s3; RUN: opt -S -passes=inline -inline-threshold=1 < %s | FileCheck %s4 5%struct.A = type <{ ptr, i32, [4 x i8] }>6 7; This test checks if value returned from the launder is considered aliasing8; with its argument. Due to bug caused by handling launder in capture tracking9; sometimes it would be considered noalias.10; CHECK-LABEL: define {{(noundef )?}}i32 @bar(ptr noalias11define i32 @bar(ptr noalias) {12; CHECK-NOT: noalias13 %2 = call ptr @llvm.launder.invariant.group.p0(ptr %0)14 %3 = getelementptr inbounds i8, ptr %2, i64 815 store i32 42, ptr %3, align 816 %4 = getelementptr inbounds %struct.A, ptr %0, i64 0, i32 117 %5 = load i32, ptr %4, align 818 ret i32 %519}20 21; CHECK-LABEL: define {{(noundef )?}}i32 @foo(ptr noalias22define i32 @foo(ptr noalias) {23 ; CHECK-NOT: call i32 @bar(24 ; CHECK-NOT: !noalias25 %2 = tail call i32 @bar(ptr %0)26 ret i32 %227}28 29 30; This test checks if invariant group intrinsics have zero cost for inlining.31; CHECK-LABEL: define ptr @caller(ptr32define ptr @caller(ptr %p) {33; CHECK-NOT: call ptr @lot_of_launders_and_strips34 %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)38 ret ptr %a439}40 41define 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)46 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)51 52 ret ptr %s453}54 55 56declare ptr @llvm.launder.invariant.group.p0(ptr)57declare ptr @llvm.strip.invariant.group.p0(ptr)58