[llvm] [DAG] Add legalization handling for ABDS/ABDU (PR #92576)

via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 7 08:16:48 PDT 2024


bgra8 wrote:

@RKSimon this patch is enters an infinite loop while compiling a `CC` that only takes 2.5s to compile with the previous version.

Here's 2 stack samples at 3 different moments:

T1:
```
#0  0x000055555c5e96d5 in (anonymous namespace)::SelectionDAGLegalize::ExpandNode(llvm::SDNode*) ()
#1  0x000055555c5e45d2 in (anonymous namespace)::SelectionDAGLegalize::LegalizeOp(llvm::SDNode*) ()
#2  0x000055555c5e3c07 in llvm::SelectionDAG::Legalize() ()
#3  0x000055555c6a0bdc in llvm::SelectionDAGISel::CodeGenAndEmitDAG() ()
#4  0x000055555c69f744 in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) ()
#5  0x000055555c69e0c8 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
#6  0x000055555c69c9e1 in llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) ()
#7  0x000055555c37924f in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()
#8  0x000055555d6d88f2 in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
#9  0x000055555d6df424 in llvm::FPPassManager::runOnModule(llvm::Module&) ()
#10 0x000055555d6d9165 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
#11 0x0000555558ad3a64 in 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::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream> >, clang::BackendConsumer*) ()
#12 0x00005555587a44f7 in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) ()
#13 0x0000555559602cf9 in clang::ParseAST(clang::Sema&, bool, bool) ()
#14 0x000055555936925a in clang::FrontendAction::Execute() ()
#15 0x00005555592e06a4 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
#16 0x000055555846b35f in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) ()
#17 0x00005555584606b6 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) ()
#18 0x000055555845d3e6 in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) ()
#19 0x000055555845c1cb in clang_main(int, char**, llvm::ToolContext const&) ()
#20 0x000055555845ae34 in main ()
```

T2:
```
#0  0x000055555c604f04 in llvm::SelectionDAG::DeleteNode(llvm::SDNode*) ()
#1  0x000055555c5e3baf in llvm::SelectionDAG::Legalize() ()
#2  0x000055555c6a0bdc in llvm::SelectionDAGISel::CodeGenAndEmitDAG() ()
#3  0x000055555c69f744 in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) ()
#4  0x000055555c69e0c8 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
#5  0x000055555c69c9e1 in llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) ()
#6  0x000055555c37924f in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()
#7  0x000055555d6d88f2 in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
#8  0x000055555d6df424 in llvm::FPPassManager::runOnModule(llvm::Module&) ()
#9  0x000055555d6d9165 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
#10 0x0000555558ad3a64 in 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::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream> >, clang::BackendConsumer*) ()
#11 0x00005555587a44f7 in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) ()
#12 0x0000555559602cf9 in clang::ParseAST(clang::Sema&, bool, bool) ()
#13 0x000055555936925a in clang::FrontendAction::Execute() ()
#14 0x00005555592e06a4 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
#15 0x000055555846b35f in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) ()
#16 0x00005555584606b6 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) ()
#17 0x000055555845d3e6 in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) ()
#18 0x000055555845c1cb in clang_main(int, char**, llvm::ToolContext const&) ()
#19 0x000055555845ae34 in main ()
```

T3:
```
#0  0x000055555d8d018b in llvm::SmallPtrSetImplBase::insert_imp_big(void const*) ()
#1  0x000055555c5e3bf3 in llvm::SelectionDAG::Legalize() ()
#2  0x000055555c6a0bdc in llvm::SelectionDAGISel::CodeGenAndEmitDAG() ()
#3  0x000055555c69f744 in llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) ()
#4  0x000055555c69e0c8 in llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) ()
#5  0x000055555c69c9e1 in llvm::SelectionDAGISelLegacy::runOnMachineFunction(llvm::MachineFunction&) ()
#6  0x000055555c37924f in llvm::MachineFunctionPass::runOnFunction(llvm::Function&) ()
#7  0x000055555d6d88f2 in llvm::FPPassManager::runOnFunction(llvm::Function&) ()
#8  0x000055555d6df424 in llvm::FPPassManager::runOnModule(llvm::Module&) ()
#9  0x000055555d6d9165 in llvm::legacy::PassManagerImpl::run(llvm::Module&) ()
#10 0x0000555558ad3a64 in 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::__u::unique_ptr<llvm::raw_pwrite_stream, std::__u::default_delete<llvm::raw_pwrite_stream> >, clang::BackendConsumer*) ()
#11 0x00005555587a44f7 in clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) ()
#12 0x0000555559602cf9 in clang::ParseAST(clang::Sema&, bool, bool) ()
#13 0x000055555936925a in clang::FrontendAction::Execute() ()
#14 0x00005555592e06a4 in clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) ()
#15 0x000055555846b35f in clang::ExecuteCompilerInvocation(clang::CompilerInstance*) ()
#16 0x00005555584606b6 in cc1_main(llvm::ArrayRef<char const*>, char const*, void*) ()
#17 0x000055555845d3e6 in ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) ()
#18 0x000055555845c1cb in clang_main(int, char**, llvm::ToolContext const&) ()
#19 0x000055555845ae34 in main ()
```

The compilation never finishes (waited more than 15min).

I see you're also investigating a crash. Can you please revert while we work for a reproducer? 

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


More information about the llvm-commits mailing list