diff options
author | Youngsuk Kim <youngsuk.kim@hpe.com> | 2023-06-30 17:33:28 -0400 |
---|---|---|
committer | JOE1994 <joseph942010@gmail.com> | 2023-06-30 17:35:36 -0400 |
commit | 5f32baf17db172478f1081e3d345f08e1053579f (patch) | |
tree | e5213188be44bf15ea8866319e1eb723104c0a8f /clang/lib/CodeGen/CGClass.cpp | |
parent | a63d6a00140d25289e0cba294c9228dbb74b06fa (diff) | |
download | llvm-5f32baf17db172478f1081e3d345f08e1053579f.zip llvm-5f32baf17db172478f1081e3d345f08e1053579f.tar.gz llvm-5f32baf17db172478f1081e3d345f08e1053579f.tar.bz2 |
[clang] Replace uses of CreateElementBitCast (NFC)
Partial progress towards replacing uses of CreateElementBitCast, as it
no longer does what its name suggests.
Reviewed By: barannikov88
Differential Revision: https://reviews.llvm.org/D154229
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGClass.cpp | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp index 4bc8001..93e7b54 100644 --- a/clang/lib/CodeGen/CGClass.cpp +++ b/clang/lib/CodeGen/CGClass.cpp @@ -236,12 +236,10 @@ CodeGenFunction::GetAddressOfDirectBaseInCompleteClass(Address This, // TODO: for complete types, this should be possible with a GEP. Address V = This; if (!Offset.isZero()) { - V = Builder.CreateElementBitCast(V, Int8Ty); + V = V.withElementType(Int8Ty); V = Builder.CreateConstInBoundsByteGEP(V, Offset); } - V = Builder.CreateElementBitCast(V, ConvertType(Base)); - - return V; + return V.withElementType(ConvertType(Base)); } static Address @@ -342,7 +340,7 @@ Address CodeGenFunction::GetAddressOfBaseClass( EmitTypeCheck(TCK_Upcast, Loc, Value.getPointer(), DerivedTy, DerivedAlign, SkippedChecks); } - return Builder.CreateElementBitCast(Value, BaseValueTy); + return Value.withElementType(BaseValueTy); } llvm::BasicBlock *origBB = nullptr; @@ -379,7 +377,7 @@ Address CodeGenFunction::GetAddressOfBaseClass( VirtualOffset, Derived, VBase); // Cast to the destination type. - Value = Builder.CreateElementBitCast(Value, BaseValueTy); + Value = Value.withElementType(BaseValueTy); // Build a phi if we needed a null check. if (NullCheckValue) { @@ -416,7 +414,7 @@ CodeGenFunction::GetAddressOfDerivedClass(Address BaseAddr, if (!NonVirtualOffset) { // No offset, we can just cast back. - return Builder.CreateElementBitCast(BaseAddr, DerivedValueTy); + return BaseAddr.withElementType(DerivedValueTy); } llvm::BasicBlock *CastNull = nullptr; @@ -997,8 +995,8 @@ namespace { private: void emitMemcpyIR(Address DestPtr, Address SrcPtr, CharUnits Size) { - DestPtr = CGF.Builder.CreateElementBitCast(DestPtr, CGF.Int8Ty); - SrcPtr = CGF.Builder.CreateElementBitCast(SrcPtr, CGF.Int8Ty); + DestPtr = DestPtr.withElementType(CGF.Int8Ty); + SrcPtr = SrcPtr.withElementType(CGF.Int8Ty); CGF.Builder.CreateMemCpy(DestPtr, SrcPtr, Size.getQuantity()); } @@ -2581,7 +2579,7 @@ void CodeGenFunction::InitializeVTablePointer(const VPtr &Vptr) { llvm::Type *PtrTy = llvm::PointerType::get(CGM.getLLVMContext(), GlobalsAS); // vtable field is derived from `this` pointer, therefore they should be in // the same addr space. Note that this might not be LLVM address space 0. - VTableField = Builder.CreateElementBitCast(VTableField, PtrTy); + VTableField = VTableField.withElementType(PtrTy); llvm::StoreInst *Store = Builder.CreateStore(VTableAddressPoint, VTableField); TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(PtrTy); @@ -2677,7 +2675,7 @@ void CodeGenFunction::InitializeVTablePointers(const CXXRecordDecl *RD) { llvm::Value *CodeGenFunction::GetVTablePtr(Address This, llvm::Type *VTableTy, const CXXRecordDecl *RD) { - Address VTablePtrSrc = Builder.CreateElementBitCast(This, VTableTy); + Address VTablePtrSrc = This.withElementType(VTableTy); llvm::Instruction *VTable = Builder.CreateLoad(VTablePtrSrc, "vtable"); TBAAAccessInfo TBAAInfo = CGM.getTBAAVTablePtrAccessInfo(VTableTy); CGM.DecorateInstructionWithTBAA(VTable, TBAAInfo); |