[clang] [llvm] [X86] Use X86AS::GS and X86AS::FS instead of 256 and 257. NFC (PR #109342)
Craig Topper via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 19 15:24:40 PDT 2024
https://github.com/topperc created https://github.com/llvm/llvm-project/pull/109342
None
>From bc0a290b1e139f32225bc55fc99027b34c4f1bd6 Mon Sep 17 00:00:00 2001
From: Craig Topper <craig.topper at sifive.com>
Date: Thu, 19 Sep 2024 15:13:55 -0700
Subject: [PATCH] [X86] Use X86AS::GS and X86AS::FS instead of 256 and 257. NFC
---
clang/lib/CodeGen/CMakeLists.txt | 1 +
llvm/lib/Target/X86/X86ISelLowering.cpp | 6 +++---
llvm/lib/Target/X86/X86ISelLoweringCall.cpp | 5 +++--
llvm/lib/Target/X86/X86WinEHState.cpp | 4 ++--
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/clang/lib/CodeGen/CMakeLists.txt b/clang/lib/CodeGen/CMakeLists.txt
index aa0c871c5352a8..868ec847b9634b 100644
--- a/clang/lib/CodeGen/CMakeLists.txt
+++ b/clang/lib/CodeGen/CMakeLists.txt
@@ -144,6 +144,7 @@ add_clang_library(clangCodeGen
VarBypassDetector.cpp
DEPENDS
+ vt_gen
intrinsics_gen
ClangDriverOptions
# These generated headers are included transitively.
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 9637e96c21cf52..b9c9e5703849ae 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -18925,7 +18925,7 @@ static SDValue LowerToTLSExecModel(GlobalAddressSDNode *GA, SelectionDAG &DAG,
// Get the Thread Pointer, which is %gs:0 (32-bit) or %fs:0 (64-bit).
Value *Ptr = Constant::getNullValue(
- PointerType::get(*DAG.getContext(), is64Bit ? 257 : 256));
+ PointerType::get(*DAG.getContext(), is64Bit ? X86AS::FS : X86AS::GS));
SDValue ThreadPointer =
DAG.getLoad(PtrVT, dl, DAG.getEntryNode(), DAG.getIntPtrConstant(0, dl),
@@ -19070,8 +19070,8 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
// %gs:0x58 (64-bit). On MinGW, __tls_array is not available, so directly
// use its literal value of 0x2C.
Value *Ptr = Constant::getNullValue(
- Subtarget.is64Bit() ? PointerType::get(*DAG.getContext(), 256)
- : PointerType::get(*DAG.getContext(), 257));
+ Subtarget.is64Bit() ? PointerType::get(*DAG.getContext(), X86AS::GS)
+ : PointerType::get(*DAG.getContext(), X86AS::FS));
SDValue TlsArray = Subtarget.is64Bit()
? DAG.getIntPtrConstant(0x58, dl)
diff --git a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
index 43dcaefc623bea..b9124658028da4 100644
--- a/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
+++ b/llvm/lib/Target/X86/X86ISelLoweringCall.cpp
@@ -524,8 +524,9 @@ X86TargetLowering::findRepresentativeClass(const TargetRegisterInfo *TRI,
unsigned X86TargetLowering::getAddressSpace() const {
if (Subtarget.is64Bit())
- return (getTargetMachine().getCodeModel() == CodeModel::Kernel) ? 256 : 257;
- return 256;
+ return (getTargetMachine().getCodeModel() == CodeModel::Kernel) ? X86AS::GS
+ : X86AS::FS;
+ return X86AS::GS;
}
static bool hasStackGuardSlotTLS(const Triple &TargetTriple) {
diff --git a/llvm/lib/Target/X86/X86WinEHState.cpp b/llvm/lib/Target/X86/X86WinEHState.cpp
index 578d653c1e0ada..963d613ddbfe7d 100644
--- a/llvm/lib/Target/X86/X86WinEHState.cpp
+++ b/llvm/lib/Target/X86/X86WinEHState.cpp
@@ -423,7 +423,7 @@ void WinEHStatePass::linkExceptionRegistration(IRBuilder<> &Builder,
// Handler = Handler
Builder.CreateStore(Handler, Builder.CreateStructGEP(LinkTy, Link, 1));
// Next = [fs:00]
- Constant *FSZero = Constant::getNullValue(PointerType::get(C, 257));
+ Constant *FSZero = Constant::getNullValue(PointerType::get(C, X86AS::FS));
Value *Next = Builder.CreateLoad(PointerType::getUnqual(C), FSZero);
Builder.CreateStore(Next, Builder.CreateStructGEP(LinkTy, Link, 0));
// [fs:00] = Link
@@ -443,7 +443,7 @@ void WinEHStatePass::unlinkExceptionRegistration(IRBuilder<> &Builder) {
// [fs:00] = Link->Next
Value *Next = Builder.CreateLoad(PointerType::getUnqual(C),
Builder.CreateStructGEP(LinkTy, Link, 0));
- Constant *FSZero = Constant::getNullValue(PointerType::get(C, 257));
+ Constant *FSZero = Constant::getNullValue(PointerType::get(C, X86AS::FS));
Builder.CreateStore(Next, FSZero);
}
More information about the cfe-commits
mailing list