<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 2, 2015 at 1:13 PM, Reid Kleckner <span dir="ltr"><<a href="mailto:rnk@google.com" target="_blank">rnk@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr">I would prefer it if we kept hex integer literals. The .ll syntax mostly exists to support compiler developers reasoning about the code. If you hand write a .ll file, the hex syntax can be very handy. Besides, we need to parse floating point hex constants anyway.</div></blockquote><div><br></div><div><br></div><div>What I was saying is that I don't think we have a way to make a hex integer literal without the 'u' or 's' prefix. I assume nobody uses the 'u' or 's' prefix, so there's no harm in removing the parsing of such prefixed constants (i.e. all hex integer constants AFAICT). AFAICT, 0xdeadbeef is considered to have floating point type.</div><div><br></div><div>E.g.:</div><div><br></div><div><p style="margin:0px;font-size:12px;font-family:Menlo"><span style="color:rgb(52,187,199)">Sean</span>:~/pg/llvm/test/Integer <span style="color:rgb(195,55,32)">%</span> cat ~/tmp/testhexconstant.ll </p>
<p style="margin:0px;font-size:12px;font-family:Menlo">define i32 @foo() {</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">  ret i32 0xdeadbeef</p>
<p style="margin:0px;font-size:12px;font-family:Menlo">}</p>
<p style="margin:0px;font-size:12px;font-family:Menlo"><span style="color:rgb(52,187,199)">Sean</span>:~/pg/llvm/test/Integer <span style="color:rgb(83,48,225)">%</span> ~/pg/release/bin/llvm-as <~/tmp/testhexconstant.ll</p>
<p style="margin:0px;font-size:12px;font-family:Menlo"><b>/Users/Sean/pg/release/bin/llvm-as: <stdin>:2:11: </b><span style="color:rgb(195,55,32)"><b>error: </b></span><b>floating point constant invalid for type</b></p>
<p style="margin:0px;font-size:12px;font-family:Menlo">  ret i32 0xdeadbeef</p>
<p style="margin:0px;font-size:12px;font-family:Menlo;color:rgb(52,189,38)"><b>          ^</b></p>
<p style="margin:0px;font-size:12px;font-family:Menlo">zsh: exit 1     ~/pg/release/bin/llvm-as < ~/tmp/testhexconstant.ll</p></div><div><br></div><div><br></div><div>Grepping the repository finds some interesting related stuff:</div><div><br></div><div><p style="margin:0px;font-size:12px;font-family:Menlo"><span style="color:rgb(52,187,199)">Sean</span>:~/pg/llvm/test <span style="color:rgb(83,48,225)">%</span> git grep 'i32.*0x'</p></div><div><br></div><div>We seem to have cases where we add explicit comments regarding the hex form of an integer literal, presumably due to lack of an ability to just write one, e.g.:</div><div><br></div><div><p style="margin:0px;font-size:12px;font-family:Menlo">CodeGen/AArch64/bitfield-insert.ll<span style="color:rgb(52,187,199)">:</span>  %oldval_keep = and <span style="color:rgb(195,55,32)"><b>i32 %oldval, 2214592511 ; =0x</b></span>83ffffff</p></div><div><br></div><div>We also seem to have a test verifying that we accept a hacky workaround:</div><div><br></div><div><p style="margin:0px;font-size:12px;font-family:Menlo">Feature/fold-fpcast.ll<span style="color:rgb(52,187,199)">:</span>   ret <span style="color:rgb(195,55,32)"><b>i32 bitcast(float 0x</b></span>400D9999A0000000 to i32)</p></div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class=""><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 2, 2015 at 12:43 PM, Sean Silva <span dir="ltr"><<a href="mailto:chisophugis@gmail.com" target="_blank">chisophugis@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div>On Mon, Feb 2, 2015 at 9:51 AM, Robin Eklind <span dir="ltr"><<a href="mailto:carl.eklind@myport.ac.uk" target="_blank">carl.eklind@myport.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>(forgot to cc the list)<br>
<br></span>
Answers, questions and assumptions are inlined in the response.<br>
<br>
If someone with knowledge of the LLVM IR type system could take a look at my assumptions below I'd be very happy.<span><br>
<br>
On 01/30/2015 02:24 AM, Sean Silva wrote:<br>
</span><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On Thu, Jan 29, 2015 at 10:42 PM, Robin Eklind <<a href="mailto:carl.eklind@myport.ac.uk" target="_blank">carl.eklind@myport.ac.uk</a>><br>
wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Thank you for reviewing and commiting the patch Sean :) It was the first<br>
one I've ever submitted to LLVM and the whole process was really smooth!<br>
Using Phabricator with GitHub OAuth login was brilliant as it removed one<br>
more step for new contributors. I also feel very happy that the first patch<br>
ended up removing more code than it introduced :) Not likely to speed up<br>
the compilation process by a lot, but one can hope to keep the trend!<br>
<br>
</blockquote>
<br>
Great!<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
I read the blog post about the type system rewrite. Thank you for the<br>
link. It did clear up a lot of my uncertainties, but introduced a new one.<br>
Could you help me make sense of this part, which was presented under the<br>
"Identified structs have a 1-1 mapping with a name" section.<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
"... and the only types that can be named are identified structs"<br>
</blockquote>
<br>
Does this mean that other types cannot be named? What about type type "%x"<br>
in b.ll? It seems like I'm interpreting this in the wrong way. Could you<br>
help me make this clear? Is there a difference between a named type and an<br>
identified type (or are those two ways of saying the same thing)? If types<br>
other than structures can be given names, does this name impact type<br>
equality somehow?<br>
<br>
</blockquote>
<br>
I'll need to punt to someone else for these questions. I haven't dealt with<br>
this part of the IR in a while.<br>
<br>
</blockquote>
<br>
<br></span><span>
Anyone else knowledgeable in this area? I would like to list a set of assumptions that I've made after reading the blog post and experimenting with the reference implementation. If anyone could verify these assumptions, and of cause point out which are incorrect, I'd be very grateful.<br>
<br>
* Assumption 1 - all types can be given a name, not only structures.<br>
* Assumption 2 - the type name works as an alias for all types except structures, and it is ignored when calculating type equality.<br>
* Assumption 3 - for structures the type name works as an identity, and type equality depends on it.<br>
* Assumption 4 - type equality is calculated by comparing the base type (e.g. the underlying type of a type name identifier) of one type against another (recursively and for each element in the case of vectors, arrays and other derived types). In the case of identified structures the comparison is made strictly based on the structure's name, and in the case of structure literals the comparison is made in the same way as for other derived types.<br></span></blockquote><div><br></div></div></div><div>There are quite a few people on the list that can answer this. Just a matter of waiting for one of them to pipe up.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
<br>
<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br><span>
To keep up with the spirit of the original topic here are a few more items<br>
:)<br>
<br>
* Item 11 - hexadecimal integer constants<br>
<br>
The lexer handles hexadecimal integer constants, e.g. from<br>
lib/AsmParser/LLLexer.cpp<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
///    HexIntConstant  [us]0x[0-9A-Fa-f]+<br>
</blockquote>
<br>
This representation of integer constants is not mentioned in the language<br>
specification as far as I can tell.<br>
<br>
</span></blockquote><span>
<br>
I assume you are talking about the 'u' and 's' prefix? That seems like a<br>
historical artifact. The type system doesn't have signedness so there is no<br>
sense in which a constant can be "signed" or "unsigned". In fact, most<br>
places that even look at the signedness of the lexer's APSIntVal it's just<br>
to issue an error. A patch removing this old cruft would be great.<br>
<br>
</span></blockquote>
<br><span>
<br>
I'd be happy to remove this old cruft :) Just want to make sure I understood correctly. Are you referring to the prefix or the whole HexIntConstant representation? Because if we simply remove the prefix it would collide with the hexadecimal representation of floating point constants.<br></span></blockquote><div><br></div></span><div>If we don't currently accept 0xDEADBEEF as an integer constant, then it's probably safe to remove HexIntConstant altogether. That u and s prefixed stuff is clearly out of date by several years, so clearly nobody is relying on this if that is the only way to get a hex integer constant.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
<br>
It seems like clang has been using HexIntConstants in the past (and maybe still?), based on the following comment from lib/AsmParser/LLLexer.cpp:<br>
<br>
> // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by<br>
> // the CFE to avoid forcing it to deal with 64-bit numbers.<br>
<br>
Is clang still using this representation? If not, I'll start preparing a patch to get rid of the HexIntConstant parsing :)<br></span></blockquote><div><br></div></span><div>I don't think any code inside of clang ever directly writes .ll files; it all happens via the llvm libraries. So all you need to make sure is that nowhere inside the llvm libraries will write out .ll which has this construct.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br><span>
* Item 12 - constant expressions<br>
<br>
The documentation of sext states that the bit size of the constant must be<br>
smaller than the target type, but the implementation also accepts constants<br>
which have the same size as the target type. E.g. the documentation should<br>
be updated or the implementation made more strict.<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
sext (CST to TYPE)<br>
    Sign extend a constant to another type. The bit size of CST must be<br>
