<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </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 --- - regression: Compilation hangs with -O2 -mavx for certain input (valid code)"
   href="https://llvm.org/bugs/show_bug.cgi?id=26354">26354</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>regression: Compilation hangs with -O2 -mavx for certain input (valid code)
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.8
          </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>Keywords</th>
          <td>regression
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>release blocker
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>C++14
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>pipping@exherbo.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>hans@chromium.org, llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have a (unfortunately very large still) chunk of C++ code which clang++ never
appears to finish compiling.

The following three criteria need to met in order for this to happen:
 * I need to use clang 3.8.0rc1 (the issue does not occur with 3.7.1)
 * I need to pass -mavx (or something that implies it, like -march=sandybridge)
 * I need to pass -O2 (the issue does not occur with -O1)

I've created a preprocessor dump using clang 3.7.1 and -save-temps that I'm
attaching to this report. As expected, it shows the following behaviour:

# clang++ 3.7.1 didn't have the problem
% ( ulimit -t 10; time clang++3.7.1 -c -std=c++14 -o /dev/null
uggridgeometry.ii -O2 -march=sandybridge )
1.26s user 0.02s system 99% cpu 1.287 total

# clang++ 3.8.0rc1 has the problem
% ( ulimit -t 10; time clang++3.8.0rc1 -c -std=c++14 -o /dev/null
uggridgeometry.ii -O2 -march=sandybridge )
#0 0x0000000001c048e5 llvm::sys::PrintStackTrace(llvm::raw_ostream&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1c048e5)
#1 0x0000000001c028a6 llvm::sys::RunSignalHandlers()
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1c028a6)
#2 0x0000000001c02ac4 SignalHandler(int)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1c02ac4)
#3 0x00007efdc42e08d0 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0xf8d0)
#4 0x000000000147cebc llvm::FindAvailableLoadedValue(llvm::Value*,
llvm::BasicBlock*, llvm::ilist_iterator<llvm::Instruction>&, unsigned int,
llvm::AAResults*, llvm::AAMDNodes*)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x147cebc)
#5 0x00000000019a1b5a llvm::InstCombiner::visitLoadInst(llvm::LoadInst&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x19a1b5a)
#6 0x0000000001965213 llvm::InstCombiner::run()
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1965213)
#7 0x0000000001966309 combineInstructionsOverFunction(llvm::Function&,
llvm::InstCombineWorklist&, llvm::AAResults*, llvm::AssumptionCache&,
llvm::TargetLibraryInfo&, llvm::DominatorTree&, llvm::LoopInfo*)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1966309)
#8 0x0000000001966c70 (anonymous
namespace)::InstructionCombiningPass::runOnFunction(llvm::Function&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1966c70)
#9 0x00000000018c7083 llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x18c7083)
#10 0x00000000018c76cb llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x18c76cb)
#11 0x0000000001d1d0d2 clang::EmitBackendOutput(clang::DiagnosticsEngine&,
clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions
const&, llvm::StringRef, llvm::Module*, clang::BackendAction,
llvm::raw_pwrite_stream*)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1d1d0d2)
#12 0x0000000002271917
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x2271917)
#13 0x000000000255755d clang::ParseAST(clang::Sema&, bool, bool)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x255755d)
#14 0x00000000022719fb clang::CodeGenAction::ExecuteAction()
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x22719fb)
#15 0x0000000001fd9b26 clang::FrontendAction::Execute()
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1fd9b26)
#16 0x0000000001fb3216
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x1fb3216)
#17 0x00000000020601b3
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0x20601b3)
#18 0x0000000000a985c8 cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0xa985c8)
#19 0x0000000000a57c82 main
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0xa57c82)
#20 0x00007efdc350ab45 __libc_start_main
/build/glibc-3Vu5mt/glibc-2.19/csu/libc-start.c:321:0
#21 0x0000000000a947c4 _start
(/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8+0xa947c4)
Stack dump:
0.    Program arguments:
/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/clang-3.8 -cc1 -triple
x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name
uggridgeometry.ii -mrelocation-model static -mthread-model posix -fmath-errno
-masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array
-target-cpu sandybridge -momit-leaf-frame-pointer -dwarf-column-info
-debugger-tuning=gdb -coverage-file /dev/null -resource-dir
/home/mi/pipping/dune/inst/clang-3.8.0rc1/bin/../lib/clang/3.8.0 -O2 -std=c++14
-fdeprecated-macro -fdebug-compilation-dir
/home/mi/pipping/dune/build-Release/dune-grid/lib -ferror-limit 19
-fmessage-length 175 -fobjc-runtime=gcc -fcxx-exceptions -fexceptions
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-o /dev/null -x c++-cpp-output uggridgeometry.ii 
1.    <eof> parser at end of file
2.    Per-module optimization passes
3.    Running pass 'Function Pass Manager' on module 'uggridgeometry.ii'.
4.    Running pass 'Combine redundant instructions' on function
'@_ZN4Dune5UG_NSILi3EE14TransformationEiPPdRKNS_11FieldVectorIdLi3EEERNS_11FieldMatrixIdLi3ELi3EEE'
clang-3.8: error: unable to execute command: CPU time limit exceeded
clang-3.8: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 3.8.0 (tags/RELEASE_380/rc1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/mi/pipping/dune/inst/clang-3.8.0rc1/bin
clang-3.8: 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-3.8: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.
11.12s user 0.06s system 98% cpu 11.348 total

# The problem goes away with -O1
% ( ulimit -t 10; time clang++3.8.0rc1 -c -std=c++14 -o /dev/null
uggridgeometry.ii -O1 -march=sandybridge )
1.30s user 0.04s system 99% cpu 1.340 total

# The problem goes away with an architecture that does not support AVX
% ( ulimit -t 10; time clang++3.8.0rc1 -c -std=c++14 -o /dev/null
uggridgeometry.ii -O2 -march=westmere )
1.29s user 0.04s system 99% cpu 1.340 total

# The problem is triggered by the addition of AVX
% ( ulimit -t 10; time clang++3.8.0rc1 -c -std=c++14 -o /dev/null
uggridgeometry.ii -O2 -march=westmere -mavx )
< killed after 10s, same output a above >

# The problem is triggered by AVX alone
% ( ulimit -t 10; time clang++3.8.0rc1 -c -std=c++14 -o /dev/null
uggridgeometry.ii -O2 -mavx )
< killed after 10s, same output a above ></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>