klee/0001-llvm37-handle-GetElementPtrInst-Create-s-new-paramet.patch

73 lines
3.2 KiB
Diff

From: Jiri Slaby <jirislaby@gmail.com>
Date: Thu, 15 Jun 2017 15:20:49 +0200
Subject: llvm37: handle GetElementPtrInst::Create's new parameter
Patch-mainline: no
LLVM 3.7 added a PointeeType parameter to GetElementPtrInst::Create.
Let's handle that by a macro called KLEE_LLVM_GEP_TYPE, defined in
Version.h.
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
---
include/klee/Config/Version.h | 6 ++++++
lib/Core/ExternalDispatcher.cpp | 1 +
lib/Module/IntrinsicCleaner.cpp | 12 ++++++++----
3 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/include/klee/Config/Version.h b/include/klee/Config/Version.h
index ccf54ae13092..532051602fe3 100644
--- a/include/klee/Config/Version.h
+++ b/include/klee/Config/Version.h
@@ -15,6 +15,12 @@
#define LLVM_VERSION(major, minor) (((major) << 8) | (minor))
#define LLVM_VERSION_CODE LLVM_VERSION(LLVM_VERSION_MAJOR, LLVM_VERSION_MINOR)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+# define KLEE_LLVM_GEP_TYPE(x) (x),
+#else
+# define KLEE_LLVM_GEP_TYPE(x)
+#endif
+
#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
# define KLEE_LLVM_CL_VAL_END
#else
diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp
index 28546915b539..3558049d87cc 100644
--- a/lib/Core/ExternalDispatcher.cpp
+++ b/lib/Core/ExternalDispatcher.cpp
@@ -324,6 +324,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
Type *argTy =
(i < FTy->getNumParams() ? FTy->getParamType(i) : (*ai)->getType());
Instruction *argI64p = GetElementPtrInst::Create(
+ KLEE_LLVM_GEP_TYPE(nullptr)
argI64s, ConstantInt::get(Type::getInt32Ty(ctx), idx), "", dBB);
Instruction *argp =
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index b02605208bbb..54bda16013b6 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -82,11 +82,15 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
Value *pSrc = CastInst::CreatePointerCast(src, i64p, "vacopy.cast.src", ii);
Value *val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
Value *off = ConstantInt::get(Type::getInt64Ty(ctx), 1);
- pDst = GetElementPtrInst::Create(pDst, off, std::string(), ii);
- pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii);
+ pDst = GetElementPtrInst::Create(KLEE_LLVM_GEP_TYPE(nullptr)
+ pDst, off, std::string(), ii);
+ pSrc = GetElementPtrInst::Create(KLEE_LLVM_GEP_TYPE(nullptr)
+ pSrc, off, std::string(), ii);
val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
- pDst = GetElementPtrInst::Create(pDst, off, std::string(), ii);
- pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii);
+ pDst = GetElementPtrInst::Create(KLEE_LLVM_GEP_TYPE(nullptr)
+ pDst, off, std::string(), ii);
+ pSrc = GetElementPtrInst::Create(KLEE_LLVM_GEP_TYPE(nullptr)
+ pSrc, off, std::string(), ii);
val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
}
ii->removeFromParent();
--
2.15.0