This is an archive of the discontinued LLVM Phabricator instance.

[x86] prevent 64b operands to "r" constrained inline asm for -m32
Needs ReviewPublic

Authored by nickdesaulniers on May 12 2020, 1:22 PM.

Details

Summary

As pointed out by David Woodhouse and Akira Hatanaka in
https://bugs.llvm.org/show_bug.cgi?id=33587, Clang was inconsistent with
GCC validating inline asm constraints for -m32. For -m32 Clang was
disallowing 64b inputs/outputs to inline asm with "q" constraints, but
not for "r" constraints. This change improves Clang's validations to
match GCC's.

Adds a test case in x86_32-inline-asm.c, and fixes up previous tests
that used "r"+64b operands+32b x86 targets.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2020, 1:22 PM

I'm trying to catch up here. It looks like gcc has only started complaining about this from maybe version 7 on? And only as a warning?

The LLVM X86 backend used a 32-bit register for 'r' or 'R' on -m32 for 64-bit values. But the backend would fail for 'q' or 'Q' if the frontend check were not there.

Weirdly the backend fails for double with 'Q' in 64-bit mode. But does not fail with 'q' or 'r' or 'R'.