<div dir="ltr">I think either this or r212125 broke "check-asan" and Chromium build but it was hidden by another build failure (r211216).<div><br></div><div>Can you please take a look at "TestCases/Windows/dll_cerr.cc" (or Chromium failures) ?</div>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-07-02 2:24 GMT+04:00 David Majnemer <span dir="ltr"><<a href="mailto:david.majnemer@gmail.com" target="_blank">david.majnemer@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: majnemer<br>
Date: Tue Jul 1 17:24:56 2014<br>
New Revision: 212138<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=212138&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=212138&view=rev</a><br>
Log:<br>
Driver: Handle /GR- in a compatible way with MSVC<br>
<br>
There are slight differences between /GR- and -fno-rtti which made<br>
mapping one to the other inappropriate.<br>
<br>
-fno-rtti disables dynamic_cast, typeid, and does not emit RTTI related<br>
information for the v-table.<br>
<br>
/GR- does not generate complete object locators and thus will not<br>
reference them in vftables. However, constructs like dynamic_cast and<br>
typeid are permitted.<br>
<br>
This should bring our implementation of RTTI up to semantic parity with<br>
MSVC modulo bugs.<br>
<br>
Added:<br>
cfe/trunk/test/CodeGenCXX/microsoft-no-rtti-data.cpp<br>
Modified:<br>
cfe/trunk/include/clang/Basic/LangOptions.def<br>
cfe/trunk/include/clang/Driver/CC1Options.td<br>
cfe/trunk/include/clang/Driver/CLCompatOptions.td<br>
cfe/trunk/lib/AST/VTableBuilder.cpp<br>
cfe/trunk/lib/Basic/Targets.cpp<br>
cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp<br>
cfe/trunk/lib/CodeGen/MicrosoftRTTI.cpp<br>
cfe/trunk/lib/Driver/Tools.cpp<br>
cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
cfe/trunk/test/Driver/cl-fallback.c<br>
cfe/trunk/test/Driver/cl-options.c<br>
<br>
Modified: cfe/trunk/include/clang/Basic/LangOptions.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)<br>
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Jul 1 17:24:56 2014<br>
@@ -84,6 +84,7 @@ LANGOPT(CXXExceptions , 1, 0, "C++ e<br>
LANGOPT(SjLjExceptions , 1, 0, "setjmp-longjump exception handling")<br>
LANGOPT(TraditionalCPP , 1, 0, "traditional CPP emulation")<br>
LANGOPT(RTTI , 1, 1, "run-time type information")<br>
+LANGOPT(RTTIData , 1, 1, "emit run-time type information data")<br>
LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout")<br>
LANGOPT(Freestanding, 1, 0, "freestanding implementation")<br>
LANGOPT(NoBuiltin , 1, 0, "disable builtin functions")<br>
<br>
Modified: cfe/trunk/include/clang/Driver/CC1Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Jul 1 17:24:56 2014<br>
@@ -484,6 +484,8 @@ def fobjc_subscripting_legacy_runtime :<br>
HelpText<"Allow Objective-C array and dictionary subscripting in legacy runtime">;<br>
def vtordisp_mode_EQ : Joined<["-"], "vtordisp-mode=">,<br>
HelpText<"Control vtordisp placement on win32 targets">;<br>
+def fno_rtti_data : Flag<["-"], "fno-rtti-data">,<br>
+ HelpText<"Control emission of RTTI data">;<br>
<br>
//===----------------------------------------------------------------------===//<br>
// Header Search Options<br>
<br>
Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)<br>
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Tue Jul 1 17:24:56 2014<br>
@@ -58,8 +58,8 @@ def _SLASH_c : CLFlag<"c">, HelpText<"Co<br>
def _SLASH_D : CLJoinedOrSeparate<"D">, HelpText<"Define macro">,<br>
MetaVarName<"<macro[=value]>">, Alias<D>;<br>
def _SLASH_E : CLFlag<"E">, HelpText<"Preprocess to stdout">, Alias<E>;<br>
-def _SLASH_GR : CLFlag<"GR">, HelpText<"Enable RTTI">, Alias<frtti>;<br>
-def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable RTTI">, Alias<fno_rtti>;<br>
+def _SLASH_GR : CLFlag<"GR">, HelpText<"Enable emission of RTTI data">;<br>
+def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable emission of RTTI data">;<br>
def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">,<br>
Alias<fwritable_strings>;<br>
def _SLASH_Gy : CLFlag<"Gy">, HelpText<"Put each function in its own section">,<br>
<br>
Modified: cfe/trunk/lib/AST/VTableBuilder.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/VTableBuilder.cpp?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/VTableBuilder.cpp (original)<br>
+++ cfe/trunk/lib/AST/VTableBuilder.cpp Tue Jul 1 17:24:56 2014<br>
@@ -2579,7 +2579,7 @@ public:<br>
Overriders(MostDerivedClass, CharUnits(), MostDerivedClass) {<br>
// Only include the RTTI component if we know that we will provide a<br>
// definition of the vftable.<br>
- HasRTTIComponent = Context.getLangOpts().RTTI &&<br>
+ HasRTTIComponent = Context.getLangOpts().RTTIData &&<br>
!MostDerivedClass->hasAttr<DLLImportAttr>();<br>
if (HasRTTIComponent)<br>
Components.push_back(VTableComponent::MakeRTTI(MostDerivedClass));<br>
<br>
Modified: cfe/trunk/lib/Basic/Targets.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Basic/Targets.cpp (original)<br>
+++ cfe/trunk/lib/Basic/Targets.cpp Tue Jul 1 17:24:56 2014<br>
@@ -572,7 +572,7 @@ protected:<br>
void getVisualStudioDefines(const LangOptions &Opts,<br>
MacroBuilder &Builder) const {<br>
if (Opts.CPlusPlus) {<br>
- if (Opts.RTTI)<br>
+ if (Opts.RTTIData)<br>
Builder.defineMacro("_CPPRTTI");<br>
<br>
if (Opts.Exceptions)<br>
<br>
Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Tue Jul 1 17:24:56 2014<br>
@@ -1152,7 +1152,7 @@ llvm::GlobalVariable *MicrosoftCXXABI::g<br>
llvm::GlobalValue::ExternalLinkage;<br>
llvm::ArrayType *VTableType =<br>
llvm::ArrayType::get(CGM.Int8PtrTy, NumVTableSlots);<br>
- if (getContext().getLangOpts().RTTI) {<br>
+ if (getContext().getLangOpts().RTTIData) {<br>
VTableLinkage = llvm::GlobalValue::PrivateLinkage;<br>
VTableName = "";<br>
}<br>
@@ -1163,7 +1163,8 @@ llvm::GlobalVariable *MicrosoftCXXABI::g<br>
CGM.getModule(), VTableType, /*isConstant=*/true, VTableLinkage,<br>
/*Initializer=*/nullptr, VTableName);<br>
VTable->setUnnamedAddr(true);<br>
- if (getContext().getLangOpts().RTTI && !RD->hasAttr<DLLImportAttr>()) {<br>
+ if (getContext().getLangOpts().RTTIData &&<br>
+ !RD->hasAttr<DLLImportAttr>()) {<br>
llvm::Value *GEPIndices[] = {llvm::ConstantInt::get(CGM.IntTy, 0),<br>
llvm::ConstantInt::get(CGM.IntTy, 1)};<br>
llvm::Constant *VTableGEP =<br>
<br>
Modified: cfe/trunk/lib/CodeGen/MicrosoftRTTI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftRTTI.cpp?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftRTTI.cpp?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/MicrosoftRTTI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/MicrosoftRTTI.cpp Tue Jul 1 17:24:56 2014<br>
@@ -508,7 +508,7 @@ llvm::Constant *CodeGenModule::getMSType<br>
llvm::Constant *<br>
CodeGenModule::getMSCompleteObjectLocator(const CXXRecordDecl *RD,<br>
const VPtrInfo *Info) {<br>
- if (!getLangOpts().RTTI)<br>
+ if (!getLangOpts().RTTIData)<br>
return llvm::Constant::getNullValue(Int8PtrTy);<br>
return MSRTTIBuilder(*this, RD).getCompleteObjectLocator(Info);<br>
}<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Tue Jul 1 17:24:56 2014<br>
@@ -4193,15 +4193,7 @@ void Clang::ConstructJob(Compilation &C,<br>
(InputType == types::TY_C || InputType == types::TY_CXX)) {<br>
Command *CLCommand = getCLFallback()->GetCommand(C, JA, Output, Inputs,<br>
Args, LinkingOutput);<br>
- // RTTI support in clang-cl is a work in progress. Fall back to MSVC early<br>
- // if we are using 'clang-cl /fallback /GR'.<br>
- // FIXME: Remove this when RTTI is finished.<br>
- if (Args.hasFlag(options::OPT_frtti, options::OPT_fno_rtti, false)) {<br>
- D.Diag(diag::warn_drv_rtti_fallback) << CLCommand->getExecutable();<br>
- C.addCommand(CLCommand);<br>
- } else {<br>
- C.addCommand(new FallbackCommand(JA, *this, Exec, CmdArgs, CLCommand));<br>
- }<br>
+ C.addCommand(new FallbackCommand(JA, *this, Exec, CmdArgs, CLCommand));<br>
} else {<br>
C.addCommand(new Command(JA, *this, Exec, CmdArgs));<br>
}<br>
@@ -4446,9 +4438,10 @@ void Clang::AddClangCLArgs(const ArgList<br>
if (Arg *A = Args.getLastArg(options::OPT_show_includes))<br>
A->render(Args, CmdArgs);<br>
<br>
- // RTTI is currently not supported, so disable it by default.<br>
- if (!Args.hasArg(options::OPT_frtti, options::OPT_fno_rtti))<br>
- CmdArgs.push_back("-fno-rtti");<br>
+ // This controls whether or not we emit RTTI data for polymorphic types.<br>
+ if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,<br>
+ /*default=*/false))<br>
+ CmdArgs.push_back("-fno-rtti-data");<br>
<br>
const Driver &D = getToolChain().getDriver();<br>
EHFlags EH = parseClangCLEHFlags(D, Args);<br>
@@ -7709,9 +7702,9 @@ Command *visualstudio::Compile::GetComma<br>
// Flags for which clang-cl have an alias.<br>
// FIXME: How can we ensure this stays in sync with relevant clang-cl options?<br>
<br>
- if (Arg *A = Args.getLastArg(options::OPT_frtti, options::OPT_fno_rtti))<br>
- CmdArgs.push_back(A->getOption().getID() == options::OPT_frtti ? "/GR"<br>
- : "/GR-");<br>
+ if (Args.hasFlag(options::OPT__SLASH_GR_, options::OPT__SLASH_GR,<br>
+ /*default=*/false))<br>
+ CmdArgs.push_back("/GR-");<br>
if (Arg *A = Args.getLastArg(options::OPT_ffunction_sections,<br>
options::OPT_fno_function_sections))<br>
CmdArgs.push_back(A->getOption().getID() == options::OPT_ffunction_sections<br>
<br>
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Jul 1 17:24:56 2014<br>
@@ -1447,6 +1447,7 @@ static void ParseLangArgs(LangOptions &O<br>
Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);<br>
<br>
Opts.RTTI = !Args.hasArg(OPT_fno_rtti);<br>
+ Opts.RTTIData = Opts.RTTI && !Args.hasArg(OPT_fno_rtti_data);<br>
Opts.Blocks = Args.hasArg(OPT_fblocks);<br>
Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);<br>
Opts.Modules = Args.hasArg(OPT_fmodules);<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/microsoft-no-rtti-data.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-no-rtti-data.cpp?rev=212138&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-no-rtti-data.cpp?rev=212138&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/microsoft-no-rtti-data.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/microsoft-no-rtti-data.cpp Tue Jul 1 17:24:56 2014<br>
@@ -0,0 +1,21 @@<br>
+// RUN: %clang_cc1 %s -fno-rtti-data -triple=i386-pc-win32 -o - -emit-llvm | FileCheck %s<br>
+<br>
+// vftable shouldn't have RTTI data in it.<br>
+// CHECK: @"\01??_7S@@6B@" = linkonce_odr unnamed_addr constant [1 x i8*] [i8* bitcast ({{.*}} @"\01??_GS@@UAEPAXI@Z" to i8*)]<br>
+<br>
+struct type_info;<br>
+namespace std { using ::type_info; }<br>
+<br>
+struct S {<br>
+ virtual ~S();<br>
+} s;<br>
+<br>
+struct U : S {<br>
+ virtual ~U();<br>
+};<br>
+<br>
+extern S *getS();<br>
+<br>
+const std::type_info &ti = typeid(*getS());<br>
+const U &u = dynamic_cast<U &>(*getS());<br>
+// CHECK: call i8* @__RTDynamicCast(i8* %0, i32 0, i8* bitcast ({{.*}} @"\01??_R0?AUS@@@8" to i8*), i8* bitcast ({{.*}} @"\01??_R0?AUU@@@8" to i8*), i32 1)<br>
<br>
Modified: cfe/trunk/test/Driver/cl-fallback.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-fallback.c?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-fallback.c?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/cl-fallback.c (original)<br>
+++ cfe/trunk/test/Driver/cl-fallback.c Tue Jul 1 17:24:56 2014<br>
@@ -31,6 +31,10 @@<br>
// CHECK: "/Tc" "{{.*cl-fallback.c}}"<br>
// CHECK: "/Fo{{.*cl-fallback.*.obj}}"<br>
<br>
+// RUN: %clang_cl /fallback /GR- -### -- %s 2>&1 | FileCheck -check-prefix=GR %s<br>
+// GR: cl.exe<br>
+// GR: "/GR-"<br>
+<br>
// RUN: %clang_cl /fallback /Od -### -- %s 2>&1 | FileCheck -check-prefix=O0 %s<br>
// O0: cl.exe<br>
// O0: "/Od"<br>
@@ -56,15 +60,12 @@<br>
// RUN: FileCheck -check-prefix=ErrWarn %s<br>
// ErrWarn: warning: falling back to {{.*}}cl.exe<br>
<br>
-// Don't attempt to run clang -cc1 with /fallback and /GR. It isn't ready yet.<br>
-// RUN: %clang_cl /fallback /c /GR -### -- %s 2>&1 | \<br>
-// RUN: FileCheck -check-prefix=RTTI %s<br>
-// RTTI: warning: cannot compile RTTI yet, falling back to {{.*}}cl.exe<br>
// RUN: %clang_cl /fallback /c /GR /GR- -### -- %s 2>&1 | \<br>
// RUN: FileCheck -check-prefix=NO_RTTI %s<br>
// NO_RTTI: "-cc1"<br>
// NO_RTTI: ||<br>
// NO_RTTI: cl.exe<br>
+// NO_RTTI: "/GR-"<br>
<br>
// Don't fall back on non-C or C++ files.<br>
// RUN: %clang_cl /fallback -### -- %S/Inputs/file.ll 2>&1 | FileCheck -check-prefix=LL %s<br>
<br>
Modified: cfe/trunk/test/Driver/cl-options.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=212138&r1=212137&r2=212138&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=212138&r1=212137&r2=212138&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/cl-options.c (original)<br>
+++ cfe/trunk/test/Driver/cl-options.c Tue Jul 1 17:24:56 2014<br>
@@ -289,10 +289,12 @@<br>
// RUN: %clang_cl /Zs /WX -m32 -m64 -### -- 2>&1 %s | FileCheck -check-prefix=MFLAGS %s<br>
// MFLAGS-NOT: argument unused during compilation<br>
<br>
-// Use -fno-rtti by default.<br>
-// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s<br>
-// NoRTTI: "-fno-rtti"<br>
+// RTTI is on by default. /GR- controls -fno-rtti-data.<br>
+// RUN: %clang_cl /c /GR- -### -- %s 2>&1 | FileCheck -check-prefix=NoRTTI %s<br>
+// NoRTTI: "-fno-rtti-data"<br>
+// NoRTTI-NOT: "-fno-rtti"<br>
// RUN: %clang_cl /c /GR -### -- %s 2>&1 | FileCheck -check-prefix=RTTI %s<br>
+// RTTI-NOT: "-fno-rtti-data"<br>
// RTTI-NOT: "-fno-rtti"<br>
<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>