[prev in list] [next in list] [prev in thread] [next in thread]
List: klee-commits
Subject: [klee-commits] [PATCH] Allow compilation with LLVM 3.2
From: c.cadar () imperial ! ac ! uk (Cristian Cadar)
Date: 2013-04-03 21:01:00
Message-ID: 515C988C.2010206 () imperial ! ac ! uk
[Download RAW message or body]
Hi Michael,
Many thanks for this patch. I have recently received a similar patch
for compatibility with LLVM 3.2 from Jiri (cc-ed), which I am attaching
to this message. After a quick scan over the two patches, I think they
are semantically equivalent (which is a reassuring!) but I'll let you
two take a look as well before I commit this.
Best,
Cristian
On 03/04/2013 19:59, Michael Contreras wrote:
> Allow KLEE to compile with LLVM 3.2
>
> Signed-off-by: Michael Contreras <michael at inetric.com>
> ---
> lib/Core/Executor.cpp | 8 ++++++++
> lib/Core/SpecialFunctionHandler.cpp | 7 ++++++-
> lib/Module/InstructionInfoTable.cpp | 4 +++-
> lib/Module/IntrinsicCleaner.cpp | 4 ++++
> lib/Module/Optimize.cpp | 7 ++++++-
> 5 files changed, 27 insertions(+), 3 deletions(-)
>
> diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
> index 473f45e..fc064f6 100644
> --- a/lib/Core/Executor.cpp
> +++ b/lib/Core/Executor.cpp
> @@ -1380,7 +1380,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
> CallSite(cast<CallInst>(caller)));
>
> // XXX need to check other param attrs ?
> +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 2)
> if (cs.paramHasAttr(0, llvm::Attribute::SExt)) {
> +#else
> + if (cs.paramHasAttr(0, llvm::Attributes::SExt)) {
> +#endif
> result = SExtExpr::create(result, to);
> } else {
> result = ZExtExpr::create(result, to);
> @@ -1579,7 +1583,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
>
> if (from != to) {
> // XXX need to check other param attrs ?
> +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 2)
> if (cs.paramHasAttr(i+1, llvm::Attribute::SExt)) {
> +#else
> + if (cs.paramHasAttr(i+1, llvm::Attributes::SExt)) {
> +#endif
> arguments[i] = SExtExpr::create(arguments[i], to);
> } else {
> arguments[i] = ZExtExpr::create(arguments[i], to);
> diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp
> index d01a9ef..6106de7 100644
> --- a/lib/Core/SpecialFunctionHandler.cpp
> +++ b/lib/Core/SpecialFunctionHandler.cpp
> @@ -130,8 +130,13 @@ void SpecialFunctionHandler::prepare() {
> if (f && (!hi.doNotOverride || f->isDeclaration())) {
> // Make sure NoReturn attribute is set, for optimization and
> // coverage counting.
> - if (hi.doesNotReturn)
> + if (hi.doesNotReturn) {
> +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 2)
> f->addFnAttr(Attribute::NoReturn);
> +#else
> + f->addFnAttr(Attributes::NoReturn);
> +#endif
> + }
>
> // Change to a declaration since we handle internally (simplifies
> // module and allows deleting dead code).
> diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
> index 0e19345..d0ef52d 100644
> --- a/lib/Module/InstructionInfoTable.cpp
> +++ b/lib/Module/InstructionInfoTable.cpp
> @@ -24,7 +24,9 @@
> #include "llvm/Support/CFG.h"
> #include "llvm/Support/InstIterator.h"
> #include "llvm/Support/raw_ostream.h"
> -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
> +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
> +#include "llvm/DebugInfo.h"
> +#elif LLVM_VERSION_CODE >= LLVM_VERSION(2, 7)
> #include "llvm/Analysis/DebugInfo.h"
> #endif
> #include "llvm/Analysis/ValueTracking.h"
> diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
> index fd0db91..9f14313 100644
> --- a/lib/Module/IntrinsicCleaner.cpp
> +++ b/lib/Module/IntrinsicCleaner.cpp
> @@ -23,7 +23,11 @@
> #include "llvm/Module.h"
> #include "llvm/Pass.h"
> #include "llvm/Type.h"
> +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 2)
> #include "llvm/Support/IRBuilder.h"
> +#else
> +#include "llvm/IRBuilder.h"
> +#endif
> #include "llvm/Transforms/Scalar.h"
> #include "llvm/Transforms/Utils/BasicBlockUtils.h"
> #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
> diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
> index da2c973..ca52fe5 100644
> --- a/lib/Module/Optimize.cpp
> +++ b/lib/Module/Optimize.cpp
> @@ -197,8 +197,13 @@ void Optimize(Module* M) {
> // Now that composite has been compiled, scan through the module, looking
> // for a main function. If main is defined, mark all other functions
> // internal.
> - if (!DisableInternalize)
> + if (!DisableInternalize) {
> +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 2)
> addPass(Passes, createInternalizePass(true));
> +#else
> + addPass(Passes, createInternalizePass(std::vector<const char *>(1, "main")));
> +#endif
> + }
>
> // Propagate constants at call sites into the functions they call. This
> // opens opportunities for globalopt (and inlining) by substituting function
>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic