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

Matt Arsenault via All-commits all-commits at lists.llvm.org
Mon Mar 24 22:55:27 PDT 2025


  Branch: refs/heads/users/arsenm/llvm-reduce/add-reduce-values-to-return-reduction
  Home:   https://github.com/llvm/llvm-project
  Commit: c43fa0f99d9524b6ffb867000f273a495b233ae3
      https://github.com/llvm/llvm-project/commit/c43fa0f99d9524b6ffb867000f273a495b233ae3
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-03-25 (Tue, 25 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


  Commit: c658ad37b4014d24dca04d91691f5ed642c6c575
      https://github.com/llvm/llvm-project/commit/c658ad37b4014d24dca04d91691f5ed642c6c575
  Author: Matt Arsenault <Matthew.Arsenault at amd.com>
  Date:   2025-03-25 (Tue, 25 Mar 2025)

  Changed paths:
    A llvm/test/tools/llvm-reduce/reduce-values-to-return-nonvoid-noncallee-use.ll
    M llvm/tools/llvm-reduce/deltas/ReduceValuesToReturn.cpp

  Log Message:
  -----------
  Fix non-void return typed non-callee uses


Compare: https://github.com/llvm/llvm-project/compare/d9602fc79b4f...c658ad37b401

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