This is an archive of the discontinued LLVM Phabricator instance.

[Clang] Enable -print-pipeline-passes in clang.
ClosedPublic

Authored by jcranmer-intel on Jun 7 2022, 8:31 AM.

Diff Detail

Event Timeline

jcranmer-intel created this revision.Jun 7 2022, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 8:31 AM
Herald added a subscriber: ormris. · View Herald Transcript
jcranmer-intel requested review of this revision.Jun 7 2022, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 7 2022, 8:31 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Matt added a subscriber: Matt.Jul 20 2022, 12:06 PM
arsenm accepted this revision.Dec 19 2022, 4:43 PM
arsenm added a subscriber: arsenm.

I have no idea how you're supposed to work with clang without this

This revision is now accepted and ready to land.Dec 19 2022, 4:43 PM
jryans added a subscriber: jryans.Dec 27 2022, 10:10 AM

Rebase to trunk.

aaron.ballman added a subscriber: aaron.ballman.

Adding codegen code owners as reviewers just so they're aware (I think you're fine to land these changes if you don't hear back in the next day or two).

aeubanks added inline comments.
clang/lib/CodeGen/BackendUtil.cpp
1102

I wouldn't return here, doesn't seem right that we'll skip running the opt pipeline but continue with compilation. we should either bail out entirely of producing any output files (which would probably require code changes elsewhere), or run everything as normal, not do something weird where we don't run the optimization pipeline but still output files

clang/test/CodeGen/print-pipeline-passes.c
8

I wouldn't test BitcodeWriterPass, we may have a proper textual name for it at some point

jcranmer-intel added inline comments.Sep 11 2023, 2:09 PM
clang/lib/CodeGen/BackendUtil.cpp
1102

This is basically doing the same thing that opt -print-pipeline-passes is doing: https://github.com/llvm/llvm-project/blob/d1b418f55263ec48d14f220ad020d55f126cfcab/llvm/tools/opt/NewPMDriver.cpp#L500-L524.

In the case of emitting LLVM IR or bitcode, this logic is sufficient to not emit any output. In the case of .s or .o files, it looks like I have to also bail out of running RunCodegenPipeline

Address review comments.

aeubanks accepted this revision.Sep 11 2023, 2:28 PM

lg with one test comment

clang/lib/CodeGen/BackendUtil.cpp
1102

if skipping RunCodegenPipeline doesn't produce any output file, sgtm

clang/test/CodeGen/print-pipeline-passes.c
9

I believe this will fail in non-assert builds

9

since we don't run the verifier in non-assert builds

I don't really like extern cl::opt<bool> PrintPipelinePasses; (as opposed to implementing a proper driver option that calls a proper API); secret handshakes like this make it harder for people to write non-clang frontends. But I won't block the patch just for that, I guess.

Replace verify with annotation-remarks

jcranmer-intel marked 5 inline comments as done.Sep 12 2023, 8:09 AM
jcranmer-intel added inline comments.
clang/test/CodeGen/print-pipeline-passes.c
9

Apparently verify is added by clang unless -disable-llvm-verifier is present on the command line, but I've switched it to annotation-remarks nevertheless.

aeubanks added inline comments.Sep 12 2023, 9:18 AM
clang/test/CodeGen/print-pipeline-passes.c
9

-disable-llvm-verifier is added by clang in non-assert builds

This revision was automatically updated to reflect the committed changes.
jcranmer-intel marked an inline comment as done.