Skip to content

[AArch64] Preserve undef on registers when expanding CALL_RVMARKER. #71177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,8 @@ bool AArch64ExpandPseudo::expandCALL_RVMARKER(
auto MOP = MI.getOperand(RegMaskStartIdx);
assert(MOP.isReg() && "can only add register operands");
OriginalCall->addOperand(MachineOperand::CreateReg(
MOP.getReg(), /*Def=*/false, /*Implicit=*/true));
MOP.getReg(), /*Def=*/false, /*Implicit=*/true, /*isKill=*/false,
/*isDead=*/false, /*isUndef=*/MOP.isUndef()));
RegMaskStartIdx++;
}
for (const MachineOperand &MO :
Expand Down
31 changes: 30 additions & 1 deletion llvm/test/CodeGen/AArch64/expand-blr-rvmarker-pseudo.mir
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# RUN: llc -run-pass=aarch64-expand-pseudo -mtriple=arm64-apple-ios -o - -emit-call-site-info %s | FileCheck %s
# RUN: llc -run-pass=aarch64-expand-pseudo -mtriple=arm64-apple-ios -o - -emit-call-site-info %s -verify-machineinstrs | FileCheck %s

--- |
define void @test_1_callsite_info() {
Expand All @@ -25,7 +25,13 @@
ret void
}

define void @test_blr_undef_arg_in_x0() {
ret void
}

declare i8* @attachedcall()

declare ptr @objc_retainAutoreleasedReturnValue()
...
---

Expand Down Expand Up @@ -132,3 +138,26 @@ body: |
BLR_RVMARKER @attachedcall, $x8, $w0, $w1, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $x0
RET_ReallyLR implicit killed $w0
...

# Test for https://github.com/llvm/llvm-project/issues/68005.
#
# CHECK-LABEL: : test_blr_undef_arg_in_x0
# CHECK: bb.0:
# CHECK-NEXT: liveins:
# CHECK-NEXT: {{ $}}
# CHECK-NEXT: BUNDLE implicit-def $lr, implicit-def $w30, implicit-def $sp, implicit-def $wsp, implicit-def dead $x0, implicit-def $fp, implicit-def $w29, implicit $sp, implicit undef $x0, implicit $xzr, implicit $fp {
# CHECK-NEXT: BL @foo, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit undef $x0, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $x0
# CHECK-NEXT: $fp = ORRXrs $xzr, $fp, 0
# CHECK-NEXT: BL @objc_retainAutoreleasedReturnValue, implicit-def $lr, implicit internal $sp
# CHECK-NEXT: }
# CHECK-NEXT: RET undef $lr
#
name: test_blr_undef_arg_in_x0
tracksRegLiveness: true
body: |
bb.0:
liveins: $lr

BLR_RVMARKER @objc_retainAutoreleasedReturnValue, @foo, undef $x0, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp, implicit-def dead $x0
RET_ReallyLR
...