forked from OSchip/llvm-project
[opaque pointer types] Cleanup CGBuilder's Create*GEP.
The various EltSize, Offset, DataLayout, and StructLayout arguments are all computable from the Address's element type and the DataLayout which the CGBuilder already has access to. After having previously asserted that the computed values are the same as those passed in, now remove the redundant arguments from CGBuilder's Create*GEP functions. Differential Revision: https://reviews.llvm.org/D57767 llvm-svn: 353629
This commit is contained in:
parent
a561d46633
commit
751fe286dc
|
@ -201,7 +201,7 @@ namespace {
|
|||
assert(LVal.isSimple());
|
||||
Address addr = getAtomicAddress();
|
||||
if (hasPadding())
|
||||
addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits());
|
||||
addr = CGF.Builder.CreateStructGEP(addr, 0);
|
||||
|
||||
return LValue::MakeAddr(addr, getValueType(), CGF.getContext(),
|
||||
LVal.getBaseInfo(), LVal.getTBAAInfo());
|
||||
|
@ -1356,7 +1356,7 @@ RValue AtomicInfo::convertAtomicTempToRValue(Address addr,
|
|||
|
||||
// Drill into the padding structure if we have one.
|
||||
if (hasPadding())
|
||||
addr = CGF.Builder.CreateStructGEP(addr, 0, CharUnits());
|
||||
addr = CGF.Builder.CreateStructGEP(addr, 0);
|
||||
|
||||
// Otherwise, just convert the temporary to an r-value using the
|
||||
// normal conversion routine.
|
||||
|
|
|
@ -836,9 +836,8 @@ static void enterBlockScope(CodeGenFunction &CGF, BlockDecl *block) {
|
|||
}
|
||||
|
||||
// GEP down to the address.
|
||||
Address addr = CGF.Builder.CreateStructGEP(blockInfo.LocalAddress,
|
||||
capture.getIndex(),
|
||||
capture.getOffset());
|
||||
Address addr =
|
||||
CGF.Builder.CreateStructGEP(blockInfo.LocalAddress, capture.getIndex());
|
||||
|
||||
// We can use that GEP as the dominating IP.
|
||||
if (!blockInfo.DominatingIP)
|
||||
|
@ -975,27 +974,24 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
|
|||
flags |= BLOCK_IS_NOESCAPE | BLOCK_IS_GLOBAL;
|
||||
}
|
||||
|
||||
auto projectField =
|
||||
[&](unsigned index, CharUnits offset, const Twine &name) -> Address {
|
||||
return Builder.CreateStructGEP(blockAddr, index, offset, name);
|
||||
};
|
||||
auto storeField =
|
||||
[&](llvm::Value *value, unsigned index, CharUnits offset,
|
||||
const Twine &name) {
|
||||
Builder.CreateStore(value, projectField(index, offset, name));
|
||||
};
|
||||
auto projectField = [&](unsigned index, const Twine &name) -> Address {
|
||||
return Builder.CreateStructGEP(blockAddr, index, name);
|
||||
};
|
||||
auto storeField = [&](llvm::Value *value, unsigned index, const Twine &name) {
|
||||
Builder.CreateStore(value, projectField(index, name));
|
||||
};
|
||||
|
||||
// Initialize the block header.
|
||||
{
|
||||
// We assume all the header fields are densely packed.
|
||||
unsigned index = 0;
|
||||
CharUnits offset;
|
||||
auto addHeaderField =
|
||||
[&](llvm::Value *value, CharUnits size, const Twine &name) {
|
||||
storeField(value, index, offset, name);
|
||||
offset += size;
|
||||
index++;
|
||||
};
|
||||
auto addHeaderField = [&](llvm::Value *value, CharUnits size,
|
||||
const Twine &name) {
|
||||
storeField(value, index, name);
|
||||
offset += size;
|
||||
index++;
|
||||
};
|
||||
|
||||
if (!IsOpenCL) {
|
||||
addHeaderField(isa, getPointerSize(), "block.isa");
|
||||
|
@ -1031,8 +1027,8 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
|
|||
|
||||
// First, 'this'.
|
||||
if (blockDecl->capturesCXXThis()) {
|
||||
Address addr = projectField(blockInfo.CXXThisIndex, blockInfo.CXXThisOffset,
|
||||
"block.captured-this.addr");
|
||||
Address addr =
|
||||
projectField(blockInfo.CXXThisIndex, "block.captured-this.addr");
|
||||
Builder.CreateStore(LoadCXXThis(), addr);
|
||||
}
|
||||
|
||||
|
@ -1048,8 +1044,7 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
|
|||
|
||||
// This will be a [[type]]*, except that a byref entry will just be
|
||||
// an i8**.
|
||||
Address blockField =
|
||||
projectField(capture.getIndex(), capture.getOffset(), "block.captured");
|
||||
Address blockField = projectField(capture.getIndex(), "block.captured");
|
||||
|
||||
// Compute the address of the thing we're going to move into the
|
||||
// block literal.
|
||||
|
@ -1068,7 +1063,6 @@ llvm::Value *CodeGenFunction::EmitBlockLiteral(const CGBlockInfo &blockInfo) {
|
|||
// This is a [[type]]*, except that a byref entry will just be an i8**.
|
||||
src = Builder.CreateStructGEP(LoadBlockStruct(),
|
||||
enclosingCapture.getIndex(),
|
||||
enclosingCapture.getOffset(),
|
||||
"block.capture.addr");
|
||||
} else {
|
||||
auto I = LocalDeclMap.find(variable);
|
||||
|
@ -1330,9 +1324,8 @@ Address CodeGenFunction::GetAddrOfBlockDecl(const VarDecl *variable) {
|
|||
// Handle constant captures.
|
||||
if (capture.isConstant()) return LocalDeclMap.find(variable)->second;
|
||||
|
||||
Address addr =
|
||||
Builder.CreateStructGEP(LoadBlockStruct(), capture.getIndex(),
|
||||
capture.getOffset(), "block.capture.addr");
|
||||
Address addr = Builder.CreateStructGEP(LoadBlockStruct(), capture.getIndex(),
|
||||
"block.capture.addr");
|
||||
|
||||
if (variable->isEscapingByref()) {
|
||||
// addr should be a void** right now. Load, then cast the result
|
||||
|
@ -1615,9 +1608,8 @@ CodeGenFunction::GenerateBlockFunction(GlobalDecl GD,
|
|||
// If we have a C++ 'this' reference, go ahead and force it into
|
||||
// existence now.
|
||||
if (blockDecl->capturesCXXThis()) {
|
||||
Address addr =
|
||||
Builder.CreateStructGEP(LoadBlockStruct(), blockInfo.CXXThisIndex,
|
||||
blockInfo.CXXThisOffset, "block.captured-this");
|
||||
Address addr = Builder.CreateStructGEP(
|
||||
LoadBlockStruct(), blockInfo.CXXThisIndex, "block.captured-this");
|
||||
CXXThisValue = Builder.CreateLoad(addr, "this");
|
||||
}
|
||||
|
||||
|
@ -2060,8 +2052,8 @@ CodeGenFunction::GenerateCopyHelperFunction(const CGBlockInfo &blockInfo) {
|
|||
BlockFieldFlags flags = CopiedCapture.CopyFlags;
|
||||
|
||||
unsigned index = capture.getIndex();
|
||||
Address srcField = Builder.CreateStructGEP(src, index, capture.getOffset());
|
||||
Address dstField = Builder.CreateStructGEP(dst, index, capture.getOffset());
|
||||
Address srcField = Builder.CreateStructGEP(src, index);
|
||||
Address dstField = Builder.CreateStructGEP(dst, index);
|
||||
|
||||
switch (CopiedCapture.CopyKind) {
|
||||
case BlockCaptureEntityKind::CXXRecord:
|
||||
|
@ -2249,8 +2241,7 @@ CodeGenFunction::GenerateDestroyHelperFunction(const CGBlockInfo &blockInfo) {
|
|||
const CGBlockInfo::Capture &capture = *DestroyedCapture.Capture;
|
||||
BlockFieldFlags flags = DestroyedCapture.DisposeFlags;
|
||||
|
||||
Address srcField =
|
||||
Builder.CreateStructGEP(src, capture.getIndex(), capture.getOffset());
|
||||
Address srcField = Builder.CreateStructGEP(src, capture.getIndex());
|
||||
|
||||
pushCaptureCleanup(DestroyedCapture.DisposeKind, srcField,
|
||||
CI.getVariable()->getType(), flags,
|
||||
|
@ -2710,13 +2701,11 @@ Address CodeGenFunction::emitBlockByrefAddress(Address baseAddr,
|
|||
const llvm::Twine &name) {
|
||||
// Chase the forwarding address if requested.
|
||||
if (followForward) {
|
||||
Address forwardingAddr =
|
||||
Builder.CreateStructGEP(baseAddr, 1, getPointerSize(), "forwarding");
|
||||
Address forwardingAddr = Builder.CreateStructGEP(baseAddr, 1, "forwarding");
|
||||
baseAddr = Address(Builder.CreateLoad(forwardingAddr), info.ByrefAlignment);
|
||||
}
|
||||
|
||||
return Builder.CreateStructGEP(baseAddr, info.FieldIndex,
|
||||
info.FieldOffset, name);
|
||||
return Builder.CreateStructGEP(baseAddr, info.FieldIndex, name);
|
||||
}
|
||||
|
||||
/// BuildByrefInfo - This routine changes a __block variable declared as T x
|
||||
|
@ -2834,8 +2823,7 @@ void CodeGenFunction::emitByrefStructureInit(const AutoVarEmission &emission) {
|
|||
CharUnits nextHeaderOffset;
|
||||
auto storeHeaderField = [&](llvm::Value *value, CharUnits fieldSize,
|
||||
const Twine &name) {
|
||||
auto fieldAddr = Builder.CreateStructGEP(addr, nextHeaderIndex,
|
||||
nextHeaderOffset, name);
|
||||
auto fieldAddr = Builder.CreateStructGEP(addr, nextHeaderIndex, name);
|
||||
Builder.CreateStore(value, fieldAddr);
|
||||
|
||||
nextHeaderIndex++;
|
||||
|
|
|
@ -167,33 +167,25 @@ public:
|
|||
return Address(Ptr, Addr.getAlignment());
|
||||
}
|
||||
|
||||
/// Given
|
||||
/// %addr = {T1, T2...}* ...
|
||||
/// produce
|
||||
/// %name = getelementptr inbounds %addr, i32 0, i32 index
|
||||
///
|
||||
/// This API assumes that drilling into a struct like this is always an
|
||||
/// inbounds operation.
|
||||
using CGBuilderBaseTy::CreateStructGEP;
|
||||
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset,
|
||||
Address CreateStructGEP(Address Addr, unsigned Index,
|
||||
const llvm::Twine &Name = "") {
|
||||
#ifndef NDEBUG
|
||||
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
|
||||
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
|
||||
const llvm::StructLayout *SL = DL.getStructLayout(ElTy);
|
||||
assert(SL->getElementOffset(Index) == (uint64_t)Offset.getQuantity());
|
||||
#endif
|
||||
const llvm::StructLayout *Layout = DL.getStructLayout(ElTy);
|
||||
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
|
||||
|
||||
return Address(CreateStructGEP(Addr.getElementType(),
|
||||
Addr.getPointer(), Index, Name),
|
||||
Addr.getAlignment().alignmentAtOffset(Offset));
|
||||
}
|
||||
Address CreateStructGEP(Address Addr, unsigned Index,
|
||||
const llvm::StructLayout *Layout,
|
||||
const llvm::Twine &Name = "") {
|
||||
#ifndef NDEBUG
|
||||
llvm::StructType *ElTy = cast<llvm::StructType>(Addr.getElementType());
|
||||
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
|
||||
const llvm::StructLayout *SL = DL.getStructLayout(ElTy);
|
||||
assert(Layout == SL);
|
||||
#endif
|
||||
|
||||
auto Offset = CharUnits::fromQuantity(Layout->getElementOffset(Index));
|
||||
return CreateStructGEP(Addr, Index, Offset, Name);
|
||||
}
|
||||
|
||||
/// Given
|
||||
/// %addr = [n x T]* ...
|
||||
|
@ -203,24 +195,6 @@ public:
|
|||
///
|
||||
/// This API assumes that drilling into an array like this is always
|
||||
/// an inbounds operation.
|
||||
///
|
||||
/// \param EltSize - the size of the type T in bytes
|
||||
Address CreateConstArrayGEP(Address Addr, uint64_t Index, CharUnits EltSize,
|
||||
const llvm::Twine &Name = "") {
|
||||
#ifndef NDEBUG
|
||||
llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType());
|
||||
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
|
||||
assert(DL.getTypeAllocSize(ElTy->getElementType()) ==
|
||||
(uint64_t)EltSize.getQuantity());
|
||||
#endif
|
||||
|
||||
return Address(CreateInBoundsGEP(Addr.getPointer(),
|
||||
{getSize(CharUnits::Zero()),
|
||||
getSize(Index)},
|
||||
Name),
|
||||
Addr.getAlignment().alignmentAtOffset(Index * EltSize));
|
||||
}
|
||||
|
||||
Address CreateConstArrayGEP(Address Addr, uint64_t Index,
|
||||
const llvm::Twine &Name = "") {
|
||||
llvm::ArrayType *ElTy = cast<llvm::ArrayType>(Addr.getElementType());
|
||||
|
@ -239,16 +213,11 @@ public:
|
|||
/// produce
|
||||
/// %name = getelementptr inbounds %addr, i64 index
|
||||
/// where i64 is actually the target word size.
|
||||
///
|
||||
/// \param EltSize - the size of the type T in bytes
|
||||
Address CreateConstInBoundsGEP(Address Addr, uint64_t Index,
|
||||
CharUnits EltSize,
|
||||
const llvm::Twine &Name = "") {
|
||||
#ifndef NDEBUG
|
||||
llvm::Type *ElTy = Addr.getElementType();
|
||||
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
|
||||
assert(DL.getTypeAllocSize(ElTy) == (uint64_t)EltSize.getQuantity());
|
||||
#endif
|
||||
CharUnits EltSize = CharUnits::fromQuantity(DL.getTypeAllocSize(ElTy));
|
||||
|
||||
return Address(CreateInBoundsGEP(Addr.getElementType(), Addr.getPointer(),
|
||||
getSize(Index), Name),
|
||||
|
@ -260,15 +229,12 @@ public:
|
|||
/// produce
|
||||
/// %name = getelementptr inbounds %addr, i64 index
|
||||
/// where i64 is actually the target word size.
|
||||
///
|
||||
/// \param EltSize - the size of the type T in bytes
|
||||
Address CreateConstGEP(Address Addr, uint64_t Index, CharUnits EltSize,
|
||||
Address CreateConstGEP(Address Addr, uint64_t Index,
|
||||
const llvm::Twine &Name = "") {
|
||||
#ifndef NDEBUG
|
||||
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
|
||||
assert(DL.getTypeAllocSize(Addr.getElementType()) ==
|
||||
(uint64_t)EltSize.getQuantity());
|
||||
#endif
|
||||
CharUnits EltSize =
|
||||
CharUnits::fromQuantity(DL.getTypeAllocSize(Addr.getElementType()));
|
||||
|
||||
return Address(CreateGEP(Addr.getElementType(), Addr.getPointer(),
|
||||
getSize(Index), Name),
|
||||
Addr.getAlignment().alignmentAtOffset(Index * EltSize));
|
||||
|
@ -289,13 +255,9 @@ public:
|
|||
}
|
||||
|
||||
using CGBuilderBaseTy::CreateConstInBoundsGEP2_32;
|
||||
Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0,
|
||||
unsigned Idx1, const llvm::DataLayout &DL,
|
||||
const llvm::Twine &Name = "") {
|
||||
#ifndef NDEBUG
|
||||
const llvm::DataLayout &DL2 = BB->getParent()->getParent()->getDataLayout();
|
||||
assert(DL == DL2);
|
||||
#endif
|
||||
Address CreateConstInBoundsGEP2_32(Address Addr, unsigned Idx0, unsigned Idx1,
|
||||
const llvm::Twine &Name = "") {
|
||||
const llvm::DataLayout &DL = BB->getParent()->getParent()->getDataLayout();
|
||||
|
||||
auto *GEP = cast<llvm::GetElementPtrInst>(CreateConstInBoundsGEP2_32(
|
||||
Addr.getElementType(), Addr.getPointer(), Idx0, Idx1, Name));
|
||||
|
|
|
@ -2527,8 +2527,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
|
|||
// Store the stack pointer to the setjmp buffer.
|
||||
Value *StackAddr =
|
||||
Builder.CreateCall(CGM.getIntrinsic(Intrinsic::stacksave));
|
||||
Address StackSaveSlot =
|
||||
Builder.CreateConstInBoundsGEP(Buf, 2, getPointerSize());
|
||||
Address StackSaveSlot = Builder.CreateConstInBoundsGEP(Buf, 2);
|
||||
Builder.CreateStore(StackAddr, StackSaveSlot);
|
||||
|
||||
// Call LLVM's EH setjmp, which is lightweight.
|
||||
|
|
|
@ -1151,7 +1151,7 @@ EnterStructPointerForCoercedAccess(Address SrcPtr,
|
|||
return SrcPtr;
|
||||
|
||||
// GEP into the first element.
|
||||
SrcPtr = CGF.Builder.CreateStructGEP(SrcPtr, 0, CharUnits(), "coerce.dive");
|
||||
SrcPtr = CGF.Builder.CreateStructGEP(SrcPtr, 0, "coerce.dive");
|
||||
|
||||
// If the first element is a struct, recurse.
|
||||
llvm::Type *SrcTy = SrcPtr.getElementType();
|
||||
|
@ -1279,12 +1279,8 @@ static void BuildAggStore(CodeGenFunction &CGF, llvm::Value *Val,
|
|||
// Prefer scalar stores to first-class aggregate stores.
|
||||
if (llvm::StructType *STy =
|
||||
dyn_cast<llvm::StructType>(Val->getType())) {
|
||||
const llvm::StructLayout *Layout =
|
||||
CGF.CGM.getDataLayout().getStructLayout(STy);
|
||||
|
||||
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
|
||||
auto EltOffset = CharUnits::fromQuantity(Layout->getElementOffset(i));
|
||||
Address EltPtr = CGF.Builder.CreateStructGEP(Dest, i, EltOffset);
|
||||
Address EltPtr = CGF.Builder.CreateStructGEP(Dest, i);
|
||||
llvm::Value *Elt = CGF.Builder.CreateExtractValue(Val, i);
|
||||
CGF.Builder.CreateStore(Elt, EltPtr, DestIsVolatile);
|
||||
}
|
||||
|
@ -2271,9 +2267,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|||
// If we're using inalloca, all the memory arguments are GEPs off of the last
|
||||
// parameter, which is a pointer to the complete memory area.
|
||||
Address ArgStruct = Address::invalid();
|
||||
const llvm::StructLayout *ArgStructLayout = nullptr;
|
||||
if (IRFunctionArgs.hasInallocaArg()) {
|
||||
ArgStructLayout = CGM.getDataLayout().getStructLayout(FI.getArgStruct());
|
||||
ArgStruct = Address(FnArgs[IRFunctionArgs.getInallocaArgNo()],
|
||||
FI.getArgStructAlignment());
|
||||
|
||||
|
@ -2322,10 +2316,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|||
case ABIArgInfo::InAlloca: {
|
||||
assert(NumIRArgs == 0);
|
||||
auto FieldIndex = ArgI.getInAllocaFieldIndex();
|
||||
CharUnits FieldOffset =
|
||||
CharUnits::fromQuantity(ArgStructLayout->getElementOffset(FieldIndex));
|
||||
Address V = Builder.CreateStructGEP(ArgStruct, FieldIndex, FieldOffset,
|
||||
Arg->getName());
|
||||
Address V =
|
||||
Builder.CreateStructGEP(ArgStruct, FieldIndex, Arg->getName());
|
||||
ArgVals.push_back(ParamValue::forIndirect(V));
|
||||
break;
|
||||
}
|
||||
|
@ -2485,7 +2477,6 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|||
llvm::StructType *STy = dyn_cast<llvm::StructType>(ArgI.getCoerceToType());
|
||||
if (ArgI.isDirect() && ArgI.getCanBeFlattened() && STy &&
|
||||
STy->getNumElements() > 1) {
|
||||
auto SrcLayout = CGM.getDataLayout().getStructLayout(STy);
|
||||
uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(STy);
|
||||
llvm::Type *DstTy = Ptr.getElementType();
|
||||
uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(DstTy);
|
||||
|
@ -2502,9 +2493,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|||
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
|
||||
auto AI = FnArgs[FirstIRArg + i];
|
||||
AI->setName(Arg->getName() + ".coerce" + Twine(i));
|
||||
auto Offset = CharUnits::fromQuantity(SrcLayout->getElementOffset(i));
|
||||
Address EltPtr =
|
||||
Builder.CreateStructGEP(AddrToStoreInto, i, Offset);
|
||||
Address EltPtr = Builder.CreateStructGEP(AddrToStoreInto, i);
|
||||
Builder.CreateStore(AI, EltPtr);
|
||||
}
|
||||
|
||||
|
@ -2540,7 +2529,6 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|||
|
||||
auto coercionType = ArgI.getCoerceAndExpandType();
|
||||
alloca = Builder.CreateElementBitCast(alloca, coercionType);
|
||||
auto layout = CGM.getDataLayout().getStructLayout(coercionType);
|
||||
|
||||
unsigned argIndex = FirstIRArg;
|
||||
for (unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
|
||||
|
@ -2548,7 +2536,7 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
|
|||
if (ABIArgInfo::isPaddingForCoerceAndExpand(eltType))
|
||||
continue;
|
||||
|
||||
auto eltAddr = Builder.CreateStructGEP(alloca, i, layout);
|
||||
auto eltAddr = Builder.CreateStructGEP(alloca, i);
|
||||
auto elt = FnArgs[argIndex++];
|
||||
Builder.CreateStore(elt, eltAddr);
|
||||
}
|
||||
|
@ -2953,7 +2941,6 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
|
|||
|
||||
case ABIArgInfo::CoerceAndExpand: {
|
||||
auto coercionType = RetAI.getCoerceAndExpandType();
|
||||
auto layout = CGM.getDataLayout().getStructLayout(coercionType);
|
||||
|
||||
// Load all of the coerced elements out into results.
|
||||
llvm::SmallVector<llvm::Value*, 4> results;
|
||||
|
@ -2963,7 +2950,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
|
|||
if (ABIArgInfo::isPaddingForCoerceAndExpand(coercedEltType))
|
||||
continue;
|
||||
|
||||
auto eltAddr = Builder.CreateStructGEP(addr, i, layout);
|
||||
auto eltAddr = Builder.CreateStructGEP(addr, i);
|
||||
auto elt = Builder.CreateLoad(eltAddr);
|
||||
results.push_back(elt);
|
||||
}
|
||||
|
@ -3852,10 +3839,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
// If we're using inalloca, insert the allocation after the stack save.
|
||||
// FIXME: Do this earlier rather than hacking it in here!
|
||||
Address ArgMemory = Address::invalid();
|
||||
const llvm::StructLayout *ArgMemoryLayout = nullptr;
|
||||
if (llvm::StructType *ArgStruct = CallInfo.getArgStruct()) {
|
||||
const llvm::DataLayout &DL = CGM.getDataLayout();
|
||||
ArgMemoryLayout = DL.getStructLayout(ArgStruct);
|
||||
llvm::Instruction *IP = CallArgs.getStackBase();
|
||||
llvm::AllocaInst *AI;
|
||||
if (IP) {
|
||||
|
@ -3872,13 +3857,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
ArgMemory = Address(AI, Align);
|
||||
}
|
||||
|
||||
// Helper function to drill into the inalloca allocation.
|
||||
auto createInAllocaStructGEP = [&](unsigned FieldIndex) -> Address {
|
||||
auto FieldOffset =
|
||||
CharUnits::fromQuantity(ArgMemoryLayout->getElementOffset(FieldIndex));
|
||||
return Builder.CreateStructGEP(ArgMemory, FieldIndex, FieldOffset);
|
||||
};
|
||||
|
||||
ClangToLLVMArgMapping IRFunctionArgs(CGM.getContext(), CallInfo);
|
||||
SmallVector<llvm::Value *, 16> IRCallArgs(IRFunctionArgs.totalIRArgs());
|
||||
|
||||
|
@ -3901,7 +3879,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
if (IRFunctionArgs.hasSRetArg()) {
|
||||
IRCallArgs[IRFunctionArgs.getSRetArgNo()] = SRetPtr.getPointer();
|
||||
} else if (RetAI.isInAlloca()) {
|
||||
Address Addr = createInAllocaStructGEP(RetAI.getInAllocaFieldIndex());
|
||||
Address Addr =
|
||||
Builder.CreateStructGEP(ArgMemory, RetAI.getInAllocaFieldIndex());
|
||||
Builder.CreateStore(SRetPtr.getPointer(), Addr);
|
||||
}
|
||||
}
|
||||
|
@ -3939,12 +3918,14 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
cast<llvm::Instruction>(Addr.getPointer());
|
||||
CGBuilderTy::InsertPoint IP = Builder.saveIP();
|
||||
Builder.SetInsertPoint(Placeholder);
|
||||
Addr = createInAllocaStructGEP(ArgInfo.getInAllocaFieldIndex());
|
||||
Addr =
|
||||
Builder.CreateStructGEP(ArgMemory, ArgInfo.getInAllocaFieldIndex());
|
||||
Builder.restoreIP(IP);
|
||||
deferPlaceholderReplacement(Placeholder, Addr.getPointer());
|
||||
} else {
|
||||
// Store the RValue into the argument struct.
|
||||
Address Addr = createInAllocaStructGEP(ArgInfo.getInAllocaFieldIndex());
|
||||
Address Addr =
|
||||
Builder.CreateStructGEP(ArgMemory, ArgInfo.getInAllocaFieldIndex());
|
||||
unsigned AS = Addr.getType()->getPointerAddressSpace();
|
||||
llvm::Type *MemType = ConvertTypeForMem(I->Ty)->getPointerTo(AS);
|
||||
// There are some cases where a trivial bitcast is not avoidable. The
|
||||
|
@ -4125,11 +4106,9 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
STy->getPointerTo(Src.getAddressSpace()));
|
||||
}
|
||||
|
||||
auto SrcLayout = CGM.getDataLayout().getStructLayout(STy);
|
||||
assert(NumIRArgs == STy->getNumElements());
|
||||
for (unsigned i = 0, e = STy->getNumElements(); i != e; ++i) {
|
||||
auto Offset = CharUnits::fromQuantity(SrcLayout->getElementOffset(i));
|
||||
Address EltPtr = Builder.CreateStructGEP(Src, i, Offset);
|
||||
Address EltPtr = Builder.CreateStructGEP(Src, i);
|
||||
llvm::Value *LI = Builder.CreateLoad(EltPtr);
|
||||
IRCallArgs[FirstIRArg + i] = LI;
|
||||
}
|
||||
|
@ -4179,7 +4158,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
for (unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
|
||||
llvm::Type *eltType = coercionType->getElementType(i);
|
||||
if (ABIArgInfo::isPaddingForCoerceAndExpand(eltType)) continue;
|
||||
Address eltAddr = Builder.CreateStructGEP(addr, i, layout);
|
||||
Address eltAddr = Builder.CreateStructGEP(addr, i);
|
||||
llvm::Value *elt = Builder.CreateLoad(eltAddr);
|
||||
IRCallArgs[IRArgPos++] = elt;
|
||||
}
|
||||
|
@ -4481,7 +4460,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
switch (RetAI.getKind()) {
|
||||
case ABIArgInfo::CoerceAndExpand: {
|
||||
auto coercionType = RetAI.getCoerceAndExpandType();
|
||||
auto layout = CGM.getDataLayout().getStructLayout(coercionType);
|
||||
|
||||
Address addr = SRetPtr;
|
||||
addr = Builder.CreateElementBitCast(addr, coercionType);
|
||||
|
@ -4493,7 +4471,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
for (unsigned i = 0, e = coercionType->getNumElements(); i != e; ++i) {
|
||||
llvm::Type *eltType = coercionType->getElementType(i);
|
||||
if (ABIArgInfo::isPaddingForCoerceAndExpand(eltType)) continue;
|
||||
Address eltAddr = Builder.CreateStructGEP(addr, i, layout);
|
||||
Address eltAddr = Builder.CreateStructGEP(addr, i);
|
||||
llvm::Value *elt = CI;
|
||||
if (requiresExtract)
|
||||
elt = Builder.CreateExtractValue(elt, unpaddedIndex++);
|
||||
|
|
|
@ -52,12 +52,8 @@ DominatingValue<RValue>::saved_type::save(CodeGenFunction &CGF, RValue rv) {
|
|||
llvm::Type *ComplexTy =
|
||||
llvm::StructType::get(V.first->getType(), V.second->getType());
|
||||
Address addr = CGF.CreateDefaultAlignTempAlloca(ComplexTy, "saved-complex");
|
||||
CGF.Builder.CreateStore(V.first,
|
||||
CGF.Builder.CreateStructGEP(addr, 0, CharUnits()));
|
||||
CharUnits offset = CharUnits::fromQuantity(
|
||||
CGF.CGM.getDataLayout().getTypeAllocSize(V.first->getType()));
|
||||
CGF.Builder.CreateStore(V.second,
|
||||
CGF.Builder.CreateStructGEP(addr, 1, offset));
|
||||
CGF.Builder.CreateStore(V.first, CGF.Builder.CreateStructGEP(addr, 0));
|
||||
CGF.Builder.CreateStore(V.second, CGF.Builder.CreateStructGEP(addr, 1));
|
||||
return saved_type(addr.getPointer(), ComplexAddress);
|
||||
}
|
||||
|
||||
|
@ -95,12 +91,10 @@ RValue DominatingValue<RValue>::saved_type::restore(CodeGenFunction &CGF) {
|
|||
}
|
||||
case ComplexAddress: {
|
||||
Address address = getSavingAddress(Value);
|
||||
llvm::Value *real = CGF.Builder.CreateLoad(
|
||||
CGF.Builder.CreateStructGEP(address, 0, CharUnits()));
|
||||
CharUnits offset = CharUnits::fromQuantity(
|
||||
CGF.CGM.getDataLayout().getTypeAllocSize(real->getType()));
|
||||
llvm::Value *imag = CGF.Builder.CreateLoad(
|
||||
CGF.Builder.CreateStructGEP(address, 1, offset));
|
||||
llvm::Value *real =
|
||||
CGF.Builder.CreateLoad(CGF.Builder.CreateStructGEP(address, 0));
|
||||
llvm::Value *imag =
|
||||
CGF.Builder.CreateLoad(CGF.Builder.CreateStructGEP(address, 1));
|
||||
return RValue::getComplex(real, imag);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -917,9 +917,8 @@ static void emitStoresForInitAfterBZero(CodeGenModule &CGM,
|
|||
// If necessary, get a pointer to the element and emit it.
|
||||
if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
|
||||
emitStoresForInitAfterBZero(
|
||||
CGM, Elt,
|
||||
Builder.CreateConstInBoundsGEP2_32(Loc, 0, i, CGM.getDataLayout()),
|
||||
isVolatile, Builder);
|
||||
CGM, Elt, Builder.CreateConstInBoundsGEP2_32(Loc, 0, i), isVolatile,
|
||||
Builder);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -932,10 +931,9 @@ static void emitStoresForInitAfterBZero(CodeGenModule &CGM,
|
|||
|
||||
// If necessary, get a pointer to the element and emit it.
|
||||
if (!Elt->isNullValue() && !isa<llvm::UndefValue>(Elt))
|
||||
emitStoresForInitAfterBZero(
|
||||
CGM, Elt,
|
||||
Builder.CreateConstInBoundsGEP2_32(Loc, 0, i, CGM.getDataLayout()),
|
||||
isVolatile, Builder);
|
||||
emitStoresForInitAfterBZero(CGM, Elt,
|
||||
Builder.CreateConstInBoundsGEP2_32(Loc, 0, i),
|
||||
isVolatile, Builder);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1884,7 +1884,6 @@ Address CodeGenFunction::EmitExtVectorElementLValue(LValue LV) {
|
|||
|
||||
Address VectorBasePtrPlusIx =
|
||||
Builder.CreateConstInBoundsGEP(CastToPointerElement, ix,
|
||||
getContext().getTypeSizeInChars(EQT),
|
||||
"vector.elt");
|
||||
|
||||
return VectorBasePtrPlusIx;
|
||||
|
@ -3824,20 +3823,7 @@ static Address emitAddrOfFieldStorage(CodeGenFunction &CGF, Address base,
|
|||
unsigned idx =
|
||||
CGF.CGM.getTypes().getCGRecordLayout(rec).getLLVMFieldNo(field);
|
||||
|
||||
CharUnits offset;
|
||||
// Adjust the alignment down to the given offset.
|
||||
// As a special case, if the LLVM field index is 0, we know that this
|
||||
// is zero.
|
||||
assert((idx != 0 || CGF.getContext().getASTRecordLayout(rec)
|
||||
.getFieldOffset(field->getFieldIndex()) == 0) &&
|
||||
"LLVM field at index zero had non-zero offset?");
|
||||
if (idx != 0) {
|
||||
auto &recLayout = CGF.getContext().getASTRecordLayout(rec);
|
||||
auto offsetInBits = recLayout.getFieldOffset(field->getFieldIndex());
|
||||
offset = CGF.getContext().toCharUnitsFromBits(offsetInBits);
|
||||
}
|
||||
|
||||
return CGF.Builder.CreateStructGEP(base, idx, offset, field->getName());
|
||||
return CGF.Builder.CreateStructGEP(base, idx, field->getName());
|
||||
}
|
||||
|
||||
static bool hasAnyVptr(const QualType Type, const ASTContext &Context) {
|
||||
|
@ -3871,8 +3857,7 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
|
|||
unsigned Idx = RL.getLLVMFieldNo(field);
|
||||
if (Idx != 0)
|
||||
// For structs, we GEP to the field that the record layout suggests.
|
||||
Addr = Builder.CreateStructGEP(Addr, Idx, Info.StorageOffset,
|
||||
field->getName());
|
||||
Addr = Builder.CreateStructGEP(Addr, Idx, field->getName());
|
||||
// Get the access type.
|
||||
llvm::Type *FieldIntTy =
|
||||
llvm::Type::getIntNTy(getLLVMContext(), Info.StorageSize);
|
||||
|
|
|
@ -759,8 +759,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
|
|||
|
||||
// Build a GEP to refer to the subobject.
|
||||
Address valueAddr =
|
||||
CGF.Builder.CreateStructGEP(valueDest.getAddress(), 0,
|
||||
CharUnits());
|
||||
CGF.Builder.CreateStructGEP(valueDest.getAddress(), 0);
|
||||
valueDest = AggValueSlot::forAddr(valueAddr,
|
||||
valueDest.getQualifiers(),
|
||||
valueDest.isExternallyDestructed(),
|
||||
|
@ -780,8 +779,7 @@ void AggExprEmitter::VisitCastExpr(CastExpr *E) {
|
|||
CGF.CreateAggTemp(atomicType, "atomic-to-nonatomic.temp");
|
||||
CGF.EmitAggExpr(E->getSubExpr(), atomicSlot);
|
||||
|
||||
Address valueAddr =
|
||||
Builder.CreateStructGEP(atomicSlot.getAddress(), 0, CharUnits());
|
||||
Address valueAddr = Builder.CreateStructGEP(atomicSlot.getAddress(), 0);
|
||||
RValue rvalue = RValue::getAggregate(valueAddr, atomicSlot.isVolatile());
|
||||
return EmitFinalDestCopy(valueType, rvalue);
|
||||
}
|
||||
|
|
|
@ -327,15 +327,12 @@ public:
|
|||
|
||||
Address CodeGenFunction::emitAddrOfRealComponent(Address addr,
|
||||
QualType complexType) {
|
||||
CharUnits offset = CharUnits::Zero();
|
||||
return Builder.CreateStructGEP(addr, 0, offset, addr.getName() + ".realp");
|
||||
return Builder.CreateStructGEP(addr, 0, addr.getName() + ".realp");
|
||||
}
|
||||
|
||||
Address CodeGenFunction::emitAddrOfImagComponent(Address addr,
|
||||
QualType complexType) {
|
||||
QualType eltType = complexType->castAs<ComplexType>()->getElementType();
|
||||
CharUnits offset = getContext().getTypeSizeInChars(eltType);
|
||||
return Builder.CreateStructGEP(addr, 1, offset, addr.getName() + ".imagp");
|
||||
return Builder.CreateStructGEP(addr, 1, addr.getName() + ".imagp");
|
||||
}
|
||||
|
||||
/// EmitLoadOfLValue - Given an RValue reference for a complex, emit code to
|
||||
|
|
|
@ -413,8 +413,7 @@ template <class Derived> struct GenFuncBase {
|
|||
if (Offset.getQuantity() == 0)
|
||||
return Addr;
|
||||
Addr = CGF->Builder.CreateBitCast(Addr, CGF->CGM.Int8PtrTy);
|
||||
Addr = CGF->Builder.CreateConstInBoundsGEP(Addr, Offset.getQuantity(),
|
||||
CharUnits::One());
|
||||
Addr = CGF->Builder.CreateConstInBoundsGEP(Addr, Offset.getQuantity());
|
||||
return CGF->Builder.CreateBitCast(Addr, CGF->CGM.Int8PtrPtrTy);
|
||||
}
|
||||
|
||||
|
|
|
@ -158,9 +158,8 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E,
|
|||
if (ALE) {
|
||||
// Emit the element and store it to the appropriate array slot.
|
||||
const Expr *Rhs = ALE->getElement(i);
|
||||
LValue LV = MakeAddrLValue(
|
||||
Builder.CreateConstArrayGEP(Objects, i, getPointerSize()),
|
||||
ElementType, AlignmentSource::Decl);
|
||||
LValue LV = MakeAddrLValue(Builder.CreateConstArrayGEP(Objects, i),
|
||||
ElementType, AlignmentSource::Decl);
|
||||
|
||||
llvm::Value *value = EmitScalarExpr(Rhs);
|
||||
EmitStoreThroughLValue(RValue::get(value), LV, true);
|
||||
|
@ -170,17 +169,15 @@ llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E,
|
|||
} else {
|
||||
// Emit the key and store it to the appropriate array slot.
|
||||
const Expr *Key = DLE->getKeyValueElement(i).Key;
|
||||
LValue KeyLV = MakeAddrLValue(
|
||||
Builder.CreateConstArrayGEP(Keys, i, getPointerSize()),
|
||||
ElementType, AlignmentSource::Decl);
|
||||
LValue KeyLV = MakeAddrLValue(Builder.CreateConstArrayGEP(Keys, i),
|
||||
ElementType, AlignmentSource::Decl);
|
||||
llvm::Value *keyValue = EmitScalarExpr(Key);
|
||||
EmitStoreThroughLValue(RValue::get(keyValue), KeyLV, /*isInit=*/true);
|
||||
|
||||
// Emit the value and store it to the appropriate array slot.
|
||||
const Expr *Value = DLE->getKeyValueElement(i).Value;
|
||||
LValue ValueLV = MakeAddrLValue(
|
||||
Builder.CreateConstArrayGEP(Objects, i, getPointerSize()),
|
||||
ElementType, AlignmentSource::Decl);
|
||||
LValue ValueLV = MakeAddrLValue(Builder.CreateConstArrayGEP(Objects, i),
|
||||
ElementType, AlignmentSource::Decl);
|
||||
llvm::Value *valueValue = EmitScalarExpr(Value);
|
||||
EmitStoreThroughLValue(RValue::get(valueValue), ValueLV, /*isInit=*/true);
|
||||
if (TrackNeededObjects) {
|
||||
|
@ -1666,8 +1663,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
|
|||
// Save the initial mutations value. This is the value at an
|
||||
// address that was written into the state object by
|
||||
// countByEnumeratingWithState:objects:count:.
|
||||
Address StateMutationsPtrPtr = Builder.CreateStructGEP(
|
||||
StatePtr, 2, 2 * getPointerSize(), "mutationsptr.ptr");
|
||||
Address StateMutationsPtrPtr =
|
||||
Builder.CreateStructGEP(StatePtr, 2, "mutationsptr.ptr");
|
||||
llvm::Value *StateMutationsPtr
|
||||
= Builder.CreateLoad(StateMutationsPtrPtr, "mutationsptr");
|
||||
|
||||
|
@ -1748,8 +1745,8 @@ void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){
|
|||
// Fetch the buffer out of the enumeration state.
|
||||
// TODO: this pointer should actually be invariant between
|
||||
// refreshes, which would help us do certain loop optimizations.
|
||||
Address StateItemsPtr = Builder.CreateStructGEP(
|
||||
StatePtr, 1, getPointerSize(), "stateitems.ptr");
|
||||
Address StateItemsPtr =
|
||||
Builder.CreateStructGEP(StatePtr, 1, "stateitems.ptr");
|
||||
llvm::Value *EnumStateItems =
|
||||
Builder.CreateLoad(StateItemsPtr, "stateitems");
|
||||
|
||||
|
|
|
@ -2473,10 +2473,8 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
|
|||
Address ObjCSuper = CGF.CreateTempAlloca(ObjCSuperTy,
|
||||
CGF.getPointerAlign());
|
||||
|
||||
Builder.CreateStore(Receiver,
|
||||
Builder.CreateStructGEP(ObjCSuper, 0, CharUnits::Zero()));
|
||||
Builder.CreateStore(ReceiverClass,
|
||||
Builder.CreateStructGEP(ObjCSuper, 1, CGF.getPointerSize()));
|
||||
Builder.CreateStore(Receiver, Builder.CreateStructGEP(ObjCSuper, 0));
|
||||
Builder.CreateStore(ReceiverClass, Builder.CreateStructGEP(ObjCSuper, 1));
|
||||
|
||||
ObjCSuper = EnforceType(Builder, ObjCSuper, PtrToObjCSuperTy);
|
||||
|
||||
|
|
|
@ -2008,9 +2008,8 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
|
|||
"objc_super");
|
||||
llvm::Value *ReceiverAsObject =
|
||||
CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);
|
||||
CGF.Builder.CreateStore(
|
||||
ReceiverAsObject,
|
||||
CGF.Builder.CreateStructGEP(ObjCSuper, 0, CharUnits::Zero()));
|
||||
CGF.Builder.CreateStore(ReceiverAsObject,
|
||||
CGF.Builder.CreateStructGEP(ObjCSuper, 0));
|
||||
|
||||
// If this is a class message the metaclass is passed as the target.
|
||||
llvm::Value *Target;
|
||||
|
@ -2045,8 +2044,7 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
|
|||
llvm::Type *ClassTy =
|
||||
CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());
|
||||
Target = CGF.Builder.CreateBitCast(Target, ClassTy);
|
||||
CGF.Builder.CreateStore(Target,
|
||||
CGF.Builder.CreateStructGEP(ObjCSuper, 1, CGF.getPointerSize()));
|
||||
CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1));
|
||||
return EmitMessageSend(CGF, Return, ResultType,
|
||||
EmitSelector(CGF, Sel),
|
||||
ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy,
|
||||
|
@ -7156,8 +7154,7 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF,
|
|||
args[1].setRValue(RValue::get(mref.getPointer()));
|
||||
|
||||
// Load the function to call from the message ref table.
|
||||
Address calleeAddr =
|
||||
CGF.Builder.CreateStructGEP(mref, 0, CharUnits::Zero());
|
||||
Address calleeAddr = CGF.Builder.CreateStructGEP(mref, 0);
|
||||
llvm::Value *calleePtr = CGF.Builder.CreateLoad(calleeAddr, "msgSend_fn");
|
||||
|
||||
calleePtr = CGF.Builder.CreateBitCast(calleePtr, MSI.MessengerType);
|
||||
|
@ -7354,9 +7351,8 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
|
|||
|
||||
llvm::Value *ReceiverAsObject =
|
||||
CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy);
|
||||
CGF.Builder.CreateStore(
|
||||
ReceiverAsObject,
|
||||
CGF.Builder.CreateStructGEP(ObjCSuper, 0, CharUnits::Zero()));
|
||||
CGF.Builder.CreateStore(ReceiverAsObject,
|
||||
CGF.Builder.CreateStructGEP(ObjCSuper, 0));
|
||||
|
||||
// If this is a class message the metaclass is passed as the target.
|
||||
llvm::Value *Target;
|
||||
|
@ -7370,8 +7366,7 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF,
|
|||
llvm::Type *ClassTy =
|
||||
CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType());
|
||||
Target = CGF.Builder.CreateBitCast(Target, ClassTy);
|
||||
CGF.Builder.CreateStore(
|
||||
Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1, CGF.getPointerSize()));
|
||||
CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1));
|
||||
|
||||
return (isVTableDispatchedSelector(Sel))
|
||||
? EmitVTableMessageSend(CGF, Return, ResultType, Sel,
|
||||
|
|
|
@ -3090,8 +3090,7 @@ void CGOpenMPRuntime::emitTaskgroupRegion(CodeGenFunction &CGF,
|
|||
static Address emitAddrOfVarFromArray(CodeGenFunction &CGF, Address Array,
|
||||
unsigned Index, const VarDecl *Var) {
|
||||
// Pull out the pointer to the variable.
|
||||
Address PtrAddr =
|
||||
CGF.Builder.CreateConstArrayGEP(Array, Index, CGF.getPointerSize());
|
||||
Address PtrAddr = CGF.Builder.CreateConstArrayGEP(Array, Index);
|
||||
llvm::Value *Ptr = CGF.Builder.CreateLoad(PtrAddr);
|
||||
|
||||
Address Addr = Address(Ptr, CGF.getContext().getDeclAlign(Var));
|
||||
|
@ -3207,8 +3206,7 @@ void CGOpenMPRuntime::emitSingleRegion(CodeGenFunction &CGF,
|
|||
Address CopyprivateList =
|
||||
CGF.CreateMemTemp(CopyprivateArrayTy, ".omp.copyprivate.cpr_list");
|
||||
for (unsigned I = 0, E = CopyprivateVars.size(); I < E; ++I) {
|
||||
Address Elem = CGF.Builder.CreateConstArrayGEP(
|
||||
CopyprivateList, I, CGF.getPointerSize());
|
||||
Address Elem = CGF.Builder.CreateConstArrayGEP(CopyprivateList, I);
|
||||
CGF.Builder.CreateStore(
|
||||
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
|
||||
CGF.EmitLValue(CopyprivateVars[I]).getPointer(), CGF.VoidPtrTy),
|
||||
|
@ -5105,7 +5103,6 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
|
|||
} else {
|
||||
KmpDependInfoRD = cast<RecordDecl>(KmpDependInfoTy->getAsTagDecl());
|
||||
}
|
||||
CharUnits DependencySize = C.getTypeSizeInChars(KmpDependInfoTy);
|
||||
// Define type kmp_depend_info[<Dependences.size()>];
|
||||
QualType KmpDependInfoArrayTy = C.getConstantArrayType(
|
||||
KmpDependInfoTy, llvm::APInt(/*numBits=*/64, NumDependencies),
|
||||
|
@ -5132,7 +5129,7 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, SourceLocation Loc,
|
|||
Size = CGF.getTypeSize(Ty);
|
||||
}
|
||||
LValue Base = CGF.MakeAddrLValue(
|
||||
CGF.Builder.CreateConstArrayGEP(DependenciesArray, I, DependencySize),
|
||||
CGF.Builder.CreateConstArrayGEP(DependenciesArray, I),
|
||||
KmpDependInfoTy);
|
||||
// deps[i].base_addr = &<Dependences[i].second>;
|
||||
LValue BaseAddrLVal = CGF.EmitLValueForField(
|
||||
|
@ -5499,8 +5496,7 @@ llvm::Function *CGOpenMPRuntime::emitReductionFunction(
|
|||
if (PrivTy->isVariablyModifiedType()) {
|
||||
// Get array size and emit VLA type.
|
||||
++Idx;
|
||||
Address Elem =
|
||||
CGF.Builder.CreateConstArrayGEP(LHS, Idx, CGF.getPointerSize());
|
||||
Address Elem = CGF.Builder.CreateConstArrayGEP(LHS, Idx);
|
||||
llvm::Value *Ptr = CGF.Builder.CreateLoad(Elem);
|
||||
const VariableArrayType *VLA =
|
||||
CGF.getContext().getAsVariableArrayType(PrivTy);
|
||||
|
@ -5638,8 +5634,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
|
|||
auto IPriv = Privates.begin();
|
||||
unsigned Idx = 0;
|
||||
for (unsigned I = 0, E = RHSExprs.size(); I < E; ++I, ++IPriv, ++Idx) {
|
||||
Address Elem =
|
||||
CGF.Builder.CreateConstArrayGEP(ReductionList, Idx, CGF.getPointerSize());
|
||||
Address Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx);
|
||||
CGF.Builder.CreateStore(
|
||||
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
|
||||
CGF.EmitLValue(RHSExprs[I]).getPointer(), CGF.VoidPtrTy),
|
||||
|
@ -5647,8 +5642,7 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
|
|||
if ((*IPriv)->getType()->isVariablyModifiedType()) {
|
||||
// Store array size.
|
||||
++Idx;
|
||||
Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx,
|
||||
CGF.getPointerSize());
|
||||
Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx);
|
||||
llvm::Value *Size = CGF.Builder.CreateIntCast(
|
||||
CGF.getVLASize(
|
||||
CGF.getContext().getAsVariableArrayType((*IPriv)->getType()))
|
||||
|
@ -7168,7 +7162,7 @@ private:
|
|||
Address HB = CGF.Builder.CreateConstGEP(
|
||||
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(LB,
|
||||
CGF.VoidPtrTy),
|
||||
TypeSize.getQuantity() - 1, CharUnits::One());
|
||||
TypeSize.getQuantity() - 1);
|
||||
PartialStruct.HighestElem = {
|
||||
std::numeric_limits<decltype(
|
||||
PartialStruct.HighestElem.first)>::max(),
|
||||
|
@ -7202,15 +7196,13 @@ private:
|
|||
Pointers.push_back(LB.getPointer());
|
||||
Sizes.push_back(Size);
|
||||
Types.push_back(Flags);
|
||||
LB = CGF.Builder.CreateConstGEP(ComponentLB, 1,
|
||||
CGF.getPointerSize());
|
||||
LB = CGF.Builder.CreateConstGEP(ComponentLB, 1);
|
||||
}
|
||||
BasePointers.push_back(BP.getPointer());
|
||||
Pointers.push_back(LB.getPointer());
|
||||
Size = CGF.Builder.CreatePtrDiff(
|
||||
CGF.EmitCastToVoidPtr(
|
||||
CGF.Builder.CreateConstGEP(HB, 1, CharUnits::One())
|
||||
.getPointer()),
|
||||
CGF.Builder.CreateConstGEP(HB, 1).getPointer()),
|
||||
CGF.EmitCastToVoidPtr(LB.getPointer()));
|
||||
Sizes.push_back(Size);
|
||||
Types.push_back(Flags);
|
||||
|
@ -9491,10 +9483,8 @@ void CGOpenMPRuntime::emitDoacrossInit(CodeGenFunction &CGF,
|
|||
enum { LowerFD = 0, UpperFD, StrideFD };
|
||||
// Fill dims with data.
|
||||
for (unsigned I = 0, E = NumIterations.size(); I < E; ++I) {
|
||||
LValue DimsLVal =
|
||||
CGF.MakeAddrLValue(CGF.Builder.CreateConstArrayGEP(
|
||||
DimsAddr, I, C.getTypeSizeInChars(KmpDimTy)),
|
||||
KmpDimTy);
|
||||
LValue DimsLVal = CGF.MakeAddrLValue(
|
||||
CGF.Builder.CreateConstArrayGEP(DimsAddr, I), KmpDimTy);
|
||||
// dims.upper = num_iterations;
|
||||
LValue UpperLVal = CGF.EmitLValueForField(
|
||||
DimsLVal, *std::next(RD->field_begin(), UpperFD));
|
||||
|
@ -9517,9 +9507,7 @@ void CGOpenMPRuntime::emitDoacrossInit(CodeGenFunction &CGF,
|
|||
getThreadID(CGF, D.getBeginLoc()),
|
||||
llvm::ConstantInt::getSigned(CGM.Int32Ty, NumIterations.size()),
|
||||
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
|
||||
CGF.Builder
|
||||
.CreateConstArrayGEP(DimsAddr, 0, C.getTypeSizeInChars(KmpDimTy))
|
||||
.getPointer(),
|
||||
CGF.Builder.CreateConstArrayGEP(DimsAddr, 0).getPointer(),
|
||||
CGM.VoidPtrTy)};
|
||||
|
||||
llvm::FunctionCallee RTLFn =
|
||||
|
@ -9547,19 +9535,13 @@ void CGOpenMPRuntime::emitDoacrossOrdered(CodeGenFunction &CGF,
|
|||
llvm::Value *CntVal = CGF.EmitScalarConversion(
|
||||
CGF.EmitScalarExpr(CounterVal), CounterVal->getType(), Int64Ty,
|
||||
CounterVal->getExprLoc());
|
||||
CGF.EmitStoreOfScalar(
|
||||
CntVal,
|
||||
CGF.Builder.CreateConstArrayGEP(
|
||||
CntAddr, I, CGM.getContext().getTypeSizeInChars(Int64Ty)),
|
||||
/*Volatile=*/false, Int64Ty);
|
||||
CGF.EmitStoreOfScalar(CntVal, CGF.Builder.CreateConstArrayGEP(CntAddr, I),
|
||||
/*Volatile=*/false, Int64Ty);
|
||||
}
|
||||
llvm::Value *Args[] = {
|
||||
emitUpdateLocation(CGF, C->getBeginLoc()),
|
||||
getThreadID(CGF, C->getBeginLoc()),
|
||||
CGF.Builder
|
||||
.CreateConstArrayGEP(CntAddr, 0,
|
||||
CGM.getContext().getTypeSizeInChars(Int64Ty))
|
||||
.getPointer()};
|
||||
CGF.Builder.CreateConstArrayGEP(CntAddr, 0).getPointer()};
|
||||
llvm::FunctionCallee RTLFn;
|
||||
if (C->getDependencyKind() == OMPC_DEPEND_source) {
|
||||
RTLFn = createRuntimeFunction(OMPRTL__kmpc_doacross_post);
|
||||
|
|
|
@ -2240,8 +2240,7 @@ void CGOpenMPRuntimeNVPTX::emitGenericVarsProlog(CodeGenFunction &CGF,
|
|||
.getPointerType(CGM.getContext().VoidPtrTy)
|
||||
.castAs<PointerType>());
|
||||
llvm::Value *GlobalRecValue =
|
||||
Bld.CreateConstInBoundsGEP(FrameAddr, Offset, CharUnits::One())
|
||||
.getPointer();
|
||||
Bld.CreateConstInBoundsGEP(FrameAddr, Offset).getPointer();
|
||||
I->getSecond().GlobalRecordAddr = GlobalRecValue;
|
||||
I->getSecond().IsInSPMDModeFlag = nullptr;
|
||||
GlobalRecCastAddr = Bld.CreatePointerBitCastOrAddrSpaceCast(
|
||||
|
@ -2541,8 +2540,7 @@ void CGOpenMPRuntimeNVPTX::emitNonSPMDParallelCall(
|
|||
SharedArgs, Ctx.getPointerType(Ctx.getPointerType(Ctx.VoidPtrTy))
|
||||
.castAs<PointerType>());
|
||||
for (llvm::Value *V : CapturedVars) {
|
||||
Address Dst = Bld.CreateConstInBoundsGEP(SharedArgListAddress, Idx,
|
||||
CGF.getPointerSize());
|
||||
Address Dst = Bld.CreateConstInBoundsGEP(SharedArgListAddress, Idx);
|
||||
llvm::Value *PtrV;
|
||||
if (V->getType()->isIntegerTy())
|
||||
PtrV = Bld.CreateIntToPtr(V, CGF.VoidPtrTy);
|
||||
|
@ -2851,7 +2849,7 @@ static void shuffleAndStore(CodeGenFunction &CGF, Address SrcAddr,
|
|||
Address ElemPtr = DestAddr;
|
||||
Address Ptr = SrcAddr;
|
||||
Address PtrEnd = Bld.CreatePointerBitCastOrAddrSpaceCast(
|
||||
Bld.CreateConstGEP(SrcAddr, 1, Size), CGF.VoidPtrTy);
|
||||
Bld.CreateConstGEP(SrcAddr, 1), CGF.VoidPtrTy);
|
||||
for (int IntSize = 8; IntSize >= 1; IntSize /= 2) {
|
||||
if (Size < CharUnits::fromQuantity(IntSize))
|
||||
continue;
|
||||
|
@ -2886,10 +2884,8 @@ static void shuffleAndStore(CodeGenFunction &CGF, Address SrcAddr,
|
|||
CGF, CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc),
|
||||
IntType, Offset, Loc);
|
||||
CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType);
|
||||
Address LocalPtr =
|
||||
Bld.CreateConstGEP(Ptr, 1, CharUnits::fromQuantity(IntSize));
|
||||
Address LocalElemPtr =
|
||||
Bld.CreateConstGEP(ElemPtr, 1, CharUnits::fromQuantity(IntSize));
|
||||
Address LocalPtr = Bld.CreateConstGEP(Ptr, 1);
|
||||
Address LocalElemPtr = Bld.CreateConstGEP(ElemPtr, 1);
|
||||
PhiSrc->addIncoming(LocalPtr.getPointer(), ThenBB);
|
||||
PhiDest->addIncoming(LocalElemPtr.getPointer(), ThenBB);
|
||||
CGF.EmitBranch(PreCondBB);
|
||||
|
@ -2899,9 +2895,8 @@ static void shuffleAndStore(CodeGenFunction &CGF, Address SrcAddr,
|
|||
CGF, CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc),
|
||||
IntType, Offset, Loc);
|
||||
CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType);
|
||||
Ptr = Bld.CreateConstGEP(Ptr, 1, CharUnits::fromQuantity(IntSize));
|
||||
ElemPtr =
|
||||
Bld.CreateConstGEP(ElemPtr, 1, CharUnits::fromQuantity(IntSize));
|
||||
Ptr = Bld.CreateConstGEP(Ptr, 1);
|
||||
ElemPtr = Bld.CreateConstGEP(ElemPtr, 1);
|
||||
}
|
||||
Size = Size % IntSize;
|
||||
}
|
||||
|
@ -2964,16 +2959,14 @@ static void emitReductionListCopy(
|
|||
switch (Action) {
|
||||
case RemoteLaneToThread: {
|
||||
// Step 1.1: Get the address for the src element in the Reduce list.
|
||||
Address SrcElementPtrAddr =
|
||||
Bld.CreateConstArrayGEP(SrcBase, Idx, CGF.getPointerSize());
|
||||
Address SrcElementPtrAddr = Bld.CreateConstArrayGEP(SrcBase, Idx);
|
||||
SrcElementAddr = CGF.EmitLoadOfPointer(
|
||||
SrcElementPtrAddr,
|
||||
C.getPointerType(Private->getType())->castAs<PointerType>());
|
||||
|
||||
// Step 1.2: Create a temporary to store the element in the destination
|
||||
// Reduce list.
|
||||
DestElementPtrAddr =
|
||||
Bld.CreateConstArrayGEP(DestBase, Idx, CGF.getPointerSize());
|
||||
DestElementPtrAddr = Bld.CreateConstArrayGEP(DestBase, Idx);
|
||||
DestElementAddr =
|
||||
CGF.CreateMemTemp(Private->getType(), ".omp.reduction.element");
|
||||
ShuffleInElement = true;
|
||||
|
@ -2982,16 +2975,14 @@ 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, CGF.getPointerSize());
|
||||
Address SrcElementPtrAddr = Bld.CreateConstArrayGEP(SrcBase, Idx);
|
||||
SrcElementAddr = CGF.EmitLoadOfPointer(
|
||||
SrcElementPtrAddr,
|
||||
C.getPointerType(Private->getType())->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, CGF.getPointerSize());
|
||||
DestElementPtrAddr = Bld.CreateConstArrayGEP(DestBase, Idx);
|
||||
DestElementAddr = CGF.EmitLoadOfPointer(
|
||||
DestElementPtrAddr,
|
||||
C.getPointerType(Private->getType())->castAs<PointerType>());
|
||||
|
@ -2999,8 +2990,7 @@ static void emitReductionListCopy(
|
|||
}
|
||||
case ThreadToScratchpad: {
|
||||
// Step 1.1: Get the address for the src element in the Reduce list.
|
||||
Address SrcElementPtrAddr =
|
||||
Bld.CreateConstArrayGEP(SrcBase, Idx, CGF.getPointerSize());
|
||||
Address SrcElementPtrAddr = Bld.CreateConstArrayGEP(SrcBase, Idx);
|
||||
SrcElementAddr = CGF.EmitLoadOfPointer(
|
||||
SrcElementPtrAddr,
|
||||
C.getPointerType(Private->getType())->castAs<PointerType>());
|
||||
|
@ -3035,8 +3025,7 @@ static void emitReductionListCopy(
|
|||
|
||||
// Step 1.2: Create a temporary to store the element in the destination
|
||||
// Reduce list.
|
||||
DestElementPtrAddr =
|
||||
Bld.CreateConstArrayGEP(DestBase, Idx, CGF.getPointerSize());
|
||||
DestElementPtrAddr = Bld.CreateConstArrayGEP(DestBase, Idx);
|
||||
DestElementAddr =
|
||||
CGF.CreateMemTemp(Private->getType(), ".omp.reduction.element");
|
||||
UpdateDestListPtr = true;
|
||||
|
@ -3251,8 +3240,7 @@ static llvm::Value *emitInterWarpCopyFunction(CodeGenModule &CGM,
|
|||
CGF.EmitBlock(ThenBB);
|
||||
|
||||
// Reduce element = LocalReduceList[i]
|
||||
Address ElemPtrPtrAddr =
|
||||
Bld.CreateConstArrayGEP(LocalReduceList, Idx, CGF.getPointerSize());
|
||||
Address ElemPtrPtrAddr = Bld.CreateConstArrayGEP(LocalReduceList, Idx);
|
||||
llvm::Value *ElemPtrPtr = CGF.EmitLoadOfScalar(
|
||||
ElemPtrPtrAddr, /*Volatile=*/false, C.VoidPtrTy, SourceLocation());
|
||||
// elemptr = ((CopyType*)(elemptrptr)) + I
|
||||
|
@ -3318,8 +3306,7 @@ static llvm::Value *emitInterWarpCopyFunction(CodeGenModule &CGM,
|
|||
SrcMediumPtr = Bld.CreateElementBitCast(SrcMediumPtr, CopyType);
|
||||
|
||||
// TargetElemPtr = (CopyType*)(SrcDataAddr[i]) + I
|
||||
Address TargetElemPtrPtr =
|
||||
Bld.CreateConstArrayGEP(LocalReduceList, Idx, CGF.getPointerSize());
|
||||
Address TargetElemPtrPtr = Bld.CreateConstArrayGEP(LocalReduceList, Idx);
|
||||
llvm::Value *TargetElemPtrVal = CGF.EmitLoadOfScalar(
|
||||
TargetElemPtrPtr, /*Volatile=*/false, C.VoidPtrTy, Loc);
|
||||
Address TargetElemPtr = Address(TargetElemPtrVal, Align);
|
||||
|
@ -3865,8 +3852,7 @@ void CGOpenMPRuntimeNVPTX::emitReduction(
|
|||
auto IPriv = Privates.begin();
|
||||
unsigned Idx = 0;
|
||||
for (unsigned I = 0, E = RHSExprs.size(); I < E; ++I, ++IPriv, ++Idx) {
|
||||
Address Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx,
|
||||
CGF.getPointerSize());
|
||||
Address Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx);
|
||||
CGF.Builder.CreateStore(
|
||||
CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
|
||||
CGF.EmitLValue(RHSExprs[I]).getPointer(), CGF.VoidPtrTy),
|
||||
|
@ -3874,8 +3860,7 @@ void CGOpenMPRuntimeNVPTX::emitReduction(
|
|||
if ((*IPriv)->getType()->isVariablyModifiedType()) {
|
||||
// Store array size.
|
||||
++Idx;
|
||||
Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx,
|
||||
CGF.getPointerSize());
|
||||
Elem = CGF.Builder.CreateConstArrayGEP(ReductionList, Idx);
|
||||
llvm::Value *Size = CGF.Builder.CreateIntCast(
|
||||
CGF.getVLASize(
|
||||
CGF.getContext().getAsVariableArrayType((*IPriv)->getType()))
|
||||
|
@ -4141,8 +4126,7 @@ llvm::Function *CGOpenMPRuntimeNVPTX::createParallelDataSharingWrapper(
|
|||
}
|
||||
unsigned Idx = 0;
|
||||
if (isOpenMPLoopBoundSharingDirective(D.getDirectiveKind())) {
|
||||
Address Src = Bld.CreateConstInBoundsGEP(SharedArgListAddress, Idx,
|
||||
CGF.getPointerSize());
|
||||
Address Src = Bld.CreateConstInBoundsGEP(SharedArgListAddress, Idx);
|
||||
Address TypedAddress = Bld.CreatePointerBitCastOrAddrSpaceCast(
|
||||
Src, CGF.SizeTy->getPointerTo());
|
||||
llvm::Value *LB = CGF.EmitLoadOfScalar(
|
||||
|
@ -4152,8 +4136,7 @@ llvm::Function *CGOpenMPRuntimeNVPTX::createParallelDataSharingWrapper(
|
|||
cast<OMPLoopDirective>(D).getLowerBoundVariable()->getExprLoc());
|
||||
Args.emplace_back(LB);
|
||||
++Idx;
|
||||
Src = Bld.CreateConstInBoundsGEP(SharedArgListAddress, Idx,
|
||||
CGF.getPointerSize());
|
||||
Src = Bld.CreateConstInBoundsGEP(SharedArgListAddress, Idx);
|
||||
TypedAddress = Bld.CreatePointerBitCastOrAddrSpaceCast(
|
||||
Src, CGF.SizeTy->getPointerTo());
|
||||
llvm::Value *UB = CGF.EmitLoadOfScalar(
|
||||
|
@ -4168,8 +4151,7 @@ llvm::Function *CGOpenMPRuntimeNVPTX::createParallelDataSharingWrapper(
|
|||
ASTContext &CGFContext = CGF.getContext();
|
||||
for (unsigned I = 0, E = CS.capture_size(); I < E; ++I, ++CI, ++CurField) {
|
||||
QualType ElemTy = CurField->getType();
|
||||
Address Src = Bld.CreateConstInBoundsGEP(SharedArgListAddress, I + Idx,
|
||||
CGF.getPointerSize());
|
||||
Address Src = Bld.CreateConstInBoundsGEP(SharedArgListAddress, I + Idx);
|
||||
Address TypedAddress = Bld.CreatePointerBitCastOrAddrSpaceCast(
|
||||
Src, CGF.ConvertTypeForMem(CGFContext.getPointerType(ElemTy)));
|
||||
llvm::Value *Arg = CGF.EmitLoadOfScalar(TypedAddress,
|
||||
|
|
|
@ -3158,11 +3158,11 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective(
|
|||
(void)Scope.Privatize();
|
||||
if (InputInfo.NumberOfTargetItems > 0) {
|
||||
InputInfo.BasePointersArray = CGF.Builder.CreateConstArrayGEP(
|
||||
CGF.GetAddrOfLocalVar(BPVD), /*Index=*/0, CGF.getPointerSize());
|
||||
CGF.GetAddrOfLocalVar(BPVD), /*Index=*/0);
|
||||
InputInfo.PointersArray = CGF.Builder.CreateConstArrayGEP(
|
||||
CGF.GetAddrOfLocalVar(PVD), /*Index=*/0, CGF.getPointerSize());
|
||||
CGF.GetAddrOfLocalVar(PVD), /*Index=*/0);
|
||||
InputInfo.SizesArray = CGF.Builder.CreateConstArrayGEP(
|
||||
CGF.GetAddrOfLocalVar(SVD), /*Index=*/0, CGF.getSizeSize());
|
||||
CGF.GetAddrOfLocalVar(SVD), /*Index=*/0);
|
||||
}
|
||||
|
||||
Action.Enter(CGF);
|
||||
|
|
|
@ -2023,7 +2023,7 @@ Address ARMCXXABI::InitializeArrayCookie(CodeGenFunction &CGF,
|
|||
CGF.Builder.CreateStore(elementSize, cookie);
|
||||
|
||||
// The second element is the element count.
|
||||
cookie = CGF.Builder.CreateConstInBoundsGEP(cookie, 1, CGF.getSizeSize());
|
||||
cookie = CGF.Builder.CreateConstInBoundsGEP(cookie, 1);
|
||||
CGF.Builder.CreateStore(numElements, cookie);
|
||||
|
||||
// Finally, compute a pointer to the actual data buffer by skipping
|
||||
|
|
|
@ -3641,8 +3641,8 @@ void X86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const {
|
|||
|
||||
static Address EmitX86_64VAArgFromMemory(CodeGenFunction &CGF,
|
||||
Address VAListAddr, QualType Ty) {
|
||||
Address overflow_arg_area_p = CGF.Builder.CreateStructGEP(
|
||||
VAListAddr, 2, CharUnits::fromQuantity(8), "overflow_arg_area_p");
|
||||
Address overflow_arg_area_p =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 2, "overflow_arg_area_p");
|
||||
llvm::Value *overflow_arg_area =
|
||||
CGF.Builder.CreateLoad(overflow_arg_area_p, "overflow_arg_area");
|
||||
|
||||
|
@ -3713,18 +3713,14 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
Address gp_offset_p = Address::invalid(), fp_offset_p = Address::invalid();
|
||||
llvm::Value *gp_offset = nullptr, *fp_offset = nullptr;
|
||||
if (neededInt) {
|
||||
gp_offset_p =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 0, CharUnits::Zero(),
|
||||
"gp_offset_p");
|
||||
gp_offset_p = CGF.Builder.CreateStructGEP(VAListAddr, 0, "gp_offset_p");
|
||||
gp_offset = CGF.Builder.CreateLoad(gp_offset_p, "gp_offset");
|
||||
InRegs = llvm::ConstantInt::get(CGF.Int32Ty, 48 - neededInt * 8);
|
||||
InRegs = CGF.Builder.CreateICmpULE(gp_offset, InRegs, "fits_in_gp");
|
||||
}
|
||||
|
||||
if (neededSSE) {
|
||||
fp_offset_p =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 1, CharUnits::fromQuantity(4),
|
||||
"fp_offset_p");
|
||||
fp_offset_p = CGF.Builder.CreateStructGEP(VAListAddr, 1, "fp_offset_p");
|
||||
fp_offset = CGF.Builder.CreateLoad(fp_offset_p, "fp_offset");
|
||||
llvm::Value *FitsInFP =
|
||||
llvm::ConstantInt::get(CGF.Int32Ty, 176 - neededSSE * 16);
|
||||
|
@ -3753,9 +3749,7 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
// loads than necessary. Can we clean this up?
|
||||
llvm::Type *LTy = CGF.ConvertTypeForMem(Ty);
|
||||
llvm::Value *RegSaveArea = CGF.Builder.CreateLoad(
|
||||
CGF.Builder.CreateStructGEP(
|
||||
VAListAddr, 3, CharUnits::fromQuantity(8) + CGF.getPointerSize()),
|
||||
"reg_save_area");
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 3), "reg_save_area");
|
||||
|
||||
Address RegAddr = Address::invalid();
|
||||
if (neededInt && neededSSE) {
|
||||
|
@ -3781,16 +3775,13 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
llvm::Value *V = CGF.Builder.CreateAlignedLoad(
|
||||
TyLo, CGF.Builder.CreateBitCast(RegLoAddr, PTyLo),
|
||||
CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(TyLo)));
|
||||
CGF.Builder.CreateStore(V,
|
||||
CGF.Builder.CreateStructGEP(Tmp, 0, CharUnits::Zero()));
|
||||
CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 0));
|
||||
|
||||
// Copy the second element.
|
||||
V = CGF.Builder.CreateAlignedLoad(
|
||||
TyHi, CGF.Builder.CreateBitCast(RegHiAddr, PTyHi),
|
||||
CharUnits::fromQuantity(getDataLayout().getABITypeAlignment(TyHi)));
|
||||
CharUnits Offset = CharUnits::fromQuantity(
|
||||
getDataLayout().getStructLayout(ST)->getElementOffset(1));
|
||||
CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1, Offset));
|
||||
CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
|
||||
|
||||
RegAddr = CGF.Builder.CreateElementBitCast(Tmp, LTy);
|
||||
} else if (neededInt) {
|
||||
|
@ -3837,12 +3828,10 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
Tmp = CGF.Builder.CreateElementBitCast(Tmp, ST);
|
||||
V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
|
||||
RegAddrLo, ST->getStructElementType(0)));
|
||||
CGF.Builder.CreateStore(V,
|
||||
CGF.Builder.CreateStructGEP(Tmp, 0, CharUnits::Zero()));
|
||||
CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 0));
|
||||
V = CGF.Builder.CreateLoad(CGF.Builder.CreateElementBitCast(
|
||||
RegAddrHi, ST->getStructElementType(1)));
|
||||
CGF.Builder.CreateStore(V,
|
||||
CGF.Builder.CreateStructGEP(Tmp, 1, CharUnits::fromQuantity(8)));
|
||||
CGF.Builder.CreateStore(V, CGF.Builder.CreateStructGEP(Tmp, 1));
|
||||
|
||||
RegAddr = CGF.Builder.CreateElementBitCast(Tmp, LTy);
|
||||
}
|
||||
|
@ -4184,9 +4173,9 @@ Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAList,
|
|||
// The calling convention either uses 1-2 GPRs or 1 FPR.
|
||||
Address NumRegsAddr = Address::invalid();
|
||||
if (isInt || IsSoftFloatABI) {
|
||||
NumRegsAddr = Builder.CreateStructGEP(VAList, 0, CharUnits::Zero(), "gpr");
|
||||
NumRegsAddr = Builder.CreateStructGEP(VAList, 0, "gpr");
|
||||
} else {
|
||||
NumRegsAddr = Builder.CreateStructGEP(VAList, 1, CharUnits::One(), "fpr");
|
||||
NumRegsAddr = Builder.CreateStructGEP(VAList, 1, "fpr");
|
||||
}
|
||||
|
||||
llvm::Value *NumRegs = Builder.CreateLoad(NumRegsAddr, "numUsedRegs");
|
||||
|
@ -4214,8 +4203,7 @@ Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAList,
|
|||
{
|
||||
CGF.EmitBlock(UsingRegs);
|
||||
|
||||
Address RegSaveAreaPtr =
|
||||
Builder.CreateStructGEP(VAList, 4, CharUnits::fromQuantity(8));
|
||||
Address RegSaveAreaPtr = Builder.CreateStructGEP(VAList, 4);
|
||||
RegAddr = Address(Builder.CreateLoad(RegSaveAreaPtr),
|
||||
CharUnits::fromQuantity(8));
|
||||
assert(RegAddr.getElementType() == CGF.Int8Ty);
|
||||
|
@ -4263,8 +4251,7 @@ Address PPC32_SVR4_ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAList,
|
|||
Size = CGF.getPointerSize();
|
||||
}
|
||||
|
||||
Address OverflowAreaAddr =
|
||||
Builder.CreateStructGEP(VAList, 3, CharUnits::fromQuantity(4));
|
||||
Address OverflowAreaAddr = Builder.CreateStructGEP(VAList, 3);
|
||||
Address OverflowArea(Builder.CreateLoad(OverflowAreaAddr, "argp.cur"),
|
||||
OverflowAreaAlign);
|
||||
// Round up address of argument to alignment
|
||||
|
@ -5304,25 +5291,18 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr,
|
|||
Address reg_offs_p = Address::invalid();
|
||||
llvm::Value *reg_offs = nullptr;
|
||||
int reg_top_index;
|
||||
CharUnits reg_top_offset;
|
||||
int RegSize = IsIndirect ? 8 : TyInfo.first.getQuantity();
|
||||
if (!IsFPR) {
|
||||
// 3 is the field number of __gr_offs
|
||||
reg_offs_p =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 3, CharUnits::fromQuantity(24),
|
||||
"gr_offs_p");
|
||||
reg_offs_p = CGF.Builder.CreateStructGEP(VAListAddr, 3, "gr_offs_p");
|
||||
reg_offs = CGF.Builder.CreateLoad(reg_offs_p, "gr_offs");
|
||||
reg_top_index = 1; // field number for __gr_top
|
||||
reg_top_offset = CharUnits::fromQuantity(8);
|
||||
RegSize = llvm::alignTo(RegSize, 8);
|
||||
} else {
|
||||
// 4 is the field number of __vr_offs.
|
||||
reg_offs_p =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 4, CharUnits::fromQuantity(28),
|
||||
"vr_offs_p");
|
||||
reg_offs_p = CGF.Builder.CreateStructGEP(VAListAddr, 4, "vr_offs_p");
|
||||
reg_offs = CGF.Builder.CreateLoad(reg_offs_p, "vr_offs");
|
||||
reg_top_index = 2; // field number for __vr_top
|
||||
reg_top_offset = CharUnits::fromQuantity(16);
|
||||
RegSize = 16 * NumRegs;
|
||||
}
|
||||
|
||||
|
@ -5384,8 +5364,8 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr,
|
|||
CGF.EmitBlock(InRegBlock);
|
||||
|
||||
llvm::Value *reg_top = nullptr;
|
||||
Address reg_top_p = CGF.Builder.CreateStructGEP(VAListAddr, reg_top_index,
|
||||
reg_top_offset, "reg_top_p");
|
||||
Address reg_top_p =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, reg_top_index, "reg_top_p");
|
||||
reg_top = CGF.Builder.CreateLoad(reg_top_p, "reg_top");
|
||||
Address BaseAddr(CGF.Builder.CreateInBoundsGEP(reg_top, reg_offs),
|
||||
CharUnits::fromQuantity(IsFPR ? 16 : 8));
|
||||
|
@ -5425,8 +5405,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr,
|
|||
CGF.Builder.CreateConstInBoundsByteGEP(BaseAddr, BaseOffset);
|
||||
LoadAddr = CGF.Builder.CreateElementBitCast(LoadAddr, BaseTy);
|
||||
|
||||
Address StoreAddr =
|
||||
CGF.Builder.CreateConstArrayGEP(Tmp, i, BaseTyInfo.first);
|
||||
Address StoreAddr = CGF.Builder.CreateConstArrayGEP(Tmp, i);
|
||||
|
||||
llvm::Value *Elem = CGF.Builder.CreateLoad(LoadAddr);
|
||||
CGF.Builder.CreateStore(Elem, StoreAddr);
|
||||
|
@ -5455,8 +5434,7 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr,
|
|||
//=======================================
|
||||
CGF.EmitBlock(OnStackBlock);
|
||||
|
||||
Address stack_p = CGF.Builder.CreateStructGEP(VAListAddr, 0,
|
||||
CharUnits::Zero(), "stack_p");
|
||||
Address stack_p = CGF.Builder.CreateStructGEP(VAListAddr, 0, "stack_p");
|
||||
llvm::Value *OnStackPtr = CGF.Builder.CreateLoad(stack_p, "stack");
|
||||
|
||||
// Again, stack arguments may need realignment. In this case both integer and
|
||||
|
@ -6599,8 +6577,7 @@ Address SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
// Vector arguments are always passed in the high bits of a
|
||||
// single (8 byte) or double (16 byte) stack slot.
|
||||
Address OverflowArgAreaPtr =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 2, CharUnits::fromQuantity(16),
|
||||
"overflow_arg_area_ptr");
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 2, "overflow_arg_area_ptr");
|
||||
Address OverflowArgArea =
|
||||
Address(CGF.Builder.CreateLoad(OverflowArgAreaPtr, "overflow_arg_area"),
|
||||
TyInfo.second);
|
||||
|
@ -6632,9 +6609,8 @@ Address SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
RegPadding = Padding; // values are passed in the low bits of a GPR
|
||||
}
|
||||
|
||||
Address RegCountPtr = CGF.Builder.CreateStructGEP(
|
||||
VAListAddr, RegCountField, RegCountField * CharUnits::fromQuantity(8),
|
||||
"reg_count_ptr");
|
||||
Address RegCountPtr =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, RegCountField, "reg_count_ptr");
|
||||
llvm::Value *RegCount = CGF.Builder.CreateLoad(RegCountPtr, "reg_count");
|
||||
llvm::Value *MaxRegsV = llvm::ConstantInt::get(IndexTy, MaxRegs);
|
||||
llvm::Value *InRegs = CGF.Builder.CreateICmpULT(RegCount, MaxRegsV,
|
||||
|
@ -6657,8 +6633,7 @@ Address SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
llvm::Value *RegOffset =
|
||||
CGF.Builder.CreateAdd(ScaledRegCount, RegBase, "reg_offset");
|
||||
Address RegSaveAreaPtr =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 3, CharUnits::fromQuantity(24),
|
||||
"reg_save_area_ptr");
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 3, "reg_save_area_ptr");
|
||||
llvm::Value *RegSaveArea =
|
||||
CGF.Builder.CreateLoad(RegSaveAreaPtr, "reg_save_area");
|
||||
Address RawRegAddr(CGF.Builder.CreateGEP(RegSaveArea, RegOffset,
|
||||
|
@ -6678,8 +6653,8 @@ Address SystemZABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
|||
CGF.EmitBlock(InMemBlock);
|
||||
|
||||
// Work out the address of a stack argument.
|
||||
Address OverflowArgAreaPtr = CGF.Builder.CreateStructGEP(
|
||||
VAListAddr, 2, CharUnits::fromQuantity(16), "overflow_arg_area_ptr");
|
||||
Address OverflowArgAreaPtr =
|
||||
CGF.Builder.CreateStructGEP(VAListAddr, 2, "overflow_arg_area_ptr");
|
||||
Address OverflowArgArea =
|
||||
Address(CGF.Builder.CreateLoad(OverflowArgAreaPtr, "overflow_arg_area"),
|
||||
PaddedSize);
|
||||
|
|
Loading…
Reference in New Issue