forked from OSchip/llvm-project
[CodeGen] Avoid some pointer element type accesses
Possibly this is sufficient to fix PR53089.
This commit is contained in:
parent
7893bb7408
commit
7725331ccd
|
@ -4699,12 +4699,9 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
|
|||
if (LV.isSimple()) {
|
||||
Address V = LV.getAddress(*this);
|
||||
if (V.isValid()) {
|
||||
llvm::Type *T =
|
||||
ConvertTypeForMem(E->getType())
|
||||
->getPointerTo(
|
||||
cast<llvm::PointerType>(V.getType())->getAddressSpace());
|
||||
if (V.getType() != T)
|
||||
LV.setAddress(Builder.CreateBitCast(V, T));
|
||||
llvm::Type *T = ConvertTypeForMem(E->getType());
|
||||
if (V.getElementType() != T)
|
||||
LV.setAddress(Builder.CreateElementBitCast(V, T));
|
||||
}
|
||||
}
|
||||
return LV;
|
||||
|
@ -4763,8 +4760,9 @@ LValue CodeGenFunction::EmitCastLValue(const CastExpr *E) {
|
|||
|
||||
CGM.EmitExplicitCastExprType(CE, this);
|
||||
LValue LV = EmitLValue(E->getSubExpr());
|
||||
Address V = Builder.CreateBitCast(LV.getAddress(*this),
|
||||
ConvertType(CE->getTypeAsWritten()));
|
||||
Address V = Builder.CreateElementBitCast(
|
||||
LV.getAddress(*this),
|
||||
ConvertTypeForMem(CE->getTypeAsWritten()->getPointeeType()));
|
||||
|
||||
if (SanOpts.has(SanitizerKind::CFIUnrelatedCast))
|
||||
EmitVTablePtrCheckForCast(E->getType(), V.getPointer(),
|
||||
|
|
Loading…
Reference in New Issue