[llvm] 269b335 - [Inliner] Propagate SROA analysis through invariant group intrinsics
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 12 10:55:27 PDT 2021
Author: Arthur Eubanks
Date: 2021-04-12T10:54:22-07:00
New Revision: 269b335bd7332cd0d13451260d408dc9fcbcb5b1
URL: https://github.com/llvm/llvm-project/commit/269b335bd7332cd0d13451260d408dc9fcbcb5b1
DIFF: https://github.com/llvm/llvm-project/commit/269b335bd7332cd0d13451260d408dc9fcbcb5b1.diff
LOG: [Inliner] Propagate SROA analysis through invariant group intrinsics
SROA can handle invariant group intrinsics, let the inliner know that
for better heuristics when the intrinsics are present.
This fixes size issues in a couple files when turning on
-fstrict-vtable-pointers in Chrome.
Reviewed By: rnk, mtrofin
Differential Revision: https://reviews.llvm.org/D100249
Added:
llvm/test/Transforms/Inline/invariant-group-sroa.ll
Modified:
llvm/lib/Analysis/InlineCost.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp
index 06cc778ade74e..b367efa04417f 100644
--- a/llvm/lib/Analysis/InlineCost.cpp
+++ b/llvm/lib/Analysis/InlineCost.cpp
@@ -1884,6 +1884,11 @@ bool CallAnalyzer::visitCallBase(CallBase &Call) {
case Intrinsic::vastart:
InitsVargArgs = true;
return false;
+ case Intrinsic::launder_invariant_group:
+ case Intrinsic::strip_invariant_group:
+ if (auto *SROAArg = getSROAArgForValueOrNull(II->getOperand(0)))
+ SROAArgValues[II] = SROAArg;
+ return true;
}
}
diff --git a/llvm/test/Transforms/Inline/invariant-group-sroa.ll b/llvm/test/Transforms/Inline/invariant-group-sroa.ll
new file mode 100644
index 0000000000000..086e8b6c04bf9
--- /dev/null
+++ b/llvm/test/Transforms/Inline/invariant-group-sroa.ll
@@ -0,0 +1,26 @@
+; RUN: opt -passes='print<inline-cost>' -disable-output %s 2>&1 | FileCheck %s
+
+; SROA analysis should yield non-zero savings for allocas passed through invariant group intrinsics
+; CHECK: SROACostSavings: 10
+
+declare i8* @llvm.launder.invariant.group.p0i8(i8*)
+declare i8* @llvm.strip.invariant.group.p0i8(i8*)
+
+declare void @b()
+
+define i32 @f() {
+ %a = alloca i32
+ %r = call i32 @g(i32* %a)
+ ret i32 %r
+}
+
+define i32 @g(i32* %a) {
+ %a_i8 = bitcast i32* %a to i8*
+ %a_inv_i8 = call i8* @llvm.launder.invariant.group.p0i8(i8* %a_i8)
+ %a_inv = bitcast i8* %a_inv_i8 to i32*
+ %i1 = load i32, i32* %a_inv
+ %i2 = load i32, i32* %a_inv
+ %i3 = add i32 %i1, %i2
+ %t = call i8* @llvm.strip.invariant.group.p0i8(i8* %a_inv_i8)
+ ret i32 %i3
+}
More information about the llvm-commits
mailing list