summarylogtreecommitdiffstats
path: root/llvm-3.8.patch
blob: 43a05941a23775d9fd83609b7fde5582e6b84ab2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
Index: frontends/llvm/CMakeLists.txt
===================================================================
--- frontends/llvm/CMakeLists.txt	(révision 1079)
+++ frontends/llvm/CMakeLists.txt	(copie de travail)
@@ -123,8 +123,8 @@
 find_package(LLVM REQUIRED)
 message(STATUS "Found LLVM ${LLVM_VERSION}")
 
-if (NOT LLVM_VERSION EQUAL 3.7)
-  message(FATAL_ERROR "llvm 3.7 required.")
+if (LLVM_VERSION VERSION_LESS "3.7")
+  message(FATAL_ERROR "llvm 3.7 or higher required.")
 endif()
 
 set(LLVM_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
@@ -191,7 +191,6 @@
   core
   instcombine
   instrumentation
-  ipa
   ipo
   irreader
   mc
@@ -204,4 +203,10 @@
 )
 target_link_libraries(ikos-pp ${IKOS_PP_LLVM_LIBS})
 
+if (LLVM_VERSION VERSION_LESS "3.8")
+  # IPA is only available on llvm 3.7 and below
+  llvm_map_components_to_libnames(IKOS_PP_IPA ipa)
+  target_link_libraries(ikos-pp ${IKOS_PP_IPA})
+endif()
+
 install(TARGETS ikos-pp RUNTIME DESTINATION bin OPTIONAL)
Index: frontends/llvm/src/ikos-pp/ikos_pp.cpp
===================================================================
--- frontends/llvm/src/ikos-pp/ikos_pp.cpp	(révision 1079)
+++ frontends/llvm/src/ikos-pp/ikos_pp.cpp	(copie de travail)
@@ -182,10 +182,13 @@
 
   llvm::legacy::PassManager pass_manager;
   llvm::PassRegistry& Registry = *llvm::PassRegistry::getPassRegistry();
+
   llvm::initializeAnalysis(Registry);
 
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 7)
   /// call graph and other IPA passes
   llvm::initializeIPA(Registry);
+#endif
 
   if (PPLevel == simple) {
     // -- SSA
@@ -251,7 +254,11 @@
     // loop-closed SSA
     pass_manager.add(llvm::createLCSSAPass());
     // trivial invariants outside loops
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 7)
     pass_manager.add(llvm::createBasicAliasAnalysisPass());
+#else
+    pass_manager.add(llvm::createBasicAAWrapperPass());
+#endif
     pass_manager.add(llvm::createLICMPass()); // LICM needs alias analysis
     pass_manager.add(llvm::createPromoteMemoryToRegisterPass());
     // dead loop elimination
