-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
bcmp
/memcmp
removal optimization should remove unneeded alloca
s
#52701
Comments
The problem is that ExpandMemCmp (and MergeICmps as well, for that matter) only run as part of the backend pipeline, so there is little optimization happening after they run. There was a previous attempt to move these into the end of the module pipeline, but these got reverted. I don't quite remember why that was. Maybe @legrosbuffle knows. |
Brainfart, this issue is about |
Sorry I missed this. Yes, that was https://reviews.llvm.org/D60318. Unfortunately that patch was interfering with sanitizers because the sanitizers are running after the pass and no longer see the memcmp, which prevent them from doing their interception work. There were also some compile-time regressions on some binaries because it's harder for LLVM to deal with a large number of loads than with
That being said at one point gchatelet@ was planning on addind |
Example from rust-lang/rust#91838: https://godbolt.org/z/9h83ezxvj
Demonstration that more
opt -O3
doesn't help: https://llvm.godbolt.org/z/qdanMeEarCodegen repro via
llc
trunk: https://llvm.godbolt.org/z/oxMh6fEjqIt's excellent that short, known-length
memcmp
can just bemov
+cmp
in codegen.But, unfortunately, if one of the sides of the comparison was passed directly (not via pointer), the
alloca
into which it was written to be able to callmemcmp
sticks around, resulting in generated assembly that writes the argument to stack then immediately reads it again:It would be nice if it could instead be
The text was updated successfully, but these errors were encountered: