LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 29 - C++ front-end is not generating linkonce linkage type when it can
Summary: C++ front-end is not generating linkonce linkage type when it can
Status: RESOLVED FIXED
Alias: None
Product: tools
Classification: Unclassified
Component: llvm-g++ (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Chris Lattner
URL:
Keywords: quality-of-implementation
Depends on: 58
Blocks:
  Show dependency tree
 
Reported: 2003-10-10 00:12 PDT by Chris Lattner
Modified: 2010-02-22 12:53 PST (History)
1 user (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Lattner 2003-10-10 00:12:46 PDT
In this testcase:

inline int foo() {
  static int X = 0;
  return ++X;
}
int bar() {
  return foo();
}

The LLVM global variable declaration for the X variable should have "linkonce",
not "weak" linkage.

It is not clear how to get this information from the GCC front-end.
Comment 1 Chris Lattner 2003-10-10 00:14:36 PDT
Just to be perfectly clear here: this does not cause incorrect compilation at
all.  This just prevents the LLVM optimizers from deleting the variable when it
is unreferenced in a translation unit.
Comment 2 Chris Lattner 2003-10-26 14:18:22 PST
A question about this has now been asked on the GCC list:
http://gcc.gnu.org/ml/gcc/2003-10/msg01272.html
Comment 3 Chris Lattner 2003-10-27 00:23:46 PST
More analysis is available here:
http://gcc.gnu.org/ml/gcc/2003-10/msg01292.html

Fixing this bug is critical for compiling reasonably sized C++ translation
units, so I'm upgrading it's severity to 'normal', and targetting it to 1.1.
Comment 4 Chris Lattner 2003-10-27 11:02:06 PST
This has now been fixed by 'ifdef'ing out the "win32" specific case in this post:
http://gcc.gnu.org/ml/gcc/2003-10/msg01309.html

-Chris
Comment 5 Chris Lattner 2003-11-02 00:38:50 PST
New testcase for another form of this problem:
test/Regression/C++Frontend/2003-11-02-WeakLinkage.cpp.tr

This instance of the bug has also been fixed in the CFE now.