r312965 - [codeview] omit debug locations for nested exprs unless column info enabled

2017-09-11 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Sep 11 15:11:57 2017
New Revision: 312965

URL: http://llvm.org/viewvc/llvm-project?rev=312965&view=rev
Log:
[codeview] omit debug locations for nested exprs unless column info enabled

Summary:
Microsoft Visual Studio expects debug locations to correspond to
statements. We used to emit locations for expressions nested inside statements.
This would confuse the debugger, causing it to stop multiple times on the
same line and breaking the "step into specific" feature. This change inhibits
the emission of debug locations for nested expressions when emitting CodeView
debug information, unless column information is enabled.

Fixes PR34312.

Reviewers: rnk, zturner

Reviewed By: rnk

Subscribers: majnemer, echristo, aprantl, cfe-commits

Differential Revision: https://reviews.llvm.org/D37529

Added:
cfe/trunk/test/CodeGenCXX/debug-info-nested-exprs.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.h

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=312965&r1=312964&r2=312965&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Sep 11 15:11:57 2017
@@ -97,6 +97,10 @@ void ApplyDebugLocation::init(SourceLoca
   }
 
   OriginalLocation = CGF->Builder.getCurrentDebugLocation();
+
+  if (OriginalLocation && !DI->CGM.getExpressionLocationsEnabled())
+return;
+
   if (TemporaryLocation.isValid()) {
 DI->EmitLocation(CGF->Builder, TemporaryLocation);
 return;

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=312965&r1=312964&r2=312965&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Sep 11 15:11:57 2017
@@ -3553,6 +3553,10 @@ CodeGenModule::GetAddrOfConstantCFString
   return ConstantAddress(GV, Alignment);
 }
 
