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

James Molloy via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 2 05:13:07 PST 2015


jmolloy added a comment.

Hi guys,

Thanks for all the swift feedback. I have proposed adding a new "norecurse" function attribute in http://reviews.llvm.org/D14227, and uploaded a patch to FunctionAttrs to populate it in http://reviews.llvm.org/D14228. This patch now depends on those.

David, I agree the "main" hack is indeed a hack. The new "norecurse" attribute allows us to completely remove it as you say by teaching Clang to emit it during codegen for main() in C++ mode. I'll do that in a followup patch when the new attribute is committed and the dust has settled, if that's OK?

Mehdi, I've taken hopefully all your comments on board with this new version. One thing to comment on though:

> So you moved this optimization a after all the previous one (like TryToShrinkGlobalToBoolean, OptimizeOnceStoredGlobal, ...), why?


I mentioned this in the description above, but basically it's because demoting globals to locals is less of a powerful optimization than deleting them outright (or shrinking them). With this patch global demotion triggers more often, so if we're not careful we could demote a global to a local that could have been deleted instead. That's why I changed the ordering.

James


Repository:
  rL LLVM

http://reviews.llvm.org/D14148





More information about the llvm-commits mailing list