</blockquote>
smaller than the bit size of TYPE. Both types must be integers.<br>
<br>
The same goes for the trunc, zext, sext, fptrunc and fpext operations.<br>
Some refer to larger instead of smaller but none states that types of equal<br>
size is allowed.<br>
<br>
</span></blockquote><span>
<br>
Probably worth updating the documentation to what is actually allowed by<br>
the code. Could you please send a patch to LangRef? (and for convenience,<br>
can you point to the relevant source code for citation?).<br>
<br>
</span></blockquote><span>
<br>
I'll try to look into it. So far I've not found this in the source code, but rather by examining the behaviour of compiling .ll files with clang.<br></span></blockquote><div><br></div></span><div>Surely there is somewhere in the llvm libraries where we either reject or accept (through inaction) extension/truncation to types of the same size. Maybe the verifier?</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br><span>
* Item 13 - LocalVar and LocalID for named types<br>
<br>
This is more of a question. Why are types referred to using local names<br>
"%x" instead of global names "@x"? It seems inconsistent as local names are<br>
scoped to the function; a local variable name in one function refers to a<br>
different value from a local variable name in another. Since types are<br>
scoped to the module wouldn't a global name make more sense?<br>
<br>
</span></blockquote><span>
<br>
I doubt there's a particular rationale. I wouldn't pay too much attention<br>
to the sigils. They are pretty much arbitrary and just to make the lexer<br>
simpler, similar to using introducer keywords makes the parser simpler.<br>
<br>
A more concerning inconsistency regarding sigils (if choice of sigils were<br>
to be concerning) is the use of the same sigils for types and values. Types<br>
are a purely compile-time thing while locals and globals actually<br>
correspond to materializable run-time values (slightly muddled by things<br>
like dbg.declare and llvm.assume).<br>
<br>
</span></blockquote><span>
<br>
Would it make sense to start a discussion about this inconsistency where the same sigil is used for types and values? It the compatibility between releases is ensured using the Bitcode format, it may be possible to introduce a patch to the assembly representation of LLVM IR. To port old files to the new representation one could convert .ll files to .bc using the current version of llvm-as, and then convert back using a newer version of llvm-dis. I can understand if this is a low priority issue, but discussing and fixing any inconsistency in the language makes sense and pays off in the long run.<br></span></blockquote><div><br></div></span><div>I don't think anybody really cares about the sigils. They are just there to simplify the lexer/parser code. In this case, the complexity of reconstructing the .ll files *including the FileCheck comments* is probably not worth it (especially since any mistakes effectively end up silently reducing our test coverage).</div><span><font color="#888888"><div><br></div><div>-- Sean Silva</div></font></span><div><div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span>
<br>
</span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br><div><div>
As always, I'm eager to hear more about the type system in particular. The<br>
compilation timed in at 120m36.240s while the test cases took 32m10.111s.<br>
It will be interesting to see if this goes up or down as time passes :)<br>
<br>
</div></div></blockquote><div><div>
<br>
Unfortunately probably up. On my main machine in college, a full build of<br>
LLVM + Clang took 20 minutes. Last I checked (quite some time ago), that<br>
machine took 40 minutes.<br>
<br>
Also, btw, you can do builddir/bin/llvm-lit llvm/test/path/to/test.ll to<br>
run just a single test while iterating (or shell glob a list of tests; or<br>
pass a directory). There's also a way to run a subset of the unittests, but<br>
I forget it off the top of my head.<br>
<br>
-- Sean Silva<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Cheers /Robin Eklind<br>
<br>
<br>
On 01/28/2015 08:31 PM, Sean Silva wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
On Wed, Jan 28, 2015 at 6:28 PM, Robin Eklind <<a href="mailto:carl.eklind@myport.ac.uk" target="_blank">carl.eklind@myport.ac.uk</a>><br>
wrote:<br>
<br>
  Hello Sean,<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Thank you for your reply. I'll give your suggestion to item 6 and 7 a try<br>
