<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 - emscripten exception with new LLVM backend"
   href="https://bugs.llvm.org/show_bug.cgi?id=43260">43260</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>emscripten exception with new LLVM backend
          </td>
        </tr>

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

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

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

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

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

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

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

        <tr>
          <th>Reporter</th>
          <td>hacker@linux.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When compiling [sphincs.js](<a href="https://github.com/cyph/sphincs.js">https://github.com/cyph/sphincs.js</a>) with emscripten
latest-upstream, I get the following error. Specifically, the problem is caused
by using `WASM=1` with anything other than `-O0`.

Not sure if this is more of an llvm or emscripten problem, so I submitted to
both. emscripten issue:
<a href="https://github.com/emscripten-core/emscripten/issues/9413">https://github.com/emscripten-core/emscripten/issues/9413</a>

```
clang-10:
/b/s/w/ir/cache/builder/emscripten-releases/llvm-project/llvm/lib/Analysis/ScalarEvolution.cpp:4069:
const llvm::SCEV *llvm::ScalarEvolution::getNoopOrZeroExtend(const llvm::SCEV
*, llvm::Type *): Assertion `getTypeSizeInBits(SrcTy) <= getTypeSizeInBits(Ty)
&& "getNoopOrZeroExtend cannot truncate!"' failed.
Stack dump:
0.      Program arguments: /home/gibson/emsdk/upstream/bin/clang-10 -cc1
-triple wasm32-unknown-emscripten -emit-obj -disable-free -main-file-name
sign.c -mrelocation-model static -mthread-model posix -mframe-pointer=none
-masm-verbose -mconstructor-aliases -fuse-init-array -target-cpu generic
-fvisibility hidden -dwarf-column-info -debugger-tuning=gdb
-coverage-notes-file /tmp/emscripten_temp__jRzu7/sign_8.gcno -resource-dir
/home/gibson/emsdk/upstream/lib/clang/10.0.0 -include
c_src/crypto_stream/chacha12/e/ref/namespace.h -D __EMSCRIPTEN_major__=1 -D
__EMSCRIPTEN_minor__=38 -D __EMSCRIPTEN_tiny__=43 -D _LIBCPP_ABI_VERSION=2 -D
unix -D __unix -D __unix__ -D EMSCRIPTEN -I
libsodium/src/libsodium/include/sodium -I openssl/include -I c_src -I
c_src/include -I c_src/crypto_stream/chacha12/e/ref -internal-isystem
/home/gibson/emsdk/upstream/lib/clang/10.0.0/include -internal-isystem
/include/wasm32-emscripten -internal-isystem /include -O3
-Werror=implicit-function-declaration -fdebug-compilation-dir /cyph/sphincs.js
-ferror-limit 19 -fmessage-length 0 -fobjc-runtime=gnustep -fno-common
-fdiagnostics-show-option -fcolor-diagnostics -vectorize-loops -vectorize-slp
-nostdsysteminc
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/libcxx
-isystem/home/gibson/emsdk/upstream/emscripten/system/lib/libcxxabi/include
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/compat
-isystem/home/gibson/emsdk/upstream/emscripten/system/include
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/libc
-isystem/home/gibson/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten
-isystem/home/gibson/emsdk/upstream/emscripten/system/local/include
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/SDL -mllvm
-combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm
-disable-lsr -o /tmp/emscripten_temp__jRzu7/sign_8.o -x c
c_src/crypto_sign/sphincs256/ref/sign.c
1.      <eof> parser at end of file
2.      Per-module optimization passes
3.      Running pass 'CallGraph Pass Manager' on module
'c_src/crypto_sign/sphincs256/ref/sign.c'.
4.      Running pass 'Loop Pass Manager' on function
'@crypto_sign_sphincs_open'
5.      Running pass 'Recognize loop idioms' on basic block '%for.body72'
 #0 0x00007f8fdb7f5bd4 PrintStackTraceSignalHandler(void*)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x6e7bd4)
 #1 0x00007f8fdb7f395e llvm::sys::RunSignalHandlers()
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x6e595e)
 #2 0x00007f8fdb7f5e88 SignalHandler(int)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x6e7e88)
 #3 0x00007f8fdb0f4730 __restore_rt
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12730)
 #4 0x00007f8fd7b5e7bb raise (/lib/x86_64-linux-gnu/libc.so.6+0x377bb)
 #5 0x00007f8fd7b49535 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22535)
 #6 0x00007f8fd7b4940f (/lib/x86_64-linux-gnu/libc.so.6+0x2240f)
 #7 0x00007f8fd7b57102 (/lib/x86_64-linux-gnu/libc.so.6+0x30102)
 #8 0x00007f8fdca0d51a
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x18ff51a)
 #9 0x00007f8fdc507961 (anonymous
