forked from OSchip/llvm-project
[Attributor] Avoid some pointer element type accesses
This commit is contained in:
parent
1f9e18b656
commit
e7762653d3
|
@ -1216,7 +1216,7 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl {
|
||||||
}
|
}
|
||||||
UsrOI.Offset = PtrOI.Offset +
|
UsrOI.Offset = PtrOI.Offset +
|
||||||
DL.getIndexedOffsetInType(
|
DL.getIndexedOffsetInType(
|
||||||
CurPtr->getType()->getPointerElementType(), Indices);
|
GEP->getSourceElementType(), Indices);
|
||||||
Follow = true;
|
Follow = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -6650,9 +6650,10 @@ struct AAPrivatizablePtrArgument final : public AAPrivatizablePtrImpl {
|
||||||
IRBuilder<NoFolder> IRB(IP);
|
IRBuilder<NoFolder> IRB(IP);
|
||||||
const DataLayout &DL = IP->getModule()->getDataLayout();
|
const DataLayout &DL = IP->getModule()->getDataLayout();
|
||||||
|
|
||||||
if (Base->getType()->getPointerElementType() != PrivType)
|
Type *PrivPtrType = PrivType->getPointerTo();
|
||||||
Base = BitCastInst::CreateBitOrPointerCast(Base, PrivType->getPointerTo(),
|
if (Base->getType() != PrivPtrType)
|
||||||
"", ACS.getInstruction());
|
Base = BitCastInst::CreateBitOrPointerCast(Base, PrivPtrType, "",
|
||||||
|
ACS.getInstruction());
|
||||||
|
|
||||||
// Traverse the type, build GEPs and loads.
|
// Traverse the type, build GEPs and loads.
|
||||||
if (auto *PrivStructType = dyn_cast<StructType>(PrivType)) {
|
if (auto *PrivStructType = dyn_cast<StructType>(PrivType)) {
|
||||||
|
@ -6794,7 +6795,7 @@ struct AAPrivatizablePtrFloating : public AAPrivatizablePtrImpl {
|
||||||
if (auto *AI = dyn_cast<AllocaInst>(Obj))
|
if (auto *AI = dyn_cast<AllocaInst>(Obj))
|
||||||
if (auto *CI = dyn_cast<ConstantInt>(AI->getArraySize()))
|
if (auto *CI = dyn_cast<ConstantInt>(AI->getArraySize()))
|
||||||
if (CI->isOne())
|
if (CI->isOne())
|
||||||
return Obj->getType()->getPointerElementType();
|
return AI->getAllocatedType();
|
||||||
if (auto *Arg = dyn_cast<Argument>(Obj)) {
|
if (auto *Arg = dyn_cast<Argument>(Obj)) {
|
||||||
auto &PrivArgAA = A.getAAFor<AAPrivatizablePtr>(
|
auto &PrivArgAA = A.getAAFor<AAPrivatizablePtr>(
|
||||||
*this, IRPosition::argument(*Arg), DepClassTy::REQUIRED);
|
*this, IRPosition::argument(*Arg), DepClassTy::REQUIRED);
|
||||||
|
|
Loading…
Reference in New Issue