[PATCH] D14148: [GlobalOpt] Demote globals to locals more aggressively

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 16 02:39:40 PST 2015


jmolloy added a comment.

Hi All,

I just want to apologize - after rereading the phab comments here I realize that I actually mistook Mehdi's LGTM on http://reviews.llvm.org/D14228 for this review when looking at my backlog, so I committed it before it was fully approved.

To reply to Mehdi's comment specifically:

> If the function does not recurse and is the only user of the global, why do we need isPointerValueDeadOnEntryToFunction?


Consider this:

  static int g = 0;
  int f() {
    printf("%d\n", g++);
  }

``g`` can obviously not be localized, and ``f`` does not recurse. However, each invocation of ``f`` depends on the previous invocation because ``g`` is read before being written. The "isPointerValueDeadOnEntry" function is there to ensure the function is idempotent with respect to the given global.

James


Repository:
  rL LLVM

http://reviews.llvm.org/D14148





More information about the llvm-commits mailing list