[PATCH] D25779: MS ABI: Don't assert when generating virtual function call with virtual bases and -flto (PR30731)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 19 10:51:50 PDT 2016
hans created this revision.
hans added a reviewer: pcc.
hans added a subscriber: cfe-commits.
Herald added a subscriber: mehdi_amini.
getClassAtVTableLocation() was calling ASTRecordLayout::getBaseClassOffset() on a virtual base, causing an assert.
https://reviews.llvm.org/D25779
Files:
lib/CodeGen/MicrosoftCXXABI.cpp
test/CodeGenCXX/pr30731.cpp
Index: test/CodeGenCXX/pr30731.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/pr30731.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple i386-pc-win32 -emit-llvm -flto -std=c++11 -o - %s | FileCheck %s
+
+struct A {
+ virtual ~A();
+};
+
+struct B {};
+
+struct C {
+ virtual void f();
+};
+
+struct S : A, virtual B, C {
+ void f() override;
+};
+
+void f(S* s) { s->f(); }
+
+// CHECK-LABEL: define void @"\01?f@@YAXPAUS@@@Z"
+// CHECK: call
+// CHECK: ret void
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===================================================================
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -1773,15 +1773,8 @@
CharUnits MaxBaseOffset;
for (auto &&B : RD->bases()) {
const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl();
- CharUnits BaseOffset = Layout.getBaseClassOffset(Base);
- if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) {
- MaxBase = Base;
- MaxBaseOffset = BaseOffset;
- }
- }
- for (auto &&B : RD->vbases()) {
- const CXXRecordDecl *Base = B.getType()->getAsCXXRecordDecl();
- CharUnits BaseOffset = Layout.getVBaseClassOffset(Base);
+ CharUnits BaseOffset = B.isVirtual() ? Layout.getVBaseClassOffset(Base)
+ : Layout.getBaseClassOffset(Base);
if (BaseOffset <= Offset && BaseOffset >= MaxBaseOffset) {
MaxBase = Base;
MaxBaseOffset = BaseOffset;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25779.75171.patch
Type: text/x-patch
Size: 1492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161019/1349e7fc/attachment.bin>
More information about the cfe-commits
mailing list