@@ -1265,7 +1265,11 @@ void *JIT::ExecutableCode(JIT::Function_p f)
1265
1265
// Return an executable pointer to the function
1266
1266
// ----------------------------------------------------------------------------
1267
1267
{
1268
+ #if LLVM_VERSION < 1100
1268
1269
JITTargetAddress address = p.Address (f->getName ());
1270
+ #else // LLVM_VERSION >= 1100
1271
+ JITTargetAddress address = p.Address (f->getName ().str ());
1272
+ #endif // LLVM_VERSION
1269
1273
record (llvm_functions, " Address of %v is %p" , f, (void *) address);
1270
1274
return (void *) address;
1271
1275
}
@@ -1292,7 +1296,11 @@ JIT::Function_p JIT::Prototype(JIT::Function_p function)
1292
1296
// If the function is in this module, return it, else return prototype for it
1293
1297
{
1294
1298
JIT::Module_p module = p.Module ();
1299
+ #if LLVM_VERSION < 1100
1295
1300
text name = function->getName ();
1301
+ #else // LLVM_VERSION >= 1100
1302
+ text name = function->getName ().str ();
1303
+ #endif
1296
1304
1297
1305
// First check if we don't already have it in the current module
1298
1306
if (module )
@@ -1583,13 +1591,38 @@ void JITBlock::SwitchTo(JIT::BasicBlock_p block)
1583
1591
}
1584
1592
1585
1593
1594
+ #if LLVM_VERSION < 1100
1595
+ #define Callee (V ) (V)
1596
+ #else // LLVM_VERSION >= 1100
1597
+ static inline llvm::FunctionCallee Callee (JIT::Value_p callee)
1598
+ // ----------------------------------------------------------------------------
1599
+ // Another totally useless wrapper with more damage to come
1600
+ // ----------------------------------------------------------------------------
1601
+ {
1602
+ JIT::Type_p type = callee->getType ();
1603
+ if (type->isFunctionTy ())
1604
+ {
1605
+ JIT::FunctionType_p ftype = (JIT::FunctionType_p) type;
1606
+ return llvm::FunctionCallee (ftype, callee);
1607
+ }
1608
+
1609
+ assert (type->isPointerTy () && " Callee requires a callable value" );
1610
+ JIT::PointerType_p ptype = (JIT::PointerType_p) type;
1611
+ type = ptype->getElementType ();
1612
+ assert (type->isFunctionTy () && " Callee require function type for callee" );
1613
+ JIT::FunctionType_p ftype = (JIT::FunctionType_p) type;
1614
+ return llvm::FunctionCallee (ftype, callee);
1615
+ }
1616
+ #endif
1617
+
1618
+
1586
1619
JIT::Value_p JITBlock::Call (JIT::Value_p callee, JIT::Value_p arg1)
1587
1620
// ----------------------------------------------------------------------------
1588
1621
// Create a call with one argument
1589
1622
// ----------------------------------------------------------------------------
1590
1623
{
1591
1624
JIT::Value_p proto = b.jit .Prototype (callee);
1592
- JIT::Value_p result = b->CreateCall (proto, {arg1});
1625
+ JIT::Value_p result = b->CreateCall (Callee ( proto) , {arg1});
1593
1626
record (llvm_ir, " Call %v(%v) = %v" , callee, arg1, result);
1594
1627
return result;
1595
1628
}
@@ -1603,7 +1636,7 @@ JIT::Value_p JITBlock::Call(JIT::Value_p callee,
1603
1636
// ----------------------------------------------------------------------------
1604
1637
{
1605
1638
JIT::Value_p proto = b.jit .Prototype (callee);
1606
- JIT::Value_p result = b->CreateCall (proto, {arg1, arg2});
1639
+ JIT::Value_p result = b->CreateCall (Callee ( proto) , {arg1, arg2});
1607
1640
record (llvm_ir, " Call %v(%v, %v) = %v" , callee, arg1, arg2, result);
1608
1641
return result;
1609
1642
}
@@ -1618,7 +1651,7 @@ JIT::Value_p JITBlock::Call(JIT::Value_p callee,
1618
1651
// ----------------------------------------------------------------------------
1619
1652
{
1620
1653
JIT::Value_p proto = b.jit .Prototype (callee);
1621
- JIT::Value_p result = b->CreateCall (proto, {arg1, arg2, arg3});
1654
+ JIT::Value_p result = b->CreateCall (Callee ( proto) , {arg1, arg2, arg3});
1622
1655
record (llvm_ir, " Call %v(%v, %v, %v) = %v" , callee, arg1,arg2,arg3, result);
1623
1656
return result;
1624
1657
}
@@ -1631,7 +1664,8 @@ JIT::Value_p JITBlock::Call(JIT::Value_p callee,
1631
1664
// ----------------------------------------------------------------------------
1632
1665
{
1633
1666
JIT::Value_p proto = b.jit .Prototype (callee);
1634
- JIT::Value_p result = b->CreateCall (proto, ArrayRef<JIT::Value_p>(args));
1667
+ JIT::Value_p result = b->CreateCall (Callee (proto),
1668
+ ArrayRef<JIT::Value_p>(args));
1635
1669
record (llvm_ir, " Call %v(#%u) = %v" , callee, args.size (), result);
1636
1670
return result;
1637
1671
}
0 commit comments