[LLVMdev] IAS and inline assembly

Rafael EspĂ­ndola rafael.espindola at gmail.com
Fri Feb 21 08:29:56 PST 2014


On 21 February 2014 11:22, Saleem Abdulrasool <compnerd at compnerd.org> wrote:
> (Sorry about the duplicate, I got the mailing list address incorrect the
> first time around).
>
> While working on the IAS, I ran into a behavioural difference between GCC
> and clang.
>
> The Linux Kernel relies on GCC's acceptance of inline assembly as an opaque
> object which will not have any validation performed on the content.  The
> current behaviour in LLVM is to perform validation of the contents by means
> of parsing the input if the MC layer can handle it.
>
> When compiling to an object file, this distinction is unimportant since the
> assembler will have to parse the content anyways.  However, the case where
> the emission is an assembly file (as used by the Linux kernel) is something
> which needs to be discussed.
>
> The current options include:
> - continuing with the current behaviour (the user can disable the IAS even
> when assembling (-S) if necessary
> - behaving more like GCC and disabling the validation
> - introducing a new flag (-W{no-,}inline-asm-syntax ?) to control the
> behaviour
> - relaxing all errors to warnings
>
> Personally, I think that the LLVM model is better since it allows for
> earlier diagnosis of errors.  But, I am torn between options 1 and 3 and
> could be easily convinced that either is better.
>
> This is sufficiently controversial that it deserves a separate thread of
> conversation.
>
> Thanks!

My preference is also for the first option. The files we reject now
with -S are the ones we used to reject with -c. We just ask for "-S
-no-integrated-as" to be used when a file contains invalid inline
assembly. If that is too strict to work in practice, I think the
alternatives I would prefer would be

* Have the driver pass -no-integrated-as when given -S but not
-integrated-as. That is, -no-integrated-as is always the default for
-S in clang. This has the big advantage that parsing assembly is still
just a on/off switch.
* Have a second TargetOption: StrictIntegratedAS. Have the driver set
that based on -S/-c and -integrated-as/-no-integrated-as. With this
option we downgrade assembly parsing errors to warnings and fallback
to EmitRawText, but without ever calling hasRawTextSupport. I believe
this is equivalent to Renato's proposal.

Even if we decide to go with the option of downgrading errors to
warnings, we should probably still do that in a second step and first
just have the driver disable the integrated assembler with -S for now.

Cheers,
Rafael



More information about the llvm-dev mailing list