This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug lto/86442] Wrong error: global register variable follows a function definition when using LTO
- From: "hubicka at ucw dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Mon, 09 Jul 2018 15:24:30 +0000
- Subject: [Bug lto/86442] Wrong error: global register variable follows a function definition when using LTO
- Auto-submitted: auto-generated
- References: <bug-86442-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86442
--- Comment #1 from Jan Hubicka <hubicka at ucw dot cz> ---
> Following wrong error is printed with LTO:
>
> $ cat global.cpp
> register int a __asm__("r12");
>
> class b {
> public:
> b();
> };
>
> b c;
>
> int main() { a = 3; }
>
> $ g++ global.cpp -O2 -flto
> global.cpp: In function ‘main’:
> global.cpp:1:14: error: global register variable follows a function definition
> register int a __asm__("r12");
> ^
> lto-wrapper: fatal error: g++ returned 1 exit status
> compilation terminated.
> /usr/lib64/gcc/x86_64-suse-linux/8/../../../../x86_64-suse-linux/bin/ld: error:
> lto-wrapper failed
> collect2: error: ld returned 1 exit status
Global register variables are not really working with LTO (because they should
be part of the function context since they may differ across units).
We could try to fix them for gcc 9. I was thinking a bit about it, but it
would
need to attach the information somewhere into optimization node and make
inliner
to not inline across different globally allocated registers.
It is overall questionable how global registers should interact with the symbol
table.
Honza