aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Module/InstructionInfoTable.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Module/InstructionInfoTable.cpp')
-rw-r--r--lib/Module/InstructionInfoTable.cpp91
1 files changed, 7 insertions, 84 deletions
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index 6ff49669..48575c82 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -10,41 +10,21 @@
#include "klee/Internal/Module/InstructionInfoTable.h"
#include "klee/Config/Version.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/IR/AssemblyAnnotationWriter.h"
+#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/InstIterator.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
-
-# if LLVM_VERSION_CODE < LLVM_VERSION(3,5)
-#include "llvm/Assembly/AssemblyAnnotationWriter.h"
-#include "llvm/Support/InstIterator.h"
-#include "llvm/Linker.h"
-#else
-#include "llvm/IR/AssemblyAnnotationWriter.h"
-#include "llvm/IR/InstIterator.h"
#include "llvm/Linker/Linker.h"
-#endif
-
-#include "llvm/Support/FormattedStream.h"
-#include "llvm/Support/raw_ostream.h"
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3,5)
-#include "llvm/IR/DebugInfo.h"
-#else
-#include "llvm/DebugInfo.h"
-#endif
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
-#include "llvm/IR/DebugInfoMetadata.h"
-#endif
-
-#if LLVM_VERSION_CODE == LLVM_VERSION(3, 6)
-#include "llvm/Support/Debug.h"
-#endif
-
-#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
#include <cstdint>
#include <map>
@@ -112,9 +92,6 @@ static std::string getFullPath(llvm::StringRef Directory,
class DebugInfoExtractor {
std::vector<std::unique_ptr<std::string>> &internedStrings;
std::map<uintptr_t, uint64_t> lineTable;
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
- llvm::DebugInfoFinder DIF;
-#endif
const llvm::Module &module;
@@ -123,9 +100,6 @@ public:
std::vector<std::unique_ptr<std::string>> &_internedStrings,
const llvm::Module &_module)
: internedStrings(_internedStrings), module(_module) {
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 8)
- DIF.processModule(module);
-#endif
lineTable = buildInstructionToLineMap(module);
}
@@ -146,8 +120,6 @@ public:
std::unique_ptr<FunctionInfo> getFunctionInfo(const llvm::Function &Func) {
auto asmLine = lineTable.at(reinterpret_cast<std::uintptr_t>(&Func));
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
-
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
auto dsub = Func.getSubprogram();
#else
@@ -159,33 +131,6 @@ public:
0, getInternedString(path), dsub->getLine(), asmLine));
}
-#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 7)
- for (const auto SP : DIF.subprograms()) {
- auto &SubProgram = *SP;
- if (SubProgram.getFunction() != &Func)
- continue;
- auto path =
- getFullPath(SubProgram.getDirectory(), SubProgram.getFilename());
- return std::unique_ptr<FunctionInfo>(new FunctionInfo(
- 0, getInternedString(path), SubProgram.getLine(), asmLine));
- }
-#endif
-
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 6)
- // Workaround missing debug information for older LLVM versions
- // Search for any instructions inside this function with debug information
- // and assume it's part of this function in the source code as well.
- for (auto it = llvm::inst_begin(&Func), ie = llvm::inst_end(&Func);
- it != ie; ++it) {
- auto iInfo = getInstructionInfo(*it, nullptr);
- if (iInfo->file.empty())
- continue;
- // Found an instruction
- return std::unique_ptr<FunctionInfo>(new FunctionInfo(
- 0, getInternedString(iInfo->file), iInfo->line, asmLine));
- }
-
-#endif
// Fallback: Mark as unknown
return std::unique_ptr<FunctionInfo>(
new FunctionInfo(0, getInternedString(""), 0, asmLine));
@@ -195,7 +140,6 @@ public:
getInstructionInfo(const llvm::Instruction &Inst, const FunctionInfo *f) {
auto asmLine = lineTable.at(reinterpret_cast<std::uintptr_t>(&Inst));
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
// Retrieve debug information associated with instruction
auto dl = Inst.getDebugLoc();
@@ -217,27 +161,6 @@ public:
return std::unique_ptr<InstructionInfo>(new InstructionInfo(
0, getInternedString(full_path), line, column, asmLine));
}
-#elif LLVM_VERSION_CODE == LLVM_VERSION(3, 7)
- // Retrieve debug information
- llvm::DebugLoc Loc(Inst.getDebugLoc());
- // Check if valid
- if (Loc.get() != nullptr) {
- auto subProg = getDISubprogram(Loc.getScope());
- auto full_path =
- getFullPath(subProg->getDirectory(), subProg->getFilename());
- return std::unique_ptr<InstructionInfo>(
- new InstructionInfo(0, getInternedString(full_path), Loc.getLine(),
- Loc.getCol(), asmLine));
- }
-#elif LLVM_VERSION_CODE <= LLVM_VERSION(3, 6)
- if (llvm::MDNode *N = Inst.getMetadata("dbg")) {
- llvm::DILocation Loc(N);
- auto path = getFullPath(Loc.getDirectory(), Loc.getFilename());
- auto Line = Loc.getLineNumber();
- return std::unique_ptr<InstructionInfo>(
- new InstructionInfo(0, getInternedString(path), Line, 0, asmLine));
- }
-#endif
if (f != nullptr)
// If nothing found, use the surrounding function