This is an archive of the discontinued LLVM Phabricator instance.

[WPD] Filter out intrinsics inserted from whole-program-vtables
Needs RevisionPublic

Authored by xur on Jul 1 2022, 9:48 AM.

Details

Summary

These intrinsics should be counted in the heuristics in
InstCombine and CallsiteSplit.

They are causing FDO hash mismatches when whole-program-vtables
is enabled in optimized build but not in instrumentation build.

Diff Detail

Event Timeline

xur created this revision.Jul 1 2022, 9:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 9:48 AM
xur requested review of this revision.Jul 1 2022, 9:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2022, 9:48 AM

this doesn't seem very principled, it's seemingly adding checks in random places hoping that passes won't look too much at assumes/type tests
is there anything wrong with making the instrumented build use -fwhole-program-vtables?

llvm/test/Transforms/InstCombine/wpvt.ll
1

this test is very noisy and doesn't really show what's going on, could you reduce it a bit, and also maybe run it through -passes=metarenamer (and maybe convert to opaque pointers to remove some unnecessary pointer bitcasts via opt -S -opaque-pointers foo.ll)

In the summary, do you mean 'should not be counted'? Also agree that the test should be cleaned up.

llvm/lib/Analysis/Loads.cpp
619

Add a wrapper interface 'isNopInst()' instead?

These instructions should not be counted in inline size estimation either.

aeubanks added inline comments.Jul 1 2022, 10:24 AM
llvm/lib/Analysis/Loads.cpp
619

the assume and type test should be already handled in CallAnalyzer::analyzeBlock by being ephemeral values (analyzed by AssumptionCache/CodeMetrics::collectEphemeralValues), but it'd be good to double check

nikic added a subscriber: nikic.

This should be split into a patch for CallSiteSplitting and one for Loads. For CallSiteSplitting, you'll probably want to implement ephemeral value handling along the lines of https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Utils/SimplifyCFG.cpp#L2941. For Loads, we'd want something along the lines of D101553.

nikic requested changes to this revision.Jul 1 2022, 2:18 PM
This revision now requires changes to proceed.Jul 1 2022, 2:18 PM

This should be split into a patch for CallSiteSplitting and one for Loads. For CallSiteSplitting, you'll probably want to implement ephemeral value handling along the lines of https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Utils/SimplifyCFG.cpp#L2941. For Loads, we'd want something along the lines of D101553.

You may want to spell out the interface changes you think is right more clearly :)

llvm/lib/Analysis/Loads.cpp
619

It is probably better to unify the interface that does this though (an old comment -- forgot to click the submit button).