[PATCH] D15075: No error for conflict between inputs\outputs and clobber list

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 30 07:16:34 PDT 2016


ahatanak added a comment.

This patch doesn't detect more complex conflicts (like the following code), but I think it's OK for now.

  asm ("foo" : "=Q" (x) : : "%rax", "%rbx", "%rcx", "%rdx"); // Q: Any register accessible as rh: a, b, c, and d. 



> TargetInfo.h:593
>    ///
>    /// For example, on x86 it will return "ax" when "eax" is passed in.
> +  StringRef getNormalizedGCCRegisterName(StringRef Name,

It looks like this comment was wrong: it didn't return "ax" when "eax" was passed in Name.

> TargetInfo.cpp:406
>  StringRef
> -TargetInfo::getNormalizedGCCRegisterName(StringRef Name) const {
> +TargetInfo::getNormalizedGCCRegisterName(StringRef Name,
> +bool ReturnCannonical) const {

I think it's spelled "Canonical" rather than "Cannonical".

The comment added here doesn't seem correct to me. ReturnCanonical is used to make this function return the "canonical" register instead of the register passed in Name (e.g., when ReturnCanonical=true and Name="rax", it returns "ax").

> Targets.cpp:2718
> +      switch (Constraint[i]) {
> +        // Ignore these
> +      case '*':

Can we skip the checks for all these non-alphabet characters and handle them in "default"? Would doing so be incorrect?

> asm.c:34
> +  int a,b,c;
> +  asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}
> +  asm ("nop" : "=r" (clobber_conflict) : "r" (no_clobber_conflict) : "%rcx"); // expected-error {{asm-specifier for input or output variable conflicts with asm clobber list}}

Do you think you can improve the error message using '^' so that it's clear which constraint has a conflict with the clobbers? I was thinking about something like this:

error: inline-asm constraint "=r" conflicts with clobber list

asm ("nop" : "=r" (no_clobber_conflict) : "r" (clobber_conflict) : "%rcx");

  ^

https://reviews.llvm.org/D15075





More information about the cfe-commits mailing list