[llvm] [BOLT][NFC] Add sink block to flow CFG in profile inference (PR #95047)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 11 09:25:49 PDT 2024


================
@@ -309,23 +309,28 @@ createFlowFunction(const BinaryFunction::BasicBlockOrderType &BlockOrder) {
   FlowFunction Func;
 
   // Add a special "dummy" source so that there is always a unique entry point.
-  // Because of the extra source, for all other blocks in FlowFunction it holds
-  // that Block.Index == BB->getIndex() + 1
   FlowBlock EntryBlock;
   EntryBlock.Index = 0;
   Func.Blocks.push_back(EntryBlock);
 
-  // Create FlowBlock for every basic block in the binary function
+  // Create FlowBlock for every basic block in the binary function.
   for (const BinaryBasicBlock *BB : BlockOrder) {
     Func.Blocks.emplace_back();
     FlowBlock &Block = Func.Blocks.back();
     Block.Index = Func.Blocks.size() - 1;
+    Block.IsExit = BB->successors().empty();
----------------
aaupov wrote:

I thought a bit more about this change and realized it's not NFC for the following reason: we used to determine whether a block is an exit depending on both CFG successors AND landing pads (see line 351 below)
`351     for (const BinaryBasicBlock *DstBB : SrcBB->landing_pads()) {`

In the new IsExit determination, we will only use CFG edges and omit LPs. This omission should help the case we want to target (degenerate graphs with no blocks without CFG/LP successors), but we'll need to add a test for it.

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


More information about the llvm-commits mailing list