This is an archive of the discontinued LLVM Phabricator instance.

PowerPC/SPE: Add phony registers for high halves of SPE SuperRegs
ClosedPublic

Authored by long5hot on Jun 8 2023, 5:48 AM.

Details

Summary

The intent of this patch is to make upper halves of SPE SuperRegs(s0,..,s31)
as artificial regs, similar to how X86 has done it.
And emit store /reload instructions for the required halves.

PR : https://github.com/llvm/llvm-project/issues/57307

Diff Detail

Event Timeline

long5hot created this revision.Jun 8 2023, 5:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 5:48 AM
long5hot requested review of this revision.Jun 8 2023, 5:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 8 2023, 5:48 AM
long5hot edited the summary of this revision. (Show Details)Jun 8 2023, 5:49 AM

I love the goal of this, but it looks incomplete. I only noted on one, but it's probably the same for the other tests, that the change will end up clobbering the top half of registers without saving and restoring them.

llvm/test/CodeGen/PowerPC/fp-strict.ll
1612

This is wrong, because below it's evmergeloing into these registers, which clobbers the top half.

long5hot updated this revision to Diff 532626.Jun 19 2023, 6:16 AM
long5hot updated this revision to Diff 532635.Jun 19 2023, 6:42 AM
jhibbits accepted this revision.Jun 19 2023, 10:22 AM

Looks good to me, thanks!

This revision is now accepted and ready to land.Jun 19 2023, 10:22 AM

Looks good to me, thanks!

@jhibbits Can you please help to commit the changes??

Looks good to me, thanks!

@jhibbits Can you please help to commit the changes??

Name : Kishan Parmar
E-mail : kparmar2101@gmail.com

This revision was landed with ongoing or failed builds.Jun 21 2023, 3:24 AM
This revision was automatically updated to reflect the committed changes.

https://github.com/llvm/llvm-project/commit/c42f0a6e6476971974cb3f52c1138dbd8f9cca1f

The CI was failing because part of this wasn't clang-format-ed, but we don't signal that well so I don't blame you for missing it. See https://llvm.org/docs/Contributing.html#how-to-submit-a-patch for how to run it locally in future. For now I just ran it for you and updated the committed version.

Thanks for your contribution! If you are going to do more, consider getting commit access: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

arsenm added a subscriber: arsenm.Jun 21 2023, 3:52 AM
arsenm added inline comments.
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
2333

This looks like you're working around inaccurate CSR regmasks. You should try adjusting those instead

2338

Don't use reference to MCPhysReg

kosarev added inline comments.
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
2348–2349

Doesn't this invalidate the (implicit) iterators the for () loop above uses? Can we just do CSI[Idx] = CalleeSavedInfo(Lower); instead?

This seems to fail on CodeGen/PowerPC/spe.ll on builds with libc++'s consistency checks enabled, https://github.com/llvm/llvm-project/issues/68594.

******************** TEST 'LLVM :: CodeGen/PowerPC/spe.ll' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 2: /home/kosarev/labs/llvm-project/build/debug+expensive_checks/bin/llc -verify-machineinstrs < /home/kosarev/labs/llvm-project/llvm/test/CodeGen/PowerPC/spe.ll -mtriple=powerpc-unknown-linux-gnu           -mattr=+spe | /home/kosarev/labs/llvm-project/build/debug+expensive_checks/bin/FileCheck /home/kosarev/labs/llvm-project/llvm/test/CodeGen/PowerPC/spe.ll -check-prefixes=CHECK,SPE
+ /home/kosarev/labs/llvm-project/build/debug+expensive_checks/bin/llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu -mattr=+spe
+ /home/kosarev/labs/llvm-project/build/debug+expensive_checks/bin/FileCheck /home/kosarev/labs/llvm-project/llvm/test/CodeGen/PowerPC/spe.ll -check-prefixes=CHECK,SPE
/usr/include/c++/11/debug/safe_iterator.h:330:
In function:
    gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>& 
    gnu_debug::_Safe_iterator<_Iterator, _Sequence, _Category>::operator++() 
    [with _Iterator = gnu_cxx::normal_iterator<llvm::CalleeSavedInfo*, std::
    vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo> > >; 
    _Sequence = std::debug::vector<llvm::CalleeSavedInfo>; _Category = 
    std::forward_iterator_tag]

Error: attempt to increment a singular iterator.