+bool CodeGenModule::getExpressionLocationsEnabled() const {
+  return !CodeGenOpts.EmitCodeView || CodeGenOpts.DebugColumnInfo;
+}
+
 QualType CodeGenModule::getObjCFastEnumerationStateType() {
   if (ObjCFastEnumerationStateType.isNull()) {
 RecordDecl *D = Context.buildImplicitRecord("__objcFastEnumerationState");

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.h?rev=312965&r1=312964&r2=312965&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.h Mon Sep 11 15:11:57 2017
@@ -513,6 +513,9 @@ public:
   /// Finalize LLVM code generation.
   void Release();
 
+  /// Return true if we should emit location information for expressions.
+  bool getExpressionLocationsEnabled() const;
+
   /// Return a reference to the configured Objective-C runtime.
   CGObjCRuntime &getObjCRuntime() {
 if (!ObjCRuntime) createObjCRuntime();

Added: cfe/trunk/test/CodeGenCXX/debug-info-nested-exprs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-nested-exprs.cpp?rev=312965&view=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-nested-exprs.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-nested-exprs.cpp Mon Sep 11 15:11:57 
2017
@@ -0,0 +1,202 @@
+// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \
+// RUN:-std=c++11 -gcodeview -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=NONEST %s
+// RUN: %clang_cc1 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited \
+// RUN:-std=c++11 -gcodeview -dwarf-column-info -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=COLUMNS %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \
+// RUN:-std=c++11 -emit-llvm -o - %s | FileCheck -check-prefix=NESTED %s
+// RUN: %clang_cc1 -triple=x86_64-unknown-linux-gnu -debug-info-kind=limited \
+// RUN:-std=c++11 -dwarf-column-info -emit-llvm -o - %s \
+// RUN:| FileCheck -check-prefix=COLUMNS %s
+
+class Foo {
+public:
+  static Foo create();
+  void func();
+  int *begin();
+  int *end();
+};
+
+int bar(int x, int y);
+int baz(int x, int y);
+int qux(int x, int y);
+int onearg(int x);
+int noargs();
+int noargs1();
+Foo range(int x);
+
+int foo(int x, int y, int z) {
+  int a = bar(x, y) +
+  baz(x, z) +
+  qux(y, z);
+  // NONEST: call i32 @{{.*}}bar{{.*}}, !dbg ![[LOC:[0-9]+]]
+  // NONEST: call i32 @{{.*}}baz{{.*}}, !dbg ![[LOC]]
+  // NONEST: call i32 @{{.*}}qux{{.*}}, !dbg ![[LOC]]
+  // NONEST: store i32 {{.*}}, i32* %a,{{.*}} !dbg ![[LOC]]
+  //

r313425 - [docs] add Windows examples to ThinLTO.rst

2017-09-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Fri Sep 15 17:16:13 2017
New Revision: 313425

URL: http://llvm.org/viewvc/llvm-project?rev=313425&view=rev
Log:
[docs] add Windows examples to ThinLTO.rst

Reviewers: pcc, ruiu

Reviewed By: ruiu

Subscribers: mehdi_amini, eraman, cfe-commits

Differential Revision: https://reviews.llvm.org/D37943

Modified:
cfe/trunk/docs/ThinLTO.rst

Modified: cfe/trunk/docs/ThinLTO.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThinLTO.rst?rev=313425&r1=313424&r2=313425&view=diff
==
--- cfe/trunk/docs/ThinLTO.rst (original)
+++ cfe/trunk/docs/ThinLTO.rst Fri Sep 15 17:16:13 2017
@@ -63,7 +63,7 @@ ThinLTO is currently supported for the f
 - **ld64**:
   Starting with `Xcode 8 `_.
 - **lld**:
-  Starting with r284050 (ELF only).
+  Starting with r284050 for ELF, r298942 for COFF.
 
 Usage
 =
@@ -78,6 +78,13 @@ To utilize ThinLTO, simply add the -flto
   % clang -flto=thin -O2 file1.c file2.c -c
   % clang -flto=thin -O2 file1.o file2.o -o a.out
 
+When using lld-link, the -flto option need only be added to the compile step:
+
+.. code-block:: console
+
+  % clang-cl -flto=thin -O2 -c file1.c file2.c
+  % lld-link /out:a.exe file1.obj file2.obj
+
 As mentioned earlier, by default the linkers will launch the ThinLTO backend
 threads in parallel, passing the resulting native object files back to the
 linker for the final native link.  As such, the usage model the same as
@@ -111,6 +118,8 @@ be reduced to ``N`` via:
   ``-Wl,-mllvm,-threads=N``
 - lld:
   ``-Wl,--thinlto-jobs=N``
+- lld-link:
+  ``/opt:lldltojobs=N``
 
 Incremental
 ---
@@ -125,7 +134,7 @@ which currently must be enabled through
   ``-Wl,-cache_path_lto,/path/to/cache``
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-dir=/path/to/cache``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocache:/path/to/cache``
 
 Cache Pruning
@@ -138,7 +147,7 @@ policy string. The cache policy must be
 
 - ELF lld (as of LLVM 5.0):
   ``-Wl,--thinlto-cache-policy,POLICY``
-- COFF lld (as of LLVM 6.0):
+- COFF lld-link (as of LLVM 6.0):
   ``/lldltocachepolicy:POLICY``
 
 A policy string is a series of key-value pairs separated by ``:`` characters.
@@ -187,13 +196,20 @@ To bootstrap clang/LLVM with ThinLTO, fo
when configuring the bootstrap compiler build:
 
   * ``-DLLVM_ENABLE_LTO=Thin``
-  * ``-DLLVM_PARALLEL_LINK_JOBS=1``
-(since the ThinLTO link invokes parallel backend jobs)
   * ``-DCMAKE_C_COMPILER=/path/to/host/clang``
   * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang++``
   * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib``
   * ``-DCMAKE_AR=/path/to/host/llvm-ar``
 
+  Or, on Windows:
+
+  * ``-DLLVM_ENABLE_LTO=Thin``
+  * ``-DCMAKE_C_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_CXX_COMPILER=/path/to/host/clang-cl.exe``
+  * ``-DCMAKE_LINKER=/path/to/host/lld-link.exe``
+  * ``-DCMAKE_RANLIB=/path/to/host/llvm-ranlib.exe``
+  * ``-DCMAKE_AR=/path/to/host/llvm-ar.exe``
+
 #. To use additional linker arguments for controlling the backend
parallelism_ or enabling incremental_ builds of the bootstrap compiler,
after configuring the build, modify the resulting CMakeCache.txt file in the


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366127 - [clang] allow -fthinlto-index= without -x ir

2019-07-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul 15 13:51:44 2019
New Revision: 366127

URL: http://llvm.org/viewvc/llvm-project?rev=366127&view=rev
Log:
[clang] allow -fthinlto-index= without -x ir

Summary:
Previously, passing -fthinlto-index= to clang required that bitcode
files be explicitly marked by -x ir. This change makes us detect files
with object file extensions as bitcode files when -fthinlto-index= is
present, so that explicitly marking them is no longer necessary.
Explicitly specifying -x ir is still accepted and continues to be part
of the test case to ensure we continue to support it.

Reviewers: tejohnson, rnk, pcc

Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64610

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/thinlto_backend.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=366127&r1=366126&r2=366127&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jul 15 13:51:44 
2019
@@ -159,6 +159,8 @@ def err_drv_cannot_read_config_file : Er
   "cannot read configuration file '%0'">;
 def err_drv_nested_config_file: Error<
   "option '--config' is not allowed inside configuration file">;
+def err_drv_arg_requires_bitcode_input: Error<
+  "option '%0' requires input to be LLVM bitcode">;
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=366127&r1=366126&r2=366127&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jul 15 13:51:44 2019
@@ -2119,6 +2119,12 @@ void Driver::BuildInputs(const ToolChain
   Diag(clang::diag::warn_drv_treating_input_as_cxx)
   << getTypeName(OldTy) << getTypeName(Ty);
   }
+
+  // If running with -fthinlto-index=, extensions that normally 
identify
+  // native object files actually identify LLVM bitcode files.
+  if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+  Ty == types::TY_Object)
+Ty = types::TY_LLVM_BC;
 }
 
 // -ObjC and -ObjC++ override the default language, but only for 
"source

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=366127&r1=366126&r2=366127&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jul 15 13:51:44 2019
@@ -3647,8 +3647,7 @@ void Clang::ConstructJob(Compilation &C,
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
 if (!types::isLLVMIR(Input.getType()))
-  D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
-   << "-x ir";
+  D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 

Modified: cfe/trunk/test/Driver/thinlto_backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/thinlto_backend.c?rev=366127&r1=366126&r2=366127&view=diff
==
--- cfe/trunk/test/Driver/thinlto_backend.c (original)
+++ cfe/trunk/test/Driver/thinlto_backend.c Mon Jul 15 13:51:44 2019
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 
2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc 
-save-temps -### 2>&1 | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS 
-check-prefix=CHECK-SAVE-TEMPS-CWD
@@ -15,5 +21,6 @@
 // CHECK-SAVE-TEMPS-NOT: -emit-llvm-bc
 
 // Ensure clang driver gives 

r366146 - add -fthinlto-index= option to clang-cl

2019-07-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul 15 15:50:04 2019
New Revision: 366146

URL: http://llvm.org/viewvc/llvm-project?rev=366146&view=rev
Log:
add -fthinlto-index= option to clang-cl

Summary:
This adds a -fthinlto-index= option to clang-cl, which allows it to
be used to drive ThinLTO backend passes. This allows clang-cl to be
used for distributed ThinLTO.

Reviewers: tejohnson, pcc, rnk

Subscribers: mehdi_amini, steven_wu, dexonsmith, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D64458

Added:
cfe/trunk/test/Driver/cl-thinlto-backend.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=366146&r1=366145&r2=366146&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 15 15:50:04 2019
@@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-j
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;

Added: cfe/trunk/test/Driver/cl-thinlto-backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-thinlto-backend.c?rev=366146&view=auto
==
--- cfe/trunk/test/Driver/cl-thinlto-backend.c (added)
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c Mon Jul 15 15:50:04 2019
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r366165 - reland "add -fthinlto-index= option to clang-cl"

2019-07-15 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul 15 18:35:49 2019
New Revision: 366165

URL: http://llvm.org/viewvc/llvm-project?rev=366165&view=rev
Log:
reland "add -fthinlto-index= option to clang-cl"

Summary:
This is a reland of r366146, adding in the previously missing '--'
flag that prevents filenames from being interpreted as flags.

Original description:
This adds a -fthinlto-index= option to clang-cl, which allows it to
be used to drive ThinLTO backend passes. This allows clang-cl to be
used for distributed ThinLTO.

Tags: #clang

Added:
cfe/trunk/test/Driver/cl-thinlto-backend.c
Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=366165&r1=366164&r2=366165&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jul 15 18:35:49 2019
@@ -1270,7 +1270,7 @@ def flto_jobs_EQ : Joined<["-"], "flto-j
"of 0 means the number of threads will be derived from "
"the number of CPUs detected)">;
 def fthinlto_index_EQ : Joined<["-"], "fthinlto-index=">,
-  Flags<[CC1Option]>, Group,
+  Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Perform ThinLTO importing using provided function summary index">;
 def fmacro_backtrace_limit_EQ : Joined<["-"], "fmacro-backtrace-limit=">,
 Group, Flags<[DriverOption, 
CoreOption]>;

Added: cfe/trunk/test/Driver/cl-thinlto-backend.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-thinlto-backend.c?rev=366165&view=auto
==
--- cfe/trunk/test/Driver/cl-thinlto-backend.c (added)
+++ cfe/trunk/test/Driver/cl-thinlto-backend.c Mon Jul 15 18:35:49 2019
@@ -0,0 +1,9 @@
+// RUN: %clang_cl -c -flto=thin -Fo%t.obj -- %s
+// RUN: llvm-lto2 run -thinlto-distributed-indexes -o %t.exe %t.obj
+
+// -fthinlto_index should be passed to cc1
+// RUN: %clang_cl -### -c -fthinlto-index=%t.thinlto.bc -Fo%t1.obj \
+// RUN: -- %t.obj 2>&1 | FileCheck %s
+
+// CHECK: -fthinlto-index=
+// CHECK: "-x" "ir"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r336604 - Added -fcrash-diagnostics-dir flag

2018-07-09 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Jul  9 14:07:20 2018
New Revision: 336604

URL: http://llvm.org/viewvc/llvm-project?rev=336604&view=rev
Log:
Added -fcrash-diagnostics-dir flag

Summary:
New flag causes crash reports to be written in the specified directory
rather than the temp directory.

Patch by Chijioke Kamanu.

Reviewers: hans, inglorion, rnk

Reviewed By: hans

Subscribers: zturner, hiraditya, llvm-commits, cfe-commits

Differential Revision: https://reviews.llvm.org/D48601

Added:
cfe/trunk/test/Driver/crash-diagnostics-dir.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=336604&r1=336603&r2=336604&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Jul  9 14:07:20 2018
@@ -798,6 +798,7 @@ def fconstexpr_backtrace_limit_EQ : Join
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
+def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">, 
Group, Flags<[NoArgumentUnused]>;
 def fcreate_profile : Flag<["-"], "fcreate-profile">, Group;
 def fcxx_exceptions: Flag<["-"], "fcxx-exceptions">, Group,
   HelpText<"Enable C++ exceptions">, Flags<[CC1Option]>;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=336604&r1=336603&r2=336604&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Jul  9 14:07:20 2018
@@ -1291,12 +1291,13 @@ void Driver::generateCompilationDiagnost
   // Assume associated files are based off of the first temporary file.
   CrashReportInfo CrashInfo(TempFiles[0], VFS);
 
-  std::string Script = CrashInfo.Filename.rsplit('.').first.str() + ".sh";
+  llvm::SmallString<128> Script(CrashInfo.Filename);
+  llvm::sys::path::replace_extension(Script, "sh");
   std::error_code EC;
   llvm::raw_fd_ostream ScriptOS(Script, EC, llvm::sys::fs::CD_CreateNew);
   if (EC) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
-<< "Error generating run script: " + Script + " " + EC.message();
+<< "Error generating run script: " << Script << " " << EC.message();
   } else {
 ScriptOS << "# Crash reproducer for " << getClangFullVersion() << "\n"
  << "# Driver args: ";
@@ -1308,7 +1309,7 @@ void Driver::generateCompilationDiagnost
   ScriptOS << "\n# Additional information: " << AdditionalInformation
<< "\n";
 if (Report)
-  Report->TemporaryFiles.push_back(Script);
+  Report->TemporaryFiles.push_back(Script.str());
 Diag(clang::diag::note_drv_command_failed_diag_msg) << Script;
   }
 
@@ -4018,8 +4019,22 @@ const char *Driver::GetNamedOutputPath(C
   CCGenDiagnostics) {
 StringRef Name = llvm::sys::path::filename(BaseInput);
 std::pair Split = Name.split('.');
-std::string TmpName = GetTemporaryPath(
-Split.first, types::getTypeTempSuffix(JA.getType(), IsCLMode()));
+SmallString<128> TmpName;
+const char *Suffix = types::getTypeTempSuffix(JA.getType(), IsCLMode());
+Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
+if (CCGenDiagnostics && A) {
+  SmallString<128> CrashDirectory(A->getValue());
+  llvm::sys::path::append(CrashDirectory, Split.first);
+  const char *Middle = Suffix ? "-%%." : "-%%";
+  std::error_code EC =
+  llvm::sys::fs::createUniqueFile(CrashDirectory + Middle + Suffix, 
TmpName);
+  if (EC) {
+Diag(clang::diag::err_unable_to_make_temp) << EC.message();
+return "";
+  }
+} else {
+  TmpName = GetTemporaryPath(Split.first, Suffix);
+}
 return C.addTempFile(C.getArgs().MakeArgString(TmpName));
   }
 

Added: cfe/trunk/test/Driver/crash-diagnostics-dir.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/crash-diagnostics-dir.c?rev=336604&view=auto
==
--- cfe/trunk/test/Driver/crash-diagnostics-dir.c (added)
+++ cfe/trunk/test/Driver/crash-diagnostics-dir.c Mon Jul  9 14:07:20 2018
@@ -0,0 +1,6 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: not %clang -fcrash-diagnostics-dir=%t -c %s 2>&1 | FileCheck %s
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: 
{{.*}}Output{{/|\\}}crash-diagnostics-dir.c.tmp{{(/|\\).*}}.c


___
cfe-

[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-14 Thread Bob Haarman via cfe-commits
inglorion updated this revision to Diff 74733.
inglorion added a comment.

@rnk's comments (thanks!)

- Converted SeenTypes to a DenseSet.
- Switched to getCodeGenOpts().EmitCodeView to check if we should emit the 
extra records.
- Switched to using SeenTypes.count(...) != 0 to check if we've seen a type.


https://reviews.llvm.org/D25579

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-ms-vbase.cpp

Index: test/CodeGenCXX/debug-info-ms-vbase.cpp
===
--- test/CodeGenCXX/debug-info-ms-vbase.cpp
+++ test/CodeGenCXX/debug-info-ms-vbase.cpp
@@ -24,6 +24,18 @@
 
 // CHECK: ![[HasVirtualMethod_base]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasPrimaryBase]], baseType: ![[HasVirtualMethod]])
 
+// CHECK: ![[HasIndirectVirtualBase:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasIndirectVirtualBase"
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[HasPrimaryBase]]
+// CHECK-NOT: DIFlagIndirect
+// CHECK-SAME: )
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[SecondaryVTable]]
+// CHECK-SAME: flags:
+// CHECK-SAME: DIFlagVirtual
+// CHECK-SAME: DIFlagIndirect
+
 // CHECK: ![[DynamicNoVFPtr:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DynamicNoVFPtr",
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 
@@ -52,3 +64,6 @@
 
 HasPrimaryBase has_primary_base;
 
+struct HasIndirectVirtualBase : public HasPrimaryBase {};
+
+HasIndirectVirtualBase has_indirect_virtual_base;
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -15,12 +15,14 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
 
 #include "CGBuilder.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -32,7 +34,6 @@
 }
 
 namespace clang {
-class CXXMethodDecl;
 class ClassTemplateSpecializationDecl;
 class GlobalDecl;
 class ModuleMap;
@@ -218,6 +219,15 @@
SmallVectorImpl &EltTys,
llvm::DIType *RecordTy);
 
