[all-commits] [llvm/llvm-project] b440a4: llvm-reduce: Add values to return reduction

Matt Arsenault via All-commits all-commits at lists.llvm.org
Mon Mar 24 00:35:11 PDT 2025


  Branch: refs/heads/users/arsenm/llvm-reduce/add-reduce-values-to-return-reduction
  Home:   https://github.com/llvm/llvm-project
  Commit: b440a43f7ab59b301db5b465661678e8fcbafbae
      https://github.com/llvm/llvm-project/commit/b440a43f7ab59b301db5b465661678e8fcbafbae
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-03-24 (Mon, 24 Mar 2025)

  Changed paths:
    M llvm/include/llvm/IR/Function.h
    M llvm/lib/IR/Function.cpp
    M llvm/test/tools/llvm-reduce/reduce-operands-fp.ll
    M llvm/test/tools/llvm-reduce/reduce-operands-int.ll
    M llvm/test/tools/llvm-reduce/reduce-operands-ptr.ll
    A llvm/test/tools/llvm-reduce/reduce-values-to-return.ll
    M llvm/tools/llvm-reduce/CMakeLists.txt
    M llvm/tools/llvm-reduce/DeltaManager.cpp
    A llvm/tools/llvm-reduce/deltas/ReduceValuesToReturn.cpp
    A llvm/tools/llvm-reduce/deltas/ReduceValuesToReturn.h

  Log Message:
  -----------
  llvm-reduce: Add values to return reduction

In void functions, try to replace instruction uses
with a new non-void return. If the return type matches
the instruction, also try to directly return it.

This handles most of the cases, but doesn't try to handle
all of the weird exception related terminators.

Also doesn't try to replace argument uses, although it could. We
could also handle cases where we can insert a simple cast to an
original return value. I didn't think too hard about where to put this
in the default pass order. In many cases it obviates the need for most
of the CFG folds, but I've left it near the end initially.

I also think this is too aggressive about removing dead code, and
should leave existing dead code alone. I'm also not sure why we have
both "removeUnreachableBlocks" and EliminateUnreachableBlocks" in Utils.

Fixes #66039, fixes #107327



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