Bug 50676 - Partitioning may fail with presence of static variables referring to function labels
Summary: Partitioning may fail with presence of static variables referring to function...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: ---
Assignee: Jan Hubicka
URL:
Keywords: patch
: 61635 83375 (view as bug list)
Depends on:
Blocks:
 
Reported: 2011-10-09 12:44 UTC by Jan Hubicka
Modified: 2023-10-25 06:08 UTC (History)
6 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-03-30 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Hubicka 2011-10-09 12:44:55 UTC
Noticed the bug while preparing -fno-topelvel-reorder patch for Andi.
With WIP version of patch I got following failure building Mozilla:
/tmp/ccPpJShB.ltrans29.ltrans.o:ccPpJShB.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.7094572: error: undefined reference to
+'.L79667'                                                                                                                                                                          
/tmp/ccPpJShB.ltrans29.ltrans.o:ccPpJShB.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.7094572: error: undefined reference to
+'.L79668'                                                                                                                                                                          
/tmp/ccPpJShB.ltrans29.ltrans.o:ccPpJShB.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.7094572: error: undefined reference to
+'.L79669'                                                                                                                                                                          
/tmp/ccPpJShB.ltrans29.ltrans.o:ccPpJShB.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.7094572: error: undefined reference to
+'.L79670'                                                                                                                                                                          
/tmp/ccPpJShB.ltrans29.ltrans.o:ccPpJShB.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.7094572: error: undefined reference to
+'.L79671' 

We will need artificial testcase for that that is bit tricky because it involves putting function into one partition and its local static variable into another, but clearly ipa-reference is not recording the cases where address of local label is taken and thus partitioning happily breaks such code.

Honza
Comment 1 Markus Trippelsdorf 2011-10-09 13:04:28 UTC
Have a look at PR50620. I can provide 30 different testcases
for this issue ;-).
Comment 2 Jan Hubicka 2011-10-09 13:17:58 UTC
> Have a look at PR50620. I can provide 30 different testcases
> for this issue ;-).
Those are different problems (i.e. not involving labels with address taken).
I will look into that now.

Honza
Comment 3 Markus Trippelsdorf 2011-11-07 10:49:23 UTC
Just hit the same problem today:
...
/tmp/ccNz0HZT.ltrans29.ltrans.o:ccNz0HZT.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.98063: 
error: undefined reference to '.L3709'
/tmp/ccNz0HZT.ltrans29.ltrans.o:ccNz0HZT.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.98063: 
error: undefined reference to '.L3710'
/tmp/ccNz0HZT.ltrans29.ltrans.o:ccNz0HZT.ltrans29.o:function _ZZN2js9InterpretEP9JSContextPNS_10StackFrameENS_10InterpModeEE15normalJumpTable.98063:
error: undefined reference to '.L3711'
...
Comment 4 Jan Hubicka 2015-03-30 07:29:04 UTC
*** Bug 61635 has been marked as a duplicate of this bug. ***
Comment 5 Jan Hubicka 2015-03-30 07:33:19 UTC
Patch posted https://gcc.gnu.org/ml/gcc-patches/2015-03/msg01526.html
Comment 6 Andi Kleen 2015-07-18 17:37:01 UTC
The patch doesn't seem to be checked in yet. Is there a reason for that?
Comment 7 Eric Gallager 2018-08-14 02:21:22 UTC
(In reply to Andi Kleen from comment #6)
> The patch doesn't seem to be checked in yet. Is there a reason for that?

Maybe people just forgot about it?
Comment 8 Andrew Pinski 2021-12-24 11:57:10 UTC
*** Bug 83375 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Pinski 2021-12-24 11:57:58 UTC
Simple testcase from the other bug:
/* { dg-do link } */
/* { dg-options "-flto-partition=max -flto -O2" } */
/* { dg-require-effective-target lto } */

/* Test for putting static with label references into same LTO partition */

int x, y;

void f(int i)
{
	typedef void *ptr;
	static ptr data[] = {&&l1,&&l2,&&l3,&&l4};

	goto *data[i];
l1:
	x++;
l2:
	y++;
l3:
	x--;
l4:
	y--;
}

int main(void)
{
	f(x);
	return 0;
}