<div dir="ltr">+1/ping on this - Jorge, could you include some details about the reason for the revert & the revision?<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 14, 2019 at 5:06 PM Richard Smith via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Hi Jorge,<div><br></div><div>Please mention the reason for a revert in revert commit messages. Also, until SVN stops being our system of record, please use SVN revision numbers to reference prior commits in reverts.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 14 Oct 2019 at 16:22, Jorge Gorbe Moya via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Author: jgorbe<br>
Date: Mon Oct 14 16:25:25 2019<br>
New Revision: 374844<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=374844&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=374844&view=rev</a><br>
Log:<br>
Revert "Dead Virtual Function Elimination"<br>
<br>
This reverts commit 9f6a873268e1ad9855873d9d8007086c0d01cf4f.<br>
<br>
Removed:<br>
    cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp<br>
    cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp<br>
    cfe/trunk/test/Driver/virtual-function-elimination.cpp<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/CodeGenOptions.def<br>
    cfe/trunk/include/clang/Driver/Options.td<br>
    cfe/trunk/lib/CodeGen/CGClass.cpp<br>
    cfe/trunk/lib/CodeGen/CGVTables.cpp<br>
    cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
    cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
    cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br>
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.def<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.def?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/CodeGenOptions.def (original)<br>
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.def Mon Oct 14 16:25:25 2019<br>
@@ -278,10 +278,6 @@ CODEGENOPT(EmitLLVMUseLists, 1, 0) ///<<br>
 CODEGENOPT(WholeProgramVTables, 1, 0) ///< Whether to apply whole-program<br>
                                       ///  vtable optimization.<br>
<br>
-CODEGENOPT(VirtualFunctionElimination, 1, 0) ///< Whether to apply the dead<br>
-                                             /// virtual function elimination<br>
-                                             /// optimization.<br>
-<br>
 /// Whether to use public LTO visibility for entities in std and stdext<br>
 /// namespaces. This is enabled by clang-cl's /MT and /MTd flags.<br>
 CODEGENOPT(LTOVisibilityPublicStd, 1, 0)<br>
<br>
Modified: cfe/trunk/include/clang/Driver/Options.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Driver/Options.td (original)<br>
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 14 16:25:25 2019<br>
@@ -1863,13 +1863,6 @@ def fforce_emit_vtables : Flag<["-"], "f<br>
     HelpText<"Emits more virtual tables to improve devirtualization">;<br>
 def fno_force_emit_vtables : Flag<["-"], "fno-force-emit-vtables">, Group<f_Group>,<br>
   Flags<[CoreOption]>;<br>
-<br>
-def fvirtual_function_elimination : Flag<["-"], "fvirtual-function-elimination">, Group<f_Group>,<br>
-  Flags<[CoreOption, CC1Option]>,<br>
-  HelpText<"Enables dead virtual function elimination optimization. Requires -flto=full">;<br>
-def fno_virtual_function_elimination : Flag<["-"], "fno-virtual-function_elimination">, Group<f_Group>,<br>
-  Flags<[CoreOption]>;<br>
-<br>
 def fwrapv : Flag<["-"], "fwrapv">, Group<f_Group>, Flags<[CC1Option]>,<br>
   HelpText<"Treat signed integer overflow as two's complement">;<br>
 def fwritable_strings : Flag<["-"], "fwritable-strings">, Group<f_Group>, Flags<[CC1Option]>,<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGClass.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Mon Oct 14 16:25:25 2019<br>
@@ -2784,16 +2784,11 @@ void CodeGenFunction::EmitVTablePtrCheck<br>
<br>
 bool CodeGenFunction::ShouldEmitVTableTypeCheckedLoad(const CXXRecordDecl *RD) {<br>
   if (!CGM.getCodeGenOpts().WholeProgramVTables ||<br>
+      !SanOpts.has(SanitizerKind::CFIVCall) ||<br>
+      !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall) ||<br>
       !CGM.HasHiddenLTOVisibility(RD))<br>
     return false;<br>
