<html>
    <head>
      <base href="https://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 - clang crashes at -Os with polly: Use still stuck around after Def is destroyed."
   href="https://bugs.llvm.org/show_bug.cgi?id=34680">34680</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang crashes at -Os with polly: Use still stuck around after Def is destroyed.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>Polly
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>All
          </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>Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>polly-dev@googlegroups.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>helloqirun@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>$ clang-trunk -v
clang version 6.0.0 (trunk 313617)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin



$ clang-trunk -mllvm -polly abc.c  -m32 -Os
While deleting: i16 %bf.clear
Use still stuck around after Def is destroyed:  store i16 %bf.clear, i16*
getelementptr inbounds (%struct.anon, %struct.anon* @b, i32 0, i32 0), align 4
clang-6.0: /home/absozero/trunk/llvm/lib/IR/Value.cpp:86:
llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is
destroyed!"' failed.
#0 0x000000000201f67a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x201f67a)
#1 0x000000000201d51e llvm::sys::RunSignalHandlers()
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x201d51e)
#2 0x000000000201d672 SignalHandler(int)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x201d672)
#3 0x00007fd45ad4c330 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)
#4 0x00007fd4598c9c37 gsignal
/build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0
#5 0x00007fd4598cd028 abort
/build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0
#6 0x00007fd4598c2bf6 __assert_fail_base
/build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0
#7 0x00007fd4598c2ca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)
#8 0x0000000001bad5db (/home/absozero/trunk/root-clang/bin/clang-6.0+0x1bad5db)
#9 0x0000000001bad630 llvm::Value::deleteValue()
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1bad630)
#10 0x0000000001abcaec llvm::BasicBlock::~BasicBlock()
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1abcaec)
#11 0x000000000208b863 llvm::removeUnreachableBlocks(llvm::Function&,
llvm::LazyValueInfo*) (/home/absozero/trunk/root-clang/bin/clang-6.0+0x208b863)
#12 0x0000000001f7a70b (anonymous
namespace)::BaseCFGSimplifyPass::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1f7a70b)
#13 0x0000000001b713f3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b713f3)
#14 0x0000000001b71589
llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b71589)
#15 0x0000000001b71cdf llvm::legacy::FunctionPassManager::run(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b71cdf)
#16 0x0000000001b713f3 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b713f3)
#17 0x0000000001b714bc llvm::FPPassManager::runOnModule(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b714bc)
#18 0x0000000001b70f8d llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x1b70f8d)
#19 0x00000000021c8c86 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/absozero/trunk/root-clang/bin/clang-6.0+0x21c8c86)
#20 0x00000000029d0d27
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x29d0d27)
#21 0x0000000002baca18 clang::ParseAST(clang::Sema&, bool, bool)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x2baca18)
#22 0x00000000029d00dc clang::CodeGenAction::ExecuteAction()
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x29d00dc)
#23 0x000000000257354e clang::FrontendAction::Execute()
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x257354e)
#24 0x0000000002542d06
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x2542d06)
#25 0x0000000002605cf3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x2605cf3)
#26 0x0000000000a3bb48 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/absozero/trunk/root-clang/bin/clang-6.0+0xa3bb48)
#27 0x00000000009bb811 main
(/home/absozero/trunk/root-clang/bin/clang-6.0+0x9bb811)
#28 0x00007fd4598b4f45 __libc_start_main
/build/eglibc-oGUzwX/eglibc-2.19/csu/libc-start.c:321:0
#29 0x0000000000a38059 _start
(/home/absozero/trunk/root-clang/bin/clang-6.0+0xa38059)
Stack dump:
0.      Program arguments: /home/absozero/trunk/root-clang/bin/clang-6.0 -cc1
-triple i386-unknown-linux-gnu -emit-obj -disable-free -main-file-name abc.c
-mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose
-mconstructor-aliases -fuse-init-array -target-cpu pentium4 -dwarf-column-info
-debugger-tuning=gdb -momit-leaf-frame-pointer -resource-dir
/home/absozero/trunk/root-clang/lib/clang/6.0.0 -internal-isystem
/usr/local/include -internal-isystem
/home/absozero/trunk/root-clang/lib/clang/6.0.0/include
-internal-externc-isystem /include -internal-externc-isystem /usr/include -Os
-fdebug-compilation-dir /home/absozero/projects/reduction/crash -ferror-limit
19 -fmessage-length 172 -fobjc-runtime=gcc -fdiagnostics-show-option
-fcolor-diagnostics -vectorize-loops -vectorize-slp -mllvm -polly -o
/tmp/abc-b2dfa7.o -x c abc.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'Function Pass Manager' on module 'abc.c'.
4.      Running pass 'Polly - Cleanup after code generation' on function
'@main'
5.      Running pass 'Simplify the CFG' on function '@main'
clang-6.0: error: unable to execute command: Aborted (core dumped)
clang-6.0: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 6.0.0 (trunk 313617)
Target: i386-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
clang-6.0: note: diagnostic msg: PLEASE submit a bug report to
<a href="http://llvm.org/bugs/">http://llvm.org/bugs/</a> and include the crash backtrace, preprocessed source, and
associated run script.
clang-6.0: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-6.0: note: diagnostic msg: /tmp/abc-e80e90.c
clang-6.0: note: diagnostic msg: /tmp/abc-e80e90.sh
clang-6.0: note: diagnostic msg:

********************



$ cat abc.c
int a, c, d, e;
struct {
  signed f9 : 9;
} b;
int main() {
  d = 0;
  for (; d < 56; d++) {
    e = 8;
    for (; e; e--)
      if (d & 1)
        a = c;
  }
  int f = 14;
  for (; f != 8; ++f)
    b.f9 = 0;
}</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>