aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/Module
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-07-20 13:35:52 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2011-07-20 13:35:52 +0000
commited9ea0cf9dc856920afc6813fa1bea0ec7660ba1 (patch)
tree46de7f5cae7ce4b8a7f5fee7f66f4d2f551b9a47 /lib/Module
parent384a6c5652ae815f33e2a6cd1013b1cf14caed63 (diff)
downloadklee-ed9ea0cf9dc856920afc6813fa1bea0ec7660ba1.tar.gz
Deprecate LLVM_VERSION_MAJOR and LLVM_VERSION_MINOR in favour of
version codes. This makes the preprocessor-based version tests more concise and less error prone. Also, fix the version tests in lib/Expr/Parser.cpp (immutable zext and trunc were introduced in LLVM 2.9); now 2.9 passes "make test". git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@135583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/Checks.cpp4
-rw-r--r--lib/Module/InstructionInfoTable.cpp12
-rw-r--r--lib/Module/IntrinsicCleaner.cpp8
-rw-r--r--lib/Module/KModule.cpp11
-rw-r--r--lib/Module/LowerSwitch.cpp3
-rw-r--r--lib/Module/ModuleUtil.cpp8
-rw-r--r--lib/Module/Optimize.cpp12
-rw-r--r--lib/Module/Passes.h14
-rw-r--r--lib/Module/RaiseAsm.cpp14
9 files changed, 45 insertions, 41 deletions
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index 2edcf940..c2f98c0f 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -9,6 +9,8 @@
#include "Passes.h"
+#include "klee/Config/Version.h"
+
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
@@ -16,7 +18,7 @@
#include "llvm/Instruction.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/LLVMContext.h"
#endif
#include "llvm/Module.h"
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index e08dc2b3..0e193452 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -7,15 +7,15 @@
//
//===----------------------------------------------------------------------===//
-#include "klee/Config/config.h"
#include "klee/Internal/Module/InstructionInfoTable.h"
+#include "klee/Config/Version.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Linker.h"
#include "llvm/Module.h"
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
#include "llvm/Assembly/AsmAnnotationWriter.h"
#else
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
@@ -24,7 +24,7 @@
#include "llvm/Support/CFG.h"
#include "llvm/Support/InstIterator.h"
#include "llvm/Support/raw_ostream.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/Analysis/DebugInfo.h"
#endif
#include "llvm/Analysis/ValueTracking.h"
@@ -37,7 +37,7 @@ using namespace klee;
class InstructionToLineAnnotator : public llvm::AssemblyAnnotationWriter {
public:
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
void emitInstructionAnnot(const Instruction *i, llvm::raw_ostream &os) {
#else
void emitInstructionAnnot(const Instruction *i,
@@ -74,7 +74,7 @@ static void buildInstructionToLineMap(Module *m,
}
}
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
static std::string getDSPIPath(const DbgStopPointInst *dspi) {
std::string dir, file;
bool res = GetConstantStringInfo(dspi->getDirectory(), dir);
@@ -98,7 +98,7 @@ static std::string getDSPIPath(DILocation Loc) {
bool InstructionInfoTable::getInstructionDebugInfo(const llvm::Instruction *I,
const std::string *&File,
unsigned &Line) {
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
if (const DbgStopPointInst *dspi = dyn_cast<DbgStopPointInst>(I)) {
File = internString(getDSPIPath(dspi));
Line = dspi->getLine();
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index da0c65f8..8e326af9 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -9,7 +9,7 @@
#include "Passes.h"
-#include "klee/Config/config.h"
+#include "klee/Config/Version.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Function.h"
@@ -17,7 +17,7 @@
#include "llvm/Instruction.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/LLVMContext.h"
#endif
#include "llvm/Module.h"
@@ -61,7 +61,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) {
// FIXME: This is much more target dependent than just the word size,
// however this works for x86-32 and x86-64.
case Intrinsic::vacopy: { // (dst, src) -> *((i8**) dst) = *((i8**) src)
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
Value *dst = ii->getOperand(1);
Value *src = ii->getOperand(2);
#else
@@ -94,7 +94,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) {
break;
}
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
case Intrinsic::dbg_stoppoint: {
// We can remove this stoppoint if the next instruction is
// sure to be another stoppoint. This is nice for cleanliness
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 0364127d..94c3d05b 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -14,6 +14,7 @@
#include "Passes.h"
+#include "klee/Config/Version.h"
#include "klee/Interpreter.h"
#include "klee/Internal/Module/Cell.h"
#include "klee/Internal/Module/KInstruction.h"
@@ -22,7 +23,7 @@
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Instructions.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/LLVMContext.h"
#endif
#include "llvm/Module.h"
@@ -31,10 +32,10 @@
#include "llvm/Support/CallSite.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/raw_ostream.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/Support/raw_os_ostream.h"
#endif
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9)
#include "llvm/System/Path.h"
#else
#include "llvm/Support/Path.h"
@@ -230,7 +231,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
BasicBlock *exit = BasicBlock::Create(getGlobalContext(), "exit", f);
PHINode *result = 0;
if (f->getReturnType() != Type::getVoidTy(getGlobalContext()))
-#if (LLVM_VERSION_MAJOR > 2)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
result = PHINode::Create(f->getReturnType(), 0, "retval", exit);
#else
result = PHINode::Create(f->getReturnType(), "retval", exit);
@@ -341,7 +342,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
std::ostream *os = ih->openOutputFile("assembly.ll");
assert(os && os->good() && "unable to open source output");
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 6)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 6)
// We have an option for this in case the user wants a .ll they
// can compile.
if (NoTruncateSourceLines) {
diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp
index 7d6920be..6667a006 100644
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -15,7 +15,8 @@
//===----------------------------------------------------------------------===//
#include "Passes.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#include "klee/Config/Version.h"
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/LLVMContext.h"
#endif
#include <algorithm>
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 11f2b2c5..029540ae 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -8,14 +8,14 @@
//===----------------------------------------------------------------------===//
#include "klee/Internal/Support/ModuleUtil.h"
-#include "klee/Config/config.h"
+#include "klee/Config/Version.h"
#include "llvm/Function.h"
#include "llvm/Instructions.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/Linker.h"
#include "llvm/Module.h"
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
#include "llvm/Assembly/AsmAnnotationWriter.h"
#else
#include "llvm/Assembly/AssemblyAnnotationWriter.h"
@@ -25,7 +25,7 @@
#include "llvm/Support/InstIterator.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Analysis/ValueTracking.h"
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9)
#include "llvm/System/Path.h"
#else
#include "llvm/Support/Path.h"
@@ -72,7 +72,7 @@ Function *klee::getDirectCallTarget(CallSite cs) {
}
static bool valueIsOnlyCalled(const Value *v) {
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
for (Value::use_const_iterator it = v->use_begin(), ie = v->use_end();
it != ie; ++it) {
#else
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 633c21a1..e0ae4d99 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -15,14 +15,14 @@
//
//===----------------------------------------------------------------------===//
-#include "klee/Config/config.h"
+#include "klee/Config/Version.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Support/CommandLine.h"
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9)
#include "llvm/System/DynamicLibrary.h"
#else
#include "llvm/Support/DynamicLibrary.h"
@@ -99,7 +99,7 @@ static void AddStandardCompilePasses(PassManager &PM) {
if (DisableOptimizations) return;
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst
#endif
addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code
@@ -124,7 +124,7 @@ static void AddStandardCompilePasses(PassManager &PM) {
addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs
addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas
addPass(PM, createInstructionCombiningPass()); // Combine silly seq's
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
addPass(PM, createCondPropagationPass()); // Propagate conditionals
#endif
@@ -134,7 +134,7 @@ static void AddStandardCompilePasses(PassManager &PM) {
addPass(PM, createLoopRotatePass());
addPass(PM, createLICMPass()); // Hoist loop invariants
addPass(PM, createLoopUnswitchPass()); // Unswitch loops.
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9)
addPass(PM, createLoopIndexSplitPass()); // Index split loops.
#endif
// FIXME : Removing instcombine causes nestedloop regression.
@@ -150,7 +150,7 @@ static void AddStandardCompilePasses(PassManager &PM) {
// Run instcombine after redundancy elimination to exploit opportunities
// opened up by them.
addPass(PM, createInstructionCombiningPass());
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7)
addPass(PM, createCondPropagationPass()); // Propagate conditionals
#endif
diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h
index 2b1ea9bc..480fbde6 100644
--- a/lib/Module/Passes.h
+++ b/lib/Module/Passes.h
@@ -10,7 +10,7 @@
#ifndef KLEE_PASSES_H
#define KLEE_PASSES_H
-#include "klee/Config/config.h"
+#include "klee/Config/Version.h"
#include "llvm/Constants.h"
#include "llvm/Instructions.h"
@@ -34,7 +34,7 @@ namespace klee {
class RaiseAsmPass : public llvm::ModulePass {
static char ID;
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9)
const llvm::TargetLowering *TLI;
#endif
@@ -51,7 +51,7 @@ class RaiseAsmPass : public llvm::ModulePass {
bool runOnInstruction(llvm::Module &M, llvm::Instruction *I);
public:
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
RaiseAsmPass() : llvm::ModulePass((intptr_t) &ID) {}
#else
RaiseAsmPass() : llvm::ModulePass(ID) {}
@@ -72,7 +72,7 @@ class IntrinsicCleanerPass : public llvm::ModulePass {
public:
IntrinsicCleanerPass(const llvm::TargetData &TD,
bool LI=true)
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
: llvm::ModulePass((intptr_t) &ID),
#else
: llvm::ModulePass(ID),
@@ -101,7 +101,7 @@ class PhiCleanerPass : public llvm::FunctionPass {
static char ID;
public:
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
PhiCleanerPass() : llvm::FunctionPass((intptr_t) &ID) {}
#else
PhiCleanerPass() : llvm::FunctionPass(ID) {}
@@ -113,7 +113,7 @@ public:
class DivCheckPass : public llvm::ModulePass {
static char ID;
public:
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
DivCheckPass(): ModulePass((intptr_t) &ID) {}
#else
DivCheckPass(): ModulePass(ID) {}
@@ -127,7 +127,7 @@ public:
class LowerSwitchPass : public llvm::FunctionPass {
public:
static char ID; // Pass identification, replacement for typeid
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
LowerSwitchPass() : FunctionPass((intptr_t) &ID) {}
#else
LowerSwitchPass() : FunctionPass(ID) {}
diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp
index 76a4f242..8f862ffa 100644
--- a/lib/Module/RaiseAsm.cpp
+++ b/lib/Module/RaiseAsm.cpp
@@ -8,13 +8,13 @@
//===----------------------------------------------------------------------===//
#include "Passes.h"
-#include "klee/Config/config.h"
+#include "klee/Config/Version.h"
#include "llvm/InlineAsm.h"
-#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
#include "llvm/LLVMContext.h"
#endif
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9)
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Host.h"
#include "llvm/Target/TargetLowering.h"
@@ -38,7 +38,7 @@ Function *RaiseAsmPass::getIntrinsic(llvm::Module &M,
bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) {
if (CallInst *ci = dyn_cast<CallInst>(I)) {
if (InlineAsm *ia = dyn_cast<InlineAsm>(ci->getCalledValue())) {
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9)
(void) ia;
return TLI && TLI->ExpandInlineAsm(ci);
#else
@@ -47,7 +47,7 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) {
const llvm::Type *T = ci->getType();
// bswaps
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
unsigned NumOperands = ci->getNumOperands();
llvm::Value *Arg0 = NumOperands > 1 ? ci->getOperand(1) : 0;
#else
@@ -62,7 +62,7 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) {
as == "rorw $$8, ${0:w};rorl $$16, $0;rorw $$8, ${0:w}" &&
cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}"))) {
Function *F = getIntrinsic(M, Intrinsic::bswap, Arg0->getType());
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 8)
+#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8)
ci->setOperand(0, F);
#else
ci->setCalledFunction(F);
@@ -79,7 +79,7 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) {
bool RaiseAsmPass::runOnModule(Module &M) {
bool changed = false;
-#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9)
+#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9)
std::string Err;
std::string HostTriple = llvm::sys::getHostTriple();
const Target *NativeTarget = TargetRegistry::lookupTarget(HostTriple, Err);