forked from OSchip/llvm-project
[CodeGen] Avoid pointer element type access when creating LValue
This required fixing two places that were passing the pointer type rather than the expected pointee type to the method.
This commit is contained in:
parent
33319dde2a
commit
09669e6c5f
|
@ -1309,7 +1309,8 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) {
|
|||
const ConstantExpr *CE = cast<ConstantExpr>(E);
|
||||
if (llvm::Value *Result = ConstantEmitter(*this).tryEmitConstantExpr(CE)) {
|
||||
QualType RetType = cast<CallExpr>(CE->getSubExpr()->IgnoreImplicit())
|
||||
->getCallReturnType(getContext());
|
||||
->getCallReturnType(getContext())
|
||||
->getPointeeType();
|
||||
return MakeNaturalAlignAddrLValue(Result, RetType);
|
||||
}
|
||||
return EmitLValue(cast<ConstantExpr>(E)->getSubExpr());
|
||||
|
|
|
@ -5945,7 +5945,7 @@ static llvm::Value *emitReduceInitFunction(CodeGenModule &CGM,
|
|||
} else {
|
||||
OrigLVal = CGF.MakeNaturalAlignAddrLValue(
|
||||
llvm::ConstantPointerNull::get(CGM.VoidPtrTy),
|
||||
CGM.getContext().VoidPtrTy);
|
||||
CGM.getContext().VoidTy);
|
||||
}
|
||||
// Emit the initializer:
|
||||
// %0 = bitcast void* %arg to <type>*
|
||||
|
|
|
@ -188,8 +188,8 @@ LValue CodeGenFunction::MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) {
|
|||
LValueBaseInfo BaseInfo;
|
||||
TBAAAccessInfo TBAAInfo;
|
||||
CharUnits Alignment = CGM.getNaturalTypeAlignment(T, &BaseInfo, &TBAAInfo);
|
||||
return LValue::MakeAddr(Address(V, Alignment), T, getContext(), BaseInfo,
|
||||
TBAAInfo);
|
||||
Address Addr(V, ConvertTypeForMem(T), Alignment);
|
||||
return LValue::MakeAddr(Addr, T, getContext(), BaseInfo, TBAAInfo);
|
||||
}
|
||||
|
||||
/// Given a value of type T* that may not be to a complete object,
|
||||
|
|
Loading…
Reference in New Issue