Skip to content

Commit 2d894bd

Browse files
committed
[ARM64] [Windows] Mark block address as taken when expanding catchrets
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.
1 parent 4c50112 commit 2d894bd

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

llvm/lib/Target/AArch64/AArch64InstrInfo.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1994,6 +1994,7 @@ bool AArch64InstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
19941994
.addReg(AArch64::X0)
19951995
.addMBB(TargetMBB)
19961996
.addImm(0);
1997+
TargetMBB->setMachineBlockAddressTaken();
19971998
return true;
19981999
}
19992000

llvm/test/CodeGen/AArch64/pr58516.ll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ define void @osfx(ptr %this) comdat personality ptr @__CxxFrameHandler3 {
4040
; CHECK-NEXT: // %bb.1: // %invoke.cont12
4141
; CHECK-NEXT: str wzr, [x20]
4242
; CHECK-NEXT: str wzr, [x21]
43-
; CHECK-NEXT: .LBB0_2: // %try.cont
43+
; CHECK-NEXT: .LBB0_2: // Block address taken
44+
; CHECK-NEXT: // %try.cont
4445
; CHECK-NEXT: $ehgcr_0_2:
4546
; CHECK-NEXT: .seh_startepilogue
4647
; CHECK-NEXT: sub sp, x29, #24

llvm/test/CodeGen/AArch64/wineh-try-catch.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
; CHECK-LABEL: .Ltmp0:
4242
; CHECK: bl "?func2@@YAHXZ
4343

44-
; CHECK: [[CATCHRETDEST:.LBB0_[0-9]+]]: // %catchret.dest
44+
; CHECK: [[CATCHRETDEST:.LBB0_[0-9]+]]: // Block address taken
4545

4646
; Check the catch funclet.
4747
; CHECK-LABEL: "?catch$4@?0??func@@YAHXZ@4HA":

0 commit comments

Comments
 (0)