aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Module
diff options
context:
space:
mode:
authorJulian Büning <julian.buening@rwth-aachen.de>2019-03-20 22:01:00 +0100
committerMartinNowack <martin.nowack@gmail.com>2019-03-21 12:46:01 +0000
commit9767a37f9e8a743fa81629510346cb0a5a3a7900 (patch)
treebc49e16925582e41ee51cacc35c4f7bcafd8860f /lib/Module
parenteee440835b857a7cb68b72f4af4d22eaf19e1d76 (diff)
downloadklee-9767a37f9e8a743fa81629510346cb0a5a3a7900.tar.gz
drop support for LLVM <= 3.7
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/InstructionInfoTable.cpp91
-rw-r--r--lib/Module/InstructionOperandTypeCheckPass.cpp1
-rw-r--r--lib/Module/IntrinsicCleaner.cpp4
-rw-r--r--lib/Module/KModule.cpp28
-rw-r--r--lib/Module/LowerSwitch.cpp12
-rw-r--r--lib/Module/ModuleUtil.cpp134
-rw-r--r--lib/Module/OptNone.cpp8
-rw-r--r--lib/Module/Optimize.cpp34
-rw-r--r--lib/Module/RaiseAsm.cpp13
9 files changed, 27 insertions, 298 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
diff --git a/lib/Module/InstructionOperandTypeCheckPass.cpp b/lib/Module/InstructionOperandTypeCheckPass.cpp
index 1a1422ec..39222d0f 100644
--- a/lib/Module/InstructionOperandTypeCheckPass.cpp
+++ b/lib/Module/InstructionOperandTypeCheckPass.cpp
@@ -98,7 +98,6 @@ bool checkInstruction(const Instruction *i) {
checkOperandsHaveSameType(i, 1, 2);
}
// Integer arithmetic, logical and shifting
- // TODO: When we upgrade to newer LLVM use LLVM_FALLTHROUGH
case Instruction::Add:
case Instruction::Sub:
case Instruction::Mul:
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 4c0920b3..dde97036 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -109,11 +109,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
case Intrinsic::uadd_with_overflow:
case Intrinsic::usub_with_overflow:
case Intrinsic::umul_with_overflow: {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
IRBuilder<> builder(ii->getParent(), ii->getIterator());
-#else
- IRBuilder<> builder(ii->getParent(), ii);
-#endif
Value *op1 = ii->getArgOperand(0);
Value *op2 = ii->getArgOperand(1);
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 207d4bd4..2ee49f23 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -27,6 +27,7 @@
#else
#include "llvm/Bitcode/ReaderWriter.h"
#endif
+#include "llvm/IR/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
@@ -34,28 +35,17 @@
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueSymbolTable.h"
-
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Analysis/Verifier.h"
-#include "llvm/Linker.h"
-#include "llvm/Support/CallSite.h"
-#else
-#include "llvm/IR/CallSite.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Linker/Linker.h"
-#endif
-
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Path.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/raw_os_ostream.h"
-#include "llvm/Support/Path.h"
#include "llvm/Transforms/Scalar.h"
#if LLVM_VERSION_CODE >= LLVM_VERSION(8, 0)
#include "llvm/Transforms/Scalar/Scalarizer.h"
#endif
-
#include "llvm/Transforms/Utils/Cloning.h"
-
#if LLVM_VERSION_CODE >= LLVM_VERSION(7, 0)
#include "llvm/Transforms/Utils.h"
#endif
@@ -150,14 +140,10 @@ static Function *getStubFunctionForCtorList(Module *m,
if (arr) {
for (unsigned i=0; i<arr->getNumOperands(); i++) {
auto cs = cast<ConstantStruct>(arr->getOperand(i));
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
// There is a third *optional* element in global_ctor elements (``i8
// @data``).
assert((cs->getNumOperands() == 2 || cs->getNumOperands() == 3) &&
"unexpected element in ctor initializer list");
-#else
- assert(cs->getNumOperands()==2 && "unexpected element in ctor initializer list");
-#endif
auto fp = cs->getOperand(1);
if (!fp->isNullValue()) {
if (auto ce = dyn_cast<llvm::ConstantExpr>(fp))
@@ -192,11 +178,7 @@ injectStaticConstructorsAndDestructors(Module *m,
entryFunction.str().c_str());
if (ctors) {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
llvm::IRBuilder<> Builder(&*mainFn->begin()->begin());
-#else
- llvm::IRBuilder<> Builder(mainFn->begin()->begin());
-#endif
Builder.CreateCall(getStubFunctionForCtorList(m, ctors, "klee.ctor_stub"));
}
@@ -425,14 +407,8 @@ static int getOperandNum(Value *v,
return registerMap[inst];
} else if (Argument *a = dyn_cast<Argument>(v)) {
return a->getArgNo();
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
- // Metadata is no longer a Value
} else if (isa<BasicBlock>(v) || isa<InlineAsm>(v) ||
isa<MetadataAsValue>(v)) {
-#else
- } else if (isa<BasicBlock>(v) || isa<InlineAsm>(v) ||
- isa<MDNode>(v)) {
-#endif
return -1;
} else {
assert(isa<Constant>(v));
diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp
index 4d80ddd8..b23278f7 100644
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -66,11 +66,7 @@ void LowerSwitchPass::switchConvert(CaseItr begin, CaseItr end,
// iterate through all the cases, creating a new BasicBlock for each
for (CaseItr it = begin; it < end; ++it) {
BasicBlock *newBlock = BasicBlock::Create(F->getContext(), "NodeBlock");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
Function::iterator FI = origBlock->getIterator();
-#else
- Function::iterator FI = origBlock;
-#endif
F->getBasicBlockList().insert(++FI, newBlock);
Builder.SetInsertPoint(newBlock);
auto cmpValue = Builder.CreateICmpEQ(value, it->value, "case.cmp");
@@ -108,11 +104,7 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
BasicBlock* newDefault = BasicBlock::Create(F->getContext(), "newDefault");
llvm::IRBuilder<> Builder(newDefault);
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
F->getBasicBlockList().insert(defaultBlock->getIterator(), newDefault);
-#else
- F->getBasicBlockList().insert(defaultBlock, newDefault);
-#endif
Builder.CreateBr(defaultBlock);
// If there is an entry in any PHI nodes for the default edge, make sure
@@ -126,11 +118,7 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
CaseVector cases;
-#if LLVM_VERSION_CODE > LLVM_VERSION(3, 4)
for (auto i : SI->cases())
-#else
- for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i)
-#endif
cases.push_back(SwitchCase(i.getCaseValue(),
i.getCaseSuccessor()));
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 6152c1df..6adaee6d 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -13,9 +13,13 @@
#include "klee/Internal/Support/Debug.h"
#include "klee/Internal/Support/ErrorHandling.h"
+#include "llvm/Analysis/ValueTracking.h"
#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
#include "llvm/BinaryFormat/Magic.h"
#endif
+#include "llvm/IR/AssemblyAnnotationWriter.h"
+#include "llvm/IR/DiagnosticInfo.h"
+#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
@@ -23,6 +27,7 @@
#include "llvm/IR/Module.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/IRReader/IRReader.h"
+#include "llvm/Linker/Linker.h"
#include "llvm/Object/Archive.h"
#include "llvm/Object/Error.h"
#include "llvm/Object/ObjectFile.h"
@@ -30,32 +35,17 @@
#include "llvm/Support/DataStream.h"
#endif
#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/SourceMgr.h"
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
-#include "llvm/Assembly/AssemblyAnnotationWriter.h"
-#include "llvm/Linker.h"
-#else
-#include "llvm/IR/AssemblyAnnotationWriter.h"
-#include "llvm/Linker/Linker.h"
-#endif
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
-#include "llvm/IR/DiagnosticInfo.h"
-#include "llvm/IR/DiagnosticPrinter.h"
-#endif
-
#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
#include <llvm/Bitcode/BitcodeReader.h>
#else
#include <llvm/Bitcode/ReaderWriter.h>
#endif
-#include "llvm/Analysis/ValueTracking.h"
-#include "llvm/Support/MemoryBuffer.h"
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/Path.h"
-
#include <algorithm>
#include <fstream>
#include <map>
@@ -94,13 +84,8 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
if (Function.isDeclaration())
UndefinedSymbols.insert(Function.getName());
else if (!Function.hasLocalLinkage()) {
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
- assert(!Function.hasDLLImportLinkage() &&
- "Found dllimported non-external symbol!");
-#else
assert(!Function.hasDLLImportStorageClass() &&
"Found dllimported non-external symbol!");
-#endif
DefinedSymbols.insert(Function.getName());
}
}
@@ -112,11 +97,7 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
if (I->isDeclaration())
UndefinedSymbols.insert(I->getName());
else if (!I->hasLocalLinkage()) {
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
- assert(!I->hasDLLImportLinkage() && "Found dllimported non-external symbol!");
-#else
- assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
-#endif
+ assert(!I->hasDLLImportStorageClass() && "Found dllimported non-external symbol!");
DefinedSymbols.insert(I->getName());
}
}
@@ -164,20 +145,9 @@ GetAllUndefinedSymbols(Module *M, std::set<std::string> &UndefinedSymbols) {
static bool linkTwoModules(llvm::Module *Dest,
std::unique_ptr<llvm::Module> Src,
std::string &errorMsg) {
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
// Get the potential error message (Src is moved and won't be available later)
errorMsg = "Linking module " + Src->getModuleIdentifier() + " failed";
auto linkResult = Linker::linkModules(*Dest, std::move(Src));
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
- raw_string_ostream Stream(errorMsg);
- DiagnosticPrinterRawOStream DP(Stream);
- auto linkResult = Linker::LinkModules(
- Dest, Src.release(), [&](const DiagnosticInfo &DI) { DI.print(DP); });
-#else
- auto linkResult = Linker::LinkModules(Dest, Src.release(),
- Linker::DestroySource, &errorMsg);
-#endif
return !linkResult;
}
@@ -316,12 +286,7 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) {
}
static bool valueIsOnlyCalled(const Value *v) {
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
- for (auto it = v->use_begin(), ie = v->use_end(); it != ie; ++it) {
- auto user = *it;
-#else
for (auto user : v->users()) {
-#endif
if (const auto *instr = dyn_cast<Instruction>(user)) {
// Make sure the instruction is a call or invoke.
CallSite cs(const_cast<Instruction *>(instr));
@@ -360,31 +325,20 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
KLEE_DEBUG_WITH_TYPE("klee_loader", dbgs()
<< "Load file " << fileName << "\n");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
ErrorOr<std::unique_ptr<MemoryBuffer>> bufferErr =
MemoryBuffer::getFileOrSTDIN(fileName);
std::error_code ec = bufferErr.getError();
-#else
- OwningPtr<MemoryBuffer> Buffer;
- error_code ec = MemoryBuffer::getFileOrSTDIN(fileName, Buffer);
-#endif
if (ec) {
klee_error("Loading file %s failed: %s", fileName.c_str(),
ec.message().c_str());
}
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
MemoryBufferRef Buffer = bufferErr.get()->getMemBufferRef();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- MemoryBuffer *Buffer = bufferErr->get();
-#endif
#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
file_magic magic = identify_magic(Buffer.getBuffer());
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
- sys::fs::file_magic magic = sys::fs::identify_magic(Buffer.getBuffer());
#else
- sys::fs::file_magic magic = sys::fs::identify_magic(Buffer->getBuffer());
+ sys::fs::file_magic magic = sys::fs::identify_magic(Buffer.getBuffer());
#endif
#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0)
@@ -393,13 +347,7 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
if (magic == sys::fs::file_magic::bitcode) {
#endif
SMDiagnostic Err;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
std::unique_ptr<llvm::Module> module(parseIR(Buffer, Err, context));
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- std::unique_ptr<llvm::Module> module(ParseIR(Buffer, Err, context));
-#else
- std::unique_ptr<llvm::Module> module(ParseIR(Buffer.take(), Err, context));
-#endif
if (!module) {
klee_error("Loading file %s failed: %s", fileName.c_str(),
Err.getMessage().str().c_str());
@@ -419,20 +367,11 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
if (!archOwner)
ec = errorToErrorCode(archOwner.takeError());
llvm::object::Binary *arch = archOwner.get().get();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#else
ErrorOr<std::unique_ptr<object::Binary>> archOwner =
object::createBinary(Buffer, &context);
ec = archOwner.getError();
llvm::object::Binary *arch = archOwner.get().get();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<object::Binary *> archOwner =
- object::createBinary(std::move(bufferErr.get()), &context);
- ec = archOwner.getError();
- llvm::object::Binary *arch = archOwner.get();
-#else
- OwningPtr<object::Binary> archOwner;
- ec = object::createBinary(Buffer.take(), archOwner);
- llvm::object::Binary *arch = archOwner.get();
#endif
if (ec)
klee_error("Loading file %s failed: %s", fileName.c_str(),
@@ -442,33 +381,22 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
// Load all bitcode files into memory
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
auto Err = Error::success();
- for (object::Archive::child_iterator AI = archive->child_begin(Err),
- AE = archive->child_end();
- AI != AE; ++AI)
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- for (object::Archive::child_iterator AI = archive->child_begin(),
- AE = archive->child_end();
+ for (auto AI = archive->child_begin(Err), AE = archive->child_end();
AI != AE; ++AI)
#else
- for (object::Archive::child_iterator AI = archive->begin_children(),
- AE = archive->end_children();
+ for (auto AI = archive->child_begin(), AE = archive->child_end();
AI != AE; ++AI)
#endif
{
StringRef memberName;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
std::error_code ec;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
ErrorOr<object::Archive::Child> childOrErr = *AI;
ec = childOrErr.getError();
if (ec) {
errorMsg = ec.message();
return false;
}
-#else
- object::Archive::child_iterator childOrErr = AI;
-#endif
auto memberNameErr = childOrErr->getName();
#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
ec = memberNameErr ? std::error_code() :
@@ -478,11 +406,6 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
#endif
if (!ec) {
memberName = memberNameErr.get();
-#else
- error_code ec = AI->getName(memberName);
-
- if (ec == errc::success) {
-#endif
KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs()
<< "Loading archive member "
<< memberName << "\n");
@@ -496,34 +419,19 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
childOrErr->getAsBinary();
if (!child)
ec = errorToErrorCode(child.takeError());
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
+#else
ErrorOr<std::unique_ptr<llvm::object::Binary>> child =
childOrErr->getAsBinary();
ec = child.getError();
-#else
- OwningPtr<object::Binary> child;
- ec = AI->getAsBinary(child);
#endif
if (ec) {
// If we can't open as a binary object file its hopefully a bitcode file
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
auto buff = childOrErr->getMemoryBufferRef();
#if LLVM_VERSION_CODE >= LLVM_VERSION(4, 0)
ec = buff ? std::error_code() : errorToErrorCode(buff.takeError());
#else
ec = buff.getError();
#endif
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- ErrorOr<std::unique_ptr<MemoryBuffer>> buffErr =
- AI->getMemoryBuffer();
- std::unique_ptr<MemoryBuffer> buff = nullptr;
- ec = buffErr.getError();
- if (!ec)
- buff = std::move(buffErr.get());
-#else
- OwningPtr<MemoryBuffer> buff;
- ec = AI->getMemoryBuffer(buff);
-#endif
if (ec) {
errorMsg = "Failed to get MemoryBuffer: " + ec.message();
return false;
@@ -534,16 +442,8 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
// materialise
// the module
SMDiagnostic Err;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
std::unique_ptr<llvm::Module> module =
parseIR(buff.get(), Err, context);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- std::unique_ptr<llvm::Module> module(
- ParseIR(buff.get(), Err, context));
-#else
- std::unique_ptr<llvm::Module> module(
- ParseIR(buff.take(), Err, context));
-#endif
if (!module) {
klee_error("Loading file %s failed: %s", fileName.c_str(),
Err.getMessage().str().c_str());
@@ -581,13 +481,7 @@ bool klee::loadFile(const std::string &fileName, LLVMContext &context,
}
// This might still be an assembly file. Let's try to parse it.
SMDiagnostic Err;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
std::unique_ptr<llvm::Module> module(parseIR(Buffer, Err, context));
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- std::unique_ptr<llvm::Module> module(ParseIR(Buffer, Err, context));
-#else
-std::unique_ptr<llvm::Module> module(ParseIR(Buffer.take(), Err, context));
-#endif
if (!module) {
klee_error("Loading file %s failed: Unrecognized file type.",
fileName.c_str());
diff --git a/lib/Module/OptNone.cpp b/lib/Module/OptNone.cpp
index 08837488..285fac5c 100644
--- a/lib/Module/OptNone.cpp
+++ b/lib/Module/OptNone.cpp
@@ -27,7 +27,6 @@ bool OptNonePass::runOnModule(llvm::Module &M) {
for (auto &F : M) {
if (!F.hasName() || !F.getName().startswith("klee_"))
continue;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
for (auto *U : F.users()) {
// skip non-calls and non-invokes
if (!llvm::isa<llvm::CallInst>(U) && !llvm::isa<llvm::InvokeInst>(U))
@@ -35,13 +34,6 @@ bool OptNonePass::runOnModule(llvm::Module &M) {
auto *Inst = llvm::cast<llvm::Instruction>(U);
CallingFunctions.insert(Inst->getParent()->getParent());
}
-#else
- for (auto i = F.use_begin(), e = F.use_end(); i != e; ++i) {
- if (auto Inst = llvm::dyn_cast<llvm::Instruction>(*i)) {
- CallingFunctions.insert(Inst->getParent()->getParent());
- }
- }
-#endif
}
bool changed = false;
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 0980c060..44708b11 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -22,11 +22,13 @@
#include "Passes.h"
#endif
+#include "llvm/Analysis/GlobalsModRef.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/LegacyPassManager.h"
+#include "llvm/IR/Verifier.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/DynamicLibrary.h"
#include "llvm/Support/PluginLoader.h"
@@ -34,16 +36,6 @@
#include "llvm/Transforms/IPO.h"
#include "llvm/Transforms/Scalar.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
-#include "llvm/IR/Verifier.h"
-#else
-#include "llvm/Analysis/Verifier.h"
-#endif
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
-#include "llvm/Analysis/GlobalsModRef.h"
-#endif
-
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
#include "llvm/Transforms/IPO/FunctionAttrs.h"
#include "llvm/Transforms/Scalar/GVN.h"
@@ -122,16 +114,12 @@ static void AddStandardCompilePasses(legacy::PassManager &PM) {
addPass(PM, createCFGSimplificationPass()); // Clean up after IPCP & DAE
addPass(PM, createPruneEHPass()); // Remove dead EH info
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
addPass(PM, createPostOrderFunctionAttrsLegacyPass());
#else
addPass(PM, createPostOrderFunctionAttrsPass());
#endif
addPass(PM, createReversePostOrderFunctionAttrsPass()); // Deduce function attrs
-#else
- addPass(PM, createFunctionAttrsPass()); // Deduce function attrs
-#endif
if (!DisableInline)
addPass(PM, createFunctionInliningPass()); // Inline small functions
@@ -190,19 +178,6 @@ void Optimize(Module *M, llvm::ArrayRef<const char *> preservedFunctions) {
addPass(Passes, new klee::WorkaroundLLVMPR39177Pass());
#endif
- // Add an appropriate DataLayout instance for this module...
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
- // LLVM 3.7+ doesn't have DataLayoutPass anymore.
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
- DataLayoutPass *dlpass = new DataLayoutPass();
- dlpass->doInitialization(*M);
- addPass(Passes, dlpass);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
- addPass(Passes, new DataLayoutPass(M));
-#else
- addPass(Passes, new DataLayout(M));
-#endif
-
// DWD - Run the opt standard pass list as well.
AddStandardCompilePasses(Passes);
@@ -269,7 +244,6 @@ void Optimize(Module *M, llvm::ArrayRef<const char *> preservedFunctions) {
#endif
// Run a few AA driven optimizations here and now, to cleanup the code.
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 8)
#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 9)
addPass(Passes, createPostOrderFunctionAttrsLegacyPass());
#else
@@ -277,10 +251,6 @@ void Optimize(Module *M, llvm::ArrayRef<const char *> preservedFunctions) {
#endif
addPass(Passes, createReversePostOrderFunctionAttrsPass()); // Add nocapture
addPass(Passes, createGlobalsAAWrapperPass()); // IP alias analysis
-#else
- addPass(Passes, createFunctionAttrsPass()); // Add nocapture
- addPass(Passes, createGlobalsModRefPass()); // IP alias analysis
-#endif
addPass(Passes, createLICMPass()); // Hoist loop invariants
addPass(Passes, createGVNPass()); // Remove redundancies
diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp
index eef22fb8..5d86bfd1 100644
--- a/lib/Module/RaiseAsm.cpp
+++ b/lib/Module/RaiseAsm.cpp
@@ -22,12 +22,10 @@
#include "llvm/CodeGen/TargetLowering.h"
#include "llvm/CodeGen/TargetSubtargetInfo.h"
#include "llvm/Target/TargetMachine.h"
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
+#else
#include "llvm/Target/TargetLowering.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetSubtargetInfo.h"
-#else
-#include "llvm/Target/TargetLowering.h"
#endif
using namespace llvm;
@@ -95,16 +93,9 @@ bool RaiseAsmPass::runOnModule(Module &M) {
TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions(),
None);
TLI = TM->getSubtargetImpl(*(M.begin()))->getTargetLowering();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 7)
+#else
TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions());
TLI = TM->getSubtargetImpl(*(M.begin()))->getTargetLowering();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
- TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions());
- TLI = TM->getSubtargetImpl()->getTargetLowering();
-#else
- TM = NativeTarget->createTargetMachine(HostTriple, "", "",
- TargetOptions());
- TLI = TM->getTargetLowering();
#endif
triple = llvm::Triple(HostTriple);