[llvm] [CodeGen] Fix lpad padding at section start after empty block (PR #112595)
Daniel Hoekwater via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 22 08:13:06 PDT 2024
================
@@ -265,8 +265,22 @@ void llvm::sortBasicBlocksAndUpdateBranches(
// zero implies "no landing pad." This function inserts a NOP just before the EH
// pad label to ensure a nonzero offset.
void llvm::avoidZeroOffsetLandingPad(MachineFunction &MF) {
+ std::optional<MBBSectionID> CurrentSection;
+ bool SectionEmpty = true;
+ auto IsFirstNonEmptyBBInSection = [&](const MachineBasicBlock &MBB) {
----------------
dhoekwater wrote:
This function may give false positives in the following situation:
```
bb0 (bbsections 0)
bb1 (bbsections cold)
bb2 (bbsections 0)
```
If false positives are fine (since we're just inserting a `nop`), then you can disregard this feedback. Otherwise, you may want to do something like
```
llvm::DenseSet<MBBSectionID> SectionsWithNonEmptyBlocks;
auto IsFirstNonEmptyBBInSection = [&](const MachineBasicBlock &MBB) {
if (MBB.empty() || SectionsWithNonEmptyBlocks.contains(MBB.getSectionID()))
return false;
SectionsWithNonEmptyBlocks.insert(MBB.getSectionID());
```
https://github.com/llvm/llvm-project/pull/112595
More information about the llvm-commits
mailing list