+  /// Helper function for CollectCXXBases.
+  /// Adds debug info entries for types in Bases that are not in SeenTypes.
+  void CollectCXXBasesAux(const CXXRecordDecl *RD, llvm::DIFile *Unit,
+  SmallVectorImpl &EltTys,
+  llvm::DIType *RecordTy,
+  const CXXRecordDecl::base_class_const_range &Bases,
+  llvm::DenseSet &SeenTypes,
+  llvm::DINode::DIFlags StartingFlags);
+
   /// A helper function to collect template parameters.
   llvm::DINodeArray CollectTemplateParams(const TemplateParameterList *TPList,
   ArrayRef TAList,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,7 +31,9 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DataLayout.h"
@@ -1366,13 +1368,35 @@
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl &EltTys,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto &BI : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirect | llvm::DINode::FlagVirtual);
+  }
+}
 
+void CGDebugInfo::Collec

[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-14 Thread Bob Haarman via cfe-commits
inglorion updated this revision to Diff 74734.
inglorion added a comment.

- Removed unused header.


https://reviews.llvm.org/D25579

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-ms-vbase.cpp

Index: test/CodeGenCXX/debug-info-ms-vbase.cpp
===
--- test/CodeGenCXX/debug-info-ms-vbase.cpp
+++ test/CodeGenCXX/debug-info-ms-vbase.cpp
@@ -24,6 +24,18 @@
 
 // CHECK: ![[HasVirtualMethod_base]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasPrimaryBase]], baseType: ![[HasVirtualMethod]])
 
+// CHECK: ![[HasIndirectVirtualBase:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasIndirectVirtualBase"
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[HasPrimaryBase]]
+// CHECK-NOT: DIFlagIndirect
+// CHECK-SAME: )
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[SecondaryVTable]]
+// CHECK-SAME: flags:
+// CHECK-SAME: DIFlagVirtual
+// CHECK-SAME: DIFlagIndirect
+
 // CHECK: ![[DynamicNoVFPtr:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DynamicNoVFPtr",
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 
@@ -52,3 +64,6 @@
 
 HasPrimaryBase has_primary_base;
 
