-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
mbedtls_mpi_self_test fails with llvm 12.0-rc1 on amd64 #4116
Comments
Thanks a lot @z-rui for finding and reporting this, it's an exemplary issue 👍 We will look into this. As for the proposed solution: Don't we need a memory clobber here to tell the compiler that the memory at |
@hanno-arm These days we use the absence of labels to keep track of untriaged issues, so please don't apply a label if you aren't doing the full triage (including prioritization). I'm removing the "bug" label for now. I agree that it's a bug, and we'll reapply the label, but we also need to decide whether how to prioritize it, given that the only compiler that seems to make this optimization is a beta version. I can't promise that the fix will be merged in time for the last release of the 2.7 series which is scheduled for mid-March. For information, I've reproduced this locally with Clang 12 from http://apt.llvm.org/focal/ at 12.0.0-++20210206062921+716eef9ad5b3-1 |
Prioritization: we'll prioritize fixing the known issue with Clang 12 so that it can be included in the next release. The goal of this task is to pass the unit tests with clang 12. A broader review of potential issues with the assembly code is out of scope here. |
Bug
OS
linux
mbed TLS build:
Version: 2.7.18
Configuration: default
Compiler and options (if you used a pre-built binary, please indicate how you obtained it): LLVM 12.0-rc1
Expected behavior
Actual behavior
Steps to reproduce
library
directory, create a filemain.c
:Comments
The problem only occurs with
-O3
. It seems to be related to the following code fragment inbignum.c
:The compiler reorders
u1 = ( d[0] + u0 * B->p[0] ) * mm;
andmpi_mul_hlp( m, B->p, d, u0 );
. It believes the reordering is valid because it thinks the latter doesn't affect any dependencies of the former, which is false, becausempi_mul_hlp
will alter the values ind[]
. However, the inline assembly ofmpi_mul_hlp
for amd64 doesn't indicate that it may alter the values ind[]
. If I make a change inbn_mul.h
:Then the test no longer fails.
The text was updated successfully, but these errors were encountered: