As a follow-up to D93656, I'm switching the Clang UniqueInternalLinkageNamesPass scheduling to using the LLVM one with newpm.
Test Plan:
Differential D94019
Switching Clang UniqueInternalLinkageNamesPass scheduling to using the LLVM one with newpm. hoy on Jan 4 2021, 10:16 AM. Authored by
Details As a follow-up to D93656, I'm switching the Clang UniqueInternalLinkageNamesPass scheduling to using the LLVM one with newpm. Test Plan:
Diff Detail
Event TimelineComment Actions There is the original clang test unique-internal-linkage-names.cpp that still works with the change here. What kind of new test would you like? Comment Actions Something that tests this change (something that would fail before this patch is applied, and passes afterwards - demonstrating the change in behavior). Either something like the LLVM test, testing the pass sequence, or something with very simple IR (something that can robustly demonstrate the change in optimization behavior due to this patch and will be resilient to as many other changes to LLVM as possible (ie: something that captures the essence of this change)). Comment Actions My understanding is that this change does have a functional change. It's not a refactoring change but changes the resulting output of Clang/LLVM, right? Comment Actions I'm not sure how to test this change if LLVM is treated as a black box to clang. This patch doesn't seem to change anything fundamental from the Clang point of view. My understanding is that the previous placement of the unique name pass in the pipeline didn't seem particularly important to Clang, therefore we ended up just testing the whole Clang output. If that's the case, I don't think we need to test the pass order here with this change. Comment Actions My understanding was that the change in pass ordering has some observable change in the total behavior of LLVM? So an end-to-end test could be used here (I tend towards preferring the checking the pass ordering, but understand @aeubanks contrasting position) - that's what I was trying to describe in the "or something with very simple IR (... )" part of my suggestion. If the change in pass order can be observed in terms of different final IR, that's what an end-to-end Clang test could validate. Comment Actions The change on the LLVM side is observable on the IR level when pseudo probe is enabled. I think that LLVM change is transparent to Clang. In other words, Clang doesn't need to know that the LLVM change is to favor pseudo probe. It just needs to know that LLVM already has a unique name pass scheduled and itself should not schedule the same pass again. What do you think? Comment Actions Clang's overall, user-facing behavior changed (otherwise why make this change, right?) due to a change to Clang's source code, so it should be tested to demonstrate that the source change had the desired effect and doesn't regress. These particular changes are awkward because things like CodeGenOpts aren't serialized, unlike LLVM IR, but that doesn't mean they shouldn't be tested - it means the testing isn't as elegant as it is for serialized IR. Comment Actions Yes, the user-facing behavior changed and it is tested by an LLVM test. I think that's transparent to clang and Clang doesn't know why that change is made in LLVM. A possible clang test could be to enable pseudo probe and check the output of pseudo probe metadata where unique linkage names are encoded. But we don't even has such a test in the LLVM part either. Comment Actions If this didn't involve a code change in Clang, I'd generally agree with you - but this is a code change in Clang required/intended to elicit a change in behavior, and should be tested to demonstrate that change in behavior.
Yes, I think that would be one valid option - or a test that validates the change in the pass order, like the LLVM test. Either would be acceptable to me - I'd personally lean more towards the pass order test, like the LLVM one, and @aeubanks has expressed a preference towards and end-to-end type test, I believe. Comment Actions Oh sorry, yeah this isn't NFC. But I still don't think this needs a new test. We're going from a custom Clang implementation of adding passes to something more generic that's also more tested within LLVM. Comment Actions Then could the end to end test be tightened up to demonstrate how this patch/the change in pass order has produced new/different/desired behavior? Comment Actions It could be, but again I don't see the point. Rather than thinking about testing within individual changes, I think thinking about the overall state of testing regarding UniqueInternalLinkageNames after this change is better. Comment Actions Or if the functionality were implemented as it were before this patch - by explicitly adding the pass to the MPM in Clang, rather than by using UniqueInternalLinkageNames - to demonstrate & validate that this change had the desired effect, there should be a test case. Yeah, if this code had been written with the PTO flag from the start, I probably wouldn't've considered/suggested/required this test to be written - but given the code was written that way, and is now being changed, I think that change should be tested.
General detailed testing of the functionality should be done in LLVM, I agree - but testing that this Clang change does what's intended should be done in Clang where the change is made. If MPM and other flags were serialized with IR, we would test it that way (if we had a perfect serialization boundary - we probably would've previously been testing the pass sequence via some serialized form of the pass pipeline, perhaps, then changed to testing a serialized form of the PTO values - in lieu of that, we can either test the pass pipeline dump or choose as robust an end-to-end IR example as possible that is resilient to as many other changes to the LLVM implementation as possible (as, I assume, the existing end-to-end test is) while demonstrating the purpose/value of this change) |