Index: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h =================================================================== --- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h +++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h @@ -158,6 +158,8 @@ case Intrinsic::dbg_label: case Intrinsic::invariant_start: case Intrinsic::invariant_end: + case Intrinsic::launder_invariant_group: + case Intrinsic::strip_invariant_group: case Intrinsic::lifetime_start: case Intrinsic::lifetime_end: case Intrinsic::objectsize: Index: llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll =================================================================== --- llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll +++ llvm/trunk/test/Transforms/Inline/launder.invariant.group.ll @@ -1,13 +1,13 @@ ; RUN: opt -S -inline < %s | FileCheck %s ; RUN: opt -S -O3 < %s | FileCheck %s +; RUN: opt -S -inline -inline-threshold=1 < %s | FileCheck %s + +%struct.A = type <{ i32 (...)**, i32, [4 x i8] }> ; This test checks if value returned from the launder is considered aliasing ; with its argument. Due to bug caused by handling launder in capture tracking ; sometimes it would be considered noalias. - -%struct.A = type <{ i32 (...)**, i32, [4 x i8] }> - -; CHECK: define i32 @bar(%struct.A* noalias +; CHECK-LABEL: define i32 @bar(%struct.A* noalias define i32 @bar(%struct.A* noalias) { ; CHECK-NOT: noalias %2 = bitcast %struct.A* %0 to i8* @@ -28,4 +28,32 @@ ret i32 %2 } + +; This test checks if invariant group intrinsics have zero cost for inlining. +; CHECK-LABEL: define i8* @caller(i8* +define i8* @caller(i8* %p) { +; CHECK-NOT: call i8* @lot_of_launders_and_strips + %a1 = call i8* @lot_of_launders_and_strips(i8* %p) + %a2 = call i8* @lot_of_launders_and_strips(i8* %a1) + %a3 = call i8* @lot_of_launders_and_strips(i8* %a2) + %a4 = call i8* @lot_of_launders_and_strips(i8* %a3) + ret i8* %a4 +} + +define i8* @lot_of_launders_and_strips(i8* %p) { + %a1 = call i8* @llvm.launder.invariant.group.p0i8(i8* %p) + %a2 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a1) + %a3 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a2) + %a4 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a3) + + %s1 = call i8* @llvm.strip.invariant.group.p0i8(i8* %a4) + %s2 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s1) + %s3 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s2) + %s4 = call i8* @llvm.strip.invariant.group.p0i8(i8* %s3) + + ret i8* %s4 +} + + declare i8* @llvm.launder.invariant.group.p0i8(i8*) +declare i8* @llvm.strip.invariant.group.p0i8(i8*)