[clang] 5f32baf - [clang] Replace uses of CreateElementBitCast (NFC)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 30 14:35:48 PDT 2023
Author: Youngsuk Kim
Date: 2023-06-30T17:35:36-04:00
New Revision: 5f32baf17db172478f1081e3d345f08e1053579f
URL: https://github.com/llvm/llvm-project/commit/5f32baf17db172478f1081e3d345f08e1053579f
DIFF: https://github.com/llvm/llvm-project/commit/5f32baf17db172478f1081e3d345f08e1053579f.diff
LOG: [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
Added:
Modified:
clang/lib/CodeGen/ABIInfoImpl.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGExprAgg.cpp
clang/lib/CodeGen/CGExprComplex.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/Targets/XCore.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp b/clang/lib/CodeGen/ABIInfoImpl.cpp
index 308d1a51321957..7c30cecfdb9b77 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -170,7 +170,7 @@ CodeGen::emitVoidPtrDirectVAArg(CodeGenFunction &CGF, Address VAListAddr,
// Cast the element type to i8* if necessary. Some platforms define
// va_list as a struct containing an i8* instead of just an i8*.
if (VAListAddr.getElementType() != CGF.Int8PtrTy)
- VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy);
+ VAListAddr = VAListAddr.withElementType(CGF.Int8PtrTy);
llvm::Value *Ptr = CGF.Builder.CreateLoad(VAListAddr, "argp.cur");
@@ -196,8 +196,7 @@ CodeGen::emitVoidPtrDirectVAArg(CodeGenFunction &CGF, Address VAListAddr,
Addr = CGF.Builder.CreateConstInBoundsByteGEP(Addr, SlotSize - DirectSize);
}
- Addr = CGF.Builder.CreateElementBitCast(Addr, DirectTy);
- return Addr;
+ return Addr.withElementType(DirectTy);
}
Address CodeGen::emitVoidPtrVAArg(CodeGenFunction &CGF, Address VAListAddr,
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index 4bc8001d9605dd..93e7b54fca0412 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);
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index 0b29190c0930dc..810b28f25fa18b 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -134,8 +134,8 @@ class AggExprEmitter : public StmtVisitor<AggExprEmitter> {
// destination but can have a
diff erent type. Just do a bitcast in this
// case to avoid incorrect GEPs.
if (Result->getType() != StoreDest.getType())
- StoreDest =
- CGF.Builder.CreateElementBitCast(StoreDest, Result->getType());
+ StoreDest = StoreDest.withElementType(Result->getType());
+
CGF.EmitAggregateStore(Result, StoreDest,
E->getType().isVolatileQualified());
return;
@@ -751,8 +751,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
// GCC union extension
QualType Ty = E->getSubExpr()->getType();
- Address CastPtr =
- Builder.CreateElementBitCast(Dest.getAddress(), CGF.ConvertType(Ty));
+ Address CastPtr = Dest.getAddress().withElementType(CGF.ConvertType(Ty));
EmitInitializationToLValue(E->getSubExpr(),
CGF.MakeAddrLValue(CastPtr, Ty));
break;
@@ -767,9 +766,8 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
LValue SourceLV = CGF.EmitLValue(E->getSubExpr());
Address SourceAddress =
- Builder.CreateElementBitCast(SourceLV.getAddress(CGF), CGF.Int8Ty);
- Address DestAddress =
- Builder.CreateElementBitCast(Dest.getAddress(), CGF.Int8Ty);
+ SourceLV.getAddress(CGF).withElementType(CGF.Int8Ty);
+ Address DestAddress = Dest.getAddress().withElementType(CGF.Int8Ty);
llvm::Value *SizeVal = llvm::ConstantInt::get(
CGF.SizeTy,
CGF.getContext().getTypeSizeInChars(E->getType()).getQuantity());
@@ -2024,8 +2022,7 @@ static void CheckAggExprForMemSetUse(AggValueSlot &Slot, const Expr *E,
// Okay, it seems like a good idea to use an initial memset, emit the call.
llvm::Constant *SizeVal = CGF.Builder.getInt64(Size.getQuantity());
- Address Loc = Slot.getAddress();
- Loc = CGF.Builder.CreateElementBitCast(Loc, CGF.Int8Ty);
+ Address Loc = Slot.getAddress().withElementType(CGF.Int8Ty);
CGF.Builder.CreateMemSet(Loc, CGF.Builder.getInt8(0), SizeVal, false);
// Tell the AggExprEmitter that the slot is known zero.
@@ -2189,8 +2186,8 @@ void CodeGenFunction::EmitAggregateCopy(LValue Dest, LValue Src, QualType Ty,
// we need to use a
diff erent call here. We use isVolatile to indicate when
// either the source or the destination is volatile.
- DestPtr = Builder.CreateElementBitCast(DestPtr, Int8Ty);
- SrcPtr = Builder.CreateElementBitCast(SrcPtr, Int8Ty);
+ DestPtr = DestPtr.withElementType(Int8Ty);
+ SrcPtr = SrcPtr.withElementType(Int8Ty);
// Don't do any of the memmove_collectable tests if GC isn't set.
if (CGM.getLangOpts().getGC() == LangOptions::NonGC) {
diff --git a/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp
index 7a14a418c7b65f..2dd1a991ec9719 100644
--- a/clang/lib/CodeGen/CGExprComplex.cpp
+++ b/clang/lib/CodeGen/CGExprComplex.cpp
@@ -488,15 +488,14 @@ ComplexPairTy ComplexExprEmitter::EmitCast(CastKind CK, Expr *Op,
case CK_LValueBitCast: {
LValue origLV = CGF.EmitLValue(Op);
- Address V = origLV.getAddress(CGF);
- V = Builder.CreateElementBitCast(V, CGF.ConvertType(DestTy));
+ Address V = origLV.getAddress(CGF).withElementType(CGF.ConvertType(DestTy));
return EmitLoadOfLValue(CGF.MakeAddrLValue(V, DestTy), Op->getExprLoc());
}
case CK_LValueToRValueBitCast: {
LValue SourceLVal = CGF.EmitLValue(Op);
- Address Addr = Builder.CreateElementBitCast(SourceLVal.getAddress(CGF),
- CGF.ConvertTypeForMem(DestTy));
+ Address Addr = SourceLVal.getAddress(CGF).withElementType(
+ CGF.ConvertTypeForMem(DestTy));
LValue DestLV = CGF.MakeAddrLValue(Addr, DestTy);
DestLV.setTBAAInfo(TBAAAccessInfo::getMayAliasInfo());
return EmitLoadOfLValue(DestLV, Op->getExprLoc());
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index bd0169d2d80b32..32964aa7d7e39e 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -684,8 +684,7 @@ static void EmitOMPAggregateInit(CodeGenFunction &CGF, Address DestAddr,
const ArrayType *ArrayTy = Type->getAsArrayTypeUnsafe();
llvm::Value *NumElements = CGF.emitArrayLength(ArrayTy, ElementTy, DestAddr);
if (DRD)
- SrcAddr =
- CGF.Builder.CreateElementBitCast(SrcAddr, DestAddr.getElementType());
+ SrcAddr = SrcAddr.withElementType(DestAddr.getElementType());
llvm::Value *SrcBegin = nullptr;
if (DRD)
@@ -906,8 +905,8 @@ void ReductionCodeGen::emitCleanups(CodeGenFunction &CGF, unsigned N,
QualType PrivateType = getPrivateType(N);
QualType::DestructionKind DTorKind = PrivateType.isDestructedType();
if (needCleanups(N)) {
- PrivateAddr = CGF.Builder.CreateElementBitCast(
- PrivateAddr, CGF.ConvertTypeForMem(PrivateType));
+ PrivateAddr =
+ PrivateAddr.withElementType(CGF.ConvertTypeForMem(PrivateType));
CGF.pushDestroy(DTorKind, PrivateAddr, PrivateType);
}
}
@@ -926,8 +925,7 @@ static LValue loadToBegin(CodeGenFunction &CGF, QualType BaseTy, QualType ElTy,
BaseTy = BaseTy->getPointeeType();
}
return CGF.MakeAddrLValue(
- CGF.Builder.CreateElementBitCast(BaseLV.getAddress(CGF),
- CGF.ConvertTypeForMem(ElTy)),
+ BaseLV.getAddress(CGF).withElementType(CGF.ConvertTypeForMem(ElTy)),
BaseLV.getType(), BaseLV.getBaseInfo(),
CGF.CGM.getTBAAInfoForSubobject(BaseLV, BaseLV.getType()));
}
@@ -1777,9 +1775,8 @@ llvm::Function *CGOpenMPRuntime::emitThreadPrivateVarDefinition(
llvm::Value *ArgVal = CtorCGF.EmitLoadOfScalar(
CtorCGF.GetAddrOfLocalVar(&Dst), /*Volatile=*/false,
CGM.getContext().VoidPtrTy, Dst.getLocation());
- Address Arg(ArgVal, CtorCGF.Int8Ty, VDAddr.getAlignment());
- Arg = CtorCGF.Builder.CreateElementBitCast(
- Arg, CtorCGF.ConvertTypeForMem(ASTTy));
+ Address Arg(ArgVal, CtorCGF.ConvertTypeForMem(ASTTy),
+ VDAddr.getAlignment());
CtorCGF.EmitAnyExprToMem(Init, Arg, Init->getType().getQualifiers(),
/*IsInitializer=*/true);
ArgVal = CtorCGF.EmitLoadOfScalar(
@@ -4244,8 +4241,7 @@ CGOpenMPRuntime::getDepobjElements(CodeGenFunction &CGF, LValue DepobjLVal,
cast<RecordDecl>(KmpDependInfoTy->getAsTagDecl());
QualType KmpDependInfoPtrTy = C.getPointerType(KmpDependInfoTy);
LValue Base = CGF.EmitLoadOfPointerLValue(
- CGF.Builder.CreateElementBitCast(
- DepobjLVal.getAddress(CGF),
+ DepobjLVal.getAddress(CGF).withElementType(
CGF.ConvertTypeForMem(KmpDependInfoPtrTy)),
KmpDependInfoPtrTy->castAs<PointerType>());
Address DepObjAddr = CGF.Builder.CreateGEP(
@@ -5471,8 +5467,7 @@ static llvm::Value *emitReduceInitFunction(CodeGenModule &CGM,
CGF.StartFunction(GlobalDecl(), C.VoidTy, Fn, FnInfo, Args, Loc, Loc);
QualType PrivateType = RCG.getPrivateType(N);
Address PrivateAddr = CGF.EmitLoadOfPointer(
- CGF.Builder.CreateElementBitCast(
- CGF.GetAddrOfLocalVar(&Param),
+ CGF.GetAddrOfLocalVar(&Param).withElementType(
CGF.ConvertTypeForMem(PrivateType)->getPointerTo()),
C.getPointerType(PrivateType)->castAs<PointerType>());
llvm::Value *Size = nullptr;
@@ -5560,17 +5555,16 @@ static llvm::Value *emitReduceCombFunction(CodeGenModule &CGM,
LHSVD,
// Pull out the pointer to the variable.
CGF.EmitLoadOfPointer(
- CGF.Builder.CreateElementBitCast(
- CGF.GetAddrOfLocalVar(&ParamInOut),
- CGF.ConvertTypeForMem(LHSVD->getType())->getPointerTo()),
+ CGF.GetAddrOfLocalVar(&ParamInOut)
+ .withElementType(
+ CGF.ConvertTypeForMem(LHSVD->getType())->getPointerTo()),
C.getPointerType(LHSVD->getType())->castAs<PointerType>()));
PrivateScope.addPrivate(
RHSVD,
// Pull out the pointer to the variable.
CGF.EmitLoadOfPointer(
- CGF.Builder.CreateElementBitCast(
- CGF.GetAddrOfLocalVar(&ParamIn),
- CGF.ConvertTypeForMem(RHSVD->getType())->getPointerTo()),
+ CGF.GetAddrOfLocalVar(&ParamIn).withElementType(
+ CGF.ConvertTypeForMem(RHSVD->getType())->getPointerTo()),
C.getPointerType(RHSVD->getType())->castAs<PointerType>()));
PrivateScope.Privatize();
// Emit the combiner body:
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 33a378d6597402..c1b27ad47d59b8 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1554,10 +1554,9 @@ static void emitReductionListCopy(
case RemoteLaneToThread: {
// Step 1.1: Get the address for the src element in the Reduce list.
Address SrcElementPtrAddr = Bld.CreateConstArrayGEP(SrcBase, Idx);
- SrcElementAddr =
- CGF.EmitLoadOfPointer(CGF.Builder.CreateElementBitCast(
- SrcElementPtrAddr, PrivateLlvmPtrType),
- PrivatePtrType->castAs<PointerType>());
+ SrcElementAddr = CGF.EmitLoadOfPointer(
+ SrcElementPtrAddr.withElementType(PrivateLlvmPtrType),
+ PrivatePtrType->castAs<PointerType>());
// Step 1.2: Create a temporary to store the element in the destination
// Reduce list.
@@ -1571,27 +1570,24 @@ static void emitReductionListCopy(
case ThreadCopy: {
// Step 1.1: Get the address for the src element in the Reduce list.
Address SrcElementPtrAddr = Bld.CreateConstArrayGEP(SrcBase, Idx);
- SrcElementAddr =
- CGF.EmitLoadOfPointer(CGF.Builder.CreateElementBitCast(
- SrcElementPtrAddr, PrivateLlvmPtrType),
- PrivatePtrType->castAs<PointerType>());
+ SrcElementAddr = CGF.EmitLoadOfPointer(
+ SrcElementPtrAddr.withElementType(PrivateLlvmPtrType),
+ PrivatePtrType->castAs<PointerType>());
// Step 1.2: Get the address for dest element. The destination
// element has already been created on the thread's stack.
DestElementPtrAddr = Bld.CreateConstArrayGEP(DestBase, Idx);
- DestElementAddr =
- CGF.EmitLoadOfPointer(CGF.Builder.CreateElementBitCast(
- DestElementPtrAddr, PrivateLlvmPtrType),
- PrivatePtrType->castAs<PointerType>());
+ DestElementAddr = CGF.EmitLoadOfPointer(
+ DestElementPtrAddr.withElementType(PrivateLlvmPtrType),
+ PrivatePtrType->castAs<PointerType>());
break;
}
case ThreadToScratchpad: {
// Step 1.1: Get the address for the src element in the Reduce list.
Address SrcElementPtrAddr = Bld.CreateConstArrayGEP(SrcBase, Idx);
- SrcElementAddr =
- CGF.EmitLoadOfPointer(CGF.Builder.CreateElementBitCast(
- SrcElementPtrAddr, PrivateLlvmPtrType),
- PrivatePtrType->castAs<PointerType>());
+ SrcElementAddr = CGF.EmitLoadOfPointer(
+ SrcElementPtrAddr.withElementType(PrivateLlvmPtrType),
+ PrivatePtrType->castAs<PointerType>());
// Step 1.2: Get the address for dest element:
// address = base + index * ElementSizeInChars.
@@ -1633,10 +1629,10 @@ static void emitReductionListCopy(
// Regardless of src and dest of copy, we emit the load of src
// element as this is required in all directions
- SrcElementAddr = Bld.CreateElementBitCast(
- SrcElementAddr, CGF.ConvertTypeForMem(Private->getType()));
- DestElementAddr = Bld.CreateElementBitCast(DestElementAddr,
- SrcElementAddr.getElementType());
+ SrcElementAddr = SrcElementAddr.withElementType(
+ CGF.ConvertTypeForMem(Private->getType()));
+ DestElementAddr =
+ DestElementAddr.withElementType(SrcElementAddr.getElementType());
// Now that all active lanes have read the element in the
// Reduce list, shuffle over the value from the remote lane.
@@ -1865,8 +1861,7 @@ static llvm::Value *emitInterWarpCopyFunction(CodeGenModule &CGM,
llvm::Value *ElemPtrPtr = CGF.EmitLoadOfScalar(
ElemPtrPtrAddr, /*Volatile=*/false, C.VoidPtrTy, SourceLocation());
// elemptr = ((CopyType*)(elemptrptr)) + I
- Address ElemPtr(ElemPtrPtr, CGF.Int8Ty, Align);
- ElemPtr = Bld.CreateElementBitCast(ElemPtr, CopyType);
+ Address ElemPtr(ElemPtrPtr, CopyType, Align);
if (NumIters > 1)
ElemPtr = Bld.CreateGEP(ElemPtr, Cnt);
@@ -1940,8 +1935,7 @@ static llvm::Value *emitInterWarpCopyFunction(CodeGenModule &CGM,
Address TargetElemPtrPtr = Bld.CreateConstArrayGEP(LocalReduceList, Idx);
llvm::Value *TargetElemPtrVal = CGF.EmitLoadOfScalar(
TargetElemPtrPtr, /*Volatile=*/false, C.VoidPtrTy, Loc);
- Address TargetElemPtr(TargetElemPtrVal, CGF.Int8Ty, Align);
- TargetElemPtr = Bld.CreateElementBitCast(TargetElemPtr, CopyType);
+ Address TargetElemPtr(TargetElemPtrVal, CopyType, Align);
if (NumIters > 1)
TargetElemPtr = Bld.CreateGEP(TargetElemPtr, Cnt);
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 313bdaab44f0f0..1396c2e13c4d4c 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -704,7 +704,7 @@ void CodeGenFunction::EmitOMPAggregateAssign(
// Drill down to the base element type on both arrays.
const ArrayType *ArrayTy = OriginalType->getAsArrayTypeUnsafe();
llvm::Value *NumElements = emitArrayLength(ArrayTy, ElementTy, DestAddr);
- SrcAddr = Builder.CreateElementBitCast(SrcAddr, DestAddr.getElementType());
+ SrcAddr = SrcAddr.withElementType(DestAddr.getElementType());
llvm::Value *SrcBegin = SrcAddr.getPointer();
llvm::Value *DestBegin = DestAddr.getPointer();
@@ -7192,7 +7192,7 @@ void CodeGenFunction::EmitOMPUseDevicePtrClause(
// privatization scope, so the initialization here disregards the fact
// the original variable is a reference.
llvm::Type *Ty = ConvertTypeForMem(OrigVD->getType().getNonReferenceType());
- Address InitAddr = Builder.CreateElementBitCast(InitAddrIt->second, Ty);
+ Address InitAddr = InitAddrIt->second.withElementType(Ty);
setAddrOfLocalVar(InitVD, InitAddr);
// Emit private declaration, it will be initialized by the value we
@@ -7258,9 +7258,9 @@ void CodeGenFunction::EmitOMPUseDeviceAddrClause(
MatchingVD->getType()->isArrayType()) {
QualType PtrTy = getContext().getPointerType(
OrigVD->getType().getNonReferenceType());
- PrivAddr = EmitLoadOfPointer(
- Builder.CreateElementBitCast(PrivAddr, ConvertTypeForMem(PtrTy)),
- PtrTy->castAs<PointerType>());
+ PrivAddr =
+ EmitLoadOfPointer(PrivAddr.withElementType(ConvertTypeForMem(PtrTy)),
+ PtrTy->castAs<PointerType>());
}
(void)PrivateScope.addPrivate(OrigVD, PrivAddr);
diff --git a/clang/lib/CodeGen/Targets/XCore.cpp b/clang/lib/CodeGen/Targets/XCore.cpp
index 9a291218b419c6..8be240c018d06c 100644
--- a/clang/lib/CodeGen/Targets/XCore.cpp
+++ b/clang/lib/CodeGen/Targets/XCore.cpp
@@ -164,14 +164,14 @@ Address XCoreABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
break;
case ABIArgInfo::Extend:
case ABIArgInfo::Direct:
- Val = Builder.CreateElementBitCast(AP, ArgTy);
+ Val = AP.withElementType(ArgTy);
ArgSize = CharUnits::fromQuantity(
getDataLayout().getTypeAllocSize(AI.getCoerceToType()));
ArgSize = ArgSize.alignTo(SlotSize);
break;
case ABIArgInfo::Indirect:
case ABIArgInfo::IndirectAliased:
- Val = Builder.CreateElementBitCast(AP, ArgPtrTy);
+ Val = AP.withElementType(ArgPtrTy);
Val = Address(Builder.CreateLoad(Val), ArgTy, TypeAlign);
ArgSize = SlotSize;
break;
More information about the cfe-commits
mailing list