[PATCH] D70376: [LVI] Restructure caching

Teresa Johnson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 12:32:35 PDT 2020


tejohnson added a comment.

In D70376#2148200 <https://reviews.llvm.org/D70376#2148200>, @nikic wrote:

> In D70376#2148174 <https://reviews.llvm.org/D70376#2148174>, @tejohnson wrote:
>
> > It looks like I may not be able to share the obfuscated IR for this particular test case. I'll try to look for something else that demonstrates a compile time increase from the patch. But in any case, really any code that invokes LazyValueInfoCache::eraseValue on a whole lot of values in a function with a large number of BBs is going to suffer with a compile time increase from the change to the data structures. Here's the hot call path to it in my test case:
> >
> > llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function> >::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
> >  llvm::SimplifyCFGPass::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&)
> >  simplifyFunctionCFG(llvm::Function&, llvm::TargetTransformInfo const&, llvm::SimplifyCFGOptions const&)
> >  llvm::removeUnreachableBlocks(llvm::Function&, llvm::DomTreeUpdater*, llvm::MemorySSAUpdater*)
> >  llvm::BasicBlock::eraseFromParent()
> >  llvm::BasicBlock::~BasicBlock()     
> >  llvm::Value::deleteValue()               
> >  llvm::Instruction::~Instruction()                          
> >  llvm::ValueHandleBase::ValueIsDeleted(llvm::Value*)
> >  (anonymous namespace)::LVIValueHandle::deleted()
> >
> > I think this is after JumpThreading, which presumably created all these simplify opportunities.
>
>
> This looks fishy. LazyValueInfo should not be alive when SimplifyCFG gets run. SimplifyCFG does not depend on it, or preserve it.
>
> Do you use the legacy PM or new PM?


This is with the newPM. I couldn't repro it with the old PM, but I assumed it was because PGO based inlining is different. But maybe it is related to where LVI is alive in the new PM.

BTW, that call path was with a release built compiler. Here is the stack trace in a debug opt where I am reproducing it (it was running for well over an hour when I attached via gdb). The BlockCache contains 322648 entries.

#0  0x0000000000cc11e1 in llvm::DenseMapInfo<llvm::Value*>::isEqual (LHS=0x54370218, RHS=0x4699a400)

  at llvm/include/llvm/ADT/DenseMapInfo.h:82

#1  0x000000000284416d in llvm::DenseMapBase<llvm::SmallDenseMap<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement, 4u, llvm::DenseMapInfo<llvm::AssertingVH<llvm::Value> >, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement> >, llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement, llvm::DenseMapInfo<llvm::AssertingVH<llvm::Value> >, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement> >::LookupBucketFor<llvm::AssertingVH<llvm::Value> > (this=0x4699a400, Val=..., FoundBucket=@0x7ffdaf052cc0: 0x3ad127a0)

  at llvm/include/llvm/ADT/DenseMap.h:622

#2  0x0000000002843fd5 in llvm::DenseMapBase<llvm::SmallDenseMap<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement, 4u, llvm::DenseMapInfo<llvm::AssertingVH<llvm::Value> >, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement> >, llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement, llvm::DenseMapInfo<llvm::AssertingVH<llvm::Value> >, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement> >::LookupBucketFor<llvm::AssertingVH<llvm::Value> > (this=0x4699a400, Val=..., FoundBucket=@0x7ffdaf052d20: 0x7ffdaf052d40)

  at llvm/include/llvm/ADT/DenseMap.h:662

#3  0x0000000002843e28 in llvm::DenseMapBase<llvm::SmallDenseMap<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement, 4u, llvm::DenseMapInfo<llvm::AssertingVH<llvm::Value> >, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement> >, llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement, llvm::DenseMapInfo<llvm::AssertingVH<llvm::Value> >, llvm::detail::DenseMapPair<llvm::AssertingVH<llvm::Value>, llvm::ValueLatticeElement> >::erase (this=0x4699a400, Val=...)

  at llvm/include/llvm/ADT/DenseMap.h:304

#4  0x0000000002835c62 in (anonymous namespace)::LazyValueInfoCache::eraseValue (this=0xd79b990, V=0x3ad127a0)

  at llvm/lib/Analysis/LazyValueInfo.cpp:245

#5  0x0000000002835b7c in (anonymous namespace)::LVIValueHandle::deleted (this=0x7f1e9496e478)

  at llvm/lib/Analysis/LazyValueInfo.cpp:257

#6  0x000000000344c7c6 in llvm::ValueHandleBase::ValueIsDeleted (V=0x3ad127a0)

  at llvm/lib/IR/Value.cpp:987

#7  0x000000000344c41c in llvm::Value::~Value (this=0x3ad127a0)

  at llvm/lib/IR/Value.cpp:76

#8  0x000000000290d308 in llvm::User::~User (this=0x3ad127a0)

  at llvm/include/llvm/IR/User.h:94

#9  0x0000000003354800 in llvm::Instruction::~Instruction (this=0x3ad127a0)

  at llvm/lib/IR/Instruction.cpp:61

#10 0x0000000003453dc8 in llvm::UnaryInstruction::~UnaryInstruction (this=0x3ad127a0)

  at llvm/include/llvm/IR/InstrTypes.h:57

#11 0x0000000003452688 in llvm::LoadInst::~LoadInst (this=0x3ad127a0)

  at llvm/include/llvm/IR/Instructions.h:173

#12 0x000000000344d27d in llvm::Value::deleteValue (this=0x3ad127a0)

  at llvm/include/llvm/IR/Instruction.def:172

