IrrLoopHeaderWeight = Weight;
}
+ /// Return probability of the edge from this block to MBB. This method should
+ /// NOT be called directly, but by using getEdgeProbability method from
+ /// MachineBranchProbabilityInfo class.
+ BranchProbability getSuccProbability(const_succ_iterator Succ) const;
+
private:
/// Return probability iterator corresponding to the I successor iterator.
probability_iterator getProbabilityIterator(succ_iterator I);
friend class MachineBranchProbabilityInfo;
friend class MIPrinter;
- /// Return probability of the edge from this block to MBB. This method should
- /// NOT be called directly, but by using getEdgeProbability method from
- /// MachineBranchProbabilityInfo class.
- BranchProbability getSuccProbability(const_succ_iterator Succ) const;
-
// Methods used to maintain doubly linked list of blocks...
friend struct ilist_callback_traits<MachineBasicBlock>;
--- /dev/null
+# REQUIRES: amdgpu-registered-target
+# RUN: llvm-reduce -simplify-mir -mtriple=amdgcn-amd-amdhsa --test FileCheck --test-arg --check-prefix=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
+# RUN: FileCheck --match-full-lines --check-prefix=RESULT %s < %t
+
+# CHECK-INTERESTINGNESS: V_MOV_B32
+
+
+# RESULT: bb.0.entry:
+# RESULT: %{{[0-9]+}}:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+
+# RESULT: bb.1 (address-taken, align 8):
+# RESULT: bb.2 (landing-pad, align 16):
+# RESULT: bb.3 (inlineasm-br-indirect-target):
+# RESULT: bb.4 (ehfunclet-entry):
+# RESULT: bb.5 (bbsections 1):
+# RESULT: bb.6 (bbsections 2):
+# RESULT: bb.7 (bbsections 3):
+# RESULT: bb.8:
+# RESULT-NEXT: successors: %bb.9(0x66666666), %bb.10(0x1999999a)
+# RESULT: bb.9:
+# RESULT: bb.10.exitblock:
+
+--- |
+ define void @func(i32 %size) {
+ entry:
+ br label %exitblock
+
+ exitblock:
+ ret void
+ }
+
+...
+
+---
+name: func
+alignment: 32
+exposesReturnsTwice: true
+legalized: true
+regBankSelected: true
+selected: true
+failedISel: true
+tracksRegLiveness: true
+hasWinCFI: true
+failsVerification: true
+tracksDebugUserValues: true
+body: |
+ bb.0.entry:
+ S_NOP 0
+ %0:vgpr_32 = V_MOV_B32_e32 0, implicit $exec
+
+ bb.1 (address-taken, align 8):
+
+ bb.2 (landing-pad, align 16):
+
+ bb.3 (inlineasm-br-indirect-target):
+
+ bb.4 (ehfunclet-entry):
+
+ bb.5 (bbsections 1):
+ bb.6 (bbsections 2):
+ bb.7 (bbsections 3):
+
+ bb.8:
+ successors: %bb.9(4), %bb.10(1)
+ S_CBRANCH_SCC1 %bb.10, implicit undef $scc
+ S_BRANCH %bb.9
+
+ bb.9:
+
+ bb.10.exitblock:
+ S_ENDPGM 0, implicit %0
+...
auto *DstMRI = &DstMF->getRegInfo();
// Clone blocks.
- for (MachineBasicBlock &SrcMBB : *SrcMF)
- Src2DstMBB[&SrcMBB] = DstMF->CreateMachineBasicBlock();
+ for (MachineBasicBlock &SrcMBB : *SrcMF) {
+ MachineBasicBlock *DstMBB =
+ DstMF->CreateMachineBasicBlock(SrcMBB.getBasicBlock());
+ Src2DstMBB[&SrcMBB] = DstMBB;
+
+ if (SrcMBB.hasAddressTaken())
+ DstMBB->setHasAddressTaken();
+
+ // FIXME: This is not serialized
+ if (SrcMBB.hasLabelMustBeEmitted())
+ DstMBB->setLabelMustBeEmitted();
+
+ DstMBB->setAlignment(SrcMBB.getAlignment());
+
+ // FIXME: This is not serialized
+ DstMBB->setMaxBytesForAlignment(SrcMBB.getMaxBytesForAlignment());
+
+ DstMBB->setIsEHPad(SrcMBB.isEHPad());
+ DstMBB->setIsEHScopeEntry(SrcMBB.isEHScopeEntry());
+ DstMBB->setIsEHCatchretTarget(SrcMBB.isEHCatchretTarget());
+ DstMBB->setIsEHFuncletEntry(SrcMBB.isEHFuncletEntry());
+
+ // FIXME: These are not serialized
+ DstMBB->setIsCleanupFuncletEntry(SrcMBB.isCleanupFuncletEntry());
+ DstMBB->setIsBeginSection(SrcMBB.isBeginSection());
+ DstMBB->setIsEndSection(SrcMBB.isEndSection());
+
+ DstMBB->setSectionID(SrcMBB.getSectionID());
+ DstMBB->setIsInlineAsmBrIndirectTarget(
+ SrcMBB.isInlineAsmBrIndirectTarget());
+
+ // FIXME: This is not serialized
+ if (Optional<uint64_t> Weight = SrcMBB.getIrrLoopHeaderWeight())
+ DstMBB->setIrrLoopHeaderWeight(*Weight);
+ }
const MachineFrameInfo &SrcMFI = SrcMF->getFrameInfo();
MachineFrameInfo &DstMFI = DstMF->getFrameInfo();
}
}
+ const TargetSubtargetInfo &STI = DstMF->getSubtarget();
+ const TargetInstrInfo *TII = STI.getInstrInfo();
+ const TargetRegisterInfo *TRI = STI.getRegisterInfo();
+
// Link blocks.
for (auto &SrcMBB : *SrcMF) {
auto *DstMBB = Src2DstMBB[&SrcMBB];
DstMF->push_back(DstMBB);
+
for (auto It = SrcMBB.succ_begin(), IterEnd = SrcMBB.succ_end();
It != IterEnd; ++It) {
auto *SrcSuccMBB = *It;
auto *DstSuccMBB = Src2DstMBB[SrcSuccMBB];
- DstMBB->addSuccessor(DstSuccMBB);
+ DstMBB->addSuccessor(DstSuccMBB, SrcMBB.getSuccProbability(It));
}
for (auto &LI : SrcMBB.liveins())
DstMBB->addLiveIn(LI);
+
+ // Make sure MRI knows about registers clobbered by unwinder.
+ if (DstMBB->isEHPad()) {
+ if (auto *RegMask = TRI->getCustomEHPadPreservedMask(*DstMF))
+ DstMRI->addPhysRegsUsedFromRegMask(RegMask);
+ }
}
+
// Clone instructions.
for (auto &SrcMBB : *SrcMF) {
auto *DstMBB = Src2DstMBB[&SrcMBB];
for (auto &SrcMI : SrcMBB) {
- const auto &MCID =
- DstMF->getSubtarget().getInstrInfo()->get(SrcMI.getOpcode());
+ const auto &MCID = TII->get(SrcMI.getOpcode());
auto *DstMI = DstMF->CreateMachineInstr(MCID, SrcMI.getDebugLoc(),
/*NoImplicit=*/true);
DstMBB->push_back(DstMI);