This is an archive of the discontinued LLVM Phabricator instance.

errorUnsupported should be non-fatal
AbandonedPublic

Authored by majiang31312 on May 23 2021, 7:07 PM.

Details

Summary

DiagnosticInfoUnsupported use DS_Error as the default severity, but we want errorUnsupported to be non-fatal.
So we should pass DS_Warning explicitly in errorUnsupported.

before fix, the following code could not be built with ‘clang -mno-sse’

double test() {return 0.0;}
int main()
{
  double a = test();
  return 0;
}

Diff Detail

Event Timeline

majiang31312 created this revision.May 23 2021, 7:07 PM
majiang31312 requested review of this revision.May 23 2021, 7:07 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2021, 7:07 PM
majiang31312 edited the summary of this revision. (Show Details)May 23 2021, 7:09 PM
majiang31312 edited the summary of this revision. (Show Details)

update related tests

*Why* do we want that?

*Why* do we want that?

I am compiling skia with -mno-sse , because I want to use it in graalvm(sulong) which does not support float SSE instructions for the moment.
And, I think the comment before errorUnsupported has clearly state the reason.

majiang31312 set the repository for this revision to rG LLVM Github Monorepo.

CI failed to patch? Retry with Repository 'rG LLVM Github Monorepo'

Herald added a project: Restricted Project. · View Herald TranscriptMay 24 2021, 6:52 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
craig.topper added a comment.EditedMay 24 2021, 8:11 PM

"fatal" in the comment means don't diagnose any additional errors and immediately stop. We attempt to recover to detect more errors, but the emitted binary code is likely incorrect. I don't think we can just emit a warning.

The function name says "error" in its name, it should be an error.

lebedev.ri requested changes to this revision.May 25 2021, 1:42 AM
This revision now requires changes to proceed.May 25 2021, 1:42 AM

"fatal" in the comment means don't diagnose any additional errors and immediately stop. We attempt to recover to detect more errors, but the emitted binary code is likely incorrect. I don't think we can just emit a warning.

The function name says "error" in its name, it should be an error.

Thanks for the explanations, it's reasonable now.
Although “SSE register return with SSE disabled” seems strange as the code did not use SSE directly, it's another problem. I'll close this one now.

majiang31312 abandoned this revision.May 25 2021, 6:24 PM

X86-64 ABI requires float/double arguments to use XMM registers. All x86-64 CPUs have SSE2.

majiang31312 added a comment.EditedMay 26 2021, 2:06 AM

Thanks for the information.
Well, the key problem is X86-64 ABI indeed. But we could do better here for sure.
First of all, we could fallback to use fpu instructions. I can get the following binary which should work correctly(after this fix, of course)

0000000000000000 <test>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   d9 ee                   fldz
   6:   5d                      pop    %rbp
   7:   c3                      retq
   8:   0f 1f 84 00 00 00 00    nopl   0x0(%rax,%rax,1)
   f:   00

0000000000000010 <main>:
  10:   55                      push   %rbp
  11:   48 89 e5                mov    %rsp,%rbp
  14:   48 83 ec 20             sub    $0x20,%rsp
  18:   31 c0                   xor    %eax,%eax
  1a:   c7 45 fc 00 00 00 00    movl   $0x0,-0x4(%rbp)
  21:   89 45 ec                mov    %eax,-0x14(%rbp)
  24:   e8 00 00 00 00          callq  29 <main+0x19>
                        25: R_X86_64_PLT32      test-0x4
  29:   dd 5d f0                fstpl  -0x10(%rbp)

Although it might be incompatible with other libraries because of ABI problems, it is the responsibility of the linker to prevent possible errors. The compiler should just produce the binary as requested.
There have been similar situations in https://reviews.llvm.org/D70465.

Second, even if we decided not to support the fallback feature for the moment, we certainly could give a more clear message (maybe something like "float/double arguments under -mno-sse are not supported yet").
In all, using float/double is not a error in code(even with -mno-sse) in my opinion.

However, to make -mno-sse(with float/double) working gracefully need quite a work, so I agree it's reasonable to keep current state as there are no serious users yet. Thanks again for the clarification!