aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/MachineFunction.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/MachineFunction.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 78b49c9..9defe36 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -437,8 +437,16 @@ void MachineFunction::deleteMachineInstr(MachineInstr *MI) {
/// `new MachineBasicBlock'.
MachineBasicBlock *
MachineFunction::CreateMachineBasicBlock(const BasicBlock *bb) {
- return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
- MachineBasicBlock(*this, bb);
+ MachineBasicBlock *MBB =
+ new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
+ MachineBasicBlock(*this, bb);
+ // Set BBID for `-basic-block=sections=labels` and
+ // `-basic-block-sections=list` to allow robust mapping of profiles to basic
+ // blocks.
+ if (Target.getBBSectionsType() == BasicBlockSection::Labels ||
+ Target.getBBSectionsType() == BasicBlockSection::List)
+ MBB->setBBID(NextBBID++);
+ return MBB;
}
/// Delete the given MachineBasicBlock.