diff options
author | Julian Büning <julian.buening@rwth-aachen.de> | 2018-07-21 23:01:54 +0200 |
---|---|---|
committer | MartinNowack <martin.nowack@gmail.com> | 2018-07-23 13:46:59 +0100 |
commit | 09bf6d322d79381de780871f26cdffc26d7dacf4 (patch) | |
tree | 1e829c75b7ee18c130698894e5583fee7300688f /lib/Module/ModuleUtil.cpp | |
parent | 9358aa95f9ae94cbb4e1a9f638e953e0164da86c (diff) | |
download | klee-09bf6d322d79381de780871f26cdffc26d7dacf4.tar.gz |
ModuleUtil: improve and test valueIsOnlyCalled
* handle BlockAddress (which is not a valid function pointer) * there is no instruction with opcode 0 * add test for functionality
Diffstat (limited to 'lib/Module/ModuleUtil.cpp')
-rw-r--r-- | lib/Module/ModuleUtil.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index deb5a3e2..5ca0a55b 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -312,9 +312,7 @@ static bool valueIsOnlyCalled(const Value *v) { #else for (auto user : v->users()) { #endif - if (const Instruction *instr = dyn_cast<Instruction>(user)) { - if (instr->getOpcode()==0) continue; // XXX function numbering inst - + if (const auto *instr = dyn_cast<Instruction>(user)) { // Make sure the instruction is a call or invoke. CallSite cs(const_cast<Instruction *>(instr)); if (!cs) return false; @@ -323,16 +321,17 @@ static bool valueIsOnlyCalled(const Value *v) { // not an argument. if (cs.hasArgument(v)) return false; - } else if (const llvm::ConstantExpr *ce = - dyn_cast<llvm::ConstantExpr>(user)) { - if (ce->getOpcode()==Instruction::BitCast) + } else if (const auto *ce = dyn_cast<ConstantExpr>(user)) { + if (ce->getOpcode() == Instruction::BitCast) if (valueIsOnlyCalled(ce)) continue; return false; - } else if (const GlobalAlias *ga = dyn_cast<GlobalAlias>(user)) { - // XXX what about v is bitcast of aliasee? - if (v==ga->getAliasee() && !valueIsOnlyCalled(ga)) + } else if (const auto *ga = dyn_cast<GlobalAlias>(user)) { + if (v == ga->getAliasee() && !valueIsOnlyCalled(ga)) return false; + } else if (isa<BlockAddress>(user)) { + // only valid as operand to indirectbr or comparison against null + continue; } else { return false; } |