aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2021-03-11 18:59:49 +0100
committerNikita Popov <nikita.ppv@gmail.com>2021-03-12 21:01:16 +0100
commit42eb658f656c43ee63e25222f32abbbbcb86ad7b (patch)
tree42f25f9b87040f2e894efccf389ae676f52175c1 /clang/lib/CodeGen/CGClass.cpp
parent51151828acad6b1e5b0719285ce7172506877fd1 (diff)
downloadllvm-42eb658f656c43ee63e25222f32abbbbcb86ad7b.zip
llvm-42eb658f656c43ee63e25222f32abbbbcb86ad7b.tar.gz
llvm-42eb658f656c43ee63e25222f32abbbbcb86ad7b.tar.bz2
[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/CGClass.cpp')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index e687a0d..7fcc84b 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -272,7 +272,7 @@ ApplyNonVirtualAndVirtualOffset(CodeGenFunction &CGF, Address addr,
llvm::Value *ptr = addr.getPointer();
unsigned AddrSpace = ptr->getType()->getPointerAddressSpace();
ptr = CGF.Builder.CreateBitCast(ptr, CGF.Int8Ty->getPointerTo(AddrSpace));
- ptr = CGF.Builder.CreateInBoundsGEP(ptr, baseOffset, "add.ptr");
+ ptr = CGF.Builder.CreateInBoundsGEP(CGF.Int8Ty, ptr, baseOffset, "add.ptr");
// If we have a virtual component, the alignment of the result will
// be relative only to the known alignment of that vbase.
@@ -434,8 +434,8 @@ CodeGenFunction::GetAddressOfDerivedClass(Address BaseAddr,
// Apply the offset.
llvm::Value *Value = Builder.CreateBitCast(BaseAddr.getPointer(), Int8PtrTy);
- Value = Builder.CreateInBoundsGEP(Value, Builder.CreateNeg(NonVirtualOffset),
- "sub.ptr");
+ Value = Builder.CreateInBoundsGEP(
+ Int8Ty, Value, Builder.CreateNeg(NonVirtualOffset), "sub.ptr");
// Just cast.
Value = Builder.CreateBitCast(Value, DerivedPtrTy);
@@ -1963,9 +1963,10 @@ void CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *ctor,
}
// Find the end of the array.
+ llvm::Type *elementType = arrayBase.getElementType();
llvm::Value *arrayBegin = arrayBase.getPointer();
- llvm::Value *arrayEnd = Builder.CreateInBoundsGEP(arrayBegin, numElements,
- "arrayctor.end");
+ llvm::Value *arrayEnd = Builder.CreateInBoundsGEP(
+ elementType, arrayBegin, numElements, "arrayctor.end");
// Enter the loop, setting up a phi for the current location to initialize.
llvm::BasicBlock *entryBB = Builder.GetInsertBlock();
@@ -2023,9 +2024,8 @@ void CodeGenFunction::EmitCXXAggrConstructorCall(const CXXConstructorDecl *ctor,
}
// Go to the next element.
- llvm::Value *next =
- Builder.CreateInBoundsGEP(cur, llvm::ConstantInt::get(SizeTy, 1),
- "arrayctor.next");
+ llvm::Value *next = Builder.CreateInBoundsGEP(
+ elementType, cur, llvm::ConstantInt::get(SizeTy, 1), "arrayctor.next");
cur->addIncoming(next, Builder.GetInsertBlock());
// Check whether that's the end of the loop.