Skip to content

Commit 474ec69

Browse files
committed
[clang] Replace uses of CGBuilderTy::CreateElementBitCast (NFC)
Partial progress towards replacing `CreateElementBitCast`, as it no longer does what its name suggests. Either replace its uses with `Address::withElementType()`, or remove them if no longer needed. Reviewed By: barannikov88, nikic Differential Revision: https://reviews.llvm.org/D153314
1 parent 2325e01 commit 474ec69

File tree

10 files changed

+86
-118
lines changed

10 files changed

+86
-118
lines changed

clang/lib/CodeGen/CGAtomic.cpp

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ namespace {
162162
}
163163

164164
Address getAtomicAddressAsAtomicIntPointer() const {
165-
return emitCastToAtomicIntPointer(getAtomicAddress());
165+
return castToAtomicIntPointer(getAtomicAddress());
166166
}
167167

168168
/// Is the atomic size larger than the underlying value type?
@@ -184,7 +184,7 @@ namespace {
184184

185185
/// Cast the given pointer to an integer pointer suitable for atomic
186186
/// operations if the source.
187-
Address emitCastToAtomicIntPointer(Address Addr) const;
187+
Address castToAtomicIntPointer(Address Addr) const;
188188

189189
/// If Addr is compatible with the iN that will be used for an atomic
190190
/// operation, bitcast it. Otherwise, create a temporary that is suitable
@@ -979,21 +979,21 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
979979
AtomicInfo Atomics(*this, AtomicVal);
980980

981981
if (ShouldCastToIntPtrTy) {
982-
Ptr = Atomics.emitCastToAtomicIntPointer(Ptr);
982+
Ptr = Atomics.castToAtomicIntPointer(Ptr);
983983
if (Val1.isValid())
984984
Val1 = Atomics.convertToAtomicIntPointer(Val1);
985985
if (Val2.isValid())
986986
Val2 = Atomics.convertToAtomicIntPointer(Val2);
987987
}
988988
if (Dest.isValid()) {
989989
if (ShouldCastToIntPtrTy)
990-
Dest = Atomics.emitCastToAtomicIntPointer(Dest);
990+
Dest = Atomics.castToAtomicIntPointer(Dest);
991991
} else if (E->isCmpXChg())
992992
Dest = CreateMemTemp(RValTy, "cmpxchg.bool");
993993
else if (!RValTy->isVoidType()) {
994994
Dest = Atomics.CreateTempAlloca();
995995
if (ShouldCastToIntPtrTy)
996-
Dest = Atomics.emitCastToAtomicIntPointer(Dest);
996+
Dest = Atomics.castToAtomicIntPointer(Dest);
997997
}
998998

999999
// Use a library call. See: http://gcc.gnu.org/wiki/Atomic/GCCMM/LIbrary .
@@ -1338,16 +1338,14 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
13381338
if (E->getOp() == AtomicExpr::AO__atomic_nand_fetch)
13391339
ResVal = Builder.CreateNot(ResVal);
13401340

1341-
Builder.CreateStore(
1342-
ResVal, Builder.CreateElementBitCast(Dest, ResVal->getType()));
1341+
Builder.CreateStore(ResVal, Dest.withElementType(ResVal->getType()));
13431342
}
13441343

13451344
if (RValTy->isVoidType())
13461345
return RValue::get(nullptr);
13471346

1348-
return convertTempToRValue(
1349-
Builder.CreateElementBitCast(Dest, ConvertTypeForMem(RValTy)),
1350-
RValTy, E->getExprLoc());
1347+
return convertTempToRValue(Dest.withElementType(ConvertTypeForMem(RValTy)),
1348+
RValTy, E->getExprLoc());
13511349
}
13521350

13531351
bool IsStore = E->getOp() == AtomicExpr::AO__c11_atomic_store ||
@@ -1398,9 +1396,8 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
13981396
if (RValTy->isVoidType())
13991397
return RValue::get(nullptr);
14001398

1401-
return convertTempToRValue(
1402-
Builder.CreateElementBitCast(Dest, ConvertTypeForMem(RValTy)),
1403-
RValTy, E->getExprLoc());
1399+
return convertTempToRValue(Dest.withElementType(ConvertTypeForMem(RValTy)),
1400+
RValTy, E->getExprLoc());
14041401
}
14051402

