OBS-URL: https://build.opensuse.org/package/show/devel:tools:statica/klee?expand=0&rev=37
72 lines
3.0 KiB
Diff
72 lines
3.0 KiB
Diff
From: Jiri Slaby <jirislaby@gmail.com>
|
|
Date: Thu, 8 Jun 2017 13:25:56 +0200
|
|
Subject: llvm: PointerType is not SequentialType in LLVM 4
|
|
Patch-mainline: no
|
|
|
|
So handle the type specially whenever needed.
|
|
|
|
Signed-off-by: Jiri Slaby <jirislaby@gmail.com>
|
|
---
|
|
include/klee/util/GetElementPtrTypeIterator.h | 4 ++++
|
|
lib/Core/Executor.cpp | 22 +++++++++++++++++++---
|
|
2 files changed, 23 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/include/klee/util/GetElementPtrTypeIterator.h b/include/klee/util/GetElementPtrTypeIterator.h
|
|
index 5fb9f4ec5c2f..bf7cb6ff0bea 100644
|
|
--- a/include/klee/util/GetElementPtrTypeIterator.h
|
|
+++ b/include/klee/util/GetElementPtrTypeIterator.h
|
|
@@ -78,6 +78,10 @@ class generic_gep_type_iterator
|
|
generic_gep_type_iterator& operator++() { // Preincrement
|
|
if (llvm::CompositeType *CT = dyn_cast<llvm::CompositeType>(CurTy)) {
|
|
CurTy = CT->getTypeAtIndex(getOperand());
|
|
+#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
|
|
+ } else if (llvm::PointerType *ptr = dyn_cast<llvm::PointerType>(CurTy)) {
|
|
+ CurTy = ptr->getElementType();
|
|
+#endif
|
|
} else {
|
|
CurTy = 0;
|
|
}
|
|
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
|
|
index 19499e1be37d..093be697c7da 100644
|
|
--- a/lib/Core/Executor.cpp
|
|
+++ b/lib/Core/Executor.cpp
|
|
@@ -2522,8 +2522,7 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) {
|
|
uint64_t addend = sl->getElementOffset((unsigned) ci->getZExtValue());
|
|
constantOffset = constantOffset->Add(ConstantExpr::alloc(addend,
|
|
Context::get().getPointerWidth()));
|
|
- } else {
|
|
- const SequentialType *set = cast<SequentialType>(*ii);
|
|
+ } else if (const SequentialType *set = dyn_cast<SequentialType>(*ii)) {
|
|
uint64_t elementSize =
|
|
kmodule->targetData->getTypeStoreSize(set->getElementType());
|
|
Value *operand = ii.getOperand();
|
|
@@ -2537,7 +2536,24 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) {
|
|
} else {
|
|
kgepi->indices.push_back(std::make_pair(index, elementSize));
|
|
}
|
|
- }
|
|
+#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
|
|
+ } else if (const PointerType *ptr = dyn_cast<PointerType>(*ii)) {
|
|
+ uint64_t elementSize =
|
|
+ kmodule->targetData->getTypeStoreSize(ptr->getElementType());
|
|
+ Value *operand = ii.getOperand();
|
|
+ if (Constant *c = dyn_cast<Constant>(operand)) {
|
|
+ ref<ConstantExpr> index =
|
|
+ evalConstant(c)->SExt(Context::get().getPointerWidth());
|
|
+ ref<ConstantExpr> addend =
|
|
+ index->Mul(ConstantExpr::alloc(elementSize,
|
|
+ Context::get().getPointerWidth()));
|
|
+ constantOffset = constantOffset->Add(addend);
|
|
+ } else {
|
|
+ kgepi->indices.push_back(std::make_pair(index, elementSize));
|
|
+ }
|
|
+#endif
|
|
+ } else
|
|
+ assert("invalid type" && 0);
|
|
index++;
|
|
}
|
|
kgepi->offset = constantOffset->getZExtValue();
|
|
--
|
|
2.15.1
|
|
|