[llvm] [LAA] Fix non-NFC parts of 1aded51 (PR #160701)

Mikael Holmen via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 26 11:42:48 PDT 2025


mikaelholmen wrote:

Hi again @artagnon

After some more testing we see that the following starts crashing with this patch and it still crashes on trunk (d48bda5421):
```clang -O2 -fwrapv bbi-110970.c -c```
Result:
```
clang: ../lib/Analysis/LoopAccessAnalysis.cpp:2212: MemoryDepChecker::Dependence::DepType llvm::MemoryDepChecker::isDependent(const MemAccessInfo &, unsigned int, const MemAccessInfo &, unsigned int): Assertion `HasSameSize && "Accesses must have the same size"' failed.
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: build-all/bin/clang -O2 -fwrapv bbi-110970.c -c
1.	<eof> parser at end of file
2.	Optimizer
3.	Running pass "function<eager-inv>(drop-unnecessary-assumes,float2int,lower-constant-intrinsics,loop(loop-rotate<header-duplication;no-prepare-for-lto>,loop-deletion),loop-distribute,inject-tli-mappings,loop-vectorize<no-interleave-forced-only;no-vectorize-forced-only;>,infer-alignment,loop-load-elim,instcombine<max-iterations=1;no-verify-fixpoint>,simplifycfg<bonus-inst-threshold=1;forward-switch-cond;switch-range-to-icmp;switch-to-lookup;no-keep-loops;hoist-common-insts;no-hoist-loads-stores-with-cond-faulting;sink-common-insts;speculate-blocks;simplify-cond-branch;no-speculate-unpredictables>,slp-vectorizer,vector-combine,instcombine<max-iterations=1;no-verify-fixpoint>,loop-unroll<O2>,transform-warning,sroa<preserve-cfg>,infer-alignment,instcombine<max-iterations=1;no-verify-fixpoint>,loop-mssa(licm<allowspeculation>),alignment-from-assumptions,loop-sink,instsimplify,div-rem-pairs,tailcallelim,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;hoist-loads-stores-with-cond-faulting;no-sink-common-insts;speculate-blocks;simplify-cond-branch;speculate-unpredictables>)" on module "bbi-110970.c"
4.	Running pass "loop-load-elim" on function "f1150"
 #0 0x000055806ec88ab6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (build-all/bin/clang+0x8d02ab6)
 #1 0x000055806ec86205 llvm::sys::RunSignalHandlers() (build-all/bin/clang+0x8d00205)
 #2 0x000055806ec87df4 llvm::sys::CleanupOnSignal(unsigned long) (build-all/bin/clang+0x8d01df4)
 #3 0x000055806ebe920d CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007f08c41da990 __restore_rt (/lib64/libpthread.so.0+0x12990)
 #5 0x00007f08c1b7a52f raise (/lib64/libc.so.6+0x4e52f)
 #6 0x00007f08c1b4de65 abort (/lib64/libc.so.6+0x21e65)
 #7 0x00007f08c1b4dd39 _nl_load_domain.cold.0 (/lib64/libc.so.6+0x21d39)
 #8 0x00007f08c1b72e86 (/lib64/libc.so.6+0x46e86)
 #9 0x000055806dcbecb1 llvm::MemoryDepChecker::isDependent(llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>> const&, unsigned int, llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>> const&, unsigned int) (build-all/bin/clang+0x7d38cb1)
#10 0x000055806dcbfabd llvm::MemoryDepChecker::areDepsSafe(llvm::EquivalenceClasses<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>> const&, llvm::SmallVector<llvm::PointerIntPair<llvm::Value*, 1u, bool, llvm::PointerLikeTypeTraits<llvm::Value*>, llvm::PointerIntPairInfo<llvm::Value*, 1u, llvm::PointerLikeTypeTraits<llvm::Value*>>>, 8u> const&) (build-all/bin/clang+0x7d39abd)
#11 0x000055806dcc3cd7 llvm::LoopAccessInfo::analyzeLoop(llvm::AAResults*, llvm::LoopInfo const*, llvm::TargetLibraryInfo const*, llvm::DominatorTree*) (build-all/bin/clang+0x7d3dcd7)
#12 0x000055806dcc6c39 llvm::LoopAccessInfo::LoopAccessInfo(llvm::Loop*, llvm::ScalarEvolution*, llvm::TargetTransformInfo const*, llvm::TargetLibraryInfo const*, llvm::AAResults*, llvm::DominatorTree*, llvm::LoopInfo*, llvm::AssumptionCache*, bool) (build-all/bin/clang+0x7d40c39)
#13 0x000055806dcc7512 llvm::LoopAccessInfoManager::getInfo(llvm::Loop&, bool) (build-all/bin/clang+0x7d41512)
#14 0x000055807027379e eliminateLoadsAcrossLoops(llvm::Function&, llvm::LoopInfo&, llvm::DominatorTree&, llvm::BlockFrequencyInfo*, llvm::ProfileSummaryInfo*, llvm::ScalarEvolution*, llvm::AssumptionCache*, llvm::LoopAccessInfoManager&) LoopLoadElimination.cpp:0:0
#15 0x0000558070272de8 llvm::LoopLoadEliminationPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/clang+0xa2ecde8)
#16 0x000055806fe93a1d llvm::detail::PassModel<llvm::Function, llvm::LoopLoadEliminationPass, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) PassBuilder.cpp:0:0
#17 0x000055806e64b475 llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (build-all/bin/clang+0x86c5475)
#18 0x000055806c3fb8ed llvm::detail::PassModel<llvm::Function, llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) AMDGPUTargetMachine.cpp:0:0
#19 0x000055806e64f3ce llvm::ModuleToFunctionPassAdaptor::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/clang+0x86c93ce)
#20 0x000055806c3fd05d llvm::detail::PassModel<llvm::Module, llvm::ModuleToFunctionPassAdaptor, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) AMDGPUTargetMachine.cpp:0:0
#21 0x000055806e64a475 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (build-all/bin/clang+0x86c4475)
#22 0x000055806f45816b (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
#23 0x000055806f44dea2 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*) (build-all/bin/clang+0x94c7ea2)
#24 0x000055806f464394 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (build-all/bin/clang+0x94de394)
#25 0x0000558070f59959 clang::ParseAST(clang::Sema&, bool, bool) (build-all/bin/clang+0xafd3959)
#26 0x000055806f9a0b84 clang::FrontendAction::Execute() (build-all/bin/clang+0x9a1ab84)
#27 0x000055806f90447d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (build-all/bin/clang+0x997e47d)
#28 0x000055806fab50ae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (build-all/bin/clang+0x9b2f0ae)
#29 0x000055806bfe43c8 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (build-all/bin/clang+0x605e3c8)
#30 0x000055806bfe04c3 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#31 0x000055806bfe2928 int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#32 0x000055806f76c7b9 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
#33 0x000055806ebe8e36 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (build-all/bin/clang+0x8c62e36)
#34 0x000055806f76bcc3 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (build-all/bin/clang+0x97e5cc3)
#35 0x000055806f729938 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (build-all/bin/clang+0x97a3938)
#36 0x000055806f729c57 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (build-all/bin/clang+0x97a3c57)
#37 0x000055806f743809 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (build-all/bin/clang+0x97bd809)
#38 0x000055806bfdfced clang_main(int, char**, llvm::ToolContext const&) (build-all/bin/clang+0x6059ced)
#39 0x000055806bff0286 main (build-all/bin/clang+0x606a286)
#40 0x00007f08c1b667e5 __libc_start_main (/lib64/libc.so.6+0x3a7e5)
#41 0x000055806bfdde6e _start (build-all/bin/clang+0x6057e6e)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 22.0.0git
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /repo/uabelho/main-github/llvm/build-all/bin
Build config: +assertions
```
[godbolt](https://llvm.godbolt.org/#g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,selection:(endColumn:2,endLineNumber:12,positionColumn:2,positionLineNumber:12,selectionStartColumn:2,selectionStartLineNumber:12,startColumn:2,startLineNumber:12),source:'int+b1150,+c1150,+a1150%5B8%5D%3B%0A%0Avoid+f1150(void)%0A%7B%0A++++for+(%3B+c1150%3B+%2B%2Bc1150)%0A++++%7B%0A++++++++if+(a1150%5Bc1150%5D)%0A++++++++%7B%0A++++++++++++a1150%5Bc1150%5D+%3D+b1150%3B%0A++++++++%7D%0A++++%7D%0A%7D'),l:'5',n:'0',o:'C+source+%231',t:'0'),(h:compiler,i:(compiler:cclang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:___c,libs:!(),options:'-O2+-fwrapv',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0'),(h:output,i:(compilerName:'x86-64+clang+(assertions+trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%231)',t:'0')),k:100,l:'4',m:100,n:'0',o:'',s:0,t:'0')),version:4)

[bbi-110970.c.gz](https://github.com/user-attachments/files/22566455/bbi-110970.c.gz)


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


More information about the llvm-commits mailing list