Commit 6257aa2a authored by Hans Wennborg's avatar Hans Wennborg
Browse files

Merging r310006:

------------------------------------------------------------------------
r310006 | ahatanak | 2017-08-03 16:55:42 -0700 (Thu, 03 Aug 2017) | 22 lines

[Driver][Darwin] Pass -munwind-table when !UseSjLjExceptions.

This commit fixes a bug where clang/llvm doesn't emit an unwind table
for a function when it is marked noexcept. Without this patch, the
following code terminates with an uncaught exception on ARM64:

int foo1() noexcept {
  try {
    throw 0;
  } catch (int i) {
    return 0;
  }
  return 1;
}

int main() {
  return foo1();
}

rdar://problem/32411865

Differential Revision: https://reviews.llvm.org/D35693
------------------------------------------------------------------------

llvm-svn: 310677
parent 5b60b618
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -315,7 +315,7 @@ public:

  /// IsUnwindTablesDefault - Does this tool chain use -funwind-tables
  /// by default.
  virtual bool IsUnwindTablesDefault() const;
  virtual bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const;

  /// \brief Test whether this toolchain defaults to PIC.
  virtual bool isPICDefault() const = 0;
+1 −1
Original line number Diff line number Diff line
@@ -217,7 +217,7 @@ StringRef ToolChain::getDefaultUniversalArchName() const {
  }
}

bool ToolChain::IsUnwindTablesDefault() const {
bool ToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
  return false;
}

+1 −1
Original line number Diff line number Diff line
@@ -2538,7 +2538,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
  bool AsynchronousUnwindTables =
      Args.hasFlag(options::OPT_fasynchronous_unwind_tables,
                   options::OPT_fno_asynchronous_unwind_tables,
                   (getToolChain().IsUnwindTablesDefault() ||
                   (getToolChain().IsUnwindTablesDefault(Args) ||
                    getToolChain().getSanitizerArgs().needsUnwindTables()) &&
                       !KernelOrKext);
  if (Args.hasFlag(options::OPT_funwind_tables, options::OPT_fno_unwind_tables,
+1 −1
Original line number Diff line number Diff line
@@ -214,7 +214,7 @@ CrossWindowsToolChain::CrossWindowsToolChain(const Driver &D,
  }
}

bool CrossWindowsToolChain::IsUnwindTablesDefault() const {
bool CrossWindowsToolChain::IsUnwindTablesDefault(const ArgList &Args) const {
  // FIXME: all non-x86 targets need unwind tables, however, LLVM currently does
  // not know how to emit them.
  return getArch() == llvm::Triple::x86_64;
+1 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ public:
                        const llvm::opt::ArgList &Args);

  bool IsIntegratedAssemblerDefault() const override { return true; }
  bool IsUnwindTablesDefault() const override;
  bool IsUnwindTablesDefault(const llvm::opt::ArgList &Args) const override;
  bool isPICDefault() const override;
  bool isPIEDefault() const override;
  bool isPICDefaultForced() const override;
Loading