-
Notifications
You must be signed in to change notification settings - Fork 14k
[LowerTypeTests] Skip declarations when determining Thumb support #129599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LowerTypeTests] Skip declarations when determining Thumb support #129599
Conversation
Created using spr 1.3.6-beta.1
@llvm/pr-subscribers-llvm-transforms Author: Alexander Richardson (arichardson) ChangesWhen looping over all functions in a module to determine whether any of Full diff: https://github.com/llvm/llvm-project/pull/129599.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
index e3caefe70311b..85cfa42fdc94f 100644
--- a/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
+++ b/llvm/lib/Transforms/IPO/LowerTypeTests.cpp
@@ -1847,6 +1847,10 @@ LowerTypeTestsModule::LowerTypeTestsModule(
auto &FAM =
AM.getResult<FunctionAnalysisManagerModuleProxy>(M).getManager();
for (Function &F : M) {
+ // Skip intrinsics since we should not query the TTI for them.
+ // TODO: Can we skip all declarations and only look at definitions?
+ if (F.isIntrinsic())
+ continue;
auto &TTI = FAM.getResult<TargetIRAnalysis>(F);
if (TTI.hasArmWideBranch(false))
CanUseArmJumpTable = true;
|
This code was last revisited in a8cd35c, I think. We should only need to visit functions that have definitions; the idea here is to figure out the supported subtargets based on code we're actually generating. The whole logic here is a bit dubious though, given that runtime feature detection exists on A-class targets. Probably more of this should be driven by the target triple. |
That's what I wasn't sure about - thanks. I'll update this to just use definitions. |
Created using spr 1.3.6-beta.1
If the target triple reliably contained enough information to distinguish Armv6-M from later versions, I agree! I only did this horrible thing at all because I couldn't see any other way to find out that specific detail. I agree that a module including functions with elevated target attributes, intending not to call them unless runtime feature detection permits, would confuse this logic, and I'd love it if there were a way to find out the same fact that's both simpler and more reliable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@arichardson, the patch LGTM, but I presume you'll edit the title and description to say "declarations" rather than "intrinsics" after the patch itself was modified?
Created using spr 1.3.6-beta.1
…support When looping over all functions in a module to determine whether any of them is built with support for B.W, we can skip declarations since those do not have an associated target-feature attribute. This was found by the assertion from llvm/llvm-project#129600 Reviewed By: statham-arm Pull Request: llvm/llvm-project#129599
clang generally rewrites the triple in a way that makes querying the subarch from the triple reliable. Not sure if we expect non-clang frontends to do the same thing. |
I don't know either 🙂 I can imagine in some cases even that might not be enough. For this particular purpose the subarch is all that's needed, but if we needed to query a particular SubtargetFeature to decide whether a certain instruction was safe to put in jump tables, surely the target triple wouldn't include that much detail. I don't think that's come up yet. In this same module there is the question of whether to put the Arm I must say that if I were considering cleaning this code up, I'd start by trying to move the generation of detailed machine code jump tables into the backend, where it surely belongs, and where all the necessary information is already conveniently available! Having to do it by emitting But someone else's closed PR is also not the best place to discuss it 🙂 |
When looping over all functions in a module to determine whether any of them is built with support for B.W, we can skip declarations since those do not have an associated target-feature attribute. This was found by the assertion from llvm#129600 Reviewed By: statham-arm Pull Request: llvm#129599
When looping over all functions in a module to determine whether any of
them is built with support for B.W, we can skip declarations since those
do not have an associated target-feature attribute.
This was found by the assertion from #129600