Skip to content

Commit 600e33e

Browse files
veselypetaresistor
authored andcommitted
Use upstream method to get global addrespace (NFC)
1 parent 270c311 commit 600e33e

File tree

20 files changed

+77
-60
lines changed

20 files changed

+77
-60
lines changed

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,7 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {
23152315

23162316
// Handle typeid(T).
23172317
if (TypeInfoLValue TI = base.dyn_cast<TypeInfoLValue>()) {
2318-
unsigned GlobalAS = CGM.getDataLayout().getGlobalsAddressSpace();
2318+
unsigned GlobalAS = CGM.getDataLayout().getDefaultGlobalsAddressSpace();
23192319
llvm::Type *StdTypeInfoPtrTy = llvm::PointerType::get(CGM.getLLVMContext(), GlobalAS);
23202320
llvm::Constant *TypeInfo =
23212321
CGM.GetAddrOfRTTIDescriptor(QualType(TI.getType(), 0));

clang/lib/CodeGen/CodeGenAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,7 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
852852
FullSourceLoc Loc =
853853
getBestLocationFromDebugLoc(DICI, BadDebugInfo, Filename, Line, Column);
854854
const auto &DL = DICI.getFunction().getParent()->getDataLayout();
855-
bool IsPurecap = DL.isFatPointer(DL.getGlobalsAddressSpace());
855+
bool IsPurecap = DL.isFatPointer(DL.getDefaultGlobalsAddressSpace());
856856

857857
Diags.Report(Loc, diag::warn_fe_backend_cheri_inefficient)
858858
<< DICI.getMessage();

llvm/include/llvm/CodeGen/TargetLowering.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4090,7 +4090,7 @@ class LLVM_ABI TargetLowering : public TargetLoweringBase {
40904090
virtual unsigned getJumpTableEncoding() const;
40914091

40924092
virtual MVT getJumpTableRegTy(const DataLayout &DL) const {
4093-
return getPointerRangeTy(DL, DL.getGlobalsAddressSpace());
4093+
return getPointerRangeTy(DL, DL.getDefaultGlobalsAddressSpace());
40944094
}
40954095

40964096
virtual const MCExpr *

llvm/include/llvm/IR/DataLayout.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ class DataLayout {
252252
unsigned getDefaultGlobalsAddressSpace() const {
253253
return DefaultGlobalsAddrSpace;
254254
}
255-
// TODO: remove this and use the upstreamed version
256-
unsigned getGlobalsAddressSpace() const { return DefaultGlobalsAddrSpace; }
257255

258256
bool hasMicrosoftFastStdCallMangling() const {
259257
return ManglingMode == MM_WinCOFFX86;

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,7 @@ bool AtomicExpandImpl::expandAtomicOpToLibcall(
21192119
std::string LibcallName = TLI->getLibcallName(RTLibType);
21202120
// We are compiling for CHERI purecap mode if the default globals address
21212121
// space is a capability type.
2122-
bool IsCheriPurecap = DL.isFatPointer(DL.getGlobalsAddressSpace());
2122+
bool IsCheriPurecap = DL.isFatPointer(DL.getDefaultGlobalsAddressSpace());
21232123
if (ValueOperandIsCap) {
21242124
LibcallName += "_cap";
21252125
}

llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28925,7 +28925,7 @@ SDValue DAGCombiner::convertSelectOfFPConstantsToLoadOffset(
2892528925
SDValue CPIdx = DAG.getConstantPool(
2892628926
CA,
2892728927
TLI.getPointerTy(DAG.getDataLayout(),
28928-
DAG.getDataLayout().getGlobalsAddressSpace()),
28928+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()),
2892928929
TD.getPrefTypeAlign(FPTy));
2893028930
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
2893128931

llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,9 @@ SelectionDAGLegalize::ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP) {
361361
}
362362

363363
SDValue CPIdx = DAG.getConstantPool(
364-
LLVMC, TLI.getPointerTy(DAG.getDataLayout(),
365-
DAG.getDataLayout().getGlobalsAddressSpace()));
364+
LLVMC,
365+
TLI.getPointerTy(DAG.getDataLayout(),
366+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
366367
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
367368
if (Extend) {
368369
SDValue Result = DAG.getExtLoad(
@@ -384,7 +385,7 @@ SDValue SelectionDAGLegalize::ExpandConstant(ConstantSDNode *CP) {
384385
SDValue CPIdx = DAG.getConstantPool(
385386
CP->getConstantIntValue(),
386387
TLI.getPointerTy(DAG.getDataLayout(),
387-
DAG.getDataLayout().getGlobalsAddressSpace()));
388+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
388389
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
389390
SDValue Result = DAG.getLoad(
390391
VT, dl, DAG.getEntryNode(), CPIdx,
@@ -2096,8 +2097,9 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
20962097
}
20972098
Constant *CP = ConstantVector::get(CV);
20982099
SDValue CPIdx = DAG.getConstantPool(
2099-
CP, TLI.getPointerTy(DAG.getDataLayout(),
2100-
DAG.getDataLayout().getGlobalsAddressSpace()));
2100+
CP,
2101+
TLI.getPointerTy(DAG.getDataLayout(),
2102+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
21012103
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
21022104
return DAG.getLoad(
21032105
VT, dl, DAG.getEntryNode(), CPIdx,
@@ -2887,7 +2889,7 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
28872889
SDValue CPIdx = DAG.getConstantPool(
28882890
FudgeFactor,
28892891
TLI.getPointerTy(DAG.getDataLayout(),
2890-
DAG.getDataLayout().getGlobalsAddressSpace()));
2892+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
28912893
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
28922894
CPIdx = DAG.getNode(ISD::ADD, dl, CPIdx.getValueType(), CPIdx, CstOffset);
28932895
Alignment = commonAlignment(Alignment, 4);

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,8 +1975,8 @@ SDValue SelectionDAG::getJumpTable(int JTI, EVT VT, bool isTarget,
19751975

19761976
SDValue SelectionDAG::getJumpTableDebugInfo(int JTI, SDValue Chain,
19771977
const SDLoc &DL) {
1978-
EVT PTy = getTargetLoweringInfo().getPointerTy(getDataLayout(),
1979-
getDataLayout().getGlobalsAddressSpace());
1978+
EVT PTy = getTargetLoweringInfo().getPointerTy(
1979+
getDataLayout(), getDataLayout().getDefaultGlobalsAddressSpace());
19801980
return getNode(ISD::JUMP_TABLE_DEBUG_INFO, DL, MVT::Glue, Chain,
19811981
getTargetConstant(static_cast<uint64_t>(JTI), DL, PTy, true));
19821982
}

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2957,7 +2957,7 @@ void SelectionDAGBuilder::visitJumpTable(SwitchCG::JumpTable &JT) {
29572957
assert(JT.Reg && "Should lower JT Header first!");
29582958
const DataLayout &TD = DAG.getDataLayout();
29592959
const auto &TLI = DAG.getTargetLoweringInfo();
2960-
EVT PTy = TLI.getPointerTy(TD, TD.getGlobalsAddressSpace());
2960+
EVT PTy = TLI.getPointerTy(TD, TD.getDefaultGlobalsAddressSpace());
29612961
EVT IndexTy = TLI.getJumpTableRegTy(TD);
29622962
SDValue Index =
29632963
DAG.getCopyFromReg(getControlRoot(), *JT.SL, JT.Reg, IndexTy);
@@ -4961,14 +4961,14 @@ static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index,
49614961
Base = SDB->getValue(C);
49624962

49634963
ElementCount NumElts = cast<VectorType>(Ptr->getType())->getElementCount();
4964-
EVT VT = EVT::getVectorVT(*DAG.getContext(),
4965-
TLI.getPointerTy(DL, DL.getGlobalsAddressSpace()),
4966-
NumElts);
4964+
EVT VT = EVT::getVectorVT(
4965+
*DAG.getContext(),
4966+
TLI.getPointerTy(DL, DL.getDefaultGlobalsAddressSpace()), NumElts);
49674967
Index = DAG.getConstant(0, SDB->getCurSDLoc(), VT);
49684968
IndexType = ISD::SIGNED_SCALED;
49694969
Scale = DAG.getTargetConstant(
49704970
1, SDB->getCurSDLoc(),
4971-
TLI.getPointerTy(DL, DL.getGlobalsAddressSpace()));
4971+
TLI.getPointerTy(DL, DL.getDefaultGlobalsAddressSpace()));
49724972
return true;
49734973
}
49744974

@@ -9850,7 +9850,7 @@ static SDValue getAddressForMemoryInput(SDValue Chain, const SDLoc &Location,
98509850
OpInfo.CallOperand = DAG.getConstantPool(
98519851
cast<Constant>(OpVal),
98529852
TLI.getPointerTy(DAG.getDataLayout(),
9853-
DAG.getDataLayout().getGlobalsAddressSpace()));
9853+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
98549854
return Chain;
98559855
}
98569856

@@ -10393,7 +10393,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
1039310393
assert(InOperandVal.getValueType() ==
1039410394
TLI.getPointerTy(
1039510395
DAG.getDataLayout(),
10396-
DAG.getDataLayout().getGlobalsAddressSpace()) &&
10396+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()) &&
1039710397
"Memory operands expect pointer values");
1039810398

1039910399
const InlineAsm::ConstraintCode ConstraintID =

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9507,7 +9507,8 @@ SDValue TargetLowering::CTTZTableLookup(SDNode *Node, SelectionDAG &DAG,
95079507
DAG.getConstant(ShiftAmt, DL, VT));
95089508
Lookup = DAG.getSExtOrTrunc(
95099509
Lookup, DL,
9510-
getPointerRangeTy(TD, DAG.getDataLayout().getGlobalsAddressSpace()));
9510+
getPointerRangeTy(TD,
9511+
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
95119512

95129513
SmallVector<uint8_t> Table(BitWidth, 0);
95139514
for (unsigned i = 0; i < BitWidth; i++) {
@@ -9519,7 +9520,7 @@ SDValue TargetLowering::CTTZTableLookup(SDNode *Node, SelectionDAG &DAG,
95199520
// Create a ConstantArray in Constant Pool
95209521
auto *CA = ConstantDataArray::get(*DAG.getContext(), Table);
95219522
SDValue CPIdx = DAG.getConstantPool(
9522-
CA, getPointerTy(TD, DAG.getDataLayout().getGlobalsAddressSpace()),
9523+
CA, getPointerTy(TD, DAG.getDataLayout().getDefaultGlobalsAddressSpace()),
95239524
TD.getPrefTypeAlign(CA->getType()));
95249525
SDValue ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, DL, VT, DAG.getEntryNode(),
95259526
DAG.getMemBasePlusOffset(CPIdx, Lookup, DL),
@@ -10780,8 +10781,8 @@ SDValue TargetLowering::LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA,
1078010781
SelectionDAG &DAG) const {
1078110782
// Access to address of TLS varialbe xyz is lowered to a function call:
1078210783
// __emutls_get_address( address of global variable named "__emutls_v.xyz" )
10783-
EVT DataPtrVT = getPointerTy(DAG.getDataLayout(),
10784-
DAG.getDataLayout().getGlobalsAddressSpace());
10784+
EVT DataPtrVT = getPointerTy(
10785+
DAG.getDataLayout(), DAG.getDataLayout().getDefaultGlobalsAddressSpace());
1078510786
PointerType *VoidPtrType = PointerType::get(*DAG.getContext(), 0);
1078610787
SDLoc dl(GA);
1078710788

0 commit comments

Comments
 (0)