[llvm] [mlir] Verify threadlocal_address constraints (PR #87841)

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 9 10:34:26 PDT 2024


sbc100 wrote:

This seems to have caused a regression when integrating into emscripten today: https://logs.chromium.org/logs/emscripten-releases/buildbucket/cr-buildbucket/8751138098141239841/+/u/Build_Emscripten/stdout


When I run locally I get this:

```
llvm.threadlocal.address operand isThreadLocal() must no be false
in function __clock
fatal error: error in backend: Broken function found, compilation aborted!
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: /usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang -target wasm32-unknown-emscripten -fignore-exceptions -fvisibility=default -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --sysroot=/usr/local/google/home/sbc/dev/wasm/emscripten/cache/sysroot -Werror=implicit-function-declaration -Xclang -iwithsysroot/include/fakesdl -Xclang -iwithsysroot/include/compat -c -O2 -Wall -fno-unroll-loops -std=c99 -D_XOPEN_SOURCE=700 -Wno-unused-result -Os -fno-inline-functions -fno-builtin -Wno-ignored-attributes -Wno-macro-redefined -Wno-shift-op-parentheses -Wno-string-plus-int -Wno-missing-braces -Wno-logical-op-parentheses -Wno-bitwise-op-parentheses -Wno-unused-but-set-variable -Wno-unused-variable -Wno-unused-label -Wno-pointer-sign -g3 -Werror -I/usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc/musl/src/internal -I/usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc/musl/src/include -I/usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc/musl/include -I/usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc -I/usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/pthread /usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc/emscripten_time.c -o /usr/local/google/home/sbc/dev/wasm/emscripten/cache/build/libc-debug-tmp/emscripten_time.o
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '/usr/local/google/home/sbc/dev/wasm/emscripten/system/lib/libc/emscripten_time.c'.
4.	Running pass 'Module Verifier' on function '@__clock'
 #0 0x00007fc0c998a188 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x18a188)
 #1 0x00007fc0c9987dfe llvm::sys::RunSignalHandlers() (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x187dfe)
 #2 0x00007fc0c9989561 llvm::sys::CleanupOnSignal(unsigned long) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x189561)
 #3 0x00007fc0c98c6557 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #4 0x00007fc0c98c64ef llvm::CrashRecoveryContext::HandleExit(int) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0xc64ef)
 #5 0x00007fc0c9984ad7 llvm::sys::Process::Exit(int, bool) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0x184ad7)
 #6 0x00005571d7549a53 (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang+0x10a53)
 #7 0x00007fc0c98d87fc llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0xd87fc)
 #8 0x00007fc0c98d86e6 (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0xd86e6)
 #9 0x00007fc0c9f443f0 void llvm::VerifierSupport::WriteTs<llvm::Instruction*, llvm::MDNode const*>(llvm::Instruction* const&, llvm::MDNode const* const&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMCore.so.19.0git+0x3443f0)
#10 0x00007fc0c9e95a5a llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMCore.so.19.0git+0x295a5a)
#11 0x00007fc0c9e9de62 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMCore.so.19.0git+0x29de62)
#12 0x00007fc0c9e9654f llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMCore.so.19.0git+0x29654f)
#13 0x00007fc0cdee6ad9 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::__2::unique_ptr<llvm::raw_pwrite_stream, std::__2::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangCodeGen.so.19.0git+0xe6ad9)
#14 0x00007fc0ce33a934 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangCodeGen.so.19.0git+0x53a934)
#15 0x00007fc0c78f3179 clang::ParseAST(clang::Sema&, bool, bool) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/../lib/libclangParse.so.19.0git+0x38179)
#16 0x00007fc0cc54620f clang::FrontendAction::Execute() (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangFrontend.so.19.0git+0x14620f)
#17 0x00007fc0cc4af7ad clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangFrontend.so.19.0git+0xaf7ad)
#18 0x00007fc0cf8776d0 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangFrontendTool.so.19.0git+0x46d0)
#19 0x00005571d7549648 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang+0x10648)
#20 0x00005571d754637b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x00007fc0cc0d2349 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__2::optional<llvm::StringRef>>, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>*, bool*) const::$_0>(long) Job.cpp:0:0
#22 0x00007fc0c98c6486 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libLLVMSupport.so.19.0git+0xc6486)
#23 0x00007fc0cc0d1992 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__2::optional<llvm::StringRef>>, std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>*, bool*) const (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangDriver.so.19.0git+0xd1992)
#24 0x00007fc0cc08992c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangDriver.so.19.0git+0x8992c)
#25 0x00007fc0cc089c1e clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*>>&, bool) const (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangDriver.so.19.0git+0x89c1e)
#26 0x00007fc0cc0ad62f clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__2::pair<int, clang::driver::Command const*>>&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/../lib/libclangDriver.so.19.0git+0xad62f)
#27 0x00005571d7545660 clang_main(int, char**, llvm::ToolContext const&) (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang+0xc660)
#28 0x00005571d75542f7 main (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang+0x1b2f7)
#29 0x00007fc0ca8456ca __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#30 0x00007fc0ca845785 call_init ./csu/../csu/libc-start.c:128:20
#31 0x00007fc0ca845785 __libc_start_main ./csu/../csu/libc-start.c:347:5
#32 0x00005571d7543b6a _start (/usr/local/google/home/sbc/dev/wasm/llvm-build/bin/clang+0xab6a)
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 19.0.0git (https://github.com/sbc100/llvm-project 4a812b5912d3149592cae195c9007b05649d9b41)
Target: wasm32-unknown-emscripten
Thread model: posix
InstalledDir: /usr/local/google/home/sbc/dev/wasm/llvm-build/bin
Build config: +assertions
clang: note: diagnostic msg: 
********************
```

See: 
The source being compiled is https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/emscripten_time.c

https://github.com/llvm/llvm-project/pull/87841


More information about the llvm-commits mailing list