diff --git a/llvm/lib/CodeGen/TailDuplicator.cpp b/llvm/lib/CodeGen/TailDuplicator.cpp index 797e417339a0..350412ed32c8 100644 --- a/llvm/lib/CodeGen/TailDuplicator.cpp +++ b/llvm/lib/CodeGen/TailDuplicator.cpp @@ -76,6 +76,13 @@ static cl::opt static cl::opt TailDupLimit("tail-dup-limit", cl::init(~0U), cl::Hidden); +// EraVM local begin +static cl::opt + TailDupFallthroughBBs("tail-dup-fallthrough-bbs", + cl::desc("Tail duplicate fallthrough basic blocks"), + cl::init(false), cl::Hidden); +// EraVM local end + void TailDuplicator::initMF(MachineFunction &MFin, bool PreRegAlloc, const MachineBranchProbabilityInfo *MBPIin, MBFIWrapper *MBFIin, @@ -559,8 +566,10 @@ bool TailDuplicator::shouldTailDuplicate(bool IsSimple, // When doing tail-duplication during layout, the block ordering is in flux, // so canFallThrough returns a result based on incorrect information and // should just be ignored. - if (!LayoutMode && TailBB.canFallThrough()) + // EraVM local begin + if (!TailDupFallthroughBBs && !LayoutMode && TailBB.canFallThrough()) return false; + // EraVM local end // Don't try to tail-duplicate single-block loops. if (TailBB.isSuccessor(&TailBB)) diff --git a/llvm/test/CodeGen/EraVM/tail-dup-fallthrough-bbs.mir b/llvm/test/CodeGen/EraVM/tail-dup-fallthrough-bbs.mir index 68c3d32bfca6..8c35957e34a7 100644 --- a/llvm/test/CodeGen/EraVM/tail-dup-fallthrough-bbs.mir +++ b/llvm/test/CodeGen/EraVM/tail-dup-fallthrough-bbs.mir @@ -1,5 +1,5 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2 -# RUN: llc -x mir -run-pass tailduplication -verify-machineinstrs -compile-twice=false < %s | FileCheck %s +# RUN: llc -x mir -run-pass tailduplication -tail-dup-fallthrough-bbs -verify-machineinstrs -compile-twice=false < %s | FileCheck %s --- | @@ -15,17 +15,12 @@ tracksRegLiveness: true body: | ; CHECK-LABEL: name: test ; CHECK: bb.0: - ; CHECK-NEXT: successors: %bb.1(0x80000000) - ; CHECK-NEXT: liveins: $r1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: J %bb.1 - ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: bb.1: ; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000) ; CHECK-NEXT: liveins: $r1 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: dead $r0 = SUBxrr_v i256 10, $r1, i256 0, implicit-def $flags - ; CHECK-NEXT: JCl %bb.3, i256 3, implicit killed $flags + ; CHECK-NEXT: JCl %bb.3, 3, implicit $flags + ; CHECK-NEXT: J %bb.2 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.2: ; CHECK-NEXT: liveins: $r1