<br>
-  if (CGM.getCodeGenOpts().VirtualFunctionElimination)<br>
-    return true;<br>
-<br>
-  if (!SanOpts.has(SanitizerKind::CFIVCall) ||<br>
-      !CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIVCall))<br>
-    return false;<br>
-<br>
   std::string TypeName = RD->getQualifiedNameAsString();<br>
   return !getContext().getSanitizerBlacklist().isBlacklistedType(<br>
       SanitizerKind::CFIVCall, TypeName);<br>
@@ -2816,13 +2811,8 @@ llvm::Value *CodeGenFunction::EmitVTable<br>
        TypeId});<br>
   llvm::Value *CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);<br>
<br>
-  std::string TypeName = RD->getQualifiedNameAsString();<br>
-  if (SanOpts.has(SanitizerKind::CFIVCall) &&<br>
-      !getContext().getSanitizerBlacklist().isBlacklistedType(<br>
-          SanitizerKind::CFIVCall, TypeName)) {<br>
-    EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),<br>
-              SanitizerHandler::CFICheckFail, {}, {});<br>
-  }<br>
+  EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIVCall),<br>
+            SanitizerHandler::CFICheckFail, nullptr, nullptr);<br>
<br>
   return Builder.CreateBitCast(<br>
       Builder.CreateExtractValue(CheckedLoad, 0),<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGVTables.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGVTables.cpp Mon Oct 14 16:25:25 2019<br>
@@ -808,7 +808,7 @@ CodeGenVTables::GenerateConstructionVTab<br>
   assert(!VTable->isDeclaration() && "Shouldn't set properties on declaration");<br>
   CGM.setGVProperties(VTable, RD);<br>
<br>
-  CGM.EmitVTableTypeMetadata(RD, VTable, *VTLayout.get());<br>
+  CGM.EmitVTableTypeMetadata(VTable, *VTLayout.get());<br>
<br>
   return VTable;<br>
 }<br>
@@ -1039,32 +1039,7 @@ bool CodeGenModule::HasHiddenLTOVisibili<br>
   return true;<br>
 }<br>
<br>
-llvm::GlobalObject::VCallVisibility<br>
-CodeGenModule::GetVCallVisibilityLevel(const CXXRecordDecl *RD) {<br>
-  LinkageInfo LV = RD->getLinkageAndVisibility();<br>
-  llvm::GlobalObject::VCallVisibility TypeVis;<br>
-  if (!isExternallyVisible(LV.getLinkage()))<br>
-    TypeVis = llvm::GlobalObject::VCallVisibilityTranslationUnit;<br>
-  else if (HasHiddenLTOVisibility(RD))<br>
-    TypeVis = llvm::GlobalObject::VCallVisibilityLinkageUnit;<br>
-  else<br>
-    TypeVis = llvm::GlobalObject::VCallVisibilityPublic;<br>
-<br>
-  for (auto B : RD->bases())<br>
-    if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())<br>
-      TypeVis = std::min(TypeVis,<br>
-                    GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));<br>
-<br>
-  for (auto B : RD->vbases())<br>
-    if (B.getType()->getAsCXXRecordDecl()->isDynamicClass())<br>
-      TypeVis = std::min(TypeVis,<br>
-                    GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl()));<br>
-<br>
-  return TypeVis;<br>
-}<br>
-<br>
-void CodeGenModule::EmitVTableTypeMetadata(const CXXRecordDecl *RD,<br>
-                                           llvm::GlobalVariable *VTable,<br>
+void CodeGenModule::EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,<br>
                                            const VTableLayout &VTLayout) {<br>
   if (!getCodeGenOpts().LTOUnit)<br>
     return;<br>
@@ -1124,10 +1099,4 @@ void CodeGenModule::EmitVTableTypeMetada<br>
       VTable->addTypeMetadata((PointerWidth * I).getQuantity(), MD);<br>
     }<br>
   }<br>