14061403
// Long case, when Order isn't obviously constant.
@@ -1470,15 +1467,14 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E) {
14701467
return RValue::get(nullptr);
14711468

14721469
assert(Atomics.getValueSizeInBits() <= Atomics.getAtomicSizeInBits());
1473-
return convertTempToRValue(
1474-
Builder.CreateElementBitCast(Dest, ConvertTypeForMem(RValTy)),
1475-
RValTy, E->getExprLoc());
1470+
return convertTempToRValue(Dest.withElementType(ConvertTypeForMem(RValTy)),
1471+
RValTy, E->getExprLoc());
14761472
}
14771473

1478-
Address AtomicInfo::emitCastToAtomicIntPointer(Address addr) const {
1474+
Address AtomicInfo::castToAtomicIntPointer(Address addr) const {
14791475
llvm::IntegerType *ty =
14801476
llvm::IntegerType::get(CGF.getLLVMContext(), AtomicSizeInBits);
1481-
return CGF.Builder.CreateElementBitCast(addr, ty);
1477+
return addr.withElementType(ty);
14821478
}
14831479

14841480
Address AtomicInfo::convertToAtomicIntPointer(Address Addr) const {
@@ -1491,7 +1487,7 @@ Address AtomicInfo::convertToAtomicIntPointer(Address Addr) const {
14911487
Addr = Tmp;
14921488
}
14931489

1494-
return emitCastToAtomicIntPointer(Addr);
1490+
return castToAtomicIntPointer(Addr);
14951491
}
14961492

14971493
RValue AtomicInfo::convertAtomicTempToRValue(Address addr,
@@ -1563,7 +1559,7 @@ RValue AtomicInfo::ConvertIntToValueOrAtomic(llvm::Value *IntVal,
15631559
}
15641560

15651561
// Slam the integer into the temporary.
1566-
Address CastTemp = emitCastToAtomicIntPointer(Temp);
1562+
Address CastTemp = castToAtomicIntPointer(Temp);
15671563
CGF.Builder.CreateStore(IntVal, CastTemp)
15681564
->setVolatile(TempIsVolatile);
15691565

@@ -1741,7 +1737,7 @@ llvm::Value *AtomicInfo::convertRValueToInt(RValue RVal) const {
17411737
Address Addr = materializeRValue(RVal);
17421738

17431739
// Cast the temporary to the atomic int type and pull a value out.
1744-
Addr = emitCastToAtomicIntPointer(Addr);
1740+
Addr = castToAtomicIntPointer(Addr);
17451741
return CGF.Builder.CreateLoad(Addr);
17461742
}
17471743

@@ -1919,7 +1915,7 @@ void AtomicInfo::EmitAtomicUpdateOp(
19191915
/*NumReservedValues=*/2);
19201916
PHI->addIncoming(OldVal, CurBB);
19211917
Address NewAtomicAddr = CreateTempAlloca();
1922-
Address NewAtomicIntAddr = emitCastToAtomicIntPointer(NewAtomicAddr);
1918+
Address NewAtomicIntAddr = castToAtomicIntPointer(NewAtomicAddr);
19231919
if ((LVal.isBitField() && BFI.Size != ValueSizeInBits) ||
19241920
requiresMemSetZero(getAtomicAddress().getElementType())) {
19251921
CGF.Builder.CreateStore(PHI, NewAtomicIntAddr);
@@ -2001,7 +1997,7 @@ void AtomicInfo::EmitAtomicUpdateOp(llvm::AtomicOrdering AO, RValue UpdateRVal,
20011997
/*NumReservedValues=*/2);
20021998
PHI->addIncoming(OldVal, CurBB);
20031999
Address NewAtomicAddr = CreateTempAlloca();
2004-
Address NewAtomicIntAddr = emitCastToAtomicIntPointer(NewAtomicAddr);
2000+
Address NewAtomicIntAddr = castToAtomicIntPointer(NewAtomicAddr);
20052001
if ((LVal.isBitField() && BFI.Size != ValueSizeInBits) ||
20062002
requiresMemSetZero(getAtomicAddress().getElementType())) {
20072003
CGF.Builder.CreateStore(PHI, NewAtomicIntAddr);
@@ -2095,8 +2091,7 @@ void CodeGenFunction::EmitAtomicStore(RValue rvalue, LValue dest,
20952091
llvm::Value *intValue = atomics.convertRValueToInt(rvalue);
20962092

20972093
// Do the atomic store.
2098-
Address addr =
2099-
atomics.emitCastToAtomicIntPointer(atomics.getAtomicAddress());
2094+
Address addr = atomics.castToAtomicIntPointer(atomics.getAtomicAddress());
21002095
intValue = Builder.CreateIntCast(
21012096
intValue, addr.getElementType(), /*isSigned=*/false);
21022097
llvm::StoreInst *store = Builder.CreateStore(intValue, addr);

clang/lib/CodeGen/CGCXXABI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ void CGCXXABI::ReadArrayCookie(CodeGenFunction &CGF, Address ptr,
247247
llvm::Value *&numElements,
248248
llvm::Value *&allocPtr, CharUnits &cookieSize) {
249249
// Derive a char* in the same address space as the pointer.
250-
ptr = CGF.Builder.CreateElementBitCast(ptr, CGF.Int8Ty);
250+
ptr = ptr.withElementType(CGF.Int8Ty);
251251

252252
// If we don't need an array cookie, bail out early.
253253
if (!requiresArrayCookie(expr, eltTy)) {

clang/lib/CodeGen/CGNonTrivialStruct.cpp

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,8 @@ template <class Derived> struct GenFuncBase {
365365
llvm::ConstantInt::get(NumElts->getType(), BaseEltSize);
366366
llvm::Value *SizeInBytes =
367367
CGF.Builder.CreateNUWMul(BaseEltSizeVal, NumElts);
368-
Address BC = CGF.Builder.CreateElementBitCast(DstAddr, CGF.CGM.Int8Ty);
369-
llvm::Value *DstArrayEnd =
370-
CGF.Builder.CreateInBoundsGEP(CGF.Int8Ty, BC.getPointer(), SizeInBytes);
368+
llvm::Value *DstArrayEnd = CGF.Builder.CreateInBoundsGEP(
369+
CGF.Int8Ty, DstAddr.getPointer(), SizeInBytes);
371370
DstArrayEnd = CGF.Builder.CreateBitCast(
372371
DstArrayEnd, CGF.CGM.Int8PtrPtrTy, "dstarray.end");
373372
llvm::BasicBlock *PreheaderBB = CGF.Builder.GetInsertBlock();
@@ -426,9 +425,9 @@ template <class Derived> struct GenFuncBase {
426425
assert(Addr.isValid() && "invalid address");
427426
if (Offset.getQuantity() == 0)
428427
return Addr;
429-
Addr = CGF->Builder.CreateElementBitCast(Addr, CGF->CGM.Int8Ty);
428+
Addr = Addr.withElementType(CGF->CGM.Int8Ty);
430429
Addr = CGF->Builder.CreateConstInBoundsGEP(Addr, Offset.getQuantity());
431-
return CGF->Builder.CreateElementBitCast(Addr, CGF->CGM.Int8PtrTy);
430+
return Addr.withElementType(CGF->CGM.Int8PtrTy);
432431
}
433432

434433
Address getAddrWithOffset(Address Addr, CharUnits StructFieldOffset,
@@ -491,8 +490,7 @@ template <class Derived> struct GenFuncBase {
491490

492491
for (unsigned I = 0; I < N; ++I) {
493492
Alignments[I] = Addrs[I].getAlignment();
494-
Ptrs[I] = CallerCGF.Builder.CreateElementBitCast(
495-
Addrs[I], CallerCGF.CGM.Int8PtrTy).getPointer();
493+
Ptrs[I] = Addrs[I].getPointer();
496494
}
497495

498496
if (llvm::Function *F =
@@ -526,17 +524,15 @@ struct GenBinaryFunc : CopyStructVisitor<Derived, IsMove>,
526524
!llvm::has_single_bit<uint32_t>(Size.getQuantity())) {
527525
llvm::Value *SizeVal =
528526
llvm::ConstantInt::get(this->CGF->SizeTy, Size.getQuantity());
529-
DstAddr =
530-
this->CGF->Builder.CreateElementBitCast(DstAddr, this->CGF->Int8Ty);
531-
SrcAddr =
532-
this->CGF->Builder.CreateElementBitCast(SrcAddr, this->CGF->Int8Ty);
527+
DstAddr = DstAddr.withElementType(this->CGF->Int8Ty);
528+
SrcAddr = SrcAddr.withElementType(this->CGF->Int8Ty);
533529
this->CGF->Builder.CreateMemCpy(DstAddr, SrcAddr, SizeVal, false);
534530
} else {
535531
llvm::Type *Ty = llvm::Type::getIntNTy(
536532
this->CGF->getLLVMContext(),
537533
Size.getQuantity() * this->CGF->getContext().getCharWidth());
538-
DstAddr = this->CGF->Builder.CreateElementBitCast(DstAddr, Ty);
539-
SrcAddr = this->CGF->Builder.CreateElementBitCast(SrcAddr, Ty);
534+
DstAddr = DstAddr.withElementType(Ty);
535+
SrcAddr = SrcAddr.withElementType(Ty);
540536
llvm::Value *SrcVal = this->CGF->Builder.CreateLoad(SrcAddr, false);
541537
this->CGF->Builder.CreateStore(SrcVal, DstAddr, false);
542538
}
@@ -556,19 +552,17 @@ struct GenBinaryFunc : CopyStructVisitor<Derived, IsMove>,
556552
QualType RT = QualType(FD->getParent()->getTypeForDecl(), 0);
557553
llvm::Type *Ty = this->CGF->ConvertType(RT);
558554
Address DstAddr = this->getAddrWithOffset(Addrs[DstIdx], Offset);
559-
LValue DstBase = this->CGF->MakeAddrLValue(
560-
this->CGF->Builder.CreateElementBitCast(DstAddr, Ty), FT);
555+
LValue DstBase =
556+
this->CGF->MakeAddrLValue(DstAddr.withElementType(Ty), FT);
561557
DstLV = this->CGF->EmitLValueForField(DstBase, FD);
562558
Address SrcAddr = this->getAddrWithOffset(Addrs[SrcIdx], Offset);
563-
LValue SrcBase = this->CGF->MakeAddrLValue(
564-
this->CGF->Builder.CreateElementBitCast(SrcAddr, Ty), FT);
559+
LValue SrcBase =
560+
this->CGF->MakeAddrLValue(SrcAddr.withElementType(Ty), FT);
565561
SrcLV = this->CGF->EmitLValueForField(SrcBase, FD);
566562
} else {
567563
llvm::Type *Ty = this->CGF->ConvertTypeForMem(FT);
568-
Address DstAddr =
569-
this->CGF->Builder.CreateElementBitCast(Addrs[DstIdx], Ty);
570-
Address SrcAddr =
571-
this->CGF->Builder.CreateElementBitCast(Addrs[SrcIdx], Ty);
564+
Address DstAddr = Addrs[DstIdx].withElementType(Ty);
565+
Address SrcAddr = Addrs[SrcIdx].withElementType(Ty);
572566
DstLV = this->CGF->MakeAddrLValue(DstAddr, FT);
573567
SrcLV = this->CGF->MakeAddrLValue(SrcAddr, FT);
574568
}
@@ -666,7 +660,7 @@ struct GenDefaultInitialize
666660

667661
llvm::Constant *SizeVal = CGF->Builder.getInt64(Size.getQuantity());
668662
Address DstAddr = getAddrWithOffset(Addrs[DstIdx], CurStructOffset, FD);
669-
Address Loc = CGF->Builder.CreateElementBitCast(DstAddr, CGF->Int8Ty);
663+
Address Loc = DstAddr.withElementType(CGF->Int8Ty);
670664
CGF->Builder.CreateMemSet(Loc, CGF->Builder.getInt8(0), SizeVal,
671665
IsVolatile);
672666
}
@@ -818,8 +812,7 @@ void CodeGenFunction::destroyNonTrivialCStruct(CodeGenFunction &CGF,
818812
// such structure.
819813
void CodeGenFunction::defaultInitNonTrivialCStructVar(LValue Dst) {
820814
GenDefaultInitialize Gen(getContext());
821-
Address DstPtr =
822-
Builder.CreateElementBitCast(Dst.getAddress(*this), CGM.Int8PtrTy);
815+
Address DstPtr = Dst.getAddress(*this).withElementType(CGM.Int8PtrTy);
823816
Gen.setCGF(this);
824817
QualType QT = Dst.getType();
825818
QT = Dst.isVolatile() ? QT.withVolatile() : QT;
@@ -832,7 +825,7 @@ static void callSpecialFunction(G &&Gen, StringRef FuncName, QualType QT,
832825
std::array<Address, N> Addrs) {
833826
auto SetArtificialLoc = ApplyDebugLocation::CreateArtificial(CGF);
834827
for (unsigned I = 0; I < N; ++I)
835-
Addrs[I] = CGF.Builder.CreateElementBitCast(Addrs[I], CGF.CGM.Int8PtrTy);
828+
Addrs[I] = Addrs[I].withElementType(CGF.CGM.Int8PtrTy);
836829
QT = IsVolatile ? QT.withVolatile() : QT;
837830
Gen.callFunc(FuncName, QT, Addrs, CGF);
838831
}

clang/lib/CodeGen/MicrosoftCXXABI.cpp

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ void MicrosoftCXXABI::emitBeginCatch(CodeGenFunction &CGF,
937937
std::tuple<Address, llvm::Value *, const CXXRecordDecl *>
938938
MicrosoftCXXABI::performBaseAdjustment(CodeGenFunction &CGF, Address Value,
939939
QualType SrcRecordTy) {
940-
Value = CGF.Builder.CreateElementBitCast(Value, CGF.Int8Ty);
940+
Value = Value.withElementType(CGF.Int8Ty);
941941
const CXXRecordDecl *SrcDecl = SrcRecordTy->getAsCXXRecordDecl();
942942
const ASTContext &Context = getContext();
943943

@@ -1452,7 +1452,7 @@ Address MicrosoftCXXABI::adjustThisArgumentForVirtualFunctionCall(
14521452
if (Adjustment.isZero())
14531453
return This;
14541454

1455-
This = CGF.Builder.CreateElementBitCast(This, CGF.Int8Ty);
1455+
This = This.withElementType(CGF.Int8Ty);
14561456
assert(Adjustment.isPositive());
14571457
return CGF.Builder.CreateConstByteGEP(This, Adjustment);
14581458
}
@@ -1483,7 +1483,7 @@ Address MicrosoftCXXABI::adjustThisArgumentForVirtualFunctionCall(
14831483

14841484
Address Result = This;
14851485
if (ML.VBase) {
1486-
Result = CGF.Builder.CreateElementBitCast(Result, CGF.Int8Ty);
1486+
Result = Result.withElementType(CGF.Int8Ty);
14871487

14881488
const CXXRecordDecl *Derived = MD->getParent();
14891489
const CXXRecordDecl *VBase = ML.VBase;
@@ -1497,7 +1497,7 @@ Address MicrosoftCXXABI::adjustThisArgumentForVirtualFunctionCall(
14971497
}
14981498
if (!StaticOffset.isZero()) {
14991499
assert(StaticOffset.isPositive());
1500-
Result = CGF.Builder.CreateElementBitCast(Result, CGF.Int8Ty);
1500+
Result = Result.withElementType(CGF.Int8Ty);
15011501
if (ML.VBase) {
15021502
// Non-virtual adjustment might result in a pointer outside the allocated
15031503
// object, e.g. if the final overrider class is laid out after the virtual
@@ -2217,7 +2217,7 @@ llvm::Value *MicrosoftCXXABI::performThisAdjustment(CodeGenFunction &CGF,
22172217
if (TA.isEmpty())
22182218
return This.getPointer();
22192219

2220-
This = CGF.Builder.CreateElementBitCast(This, CGF.Int8Ty);
2220+
This = This.withElementType(CGF.Int8Ty);
22212221

22222222
llvm::Value *V;
22232223
if (TA.Virtual.isEmpty()) {
@@ -2228,7 +2228,7 @@ llvm::Value *MicrosoftCXXABI::performThisAdjustment(CodeGenFunction &CGF,
22282228
Address VtorDispPtr =
22292229
CGF.Builder.CreateConstInBoundsByteGEP(This,
22302230
CharUnits::fromQuantity(TA.Virtual.Microsoft.VtordispOffset));
2231-
VtorDispPtr = CGF.Builder.CreateElementBitCast(VtorDispPtr, CGF.Int32Ty);
2231+
VtorDispPtr = VtorDispPtr.withElementType(CGF.Int32Ty);
22322232
llvm::Value *VtorDisp = CGF.Builder.CreateLoad(VtorDispPtr, "vtordisp");
22332233
V = CGF.Builder.CreateGEP(This.getElementType(), This.getPointer(),
22342234
CGF.Builder.CreateNeg(VtorDisp));
@@ -2270,7 +2270,7 @@ MicrosoftCXXABI::performReturnAdjustment(CodeGenFunction &CGF, Address Ret,
22702270
return Ret.getPointer();
22712271

22722272
auto OrigTy = Ret.getType();
2273-
Ret = CGF.Builder.CreateElementBitCast(Ret, CGF.Int8Ty);
2273+
Ret = Ret.withElementType(CGF.Int8Ty);
22742274

22752275
llvm::Value *V = Ret.getPointer();
22762276
if (RA.Virtual.Microsoft.VBIndex) {
@@ -2314,8 +2314,7 @@ CharUnits MicrosoftCXXABI::getArrayCookieSizeImpl(QualType type) {
23142314
llvm::Value *MicrosoftCXXABI::readArrayCookieImpl(CodeGenFunction &CGF,
23152315
Address allocPtr,
23162316
CharUnits cookieSize) {
2317-
Address numElementsPtr =
2318-
CGF.Builder.CreateElementBitCast(allocPtr, CGF.SizeTy);
2317+
Address numElementsPtr = allocPtr.withElementType(CGF.SizeTy);
23192318
return CGF.Builder.CreateLoad(numElementsPtr);
23202319
}
23212320

@@ -2333,8 +2332,7 @@ Address MicrosoftCXXABI::InitializeArrayCookie(CodeGenFunction &CGF,
23332332
Address cookiePtr = newPtr;
23342333

23352334
// Write the number of elements into the appropriate slot.
2336-
Address numElementsPtr
2337-
= CGF.Builder.CreateElementBitCast(cookiePtr, CGF.SizeTy);
2335+
Address numElementsPtr = cookiePtr.withElementType(CGF.SizeTy);
23382336
CGF.Builder.CreateStore(numElements, numElementsPtr);
23392337

23402338
// Finally, compute a pointer to the actual data buffer by skipping
@@ -3134,12 +3132,10 @@ MicrosoftCXXABI::GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF,
31343132
llvm::Value **VBPtrOut) {
31353133
CGBuilderTy &Builder = CGF.Builder;
31363134
// Load the vbtable pointer from the vbptr in the instance.
3137-
This = Builder.CreateElementBitCast(This, CGM.Int8Ty);
3138-
llvm::Value *VBPtr = Builder.CreateInBoundsGEP(
3139-
This.getElementType(), This.getPointer(), VBPtrOffset, "vbptr");
3140-
if (VBPtrOut) *VBPtrOut = VBPtr;
3141-
VBPtr = Builder.CreateBitCast(VBPtr,
3142-
CGM.Int32Ty->getPointerTo(0)->getPointerTo(This.getAddressSpace()));
3135+
llvm::Value *VBPtr = Builder.CreateInBoundsGEP(CGM.Int8Ty, This.getPointer(),
3136+
VBPtrOffset, "vbptr");
3137+
if (VBPtrOut)
3138+
*VBPtrOut = VBPtr;
31433139

31443140
CharUnits VBPtrAlign;
31453141
if (auto CI = dyn_cast<llvm::ConstantInt>(VBPtrOffset)) {
@@ -3160,7 +3156,6 @@ MicrosoftCXXABI::GetVBaseOffsetFromVBPtr(CodeGenFunction &CGF,
31603156
// Load an i32 offset from the vb-table.
31613157
llvm::Value *VBaseOffs =
31623158
Builder.CreateInBoundsGEP(CGM.Int32Ty, VBTable, VBTableIndex);
3163-
VBaseOffs = Builder.CreateBitCast(VBaseOffs, CGM.Int32Ty->getPointerTo(0));
31643159
return Builder.CreateAlignedLoad(CGM.Int32Ty, VBaseOffs,
31653160
CharUnits::fromQuantity(4), "vbase_offs");
31663161
}
@@ -3171,7 +3166,7 @@ llvm::Value *MicrosoftCXXABI::AdjustVirtualBase(
31713166
CodeGenFunction &CGF, const Expr *E, const CXXRecordDecl *RD,
31723167
Address Base, llvm::Value *VBTableOffset, llvm::Value *VBPtrOffset) {
31733168
CGBuilderTy &Builder = CGF.Builder;
3174-
Base = Builder.CreateElementBitCast(Base, CGM.Int8Ty);
3169+
Base = Base.withElementType(CGM.Int8Ty);
31753170
llvm::BasicBlock *OriginalBB = nullptr;
31763171
llvm::BasicBlock *SkipAdjustBB = nullptr;
31773172
llvm::BasicBlock *VBaseAdjustBB = nullptr;

0 commit comments

Comments
 (0)