| ... | ... |
@@ -24,9 +24,16 @@ |
| 24 | 24 |
#ifndef _WIN32 |
| 25 | 25 |
#include <sys/time.h> |
| 26 | 26 |
#endif |
| 27 |
+#include <cstdlib> |
|
| 28 |
+#include <csetjmp> |
|
| 29 |
+#include <new> |
|
| 30 |
+#include <cerrno> |
|
| 31 |
+#include <string> |
|
| 27 | 32 |
|
| 28 | 33 |
#include "ClamBCModule.h" |
| 29 | 34 |
#include "ClamBCDiagnostics.h" |
| 35 |
+#include "llvm30_compat.h" |
|
| 36 |
+ |
|
| 30 | 37 |
#include "llvm/ADT/DenseMap.h" |
| 31 | 38 |
#include "llvm/ADT/BitVector.h" |
| 32 | 39 |
#include "llvm/ADT/PostOrderIterator.h" |
| ... | ... |
@@ -53,7 +60,16 @@ |
| 53 | 53 |
#include "llvm/Support/SourceMgr.h" |
| 54 | 54 |
#include "llvm/Support/PrettyStackTrace.h" |
| 55 | 55 |
|
| 56 |
-#ifdef LLVM29 |
|
| 56 |
+#if LLVM_VERSION < 29 |
|
| 57 |
+#include "llvm/System/DataTypes.h" |
|
| 58 |
+#include "llvm/System/Host.h" |
|
| 59 |
+#include "llvm/System/Memory.h" |
|
| 60 |
+#include "llvm/System/Mutex.h" |
|
| 61 |
+#include "llvm/System/Signals.h" |
|
| 62 |
+#include "llvm/System/Threading.h" |
|
| 63 |
+#include "llvm/System/ThreadLocal.h" |
|
| 64 |
+#else |
|
| 65 |
+#include "llvm/PassRegistry.h" |
|
| 57 | 66 |
#include "llvm/Support/DataTypes.h" |
| 58 | 67 |
#include "llvm/Support/FileSystem.h" |
| 59 | 68 |
#include "llvm/Support/Host.h" |
| ... | ... |
@@ -62,21 +78,13 @@ |
| 62 | 62 |
#include "llvm/Support/Signals.h" |
| 63 | 63 |
#include "llvm/Support/Threading.h" |
| 64 | 64 |
#include "llvm/Support/ThreadLocal.h" |
| 65 |
-#include "llvm/PassRegistry.h" |
|
| 65 |
+#endif |
|
| 66 |
+ |
|
| 66 | 67 |
#if LLVM_VERSION < 33 |
| 67 | 68 |
#include "llvm/IntrinsicInst.h" |
| 68 | 69 |
#else |
| 69 | 70 |
#include "llvm/IR/IntrinsicInst.h" |
| 70 | 71 |
#endif |
| 71 |
-#else |
|
| 72 |
-#include "llvm/System/DataTypes.h" |
|
| 73 |
-#include "llvm/System/Host.h" |
|
| 74 |
-#include "llvm/System/Memory.h" |
|
| 75 |
-#include "llvm/System/Mutex.h" |
|
| 76 |
-#include "llvm/System/Signals.h" |
|
| 77 |
-#include "llvm/System/Threading.h" |
|
| 78 |
-#include "llvm/System/ThreadLocal.h" |
|
| 79 |
-#endif |
|
| 80 | 72 |
|
| 81 | 73 |
#include "llvm/Support/Timer.h" |
| 82 | 74 |
|
| ... | ... |
@@ -84,22 +92,18 @@ extern "C" {
|
| 84 | 84 |
void LLVMInitializeX86AsmPrinter(); |
| 85 | 85 |
void LLVMInitializePowerPCAsmPrinter(); |
| 86 | 86 |
} |
| 87 |
-#include "llvm30_compat.h" |
|
| 88 |
-#ifdef LLVM30 |
|
| 89 |
-#include "llvm/Support/TargetSelect.h" |
|
| 90 |
-#else |
|
| 87 |
+ |
|
| 88 |
+#if LLVM_VERSION < 30 |
|
| 91 | 89 |
#include "llvm/Target/TargetSelect.h" |
| 90 |
+#else |
|
| 91 |
+#include "llvm/Support/TargetSelect.h" |
|
| 92 | 92 |
#endif |
| 93 |
+ |
|
| 93 | 94 |
#include "llvm/Target/TargetOptions.h" |
| 94 | 95 |
#include "llvm/Support/TargetFolder.h" |
| 95 | 96 |
#include "llvm/Transforms/Scalar.h" |
| 96 | 97 |
#include "llvm/Transforms/IPO.h" |
| 97 | 98 |
#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
| 98 |
-#include <cstdlib> |
|
| 99 |
-#include <csetjmp> |
|
| 100 |
-#include <new> |
|
| 101 |
-#include <cerrno> |
|
| 102 |
-#include <string> |
|
| 103 | 99 |
|
| 104 | 100 |
#if LLVM_VERSION < 32 |
| 105 | 101 |
#include "llvm/Analysis/DebugInfo.h" |
| ... | ... |
@@ -134,7 +138,9 @@ void LLVMInitializePowerPCAsmPrinter(); |
| 134 | 134 |
#include "llvm/IR/Module.h" |
| 135 | 135 |
#endif |
| 136 | 136 |
|
| 137 |
-#if LLVM_VERSION >= 34 |
|
| 137 |
+#if LLVM_VERSION < 34 |
|
| 138 |
+#include "llvm/Support/CFG.h" |
|
| 139 |
+#else |
|
| 138 | 140 |
#include "llvm/Analysis/CFG.h" |
| 139 | 141 |
#endif |
| 140 | 142 |
|
| ... | ... |
@@ -199,18 +205,14 @@ struct cli_bcengine {
|
| 199 | 199 |
}; |
| 200 | 200 |
|
| 201 | 201 |
extern "C" uint8_t cli_debug_flag; |
| 202 |
-#ifdef LLVM29 |
|
| 202 |
+#if LLVM_VERSION >= 29 |
|
| 203 | 203 |
namespace llvm {
|
| 204 | 204 |
void initializeRuntimeLimitsPass(PassRegistry&); |
| 205 | 205 |
}; |
| 206 | 206 |
#endif |
| 207 | 207 |
namespace {
|
| 208 | 208 |
|
| 209 |
-#ifndef LLVM28 |
|
| 210 |
-#define LLVM28 |
|
| 211 |
-#endif |
|
| 212 |
- |
|
| 213 |
-#ifdef LLVM28 |
|
| 209 |
+#if LLVM_VERSION >= 28 |
|
| 214 | 210 |
#define llvm_report_error(x) report_fatal_error(x) |
| 215 | 211 |
#define llvm_install_error_handler(x) install_fatal_error_handler(x) |
| 216 | 212 |
#define DwarfExceptionHandling JITExceptionHandling |
| ... | ... |
@@ -220,7 +222,7 @@ namespace {
|
| 220 | 220 |
#define DEFINEPASS(passname) passname() : FunctionPass(&ID) |
| 221 | 221 |
#endif |
| 222 | 222 |
|
| 223 |
-#ifdef LLVM29 |
|
| 223 |
+#if LLVM_VERSION >= 29 |
|
| 224 | 224 |
#define NORETURN LLVM_ATTRIBUTE_NORETURN |
| 225 | 225 |
#endif |
| 226 | 226 |
|
| ... | ... |
@@ -464,10 +466,10 @@ public: |
| 464 | 464 |
|
| 465 | 465 |
class LLVMTypeMapper {
|
| 466 | 466 |
private: |
| 467 |
-#ifdef LLVM30 |
|
| 468 |
- std::vector<Type*> TypeMap; |
|
| 469 |
-#else |
|
| 467 |
+#if LLVM_VERSION < 30 |
|
| 470 | 468 |
std::vector<PATypeHolder> TypeMap; |
| 469 |
+#else |
|
| 470 |
+ std::vector<Type*> TypeMap; |
|
| 471 | 471 |
#endif |
| 472 | 472 |
LLVMContext &Context; |
| 473 | 473 |
unsigned numTypes; |
| ... | ... |
@@ -502,22 +504,22 @@ public: |
| 502 | 502 |
// invalidated, so we must use a TypeHolder to an Opaque type as a |
| 503 | 503 |
// start. |
| 504 | 504 |
for (unsigned i=0;i<count;i++) {
|
| 505 |
-#ifdef LLVM30 |
|
| 506 |
- TypeMap.push_back(0); |
|
| 507 |
-#else |
|
| 505 |
+#if LLVM_VERSION < 30 |
|
| 508 | 506 |
TypeMap.push_back(OpaqueType::get(Context)); |
| 507 |
+#else |
|
| 508 |
+ TypeMap.push_back(0); |
|
| 509 | 509 |
#endif |
| 510 | 510 |
} |
| 511 | 511 |
for (unsigned i=0;i<count;i++) {
|
| 512 | 512 |
const struct cli_bc_type *type = &types[i]; |
| 513 | 513 |
|
| 514 | 514 |
constType *Ty = buildType(type, types, Hidden, 0); |
| 515 |
-#ifdef LLVM30 |
|
| 516 |
- TypeMap[i] = Ty; |
|
| 517 |
-#else |
|
| 515 |
+#if LLVM_VERSION < 30 |
|
| 518 | 516 |
// Make the opaque type a concrete type, doing recursive type |
| 519 | 517 |
// unification if needed. |
| 520 | 518 |
cast<OpaqueType>(TypeMap[i].get())->refineAbstractTypeTo(Ty); |
| 519 |
+#else |
|
| 520 |
+ TypeMap[i] = Ty; |
|
| 521 | 521 |
#endif |
| 522 | 522 |
} |
| 523 | 523 |
} |
| ... | ... |
@@ -569,7 +571,9 @@ public: |
| 569 | 569 |
return getStatic(ty); |
| 570 | 570 |
ty -= 69; |
| 571 | 571 |
assert(ty < numTypes && "TypeID out of range"); |
| 572 |
-#ifdef LLVM30 |
|
| 572 |
+#if LLVM_VERSION < 30 |
|
| 573 |
+ return TypeMap[ty].get(); |
|
| 574 |
+#else |
|
| 573 | 575 |
Type *Ty = TypeMap[ty]; |
| 574 | 576 |
if (Ty) |
| 575 | 577 |
return Ty; |
| ... | ... |
@@ -577,8 +581,6 @@ public: |
| 577 | 577 |
Ty = buildType(&types[ty], types, Hidden, 1); |
| 578 | 578 |
TypeMap[ty] = Ty; |
| 579 | 579 |
return Ty; |
| 580 |
-#else |
|
| 581 |
- return TypeMap[ty].get(); |
|
| 582 | 580 |
#endif |
| 583 | 581 |
} |
| 584 | 582 |
}; |
| ... | ... |
@@ -637,7 +639,7 @@ class RuntimeLimits : public FunctionPass {
|
| 637 | 637 |
public: |
| 638 | 638 |
static char ID; |
| 639 | 639 |
DEFINEPASS(RuntimeLimits) {
|
| 640 |
-#ifdef LLVM29 |
|
| 640 |
+#if LLVM_VERSION >= 29 |
|
| 641 | 641 |
PassRegistry &Registry = *PassRegistry::getPassRegistry(); |
| 642 | 642 |
initializeRuntimeLimitsPass(Registry); |
| 643 | 643 |
#endif |
| ... | ... |
@@ -735,7 +737,7 @@ public: |
| 735 | 735 |
IRBuilder<false> Builder(F.getContext()); |
| 736 | 736 |
|
| 737 | 737 |
Value *Flag = F.arg_begin(); |
| 738 |
-#ifndef LLVM30 |
|
| 738 |
+#if LLVM_VERSION < 30 |
|
| 739 | 739 |
Function *LSBarrier = Intrinsic::getDeclaration(F.getParent(), |
| 740 | 740 |
Intrinsic::memory_barrier); |
| 741 | 741 |
Value *MBArgs[] = {
|
| ... | ... |
@@ -755,11 +757,11 @@ public: |
| 755 | 755 |
E=needsTimeoutCheck.end(); I != E; ++I) {
|
| 756 | 756 |
BasicBlock *BB = *I; |
| 757 | 757 |
Builder.SetInsertPoint(BB, BB->getTerminator()); |
| 758 |
-#ifdef LLVM30 |
|
| 759 |
- Builder.CreateFence(Release); |
|
| 760 |
-#else |
|
| 758 |
+#if LLVM_VERSION < 30 |
|
| 761 | 759 |
// store-load barrier: will be a no-op on x86 but not other arches |
| 762 | 760 |
Builder.CreateCall(LSBarrier, ARRAYREF(Value*, MBArgs, MBArgs+5)); |
| 761 |
+#else |
|
| 762 |
+ Builder.CreateFence(Release); |
|
| 763 | 763 |
#endif |
| 764 | 764 |
// Load Flag that tells us we timed out (first byte in bc_ctx) |
| 765 | 765 |
Value *Cond = Builder.CreateLoad(Flag, true); |
| ... | ... |
@@ -1094,7 +1096,7 @@ public: |
| 1094 | 1094 |
numArgs = 0; |
| 1095 | 1095 |
} |
| 1096 | 1096 |
|
| 1097 |
-#ifndef LLVM30 |
|
| 1097 |
+#if LLVM_VERSION < 30 |
|
| 1098 | 1098 |
template <typename InputIterator> |
| 1099 | 1099 |
#endif |
| 1100 | 1100 |
Value* createGEP(Value *Base, constType *ETy, ARRAYREFPARAM(Value*,InputIterator Start,InputIterator End,ARef)) {
|
| ... | ... |
@@ -1111,10 +1113,10 @@ public: |
| 1111 | 1111 |
ostr << " base: " << *Base << ";"; |
| 1112 | 1112 |
Base->getType()->print(ostr); |
| 1113 | 1113 |
ostr << "\n indices: "; |
| 1114 |
-#ifdef LLVM30 |
|
| 1115 |
- for (ArrayRef<Value*>::iterator I=ARef.begin(); I != ARef.end(); I++) {
|
|
| 1116 |
-#else |
|
| 1114 |
+#if LLVM_VERSION < 30 |
|
| 1117 | 1115 |
for (InputIterator I=Start; I != End; I++) {
|
| 1116 |
+#else |
|
| 1117 |
+ for (ArrayRef<Value*>::iterator I=ARef.begin(); I != ARef.end(); I++) {
|
|
| 1118 | 1118 |
#endif |
| 1119 | 1119 |
ostr << **I << ", "; |
| 1120 | 1120 |
} |
| ... | ... |
@@ -1128,7 +1130,7 @@ public: |
| 1128 | 1128 |
return Builder.CreateGEP(Base,ARRAYREFP(Start,End,ARef)); |
| 1129 | 1129 |
} |
| 1130 | 1130 |
|
| 1131 |
-#ifndef LLVM30 |
|
| 1131 |
+#if LLVM_VERSION < 30 |
|
| 1132 | 1132 |
template <typename InputIterator> |
| 1133 | 1133 |
#endif |
| 1134 | 1134 |
bool createGEP(unsigned dest, Value *Base, ARRAYREFPARAM(Value*,InputIterator Start,InputIterator End,ARef)) {
|
| ... | ... |
@@ -1185,7 +1187,7 @@ public: |
| 1185 | 1185 |
// Have an alloca -> some instruction uses its address otherwise |
| 1186 | 1186 |
// mem2reg would have converted it to an SSA register. |
| 1187 | 1187 |
// Enable stack protector for this function. |
| 1188 |
-#ifndef LLVM29 |
|
| 1188 |
+#if LLVM_VERSION < 29 |
|
| 1189 | 1189 |
// LLVM 2.9 has broken SSP, it does a 'mov 0x28, $rax', which tries |
| 1190 | 1190 |
// to read from the address 0x28 and crashes |
| 1191 | 1191 |
F->addFnAttr(Attribute::StackProtectReq); |
| ... | ... |
@@ -1194,7 +1196,7 @@ public: |
| 1194 | 1194 |
// always add stackprotect attribute (bb #2239), so we know this |
| 1195 | 1195 |
// function was verified. If there is no alloca it won't actually add |
| 1196 | 1196 |
// stack protector in emitted code so this won't slow down the app. |
| 1197 |
-#ifndef LLVM29 |
|
| 1197 |
+#if LLVM_VERSION < 29 |
|
| 1198 | 1198 |
F->addFnAttr(Attribute::StackProtect); |
| 1199 | 1199 |
#endif |
| 1200 | 1200 |
} |
| ... | ... |
@@ -1702,14 +1704,14 @@ public: |
| 1702 | 1702 |
Value *Val = convertOperand(func, Type::getInt8Ty(Context), inst->u.three[1]); |
| 1703 | 1703 |
//Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
| 1704 | 1704 |
Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]); |
| 1705 |
-#ifdef LLVM30 |
|
| 1705 |
+#if LLVM_VERSION < 30 |
|
| 1706 |
+ CallInst *c = Builder.CreateCall4(CF->FMemset, Dst, Val, Len, |
|
| 1707 |
+ ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
| 1708 |
+#else |
|
| 1706 | 1709 |
CallInst *c = Builder.CreateCall5(CF->FMemset, Dst, Val, Len, |
| 1707 | 1710 |
ConstantInt::get(Type::getInt32Ty(Context), 1), |
| 1708 | 1711 |
ConstantInt::get(Type::getInt1Ty(Context), 0) |
| 1709 | 1712 |
); |
| 1710 |
-#else |
|
| 1711 |
- CallInst *c = Builder.CreateCall4(CF->FMemset, Dst, Val, Len, |
|
| 1712 |
- ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
| 1713 | 1713 |
#endif |
| 1714 | 1714 |
c->setTailCall(true); |
| 1715 | 1715 |
c->setDoesNotThrow(); |
| ... | ... |
@@ -1724,14 +1726,14 @@ public: |
| 1724 | 1724 |
Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context))); |
| 1725 | 1725 |
//Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
| 1726 | 1726 |
Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]); |
| 1727 |
-#ifdef LLVM30 |
|
| 1727 |
+#if LLVM_VERSION < 30 |
|
| 1728 |
+ CallInst *c = Builder.CreateCall4(CF->FMemcpy, Dst, Src, Len, |
|
| 1729 |
+ ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
| 1730 |
+#else |
|
| 1728 | 1731 |
CallInst *c = Builder.CreateCall5(CF->FMemcpy, Dst, Src, Len, |
| 1729 | 1732 |
ConstantInt::get(Type::getInt32Ty(Context), 1), |
| 1730 | 1733 |
ConstantInt::get(Type::getInt1Ty(Context), 0) |
| 1731 | 1734 |
); |
| 1732 |
-#else |
|
| 1733 |
- CallInst *c = Builder.CreateCall4(CF->FMemcpy, Dst, Src, Len, |
|
| 1734 |
- ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
| 1735 | 1735 |
#endif |
| 1736 | 1736 |
c->setTailCall(true); |
| 1737 | 1737 |
c->setDoesNotThrow(); |
| ... | ... |
@@ -1746,13 +1748,13 @@ public: |
| 1746 | 1746 |
Src = Builder.CreatePointerCast(Src, PointerType::getUnqual(Type::getInt8Ty(Context))); |
| 1747 | 1747 |
//Value *Len = convertOperand(func, Type::getInt32Ty(Context), inst->u.three[2]); |
| 1748 | 1748 |
Value *Len = convertOperand(func, Type::getInt64Ty(Context), inst->u.three[2]); |
| 1749 |
-#ifdef LLVM30 |
|
| 1749 |
+#if LLVM_VERSION < 30 |
|
| 1750 |
+ CallInst *c = Builder.CreateCall4(CF->FMemmove, Dst, Src, Len, |
|
| 1751 |
+ ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
| 1752 |
+#else |
|
| 1750 | 1753 |
CallInst *c = Builder.CreateCall5(CF->FMemmove, Dst, Src, Len, |
| 1751 | 1754 |
ConstantInt::get(Type::getInt32Ty(Context), 1), |
| 1752 | 1755 |
ConstantInt::get(Type::getInt1Ty(Context), 0)); |
| 1753 |
-#else |
|
| 1754 |
- CallInst *c = Builder.CreateCall4(CF->FMemmove, Dst, Src, Len, |
|
| 1755 |
- ConstantInt::get(Type::getInt32Ty(Context), 1)); |
|
| 1756 | 1756 |
#endif |
| 1757 | 1757 |
c->setTailCall(true); |
| 1758 | 1758 |
c->setDoesNotThrow(); |
| ... | ... |
@@ -2005,18 +2007,18 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
| 2005 | 2005 |
//args.push_back(Type::getInt32Ty(Context)); |
| 2006 | 2006 |
args.push_back(Type::getInt64Ty(Context)); |
| 2007 | 2007 |
args.push_back(Type::getInt32Ty(Context)); |
| 2008 |
-#ifdef LLVM30 |
|
| 2008 |
+#if LLVM_VERSION >= 30 |
|
| 2009 | 2009 |
args.push_back(Type::getInt1Ty(Context)); |
| 2010 | 2010 |
#endif |
| 2011 | 2011 |
FunctionType* FuncTy_3 = FunctionType::get(Type::getVoidTy(Context), |
| 2012 | 2012 |
args, false); |
| 2013 | 2013 |
CF->FMemset = Function::Create(FuncTy_3, GlobalValue::ExternalLinkage, |
| 2014 |
-#ifdef LLVM30 |
|
| 2015 |
- //"llvm.memset.p0i8.i32", |
|
| 2016 |
- "llvm.memset.p0i8.i64", |
|
| 2017 |
-#else |
|
| 2014 |
+#if LLVM_VERSION < 30 |
|
| 2018 | 2015 |
//"llvm.memset.i32", |
| 2019 | 2016 |
"llvm.memset.i64", |
| 2017 |
+#else |
|
| 2018 |
+ //"llvm.memset.p0i8.i32", |
|
| 2019 |
+ "llvm.memset.p0i8.i64", |
|
| 2020 | 2020 |
#endif |
| 2021 | 2021 |
M); |
| 2022 | 2022 |
CF->FMemset->setDoesNotThrow(); |
| ... | ... |
@@ -2032,18 +2034,18 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
| 2032 | 2032 |
//args.push_back(Type::getInt32Ty(Context)); |
| 2033 | 2033 |
args.push_back(Type::getInt64Ty(Context)); |
| 2034 | 2034 |
args.push_back(Type::getInt32Ty(Context)); |
| 2035 |
-#ifdef LLVM30 |
|
| 2035 |
+#if LLVM_VERSION >= 30 |
|
| 2036 | 2036 |
args.push_back(Type::getInt1Ty(Context)); |
| 2037 | 2037 |
#endif |
| 2038 | 2038 |
FunctionType* FuncTy_4 = FunctionType::get(Type::getVoidTy(Context), |
| 2039 | 2039 |
args, false); |
| 2040 | 2040 |
CF->FMemmove = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage, |
| 2041 |
-#ifdef LLVM30 |
|
| 2042 |
- //"llvm.memmove.p0i8.i32", |
|
| 2043 |
- "llvm.memmove.p0i8.i64", |
|
| 2044 |
-#else |
|
| 2041 |
+#if LLVM_VERSION < 30 |
|
| 2045 | 2042 |
//"llvm.memmove.i32", |
| 2046 | 2043 |
"llvm.memcpy.i64", |
| 2044 |
+#else |
|
| 2045 |
+ //"llvm.memmove.p0i8.i32", |
|
| 2046 |
+ "llvm.memmove.p0i8.i64", |
|
| 2047 | 2047 |
#endif |
| 2048 | 2048 |
M); |
| 2049 | 2049 |
CF->FMemmove->setDoesNotThrow(); |
| ... | ... |
@@ -2054,12 +2056,12 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
| 2054 | 2054 |
#endif |
| 2055 | 2055 |
|
| 2056 | 2056 |
CF->FMemcpy = Function::Create(FuncTy_4, GlobalValue::ExternalLinkage, |
| 2057 |
-#ifdef LLVM30 |
|
| 2058 |
- //"llvm.memcpy.p0i8.p0i8.i32", |
|
| 2059 |
- "llvm.memcpy.p0i8.p0i8.i64", |
|
| 2060 |
-#else |
|
| 2057 |
+#if LLVM_VERSION < 30 |
|
| 2061 | 2058 |
//"llvm.memcpy.i32", |
| 2062 | 2059 |
"llvm.memcpy.i64", |
| 2060 |
+#else |
|
| 2061 |
+ //"llvm.memcpy.p0i8.p0i8.i32", |
|
| 2062 |
+ "llvm.memcpy.p0i8.p0i8.i64", |
|
| 2063 | 2063 |
#endif |
| 2064 | 2064 |
M); |
| 2065 | 2065 |
CF->FMemcpy->setDoesNotThrow(); |
| ... | ... |
@@ -2120,7 +2122,7 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
| 2120 | 2120 |
} |
| 2121 | 2121 |
|
| 2122 | 2122 |
} |
| 2123 |
-#ifdef LLVM29 |
|
| 2123 |
+#if LLVM_VERSION >= 29 |
|
| 2124 | 2124 |
INITIALIZE_PASS_BEGIN(RuntimeLimits, "rl", "Runtime Limits", false, false) |
| 2125 | 2125 |
INITIALIZE_PASS_DEPENDENCY(LoopInfo) |
| 2126 | 2126 |
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
| ... | ... |
@@ -2707,7 +2709,9 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
| 2707 | 2707 |
if (I == LinePrinter.files.end()) {
|
| 2708 | 2708 |
lines = new linesTy; |
| 2709 | 2709 |
std::string ErrorMessage; |
| 2710 |
-#ifdef LLVM29 |
|
| 2710 |
+#if LLVM_VERSION < 29 |
|
| 2711 |
+ lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage); |
|
| 2712 |
+#else |
|
| 2711 | 2713 |
OwningPtr<MemoryBuffer> File; |
| 2712 | 2714 |
error_code ec = MemoryBuffer::getFile(path, File); |
| 2713 | 2715 |
if (ec) {
|
| ... | ... |
@@ -2715,8 +2719,6 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
| 2715 | 2715 |
lines->buffer = 0; |
| 2716 | 2716 |
} else |
| 2717 | 2717 |
lines->buffer = File.take(); |
| 2718 |
-#else |
|
| 2719 |
- lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage); |
|
| 2720 | 2718 |
#endif |
| 2721 | 2719 |
if (!lines->buffer) {
|
| 2722 | 2720 |
errs() << "Unable to open file '" << path << "'\n"; |
| ... | ... |
@@ -2750,7 +2752,7 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
| 2750 | 2750 |
} |
| 2751 | 2751 |
assert(ctx->line < lines->linev.size()); |
| 2752 | 2752 |
|
| 2753 |
-#ifndef LLVM28 |
|
| 2753 |
+#if LLVM_VERSION < 28 |
|
| 2754 | 2754 |
int line = (int)ctx->line ? (int)ctx->line : -1; |
| 2755 | 2755 |
int col = (int)ctx->col ? (int)ctx->col : -1; |
| 2756 | 2756 |
//TODO: print this ourselves, instead of using SMDiagnostic |
| ... | ... |
@@ -2796,7 +2798,7 @@ void stop(const char *msg, llvm::Function* F, llvm::Instruction* I) |
| 2796 | 2796 |
} |
| 2797 | 2797 |
} |
| 2798 | 2798 |
|
| 2799 |
-#ifdef LLVM29 |
|
| 2799 |
+#if LLVM_VERSION >= 29 |
|
| 2800 | 2800 |
static Value *findDbgGlobalDeclare(GlobalVariable *V) {
|
| 2801 | 2801 |
const Module *M = V->getParent(); |
| 2802 | 2802 |
NamedMDNode *NMD = M->getNamedMetadata("llvm.dbg.gv");
|
| ... | ... |
@@ -21,19 +21,18 @@ |
| 21 | 21 |
*/ |
| 22 | 22 |
|
| 23 | 23 |
#include "llvm/ADT/Triple.h" |
| 24 |
+#include "llvm/Config/config.h" |
|
| 24 | 25 |
#include "llvm/Support/raw_ostream.h" |
| 25 |
-#ifdef LLVM29 |
|
| 26 |
-#include "llvm/Support/Host.h" |
|
| 27 |
-#include "llvm/Support/DataTypes.h" |
|
| 28 |
-#include "llvm/Support/Memory.h" |
|
| 29 |
-#else |
|
| 30 |
-#include "llvm/System/Host.h" |
|
| 26 |
+#if LLVM_VERSION < 29 |
|
| 31 | 27 |
#include "llvm/System/DataTypes.h" |
| 28 |
+#include "llvm/System/Host.h" |
|
| 32 | 29 |
#include "llvm/System/Memory.h" |
| 30 |
+#else |
|
| 31 |
+#include "llvm/Support/DataTypes.h" |
|
| 32 |
+#include "llvm/Support/Host.h" |
|
| 33 |
+#include "llvm/Support/Memory.h" |
|
| 33 | 34 |
#endif |
| 34 | 35 |
|
| 35 |
-#include "llvm/Config/config.h" |
|
| 36 |
- |
|
| 37 | 36 |
extern "C" {
|
| 38 | 37 |
#include "bytecode_detect.h" |
| 39 | 38 |
} |
| ... | ... |
@@ -155,7 +154,7 @@ void cli_detect_env_jit(struct cli_environment *env) |
| 155 | 155 |
CASE_OS(Linux, os_linux); |
| 156 | 156 |
CASE_OS(Lv2, os_unknown); |
| 157 | 157 |
CASE_OS(MinGW32, os_win32); |
| 158 |
-#ifndef LLVM29 |
|
| 158 |
+#if LLVM_VERSION < 29 |
|
| 159 | 159 |
CASE_OS(MinGW64, os_win64); |
| 160 | 160 |
#endif |
| 161 | 161 |
CASE_OS(NetBSD, os_bsd); |
| ... | ... |
@@ -1,16 +1,4 @@ |
| 1 |
-#ifdef LLVM30 |
|
| 2 |
-#define constType Type |
|
| 3 |
-#define constArrayType ArrayType |
|
| 4 |
-#define constStructType StructType |
|
| 5 |
-#define constPointerType PointerType |
|
| 6 |
-#define constFunctionType FunctionType |
|
| 7 |
-#define ARRAYREF(t,a,b) ArrayRef<t>(a,b) |
|
| 8 |
-#define ARRAYREFPARAM(t,a,b,n) ArrayRef<t> n |
|
| 9 |
-#define ARRAYREFP(a,b,n) n |
|
| 10 |
-#define ARRAYREFVECTOR(t,a) ArrayRef<t>(a) |
|
| 11 |
-#define HINT(n) n, |
|
| 12 |
-#define OPT(n) ,n |
|
| 13 |
-#else |
|
| 1 |
+#if LLVM_VERSION < 30 |
|
| 14 | 2 |
#define constType const Type |
| 15 | 3 |
#define constArrayType const ArrayType |
| 16 | 4 |
#define constStructType const StructType |
| ... | ... |
@@ -22,4 +10,16 @@ |
| 22 | 22 |
#define ARRAYREFVECTOR(t,a) (a).begin(),(a).end() |
| 23 | 23 |
#define HINT(n) |
| 24 | 24 |
#define OPT(n) |
| 25 |
+#else |
|
| 26 |
+#define constType Type |
|
| 27 |
+#define constArrayType ArrayType |
|
| 28 |
+#define constStructType StructType |
|
| 29 |
+#define constPointerType PointerType |
|
| 30 |
+#define constFunctionType FunctionType |
|
| 31 |
+#define ARRAYREF(t,a,b) ArrayRef<t>(a,b) |
|
| 32 |
+#define ARRAYREFPARAM(t,a,b,n) ArrayRef<t> n |
|
| 33 |
+#define ARRAYREFP(a,b,n) n |
|
| 34 |
+#define ARRAYREFVECTOR(t,a) ArrayRef<t>(a) |
|
| 35 |
+#define HINT(n) n, |
|
| 36 |
+#define OPT(n) ,n |
|
| 25 | 37 |
#endif |