[PATCH] D82761: SpeculativeExecution: Fix for logic change introduced in D81730.
Daniil Fukalov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 05:54:20 PDT 2020
dfukalov created this revision.
dfukalov added reviewers: aprantl, arsenm, nhaehnle.
Herald added subscribers: hiraditya, wdng.
Herald added a project: LLVM.
The test case started to hoist bitcasts to upper BB after D81730 <https://reviews.llvm.org/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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D82761
Files:
llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
llvm/test/Transforms/SpeculativeExecution/PR46267.ll
Index: llvm/test/Transforms/SpeculativeExecution/PR46267.ll
===================================================================
--- llvm/test/Transforms/SpeculativeExecution/PR46267.ll
+++ llvm/test/Transforms/SpeculativeExecution/PR46267.ll
@@ -1,6 +1,35 @@
; RUN: opt < %s -S -speculative-execution | FileCheck %s
; RUN: opt < %s -S -passes='speculative-execution' | FileCheck %s
+%class.B = type { i32 (...)** }
+
+define i8* @_Z9void_castP1B(%class.B* readonly %b) {
+; CHECK-LABEL: _Z9void_castP1B
+; CHECK-LABEL: entry
+; CHECK-NEXT: %i = icmp eq %class.B* %b, null
+; CHECK-NEXT: br i1 %i, label %dynamic_cast.end, label %dynamic_cast.notnull
+entry:
+ %i = icmp eq %class.B* %b, null
+ br i1 %i, label %dynamic_cast.end, label %dynamic_cast.notnull
+
+; CHECK-LABEL: dynamic_cast.notnull:
+; CHECK-NEXT: %i1 = bitcast %class.B* %b to i32**
+; CHECK: %i3 = bitcast %class.B* %b to i8*
+dynamic_cast.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 %dynamic_cast.end
+
+dynamic_cast.end: ; preds = %dynamic_cast.notnull, %entry
+ %i6 = phi i8* [ %i5, %dynamic_cast.notnull ], [ null, %entry ]
+ ret i8* %i6
+}
+
define void @f(i32 %i) {
entry:
; CHECK-LABEL: @f(
Index: llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -291,10 +291,8 @@
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D82761.274076.patch
Type: text/x-patch
Size: 2371 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200629/aacd962d/attachment-0001.bin>
More information about the llvm-commits
mailing list