[all-commits] [llvm/llvm-project] 655a70: Reapply [MemCpyOpt] Make capture check during call...

Nikita Popov via All-commits all-commits at lists.llvm.org
Thu Jan 20 00:30:47 PST 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 655a7024dbbc65ac2e3867094157746905cfd3a3
      https://github.com/llvm/llvm-project/commit/655a7024dbbc65ac2e3867094157746905cfd3a3
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-01-20 (Thu, 20 Jan 2022)

  Changed paths:
    M llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
    M llvm/test/Transforms/MemCpyOpt/capturing-func.ll

  Log Message:
  -----------
  Reapply [MemCpyOpt] Make capture check during call slot optimization more precise

This is a recommit of the patch without changes. The reason for
the revert has been addressed in D117679.

-----

Call slot optimization is currently supposed to be prevented if
the call can capture the source pointer. Due to an implementation
bug, this check currently doesn't trigger if a bitcast of the source
pointer is passed instead. I'm somewhat afraid of the fallout of
fixing this bug (due to heavy reliance on call slot optimization
in rust), so I'd like to strengthen the capture reasoning a bit first.

In particular, I believe that the capture is fine as long as a)
the call itself cannot depend on the pointer identity, because
neither dest has been captured before/at nor src before the
call and b) there is no potential use of the captured pointer
before the lifetime of the source alloca ends, either due to
lifetime.end or a return from a function. At that point the
potentially captured pointer becomes dangling.

Differential Revision: https://reviews.llvm.org/D115615


  Commit: 0d20407d1ac58a5c97fd354aaef86d5da888d2e1
      https://github.com/llvm/llvm-project/commit/0d20407d1ac58a5c97fd354aaef86d5da888d2e1
  Author: Nikita Popov <npopov at redhat.com>
  Date:   2022-01-20 (Thu, 20 Jan 2022)

  Changed paths:
    M llvm/lib/Transforms/Scalar/MemCpyOptimizer.cpp
    M llvm/test/Transforms/MemCpyOpt/callslot.ll
    M llvm/test/Transforms/MemCpyOpt/capturing-func.ll

  Log Message:
  -----------
  Reapply [MemCpyOpt] Look through pointer casts when checking capture

This is a recommit of the patch without changes. The reason for
the revert has been addressed in D117679.

-----

The user scanning loop above looks through pointer casts, so we
also need to strip pointer casts in the capture check. Previously
the source was incorrectly considered not captured if a bitcast
was passed to the call.


Compare: https://github.com/llvm/llvm-project/compare/baa08d1ec3e2...0d20407d1ac5


More information about the All-commits mailing list