+struct HasIndirectVirtualBase : public HasPrimaryBase {};
+
+HasIndirectVirtualBase has_indirect_virtual_base;
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -15,12 +15,14 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
 
 #include "CGBuilder.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -32,7 +34,6 @@
 }
 
 namespace clang {
-class CXXMethodDecl;
 class ClassTemplateSpecializationDecl;
 class GlobalDecl;
 class ModuleMap;
@@ -218,6 +219,15 @@
SmallVectorImpl &EltTys,
llvm::DIType *RecordTy);
 
+  /// Helper function for CollectCXXBases.
+  /// Adds debug info entries for types in Bases that are not in SeenTypes.
+  void CollectCXXBasesAux(const CXXRecordDecl *RD, llvm::DIFile *Unit,
+  SmallVectorImpl &EltTys,
+  llvm::DIType *RecordTy,
+  const CXXRecordDecl::base_class_const_range &Bases,
+  llvm::DenseSet &SeenTypes,
+  llvm::DINode::DIFlags StartingFlags);
+
   /// A helper function to collect template parameters.
   llvm::DINodeArray CollectTemplateParams(const TemplateParameterList *TPList,
   ArrayRef TAList,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1366,13 +1367,35 @@
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl &EltTys,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto &BI : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirect | llvm::DINode::FlagVirtual);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl &EltTys, llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range &Bases,
+llvm::DenseSet &SeenTypes,
+llvm::DINode::DIFlags StartingFlags) {
+  const ASTRecordLayo

r295872 - stop using associative comdats for SEH filter functions

2017-02-22 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Wed Feb 22 14:29:39 2017
New Revision: 295872

URL: http://llvm.org/viewvc/llvm-project?rev=295872&view=rev
Log:
stop using associative comdats for SEH filter functions

Summary: We implement structured exception handling (SEH) by generating filter 
functions for functions that use exceptions. Currently, we use associative 
comdats to ensure that the filter functions are preserved if and only if the 
functions we generated them for are preserved. This can lead to problems when 
generating COFF objects - LLVM may decide to inline a function that uses SEH 
and remove its body, at which point we will end up with a comdat that COFF 
cannot represent. To avoid running into that situation, this change makes us 
not use associative comdats for SEH filter functions. We can still get the 
benefits we used the associative comdats for: we will always preserve filter 
functions we use, and dead stripping can eliminate the ones we don't use.

Reviewers: rnk, pcc, ruiu

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D30117

Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp

Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=295872&r1=295871&r2=295872&view=diff
==
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Wed Feb 22 14:29:39 2017
@@ -1666,23 +1666,12 @@ void CodeGenFunction::startOutlinedSEHHe
 
   QualType RetTy = IsFilter ? getContext().LongTy : getContext().VoidTy;
 
-  llvm::Function *ParentFn = ParentCGF.CurFn;
   const CGFunctionInfo &FnInfo =
 CGM.getTypes().arrangeBuiltinFunctionDeclaration(RetTy, Args);
 
   llvm::FunctionType *FnTy = CGM.getTypes().GetFunctionType(FnInfo);
   llvm::Function *Fn = llvm::Function::Create(
   FnTy, llvm::GlobalValue::InternalLinkage, Name.str(), &CGM.getModule());
-  // The filter is either in the same comdat as the function, or it's internal.
-  if (llvm::Comdat *C = ParentFn->getComdat()) {
-Fn->setComdat(C);
-  } else if (ParentFn->hasWeakLinkage() || ParentFn->hasLinkOnceLinkage()) {
-llvm::Comdat *C = CGM.getModule().getOrInsertComdat(ParentFn->getName());
-ParentFn->setComdat(C);
-Fn->setComdat(C);
-  } else {
-Fn->setLinkage(llvm::GlobalValue::InternalLinkage);
-  }
 
   IsOutlinedSEHHelper = true;
 

Modified: cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp?rev=295872&r1=295871&r2=295872&view=diff
==
--- cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/exceptions-seh.cpp Wed Feb 22 14:29:39 2017
@@ -118,7 +118,7 @@ void use_inline() {
   use_seh_in_inline_func();
 }
 
-// CHECK-LABEL: define linkonce_odr void @use_seh_in_inline_func() #{{[0-9]+}} 
comdat
+// CHECK-LABEL: define linkonce_odr void @use_seh_in_inline_func() #{{[0-9]+}}
 // CHECK-SAME:  personality i8* bitcast (i32 (...)* @__C_specific_handler to 
i8*)
 // CHECK: invoke void @might_throw()
 //
