[PATCH] D143219: [llvm][TailDuplicator] permit taildup'ing pred MBB containing INLINEASM_BR
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 2 14:57:12 PST 2023
nickdesaulniers created this revision.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
If we have:
bb0:
INLINEASM_BR ...
b bb2
bb1:
...
bb2:
ret
it would be nice to taildup that ret into bb0.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D143219
Files:
llvm/lib/CodeGen/TailDuplicator.cpp
llvm/test/CodeGen/X86/callbr-asm-sink.ll
llvm/test/CodeGen/X86/callbr-asm.ll
llvm/test/CodeGen/X86/inline-asm-pic.ll
Index: llvm/test/CodeGen/X86/inline-asm-pic.ll
===================================================================
--- llvm/test/CodeGen/X86/inline-asm-pic.ll
+++ llvm/test/CodeGen/X86/inline-asm-pic.ll
@@ -29,7 +29,6 @@
; CHECK-NEXT: ## LBB1_1
; CHECK-EMPTY:
; CHECK-NEXT: ## InlineAsm End
-; CHECK-NEXT: ## %bb.2: ## %return
; CHECK-NEXT: retl
; CHECK-NEXT: Ltmp0: ## Block address taken
; CHECK-NEXT: LBB1_1: ## %overflow
Index: llvm/test/CodeGen/X86/callbr-asm.ll
===================================================================
--- llvm/test/CodeGen/X86/callbr-asm.ll
+++ llvm/test/CodeGen/X86/callbr-asm.ll
@@ -171,13 +171,14 @@
; CHECK-LABEL: test4:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: #APP
-; CHECK-NEXT: ja .LBB4_3
+; CHECK-NEXT: ja .LBB4_2
; CHECK-NEXT: #NO_APP
; CHECK-NEXT: # %bb.1: # %asm.fallthrough
; CHECK-NEXT: #APP
-; CHECK-NEXT: ja .LBB4_3
+; CHECK-NEXT: ja .LBB4_2
; CHECK-NEXT: #NO_APP
-; CHECK-NEXT: .LBB4_3: # Block address taken
+; CHECK-NEXT: retl
+; CHECK-NEXT: .LBB4_2: # Block address taken
; CHECK-NEXT: # %quux
; CHECK-NEXT: # Label of block must be emitted
; CHECK-NEXT: retl
Index: llvm/test/CodeGen/X86/callbr-asm-sink.ll
===================================================================
--- llvm/test/CodeGen/X86/callbr-asm-sink.ll
+++ llvm/test/CodeGen/X86/callbr-asm-sink.ll
@@ -14,7 +14,6 @@
; CHECK-NEXT: #APP
; CHECK-NEXT: # 8(%rdi) .LBB0_1
; CHECK-NEXT: #NO_APP
-; CHECK-NEXT: # %bb.2:
; CHECK-NEXT: retq
; CHECK-NEXT: .LBB0_1: # Block address taken
; CHECK-NEXT: # Label of block must be emitted
Index: llvm/lib/CodeGen/TailDuplicator.cpp
===================================================================
--- llvm/lib/CodeGen/TailDuplicator.cpp
+++ llvm/lib/CodeGen/TailDuplicator.cpp
@@ -791,7 +791,7 @@
bool TailDuplicator::canTailDuplicate(MachineBasicBlock *TailBB,
MachineBasicBlock *PredBB) {
// EH edges are ignored by analyzeBranch.
- if (PredBB->succ_size() > 1)
+ if (PredBB->succ_size() > 1 && !PredBB->mayHaveInlineAsmBr())
return false;
MachineBasicBlock *PredTBB = nullptr, *PredFBB = nullptr;
@@ -896,7 +896,7 @@
// Update the CFG.
PredBB->removeSuccessor(PredBB->succ_begin());
- assert(PredBB->succ_empty() &&
+ assert((PredBB->succ_empty() || PredBB->mayHaveInlineAsmBr()) &&
"TailDuplicate called on block with multiple successors!");
for (MachineBasicBlock *Succ : TailBB->successors())
PredBB->addSuccessor(Succ, MBPI->getEdgeProbability(TailBB, Succ));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D143219.494441.patch
Type: text/x-patch
Size: 2621 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230202/a192e7a4/attachment.bin>
More information about the llvm-commits
mailing list