[llvm-bugs] [Bug 41321] New: Module Verifier failed with "opt -ipsccp -loop-distribute": Instruction operands must be first-class values!

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Mar 31 01:42:44 PDT 2019


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

            Bug ID: 41321
           Summary: Module Verifier failed with "opt -ipsccp
                    -loop-distribute": Instruction operands must be
                    first-class values!
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: unassignedbugs at nondot.org
          Reporter: cszide at 163.com
                CC: llvm-bugs at lists.llvm.org

Created attachment 21712
  --> https://bugs.llvm.org/attachment.cgi?id=21712&action=edit
.bc file of the source code

$clang -v
clang version 9.0.0 (trunk 355281)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.3.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64

$clang -O3 -c -emit-llvm  -mllvm -disable-llvm-optzns small.c

$opt -loop-versioning-licm -structurizecfg -gvn -sccp -sroa -reg2mem
-forceattrs -loop-extract-single -gvn -jump-threading small.bc -o small-opt.bc

$opt -ipsccp -loop-distribute small2-opt.bc
Instruction operands must be first-class values!
  br void Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt -ipsccp
-loop-distribute small-opt.bc 
1.      Running pass 'Function Pass Manager' on module 'small-opt.bc'.
2.      Running pass 'Module Verifier' on function '@c'
 #0 0x0000562392566d2a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x20d9d2a)
 #1 0x0000562392564d04 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x20d7d04)
 #2 0x0000562392564e42 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x20d7e42)
 #3 0x00007fe0c19ee890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x0000562391e4813e llvm::SlotTracker::SlotTracker(llvm::Function const*,
bool) (/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19bb13e)
 #5 0x0000562391e482bf createSlotTracker(llvm::Value const*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19bb2bf)
 #6 0x0000562391e4dfaf WriteAsOperandInternal(llvm::raw_ostream&, llvm::Value
const*, (anonymous namespace)::TypePrinting*, llvm::SlotTracker*, llvm::Module
const*)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19c0faf)
 #7 0x0000562391e5475f (anonymous
namespace)::AssemblyWriter::printInstruction(llvm::Instruction const&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19c775f)
 #8 0x0000562391e58991 llvm::Value::print(llvm::raw_ostream&,
llvm::ModuleSlotTracker&, bool) const
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19cb991)
 #9 0x0000562391f7887b llvm::VerifierSupport::Write(llvm::Value const&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1aeb87b)
#10 0x0000562391f8a223 (anonymous
namespace)::Verifier::visitInstruction(llvm::Instruction&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1afd223)
#11 0x0000562391f8b85b (anonymous
namespace)::Verifier::visitTerminator(llvm::Instruction&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1afe85b)
#12 0x0000562391f931c4 (anonymous namespace)::Verifier::verify(llvm::Function
const&) (.part.1280)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1b061c4)
#13 0x0000562391f95355 (anonymous
namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1b08355)
#14 0x0000562391f207a9 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1a937a9)
#15 0x0000562391f20831 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1a93831)
#16 0x0000562391f1fb59 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1a92b59)
#17 0x0000562390abd153 main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x630153)
#18 0x00007fe0c0683b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#19 0x0000562390b51f6a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x6c4f6a)
Segmentation fault (core dumped)

Without -loop-distribute pass, opt also crashes.

$opt -ipsccp  small-opt.bc
Referring to a basic block in another function!
  br *** stack smashing detected ***: <unknown> terminated
Stack dump:
0.      Program arguments:
/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt -ipsccp
small-opt.bc 
1.      Running pass 'Function Pass Manager' on module 'small-opt.bc'.
2.      Running pass 'Module Verifier' on function '@c'
 #0 0x000055f6fac13d2a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x20d9d2a)
 #1 0x000055f6fac11d04 llvm::sys::RunSignalHandlers()
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x20d7d04)
 #2 0x000055f6fac11e42 SignalHandler(int)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x20d7e42)
 #3 0x00007f5b60424890 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)
 #4 0x00007f5b5f0d6e97 gsignal
/build/glibc-OTsEL5/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
 #5 0x00007f5b5f0d8801 abort /build/glibc-OTsEL5/glibc-2.27/stdlib/abort.c:81:0
 #6 0x00007f5b5f121897 __libc_message
/build/glibc-OTsEL5/glibc-2.27/libio/../sysdeps/posix/libc_fatal.c:181:0
 #7 0x00007f5b5f1cccd1 __GI___fortify_fail_abort
/build/glibc-OTsEL5/glibc-2.27/debug/fortify_fail.c:33:0
 #8 0x00007f5b5f1ccc92 (/lib/x86_64-linux-gnu/libc.so.6+0x134c92)
 #9 0x000055f6fa4f8948
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19be948)
#10 0x000055f6fa501851 (anonymous
namespace)::AssemblyWriter::printInstruction(llvm::Instruction const&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19c7851)
#11 0x000055f6fa505991 llvm::Value::print(llvm::raw_ostream&,
llvm::ModuleSlotTracker&, bool) const
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x19cb991)
#12 0x000055f6fa62587b llvm::VerifierSupport::Write(llvm::Value const&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1aeb87b)
#13 0x000055f6fa637223 (anonymous
namespace)::Verifier::visitInstruction(llvm::Instruction&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1afd223)
#14 0x000055f6fa63885b (anonymous
namespace)::Verifier::visitTerminator(llvm::Instruction&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1afe85b)
#15 0x000055f6fa6401c4 (anonymous namespace)::Verifier::verify(llvm::Function
const&) (.part.1280)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1b061c4)
#16 0x000055f6fa642355 (anonymous
namespace)::VerifierLegacyPass::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1b08355)
#17 0x000055f6fa5cd7a9 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1a937a9)
#18 0x000055f6fa5cd831 llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1a93831)
#19 0x000055f6fa5ccb59 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x1a92b59)
#20 0x000055f6f916a153 main
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x630153)
#21 0x00007f5b5f0b9b97 __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0
#22 0x000055f6f91fef6a _start
(/home/jack-zhou/Documents/llvm/llvm_truck/llvm/build4/bin/opt+0x6c4f6a)
Aborted (core dumped)


By using godbolt, it shows that this problem also occurs in LLVM 6/7/trunk.
-----------------------------------------------------
#include "csmith.h"
a, b;
c() {
  a = 2;
d:
  for (; a;) {
    int e;
    for (; b;) {
      int e = safe_lshift_func_int16_t_s_s;
      if (e)
        continue;
    }
    for (; c;)
      goto d;
  }
}

-- 
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/20190331/e4950701/attachment-0001.html>


More information about the llvm-bugs mailing list