This is an archive of the discontinued LLVM Phabricator instance.

[PPC] Fix layering issues between MCTargetDesc and CodeGen
ClosedPublic

Authored by rnk on Jul 27 2023, 2:00 PM.

Details

Reviewers
nemanjai
Group Reviewers
Restricted Project
Commits
rGcda23c07328c: [PPC] Fix layering issues between MCTargetDesc and CodeGen
Summary

See issue #64166 for more information about the layering issue.

The PPCMCTargetDesc library was including CodeGen headers such as
PPCInstrInfo.h and calling inline functions in them. This doesn't work
in the Bazel build, and is error-prone. If the inline function moves to
a cpp file, it will result in linker errors.

To address the issue, I moved several inline functions to
PPCMCTargetDesc.cpp, and declared them in the PPC namespace in
PPCMCTargetDesc.h, which seemed like the most straightforward fix.

Diff Detail

Event Timeline

rnk created this revision.Jul 27 2023, 2:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 2:00 PM
rnk requested review of this revision.Jul 27 2023, 2:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 27 2023, 2:00 PM

Thank you for the patch. This is actually interesting and is a bit of a change to how we thought the code was do be structured. For us the affinity between CodeGen and MCTargetDesc was an indication that the libraries, although separate, are dependent on each other. Of course, this is not necessary so I am in favour of this refactoring.

I don't want to approve this patch immediately, not because I am opposed to it, but because I think it should be seen and reviewed by all interested developers for the PowerPC back end so that we can change the mindset about these libraries.

Finally, I wonder if we can add some tests that would prevent us from forming these dependencies again in the future? Is there a buildbot that uses Bazel? Immediate notification when new dependencies are re-introduced is essential to ensuring we stay on the straight and narrow wrt. to these libraries.

nemanjai added a reviewer: Restricted Project.Jul 27 2023, 3:39 PM
rnk added a comment.Jul 27 2023, 4:11 PM

Thank you for the patch. This is actually interesting and is a bit of a change to how we thought the code was do be structured. For us the affinity between CodeGen and MCTargetDesc was an indication that the libraries, although separate, are dependent on each other. Of course, this is not necessary so I am in favour of this refactoring.

I don't want to approve this patch immediately, not because I am opposed to it, but because I think it should be seen and reviewed by all interested developers for the PowerPC back end so that we can change the mindset about these libraries.

Sounds good. I kind of hacked this patch together, so there may be better places to put the code that I had to move around.

Finally, I wonder if we can add some tests that would prevent us from forming these dependencies again in the future? Is there a buildbot that uses Bazel? Immediate notification when new dependencies are re-introduced is essential to ensuring we stay on the straight and narrow wrt. to these libraries.

There is both a bazel bot and a premerge check for Bazel, documented here:
https://github.com/llvm/llvm-project/tree/main/utils/bazel#pre-merge-testing

You have to opt in to receiving Bazel build notifications on your changes, because the understanding is that LLVM developers are not generally expected to maintain the Bazel build.

Once I land the change to remove the CodeGen dep from the *UtilsAndDesc libraries, including codegen headers from MCTargetDesc will break the bazel build, so at the very least, a Bazel user will notice and will take action.

rnk added a comment.Aug 17 2023, 3:32 PM

Ping, any outstanding concerns?

rnk updated this revision to Diff 551636.Aug 18 2023, 2:13 PM
  • rebase
rnk added a comment.Aug 30 2023, 4:05 PM

I haven't heard any serious concerns, and I hope I addressed your questions. I plan to go ahead and land this, but feel free to modify or revert if you have concerns.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 30 2023, 4:09 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.