From 6b60b63c42c65796fc301ab0c3219c895e0f05fb Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Sat, 20 Feb 2016 11:45:10 -0600 Subject: 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. --- lib/Module/ModuleUtil.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/Module/ModuleUtil.cpp') 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(*it)) { if (instr->getOpcode()==0) continue; // XXX function numbering inst - if (!isa(instr) && !isa(instr)) return false; + + // Make sure the instruction is a call or invoke. + CallSite cs(const_cast(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(*it)) { if (ce->getOpcode()==Instruction::BitCast) -- cgit 1.4.1