Go to file
James Molloy 9c7d4d8855 [GlobalOpt] Demote globals to locals more aggressively
Global to local demotion can speed up programs that use globals a lot. It is particularly useful with LTO, when the entire call graph is known and most functions have been internalized.

For a global to be demoted, it must only be accessed by one function and that function:
  1. Must never recurse directly or indirectly, else the GV would be clobbered.
  2. Must never rely on the value in GV at the start of the function (apart from the initializer).

GlobalOpt can already do this, but it is hamstrung and only ever tries to demote globals inside "main", because C++ gives extra guarantees about how main is called - once and only once.

In LTO mode, we can often prove the first property (if the function is internal by this point, we know enough about the callgraph to determine if it could possibly recurse). FunctionAttrs now infers the "norecurse" attribute for this reason.

The second property can be proven for a subset of functions by proving that all loads from GV are dominated by a store to GV. This is conservative in the name of compile time - this only requires a DominatorTree which is fairly cheap in the grand scheme of things. We could do more fancy stuff with MemoryDependenceAnalysis too to catch more cases but this appears to catch most of the useful ones in my testing.

llvm-svn: 253168
2015-11-15 14:21:37 +00:00
clang [libclang] Visit TypeAliasTemplateDecl 2015-11-15 13:48:32 +00:00
clang-tools-extra [clang-tidy] Remove unused #includes. 2015-11-13 12:16:10 +00:00
compiler-rt Reverting r253080 ([tsan] Don't demangle names not starting with "_Z"). 2015-11-14 10:42:08 +00:00
debuginfo-tests New round of fixes for "Always compile debuginfo-tests for the host triple" 2014-10-18 23:47:59 +00:00
libclc integer: remove explicit casts from _MIN definitions 2015-10-06 19:12:12 +00:00
libcxx Implement P0074: Making owner_less more flexible 2015-11-12 15:56:44 +00:00
libcxxabi Fix LIBCXXABI_HAS_NO_THREADS configuration. 2015-10-14 19:21:38 +00:00
libunwind Make it possible to use libunwind without heap. 2015-11-09 06:57:29 +00:00
lld [ELF2] - Implemented PT_GNU_STACK support, -z execstack option. 2015-11-14 20:56:08 +00:00
lldb Add more autotools/gmake NetBSD glue 2015-11-15 02:00:09 +00:00
llgo debug: Update for debug info API change. 2015-11-05 22:04:20 +00:00
llvm [GlobalOpt] Demote globals to locals more aggressively 2015-11-15 14:21:37 +00:00
openmp Add debug trace message for hierarchical barrier 2015-11-12 21:40:39 +00:00
polly ScopInfo: Reset compute operations before starting compute out region 2015-11-13 16:56:13 +00:00