diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-11 18:59:49 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2021-03-12 21:01:16 +0100 |
| commit | 42eb658f656c43ee63e25222f32abbbbcb86ad7b (patch) | |
| tree | 42f25f9b87040f2e894efccf389ae676f52175c1 /clang/lib/CodeGen/CGExpr.cpp | |
| parent | 51151828acad6b1e5b0719285ce7172506877fd1 (diff) | |
[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.
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 18 |
1 files changed, 9 insertions, 9 deletions
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<llvm::Value*> 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. |
