This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU][printf] Run AMDGPUPrintfRuntimeBindingPass in -O0
ClosedPublic

Authored by jmmartinez on Mar 23 2023, 6:54 AM.

Details

Summary

AMDGPUPrintfRuntimeBindingPass is not run in the IR optimization
pipeline with -O0.

This means that with OpenCL the printf definition coming from
device_libs gets linked with the user's code, which blocks
AMDGPUPrintfRuntimeBindingPass from working after the linkage is done.

This patch also adds an opt-pipeline.ll test inspired from
llc-pipeline.ll to document the optimization pipeline.

Diff Detail

Event Timeline

jmmartinez created this revision.Mar 23 2023, 6:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 23 2023, 6:54 AM
jmmartinez requested review of this revision.Mar 23 2023, 6:54 AM
jmmartinez added inline comments.
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
18 ↗(On Diff #507727)

I have the feeling that I should remove analysis and analysis invalidations from the list.

arsenm accepted this revision.Mar 23 2023, 9:48 AM

LGTM, thanks I noticed this when I was fixing printf recently but forgot to fix this part

llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
18 ↗(On Diff #507727)

Depends, do theses passes actually do anything? I don’t know what CoroConditionalWrappper does

This revision is now accepted and ready to land.Mar 23 2023, 9:48 AM
  • Updating opt-pipeline.ll test to validate on the CI
arsenm added inline comments.Mar 24 2023, 4:36 AM
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
18 ↗(On Diff #507727)

By remove I thought you meant stop the pass from running. In terms of testing, I expect every single pass run to be tested here and every check use -NEXT

jmmartinez added inline comments.Mar 24 2023, 5:12 AM
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
18 ↗(On Diff #507727)

Oh sorry, I actually meant the removing the "Running analysis" and "Invalidating analysis" entries, such that only the code transformation are checked. And, since I removed the analysis entries, I've added the I've added the --implicit-check-not="Running pass" flag instead of using CHECK-NEXT.

I can revert these changes if you prefer.

foad added a subscriber: aeubanks.Mar 24 2023, 5:51 AM
foad added inline comments.
llvm/test/CodeGen/AMDGPU/opt-pipeline.ll
1 ↗(On Diff #508011)

See previous discussion of why this file was removed and what it should be replaced with: https://github.com/llvm/llvm-project/commit/6f73bd781305266a747055875ce8352e5a36c809

Adding @aeubanks.

could we not put the full pipeline as a test and just check that relevant passes run?

could we not put the full pipeline as a test and just check that relevant passes run?

Sounds good to me. There is a test already checking this (well, not exactly, it checks that the transformation done by the pass is done).

I'm going to remove the opt-pipeline test, it seems that most of the problems are coming from there.

  • Removed the opt-pipeline.ll test.
arsenm accepted this revision.Mar 24 2023, 8:44 AM

LGTM with test nit

llvm/test/CodeGen/AMDGPU/opencl-printf-pipeline.ll
13

This will be a really fragile negative check, just use generated checks for the output

15

Don't think you need the (ptr addrspace(4), ...) here

  • Update test to use auto generated checks.
jmmartinez marked 2 inline comments as done.Mar 24 2023, 9:16 AM
  • Took into account remarks.

this is fine, but I meant that you could still do the -debug-pass-manager run, just only check for AMDGPUPrintfRuntimeBindingPass instead of the whole pipeline