forked from OSchip/llvm-project
[CodeGen] Avoid more pointer element type accesses
This commit is contained in:
parent
2e630eabd3
commit
1f07a4a569
|
@ -390,7 +390,7 @@ Address CodeGenFunction::GetAddressOfBaseClass(
|
|||
llvm::PHINode *PHI = Builder.CreatePHI(BasePtrTy, 2, "cast.result");
|
||||
PHI->addIncoming(Value.getPointer(), notNullBB);
|
||||
PHI->addIncoming(llvm::Constant::getNullValue(BasePtrTy), origBB);
|
||||
Value = Address(PHI, Value.getAlignment());
|
||||
Value = Value.withPointer(PHI);
|
||||
}
|
||||
|
||||
return Value;
|
||||
|
@ -1983,7 +1983,7 @@ void CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *ctor,
|
|||
CharUnits eltAlignment =
|
||||
arrayBase.getAlignment()
|
||||
.alignmentOfArrayElement(getContext().getTypeSizeInChars(type));
|
||||
Address curAddr = Address(cur, eltAlignment);
|
||||
Address curAddr = Address(cur, elementType, eltAlignment);
|
||||
|
||||
// Zero initialize the storage, if requested.
|
||||
if (zeroInitialize)
|
||||
|
|
|
@ -614,8 +614,8 @@ void AggExprEmitter::EmitArrayInit(Address DestPtr, llvm::ArrayType *AType,
|
|||
// every temporary created in a default argument is sequenced before
|
||||
// the construction of the next array element, if any
|
||||
CodeGenFunction::RunCleanupsScope CleanupsScope(CGF);
|
||||
LValue elementLV =
|
||||
CGF.MakeAddrLValue(Address(currentElement, elementAlign), elementType);
|
||||
LValue elementLV = CGF.MakeAddrLValue(
|
||||
Address(currentElement, llvmElementType, elementAlign), elementType);
|
||||
if (filler)
|
||||
EmitInitializationToLValue(filler, elementLV);
|
||||
else
|
||||
|
@ -1801,6 +1801,7 @@ void AggExprEmitter::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E,
|
|||
CharUnits elementSize = CGF.getContext().getTypeSizeInChars(elementType);
|
||||
CharUnits elementAlign =
|
||||
destPtr.getAlignment().alignmentOfArrayElement(elementSize);
|
||||
llvm::Type *llvmElementType = CGF.ConvertTypeForMem(elementType);
|
||||
|
||||
llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
|
||||
llvm::BasicBlock *bodyBB = CGF.createBasicBlock("arrayinit.body");
|
||||
|
@ -1810,8 +1811,8 @@ void AggExprEmitter::VisitArrayInitLoopExpr(const ArrayInitLoopExpr *E,
|
|||
llvm::PHINode *index =
|
||||
Builder.CreatePHI(zero->getType(), 2, "arrayinit.index");
|
||||
index->addIncoming(zero, entryBB);
|
||||
llvm::Value *element = Builder.CreateInBoundsGEP(
|
||||
begin->getType()->getPointerElementType(), begin, index);
|
||||
llvm::Value *element =
|
||||
Builder.CreateInBoundsGEP(llvmElementType, begin, index);
|
||||
|
||||
// Prepare for a cleanup.
|
||||
QualType::DestructionKind dtorKind = elementType.isDestructedType();
|
||||
|
|
|
@ -182,6 +182,7 @@ template <> struct DominatingValue<Address> {
|
|||
|
||||
struct saved_type {
|
||||
DominatingLLVMValue::saved_type SavedValue;
|
||||
llvm::Type *ElementType;
|
||||
CharUnits Alignment;
|
||||
};
|
||||
|
||||
|
@ -190,11 +191,11 @@ template <> struct DominatingValue<Address> {
|
|||
}
|
||||
static saved_type save(CodeGenFunction &CGF, type value) {
|
||||
return { DominatingLLVMValue::save(CGF, value.getPointer()),
|
||||
value.getAlignment() };
|
||||
value.getElementType(), value.getAlignment() };
|
||||
}
|
||||
static type restore(CodeGenFunction &CGF, saved_type value) {
|
||||
return Address(DominatingLLVMValue::restore(CGF, value.SavedValue),
|
||||
value.Alignment);
|
||||
value.ElementType, value.Alignment);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -697,8 +697,8 @@ CGCallee ItaniumCXXABI::EmitLoadOfMemberFunctionPointer(
|
|||
CharUnits VTablePtrAlign =
|
||||
CGF.CGM.getDynamicOffsetAlignment(ThisAddr.getAlignment(), RD,
|
||||
CGF.getPointerAlign());
|
||||
llvm::Value *VTable =
|
||||
CGF.GetVTablePtr(Address(This, VTablePtrAlign), VTableTy, RD);
|
||||
llvm::Value *VTable = CGF.GetVTablePtr(
|
||||
Address(This, ThisAddr.getElementType(), VTablePtrAlign), VTableTy, RD);
|
||||
|
||||
// Apply the offset.
|
||||
// On ARM64, to reserve extra space in virtual member function pointers,
|
||||
|
|
Loading…
Reference in New Issue