[llvm] r322008 - Revert "Emit Function IDs table for Control Flow Guard"

Adrian McCarthy via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 8 09:12:01 PST 2018


Author: amccarth
Date: Mon Jan  8 09:12:01 2018
New Revision: 322008

URL: http://llvm.org/viewvc/llvm-project?rev=322008&view=rev
Log:
Revert "Emit Function IDs table for Control Flow Guard"

The new test fails on the Hexagon bot.  Reverting while I investigate.

This reverts https://reviews.llvm.org/rL322005

This reverts commit b7e0026b4385180c378edc658ec91a39566f2942.

Removed:
    llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.h
    llvm/trunk/test/CodeGen/WinCFGuard/
    llvm/trunk/test/MC/COFF/symidx.s
Modified:
    llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
    llvm/trunk/include/llvm/MC/MCStreamer.h
    llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h
    llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt
    llvm/trunk/lib/MC/MCAsmStreamer.cpp
    llvm/trunk/lib/MC/MCObjectFileInfo.cpp
    llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
    llvm/trunk/lib/MC/MCStreamer.cpp
    llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp

Modified: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h Mon Jan  8 09:12:01 2018
@@ -196,7 +196,6 @@ protected:
   MCSection *PDataSection;
   MCSection *XDataSection;
   MCSection *SXDataSection;
-  MCSection *GFIDsSection;
 
 public:
   void InitMCObjectFileInfo(const Triple &TT, bool PIC, MCContext &ctx,
@@ -350,7 +349,6 @@ public:
   MCSection *getPDataSection() const { return PDataSection; }
   MCSection *getXDataSection() const { return XDataSection; }
   MCSection *getSXDataSection() const { return SXDataSection; }
-  MCSection *getGFIDsSection() const { return GFIDsSection; }
 
   MCSection *getEHFrameSection() {
     return EHFrameSection;

Modified: llvm/trunk/include/llvm/MC/MCStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCStreamer.h?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCStreamer.h Mon Jan  8 09:12:01 2018
@@ -499,9 +499,6 @@ public:
 
   virtual void EmitCOFFSafeSEH(MCSymbol const *Symbol);
 
-  /// \brief Emits the symbol table index of a Symbol into the current section.
-  virtual void EmitCOFFSymbolIndex(MCSymbol const *Symbol);
-
   /// \brief Emits a COFF section index.
   ///
   /// \param Symbol - Symbol the section number relocation should point to.

Modified: llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCWinCOFFStreamer.h Mon Jan  8 09:12:01 2018
@@ -50,7 +50,6 @@ public:
   void EmitCOFFSymbolType(int Type) override;
   void EndCOFFSymbolDef() override;
   void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
-  void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override;
   void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
   void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
   void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Mon Jan  8 09:12:01 2018
@@ -16,7 +16,6 @@
 #include "CodeViewDebug.h"
 #include "DwarfDebug.h"
 #include "DwarfException.h"
-#include "WinCFGuard.h"
 #include "WinException.h"
 #include "llvm/ADT/APFloat.h"
 #include "llvm/ADT/APInt.h"
@@ -131,8 +130,6 @@ static const char *const DbgTimerName =
 static const char *const DbgTimerDescription = "Debug Info Emission";
 static const char *const EHTimerName = "write_exception";
 static const char *const EHTimerDescription = "DWARF Exception Writer";
-static const char *const CFGuardName = "Control Flow Guard";
-static const char *const CFGuardDescription = "Control Flow Guard Tables";
 static const char *const CodeViewLineTablesGroupName = "linetables";
 static const char *const CodeViewLineTablesGroupDescription =
   "CodeView Line Tables";
@@ -357,13 +354,6 @@ bool AsmPrinter::doInitialization(Module
   if (ES)
     Handlers.push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription,
                                    DWARFGroupName, DWARFGroupDescription));
-
-  if (mdconst::extract_or_null<ConstantInt>(
-          MMI->getModule()->getModuleFlag("cfguard")))
-    Handlers.push_back(HandlerInfo(new WinCFGuard(this), CFGuardName,
-                                   CFGuardDescription, DWARFGroupName,
-                                   DWARFGroupDescription));
-
   return false;
 }
 

