This is an archive of the discontinued LLVM Phabricator instance.

Avoid constructing GlobalExtensions only to find out it is empty.
ClosedPublic

Authored by marsupial on May 20 2017, 12:57 PM.

Details

Summary

GlobalExtensions is dereferenced twice, once for iteration and then a check if it is empty.
As a ManagedStatic this dereference forces it's construction which is unnecessary.

Diff Detail

Repository
rL LLVM

Event Timeline

marsupial created this revision.May 20 2017, 12:57 PM
davide resigned from this revision.Jun 19 2017, 8:22 AM

Don't know extension points well enough, resigning from this one.

mehdi_amini accepted this revision.Jun 19 2017, 8:56 AM

LGTM with an inline comment

lib/Transforms/IPO/PassManagerBuilder.cpp
172 ↗(On Diff #99678)

It took me some time to understand the comment here, because the function looks like a simple predicate.

I'd write something like:

/// Check if GlobalExtensions is constructed and not empty. 
/// Since GlobalExtensions is a managed static, just calling `empty()`
/// would trigger the construction of the object.
This revision is now accepted and ready to land.Jun 19 2017, 8:56 AM
This revision was automatically updated to reflect the committed changes.