Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9702,10 +9702,11 @@ Value *CodeGenFunction::EmitSVEStructLoad(const SVETypeFlags &TypeFlags,
SmallVectorImpl<Value*> &Ops,
unsigned IntID) {
llvm::ScalableVectorType *VTy = getSVEType(TypeFlags);
auto VecPtrTy =
llvm::PointerType::get(VTy, CGM.getDataLayout().getGlobalsAddressSpace());
auto VecPtrTy = llvm::PointerType::get(
VTy, CGM.getDataLayout().getDefaultGlobalsAddressSpace());
auto EltPtrTy = llvm::PointerType::get(
VTy->getElementType(), CGM.getDataLayout().getGlobalsAddressSpace());
VTy->getElementType(),
CGM.getDataLayout().getDefaultGlobalsAddressSpace());

unsigned N;
switch (IntID) {
Expand Down Expand Up @@ -9748,10 +9749,11 @@ Value *CodeGenFunction::EmitSVEStructStore(const SVETypeFlags &TypeFlags,
SmallVectorImpl<Value*> &Ops,
unsigned IntID) {
llvm::ScalableVectorType *VTy = getSVEType(TypeFlags);
auto VecPtrTy =
llvm::PointerType::get(VTy, CGM.getDataLayout().getGlobalsAddressSpace());
auto VecPtrTy = llvm::PointerType::get(
VTy, CGM.getDataLayout().getDefaultGlobalsAddressSpace());
auto EltPtrTy = llvm::PointerType::get(
VTy->getElementType(), CGM.getDataLayout().getGlobalsAddressSpace());
VTy->getElementType(),
CGM.getDataLayout().getDefaultGlobalsAddressSpace());

unsigned N;
switch (IntID) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ ConstantLValueEmitter::tryEmitBase(const APValue::LValueBase &base) {

// Handle typeid(T).
if (TypeInfoLValue TI = base.dyn_cast<TypeInfoLValue>()) {
unsigned GlobalAS = CGM.getDataLayout().getGlobalsAddressSpace();
unsigned GlobalAS = CGM.getDataLayout().getDefaultGlobalsAddressSpace();
llvm::Type *StdTypeInfoPtrTy = llvm::PointerType::get(CGM.getLLVMContext(), GlobalAS);
llvm::Constant *TypeInfo =
CGM.GetAddrOfRTTIDescriptor(QualType(TI.getType(), 0));
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,8 +969,7 @@ void BackendConsumer::DiagnosticHandlerImpl(const DiagnosticInfo &DI) {
bool BadDebugInfo = false;
FullSourceLoc Loc =
getBestLocationFromDebugLoc(DICI, BadDebugInfo, Filename, Line, Column);
const auto &DL = DICI.getFunction().getParent()->getDataLayout();
bool IsPurecap = DL.isFatPointer(DL.getGlobalsAddressSpace());
bool IsPurecap = Context->getTargetInfo().areAllPointersCapabilities();

Diags.Report(Loc, diag::warn_fe_backend_cheri_inefficient)
<< DICI.getMessage();
Expand Down
4 changes: 4 additions & 0 deletions llvm/include/llvm/CodeGen/TargetLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -3277,6 +3277,7 @@ class TargetLoweringBase {
Register getNullCapabilityRegister() const {
return NullCapabilityRegister;
}
bool isCheriPureCap() const { return IsCheriPureCap; }

/// Does this target require the clearing of high-order bits in a register
/// passed to the fp16 to fp conversion library function.
Expand Down Expand Up @@ -3646,6 +3647,9 @@ class TargetLoweringBase {
/// Should be one of c64/c128/c256
MVT CapType = MVT();

/// All pointers are capabilities.
bool IsCheriPureCap = false;

/// Whether the CHERI capability type supports precise bounds for any
/// allocation. Defaults to false for safety over efficiency.
bool CapTypeHasPreciseBounds = false;
Expand Down
2 changes: 0 additions & 2 deletions llvm/include/llvm/IR/DataLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ class DataLayout {
unsigned getDefaultGlobalsAddressSpace() const {
return DefaultGlobalsAddrSpace;
}
// TODO: remove this and use the upstreamed version
unsigned getGlobalsAddressSpace() const { return DefaultGlobalsAddrSpace; }

bool hasMicrosoftFastStdCallMangling() const {
return ManglingMode == MM_WinCOFFX86;
Expand Down
5 changes: 1 addition & 4 deletions llvm/lib/CodeGen/AtomicExpandPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1986,13 +1986,10 @@ bool AtomicExpand::expandAtomicOpToLibcall(
// adding the 20+ new entries to RuntimeLibcalls.def. We also suffix with
// _c for capability pointer arguments in hybrid mode.
std::string LibcallName = TLI->getLibcallName(RTLibType);
// We are compiling for CHERI purecap mode if the default globals address
// space is a capability type.
bool IsCheriPurecap = DL.isFatPointer(DL.getGlobalsAddressSpace());
if (ValueOperandIsCap) {
LibcallName += "_cap";
}
if (PointerOperandIsCap && !IsCheriPurecap) {
if (PointerOperandIsCap && !TLI->isCheriPureCap()) {
// Add a _c suffix if the function uses capability pointer operands in
// hybrid mode.
assert(StringRef(LibcallName).startswith("__atomic"));
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26839,7 +26839,7 @@ SDValue DAGCombiner::convertSelectOfFPConstantsToLoadOffset(
SDValue CPIdx = DAG.getConstantPool(
CA,
TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()),
DAG.getDataLayout().getDefaultGlobalsAddressSpace()),
TD.getPrefTypeAlign(FPTy));
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();

Expand Down
14 changes: 8 additions & 6 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,9 @@ SelectionDAGLegalize::ExpandConstantFP(ConstantFPSDNode *CFP, bool UseCP) {
}

SDValue CPIdx = DAG.getConstantPool(
LLVMC, TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()));
LLVMC,
TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
if (Extend) {
SDValue Result = DAG.getExtLoad(
Expand All @@ -356,7 +357,7 @@ SDValue SelectionDAGLegalize::ExpandConstant(ConstantSDNode *CP) {
SDValue CPIdx = DAG.getConstantPool(
CP->getConstantIntValue(),
TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()));
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
SDValue Result = DAG.getLoad(
VT, dl, DAG.getEntryNode(), CPIdx,
Expand Down Expand Up @@ -2013,8 +2014,9 @@ SDValue SelectionDAGLegalize::ExpandBUILD_VECTOR(SDNode *Node) {
}
Constant *CP = ConstantVector::get(CV);
SDValue CPIdx = DAG.getConstantPool(
CP, TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()));
CP,
TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
return DAG.getLoad(
VT, dl, DAG.getEntryNode(), CPIdx,
Expand Down Expand Up @@ -2829,7 +2831,7 @@ SDValue SelectionDAGLegalize::ExpandLegalINT_TO_FP(SDNode *Node,
SDValue CPIdx = DAG.getConstantPool(
FudgeFactor,
TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()));
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
Align Alignment = cast<ConstantPoolSDNode>(CPIdx)->getAlign();
CPIdx = DAG.getNode(ISD::ADD, dl, CPIdx.getValueType(), CPIdx, CstOffset);
Alignment = commonAlignment(Alignment, 4);
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2670,7 +2670,7 @@ void SelectionDAGBuilder::visitJumpTable(SwitchCG::JumpTable &JT) {
assert(JT.Reg != -1U && "Should lower JT Header first!");
const DataLayout &TD = DAG.getDataLayout();
const auto &TLI = DAG.getTargetLoweringInfo();
EVT PTy = TLI.getPointerTy(TD, TD.getGlobalsAddressSpace());
EVT PTy = TLI.getPointerTy(TD, TD.getDefaultGlobalsAddressSpace());
EVT IndexTy = TLI.getPointerRangeTy(TD , TD.getProgramAddressSpace());
SDValue Index =
DAG.getCopyFromReg(getControlRoot(), getCurSDLoc(), JT.Reg, IndexTy);
Expand Down Expand Up @@ -4518,14 +4518,14 @@ static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index,
Base = SDB->getValue(C);

ElementCount NumElts = cast<VectorType>(Ptr->getType())->getElementCount();
EVT VT = EVT::getVectorVT(*DAG.getContext(),
TLI.getPointerTy(DL, DL.getGlobalsAddressSpace()),
NumElts);
EVT VT = EVT::getVectorVT(
*DAG.getContext(),
TLI.getPointerTy(DL, DL.getDefaultGlobalsAddressSpace()), NumElts);
Index = DAG.getConstant(0, SDB->getCurSDLoc(), VT);
IndexType = ISD::SIGNED_SCALED;
Scale = DAG.getTargetConstant(
1, SDB->getCurSDLoc(),
TLI.getPointerTy(DL, DL.getGlobalsAddressSpace()));
TLI.getPointerTy(DL, DL.getDefaultGlobalsAddressSpace()));
return true;
}

Expand Down Expand Up @@ -8924,7 +8924,7 @@ static SDValue getAddressForMemoryInput(SDValue Chain, const SDLoc &Location,
OpInfo.CallOperand = DAG.getConstantPool(
cast<Constant>(OpVal),
TLI.getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()));
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));
return Chain;
}

Expand Down Expand Up @@ -9470,7 +9470,7 @@ void SelectionDAGBuilder::visitInlineAsm(const CallBase &Call,
assert(InOperandVal.getValueType() ==
TLI.getPointerTy(
DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace()) &&
DAG.getDataLayout().getDefaultGlobalsAddressSpace()) &&
"Memory operands expect pointer values");

unsigned ConstraintID =
Expand Down
14 changes: 8 additions & 6 deletions llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,9 @@ SDValue TargetLowering::getPICJumpTableRelocBase(SDValue Table,

if ((JTEncoding == MachineJumpTableInfo::EK_GPRel64BlockAddress) ||
(JTEncoding == MachineJumpTableInfo::EK_GPRel32BlockAddress))
return DAG.getGLOBAL_OFFSET_TABLE(getPointerTy(
DAG.getDataLayout(), DAG.getDataLayout().getGlobalsAddressSpace()));
return DAG.getGLOBAL_OFFSET_TABLE(
getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));

return Table;
}
Expand Down Expand Up @@ -8645,7 +8646,8 @@ SDValue TargetLowering::CTTZTableLookup(SDNode *Node, SelectionDAG &DAG,
DAG.getConstant(ShiftAmt, DL, VT));
Lookup = DAG.getSExtOrTrunc(
Lookup, DL,
getPointerRangeTy(TD, DAG.getDataLayout().getGlobalsAddressSpace()));
getPointerRangeTy(TD,
DAG.getDataLayout().getDefaultGlobalsAddressSpace()));

SmallVector<uint8_t> Table(BitWidth, 0);
for (unsigned i = 0; i < BitWidth; i++) {
Expand All @@ -8657,7 +8659,7 @@ SDValue TargetLowering::CTTZTableLookup(SDNode *Node, SelectionDAG &DAG,
// Create a ConstantArray in Constant Pool
auto *CA = ConstantDataArray::get(*DAG.getContext(), Table);
SDValue CPIdx = DAG.getConstantPool(
CA, getPointerTy(TD, DAG.getDataLayout().getGlobalsAddressSpace()),
CA, getPointerTy(TD, DAG.getDataLayout().getDefaultGlobalsAddressSpace()),
TD.getPrefTypeAlign(CA->getType()));
SDValue ExtLoad = DAG.getExtLoad(ISD::ZEXTLOAD, DL, VT, DAG.getEntryNode(),
DAG.getMemBasePlusOffset(CPIdx, Lookup, DL),
Expand Down Expand Up @@ -9724,8 +9726,8 @@ SDValue TargetLowering::LowerToTLSEmulatedModel(const GlobalAddressSDNode *GA,
SelectionDAG &DAG) const {
// Access to address of TLS varialbe xyz is lowered to a function call:
// __emutls_get_address( address of global variable named "__emutls_v.xyz" )
EVT DataPtrVT = getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace());
EVT DataPtrVT = getPointerTy(
DAG.getDataLayout(), DAG.getDataLayout().getDefaultGlobalsAddressSpace());
PointerType *VoidPtrType = Type::getInt8PtrTy(*DAG.getContext());
SDLoc dl(GA);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/IRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ IRBuilderBase::CreateGlobalString(StringRef Str, const Twine &Name,
*M, StrConstant->getType(), true, GlobalValue::PrivateLinkage,
StrConstant, Name, nullptr, GlobalVariable::NotThreadLocal,
AddressSpace ? *AddressSpace
: M->getDataLayout().getGlobalsAddressSpace());
: M->getDataLayout().getDefaultGlobalsAddressSpace());
GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
GV->setAlignment(Align(1));
return GV;
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/Mips/MipsISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ MipsTargetLowering::MipsTargetLowering(const MipsTargetMachine &TM,
CapType = STI.typeForCapabilities();
CapTypeHasPreciseBounds = STI.isCheri256();
assert(cheriCapabilityType().isFatPointer());
IsCheriPureCap = ABI.IsCheriPureCap();

// Mips does not have i1 type, so use i32 for
// setcc operations results (slt, sgt, ...).
Expand Down
24 changes: 13 additions & 11 deletions llvm/lib/Target/RISCV/RISCVISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ RISCVTargetLowering::RISCVTargetLowering(const TargetMachine &TM,
CapType = Subtarget.typeForCapabilities();
NullCapabilityRegister = RISCV::C0;
addRegisterClass(CapType, &RISCV::GPCRRegClass);
IsCheriPureCap = RISCVABI::isCheriPureCapABI(ABI);
}

static const MVT::SimpleValueType BoolVecVTs[] = {
Expand Down Expand Up @@ -5997,7 +5998,7 @@ SDValue RISCVTargetLowering::getDynamicTLSAddr(GlobalAddressSDNode *N,
SelectionDAG &DAG) const {
SDLoc DL(N);
Type *CallTy = Type::getInt8PtrTy(
*DAG.getContext(), DAG.getDataLayout().getGlobalsAddressSpace());
*DAG.getContext(), DAG.getDataLayout().getDefaultGlobalsAddressSpace());
const GlobalValue *GV = N->getGlobal();

// Use a PC-relative addressing mode to access the global dynamic GOT address.
Expand Down Expand Up @@ -7482,8 +7483,9 @@ SDValue RISCVTargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
case Intrinsic::thread_pointer: {
MCPhysReg PhysReg = RISCVABI::isCheriPureCapABI(Subtarget.getTargetABI())
? RISCV::C4 : RISCV::X4;
EVT PtrVT = getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getGlobalsAddressSpace());
EVT PtrVT =
getPointerTy(DAG.getDataLayout(),
DAG.getDataLayout().getDefaultGlobalsAddressSpace());
return DAG.getRegister(PhysReg, PtrVT);
}
case Intrinsic::riscv_orc_b:
Expand Down Expand Up @@ -15167,8 +15169,9 @@ bool RISCV::CC_RISCV(const DataLayout &DL, RISCVABI::ABI ABI, unsigned ValNo,
MVT XLenVT = XLen == 32 ? MVT::i32 : MVT::i64;
MVT CLenVT = Subtarget.hasCheri() ? Subtarget.typeForCapabilities()
: MVT();
MVT PtrVT = DL.isFatPointer(DL.getAllocaAddrSpace()) ? CLenVT : XLenVT;
bool IsPureCapVarArgs = !IsFixed && RISCVABI::isCheriPureCapABI(ABI);
bool IsPureCap = RISCVABI::isCheriPureCapABI(ABI);
MVT PtrVT = IsPureCap ? CLenVT : XLenVT;
bool IsPureCapVarArgs = !IsFixed && IsPureCap;
Comment on lines +15172 to +15174
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wrote the code like the LHS because PtrVT is a stack pointer and so should be tied to the alloca AS. In practice the RHS is entirely equivalent because the alloca AS is a capability if and only if a purecap ABI is in use, but I was trying to be as general as possible, using fine-grained ASes where appropriate.

Copy link
Member

@jrtc27 jrtc27 Jul 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also the commit message you used was:

[CHERI] Use ABI to deduce purecap instead of default addrspace

which isn't appropriate here, because this is the alloca AS, not the default globals AS.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind reverting this part? I thought it didn't matter since alloca AS == 200 is always equivalent to purecap and we were checking the ABI later again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I understand the difference now. Please revert if needed or I can push a patch which just resets this particular hunk?


// Static chain parameter must not be passed in normal argument registers,
// so we assign t2 for it as done in GCC's __builtin_call_with_static_chain
Expand Down Expand Up @@ -16562,11 +16565,11 @@ bool RISCVTargetLowering::isUsedByReturnOnly(SDNode *N, SDValue &Chain) const {
return false;

SDNode *Copy = *N->use_begin();

if (Copy->getOpcode() == ISD::BITCAST) {
return isUsedByReturnOnly(Copy, Chain);
}

// TODO: Handle additional opcodes in order to support tail-calling libcalls
// with soft float ABIs.
if (Copy->getOpcode() != ISD::CopyToReg) {
Expand Down Expand Up @@ -17848,10 +17851,9 @@ bool RISCVTargetLowering::preferScalarizeSplat(SDNode *N) const {

static Value *useTpOffset(IRBuilderBase &IRB, unsigned Offset) {
Module *M = IRB.GetInsertBlock()->getParent()->getParent();
unsigned AS = M->getDataLayout().getGlobalsAddressSpace();
Function *ThreadPointerFunc =
Intrinsic::getDeclaration(M, Intrinsic::thread_pointer,
IRB.getInt8PtrTy(AS));
unsigned AS = M->getDataLayout().getDefaultGlobalsAddressSpace();
Function *ThreadPointerFunc = Intrinsic::getDeclaration(
M, Intrinsic::thread_pointer, IRB.getInt8PtrTy(AS));
return IRB.CreatePointerCast(
IRB.CreateConstGEP1_32(IRB.getInt8Ty(),
IRB.CreateCall(ThreadPointerFunc), Offset),
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,9 @@ bool DevirtModule::shouldExportConstantsAsAbsoluteSymbols() {

void DevirtModule::exportGlobal(VTableSlot Slot, ArrayRef<uint64_t> Args,
StringRef Name, Constant *C) {
GlobalAlias *GA = GlobalAlias::create(Int8Ty, M.getDataLayout().getGlobalsAddressSpace(), GlobalValue::ExternalLinkage,
getGlobalName(Slot, Args, Name), C, &M);
GlobalAlias *GA = GlobalAlias::create(
Int8Ty, M.getDataLayout().getDefaultGlobalsAddressSpace(),
GlobalValue::ExternalLinkage, getGlobalName(Slot, Args, Name), C, &M);
GA->setVisibility(GlobalValue::HiddenVisibility);
}

Expand Down Expand Up @@ -1874,7 +1875,8 @@ void DevirtModule::rebuildGlobal(VTableBits &B) {
// Build an alias named after the original global, pointing at the second
// element (the original initializer).
auto Alias = GlobalAlias::create(
B.GV->getInitializer()->getType(), M.getDataLayout().getGlobalsAddressSpace(), B.GV->getLinkage(), "",
B.GV->getInitializer()->getType(),
M.getDataLayout().getDefaultGlobalsAddressSpace(), B.GV->getLinkage(), "",
ConstantExpr::getGetElementPtr(
NewInit->getType(), NewGV,
ArrayRef<Constant *>{ConstantInt::get(Int32Ty, 0),
Expand Down
24 changes: 10 additions & 14 deletions llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -400,21 +400,16 @@ bool ModuleSanitizerCoverage::instrumentModule(
IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits(0));

PcAddrTy = Type::getIntNTy(*C, DL->getIndexSizeInBits(DL->getProgramAddressSpace()));
Type *PcAddrPtrTy = PcAddrTy->getPointerTo(DL->getGlobalsAddressSpace());
unsigned GlobalAS = DL->getDefaultGlobalsAddressSpace();
Type *PcAddrPtrTy = PcAddrTy->getPointerTo(GlobalAS);
Type *VoidTy = Type::getVoidTy(*C);
IRBuilder<> IRB(*C);
GlobalsInt128PtrTy =
PointerType::get(IRB.getInt128Ty(), DL->getGlobalsAddressSpace());
GlobalsInt64PtrTy =
PointerType::get(IRB.getInt64Ty(), DL->getGlobalsAddressSpace());
GlobalsInt32PtrTy =
PointerType::get(IRB.getInt32Ty(), DL->getGlobalsAddressSpace());
GlobalsInt16PtrTy =
PointerType::get(IRB.getInt16Ty(), DL->getGlobalsAddressSpace());
GlobalsInt8PtrTy =
PointerType::get(IRB.getInt8Ty(), DL->getGlobalsAddressSpace());
GlobalsInt1PtrTy =
PointerType::get(IRB.getInt1Ty(), DL->getGlobalsAddressSpace());
GlobalsInt128PtrTy = PointerType::get(IRB.getInt128Ty(), GlobalAS);
GlobalsInt64PtrTy = PointerType::get(IRB.getInt64Ty(), GlobalAS);
GlobalsInt32PtrTy = PointerType::get(IRB.getInt32Ty(), GlobalAS);
GlobalsInt16PtrTy = PointerType::get(IRB.getInt16Ty(), GlobalAS);
GlobalsInt8PtrTy = PointerType::get(IRB.getInt8Ty(), GlobalAS);
GlobalsInt1PtrTy = PointerType::get(IRB.getInt1Ty(), GlobalAS);
Int64Ty = IRB.getInt64Ty();
Int32Ty = IRB.getInt32Ty();
Int16Ty = IRB.getInt16Ty();
Expand Down Expand Up @@ -1076,7 +1071,8 @@ ModuleSanitizerCoverage::getSectionEnd(const std::string &Section) const {
void ModuleSanitizerCoverage::createFunctionControlFlow(Function &F) {
SmallVector<Constant *, 32> CFs;
IRBuilder<> IRB(&*F.getEntryBlock().getFirstInsertionPt());
Type *PcAddrPtrTy = PcAddrTy->getPointerTo(DL->getGlobalsAddressSpace());
Type *PcAddrPtrTy =
PcAddrTy->getPointerTo(DL->getDefaultGlobalsAddressSpace());

for (auto &BB : F) {
// blockaddress can not be used on function's entry block.
Expand Down
Loading