-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathllvm-13.patch
388 lines (331 loc) · 14.4 KB
/
llvm-13.patch
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
From c3e0f2480dcd5be544dea42ad1f383ca80b833d3 Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 13:59:21 +0200
Subject: [PATCH 1/6] Support/FileHandling.cpp: rewrite to C++14
---
klee/lib/Support/FileHandling.cpp | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/klee/lib/Support/FileHandling.cpp b/klee/lib/Support/FileHandling.cpp
index af532a0..5318270 100644
--- a/klee/lib/Support/FileHandling.cpp
+++ b/klee/lib/Support/FileHandling.cpp
@@ -22,10 +22,9 @@ namespace klee {
std::unique_ptr<llvm::raw_fd_ostream>
klee_open_output_file(const std::string &path, std::string &error) {
- error = "";
- std::unique_ptr<llvm::raw_fd_ostream> f;
+ error.clear();
std::error_code ec;
- f = std::unique_ptr<llvm::raw_fd_ostream>(new llvm::raw_fd_ostream(path.c_str(), ec, llvm::sys::fs::F_None)); // FIXME C++14
+ auto f = std::make_unique<llvm::raw_fd_ostream>(path.c_str(), ec, llvm::sys::fs::F_None);
if (ec)
error = ec.message();
if (!error.empty()) {
@@ -37,8 +36,8 @@ klee_open_output_file(const std::string &path, std::string &error) {
#ifdef HAVE_ZLIB_H
std::unique_ptr<llvm::raw_ostream>
klee_open_compressed_output_file(const std::string &path, std::string &error) {
- error = "";
- std::unique_ptr<llvm::raw_ostream> f(new compressed_fd_ostream(path, error));
+ error.clear();
+ auto f = std::make_unique<compressed_fd_ostream>(path, error);
if (!error.empty()) {
f.reset(nullptr);
}
--
2.31.1
From e50fcad5b1323d5af460c9d55db59065d9e2ac16 Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 13:59:28 +0200
Subject: [PATCH 2/6] llvm13: llvm::fs::F_None has been removed
... and should be replaced with llvm::fs::OF_None since LLVM 7.
See: https://reviews.llvm.org/D101506
https://github.com/llvm/llvm-project/commit/1f67a3cba9b09636c56e2109d8a35ae96dc15782
---
klee/lib/Support/FileHandling.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/klee/lib/Support/FileHandling.cpp b/klee/lib/Support/FileHandling.cpp
index 5318270..3a75684 100644
--- a/klee/lib/Support/FileHandling.cpp
+++ b/klee/lib/Support/FileHandling.cpp
@@ -24,7 +24,12 @@ std::unique_ptr<llvm::raw_fd_ostream>
klee_open_output_file(const std::string &path, std::string &error) {
error.clear();
std::error_code ec;
+
+#if LLVM_VERSION_CODE >= LLVM_VERSION(7, 0)
+ auto f = std::make_unique<llvm::raw_fd_ostream>(path.c_str(), ec, llvm::sys::fs::OF_None);
+#else
auto f = std::make_unique<llvm::raw_fd_ostream>(path.c_str(), ec, llvm::sys::fs::F_None);
+#endif
if (ec)
error = ec.message();
if (!error.empty()) {
--
2.31.1
From 9ee0e3ca9eab65b6f898eb234f48b8c4faabd544 Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 13:59:29 +0200
Subject: [PATCH 3/6] llvm13: llvm::cl::GeneralCategory is no longer a global
Therefore, llvm::cl::getGlobalCategoiry() should be used instead.
See: https://reviews.llvm.org/D105959
---
klee/tools/kleaver/main.cpp | 5 ++++-
klee/tools/klee/main.cpp | 4 ++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/klee/tools/kleaver/main.cpp b/klee/tools/kleaver/main.cpp
index 57d384a..3af7b22 100644
--- a/klee/tools/kleaver/main.cpp
+++ b/klee/tools/kleaver/main.cpp
@@ -388,8 +388,11 @@ static bool printInputAsSMTklee/libv2(const char *Filename,
}
int main(int argc, char **argv) {
-
+#if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0)
+ KCommandLine::HideOptions(llvm::cl::getGeneralCategory());
+#else
KCommandLine::HideOptions(llvm::cl::GeneralCategory);
+#endif
bool success = true;
diff --git a/klee/tools/klee/main.cpp b/klee/tools/klee/main.cpp
index 7e9b837..72e476b 100644
--- a/klee/tools/klee/main.cpp
+++ b/klee/tools/klee/main.cpp
@@ -1533,7 +1533,11 @@ loadBitcode(const std::string& inputFile,
int main(int argc, char **argv, char **envp) {
atexit(llvm_shutdown); // Call llvm_shutdown() on exit.
+#if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0)
+ KCommandLine::HideOptions(llvm::cl::getGeneralCategory());
+#else
KCommandLine::HideOptions(llvm::cl::GeneralCategory);
+#endif
llvm::InitializeNativeTarget();
--
2.31.1
From d275546e491b6dd1a032ad773a8343ac983ff0f3 Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 13:59:31 +0200
Subject: [PATCH 4/6] llvm13: CreateLoad API with implicit types has been
deprecated
See: https://github.com/llvm/llvm-project/commit/6312c53870897435b38881795460ad9f34bf9819
---
klee/lib/Core/ExternalDispatcher.cpp | 4 ++--
klee/lib/Module/IntrinsicCleaner.cpp | 11 +++++++----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/klee/lib/Core/ExternalDispatcher.cpp b/klee/lib/Core/ExternalDispatcher.cpp
index dc1fb0a..34e83b1 100644
--- a/klee/lib/Core/ExternalDispatcher.cpp
+++ b/klee/lib/Core/ExternalDispatcher.cpp
@@ -277,7 +277,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
ConstantInt::get(Type::getInt64Ty(ctx), (uintptr_t)(void *)&gTheArgsP),
PointerType::getUnqual(PointerType::getUnqual(Type::getInt64Ty(ctx))),
"argsp");
- auto argI64s = Builder.CreateLoad(argI64sp, "args");
+ auto argI64s = Builder.CreateLoad(argI64sp->getType()->getPointerElementType(), argI64sp, "args");
// Get the target function type.
FunctionType *FTy = cast<FunctionType>(
@@ -296,7 +296,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
ConstantInt::get(Type::getInt32Ty(ctx), idx));
auto argp = Builder.CreateBitCast(argI64p, PointerType::getUnqual(argTy));
- args[i] = Builder.CreateLoad(argp);
+ args[i] = Builder.CreateLoad(argp->getType()->getPointerElementType(), argp, "");
unsigned argSize = argTy->getPrimitiveSizeInBits();
idx += ((!!argSize ? argSize : 64) + 63) / 64;
diff --git a/klee/lib/Module/IntrinsicCleaner.cpp b/klee/lib/Module/IntrinsicCleaner.cpp
index 7fe3359..b91d277 100644
--- a/klee/lib/Module/IntrinsicCleaner.cpp
+++ b/klee/lib/Module/IntrinsicCleaner.cpp
@@ -82,24 +82,27 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
Builder.CreatePointerCast(dst, i8pp, "vacopy.cast.dst");
auto castedSrc =
Builder.CreatePointerCast(src, i8pp, "vacopy.cast.src");
- auto load = Builder.CreateLoad(castedSrc, "vacopy.read");
+ auto load = Builder.CreateLoad(castedSrc->getType()->getPointerElementType(), castedSrc, "vacopy.read");
Builder.CreateStore(load, castedDst, false /* isVolatile */);
} else {
assert(WordSize == 8 && "Invalid word size!");
Type *i64p = PointerType::getUnqual(Type::getInt64Ty(ctx));
auto pDst = Builder.CreatePointerCast(dst, i64p, "vacopy.cast.dst");
auto pSrc = Builder.CreatePointerCast(src, i64p, "vacopy.cast.src");
- auto val = Builder.CreateLoad(pSrc, std::string());
+
+ auto pType = pSrc->getType()->getPointerElementType();
+
+ auto val = Builder.CreateLoad(pType, pSrc, "");
Builder.CreateStore(val, pDst, ii);
auto off = ConstantInt::get(Type::getInt64Ty(ctx), 1);
pDst = Builder.CreateGEP(nullptr, pDst, off, std::string());
pSrc = Builder.CreateGEP(nullptr, pSrc, off, std::string());
- val = Builder.CreateLoad(pSrc, std::string());
+ val = Builder.CreateLoad(pType, pSrc, "");
Builder.CreateStore(val, pDst);
pDst = Builder.CreateGEP(nullptr, pDst, off, std::string());
pSrc = Builder.CreateGEP(nullptr, pSrc, off, std::string());
- val = Builder.CreateLoad(pSrc, std::string());
+ val = Builder.CreateLoad(pType, pSrc, "");
Builder.CreateStore(val, pDst);
}
ii->eraseFromParent();
--
2.31.1
From cf6de8387db20ec030297a9448d00d6115cc36b7 Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 13:59:32 +0200
Subject: [PATCH 5/6] llvm13: CreateGEP no longer accepts nullptr
See: https://reviews.llvm.org/D105653
---
klee/lib/Core/ExternalDispatcher.cpp | 2 +-
klee/lib/Module/IntrinsicCleaner.cpp | 17 +++++++++--------
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/klee/lib/Core/ExternalDispatcher.cpp b/klee/lib/Core/ExternalDispatcher.cpp
index 34e83b1..ae5f268 100644
--- a/klee/lib/Core/ExternalDispatcher.cpp
+++ b/klee/lib/Core/ExternalDispatcher.cpp
@@ -292,7 +292,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
auto argTy =
(i < FTy->getNumParams() ? FTy->getParamType(i) : (*ai)->getType());
auto argI64p =
- Builder.CreateGEP(nullptr, argI64s,
+ Builder.CreateGEP(argI64s->getType()->getPointerElementType(), argI64s,
ConstantInt::get(Type::getInt32Ty(ctx), idx));
auto argp = Builder.CreateBitCast(argI64p, PointerType::getUnqual(argTy));
diff --git a/klee/lib/Module/IntrinsicCleaner.cpp b/klee/lib/Module/IntrinsicCleaner.cpp
index b91d277..47827a7 100644
--- a/klee/lib/Module/IntrinsicCleaner.cpp
+++ b/klee/lib/Module/IntrinsicCleaner.cpp
@@ -90,19 +90,20 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
auto pDst = Builder.CreatePointerCast(dst, i64p, "vacopy.cast.dst");
auto pSrc = Builder.CreatePointerCast(src, i64p, "vacopy.cast.src");
- auto pType = pSrc->getType()->getPointerElementType();
+ auto pSrcType = pSrc->getType()->getPointerElementType();
+ auto pDstType = pDst->getType()->getPointerElementType();
- auto val = Builder.CreateLoad(pType, pSrc, "");
+ auto val = Builder.CreateLoad(pSrcType, pSrc, "");
Builder.CreateStore(val, pDst, ii);
auto off = ConstantInt::get(Type::getInt64Ty(ctx), 1);
- pDst = Builder.CreateGEP(nullptr, pDst, off, std::string());
- pSrc = Builder.CreateGEP(nullptr, pSrc, off, std::string());
- val = Builder.CreateLoad(pType, pSrc, "");
+ pDst = Builder.CreateGEP(pDstType, pDst, off);
+ pSrc = Builder.CreateGEP(pSrcType, pSrc, off);
+ val = Builder.CreateLoad(pSrcType, pSrc, "");
Builder.CreateStore(val, pDst);
- pDst = Builder.CreateGEP(nullptr, pDst, off, std::string());
- pSrc = Builder.CreateGEP(nullptr, pSrc, off, std::string());
- val = Builder.CreateLoad(pType, pSrc, "");
+ pDst = Builder.CreateGEP(pDstType, pDst, off);
+ pSrc = Builder.CreateGEP(pSrcType, pSrc, off);
+ val = Builder.CreateLoad(pSrcType, pSrc, "");
Builder.CreateStore(val, pDst);
}
ii->eraseFromParent();
--
2.31.1
From 634db97407a7ef8841e84d2b94a55b208d3c12af Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 13:59:33 +0200
Subject: [PATCH 6/6] llvm13: std::string llvm::APInt::toString has been moved
to StringExtras.h
See: https://reviews.llvm.org/D103888
---
klee/lib/Expr/Expr.cpp | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/klee/lib/Expr/Expr.cpp b/klee/lib/Expr/Expr.cpp
index 9aad63d..5b1bb68 100644
--- a/klee/lib/Expr/Expr.cpp
+++ b/klee/lib/Expr/Expr.cpp
@@ -17,6 +17,9 @@
#include "klee/OptionCategories.h"
#include "llvm/ADT/Hashing.h"
+#if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0)
+#include "llvm/ADT/StringExtras.h"
+#endif
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
@@ -366,7 +369,11 @@ void ConstantExpr::toMemory(void *address) {
}
void ConstantExpr::toString(std::string &Res, unsigned radix) const {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0)
+ Res = llvm::toString(value, radix, false);
+#else
Res = value.toString(radix, false);
+#endif
}
ref<ConstantExpr> ConstantExpr::Concat(const ref<ConstantExpr> &RHS) {
--
2.31.1
From a88060231b3fe7feebb6a1f54a4c7af10c7d84fd Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Tue, 24 Aug 2021 16:04:58 +0200
Subject: [PATCH] llvm13: std::string llvm::APInt::toString has been moved to
StringExtras.h
See: https://reviews.llvm.org/D103888
---
klee/include/klee/ConcreteValue.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/klee/include/klee/ConcreteValue.h b/klee/include/klee/ConcreteValue.h
index 967f4af..ba38551 100644
--- a/klee/include/klee/ConcreteValue.h
+++ b/klee/include/klee/ConcreteValue.h
@@ -2,6 +2,9 @@
#define KLEE_CONCRETE_VALUE_
#include <llvm/ADT/APInt.h>
+#if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0)
+#include "llvm/ADT/StringExtras.h"
+#endif
#include <experimental/optional>
namespace klee {
@@ -39,7 +42,13 @@ public:
unsigned getBitWidth() const { return value.getBitWidth(); }
// WARNING: not efficient
- std::string toString() const { return value.toString(10, issigned); }
+ std::string toString() const {
+#if LLVM_VERSION_CODE >= LLVM_VERSION(13, 0)
+ return llvm::toString(value, 10, issigned);
+#else
+ return value.toString(10, issigned);
+#endif
+ }
bool isPointer() const { return static_cast<bool>(pointer); }
llvm::APInt& getPointer() { return *pointer; }
--
2.31.1
From a02a538050bce49e6782e1b831783f0a890d11f8 Mon Sep 17 00:00:00 2001
From: Lukas Zaoral <[email protected]>
Date: Thu, 4 Mar 2021 15:02:57 +0100
Subject: [PATCH] llvm12: VectorType::getNumElements() has been deprecated
... and has already been removed from the LLVM 13 source tree.
See:
https://reviews.llvm.org/D78127
https://reviews.llvm.org/D95570
---
lib/Core/Executor.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/klee/lib/Core/Executor.cpp b/klee/lib/Core/Executor.cpp
index a81c4882..aaa56a55 100644
--- a/klee/lib/Core/Executor.cpp
+++ b/klee/lib/Core/Executor.cpp
@@ -3137,7 +3137,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
return;
}
uint64_t iIdx = cIdx->getZExtValue();
+#if LLVM_VERSION_MAJOR >= 11
+ const auto *vt = cast<llvm::FixedVectorType>(iei->getType());
+#else
const llvm::VectorType *vt = iei->getType();
+#endif
unsigned EltBits = getWidthForLLVMType(vt->getElementType());
if (iIdx >= vt->getNumElements()) {
@@ -3175,7 +3179,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
return;
}
uint64_t iIdx = cIdx->getZExtValue();
+#if LLVM_VERSION_MAJOR >= 11
+ const auto *vt = cast<llvm::FixedVectorType>(eei->getVectorOperandType());
+#else
const llvm::VectorType *vt = eei->getVectorOperandType();
+#endif
unsigned EltBits = getWidthForLLVMType(vt->getElementType());
if (iIdx >= vt->getNumElements()) {
--
2.31.1