@@ -134,12 +134,12 @@ void use_inline() {
 // CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
 // CHECK: call void @"\01?fin$0@0@use_seh_in_inline_func@@"(i8 1, i8* %[[fp]])
 
-// CHECK-LABEL: define internal i32 
@"\01?filt$0@0@use_seh_in_inline_func@@"(i8* %exception_pointers, i8* 
%frame_pointer) #{{[0-9]+}} comdat($use_seh_in_inline_func)
+// CHECK-LABEL: define internal i32 
@"\01?filt$0@0@use_seh_in_inline_func@@"(i8* %exception_pointers, i8* 
%frame_pointer) #{{[0-9]+}}
 // CHECK: icmp eq i32 %{{.*}}, 424242
 // CHECK: zext i1 %{{.*}} to i32
 // CHECK: ret i32
 
-// CHECK-LABEL: define internal void 
@"\01?fin$0@0@use_seh_in_inline_func@@"(i8 %abnormal_termination, i8* 
%frame_pointer) #{{[0-9]+}} comdat($use_seh_in_inline_func)
+// CHECK-LABEL: define internal void 
@"\01?fin$0@0@use_seh_in_inline_func@@"(i8 %abnormal_termination, i8* 
%frame_pointer) #{{[0-9]+}}
 // CHECK: store i32 1234, i32* @my_unique_global
 
 // CHECK: attributes #[[NOINLINE]] = { {{.*noinline.*}} }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296373 - enable -flto=thin in clang-cl

2017-02-27 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Mon Feb 27 13:40:19 2017
New Revision: 296373

URL: http://llvm.org/viewvc/llvm-project?rev=296373&view=rev
Log:
enable -flto=thin in clang-cl

Summary: This enables LTO to be used with the clang-cl frontend.

Reviewers: rnk, hans

Reviewed By: hans

Subscribers: pcc, cfe-commits, mehdi_amini, Prazek

Differential Revision: https://reviews.llvm.org/D30239

Modified:
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Feb 27 13:40:19 
2017
@@ -133,6 +133,7 @@ def err_drv_invalid_gcc_output_type : Er
 "invalid output type '%0' for use with gcc tool">;
 def err_drv_cc_print_options_failure : Error<
 "unable to open CC_PRINT_OPTIONS file: %0">;
+def err_drv_lto_without_lld : Error<"LTO requires -fuse-ld=lld">;
 def err_drv_preamble_format : Error<
 "incorrect format for -preamble-bytes=N,END">;
 def err_drv_conflicting_deployment_targets : Error<

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Feb 27 13:40:19 2017
@@ -957,7 +957,7 @@ def fxray_instruction_threshold_ :
 def flat__namespace : Flag<["-"], "flat_namespace">;
 def flax_vector_conversions : Flag<["-"], "flax-vector-conversions">, 
Group;
 def flimited_precision_EQ : Joined<["-"], "flimited-precision=">, 
Group;
-def flto_EQ : Joined<["-"], "flto=">, Flags<[CC1Option]>, Group,
+def flto_EQ : Joined<["-"], "flto=">, Flags<[CoreOption, CC1Option]>, 
Group,
   HelpText<"Set LTO mode to either 'full' or 'thin'">;
 def flto : Flag<["-"], "flto">, Flags<[CoreOption, CC1Option]>, Group,
   HelpText<"Enable LTO in 'full' mode">;

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Feb 27 13:40:19 2017
@@ -2353,8 +2353,12 @@ void Driver::BuildActions(Compilation &C
   Arg *FinalPhaseArg;
   phases::ID FinalPhase = getFinalPhase(Args, &FinalPhaseArg);
 
-  if (FinalPhase == phases::Link && Args.hasArg(options::OPT_emit_llvm)) {
-Diag(clang::diag::err_drv_emit_llvm_link);
+  if (FinalPhase == phases::Link) {
+if (Args.hasArg(options::OPT_emit_llvm))
+  Diag(clang::diag::err_drv_emit_llvm_link);
+if (IsCLMode() && LTOMode != LTOK_None &&
+!Args.getLastArgValue(options::OPT_fuse_ld_EQ).equals_lower("lld"))
+  Diag(clang::diag::err_drv_lto_without_lld);
   }
 
   // Reject -Z* at the top level, these options should never have been exposed

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=296373&r1=296372&r2=296373&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Feb 27 13:40:19 2017
@@ -522,6 +522,15 @@
 
 // RUN: env CL="%s" _CL_="%s" not %clang --rsp-quoting=windows -c
 
+// RUN: %clang_cl -### /c -flto -- %s 2>&1 | FileCheck -check-prefix=LTO %s
+// LTO: -flto
+
+// RUN: %clang_cl -### /c -flto=thin -- %s 2>&1 | FileCheck 
-check-prefix=LTO-THIN %s
+// LTO-THIN: -flto=thin
+
+// RUN: %clang_cl -### -Fe%t.exe -entry:main -flto -- %s 2>&1 | FileCheck 
-check-prefix=LTO-WITHOUT-LLD %s
+// LTO-WITHOUT-LLD: LTO requires -fuse-ld=lld
+
 // Accept "core" clang options.
 // (/Zs is for syntax-only, -Werror makes it fail hard on unknown options)
 // RUN: %clang_cl \


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r288230 - make -fprofile-instr-generate and -fprofile-instr-use work with clang-cl

2016-11-29 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Tue Nov 29 21:25:36 2016
New Revision: 288230

URL: http://llvm.org/viewvc/llvm-project?rev=288230&view=rev
Log:
make -fprofile-instr-generate and -fprofile-instr-use work with clang-cl

Summary: Makes -fprofile-instr-generate and -fprofile-instr-use work
with clang-cl so that profile-guided optimization can be used.

Differential Revision: https://reviews.llvm.org/D27086

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=288230&r1=288229&r2=288230&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Nov 29 21:25:36 2016
@@ -510,15 +510,15 @@ def fprofile_sample_use_EQ : Joined<["-"
 def fauto_profile_EQ : Joined<["-"], "fauto-profile=">,
 Alias;
 def fprofile_instr_generate : Flag<["-"], "fprofile-instr-generate">,
-Group, Flags<[DriverOption]>,
+Group, Flags<[CoreOption]>,
 HelpText<"Generate instrumented code to collect execution counts into 
default.profraw file (overriden by '=' form of option or LLVM_PROFILE_FILE env 
var)">;
 def fprofile_instr_generate_EQ : Joined<["-"], "fprofile-instr-generate=">,
-Group, Flags<[DriverOption]>, MetaVarName<"">,
+Group, Flags<[CoreOption]>, MetaVarName<"">,
 HelpText<"Generate instrumented code to collect execution counts into 
 (overridden by LLVM_PROFILE_FILE env var)">;
 def fprofile_instr_use : Flag<["-"], "fprofile-instr-use">, Group,
-Flags<[DriverOption]>;
+Flags<[CoreOption]>;
 def fprofile_instr_use_EQ : Joined<["-"], "fprofile-instr-use=">,
-Group, Flags<[DriverOption]>,
+Group, Flags<[CoreOption]>,
 HelpText<"Use instrumentation data for profile-guided optimization">;
 def fcoverage_mapping : Flag<["-"], "fcoverage-mapping">,
 Group, Flags<[CC1Option]>,

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=288230&r1=288229&r2=288230&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Tue Nov 29 21:25:36 2016
@@ -59,6 +59,19 @@
 // RUN: %clang_cl /Z7 -### -- %s 2>&1 | FileCheck -check-prefix=gdefcolumn %s
 // gdefcolumn-NOT: -dwarf-column-info
 
+// RUN: %clang_cl -### /FA -fprofile-instr-generate -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-GENERATE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate=/tmp/somefile.profraw -- 
%s 2>&1 | FileCheck -check-prefix=CHECK-PROFILE-GENERATE-FILE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use -- %s 
2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-generate -fprofile-instr-use=file 
-- %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-GEN-USE %s
+// CHECK-PROFILE-GENERATE: "-fprofile-instrument=clang"
+// CHECK-PROFILE-GENERATE-FILE: 
"-fprofile-instrument-path=/tmp/somefile.profraw"
+// CHECK-NO-MIX-GEN-USE: '{{[a-z=-]*}}' not allowed with '{{[a-z=-]*}}'
+
+// RUN: %clang_cl -### /FA -fprofile-instr-use -- %s 2>&1 | FileCheck 
-check-prefix=CHECK-PROFILE-USE %s
+// RUN: %clang_cl -### /FA -fprofile-instr-use=/tmp/somefile.prof -- %s 2>&1 | 
FileCheck -check-prefix=CHECK-PROFILE-USE-FILE %s
+// CHECK-PROFILE-USE: "-fprofile-instrument-use-path=default.profdata"
+// CHECK-PROFILE-USE-FILE: "-fprofile-instrument-use-path=/tmp/somefile.prof"
+
 // RUN: %clang_cl /GA -### -- %s 2>&1 | FileCheck -check-prefix=GA %s
 // GA: -ftls-model=local-exec
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-20 Thread Bob Haarman via cfe-commits
inglorion updated this revision to Diff 75367.
inglorion added a comment.

Updated to track the latest state of https://reviews.llvm.org/D25578


https://reviews.llvm.org/D25579

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-ms-vbase.cpp

Index: test/CodeGenCXX/debug-info-ms-vbase.cpp
===
--- test/CodeGenCXX/debug-info-ms-vbase.cpp
+++ test/CodeGenCXX/debug-info-ms-vbase.cpp
@@ -24,6 +24,17 @@
 
 // CHECK: ![[HasVirtualMethod_base]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasPrimaryBase]], baseType: ![[HasVirtualMethod]])
 
+// CHECK: ![[HasIndirectVirtualBase:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasIndirectVirtualBase"
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[HasPrimaryBase]]
+// CHECK-NOT: DIFlagIndirectVirtualBase
+// CHECK-SAME: )
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[SecondaryVTable]]
+// CHECK-SAME: flags:
+// CHECK-SAME: DIFlagIndirectVirtualBase
+
 // CHECK: ![[DynamicNoVFPtr:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DynamicNoVFPtr",
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 
@@ -52,3 +63,6 @@
 
 HasPrimaryBase has_primary_base;
 
+struct HasIndirectVirtualBase : public HasPrimaryBase {};
+
+HasIndirectVirtualBase has_indirect_virtual_base;
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -15,12 +15,14 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
 
 #include "CGBuilder.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -32,7 +34,6 @@
 }
 
 namespace clang {
-class CXXMethodDecl;
 class ClassTemplateSpecializationDecl;
 class GlobalDecl;
 class ModuleMap;
@@ -218,6 +219,15 @@
SmallVectorImpl &EltTys,
llvm::DIType *RecordTy);
 
+  /// Helper function for CollectCXXBases.
+  /// Adds debug info entries for types in Bases that are not in SeenTypes.
+  void CollectCXXBasesAux(const CXXRecordDecl *RD, llvm::DIFile *Unit,
+  SmallVectorImpl &EltTys,
+  llvm::DIType *RecordTy,
+  const CXXRecordDecl::base_class_const_range &Bases,
+  llvm::DenseSet &SeenTypes,
+  llvm::DINode::DIFlags StartingFlags);
+
   /// A helper function to collect template parameters.
   llvm::DINodeArray CollectTemplateParams(const TemplateParameterList *TPList,
   ArrayRef TAList,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1380,13 +1381,35 @@
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl &EltTys,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto &BI : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirectVirtualBase);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl &EltTys, llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range &Bases,
+llvm::DenseSet &SeenTypes,
+llvm::DINode::DIFlags StartingFlags) {
+  

[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-20 Thread Bob Haarman via cfe-commits
inglorion updated this revision to Diff 75381.
inglorion added a comment.

Use insert's return value to save a set lookup, and use CanonicalDeclPtr


https://reviews.llvm.org/D25579

Files:
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGDebugInfo.h
  test/CodeGenCXX/debug-info-ms-vbase.cpp

Index: test/CodeGenCXX/debug-info-ms-vbase.cpp
===
--- test/CodeGenCXX/debug-info-ms-vbase.cpp
+++ test/CodeGenCXX/debug-info-ms-vbase.cpp
@@ -24,6 +24,17 @@
 
 // CHECK: ![[HasVirtualMethod_base]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasPrimaryBase]], baseType: ![[HasVirtualMethod]])
 
+// CHECK: ![[HasIndirectVirtualBase:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasIndirectVirtualBase"
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[HasPrimaryBase]]
+// CHECK-NOT: DIFlagIndirectVirtualBase
+// CHECK-SAME: )
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[SecondaryVTable]]
+// CHECK-SAME: flags:
+// CHECK-SAME: DIFlagIndirectVirtualBase
+
 // CHECK: ![[DynamicNoVFPtr:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DynamicNoVFPtr",
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 
@@ -52,3 +63,6 @@
 
 HasPrimaryBase has_primary_base;
 
