[all-commits] [llvm/llvm-project] e09055: [ArgPromotion] Delay dead GEP removal until doProm...

Florian Hahn via All-commits all-commits at lists.llvm.org
Mon Jan 4 02:17:18 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e0905553b424afe94938e2cc010fcecd0822eaba
      https://github.com/llvm/llvm-project/commit/e0905553b424afe94938e2cc010fcecd0822eaba
  Author: Florian Hahn <flo at fhahn.com>
  Date:   2021-01-04 (Mon, 04 Jan 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
    A llvm/test/Transforms/ArgumentPromotion/dead-gep-no-promotion.ll

  Log Message:
  -----------
  [ArgPromotion] Delay dead GEP removal until doPromotion.

Currently ArgPromotion removes dead GEPs as part of the legality check
in isSafeToPromoteArgument. If no promotion happens, this means the pass
claims no modifications happened, even though GEPs were removed.

This patch fixes the issue by delaying removal of dead GEPs until
doPromotion: isSafeToPromoteArgument can simply skips dead GEPs and
the code in doPromotion dealing with GEPs is updated to account for
dead GEPs. Once we committed to promotion, it should be safe to
remove dead GEPs.

Alternatively isSafeToPromoteArgument could return an additional boolean
to indicate whether it made changes, but this is quite cumbersome and
there should be no real benefit of weeding out some dead GEPs here if we
do not perform promotion.

I added a test for the case where dead GEPs need to be removed when
promotion happens in 578c5a0c6e71.

Fixes PR47477.

Reviewed By: jdoerfert

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




More information about the All-commits mailing list