#13 0x00000000030988b8 in llvm::ilist_alloc_traits<llvm::Instruction>::deleteNode (V=0x3ad127a0)

  at llvm/include/llvm/IR/Instruction.h:829

#14 0x0000000003098885 in llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>, llvm::SymbolTableListTraits<llvm::Instruction> >::erase (this=0x3ad124e8, where=...) at llvm/include/llvm/ADT/ilist.h:268
#15 0x00000000030986db in llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>, llvm::SymbolTableListTraits<llvm::Instruction> >::erase (this=0x3ad124e8, first=..., last=...)

  at llvm/include/llvm/ADT/ilist.h:305

#16 0x000000000320d014 in llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>, llvm::SymbolTableListTraits<llvm::Instruction> >::clear (this=0x3ad124e8) at llvm/include/llvm/ADT/ilist.h:309
#17 0x000000000320a7fd in llvm::BasicBlock::~BasicBlock (this=0x3ad124c0)

  at llvm/lib/IR/BasicBlock.cpp:90

#18 0x000000000320e837 in llvm::ilist_alloc_traits<llvm::BasicBlock>::deleteNode (V=0x3ad124c0)

  at llvm/include/llvm/ADT/ilist.h:41

#19 0x000000000320d575 in llvm::iplist_impl<llvm::simple_ilist<llvm::BasicBlock>, llvm::SymbolTableListTraits<llvm::BasicBlock> >::erase (this=0x91ad8e0, where=...) at llvm/include/llvm/ADT/ilist.h:268
#20 0x000000000320ad3c in llvm::BasicBlock::eraseFromParent (this=0x3ad124c0)

  at llvm/lib/IR/BasicBlock.cpp:128

#21 0x0000000003fd4b72 in llvm::removeUnreachableBlocks (F=..., DTU=0x0, MSSAU=0x0)

  at llvm/lib/Transforms/Utils/Local.cpp:2325

#22 0x0000000003d597c7 in simplifyFunctionCFG (F=..., TTI=..., Options=...)

  at llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:191

#23 0x0000000003d59736 in llvm::SimplifyCFGPass::run (this=0xc68ea28, F=..., AM=...)

  at llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp:237

#24 0x000000000422e645 in llvm::detail::PassModel<llvm::Function, llvm::SimplifyCFGPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (this=0xc68ea20, IR=..., AM=...)

  at llvm/include/llvm/IR/PassManagerInternal.h:79

#25 0x00000000034118e2 in llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>>::run(llvm::Function&, llvm::AnalysisManager<llvm::Function>&) (this=0x92a7a48, IR=..., AM=...)

  at llvm/include/llvm/IR/PassManager.h:520

#26 0x0000000004240fb8 in llvm::CGSCCToFunctionPassAdaptor<llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>> >::run(llvm::LazyCallGraph::SCC&, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>&, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&) (this=0x92a7a48, C=..., AM=..., CG=..., UR=...)

  at llvm/include/llvm/Analysis/CGSCCPassManager.h:506

#27 0x0000000004240ce5 in llvm::detail::PassModel<llvm::LazyCallGraph::SCC, llvm::CGSCCToFunctionPassAdaptor<llvm::PassManager<llvm::Function, llvm::AnalysisManager<llvm::Function>> >, llvm::PreservedAnalyses, 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&) (this=0x92a7a40, IR=...,

  AM=..., ExtraArgs=..., ExtraArgs=...)
  at llvm/include/llvm/IR/PassManagerInternal.h:79

#28 0x0000000002721019 in llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&>::run (this=0xd03b248, InitialC=..., AM=..., G=..., UR=...)

  at llvm/lib/Analysis/CGSCCPassManager.cpp:87

#29 0x00000000035e2f46 in llvm::DevirtSCCRepeatedPass<llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&> >::run (this=0xd03b248,

  InitialC=..., AM=..., CG=..., UR=...)
  at llvm/include/llvm/Analysis/CGSCCPassManager.h:635

#30 0x00000000035e2887 in llvm::ModuleToPostOrderCGSCCPassAdaptor<llvm::DevirtSCCRepeatedPass<llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&> > >::run (this=0xd03b248, M=..., AM=...)

  at llvm/include/llvm/Analysis/CGSCCPassManager.h:898

#31 0x00000000035e1ff5 in llvm::detail::PassModel<llvm::Module, llvm::ModuleToPostOrderCGSCCPassAdaptor<llvm::DevirtSCCRepeatedPass<llvm::PassManager<llvm::LazyCallGraph::SCC, llvm::AnalysisManager<llvm::LazyCallGraph::SCC, llvm::LazyCallGraph&>, llvm::LazyCallGraph&, llvm::CGSCCUpdateResult&> > >, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0xd03b240, IR=..., AM=...)

  at llvm/include/llvm/IR/PassManagerInternal.h:79

#32 0x0000000003410a4c in llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x92a1cd0, IR=..., AM=...)

  at llvm/include/llvm/IR/PassManager.h:520

#33 0x00000000035d04b6 in llvm::ModuleInlinerWrapperPass::run (this=0x92a1c68, M=..., MAM=...)

  at llvm/lib/Transforms/IPO/Inliner.cpp:1070

#34 0x00000000042417d5 in llvm::detail::PassModel<llvm::Module, llvm::ModuleInlinerWrapperPass, llvm::PreservedAnalyses, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (this=0x92a1c60, IR=..., AM=...)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D70376/new/

https://reviews.llvm.org/D70376





More information about the llvm-commits mailing list