r258596 - [cfi] Do not emit bit set entry for available_externally vtables.
Evgeniy Stepanov via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 22 17:20:19 PST 2016
Author: eugenis
Date: Fri Jan 22 19:20:18 2016
New Revision: 258596
URL: http://llvm.org/viewvc/llvm-project?rev=258596&view=rev
Log:
[cfi] Do not emit bit set entry for available_externally vtables.
In the Itanium ABI, vtable may be emitted speculatively as an
available_externally global. Such vtable may not be present at the
link time and should not have a corresponding CFI bit set entry.
Added:
cfe/trunk/test/CodeGenCXX/cfi-speculative-vtable.cpp
Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=258596&r1=258595&r2=258596&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Fri Jan 22 19:20:18 2016
@@ -1496,7 +1496,8 @@ void ItaniumCXXABI::emitVTableDefinition
DC->getParent()->isTranslationUnit())
EmitFundamentalRTTIDescriptors();
- CGM.EmitVTableBitSetEntries(VTable, VTLayout);
+ if (!VTable->isDeclarationForLinker())
+ CGM.EmitVTableBitSetEntries(VTable, VTLayout);
}
bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(
Added: cfe/trunk/test/CodeGenCXX/cfi-speculative-vtable.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cfi-speculative-vtable.cpp?rev=258596&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/cfi-speculative-vtable.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/cfi-speculative-vtable.cpp Fri Jan 22 19:20:18 2016
@@ -0,0 +1,14 @@
+// Test that we don't emit a bit set entry for a speculative (available_externally) vtable.
+// This does not happen in the Microsoft ABI.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -O1 -fsanitize=cfi-vcall -fsanitize-trap=cfi-vcall -fsanitize-cfi-cross-dso -emit-llvm -o - %s | FileCheck %s
+
+class A {
+ public:
+ virtual ~A();
+};
+
+A a;
+
+// CHECK: @_ZTV1A ={{.*}} available_externally
+// CHECK-NOT: !{{.*}} = !{!{{.*}}, [4 x i8*]* @_ZTV1A, i64 16}
More information about the cfe-commits
mailing list