about summary refs log tree commit diff homepage
path: root/lib
diff options
context:
space:
mode:
authorSean Bartell <yotann@yotann.org>2016-02-20 11:45:10 -0600
committerSean Bartell <yotann@yotann.org>2016-02-20 11:56:57 -0600
commit6b60b63c42c65796fc301ab0c3219c895e0f05fb (patch)
tree2714915d54850c50df21ea16e2bb7aa568d84c42 /lib
parent8409a27a57a6fd4aad8828b0912c3afd39efb7e0 (diff)
downloadklee-6b60b63c42c65796fc301ab0c3219c895e0f05fb.tar.gz
Fix valueIsOnlyCalled() used by MD2U.
CallInst::getOperand() uses incompatible operand orders across LLVM
versions. Use CallSite::hasArgument() instead. This bug prevented the
MD2U searcher from working correctly.
Diffstat (limited to 'lib')
-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)