-<br>
-  if (getCodeGenOpts().VirtualFunctionElimination) {<br>
-    llvm::GlobalObject::VCallVisibility TypeVis = GetVCallVisibilityLevel(RD);<br>
-    if (TypeVis != llvm::GlobalObject::VCallVisibilityPublic)<br>
-      VTable->addVCallVisibilityMetadata(TypeVis);<br>
-  }<br>
 }<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Oct 14 16:25:25 2019<br>
@@ -1280,16 +1280,8 @@ public:<br>
   /// optimization.<br>
   bool HasHiddenLTOVisibility(const CXXRecordDecl *RD);<br>
<br>
-  /// Returns the vcall visibility of the given type. This is the scope in which<br>
-  /// a virtual function call could be made which ends up being dispatched to a<br>
-  /// member function of this class. This scope can be wider than the visibility<br>
-  /// of the class itself when the class has a more-visible dynamic base class.<br>
-  llvm::GlobalObject::VCallVisibility<br>
-  GetVCallVisibilityLevel(const CXXRecordDecl *RD);<br>
-<br>
   /// Emit type metadata for the given vtable using the given layout.<br>
-  void EmitVTableTypeMetadata(const CXXRecordDecl *RD,<br>
-                              llvm::GlobalVariable *VTable,<br>
+  void EmitVTableTypeMetadata(llvm::GlobalVariable *VTable,<br>
                               const VTableLayout &VTLayout);<br>
<br>
   /// Generate a cross-DSO type identifier for MD.<br>
<br>
Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon Oct 14 16:25:25 2019<br>
@@ -644,6 +644,8 @@ CGCallee ItaniumCXXABI::EmitLoadOfMember<br>
     VTableOffset = Builder.CreateTrunc(VTableOffset, CGF.Int32Ty);<br>
     VTableOffset = Builder.CreateZExt(VTableOffset, CGM.PtrDiffTy);<br>
   }<br>
+  // Compute the address of the virtual function pointer.<br>
+  llvm::Value *VFPAddr = Builder.CreateGEP(VTable, VTableOffset);<br>
<br>
   // Check the address of the function pointer if CFI on member function<br>
   // pointers is enabled.<br>
@@ -651,81 +653,44 @@ CGCallee ItaniumCXXABI::EmitLoadOfMember<br>
   llvm::Constant *CheckTypeDesc;<br>
   bool ShouldEmitCFICheck = CGF.SanOpts.has(SanitizerKind::CFIMFCall) &&<br>
                             CGM.HasHiddenLTOVisibility(RD);<br>
-  bool ShouldEmitVFEInfo = CGM.getCodeGenOpts().VirtualFunctionElimination &&<br>
-                           CGM.HasHiddenLTOVisibility(RD);<br>
-  llvm::Value *VirtualFn = nullptr;<br>
-<br>
-  {<br>
+  if (ShouldEmitCFICheck) {<br>
     CodeGenFunction::SanitizerScope SanScope(&CGF);<br>
-    llvm::Value *TypeId = nullptr;<br>
-    llvm::Value *CheckResult = nullptr;<br>
<br>
-    if (ShouldEmitCFICheck || ShouldEmitVFEInfo) {<br>
-      // If doing CFI or VFE, we will need the metadata node to check against.<br>
-      llvm::Metadata *MD =<br>
-          CGM.CreateMetadataIdentifierForVirtualMemPtrType(QualType(MPT, 0));<br>
-      TypeId = llvm::MetadataAsValue::get(CGF.getLLVMContext(), MD);<br>
-    }<br>
+    CheckSourceLocation = CGF.EmitCheckSourceLocation(E->getBeginLoc());<br>
+    CheckTypeDesc = CGF.EmitCheckTypeDescriptor(QualType(MPT, 0));<br>
+    llvm::Constant *StaticData[] = {<br>
+        llvm::ConstantInt::get(CGF.Int8Ty, CodeGenFunction::CFITCK_VMFCall),<br>
+        CheckSourceLocation,<br>
+        CheckTypeDesc,<br>
+    };<br>
+<br>
+    llvm::Metadata *MD =<br>
+        CGM.CreateMetadataIdentifierForVirtualMemPtrType(QualType(MPT, 0));<br>
+    llvm::Value *TypeId = llvm::MetadataAsValue::get(CGF.getLLVMContext(), MD);<br>
<br>
-    llvm::Value *VFPAddr = Builder.CreateGEP(VTable, VTableOffset);<br>
+    llvm::Value *TypeTest = Builder.CreateCall(<br>
+        CGM.getIntrinsic(llvm::Intrinsic::type_test), {VFPAddr, TypeId});<br>
<br>
-    if (ShouldEmitVFEInfo) {<br>
-      // If doing VFE, load from the vtable with a type.checked.load intrinsic<br>
-      // call. Note that we use the GEP to calculate the address to load from<br>
-      // and pass 0 as the offset to the intrinsic. This is because every<br>
-      // vtable slot of the correct type is marked with matching metadata, and<br>
-      // we know that the load must be from one of these slots.<br>
-      llvm::Value *CheckedLoad = Builder.CreateCall(<br>
-          CGM.getIntrinsic(llvm::Intrinsic::type_checked_load),<br>
-          {VFPAddr, llvm::ConstantInt::get(CGM.Int32Ty, 0), TypeId});<br>
-      CheckResult = Builder.CreateExtractValue(CheckedLoad, 1);<br>
-      VirtualFn = Builder.CreateExtractValue(CheckedLoad, 0);<br>
-      VirtualFn = Builder.CreateBitCast(VirtualFn, FTy->getPointerTo(),<br>
-                                        "memptr.virtualfn");<br>
+    if (CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIMFCall)) {<br>
+      CGF.EmitTrapCheck(TypeTest);<br>
     } else {<br>
-      // When not doing VFE, emit a normal load, as it allows more<br>
-      // optimisations than type.checked.load.<br>
-      if (ShouldEmitCFICheck) {<br>
-        CheckResult = Builder.CreateCall(<br>
-            CGM.getIntrinsic(llvm::Intrinsic::type_test),<br>
-            {Builder.CreateBitCast(VFPAddr, CGF.Int8PtrTy), TypeId});<br>
-      }<br>
-      VFPAddr =<br>
-          Builder.CreateBitCast(VFPAddr, FTy->getPointerTo()->getPointerTo());<br>
-      VirtualFn = Builder.CreateAlignedLoad(VFPAddr, CGF.getPointerAlign(),<br>
-                                            "memptr.virtualfn");<br>
+      llvm::Value *AllVtables = llvm::MetadataAsValue::get(<br>
+          CGM.getLLVMContext(),<br>
+          llvm::MDString::get(CGM.getLLVMContext(), "all-vtables"));<br>
+      llvm::Value *ValidVtable = Builder.CreateCall(<br>
+          CGM.getIntrinsic(llvm::Intrinsic::type_test), {VTable, AllVtables});<br>
+      CGF.EmitCheck(std::make_pair(TypeTest, SanitizerKind::CFIMFCall),<br>
+                    SanitizerHandler::CFICheckFail, StaticData,<br>
+                    {VTable, ValidVtable});<br>
     }<br>
-    assert(VirtualFn && "Virtual fuction pointer not created!");<br>
-    assert((!ShouldEmitCFICheck || !ShouldEmitVFEInfo || CheckResult) &&<br>
-           "Check result required but not created!");<br>
-<br>
-    if (ShouldEmitCFICheck) {<br>
-      // If doing CFI, emit the check.<br>
-      CheckSourceLocation = CGF.EmitCheckSourceLocation(E->getBeginLoc());<br>
-      CheckTypeDesc = CGF.EmitCheckTypeDescriptor(QualType(MPT, 0));<br>
-      llvm::Constant *StaticData[] = {<br>
-          llvm::ConstantInt::get(CGF.Int8Ty, CodeGenFunction::CFITCK_VMFCall),<br>
-          CheckSourceLocation,<br>
-          CheckTypeDesc,<br>
-      };<br>
-<br>
-      if (CGM.getCodeGenOpts().SanitizeTrap.has(SanitizerKind::CFIMFCall)) {<br>
-        CGF.EmitTrapCheck(CheckResult);<br>
-      } else {<br>
-        llvm::Value *AllVtables = llvm::MetadataAsValue::get(<br>
-            CGM.getLLVMContext(),<br>
-            llvm::MDString::get(CGM.getLLVMContext(), "all-vtables"));<br>
-        llvm::Value *ValidVtable = Builder.CreateCall(<br>
-            CGM.getIntrinsic(llvm::Intrinsic::type_test), {VTable, AllVtables});<br>
-        CGF.EmitCheck(std::make_pair(CheckResult, SanitizerKind::CFIMFCall),<br>
-                      SanitizerHandler::CFICheckFail, StaticData,<br>
-                      {VTable, ValidVtable});<br>
-      }<br>
<br>
-      FnVirtual = Builder.GetInsertBlock();<br>
-    }<br>
-  } // End of sanitizer scope<br>
+    FnVirtual = Builder.GetInsertBlock();<br>
+  }<br>
<br>
+  // Load the virtual function to call.<br>
+  VFPAddr = Builder.CreateBitCast(VFPAddr, FTy->getPointerTo()->getPointerTo());<br>
+  llvm::Value *VirtualFn = Builder.CreateAlignedLoad(<br>
+      VFPAddr, CGF.getPointerAlign(), "memptr.virtualfn");<br>
   CGF.EmitBranch(FnEnd);<br>
