-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
LLVM 17 breaks inlining callees with compatible target attributes #65205
Comments
@llvm/issue-subscribers-backend-x86 |
I think we should revert this change. I've seen this cause issues on multiple instances already. always_inline overriding the target feature check was a feature, not a bug. |
Sorry, I somehow missed this. Let me take a look. |
It looks like
Now, the only call in the callee in this case is the inline asm, which shouldn't pose a problem in terms of the ABI compatibility. Disregarding inline asm like so around
I'll turn this into a pull request with a test case. |
That's a reasonable change, but this is only a specific issue. Others I've seen are calls being compatible in ways that LLVM does not understand (different target features that do not affect ABI) and the TTI hook not being implemented by all targets (IIRC PowerPC was one of the targets that doesn't, resulting in altivec inlining issues). We should fix such cases to make general inlining more powerful, but IMHO the change to always_inline behavior is still questionable, at least without a comprehensive review of TTI hooks for accuracy. |
I agree that the new behaviour is questionable. If I annotate a function as |
@nikic Are "others you've seen" are publicly available? If so, could you post pointers to some of those? (I'm aware of #65152 for the 32-bit ARM.) One problem with this Skipping safety checks is concerning to me. In the best case, the compiler crashes (as seen in #62664), and the user would immediately know something is wrong (but not necessarily why something is wrong). In this particular case, the caller ends up with LLVM IR instructions/intrinsics that cannot be lowered to the target hardware instructions available for the specified target attributes, and the backend fails to select instructions. Other cases could quietly lead to miscompilation. Ignoring an ABI compatibility like the one checked in I don't think if we should specify @kalcutter You might find |
Currently, a "normal" reason for failed inlining of a I don't know what would be the best option here, but an edit side-note: looks like recursive |
IMO missed inlining of |
The other x86 issues is https://reviews.llvm.org/D157826. I wasn't able to find the powerpc issue in my mail archive quickly. In any case, we have at least 4 different regressions caused by this change, and probably more we're not aware of (because "missing inlining" may easily go unnoticed), so we should err on the side of reverting. |
Thanks for the gotbolt link. I wasn't aware of the language frontend capable of issuing error messages in certain cases. As far as the original code here goes, the backend, namely
Thanks for this also. If I switch to GCC, I see:
|
I've flied an offshoot issue #67054, where the callee is declared is |
This reverts commit d6f994a. Several people have reported breakage resulting from this patch: - llvm#65152 - llvm#65205
/cherry-pick b4301df |
/branch llvm/llvm-project-release-prs/issue65205 |
This reverts commit d6f994a. Several people have reported breakage resulting from this patch: - llvm/llvm-project#65152 - llvm/llvm-project#65205 (cherry picked from commit b4301df61fc77a9d54ac236bc88742a731285f1c)
/pull-request llvm/llvm-project-release-prs#708 |
This reverts commit d6f994a. Several people have reported breakage resulting from this patch: - llvm/llvm-project#65152 - llvm/llvm-project#65205 (cherry picked from commit b4301df61fc77a9d54ac236bc88742a731285f1c)
This revert is keeping a soundness issue alive. LLVM will turn working code into broken code currently, and it's hard for frontends to work around that problem. I wonder if the approach outlined here could be a path forward towards fixing this inliner bug? |
Consider the following code:
When compiling with previous versions of clang (up to and including version 16),
MM512_MASK_ADD_EPI8
is inlined intoF
,G
, andH
(as expected) . Testing with LLVM 17 RC yields a different result: onlyF
allows inlining and horrible code is generated forG
andH
. I believe this regression is caused by d6f994a.Please revert that change or apply the appropriate fix to
X86TargetTransformInfo.cpp
for the LLVM 17 release.The text was updated successfully, but these errors were encountered: