Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

WASM crash when using __funcref #140933

Copy link
Copy link
Open
Open
Copy link
@glingy

Description

@glingy
Issue body actions

I'm attempting to instantiate a call_indirect to a specific table, and I believe this is the correct construct, but I am getting a clang crash.

typedef void (*__funcref fn)(void);
extern "C" fn table[1];

void foo() { table[1](); }

Reproduction on Godbolt here: https://godbolt.org/z/c3nc59MWz

Backtrace:

fatal error: error in backend: Cannot select: 0x19f4fbc8: funcref,ch = load<(load (s0) from `ptr getelementptr inbounds ([1 x ptr addrspace(20)], ptr @table, i32 0, i32 1)`)> 0x19f16670, 0x19f4fa60, undef:i32, example.cpp:4:14
  0x19f4fa60: i32 = add nuw 0x19f4fd30, Constant:i32<1>, example.cpp:4:14
    0x19f4fd30: i32 = WebAssemblyISD::Wrapper TargetGlobalAddress:i32<ptr @table> 0, example.cpp:4:14
      0x19f4fad8: i32 = TargetGlobalAddress<ptr @table> 0, example.cpp:4:14
    0x19f4f9e8: i32 = Constant<1>
  0x19f4fb50: i32 = undef
In function: _Z3foov
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: /opt/compiler-explorer/clang-trunk/bin/clang++ -g -o /app/output.s -fno-verbose-asm -S -target wasm32 -fcolor-diagnostics -fno-crash-diagnostics <source>
1.	<eof> parser at end of file
2.	Code generation
3.	Running pass 'Function Pass Manager' on module '<source>'.
4.	Running pass 'WebAssembly Instruction Selection' on function '@_Z3foov'
 #0 0x0000000003c65448 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c65448)
 #1 0x0000000003c6358c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c6358c)
 #2 0x0000000003bb4273 llvm::CrashRecoveryContext::HandleExit(int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bb4273)
 #3 0x0000000003c5b09e llvm::sys::Process::Exit(int, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c5b09e)
 #4 0x0000000000dbd4fb LLVMErrorHandler(void*, char const*, bool) cc1_main.cpp:0:0
 #5 0x0000000003bbe0a3 llvm::report_fatal_error(llvm::Twine const&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bbe0a3)
 #6 0x000000000521c288 llvm::SelectionDAGISel::CannotYetSelect(llvm::SDNode*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x521c288)
 #7 0x00000000052225f9 llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52225f9)
 #8 0x00000000025cf86f (anonymous namespace)::WebAssemblyDAGToDAGISel::Select(llvm::SDNode*) WebAssemblyISelDAGToDAG.cpp:0:0
 #9 0x0000000005219774 llvm::SelectionDAGISel::DoInstructionSelection() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5219774)
#10 0x0000000005228272 llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x5228272)
#11 0x000000000522abea llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x522abea)
#12 0x000000000522cac6 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x522cac6)
#13 0x00000000052192f1 llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x52192f1)
#14 0x000000000305c428 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (.part.0) MachineFunctionPass.cpp:0:0
#15 0x00000000035d1d92 llvm::FPPassManager::runOnFunction(llvm::Function&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35d1d92)
#16 0x00000000035d2021 llvm::FPPassManager::runOnModule(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35d2021)
#17 0x00000000035d3989 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x35d3989)
#18 0x0000000003f170cd clang::emitBackendOutput(clang::CompilerInstance&, clang::CodeGenOptions&, 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>>, clang::BackendConsumer*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3f170cd)
#19 0x00000000045ae945 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45ae945)
#20 0x00000000061fe3ac clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61fe3ac)
#21 0x00000000045af4fd clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45af4fd)
#22 0x00000000048bf53a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48bf53a)
#23 0x000000000483c22b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x483c22b)
#24 0x00000000049b5293 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x49b5293)
#25 0x0000000000dbf432 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdbf432)
#26 0x0000000000db6d8d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x0000000004621c59 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x0000000003bb4173 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3bb4173)
#29 0x0000000004621e79 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x00000000045e4c7d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45e4c7d)
#31 0x00000000045e5c41 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45e5c41)
#32 0x00000000045f041c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45f041c)
#33 0x0000000000dbb981 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdbb981)
#34 0x0000000000c3caf4 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc3caf4)
#35 0x00007f9bad229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007f9bad229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000db6825 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdb6825)
clang++: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Compiler returned: 70

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.