r319297 - Toolchain: Normalize dwarf, sjlj and seh eh

Martell Malone via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 29 10:33:59 PST 2017


Thanks for letting me know Reid.
I’ll in work and won’t be able to access the repo until lunch time. (~3
hours)
Feel free to revert if it is not trivial.

The easy fix might be to change to == x86_64 from != x86 For is Windows in
the default toolchain. That should restore the old behavior.

I’m curious, is this in clang-cl mode?


On Wed 29 Nov 2017 at 10:12, Reid Kleckner <rnk at google.com> wrote:

> I see a bunch of link errors that suggest we're using the wrong EH
> personality in MSVC mode now:
>
> FAILED: win_clang_nacl_win64/swiftshader/libEGL.dll
> win_clang_nacl_win64/swiftshader/libEGL.dll.lib
> win_clang_nacl_win64/swiftshader/libEGL.dll.pdb
> C:/b/depot_tools/win_tools-2_7_6_bin/python/bin/python.exe
> ../../build/toolchain/win/tool_wrapper.py link-wrapper environment.x64
> False link.exe /nologo
> /IMPLIB:win_clang_nacl_win64/swiftshader/libEGL.dll.lib /DLL
> /OUT:win_clang_nacl_win64/swiftshader/libEGL.dll
> /PDB:win_clang_nacl_win64/swiftshader/libEGL.dll.pdb
> @win_clang_nacl_win64/swiftshader/libEGL.dll.rsp
> Config.obj : error LNK2001: unresolved external symbol _Unwind_Resume
> Display.obj : error LNK2001: unresolved external symbol _Unwind_Resume
> Surface.obj : error LNK2001: unresolved external symbol _Unwind_Resume
> Config.obj : error LNK2001: unresolved external symbol
> __gxx_personality_seh0
> Display.obj : error LNK2001: unresolved external symbol
> __gxx_personality_seh0
> Surface.obj : error LNK2001: unresolved external symbol
> __gxx_personality_seh0
>
> I'll dig in a bit to see if there's an easy fix.
>
> On Tue, Nov 28, 2017 at 11:25 PM, Martell Malone via cfe-commits <
> cfe-commits at lists.llvm.org> wrote:
>
>> Author: martell
>> Date: Tue Nov 28 23:25:12 2017
>> New Revision: 319297
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=319297&view=rev
>> Log:
>> Toolchain: Normalize dwarf, sjlj and seh eh
>>
>> This is a re-apply of r319294.
>>
>> adds -fseh-exceptions and -fdwarf-exceptions flags
>>
>> clang will check if the user has specified an exception model flag,
>> in the absense of specifying the exception model clang will then check
>> the driver default and append the model flag for that target to cc1
>>
>> -fno-exceptions has a higher priority then specifying the model
>>
>> move __SEH__ macro definitions out of Targets into InitPreprocessor
>> behind the -fseh-exceptions flag
>>
>> move __ARM_DWARF_EH__ macrodefinitions out of verious targets and into
>> InitPreprocessor behind the -fdwarf-exceptions flag and arm|thumb check
>>
>> remove unused USESEHExceptions from the MinGW Driver
>>
>> fold USESjLjExceptions into a new GetExceptionModel function that
>> gives the toolchain classes more flexibility with eh models
>>
>> Reviewers: rnk, mstorsjo
>>
>> Differential Revision: https://reviews.llvm.org/D39673
>>
>> Added:
>>     cfe/trunk/test/CodeGenCXX/mingw-w64-exceptions.c
>> Modified:
>>     cfe/trunk/docs/ClangCommandLineReference.rst
>>     cfe/trunk/include/clang/Basic/LangOptions.def
>>     cfe/trunk/include/clang/Driver/Options.td
>>     cfe/trunk/include/clang/Driver/ToolChain.h
>>     cfe/trunk/lib/Basic/Targets/ARM.cpp
>>     cfe/trunk/lib/Basic/Targets/OSTargets.cpp
>>     cfe/trunk/lib/Basic/Targets/OSTargets.h
>>     cfe/trunk/lib/Basic/Targets/X86.h
>>     cfe/trunk/lib/CodeGen/BackendUtil.cpp
>>     cfe/trunk/lib/CodeGen/CGException.cpp
>>     cfe/trunk/lib/Driver/ToolChain.cpp
>>     cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>>     cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>>     cfe/trunk/lib/Driver/ToolChains/Darwin.h
>>     cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
>>     cfe/trunk/lib/Driver/ToolChains/FreeBSD.h
>>     cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>>     cfe/trunk/lib/Driver/ToolChains/MinGW.h
>>     cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
>>     cfe/trunk/lib/Driver/ToolChains/NetBSD.h
>>     cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>>     cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>>     cfe/trunk/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
>>     cfe/trunk/test/Preprocessor/arm-target-features.c
>>     cfe/trunk/test/Preprocessor/init.c
>>
>> Modified: cfe/trunk/docs/ClangCommandLineReference.rst
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/docs/ClangCommandLineReference.rst (original)
>> +++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Nov 28 23:25:12 2017
>> @@ -1706,10 +1706,18 @@ Which overload candidates to show when o
>>
>>  Enable C++14 sized global deallocation functions
>>
>> +.. option:: -fdwarf-exceptions
>> +
>> +Use DWARF style exceptions
>> +
>>  .. option:: -fsjlj-exceptions
>>
>>  Use SjLj style exceptions
>>
>> +.. option:: -fseh-exceptions
>> +
>> +Use SEH style exceptions
>> +
>>  .. option:: -fslp-vectorize, -fno-slp-vectorize, -ftree-slp-vectorize
>>
>>  Enable the superword-level parallelism vectorization passes
>>
>> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
>> +++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Nov 28 23:25:12 2017
>> @@ -124,7 +124,9 @@ LANGOPT(ZVector           , 1, 0, "Syste
>>  LANGOPT(Exceptions        , 1, 0, "exception handling")
>>  LANGOPT(ObjCExceptions    , 1, 0, "Objective-C exceptions")
>>  LANGOPT(CXXExceptions     , 1, 0, "C++ exceptions")
>> +LANGOPT(DWARFExceptions   , 1, 0, "dwarf exception handling")
>>  LANGOPT(SjLjExceptions    , 1, 0, "setjmp-longjump exception handling")
>> +LANGOPT(SEHExceptions     , 1, 0, "SEH .xdata exception handling")
>>  LANGOPT(ExternCNoUnwind   , 1, 0, "Assume extern C functions don't
>> unwind")
>>  LANGOPT(TraditionalCPP    , 1, 0, "traditional CPP emulation")
>>  LANGOPT(RTTI              , 1, 1, "run-time type information")
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Tue Nov 28 23:25:12 2017
>> @@ -800,8 +800,12 @@ def fencoding_EQ : Joined<["-"], "fencod
>>  def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group<f_Group>,
>> Flags<[CoreOption]>;
>>  def fexceptions : Flag<["-"], "fexceptions">, Group<f_Group>,
>> Flags<[CC1Option]>,
>>    HelpText<"Enable support for exception handling">;
>> +def fdwarf_exceptions : Flag<["-"], "fdwarf-exceptions">, Group<f_Group>,
>> +  Flags<[CC1Option]>, HelpText<"Use DWARF style exceptions">;
>>  def fsjlj_exceptions : Flag<["-"], "fsjlj-exceptions">, Group<f_Group>,
>>    Flags<[CC1Option]>, HelpText<"Use SjLj style exceptions">;
>> +def fseh_exceptions : Flag<["-"], "fseh-exceptions">, Group<f_Group>,
>> +  Flags<[CC1Option]>, HelpText<"Use SEH style exceptions">;
>>  def fexcess_precision_EQ : Joined<["-"], "fexcess-precision=">,
>>      Group<clang_ignored_gcc_optimization_f_Group>;
>>  def : Flag<["-"], "fexpensive-optimizations">,
>> Group<clang_ignored_gcc_optimization_f_Group>;
>>
>> Modified: cfe/trunk/include/clang/Driver/ToolChain.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/ToolChain.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/include/clang/Driver/ToolChain.h (original)
>> +++ cfe/trunk/include/clang/Driver/ToolChain.h Tue Nov 28 23:25:12 2017
>> @@ -397,10 +397,9 @@ public:
>>      return llvm::DebuggerKind::GDB;
>>    }
>>
>> -  /// UseSjLjExceptions - Does this tool chain use SjLj exceptions.
>> -  virtual bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const {
>> -    return false;
>> -  }
>> +  /// GetExceptionModel - Return the tool chain exception model.
>> +  virtual llvm::ExceptionHandling
>> +  GetExceptionModel(const llvm::opt::ArgList &Args) const;
>>
>>    /// SupportsEmbeddedBitcode - Does this tool chain support embedded
>> bitcode.
>>    virtual bool SupportsEmbeddedBitcode() const {
>>
>> Modified: cfe/trunk/lib/Basic/Targets/ARM.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/ARM.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Basic/Targets/ARM.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets/ARM.cpp Tue Nov 28 23:25:12 2017
>> @@ -1000,7 +1000,6 @@ void MinGWARMTargetInfo::getTargetDefine
>>                                            MacroBuilder &Builder) const {
>>    WindowsARMTargetInfo::getTargetDefines(Opts, Builder);
>>    Builder.defineMacro("_ARM_");
>> -  Builder.defineMacro("__ARM_DWARF_EH__");
>>  }
>>
>>  CygwinARMTargetInfo::CygwinARMTargetInfo(const llvm::Triple &Triple,
>>
>> Modified: cfe/trunk/lib/Basic/Targets/OSTargets.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Basic/Targets/OSTargets.cpp (original)
>> +++ cfe/trunk/lib/Basic/Targets/OSTargets.cpp Tue Nov 28 23:25:12 2017
>> @@ -133,10 +133,6 @@ void getDarwinDefines(MacroBuilder &Buil
>>    if (Triple.isOSDarwin())
>>      Builder.defineMacro("__MACH__");
>>
>> -  // The Watch ABI uses Dwarf EH.
>> -  if (Triple.isWatchABI())
>> -    Builder.defineMacro("__ARM_DWARF_EH__");
>> -
>>    PlatformMinVersion = VersionTuple(Maj, Min, Rev);
>>  }
>>  } // namespace targets
>>
>> Modified: cfe/trunk/lib/Basic/Targets/OSTargets.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/OSTargets.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Basic/Targets/OSTargets.h (original)
>> +++ cfe/trunk/lib/Basic/Targets/OSTargets.h Tue Nov 28 23:25:12 2017
>> @@ -358,17 +358,6 @@ protected:
>>      Builder.defineMacro("__ELF__");
>>      if (Opts.POSIXThreads)
>>        Builder.defineMacro("_REENTRANT");
>> -
>> -    switch (Triple.getArch()) {
>> -    default:
>> -      break;
>> -    case llvm::Triple::arm:
>> -    case llvm::Triple::armeb:
>> -    case llvm::Triple::thumb:
>> -    case llvm::Triple::thumbeb:
>> -      Builder.defineMacro("__ARM_DWARF_EH__");
>> -      break;
>> -    }
>>    }
>>
>>  public:
>>
>> Modified: cfe/trunk/lib/Basic/Targets/X86.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Basic/Targets/X86.h (original)
>> +++ cfe/trunk/lib/Basic/Targets/X86.h Tue Nov 28 23:25:12 2017
>> @@ -710,15 +710,6 @@ public:
>>      LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
>>      HasFloat128 = true;
>>    }
>> -
>> -  void getTargetDefines(const LangOptions &Opts,
>> -                        MacroBuilder &Builder) const override {
>> -    WindowsX86_64TargetInfo::getTargetDefines(Opts, Builder);
>> -
>> -    // GCC defines this macro when it is using __gxx_personality_seh0.
>> -    if (!Opts.SjLjExceptions)
>> -      Builder.defineMacro("__SEH__");
>> -  }
>>  };
>>
>>  // x86-64 Cygwin target
>> @@ -740,10 +731,6 @@ public:
>>      DefineStd(Builder, "unix", Opts);
>>      if (Opts.CPlusPlus)
>>        Builder.defineMacro("_GNU_SOURCE");
>> -
>> -    // GCC defines this macro when it is using __gxx_personality_seh0.
>> -    if (!Opts.SjLjExceptions)
>> -      Builder.defineMacro("__SEH__");
>>    }
>>  };
>>
>>
>> Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Nov 28 23:25:12 2017
>> @@ -424,6 +424,10 @@ static void initTargetOptions(llvm::Targ
>>
>>    if (LangOpts.SjLjExceptions)
>>      Options.ExceptionModel = llvm::ExceptionHandling::SjLj;
>> +  if (LangOpts.SEHExceptions)
>> +    Options.ExceptionModel = llvm::ExceptionHandling::WinEH;
>> +  if (LangOpts.DWARFExceptions)
>> +    Options.ExceptionModel = llvm::ExceptionHandling::DwarfCFI;
>>
>>    Options.NoInfsFPMath = CodeGenOpts.NoInfsFPMath;
>>    Options.NoNaNsFPMath = CodeGenOpts.NoNaNsFPMath;
>>
>> Modified: cfe/trunk/lib/CodeGen/CGException.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/CodeGen/CGException.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGException.cpp Tue Nov 28 23:25:12 2017
>> @@ -112,17 +112,11 @@ EHPersonality::MSVC_C_specific_handler =
>>  const EHPersonality
>>  EHPersonality::MSVC_CxxFrameHandler3 = { "__CxxFrameHandler3", nullptr };
>>
>> -/// On Win64, use libgcc's SEH personality function. We fall back to
>> dwarf on
>> -/// other platforms, unless the user asked for SjLj exceptions.
>> -static bool useLibGCCSEHPersonality(const llvm::Triple &T) {
>> -  return T.isOSWindows() && T.getArch() == llvm::Triple::x86_64;
>> -}
>> -
>>  static const EHPersonality &getCPersonality(const llvm::Triple &T,
>>                                              const LangOptions &L) {
>>    if (L.SjLjExceptions)
>>      return EHPersonality::GNU_C_SJLJ;
>> -  else if (useLibGCCSEHPersonality(T))
>> +  if (L.SEHExceptions)
>>      return EHPersonality::GNU_C_SEH;
>>    return EHPersonality::GNU_C;
>>  }
>> @@ -144,7 +138,7 @@ static const EHPersonality &getObjCPerso
>>    case ObjCRuntime::ObjFW:
>>      if (L.SjLjExceptions)
>>        return EHPersonality::GNU_ObjC_SJLJ;
>> -    else if (useLibGCCSEHPersonality(T))
>> +    if (L.SEHExceptions)
>>        return EHPersonality::GNU_ObjC_SEH;
>>      return EHPersonality::GNU_ObjC;
>>    }
>> @@ -155,7 +149,7 @@ static const EHPersonality &getCXXPerson
>>                                                const LangOptions &L) {
>>    if (L.SjLjExceptions)
>>      return EHPersonality::GNU_CPlusPlus_SJLJ;
>> -  else if (useLibGCCSEHPersonality(T))
>> +  if (L.SEHExceptions)
>>      return EHPersonality::GNU_CPlusPlus_SEH;
>>    return EHPersonality::GNU_CPlusPlus;
>>  }
>> @@ -211,6 +205,10 @@ const EHPersonality &EHPersonality::get(
>>    if (T.isWindowsMSVCEnvironment() && !L.ObjC1) {
>>      if (L.SjLjExceptions)
>>        return EHPersonality::GNU_CPlusPlus_SJLJ;
>> +    if (L.SEHExceptions)
>> +      return EHPersonality::GNU_CPlusPlus_SEH;
>> +    if (L.DWARFExceptions)
>> +      return EHPersonality::GNU_CPlusPlus;
>>      else
>>        return EHPersonality::MSVC_CxxFrameHandler3;
>>    }
>>
>> Modified: cfe/trunk/lib/Driver/ToolChain.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChain.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChain.cpp Tue Nov 28 23:25:12 2017
>> @@ -27,6 +27,8 @@
>>  #include "llvm/Support/ErrorHandling.h"
>>  #include "llvm/Support/FileSystem.h"
>>  #include "llvm/Support/Path.h"
>> +#include "llvm/MC/MCAsmInfo.h"
>> +#include "llvm/MC/MCRegisterInfo.h"
>>  #include "llvm/Support/TargetParser.h"
>>  #include "llvm/Support/TargetRegistry.h"
>>
>> @@ -449,6 +451,13 @@ ObjCRuntime ToolChain::getDefaultObjCRun
>>                       VersionTuple());
>>  }
>>
>> +llvm::ExceptionHandling
>> +ToolChain::GetExceptionModel(const llvm::opt::ArgList &Args) const {
>> +  if (Triple.isOSWindows() && Triple.getArch() != llvm::Triple::x86)
>> +    return llvm::ExceptionHandling::WinEH;
>> +  return llvm::ExceptionHandling::None;
>> +}
>> +
>>  bool ToolChain::isThreadModelSupported(const StringRef Model) const {
>>    if (Model == "single") {
>>      // FIXME: 'single' is only supported on ARM and WebAssembly so far.
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Nov 28 23:25:12 2017
>> @@ -4166,9 +4166,33 @@ void Clang::ConstructJob(Compilation &C,
>>      addExceptionArgs(Args, InputType, getToolChain(), KernelOrKext,
>> Runtime,
>>                       CmdArgs);
>>
>> -  if (Args.hasArg(options::OPT_fsjlj_exceptions) ||
>> -      getToolChain().UseSjLjExceptions(Args))
>> -    CmdArgs.push_back("-fsjlj-exceptions");
>> +  // Handle exception personalities
>> +  Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
>> +                           options::OPT_fseh_exceptions,
>> +                           options::OPT_fdwarf_exceptions);
>> +  if (A) {
>> +    const Option &Opt = A->getOption();
>> +    if (Opt.matches(options::OPT_fsjlj_exceptions))
>> +      CmdArgs.push_back("-fsjlj-exceptions");
>> +    if (Opt.matches(options::OPT_fseh_exceptions))
>> +      CmdArgs.push_back("-fseh-exceptions");
>> +    if (Opt.matches(options::OPT_fdwarf_exceptions))
>> +      CmdArgs.push_back("-fdwarf-exceptions");
>> +  } else {
>> +    switch(getToolChain().GetExceptionModel(Args)) {
>> +      default:
>> +        break;
>> +      case llvm::ExceptionHandling::DwarfCFI:
>> +        CmdArgs.push_back("-fdwarf-exceptions");
>> +        break;
>> +      case llvm::ExceptionHandling::SjLj:
>> +        CmdArgs.push_back("-fsjlj-exceptions");
>> +        break;
>> +      case llvm::ExceptionHandling::WinEH:
>> +        CmdArgs.push_back("-fseh-exceptions");
>> +        break;
>> +    }
>> +  }
>>
>>    // C++ "sane" operator new.
>>    if (!Args.hasFlag(options::OPT_fassume_sane_operator_new,
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Nov 28 23:25:12 2017
>> @@ -1881,7 +1881,7 @@ bool MachO::IsUnwindTablesDefault(const
>>    // Unwind tables are not emitted if -fno-exceptions is supplied
>> (except when
>>    // targeting x86_64).
>>    return getArch() == llvm::Triple::x86_64 ||
>> -         (!UseSjLjExceptions(Args) &&
>> +         (GetExceptionModel(Args) != llvm::ExceptionHandling::SjLj &&
>>            Args.hasFlag(options::OPT_fexceptions,
>> options::OPT_fno_exceptions,
>>                         true));
>>  }
>> @@ -1892,15 +1892,18 @@ bool MachO::UseDwarfDebugFlags() const {
>>    return false;
>>  }
>>
>> -bool Darwin::UseSjLjExceptions(const ArgList &Args) const {
>> +llvm::ExceptionHandling Darwin::GetExceptionModel(const ArgList &Args)
>> const {
>>    // Darwin uses SjLj exceptions on ARM.
>>    if (getTriple().getArch() != llvm::Triple::arm &&
>>        getTriple().getArch() != llvm::Triple::thumb)
>> -    return false;
>> +    return llvm::ExceptionHandling::None;
>>
>>    // Only watchOS uses the new DWARF/Compact unwinding method.
>>    llvm::Triple Triple(ComputeLLVMTriple(Args));
>> -  return !Triple.isWatchABI();
>> +  if(Triple.isWatchABI())
>> +    return llvm::ExceptionHandling::DwarfCFI;
>> +
>> +  return llvm::ExceptionHandling::SjLj;
>>  }
>>
>>  bool Darwin::SupportsEmbeddedBitcode() const {
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/Darwin.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Darwin.h Tue Nov 28 23:25:12 2017
>> @@ -247,8 +247,9 @@ public:
>>
>>    bool UseDwarfDebugFlags() const override;
>>
>> -  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override {
>> -    return false;
>> +  llvm::ExceptionHandling
>> +  GetExceptionModel(const llvm::opt::ArgList &Args) const override {
>> +    return llvm::ExceptionHandling::None;
>>    }
>>
>>    /// }
>> @@ -455,7 +456,8 @@ public:
>>
>>    void CheckObjCARC() const override;
>>
>> -  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
>> +  llvm::ExceptionHandling GetExceptionModel(
>> +      const llvm::opt::ArgList &Args) const override;
>>
>>    bool SupportsEmbeddedBitcode() const override;
>>
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp Tue Nov 28 23:25:12 2017
>> @@ -359,17 +359,18 @@ Tool *FreeBSD::buildAssembler() const {
>>
>>  Tool *FreeBSD::buildLinker() const { return new
>> tools::freebsd::Linker(*this); }
>>
>> -bool FreeBSD::UseSjLjExceptions(const ArgList &Args) const {
>> +llvm::ExceptionHandling FreeBSD::GetExceptionModel(const ArgList &Args)
>> const {
>>    // FreeBSD uses SjLj exceptions on ARM oabi.
>>    switch (getTriple().getEnvironment()) {
>>    case llvm::Triple::GNUEABIHF:
>>    case llvm::Triple::GNUEABI:
>>    case llvm::Triple::EABI:
>> -    return false;
>> -
>> +    return llvm::ExceptionHandling::None;
>>    default:
>> -    return (getTriple().getArch() == llvm::Triple::arm ||
>> -            getTriple().getArch() == llvm::Triple::thumb);
>> +    if (getTriple().getArch() == llvm::Triple::arm ||
>> +        getTriple().getArch() == llvm::Triple::thumb)
>> +      return llvm::ExceptionHandling::SjLj;
>> +    return llvm::ExceptionHandling::None;
>>    }
>>  }
>>
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/FreeBSD.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.h Tue Nov 28 23:25:12 2017
>> @@ -66,7 +66,8 @@ public:
>>    void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
>>                             llvm::opt::ArgStringList &CmdArgs) const
>> override;
>>
>> -  bool UseSjLjExceptions(const llvm::opt::ArgList &Args) const override;
>> +  llvm::ExceptionHandling GetExceptionModel(
>> +      const llvm::opt::ArgList &Args) const override;
>>    bool isPIEDefault() const override;
>>    SanitizerMask getSupportedSanitizers() const override;
>>    unsigned GetDefaultDwarfVersion() const override { return 2; }
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Tue Nov 28 23:25:12 2017
>> @@ -367,8 +367,11 @@ bool toolchains::MinGW::isPICDefaultForc
>>    return getArch() == llvm::Triple::x86_64;
>>  }
>>
>> -bool toolchains::MinGW::UseSEHExceptions() const {
>> -  return getArch() == llvm::Triple::x86_64;
>> +llvm::ExceptionHandling
>> +toolchains::MinGW::GetExceptionModel(const ArgList &Args) const {
>> +  if (getArch() == llvm::Triple::x86_64)
>> +    return llvm::ExceptionHandling::WinEH;
>> +  return llvm::ExceptionHandling::DwarfCFI;
>>  }
>>
>>  void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Tue Nov 28 23:25:12 2017
>> @@ -64,7 +64,9 @@ public:
>>    bool isPICDefault() const override;
>>    bool isPIEDefault() const override;
>>    bool isPICDefaultForced() const override;
>> -  bool UseSEHExceptions() const;
>> +
>> +  llvm::ExceptionHandling GetExceptionModel(
>> +      const llvm::opt::ArgList &Args) const override;
>>
>>    void
>>    AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/NetBSD.cpp Tue Nov 28 23:25:12 2017
>> @@ -416,6 +416,15 @@ void NetBSD::addLibStdCxxIncludePaths(co
>>                             "", DriverArgs, CC1Args);
>>  }
>>
>> +llvm::ExceptionHandling NetBSD::GetExceptionModel(const ArgList &Args)
>> const {
>> +  // NetBSD uses Dwarf exceptions on ARM.
>> +  llvm::Triple::ArchType TArch = getTriple().getArch();
>> +  if (TArch == llvm::Triple::arm || TArch == llvm::Triple::armeb ||
>> +      TArch == llvm::Triple::thumb || TArch == llvm::Triple::thumbeb)
>> +    return llvm::ExceptionHandling::DwarfCFI;
>> +  return llvm::ExceptionHandling::None;
>> +}
>> +
>>  SanitizerMask NetBSD::getSupportedSanitizers() const {
>>    const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
>>    const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/NetBSD.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/NetBSD.h?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Driver/ToolChains/NetBSD.h (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/NetBSD.h Tue Nov 28 23:25:12 2017
>> @@ -69,6 +69,9 @@ public:
>>      return true;
>>    }
>>
>> +  llvm::ExceptionHandling GetExceptionModel(
>> +      const llvm::opt::ArgList &Args) const override;
>> +
>>    SanitizerMask getSupportedSanitizers() const override;
>>
>>  protected:
>>
>> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
>> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Nov 28 23:25:12 2017
>> @@ -2141,7 +2141,18 @@ static void ParseLangArgs(LangOptions &O
>>    Opts.Exceptions = Args.hasArg(OPT_fexceptions);
>>    Opts.ObjCExceptions = Args.hasArg(OPT_fobjc_exceptions);
>>    Opts.CXXExceptions = Args.hasArg(OPT_fcxx_exceptions);
>> -  Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
>> +
>> +  // Handle exception personalities
>> +  Arg *A = Args.getLastArg(options::OPT_fsjlj_exceptions,
>> +                           options::OPT_fseh_exceptions,
>> +                           options::OPT_fdwarf_exceptions);
>> +  if (A) {
>> +    const Option &Opt = A->getOption();
>> +    Opts.SjLjExceptions = Opt.matches(options::OPT_fsjlj_exceptions);
>> +    Opts.SEHExceptions = Opt.matches(options::OPT_fseh_exceptions);
>> +    Opts.DWARFExceptions = Opt.matches(options::OPT_fdwarf_exceptions);
>> +  }
>> +
>>    Opts.ExternCNoUnwind = Args.hasArg(OPT_fexternc_nounwind);
>>    Opts.TraditionalCPP = Args.hasArg(OPT_traditional_cpp);
>>
>>
>> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
>> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Tue Nov 28 23:25:12 2017
>> @@ -677,8 +677,14 @@ static void InitializePredefinedMacros(c
>>      Builder.defineMacro("__EXCEPTIONS");
>>    if (!LangOpts.MSVCCompat && LangOpts.RTTI)
>>      Builder.defineMacro("__GXX_RTTI");
>> +
>>    if (LangOpts.SjLjExceptions)
>>      Builder.defineMacro("__USING_SJLJ_EXCEPTIONS__");
>> +  else if (LangOpts.SEHExceptions)
>> +    Builder.defineMacro("__SEH__");
>> +  else if (LangOpts.DWARFExceptions &&
>> +          (TI.getTriple().isThumb() || TI.getTriple().isARM()))
>> +    Builder.defineMacro("__ARM_DWARF_EH__");
>>
>>    if (LangOpts.Deprecated)
>>      Builder.defineMacro("__DEPRECATED");
>>
>> Added: cfe/trunk/test/CodeGenCXX/mingw-w64-exceptions.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mingw-w64-exceptions.c?rev=319297&view=auto
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenCXX/mingw-w64-exceptions.c (added)
>> +++ cfe/trunk/test/CodeGenCXX/mingw-w64-exceptions.c Tue Nov 28 23:25:12
>> 2017
>> @@ -0,0 +1,22 @@
>> +// RUN: %clang -target x86_64-windows-gnu -c %s -### 2>&1 | FileCheck %s
>> --check-prefix=CHECK-SEH
>> +// RUN: %clang -target i686-windows-gnu -c %s -### 2>&1 | FileCheck %s
>> --check-prefix=CHECK-DWARF
>> +
>> +// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions -c %s -###
>> 2>&1 | \
>> +// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
>> +
>> +// RUN: %clang -target x86_64-windows-gnu -fdwarf-exceptions -c %s -###
>> 2>&1 | \
>> +// RUN: FileCheck %s --check-prefix=CHECK-DWARF
>> +
>> +// RUN: %clang -target x86_64-windows-gnu -fsjlj-exceptions
>> -fseh-exceptions -c %s -### 2>&1 | \
>> +// RUN: FileCheck %s --check-prefix=CHECK-SEH
>> +
>> +// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions
>> -fsjlj-exceptions -c %s -### 2>&1 | \
>> +// RUN: FileCheck %s --check-prefix=CHECK-SJLJ
>> +
>> +// RUN: %clang -target x86_64-windows-gnu -fseh-exceptions
>> -fdwarf-exceptions -c %s -### 2>&1 | \
>> +// RUN: FileCheck %s --check-prefix=CHECK-DWARF
>> +
>> +// CHECK-SEH: "-fseh-exceptions"
>> +// CHECK-SJLJ: "-fsjlj-exceptions"
>> +// CHECK-DWARF-NOT: "-fsjlj-exceptions"
>> +// CHECK-DWARF-NOT: "-fseh-exceptions"
>>
>> Modified: cfe/trunk/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp (original)
>> +++ cfe/trunk/test/CodeGenCXX/mingw-w64-seh-exceptions.cpp Tue Nov 28
>> 23:25:12 2017
>> @@ -1,4 +1,5 @@
>> -// RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple
>> x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
>> +// RUN: %clang_cc1 %s -fexceptions -fseh-exceptions -emit-llvm -triple
>> x86_64-w64-windows-gnu -o - | FileCheck %s --check-prefix=X64
>> +// RUN: %clang_cc1 %s -fexceptions -fdwarf-exceptions -emit-llvm -triple
>> i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
>>  // RUN: %clang_cc1 %s -fexceptions -emit-llvm -triple
>> i686-w64-windows-gnu -o - | FileCheck %s --check-prefix=X86
>>
>>  extern "C" void foo();
>>
>> Modified: cfe/trunk/test/Preprocessor/arm-target-features.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/arm-target-features.c?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/Preprocessor/arm-target-features.c (original)
>> +++ cfe/trunk/test/Preprocessor/arm-target-features.c Tue Nov 28 23:25:12
>> 2017
>> @@ -214,6 +214,7 @@
>>  // A5:#define __ARM_ARCH_7A__ 1
>>  // A5-NOT:#define __ARM_ARCH_EXT_IDIV__
>>  // A5:#define __ARM_ARCH_PROFILE 'A'
>> +// A5-NOT:#define __ARM_DWARF_EH__ 1
>>  // A5-NOT: #define __ARM_FEATURE_DIRECTED_ROUNDING
>>  // A5:#define __ARM_FEATURE_DSP 1
>>  // A5-NOT: #define __ARM_FEATURE_NUMERIC_MAXMIN
>> @@ -225,6 +226,7 @@
>>  // A7:#define __ARM_ARCH 7
>>  // A7:#define __ARM_ARCH_EXT_IDIV__ 1
>>  // A7:#define __ARM_ARCH_PROFILE 'A'
>> +// A7-NOT:#define __ARM_DWARF_EH__ 1
>>  // A7:#define __ARM_FEATURE_DSP 1
>>  // A7:#define __ARM_FP 0xE
>>
>>
>> Modified: cfe/trunk/test/Preprocessor/init.c
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=319297&r1=319296&r2=319297&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/test/Preprocessor/init.c (original)
>> +++ cfe/trunk/test/Preprocessor/init.c Tue Nov 28 23:25:12 2017
>> @@ -1442,6 +1442,7 @@
>>  //
>>  // ARM-MSVC: #define _M_ARM_NT 1
>>  // ARM-MSVC: #define _WIN32 1
>> +// ARM-MSVC-NOT:#define __ARM_DWARF_EH__ 1
>>
>>  // RUN: %clang_cc1 -E -dM -ffreestanding -triple=aarch64-windows-msvc <
>> /dev/null | FileCheck -match-full-lines -check-prefix AARCH64-MSVC %s
>>  //
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171129/b68e6d05/attachment-0001.html>


More information about the cfe-commits mailing list