From 9358aa95f9ae94cbb4e1a9f638e953e0164da86c Mon Sep 17 00:00:00 2001 From: Julian Büning Date: Fri, 29 Jun 2018 18:34:11 +0200 Subject: fix: LLVM 3.5, begin_user() instead of begin_use() With version 3.5, LLVM introduced a subtle semantic change in the API of `Value`. With that change, `use_begin()` is renamed to `user_begin()`. Additionally, a new method `use_begin()` with a different meaning was introduced. Now, `use_begin()` actually iterates over `Use`s, whereas before, dereferencing it would give a `User *`. For further details, please refer to https://reviews.llvm.org/rL203364. Due to the reintroduction of `use_begin()`, existing code may still compile, although the semantics have changed. In the code changed with this patch, all `dyn_cast`s for `Use` fail and the else branch is always taken. --- lib/Module/ModuleUtil.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'lib/Module') diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 4912ca94..deb5a3e2 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -306,9 +306,13 @@ Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) { } static bool valueIsOnlyCalled(const Value *v) { - for (Value::const_use_iterator it = v->use_begin(), ie = v->use_end(); - it != ie; ++it) { - if (const Instruction *instr = dyn_cast(*it)) { +#if LLVM_VERSION_CODE < LLVM_VERSION(3, 5) + for (auto it = v->use_begin(), ie = v->use_end(); it != ie; ++it) { + auto user = *it; +#else + for (auto user : v->users()) { +#endif + if (const Instruction *instr = dyn_cast(user)) { if (instr->getOpcode()==0) continue; // XXX function numbering inst // Make sure the instruction is a call or invoke. @@ -320,12 +324,12 @@ static bool valueIsOnlyCalled(const Value *v) { if (cs.hasArgument(v)) return false; } else if (const llvm::ConstantExpr *ce = - dyn_cast(*it)) { + dyn_cast(user)) { if (ce->getOpcode()==Instruction::BitCast) if (valueIsOnlyCalled(ce)) continue; return false; - } else if (const GlobalAlias *ga = dyn_cast(*it)) { + } else if (const GlobalAlias *ga = dyn_cast(user)) { // XXX what about v is bitcast of aliasee? if (v==ga->getAliasee() && !valueIsOnlyCalled(ga)) return false; -- cgit 1.4.1