[all-commits] [llvm/llvm-project] af1dd0: [Reduce] Basic block reduction: do properly handle...

Roman Lebedev via All-commits all-commits at lists.llvm.org
Sat Jul 25 15:32:30 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: af1dd0b1adc40e62bd922673af3741ad66989eee
      https://github.com/llvm/llvm-project/commit/af1dd0b1adc40e62bd922673af3741ad66989eee
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-07-26 (Sun, 26 Jul 2020)

  Changed paths:
    A llvm/test/Reduce/remove-bbs-unwinded-to.ll
    M llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp

  Log Message:
  -----------
  [Reduce] Basic block reduction: do properly handle invoke insts (PR46818)

Terminator may have returned value, so we need to replace uses,
and in general handle invoke as a branch inst.

I'm not sure this is the best handling, but IMO poorly reduced
input is much better than crashing reduction tool.
A (previously-crashing!) test added.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46818


  Commit: 9932d74740b19030f12b82ae93a9e61af32f5931
      https://github.com/llvm/llvm-project/commit/9932d74740b19030f12b82ae93a9e61af32f5931
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-07-26 (Sun, 26 Jul 2020)

  Changed paths:
    A llvm/test/Reduce/remove-invoked-functions.ll
    M llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp

  Log Message:
  -----------
  [Reduce] Argument reduction: do properly handle invoke insts (PR46819)

replaceFunctionCalls() is very non-exhaustive, it only handles
CallInst's. Which means, by the time we drop old function,
there may still be uses of it lurking around.
Let's instead whack-a-mole them by all by replacing with undef.

I'm not sure this is the best handling, especially for calls, but IMO
poorly reduced input is much better than crashing reduction tool.
A (previously-crashing!) test added.

Fixes https://bugs.llvm.org/show_bug.cgi?id=46819


  Commit: 96d74530c09edd95452295bb4e300ab310a9bb2d
      https://github.com/llvm/llvm-project/commit/96d74530c09edd95452295bb4e300ab310a9bb2d
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-07-26 (Sun, 26 Jul 2020)

  Changed paths:
    M llvm/lib/Transforms/Utils/CloneFunction.cpp
    R llvm/test/Reduce/Inputs/remove-multiple-use-of-args-in-same-instruction.py
    R llvm/test/Reduce/Inputs/remove-multiple-use-of-global-vars-in-same-instruction.py
    A llvm/test/Reduce/remove-args-from-declaration.ll
    M llvm/test/Reduce/remove-multiple-use-of-args-in-same-instruction.ll
    M llvm/test/Reduce/remove-multiple-use-of-global-vars-in-same-instruction.ll
    M llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp

  Log Message:
  -----------
  [Reduce] Argument reduction: do deal with function declarations

We can happily turn function definitions into declarations,
thus obscuring their argument from being elided by this pass.

I don't believe there is a good reason to just ignore declarations.
likely even proper llvm intrinsics ones,
at worst the input becomes uninteresting.

The other question here is that all these transforms are all-or-nothing.
In some cases, should we be treating each use separately?

The main blocker here seemed to be that llvm::CloneFunctionInto()
does `&OldFunc->front()`, which inserts a nullptr into a densemap,
which is not happy about it and asserts.


Compare: https://github.com/llvm/llvm-project/compare/a01c4ee71cb2...96d74530c09e


More information about the All-commits mailing list