Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-fvisibility=hidden does not work for method on an inner struct of an extern template class #8579

Closed
nico opened this issue Sep 22, 2010 · 3 comments
Labels
bugzilla Issues migrated from bugzilla c++

Comments

@nico
Copy link
Contributor

nico commented Sep 22, 2010

Bugzilla Link 8207
Resolution FIXED
Resolved on Sep 27, 2010 16:36
Version unspecified
OS All
CC @DougGregor,@ismail

Extended Description

This is another try to get to the bottom of http://crbug.com/56471

hummer:delta thakis$ cat string16.ii
typedef long unsigned int size_t;
namespace std {
template
class basic_string {
private:
struct _Rep {
void _M_clone();
};
};
template
void basic_string<_CharT>::_Rep::_M_clone() {}
}
typedef unsigned short char16;
extern template class std::basic_string;
template class std::basic_string;

_M_clone becomes a private external symbol in gcc with -fvisibility=hidden:

hummer:delta thakis$ gcc -c string16.ii -fvisibility=hidden
hummer:delta thakis$ nm -m string16.o
0000000000000010 (__TEXT,__eh_frame) non-external EH_frame1
0000000000000000 (__TEXT,__text) private external __ZNSbItE4_Rep8_M_cloneEv
0000000000000030 (__TEXT,__eh_frame) private external __ZNSbItE4_Rep8_M_cloneEv.eh
(undefined) external ___gxx_personality_v0

It doesn't do that in clang:

hummer:delta thakis$ ~/src/llvm/Release+Asserts/bin/clang -c string16.ii -fvisibility=hidden
hummer:delta thakis$ nm -m string16.o
0000000000000010 (__TEXT,__eh_frame) non-external EH_frame0
0000000000000000 (__TEXT,__textcoal_nt) weak external __ZNSbItE4_Rep8_M_cloneEv
0000000000000028 (__TEXT,__eh_frame) weak external __ZNSbItE4_Rep8_M_cloneEv.eh

It works fine in clang if I move the method out of the containing inner struct or make the class not a template class.

@nico
Copy link
Contributor Author

nico commented Sep 25, 2010

Simpler repro case:

template
class C {
struct Inner {
void f();
};
};
template void C::Inner::f() {}
extern template class C;
template class C;

@nico
Copy link
Contributor Author

nico commented Sep 27, 2010

@nico
Copy link
Contributor Author

nico commented Sep 27, 2010

Fixed in r114874.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
Michael137 added a commit to Michael137/llvm-project that referenced this issue Apr 30, 2024
…ork/lazy-method-loading

Note, this is a no-op when the LLDB setting
`plugin.typesystem.clang.experimental-redecl-completion` is not set (which is currently the default). So this patch has no effect unless the user explicitly opts into it.

The type-completion rework (aka redecl-completion) implemented in apple#8222 comes with a large performance penalty, since we now eagerly complete `RecordType`s. Completing a `RecordType` previously unconditionally resolved all member functions of said type. With redecl-completion completion, however, this meant we were now pulling in many more definitions than needed. Without redecl-completion, this isn't a problem, since importing method parameters is cheap (they are imported minimally), so we wouldn't notice that we always resolved all member functions.

This patch tries to load methods lazily when in redecl-completion mode. We do this by introducing a new `ExternalASTSource::FindExternalVisibleMethods` API which Clang calls when parsing a member access expression. The callback into LLDB will do a `FindFunctions` call for all methods with the method name we're looking for, filters out any mismatches, and lets Clang continue with its parsing. We still load following methods eagerly:
1. virtual functions: currently overrides are resolved in `CompleteRecordType`
2. operators: currently I couldn't find a point at which Clang can call into LLDB here to facilitate lazy loading
3. ctors/dtors: same reason as (2)

In our benchmark harness, we saw this patch bring down redecl-completion expression evaluation performance on-par with top-of-tree expression evaluation.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++
Projects
None yet
Development

No branches or pull requests

1 participant