[llvm] Enable logf128 constant folding for hosts with 128bit long double (PR #96287)

Khem Raj via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 23 19:25:29 PDT 2024


kraj wrote:

@MDevereau sadly the relanded patch has caused regression while compiling gawk on aarch64, I am attaching the failing test file and script to run

```
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: /home/khem/llvm-project/build/bin/clang -DGAWK -DHAVE_CONFIG_H -I./.. -I. -I.. -g -O2 -DNDEBUG -DNDEBUG -g -O2 -DNDEBUG -DNDEBUG -MT pma.o -MD -MP -MF .deps/pma.Tpo -c -o pma.o pma.c
1.      <eof> parser at end of file
2.      Optimizer
3.      Running pass "require<globals-aa>,function(invalidate<aa>),require<profile-summary>,cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-idiom-vectorize,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split)),function(invalidate<should-not-run-function-passes>),cgscc(devirt<4>())" on module "pma.c"
4.      Running pass "cgscc(devirt<4>(inline,function-attrs<skip-non-recursive-function-attrs>,openmp-opt-cgscc,function<eager-inv;no-rerun>(sroa<modify-cfg>,early-cse<memssa>,speculative-execution<only-if-divergent-target>,jump-threading,correlated-propagation,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,aggressive-instcombine,libcalls-shrinkwrap,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,reassociate,constraint-elimination,loop-mssa(loop-instsimplify,loop-simplifycfg,licm<no-allowspeculation>,loop-rotate<header-duplication;no-prepare-for-lto>,licm<allowspeculation>,simple-loop-unswitch<no-nontrivial;trivial>),simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,loop(loop-idiom,indvars,simple-loop-unswitch<no-nontrivial;trivial>,loop-idiom-vectorize,loop-deletion,loop-unroll-full),sroa<modify-cfg>,vector-combine,mldst-motion<no-split-footer-bb>,gvn<>,sccp,bdce,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>,jump-threading,correlated-propagation,adce,memcpyopt,dse,move-auto-init,loop-mssa(licm<allowspeculation>),coro-elide,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;hoist-common-insts;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,instcombine<max-iterations=1;no-use-loop-info;no-verify-fixpoint>),function-attrs,function(require<should-not-run-function-passes>),coro-split))" on module "pma.c"
 #0 0x0000c71975749f44 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/khem/llvm-project/build/bin/clang+0x35d9f44)
 #1 0x0000c71975748450 llvm::sys::CleanupOnSignal(unsigned long) (/home/khem/llvm-project/build/bin/clang+0x35d8450)
 #2 0x0000c7197569cf18 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x0000e517c22828f8 (linux-vdso.so.1+0x8f8)
 #4 0x0000c7197487d08c (anonymous namespace)::ConstantFoldScalarCall1(llvm::StringRef, unsigned int, llvm::Type*, llvm::ArrayRef<llvm::Constant*>, llvm::TargetLibraryInfo const*, llvm::CallBase const*) (.isra.0) ConstantFolding.cpp:0:0
 #5 0x0000c719748d19ec (anonymous namespace)::CallAnalyzer::visitCallBase(llvm::CallBase&) InlineCost.cpp:0:0
 #6 0x0000c719748d40f4 (anonymous namespace)::CallAnalyzer::analyze() (.part.0) InlineCost.cpp:0:0
 #7 0x0000c719748d5acc llvm::getInlineCost(llvm::CallBase&, llvm::Function*, llvm::InlineParams const&, llvm::TargetTransformInfo&, llvm::function_ref<llvm::AssumptionCache& (llvm::Function&)>, llvm::function_ref<llvm::TargetLibraryInfo const& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*) (/home/khem/llvm-project/build/bin/clang+0x2765acc)
 #8 0x0000c719748d5e70 llvm::getInlineCost(llvm::CallBase&, llvm::InlineParams const&, llvm::TargetTransformInfo&, llvm::function_ref<llvm::AssumptionCache& (llvm::Function&)>, llvm::function_ref<llvm::TargetLibraryInfo const& (llvm::Function&)>, llvm::function_ref<llvm::BlockFrequencyInfo& (llvm::Function&)>, llvm::ProfileSummaryInfo*, llvm::OptimizationRemarkEmitter*) (/home/khem/llvm-project/build/bin/clang+0x2765e70)
 #9 0x0000c71978ece8e4 llvm::InlineCost llvm::function_ref<llvm::InlineCost (llvm::CallBase&)>::callback_fn<getDefaultInlineAdvice(llvm::CallBase&, llvm::AnalysisManager<llvm::Function>&, llvm::InlineParams const&)::'lambda2'(llvm::CallBase&)>(long, llvm::CallBase&) InlineAdvisor.cpp:0:0
#10 0x0000c71978ed38e0 llvm::shouldInline(llvm::CallBase&, llvm::function_ref<llvm::InlineCost (llvm::CallBase&)>, llvm::OptimizationRemarkEmitter&, bool) (/home/khem/llvm-project/build/bin/clang+0x6d638e0)
#11 0x0000c71978ed48f0 getDefaultInlineAdvice(llvm::CallBase&, llvm::AnalysisManager<llvm::Function>&, llvm::InlineParams const&) InlineAdvisor.cpp:0:0
#12 0x0000c71978ed4998 llvm::DefaultInlineAdvisor::getAdviceImpl(llvm::CallBase&) (/home/khem/llvm-project/build/bin/clang+0x6d64998)
#13 0x0000c71978ed1650 llvm::InlineAdvisor::getAdvice(llvm::CallBase&, bool) (/home/khem/llvm-project/build/bin/clang+0x6d61650)
#14 0x0000c71976a09bcc llvm::InlinerPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/khem/llvm-project/build/bin/clang+0x4899bcc)
#15 0x0000c71976861fdc llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::InlinerPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/khem/llvm-project/build/bin/clang+0x46f1fdc)
#16 0x0000c71974861424 llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/khem/llvm-project/build/bin/clang+0x26f1424)
#17 0x0000c7197685dd5c llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/khem/llvm-project/build/bin/clang+0x46edd5c)
#18 0x0000c71974867580 llvm::DevirtSCCRepeatedPass::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/khem/llvm-project/build/bin/clang+0x26f7580)
#19 0x0000c7197685ddbc llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::DevirtSCCRepeatedPass, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (/home/khem/llvm-project/build/bin/clang+0x46eddbc)
#20 0x0000c7197486323c llvm::ModuleToPostOrderCGSCCPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/khem/llvm-project/build/bin/clang+0x26f323c)
#21 0x0000c7197685dcfc llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/khem/llvm-project/build/bin/clang+0x46edcfc)
#22 0x0000c719751a4b7c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/khem/llvm-project/build/bin/clang+0x3034b7c)
#23 0x0000c71976a084e8 llvm::ModuleInlinerWrapperPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/khem/llvm-project/build/bin/clang+0x48984e8)
#24 0x0000c7197685d24c llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/khem/llvm-project/build/bin/clang+0x46ed24c)
#25 0x0000c719751a4b7c llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/home/khem/llvm-project/build/bin/clang+0x3034b7c)
#26 0x0000c719759911c0 (anonymous namespace)::EmitAssemblyHelper::RunOptimizationPipeline(clang::BackendAction, std::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>&, std::unique_ptr<llvm::ToolOutputFile, std::default_delete<llvm::ToolOutputFile>>&, clang::BackendConsumer*) BackendUtil.cpp:0:0
#27 0x0000c719759939e0 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::unique_ptr<llvm::raw_pwrite_stream, std::default_delete<llvm::raw_pwrite_stream>>, clang::BackendConsumer*) (/home/khem/llvm-project/build/bin/clang+0x38239e0)
#28 0x0000c71975ee4484 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/khem/llvm-project/build/bin/clang+0x3d74484)
#29 0x0000c7197764076c clang::ParseAST(clang::Sema&, bool, bool) (/home/khem/llvm-project/build/bin/clang+0x54d076c)
#30 0x0000c71976136ca0 clang::FrontendAction::Execute() (/home/khem/llvm-project/build/bin/clang+0x3fc6ca0)
#31 0x0000c719760c40f0 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/khem/llvm-project/build/bin/clang+0x3f540f0)
#32 0x0000c719761eed10 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/home/khem/llvm-project/build/bin/clang+0x407ed10)
#33 0x0000c7197301b9c0 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/khem/llvm-project/build/bin/clang+0xeab9c0)
#34 0x0000c71973015afc ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#35 0x0000c71975f26260 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
#36 0x0000c7197569d3c4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/home/khem/llvm-project/build/bin/clang+0x352d3c4)
#37 0x0000c71975f265ec 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
#38 0x0000c71975ef340c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/home/khem/llvm-project/build/bin/clang+0x3d8340c)
#39 0x0000c71975ef3c34 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/home/khem/llvm-project/build/bin/clang+0x3d83c34)
#40 0x0000c71975f03724 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/home/khem/llvm-project/build/bin/clang+0x3d93724)
#41 0x0000c719730189d4 clang_main(int, char**, llvm::ToolContext const&) (/home/khem/llvm-project/build/bin/clang+0xea89d4)
#42 0x0000c71972f43adc main (/home/khem/llvm-project/build/bin/clang+0xdd3adc)
#43 0x0000e517c1c773fc (/lib/aarch64-linux-gnu/libc.so.6+0x273fc)
#44 0x0000e517c1c774cc __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x274cc)
#45 0x0000c719730155b0 _start (/home/khem/llvm-project/build/bin/clang+0xea55b0)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
clang version 20.0.0git (git at github.com:kraj/llvm-project f67388232384682fb442d6e5501d9259c41fd714)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/khem/llvm-project/build/bin
```

[pma.zip](https://github.com/user-attachments/files/16734930/pma.zip)


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


More information about the llvm-commits mailing list