This is an archive of the discontinued LLVM Phabricator instance.

[msan] Change logic of ClInstrumentationWithCallThreshold
ClosedPublic

Authored by vitalybuka on Sep 14 2022, 11:06 AM.

Details

Summary

According to logs, ClInstrumentationWithCallThreshold is workaround
for slow backend with large number of basic blocks.
However, I can't reproduce that one, but I see significant slowdown
after ClCheckConstantShadow. Without ClInstrumentationWithCallThreshold
compiler is able to eliminate many of the branches.

So maybe we should drop ClInstrumentationWithCallThreshold completly.

For now I just change the logic to ignore constant shadow so it will
not trigger callback fallback too early.

Diff Detail

Event Timeline

vitalybuka created this revision.Sep 14 2022, 11:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 11:06 AM
vitalybuka requested review of this revision.Sep 14 2022, 11:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 14 2022, 11:06 AM

This seems to have changed the logic for emitting callbacks to such that it would emit inlined code and once the threshold is reached it would start outlining them. Before it would either always emit outlined or always inlined for each function. Is that correct and if so it is intended?

llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
1153

s/folloup/follow-up/

1154

To avoid negative integer underflow.

vitalybuka marked 2 inline comments as done.
This comment was removed by vitalybuka.
llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
1154

Total count is useful for debugging
maybe this way?

This seems to have changed the logic for emitting callbacks to such that it would emit inlined code and once the threshold is reached it would start outlining them. Before it would either always emit outlined or always inlined for each function. Is that correct and if so it is intended?

Yes. This is just workaround for huge number of basic blocks. So I don't think this particular part is important.
Alternative is to first pass handle constants, then InstrumentWithCalls, and run another pass as before, using InstrumentWithCalls.
However it looks like causing more convoluted code without a reason.

fix compilation

kstoimenov accepted this revision.Sep 14 2022, 2:31 PM
This revision is now accepted and ready to land.Sep 14 2022, 2:31 PM
This revision was landed with ongoing or failed builds.Sep 14 2022, 2:58 PM
This revision was automatically updated to reflect the committed changes.