This is an archive of the discontinued LLVM Phabricator instance.

Update opt-bisect code to avoid skipping AlwaysInliner
ClosedPublic

Authored by andrew.w.kaylor on Apr 27 2016, 5:00 PM.

Details

Summary

While working on an improved test for the opt bisect code I discovered that the AlwaysInliner pass was being skipped because it inherits its runOnSCC implementation from the Inliner base class. This causes failures for AMDGPU targets.

This patch works around that problem by making the skipSCC method virtual and overriding it in AlwaysInliner. There doesn't seem to be a good existing way to determine from the run function whether or not the derived pass can be skipped. Alternatives I considered were either adding a virtual method specific to this purpose (which seemed equivalent to the approach taken in this patch but with extra baggage) and removing the skipSCC check in the base Inliner class but adding case checks for individual function inlining and checking for the "always-inline" attribute at the callsite (which would be useful but leaks a bit of the attribute handling into the base class).

Diff Detail

Repository
rL LLVM

Event Timeline

andrew.w.kaylor retitled this revision from to Update opt-bisect code to avoid skipping AlwaysInliner.
andrew.w.kaylor updated this object.
andrew.w.kaylor set the repository for this revision to rL LLVM.
andrew.w.kaylor added a subscriber: llvm-commits.
MatzeB requested changes to this revision.May 20 2016, 8:18 PM
MatzeB edited edge metadata.

I think we can achieve this without a virtual function by refactoring all the code inside Inliner::runOnScc() that comes below the skipSCC() check into an own function. The AlwaysInliner pass can then just override runOnSCC() which calls this common function but contrary to Inliner::runOnSCC() without checking skipSCC().

This revision now requires changes to proceed.May 20 2016, 8:18 PM

I think we can achieve this without a virtual function by refactoring all the code inside Inliner::runOnScc() that comes below the skipSCC() check into an own function. The AlwaysInliner pass can then just override runOnSCC() which calls this common function but contrary to Inliner::runOnSCC() without checking skipSCC().

So you're thinking something like this?

bool Inliner::runOnSCC(CallGraphSCC &SCC) {
  if (skipSCC(SCC))
    return false;

  return inlineCalls(SCC);
}

bool AlwaysInliner::runOnSCC(CallGraphSCC &SCC) {
  return inlineCalls(SCC);
}

Alternatively, I could just add a "canSkipPass()" virtual method to Inliner, but I suppose the above is consistent with the way that passes are being migrated to the new pass manager.

andrew.w.kaylor edited edge metadata.

Refactored implementation as suggested.

MatzeB accepted this revision.May 23 2016, 11:13 AM
MatzeB edited edge metadata.

LGTM. Nitpick below.

lib/Transforms/IPO/InlineAlways.cpp
48 ↗(On Diff #58122)

Use three slashes.

This revision is now accepted and ready to land.May 23 2016, 11:13 AM
This revision was automatically updated to reflect the committed changes.