-
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
8e464c4 breaks clang 12 -O2 (make test failed) #4786
Comments
I can reproduce the failure with Ubuntu clang version 12.0.1-++20210630032618+fed41342a82f-1 Thanks for doing the bisection. I'm staring at this patch and I really can't see how it might cause undefined behavior. So this is looking like a compiler bug. Based on the logs from
|
The easy fix is to revert the patch and we'll probably do that, but I want to 1. make sure this is indeed a compiler bug and not undefined behavior in our code, and 2. if so be a good citizen and make sure the Clang bug is reported. |
I couldn't reproduce this on clang 13.0.0, I'll try version 12 shortly. |
@davidhorstmann-arm Which build of Clang 13 was that? It's a development version, so maybe the bug has been fixed recently. |
I built it from source - the llvm-project main branch, so should have all of the latest fixes. |
Still failing with Ubuntu clang version 13.0.0-++20210721052618+968899ad9cf1-1 |
I think we should investigate completely what is going on here. I can see that the function mpi_mul_hlp() had already some weird issue with some compiler: #if defined(__APPLE__) && defined(__arm__)
/*
* Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
* appears to need this to prevent bad ARM code generation at -O3.
*/
__attribute__ ((noinline))
#endif Furthermore, this function uses assembly code which is probably very difficult to make right especially for multiple compiler versions, compilation options ... |
Apologies for the delay - I can confirm that I've reproduced the tests hanging on clang-12 with the following exact version: $ clang --version
clang version 12.0.1 (https://github.com/llvm/llvm-project.git fed41342a82f5a3a9201819a82bf7a48313e296b) The tests hang on
|
I'm not sure exactly what happened previously (I may have forgotten to remove some state), but I can now reproduce the problem with clang-13. Specifically:
One small note: to get this to compile I had to modify |
As @ronald-cron-arm pointed out, there is already some code generation issue. When I commented out the /*#if defined(__APPLE__) && defined(__arm__)*/
/*
* Apple LLVM version 4.2 (clang-425.0.24) (based on LLVM 3.2svn)
* appears to need this to prevent bad ARM code generation at -O3.
*/
__attribute__ ((noinline))
/*#endif*/ (i.e. making the |
Given that this bug only arises when I think we are declaring register usage correctly: the code uses 7 registers:
However, there are no constraints on memory. Shouldn't there be? The code reads from |
I have been able to reproduce this result locally. Would it be worthwhile to see if this also removes the need for the previous |
Summary
seems that 8e464c4 (bisected) confused clang 12 when you compile with -O2....
System information
Mbed TLS version (number or commit id): 3.0.0 or 2.27 branch
Operating system and version: archlinux x86_64 with clang 12, happens with llvm-mingw (windows cross-compiler) too
Configuration (if not default, please attach
mbedtls_config.h
): defaultCompiler and options (if you used a pre-built binary, please indicate how you obtained it):
Additional environment information:
Expected behavior
make test succeeded
Actual behavior
make test failed
Steps to reproduce
CC=clang cmake .. -DCMAKE_BUILD_TYPE=Release
make -j14
make -j14 test
Additional information
The text was updated successfully, but these errors were encountered: