Skip to content

[X86] Use X86AS::GS and X86AS::FS instead of 256 and 257. NFC #109342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Target/X86/X86ISelLoweringCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/X86/X86WinEHState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
Loading