diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-09-03 21:05:13 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-09-03 21:05:13 +0000 |
| commit | 889a6758554c27ca4cf93502cfb5dc788cb47990 (patch) | |
| tree | bb70ea735753a700c6a65cb93c0742db7fb12b24 /lib/CodeGen/CGExpr.cpp | |
| parent | caa5ab264ddea332e8423af1ebcea50d0cb37206 (diff) | |
| download | clang-889a6758554c27ca4cf93502cfb5dc788cb47990.tar.gz clang-889a6758554c27ca4cf93502cfb5dc788cb47990.tar.bz2 clang-889a6758554c27ca4cf93502cfb5dc788cb47990.tar.xz | |
Don't emit an available_externally vtable pointing to linkonce_odr funcs.
This fixes pr13124.
From the discussion at
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2012-June/022606.html
we know that we cannot make funcions in a weak_odr vtable also weak_odr. They
should remain linkonce_odr.
The side effect is that we cannot emit a available_externally vtable unless we
also emit a copy of the function. This also has an issue: If codegen is going
to output a function, sema has to mark it used. Given llvm.org/pr9114, it looks
like sema cannot be more aggressive at marking functions used because
of vtables.
This leaves us with a few unpleasant options:
* Marking functions in vtables used if possible. This sounds a bit sloppy, so
we should avoid it.
* Producing available_externally vtables only when all the functions in it are
already used or weak_odr. This would cover cases like
--------------------
struct foo {
virtual ~foo();
};
struct bar : public foo {
virtual void zed();
};
void f() {
foo *x(new bar);
delete x;
}
void g(bar *x) {
x->~bar(); // force the destructor to be used
}
--------------------------
and
----------------------------------
template<typename T>
struct bar {
virtual ~bar();
};
template<typename T>
bar<T>::~bar() {
}
// make the destructor weak_odr instead of linkonce_odr
extern template class bar<int>;
void f() {
bar<int> *x(new bar<int>);
delete x;
}
----------------------------
These look like corner cases, so it is unclear if it is worth it.
* And finally: Just nuke this optimization. That is what this patch implements.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189852 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
0 files changed, 0 insertions, 0 deletions
