[cfe-dev] Modules requires, silent error issues

Thompson, John John_Thompson at playstation.sony.com
Wed May 20 17:47:59 PDT 2015

The module.modulemap has the two module entries:

    explicit module sse4_1 {
      requires sse41
      export ssse3
      header "smmintrin.h"

    explicit module sse4_2 {
      requires sse42
      export sse4_1
      header "nmmintrin.h"

However, "sse41" and "sse42" in the requires don't match the "sse4.1" and "sse4.2" target features.  This leads to error messages like:

4.cpp:5:12: error: call to '_mm_blendv_ps' is ambiguous
    return _mm_blendv_ps(x,y,z);
...\lib\clang\include\smmintrin.h:103:1: note: candidate function
_mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M)
...\lib\clang\include\smmintrin.h:103:1: note: candidate function
_mm_blendv_ps (__m128 __V1, __m128 __V2, __m128 __M)
1 error generated.

Because the '.' makes the requires name an invalid identifier, either the feature name needs to change, or there needs to be some kinds of mapping or substitution done.  For example, I understand changing the feature name might be problematic, so changing the module map to use "sse4_1" and have clang replace the '_' with '.' before the feature check, or just map the problematic names, or decouple the "requires" names from the features names, are some possible options.  What do you think?

But also, this raises another issue.  The reason I get the error is because the compiler silently failed to match the requires argument, but went ahead and processed the header textually or something, leading to the confusing error.  Could we improve the error detection here?  Are there other situations where a silent failure is problematic?

Perhaps make the hasFeature return a three-state value with one that will indicate invalid feature name?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150521/8fd91b3d/attachment.html>

More information about the cfe-dev mailing list