[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:       michael () inetric ! com (Michael Contreras)
Date:       2013-04-03 22:36:49
Message-ID: 20130403223649.GA16254 () inetric ! com
[Download RAW message or body]

Hi Cristian,

On Wed, Apr 03, 2013 at 10:01:00PM +0100, Cristian Cadar wrote:
> 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

They look equivalent to me as well, and both compile with LLVM 3.2 as
expected.

Thanks,
Michael

> 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
> >

> >From f7a129c7950321fd7487bb14c5421016f925acac Mon Sep 17 00:00:00 2001
> From: Jiri Slaby <jirislaby at gmail.com>
> Date: Fri, 15 Mar 2013 13:15:33 +0100
> Subject: [PATCH] add support for llvm 3.2
> 
> ---
>  lib/Core/Executor.cpp               | 14 ++++++++++++--
>  lib/Core/SpecialFunctionHandler.cpp |  4 ++++
>  lib/Module/InstructionInfoTable.cpp |  4 +++-
>  lib/Module/IntrinsicCleaner.cpp     |  4 ++++
>  lib/Module/Optimize.cpp             | 12 ++++++++++--
>  5 files changed, 33 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
> index fa5835d..269ca51 100644
> --- a/lib/Core/Executor.cpp
> +++ b/lib/Core/Executor.cpp
> @@ -1380,7 +1380,12 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
>                             CallSite(cast<CallInst>(caller)));
>  
>              // XXX need to check other param attrs ?
> -            if (cs.paramHasAttr(0, llvm::Attribute::SExt)) {
> +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
> +	    bool isSExt = cs.paramHasAttr(0, llvm::Attributes::SExt);
> +#else
> +	    bool isSExt = cs.paramHasAttr(0, llvm::Attribute::SExt);
> +#endif
> +            if (isSExt) {
>                result = SExtExpr::create(result, to);
>              } else {
>                result = ZExtExpr::create(result, to);
> @@ -1579,7 +1584,12 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
>  
>              if (from != to) {
>                // XXX need to check other param attrs ?
> -              if (cs.paramHasAttr(i+1, llvm::Attribute::SExt)) {
> +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
> +	      bool isSExt = cs.paramHasAttr(i+1, llvm::Attributes::SExt);
> +#else
> +	      bool isSExt = cs.paramHasAttr(i+1, llvm::Attribute::SExt);
> +#endif
> +              if (isSExt) {
>                  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..d44e13b 100644
> --- a/lib/Core/SpecialFunctionHandler.cpp
> +++ b/lib/Core/SpecialFunctionHandler.cpp
> @@ -131,7 +131,11 @@ void SpecialFunctionHandler::prepare() {
>        // Make sure NoReturn attribute is set, for optimization and
>        // coverage counting.
>        if (hi.doesNotReturn)
> +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
> +        f->addFnAttr(Attributes::NoReturn);
> +#else
>          f->addFnAttr(Attribute::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..b897fcc 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/IRBuilder.h"
> +#else
>  #include "llvm/Support/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..97410a5 100644
> --- a/lib/Module/Optimize.cpp
> +++ b/lib/Module/Optimize.cpp
> @@ -197,8 +197,16 @@ 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)
> -      addPass(Passes, createInternalizePass(true));
> +    if (!DisableInternalize) {
> +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
> +      std::vector<const char*> E;
> +      E.push_back("main");
> +      ModulePass *pass = createInternalizePass(E);
> +#else
> +      ModulePass *pass = createInternalizePass(true);
> +#endif
> +      addPass(Passes, pass);
> +    }
>  
>      // Propagate constants at call sites into the functions they call.  This
>      // opens opportunities for globalopt (and inlining) by substituting function
> -- 
> 1.8.2
> 



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic