r288721 - CodeGen: fix windows itanium RTTI in EH mode

Saleem Abdulrasool via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 5 14:40:20 PST 2016


Author: compnerd
Date: Mon Dec  5 16:40:20 2016
New Revision: 288721

URL: http://llvm.org/viewvc/llvm-project?rev=288721&view=rev
Log:
CodeGen: fix windows itanium RTTI in EH mode

When emitting RTTI for EH only, we would mark the locally defined (LinkOnceODR)
RTTI definition as dllimport, which is incorrect.  Ensure that if we are
generating the type information for EH only, it is marked as LinkOnceODR and we
do not make it dllimport.

Modified:
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=288721&r1=288720&r2=288721&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Dec  5 16:40:20 2016
@@ -3133,7 +3133,7 @@ llvm::Constant *ItaniumRTTIBuilder::Buil
     if (DLLExport || (RD && RD->hasAttr<DLLExportAttr>())) {
       TypeName->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
       GV->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
-    } else if (RD && RD->hasAttr<DLLImportAttr>()) {
+    } else if (CGM.getLangOpts().RTTI && RD && RD->hasAttr<DLLImportAttr>()) {
       TypeName->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
       GV->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
 

Modified: cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp?rev=288721&r1=288720&r2=288721&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/windows-itanium-type-info.cpp Mon Dec  5 16:40:20 2016
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i686-windows-itanium -fdeclspec -fcxx-exceptions -fno-rtti -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-EH-IMPORT
 
 namespace __cxxabiv1 {
 class __declspec(dllexport) __fundamental_type_info {
@@ -19,6 +20,10 @@ derived::~derived() {
   method();
 }
 
+void f() {
+  throw base();
+}
+
 // CHECK-DAG: @_ZTIi = dllexport constant
 // CHECK-DAG: @_ZTSi = dllexport constant
 
@@ -30,3 +35,6 @@ derived::~derived() {
 // CHECK-DAG: @_ZTS4base = external dllimport constant
 // CHECK-NOT: @_ZTV4base = external dllimport constant
 
+// CHECK-EH-IMPORT: @_ZTS4base = linkonce_odr constant
+// CHECK-EH-IMPORT: @_ZTI4base = linkonce_odr constant
+




More information about the cfe-commits mailing list