[llvm-branch-commits] [llvm] d079fec - [X86] Fix lowering TLS under darwin large code model (#80907)
Tom Stellard via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Fri Feb 9 13:29:02 PST 2024
Author: Arthur Eubanks
Date: 2024-02-09T13:28:23-08:00
New Revision: d079fec440081f3e8e0a79dbbde2066cca077f77
URL: https://github.com/llvm/llvm-project/commit/d079fec440081f3e8e0a79dbbde2066cca077f77
DIFF: https://github.com/llvm/llvm-project/commit/d079fec440081f3e8e0a79dbbde2066cca077f77.diff
LOG: [X86] Fix lowering TLS under darwin large code model (#80907)
OpFlag and WrapperKind should be chosen consistently with each other in
regards to PIC, otherwise we hit asserts later on.
Broken by c04a05d8.
Fixes #80831.
(cherry picked from commit 5a83bccb35d6b0e6914b52af6db067aa01dd3efb)
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/tls-models.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index e158312caffdec..a071c5a3ca0326 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18703,16 +18703,18 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
if (Subtarget.isTargetDarwin()) {
// Darwin only has one model of TLS. Lower to that.
unsigned char OpFlag = 0;
- unsigned WrapperKind = Subtarget.isPICStyleRIPRel() ?
- X86ISD::WrapperRIP : X86ISD::Wrapper;
+ unsigned WrapperKind = 0;
// In PIC mode (unless we're in RIPRel PIC mode) we add an offset to the
// global base reg.
bool PIC32 = PositionIndependent && !Subtarget.is64Bit();
- if (PIC32)
+ if (PIC32) {
OpFlag = X86II::MO_TLVP_PIC_BASE;
- else
+ WrapperKind = X86ISD::Wrapper;
+ } else {
OpFlag = X86II::MO_TLVP;
+ WrapperKind = X86ISD::WrapperRIP;
+ }
SDLoc DL(Op);
SDValue Result = DAG.getTargetGlobalAddress(GA->getGlobal(), DL,
GA->getValueType(0),
diff --git a/llvm/test/CodeGen/X86/tls-models.ll b/llvm/test/CodeGen/X86/tls-models.ll
index fc8e302338d960..8de9de15a5f06e 100644
--- a/llvm/test/CodeGen/X86/tls-models.ll
+++ b/llvm/test/CodeGen/X86/tls-models.ll
@@ -5,6 +5,7 @@
; Darwin always uses the same model.
; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck -check-prefix=DARWIN %s
+; RUN: llc < %s -mtriple=x86_64-apple-darwin -code-model=large | FileCheck -check-prefix=DARWIN %s
@external_gd = external thread_local global i32
@internal_gd = internal thread_local global i32 42
More information about the llvm-branch-commits
mailing list