<br>
   // In the non-virtual path, the function pointer is actually a<br>
@@ -1669,7 +1634,7 @@ void ItaniumCXXABI::emitVTableDefinition<br>
     EmitFundamentalRTTIDescriptors(RD);<br>
<br>
   if (!VTable->isDeclarationForLinker())<br>
-    CGM.EmitVTableTypeMetadata(RD, VTable, VTLayout);<br>
+    CGM.EmitVTableTypeMetadata(VTable, VTLayout);<br>
 }<br>
<br>
 bool ItaniumCXXABI::isVirtualOffsetNeededForVTableField(<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Oct 14 16:25:25 2019<br>
@@ -5366,30 +5366,9 @@ void Clang::ConstructJob(Compilation &C,<br>
     CmdArgs.push_back(Args.MakeArgString(TargetInfo.str()));<br>
   }<br>
<br>
-  bool VirtualFunctionElimination =<br>
-      Args.hasFlag(options::OPT_fvirtual_function_elimination,<br>
-                   options::OPT_fno_virtual_function_elimination, false);<br>
-  if (VirtualFunctionElimination) {<br>
-    // VFE requires full LTO (currently, this might be relaxed to allow ThinLTO<br>
-    // in the future).<br>
-    if (D.getLTOMode() != LTOK_Full)<br>
-      D.Diag(diag::err_drv_argument_only_allowed_with)<br>
-          << "-fvirtual-function-elimination"<br>
-          << "-flto=full";<br>
-<br>
-    CmdArgs.push_back("-fvirtual-function-elimination");<br>
-  }<br>
-<br>
-  // VFE requires whole-program-vtables, and enables it by default.<br>
-  bool WholeProgramVTables = Args.hasFlag(<br>
-      options::OPT_fwhole_program_vtables,<br>
-      options::OPT_fno_whole_program_vtables, VirtualFunctionElimination);<br>
-  if (VirtualFunctionElimination && !WholeProgramVTables) {<br>
-    D.Diag(diag::err_drv_argument_not_allowed_with)<br>
-        << "-fno-whole-program-vtables"<br>
-        << "-fvirtual-function-elimination";<br>
-  }<br>
-<br>
+  bool WholeProgramVTables =<br>
+      Args.hasFlag(options::OPT_fwhole_program_vtables,<br>
+                   options::OPT_fno_whole_program_vtables, false);<br>
   if (WholeProgramVTables) {<br>
     if (!D.isUsingLTO())<br>
       D.Diag(diag::err_drv_argument_only_allowed_with)<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=374844&r1=374843&r2=374844&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=374844&r1=374843&r2=374844&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Oct 14 16:25:25 2019<br>
@@ -758,8 +758,6 @@ static bool ParseCodeGenArgs(CodeGenOpti<br>
   Opts.CodeViewGHash = Args.hasArg(OPT_gcodeview_ghash);<br>
   Opts.MacroDebugInfo = Args.hasArg(OPT_debug_info_macro);<br>
   Opts.WholeProgramVTables = Args.hasArg(OPT_fwhole_program_vtables);<br>
-  Opts.VirtualFunctionElimination =<br>
-      Args.hasArg(OPT_fvirtual_function_elimination);<br>
   Opts.LTOVisibilityPublicStd = Args.hasArg(OPT_flto_visibility_public_std);<br>
   Opts.SplitDwarfFile = Args.getLastArgValue(OPT_split_dwarf_file);<br>
   Opts.SplitDwarfOutput = Args.getLastArgValue(OPT_split_dwarf_output);<br>
<br>
Removed: cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp?rev=374843&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp?rev=374843&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/vcall-visibility-metadata.cpp (removed)<br>
@@ -1,88 +0,0 @@<br>
-// RUN: %clang_cc1 -flto -flto-unit -triple x86_64-unknown-linux -emit-llvm -fvirtual-function-elimination -fwhole-program-vtables -o - %s | FileCheck %s<br>
-<br>
-<br>
-// Anonymous namespace.<br>
-namespace {<br>
-// CHECK: @_ZTVN12_GLOBAL__N_11AE = {{.*}} !vcall_visibility [[VIS_TU:![0-9]+]]<br>
-struct A {<br>
-  A() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-}<br>
-void *construct_A() {<br>
-  return new A();<br>
-}<br>
-<br>
-<br>
-// Hidden visibility.<br>
-// CHECK: @_ZTV1B = {{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]<br>
-struct __attribute__((visibility("hidden"))) B {<br>
-  B() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-B *construct_B() {<br>
-  return new B();<br>
-}<br>
-<br>
-<br>
-// Default visibility.<br>
-// CHECK-NOT: @_ZTV1C = {{.*}} !vcall_visibility<br>
-struct __attribute__((visibility("default"))) C {<br>
-  C() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-C *construct_C() {<br>
-  return new C();<br>
-}<br>
-<br>
-<br>
-// Hidden visibility, public LTO visibility.<br>
-// CHECK-NOT: @_ZTV1D = {{.*}} !vcall_visibility<br>
-struct __attribute__((visibility("hidden"))) [[clang::lto_visibility_public]] D {<br>
-  D() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-D *construct_D() {<br>
-  return new D();<br>
-}<br>
-<br>
-<br>
-// Hidden visibility, but inherits from class with default visibility.<br>
-// CHECK-NOT: @_ZTV1E = {{.*}} !vcall_visibility<br>
-struct __attribute__((visibility("hidden"))) E : C {<br>
-  E() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-E *construct_E() {<br>
-  return new E();<br>
-}<br>
-<br>
-<br>
-// Anonymous namespace, but inherits from class with default visibility.<br>
-// CHECK-NOT: @_ZTVN12_GLOBAL__N_11FE = {{.*}} !vcall_visibility<br>
-namespace {<br>
-struct __attribute__((visibility("hidden"))) F : C {<br>
-  F() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-}<br>
-void *construct_F() {<br>
-  return new F();<br>
-}<br>
-<br>
-<br>
-// Anonymous namespace, but inherits from class with hidden visibility.<br>
-// CHECK: @_ZTVN12_GLOBAL__N_11GE = {{.*}} !vcall_visibility [[VIS_DSO:![0-9]+]]<br>
-namespace {<br>
-struct __attribute__((visibility("hidden"))) G : B {<br>
-  G() {}<br>
-  virtual int f() { return 1; }<br>
-};<br>
-}<br>
-void *construct_G() {<br>
-  return new G();<br>
-}<br>
-<br>
-<br>
-// CHECK-DAG: [[VIS_DSO]] = !{i64 1}<br>
-// CHECK-DAG: [[VIS_TU]] = !{i64 2}<br>
<br>
Removed: cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp?rev=374843&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp?rev=374843&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/virtual-function-elimination.cpp (removed)<br>
@@ -1,75 +0,0 @@<br>
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -flto -flto-unit -fvirtual-function-elimination -fwhole-program-vtables -emit-llvm -o - %s | FileCheck %s<br>
-<br>
-<br>
-struct __attribute__((visibility("default"))) A {<br>
-  virtual void foo();<br>
-};<br>
-<br>
-void test_1(A *p) {<br>
-  // A has default visibility, so no need for type.checked.load.<br>
-// CHECK-LABEL: define void @_Z6test_1P1A<br>
-// CHECK: [[FN_PTR_ADDR:%.+]] = getelementptr inbounds void (%struct.A*)*, void (%struct.A*)** {{%.+}}, i64 0<br>
-// CHECK: [[FN_PTR:%.+]] = load void (%struct.A*)*, void (%struct.A*)** [[FN_PTR_ADDR]]<br>
-// CHECK: call void [[FN_PTR]](<br>
-  p->foo();<br>
-}<br>
-<br>
-<br>
-struct __attribute__((visibility("hidden"))) [[clang::lto_visibility_public]] B {<br>
-  virtual void foo();<br>
-};<br>
-<br>
-void test_2(B *p) {<br>
-  // B has public LTO visibility, so no need for type.checked.load.<br>
-// CHECK-LABEL: define void @_Z6test_2P1B<br>
-// CHECK: [[FN_PTR_ADDR:%.+]] = getelementptr inbounds void (%struct.B*)*, void (%struct.B*)** {{%.+}}, i64 0<br>
-// CHECK: [[FN_PTR:%.+]] = load void (%struct.B*)*, void (%struct.B*)** [[FN_PTR_ADDR]]<br>
-// CHECK: call void [[FN_PTR]](<br>
-  p->foo();<br>
-}<br>
-<br>
-<br>
-struct __attribute__((visibility("hidden"))) C {<br>
-  virtual void foo();<br>
-  virtual void bar();<br>
-};<br>
-<br>
-void test_3(C *p) {<br>
-  // C has hidden visibility, so we generate type.checked.load to allow VFE.<br>
-// CHECK-LABEL: define void @_Z6test_3P1C<br>
-// CHECK: [[LOAD:%.+]] = call { i8*, i1 } @llvm.type.checked.load(i8* {{%.+}}, i32 0, metadata !"_ZTS1C")<br>
-// CHECK: [[FN_PTR_I8:%.+]] = extractvalue { i8*, i1 } [[LOAD]], 0<br>
-// CHECK: [[FN_PTR:%.+]] = bitcast i8* [[FN_PTR_I8]] to void (%struct.C*)*<br>
-// CHECK: call void [[FN_PTR]](<br>
-  p->foo();<br>
-}<br>
-<br>
-void test_4(C *p) {<br>
-  // When using type.checked.load, we pass the vtable offset to the intrinsic,<br>
-  // rather than adding it to the pointer with a GEP.<br>
-// CHECK-LABEL: define void @_Z6test_4P1C<br>
-// CHECK: [[LOAD:%.+]] = call { i8*, i1 } @llvm.type.checked.load(i8* {{%.+}}, i32 8, metadata !"_ZTS1C")<br>
-// CHECK: [[FN_PTR_I8:%.+]] = extractvalue { i8*, i1 } [[LOAD]], 0<br>
-// CHECK: [[FN_PTR:%.+]] = bitcast i8* [[FN_PTR_I8]] to void (%struct.C*)*<br>
-// CHECK: call void [[FN_PTR]](<br>
-  p->bar();<br>
-}<br>
-<br>
-void test_5(C *p, void (C::*q)(void)) {<br>
-  // We also use type.checked.load for the virtual side of member function<br>
-  // pointer calls. We use a GEP to calculate the address to load from and pass<br>
-  // 0 as the offset to the intrinsic, because we know that the load must be<br>
-  // from exactly the point marked by one of the function-type metadatas (in<br>
-  // this case "_ZTSM1CFvvE.virtual"). If we passed the offset from the member<br>
-  // function pointer to the intrinsic, this information would be lost. No<br>
-  // codegen changes on the non-virtual side.<br>
-// CHECK-LABEL: define void @_Z6test_5P1CMS_FvvE(<br>
-// CHECK: [[FN_PTR_ADDR:%.+]] = getelementptr i8, i8* %vtable, i64 {{%.+}}<br>
-// CHECK: [[LOAD:%.+]] = call { i8*, i1 } @llvm.type.checked.load(i8* [[FN_PTR_ADDR]], i32 0, metadata !"_ZTSM1CFvvE.virtual")<br>
-// CHECK: [[FN_PTR_I8:%.+]] = extractvalue { i8*, i1 } [[LOAD]], 0<br>
-// CHECK: [[FN_PTR:%.+]] = bitcast i8* [[FN_PTR_I8]] to void (%struct.C*)*<br>
-<br>
-// CHECK: [[PHI:%.+]] = phi void (%struct.C*)* {{.*}}[ [[FN_PTR]], {{.*}} ]<br>
-// CHECK: call void [[PHI]](<br>
-  (p->*q)();<br>
-}<br>
<br>
Removed: cfe/trunk/test/Driver/virtual-function-elimination.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/virtual-function-elimination.cpp?rev=374843&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/virtual-function-elimination.cpp?rev=374843&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/virtual-function-elimination.cpp (original)<br>
+++ cfe/trunk/test/Driver/virtual-function-elimination.cpp (removed)<br>
@@ -1,11 +0,0 @@<br>
-// RUN: %clang -target x86_64-unknown-linux -fvirtual-function-elimination -### %s 2>&1 | FileCheck --check-prefix=BAD-LTO %s<br>
-// RUN: %clang -target x86_64-unknown-linux -fvirtual-function-elimination -flto=thin -### %s 2>&1 | FileCheck --check-prefix=BAD-LTO %s<br>
-// BAD-LTO: invalid argument '-fvirtual-function-elimination' only allowed with '-flto=full'<br>
-<br>
-// RUN: %clang -target x86_64-unknown-linux -fvirtual-function-elimination -flto -### %s 2>&1 | FileCheck --check-prefix=GOOD %s<br>
-// RUN: %clang -target x86_64-unknown-linux -fvirtual-function-elimination -flto=full -### %s 2>&1 | FileCheck --check-prefix=GOOD %s<br>
-// RUN: %clang -target x86_64-unknown-linux -fvirtual-function-elimination -flto -fwhole-program-vtables -### %s 2>&1 | FileCheck --check-prefix=GOOD %s<br>
-// GOOD: "-fvirtual-function-elimination" "-fwhole-program-vtables"<br>
-<br>
-// RUN: %clang -target x86_64-unknown-linux -fvirtual-function-elimination -fno-whole-program-vtables -flto -### %s 2>&1 | FileCheck --check-prefix=NO-WHOLE-PROGRAM-VTABLES %s<br>
-// NO-WHOLE-PROGRAM-VTABLES: invalid argument '-fno-whole-program-vtables' not allowed with '-fvirtual-function-elimination'<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div></div>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>