[all-commits] [llvm/llvm-project] 650eeb: [ShrinkWrap] Modify shrink wrapping to accommodate...

Nathan Corbyn via All-commits all-commits at lists.llvm.org
Thu Nov 27 02:17:48 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 650eeb867fa95435b7c123e6630eb98934ac5bf3
      https://github.com/llvm/llvm-project/commit/650eeb867fa95435b7c123e6630eb98934ac5bf3
  Author: Nathan Corbyn <n_corbyn at apple.com>
  Date:   2025-11-27 (Thu, 27 Nov 2025)

  Changed paths:
    M llvm/include/llvm/CodeGen/MachineBasicBlock.h
    M llvm/lib/CodeGen/ShrinkWrap.cpp
    M llvm/test/CodeGen/AArch64/arm64-shrink-wrapping.ll

  Log Message:
  -----------
  [ShrinkWrap] Modify shrink wrapping to accommodate functions terminated by no-return blocks (#167548)

At present, the shrink wrapping pass misses opportunities to shrink wrap
in the presence of machine basic blocks which exit the function without
returning. Such cases arise from C++ functions like the following:
```cxx
int foo(int err, void* ptr) {
    if (err == -1) {
         if (ptr == nullptr) {
             throw MyException("Received `nullptr`!", __FILE__, __LINE__);
         }
         
         handle(ptr);
    }
    
    return STATUS_OK;
}
```
In particular, assuming `MyException`'s constructor is not marked
`noexcept`, the above code will generate a trivial EH landing pad
calling `__cxa_free_exception()` and rethrowing the unhandled internal
exception, exiting the function without returning. As such, the shrink
wrapping pass refuses to touch the above function, spilling to the stack
on every call, even though no CSRs are clobbered on the hot path. This
patch tweaks the shrink wrapping logic to enable the pass to fire in
this and similar cases.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list