1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[IR] Move global_objects and global_values out of line, NFC

This saves 2.4% of CPU time compiling opt, according to
ClangBuildAnalyzer. These helpers being inlined in the header was
triggering the instantiation of concat_iterator in every TU using
Module.h (~1118 TUs): https://reviews.llvm.org/P8171$35

**** Templates that took longest to instantiate:
 76187 ms: llvm::AnalysisManager<llvm::Function>::getResult<llvm::TargetLibrary... (396 times, avg 192 ms)
 73609 ms: llvm::AnalysisManager<llvm::Function>::getResultImpl (420 times, avg 175 ms)
 49657 ms: llvm::detail::concat_range<llvm::GlobalValue, llvm::iterator_range<l... (1118 times, avg 44 ms)
 49376 ms: llvm::detail::concat_range<const llvm::GlobalValue, llvm::iterator_r... (1118 times, avg 44 ms)
 48167 ms: llvm::iterator_range<llvm::concat_iterator<llvm::GlobalValue, llvm::... (1118 times, avg 43 ms)
 48125 ms: llvm::iterator_range<llvm::concat_iterator<const llvm::GlobalValue, ... (1118 times, avg 43 ms)
 48061 ms: llvm::concat_iterator<llvm::GlobalValue, llvm::ilist_iterator<llvm::... (1118 times, avg 42 ms)
 48014 ms: llvm::concat_iterator<const llvm::GlobalValue, llvm::ilist_iterator<... (1118 times, avg 42 ms)
...

I haven't measured, but I don't think these helpers are performance
critical.  The iterator advance call can still be inlined, which is what
matters for performance.

Remove global_(objects|values)_(begin|end), since they were dead and
would have to be out of line anyway.
This commit is contained in:
Reid Kleckner 2019-11-22 19:17:34 -08:00
parent 52da15c594
commit bc98d63562
2 changed files with 20 additions and 35 deletions

View File

@ -660,24 +660,8 @@ public:
concat_iterator<const GlobalObject, const_iterator,
const_global_iterator>;
iterator_range<global_object_iterator> global_objects() {
return concat<GlobalObject>(functions(), globals());
}
iterator_range<const_global_object_iterator> global_objects() const {
return concat<const GlobalObject>(functions(), globals());
}
global_object_iterator global_object_begin() {
return global_objects().begin();
}
global_object_iterator global_object_end() { return global_objects().end(); }
const_global_object_iterator global_object_begin() const {
return global_objects().begin();
}
const_global_object_iterator global_object_end() const {
return global_objects().end();
}
iterator_range<global_object_iterator> global_objects();
iterator_range<const_global_object_iterator> global_objects() const;
using global_value_iterator =
concat_iterator<GlobalValue, iterator, global_iterator, alias_iterator,
@ -686,23 +670,8 @@ public:
concat_iterator<const GlobalValue, const_iterator, const_global_iterator,
const_alias_iterator, const_ifunc_iterator>;
iterator_range<global_value_iterator> global_values() {
return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
}
iterator_range<const_global_value_iterator> global_values() const {
return concat<const GlobalValue>(functions(), globals(), aliases(),
ifuncs());
}
global_value_iterator global_value_begin() { return global_values().begin(); }
global_value_iterator global_value_end() { return global_values().end(); }
const_global_value_iterator global_value_begin() const {
return global_values().begin();
}
const_global_value_iterator global_value_end() const {
return global_values().end();
}
iterator_range<global_value_iterator> global_values();
iterator_range<const_global_value_iterator> global_values() const;
/// @}
/// @name Named Metadata Iteration

View File

@ -381,6 +381,22 @@ void Module::debug_compile_units_iterator::SkipNoDebugCUs() {
++Idx;
}
iterator_range<Module::global_object_iterator> Module::global_objects() {
return concat<GlobalObject>(functions(), globals());
}
iterator_range<Module::const_global_object_iterator>
Module::global_objects() const {
return concat<const GlobalObject>(functions(), globals());
}
iterator_range<Module::global_value_iterator> Module::global_values() {
return concat<GlobalValue>(functions(), globals(), aliases(), ifuncs());
}
iterator_range<Module::const_global_value_iterator>
Module::global_values() const {
return concat<const GlobalValue>(functions(), globals(), aliases(), ifuncs());
}
//===----------------------------------------------------------------------===//
// Methods to control the materialization of GlobalValues in the Module.
//