<html>
    <head>
      <base href="http://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Assertion failed: Idx >= 0 && "Invalid basic block argument!", file C:\src\llvm\include\llvm/IR/Instructions.h, line 2715"
   href="http://bugs.llvm.org/show_bug.cgi?id=32178">32178</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assertion failed: Idx >= 0 && "Invalid basic block argument!", file C:\src\llvm\include\llvm/IR/Instructions.h, line 2715
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>douglas_yung@playstation.sony.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following code after r296898 hits an assertion failure when run with
optimizations enabled (-O2):

int foo(int a, int b)
{
  int c = 0;
  int d = 0;

label1:
  if(a == 100)
    c = 1;
  else {
label2:
    if(b == 50)
      return d;
    b = 75;
  }
  if(a != 0)
    goto label2;
  d = 5;
  goto label1;
}

Output of running clang -c -O2 repro.cpp:

clang -c -O2 repro.cpp
clang-5.0:
/home/dyung/src/upstream/llvm_clean/include/llvm/IR/Instructions.h:2715:
llvm::Value* llvm::PHINode::getIncomingValueForBlock(const llvm::BasicBlock*)
const: Assertion `Idx >= 0 && "Invalid basic block argument!"' failed.
#0 0x0000000001efe44a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1efe44a)
#1 0x0000000001efc46e llvm::sys::RunSignalHandlers()
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1efc46e)
#2 0x0000000001efc5d2 SignalHandler(int)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1efc5d2)
#3 0x00007f3e3326e330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007f3e324abc37 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x36c37)
#5 0x00007f3e324af028 abort (/lib/x86_64-linux-gnu/libc.so.6+0x3a028)
#6 0x00007f3e324a4bf6 (/lib/x86_64-linux-gnu/libc.so.6+0x2fbf6)
#7 0x00007f3e324a4ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x0000000000891aba llvm::cast_retty<llvm::BranchInst,
llvm::TerminatorInst*>::ret_type llvm::cast<llvm::BranchInst,
llvm::TerminatorInst>(llvm::TerminatorInst*) [clone .part.183]
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x891aba)
#9 0x0000000001f6d83d cloneLoopBlocks(llvm::Loop*, unsigned int,
llvm::BasicBlock*, llvm::BasicBlock*, llvm::BasicBlock*,
llvm::SmallVectorImpl<llvm::BasicBlock*>&, llvm::LoopBlocksDFS&,
llvm::ValueMap<llvm::Value const*, llvm::WeakVH,
llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false> > >&,
llvm::ValueMap<llvm::Value const*, llvm::WeakVH,
llvm::ValueMapConfig<llvm::Value const*, llvm::sys::SmartMutex<false> > >&,
llvm::DominatorTree*, llvm::LoopInfo*)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1f6d83d)
#10 0x0000000001f6eb63 llvm::peelLoop(llvm::Loop*, unsigned int,
llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::DominatorTree*,
llvm::AssumptionCache*, bool)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1f6eb63)
#11 0x0000000001f693c9 llvm::UnrollLoop(llvm::Loop*, unsigned int, unsigned
int, bool, bool, bool, bool, bool, unsigned int, unsigned int, llvm::LoopInfo*,
llvm::ScalarEvolution*, llvm::DominatorTree*, llvm::AssumptionCache*,
llvm::OptimizationRemarkEmitter*, bool)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1f693c9)
#12 0x0000000001dec250 tryToUnrollLoop(llvm::Loop*, llvm::DominatorTree&,
llvm::LoopInfo*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const&,
llvm::AssumptionCache&, llvm::OptimizationRemarkEmitter&, bool, int,
llvm::Optional<unsigned int>, llvm::Optional<unsigned int>,
llvm::Optional<bool>, llvm::Optional<bool>, llvm::Optional<bool>)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1dec250)
#13 0x0000000001dec9aa (anonymous
namespace)::LoopUnroll::runOnLoop(llvm::Loop*, llvm::LPPassManager&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1dec9aa)
#14 0x000000000168ff07 llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x168ff07)
#15 0x0000000001aec243 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1aec243)
#16 0x000000000284eaef (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x284eaef)
#17 0x0000000001aed04f llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x1aed04f)
#18 0x000000000208982a (anonymous
namespace)::EmitAssemblyHelper::EmitAssembly(clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x208982a)
#19 0x000000000208ab13 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::HeaderSearchOptions const&, clang::CodeGenOptions const&,
clang::TargetOptions const&, clang::LangOptions const&, llvm::DataLayout
const&, llvm::Module*, clang::BackendAction,
std::unique_ptr<llvm::raw_pwrite_stream,
std::default_delete<llvm::raw_pwrite_stream> >)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x208ab13)
#20 0x00000000026ef18c
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x26ef18c)
#21 0x0000000002ab22e2 clang::ParseAST(clang::Sema&, bool, bool)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x2ab22e2)
#22 0x00000000026edb2a clang::CodeGenAction::ExecuteAction()
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x26edb2a)
#23 0x00000000023d21d6 clang::FrontendAction::Execute()
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x23d21d6)
#24 0x00000000023acaf6
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x23acaf6)
#25 0x000000000245d3f4
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0x245d3f4)
#26 0x0000000000b28898 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0xb28898)
#27 0x0000000000aca0ba main
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0xaca0ba)
#28 0x00007f3e32496f45 __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x21f45)
#29 0x0000000000b24189 _start
(/home/dyung/src/upstream/296898-linux/bin/clang-5.0+0xb24189)
Stack dump:
0.      Program arguments: /home/dyung/src/upstream/296898-linux/bin/clang-5.0
-cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name
repro.cpp -mrelocation-model static -mthread-model posix -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu x86-64 -momit-leaf-frame-pointer -dwarf-column-info
-debugger-tuning=gdb -coverage-notes-file /home/dyung/sandbox/repro.gcno
-resource-dir /home/dyung/src/upstream/296898-linux/lib/clang/5.0.0
-internal-isystem /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/x86_64-linux-gnu/c++/4.8
-internal-isystem
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/backward
-internal-isystem /usr/local/include -internal-isystem
/home/dyung/src/upstream/296898-linux/lib/clang/5.0.0/include
-internal-externc-isystem /usr/include/x86_64-linux-gnu
-internal-externc-isystem /include -internal-externc-isystem /usr/include -O2
-fdeprecated-macro -fdebug-compilation-dir /home/dyung/sandbox -ferror-limit 19
-fmessage-length 235 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -vectorize-loops -vectorize-slp -o repro.o -x c++
repro.cpp
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module 'repro.cpp'.
4.      Running pass 'Loop Pass Manager' on function '@_Z3fooii'
5.      Running pass 'Unroll loops' on basic block '%label1'
clang-5.0: error: unable to execute command: Aborted (core dumped)
clang-5.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 5.0.0 (trunk 296898)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/dyung/src/upstream/296898-linux/bin</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>