[PATCH] D42600: [CodeGen][Shrink-wrap]split restore point

Alan Zhao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 10 10:52:10 PDT 2023


ayzhao added a comment.

In D42600#4329528 <https://reviews.llvm.org/D42600#4329528>, @sushgokh wrote:

> In D42600#4327970 <https://reviews.llvm.org/D42600#4327970>, @ayzhao wrote:
>
>> This is causing lld to crash on Chrome builds when PGO and ThinLTO are enabled: https://crbug.com/1443635
>
> @ayzhao I request you to please provide me following information:
>
> 1. Reproducer of the function causing the assert failure

F27396851: patternprops.o.5.precodegen.ll <https://reviews.llvm.org/F27396851>

  ~/src/llvm-project/build/bin/llc patternprops.o.5.precodegen.ll
  llc: /usr/local/google/home/ayzhao/src/llvm-project/llvm/lib/CodeGen/ShrinkWrap.cpp:666: bool (anonymous namespace)::ShrinkWrap::postShrinkWrapping(bool, llvm::MachineFunction &, llvm::RegScavenger *): Assertion `(!MLI->getLoopFor(Save) && !MLI->getLoopFor(Restore)) && "Unexpected save or restore point in a loop"' failed.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
  Stack dump:
  0.      Program arguments: /usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc patternprops.o.5.precodegen.ll
  1.      Running pass 'Function Pass Manager' on module 'patternprops.o.5.precodegen.ll'.
  2.      Running pass 'Shrink Wrapping analysis' on function '@_ZN6icu_7212PatternProps14trimWhiteSpaceEPKDsRi'
   #0 0x0000563786318bd7 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x1e44bd7)
   #1 0x0000563786316a8e llvm::sys::RunSignalHandlers() (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x1e42a8e)
   #2 0x00005637863193ba SignalHandler(int) Signals.cpp:0:0
   #3 0x00007fafd965af90 (/lib/x86_64-linux-gnu/libc.so.6+0x3bf90)
   #4 0x00007fafd96a9ccc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
   #5 0x00007fafd965aef2 raise ./signal/../sysdeps/posix/raise.c:27:6
   #6 0x00007fafd9645472 abort ./stdlib/abort.c:81:7
   #7 0x00007fafd9645395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
   #8 0x00007fafd9653df2 (/lib/x86_64-linux-gnu/libc.so.6+0x34df2)
   #9 0x000056378598fbbf (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x14bbbbf)
  #10 0x00005637857517bc llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x127d7bc)
  #11 0x0000563785c6bcb3 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x1797cb3)
  #12 0x0000563785c73e11 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x179fe11)
  #13 0x0000563785c6c6cc llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x17986cc)
  #14 0x0000563784a8ad89 main (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x5b6d89)
  #15 0x00007fafd964618a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
  #16 0x00007fafd9646245 call_init ./csu/../csu/libc-start.c:128:20
  #17 0x00007fafd9646245 __libc_start_main ./csu/../csu/libc-start.c:368:5
  #18 0x0000563784a857b1 _start (/usr/local/google/home/ayzhao/src/llvm-project/build/bin/llc+0x5b17b1)
  [1]    2041024 IOT instruction  ~/src/llvm-project/build/bin/llc patternprops.o.5.precodegen.ll



> 2. llc -print-before=shrink-wrap   for the function

F27396888: print-before-shrink-wrap-stderr.txt <https://reviews.llvm.org/F27396888>

F27396887: print-before-shrink-wrap-stdout.txt <https://reviews.llvm.org/F27396887>

> 3. llc -debug-only=shrink-wrap     for function

F27396920: debug-only-shrink-wrap-stderr.txt <https://reviews.llvm.org/F27396920>

F27396919: debug-only-shrink-wrap-stdout.txt <https://reviews.llvm.org/F27396919>

> Also, I request to check if the following patch works since I suspect that PGO is changing the block frequencies:
>
>   --- a/llvm/lib/CodeGen/ShrinkWrap.cpp
>   +++ b/llvm/lib/CodeGen/ShrinkWrap.cpp
>   @@ -632,7 +632,8 @@ bool ShrinkWrap::postShrinkWrapping(bool HasCandidate, MachineFunction &MF,
>          FindIDom<>(**DirtyPreds.begin(), DirtyPreds, *MDT, false);
>   
>      while (NewSave && (hasDirtyPred(ReachableByDirty, *NewSave) ||
>   -                     EntryFreq < MBFI->getBlockFreq(NewSave).getFrequency()))
>   +                     EntryFreq < MBFI->getBlockFreq(NewSave).getFrequency() ||
>   +                     MLI->getLoopFor(NewSave)))
>        NewSave = FindIDom<>(**NewSave->pred_begin(), NewSave->predecessors(), *MDT,
>                             false);

That seems to work:

  $ ~/src/llvm-project/build/bin/llc patternprops.o.5.precodegen.ll
  
  $ echo $?
  0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D42600



More information about the llvm-commits mailing list