This is an archive of the discontinued LLVM Phabricator instance.

[SampleProfile] Use CallBase in function arguments and data structures to reduce the number of explicit casts. NFCI
ClosedPublic

Authored by craig.topper on Apr 15 2020, 2:42 PM.

Details

Summary

Removing CallSite left us with a bunch of explicit casts from
Instruction to CallBase. This moves the casts earlier so that
function arguments and data structure types are CallBase so
we don't have to cast when we use them.

Diff Detail

Event Timeline

craig.topper created this revision.Apr 15 2020, 2:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 15 2020, 2:42 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
dblaikie accepted this revision.Apr 16 2020, 12:44 PM

Looks good (the few couple of suggestions of collapsing isa+cast /might/ be wrong if they're really intentionally trying to restrict to just just Call+Invoke, not CallBrInst? in which case collapsing them would be wrong, because it'd include CallBrInst - but I don't think that's the case)

llvm/lib/Transforms/IPO/SampleProfile.cpp
722–725

Could maybe restructure this to:

if (auto *CB = dyn_cast<CallBase>(&Inst))
  if (CB->isIndirectCall() && findCalleeFunctionSamples(CB))
    return 0;
1054–1055

again, might be nice to "if (dyn_cast) + if(inlineCallInstruction)"

This revision is now accepted and ready to land.Apr 16 2020, 12:44 PM
This revision was automatically updated to reflect the committed changes.