Skip to content

Commit 888f84f

Browse files
authored
[ARM] Return the correct chain when expanding READ_REGISTER (#145237)
This prevents it CSEing multiple nodes together from "volatile" registers as they would end up with the same chain. The new chain out should be the chain from the new READ_REGISTER node. Fixes #144845
1 parent 13a9b86 commit 888f84f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6186,7 +6186,7 @@ static void ExpandREAD_REGISTER(SDNode *N, SmallVectorImpl<SDValue> &Results,
61866186

61876187
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, DL, MVT::i64, Read.getValue(0),
61886188
Read.getValue(1)));
6189-
Results.push_back(Read.getOperand(0));
6189+
Results.push_back(Read.getValue(2)); // Chain
61906190
}
61916191

61926192
/// \p BC is a bitcast that is about to be turned into a VMOVDRR.

llvm/test/CodeGen/ARM/special-reg.ll

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,18 @@ entry:
2525
define i64 @read_volatile_i64_twice() {
2626
; ACORE-LABEL: read_volatile_i64_twice:
2727
; ACORE: @ %bb.0: @ %entry
28-
; ACORE-NEXT: mov r0, #0
29-
; ACORE-NEXT: mov r1, #0
28+
; ACORE-NEXT: mrrc p15, #1, r0, r1, c14
29+
; ACORE-NEXT: mrrc p15, #1, r2, r3, c14
30+
; ACORE-NEXT: eor r0, r2, r0
31+
; ACORE-NEXT: eor r1, r3, r1
3032
; ACORE-NEXT: bx lr
3133
;
3234
; MCORE-LABEL: read_volatile_i64_twice:
3335
; MCORE: @ %bb.0: @ %entry
34-
; MCORE-NEXT: movs r0, #0
35-
; MCORE-NEXT: movs r1, #0
36+
; MCORE-NEXT: mrrc p15, #1, r0, r1, c14
37+
; MCORE-NEXT: mrrc p15, #1, r2, r3, c14
38+
; MCORE-NEXT: eors r0, r2
39+
; MCORE-NEXT: eors r1, r3
3640
; MCORE-NEXT: bx lr
3741
entry:
3842
%0 = tail call i64 @llvm.read_volatile_register.i64(metadata !5)

0 commit comments

Comments
 (0)