Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashed when lowering memcpy through MLIR #1018

Open
PikachuHyA opened this issue Oct 29, 2024 · 0 comments
Open

crashed when lowering memcpy through MLIR #1018

PikachuHyA opened this issue Oct 29, 2024 · 0 comments
Assignees

Comments

@PikachuHyA
Copy link
Contributor

test case from clang/test/CIR/CodeGen/libc.c

void *memcpy(void *, const void *, unsigned long);
void testMemcpy(void *src, const void *dst, unsigned long size) {
  memcpy(dst, src, size);
 }

test with clang -c libc.c -fclangir -Xclang -emit-mlir -o libc.mlir -fno-clangir-direct-lowering

test2.c:3:10: warning: passing 'const void *' to parameter of type 'void *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers]
    3 |   memcpy(dst, src, size);
      |          ^~~
test2.c:1:20: note: passing argument to parameter here
    1 | void *memcpy(void *, const void *, unsigned long);
      |                    ^
loc(fused["test2.c":2:1, "test2.c":5:2]): error: failed to legalize operation 'cir.func' that was explicitly marked illegal
fatal error: error in backend: The pass manager failed to lower CIR to LLVMIR dialect!
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: clang -c test2.c -fclangir -Xclang -emit-mlir -o test.mlir -fno-clangir-direct-lowering
1.	<eof> parser at end of file
 #0 0x00000000046259c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (clang+0x46259c8)
 #1 0x00000000046234be llvm::sys::RunSignalHandlers() (clang+0x46234be)
 #2 0x0000000004624d59 llvm::sys::CleanupOnSignal(unsigned long) (clang+0x4624d59)
 #3 0x0000000004595067 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) CrashRecoveryContext.cpp:0:0
 #4 0x0000000004594fff llvm::CrashRecoveryContext::HandleExit(int) (clang+0x4594fff)
 #5 0x000000000461f9f7 llvm::sys::Process::Exit(int, bool) (clang+0x461f9f7)
 #6 0x0000000003380be6 (clang+0x3380be6)
 #7 0x000000000459b7c6 llvm::report_fatal_error(llvm::Twine const&, bool) (clang+0x459b7c6)
 #8 0x000000000459b6a6 (clang+0x459b6a6)
 #9 0x0000000005be09e6 cir::lowerFromCIRToMLIR(mlir::ModuleOp, mlir::MLIRContext*) (clang+0x5be09e6)
#10 0x0000000005b653e8 cir::CIRGenConsumer::HandleTranslationUnit(clang::ASTContext&) CIRGenAction.cpp:0:0
#11 0x0000000007f11799 clang::ParseAST(clang::Sema&, bool, bool) (clang+0x7f11799)
#12 0x00000000052ea00f clang::FrontendAction::Execute() (clang+0x52ea00f)
#13 0x000000000525a82d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (clang+0x525a82d)
#14 0x00000000053d542e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (clang+0x53d542e)
#15 0x000000000338078b cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (clang+0x338078b)
#16 0x000000000337cd6e ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#17 0x00000000050b0d59 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::$_0>(long) Job.cpp:0:0
#18 0x0000000004594f96 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (clang+0x4594f96)
#19 0x00000000050b0422 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (clang+0x50b0422)
#20 0x000000000506d31c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (clang+0x506d31c)
#21 0x000000000506d627 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (clang+0x506d627)
#22 0x000000000508a758 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (clang+0x508a758)
#23 0x000000000337c3af clang_main(int, char**, llvm::ToolContext const&) (clang+0x337c3af)
#24 0x000000000338c577 main (clang+0x338c577)
#25 0x00007f61b622e192 __libc_start_main (/lib64/libc.so.6+0x28192)
#26 0x000000000337a9ae _start (clang+0x337a9ae)
bcardosolopes pushed a commit that referenced this issue Oct 31, 2024
due to the issue described in
#1018,
the MLIR lowering for `memmove` has been excluded in this patch.
lanza pushed a commit that referenced this issue Nov 5, 2024
due to the issue described in
#1018,
the MLIR lowering for `memmove` has been excluded in this patch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant