This is an archive of the discontinued LLVM Phabricator instance.

[FunctionPropertiesAnalysis] Add operand type counts
ClosedPublic

Authored by aidengrossman on Aug 15 2023, 1:31 PM.

Details

Summary

This patch adds operand type counts to the detailed function properties
analysis. This is intended to enable more interesting and detailed
comparisons across different languages on specific metrics (like usage
of inline assembly or global values).

Diff Detail

Event Timeline

aidengrossman created this revision.Aug 15 2023, 1:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 1:31 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
aidengrossman requested review of this revision.Aug 15 2023, 1:31 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 15 2023, 1:31 PM

Remove unnecessary includes.

Planning on this and then probably a follow-up patch that adds more detailed statistics on phi nodes/branching and intrinsic usage, and then we should have a complete supserset of the statistics used in the literature (when combined with raw instruction counts).

jdoerfert added inline comments.Aug 15 2023, 2:35 PM
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
122–123

Integer/FP constant count makes little sense. Make them "Operand" counts as well.

123–135

Add a "UnknownOperandCount".

131

The above should probably be a macro + a few invocations, also below. Anyway.

aidengrossman marked 2 inline comments as done.

Address some reviewer feedback.

  • Denote integer and FP constant counts as operand counts.
  • Add unknown operand count.
aidengrossman added inline comments.Aug 15 2023, 3:24 PM
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
131

Can you explicate a little bit more on how you envision the macro? A macro defining a list of features that macros can then be plugged into for doing things like printing? Generating the operand counts with a macro seems a little counterintuitive to me since I believe it would be hard to preserve the semantics of the if/else if/else chain.

jdoerfert added inline comments.Aug 15 2023, 8:40 PM
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
131
#define CHECK(TYPE) if (isa<TYPE>(Operand)) { TYPE ## OperandCount += 1; continue; }

Address reviewer feedback.

  • Convert counting operands into a macro.
  • Convert printing properties into a macro.

Remove extra includes.

jdoerfert accepted this revision.Aug 18 2023, 10:16 AM
This revision is now accepted and ready to land.Aug 18 2023, 10:16 AM
This revision was landed with ongoing or failed builds.Aug 18 2023, 1:27 PM
This revision was automatically updated to reflect the committed changes.