[cfe-dev] Gobal register variables marked local

Reid Kleckner rnk at google.com
Fri May 9 10:14:11 PDT 2014


Please don't make VarDecl ~4 bytes bigger just to support a rarely used gnu
extension.

I think it might be better to model the asm blob as an initializer, which
would save space and fix your tentative definition problems.


On Fri, May 9, 2014 at 4:29 AM, Renato Golin <renato.golin at linaro.org>wrote:

> Hi Rafael,
>
> I'm going down the route of marking the variable declaration as "named
> register" in SemaDecl (ActOnVariableDeclarator) and then adding the
> intrinsic at the initialization time.
>
> Since it has no explicit initializer, it ends up in the
> TentativeDefinitions array, which gets initialized in
> ActOnEndOfTranslationUnit. But that's not what I want, since this
> "variable" doesn't exist, per se, but I still need to keep it around
> for replacing all reads/writes by an intrinsic.
>
> Also, while parsing statements that contain a reference to this
> variable, the diagnostics on the use of the global variable detect an
> "undeclared local variable":
>
> named_reg_global.c:4:10: error: reference to local variable
> 'current_stack_pointer' declared in enclosing context
>   return current_stack_pointer;
> named_reg_global.c:1:24: note: 'current_stack_pointer' declared here
> register unsigned long current_stack_pointer asm("sp");
>
> This looks like I'm not setting the right flags beforehand, so that
> ParseStatement recognizes it's not a local variable, or just that I
> still haven't found the right place to do the substitution.
>
> ParseStatementOrDeclarationAfterAttributes has a switch with
> "identifier" in it, but that doesn't seem a specific enough place to
> add this logic. Any pointers?
>
> The changes I made to stop marking the declaration invalid and to mark
> it as "named register" is attached. Not that this would be the final
> patch, but it's helping me understand the code.
>
> cheers,
> --renato
>
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140509/74a4aa79/attachment.html>


More information about the cfe-dev mailing list