diff options
| author | Nikita Popov <npopov@redhat.com> | 2022-03-17 14:54:18 +0100 |
|---|---|---|
| committer | Nikita Popov <npopov@redhat.com> | 2022-03-17 15:25:55 +0100 |
| commit | bf1a99861c2e98cfd85792fdefe2ef9c7ec11f52 (patch) | |
| tree | d49f6fceb9496af950384e924f957983c401abcf /clang/lib/CodeGen/CGExprScalar.cpp | |
| parent | cbe1e67eade900fa73f29b88ab49fcb6fc29bbb0 (diff) | |
[CodeGen] Avoid some pointer element type accesses
Diffstat (limited to 'clang/lib/CodeGen/CGExprScalar.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 18f0dacdb3c8..18a22b50f63e 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -2641,7 +2641,7 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const UnaryOperator *E, LValue LV, = CGF.getContext().getAsVariableArrayType(type)) { llvm::Value *numElts = CGF.getVLASize(vla).NumElts; if (!isInc) numElts = Builder.CreateNSWNeg(numElts, "vla.negsize"); - llvm::Type *elemTy = value->getType()->getPointerElementType(); + llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType()); if (CGF.getLangOpts().isSignedOverflowDefined()) value = Builder.CreateGEP(elemTy, value, numElts, "vla.inc"); else @@ -3519,7 +3519,7 @@ static Value *emitPointerArithmetic(CodeGenFunction &CGF, // GEP indexes are signed, and scaling an index isn't permitted to // signed-overflow, so we use the same semantics for our explicit // multiply. We suppress this if overflow is not undefined behavior. - llvm::Type *elemTy = pointer->getType()->getPointerElementType(); + llvm::Type *elemTy = CGF.ConvertTypeForMem(vla->getElementType()); if (CGF.getLangOpts().isSignedOverflowDefined()) { index = CGF.Builder.CreateMul(index, numElements, "vla.index"); pointer = CGF.Builder.CreateGEP(elemTy, pointer, index, "add.ptr"); |
