aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGClass.cpp
diff options
context:
space:
mode:
authorPiotr Padlewski <prazek@google.com>2015-08-27 21:35:41 +0000
committerPiotr Padlewski <prazek@google.com>2015-08-27 21:35:41 +0000
commit81461a4350a105f73b40c3212baafd2b66d3ce22 (patch)
tree99c95d7c72c6d247efa6911e625241f0b4af0712 /clang/lib/CodeGen/CGClass.cpp
parent525f746710c9b132b20b653d5d8bd130e9bd5e59 (diff)
downloadllvm-81461a4350a105f73b40c3212baafd2b66d3ce22.zip
llvm-81461a4350a105f73b40c3212baafd2b66d3ce22.tar.gz
llvm-81461a4350a105f73b40c3212baafd2b66d3ce22.tar.bz2
Assume loads fix #2
There was linker problem, and it turns out that it is not always safe to refer to vtable. If the vtable is used, then we can refer to it without any problem, but because we don't know when it will be used or not, we can only check if vtable is external or it is safe to to emit it speculativly (when class it doesn't have any inline virtual functions). It should be fixed in the future. http://reviews.llvm.org/D12385 llvm-svn: 246214
Diffstat (limited to 'clang/lib/CodeGen/CGClass.cpp')
-rw-r--r--clang/lib/CodeGen/CGClass.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGClass.cpp b/clang/lib/CodeGen/CGClass.cpp
index cd39749..507bae8 100644
--- a/clang/lib/CodeGen/CGClass.cpp
+++ b/clang/lib/CodeGen/CGClass.cpp
@@ -1857,8 +1857,15 @@ void CodeGenFunction::EmitCXXConstructorCall(const CXXConstructorDecl *D,
// with a vtable. We don't do this for base subobjects for two reasons:
// first, it's incorrect for classes with virtual bases, and second, we're
// about to overwrite the vptrs anyway.
+ // We also have to make sure if we can refer to vtable:
+ // - If vtable is external then it's safe to use it (for available_externally
+ // CGVTables will make sure if it can emit it).
+ // - Otherwise we can refer to vtable if it's safe to speculatively emit.
+ // FIXME: If vtable is used by ctor/dtor, we are always safe to refer to it.
if (CGM.getCodeGenOpts().OptimizationLevel > 0 &&
- ClassDecl->isDynamicClass() && Type != Ctor_Base)
+ ClassDecl->isDynamicClass() && Type != Ctor_Base &&
+ (CGM.getVTables().isVTableExternal(ClassDecl) ||
+ CGM.getCXXABI().canSpeculativelyEmitVTable(ClassDecl)))
EmitVTableAssumptionLoads(ClassDecl, This);
}