[llvm-bugs] [Bug 38500] New: opt crashes with ../lib/IR/Constants.cpp:1905: static llvm::Constant *llvm::ConstantExpr::getCompare(unsigned short, llvm::Constant *, llvm::Constant *, bool): Assertion `C1->getType() == C2->getType() && "Op types should be identical!"' failed.

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Aug 9 06:07:07 PDT 2018


https://bugs.llvm.org/show_bug.cgi?id=38500

            Bug ID: 38500
           Summary: opt crashes with ../lib/IR/Constants.cpp:1905: static
                    llvm::Constant
                    *llvm::ConstantExpr::getCompare(unsigned short,
                    llvm::Constant *, llvm::Constant *, bool): Assertion
                    `C1->getType() == C2->getType() && "Op types should be
                    identical!"' failed.
           Product: new-bugs
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: mikael.holmen at ericsson.com
                CC: llvm-bugs at lists.llvm.org

Running 
 opt -inline -S -o - bbi-16745.ll

yields

opt: ../lib/IR/Constants.cpp:1905: static llvm::Constant
*llvm::ConstantExpr::getCompare(unsigned short, llvm::Constant *,
llvm::Constant *, bool): Assertion `C1->getType() == C2->getType() && "Op types
should be identical!"' failed.
Stack dump:
0.      Program arguments: /data/repo/llvm-patch/build-all/bin/opt -verify
-inline -S -o - bbi-16745.ll 
1.      Running pass 'CallGraph Pass Manager' on module 'bbi-16745.ll'.
#0 0x0000000002086db4 PrintStackTraceSignalHandler(void*)
(/data/repo/llvm-patch/build-all/bin/opt+0x2086db4)
#1 0x0000000002084f10 llvm::sys::RunSignalHandlers()
(/data/repo/llvm-patch/build-all/bin/opt+0x2084f10)
#2 0x0000000002087118 SignalHandler(int)
(/data/repo/llvm-patch/build-all/bin/opt+0x2087118)
#3 0x00007f2ec1966330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f2ec0555c37 gsignal
/build/eglibc-ripdx6/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007f2ec0559028 abort
/build/eglibc-ripdx6/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007f2ec054ebf6 __assert_fail_base
/build/eglibc-ripdx6/eglibc-2.19/assert/assert.c:92:0
#7 0x00007f2ec054eca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x0000000001a3dc7a llvm::ConstantExpr::getCompare(unsigned short,
llvm::Constant*, llvm::Constant*, bool)
(/data/repo/llvm-patch/build-all/bin/opt+0x1a3dc7a)
#9 0x00000000015359d0 (anonymous
namespace)::CallAnalyzer::visitCmpInst(llvm::CmpInst&)
(/data/repo/llvm-patch/build-all/bin/opt+0x15359d0)
#10 0x000000000152f643 llvm::InstVisitor<(anonymous namespace)::CallAnalyzer,
bool>::visit(llvm::Instruction&)
(/data/repo/llvm-patch/build-all/bin/opt+0x152f643)
#11 0x000000000152c2ad (anonymous
namespace)::CallAnalyzer::analyzeCall(llvm::CallSite)
(/data/repo/llvm-patch/build-all/bin/opt+0x152c2ad)
#12 0x000000000152a966 llvm::getInlineCost(llvm::CallSite, llvm::Function*,
llvm::InlineParams const&, llvm::TargetTransformInfo&,
std::function<llvm::AssumptionCache& (llvm::Function&)>&,
llvm::Optional<llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>
>, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*)
(/data/repo/llvm-patch/build-all/bin/opt+0x152a966)
#13 0x000000000152a38e llvm::getInlineCost(llvm::CallSite, llvm::InlineParams
const&, llvm::TargetTransformInfo&, std::function<llvm::AssumptionCache&
(llvm::Function&)>&,
llvm::Optional<llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>
>, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*)
(/data/repo/llvm-patch/build-all/bin/opt+0x152a38e)
#14 0x0000000001bcd01a (anonymous
namespace)::SimpleInliner::getInlineCost(llvm::CallSite)
(/data/repo/llvm-patch/build-all/bin/opt+0x1bcd01a)
#15 0x0000000001bd4bbd shouldInline(llvm::CallSite,
llvm::function_ref<llvm::InlineCost (llvm::CallSite)>,
llvm::OptimizationRemarkEmitter&)
(/data/repo/llvm-patch/build-all/bin/opt+0x1bd4bbd)
#16 0x0000000001bce49c
llvm::LegacyInlinerBase::inlineCalls(llvm::CallGraphSCC&)
(/data/repo/llvm-patch/build-all/bin/opt+0x1bce49c)
#17 0x0000000001bcd412 llvm::LegacyInlinerBase::runOnSCC(llvm::CallGraphSCC&)
(/data/repo/llvm-patch/build-all/bin/opt+0x1bcd412)
#18 0x00000000014d9614 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/data/repo/llvm-patch/build-all/bin/opt+0x14d9614)
#19 0x0000000001af927a llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/data/repo/llvm-patch/build-all/bin/opt+0x1af927a)
#20 0x00000000007553b4 main (/data/repo/llvm-patch/build-all/bin/opt+0x7553b4)
#21 0x00007f2ec0540f45 __libc_start_main
/build/eglibc-ripdx6/eglibc-2.19/csu/libc-start.c:321:0
#22 0x000000000073dafd _start
(/data/repo/llvm-patch/build-all/bin/opt+0x73dafd)
Abort


Problem seems to be that when the

  %cmp = icmp eq i32 %sub.ptr.sub, 0

is analyzed by

bool CallAnalyzer::visitCmpInst(CmpInst &I) {
  Value *LHS = I.getOperand(0), *RHS = I.getOperand(1);
  // First try to handle simplified comparisons.
  if (simplifyInstruction(I, [&](SmallVectorImpl<Constant *> &COps) {
        return ConstantExpr::getCompare(I.getPredicate(), COps[0], COps[1]);
      }))
    return true;

we call simplifyInstruction above:

template <typename Callable>
bool CallAnalyzer::simplifyInstruction(Instruction &I, Callable Evaluate) {
  SmallVector<Constant *, 2> COps;
  for (Value *Op : I.operands()) {
    Constant *COp = dyn_cast<Constant>(Op);
    if (!COp)
      COp = SimplifiedValues.lookup(Op);
    if (!COp)
      return false;
    COps.push_back(COp);
  }
  auto *C = Evaluate(COps);
  if (!C)
    return false;
  SimplifiedValues[&I] = C;
  return true;
}

The loop in simplifyInstruction finds

 i16 0
and
 i32 0

in SimplifiedValues, and then ConstantExpr::getCompare pukes because the two
values have different types.

Found at current trunk, r339288 and the problem seems to be old.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180809/3f45a5a2/attachment.html>


More information about the llvm-bugs mailing list