Help: Windows: lli crashes on 32 arch but not on 64 arch

Hello LLVM list

I am running with lli, a simple HelloWorld program twice, once targeted to 32 bits arch, the other targeted to 64 bit arch. While it is working fine with the 64 arch, it craches with the 32 arch. Below are the steps

clang.cmd -v -g -m64 -emit-llvm -S hw.c -o hw-m64.ll

clang.cmd -v -g -m32 -emit-llvm -S hw.c -o hw-m32.ll

C:\Program Files (x86)\LLVM\11.0\bin"\clang -v -g -m32 -emit-llvm -S e.c -o e-m32.ll
clang version 11.0.0
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files (x86)\LLVM\11.0\bin
(in-process)
“C:\Program Files (x86)\LLVM\11.0\bin\clang.exe” -cc1 -triple i686-pc-windows-msvc19.28.29335 -emit-llvm -disable-free -disable-llvm-verifier -discard-value-names -main-file-name e.c -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu pentium4 -gno-column-info -gcodeview -debug-info-kind=limited -v -resource-dir “C:\Program Files (x86)\LLVM\11.0\lib\clang\11.0.0” -internal-isystem “C:\Program Files (x86)\LLVM\11.0\lib\clang\11.0.0\include” -internal-isystem “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include” -internal-isystem “C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\atlmfc\include” -internal-isystem “C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt” -internal-isystem “C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared” -internal-isystem “C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um” -internal-isystem “C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt” -fdebug-compilation-dir “D:\projects\as400\rpg\clang” -ferror-limit 19 -fmessage-length=194 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.28.29335 -fdelayed-template-parsing -fcolor-diagnostics -faddrsig -o e-m32.ll -x c e.c
clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default target i686-pc-windows-msvc
#include “…” search starts here:
#include <…> search starts here:
C:\Program Files (x86)\LLVM\11.0\lib\clang\11.0.0\include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\atlmfc\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.18362.0\ucrt
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um
C:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt
End of search list.

lli hw-m64.ll

Hello World!

lli hw-m32.ll

PLEASE submit a bug report to and include the crash backtrace. Stack dump: 0. Program arguments: D:\llvm-project\build32\Debug\bin\lli hw-m32.ll #0 0x04b8eacc #1 0x03ff017b #2 0x03ff032b #3 0x0153ca18 llvm::MCJIT::runFunction(class llvm::Function *, class llvm::ArrayRef) D:\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:587:0 #4 0x01459673 llvm::ExecutionEngine::runFunctionAsMain(class llvm::Function *, class std::vector<class std::basic_string<char, struct std::char_traits, class std::allocator>, class std::allocator<class std::basic_string<char, struct std::char_traits, class std::allocator>>> const &, char const *const *) D:\llvm-project\llvm\lib\ExecutionEngine\ExecutionEngine.cpp:467:0 #5 0x007e08c5 main D:\llvm-project\llvm\tools\lli\lli.cpp:643:0 #6 0x02e12013 invoke_main d:\agent_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0 #7 0x02e11e97 _scrt_common_main_seh d:\agent_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0 #8 0x02e11d2d _scrt_common_main d:\agent_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0 #9 0x02e12098 mainCRTStartup d:\agent_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0 #10 0x75336359 (C:\WINDOWS\System32\KERNEL32.DLL+0x16359) #11 0x774c8944 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68944) #12 0x774c8914 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68914)

What is the best way to debug the 32 bit arch lli.exe under VS2019?

D:\projects\clang>type hw.c
#include <stdio.h>
int main() {
printf(“Hello World!\n”);
return 0;
}

Try setting the target triple for lli to i686-pc-windows-elf. The COFF backend for MCJIT is not complete, but ELF typically works