Details
- Reviewers
craig.topper arsenm kazu apazos
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/MC/MCSubtargetInfo.cpp | ||
---|---|---|
81–87 | avoid else-after-return (per LLVM coding conventions) And it might even be worth inverting the previous condition (so it's if (!FeatureEntry) { error stuff return false; } non-error stuff here) But also: we can't/don't usually print errors from arbitrary partts of LLVM - it's not use-LLVM-as-a-library friendly (the library client can't stop these messages from printing, render them in a different way/to a different mechanism (a log, a GUI, etc)) Are there other error handling conventions in use in nearby code you can find some inspiration from? |
llvm/lib/MC/MCSubtargetInfo.cpp | ||
---|---|---|
313 | Why do we need an Empty set to compare to? Can't we just ask if no bits are set in Set and All? Set.none() && All.none() should work? |
Thanks for the comments @dblaikie @craig.topper.
llvm/lib/MC/MCSubtargetInfo.cpp | ||
---|---|---|
81–87 |
Done, thank you.
Since the entire MCSubtargetInfo.cpp is using this same error printing mechanism and I can't find a quick fix, I think that change can be deferred to another patch? |
Is this new behavior visible through some existing non-test callers of MCSubtargetInfo::checkFeatures? Could that be tested using a lit-style test to demonstrate that this behavior is desirable/correct at that scope, beyond the narrower unit test?
Without this change, few lit tests will fail with the updated changeset for D140478. Would that be sufficient to showcase that this change is needed?
Could you walk me through that in more detail - oh, is that other patch checking for features in generic code on platforms/targets that don't support those features at all? Maybe that's a problem/the thing that should be fixed, and that other code should be moved to some target-specific hook?
That's what it looks like to me. I also think that some virtual methods a target can override would be a better way to solve this.
Thanks for the comments.
Even if we find some other way to address the needs of D140478, I think the incorrect behavior of MCSubtargetInfo::checkFeatures needs to be fixed.
Is having no existing code referring to the use case scenario being fixed a good reason we leave the incorrect behavior in the code base as is?
Thanks for the comments.
Even if we find some other way to address the needs of D140478, I think the incorrect behavior of MCSubtargetInfo::checkFeatures needs to be fixed.
Is having no existing code referring to the use case scenario being fixed a good reason we leave the incorrect behavior in the code base as is?
I'm not sure this is incorrect behavior, though - that this function doesn't handle unknown attributes seems like it could be a valid design. If there's other ways to think about this that demonstrate that the design is not good/incorrect for existing uses, perhaps, maybe that motivates this patch regardless of D140478.
It seems like the only use of checkFeatures is for implementing hwmodes?
llvm/unittests/CodeGen/TargetOptionsTest.cpp | ||
---|---|---|
71 | It's a gtest-ism that these should be swapped |
avoid else-after-return (per LLVM coding conventions)
And it might even be worth inverting the previous condition (so it's if (!FeatureEntry) { error stuff return false; } non-error stuff here)
But also: we can't/don't usually print errors from arbitrary partts of LLVM - it's not use-LLVM-as-a-library friendly (the library client can't stop these messages from printing, render them in a different way/to a different mechanism (a log, a GUI, etc))
Are there other error handling conventions in use in nearby code you can find some inspiration from?