tonight. I'll start a compilation and let it run throughout the night. My<br>
laptop (x61s) is 8 years old by know, so compiling LLVM takes a little<br>
time<br>
:)<br>
<br>
<br>
</blockquote>
This is why I did so much documentation work when in college. The docs<br>
build much faster.<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Regarding item 8. I don't know if anyone is using "": in the wild so<br>
fixing the implementation might make sense. If not the documentation<br>
(e.g.<br>
the QuoteLabel comment) should be updated to be in line with the<br>
implementation.<br>
<br>
<br>
</blockquote>
FYI the textual IR doesn't have a compatibility guarantee (we try not to<br>
egregiously change it, but users don't expect .ll to work across<br>
versions).<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
I only included item 9 since I stumbled upon it once cross-referencing<br>
the<br>
source code with the language specification. Bitrot for a project of this<br>
size is to be expected.<br>
<br>
I'm still very interested to hear about the items related to types, e.g.<br>
item 1 and 2. Is there a good reference which describes how type equality<br>
works in LLVM IR? If the source code is the reference, could someone with<br>
the high level knowledge get me up to speed?<br>
<br>
<br>
</blockquote>
Off the top of my head maybe<br>
<a href="http://blog.llvm.org/2011/11/llvm-30-type-system-rewrite.html" target="_blank">http://blog.llvm.org/2011/11/<u></u>llvm-30-type-system-rewrite.<u></u>html</a><br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Item 1 still confuses me, so I'd be very happy if someone with more<br>
insight could clarify if this is the intended behaviour and if so the<br>
motivation behind it.<br>
<br>
As it so happens, I forgot to include item 10 :)<br>
<br>
* Item 10 - lli vs. clang output<br>
<br>
Using the same source files as before, it seems like lli and clang treats<br>
common linkage and constant variables differently. The following<br>
execution<br>
demonstrates the return value after executing i.ll, j.ll, k.ll and l.ll<br>
with lli and clang respectively:<br>
<br>
  $ clang i.ll && ./a.out ; echo $?<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