+struct HasIndirectVirtualBase : public HasPrimaryBase {};
+
+HasIndirectVirtualBase has_indirect_virtual_base;
Index: lib/CodeGen/CGDebugInfo.h
===
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -15,12 +15,14 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
 
 #include "CGBuilder.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -32,7 +34,6 @@
 }
 
 namespace clang {
-class CXXMethodDecl;
 class ClassTemplateSpecializationDecl;
 class GlobalDecl;
 class ModuleMap;
@@ -218,6 +219,15 @@
SmallVectorImpl &EltTys,
llvm::DIType *RecordTy);
 
+  /// Helper function for CollectCXXBases.
+  /// Adds debug info entries for types in Bases that are not in SeenTypes.
+  void CollectCXXBasesAux(const CXXRecordDecl *RD, llvm::DIFile *Unit,
+  SmallVectorImpl &EltTys,
+  llvm::DIType *RecordTy,
+  const CXXRecordDecl::base_class_const_range &Bases,
+  llvm::DenseSet> &SeenTypes,
+  llvm::DINode::DIFlags StartingFlags);
+
   /// A helper function to collect template parameters.
   llvm::DINodeArray CollectTemplateParams(const TemplateParameterList *TPList,
   ArrayRef TAList,
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1380,13 +1381,33 @@
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl &EltTys,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto &BI : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet> SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirectVirtualBase);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl &EltTys, llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range &Bases,
+llvm::DenseSet> &SeenTypes,
+llvm::DINode::DIFlags StartingFlags

