<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Fri, May 9, 2014 at 10:19 AM, Renato Golin <span dir="ltr"><<a href="mailto:renato.golin@linaro.org" target="_blank">renato.golin@linaro.org</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 class="">On 9 May 2014 18:14, Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br>
> Please don't make VarDecl ~4 bytes bigger just to support a rarely used gnu<br>
> extension.<br>
<br>
</div>Hi Reid,<br>
<br>
As I said, that's just a marker to help me find the right decl while<br>
debugging. I wouldn't leave it in the final patch.</blockquote><div><br></div><div>Sorry, reading is hard.</div><div><br></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="">
> I think it might be better to model the asm blob as an initializer, which<br>
> would save space and fix your tentative definition problems.<br>
<br>
</div>The problem is that this "variable" will never be properly initialized<br>
because it only refers to access to a register. So, what I need to do<br>
is to keep the VarDecl around, maybe even lying about it's<br>
initialization status, and detect that the variable is a named<br>
register (SC_Register + AsmLableAttr) and emit the intrinsic instead.<br>
<br>
I'm looking for the common place where all the reads/writes to<br>
variables get lowered, so that I only change in one/two place/s.<br></blockquote><div><br></div><div>It's not just lib/CodeGen/CGExpr.cpp? That seems like the kind of place where we'd lower a regular old DeclRefExpr referring to a local or global variable.<br>
</div><div><br></div><div>It looks like Sema is confused with your variable because it has SC_Register for its storage class, which makes hasGlobalStorage() return false. This is the relevant code:</div><div><br></div><div>
<div> /// hasLocalStorage - Returns true if a variable with function scope</div><div> /// is a non-static local variable.</div><div> bool hasLocalStorage() const {</div><div> if (getStorageClass() == SC_None)</div>
<div> // Second check is for C++11 [dcl.stc]p4.</div><div> return !isFileVarDecl() && getTSCSpec() == TSCS_unspecified;</div><div><br></div><div> // Return true for: Auto, Register.</div><div> // Return false for: Extern, Static, PrivateExtern, OpenCLWorkGroupLocal.</div>
<div><br></div><div> return getStorageClass() >= SC_Auto;</div><div> }</div></div><div>...</div><div><div> /// \brief Returns true for all variables that do not have local storage.</div><div> ///</div><div> /// This includes all global variables as well as static variables declared</div>
<div> /// within a function.</div><div> bool hasGlobalStorage() const { return !hasLocalStorage(); }</div></div><div><br></div><div>Maybe hasLocalStorage() should be fixed to work on non-function scope variables, or assert that it is only ever called on function scope variables.</div>
</div></div></div>