[llvm] [BasicBlockSections] Apply path cloning with -basic-block-sections. (PR #68860)

Sriraman Tallam via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 19 14:44:00 PDT 2023


================
@@ -99,6 +101,33 @@ static cl::opt<bool> BBSectionsDetectSourceDrift(
 
 namespace {
 
+MachineBasicBlock *CloneMachineBasicBlock(MachineBasicBlock *MBB) {
+  auto &MF = *MBB->getParent();
+  auto TII = MF.getSubtarget().getInstrInfo();
+
+  auto CloneBB = MF.CreateMachineBasicBlock(MBB->getBasicBlock());
+  MF.push_back(CloneBB);
+  // Copy the instructions.
+  for (auto &I : MBB->instrs())
+    CloneBB->push_back(MF.CloneMachineInstr(&I));
+
+  // Add the successors of the original block as the new block's successors.
----------------
tmsri wrote:

Sure, sound good.

https://github.com/llvm/llvm-project/pull/68860


More information about the llvm-commits mailing list