[PATCH] D155232: [llvm] Remove uses of Type::getPointerTo() (NFC)
Sergei Barannikov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 15 05:01:07 PDT 2023
barannikov88 added a comment.
I think getting rid of typed pointers should be an actual cleanup, not just a textual replacement. I outlined a few possible simplifications, but I didn't analyze deeply.
================
Comment at: llvm/lib/CodeGen/AtomicExpandPass.cpp:728
PointerType *PtrTy = cast<PointerType>(Addr->getType());
- Type *WordPtrType = PMV.WordType->getPointerTo(PtrTy->getAddressSpace());
+ Type *WordPtrType =
+ PointerType::get(PMV.WordType->getContext(), PtrTy->getAddressSpace());
----------------
This is the same as PtrTy.
================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7852
V = Builder.CreateZExtOrBitCast(V, SplitStoreType);
- Value *Addr = Builder.CreateBitCast(
- SI.getOperand(1),
- SplitStoreType->getPointerTo(SI.getPointerAddressSpace()));
+ Value *Addr = SI.getOperand(1);
Align Alignment = SI.getAlign();
----------------
================
Comment at: llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp:705
+ return Builder.CreatePointerCast(remap(Tmp0),
+ PointerType::getUnqual(ValTy), "cst");
}
----------------
JOE1994 wrote:
> Given that this line is guarded by `if (!PtrTy->isOpaque()`,
> I wasn't sure whether using `PointerType::getUnqual(LLVMContext&)` here is acceptable.
>
> For now, I chose to play safe and just used `PointerType::getUnqual(Type *)` here.
`isOpaque()` always returns true, this whole block can be removed.
================
Comment at: llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp:713-714
remap(Tmp0), HVC.getConstInt(Adjust), "gep");
- return Builder.CreatePointerCast(remap(Tmp1), ValTy->getPointerTo(), "cst");
+ return Builder.CreatePointerCast(
+ remap(Tmp1), PointerType::getUnqual(ValTy->getContext()), "cst");
}
----------------
Isn't this a no-op? And the one above?
================
Comment at: llvm/lib/Target/X86/X86TargetTransformInfo.cpp:5750-5751
+ FixedVectorType::get(PointerType::getUnqual(ScalarTy->getContext()), VF),
+ DemandedElts,
/*Insert=*/false, /*Extract=*/true, CostKind);
----------------
clang-format does poorly when argument comments are involved.
================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:590
Value *NewPtr = nullptr;
if (!(match(Ptr, m_BitCast(m_Value(NewPtr))) &&
NewPtr->getType() == NewPtrTy))
----------------
The condition is always true because the bitcast can never be matched.
================
Comment at: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp:193-194
Value *BiasInst = Builder.Insert(OrigBiasInst->clone());
- Addr = Builder.CreateIntToPtr(BiasInst, Ty->getPointerTo());
+ Addr = Builder.CreateIntToPtr(BiasInst,
+ PointerType::getUnqual(Ty->getContext()));
}
----------------
Would that be correct?
================
Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:3389
IRB.CreateStore(getCleanShadow(Ty),
- IRB.CreatePointerCast(ShadowPtr, Ty->getPointerTo()));
+ IRB.CreatePointerCast(
+ ShadowPtr, PointerType::getUnqual(Ty->getContext())));
----------------
This cast looks no-op.
================
Comment at: llvm/lib/Transforms/Utils/EntryExitInstrumenter.cpp:38
Type *SizeTy = M.getDataLayout().getIntPtrType(C);
- Type *SizePtrTy = SizeTy->getPointerTo();
+ Type *SizePtrTy = PointerType::getUnqual(SizeTy->getContext());
GlobalVariable *GV = new GlobalVariable(M, SizeTy, /*isConstant=*/false,
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155232/new/
https://reviews.llvm.org/D155232
More information about the llvm-commits
mailing list