<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63164>63164</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang wasm32 regression when compiling c
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          TerrorJack
      </td>
    </tr>
</table>

<pre>
    Minimal repro:

```c
double ldexp() { int r = ldexp(0, 0); }
```

Command to compile:

```sh
$ clang --target=wasm32-wasi -c repro.c -o repro.o
```

Error message:

```
repro.c:1:39: warning: non-void function does not return a value [-Wreturn-type]
    1 | double ldexp() { int r = ldexp(0, 0); }
      |                                       ^
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17 -cc1 -triple wasm32-unknown-wasi -emit-obj -mrelax-all -dumpdir a- -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name repro.c -mrelocation-model static -mframe-pointer=none -ffp-contract=on -fno-rounding-math -mconstructor-aliases -target-cpu generic -fvisibility=hidden -debugger-tuning=gdb -fcoverage-compilation-dir=/workspace/ghc-wasm32-wasi -resource-dir /workspace/wasi-sdk/build/install/opt/wasi-sdk/lib/clang/17 -isysroot /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/../share/wasi-sysroot -internal-isystem /workspace/wasi-sdk/build/install/opt/wasi-sdk/lib/clang/17/include -internal-isystem /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/../share/wasi-sysroot/include/wasm32-wasi -internal-isystem /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/../share/wasi-sysroot/include -fdebug-compilation-dir=/workspace/ghc-wasm32-wasi -ferror-limit 19 -fgnuc-version=4.2.1 -fcolor-diagnostics -o /tmp/tmp.N3YVQHMdmG/repro-8a5cc1.o -x c repro.c
1.      <eof> parser at end of file
2.      Code generation
3.      Running pass 'Function Pass Manager' on module 'repro.c'.
4.      Running pass 'WebAssembly Assembly Printer' on function '@ldexp'
 #0 0x000055f1b97c9f84 PrintStackTraceSignalHandler(void*) (.llvm.7538583815639773279) Signals.cpp:0:0
 #1 0x000055f1b97c7ade llvm::sys::RunSignalHandlers() (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x1e1fade)
 #2 0x000055f1b97caa18 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f5163c634b0 (/lib/x86_64-linux-gnu/libc.so.6+0x3c4b0)
 #4 0x000055f1b8a7384f llvm::WebAssemblyAsmPrinter::getOrCreateWasmSymbol(llvm::StringRef) WebAssemblyAsmPrinter.cpp:0:0
 #5 0x000055f1b8a73e5f llvm::WebAssemblyAsmPrinter::emitDecls(llvm::Module const&) WebAssemblyAsmPrinter.cpp:0:0
 #6 0x000055f1ba72e2f6 llvm::AsmPrinter::emitFunctionHeader() (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x2d862f6)
 #7 0x000055f1ba72fb6d llvm::AsmPrinter::emitFunctionBody() (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x2d87b6d)
 #8 0x000055f1b8a7749b llvm::WebAssemblyAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) WebAssemblyAsmPrinter.cpp:0:0
 #9 0x000055f1b8e5177a llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x14a977a)
#10 0x000055f1b92fdb36 llvm::FPPassManager::runOnFunction(llvm::Function&) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x1955b36)
#11 0x000055f1b93067e3 llvm::FPPassManager::runOnModule(llvm::Module&) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x195e7e3)
#12 0x000055f1b92fe74a llvm::legacy::PassManagerImpl::run(llvm::Module&) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x195674a)
#13 0x000055f1b9feb7aa clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions const&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::StringRef, llvm::Module*, clang::BackendAction, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x26437aa)
#14 0x000055f1ba56e06f clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) CodeGenAction.cpp:0:0
#15 0x000055f1bbe0a446 clang::ParseAST(clang::Sema&, bool, bool) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x4462446)
#16 0x000055f1ba472db7 clang::FrontendAction::Execute() (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x2acadb7)
#17 0x000055f1ba3cc224 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x2a24224)
#18 0x000055f1ba567b02 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x2bbfb02)
#19 0x000055f1b8a64e6a cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x10bce6a)
#20 0x000055f1b8a61c71 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x000055f1b8a6031b clang_main(int, char**, llvm::ToolContext const&) (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x10b831b)
#22 0x000055f1b8a72d51 main (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x10cad51)
#23 0x00007f5163c4aa90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#24 0x00007f5163c4ab49 call_init ./csu/../csu/libc-start.c:128:20
#25 0x00007f5163c4ab49 __libc_start_main ./csu/../csu/libc-start.c:347:5
#26 0x000055f1b8a3fc25 _start (/workspace/wasi-sdk/build/install/opt/wasi-sdk/bin/clang-17+0x1097c25)
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 17.0.0 (git@gitlab.haskell.org:ghc/llvm-project.git 51792bfc6068a887bebfd6d12730b92fe622f9d7)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /workspace/wasi-sdk/build/install/opt/wasi-sdk/bin
clang: note: diagnostic msg: 
********************

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

********************
```

Upstream llvm revision: https://github.com/llvm/llvm-project/commit/d19a3834dce5f9e8c84835ea14e8b434e8aa5fa7
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzEWVtz4ygW_jXkhZJLAt38kAfHibt7q3uS7WSma59SCI5kJhJ4AeXy77cQ8kUe93RmOtlJJbEs4Jzv3IHDrJWNAjhH2QXKLs9Y79banN-BMdr8i_GHs0qLl_MvUsmOtdjAxmhEFyi-RPH2fx6HXx6-C91XLeBWwPMGkRKROUbFBZbKYYMRvdyNxIgscYzIHNELjIrLI3KHPJa665gS2GnMdbeRLXwPhF2PL0iKectUg6PIMdOAQ_TyidmOkuiJWYkjHqSZcRzp8VH_CYQrrxHcgbWs-S738HWki-giQXRB54gu8BMzSqrGPyqtokctBa57xZ3UCgsNFivtsAHXG4UZfmRtDxhlF9G38C5yLxtA2agkjDFOMCqW-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