37<br>
<br>
$ lli i.ll ; echo $?<br>
37<br>
<br>
<br>
$ clang j.ll && ./a.out ; echo $?<br>
0<br>
<br>
$ lli j.ll ; echo $?<br>
42<br>
<br>
<br>
$ clang k.ll && ./a.out ; echo $?<br>
37<br>
<br>
$ lli k.ll ; echo $?<br>
37<br>
<br>
<br>
$ clang l.ll && ./a.out ; echo $?<br>
Segmentation fault<br>
139<br>
<br>
$ lli l.ll ; echo $?<br>
37<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
Some of these linkage combinations and operations have dubious semantics.<br>
Talking briefly with Rafael Espindola over a build, sounds like we should<br>
mostly tighten up the verifier to remove some of these weird cases. For<br>
example, storing to a constant is sort of .... I'm sort of surprised it<br>
works at all.<br>
<br>
-- Sean Silva<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Looking forward to hear more about type equality, or get a pointer as to<br>
where I can read up about it.<br>
<br>
Cheers /Robin Eklind<br>
<br>
<br>
<br>
On 01/28/2015 03:45 PM, Sean Silva wrote:<br>
<br>
  A couple quick comments inline (didn't touch on all points):<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
On Wed, Jan 28, 2015 at 1:49 AM, Robin Eklind <<a href="mailto:carl.eklind@myport.ac.uk" target="_blank">carl.eklind@myport.ac.uk</a><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
</blockquote>
wrote:<br>
<br>
   Hello everyone!<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
I've recently had a chance to familiarize myself with the nitty-gritty<br>
details of LLVM IR. It has been a great learning experience, sometimes<br>
frustrating or confusing but mostly rewarding.<br>
<br>
There are a few cases I've come across which seems odd to me. I've<br>
tried<br>
to cross reference with the language specification and the source code<br>
to<br>
the best of my abilities, but would like to reach out to an experienced<br>
crowd with a few questions.<br>
<br>
Could you help me out by taking a look at these examples? To my novice<br>
eyes they seem to highlight inconsistencies in LLVM IR (or the<br>
reference<br>
implementation), but it is quite likely that I've overlooked something.<br>
Please help me out.<br>
<br>
Note: the example source files have been attached and a copy is made<br>
available at <a href="https://github.com/mewplay/ll" target="_blank">https://github.com/mewplay/ll</a><br>
<br>
* Item 1 - named pointer types<br>
<br>
It is possible to create a named array pointer type (and many others),<br>
but<br>
not a named structure pointer type. E.g.<br>
<br>
%x = type [1 x i32]* ; valid.<br>
%x = type {i32}*     ; invalid.<br>
<br>
Is this the intended behaviour? Attaching a.ll, b.ll, c.ll and d.ll for<br>
reference. All files except d.ll compiles without error using clang<br>
version<br>
3.5.1 (tags/RELEASE_351/final).<br>
<br>
   $ clang d.ll<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
d.ll:3:16: error: expected top-level entity<br>
%x = type {i32}*<br>
                  ^<br>
1 error generated.<br>
<br>
<br>
</blockquote>
Does it have anything to do with type equality? (just a hunch)<br>
<br>
* Item 2 - equality of named types<br>
<br>
A named integer type is equivalent to its literal type counterpart, but<br>
the same is not true for named and literal structures. I am certain<br>
that<br>
I've read about this before, but can't seem to locate the right section<br>
of<br>
the language specification; could anyone point me in the right<br>
direction?<br>
Also, what is the motivation behind this decision? I've skimmed over<br>
the<br>
code which handles named structure types (in lib/IR/core.cpp), but<br>
would<br>
love to hear the high level idea.<br>
<br>
Attaching e.ll, f.ll, g.ll and h.ll for reference. All compile just<br>
file<br>
except h.ll, which produces the following error message (using the same<br>
version of clang as above):<br>
<br>
   $ clang h.ll<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
h.ll:10:23: error: argument is not of expected type '%x = type { i32<br>
}'<br>
           call void (%x)* @foo({i32} {i32 0})<br>
                                ^<br>