namespace)::LoopIdiomRecognize::detectBCmpIdiom(llvm::ICmpInst*&,
llvm::CmpInst*&, llvm::LoadInst*&, llvm::LoadInst*&, llvm::SCEV const*&,
llvm::SCEV const*&, llvm::SCEV const*&) const
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x13f9961)
#10 0x00007f8fdc4fce6c (anonymous
namespace)::LoopIdiomRecognize::runOnNoncountableLoop()
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x13eee6c)
#11 0x00007f8fdc4f9d12 (anonymous
namespace)::LoopIdiomRecognizeLegacyPass::runOnLoop(llvm::Loop*,
llvm::LPPassManager&)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x13ebd12)
#12 0x00007f8fdc982c32 llvm::LPPassManager::runOnFunction(llvm::Function&)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x1874c32)
#13 0x00007f8fdb943b4c llvm::FPPassManager::runOnFunction(llvm::Function&)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x835b4c)
#14 0x00007f8fdc89af19 (anonymous
namespace)::CGPassManager::runOnModule(llvm::Module&)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x178cf19)
#15 0x00007f8fdb944590 llvm::legacy::PassManagerImpl::run(llvm::Module&)
(/home/gibson/emsdk/upstream/bin/../lib/libLLVM-10svn.so+0x836590)
#16 0x00007f8fd9497bca 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/gibson/emsdk/upstream/bin/../lib/libclang-cpp.so.10svn+0x148cbca)
#17 0x00007f8fd973d3b3
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&)
(/home/gibson/emsdk/upstream/bin/../lib/libclang-cpp.so.10svn+0x17323b3)
#18 0x00007f8fd8717e63 clang::ParseAST(clang::Sema&, bool, bool)
(/home/gibson/emsdk/upstream/bin/../lib/libclang-cpp.so.10svn+0x70ce63)
#19 0x00007f8fd9ecc5e8 clang::FrontendAction::Execute()
(/home/gibson/emsdk/upstream/bin/../lib/libclang-cpp.so.10svn+0x1ec15e8)
#20 0x00007f8fd9e73552
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&)
(/home/gibson/emsdk/upstream/bin/../lib/libclang-cpp.so.10svn+0x1e68552)
#21 0x00007f8fd9f37fbd
clang::ExecuteCompilerInvocation(clang::CompilerInstance*)
(/home/gibson/emsdk/upstream/bin/../lib/libclang-cpp.so.10svn+0x1f2cfbd)
#22 0x000000000041052f cc1_main(llvm::ArrayRef<char const*>, char const*,
void*) (/home/gibson/emsdk/upstream/bin/clang-10+0x41052f)
#23 0x000000000040ea65 main (/home/gibson/emsdk/upstream/bin/clang-10+0x40ea65)
#24 0x00007f8fd7b4b09b __libc_start_main
(/lib/x86_64-linux-gnu/libc.so.6+0x2409b)
#25 0x000000000040ba59 _start
(/home/gibson/emsdk/upstream/bin/clang-10+0x40ba59)
clang-10: error: unable to execute command: Aborted
clang-10: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 10.0.0
(/b/s/w/ir/cache/git/chromium.googlesource.com-external-github.com-llvm-llvm--project
4e71702cd4ab2c77aaa753770e99526085e5e6eb)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /home/gibson/emsdk/upstream/bin
clang-10: note: diagnostic msg: PLEASE submit a bug report to
<a href="https://bugs.llvm.org/">https://bugs.llvm.org/</a> and include the crash backtrace, preprocessed source,
and associated run script.
clang-10: note: diagnostic msg:
********************

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

********************
shared:ERROR: '/home/gibson/emsdk/upstream/bin/clang -target
wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=38
-D__EMSCRIPTEN_tiny__=43 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__
-Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/libcxx -Xclang
-isystem/home/gibson/emsdk/upstream/emscripten/system/lib/libcxxabi/include
-Xclang -isystem/home/gibson/emsdk/upstream/emscripten/system/include/compat
-Xclang -isystem/home/gibson/emsdk/upstream/emscripten/system/include -Xclang
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/libc -Xclang
-isystem/home/gibson/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten
-Xclang -isystem/home/gibson/emsdk/upstream/emscripten/system/local/include
-DEMSCRIPTEN -O3 -Ilibsodium/src/libsodium/include/sodium -Iopenssl/include
-Ic_src -Ic_src/include -Ic_src/crypto_stream/chacha12/e/ref -include
c_src/crypto_stream/chacha12/e/ref/namespace.h
c_src/crypto_sign/sphincs256/ref/sign.c -Xclang
-isystem/home/gibson/emsdk/upstream/emscripten/system/include/SDL -c -o
/tmp/emscripten_temp__jRzu7/sign_8.o -mllvm
-combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm
-disable-lsr' failed (254)
```

[sign-531d15.c.txt](<a href="https://github.com/emscripten-core/emscripten/files/3588279/sign-531d15.c.txt">https://github.com/emscripten-core/emscripten/files/3588279/sign-531d15.c.txt</a>)
[sign-531d15.sh.txt](<a href="https://github.com/emscripten-core/emscripten/files/3588280/sign-531d15.sh.txt">https://github.com/emscripten-core/emscripten/files/3588280/sign-531d15.sh.txt</a>)</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>