[llvm] 65b710e - [m68k] Fix incorrect handling of TLS when matching addressing mode.
via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 22 17:31:31 PDT 2023
Author: Sheng
Date: 2023-06-23T08:30:53+08:00
New Revision: 65b710efc19d46932308097258ae1f8167edcbf2
URL: https://github.com/llvm/llvm-project/commit/65b710efc19d46932308097258ae1f8167edcbf2
DIFF: https://github.com/llvm/llvm-project/commit/65b710efc19d46932308097258ae1f8167edcbf2.diff
LOG: [m68k] Fix incorrect handling of TLS when matching addressing mode.
`TargetGlobalTLSAddress` is not considered and handled correctly when matching addressing mode, which leads to an incorrect result of instruction selection.
fixes #63162.
Reviewed By: myhsu
Differential Revision: https://reviews.llvm.org/D153103
Added:
Modified:
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
Removed:
################################################################################
diff --git a/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp b/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
index 075120b973473..e33654ea3f186 100644
--- a/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
+++ b/llvm/lib/Target/M68k/M68kISelDAGToDAG.cpp
@@ -500,6 +500,13 @@ bool M68kDAGToDAGISel::matchAddressRecursively(SDValue N,
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 +731,8 @@ bool M68kDAGToDAGISel::SelectARID(SDNode *Parent, SDValue N, SDValue &Disp,
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");
@@ -736,7 +745,6 @@ bool M68kDAGToDAGISel::SelectARID(SDNode *Parent, SDValue N, SDValue &Disp,
return false;
}
- Base = AM.BaseReg;
Disp = getI16Imm(AM.Disp, SDLoc(N));
LLVM_DEBUG(dbgs() << "SUCCESS\n");
diff --git a/llvm/test/CodeGen/M68k/TLS/tlsgd.ll b/llvm/test/CodeGen/M68k/TLS/tlsgd.ll
index ed891dd6bb40f..cbbe84e44a387 100644
--- a/llvm/test/CodeGen/M68k/TLS/tlsgd.ll
+++ b/llvm/test/CodeGen/M68k/TLS/tlsgd.ll
@@ -8,7 +8,7 @@ define ptr @get_addr() nounwind {
; 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
diff --git a/llvm/test/CodeGen/M68k/TLS/tlsie.ll b/llvm/test/CodeGen/M68k/TLS/tlsie.ll
index db4000ee7b171..8e402ce679622 100644
--- a/llvm/test/CodeGen/M68k/TLS/tlsie.ll
+++ b/llvm/test/CodeGen/M68k/TLS/tlsie.ll
@@ -10,7 +10,7 @@ define dso_local ptr @get_addr() nounwind {
; 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
diff --git a/llvm/test/CodeGen/M68k/TLS/tlsld.ll b/llvm/test/CodeGen/M68k/TLS/tlsld.ll
index 1a0588dc47d02..01c4c0facb824 100644
--- a/llvm/test/CodeGen/M68k/TLS/tlsld.ll
+++ b/llvm/test/CodeGen/M68k/TLS/tlsld.ll
@@ -8,10 +8,10 @@ define dso_local ptr @get_addr() nounwind {
; 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:
diff --git a/llvm/test/CodeGen/M68k/TLS/tlsle.ll b/llvm/test/CodeGen/M68k/TLS/tlsle.ll
index b0c2b3796626c..a08898fb33eb8 100644
--- a/llvm/test/CodeGen/M68k/TLS/tlsle.ll
+++ b/llvm/test/CodeGen/M68k/TLS/tlsle.ll
@@ -8,7 +8,7 @@ define dso_local ptr @get_addr() nounwind {
; 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:
More information about the llvm-commits
mailing list