This is an archive of the discontinued LLVM Phabricator instance.

[FunctionPropertiesAnalysis] Add detailed analysis
ClosedPublic

Authored by aidengrossman on Aug 7 2023, 9:26 PM.

Details

Summary

This patch adds more detailed function properties gated behind a command line flag for use primarily in experimentation and gathering statistics on the functions in a module or project. The runtime cost should be minimal as the computation is only done when the flag is set. There will be a slight memory overhead when the ML inliner is enabled, but it should be fairly small at a handful of bytes per function.

This is an adapted form of https://reviews.llvm.org/D109661.

Diff Detail

Event Timeline

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

can u add a lit test that checks the printout?

mtrofin added inline comments.Aug 8 2023, 2:05 PM
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
350

why did this shift to the right?

aidengrossman marked an inline comment as done.Aug 8 2023, 2:13 PM
aidengrossman added inline comments.
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
350

In the actual git diff it doesn't look like it did. https://github.com/boomanaiden154/llvm-project/commit/688dbdba8bc1b27a363f32b1d92e8fe10c21a504
I uploaded this patch manually by copying the output from git diff HEAD~1 and phabricator seems to be messing up the formatting for some reason (not sure why, same process worked perfectly for other patches recently).

This section of the file didn't actually change at all in the diff.

mtrofin added inline comments.Aug 8 2023, 2:47 PM
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
350

can you try again with arcanist?

aidengrossman marked an inline comment as done.

Add lit-test, update to format diff correctly.

aidengrossman marked an inline comment as done.Aug 8 2023, 3:04 PM
mtrofin added inline comments.Aug 8 2023, 4:12 PM
llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
90

pred_size

Is the test catching this?

105

probably want to ignore debug instructions

also, do you care if it's an intrinsic?

119

++IntegerConstantCount?

121

++FloatingPointConstantCount

aidengrossman marked 3 inline comments as done.

Address reviewer feedback.

llvm/lib/Analysis/FunctionPropertiesAnalysis.cpp
90

Tests were not currently catching that. I've added a new unit test case to make sure the behavior is as expected when the number of successors and predecessors is different.

105

Not currently. I'm probably going to add a couple more features in the future and a count of instructions that are intrinsics would be nice to have, but currently focused on getting the original feature set in.

119

I've switched to doing += Direction so that this better matches the behavior of the rest of the function when updating a function analysis. It doesn't really matter in my case, but definitely shouldn't purposefully be different.

mtrofin accepted this revision.Aug 8 2023, 5:41 PM
This revision is now accepted and ready to land.Aug 8 2023, 5:41 PM
This revision was landed with ongoing or failed builds.Aug 8 2023, 6:07 PM
This revision was automatically updated to reflect the committed changes.