1 error generated.<br>
<br>
<br>
</blockquote>
* Item 3 - zero initialized common linkage variables<br>
<br>
According to the language specification common linkage variables are<br>
required to have a zero initializer [1]. If so, why are they also<br>
required<br>
to provide an initial value?<br>
<br>
Attaching i.ll and j.ll for reference. Both compiles just fine and once<br>
executed i.ll returns 37 and j.ll return 0. If the common linkage<br>
variable<br>
@x was not initialized to 0, j.ll would have returned 42.<br>
<br>
* Item 4 - constant common linkage variables<br>
<br>
The language specification states that common linkage variables may not<br>
be<br>
marked as constant [1]. The parser doesn't seem to enforce this<br>
restriction. Would doing so cause any problems?<br>
<br>
Attaching k.ll and l.ll for reference. Both compiles just fine, but<br>
once<br>
executed k.ll returns 37 (e.g. the constant variable was overwritten)<br>
while<br>
l.ll segfaults as expected when it tries to overwrite a read-only<br>
memory<br>
location.<br>
<br>
* Item 5 - appending linkage restrictions<br>
<br>
An extract from the language specification [1]:<br>
<br>
   "appending" linkage may only be applied to global variables of<br>
pointer<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
  to array type.<br>
</blockquote>
<br>
Similarly to item 4 this restriction isn't enforced by the parser.<br>
Would<br>
it make sense doing so, or is there any problem with such an approach?<br>
<br>
* Item 6 - hash token<br>
<br>
The hash token (#) is defined in lib/AsmParser/LLToken.h (release<br>
version<br>
3.5.0 of the LLVM source code) but doesn't seem to be used anywhere<br>
else<br>
in<br>
the source tree. Is this token a historical artefact or does it serve a<br>
purpose?<br>
<br>
<br>
  Try deleting it. If the tests pass send a patch. Same for item 7.<br>
