Fix GCC 12 -Og #804
No reviewers
Labels
No labels
announcement
bug
build
CI
dependencies
documentation
duplicate
enhancement
experience feedback
feature request
github_actions
help wanted
install
invalid
Long-term
optimization
portability
question
target-specific
test issue
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-Cyan4973/xxHash!804
Loading…
Reference in a new issue
No description provided.
Delete branch "gcc12-Og"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The issue actually appears to be GCC disliking that a function pointer is SOMETIMES forceinline, and withSecret was marked force inline instead of noinline (despite what the comments suggested)
This marks
XXH3_hashLong_{64,128}b_withSecretasXXH_NO_INLINEinstead ofXXH_FORCE_INLINElike the rest of thehashLongfunctions.It might be a good idea to add
-Ogand GCC 12 to CI.Fixes #800 #720
improved version of fix in #802
Agreed
I misread the comment. Perhaps this?
I now made it force inline if and only if XXH_INLINE_ALL is defined and it isn't GCC 12
This should probably be abstracted behind a dedicated macro, that can then be shared by the 2 places where it's invoked.
The comment explains that, when secret's size is
static,then it's advantageous for performance to pass that to the function.
This suggests that the constant size is propagated inside
XXH3_hashLong_64b_withSecret()for further optimization.Of course, if we use
XXH_NO_INLINE, this property is lost.Now, this could be nonetheless an acceptable trade-off if the goal is to survive the specific
gcc-12 -Ogcompilation scenario.But my understanding of below macro test is that it's more general :
gcc, >= 12XXH_NO_INLINEis always set (not just when-Ogis set), with the exception when inlining is expressly required withXXH_INLINE_ALL.So, effectively, this will impact performance on a broader range of scenarios.
And I wonder if this is the right trade off.
When XXH3 is not inlined, there isn't much of a benefit to inlining XXH3_hashLong_withSecret, as the secret size would be entirely unknown.
That's a good point.
For some reason, I expected this variant to be within the call chain of the "default" variant using the default
kSecret,but it's not, "default" delegates directly to
XXH3_hashLong_64b_internal().I'm a little lost about this
gcc-12 -Ogissue.It seems that #814 fixes it, using a different initialization strategy.
This PR seems to address the same issue, but in a very different way (
inline).Is it still useful despite #814 ?
This specific issue comes from the "failed to inline" errors, the other issue is unrelated.
Basically, the issue is that GCC 12 on -Og does not like a function pointer that can either point to something marked
always_inlineornoinline, and it errors.The Meson workaround should be fixed too if anyone gets around to it.