[PATCH] D134657: [Driver] pass -fcrash-diagnostics-dir to LTO

Yuanfang Chen via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Sep 26 11:00:13 PDT 2022


ychen updated this revision to Diff 462968.
ychen added a comment.

- use getLastArg
- rebase


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134657/new/

https://reviews.llvm.org/D134657

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/crash-diagnostics-dir-2.c


Index: clang/test/Driver/crash-diagnostics-dir-2.c
===================================================================
--- clang/test/Driver/crash-diagnostics-dir-2.c
+++ clang/test/Driver/crash-diagnostics-dir-2.c
@@ -3,3 +3,12 @@
 // OPTION: "-crash-diagnostics-dir=mydumps"
 // RUN: %clang -### -c %s 2>&1 | FileCheck %s --check-prefix=NOOPTION
 // NOOPTION-NOT: "-crash-diagnostics-dir
+
+// RUN: %clang -### -fcrash-diagnostics-dir=mydumps -flto %s 2>&1 \
+// RUN:     | FileCheck %s --check-prefix=LTO-OPTION
+// LTO-OPTION: "-cc1"
+// LTO-OPTION: "-plugin-opt=-crash-diagnostics-dir=mydumps"
+
+// RUN: %clang -### -flto %s 2>&1 | FileCheck %s --check-prefix=LTO-NOOPTION
+// LTO-NOOPTION: "-cc1"
+// LTO-NOOPTION-NOT: "-plugin-opt=-crash-diagnostics-dir=mydumps"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -631,6 +631,11 @@
     CmdArgs.push_back(
         Args.MakeArgString(Twine("-plugin-opt=stats-file=") + StatsFile));
 
+  // Setup crash diagnostics dir.
+  if (Arg *A = Args.getLastArg(options::OPT_fcrash_diagnostics_dir))
+    CmdArgs.push_back(Args.MakeArgString(
+        Twine("-plugin-opt=-crash-diagnostics-dir=") + A->getValue()));
+
   addX86AlignBranchArgs(D, Args, CmdArgs, /*IsLTO=*/true);
 
   // Handle remark diagnostics on screen options: '-Rpass-*'.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134657.462968.patch
Type: text/x-patch
Size: 1454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220926/7f3fc10c/attachment.bin>


More information about the cfe-commits mailing list