Skip to content

Commit eb14eec

Browse files
committed
Add test cases to ptrauth-isel.mir & minor comment improvements
1 parent 7297214 commit eb14eec

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class AArch64TargetLowering : public TargetLowering {
183183
MachineBasicBlock *BB) const;
184184

185185
/// Replace (0, vreg) discriminator components with the operands of blend
186-
/// or with (immediate, XZR) when possible.
186+
/// or with (immediate, NoRegister) when possible.
187187
void fixupPtrauthDiscriminator(MachineInstr &MI, MachineBasicBlock *BB,
188188
MachineOperand &IntDiscOp,
189189
MachineOperand &AddrDiscOp,

llvm/lib/Target/AArch64/AArch64InstrInfo.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2168,6 +2168,7 @@ let Predicates = [HasPAuth] in {
21682168
let usesCustomInserter = 1;
21692169
}
21702170

2171+
// A standalone pattern is used, so that literal 0 can be passed as $Disc.
21712172
def : Pat<(int_ptrauth_sign GPR64:$Val, timm:$Key, GPR64noip:$AddrDisc),
21722173
(PAC GPR64:$Val, $Key, 0, GPR64noip:$AddrDisc)>;
21732174

llvm/test/CodeGen/AArch64/ptrauth-isel.mir

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,25 @@
2525
ret i64 0
2626
}
2727

28+
define i64 @movi64imm_immediate_operand(i64 %a) {
29+
entry:
30+
ret i64 0
31+
}
32+
2833
define i64 @movi64imm_non_immediate_operand(i64 %a) {
2934
entry:
3035
ret i64 0
3136
}
37+
38+
define i64 @movi32imm_immediate_operand(i64 %a) {
39+
entry:
40+
ret i64 0
41+
}
42+
43+
define i64 @movi32imm_non_immediate_operand(i64 %a) {
44+
entry:
45+
ret i64 0
46+
}
3247
...
3348
---
3449
name: movk_correct_blend
@@ -101,6 +116,27 @@ body: |
101116
RET_ReallyLR implicit $x0
102117
...
103118
---
119+
name: movi64imm_immediate_operand
120+
tracksRegLiveness: true
121+
body: |
122+
bb.0.entry:
123+
liveins: $x0, $x1
124+
125+
; CHECK-LABEL: name: movi64imm_immediate_operand
126+
; CHECK: liveins: $x0, $x1
127+
; CHECK-NEXT: {{ $}}
128+
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
129+
; CHECK-NEXT: [[MOVi64imm:%[0-9]+]]:gpr64noip = MOVi64imm 42
130+
; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $noreg, implicit-def dead $x17
131+
; CHECK-NEXT: $x0 = COPY [[PAC]]
132+
; CHECK-NEXT: RET_ReallyLR implicit $x0
133+
%0:gpr64 = COPY $x0
134+
%1:gpr64noip = MOVi64imm 42
135+
%2:gpr64 = PAC %0, 2, 0, killed %1, implicit-def dead $x17
136+
$x0 = COPY %2
137+
RET_ReallyLR implicit $x0
138+
...
139+
---
104140
name: movi64imm_non_immediate_operand
105141
tracksRegLiveness: true
106142
body: |
@@ -121,3 +157,49 @@ body: |
121157
$x0 = COPY %2
122158
RET_ReallyLR implicit $x0
123159
...
160+
---
161+
name: movi32imm_immediate_operand
162+
tracksRegLiveness: true
163+
body: |
164+
bb.0.entry:
165+
liveins: $x0, $x1
166+
167+
; CHECK-LABEL: name: movi32imm_immediate_operand
168+
; CHECK: liveins: $x0, $x1
169+
; CHECK-NEXT: {{ $}}
170+
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
171+
; CHECK-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm 42
172+
; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32
173+
; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 42, killed $noreg, implicit-def dead $x17
174+
; CHECK-NEXT: $x0 = COPY [[PAC]]
175+
; CHECK-NEXT: RET_ReallyLR implicit $x0
176+
%0:gpr64 = COPY $x0
177+
%1:gpr32 = MOVi32imm 42
178+
%2:gpr64noip = SUBREG_TO_REG 0, killed %1, %subreg.sub_32
179+
%3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x17
180+
$x0 = COPY %3
181+
RET_ReallyLR implicit $x0
182+
...
183+
---
184+
name: movi32imm_non_immediate_operand
185+
tracksRegLiveness: true
186+
body: |
187+
bb.0.entry:
188+
liveins: $x0, $x1
189+
190+
; CHECK-LABEL: name: movi32imm_non_immediate_operand
191+
; CHECK: liveins: $x0, $x1
192+
; CHECK-NEXT: {{ $}}
193+
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x0
194+
; CHECK-NEXT: [[MOVi32imm:%[0-9]+]]:gpr32 = MOVi32imm target-flags(aarch64-pageoff, aarch64-nc) @globalvar
195+
; CHECK-NEXT: [[SUBREG_TO_REG:%[0-9]+]]:gpr64noip = SUBREG_TO_REG 0, killed [[MOVi32imm]], %subreg.sub_32
196+
; CHECK-NEXT: [[PAC:%[0-9]+]]:gpr64 = PAC [[COPY]], 2, 0, killed [[SUBREG_TO_REG]], implicit-def dead $x17
197+
; CHECK-NEXT: $x0 = COPY [[PAC]]
198+
; CHECK-NEXT: RET_ReallyLR implicit $x0
199+
%0:gpr64 = COPY $x0
200+
%1:gpr32 = MOVi32imm target-flags(aarch64-pageoff, aarch64-nc) @globalvar
201+
%2:gpr64noip = SUBREG_TO_REG 0, killed %1, %subreg.sub_32
202+
%3:gpr64 = PAC %0, 2, 0, killed %2, implicit-def dead $x17
203+
$x0 = COPY %3
204+
RET_ReallyLR implicit $x0
205+
...

0 commit comments

Comments
 (0)