[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-21 Thread Bob Haarman via cfe-commits
inglorion added a comment.

We also need https://reviews.llvm.org/D25578 in before this can land.


https://reviews.llvm.org/D25579



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D25579: [codeview] emit debug info for indirect virtual base classes

2016-10-25 Thread Bob Haarman via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL285132: [codeview] emit debug info for indirect virtual base 
classes (authored by inglorion).

Changed prior to commit:
  https://reviews.llvm.org/D25579?vs=75381&id=75804#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25579

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  cfe/trunk/lib/CodeGen/CGDebugInfo.h
  cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp

Index: cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp
===
--- cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp
+++ cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp
@@ -24,6 +24,17 @@
 
 // CHECK: ![[HasVirtualMethod_base]] = !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasPrimaryBase]], baseType: ![[HasVirtualMethod]])
 
+// CHECK: ![[HasIndirectVirtualBase:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasIndirectVirtualBase"
+// CHECK-SAME: elements: ![[elements:[0-9]+]]
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[HasPrimaryBase]]
+// CHECK-NOT: DIFlagIndirectVirtualBase
+// CHECK-SAME: )
+
+// CHECK: !DIDerivedType(tag: DW_TAG_inheritance, scope: ![[HasIndirectVirtualBase]], baseType: ![[SecondaryVTable]]
+// CHECK-SAME: flags:
+// CHECK-SAME: DIFlagIndirectVirtualBase
+
 // CHECK: ![[DynamicNoVFPtr:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "DynamicNoVFPtr",
 // CHECK-SAME: elements: ![[elements:[0-9]+]]
 
@@ -52,3 +63,6 @@
 
 HasPrimaryBase has_primary_base;
 
+struct HasIndirectVirtualBase : public HasPrimaryBase {};
+
+HasIndirectVirtualBase has_indirect_virtual_base;
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
===
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1380,13 +1381,33 @@
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl &EltTys,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto &BI : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet> SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirectVirtualBase);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl &EltTys, llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range &Bases,
+llvm::DenseSet> &SeenTypes,
+llvm::DINode::DIFlags StartingFlags) {
+  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
+  for (const auto &BI : Bases) {
 const auto *Base =
 cast(BI.getType()->getAs()->getDecl());
+if (!SeenTypes.insert(Base).second)
+  continue;
+auto *BaseTy = getOrCreateType(BI.getType(), Unit);
+llvm::DINode::DIFlags BFlags = StartingFlags;
+uint64_t BaseOffset;
 
 if (BI.isVirtual()) {
   if (CGM.getTarget().getCXXABI().isItaniumFamily()) {
@@ -1401,15 +1422,15 @@
 BaseOffset =
 4 * CGM.getMicrosoftVTableContext().getVBTableIndex(RD, Base);
   }
-  BFlags = llvm::DINode::FlagVirtual;
+  BFlags |= llvm::DINode::FlagVirtual;
 } else
   BaseOffset = CGM.getContext().toBits(RL.getBaseClassOffset(Base));
 // FIXME: Inconsistent units for BaseOffset. It is in bytes when
 // BI->isVirtual() and bits when not.
 
 BFlags |= getAccessFlag(BI.getAccessSpecifier(), RD);
-llvm::DIType *DTy = DBuilder.createInheritance(
-RecordTy, getOrCreateType(BI.getType(), Unit), BaseOffset, BFlags);
+llvm::DIType *DTy =
+DBuilder.createInheritance(RecordTy, BaseTy, BaseOffset, BFlags);
 EltTys.push_back(DTy);
   }
 }
Index: cfe/trunk/lib/CodeGen/CGDebugInfo.h
===
--- cfe/trunk/lib/CodeGen/CGDebug

r285132 - [codeview] emit debug info for indirect virtual base classes

2016-10-25 Thread Bob Haarman via cfe-commits
Author: inglorion
Date: Tue Oct 25 17:19:32 2016
New Revision: 285132

URL: http://llvm.org/viewvc/llvm-project?rev=285132&view=rev
Log:
[codeview] emit debug info for indirect virtual base classes

Summary:
Fixes PR28281.

MSVC lists indirect virtual base classes in the field list of a class.
This change makes Clang emit the information necessary for LLVM to
emit such records.

Reviewers: rnk, ruiu, zturner

Differential Revision: https://reviews.llvm.org/D25579

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/test/CodeGenCXX/debug-info-ms-vbase.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=285132&r1=285131&r2=285132&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue Oct 25 17:19:32 2016
@@ -13,9 +13,9 @@
 
 #include "CGDebugInfo.h"
 #include "CGBlocks.h"
-#include "CGRecordLayout.h"
 #include "CGCXXABI.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/ASTContext.h"
@@ -31,6 +31,7 @@
 #include "clang/Lex/HeaderSearchOptions.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/IR/Constants.h"
@@ -1380,13 +1381,33 @@ void CGDebugInfo::CollectCXXMemberFuncti
 void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile *Unit,
   SmallVectorImpl &EltTys,
   llvm::DIType *RecordTy) {
-  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
-  for (const auto &BI : RD->bases()) {
-llvm::DINode::DIFlags BFlags = llvm::DINode::FlagZero;
-uint64_t BaseOffset;
+  llvm::DenseSet> SeenTypes;
+  CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->bases(), SeenTypes,
+ llvm::DINode::FlagZero);
+
+  // If we are generating CodeView debug info, we also need to emit records for
+  // indirect virtual base classes.
+  if (CGM.getCodeGenOpts().EmitCodeView) {
+CollectCXXBasesAux(RD, Unit, EltTys, RecordTy, RD->vbases(), SeenTypes,
+   llvm::DINode::FlagIndirectVirtualBase);
+  }
+}
 
+void CGDebugInfo::CollectCXXBasesAux(
+const CXXRecordDecl *RD, llvm::DIFile *Unit,
+SmallVectorImpl &EltTys, llvm::DIType *RecordTy,
+const CXXRecordDecl::base_class_const_range &Bases,
+llvm::DenseSet> &SeenTypes,
+llvm::DINode::DIFlags StartingFlags) {
+  const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
+  for (const auto &BI : Bases) {
 const auto *Base =
 cast(BI.getType()->getAs()->getDecl());
+if (!SeenTypes.insert(Base).second)
+  continue;
+auto *BaseTy = getOrCreateType(BI.getType(), Unit);
+llvm::DINode::DIFlags BFlags = StartingFlags;
+uint64_t BaseOffset;
 
 if (BI.isVirtual()) {
   if (CGM.getTarget().getCXXABI().isItaniumFamily()) {
@@ -1401,15 +1422,15 @@ void CGDebugInfo::CollectCXXBases(const
 BaseOffset =
 4 * CGM.getMicrosoftVTableContext().getVBTableIndex(RD, Base);
   }
-  BFlags = llvm::DINode::FlagVirtual;
+  BFlags |= llvm::DINode::FlagVirtual;
 } else
   BaseOffset = CGM.getContext().toBits(RL.getBaseClassOffset(Base));
 // FIXME: Inconsistent units for BaseOffset. It is in bytes when
 // BI->isVirtual() and bits when not.
 
 BFlags |= getAccessFlag(BI.getAccessSpecifier(), RD);
-llvm::DIType *DTy = DBuilder.createInheritance(
-RecordTy, getOrCreateType(BI.getType(), Unit), BaseOffset, BFlags);
+llvm::DIType *DTy =
+DBuilder.createInheritance(RecordTy, BaseTy, BaseOffset, BFlags);
 EltTys.push_back(DTy);
   }
 }

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=285132&r1=285131&r2=285132&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Tue Oct 25 17:19:32 2016
@@ -15,12 +15,14 @@
 #define LLVM_CLANG_LIB_CODEGEN_CGDEBUGINFO_H
 
 #include "CGBuilder.h"
+#include "clang/AST/DeclCXX.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Type.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CodeGenOptions.h"
 #include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/DebugInfo.h"
@@ -32,7 +34,6 @@ class MDNode;
 }
 
 namespace clang {
-class CXXMethodDecl;
 class ClassTemplateSpecializationDecl;
 class GlobalDecl;
 class ModuleMap;
@@ -218,6 +219,15 @@ class CGDebu

[clang] 1c829ce - [clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

2021-08-24 Thread Bob Haarman via cfe-commits

Author: Bob Haarman
Date: 2021-08-24T21:25:49Z
New Revision: 1c829ce1e3627cf9b22da33943dc2e423ded11c4

URL: 
https://github.com/llvm/llvm-project/commit/1c829ce1e3627cf9b22da33943dc2e423ded11c4
DIFF: 
https://github.com/llvm/llvm-project/commit/1c829ce1e3627cf9b22da33943dc2e423ded11c4.diff

LOG: [clang][codegen] Set CurLinkModule in CodeGenAction::ExecuteAction

CodeGenAction::ExecuteAction creates a BackendConsumer for the
purpose of handling diagnostics. The BackendConsumer's
DiagnosticHandlerImpl method expects CurLinkModule to be set,
but this did not happen on the code path that goes through
ExecuteAction. This change makes it so that the BackendConsumer
constructor used by ExecuteAction requires the Module to be
specified and passes the appropriate module in ExecuteAction.

The change also adds a test that fails without this change
and passes with it. To make the test work, the FIXME in the
handling of DK_Linker diagnostics was addressed so that warnings
and notes are no longer silently discarded. Since this introduces
a new warning diagnostic, a flag to control it (-Wlinker-warnings)
has also been added.

Reviewed By: xur

Differential Revision: https://reviews.llvm.org/D108603

Added: 
clang/test/CodeGen/Inputs/linker-diagnostic1.ll
clang/test/CodeGen/linker-diagnostic.ll

Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/CodeGen/CodeGenAction.cpp
clang/test/Misc/serialized-diags-driver.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index 2bbc93d5682ce..fceafb93eda28 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -22,8 +22,9 @@ def note_fe_inline_asm_here : Note<"instantiated into 
assembly here">;
 def err_fe_source_mgr : Error<"%0">, CatSourceMgr;
 def warn_fe_source_mgr : Warning<"%0">, CatSourceMgr, 
InGroup;
 def note_fe_source_mgr : Note<"%0">, CatSourceMgr;
-def err_fe_cannot_link_module : Error<"cannot link module '%0': %1">,
-  DefaultFatal;
+def err_fe_linking_module : Error<"cannot link module '%0': %1">, DefaultFatal;
+def warn_fe_linking_module : Warning<"linking module '%0': %1">, 
InGroup;
+def note_fe_linking_module : Note<"linking module '%0': %1">;
 
 def warn_fe_frame_larger_than : Warning<"stack frame size (%0) exceeds limit 
(%1) in %q2">,
 BackendInfo, InGroup;

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 753a3d5546e2f..95023b8b34375 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1194,6 +1194,9 @@ def ASM : DiagGroup<"asm", [
 ASMOperandWidths
   ]>;
 
+// Linker warnings.
+def LinkerWarnings : DiagGroup<"linker-warnings">;
+
 // OpenMP warnings.
 def SourceUsesOpenMP : DiagGroup<"source-uses-openmp">;
 def OpenMPClauses : DiagGroup<"openmp-clauses">;

diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index b30bd11edbadb..e66e41d1278e3 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -160,7 +160,7 @@ namespace clang {
 const PreprocessorOptions &PPOpts,
 const CodeGenOptions &CodeGenOpts,
 const TargetOptions &TargetOpts,
-const LangOptions &LangOpts,
+const LangOptions &LangOpts, llvm::Module *Module,
 SmallVector LinkModules, LLVMContext &C,
 CoverageSourceInfo *CoverageInfo = nullptr)
 : Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
@@ -170,7 +170,7 @@ namespace clang {
   LLVMIRGenerationRefCount(0),
   Gen(CreateLLVMCodeGen(Diags, "", HeaderSearchOpts, PPOpts,
 CodeGenOpts, C, CoverageInfo)),
-  LinkModules(std::move(LinkModules)) {
+  LinkModules(std::move(LinkModules)), CurLinkModule(Module) {
   TimerIsEnabled = CodeGenOpts.TimePasses;
   llvm::TimePassesIsEnabled = CodeGenOpts.TimePasses;
   llvm::TimePassesPerRun = CodeGenOpts.TimePassesPerRun;
@@ -779,11 +779,7 @@ void BackendConsumer::DiagnosticHandlerImpl(const 
DiagnosticInfo &DI) {
 ComputeDiagID(Severity, backend_frame_larger_than, DiagID);
 break;
   case DK_Linker:
-assert(CurLinkModule);
-// FIXME: stop eating the warnings and notes.
-if (Severity != DS_Error)
-  return;
-DiagID = diag::err_fe_cannot_link_module;
+ComputeDiagID(Severity, linking_module, DiagID);
 break;
   case llvm::DK_OptimizationRemark:
 // Optimization remarks are always handled completely by this
@@ -845,9 +841,9 @@ void BackendConsumer::DiagnosticHandlerImpl(const 
DiagnosticInfo &DI)