mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-01 23:50:43 +03:00
Fix LLVM 13 deprecation messages during build
This commit is contained in:
parent
75b67452cb
commit
7b6810b01b
10 changed files with 72 additions and 30 deletions
|
@ -746,8 +746,7 @@ void CompoundAsmStatement_toIR(CompoundAsmStatement *stmt, IRState *p) {
|
|||
// make new blocks
|
||||
llvm::BasicBlock *bb = p->insertBB("afterasmgotoforwarder");
|
||||
|
||||
llvm::LoadInst *val =
|
||||
p->ir->CreateLoad(jump_target, "__llvm_jump_target_value");
|
||||
auto val = DtoLoad(jump_target, "__llvm_jump_target_value");
|
||||
llvm::SwitchInst *sw = p->ir->CreateSwitch(val, bb, gotoToVal.size());
|
||||
|
||||
// add all cases
|
||||
|
|
|
@ -278,10 +278,9 @@ DValue *DtoCastClass(const Loc &loc, DValue *val, Type *_to) {
|
|||
LLValue *orig = DtoRVal(val);
|
||||
LLValue *v = orig;
|
||||
if (offset != 0) {
|
||||
assert(offset > 0);
|
||||
v = DtoBitCast(v, getVoidPtrType());
|
||||
LLValue *off =
|
||||
LLConstantInt::get(LLType::getInt32Ty(gIR->context()), offset);
|
||||
v = gIR->ir->CreateGEP(v, off);
|
||||
v = DtoGEP1(v, DtoConstUint(offset));
|
||||
}
|
||||
IF_LOG {
|
||||
Logger::cout() << "V = " << *v << std::endl;
|
||||
|
|
|
@ -33,10 +33,10 @@ void emitCoverageLinecountInc(const Loc &loc) {
|
|||
|
||||
// Increment the line counter:
|
||||
// Get GEP into _d_cover_data array...
|
||||
LLType *i32Type = LLType::getInt32Ty(gIR->context());
|
||||
LLConstant *idxs[] = {DtoConstUint(0), DtoConstUint(line)};
|
||||
LLValue *ptr = llvm::ConstantExpr::getGetElementPtr(
|
||||
LLArrayType::get(LLType::getInt32Ty(gIR->context()), m->numlines),
|
||||
m->d_cover_data, idxs, true);
|
||||
LLArrayType::get(i32Type, m->numlines), m->d_cover_data, idxs, true);
|
||||
// ...and generate the "increment" instruction(s)
|
||||
switch (opts::coverageIncrement) {
|
||||
case opts::CoverageIncrement::_default: // fallthrough
|
||||
|
@ -51,7 +51,11 @@ void emitCoverageLinecountInc(const Loc &loc) {
|
|||
case opts::CoverageIncrement::nonatomic: {
|
||||
// Do a non-atomic increment, user is responsible for correct results with
|
||||
// multithreaded execution
|
||||
llvm::LoadInst *load = gIR->ir->CreateAlignedLoad(ptr, LLAlign(4));
|
||||
llvm::LoadInst *load = gIR->ir->CreateAlignedLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
i32Type,
|
||||
#endif
|
||||
ptr, LLAlign(4));
|
||||
llvm::StoreInst *store = gIR->ir->CreateAlignedStore(
|
||||
gIR->ir->CreateAdd(load, DtoConstUint(1)), ptr, LLAlign(4));
|
||||
// add !nontemporal attribute, to inform the optimizer that caching is not
|
||||
|
|
|
@ -87,7 +87,11 @@ llvm::Function *buildForwarderFunction(
|
|||
for (auto gate : gates) {
|
||||
assert(getIrGlobal(gate));
|
||||
const auto val = getIrGlobal(gate)->value;
|
||||
const auto rval = builder.CreateLoad(val, "vgate");
|
||||
const auto rval = builder.CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
getPointeeType(val),
|
||||
#endif
|
||||
val, "vgate");
|
||||
const auto res = builder.CreateAdd(rval, DtoConstUint(1), "vgate");
|
||||
builder.CreateStore(res, val);
|
||||
}
|
||||
|
|
|
@ -164,7 +164,11 @@ LLFunction *build_module_reference_and_ctor(const char *moduleMangle,
|
|||
gIR->DBuilder.EmitModuleCTor(ctor, fname.c_str());
|
||||
|
||||
// get current beginning
|
||||
LLValue *curbeg = builder.CreateLoad(mref, "current");
|
||||
LLValue *curbeg = builder.CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
modulerefPtrTy,
|
||||
#endif
|
||||
mref, "current");
|
||||
|
||||
// put current beginning as the next of this one
|
||||
LLValue *gep = builder.CreateStructGEP(
|
||||
|
|
|
@ -184,12 +184,16 @@ private:
|
|||
|
||||
Value *address = currentGlobal;
|
||||
for (auto i : currentGepPath) {
|
||||
auto t = address->getType()->getPointerElementType();
|
||||
if (i <= 0xFFFFFFFFu) {
|
||||
address = b.CreateConstInBoundsGEP2_32(
|
||||
address->getType()->getPointerElementType(), address, 0,
|
||||
address = b.CreateConstInBoundsGEP2_32(t, address, 0,
|
||||
static_cast<unsigned>(i));
|
||||
} else {
|
||||
address = b.CreateConstInBoundsGEP2_64(address, 0, i);
|
||||
address = b.CreateConstInBoundsGEP2_64(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
t,
|
||||
#endif
|
||||
address, 0, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,8 +211,12 @@ private:
|
|||
auto ifbb = BasicBlock::Create(m.getContext(), "if", ctor);
|
||||
auto endbb = BasicBlock::Create(m.getContext(), "endif", ctor);
|
||||
|
||||
auto isStillNull =
|
||||
b.CreateICmp(CmpInst::ICMP_EQ, b.CreateLoad(address, false),
|
||||
auto isStillNull = b.CreateICmp(CmpInst::ICMP_EQ,
|
||||
b.CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
t,
|
||||
#endif
|
||||
address, false),
|
||||
Constant::getNullValue(t));
|
||||
b.CreateCondBr(isStillNull, ifbb, endbb);
|
||||
|
||||
|
|
|
@ -1365,7 +1365,7 @@ public:
|
|||
PGO.emitCounterIncrement(stmt);
|
||||
|
||||
// get value for this iteration
|
||||
LLValue *loadedKey = irs->ir->CreateLoad(keyvar);
|
||||
LLValue *loadedKey = DtoLoad(keyvar);
|
||||
LLValue *gep = DtoGEP1(val, loadedKey);
|
||||
|
||||
if (!stmt->value->isRef() && !stmt->value->isOut()) {
|
||||
|
|
|
@ -451,7 +451,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
|
|||
int atomicOrdering = (*e->arguments)[1]->toInteger();
|
||||
|
||||
LLValue *ptr = DtoRVal(exp);
|
||||
LLType *pointeeType = ptr->getType()->getContainedType(0);
|
||||
LLType *pointeeType = getPointeeType(ptr);
|
||||
Type *retType = exp->type->nextOf();
|
||||
|
||||
if (!pointeeType->isIntegerTy()) {
|
||||
|
@ -465,13 +465,18 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
|
|||
}
|
||||
}
|
||||
|
||||
llvm::LoadInst *load = p->ir->CreateLoad(ptr);
|
||||
if (auto alignment = getTypeAllocSize(load->getType())) {
|
||||
const auto loadedType = getPointeeType(ptr);
|
||||
llvm::LoadInst *load = p->ir->CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
loadedType,
|
||||
#endif
|
||||
ptr);
|
||||
if (auto alignment = getTypeAllocSize(loadedType)) {
|
||||
load->setAlignment(LLAlign(alignment));
|
||||
}
|
||||
load->setAtomic(llvm::AtomicOrdering(atomicOrdering));
|
||||
llvm::Value *val = load;
|
||||
if (val->getType() != pointeeType) {
|
||||
if (loadedType != pointeeType) {
|
||||
val = DtoAllocaDump(val, retType);
|
||||
result = new DLValue(retType, val);
|
||||
} else {
|
||||
|
|
|
@ -502,14 +502,24 @@ LLConstant *DtoConstString(const char *str) {
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
namespace {
|
||||
llvm::LoadInst *DtoLoadImpl(LLValue *src, const char *name) {
|
||||
return gIR->ir->CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
getPointeeType(src),
|
||||
#endif
|
||||
src, name);
|
||||
}
|
||||
}
|
||||
|
||||
LLValue *DtoLoad(LLValue *src, const char *name) {
|
||||
return gIR->ir->CreateLoad(src, name);
|
||||
return DtoLoadImpl(src, name);
|
||||
}
|
||||
|
||||
// Like DtoLoad, but the pointer is guaranteed to be aligned appropriately for
|
||||
// the type.
|
||||
LLValue *DtoAlignedLoad(LLValue *src, const char *name) {
|
||||
llvm::LoadInst *ld = gIR->ir->CreateLoad(src, name);
|
||||
llvm::LoadInst *ld = DtoLoadImpl(src, name);
|
||||
if (auto alignment = getABITypeAlign(ld->getType())) {
|
||||
ld->setAlignment(LLAlign(alignment));
|
||||
}
|
||||
|
@ -517,7 +527,7 @@ LLValue *DtoAlignedLoad(LLValue *src, const char *name) {
|
|||
}
|
||||
|
||||
LLValue *DtoVolatileLoad(LLValue *src, const char *name) {
|
||||
llvm::LoadInst *ld = gIR->ir->CreateLoad(src, name);
|
||||
llvm::LoadInst *ld = DtoLoadImpl(src, name);
|
||||
ld->setVolatile(true);
|
||||
return ld;
|
||||
}
|
||||
|
|
|
@ -255,7 +255,11 @@ void emitBeginCatchMSVC(IRState &irs, Catch *ctch,
|
|||
|
||||
if (cpyObj) {
|
||||
// assign the caught exception to the location in the closure
|
||||
auto val = irs.ir->CreateLoad(exnObj);
|
||||
auto val = irs.ir->CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
getPointeeType(exnObj),
|
||||
#endif
|
||||
exnObj);
|
||||
irs.ir->CreateStore(val, cpyObj);
|
||||
exnObj = cpyObj;
|
||||
}
|
||||
|
@ -698,8 +702,9 @@ llvm::BasicBlock *TryCatchFinallyScopes::emitLandingPad() {
|
|||
irs.ir->CreateStore(ehPtr, getOrCreateEhPtrSlot());
|
||||
|
||||
llvm::Value *ehSelector = DtoExtractValue(landingPad, 1);
|
||||
const auto ehSelectorType = ehSelector->getType();
|
||||
if (!ehSelectorSlot)
|
||||
ehSelectorSlot = DtoRawAlloca(ehSelector->getType(), 0, "eh.selector");
|
||||
ehSelectorSlot = DtoRawAlloca(ehSelectorType, 0, "eh.selector");
|
||||
irs.ir->CreateStore(ehSelector, ehSelectorSlot);
|
||||
|
||||
// Add landingpad clauses, emit finallys and 'if' chain to catch the
|
||||
|
@ -738,8 +743,12 @@ llvm::BasicBlock *TryCatchFinallyScopes::emitLandingPad() {
|
|||
|
||||
// Compare the selector value from the unwinder against the expected
|
||||
// one and branch accordingly.
|
||||
irs.ir->CreateCondBr(
|
||||
irs.ir->CreateICmpEQ(irs.ir->CreateLoad(ehSelectorSlot), ehTypeId),
|
||||
irs.ir->CreateCondBr(irs.ir->CreateICmpEQ(irs.ir->CreateLoad(
|
||||
#if LDC_LLVM_VER >= 800
|
||||
ehSelectorType,
|
||||
#endif
|
||||
ehSelectorSlot),
|
||||
ehTypeId),
|
||||
cb.bodyBB, mismatchBB, cb.branchWeights);
|
||||
irs.ir->SetInsertPoint(mismatchBB);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue