[PATCH] D87474: Ensure that we don't update Uses after MarkLive

Aaron Hill via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 10 11:36:01 PDT 2020


Aaron1011 created this revision.
Aaron1011 added a reviewer: chandlerc.
Aaron1011 added a project: LLVM.
Herald added subscribers: llvm-commits, hiraditya.
Aaron1011 requested review of this revision.

  Fixes bug #47444
  
  Previously, we would call MarkValue for each RetOrArg, either calling
  MarkLive or inserting dependencies into Uses. However, this can cause us
  to end up calling MarkLive for a RetOrArg, and then later inserting
  additional dependencies into Uses. As a result, the liveness propagation
  during MarkLive will miss some dependencies, causing us to incorrectly
  see a RetOrArg as dead.
  
  I've fixed this by replacing MarkValue with a new function MarkValues,
  which takes in a vector of RetOrArgs to inspect. It works in two passes
  - we first insert all dependencies into Uses, and then call MarkLive for
  any live values. This ensures that liveness is correctly propagated to
  all dependencies.
  
  To ensure that this type of issue doesn't occur again, I've added an
  assertion to verify that we don't try to insert dependencies into Uses
  for a value that has been already marked live.
  
  I've included a minimized version of the IR from bug #47444 as a test
  case. Without this pass, return value #1 is incorrectly removed from
  the function 'g'.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87474

Files:
  llvm/include/llvm/Transforms/IPO/DeadArgumentElimination.h
  llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
  llvm/test/Transforms/DeadArgElim/preserve-used-ret.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87474.291039.patch
Type: text/x-patch
Size: 7153 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200910/2c99bb9d/attachment.bin>


More information about the llvm-commits mailing list