<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 20, 2014 at 3:14 AM, David Woodhouse <span dir="ltr"><<a href="mailto:dwmw2@infradead.org" target="_blank">dwmw2@infradead.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On Thu, 2014-02-20 at 02:02 -0800, Chandler Carruth wrote:<br>
><br>
> This really doesn't make sense. So, we've not disabled the inline<br>
> assembler, so we will eventually produce an error, but we don't ask it to<br>
> validate the assembly about to be fed to itself (and errored on) while we<br>
> have the full context of the source code to go with it? How is this<br>
> reasonable behavior?<br>
><br>
> Very fundamentally, LLVM's integrated assembler *is* going to assemble the<br>
> program.<br>
<br>
</div>No. It isn't.<br>
<br>
Absolutely *nothing* is going to assemble this program.<br>
<br>
We invoke the compiler with the '-S' option. It's going to *compile* the<br>
program, and spit out a .s file for us.<br>
<br>
Hence my comparison with a pre-processor. It makes as much sense for the<br>
compiler in this case to be prodding and poking at the contents of<br>
asm("") statements, as it does for a C preprocessor to barf because<br>
"that's not valid C" when we use it for X keymap files.</blockquote></div><br></div><div class="gmail_extra">Do you expect it to validate the C code it compiles? Should it produce any warnings at all? Any errors? What is the limit?</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Compiling the program, for Clang (and by extension LLVM when dealing with C programs), involves validating that the program fits Clang's semantic model for a C program. Inline assembly is an extension, but the idea is that it too should have a semantic model. I'm not very fussed about how *strict* that model is, and am quite happy for it to allow all manner of oddities that are useful to you or others, but I think it is important that it *has* a semantic model and that it is checked.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">As an example, I don't want adding -S to change the set of syntax errors produced by my program. If it *does*, I don't see how -fsyntax-only doesn't *also* change the set of syntax errors. It too is not going to generate an object file, and thus needn't assemble anything. With either of these, my mental model for how the compiler works, and what I can or cannot do to test my code and my compiler is broken.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">That said, I can imagine other design principles, and I'm not really trying to rule them out. However, the design of Clang w.r.t. inline assembly is very much that it *must* conform to the semantic model of the integrated assembler much as the C code must conform to the (extended) semantic model of C.</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">And I don't think that this precludes the interesting use cases here. Talking to Renato, it sounds much more like the validation is being entirely too pedantic and restrictive, not that we need to cease all validation.</div>
</div>