From 42eb658f656c43ee63e25222f32abbbbcb86ad7b Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Mar 2021 18:59:49 +0100 Subject: [OpaquePtrs] Remove some uses of type-less CreateGEP() (NFC) This removes some (but not all) uses of type-less CreateGEP() and CreateInBoundsGEP() APIs, which are incompatible with opaque pointers. There are a still a number of tricky uses left, as well as many more variation APIs for CreateGEP. --- clang/lib/CodeGen/CGExpr.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'clang/lib/CodeGen/CGExpr.cpp') diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index b5bfae914ba4..18f1468dcb86 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -851,10 +851,9 @@ void CodeGenFunction::EmitTypeCheck(TypeCheckKind TCK, SourceLocation Loc, llvm::ConstantInt::get(IntPtrTy, CacheSize-1)); llvm::Value *Indices[] = { Builder.getInt32(0), Slot }; - llvm::Value *CacheVal = - Builder.CreateAlignedLoad(IntPtrTy, - Builder.CreateInBoundsGEP(Cache, Indices), - getPointerAlign()); + llvm::Value *CacheVal = Builder.CreateAlignedLoad( + IntPtrTy, Builder.CreateInBoundsGEP(HashTable, Cache, Indices), + getPointerAlign()); // If the hash isn't in the cache, call a runtime handler to perform the // hard work of checking whether the vptr is for an object of the right @@ -3569,6 +3568,7 @@ static const Expr *isSimpleArrayDecayOperand(const Expr *E) { } static llvm::Value *emitArraySubscriptGEP(CodeGenFunction &CGF, + llvm::Type *elemType, llvm::Value *ptr, ArrayRef indices, bool inbounds, @@ -3580,7 +3580,7 @@ static llvm::Value *emitArraySubscriptGEP(CodeGenFunction &CGF, CodeGenFunction::NotSubtraction, loc, name); } else { - return CGF.Builder.CreateGEP(ptr, indices, name); + return CGF.Builder.CreateGEP(elemType, ptr, indices, name); } } @@ -3674,8 +3674,8 @@ static Address emitArraySubscriptGEP(CodeGenFunction &CGF, Address addr, if (!LastIndex || (!CGF.IsInPreservedAIRegion && !IsPreserveAIArrayBase(CGF, Base))) { eltPtr = emitArraySubscriptGEP( - CGF, addr.getPointer(), indices, inbounds, signedIndices, - loc, name); + CGF, addr.getElementType(), addr.getPointer(), indices, inbounds, + signedIndices, loc, name); } else { // Remember the original array subscript for bpf target unsigned idx = LastIndex->getZExtValue(); @@ -3800,8 +3800,8 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E, CharUnits EltAlign = getArrayElementAlign(Addr.getAlignment(), Idx, InterfaceSize); llvm::Value *EltPtr = - emitArraySubscriptGEP(*this, Addr.getPointer(), ScaledIdx, false, - SignedIndices, E->getExprLoc()); + emitArraySubscriptGEP(*this, Addr.getElementType(), Addr.getPointer(), + ScaledIdx, false, SignedIndices, E->getExprLoc()); Addr = Address(EltPtr, EltAlign); // Cast back. -- cgit v1.2.3