Skip to content

Commit dbe441e

Browse files
authored
X86: Avoid some uses of getPointerTy (#146306)
In most contexts the pointer type is implied by the operation and should be propagated; getPointerTy is for niche cases where there is a synthesized value.
1 parent 4f02965 commit dbe441e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19206,7 +19206,7 @@ SDValue X86TargetLowering::LowerJumpTable(SDValue Op, SelectionDAG &DAG) const {
1920619206
// global base reg.
1920719207
unsigned char OpFlag = Subtarget.classifyLocalReference(nullptr);
1920819208

19209-
auto PtrVT = getPointerTy(DAG.getDataLayout());
19209+
EVT PtrVT = Op.getValueType();
1921019210
SDValue Result = DAG.getTargetJumpTable(JT->getIndex(), PtrVT, OpFlag);
1921119211
SDLoc DL(JT);
1921219212
Result =
@@ -19234,7 +19234,7 @@ X86TargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const {
1923419234
const BlockAddress *BA = cast<BlockAddressSDNode>(Op)->getBlockAddress();
1923519235
int64_t Offset = cast<BlockAddressSDNode>(Op)->getOffset();
1923619236
SDLoc dl(Op);
19237-
auto PtrVT = getPointerTy(DAG.getDataLayout());
19237+
EVT PtrVT = Op.getValueType();
1923819238
SDValue Result = DAG.getTargetBlockAddress(BA, PtrVT, Offset, OpFlags);
1923919239
Result =
1924019240
DAG.getNode(getGlobalWrapperKind(nullptr, OpFlags), dl, PtrVT, Result);
@@ -19277,7 +19277,7 @@ SDValue X86TargetLowering::LowerGlobalOrExternal(SDValue Op, SelectionDAG &DAG,
1927719277
bool NeedsLoad = isGlobalStubReference(OpFlags);
1927819278

1927919279
CodeModel::Model M = DAG.getTarget().getCodeModel();
19280-
auto PtrVT = getPointerTy(DAG.getDataLayout());
19280+
EVT PtrVT = Op.getValueType();
1928119281
SDValue Result;
1928219282

1928319283
if (GV) {
@@ -19536,7 +19536,7 @@ X86TargetLowering::LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const {
1953619536
return LowerToTLSEmulatedModel(GA, DAG);
1953719537

1953819538
const GlobalValue *GV = GA->getGlobal();
19539-
auto PtrVT = getPointerTy(DAG.getDataLayout());
19539+
EVT PtrVT = Op.getValueType();
1954019540
bool PositionIndependent = isPositionIndependent();
1954119541

1954219542
if (Subtarget.isTargetELF()) {
@@ -25782,7 +25782,7 @@ X86TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
2578225782
Chain = DAG.getCALLSEQ_START(Chain, 0, 0, dl);
2578325783

2578425784
bool Is64Bit = Subtarget.is64Bit();
25785-
MVT SPTy = getPointerTy(DAG.getDataLayout());
25785+
MVT SPTy = Op.getValueType().getSimpleVT();
2578625786

2578725787
SDValue Result;
2578825788
if (!Lower) {
@@ -25850,7 +25850,9 @@ X86TargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
2585025850

2585125851
SDValue X86TargetLowering::LowerVASTART(SDValue Op, SelectionDAG &DAG) const {
2585225852
MachineFunction &MF = DAG.getMachineFunction();
25853-
auto PtrVT = getPointerTy(MF.getDataLayout());
25853+
SDValue Ptr = Op.getOperand(1);
25854+
EVT PtrVT = Ptr.getValueType();
25855+
2585425856
X86MachineFunctionInfo *FuncInfo = MF.getInfo<X86MachineFunctionInfo>();
2585525857

2585625858
const Value *SV = cast<SrcValueSDNode>(Op.getOperand(2))->getValue();
@@ -25861,8 +25863,7 @@ SDValue X86TargetLowering::LowerVASTART(SDValue Op, SelectionDAG &DAG) const {
2586125863
// vastart just stores the address of the VarArgsFrameIndex slot into the
2586225864
// memory location argument.
2586325865
SDValue FR = DAG.getFrameIndex(FuncInfo->getVarArgsFrameIndex(), PtrVT);
25864-
return DAG.getStore(Op.getOperand(0), DL, FR, Op.getOperand(1),
25865-
MachinePointerInfo(SV));
25866+
return DAG.getStore(Op.getOperand(0), DL, FR, Ptr, MachinePointerInfo(SV));
2586625867
}
2586725868

2586825869
// __va_list_tag:
@@ -25951,7 +25952,7 @@ SDValue X86TargetLowering::LowerVAARG(SDValue Op, SelectionDAG &DAG) const {
2595125952
DAG.getTargetConstant(ArgSize, dl, MVT::i32),
2595225953
DAG.getTargetConstant(ArgMode, dl, MVT::i8),
2595325954
DAG.getTargetConstant(Align, dl, MVT::i32)};
25954-
SDVTList VTs = DAG.getVTList(getPointerTy(DAG.getDataLayout()), MVT::Other);
25955+
SDVTList VTs = DAG.getVTList(SrcPtr.getValueType(), MVT::Other);
2595525956
SDValue VAARG = DAG.getMemIntrinsicNode(
2595625957
Subtarget.isTarget64BitLP64() ? X86ISD::VAARG_64 : X86ISD::VAARG_X32, dl,
2595725958
VTs, InstOps, MVT::i64, MachinePointerInfo(SV),
@@ -26272,9 +26273,6 @@ static SDValue recoverFramePointer(SelectionDAG &DAG, const Function *Fn,
2627226273
MachineFunction &MF = DAG.getMachineFunction();
2627326274
SDLoc dl;
2627426275

26275-
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
26276-
MVT PtrVT = TLI.getPointerTy(DAG.getDataLayout());
26277-
2627826276
// It's possible that the parent function no longer has a personality function
2627926277
// if the exceptional code was optimized away, in which case we just return
2628026278
// the incoming EBP.
@@ -26285,6 +26283,7 @@ static SDValue recoverFramePointer(SelectionDAG &DAG, const Function *Fn,
2628526283
// registration, or the .set_setframe offset.
2628626284
MCSymbol *OffsetSym = MF.getContext().getOrCreateParentFrameOffsetSymbol(
2628726285
GlobalValue::dropLLVMManglingEscape(Fn->getName()));
26286+
MVT PtrVT = EntryEBP.getValueType().getSimpleVT();
2628826287
SDValue OffsetSymVal = DAG.getMCSymbol(OffsetSym, PtrVT);
2628926288
SDValue ParentFrameOffset =
2629026289
DAG.getNode(ISD::LOCAL_RECOVER, dl, PtrVT, OffsetSymVal);
@@ -27345,7 +27344,7 @@ SDValue X86TargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
2734527344
case Intrinsic::thread_pointer: {
2734627345
if (Subtarget.isTargetELF()) {
2734727346
SDLoc dl(Op);
27348-
EVT PtrVT = getPointerTy(DAG.getDataLayout());
27347+
EVT PtrVT = Op.getValueType();
2734927348
// Get the Thread Pointer, which is %gs:0 (32-bit) or %fs:0 (64-bit).
2735027349
Value *Ptr = Constant::getNullValue(PointerType::get(
2735127350
*DAG.getContext(), Subtarget.is64Bit() ? X86AS::FS : X86AS::GS));
@@ -28217,7 +28216,7 @@ SDValue X86TargetLowering::LowerRETURNADDR(SDValue Op,
2821728216

2821828217
unsigned Depth = Op.getConstantOperandVal(0);
2821928218
SDLoc dl(Op);
28220-
EVT PtrVT = getPointerTy(DAG.getDataLayout());
28219+
EVT PtrVT = Op.getValueType();
2822128220

2822228221
if (Depth > 0) {
2822328222
SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);

0 commit comments

Comments
 (0)