</blockquote>
<br>
<br>
<br>
  * Item 7 - backslash token<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Similarly to item 7 the backslash token doesn't seem to serve a purpose<br>
(with regards to release version 3.5.0 of the LLVM source code). Is it<br>
used<br>
somewhere?<br>
<br>
* Item 8 - quoted labels<br>
<br>
A comment in lib/AsmParser/LLLexer.cpp (once again, release version<br>
3.5.0<br>
of the LLVM source code) describes quoted labels using the following<br>
regexp<br>
(e.g. at least one character between the double quotes):<br>
<br>
   ///   QuoteLabel        "[^"]+":<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
<br>
</blockquote>
In contrast the reference implementation accepts quoted labels with<br>
zero<br>
or more characters between the double quotes. Which is to be trusted?<br>
The<br>
comment makes more sense as the variable name would effectively be<br>
blank<br>
otherwise.<br>
<br>
<br>
  Looks an empty name just results in the thing becoming unnamed. That's<br>
</blockquote>
sort<br>
of confusing, but probably not harmful. Maybe we use an empty name as a<br>
sentinel for "unnamed", so it sort of just was an accident of the<br>
implementation.<br>
<br>
<br>
<br>
  * Item 9 - undocumented calling conventions<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
The following calling conventions are valid tokens but not described in<br>
the language references as of revision 223189:<br>
<br>
intel_ocl_bicc, x86_stdcallcc, x86_fastcallcc, x86_thiscallcc,<br>
kw_x86_vectorcallcc, arm_apcscc, arm_aapcscc, arm_aapcs_vfpcc,<br>
msp430_intrcc, ptx_kernel, ptx_device, spir_kernel, spir_func,<br>
x86_64_sysvcc, x86_64_win64cc, kw_ghccc<br>
<br>
<br>
   This is just bitrot.<br>
<br>
</blockquote>
<br>
-- Sean Silva<br>
<br>
<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Lastly I'd just like to thank the LLVM developers for all the time and<br>
hard work they've put into this project. I'd especially like to thank<br>
you<br>
for providing a language specification along side of the reference<br>
implementation! Keeping it up to date is a huge task, but also hugely<br>
important. Thank you!<br>
<br>
Kind regards<br>
/Robin Eklind<br>
<br>
[1]: <a href="http://llvm.org/docs/LangRef.html#linkage-types" target="_blank">http://llvm.org/docs/LangRef.<u></u>html#linkage-types</a><br>
<br>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
<br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote></blockquote>
<br>
</blockquote></blockquote>
<br>
</div></div></blockquote><div><div>
______________________________<u></u>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/<u></u>mailman/listinfo/llvmdev</a><br>
</div></div></blockquote></div></div></div><br></div></div>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div></div>