Skip to content

Commit 95cd5eb

Browse files
committed
gen/llvm.h: add a type parameter to GET_INTRINSIC_DECL macro ...
... because now LLVM requires most intrinsics to have parameter types specified
1 parent c36d01c commit 95cd5eb

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

gen/arrays.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ static void emitRangeErrorImpl(IRState *irs, const Loc &loc,
10711071
DtoCAssert(module, loc, DtoConstCString(cAssertMsg));
10721072
break;
10731073
case CHECKACTION_halt:
1074-
irs->ir->CreateCall(GET_INTRINSIC_DECL(trap), {});
1074+
irs->ir->CreateCall(GET_INTRINSIC_DECL(trap, {}), {});
10751075
irs->ir->CreateUnreachable();
10761076
break;
10771077
case CHECKACTION_context:

gen/functions.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
12541254
// initialize _argptr with a call to the va_start intrinsic
12551255
DLValue argptrVal(tvalist, argptrMem);
12561256
LLValue *llAp = gABI->prepareVaStart(&argptrVal);
1257-
llvm::CallInst::Create(GET_INTRINSIC_DECL(vastart), llAp, "",
1257+
llvm::CallInst::Create(GET_INTRINSIC_DECL(vastart, llAp->getType()), llAp, "",
12581258
gIR->scopebb());
12591259

12601260
// copy _arguments to a memory location
@@ -1265,7 +1265,7 @@ void DtoDefineFunction(FuncDeclaration *fd, bool linkageAvailableExternally) {
12651265
auto *vaendBB = llvm::BasicBlock::Create(gIR->context(), "vaend", func);
12661266
const auto savedInsertPoint = gIR->saveInsertPoint();
12671267
gIR->ir->SetInsertPoint(vaendBB);
1268-
gIR->ir->CreateCall(GET_INTRINSIC_DECL(vaend), llAp);
1268+
gIR->ir->CreateCall(GET_INTRINSIC_DECL(vaend, llAp->getType()), llAp);
12691269
funcGen.scopes.pushCleanup(vaendBB, gIR->scopebb());
12701270
}
12711271
}

gen/llvm.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,13 @@ using llvm::APFloat;
3535
using llvm::APInt;
3636
using llvm::IRBuilder;
3737

38-
#define GET_INTRINSIC_DECL(_X) \
38+
#if LDC_LLVM_VER >= 1900
39+
#define GET_INTRINSIC_DECL(_X, _TY) \
40+
(llvm::Intrinsic::getDeclaration(&gIR->module, llvm::Intrinsic::_X, _TY))
41+
#else
42+
#define GET_INTRINSIC_DECL(_X, _TY) \
3943
(llvm::Intrinsic::getDeclaration(&gIR->module, llvm::Intrinsic::_X))
44+
#endif
4045

4146
// shortcuts for the common llvm types
4247

gen/pgo_ASTbased.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ void CodeGenPGO::emitCounterIncrement(const RootObject *S) const {
909909
assert(counter_it != (*RegionCounterMap).end() &&
910910
"Statement not found in PGO counter map!");
911911
unsigned counter = counter_it->second;
912-
gIR->ir->CreateCall(GET_INTRINSIC_DECL(instrprof_increment),
912+
gIR->ir->CreateCall(GET_INTRINSIC_DECL(instrprof_increment, {}),
913913
{FuncNameVar, gIR->ir->getInt64(FunctionHash),
914914
gIR->ir->getInt32(NumRegionCounters),
915915
gIR->ir->getInt32(counter)});
@@ -1118,7 +1118,7 @@ void CodeGenPGO::valueProfile(uint32_t valueKind, llvm::Instruction *valueSite,
11181118
llvm::Value *Args[5] = {FuncNameVar, gIR->ir->getInt64(FunctionHash), value,
11191119
gIR->ir->getInt32(valueKind),
11201120
gIR->ir->getInt32(NumValueSites[valueKind])};
1121-
gIR->ir->CreateCall(GET_INTRINSIC_DECL(instrprof_value_profile), Args);
1121+
gIR->ir->CreateCall(GET_INTRINSIC_DECL(instrprof_value_profile, {}), Args);
11221122

11231123
gIR->ir->restoreIP(savedInsertPoint);
11241124

gen/runtime.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -887,7 +887,7 @@ static void emitInstrumentationFn(const char *name) {
887887

888888
// Grab the address of the calling function
889889
auto *caller =
890-
gIR->ir->CreateCall(GET_INTRINSIC_DECL(returnaddress), DtoConstInt(0));
890+
gIR->ir->CreateCall(GET_INTRINSIC_DECL(returnaddress, {}), DtoConstInt(0));
891891
auto callee = gIR->topfunc();
892892

893893
gIR->ir->CreateCall(fn, {callee, caller});

gen/tocall.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
273273
gABI->vaCopy(ap, &argptr);
274274
} else {
275275
LLValue *llAp = gABI->prepareVaStart(ap);
276-
p->ir->CreateCall(GET_INTRINSIC_DECL(vastart), llAp, "");
276+
p->ir->CreateCall(GET_INTRINSIC_DECL(vastart, llAp->getType()), llAp, "");
277277
}
278278
result = nullptr;
279279
return true;
@@ -321,7 +321,7 @@ bool DtoLowerMagicIntrinsic(IRState *p, FuncDeclaration *fndecl, CallExp *e,
321321
DLValue *ap = toElem((*e->arguments)[0])->isLVal(); // va_list
322322
assert(ap);
323323
LLValue *llAp = gABI->prepareVaArg(ap);
324-
p->ir->CreateCall(GET_INTRINSIC_DECL(vaend), llAp);
324+
p->ir->CreateCall(GET_INTRINSIC_DECL(vaend, llAp->getType()), llAp);
325325
result = nullptr;
326326
return true;
327327
}

gen/toir.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ class ToElemVisitor : public Visitor {
809809
// access to the type of the class to do a GEP).
810810
auto vtable = DtoLoad(dfnval->vtable->getType(), dfnval->vthis);
811811
auto cmp = p->ir->CreateICmpEQ(vtable, dfnval->vtable);
812-
p->ir->CreateCall(GET_INTRINSIC_DECL(assume), {cmp});
812+
p->ir->CreateCall(GET_INTRINSIC_DECL(assume, {}), {cmp});
813813
}
814814

815815
if (delayedDtorVar) {
@@ -1766,7 +1766,7 @@ class ToElemVisitor : public Visitor {
17661766
p->ir->SetInsertPoint(failedbb);
17671767

17681768
if (global.params.checkAction == CHECKACTION_halt) {
1769-
p->ir->CreateCall(GET_INTRINSIC_DECL(trap), {});
1769+
p->ir->CreateCall(GET_INTRINSIC_DECL(trap, {}), {});
17701770
p->ir->CreateUnreachable();
17711771
} else {
17721772
/* DMD Bugzilla 8360: If the condition is evaluated to true,
@@ -1923,7 +1923,7 @@ class ToElemVisitor : public Visitor {
19231923
IF_LOG Logger::print("HaltExp::toElem: %s\n", e->toChars());
19241924
LOG_SCOPE;
19251925

1926-
p->ir->CreateCall(GET_INTRINSIC_DECL(trap), {});
1926+
p->ir->CreateCall(GET_INTRINSIC_DECL(trap, {}), {});
19271927
p->ir->CreateUnreachable();
19281928

19291929
// this terminated the basicblock, start a new one

gen/trycatchfinally.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ llvm::BasicBlock *TryCatchFinallyScopes::emitLandingPad() {
730730
// "Call" llvm.eh.typeid.for, which gives us the eh selector value to
731731
// compare the landing pad selector value with.
732732
llvm::Value *ehTypeId = irs.ir->CreateCall(
733-
GET_INTRINSIC_DECL(eh_typeid_for), cb.classInfoPtr);
733+
GET_INTRINSIC_DECL(eh_typeid_for, irs.ir->getPtrTy()), cb.classInfoPtr);
734734

735735
// Compare the selector value from the unwinder against the expected
736736
// one and branch accordingly.

0 commit comments

Comments
 (0)