about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorDan Liew <delcypher@gmail.com>2016-02-22 19:19:06 +0000
committerDan Liew <delcypher@gmail.com>2016-02-22 19:19:06 +0000
commitf76b6c5fe0ce8920ee6edb13802f857dae49e785 (patch)
tree2714915d54850c50df21ea16e2bb7aa568d84c42
parent8409a27a57a6fd4aad8828b0912c3afd39efb7e0 (diff)
parent6b60b63c42c65796fc301ab0c3219c895e0f05fb (diff)
downloadklee-f76b6c5fe0ce8920ee6edb13802f857dae49e785.tar.gz
Merge pull request #339 from yotann/fix-valueisonlycalled
Fix valueIsOnlyCalled() used by MD2U.
-rw-r--r--lib/Module/ModuleUtil.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index aabc0a57..a5394067 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -460,13 +460,15 @@ static bool valueIsOnlyCalled(const Value *v) {
        it != ie; ++it) {
     if (const Instruction *instr = dyn_cast<Instruction>(*it)) {
       if (instr->getOpcode()==0) continue; // XXX function numbering inst
-      if (!isa<CallInst>(instr) && !isa<InvokeInst>(instr)) return false;
+
+      // Make sure the instruction is a call or invoke.
+      CallSite cs(const_cast<Instruction *>(instr));
+      if (!cs) return false;
       
       // Make sure that the value is only the target of this call and
       // not an argument.
-      for (unsigned i=1,e=instr->getNumOperands(); i!=e; ++i)
-        if (instr->getOperand(i)==v)
-          return false;
+      if (cs.hasArgument(v))
+        return false;
     } else if (const llvm::ConstantExpr *ce = 
                dyn_cast<llvm::ConstantExpr>(*it)) {
       if (ce->getOpcode()==Instruction::BitCast)