... | ... |
@@ -29,13 +29,20 @@ |
29 | 29 |
#include "llvm/ADT/PostOrderIterator.h" |
30 | 30 |
#include "llvm/ADT/SCCIterator.h" |
31 | 31 |
#include "llvm/Analysis/CallGraph.h" |
32 |
-#include "llvm/Analysis/Verifier.h" |
|
33 | 32 |
#if LLVM_VERSION < 32 |
34 | 33 |
#include "llvm/Analysis/DebugInfo.h" |
35 |
-#else |
|
34 |
+#elif LLVM_VERSION < 35 |
|
36 | 35 |
#include "llvm/DebugInfo.h" |
36 |
+#else |
|
37 |
+#include "llvm/IR/DebugInfo.h" |
|
37 | 38 |
#endif |
39 |
+#if LLVM_VERSION < 35 |
|
38 | 40 |
#include "llvm/Analysis/Dominators.h" |
41 |
+#include "llvm/Analysis/Verifier.h" |
|
42 |
+#else |
|
43 |
+#include "llvm/IR/Dominators.h" |
|
44 |
+#include "llvm/IR/Verifier.h" |
|
45 |
+#endif |
|
39 | 46 |
#include "llvm/Analysis/ConstantFolding.h" |
40 | 47 |
#if LLVM_VERSION < 29 |
41 | 48 |
//#include "llvm/Analysis/LiveValues.h" (unused) |
... | ... |
@@ -50,9 +57,14 @@ |
50 | 50 |
#include "llvm/Config/config.h" |
51 | 51 |
#include "llvm/Pass.h" |
52 | 52 |
#include "llvm/Support/CommandLine.h" |
53 |
+#if LLVM_VERSION < 35 |
|
53 | 54 |
#include "llvm/Support/DataFlow.h" |
54 | 55 |
#include "llvm/Support/InstIterator.h" |
55 | 56 |
#include "llvm/Support/GetElementPtrTypeIterator.h" |
57 |
+#else |
|
58 |
+#include "llvm/IR/InstIterator.h" |
|
59 |
+#include "llvm/IR/GetElementPtrTypeIterator.h" |
|
60 |
+#endif |
|
56 | 61 |
#include "llvm/ADT/DepthFirstIterator.h" |
57 | 62 |
#include "llvm/Transforms/Scalar.h" |
58 | 63 |
#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
... | ... |
@@ -71,7 +83,6 @@ |
71 | 71 |
#include "llvm/Intrinsics.h" |
72 | 72 |
#include "llvm/LLVMContext.h" |
73 | 73 |
#include "llvm/Module.h" |
74 |
-#include "llvm/Support/InstVisitor.h" |
|
75 | 74 |
#else |
76 | 75 |
#include "llvm/IR/DerivedTypes.h" |
77 | 76 |
#include "llvm/IR/Instructions.h" |
... | ... |
@@ -79,7 +90,14 @@ |
79 | 79 |
#include "llvm/IR/Intrinsics.h" |
80 | 80 |
#include "llvm/IR/LLVMContext.h" |
81 | 81 |
#include "llvm/IR/Module.h" |
82 |
+#endif |
|
83 |
+ |
|
84 |
+#if LLVM_VERSION < 33 |
|
85 |
+#include "llvm/Support/InstVisitor.h" |
|
86 |
+#elif LLVM_VERSION < 35 |
|
82 | 87 |
#include "llvm/InstVisitor.h" |
88 |
+#else |
|
89 |
+#include "llvm/IR/InstVisitor.h" |
|
83 | 90 |
#endif |
84 | 91 |
|
85 | 92 |
#define DEFINEPASS(passname) passname() : FunctionPass(ID) |
... | ... |
@@ -103,10 +121,18 @@ namespace llvm { |
103 | 103 |
private: |
104 | 104 |
DenseSet<Function*> badFunctions; |
105 | 105 |
std::vector<Instruction*> delInst; |
106 |
+#if LLVM_VERSION < 35 |
|
106 | 107 |
CallGraphNode *rootNode; |
108 |
+#else |
|
109 |
+ CallGraph *CG; |
|
110 |
+#endif |
|
107 | 111 |
public: |
108 | 112 |
static char ID; |
113 |
+#if LLVM_VERSION < 35 |
|
109 | 114 |
DEFINEPASS(PtrVerifier), rootNode(0), PT(), TD(), SE(), expander(), |
115 |
+#else |
|
116 |
+ DEFINEPASS(PtrVerifier), CG(0), PT(), TD(), SE(), expander(), |
|
117 |
+#endif |
|
110 | 118 |
DT(), AbrtBB(), Changed(false), valid(false), EP() { |
111 | 119 |
#if LLVM_VERSION >= 29 |
112 | 120 |
initializePtrVerifierPass(*PassRegistry::getPassRegistry()); |
... | ... |
@@ -133,12 +159,21 @@ namespace llvm { |
133 | 133 |
AbrtBB = 0; |
134 | 134 |
valid = true; |
135 | 135 |
|
136 |
+#if LLVM_VERSION < 35 |
|
136 | 137 |
if (!rootNode) { |
137 | 138 |
rootNode = getAnalysis<CallGraph>().getRoot(); |
139 |
+#else |
|
140 |
+ if (!CG) { |
|
141 |
+ CG = &getAnalysis<CallGraphWrapperPass>().getCallGraph(); |
|
142 |
+#endif |
|
138 | 143 |
// No recursive functions for now. |
139 | 144 |
// In the future we may insert runtime checks for stack depth. |
145 |
+#if LLVM_VERSION < 35 |
|
140 | 146 |
for (scc_iterator<CallGraphNode*> SCCI = scc_begin(rootNode), |
141 | 147 |
E = scc_end(rootNode); SCCI != E; ++SCCI) { |
148 |
+#else |
|
149 |
+ for (scc_iterator<CallGraph*> SCCI = scc_begin(CG); !SCCI.isAtEnd(); ++SCCI) { |
|
150 |
+#endif |
|
142 | 151 |
const std::vector<CallGraphNode*> &nextSCC = *SCCI; |
143 | 152 |
if (nextSCC.size() > 1 || SCCI.hasLoop()) { |
144 | 153 |
errs() << "INVALID: Recursion detected, callgraph SCC components: "; |
... | ... |
@@ -164,12 +199,19 @@ namespace llvm { |
164 | 164 |
EP = &*It; |
165 | 165 |
#if LLVM_VERSION < 32 |
166 | 166 |
TD = &getAnalysis<TargetData>(); |
167 |
-#else |
|
167 |
+#elif LLVM_VERSION < 35 |
|
168 | 168 |
TD = &getAnalysis<DataLayout>(); |
169 |
+#else |
|
170 |
+ DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); |
|
171 |
+ TD = DLP ? &DLP->getDataLayout() : 0; |
|
169 | 172 |
#endif |
170 | 173 |
SE = &getAnalysis<ScalarEvolution>(); |
171 | 174 |
PT = &getAnalysis<PointerTracking>(); |
175 |
+#if LLVM_VERSION < 35 |
|
172 | 176 |
DT = &getAnalysis<DominatorTree>(); |
177 |
+#else |
|
178 |
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
|
179 |
+#endif |
|
173 | 180 |
expander = new SCEVExpander(*SE OPT("SCEVexpander")); |
174 | 181 |
|
175 | 182 |
std::vector<Instruction*> insns; |
... | ... |
@@ -307,13 +349,23 @@ namespace llvm { |
307 | 307 |
virtual void getAnalysisUsage(AnalysisUsage &AU) const { |
308 | 308 |
#if LLVM_VERSION < 32 |
309 | 309 |
AU.addRequired<TargetData>(); |
310 |
-#else |
|
310 |
+#elif LLVM_VERSION < 35 |
|
311 | 311 |
AU.addRequired<DataLayout>(); |
312 |
+#else |
|
313 |
+ AU.addRequired<DataLayoutPass>(); |
|
312 | 314 |
#endif |
315 |
+#if LLVM_VERSION < 35 |
|
313 | 316 |
AU.addRequired<DominatorTree>(); |
317 |
+#else |
|
318 |
+ AU.addRequired<DominatorTreeWrapperPass>(); |
|
319 |
+#endif |
|
314 | 320 |
AU.addRequired<ScalarEvolution>(); |
315 | 321 |
AU.addRequired<PointerTracking>(); |
322 |
+#if LLVM_VERSION < 35 |
|
316 | 323 |
AU.addRequired<CallGraph>(); |
324 |
+#else |
|
325 |
+ AU.addRequired<CallGraphWrapperPass>(); |
|
326 |
+#endif |
|
317 | 327 |
} |
318 | 328 |
|
319 | 329 |
bool isValid() const { return valid; } |
... | ... |
@@ -321,8 +373,10 @@ namespace llvm { |
321 | 321 |
PointerTracking *PT; |
322 | 322 |
#if LLVM_VERSION < 32 |
323 | 323 |
TargetData *TD; |
324 |
-#else |
|
324 |
+#elif LLVM_VERSION < 35 |
|
325 | 325 |
DataLayout *TD; |
326 |
+#else |
|
327 |
+ const DataLayout *TD; |
|
326 | 328 |
#endif |
327 | 329 |
ScalarEvolution *SE; |
328 | 330 |
SCEVExpander *expander; |
... | ... |
@@ -855,15 +909,23 @@ namespace llvm { |
855 | 855 |
INITIALIZE_PASS_BEGIN(PtrVerifier, "", "", false, false) |
856 | 856 |
#if LLVM_VERSION < 32 |
857 | 857 |
INITIALIZE_PASS_DEPENDENCY(TargetData) |
858 |
-#else |
|
858 |
+#elif LLVM_VERSION < 35 |
|
859 | 859 |
INITIALIZE_PASS_DEPENDENCY(DataLayout) |
860 |
+#else |
|
861 |
+INITIALIZE_PASS_DEPENDENCY(DataLayoutPass) |
|
860 | 862 |
#endif |
863 |
+#if LLVM_VERSION < 35 |
|
861 | 864 |
INITIALIZE_PASS_DEPENDENCY(DominatorTree) |
865 |
+#else |
|
866 |
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
|
867 |
+#endif |
|
862 | 868 |
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
863 | 869 |
#if LLVM_VERSION < 34 |
864 | 870 |
INITIALIZE_AG_DEPENDENCY(CallGraph) |
865 |
-#else |
|
871 |
+#elif LLVM_VERSION < 35 |
|
866 | 872 |
INITIALIZE_PASS_DEPENDENCY(CallGraph) |
873 |
+#else |
|
874 |
+INITIALIZE_PASS_DEPENDENCY(CallGraphWrapperPass) |
|
867 | 875 |
#endif |
868 | 876 |
INITIALIZE_PASS_DEPENDENCY(PointerTracking) |
869 | 877 |
INITIALIZE_PASS_END(PtrVerifier, "clambc-rtchecks", "ClamBC RTchecks", false, false) |
... | ... |
@@ -16,15 +16,19 @@ |
16 | 16 |
#ifndef _WIN32 |
17 | 17 |
|
18 | 18 |
#include "llvm/Analysis/ConstantFolding.h" |
19 |
-#include "llvm/Analysis/Dominators.h" |
|
20 | 19 |
#include "llvm/Analysis/LoopInfo.h" |
21 | 20 |
#include "llvm/Analysis/MemoryBuiltins.h" |
22 | 21 |
#include "llvm/Analysis/ValueTracking.h" |
23 | 22 |
#include "PointerTracking.h" |
24 | 23 |
#include "llvm/Analysis/ScalarEvolution.h" |
25 | 24 |
#include "llvm/Analysis/ScalarEvolutionExpressions.h" |
25 |
+#if LLVM_VERSION < 35 |
|
26 | 26 |
#include "llvm/Support/CallSite.h" |
27 | 27 |
#include "llvm/Support/InstIterator.h" |
28 |
+#else |
|
29 |
+#include "llvm/IR/CallSite.h" |
|
30 |
+#include "llvm/IR/InstIterator.h" |
|
31 |
+#endif |
|
28 | 32 |
#include "llvm/Support/raw_ostream.h" |
29 | 33 |
#include "llvm/Target/TargetLibraryInfo.h" |
30 | 34 |
|
... | ... |
@@ -61,10 +65,18 @@ namespace llvm { |
61 | 61 |
}; |
62 | 62 |
INITIALIZE_PASS_BEGIN(PointerTracking, "pointertracking", |
63 | 63 |
"Track pointer bounds", false, true) |
64 |
+#if LLVM_VERSION < 35 |
|
64 | 65 |
INITIALIZE_PASS_DEPENDENCY(DominatorTree) |
66 |
+#else |
|
67 |
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
|
68 |
+#endif |
|
65 | 69 |
INITIALIZE_PASS_DEPENDENCY(LoopInfo) |
66 | 70 |
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
71 |
+#if LLVM_VERSION < 35 |
|
67 | 72 |
INITIALIZE_PASS_DEPENDENCY(DominatorTree) |
73 |
+#else |
|
74 |
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
|
75 |
+#endif |
|
68 | 76 |
INITIALIZE_PASS_END(PointerTracking, "pointertracking", |
69 | 77 |
"Track pointer bounds", false, true) |
70 | 78 |
#endif |
... | ... |
@@ -82,17 +94,28 @@ bool PointerTracking::runOnFunction(Function &F) { |
82 | 82 |
FF = &F; |
83 | 83 |
#if LLVM_VERSION < 32 |
84 | 84 |
TD = getAnalysisIfAvailable<TargetData>(); |
85 |
-#else |
|
85 |
+#elif LLVM_VERSION < 35 |
|
86 | 86 |
TD = getAnalysisIfAvailable<DataLayout>(); |
87 |
+#else |
|
88 |
+ DataLayoutPass *DLP = getAnalysisIfAvailable<DataLayoutPass>(); |
|
89 |
+ TD = DLP ? &DLP->getDataLayout() : 0; |
|
87 | 90 |
#endif |
88 | 91 |
SE = &getAnalysis<ScalarEvolution>(); |
89 | 92 |
LI = &getAnalysis<LoopInfo>(); |
93 |
+#if LLVM_VERSION < 35 |
|
90 | 94 |
DT = &getAnalysis<DominatorTree>(); |
95 |
+#else |
|
96 |
+ DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
|
97 |
+#endif |
|
91 | 98 |
return false; |
92 | 99 |
} |
93 | 100 |
|
94 | 101 |
void PointerTracking::getAnalysisUsage(AnalysisUsage &AU) const { |
102 |
+#if LLVM_VERSION < 35 |
|
95 | 103 |
AU.addRequiredTransitive<DominatorTree>(); |
104 |
+#else |
|
105 |
+ AU.addRequiredTransitive<DominatorTreeWrapperPass>(); |
|
106 |
+#endif |
|
96 | 107 |
AU.addRequiredTransitive<LoopInfo>(); |
97 | 108 |
AU.addRequiredTransitive<ScalarEvolution>(); |
98 | 109 |
AU.setPreservesAll(); |
... | ... |
@@ -28,9 +28,15 @@ |
28 | 28 |
#define LLVM_ANALYSIS_POINTERTRACKING_H |
29 | 29 |
|
30 | 30 |
#include "llvm/ADT/SmallPtrSet.h" |
31 |
+#if LLVM_VERSION < 35 |
|
31 | 32 |
#include "llvm/Analysis/Dominators.h" |
32 |
-#include "llvm/Pass.h" |
|
33 | 33 |
#include "llvm/Support/PredIteratorCache.h" |
34 |
+#else |
|
35 |
+#include "llvm/IR/Dominators.h" |
|
36 |
+#include "llvm/IR/PredIteratorCache.h" |
|
37 |
+#include "llvm/IR/DataLayout.h" |
|
38 |
+#endif |
|
39 |
+#include "llvm/Pass.h" |
|
34 | 40 |
#include "llvm30_compat.h" |
35 | 41 |
|
36 | 42 |
#if LLVM_VERSION < 33 |
... | ... |
@@ -117,8 +123,10 @@ namespace llvm { |
117 | 117 |
Function *FF; |
118 | 118 |
#if LLVM_VERSION < 32 |
119 | 119 |
TargetData *TD; |
120 |
-#else |
|
120 |
+#elif LLVM_VERSION < 35 |
|
121 | 121 |
DataLayout *TD; |
122 |
+#else |
|
123 |
+ const DataLayout *TD; |
|
122 | 124 |
#endif |
123 | 125 |
ScalarEvolution *SE; |
124 | 126 |
LoopInfo *LI; |
... | ... |
@@ -44,8 +44,15 @@ |
44 | 44 |
#include "llvm/ADT/SmallVector.h" |
45 | 45 |
#include "llvm/Analysis/LoopInfo.h" |
46 | 46 |
#include "llvm/Analysis/ScalarEvolution.h" |
47 |
+#if LLVM_VERSION < 35 |
|
47 | 48 |
#include "llvm/Analysis/Verifier.h" |
48 | 49 |
#include "llvm/AutoUpgrade.h" |
50 |
+#include "llvm/Support/TargetFolder.h" |
|
51 |
+#else |
|
52 |
+#include "llvm/IR/Verifier.h" |
|
53 |
+#include "llvm/IR/AutoUpgrade.h" |
|
54 |
+#include "llvm/Analysis/TargetFolder.h" |
|
55 |
+#endif |
|
49 | 56 |
#include "llvm/ExecutionEngine/ExecutionEngine.h" |
50 | 57 |
#include "llvm/ExecutionEngine/JIT.h" |
51 | 58 |
#include "llvm/ExecutionEngine/JITEventListener.h" |
... | ... |
@@ -100,15 +107,16 @@ void LLVMInitializePowerPCAsmPrinter(); |
100 | 100 |
#endif |
101 | 101 |
|
102 | 102 |
#include "llvm/Target/TargetOptions.h" |
103 |
-#include "llvm/Support/TargetFolder.h" |
|
104 | 103 |
#include "llvm/Transforms/Scalar.h" |
105 | 104 |
#include "llvm/Transforms/IPO.h" |
106 | 105 |
#include "llvm/Transforms/Utils/BasicBlockUtils.h" |
107 | 106 |
|
108 | 107 |
#if LLVM_VERSION < 32 |
109 | 108 |
#include "llvm/Analysis/DebugInfo.h" |
110 |
-#else |
|
109 |
+#elif LLVM_VERSION < 35 |
|
111 | 110 |
#include "llvm/DebugInfo.h" |
111 |
+#else |
|
112 |
+#include "llvm/IR/DebugInfo.h" |
|
112 | 113 |
#endif |
113 | 114 |
|
114 | 115 |
#if LLVM_VERSION < 32 |
... | ... |
@@ -144,6 +152,10 @@ void LLVMInitializePowerPCAsmPrinter(); |
144 | 144 |
#include "llvm/Analysis/CFG.h" |
145 | 145 |
#endif |
146 | 146 |
|
147 |
+#if LLVM_VERSION >= 35 |
|
148 |
+#include "llvm/IR/Dominators.h" |
|
149 |
+#endif |
|
150 |
+ |
|
147 | 151 |
//#define TIMING |
148 | 152 |
#undef TIMING |
149 | 153 |
|
... | ... |
@@ -657,7 +669,11 @@ public: |
657 | 657 |
} |
658 | 658 |
BBSetTy needsTimeoutCheck; |
659 | 659 |
BBMapTy BBMap; |
660 |
+#if LLVM_VERSION < 35 |
|
660 | 661 |
DominatorTree &DT = getAnalysis<DominatorTree>(); |
662 |
+#else |
|
663 |
+ DominatorTree &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
|
664 |
+#endif |
|
661 | 665 |
for (Function::iterator I=F.begin(),E=F.end(); I != E; ++I) { |
662 | 666 |
BasicBlock *BB = &*I; |
663 | 667 |
unsigned apicalls = 0; |
... | ... |
@@ -784,7 +800,11 @@ public: |
784 | 784 |
AU.setPreservesAll(); |
785 | 785 |
AU.addRequired<LoopInfo>(); |
786 | 786 |
AU.addRequired<ScalarEvolution>(); |
787 |
+#if LLVM_VERSION < 35 |
|
787 | 788 |
AU.addRequired<DominatorTree>(); |
789 |
+#else |
|
790 |
+ AU.addRequired<DominatorTreeWrapperPass>(); |
|
791 |
+#endif |
|
788 | 792 |
} |
789 | 793 |
}; |
790 | 794 |
char RuntimeLimits::ID; |
... | ... |
@@ -1856,7 +1876,11 @@ public: |
1856 | 1856 |
|
1857 | 1857 |
// If successful so far, run verifyFunction |
1858 | 1858 |
if (!broken) { |
1859 |
+#if LLVM_VERSION < 35 |
|
1859 | 1860 |
if (verifyFunction(*F, PrintMessageAction)) { |
1861 |
+#else |
|
1862 |
+ if (verifyFunction(*F, &errs())) { |
|
1863 |
+#endif |
|
1860 | 1864 |
// verification failed |
1861 | 1865 |
broken = true; |
1862 | 1866 |
cli_warnmsg("[Bytecode JIT]: Verification failed\n"); |
... | ... |
@@ -1945,7 +1969,11 @@ public: |
1945 | 1945 |
ReturnInst::Create(Context, CI, BB); |
1946 | 1946 |
|
1947 | 1947 |
delete [] Functions; |
1948 |
+#if LLVM_VERSION < 35 |
|
1948 | 1949 |
if (verifyFunction(*F, PrintMessageAction)) |
1950 |
+#else |
|
1951 |
+ if (verifyFunction(*F, &errs())) |
|
1952 |
+#endif |
|
1949 | 1953 |
return 0; |
1950 | 1954 |
|
1951 | 1955 |
/* DEBUG(errs() << "Generating code\n"); |
... | ... |
@@ -2125,7 +2153,11 @@ static void addFunctionProtos(struct CommonFunctions *CF, ExecutionEngine *EE, M |
2125 | 2125 |
INITIALIZE_PASS_BEGIN(RuntimeLimits, "rl", "Runtime Limits", false, false) |
2126 | 2126 |
INITIALIZE_PASS_DEPENDENCY(LoopInfo) |
2127 | 2127 |
INITIALIZE_PASS_DEPENDENCY(ScalarEvolution) |
2128 |
+#if LLVM_VERSION < 35 |
|
2128 | 2129 |
INITIALIZE_PASS_DEPENDENCY(DominatorTree) |
2130 |
+#else |
|
2131 |
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
|
2132 |
+#endif |
|
2129 | 2133 |
INITIALIZE_PASS_END(RuntimeLimits, "rl" ,"Runtime Limits", false, false) |
2130 | 2134 |
#endif |
2131 | 2135 |
|
... | ... |
@@ -2341,16 +2373,20 @@ static void setGuard(unsigned char* guardbuf) |
2341 | 2341 |
} |
2342 | 2342 |
#if LLVM_VERSION < 32 |
2343 | 2343 |
static void addFPasses(FunctionPassManager &FPM, bool trusted, const TargetData *TD) |
2344 |
-#else |
|
2344 |
+#elif LLVM_VERSION < 35 |
|
2345 | 2345 |
static void addFPasses(FunctionPassManager &FPM, bool trusted, const DataLayout *TD) |
2346 |
+#else |
|
2347 |
+static void addFPasses(FunctionPassManager &FPM, bool trusted, const Module *M) |
|
2346 | 2348 |
#endif |
2347 | 2349 |
{ |
2348 | 2350 |
// Set up the optimizer pipeline. Start with registering info about how |
2349 | 2351 |
// the target lays out data structures. |
2350 | 2352 |
#if LLVM_VERSION < 32 |
2351 | 2353 |
FPM.add(new TargetData(*TD)); |
2352 |
-#else |
|
2354 |
+#elif LLVM_VERSION < 35 |
|
2353 | 2355 |
FPM.add(new DataLayout(*TD)); |
2356 |
+#else |
|
2357 |
+ FPM.add(new DataLayoutPass(M)); |
|
2354 | 2358 |
#endif |
2355 | 2359 |
// Promote allocas to registers. |
2356 | 2360 |
FPM.add(createPromoteMemoryToRegisterPass()); |
... | ... |
@@ -2428,9 +2464,12 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2428 | 2428 |
#if LLVM_VERSION < 32 |
2429 | 2429 |
addFPasses(OurFPM, true, EE->getTargetData()); |
2430 | 2430 |
addFPasses(OurFPMUnsigned, false, EE->getTargetData()); |
2431 |
-#else |
|
2431 |
+#elif LLVM_VERSION < 35 |
|
2432 | 2432 |
addFPasses(OurFPM, true, EE->getDataLayout()); |
2433 | 2433 |
addFPasses(OurFPMUnsigned, false, EE->getDataLayout()); |
2434 |
+#else |
|
2435 |
+ addFPasses(OurFPM, true, M); |
|
2436 |
+ addFPasses(OurFPMUnsigned, false, M); |
|
2434 | 2437 |
#endif |
2435 | 2438 |
|
2436 | 2439 |
|
... | ... |
@@ -2541,8 +2580,10 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2541 | 2541 |
PassManager PM; |
2542 | 2542 |
#if LLVM_VERSION < 32 |
2543 | 2543 |
PM.add(new TargetData(*EE->getTargetData())); |
2544 |
-#else |
|
2544 |
+#elif LLVM_VERSION < 35 |
|
2545 | 2545 |
PM.add(new DataLayout(*EE->getDataLayout())); |
2546 |
+#else |
|
2547 |
+ PM.add(new DataLayoutPass(M)); |
|
2546 | 2548 |
#endif |
2547 | 2549 |
// TODO: only run this on the untrusted bytecodes, not all of them... |
2548 | 2550 |
if (has_untrusted) |
... | ... |
@@ -2601,10 +2642,17 @@ int cli_bytecode_prepare_jit(struct cli_all_bc *bcs) |
2601 | 2601 |
int bytecode_init(void) |
2602 | 2602 |
{ |
2603 | 2603 |
// If already initialized return |
2604 |
+#if LLVM_VERSION < 35 |
|
2604 | 2605 |
if (llvm_is_multithreaded()) { |
2605 | 2606 |
cli_warnmsg("bytecode_init: already initialized\n"); |
2606 | 2607 |
return CL_EARG; |
2607 | 2608 |
} |
2609 |
+#else |
|
2610 |
+ if (!LLVMIsMultithreaded()) { |
|
2611 |
+ cli_warnmsg("bytecode_init: LLVM is compiled without multithreading support\n"); |
|
2612 |
+ } |
|
2613 |
+#endif |
|
2614 |
+ |
|
2608 | 2615 |
llvm_install_error_handler(llvm_error_handler); |
2609 | 2616 |
#ifdef CL_DEBUG |
2610 | 2617 |
sys::PrintStackTraceOnErrorSignal(); |
... | ... |
@@ -2628,7 +2676,11 @@ int bytecode_init(void) |
2628 | 2628 |
#endif |
2629 | 2629 |
llvm::DwarfExceptionHandling = false; |
2630 | 2630 |
#endif |
2631 |
+#if LLVM_VERSION < 33 |
|
2631 | 2632 |
llvm_start_multithreaded(); |
2633 |
+#else |
|
2634 |
+ // This is now deprecated/useless: Multi-threading can only be enabled/disabled with the compile time define LLVM_ENABLE_THREADS in LLVM. |
|
2635 |
+#endif |
|
2632 | 2636 |
|
2633 | 2637 |
// If we have a native target, initialize it to ensure it is linked in and |
2634 | 2638 |
// usable by the JIT. |
... | ... |
@@ -2638,7 +2690,11 @@ int bytecode_init(void) |
2638 | 2638 |
InitializeAllTargets(); |
2639 | 2639 |
#endif |
2640 | 2640 |
|
2641 |
+#if LLVM_VERSION < 35 |
|
2641 | 2642 |
if (!llvm_is_multithreaded()) { |
2643 |
+#else |
|
2644 |
+ if (!LLVMIsMultithreaded()) { |
|
2645 |
+#endif |
|
2642 | 2646 |
//TODO:cli_dbgmsg |
2643 | 2647 |
DEBUG(errs() << "WARNING: ClamAV JIT built w/o atomic builtins\n" |
2644 | 2648 |
<< "On x86 for best performance ClamAV should be built for i686, not i386!\n"); |
... | ... |
@@ -2710,7 +2766,7 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
2710 | 2710 |
std::string ErrorMessage; |
2711 | 2711 |
#if LLVM_VERSION < 29 |
2712 | 2712 |
lines->buffer = MemoryBuffer::getFile(path, &ErrorMessage); |
2713 |
-#else |
|
2713 |
+#elif LLVM_VERSION < 35 |
|
2714 | 2714 |
OwningPtr<MemoryBuffer> File; |
2715 | 2715 |
error_code ec = MemoryBuffer::getFile(path, File); |
2716 | 2716 |
if (ec) { |
... | ... |
@@ -2718,6 +2774,15 @@ void cli_bytecode_debug_printsrc(const struct cli_bc_ctx *ctx) |
2718 | 2718 |
lines->buffer = 0; |
2719 | 2719 |
} else |
2720 | 2720 |
lines->buffer = File.take(); |
2721 |
+#else |
|
2722 |
+ ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFile(path); |
|
2723 |
+ if (!FileOrErr) { |
|
2724 |
+ // TODO: How to handle ErrorMessage? |
|
2725 |
+ lines->buffer = 0; |
|
2726 |
+ } |
|
2727 |
+ else { |
|
2728 |
+ lines->buffer = FileOrErr.get().release(); |
|
2729 |
+ } |
|
2721 | 2730 |
#endif |
2722 | 2731 |
if (!lines->buffer) { |
2723 | 2732 |
errs() << "Unable to open file '" << path << "'\n"; |
... | ... |
@@ -2863,7 +2928,10 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2863 | 2863 |
StringRef G; |
2864 | 2864 |
StringRef H; |
2865 | 2865 |
#endif |
2866 |
+#if LLVM_VERSION < 35 |
|
2866 | 2867 |
DIType TypeD; |
2868 |
+#endif |
|
2869 |
+ StringRef T; |
|
2867 | 2870 |
|
2868 | 2871 |
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(const_cast<Value*>(V))) { |
2869 | 2872 |
Value *DIGV = findDbgGlobalDeclare(GV); |
... | ... |
@@ -2880,7 +2948,11 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2880 | 2880 |
G = Var.getFilename(); |
2881 | 2881 |
H = Var.getDirectory(); |
2882 | 2882 |
#endif |
2883 |
+#if LLVM_VERSION < 35 |
|
2883 | 2884 |
TypeD = Var.getType(); |
2885 |
+#else |
|
2886 |
+ T = Var.getType().getName(); |
|
2887 |
+#endif |
|
2884 | 2888 |
} else if (Function *F = dyn_cast<Function>(const_cast<Value*>(V))){ |
2885 | 2889 |
Value *DIF = findDbgSubprogramDeclare(F); |
2886 | 2890 |
if (!DIF) return false; |
... | ... |
@@ -2896,7 +2968,11 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2896 | 2896 |
G = Var.getFilename(); |
2897 | 2897 |
H = Var.getDirectory(); |
2898 | 2898 |
#endif |
2899 |
+#if LLVM_VERSION < 35 |
|
2899 | 2900 |
TypeD = Var.getType(); |
2901 |
+#else |
|
2902 |
+ T = Var.getType().getName(); |
|
2903 |
+#endif |
|
2900 | 2904 |
} else { |
2901 | 2905 |
const DbgDeclareInst *DDI = findDbgDeclare(V); |
2902 | 2906 |
if (!DDI) return false; |
... | ... |
@@ -2913,10 +2989,16 @@ static bool getLocationInfo(const Value *V, std::string &DisplayName, |
2913 | 2913 |
G = StringRef(); |
2914 | 2914 |
H = StringRef(); |
2915 | 2915 |
#endif |
2916 |
+#if LLVM_VERSION < 35 |
|
2916 | 2917 |
TypeD = Var.getType(); |
2918 |
+#else |
|
2919 |
+ T = Var.getType().getName(); |
|
2920 |
+#endif |
|
2917 | 2921 |
} |
2918 | 2922 |
|
2919 |
- StringRef T = TypeD.getName(); |
|
2923 |
+#if LLVM_VERSION < 35 |
|
2924 |
+ T = TypeD.getName(); |
|
2925 |
+#endif |
|
2920 | 2926 |
if (!T.empty()) |
2921 | 2927 |
Type = T; |
2922 | 2928 |
#if LLVM_VERSION < 33 |
... | ... |
@@ -110,9 +110,9 @@ if test "x$packaged_llvm" = "xyes"; then |
110 | 110 |
elif test $llvmver_test -lt 290; then |
111 | 111 |
AC_MSG_RESULT([no ($llvmver)]) |
112 | 112 |
AC_MSG_ERROR([LLVM >= 2.9 required, but "$llvmver"($llvmver_test) found]) |
113 |
-elif test $llvmver_test -gt 342; then |
|
113 |
+elif test $llvmver_test -ge 360; then |
|
114 | 114 |
AC_MSG_RESULT([no ($llvmver)]) |
115 |
- AC_MSG_ERROR([LLVM <= 3.4.2 required, but "$llvmver"($llvmver_test) found]) |
|
115 |
+ AC_MSG_ERROR([LLVM < 3.6 required, but "$llvmver"($llvmver_test) found]) |
|
116 | 116 |
else |
117 | 117 |
AC_MSG_RESULT([ok ($llvmver)]) |
118 | 118 |
fi |