From: Jiri Slaby Date: Mon, 15 Jan 2018 10:27:54 +0100 Subject: llvm50: handle getOrInsertFunction terminator Patch-mainline: no llvm 5 does not terminate getOrInsertFunction parameters with NULL, take care of that. Since commit 9d54400bba7eb04bca80fce97fa170452d19eaf1. Signed-off-by: Jiri Slaby --- include/klee/Config/Version.h | 6 ++++++ lib/Module/Checks.cpp | 8 ++++---- lib/Module/IntrinsicCleaner.cpp | 3 ++- tools/klee/main.cpp | 20 ++++++++++---------- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/include/klee/Config/Version.h b/include/klee/Config/Version.h index 532051602fe3..a02ce28baaae 100644 --- a/include/klee/Config/Version.h +++ b/include/klee/Config/Version.h @@ -27,4 +27,10 @@ # define KLEE_LLVM_CL_VAL_END , clEnumValEnd #endif +#if LLVM_VERSION_CODE >= LLVM_VERSION(5, 0) +# define KLEE_LLVM_GOIF_TERMINATOR +#else +# define KLEE_LLVM_GOIF_TERMINATOR , NULL +#endif + #endif diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp index aac63e1d9854..406b3045e527 100644 --- a/lib/Module/Checks.cpp +++ b/lib/Module/Checks.cpp @@ -57,8 +57,8 @@ bool DivCheckPass::runOnModule(Module &M) { if (!divZeroCheckFunction) { Constant *fc = M.getOrInsertFunction("klee_div_zero_check", Type::getVoidTy(ctx), - Type::getInt64Ty(ctx), - NULL); + Type::getInt64Ty(ctx) + KLEE_LLVM_GOIF_TERMINATOR); divZeroCheckFunction = cast(fc); } @@ -118,8 +118,8 @@ bool OvershiftCheckPass::runOnModule(Module &M) { Constant *fc = M.getOrInsertFunction("klee_overshift_check", Type::getVoidTy(ctx), Type::getInt64Ty(ctx), - Type::getInt64Ty(ctx), - NULL); + Type::getInt64Ty(ctx) + KLEE_LLVM_GOIF_TERMINATOR); overshiftCheckFunction = cast(fc); } diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 0f7eb223a2d3..4d323b8e8344 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -210,7 +210,8 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { // Intrisic instruction "llvm.trap" found. Directly lower it to // a call of the abort() function. Function *F = cast( - M.getOrInsertFunction("abort", Type::getVoidTy(ctx), NULL)); + M.getOrInsertFunction("abort", Type::getVoidTy(ctx) + KLEE_LLVM_GOIF_TERMINATOR)); F->setDoesNotReturn(); F->setDoesNotThrow(); diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index def83b584167..ff87d210b863 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -678,8 +678,8 @@ static int initEnv(Module *mainModule) { cast(mainModule->getOrInsertFunction("klee_init_env", Type::getVoidTy(ctx), argcPtr->getType(), - argvPtr->getType(), - NULL)); + argvPtr->getType() + KLEE_LLVM_GOIF_TERMINATOR)); assert(initEnvFn); std::vector args; args.push_back(argcPtr); @@ -1038,20 +1038,20 @@ static llvm::Module *linkWithUclibc(llvm::Module *mainModule, StringRef libDir) mainModule->getOrInsertFunction("realpath", PointerType::getUnqual(i8Ty), PointerType::getUnqual(i8Ty), - PointerType::getUnqual(i8Ty), - NULL); + PointerType::getUnqual(i8Ty) + KLEE_LLVM_GOIF_TERMINATOR); mainModule->getOrInsertFunction("getutent", - PointerType::getUnqual(i8Ty), - NULL); + PointerType::getUnqual(i8Ty) + KLEE_LLVM_GOIF_TERMINATOR); mainModule->getOrInsertFunction("__fgetc_unlocked", Type::getInt32Ty(ctx), - PointerType::getUnqual(i8Ty), - NULL); + PointerType::getUnqual(i8Ty) + KLEE_LLVM_GOIF_TERMINATOR); mainModule->getOrInsertFunction("__fputc_unlocked", Type::getInt32Ty(ctx), Type::getInt32Ty(ctx), - PointerType::getUnqual(i8Ty), - NULL); + PointerType::getUnqual(i8Ty) + KLEE_LLVM_GOIF_TERMINATOR); } f = mainModule->getFunction("__ctype_get_mb_cur_max"); -- 2.17.1