[llvm] [ARM64] [Windows] Mark block address as taken when expanding catchrets (PR #109252)

via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 01:07:47 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-backend-aarch64

Author: Maurice Heumann (momo5502)

<details>
<summary>Changes</summary>

This fixes issue #<!-- -->109250

The issue happens during the `MachineBlockPlacement` pass. The block, whose address was previously not taken, is deemed redundant by the pass and subsequently replaced using
`MachineBasicBlock::ReplaceUsesOfBlockWith` in `BranchFolding`.

ReplaceUsesOfBlockWith only replaces uses in the terminator. However, `expandPostRAPseudo` introduces new block uses when expanding catchrets. These uses do not get replaced, which results in undefined label errors later on.

Marking the block addresss as taken prevents the replacement of the block, without also replacing non-terminator uses.

---
Full diff: https://github.com/llvm/llvm-project/pull/109252.diff


1 Files Affected:

- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.cpp (+1) 


``````````diff
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 3b38a5f78dee51..32bc0e7d0d6475 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -1994,6 +1994,7 @@ bool AArch64InstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
         .addReg(AArch64::X0)
         .addMBB(TargetMBB)
         .addImm(0);
+    TargetMBB->setMachineBlockAddressTaken();
     return true;
   }
 

``````````

</details>


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


More information about the llvm-commits mailing list