Index: frontends/llvm/src/passes/llvm_to_ar.cpp
===================================================================
--- frontends/llvm/src/passes/llvm_to_ar.cpp	(révision 1079)
+++ frontends/llvm/src/passes/llvm_to_ar.cpp	(copie de travail)
@@ -457,7 +457,7 @@
       UnifyFunctionExitNodes& ufen = getAnalysis< UnifyFunctionExitNodes >(*f);
 
       _functions.push_back(boost::shared_ptr< ARFunction >(
-          new ARFunction(f,
+          new ARFunction(&*f,
                          ufen.getReturnBlock(),
                          ufen.getUnreachableBlock(),
                          ufen.getUnwindBlock())));
@@ -532,7 +532,7 @@
   for (Module::global_iterator global = m.global_begin();
        global != m.global_end();
        global++) {
-    _global_vars[global] = boost::shared_ptr< ARGlobalVar >(
+    _global_vars[&*global] = boost::shared_ptr< ARGlobalVar >(
         new ARGlobalVar(UIDGenerator::nextUID()));
   }
 
@@ -1286,7 +1286,8 @@
       case Instruction::FCmp:
       case Instruction::ICmp: {
         CmpInst* cmp = CmpInst::Create((Instruction::OtherOps)e->getOpcode(),
-                                       e->getPredicate(),
+                                       static_cast< CmpInst::Predicate >(
+                                           e->getPredicate()),
                                        e->getOperand(0),
                                        e->getOperand(1));
         cfg.split_blocks(cmp, cmp);
Index: frontends/llvm/src/passes/lower_cst_expr.cpp
===================================================================
--- frontends/llvm/src/passes/lower_cst_expr.cpp	(révision 1079)
+++ frontends/llvm/src/passes/lower_cst_expr.cpp	(copie de travail)
@@ -180,7 +180,8 @@
       Instruction::OtherOps OtherOp =
           (Instruction::OtherOps)(CstExp->getOpcode());
       NewInst = CmpInst::Create(OtherOp,
-                                CstExp->getPredicate(),
+                                static_cast< CmpInst::Predicate >(
+                                    CstExp->getPredicate()),
                                 CstExp->getOperand(0),
                                 CstExp->getOperand(1),
                                 CstExp->getName(),
Index: frontends/llvm/src/passes/mark_no_return_functions.cpp
===================================================================
--- frontends/llvm/src/passes/mark_no_return_functions.cpp	(révision 1079)
+++ frontends/llvm/src/passes/mark_no_return_functions.cpp	(copie de travail)
@@ -73,7 +73,7 @@
       continue;
 
     bool mayHaveSideEffects = false;
-    for (inst_iterator It = inst_begin(F), Et = inst_end(F); It != Et; ++It)
+    for (inst_iterator It = inst_begin(&*F), Et = inst_end(&*F); It != Et; ++It)
       mayHaveSideEffects |= It->mayHaveSideEffects();
 
     if (mayHaveSideEffects)
Index: frontends/llvm/src/utils/local.cpp
===================================================================
--- frontends/llvm/src/utils/local.cpp	(révision 1079)
+++ frontends/llvm/src/utils/local.cpp	(copie de travail)
@@ -37,7 +37,13 @@
   new UnreachableInst(I->getContext(), I);
 
   // All instructions after this are dead.
-  BasicBlock::iterator BBI = I, BBE = BB->end();
+#if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR == 7)
+  BasicBlock::iterator BBI = I;
+#else
+  BasicBlock::iterator BBI = I->getIterator();
+#endif
+  BasicBlock::iterator BBE = BB->end();
+
   while (BBI != BBE) {
     if (!BBI->use_empty())
       BBI->replaceAllUsesWith(UndefValue::get(BBI->getType()));
@@ -85,7 +91,7 @@
           ++BBI;
           if (!isa< UnreachableInst >(BBI)) {
             // Don't insert a call to llvm.trap right before the unreachable.
-            ikos_pp::changeToUnreachable(BBI, false);
+            ikos_pp::changeToUnreachable(&*BBI, false);
             Changed = true;
           }
           break;
@@ -142,7 +148,7 @@
 /// change was made, false otherwise.
 bool ikos_pp::removeUnreachableBlocks(Function& F) {
   SmallPtrSet< BasicBlock*, 128 > Reachable;
-  bool Changed = markAliveBlocks(F.begin(), Reachable);
+  bool Changed = markAliveBlocks(&*F.begin(), Reachable);
 
   // If there are unreachable blocks in the CFG...
   if (Reachable.size() == F.size())
@@ -154,17 +160,18 @@
   // Loop over all of the basic blocks that are not reachable, dropping all of
   // their internal references...
   for (Function::iterator BB = ++F.begin(), E = F.end(); BB != E; ++BB) {
-    if (Reachable.count(BB))
+    if (Reachable.count(&*BB))
       continue;
 
-    for (succ_iterator SI = succ_begin(BB), SE = succ_end(BB); SI != SE; ++SI)
+    for (succ_iterator SI = succ_begin(&*BB), SE = succ_end(&*BB); SI != SE;
+         ++SI)
       if (Reachable.count(*SI))
-        (*SI)->removePredecessor(BB);
+        (*SI)->removePredecessor(&*BB);
     BB->dropAllReferences();
   }
 
   for (Function::iterator I = ++F.begin(); I != F.end();)
-    if (!Reachable.count(I))
+    if (!Reachable.count(&*I))
       I = F.getBasicBlockList().erase(I);
     else
       ++I;