[llvm] 167767a - SpeculativeExecution: Fix for logic change introduced in D81730.
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 9 05:45:41 PDT 2020
Author: dfukalov
Date: 2020-07-09T15:45:23+03:00
New Revision: 167767a775f3db5cd94053d4da6a4f419b6211cd
URL: https://github.com/llvm/llvm-project/commit/167767a775f3db5cd94053d4da6a4f419b6211cd
DIFF: https://github.com/llvm/llvm-project/commit/167767a775f3db5cd94053d4da6a4f419b6211cd.diff
LOG: SpeculativeExecution: Fix for logic change introduced in D81730.
Summary:
The test case started to hoist bitcasts to upper BB after D81730.
Reverted unintentional logic change. Some instructions may have zero cost but
will not be hoisted by different limitation so should be counted for threshold.
Reviewers: aprantl, arsenm, nhaehnle
Reviewed By: aprantl
Subscribers: wdng, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D82761
Added:
Modified:
llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
llvm/test/Transforms/SpeculativeExecution/PR46267.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
index ea848f4e7a2a..f82a2936c762 100644
--- a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -291,10 +291,8 @@ bool SpeculativeExecutionPass::considerHoistingFromTo(
if (TotalSpeculationCost > SpecExecMaxSpeculationCost)
return false; // too much to hoist
} else {
- // If the instruction cannot be hoisted but has zero cost suppose it's
- // a special case e.g. debug info instrinsics that should not be counted
- // for threshold.
- if (Cost)
+ // Debug info instrinsics should not be counted for threshold.
+ if (!isa<DbgInfoIntrinsic>(I))
NotHoistedInstCount++;
if (NotHoistedInstCount > SpecExecMaxNotHoisted)
return false; // too much left behind
diff --git a/llvm/test/Transforms/SpeculativeExecution/PR46267.ll b/llvm/test/Transforms/SpeculativeExecution/PR46267.ll
index 5a2c7049f991..5c61b225a7f5 100644
--- a/llvm/test/Transforms/SpeculativeExecution/PR46267.ll
+++ b/llvm/test/Transforms/SpeculativeExecution/PR46267.ll
@@ -1,6 +1,36 @@
; RUN: opt < %s -S -speculative-execution | FileCheck %s
; RUN: opt < %s -S -passes='speculative-execution' | FileCheck %s
+%class.B = type { i32 (...)** }
+
+; Testing that two bitcasts are not hoisted to the first BB
+define i8* @foo(%class.B* readonly %b) {
+; CHECK-LABEL: foo
+; CHECK-LABEL: entry
+; CHECK-NEXT: %i = icmp eq %class.B* %b, null
+; CHECK-NEXT: br i1 %i, label %end, label %notnull
+entry:
+ %i = icmp eq %class.B* %b, null
+ br i1 %i, label %end, label %notnull
+
+; CHECK-LABEL: notnull:
+; CHECK-NEXT: %i1 = bitcast %class.B* %b to i32**
+; CHECK: %i3 = bitcast %class.B* %b to i8*
+notnull: ; preds = %entry
+ %i1 = bitcast %class.B* %b to i32**
+ %vtable = load i32*, i32** %i1, align 8
+ %i2 = getelementptr inbounds i32, i32* %vtable, i64 -2
+ %offset.to.top = load i32, i32* %i2, align 4
+ %i3 = bitcast %class.B* %b to i8*
+ %i4 = sext i32 %offset.to.top to i64
+ %i5 = getelementptr inbounds i8, i8* %i3, i64 %i4
+ br label %end
+
+end: ; preds = %notnull, %entry
+ %i6 = phi i8* [ %i5, %notnull ], [ null, %entry ]
+ ret i8* %i6
+}
+
define void @f(i32 %i) {
entry:
; CHECK-LABEL: @f(
More information about the llvm-commits
mailing list