[PATCH] D153103: [m68k] Fix incorrect handling of TLS when matching addressing mode.
Sheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 15 23:28:17 PDT 2023
0x59616e created this revision.
0x59616e added reviewers: myhsu, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: All.
0x59616e requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
`TargetGlobalTLSAddress` is not considered and handled correctly when matching addressing mode, which leads to an incorrect result of instruction selection.
fixes #63162.
https://reviews.llvm.org/D153103
Files:
llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
llvm/test/CodeGen/M68k/TLS/tlsgd.ll
llvm/test/CodeGen/M68k/TLS/tlsie.ll
llvm/test/CodeGen/M68k/TLS/tlsld.ll
llvm/test/CodeGen/M68k/TLS/tlsle.ll
Index: llvm/test/CodeGen/M68k/TLS/tlsle.ll
===================================================================
--- llvm/test/CodeGen/M68k/TLS/tlsle.ll
+++ llvm/test/CodeGen/M68k/TLS/tlsle.ll
@@ -8,7 +8,7 @@
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: suba.l #4, %sp
; CHECK-NEXT: jsr __m68k_read_tp at PLT
-; CHECK-NEXT: adda.l myvar at TPOFF, %a0
+; CHECK-NEXT: lea (myvar at TPOFF,%a0), %a0
; CHECK-NEXT: adda.l #4, %sp
; CHECK-NEXT: rts
entry:
Index: llvm/test/CodeGen/M68k/TLS/tlsld.ll
===================================================================
--- llvm/test/CodeGen/M68k/TLS/tlsld.ll
+++ llvm/test/CodeGen/M68k/TLS/tlsld.ll
@@ -8,10 +8,10 @@
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: suba.l #4, %sp
; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_ at GOTPCREL,%pc), %a0
-; CHECK-NEXT: adda.l myvar at TLSLDM, %a0
+; CHECK-NEXT: lea (myvar at TLSLDM,%a0), %a0
; CHECK-NEXT: move.l %a0, (%sp)
; CHECK-NEXT: jsr (__tls_get_addr at PLT,%pc)
-; CHECK-NEXT: adda.l myvar at TLSLD, %a0
+; CHECK-NEXT: lea (myvar at TLSLD,%a0), %a0
; CHECK-NEXT: adda.l #4, %sp
; CHECK-NEXT: rts
entry:
Index: llvm/test/CodeGen/M68k/TLS/tlsie.ll
===================================================================
--- llvm/test/CodeGen/M68k/TLS/tlsie.ll
+++ llvm/test/CodeGen/M68k/TLS/tlsie.ll
@@ -10,7 +10,7 @@
; CHECK-NEXT: jsr __m68k_read_tp at PLT
; CHECK-NEXT: move.l %a0, %d0
; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_ at GOTPCREL,%pc), %a0
-; CHECK-NEXT: add.l (0,myvar at GOTTPOFF,%a0), %d0
+; CHECK-NEXT: add.l (myvar at GOTTPOFF,%a0), %d0
; CHECK-NEXT: move.l %d0, %a0
; CHECK-NEXT: adda.l #4, %sp
; CHECK-NEXT: rts
Index: llvm/test/CodeGen/M68k/TLS/tlsgd.ll
===================================================================
--- llvm/test/CodeGen/M68k/TLS/tlsgd.ll
+++ llvm/test/CodeGen/M68k/TLS/tlsgd.ll
@@ -8,7 +8,7 @@
; CHECK: ; %bb.0: ; %entry
; CHECK-NEXT: suba.l #4, %sp
; CHECK-NEXT: lea (_GLOBAL_OFFSET_TABLE_ at GOTPCREL,%pc), %a0
-; CHECK-NEXT: adda.l myvar at TLSGD, %a0
+; CHECK-NEXT: lea (myvar at TLSGD,%a0), %a0
; CHECK-NEXT: move.l %a0, (%sp)
; CHECK-NEXT: jsr (__tls_get_addr at PLT,%pc)
; CHECK-NEXT: adda.l #4, %sp
Index: llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
===================================================================
--- llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
+++ llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
@@ -500,6 +500,12 @@
return true;
}
break;
+
+ case ISD::TargetGlobalTLSAddress:
+ GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N);
+ AM.GV = GA->getGlobal();
+ AM.SymbolFlags = GA->getTargetFlags();
+ return true;
}
return matchAddressBase(N, AM);
@@ -724,6 +730,8 @@
return false;
}
+ Base = AM.BaseReg;
+
if (getSymbolicDisplacement(AM, SDLoc(N), Disp)) {
assert(!AM.Disp && "Should not be any displacement");
LLVM_DEBUG(dbgs() << "SUCCESS, matched Symbol\n");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153103.531995.patch
Type: text/x-patch
Size: 2949 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/1c9d3671/attachment-0001.bin>
More information about the llvm-commits
mailing list