[PATCH] D133730: [SimplifyCFG] Don't hoist inalloca allocas
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 12 17:46:32 PDT 2022
aeubanks updated this revision to Diff 459605.
aeubanks added a comment.
all allocas
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133730/new/
https://reviews.llvm.org/D133730
Files:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/hoist-common-skip.ll
Index: llvm/test/Transforms/SimplifyCFG/hoist-common-skip.ll
===================================================================
--- llvm/test/Transforms/SimplifyCFG/hoist-common-skip.ll
+++ llvm/test/Transforms/SimplifyCFG/hoist-common-skip.ll
@@ -388,23 +388,24 @@
}
;; Don't hoist stacksaves across inalloca allocas
-;; FIXME: currently this is miscompiled
define void @f10(i1 %cond) {
; CHECK-LABEL: @f10(
; CHECK-NEXT: [[SS:%.*]] = call ptr @llvm.stacksave()
-; CHECK-NEXT: [[SS2:%.*]] = call ptr @llvm.stacksave()
-; CHECK-NEXT: [[I2:%.*]] = alloca inalloca i64, align 8
; CHECK-NEXT: br i1 [[COND:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: [[I1:%.*]] = alloca inalloca i32, align 4
+; CHECK-NEXT: [[SS2:%.*]] = call ptr @llvm.stacksave()
+; CHECK-NEXT: [[I2:%.*]] = alloca inalloca i64, align 8
; CHECK-NEXT: call void @inalloca_i64(ptr inalloca(i64) [[I2]])
; CHECK-NEXT: call void @llvm.stackrestore(ptr [[SS2]])
; CHECK-NEXT: call void @inalloca_i32(ptr inalloca(i32) [[I1]])
; CHECK-NEXT: br label [[END:%.*]]
; CHECK: bb2:
; CHECK-NEXT: [[I3:%.*]] = alloca inalloca i64, align 8
-; CHECK-NEXT: [[TMP1:%.*]] = call ptr @inalloca_i64(ptr inalloca(i64) [[I2]])
-; CHECK-NEXT: call void @llvm.stackrestore(ptr [[SS2]])
+; CHECK-NEXT: [[SS3:%.*]] = call ptr @llvm.stacksave()
+; CHECK-NEXT: [[I4:%.*]] = alloca inalloca i64, align 8
+; CHECK-NEXT: [[TMP1:%.*]] = call ptr @inalloca_i64(ptr inalloca(i64) [[I4]])
+; CHECK-NEXT: call void @llvm.stackrestore(ptr [[SS3]])
; CHECK-NEXT: [[TMP2:%.*]] = call ptr @inalloca_i64(ptr inalloca(i64) [[I3]])
; CHECK-NEXT: br label [[END]]
; CHECK: end:
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -1442,7 +1442,9 @@
unsigned Flags = 0;
if (I->mayReadFromMemory())
Flags |= SkipReadMem;
- if (I->mayHaveSideEffects())
+ // We can't arbitrarily move around allocas, e.g. moving allocas (especially
+ // inalloca) across stacksave/stackrestore boundaries.
+ if (I->mayHaveSideEffects() || isa<AllocaInst>(I))
Flags |= SkipSideEffect;
if (!isGuaranteedToTransferExecutionToSuccessor(I))
Flags |= SkipImplicitControlFlow;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133730.459605.patch
Type: text/x-patch
Size: 2385 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220913/dbaf4586/attachment.bin>
More information about the llvm-commits
mailing list