mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +01:00
[OpaquePtr] Clean up some uses of Type::getPointerElementType()
These depend on pointee types.
This commit is contained in:
parent
8967f0ab59
commit
cfc7e26853
@ -425,8 +425,7 @@ void SafeStack::findInsts(Function &F,
|
||||
for (Argument &Arg : F.args()) {
|
||||
if (!Arg.hasByValAttr())
|
||||
continue;
|
||||
uint64_t Size =
|
||||
DL.getTypeStoreSize(Arg.getType()->getPointerElementType());
|
||||
uint64_t Size = DL.getTypeStoreSize(Arg.getParamByValType());
|
||||
if (IsSafeStackAlloca(&Arg, Size))
|
||||
continue;
|
||||
|
||||
@ -527,7 +526,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
|
||||
}
|
||||
|
||||
for (Argument *Arg : ByValArguments) {
|
||||
Type *Ty = Arg->getType()->getPointerElementType();
|
||||
Type *Ty = Arg->getParamByValType();
|
||||
uint64_t Size = DL.getTypeStoreSize(Ty);
|
||||
if (Size == 0)
|
||||
Size = 1; // Don't create zero-sized stack objects.
|
||||
@ -584,7 +583,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
|
||||
for (Argument *Arg : ByValArguments) {
|
||||
unsigned Offset = SSL.getObjectOffset(Arg);
|
||||
MaybeAlign Align(SSL.getObjectAlignment(Arg));
|
||||
Type *Ty = Arg->getType()->getPointerElementType();
|
||||
Type *Ty = Arg->getParamByValType();
|
||||
|
||||
uint64_t Size = DL.getTypeStoreSize(Ty);
|
||||
if (Size == 0)
|
||||
|
@ -880,7 +880,7 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
|
||||
|
||||
// ee (gep (ptr, idx0, ...), idx) -> gep (ee (ptr, idx), ee (idx0, idx), ...)
|
||||
if (auto *CE = dyn_cast<ConstantExpr>(Val)) {
|
||||
if (CE->getOpcode() == Instruction::GetElementPtr) {
|
||||
if (auto *GEP = dyn_cast<GEPOperator>(CE)) {
|
||||
SmallVector<Constant *, 8> Ops;
|
||||
Ops.reserve(CE->getNumOperands());
|
||||
for (unsigned i = 0, e = CE->getNumOperands(); i != e; ++i) {
|
||||
@ -894,7 +894,7 @@ Constant *llvm::ConstantFoldExtractElementInstruction(Constant *Val,
|
||||
Ops.push_back(Op);
|
||||
}
|
||||
return CE->getWithOperands(Ops, ValVTy->getElementType(), false,
|
||||
Ops[0]->getType()->getPointerElementType());
|
||||
GEP->getSourceElementType());
|
||||
} else if (CE->getOpcode() == Instruction::InsertElement) {
|
||||
if (const auto *IEIdx = dyn_cast<ConstantInt>(CE->getOperand(2))) {
|
||||
if (APSInt::isSameValue(APSInt(IEIdx->getValue()),
|
||||
|
@ -114,9 +114,9 @@ void AMDGPUAnnotateUniformValues::visitLoadInst(LoadInst &I) {
|
||||
Value *Idx = Constant::getIntegerValue(
|
||||
Type::getInt32Ty(Ptr->getContext()), APInt(64, 0));
|
||||
// Insert GEP at the entry to make it dominate all uses
|
||||
PtrI = GetElementPtrInst::Create(
|
||||
Ptr->getType()->getPointerElementType(), Ptr,
|
||||
ArrayRef<Value*>(Idx), Twine(""), F->getEntryBlock().getFirstNonPHI());
|
||||
PtrI = GetElementPtrInst::Create(I.getType(), Ptr,
|
||||
ArrayRef<Value *>(Idx), Twine(""),
|
||||
F->getEntryBlock().getFirstNonPHI());
|
||||
}
|
||||
I.replaceUsesOfWith(Ptr, PtrI);
|
||||
}
|
||||
|
@ -488,9 +488,9 @@ Value *MVEGatherScatterLowering::tryCreateMaskedGatherOffset(
|
||||
if (Load)
|
||||
return Load;
|
||||
|
||||
int Scale = computeScale(
|
||||
BasePtr->getType()->getPointerElementType()->getPrimitiveSizeInBits(),
|
||||
OriginalTy->getScalarSizeInBits());
|
||||
int Scale =
|
||||
computeScale(GEP->getSourceElementType()->getPrimitiveSizeInBits(),
|
||||
OriginalTy->getScalarSizeInBits());
|
||||
if (Scale == -1)
|
||||
return nullptr;
|
||||
Root = Extend;
|
||||
@ -630,9 +630,9 @@ Value *MVEGatherScatterLowering::tryCreateMaskedScatterOffset(
|
||||
tryCreateIncrementingGatScat(I, BasePtr, Offsets, GEP, Builder);
|
||||
if (Store)
|
||||
return Store;
|
||||
int Scale = computeScale(
|
||||
BasePtr->getType()->getPointerElementType()->getPrimitiveSizeInBits(),
|
||||
MemoryTy->getScalarSizeInBits());
|
||||
int Scale =
|
||||
computeScale(GEP->getSourceElementType()->getPrimitiveSizeInBits(),
|
||||
MemoryTy->getScalarSizeInBits());
|
||||
if (Scale == -1)
|
||||
return nullptr;
|
||||
|
||||
@ -1143,9 +1143,8 @@ bool MVEGatherScatterLowering::optimiseAddress(Value *Address, BasicBlock *BB,
|
||||
// (always i32 if it is not of vector type) and the base has to be a
|
||||
// pointer.
|
||||
if (Offsets && Base && Base != GEP) {
|
||||
PointerType *BaseType = cast<PointerType>(Base->getType());
|
||||
GetElementPtrInst *NewAddress = GetElementPtrInst::Create(
|
||||
BaseType->getPointerElementType(), Base, Offsets, "gep.merged", GEP);
|
||||
GEP->getSourceElementType(), Base, Offsets, "gep.merged", GEP);
|
||||
GEP->replaceAllUsesWith(NewAddress);
|
||||
GEP = NewAddress;
|
||||
Changed = true;
|
||||
|
@ -1321,8 +1321,7 @@ auto HexagonVectorCombine::calculatePointerDifference(Value *Ptr0,
|
||||
return None;
|
||||
|
||||
Builder B(Gep0->getParent());
|
||||
Value *BasePtr = Gep0->getPointerOperand();
|
||||
int Scale = DL.getTypeStoreSize(BasePtr->getType()->getPointerElementType());
|
||||
int Scale = DL.getTypeStoreSize(Gep0->getSourceElementType());
|
||||
|
||||
// FIXME: for now only check GEPs with a single index.
|
||||
if (Gep0->getNumOperands() != 2 || Gep1->getNumOperands() != 2)
|
||||
|
Loading…
Reference in New Issue
Block a user