diff options
author | Youngsuk Kim <youngsuk.kim@hpe.com> | 2023-07-02 10:40:00 -0400 |
---|---|---|
committer | JOE1994 <joseph942010@gmail.com> | 2023-07-02 10:40:16 -0400 |
commit | 6f986bffc51a243a1f4328b11624a0f21918a78f (patch) | |
tree | 4127d79c6f274e3213387ef9a10b706c243ecd0a /clang/lib/CodeGen/CGCall.cpp | |
parent | f55d96b9a25d7ab00be542e657565dad9b8a3e7e (diff) | |
download | llvm-6f986bffc51a243a1f4328b11624a0f21918a78f.zip llvm-6f986bffc51a243a1f4328b11624a0f21918a78f.tar.gz llvm-6f986bffc51a243a1f4328b11624a0f21918a78f.tar.bz2 |
[clang] Remove CGBuilderTy::CreateElementBitCast
`CGBuilderTy::CreateElementBitCast()` no longer does what its name suggests.
Remove remaining in-tree uses by one of the following methods.
* drop the call entirely
* fold it to an `Address` construction
* replace it with `Address::withElementType()`
This is a NFC cleanup effort.
Reviewed By: barannikov88, nikic, jrtc27
Differential Revision: https://reviews.llvm.org/D154285
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 50ef4409..2ffcec0 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1286,7 +1286,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, llvm::Type *Ty, // // FIXME: Assert that we aren't truncating non-padding bits when have access // to that information. - Src = CGF.Builder.CreateElementBitCast(Src, Ty); + Src = Src.withElementType(Ty); return CGF.Builder.CreateLoad(Src); } @@ -1396,7 +1396,7 @@ static void CreateCoercedStore(llvm::Value *Src, if (isa<llvm::ScalableVectorType>(SrcTy) || isa<llvm::ScalableVectorType>(DstTy) || SrcSize.getFixedValue() <= DstSize.getFixedValue()) { - Dst = CGF.Builder.CreateElementBitCast(Dst, SrcTy); + Dst = Dst.withElementType(SrcTy); CGF.EmitAggregateStore(Src, Dst, DstIsVolatile); } else { // Otherwise do coercion through memory. This is stupid, but @@ -1420,10 +1420,10 @@ static void CreateCoercedStore(llvm::Value *Src, static Address emitAddressAtOffset(CodeGenFunction &CGF, Address addr, const ABIArgInfo &info) { if (unsigned offset = info.getDirectOffset()) { - addr = CGF.Builder.CreateElementBitCast(addr, CGF.Int8Ty); + addr = addr.withElementType(CGF.Int8Ty); addr = CGF.Builder.CreateConstInBoundsByteGEP(addr, CharUnits::fromQuantity(offset)); - addr = CGF.Builder.CreateElementBitCast(addr, info.getCoerceToType()); + addr = addr.withElementType(info.getCoerceToType()); } return addr; } @@ -3190,7 +3190,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, Address AddrToStoreInto = Address::invalid(); if (SrcSize <= DstSize) { - AddrToStoreInto = Builder.CreateElementBitCast(Ptr, STy); + AddrToStoreInto = Ptr.withElementType(STy); } else { AddrToStoreInto = CreateTempAlloca(STy, Alloca.getAlignment(), "coerce"); @@ -3235,7 +3235,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI, ArgVals.push_back(ParamValue::forIndirect(alloca)); auto coercionType = ArgI.getCoerceAndExpandType(); - alloca = Builder.CreateElementBitCast(alloca, coercionType); + alloca = alloca.withElementType(coercionType); unsigned argIndex = FirstIRArg; for (unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) { @@ -3837,7 +3837,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI, // Load all of the coerced elements out into results. llvm::SmallVector<llvm::Value*, 4> results; - Address addr = Builder.CreateElementBitCast(ReturnValue, coercionType); + Address addr = ReturnValue.withElementType(coercionType); for (unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) { auto coercedEltType = coercionType->getElementType(i); if (ABIArgInfo::isPaddingForCoerceAndExpand(coercedEltType)) @@ -5063,10 +5063,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // Store the RValue into the argument struct. Address Addr = Builder.CreateStructGEP(ArgMemory, ArgInfo.getInAllocaFieldIndex()); - // There are some cases where a trivial bitcast is not avoidable. The - // definition of a type later in a translation unit may change it's type - // from {}* to (%struct.foo*)*. - Addr = Builder.CreateElementBitCast(Addr, ConvertTypeForMem(I->Ty)); + Addr = Addr.withElementType(ConvertTypeForMem(I->Ty)); I->copyInto(*this, Addr); } break; @@ -5261,7 +5258,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, Builder.CreateMemCpy(TempAlloca, Src, SrcSize); Src = TempAlloca; } else { - Src = Builder.CreateElementBitCast(Src, STy); + Src = Src.withElementType(STy); } assert(NumIRArgs == STy->getNumElements()); @@ -5325,7 +5322,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, Builder.CreateStore(RV.getScalarVal(), addr); } - addr = Builder.CreateElementBitCast(addr, coercionType); + addr = addr.withElementType(coercionType); unsigned IRArgPos = FirstIRArg; for (unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) { @@ -5680,8 +5677,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, case ABIArgInfo::CoerceAndExpand: { auto coercionType = RetAI.getCoerceAndExpandType(); - Address addr = SRetPtr; - addr = Builder.CreateElementBitCast(addr, coercionType); + Address addr = SRetPtr.withElementType(coercionType); assert(CI->getType() == RetAI.getUnpaddedCoerceAndExpandType()); bool requiresExtract = isa<llvm::StructType>(CI->getType()); |