Skip to content

Commit

Permalink
[AArch64][GlobalISel] Handle rtcGPR64RegClassID in AArch64RegisterBan…
Browse files Browse the repository at this point in the history
…kInfo::getRegBankFromRegClass() (#77)

TargetRegisterInfo::getMinimalPhysRegClass() returns rtcGPR64RegClassID for X16
and X17, as it's the last matching class. This in turn gets passed to
AArch64RegisterBankInfo::getRegBankFromRegClass(), which hits an unreachable.

It seems sensible to handle this case, so copies from X16 and X17 work.
Copying from X17 is used in inline assembly in libunwind for pointer
authentication.

Differential Revision: https://reviews.llvm.org/D85720

Co-authored-by: Raul Tambre <[email protected]>
  • Loading branch information
2 people authored and cuviper committed Oct 14, 2020
1 parent ae83d21 commit 70fd068
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions llvm/lib/Target/AArch64/GISel/AArch64RegisterBankInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ AArch64RegisterBankInfo::getRegBankFromRegClass(const TargetRegisterClass &RC,
case AArch64::GPR64common_and_GPR64noipRegClassID:
case AArch64::GPR64noip_and_tcGPR64RegClassID:
case AArch64::tcGPR64RegClassID:
case AArch64::rtcGPR64RegClassID:
case AArch64::WSeqPairsClassRegClassID:
case AArch64::XSeqPairsClassRegClassID:
return getRegBank(AArch64::GPRRegBankID);
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/CodeGen/AArch64/GlobalISel/regbankselect-default.mir
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@

define void @test_gphi_ptr() { ret void }

define void @test_restricted_tail_call() { ret void }

...

---
Expand Down Expand Up @@ -888,3 +890,20 @@ body: |
RET_ReallyLR implicit $x0
...

---
name: test_restricted_tail_call
legalized: true
tracksRegLiveness: true
body: |
bb.0:
liveins: $x16, $x17
; CHECK-LABEL: name: test_restricted_tail_call
; CHECK: liveins: $x16, $x17
; CHECK: [[COPY:%[0-9]+]]:gpr(s64) = COPY $x16
; CHECK: [[COPY1:%[0-9]+]]:gpr(s64) = COPY $x17
; CHECK: RET_ReallyLR
%0:_(s64) = COPY $x16
%1:_(s64) = COPY $x17
RET_ReallyLR
...

0 comments on commit 70fd068

Please sign in to comment.