From d3a467d8999e6e52892b13c2bc93ac829ee1b7c9 Mon Sep 17 00:00:00 2001 From: Richard Trembecký Date: Sun, 1 May 2016 16:38:21 +0200 Subject: llvm: make KLEE compile against LLVM 3.5 and 3.6 Based on work by @ccadeptic23 and @delcypher. Formatting fixed by @snf. Fix compiler warning by @martijnthe. Further fixes by @mchalupa. Refactored, so that changes can be reviewed -- no massive changes in whitespace and in the surrounding code. Signed-off-by: Jiri Slaby --- lib/Module/KModule.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'lib/Module/KModule.cpp') diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 08ec28ef..45dc34bf 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -158,8 +158,14 @@ static Function *getStubFunctionForCtorList(Module *m, if (arr) { for (unsigned i=0; igetNumOperands(); i++) { ConstantStruct *cs = cast(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 Constant *fp = cs->getOperand(1); if (!fp->isNullValue()) { if (llvm::ConstantExpr *ce = dyn_cast(fp)) @@ -513,8 +519,13 @@ static int getOperandNum(Value *v, return registerMap[inst]; } else if (Argument *a = dyn_cast(v)) { return a->getArgNo(); +#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6) + // Metadata is no longer a Value + } else if (isa(v) || isa(v)) { +#else } else if (isa(v) || isa(v) || isa(v)) { +#endif return -1; } else { assert(isa(v)); -- cgit 1.4.1