This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Make printf lowering faster when there are no printfs
ClosedPublic

Authored by foad on Sep 27 2019, 10:05 AM.

Details

Summary

Printf lowering unconditionally visited every instruction in the module.
To make it faster in the common case where there are no printfs, look up
the printf function (if any) and iterate over its users instead.

Event Timeline

foad created this revision.Sep 27 2019, 10:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2019, 10:05 AM
arsenm added inline comments.Sep 27 2019, 10:12 AM
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
574–575

Braces

575

Perhaps CallSiteBase in cases printf ever ends up invoked maybe?

foad marked 2 inline comments as done.Sep 27 2019, 10:45 AM
foad added inline comments.
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
574–575

I can add braces of course (just around multi-line constructs, yeah?) but whose rule is that? I don't see it in the coding standards and clang-format didn't add them.

575

I did consider that but the rest of the pass seems to be assuming CallInst, so it didn't seem worth generalizing here.

foad added a reviewer: tpr.Sep 28 2019, 1:48 AM
arsenm accepted this revision.Oct 1 2019, 5:20 PM

LGTM

llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp
574–575

clang-format apparently isn't capable of this. If it were up to me, braces would be include in 100% of contexts. the style guide doesn't actually say anything about this last I checked

This revision is now accepted and ready to land.Oct 1 2019, 5:20 PM
This revision was automatically updated to reflect the committed changes.