Modified: llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CMakeLists.txt Mon Jan  8 09:12:01 2018
@@ -20,7 +20,6 @@ add_llvm_library(LLVMAsmPrinter
   EHStreamer.cpp
   ErlangGCPrinter.cpp
   OcamlGCPrinter.cpp
-  WinCFGuard.cpp
   WinException.cpp
   CodeViewDebug.cpp
 

Removed: llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.cpp?rev=322007&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.cpp (removed)
@@ -1,45 +0,0 @@
-//===-- CodeGen/AsmPrinter/WinCFGuard.cpp - Control Flow Guard Impl ------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains support for writing Win64 exception info into asm files.
-//
-//===----------------------------------------------------------------------===//
-
-#include "WinCFGuard.h"
-#include "llvm/CodeGen/AsmPrinter.h"
-#include "llvm/CodeGen/MachineFunction.h"
-#include "llvm/CodeGen/MachineModuleInfo.h"
-#include "llvm/CodeGen/MachineOperand.h"
-#include "llvm/IR/Constants.h"
-#include "llvm/IR/Metadata.h"
-#include "llvm/MC/MCAsmInfo.h"
-#include "llvm/MC/MCObjectFileInfo.h"
-#include "llvm/MC/MCStreamer.h"
-
-#include <vector>
-
-using namespace llvm;
-
-WinCFGuard::WinCFGuard(AsmPrinter *A) : AsmPrinterHandler(), Asm(A) {}
-
-WinCFGuard::~WinCFGuard() {}
-
-void WinCFGuard::endModule() {
-  const Module *M = Asm->MMI->getModule();
-  std::vector<const Function *> Functions;
-  for (const Function &F : *M)
-    if (F.hasAddressTaken())
-      Functions.push_back(&F);
-  if (Functions.empty())
-    return;
-  auto &OS = *Asm->OutStreamer;
-  OS.SwitchSection(Asm->OutContext.getObjectFileInfo()->getGFIDsSection());
-  for (const Function *F : Functions)
-    OS.EmitCOFFSymbolIndex(Asm->getSymbol(F));
-}

Removed: llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.h?rev=322007&view=auto
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.h (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/WinCFGuard.h (removed)
@@ -1,54 +0,0 @@
-//===-- WinCFGuard.h - Windows Control Flow Guard Handling ----*- C++ -*--===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains support for writing windows exception info into asm files.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
-#define LLVM_LIB_CODEGEN_ASMPRINTER_WINCFGUARD_H
-
-#include "AsmPrinterHandler.h"
-#include "llvm/Support/Compiler.h"
-
-namespace llvm {
-
-class LLVM_LIBRARY_VISIBILITY WinCFGuard : public AsmPrinterHandler {
-  /// Target of directive emission.
-  AsmPrinter *Asm;
-
-public:
-  WinCFGuard(AsmPrinter *A);
-  ~WinCFGuard() override;
-
-  void setSymbolSize(const MCSymbol *Sym, uint64_t Size) override {}
-
-  /// \brief Emit the Control Flow Guard function ID table
-  void endModule() override;
-
-  /// \brief Gather pre-function debug information.
-  /// Every beginFunction(MF) call should be followed by an endFunction(MF)
-  /// call.
-  void beginFunction(const MachineFunction *MF) override {}
-
-  /// \brief Gather post-function debug information.
-  /// Please note that some AsmPrinter implementations may not call
-  /// beginFunction at all.
-  void endFunction(const MachineFunction *MF) override {}
-
-  /// \brief Process beginning of an instruction.
-  void beginInstruction(const MachineInstr *MI) override {}
-
-  /// \brief Process end of an instruction.
-  void endInstruction() override {}
-};
-
-} // namespace llvm
-
-#endif

Modified: llvm/trunk/lib/MC/MCAsmStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCAsmStreamer.cpp?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCAsmStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCAsmStreamer.cpp Mon Jan  8 09:12:01 2018
@@ -151,7 +151,6 @@ public:
   void EmitCOFFSymbolType(int Type) override;
   void EndCOFFSymbolDef() override;
   void EmitCOFFSafeSEH(MCSymbol const *Symbol) override;
-  void EmitCOFFSymbolIndex(MCSymbol const *Symbol) override;
   void EmitCOFFSectionIndex(MCSymbol const *Symbol) override;
   void EmitCOFFSecRel32(MCSymbol const *Symbol, uint64_t Offset) override;
   void emitELFSize(MCSymbol *Symbol, const MCExpr *Value) override;
@@ -653,12 +652,6 @@ void MCAsmStreamer::EmitCOFFSafeSEH(MCSy
   Symbol->print(OS, MAI);
   EmitEOL();
 }
-
-void MCAsmStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {
-  OS << "\t.symidx\t";
-  Symbol->print(OS, MAI);
-  EmitEOL();
-}
 
 void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
   OS << "\t.secidx\t";

Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Mon Jan  8 09:12:01 2018
@@ -819,11 +819,6 @@ void MCObjectFileInfo::initCOFFMCObjectF
   SXDataSection = Ctx->getCOFFSection(".sxdata", COFF::IMAGE_SCN_LNK_INFO,
                                       SectionKind::getMetadata());
 
-  GFIDsSection = Ctx->getCOFFSection(".gfids$y",
-                                     COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
-                                         COFF::IMAGE_SCN_MEM_READ,
-                                     SectionKind::getMetadata());
-
   TLSDataSection = Ctx->getCOFFSection(
       ".tls$", COFF::IMAGE_SCN_CNT_INITIALIZED_DATA | COFF::IMAGE_SCN_MEM_READ |
                    COFF::IMAGE_SCN_MEM_WRITE,

Modified: llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp (original)
+++ llvm/trunk/lib/MC/MCParser/COFFAsmParser.cpp Mon Jan  8 09:12:01 2018
@@ -65,9 +65,8 @@ class COFFAsmParser : public MCAsmParser
     addDirectiveHandler<&COFFAsmParser::ParseDirectiveType>(".type");
     addDirectiveHandler<&COFFAsmParser::ParseDirectiveEndef>(".endef");
     addDirectiveHandler<&COFFAsmParser::ParseDirectiveSecRel32>(".secrel32");
-    addDirectiveHandler<&COFFAsmParser::ParseDirectiveSymIdx>(".symidx");
-    addDirectiveHandler<&COFFAsmParser::ParseDirectiveSafeSEH>(".safeseh");
     addDirectiveHandler<&COFFAsmParser::ParseDirectiveSecIdx>(".secidx");
+    addDirectiveHandler<&COFFAsmParser::ParseDirectiveSafeSEH>(".safeseh");
     addDirectiveHandler<&COFFAsmParser::ParseDirectiveLinkOnce>(".linkonce");
 
     // Win64 EH directives.
@@ -131,7 +130,6 @@ class COFFAsmParser : public MCAsmParser
   bool ParseDirectiveSecRel32(StringRef, SMLoc);
   bool ParseDirectiveSecIdx(StringRef, SMLoc);
   bool ParseDirectiveSafeSEH(StringRef, SMLoc);
-  bool ParseDirectiveSymIdx(StringRef, SMLoc);
   bool parseCOMDATType(COFF::COMDATType &Type);
   bool ParseDirectiveLinkOnce(StringRef, SMLoc);
 
@@ -522,21 +520,6 @@ bool COFFAsmParser::ParseDirectiveSecIdx
   return false;
 }
 
-bool COFFAsmParser::ParseDirectiveSymIdx(StringRef, SMLoc) {
-  StringRef SymbolID;
-  if (getParser().parseIdentifier(SymbolID))
-    return TokError("expected identifier in directive");
-
-  if (getLexer().isNot(AsmToken::EndOfStatement))
-    return TokError("unexpected token in directive");
-
-  MCSymbol *Symbol = getContext().getOrCreateSymbol(SymbolID);
-
-  Lex();
-  getStreamer().EmitCOFFSymbolIndex(Symbol);
-  return false;
-}
-
 /// ::= [ identifier ]
 bool COFFAsmParser::parseCOMDATType(COFF::COMDATType &Type) {
   StringRef TypeId = getTok().getIdentifier();

Modified: llvm/trunk/lib/MC/MCStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCStreamer.cpp?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCStreamer.cpp Mon Jan  8 09:12:01 2018
@@ -804,8 +804,6 @@ void MCStreamer::EmitWinCFIEndProlog(SML
 void MCStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
 }
 
-void MCStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {}
-
 void MCStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
 }
 

Modified: llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp?rev=322008&r1=322007&r2=322008&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCWinCOFFStreamer.cpp Mon Jan  8 09:12:01 2018
@@ -193,17 +193,6 @@ void MCWinCOFFStreamer::EmitCOFFSafeSEH(
                    << COFF::SCT_COMPLEX_TYPE_SHIFT);
 }
 
-void MCWinCOFFStreamer::EmitCOFFSymbolIndex(MCSymbol const *Symbol) {
-  MCSection *Sec = getCurrentSectionOnly();
-  getAssembler().registerSection(*Sec);
-  if (Sec->getAlignment() < 4)
-    Sec->setAlignment(4);
-
-  new MCSymbolIdFragment(Symbol, getCurrentSectionOnly());
-
-  getAssembler().registerSymbol(*Symbol);
-}
-
 void MCWinCOFFStreamer::EmitCOFFSectionIndex(const MCSymbol *Symbol) {
   visitUsedSymbol(*Symbol);
   MCDataFragment *DF = getOrCreateDataFragment();

Removed: llvm/trunk/test/MC/COFF/symidx.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/COFF/symidx.s?rev=322007&view=auto
==============================================================================
--- llvm/trunk/test/MC/COFF/symidx.s (original)
+++ llvm/trunk/test/MC/COFF/symidx.s (removed)
@@ -1,15 +0,0 @@
-// RUN: llvm-mc -triple x86_64-pc-win32 -filetype=obj %s | llvm-objdump -s -t - | FileCheck %s
-.text
-foo:
-  ret
-bar:
-  ret
-.data
-.symidx	bar
-.symidx	foo
-
-// CHECK:      Contents of section .data:
-// CHECK-NEXT:  0000 0[[BAR:[1-9]]]000000 0[[FOO:[1-9]]]000000
-// CHECK:      SYMBOL TABLE:
-// CHECK:      [ [[FOO]]](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000000 foo
-// CHECK-NEXT: [ [[BAR]]](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x00000001 bar




More information about the llvm-commits mailing list