Objects involved in the operation:
    iterator "this" @ 0x7ffec8d10870 {
      state = singular;
      references sequence @ 0x7ffec8d10b80
    }
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /home/kosarev/labs/llvm-project/build/debug+expensive_checks/bin/llc -verify-machineinstrs -mtriple=powerpc-unknown-linux-gnu -mattr=+spe
1.	Running pass 'Function Pass Manager' on module '<stdin>'.
2.	Running pass 'Prologue/Epilogue Insertion & Frame Finalization' on function '@test_fma'
 #0 0x00007f4576a916c8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/kosarev/labs/llvm-project/llvm/lib/Support/Unix/Signals.inc:723:22
 #1 0x00007f4576a91ae4 PrintStackTraceSignalHandler(void*) /home/kosarev/labs/llvm-project/llvm/lib/Support/Unix/Signals.inc:798:1
 #2 0x00007f4576a8ef29 llvm::sys::RunSignalHandlers() /home/kosarev/labs/llvm-project/llvm/lib/Support/Signals.cpp:105:20
 #3 0x00007f4576a90f60 SignalHandler(int) /home/kosarev/labs/llvm-project/llvm/lib/Support/Unix/Signals.inc:413:1
 #4 0x00007f4576316520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #5 0x00007f457636a9fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
 #6 0x00007f457636a9fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
 #7 0x00007f457636a9fc pthread_kill ./nptl/pthread_kill.c:89:10
 #8 0x00007f4576316476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
 #9 0x00007f45762fc7f3 abort ./stdlib/abort.c:81:7
#10 0x00007f45765a11fb std::__throw_bad_exception() (/lib/x86_64-linux-gnu/libstdc++.so.6+0xa51fb)
#11 0x00007f4580e2d6c3 __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<llvm::CalleeSavedInfo*, std::__cxx1998::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>>, std::__debug::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>, std::forward_iterator_tag>::operator++() /usr/include/c++/11/debug/safe_iterator.h:333:49
#12 0x00007f4580e2b8da __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<llvm::CalleeSavedInfo*, std::__cxx1998::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>>, std::__debug::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>, std::bidirectional_iterator_tag>::operator++() /usr/include/c++/11/debug/safe_iterator.h:588:10
#13 0x00007f4580e29b7e __gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<llvm::CalleeSavedInfo*, std::__cxx1998::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>>, std::__debug::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>, std::random_access_iterator_tag>::operator++() /usr/include/c++/11/debug/safe_iterator.h:743:10
#14 0x00007f4580e240d9 llvm::PPCFrameLowering::assignCalleeSavedSpillSlots(llvm::MachineFunction&, llvm::TargetRegisterInfo const*, std::__debug::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>&) const /home/kosarev/labs/llvm-project/llvm/lib/Target/PowerPC/PPCFrameLowering.cpp:2338:32
#15 0x00007f4580e2751c llvm::TargetFrameLowering::assignCalleeSavedSpillSlots(llvm::MachineFunction&, llvm::TargetRegisterInfo const*, std::__debug::vector<llvm::CalleeSavedInfo, std::allocator<llvm::CalleeSavedInfo>>&, unsigned int&, unsigned int&) const /home/kosarev/labs/llvm-project/llvm/include/llvm/CodeGen/TargetFrameLowering.h:164:3
#16 0x00007f457ae1d03a assignCalleeSavedSpillSlots(llvm::MachineFunction&, llvm::BitVector const&, unsigned int&, unsigned int&) /home/kosarev/labs/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp:474:7
#17 0x00007f457ae1e434 (anonymous namespace)::PEI::spillCalleeSavedRegs(llvm::MachineFunction&) /home/kosarev/labs/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp:686:24
#18 0x00007f457ae1bc5c (anonymous namespace)::PEI::runOnMachineFunction(llvm::MachineFunction&) /home/kosarev/labs/llvm-project/llvm/lib/CodeGen/PrologEpilogInserter.cpp:251:43
#19 0x00007f457ab2553c llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/kosarev/labs/llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:93:33
#20 0x00007f45771dd0e6 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/kosarev/labs/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1435:20
#21 0x00007f45771dd496 llvm::FPPassManager::runOnModule(llvm::Module&) /home/kosarev/labs/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1481:13
#22 0x00007f45771dd917 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/kosarev/labs/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1550:20
#23 0x00007f45771d836e llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/kosarev/labs/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:535:13
#24 0x00007f45771de261 llvm::legacy::PassManager::run(llvm::Module&) /home/kosarev/labs/llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1678:1
#25 0x0000555a168b68c8 compileModule(char**, llvm::LLVMContext&) /home/kosarev/labs/llvm-project/llvm/tools/llc/llc.cpp:757:66
#26 0x0000555a168b4117 main /home/kosarev/labs/llvm-project/llvm/tools/llc/llc.cpp:416:35
#27 0x00007f45762fdd90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#28 0x00007f45762fde40 call_init ./csu/../csu/libc-start.c:128:20
#29 0x00007f45762fde40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#30 0x0000555a168b2d65 _start (/home/kosarev/labs/llvm-project/build/debug+expensive_checks/bin/llc+0xfd65)
DavidSpickett added inline comments.Thu, Nov 30, 6:03 AM
llvm/lib/Target/PowerPC/PPCFrameLowering.cpp
2348–2349