[clang] [llvm] Revert "[AArch64] Add support for -ffixed-x30" (PR #88019)

2024-04-08 Thread Francis Visoiu Mistrih via cfe-commits

https://github.com/francisvm approved this pull request.

Makes sense, LGTM.

https://github.com/llvm/llvm-project/pull/88019
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c1eacc3 - [Matrix] Fix test on SystemZ

2023-09-05 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2023-09-05T14:22:55-04:00
New Revision: c1eacc3c409458cbd2de85c21af2df8562d73bef

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

LOG: [Matrix] Fix test on SystemZ

As reported by @uweigand in https://reviews.llvm.org/D158883:

```
The newly added test cases in ffp-model.c fail on SystemZ, making CI red:
https://lab.llvm.org/buildbot/#/builders/94/builds/16280

The root cause seems to be that by default, the SystemZ back-end targets
a machine without SIMD support, and therefore vector return types are
passed via implicit reference according to the ABI
```

this uses manual stores instead of vector returns.

Added: 


Modified: 
clang/test/CodeGen/ffp-model.c

Removed: 




diff  --git a/clang/test/CodeGen/ffp-model.c b/clang/test/CodeGen/ffp-model.c
index b3d297a2f85f46f..780603284a99f7a 100644
--- a/clang/test/CodeGen/ffp-model.c
+++ b/clang/test/CodeGen/ffp-model.c
@@ -49,9 +49,9 @@ float mymuladd(float x, float y, float z) {
 
 typedef float __attribute__((ext_vector_type(2))) v2f;
 
-v2f my_vec_muladd(v2f x, float y, v2f z) {
-  // CHECK: define{{.*}} @my_vec_muladd
-  return x * y + z;
+void my_vec_muladd(v2f x, float y, v2f z, v2f *res) {
+  // CHECK: define{{.*}}@my_vec_muladd
+  *res = x * y + z;
 
   // CHECK-FAST: fmul fast <2 x float>
   // CHECK-FAST: load <2 x float>, ptr
@@ -83,9 +83,9 @@ v2f my_vec_muladd(v2f x, float y, v2f z) {
 
 typedef float __attribute__((matrix_type(2, 1))) m21f;
 
-m21f my_m21_muladd(m21f x, float y, m21f z) {
-  // CHECK: define{{.*}} <2 x float> @my_m21_muladd
-  return x * y + z;
+void my_m21_muladd(m21f x, float y, m21f z, m21f *res) {
+  // CHECK: define{{.*}}@my_m21_muladd
+  *res = x * y + z;
 
   // CHECK-FAST: fmul fast <2 x float>
   // CHECK-FAST: load <2 x float>, ptr
@@ -117,9 +117,9 @@ m21f my_m21_muladd(m21f x, float y, m21f z) {
 
 typedef float __attribute__((matrix_type(2, 2))) m22f;
 
-m22f my_m22_muladd(m22f x, float y, m22f z) {
-  // CHECK: define{{.*}} <4 x float> @my_m22_muladd
-  return x * y + z;
+void my_m22_muladd(m22f x, float y, m22f z, m22f *res) {
+  // CHECK: define{{.*}}@my_m22_muladd
+  *res = x * y + z;
 
   // CHECK-FAST: fmul fast <4 x float>
   // CHECK-FAST: load <4 x float>, ptr



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


[clang] c987f9d - [Matrix] Try to emit fmuladd for both vector and matrix types

2023-08-31 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2023-08-31T17:13:19-07:00
New Revision: c987f9d7fdc7b22c9bf68d7b3f0df10b68c679be

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

LOG: [Matrix] Try to emit fmuladd for both vector and matrix types

For vector * scalar + vector, we emit `fmuladd` directly from clang.

This enables it also for matrix * scalar + matrix.

rdar://113967122

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

Added: 


Modified: 
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/ffp-model.c

Removed: 




diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 6d5a61b24133e2..a71b7057bb523a 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -3874,6 +3874,14 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo ) {
 }
   }
 
+  // For vector and matrix adds, try to fold into a fmuladd.
+  if (op.LHS->getType()->isFPOrFPVectorTy()) {
+CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, op.FPFeatures);
+// Try to form an fmuladd.
+if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder))
+  return FMulAdd;
+  }
+
   if (op.Ty->isConstantMatrixType()) {
 llvm::MatrixBuilder MB(Builder);
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, op.FPFeatures);
@@ -3887,10 +3895,6 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo ) {
 
   if (op.LHS->getType()->isFPOrFPVectorTy()) {
 CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, op.FPFeatures);
-// Try to form an fmuladd.
-if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder))
-  return FMulAdd;
-
 return Builder.CreateFAdd(op.LHS, op.RHS, "add");
   }
 
@@ -4024,6 +4028,14 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo ) {
   }
 }
 
+// For vector and matrix subs, try to fold into a fmuladd.
+if (op.LHS->getType()->isFPOrFPVectorTy()) {
+  CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, op.FPFeatures);
+  // Try to form an fmuladd.
+  if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder, true))
+return FMulAdd;
+}
+
 if (op.Ty->isConstantMatrixType()) {
   llvm::MatrixBuilder MB(Builder);
   CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, op.FPFeatures);
@@ -4037,9 +4049,6 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo ) {
 
 if (op.LHS->getType()->isFPOrFPVectorTy()) {
   CodeGenFunction::CGFPOptionsRAII FPOptsRAII(CGF, op.FPFeatures);
-  // Try to form an fmuladd.
-  if (Value *FMulAdd = tryEmitFMulAdd(op, CGF, Builder, true))
-return FMulAdd;
   return Builder.CreateFSub(op.LHS, op.RHS, "sub");
 }
 

diff  --git a/clang/test/CodeGen/ffp-model.c b/clang/test/CodeGen/ffp-model.c
index 57fa0ef2782051..b3d297a2f85f46 100644
--- a/clang/test/CodeGen/ffp-model.c
+++ b/clang/test/CodeGen/ffp-model.c
@@ -1,18 +1,18 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang -S -emit-llvm -ffp-model=fast -emit-llvm %s -o - \
+// RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=fast %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-FAST
 
-// RUN: %clang -S -emit-llvm -ffp-model=precise %s -o - \
+// RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=precise %s -o - \
 // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-PRECISE
 
-// RUN: %clang -S -emit-llvm -ffp-model=strict %s -o - \
+// RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=strict %s -o - \
 // RUN: -target x86_64 | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT
 
-// RUN: %clang -S -emit-llvm -ffp-model=strict -ffast-math \
+// RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=strict -ffast-math \
 // RUN: -target x86_64 %s -o - | FileCheck %s \
 // RUN: --check-prefixes CHECK,CHECK-STRICT-FAST
 
-// RUN: %clang -S -emit-llvm -ffp-model=precise -ffast-math \
+// RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=precise -ffast-math \
 // RUN: %s -o - | FileCheck %s --check-prefixes CHECK,CHECK-FAST1
 
 float mymuladd(float x, float y, float z) {
@@ -46,3 +46,105 @@ float mymuladd(float x, float y, float z) {
   // CHECK-FAST1: load float, ptr {{.*}}
   // CHECK-FAST1: fadd fast float {{.*}}, {{.*}}
 }
+
+typedef float __attribute__((ext_vector_type(2))) v2f;
+
+v2f my_vec_muladd(v2f x, float y, v2f z) {
+  // CHECK: define{{.*}} @my_vec_muladd
+  return x * y + z;
+
+  // CHECK-FAST: fmul fast <2 x float>
+  // CHECK-FAST: load <2 x float>, ptr
+  // CHECK-FAST: fadd fast <2 x float>
+
+  // CHECK-PRECISE: load <2 x float>, ptr
+  // CHECK-PRECISE: load float, ptr
+  // CHECK-PRECISE: load <2 x float>, ptr
+  // CHECK-PRECISE: call <2 x float> @llvm.fmuladd.v2f32(<2 x float> {{.*}}, 
<2 x float> {{.*}}, <2 x float> {{.*}})
+
+  // CHECK-STRICT: load <2 x float>, ptr
+  // CHECK-STRICT: load float, ptr
+  // 

[clang] 06d06f2 - [CMake][llvm] avoid conflict w/ (and use when available) new builtin check_linker_flag

2021-04-27 Thread Francis Visoiu Mistrih via cfe-commits

Author: Jim Radford
Date: 2021-04-27T16:41:28-07:00
New Revision: 06d06f2f6403066415df7b8854e6aff7586a92df

URL: 
https://github.com/llvm/llvm-project/commit/06d06f2f6403066415df7b8854e6aff7586a92df
DIFF: 
https://github.com/llvm/llvm-project/commit/06d06f2f6403066415df7b8854e6aff7586a92df.diff

LOG: [CMake][llvm] avoid conflict w/ (and use when available) new builtin 
check_linker_flag

Match the API for the new check_linker_flag and use it directly when
available, leaving the old code as a fallback.

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

Added: 
llvm/cmake/modules/LLVMCheckLinkerFlag.cmake

Modified: 
clang/tools/driver/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/HandleLLVMOptions.cmake
llvm/cmake/modules/HandleLLVMStdlib.cmake

Removed: 
llvm/cmake/modules/CheckLinkerFlag.cmake



diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 01efebdcb929..7c32aadb8700 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -93,7 +93,7 @@ endif()
 
 if(CLANG_ORDER_FILE AND
 (LLVM_LINKER_IS_LD64 OR LLVM_LINKER_IS_GOLD OR LLVM_LINKER_IS_LLD))
-  include(CheckLinkerFlag)
+  include(LLVMCheckLinkerFlag)
 
   if (LLVM_LINKER_IS_LD64)
 set(LINKER_ORDER_FILE_OPTION "-Wl,-order_file,${CLANG_ORDER_FILE}")
@@ -104,7 +104,7 @@ if(CLANG_ORDER_FILE AND
   endif()
 
   # This is a test to ensure the actual order file works with the linker.
-  check_linker_flag(${LINKER_ORDER_FILE_OPTION} LINKER_ORDER_FILE_WORKS)
+  llvm_check_linker_flag(CXX ${LINKER_ORDER_FILE_OPTION} 
LINKER_ORDER_FILE_WORKS)
 
   # Passing an empty order file disables some linker layout optimizations.
   # To work around this and enable workflows for re-linking when the order file

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 2f055c779962..9bfef6dd8473 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -236,8 +236,8 @@ function(add_link_opts target_name)
   elseif(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
 # Support for ld -z discard-unused=sections was only added in
 # Solaris 11.4.
-include(CheckLinkerFlag)
-check_linker_flag("-Wl,-z,discard-unused=sections" 
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
+include(LLVMCheckLinkerFlag)
+llvm_check_linker_flag(CXX "-Wl,-z,discard-unused=sections" 
LINKER_SUPPORTS_Z_DISCARD_UNUSED)
 if (LINKER_SUPPORTS_Z_DISCARD_UNUSED)
   set_property(TARGET ${target_name} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,-z,discard-unused=sections")

diff  --git a/llvm/cmake/modules/CheckLinkerFlag.cmake 
b/llvm/cmake/modules/CheckLinkerFlag.cmake
deleted file mode 100644
index fe9d01a349cd..
--- a/llvm/cmake/modules/CheckLinkerFlag.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-include(CheckCXXCompilerFlag)
-
-function(check_linker_flag flag out_var)
-  set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}")
-  check_cxx_compiler_flag("" ${out_var})
-endfunction()

diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake 
b/llvm/cmake/modules/HandleLLVMOptions.cmake
index e7c30e9d0082..ee91386055f7 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -888,8 +888,8 @@ endif()
 
 # lld doesn't print colored diagnostics when invoked from Ninja
 if (UNIX AND CMAKE_GENERATOR STREQUAL "Ninja")
-  include(CheckLinkerFlag)
-  check_linker_flag("-Wl,--color-diagnostics" 
LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
+  include(LLVMCheckLinkerFlag)
+  llvm_check_linker_flag(CXX "-Wl,--color-diagnostics" 
LINKER_SUPPORTS_COLOR_DIAGNOSTICS)
   append_if(LINKER_SUPPORTS_COLOR_DIAGNOSTICS "-Wl,--color-diagnostics"
 CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
 endif()

diff  --git a/llvm/cmake/modules/HandleLLVMStdlib.cmake 
b/llvm/cmake/modules/HandleLLVMStdlib.cmake
index b67d87d43005..7afc10cff74f 100644
--- a/llvm/cmake/modules/HandleLLVMStdlib.cmake
+++ b/llvm/cmake/modules/HandleLLVMStdlib.cmake
@@ -13,12 +13,12 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
   endfunction()
 
   include(CheckCXXCompilerFlag)
-  include(CheckLinkerFlag)
+  include(LLVMCheckLinkerFlag)
   set(LLVM_LIBCXX_USED 0)
   if(LLVM_ENABLE_LIBCXX)
 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
   check_cxx_compiler_flag("-stdlib=libc++" CXX_COMPILER_SUPPORTS_STDLIB)
-  check_linker_flag("-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
+  llvm_check_linker_flag(CXX "-stdlib=libc++" CXX_LINKER_SUPPORTS_STDLIB)
   if(CXX_COMPILER_SUPPORTS_STDLIB AND CXX_LINKER_SUPPORTS_STDLIB)
 append("-stdlib=libc++"
   CMAKE_CXX_FLAGS CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS
@@ -36,7 +36,7 @@ if(NOT DEFINED LLVM_STDLIB_HANDLED)
 if(LLVM_COMPILER_IS_GCC_COMPATIBLE)
   

[clang] e770153 - [AArch64] Add support for -ffixed-x30

2020-04-28 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-04-28T08:48:28-07:00
New Revision: e770153865c53c4fd72a68f23acff33c24e42a08

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

LOG: [AArch64] Add support for -ffixed-x30

Add support for reserving LR in:

* the driver through `-ffixed-x30`
* cc1 through `-target-feature +reserve-x30`
* the backend through `-mattr=+reserve-x30`
* a subtarget feature `reserve-x30`

the same way we're doing for the other registers.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-fixed-x-register.c
llvm/lib/Target/AArch64/AArch64.td
llvm/test/CodeGen/AArch64/arm64-platform-reg.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 4c034d40aaf4..e71655bcbb97 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -409,6 +409,9 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   if (Args.hasArg(options::OPT_ffixed_x28))
 Features.push_back("+reserve-x28");
 
+  if (Args.hasArg(options::OPT_ffixed_x30))
+Features.push_back("+reserve-x30");
+
   if (Args.hasArg(options::OPT_fcall_saved_x8))
 Features.push_back("+call-saved-x8");
 

diff  --git a/clang/test/Driver/aarch64-fixed-x-register.c 
b/clang/test/Driver/aarch64-fixed-x-register.c
index ed8e7c2013db..52f62e68ef59 100644
--- a/clang/test/Driver/aarch64-fixed-x-register.c
+++ b/clang/test/Driver/aarch64-fixed-x-register.c
@@ -94,6 +94,10 @@
 // RUN: FileCheck --check-prefix=CHECK-FIXED-X28 < %t %s
 // CHECK-FIXED-X28: "-target-feature" "+reserve-x28"
 
+// RUN: %clang -target aarch64-none-gnu -ffixed-x30 -### %s 2> %t
+// RUN: FileCheck --check-prefix=CHECK-FIXED-X30 < %t %s
+// CHECK-FIXED-X30: "-target-feature" "+reserve-x30"
+
 // Test multiple of reserve-x# options together.
 // RUN: %clang -target aarch64-none-gnu \
 // RUN: -ffixed-x1 \

diff  --git a/llvm/lib/Target/AArch64/AArch64.td 
b/llvm/lib/Target/AArch64/AArch64.td
index d2ab0ff898aa..e99f69247a4e 100644
--- a/llvm/lib/Target/AArch64/AArch64.td
+++ b/llvm/lib/Target/AArch64/AArch64.td
@@ -142,7 +142,7 @@ def FeatureStrictAlign : SubtargetFeature<"strict-align",
   "Disallow all unaligned memory "
   "access">;
 
-foreach i = {1-7,9-15,18,20-28} in
+foreach i = {1-7,9-15,18,20-28,30} in
 def FeatureReserveX#i : SubtargetFeature<"reserve-x"#i, 
"ReserveXRegister["#i#"]", "true",
  "Reserve X"#i#", making it 
unavailable "
  "as a GPR">;

diff  --git a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll 
b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
index 42448fcce56c..89fc6457482f 100644
--- a/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
+++ b/llvm/test/CodeGen/AArch64/arm64-platform-reg.ll
@@ -29,6 +29,7 @@
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x26 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X26
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x27 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X27
 ; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x28 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X28
+; RUN: llc -mtriple=arm64-linux-gnu -mattr=+reserve-x30 -o - %s | FileCheck %s 
--check-prefixes=CHECK-RESERVE,CHECK-RESERVE-X30
 
 ; Test multiple of reserve-x# options together.
 ; RUN: llc -mtriple=arm64-linux-gnu \
@@ -67,6 +68,7 @@
 ; RUN: -mattr=+reserve-x26 \
 ; RUN: -mattr=+reserve-x27 \
 ; RUN: -mattr=+reserve-x28 \
+; RUN: -mattr=+reserve-x30 \
 ; RUN: -o - %s | FileCheck %s \
 ; RUN: --check-prefix=CHECK-RESERVE \
 ; RUN: --check-prefix=CHECK-RESERVE-X1 \
@@ -92,7 +94,8 @@
 ; RUN: --check-prefix=CHECK-RESERVE-X25 \
 ; RUN: --check-prefix=CHECK-RESERVE-X26 \
 ; RUN: --check-prefix=CHECK-RESERVE-X27 \
-; RUN: --check-prefix=CHECK-RESERVE-X28
+; RUN: --check-prefix=CHECK-RESERVE-X28 \
+; RUN: --check-prefix=CHECK-RESERVE-X30
 
 ; x18 is reserved as a platform register on Darwin but not on other
 ; systems. Create loads of register pressure and make sure this is respected.
@@ -134,6 +137,7 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
+; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: Spill
 ; CHECK-RESERVE-NOT: ldr fp
 ; CHECK-RESERVE-X1-NOT: ldr x1,
@@ -160,6 +164,7 @@ define void @keep_live() {
 ; CHECK-RESERVE-X26-NOT: ldr x26
 ; CHECK-RESERVE-X27-NOT: ldr x27
 ; CHECK-RESERVE-X28-NOT: ldr x28
+; CHECK-RESERVE-X30-NOT: ldr x30
 ; CHECK-RESERVE: ret
   ret void
 }




[clang] 9e6670b - [Driver] Only pass LTO remark arguments if the driver asks for it

2020-04-07 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-04-07T14:11:47-07:00
New Revision: 9e6670b03ceaa5980eccb06e2dd037e6a9584c66

URL: 
https://github.com/llvm/llvm-project/commit/9e6670b03ceaa5980eccb06e2dd037e6a9584c66
DIFF: 
https://github.com/llvm/llvm-project/commit/9e6670b03ceaa5980eccb06e2dd037e6a9584c66.diff

LOG: [Driver] Only pass LTO remark arguments if the driver asks for it

Previous fix missed a check to willEmitRemarks, causing remarks to
always be enabled for LTO.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-opt-record-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index ab984271555b..a113d05cc579 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -533,7 +533,8 @@ void darwin::Linker::ConstructJob(Compilation , const 
JobAction ,
   // we follow suite for ease of comparison.
   AddLinkArgs(C, Args, CmdArgs, Inputs);
 
-  if (checkRemarksOptions(getToolChain().getDriver(), Args,
+  if (willEmitRemarks(Args) &&
+  checkRemarksOptions(getToolChain().getDriver(), Args,
   getToolChain().getTriple()))
 renderRemarksOptions(Args, CmdArgs, getToolChain().getTriple(), Output, 
JA);
 

diff  --git a/clang/test/Driver/darwin-opt-record-ld.c 
b/clang/test/Driver/darwin-opt-record-ld.c
index 0e1e312c493d..83630ed01da8 100644
--- a/clang/test/Driver/darwin-opt-record-ld.c
+++ b/clang/test/Driver/darwin-opt-record-ld.c
@@ -2,6 +2,10 @@
 
 // RUN: touch %t.o
 //
+// Check that we're not passing -lto-pass-remarks-output if not requested
+// RUN: %clang -target x86_64-apple-darwin12 %t.o -### -o foo/bar.out 2> %t.log
+// RUN: FileCheck -check-prefix=NO_PASS_REMARKS_OUTPUT %s < %t.log
+// NO_PASS_REMARKS_OUTPUT-NOT: -lto-pass-remarks
 // Check that we're passing -lto-pass-remarks-output for LTO
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record 
-### -o foo/bar.out 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_OUTPUT %s < %t.log



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


[clang] ba8b305 - [Driver] Handle all optimization-record options for Darwin LTO

2020-04-03 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-04-03T15:30:08-07:00
New Revision: ba8b3052b59ebee4311d10bee5209dac8747acea

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

LOG: [Driver] Handle all optimization-record options for Darwin LTO

clang with -flto does not handle -foptimization-record-path=

This dulicates the code from ToolChains/Clang.cpp with modifications to
support everything in the same fashion.

Added: 
clang/test/Driver/darwin-opt-record-ld.c

Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 451d0d206d07..ab984271555b 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -430,6 +430,75 @@ static bool isObjCRuntimeLinked(const ArgList ) {
   return Args.hasArg(options::OPT_fobjc_link_runtime);
 }
 
+static bool checkRemarksOptions(const Driver , const ArgList ,
+const llvm::Triple ) {
+  // When enabling remarks, we need to error if:
+  // * The remark file is specified but we're targeting multiple architectures,
+  // which means more than one remark file is being generated.
+  bool hasMultipleInvocations =
+  Args.getAllArgValues(options::OPT_arch).size() > 1;
+  bool hasExplicitOutputFile =
+  Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+  if (hasMultipleInvocations && hasExplicitOutputFile) {
+D.Diag(diag::err_drv_invalid_output_with_multiple_archs)
+<< "-foptimization-record-file";
+return false;
+  }
+  return true;
+}
+
+static void renderRemarksOptions(const ArgList , ArgStringList ,
+ const llvm::Triple ,
+ const InputInfo , const JobAction ) 
{
+  StringRef Format = "yaml";
+  if (const Arg *A = 
Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+Format = A->getValue();
+
+  CmdArgs.push_back("-mllvm");
+  CmdArgs.push_back("-lto-pass-remarks-output");
+  CmdArgs.push_back("-mllvm");
+
+  const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+  if (A) {
+CmdArgs.push_back(A->getValue());
+  } else {
+assert(Output.isFilename() && "Unexpected ld output.");
+SmallString<128> F;
+F = Output.getFilename();
+F += ".opt.";
+F += Format;
+
+CmdArgs.push_back(Args.MakeArgString(F));
+  }
+
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_foptimization_record_passes_EQ)) {
+CmdArgs.push_back("-mllvm");
+std::string Passes =
+std::string("-lto-pass-remarks-filter=") + A->getValue();
+CmdArgs.push_back(Args.MakeArgString(Passes));
+  }
+
+  if (!Format.empty()) {
+CmdArgs.push_back("-mllvm");
+Twine FormatArg = Twine("-lto-pass-remarks-format=") + Format;
+CmdArgs.push_back(Args.MakeArgString(FormatArg));
+  }
+
+  if (getLastProfileUseArg(Args)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-lto-pass-remarks-with-hotness");
+
+if (const Arg *A =
+Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ)) {
+  CmdArgs.push_back("-mllvm");
+  std::string Opt =
+  std::string("-lto-pass-remarks-hotness-threshold=") + A->getValue();
+  CmdArgs.push_back(Args.MakeArgString(Opt));
+}
+  }
+}
+
 void darwin::Linker::ConstructJob(Compilation , const JobAction ,
   const InputInfo ,
   const InputInfoList ,
@@ -464,55 +533,9 @@ void darwin::Linker::ConstructJob(Compilation , const 
JobAction ,
   // we follow suite for ease of comparison.
   AddLinkArgs(C, Args, CmdArgs, Inputs);
 
-  // For LTO, pass the name of the optimization record file and other
-  // opt-remarks flags.
-  if (Args.hasFlag(options::OPT_fsave_optimization_record,
-   options::OPT_fsave_optimization_record_EQ,
-   options::OPT_fno_save_optimization_record, false)) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-lto-pass-remarks-output");
-CmdArgs.push_back("-mllvm");
-
-SmallString<128> F;
-F = Output.getFilename();
-F += ".opt.";
-if (const Arg *A =
-Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
-  F += A->getValue();
-else
-  F += "yaml";
-
-CmdArgs.push_back(Args.MakeArgString(F));
-
-if (getLastProfileUseArg(Args)) {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-lto-pass-remarks-with-hotness");
-
-  if (const Arg *A =
-  Args.getLastArg(options::OPT_fdiagnostics_hotness_threshold_EQ)) 
{
-CmdArgs.push_back("-mllvm");
-std::string Opt =
-

[clang] 7531a50 - [Remarks] Extend the RemarkStreamer to support other emitters

2020-02-04 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-02-04T17:16:02-08:00
New Revision: 7531a5039fd7ee9b48eb8a0d0770e8dfb9fa8bdf

URL: 
https://github.com/llvm/llvm-project/commit/7531a5039fd7ee9b48eb8a0d0770e8dfb9fa8bdf
DIFF: 
https://github.com/llvm/llvm-project/commit/7531a5039fd7ee9b48eb8a0d0770e8dfb9fa8bdf.diff

LOG: [Remarks] Extend the RemarkStreamer to support other emitters

This extends the RemarkStreamer to allow for other emitters (e.g.
frontends, SIL, etc.) to emit remarks through a common interface.

See changes in llvm/docs/Remarks.rst for motivation and design choices.

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

Added: 
llvm/include/llvm/IR/LLVMRemarkStreamer.h
llvm/include/llvm/Remarks/RemarkStreamer.h
llvm/lib/IR/LLVMRemarkStreamer.cpp
llvm/lib/Remarks/RemarkStreamer.cpp

Modified: 
clang/lib/CodeGen/CodeGenAction.cpp
llvm/docs/Remarks.rst
llvm/include/llvm/Analysis/OptimizationRemarkEmitter.h
llvm/include/llvm/CodeGen/AsmPrinter.h
llvm/include/llvm/CodeGen/MachineOptimizationRemarkEmitter.h
llvm/include/llvm/IR/LLVMContext.h
llvm/include/llvm/LTO/LTO.h
llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
llvm/lib/IR/CMakeLists.txt
llvm/lib/IR/LLVMContext.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/LTOBackend.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Remarks/CMakeLists.txt
llvm/tools/llc/llc.cpp
llvm/tools/opt/opt.cpp

Removed: 
llvm/include/llvm/IR/RemarkStreamer.h
llvm/lib/IR/RemarkStreamer.cpp



diff  --git a/clang/lib/CodeGen/CodeGenAction.cpp 
b/clang/lib/CodeGen/CodeGenAction.cpp
index b89b080bb3eb..5ebc34cd2700 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -32,8 +32,8 @@
 #include "llvm/IR/DiagnosticPrinter.h"
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/LLVMContext.h"
+#include "llvm/IR/LLVMRemarkStreamer.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/RemarkStreamer.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/Pass.h"
@@ -86,15 +86,15 @@ namespace clang {
const CodeGenOptions CodeGenOpts) {
 handleAllErrors(
 std::move(E),
-  [&](const RemarkSetupFileError ) {
+  [&](const LLVMRemarkSetupFileError ) {
   Diags.Report(diag::err_cannot_open_file)
   << CodeGenOpts.OptRecordFile << E.message();
 },
-  [&](const RemarkSetupPatternError ) {
+  [&](const LLVMRemarkSetupPatternError ) {
   Diags.Report(diag::err_drv_optimization_remark_pattern)
   << E.message() << CodeGenOpts.OptRecordPasses;
 },
-  [&](const RemarkSetupFormatError ) {
+  [&](const LLVMRemarkSetupFormatError ) {
   Diags.Report(diag::err_drv_optimization_remark_format)
   << CodeGenOpts.OptRecordFormat;
 });
@@ -309,7 +309,7 @@ namespace clang {
 CodeGenOpts, this));
 
   Expected> OptRecordFileOrErr =
-  setupOptimizationRemarks(
+  setupLLVMOptimizationRemarks(
   Ctx, CodeGenOpts.OptRecordFile, CodeGenOpts.OptRecordPasses,
   CodeGenOpts.OptRecordFormat, CodeGenOpts.DiagnosticsWithHotness,
   CodeGenOpts.DiagnosticsHotnessThreshold);
@@ -1150,7 +1150,7 @@ void CodeGenAction::ExecuteAction() {
 std::make_unique(CodeGenOpts, ));
 
 Expected> OptRecordFileOrErr =
-setupOptimizationRemarks(
+setupLLVMOptimizationRemarks(
 Ctx, CodeGenOpts.OptRecordFile, CodeGenOpts.OptRecordPasses,
 CodeGenOpts.OptRecordFormat, CodeGenOpts.DiagnosticsWithHotness,
 CodeGenOpts.DiagnosticsHotnessThreshold);

diff  --git a/llvm/docs/Remarks.rst b/llvm/docs/Remarks.rst
index 653b418e6fd2..b6cec12b326f 100644
--- a/llvm/docs/Remarks.rst
+++ b/llvm/docs/Remarks.rst
@@ -612,6 +612,38 @@ The typical usage through the C API is like the following:
 bool HasError = LLVMRemarkParserHasError(Parser);
 LLVMRemarkParserDispose(Parser);
 
+Remark streamers
+
+
+The ``RemarkStreamer`` interface is used to unify the serialization
+capabilities of remarks across all the components that can generate remarks.
+
+All remark serialization should go through the main remark streamer, the
+``llvm::remarks::RemarkStreamer`` set up in the ``LLVMContext``. The interface
+takes remark objects converted to ``llvm::remarks::Remark``, and takes care of
+serializing it to the requested format, using the requested type of metadata,
+etc.
+
+Typically, a specialized remark streamer will hold a reference to the one set
+up in the ``LLVMContext``, and will operate on its own type of diagnostics.
+
+For example, LLVM IR passes will emit ``llvm::DiagnosticInfoOptimization*``
+that get converted to ``llvm::remarks::Remark`` objects.  Then, 

[clang] b1a8189 - [NFC] Fix comment typo

2020-01-28 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-01-28T15:23:28-08:00
New Revision: b1a8189d7d7584ca22251a94948457b6cad19421

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

LOG: [NFC] Fix comment typo

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index d633b3dd7d32..3f132a0a62aa 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1842,7 +1842,7 @@ static void addNoBuiltinAttributes(llvm::AttrBuilder 
,
 FuncAttrs.addAttribute(AttributeName);
   };
 
-  // First, handle the language options passed through -fno-builtin[-]
+  // First, handle the language options passed through -fno-builtin.
   if (LangOpts.NoBuiltin) {
 // -fno-builtin disables them all.
 FuncAttrs.addAttribute("no-builtins");



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


[clang] 4e799ad - [CodeGen] Attach no-builtin attributes to function definitions with no Decl

2020-01-28 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-01-28T13:59:08-08:00
New Revision: 4e799ada5860d1029ea89226b9b867302e792251

URL: 
https://github.com/llvm/llvm-project/commit/4e799ada5860d1029ea89226b9b867302e792251
DIFF: 
https://github.com/llvm/llvm-project/commit/4e799ada5860d1029ea89226b9b867302e792251.diff

LOG: [CodeGen] Attach no-builtin attributes to function definitions with no Decl

When using -fno-builtin[-], we don't attach the IR attributes to
function definitions with no Decl, like the ones created through
`CreateGlobalInitOrDestructFunction`.

This results in projects using -fno-builtin or -ffreestanding to start
seeing symbols like _memset_pattern16.

The fix changes the behavior to always add the attribute if LangOptions
requests it.

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

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGenCXX/global-init.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 3a50e2b103f6..d633b3dd7d32 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1832,6 +1832,42 @@ void CodeGenModule::AddDefaultFnAttrs(llvm::Function ) 
{
   F.addAttributes(llvm::AttributeList::FunctionIndex, FuncAttrs);
 }
 
+static void addNoBuiltinAttributes(llvm::AttrBuilder ,
+   const LangOptions ,
+   const NoBuiltinAttr *NBA = nullptr) {
+  auto AddNoBuiltinAttr = [](StringRef BuiltinName) {
+SmallString<32> AttributeName;
+AttributeName += "no-builtin-";
+AttributeName += BuiltinName;
+FuncAttrs.addAttribute(AttributeName);
+  };
+
+  // First, handle the language options passed through -fno-builtin[-]
+  if (LangOpts.NoBuiltin) {
+// -fno-builtin disables them all.
+FuncAttrs.addAttribute("no-builtins");
+return;
+  }
+
+  // Then, add attributes for builtins specified through -fno-builtin-.
+  llvm::for_each(LangOpts.NoBuiltinFuncs, AddNoBuiltinAttr);
+
+  // Now, let's check the __attribute__((no_builtin("...")) attribute added to
+  // the source.
+  if (!NBA)
+return;
+
+  // If there is a wildcard in the builtin names specified through the
+  // attribute, disable them all.
+  if (llvm::is_contained(NBA->builtinNames(), "*")) {
+FuncAttrs.addAttribute("no-builtins");
+return;
+  }
+
+  // And last, add the rest of the builtin names.
+  llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
+}
+
 void CodeGenModule::ConstructAttributeList(
 StringRef Name, const CGFunctionInfo , CGCalleeInfo CalleeInfo,
 llvm::AttributeList , unsigned , bool AttrOnCallSite) 
{
@@ -1850,6 +1886,8 @@ void CodeGenModule::ConstructAttributeList(
   const Decl *TargetDecl = CalleeInfo.getCalleeDecl().getDecl();
 
   bool HasOptnone = false;
+  // The NoBuiltinAttr attached to a TargetDecl (only allowed on 
FunctionDecls).
+  const NoBuiltinAttr *NBA = nullptr;
   // FIXME: handle sseregparm someday...
   if (TargetDecl) {
 if (TargetDecl->hasAttr())
@@ -1875,22 +1913,7 @@ void CodeGenModule::ConstructAttributeList(
   if (!(AttrOnCallSite && IsVirtualCall)) {
 if (Fn->isNoReturn())
   FuncAttrs.addAttribute(llvm::Attribute::NoReturn);
-
-const auto *NBA = Fn->getAttr();
-bool HasWildcard = NBA && llvm::is_contained(NBA->builtinNames(), "*");
-if (getLangOpts().NoBuiltin || HasWildcard)
-  FuncAttrs.addAttribute("no-builtins");
-else {
-  auto AddNoBuiltinAttr = [](StringRef BuiltinName) {
-SmallString<32> AttributeName;
-AttributeName += "no-builtin-";
-AttributeName += BuiltinName;
-FuncAttrs.addAttribute(AttributeName);
-  };
-  llvm::for_each(getLangOpts().NoBuiltinFuncs, AddNoBuiltinAttr);
-  if (NBA)
-llvm::for_each(NBA->builtinNames(), AddNoBuiltinAttr);
-}
+NBA = Fn->getAttr();
   }
 }
 
@@ -1925,6 +1948,14 @@ void CodeGenModule::ConstructAttributeList(
 }
   }
 
+  // Attach "no-builtins" attributes to:
+  // * call sites: both `nobuiltin` and "no-builtins" or "no-builtin-".
+  // * definitions: "no-builtins" or "no-builtin-" only.
+  // The attributes can come from:
+  // * LangOpts: -ffreestanding, -fno-builtin, -fno-builtin-
+  // * FunctionDecl attributes: __attribute__((no_builtin(...)))
+  addNoBuiltinAttributes(FuncAttrs, getLangOpts(), NBA);
+
   ConstructDefaultFnAttrList(Name, HasOptnone, AttrOnCallSite, FuncAttrs);
 
   // This must run after constructing the default function attribute list

diff  --git a/clang/test/CodeGenCXX/global-init.cpp 
b/clang/test/CodeGenCXX/global-init.cpp
index 1970de8825e2..eaa37456774a 100644
--- a/clang/test/CodeGenCXX/global-init.cpp
+++ b/clang/test/CodeGenCXX/global-init.cpp
@@ -2,6 +2,8 @@
 // RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm %s -o - |FileCheck 

[clang] 0f34ea5 - [perf-training] Update ' (in-process)' prefix handling

2020-01-25 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-01-25T09:14:24-08:00
New Revision: 0f34ea5dc3cb3efea12dac1fa28b4d3db0cebc75

URL: 
https://github.com/llvm/llvm-project/commit/0f34ea5dc3cb3efea12dac1fa28b4d3db0cebc75
DIFF: 
https://github.com/llvm/llvm-project/commit/0f34ea5dc3cb3efea12dac1fa28b4d3db0cebc75.diff

LOG: [perf-training] Update ' (in-process)' prefix handling

A recent change added a new line after the prefix, so it's now part of
the prefix list.

Added: 


Modified: 
clang/utils/perf-training/perf-helper.py

Removed: 




diff  --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 58eef65c6e73..88708a92712a 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -123,6 +123,7 @@ def get_cc1_command_for_args(cmd, env):
   ln.startswith('Thread model:') or
   ln.startswith('InstalledDir:') or
   ln.startswith('LLVM Profile Note') or
+  ln.startswith(' (in-process)') or
   ' version ' in ln):
   continue
   cc_commands.append(ln)
@@ -131,15 +132,7 @@ def get_cc1_command_for_args(cmd, env):
   print('Fatal error: unable to determine cc1 command: %r' % cc_output)
   exit(1)
 
-  cc_command = cc_commands[0]
-
-  # When cc1 runs in the same process as the driver, it prefixes the cc1
-  # invocation with ' (in-process)'. Skip it.
-  skip_pfx_line = ' (in-process)'
-  if cc_command.startswith(skip_pfx_line):
-  cc_command = cc_command[len(skip_pfx_line):]
-
-  cc1_cmd = shlex.split(cc_command)
+  cc1_cmd = shlex.split(cc_commands[0])
   if not cc1_cmd:
   print('Fatal error: unable to determine cc1 command: %r' % cc_output)
   exit(1)



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


[clang] 03689fe - [perf-training] Ignore ' (in-process)' prefix from -###

2020-01-17 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2020-01-17T09:38:35-08:00
New Revision: 03689fe97f2377a3b19864de98b5c14b7fbd85ab

URL: 
https://github.com/llvm/llvm-project/commit/03689fe97f2377a3b19864de98b5c14b7fbd85ab
DIFF: 
https://github.com/llvm/llvm-project/commit/03689fe97f2377a3b19864de98b5c14b7fbd85ab.diff

LOG: [perf-training] Ignore ' (in-process)' prefix from -###

After D69825, the output of clang -### when running in process can be
prefixed by ' (in-process)'. Skip it.

Added: 


Modified: 
clang/utils/perf-training/perf-helper.py

Removed: 




diff  --git a/clang/utils/perf-training/perf-helper.py 
b/clang/utils/perf-training/perf-helper.py
index 3ab193ee76c0..58eef65c6e73 100644
--- a/clang/utils/perf-training/perf-helper.py
+++ b/clang/utils/perf-training/perf-helper.py
@@ -131,7 +131,15 @@ def get_cc1_command_for_args(cmd, env):
   print('Fatal error: unable to determine cc1 command: %r' % cc_output)
   exit(1)
 
-  cc1_cmd = shlex.split(cc_commands[0])
+  cc_command = cc_commands[0]
+
+  # When cc1 runs in the same process as the driver, it prefixes the cc1
+  # invocation with ' (in-process)'. Skip it.
+  skip_pfx_line = ' (in-process)'
+  if cc_command.startswith(skip_pfx_line):
+  cc_command = cc_command[len(skip_pfx_line):]
+
+  cc1_cmd = shlex.split(cc_command)
   if not cc1_cmd:
   print('Fatal error: unable to determine cc1 command: %r' % cc_output)
   exit(1)



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


[clang] 07b8f8e - [Remarks][Driver] Place temporary remark files next to temporary object files

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T16:42:02-08:00
New Revision: 07b8f8e5f5cad9c4d92c39a4bea50e21e9f0e9f1

URL: 
https://github.com/llvm/llvm-project/commit/07b8f8e5f5cad9c4d92c39a4bea50e21e9f0e9f1
DIFF: 
https://github.com/llvm/llvm-project/commit/07b8f8e5f5cad9c4d92c39a4bea50e21e9f0e9f1.diff

LOG: [Remarks][Driver] Place temporary remark files next to temporary object 
files

On Darwin, when used for generating a linked binary from a source file
(through an intermediate object file), the driver will invoke `cc1` to
generate a temporary object file. The temporary remark file will now be
emitted next to the object file, which will then be picked up by
`dsymutil` and emitted in the .dSYM bundle.

This is available for all formats except YAML since by default, YAML
doesn't need a section and the remark file will be lost.

Added: 


Modified: 
clang/docs/UsersManual.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/darwin-opt-record.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 307507388ff6..07201f0d8616 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -355,21 +355,14 @@ output format of the diagnostics that it generates.
 
where  is based on the output file of the compilation (whether
it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
-   In other cases, it's based on the input file's stem. For example:
+   For example:
 
* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
  ``out.opt.yaml``
 
-   * ``clang -fsave-optimization-record in.c -o out`` will generate
+   * ``clang -fsave-optimization-record -c in.c `` will generate
  ``in.opt.yaml``
 
-   Compiling for multiple architectures will use the following scheme:
-
-   ``-.opt.``
-
-   Note that this is only allowed on Darwin platforms and is incompatible with
-   passing multiple ``-arch `` options.
-
When targeting (Thin)LTO, the base is derived from the output filename, and
the extension is not dropped.
 
@@ -377,6 +370,32 @@ output format of the diagnostics that it generates.
 
``.opt..thin..``
 
+   Darwin-only: when used for generating a linked binary from a source file
+   (through an intermediate object file), the driver will invoke `cc1` to
+   generate a temporary object file. The temporary remark file will be emitted
+   next to the object file, which will then be picked up by `dsymutil` and
+   emitted in the .dSYM bundle. This is available for all formats except YAML.
+
+   For example:
+
+   ``clang -fsave-optimization-record=bitstream in.c -o out`` will generate
+
+   * ``/var/folders/43/9y164hh52tv_2nrdxrj31nywgn/T/a-9be59b.o``
+
+   * 
``/var/folders/43/9y164hh52tv_2nrdxrj31nywgn/T/a-9be59b.opt.bitstream``
+
+   * ``out``
+
+   * ``out.dSYM/Contents/Resources/Remarks/out``
+
+   Darwin-only: compiling for multiple architectures will use the following
+   scheme:
+
+   ``-.opt.``
+
+   Note that this is incompatible with passing the
+   :ref:`-foptimization-record-file ` option.
+
 .. _opt_foptimization-record-file:
 
 **-foptimization-record-file**

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9840acafd6ea..5c7572fb12be 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1444,7 +1444,12 @@ static bool checkRemarksOptions(const Driver , const 
ArgList ,
 
 static void renderRemarksOptions(const ArgList , ArgStringList ,
  const llvm::Triple ,
- const InputInfo , const JobAction ) {
+ const InputInfo ,
+ const InputInfo , const JobAction ) 
{
+  StringRef Format = "yaml";
+  if (const Arg *A = 
Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+Format = A->getValue();
+
   CmdArgs.push_back("-opt-record-file");
 
   const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
@@ -1454,11 +1459,17 @@ static void renderRemarksOptions(const ArgList , 
ArgStringList ,
 bool hasMultipleArchs =
 Triple.isOSDarwin() && // Only supported on Darwin platforms.
 Args.getAllArgValues(options::OPT_arch).size() > 1;
+
 SmallString<128> F;
 
 if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
   if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
 F = FinalOutput->getValue();
+} else {
+  if (Format != "yaml" && // For YAML, keep the original behavior.
+  Triple.isOSDarwin() && // Enable this only on darwin, since it's the 
only platform supporting .dSYM bundles.
+  Output.isFilename())
+F = Output.getFilename();
 }
 
 if (F.empty()) {
@@ -1494,12 +1505,9 @@ static void renderRemarksOptions(const ArgList , 
ArgStringList ,

[clang] f550961 - [Docs] Fix indentation in remarks section

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T16:41:52-08:00
New Revision: f550961c6e833cb828416f1bdee904f4aadbf37d

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

LOG: [Docs] Fix indentation in remarks section

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 87434200e777..307507388ff6 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -346,36 +346,36 @@ output format of the diagnostics that it generates.
   ``-fsave-optimization-record=bitstream``: A binary format based on LLVM
   Bitstream.
 
-The output file is controlled by :ref:`-foptimization-record-file 
`.
+   The output file is controlled by :ref:`-foptimization-record-file 
`.
 
-In the absence of an explicit output file, the file is chosen using the
-following scheme:
+   In the absence of an explicit output file, the file is chosen using the
+   following scheme:
 
-``.opt.``
+   ``.opt.``
 
-where  is based on the output file of the compilation (whether
-it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
-In other cases, it's based on the input file's stem. For example:
+   where  is based on the output file of the compilation (whether
+   it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
+   In other cases, it's based on the input file's stem. For example:
 
-* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
-  ``out.opt.yaml``
+   * ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
+ ``out.opt.yaml``
 
-* ``clang -fsave-optimization-record in.c -o out`` will generate
-  ``in.opt.yaml``
+   * ``clang -fsave-optimization-record in.c -o out`` will generate
+ ``in.opt.yaml``
 
-Compiling for multiple architectures will use the following scheme:
+   Compiling for multiple architectures will use the following scheme:
 
-``-.opt.``
+   ``-.opt.``
 
-Note that this is only allowed on Darwin platforms and is incompatible with
-passing multiple ``-arch `` options.
+   Note that this is only allowed on Darwin platforms and is incompatible with
+   passing multiple ``-arch `` options.
 
-When targeting (Thin)LTO, the base is derived from the output filename, and
-the extension is not dropped.
+   When targeting (Thin)LTO, the base is derived from the output filename, and
+   the extension is not dropped.
 
-When targeting ThinLTO, the following scheme is used:
+   When targeting ThinLTO, the following scheme is used:
 
-``.opt..thin..``
+   ``.opt..thin..``
 
 .. _opt_foptimization-record-file:
 



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


[clang] a8c678c - [Remarks][Driver][NFC] Make shouldEmitRemarks more available in the Driver

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T14:31:41-08:00
New Revision: a8c678cb9a90c4f82505f573e9b9fa23fec93a64

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

LOG: [Remarks][Driver][NFC] Make shouldEmitRemarks more available in the Driver

Move the function to Driver.h so that it can be re-used in other places.

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 64f1eb8cb5d7..d667fcb1efef 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -620,6 +620,9 @@ class Driver {
 /// And False otherwise.
 bool isOptimizationLevelFast(const llvm::opt::ArgList );
 
+/// \return True if the argument combination will end up generating remarks.
+bool willEmitRemarks(const llvm::opt::ArgList );
+
 } // end namespace driver
 } // end namespace clang
 

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f2b234315512..35e7998bf22f 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5060,3 +5060,26 @@ Driver::getIncludeExcludeOptionFlagMasks(bool 
IsClCompatMode) const {
 bool clang::driver::isOptimizationLevelFast(const ArgList ) {
   return Args.hasFlag(options::OPT_Ofast, options::OPT_O_Group, false);
 }
+
+bool clang::driver::willEmitRemarks(const ArgList ) {
+  // -fsave-optimization-record enables it.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -fsave-optimization-record= enables it as well.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -foptimization-record-file alone enables it too.
+  if (Args.hasFlag(options::OPT_foptimization_record_file_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -foptimization-record-passes alone enables it too.
+  if (Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+  return false;
+}

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5bf0efcf0503..9840acafd6ea 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1415,29 +1415,6 @@ static bool isNoCommonDefault(const llvm::Triple 
) {
   }
 }
 
-static bool shouldEmitRemarks(const ArgList ) {
-  // -fsave-optimization-record enables it.
-  if (Args.hasFlag(options::OPT_fsave_optimization_record,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-
-  // -fsave-optimization-record= enables it as well.
-  if (Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-
-  // -foptimization-record-file alone enables it too.
-  if (Args.hasFlag(options::OPT_foptimization_record_file_EQ,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-
-  // -foptimization-record-passes alone enables it too.
-  if (Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
-   options::OPT_fno_save_optimization_record, false))
-return true;
-  return false;
-}
-
 static bool hasMultipleInvocations(const llvm::Triple ,
const ArgList ) {
   // Supported only on Darwin where we invoke the compiler multiple times
@@ -3718,7 +3695,7 @@ static void RenderDebugOptions(const ToolChain , const 
Driver ,
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
   // When emitting remarks, we need at least debug lines in the output.
-  if (shouldEmitRemarks(Args) &&
+  if (willEmitRemarks(Args) &&
   DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
 DebugInfoKind = codegenoptions::DebugLineTablesOnly;
 
@@ -5546,7 +5523,7 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 CmdArgs.push_back("-fapple-pragma-pack");
 
   // Remarks can be enabled with any of the `-f.*optimization-record.*` flags.
-  if (shouldEmitRemarks(Args) && checkRemarksOptions(D, Args, Triple))
+  if (willEmitRemarks(Args) && checkRemarksOptions(D, Args, Triple))
 renderRemarksOptions(Args, CmdArgs, Triple, Input, JA);
 
   bool RewriteImports = Args.hasFlag(options::OPT_frewrite_imports,



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


[clang] d79b11f - [Remarks][Driver] Run dsymutil when remarks are enabled

2019-12-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-18T14:31:41-08:00
New Revision: d79b11fefb8e92660893b8ccf9e21d23668a6c73

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

LOG: [Remarks][Driver] Run dsymutil when remarks are enabled

When clang is invoked with a source file without -c or -S, it creates a
cc1 job, a linker job and if debug info is requested, a dsymutil job. In
case of remarks, we should also create a dsymutil job to avoid losing
the remarks that will be generated in a tempdir that gets removed.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/darwin-opt-record.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 35e7998bf22f..e718b8366df0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1990,8 +1990,9 @@ void Driver::BuildUniversalActions(Compilation , const 
ToolChain ,
 
 // Handle debug info queries.
 Arg *A = Args.getLastArg(options::OPT_g_Group);
-if (A && !A->getOption().matches(options::OPT_g0) &&
-!A->getOption().matches(options::OPT_gstabs) &&
+bool enablesDebugInfo = A && !A->getOption().matches(options::OPT_g0) &&
+!A->getOption().matches(options::OPT_gstabs);
+if ((enablesDebugInfo || willEmitRemarks(Args)) &&
 ContainsCompileOrAssembleAction(Actions.back())) {
 
   // Add a 'dsymutil' step if necessary, when debug info is enabled and we

diff  --git a/clang/test/Driver/darwin-opt-record.c 
b/clang/test/Driver/darwin-opt-record.c
index 2238dfc6baf4..477307c8022f 100644
--- a/clang/test/Driver/darwin-opt-record.c
+++ b/clang/test/Driver/darwin-opt-record.c
@@ -2,6 +2,8 @@
 
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-fsave-optimization-record -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-MULTIPLE-ARCH
 // RUN: %clang -target x86_64-apple-darwin10 -### -c -o FOO 
-foptimization-record-file=tmp -arch x86_64 -arch x86_64h %s 2>&1 | FileCheck 
%s --check-prefix=CHECK-MULTIPLE-ARCH-ERROR
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-NO-G
+// RUN: %clang -target x86_64-apple-darwin10 -### -o FOO -g0 
-fsave-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-DSYMUTIL-G0
 //
 // CHECK-MULTIPLE-ARCH: "-cc1"
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
@@ -9,3 +11,14 @@
 // CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
 //
 // CHECK-MULTIPLE-ARCH-ERROR: cannot use '-foptimization-record-file' output 
with multiple -arch options
+//
+// CHECK-DSYMUTIL-NO-G: "-cc1"
+// CHECK-DSYMUTIL-NO-G: ld
+// CHECK-DSYMUTIL-NO-G: dsymutil
+//
+// Even in the presence of -g0, -fsave-optimization-record implies
+// -gline-tables-only and would need -fno-save-optimization-record to
+// completely disable it.
+// CHECK-DSYMUTIL-G0: "-cc1"
+// CHECK-DSYMUTIL-G0: ld
+// CHECK-DSYMUTIL-G0: dsymutil



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


[clang] 60590b1 - [Remarks][Driver] Ask for line tables when remarks are enabled

2019-12-11 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-11T17:59:46-08:00
New Revision: 60590b149b33eb80d0b52c1c6723fe35817ee897

URL: 
https://github.com/llvm/llvm-project/commit/60590b149b33eb80d0b52c1c6723fe35817ee897
DIFF: 
https://github.com/llvm/llvm-project/commit/60590b149b33eb80d0b52c1c6723fe35817ee897.diff

LOG: [Remarks][Driver] Ask for line tables when remarks are enabled

Serialized remarks contain debug locations for each remark, by storing a
file path, a line, and a column.

Also, remarks support being embedded in a .dSYM bundle using a separate
section in object files, that is found by `dsymutil` through the debug
map.

In order for tools to map addresses to source and display remarks in the
source, we need line tables, and in order for `dsymutil` to find the
object files containing the remark section, we need to keep the debug
map around.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c00d5d07bcf2..38c6acc85512 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3717,6 +3717,11 @@ static void RenderDebugOptions(const ToolChain , 
const Driver ,
   // Adjust the debug info kind for the given toolchain.
   TC.adjustDebugInfoKind(DebugInfoKind, Args);
 
+  // When emitting remarks, we need at least debug lines in the output.
+  if (shouldEmitRemarks(Args) &&
+  DebugInfoKind <= codegenoptions::DebugDirectivesOnly)
+DebugInfoKind = codegenoptions::DebugLineTablesOnly;
+
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DWARFVersion,
   DebuggerTuning);
 

diff  --git a/clang/test/Driver/debug-options.c 
b/clang/test/Driver/debug-options.c
index aacc40f780d6..acbc056573ec 100644
--- a/clang/test/Driver/debug-options.c
+++ b/clang/test/Driver/debug-options.c
@@ -64,6 +64,12 @@
 // RUN: %clang -### -c -g %s -target arm64-apple-tvos9.0 2>&1 \
 // RUN: | FileCheck -check-prefix=G_STANDALONE \
 // RUN: -check-prefix=G_DWARF4 %s
+// RUN: %clang -### -c -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=GLTO_ONLY %s
+// RUN: %clang -### -c -g -fsave-optimization-record %s \
+// RUN:-target x86_64-apple-darwin 2>&1 \
+// RUN: | FileCheck -check-prefix=G_STANDALONE %s
 
 // FreeBSD.
 // RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \



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


[clang] 3bd7cbb - [Remarks][Docs] Enhance documentation for opt-remarks driver options

2019-12-10 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-10T13:19:49-08:00
New Revision: 3bd7cbb90cdb9cf2ca481107ec66a75d9c885782

URL: 
https://github.com/llvm/llvm-project/commit/3bd7cbb90cdb9cf2ca481107ec66a75d9c885782
DIFF: 
https://github.com/llvm/llvm-project/commit/3bd7cbb90cdb9cf2ca481107ec66a75d9c885782.diff

LOG: [Remarks][Docs] Enhance documentation for opt-remarks driver options

Add better documentation about the naming scheme, add a few more
explicit descriptions and make the sphinx look better.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/docs/UsersManual.rst
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index 7047cd9bb7b3..5b8a96b61b3d 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1699,9 +1699,14 @@ Emit OpenMP code only for SIMD-based constructs.
 
 .. option:: -foperator-arrow-depth=
 
-.. option:: -foptimization-record-file=
+.. option:: -foptimization-record-file=
 
-Specify the output name of the file containing the optimization remarks. 
Implies -fsave-optimization-record. On Darwin platforms, this cannot be used 
with multiple -arch  options.
+Implies -fsave-optimization-record. On Darwin platforms, this
+  cannot be used with multiple -arch  options.
+
+.. option:: -foptimization-record-passes=
+
+Only include passes which match a specified regular expression in the 
generated optimization record (by default, include all passes)
 
 .. option:: -foptimize-sibling-calls, -fno-optimize-sibling-calls
 
@@ -1834,6 +1839,12 @@ Turn on loop reroller
 
 Generate a YAML optimization record file
 
+.. program:: clang1
+.. option:: -fsave-optimization-record=
+.. program:: clang
+
+Generate an optimization record file in a specific format.
+
 .. option:: -fseh-exceptions
 
 Use SEH style exceptions

diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 62e2575c6b26..87434200e777 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -324,9 +324,10 @@ output format of the diagnostics that it generates.
 
 .. _opt_fsave-optimization-record:
 
-.. option:: -fsave-optimization-record[=]
+.. option:: -f[no-]save-optimization-record[=]
 
-   Write optimization remarks to a separate file.
+   Enable optimization remarks during compilation and write them to a separate
+   file.
 
This option, which defaults to off, controls whether Clang writes
optimization reports to a separate file. By recording diagnostics in a file,
@@ -345,20 +346,45 @@ output format of the diagnostics that it generates.
   ``-fsave-optimization-record=bitstream``: A binary format based on LLVM
   Bitstream.
 
+The output file is controlled by :ref:`-foptimization-record-file 
`.
+
+In the absence of an explicit output file, the file is chosen using the
+following scheme:
+
+``.opt.``
+
+where  is based on the output file of the compilation (whether
+it's explicitly specified through `-o` or not) when used with `-c` or `-S`.
+In other cases, it's based on the input file's stem. For example:
+
+* ``clang -fsave-optimization-record -c in.c -o out.o`` will generate
+  ``out.opt.yaml``
+
+* ``clang -fsave-optimization-record in.c -o out`` will generate
+  ``in.opt.yaml``
+
+Compiling for multiple architectures will use the following scheme:
+
+``-.opt.``
+
+Note that this is only allowed on Darwin platforms and is incompatible with
+passing multiple ``-arch `` options.
+
+When targeting (Thin)LTO, the base is derived from the output filename, and
+the extension is not dropped.
+
+When targeting ThinLTO, the following scheme is used:
+
+``.opt..thin..``
+
 .. _opt_foptimization-record-file:
 
 **-foptimization-record-file**
-   Control the file to which optimization reports are written.
-
-   When optimization reports are being output (see
-   :ref:`-fsave-optimization-record `), this
-   option controls the file to which those reports are written.
+   Control the file to which optimization reports are written. This implies
+   :ref:`-fsave-optimization-record `.
 
-   If this option is not used, optimization records are output to a file named
-   after the primary file being compiled. If that's "foo.c", for example,
-   optimization records are output to "foo.opt.yaml". If a specific
-   serialization format is specified, the file will be named
-   "foo.opt.".
+On Darwin platforms, this is incompatible with passing multiple
+``-arch `` options.
 
 .. _opt_foptimization-record-passes:
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 8965131b9001..6f404d1f2ea5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1800,16 

[clang] ae09dd8 - [Remarks][Driver] Error on -foptimization-record-file with multiple -arch options

2019-12-09 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-12-09T20:39:26-08:00
New Revision: ae09dd86a9b7f43543baa92d27c9382099691088

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

LOG: [Remarks][Driver] Error on -foptimization-record-file with multiple -arch 
options

This adds a check for the usage of -foptimization-record-file with
multiple -arch options. This is not permitted since it would require us
to rename the file requested by the user to avoid overwriting it for the
second cc1 invocation.

Added: 


Modified: 
clang/docs/ClangCommandLineReference.rst
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/darwin-opt-record.c

Removed: 




diff  --git a/clang/docs/ClangCommandLineReference.rst 
b/clang/docs/ClangCommandLineReference.rst
index e8d561fae956..7047cd9bb7b3 100644
--- a/clang/docs/ClangCommandLineReference.rst
+++ b/clang/docs/ClangCommandLineReference.rst
@@ -1701,7 +1701,7 @@ Emit OpenMP code only for SIMD-based constructs.
 
 .. option:: -foptimization-record-file=
 
-Specify the file name of any generated YAML optimization record
+Specify the output name of the file containing the optimization remarks. 
Implies -fsave-optimization-record. On Darwin platforms, this cannot be used 
with multiple -arch  options.
 
 .. option:: -foptimize-sibling-calls, -fno-optimize-sibling-calls
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 7fb1c846e0b2..b4621a0fcc81 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1415,6 +1415,132 @@ static bool isNoCommonDefault(const llvm::Triple 
) {
   }
 }
 
+static bool shouldEmitRemarks(const ArgList ) {
+  // -fsave-optimization-record enables it.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -fsave-optimization-record= enables it as well.
+  if (Args.hasFlag(options::OPT_fsave_optimization_record_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -foptimization-record-file alone enables it too.
+  if (Args.hasFlag(options::OPT_foptimization_record_file_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+
+  // -foptimization-record-passes alone enables it too.
+  if (Args.hasFlag(options::OPT_foptimization_record_passes_EQ,
+   options::OPT_fno_save_optimization_record, false))
+return true;
+  return false;
+}
+
+static bool hasMultipleInvocations(const llvm::Triple ,
+   const ArgList ) {
+  // Supported only on Darwin where we invoke the compiler multiple times
+  // followed by an invocation to lipo.
+  if (!Triple.isOSDarwin())
+return false;
+  // If more than one "-arch " is specified, we're targeting multiple
+  // architectures resulting in a fat binary.
+  return Args.getAllArgValues(options::OPT_arch).size() > 1;
+}
+
+static bool checkRemarksOptions(const Driver , const ArgList ,
+const llvm::Triple ) {
+  // When enabling remarks, we need to error if:
+  // * The remark file is specified but we're targeting multiple architectures,
+  // which means more than one remark file is being generated.
+  bool hasMultipleInvocations = ::hasMultipleInvocations(Triple, Args);
+  bool hasExplicitOutputFile =
+  Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+  if (hasMultipleInvocations && hasExplicitOutputFile) {
+D.Diag(diag::err_drv_invalid_output_with_multiple_archs)
+<< "-foptimization-record-file";
+return false;
+  }
+  return true;
+}
+
+static void renderRemarksOptions(const ArgList , ArgStringList ,
+ const llvm::Triple ,
+ const InputInfo , const JobAction ) {
+  CmdArgs.push_back("-opt-record-file");
+
+  const Arg *A = Args.getLastArg(options::OPT_foptimization_record_file_EQ);
+  if (A) {
+CmdArgs.push_back(A->getValue());
+  } else {
+bool hasMultipleArchs =
+Triple.isOSDarwin() && // Only supported on Darwin platforms.
+Args.getAllArgValues(options::OPT_arch).size() > 1;
+SmallString<128> F;
+
+if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
+  if (Arg *FinalOutput = Args.getLastArg(options::OPT_o))
+F = FinalOutput->getValue();
+}
+
+if (F.empty()) {
+  // Use the input filename.
+  F = llvm::sys::path::stem(Input.getBaseInput());
+
+  // If we're compiling for an offload architecture (i.e. a CUDA device),
+  // we need to make the file name for the device compilation 
diff erent
+  // from the host compilation.
+  if 

Re: [clang] b4e2b11 - [Remarks][Driver] Use different remark files when targeting multiple architectures

2019-11-18 Thread Francis Visoiu Mistrih via cfe-commits
Thanks. I restricted this to darwin and moved the test to a separate file.

Re-landed here: e15b26fbbd90 Reland: [Remarks][Driver] Use different remark 
files when targeting multiple architectures

> On Nov 18, 2019, at 10:53 AM, Reid Kleckner  wrote:
> 
> I reverted this, the test fails for me locally. Does -arch work on non-Mac 
> targets?
> 
> On Mon, Nov 18, 2019 at 10:39 AM Francis Visoiu Mistrih via cfe-commits 
>  wrote:
> 
> Author: Francis Visoiu Mistrih
> Date: 2019-11-18T10:38:10-08:00
> New Revision: b4e2b112b58154a89171df39dae80044865ff4ff
> 
> URL: 
> https://github.com/llvm/llvm-project/commit/b4e2b112b58154a89171df39dae80044865ff4ff
> DIFF: 
> https://github.com/llvm/llvm-project/commit/b4e2b112b58154a89171df39dae80044865ff4ff.diff
> 
> LOG: [Remarks][Driver] Use different remark files when targeting multiple 
> architectures
> 
> When the driver is targeting multiple architectures at once, for things
> like Universal Mach-Os, we need to emit different remark files for each
> cc1 invocation to avoid overwriting the files from a different
> invocation.
> 
> For example:
> 
> $ clang -c -o foo.o -fsave-optimization-record -arch x86_64 -arch x86_64h
> 
> will create two remark files:
> 
> * foo-x86_64.opt.yaml
> * foo-x86_64h.opt.yaml
> 
> Added: 
> 
> 
> Modified: 
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/test/Driver/opt-record.c
> 
> Removed: 
> 
> 
> 
> 
> diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
> b/clang/lib/Driver/ToolChains/Clang.cpp
> index 2b1c24275e3d..f5591c48d4e0 100644
> --- a/clang/lib/Driver/ToolChains/Clang.cpp
> +++ b/clang/lib/Driver/ToolChains/Clang.cpp
> @@ -5403,6 +5403,8 @@ void Clang::ConstructJob(Compilation , const 
> JobAction ,
>  if (A) {
>CmdArgs.push_back(A->getValue());
>  } else {
> +  bool hasMultipleArchs =
> +  Args.getAllArgValues(options::OPT_arch).size() > 1;
>SmallString<128> F;
> 
>if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
> @@ -5427,6 +5429,22 @@ void Clang::ConstructJob(Compilation , const 
> JobAction ,
>  }
>}
> 
> +  // If we're having more than one "-arch", we should name the files
> +  // 
> diff erently so that every cc1 invocation writes to a 
> diff erent file.
> +  // We're doing that by appending "-" with "" being the arch
> +  // name from the triple.
> +  if (hasMultipleArchs) {
> +// First, remember the extension.
> +SmallString<64> OldExtension = llvm::sys::path::extension(F);
> +// then, remove it.
> +llvm::sys::path::replace_extension(F, "");
> +// attach - to it.
> +F += "-";
> +F += Triple.getArchName();
> +// put back the extension.
> +llvm::sys::path::replace_extension(F, OldExtension);
> +  }
> +
>std::string Extension = "opt.";
>if (const Arg *A =
>Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
> 
> diff  --git a/clang/test/Driver/opt-record.c b/clang/test/Driver/opt-record.c
> index 062d0acc17da..d8d2aa53ed40 100644
> --- a/clang/test/Driver/opt-record.c
> +++ b/clang/test/Driver/opt-record.c
> @@ -18,6 +18,7 @@
>  // RUN: %clang -### -S -o FOO -fsave-optimization-record 
> -fsave-optimization-record=some-format %s 2>&1 | FileCheck %s 
> -check-prefix=CHECK-EQ-FORMAT
>  // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format %s 2>&1 
> | FileCheck %s -check-prefix=CHECK-EQ-FORMAT
>  // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format 
> -fno-save-optimization-record %s 2>&1 | FileCheck %s 
> --check-prefix=CHECK-FOPT-DISABLE-FORMAT
> +// RUN: %clang -### -S -o FOO -fsave-optimization-record -arch x86_64 -arch 
> x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
>  //
>  // CHECK: "-cc1"
>  // CHECK: "-opt-record-file" "FOO.opt.yaml"
> @@ -41,3 +42,8 @@
>  // CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
> 
>  // CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"
> +
> +// CHECK-MULTIPLE-ARCH: "-cc1"
> +// CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
> +// CHECK-MULTIPLE-ARCH: "-cc1"
> +// CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"
> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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


[clang] e15b26f - Reland: [Remarks][Driver] Use different remark files when targeting multiple architectures

2019-11-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-11-18T11:17:38-08:00
New Revision: e15b26fbbd901315a1402f97e83abf29bdce9a9f

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

LOG: Reland: [Remarks][Driver] Use different remark files when targeting 
multiple architectures

When the driver is targeting multiple architectures at once, for things
like Universal Mach-Os, we need to emit different remark files for each
cc1 invocation to avoid overwriting the files from a different
invocation.

For example:

$ clang -c -o foo.o -fsave-optimization-record -arch x86_64 -arch x86_64h

will create two remark files:

* foo-x86_64.opt.yaml
* foo-x86_64h.opt.yaml

Added: 
clang/test/Driver/darwin-opt-record.c

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 6f25eea243ad..3e00c323fc65 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5218,6 +5218,9 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 if (A) {
   CmdArgs.push_back(A->getValue());
 } else {
+  bool hasMultipleArchs =
+  Triple.isOSDarwin() && // Only supported on Darwin platforms.
+  Args.getAllArgValues(options::OPT_arch).size() > 1;
   SmallString<128> F;
 
   if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
@@ -5242,6 +5245,22 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 }
   }
 
+  // If we're having more than one "-arch", we should name the files
+  // 
diff erently so that every cc1 invocation writes to a 
diff erent file.
+  // We're doing that by appending "-" with "" being the arch
+  // name from the triple.
+  if (hasMultipleArchs) {
+// First, remember the extension.
+SmallString<64> OldExtension = llvm::sys::path::extension(F);
+// then, remove it.
+llvm::sys::path::replace_extension(F, "");
+// attach - to it.
+F += "-";
+F += Triple.getArchName();
+// put back the extension.
+llvm::sys::path::replace_extension(F, OldExtension);
+  }
+
   std::string Extension = "opt.";
   if (const Arg *A =
   Args.getLastArg(options::OPT_fsave_optimization_record_EQ))

diff  --git a/clang/test/Driver/darwin-opt-record.c 
b/clang/test/Driver/darwin-opt-record.c
new file mode 100644
index ..ca0fad7ee16d
--- /dev/null
+++ b/clang/test/Driver/darwin-opt-record.c
@@ -0,0 +1,8 @@
+// REQUIRES: system-darwin
+
+// RUN: %clang -### -S -o FOO -fsave-optimization-record -arch x86_64 -arch 
x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
+//
+// CHECK-MULTIPLE-ARCH: "-cc1"
+// CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
+// CHECK-MULTIPLE-ARCH: "-cc1"
+// CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"



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


[clang] b4e2b11 - [Remarks][Driver] Use different remark files when targeting multiple architectures

2019-11-18 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-11-18T10:38:10-08:00
New Revision: b4e2b112b58154a89171df39dae80044865ff4ff

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

LOG: [Remarks][Driver] Use different remark files when targeting multiple 
architectures

When the driver is targeting multiple architectures at once, for things
like Universal Mach-Os, we need to emit different remark files for each
cc1 invocation to avoid overwriting the files from a different
invocation.

For example:

$ clang -c -o foo.o -fsave-optimization-record -arch x86_64 -arch x86_64h

will create two remark files:

* foo-x86_64.opt.yaml
* foo-x86_64h.opt.yaml

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/opt-record.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 2b1c24275e3d..f5591c48d4e0 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5403,6 +5403,8 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 if (A) {
   CmdArgs.push_back(A->getValue());
 } else {
+  bool hasMultipleArchs =
+  Args.getAllArgValues(options::OPT_arch).size() > 1;
   SmallString<128> F;
 
   if (Args.hasArg(options::OPT_c) || Args.hasArg(options::OPT_S)) {
@@ -5427,6 +5429,22 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 }
   }
 
+  // If we're having more than one "-arch", we should name the files
+  // 
diff erently so that every cc1 invocation writes to a 
diff erent file.
+  // We're doing that by appending "-" with "" being the arch
+  // name from the triple.
+  if (hasMultipleArchs) {
+// First, remember the extension.
+SmallString<64> OldExtension = llvm::sys::path::extension(F);
+// then, remove it.
+llvm::sys::path::replace_extension(F, "");
+// attach - to it.
+F += "-";
+F += Triple.getArchName();
+// put back the extension.
+llvm::sys::path::replace_extension(F, OldExtension);
+  }
+
   std::string Extension = "opt.";
   if (const Arg *A =
   Args.getLastArg(options::OPT_fsave_optimization_record_EQ))

diff  --git a/clang/test/Driver/opt-record.c b/clang/test/Driver/opt-record.c
index 062d0acc17da..d8d2aa53ed40 100644
--- a/clang/test/Driver/opt-record.c
+++ b/clang/test/Driver/opt-record.c
@@ -18,6 +18,7 @@
 // RUN: %clang -### -S -o FOO -fsave-optimization-record 
-fsave-optimization-record=some-format %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-EQ-FORMAT
 // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format %s 2>&1 | 
FileCheck %s -check-prefix=CHECK-EQ-FORMAT
 // RUN: %clang -### -S -o FOO -fsave-optimization-record=some-format 
-fno-save-optimization-record %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-FOPT-DISABLE-FORMAT
+// RUN: %clang -### -S -o FOO -fsave-optimization-record -arch x86_64 -arch 
x86_64h %s 2>&1 | FileCheck %s --check-prefix=CHECK-MULTIPLE-ARCH
 //
 // CHECK: "-cc1"
 // CHECK: "-opt-record-file" "FOO.opt.yaml"
@@ -41,3 +42,8 @@
 // CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
 
 // CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"
+
+// CHECK-MULTIPLE-ARCH: "-cc1"
+// CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64.opt.yaml"
+// CHECK-MULTIPLE-ARCH: "-cc1"
+// CHECK-MULTIPLE-ARCH: "-opt-record-file" "FOO-x86_64h.opt.yaml"



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


[clang] f5094e1 - [Remarks] Fix Sphinx formatting

2019-10-28 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-10-28T13:13:39-07:00
New Revision: f5094e182947710f0b8dd4fafd23fd66634a3f19

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

LOG: [Remarks] Fix Sphinx formatting

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 230dbd94201b..714681d7f4ce 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -339,6 +339,9 @@ output format of the diagnostics that it generates.
-  .. _opt_fsave_optimization_record_yaml:
 
   ``-fsave-optimization-record=yaml``: A structured YAML format.
+
+   -  .. _opt_fsave_optimization_record_bitstream:
+
   ``-fsave-optimization-record=bitstream``: A binary format based on LLVM
   Bitstream.
 



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


[clang] 025166c - [Remarks] Add bitstream to the list of supported formats in clang

2019-10-28 Thread Francis Visoiu Mistrih via cfe-commits

Author: Francis Visoiu Mistrih
Date: 2019-10-28T13:08:05-07:00
New Revision: 025166cf48002317086db84f3a6eb7a2e2c10df2

URL: 
https://github.com/llvm/llvm-project/commit/025166cf48002317086db84f3a6eb7a2e2c10df2
DIFF: 
https://github.com/llvm/llvm-project/commit/025166cf48002317086db84f3a6eb7a2e2c10df2.diff

LOG: [Remarks] Add bitstream to the list of supported formats in clang

Added: 


Modified: 
clang/docs/UsersManual.rst

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index de28d7767151..230dbd94201b 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -339,6 +339,8 @@ output format of the diagnostics that it generates.
-  .. _opt_fsave_optimization_record_yaml:
 
   ``-fsave-optimization-record=yaml``: A structured YAML format.
+  ``-fsave-optimization-record=bitstream``: A binary format based on LLVM
+  Bitstream.
 
 .. _opt_foptimization-record-file:
 



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


r374126 - [IRGen] Emit lifetime markers for temporary struct allocas

2019-10-08 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Oct  8 15:10:38 2019
New Revision: 374126

URL: http://llvm.org/viewvc/llvm-project?rev=374126=rev
Log:
[IRGen] Emit lifetime markers for temporary struct allocas

When passing arguments using temporary allocas, we need to add the
appropriate lifetime markers so that the stack coloring passes can
re-use the stack space.

This patch keeps track of all the lifetime.start calls emited before the
codegened call, and adds the corresponding lifetime.end calls after the
call.

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

Added:
cfe/trunk/test/CodeGen/aarch64-byval-temp.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=374126=374125=374126=diff
==
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Oct  8 15:10:38 2019
@@ -3878,6 +3878,11 @@ RValue CodeGenFunction::EmitCall(const C
   Address swiftErrorTemp = Address::invalid();
   Address swiftErrorArg = Address::invalid();
 
+  // When passing arguments using temporary allocas, we need to add the
+  // appropriate lifetime markers. This vector keeps track of all the lifetime
+  // markers that need to be ended right after the call.
+  SmallVector CallLifetimeEndAfterCall;
+
   // Translate all of the arguments as necessary to match the IR lowering.
   assert(CallInfo.arg_size() == CallArgs.size() &&
  "Mismatch between function signature & arguments.");
@@ -3994,6 +3999,18 @@ RValue CodeGenFunction::EmitCall(const C
   Address AI = CreateMemTempWithoutCast(
   I->Ty, ArgInfo.getIndirectAlign(), "byval-temp");
   IRCallArgs[FirstIRArg] = AI.getPointer();
+
+  // Emit lifetime markers for the temporary alloca.
+  uint64_t ByvalTempElementSize =
+  CGM.getDataLayout().getTypeAllocSize(AI.getElementType());
+  llvm::Value *LifetimeSize =
+  EmitLifetimeStart(ByvalTempElementSize, AI.getPointer());
+
+  // Add cleanup code to emit the end lifetime marker after the call.
+  if (LifetimeSize) // In case we disabled lifetime markers.
+CallLifetimeEndAfterCall.emplace_back(AI, LifetimeSize);
+
+  // Generate the copy.
   I->copyInto(*this, AI);
 } else {
   // Skip the extra memcpy call.
@@ -4562,6 +4579,11 @@ RValue CodeGenFunction::EmitCall(const C
 }
   }
 
+  // Explicitly call CallLifetimeEnd::Emit just to re-use the code even though
+  // we can't use the full cleanup mechanism.
+  for (CallLifetimeEnd  : CallLifetimeEndAfterCall)
+LifetimeEnd.Emit(*this, /*Flags=*/{});
+
   return Ret;
 }
 

Added: cfe/trunk/test/CodeGen/aarch64-byval-temp.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-byval-temp.c?rev=374126=auto
==
--- cfe/trunk/test/CodeGen/aarch64-byval-temp.c (added)
+++ cfe/trunk/test/CodeGen/aarch64-byval-temp.c Tue Oct  8 15:10:38 2019
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -emit-llvm -triple arm64-- -o - %s -O0 | FileCheck %s 
--check-prefix=CHECK-O0
+// RUN: %clang_cc1 -emit-llvm -disable-llvm-optzns -triple arm64-- -o - %s -O3 
| FileCheck %s --check-prefix=CHECK-O3
+
+struct large {
+void* pointers[8];
+};
+
+void pass_large(struct large);
+
+// For arm64, we don't use byval to pass structs but instead we create
+// temporary allocas.
+//
+// Make sure we generate the appropriate lifetime markers for the temporary
+// allocas so that the optimizer can re-use stack slots if possible.
+void example() {
+struct large l = {0};
+pass_large(l);
+pass_large(l);
+}
+// CHECK-O0-LABEL: define void @example(
+// The alloca for the struct on the stack.
+// CHECK-O0: %[[l:[0-9A-Za-z-]+]] = alloca %struct.large, align 8
+// The alloca for the temporary stack space that we use to pass the argument.
+// CHECK-O0-NEXT: %[[byvaltemp:[0-9A-Za-z-]+]] = alloca %struct.large, align 8
+// Another one to pass the argument to the second function call.
+// CHECK-O0-NEXT: %[[byvaltemp1:[0-9A-Za-z-]+]] = alloca %struct.large, align 8
+// First, memset `l` to 0.
+// CHECK-O0-NEXT: %[[bitcastl:[0-9A-Za-z-]+]] = bitcast %struct.large* %[[l]] 
to i8*
+// CHECK-O0-NEXT: call void @llvm.memset.p0i8.i64(i8* align 8 %[[bitcastl]], 
i8 0, i64 64, i1 false)
+// Then, memcpy `l` to the temporary stack space.
+// CHECK-O0-NEXT: %[[src:[0-9A-Za-z-]+]] = bitcast %struct.large* 
%[[byvaltemp]] to i8*
+// CHECK-O0-NEXT: %[[dst:[0-9A-Za-z-]+]] = bitcast %struct.large* %[[l]] to i8*
+// CHECK-O0-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 8 %[[src]], 
i8* align 8 %[[dst]], i64 64, i1 false)
+// Finally, call using a pointer to the temporary stack space.
+// CHECK-O0-NEXT: call void @pass_large(%struct.large* %[[byvaltemp]])
+// Now, do the same for 

r365405 - [Frontend] Explicitly include Bitstream/BitCodes.h and BitstreamWriter.h

2019-07-08 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Mon Jul  8 16:02:50 2019
New Revision: 365405

URL: http://llvm.org/viewvc/llvm-project?rev=365405=rev
Log:
[Frontend] Explicitly include Bitstream/BitCodes.h and BitstreamWriter.h

This fixes a modules issue:

error: declaration of 'bitc' must be imported from module
'Clang_Serialization.ASTBitCodes' before it is required
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);

Modified:
cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp

Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=365405=365404=365405=diff
==
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Mon Jul  8 16:02:50 
2019
@@ -20,6 +20,8 @@
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Bitstream/BitCodes.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 


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


r365091 - [Bitcode] Move Bitstream to a separate library

2019-07-03 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Jul  3 15:40:07 2019
New Revision: 365091

URL: http://llvm.org/viewvc/llvm-project?rev=365091=rev
Log:
[Bitcode] Move Bitstream to a separate library

This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/.

This is needed to avoid a circular dependency when using the bitstream
code for parsing optimization remarks.

Since Bitcode uses Core for the IR part:

libLLVMRemarks -> Bitcode -> Core

and Core uses libLLVMRemarks to generate remarks (see
IR/RemarkStreamer.cpp):

Core -> libLLVMRemarks

we need to separate the Bitstream and Bitcode part.

For clang-doc, it seems that it doesn't need the whole bitcode layer, so
I updated the CMake to only use the bitstream part.

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

Modified:
cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h
cfe/trunk/include/clang/Frontend/SerializedDiagnosticReader.h
cfe/trunk/include/clang/Frontend/SerializedDiagnostics.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/include/clang/Serialization/ASTReader.h
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/include/clang/Serialization/Module.h
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/CMakeLists.txt
cfe/trunk/lib/Frontend/SerializedDiagnosticReader.cpp
cfe/trunk/lib/Frontend/TestModuleFileExtension.cpp
cfe/trunk/lib/Frontend/TestModuleFileExtension.h
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/lib/Serialization/CMakeLists.txt
cfe/trunk/lib/Serialization/GeneratePCH.cpp
cfe/trunk/lib/Serialization/GlobalModuleIndex.cpp
cfe/trunk/lib/Serialization/PCHContainerOperations.cpp
cfe/trunk/tools/libclang/CXLoadedDiagnostic.cpp
cfe/trunk/unittests/Serialization/CMakeLists.txt

Modified: cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h?rev=365091=365090=365091=diff
==
--- cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h (original)
+++ cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h Wed Jul  3 
15:40:07 2019
@@ -11,7 +11,7 @@
 
 #include "clang/Basic/LLVM.h"
 #include "clang/Frontend/SerializedDiagnostics.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
 
 namespace llvm {
 class raw_ostream;

Modified: cfe/trunk/include/clang/Frontend/SerializedDiagnosticReader.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/SerializedDiagnosticReader.h?rev=365091=365090=365091=diff
==
--- cfe/trunk/include/clang/Frontend/SerializedDiagnosticReader.h (original)
+++ cfe/trunk/include/clang/Frontend/SerializedDiagnosticReader.h Wed Jul  3 
15:40:07 2019
@@ -10,7 +10,7 @@
 #define LLVM_CLANG_FRONTEND_SERIALIZEDDIAGNOSTICREADER_H
 
 #include "clang/Basic/LLVM.h"
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/ErrorOr.h"
 #include 

Modified: cfe/trunk/include/clang/Frontend/SerializedDiagnostics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/SerializedDiagnostics.h?rev=365091=365090=365091=diff
==
--- cfe/trunk/include/clang/Frontend/SerializedDiagnostics.h (original)
+++ cfe/trunk/include/clang/Frontend/SerializedDiagnostics.h Wed Jul  3 
15:40:07 2019
@@ -9,7 +9,7 @@
 #ifndef LLVM_CLANG_FRONTEND_SERIALIZE_DIAGNOSTICS_H_
 #define LLVM_CLANG_FRONTEND_SERIALIZE_DIAGNOSTICS_H_
 
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
 
 namespace clang {
 namespace serialized_diags {

Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=365091=365090=365091=diff
==
--- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Jul  3 15:40:07 2019
@@ -23,7 +23,7 @@
 #include "clang/Basic/OperatorKinds.h"
 #include "clang/Basic/SourceLocation.h"
 #include "llvm/ADT/DenseMapInfo.h"
-#include "llvm/Bitcode/BitCodes.h"
+#include "llvm/Bitstream/BitCodes.h"
 #include 
 #include 
 

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: 

[clang-tools-extra] r365091 - [Bitcode] Move Bitstream to a separate library

2019-07-03 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Jul  3 15:40:07 2019
New Revision: 365091

URL: http://llvm.org/viewvc/llvm-project?rev=365091=rev
Log:
[Bitcode] Move Bitstream to a separate library

This moves Bitcode/Bitstream*, Bitcode/BitCodes.h to Bitstream/.

This is needed to avoid a circular dependency when using the bitstream
code for parsing optimization remarks.

Since Bitcode uses Core for the IR part:

libLLVMRemarks -> Bitcode -> Core

and Core uses libLLVMRemarks to generate remarks (see
IR/RemarkStreamer.cpp):

Core -> libLLVMRemarks

we need to separate the Bitstream and Bitcode part.

For clang-doc, it seems that it doesn't need the whole bitcode layer, so
I updated the CMake to only use the bitstream part.

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

Modified:
clang-tools-extra/trunk/clang-doc/BitcodeReader.h
clang-tools-extra/trunk/clang-doc/BitcodeWriter.h
clang-tools-extra/trunk/clang-doc/CMakeLists.txt
clang-tools-extra/trunk/unittests/clang-doc/BitcodeTest.cpp
clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt

Modified: clang-tools-extra/trunk/clang-doc/BitcodeReader.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/BitcodeReader.h?rev=365091=365090=365091=diff
==
--- clang-tools-extra/trunk/clang-doc/BitcodeReader.h (original)
+++ clang-tools-extra/trunk/clang-doc/BitcodeReader.h Wed Jul  3 15:40:07 2019
@@ -20,7 +20,7 @@
 #include "clang/AST/AST.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Bitcode/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamReader.h"
 #include "llvm/Support/Error.h"
 
 namespace clang {

Modified: clang-tools-extra/trunk/clang-doc/BitcodeWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/BitcodeWriter.h?rev=365091=365090=365091=diff
==
--- clang-tools-extra/trunk/clang-doc/BitcodeWriter.h (original)
+++ clang-tools-extra/trunk/clang-doc/BitcodeWriter.h Wed Jul  3 15:40:07 2019
@@ -20,7 +20,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
 #include 
 #include 
 

Modified: clang-tools-extra/trunk/clang-doc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/CMakeLists.txt?rev=365091=365090=365091=diff
==
--- clang-tools-extra/trunk/clang-doc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-doc/CMakeLists.txt Wed Jul  3 15:40:07 2019
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   support
-  BitReader
-  BitWriter
+  BitstreamReader
   )
 
 add_clang_library(clangDoc

Modified: clang-tools-extra/trunk/unittests/clang-doc/BitcodeTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/BitcodeTest.cpp?rev=365091=365090=365091=diff
==
--- clang-tools-extra/trunk/unittests/clang-doc/BitcodeTest.cpp (original)
+++ clang-tools-extra/trunk/unittests/clang-doc/BitcodeTest.cpp Wed Jul  3 
15:40:07 2019
@@ -10,8 +10,8 @@
 #include "BitcodeWriter.h"
 #include "ClangDocTest.h"
 #include "Representation.h"
-#include "llvm/Bitcode/BitstreamReader.h"
-#include "llvm/Bitcode/BitstreamWriter.h"
+#include "llvm/Bitstream/BitstreamReader.h"
+#include "llvm/Bitstream/BitstreamWriter.h"
 #include "gtest/gtest.h"
 
 namespace clang {

Modified: clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt?rev=365091=365090=365091=diff
==
--- clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/unittests/clang-doc/CMakeLists.txt Wed Jul  3 
15:40:07 2019
@@ -1,7 +1,6 @@
 set(LLVM_LINK_COMPONENTS
   support
-  BitReader
-  BitWriter
+  BitstreamReader
   )
 
 get_filename_component(CLANG_DOC_SOURCE_DIR


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


r363627 - [Remarks][Driver] Use the specified format in the remarks file extension

2019-06-17 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Mon Jun 17 15:49:38 2019
New Revision: 363627

URL: http://llvm.org/viewvc/llvm-project?rev=363627=rev
Log:
[Remarks][Driver] Use the specified format in the remarks file extension

By default, use `.opt.yaml`, but when a format is specified with
`-fsave-optimization-record=`, use `.opt.`.

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=363627=363626=363627=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jun 17 15:49:38 2019
@@ -351,7 +351,9 @@ output format of the diagnostics that it
 
If this option is not used, optimization records are output to a file named
after the primary file being compiled. If that's "foo.c", for example,
-   optimization records are output to "foo.opt.yaml".
+   optimization records are output to "foo.opt.yaml". If a specific
+   serialization format is specified, the file will be named
+   "foo.opt.".
 
 .. _opt_foptimization-record-passes:
 

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=363627=363626=363627=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Mon Jun 17 15:49:38 2019
@@ -5132,9 +5132,17 @@ void Clang::ConstructJob(Compilation ,
 }
   }
 
-  llvm::sys::path::replace_extension(F, "opt.yaml");
+  std::string Extension = "opt.";
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+Extension += A->getValue();
+  else
+Extension += "yaml";
+
+  llvm::sys::path::replace_extension(F, Extension);
   CmdArgs.push_back(Args.MakeArgString(F));
 }
+
 if (const Arg *A =
 Args.getLastArg(options::OPT_foptimization_record_passes_EQ)) {
   CmdArgs.push_back("-opt-record-passes");

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=363627=363626=363627=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Jun 17 15:49:38 2019
@@ -470,7 +470,13 @@ void darwin::Linker::ConstructJob(Compil
 
 SmallString<128> F;
 F = Output.getFilename();
-F += ".opt.yaml";
+F += ".opt.";
+if (const Arg *A =
+Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+  F += A->getValue();
+else
+  F += "yaml";
+
 CmdArgs.push_back(Args.MakeArgString(F));
 
 if (getLastProfileUseArg(Args)) {

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=363627=363626=363627=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Mon Jun 17 15:49:38 2019
@@ -333,7 +333,7 @@
 //
 // RUN: %clang -target x86_64-apple-darwin12 %t.o 
-fsave-optimization-record=some-format -### -o foo/bar.out 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_FORMAT %s < %t.log
-// PASS_REMARKS_WITH_FORMAT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" 
"foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-format=some-format"
+// PASS_REMARKS_WITH_FORMAT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" 
"foo/bar.out.opt.some-format" "-mllvm" "-lto-pass-remarks-format=some-format"
 
 // RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 
-fprofile-instr-generate -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log

Modified: cfe/trunk/test/Driver/opt-record.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/opt-record.c?rev=363627=363626=363627=diff
==
--- cfe/trunk/test/Driver/opt-record.c (original)
+++ cfe/trunk/test/Driver/opt-record.c Mon Jun 17 15:49:38 2019
@@ -37,6 +37,7 @@
 // CHECK-FOPT-DISABLE-PASSES-NOT: "-fno-save-optimization-record"
 
 // CHECK-EQ-FORMAT: "-cc1"
+// CHECK-EQ-FORMAT: "-opt-record-file" "FOO.opt.some-format"
 // CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
 
 // CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"


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


r363573 - [Remarks] Extend -fsave-optimization-record to specify the format

2019-06-17 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Mon Jun 17 09:06:00 2019
New Revision: 363573

URL: http://llvm.org/viewvc/llvm-project?rev=363573=rev
Log:
[Remarks] Extend -fsave-optimization-record to specify the format

Use -fsave-optimization-record= to specify a different format
than the default, which is YAML.

For now, only YAML is supported.

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/opt-record-MIR.c
cfe/trunk/test/CodeGen/opt-record.c
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=363573=363572=363573=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Mon Jun 17 09:06:00 2019
@@ -324,13 +324,21 @@ output format of the diagnostics that it
 
 .. _opt_fsave-optimization-record:
 
-**-fsave-optimization-record**
-   Write optimization remarks to a YAML file.
+.. option:: -fsave-optimization-record[=]
+
+   Write optimization remarks to a separate file.
 
This option, which defaults to off, controls whether Clang writes
-   optimization reports to a YAML file. By recording diagnostics in a file,
-   using a structured YAML format, users can parse or sort the remarks in a
-   convenient way.
+   optimization reports to a separate file. By recording diagnostics in a file,
+   users can parse or sort the remarks in a convenient way.
+
+   By default, the serialization format is YAML.
+
+   The supported serialization formats are:
+
+   -  .. _opt_fsave_optimization_record_yaml:
+
+  ``-fsave-optimization-record=yaml``: A structured YAML format.
 
 .. _opt_foptimization-record-file:
 

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=363573=363572=363573=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Mon Jun 17 09:06:00 2019
@@ -246,6 +246,9 @@ public:
   /// records.
   std::string OptRecordPasses;
 
+  /// The format used for serializing remarks (default: YAML)
+  std::string OptRecordFormat;
+
   /// The name of the partition that symbols are assigned to, specified with
   /// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
   std::string SymbolPartition;

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=363573=363572=363573=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Mon Jun 17 09:06:00 
2019
@@ -230,6 +230,8 @@ def err_drv_emit_llvm_link : Error<
"-emit-llvm cannot be used when linking">;
 def err_drv_optimization_remark_pattern : Error<
   "in pattern '%1': %0">;
+def err_drv_optimization_remark_format : Error<
+  "unknown remark serializer format: '%0'">;
 def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, 
please use [no]simd instead">;
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
 def err_drv_omp_host_ir_file_not_found : Error<

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=363573=363572=363573=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Jun 17 09:06:00 2019
@@ -636,6 +636,8 @@ def opt_record_file : Separate<["-"], "o
   HelpText<"File name to use for YAML optimization record output">;
 def opt_record_passes : Separate<["-"], "opt-record-passes">,
   HelpText<"Only record remark information for passes whose names match the 
given regular expression">;
+def opt_record_format : Separate<["-"], "opt-record-format">,
+  HelpText<"The format used for serializing remarks (default: YAML)">;
 
 def print_stats : Flag<["-"], "print-stats">,
   HelpText<"Print performance metrics and statistics">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 

r363463 - [Remarks][NFC] Improve testing and documentation of -foptimization-record-passes

2019-06-14 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Fri Jun 14 14:38:57 2019
New Revision: 363463

URL: http://llvm.org/viewvc/llvm-project?rev=363463=rev
Log:
[Remarks][NFC] Improve testing and documentation of -foptimization-record-passes

This adds:

* documentation to the user manual
* nicer error message
* test for the error case
* test for the gold plugin

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/test/CodeGen/opt-record.c

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=363463=363462=363463=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Fri Jun 14 14:38:57 2019
@@ -345,6 +345,18 @@ output format of the diagnostics that it
after the primary file being compiled. If that's "foo.c", for example,
optimization records are output to "foo.opt.yaml".
 
+.. _opt_foptimization-record-passes:
+
+**-foptimization-record-passes**
+   Only include passes which match a specified regular expression.
+
+   When optimization reports are being output (see
+   :ref:`-fsave-optimization-record `), this
+   option controls the passes that will be included in the final report.
+
+   If this option is not used, all the passes are included in the optimization
+   record.
+
 .. _opt_fdiagnostics-show-hotness:
 
 **-f[no-]diagnostics-show-hotness**

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=363463=363462=363463=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Fri Jun 14 14:38:57 
2019
@@ -229,7 +229,7 @@ def err_drv_gnustep_objc_runtime_incompa
 def err_drv_emit_llvm_link : Error<
"-emit-llvm cannot be used when linking">;
 def err_drv_optimization_remark_pattern : Error<
-  "%0 in '%1'">;
+  "in pattern '%1': %0">;
 def err_drv_no_neon_modifier : Error<"[no]neon is not accepted as modifier, 
please use [no]simd instead">;
 def err_drv_invalid_omp_target : Error<"OpenMP target is invalid: '%0'">;
 def err_drv_omp_host_ir_file_not_found : Error<

Modified: cfe/trunk/test/CodeGen/opt-record.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/opt-record.c?rev=363463=363462=363463=diff
==
--- cfe/trunk/test/CodeGen/opt-record.c (original)
+++ cfe/trunk/test/CodeGen/opt-record.c Fri Jun 14 14:38:57 2019
@@ -5,6 +5,7 @@
 // RUN: cat %t.yaml | FileCheck -check-prefix=CHECK -check-prefix=CHECK-PGO %s
 // RUN: %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 %s 
-o %t -dwarf-column-info -opt-record-file %t.yaml -opt-record-passes inline 
-emit-obj
 // RUN: cat %t.yaml | FileCheck -check-prefix=CHECK-PASSES %s
+// RUN: not %clang_cc1 -O3 -triple x86_64-unknown-linux-gnu -target-cpu x86-64 
%s -o %t -dwarf-column-info -opt-record-file %t.yaml -opt-record-passes "(foo" 
-emit-obj 2>&1 | FileCheck -check-prefix=CHECK-PATTERN-ERROR %s
 // REQUIRES: x86-registered-target
 
 void bar();
@@ -34,3 +35,5 @@ void Test(int *res, int *c, int *d, int
 // CHECK: Function:Test
 // CHECK-PGO: Hotness:
 // CHECK-PASSES-NOT: loop-vectorize
+
+// CHECK-PATTERN-ERROR: error: in pattern '(foo': parentheses not balanced


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


r363415 - Reland: [Remarks] Refactor optimization remarks setup

2019-06-14 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Fri Jun 14 09:20:51 2019
New Revision: 363415

URL: http://llvm.org/viewvc/llvm-project?rev=363415=rev
Log:
Reland: [Remarks] Refactor optimization remarks setup

* Add a common function to setup opt-remarks
* Rename common options to the same names
* Add error types to distinguish between file errors and regex errors

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=363415=363414=363415=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Jun 14 09:20:51 2019
@@ -262,35 +262,32 @@ namespace clang {
   Ctx.getDiagnosticHandler();
   Ctx.setDiagnosticHandler(llvm::make_unique(
 CodeGenOpts, this));
-  Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
-  if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
-Ctx.setDiagnosticsHotnessThreshold(
-CodeGenOpts.DiagnosticsHotnessThreshold);
 
-  std::unique_ptr OptRecordFile;
-  if (!CodeGenOpts.OptRecordFile.empty()) {
-std::error_code EC;
-OptRecordFile = llvm::make_unique(
-CodeGenOpts.OptRecordFile, EC, sys::fs::F_None);
-if (EC) {
-  Diags.Report(diag::err_cannot_open_file) <<
-CodeGenOpts.OptRecordFile << EC.message();
-  return;
-}
+  Expected> OptRecordFileOrErr =
+  setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
+   CodeGenOpts.OptRecordPasses,
+   CodeGenOpts.DiagnosticsWithHotness,
+   CodeGenOpts.DiagnosticsHotnessThreshold);
 
-Ctx.setRemarkStreamer(llvm::make_unique(
-CodeGenOpts.OptRecordFile,
-llvm::make_unique(OptRecordFile->os(;
-
-if (!CodeGenOpts.OptRecordPasses.empty())
-  if (Error E = Ctx.getRemarkStreamer()->setFilter(
-  CodeGenOpts.OptRecordPasses))
-Diags.Report(diag::err_drv_optimization_remark_pattern)
-<< toString(std::move(E)) << CodeGenOpts.OptRecordPasses;
-
-if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
-  Ctx.setDiagnosticsHotnessRequested(true);
+  if (Error E = OptRecordFileOrErr.takeError()) {
+handleAllErrors(
+std::move(E),
+[&](const RemarkSetupFileError ) {
+  Diags.Report(diag::err_cannot_open_file)
+  << CodeGenOpts.OptRecordFile << E.message();
+},
+[&](const RemarkSetupPatternError ) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << E.message() << CodeGenOpts.OptRecordPasses;
+});
+return;
   }
+  std::unique_ptr OptRecordFile =
+  std::move(*OptRecordFileOrErr);
+
+  if (OptRecordFile &&
+  CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+Ctx.setDiagnosticsHotnessRequested(true);
 
   // Link each LinkModule into our module.
   if (LinkInModules())


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


r363343 - Revert "[Remarks] Refactor optimization remarks setup"

2019-06-13 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Thu Jun 13 17:05:56 2019
New Revision: 363343

URL: http://llvm.org/viewvc/llvm-project?rev=363343=rev
Log:
Revert "[Remarks] Refactor optimization remarks setup"

This reverts commit 6e6e3af55bb97e1a4c97375c15a2b0099120c5a7.

This breaks greendragon.

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=363343=363342=363343=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Jun 13 17:05:56 2019
@@ -262,32 +262,35 @@ namespace clang {
   Ctx.getDiagnosticHandler();
   Ctx.setDiagnosticHandler(llvm::make_unique(
 CodeGenOpts, this));
+  Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
+  if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
+Ctx.setDiagnosticsHotnessThreshold(
+CodeGenOpts.DiagnosticsHotnessThreshold);
 
-  Expected> OptRecordFileOrErr =
-  setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
-   CodeGenOpts.OptRecordPasses,
-   CodeGenOpts.DiagnosticsWithHotness,
-   CodeGenOpts.DiagnosticsHotnessThreshold);
+  std::unique_ptr OptRecordFile;
+  if (!CodeGenOpts.OptRecordFile.empty()) {
+std::error_code EC;
+OptRecordFile = llvm::make_unique(
+CodeGenOpts.OptRecordFile, EC, sys::fs::F_None);
+if (EC) {
+  Diags.Report(diag::err_cannot_open_file) <<
+CodeGenOpts.OptRecordFile << EC.message();
+  return;
+}
 
-  if (Error E = OptRecordFileOrErr.takeError()) {
-handleAllErrors(
-std::move(E),
-[&](const RemarkSetupFileError ) {
-  Diags.Report(diag::err_cannot_open_file)
-  << CodeGenOpts.OptRecordFile << E.message();
-},
-[&](const RemarkSetupPatternError ) {
-  Diags.Report(diag::err_drv_optimization_remark_pattern)
-  << E.message() << CodeGenOpts.OptRecordPasses;
-});
-return;
-  }
-  std::unique_ptr OptRecordFile =
-  std::move(*OptRecordFileOrErr);
+Ctx.setRemarkStreamer(llvm::make_unique(
+CodeGenOpts.OptRecordFile,
+llvm::make_unique(OptRecordFile->os(;
+
+if (!CodeGenOpts.OptRecordPasses.empty())
+  if (Error E = Ctx.getRemarkStreamer()->setFilter(
+  CodeGenOpts.OptRecordPasses))
+Diags.Report(diag::err_drv_optimization_remark_pattern)
+<< toString(std::move(E)) << CodeGenOpts.OptRecordPasses;
 
-  if (OptRecordFile &&
-  CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
-Ctx.setDiagnosticsHotnessRequested(true);
+if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+  Ctx.setDiagnosticsHotnessRequested(true);
+  }
 
   // Link each LinkModule into our module.
   if (LinkInModules())


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


r363328 - [Remarks] Refactor optimization remarks setup

2019-06-13 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Thu Jun 13 14:46:57 2019
New Revision: 363328

URL: http://llvm.org/viewvc/llvm-project?rev=363328=rev
Log:
[Remarks] Refactor optimization remarks setup

* Add a common function to setup opt-remarks
* Rename common options to the same names
* Add error types to distinguish between file errors and regex errors

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=363328=363327=363328=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Jun 13 14:46:57 2019
@@ -262,35 +262,32 @@ namespace clang {
   Ctx.getDiagnosticHandler();
   Ctx.setDiagnosticHandler(llvm::make_unique(
 CodeGenOpts, this));
-  Ctx.setDiagnosticsHotnessRequested(CodeGenOpts.DiagnosticsWithHotness);
-  if (CodeGenOpts.DiagnosticsHotnessThreshold != 0)
-Ctx.setDiagnosticsHotnessThreshold(
-CodeGenOpts.DiagnosticsHotnessThreshold);
 
-  std::unique_ptr OptRecordFile;
-  if (!CodeGenOpts.OptRecordFile.empty()) {
-std::error_code EC;
-OptRecordFile = llvm::make_unique(
-CodeGenOpts.OptRecordFile, EC, sys::fs::F_None);
-if (EC) {
-  Diags.Report(diag::err_cannot_open_file) <<
-CodeGenOpts.OptRecordFile << EC.message();
-  return;
-}
+  Expected> OptRecordFileOrErr =
+  setupOptimizationRemarks(Ctx, CodeGenOpts.OptRecordFile,
+   CodeGenOpts.OptRecordPasses,
+   CodeGenOpts.DiagnosticsWithHotness,
+   CodeGenOpts.DiagnosticsHotnessThreshold);
 
-Ctx.setRemarkStreamer(llvm::make_unique(
-CodeGenOpts.OptRecordFile,
-llvm::make_unique(OptRecordFile->os(;
-
-if (!CodeGenOpts.OptRecordPasses.empty())
-  if (Error E = Ctx.getRemarkStreamer()->setFilter(
-  CodeGenOpts.OptRecordPasses))
-Diags.Report(diag::err_drv_optimization_remark_pattern)
-<< toString(std::move(E)) << CodeGenOpts.OptRecordPasses;
-
-if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
-  Ctx.setDiagnosticsHotnessRequested(true);
+  if (Error E = OptRecordFileOrErr.takeError()) {
+handleAllErrors(
+std::move(E),
+[&](const RemarkSetupFileError ) {
+  Diags.Report(diag::err_cannot_open_file)
+  << CodeGenOpts.OptRecordFile << E.message();
+},
+[&](const RemarkSetupPatternError ) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << E.message() << CodeGenOpts.OptRecordPasses;
+});
+return;
   }
+  std::unique_ptr OptRecordFile =
+  std::move(*OptRecordFileOrErr);
+
+  if (OptRecordFile &&
+  CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
+Ctx.setDiagnosticsHotnessRequested(true);
 
   // Link each LinkModule into our module.
   if (LinkInModules())


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


r362160 - [Remarks][NFC] Move the serialization to lib/Remarks

2019-05-30 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Thu May 30 14:45:59 2019
New Revision: 362160

URL: http://llvm.org/viewvc/llvm-project?rev=362160=rev
Log:
[Remarks][NFC] Move the serialization to lib/Remarks

Separate the remark serialization to YAML from the LLVM Diagnostics.

This adds a new serialization abstraction: remarks::Serializer. It's
completely independent from lib/IR and it provides an easy way to
replace YAML by providing a new remarks::Serializer.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=362160=362159=362160=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu May 30 14:45:59 2019
@@ -279,7 +279,8 @@ namespace clang {
 }
 
 Ctx.setRemarkStreamer(llvm::make_unique(
-CodeGenOpts.OptRecordFile, OptRecordFile->os()));
+CodeGenOpts.OptRecordFile,
+llvm::make_unique(OptRecordFile->os(;
 
 if (!CodeGenOpts.OptRecordPasses.empty())
   if (Error E = Ctx.getRemarkStreamer()->setFilter(


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


r355984 - Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"

2019-03-12 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Mar 12 14:22:27 2019
New Revision: 355984

URL: http://llvm.org/viewvc/llvm-project?rev=355984=rev
Log:
Reland "[Remarks] Add -foptimization-record-passes to filter remark emission"

Currently we have -Rpass for filtering the remarks that are displayed as
diagnostics, but when using -fsave-optimization-record, there is no way
to filter the remarks while generating them.

This adds support for filtering remarks by passes using a regex.
Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline`

will only emit the remarks coming from the pass `inline`.

This adds:

* `-fsave-optimization-record` to the driver
* `-opt-record-passes` to cc1
* `-lto-pass-remarks-filter` to the LTOCodeGenerator
* `--opt-remarks-passes` to lld
* `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2
* `-opt-remarks-passes` to gold-plugin

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

Original llvm-svn: 355964

Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/opt-record-MIR.c
cfe/trunk/test/CodeGen/opt-record.c
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=355984=355983=355984=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Tue Mar 12 14:22:27 2019
@@ -238,6 +238,10 @@ public:
   /// records.
   std::string OptRecordFile;
 
+  /// The regex that filters the passes that should be saved to the 
optimization
+  /// records.
+  std::string OptRecordPasses;
+
   /// Regular expression to select optimizations for which we should enable
   /// optimization remarks. Transformation passes whose name matches this
   /// expression (and support this feature), will emit a diagnostic

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=355984=355983=355984=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Mar 12 14:22:27 2019
@@ -603,6 +603,8 @@ def arcmt_migrate : Flag<["-"], "arcmt-m
 
 def opt_record_file : Separate<["-"], "opt-record-file">,
   HelpText<"File name to use for YAML optimization record output">;
+def opt_record_passes : Separate<["-"], "opt-record-passes">,
+  HelpText<"Only record remark information for passes whose names match the 
given regular expression">;
 
 def print_stats : Flag<["-"], "print-stats">,
   HelpText<"Print performance metrics and statistics">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=355984=355983=355984=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 12 14:22:27 2019
@@ -1715,6 +1715,10 @@ def fno_save_optimization_record : Flag<
 def foptimization_record_file_EQ : Joined<["-"], "foptimization-record-file=">,
   Group,
   HelpText<"Specify the file name of any generated YAML optimization record">;
+def foptimization_record_passes_EQ : Joined<["-"], 
"foptimization-record-passes=">,
+  Group,
+  HelpText<"Only include passes which match a specified regular expression in 
the generated optimization record (by default, include all passes)">;
+
 
 def ftest_coverage : Flag<["-"], "ftest-coverage">, Group;
 def fvectorize : Flag<["-"], "fvectorize">, Group,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=355984=355983=355984=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Mar 12 14:22:27 2019
@@ -1340,6 +1340,7 @@ static void runThinLTOBackend(ModuleSumm
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
+  Conf.RemarksPasses = CGOpts.OptRecordPasses;
   Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 

r355976 - Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"

2019-03-12 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Mar 12 13:54:18 2019
New Revision: 355976

URL: http://llvm.org/viewvc/llvm-project?rev=355976=rev
Log:
Revert "[Remarks] Add -foptimization-record-passes to filter remark emission"

This reverts commit 20fff32b7d1f1a1bd417b22aa9f26ededd97a3e5.

Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/opt-record-MIR.c
cfe/trunk/test/CodeGen/opt-record.c
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=355976=355975=355976=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Tue Mar 12 13:54:18 2019
@@ -238,10 +238,6 @@ public:
   /// records.
   std::string OptRecordFile;
 
-  /// The regex that filters the passes that should be saved to the 
optimization
-  /// records.
-  std::string OptRecordPasses;
-
   /// Regular expression to select optimizations for which we should enable
   /// optimization remarks. Transformation passes whose name matches this
   /// expression (and support this feature), will emit a diagnostic

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=355976=355975=355976=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Mar 12 13:54:18 2019
@@ -603,8 +603,6 @@ def arcmt_migrate : Flag<["-"], "arcmt-m
 
 def opt_record_file : Separate<["-"], "opt-record-file">,
   HelpText<"File name to use for YAML optimization record output">;
-def opt_record_passes : Separate<["-"], "opt-record-passes">,
-  HelpText<"Only record remark information for passes whose names match the 
given regular expression">;
 
 def print_stats : Flag<["-"], "print-stats">,
   HelpText<"Print performance metrics and statistics">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=355976=355975=355976=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 12 13:54:18 2019
@@ -1715,10 +1715,6 @@ def fno_save_optimization_record : Flag<
 def foptimization_record_file_EQ : Joined<["-"], "foptimization-record-file=">,
   Group,
   HelpText<"Specify the file name of any generated YAML optimization record">;
-def foptimization_record_passes_EQ : Joined<["-"], 
"foptimization-record-passes=">,
-  Group,
-  HelpText<"Only include passes which match a specified regular expression in 
the generated optimization record (by default, include all passes)">;
-
 
 def ftest_coverage : Flag<["-"], "ftest-coverage">, Group;
 def fvectorize : Flag<["-"], "fvectorize">, Group,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=355976=355975=355976=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Mar 12 13:54:18 2019
@@ -1340,7 +1340,6 @@ static void runThinLTOBackend(ModuleSumm
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
-  Conf.RemarksPasses = CGOpts.OptRecordPasses;
   Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=355976=355975=355976=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Tue Mar 12 13:54:18 2019
@@ -19,7 +19,6 @@
 #include "clang/Basic/TargetInfo.h"
 #include "clang/CodeGen/BackendUtil.h"
 #include "clang/CodeGen/ModuleBuilder.h"
-#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendDiagnostic.h"
 #include "clang/Lex/Preprocessor.h"
@@ -281,12 +280,6 @@ namespace clang {
 Ctx.setRemarkStreamer(llvm::make_unique(
 CodeGenOpts.OptRecordFile, 

r355964 - [Remarks] Add -foptimization-record-passes to filter remark emission

2019-03-12 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Mar 12 13:28:50 2019
New Revision: 355964

URL: http://llvm.org/viewvc/llvm-project?rev=355964=rev
Log:
[Remarks] Add -foptimization-record-passes to filter remark emission

Currently we have -Rpass for filtering the remarks that are displayed as
diagnostics, but when using -fsave-optimization-record, there is no way
to filter the remarks while generating them.

This adds support for filtering remarks by passes using a regex.
Ex: `clang -fsave-optimization-record -foptimization-record-passes=inline`

will only emit the remarks coming from the pass `inline`.

This adds:

* `-fsave-optimization-record` to the driver
* `-opt-record-passes` to cc1
* `-lto-pass-remarks-filter` to the LTOCodeGenerator
* `--opt-remarks-passes` to lld
* `-pass-remarks-filter` to llc, opt, llvm-lto, llvm-lto2
* `-opt-remarks-passes` to gold-plugin

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

Modified:
cfe/trunk/include/clang/Basic/CodeGenOptions.h
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/opt-record-MIR.c
cfe/trunk/test/CodeGen/opt-record.c
cfe/trunk/test/Driver/darwin-ld.c
cfe/trunk/test/Driver/opt-record.c

Modified: cfe/trunk/include/clang/Basic/CodeGenOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/CodeGenOptions.h?rev=355964=355963=355964=diff
==
--- cfe/trunk/include/clang/Basic/CodeGenOptions.h (original)
+++ cfe/trunk/include/clang/Basic/CodeGenOptions.h Tue Mar 12 13:28:50 2019
@@ -238,6 +238,10 @@ public:
   /// records.
   std::string OptRecordFile;
 
+  /// The regex that filters the passes that should be saved to the 
optimization
+  /// records.
+  std::string OptRecordPasses;
+
   /// Regular expression to select optimizations for which we should enable
   /// optimization remarks. Transformation passes whose name matches this
   /// expression (and support this feature), will emit a diagnostic

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=355964=355963=355964=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Tue Mar 12 13:28:50 2019
@@ -603,6 +603,8 @@ def arcmt_migrate : Flag<["-"], "arcmt-m
 
 def opt_record_file : Separate<["-"], "opt-record-file">,
   HelpText<"File name to use for YAML optimization record output">;
+def opt_record_passes : Separate<["-"], "opt-record-passes">,
+  HelpText<"Only record remark information for passes whose names match the 
given regular expression">;
 
 def print_stats : Flag<["-"], "print-stats">,
   HelpText<"Print performance metrics and statistics">;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=355964=355963=355964=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Mar 12 13:28:50 2019
@@ -1715,6 +1715,10 @@ def fno_save_optimization_record : Flag<
 def foptimization_record_file_EQ : Joined<["-"], "foptimization-record-file=">,
   Group,
   HelpText<"Specify the file name of any generated YAML optimization record">;
+def foptimization_record_passes_EQ : Joined<["-"], 
"foptimization-record-passes=">,
+  Group,
+  HelpText<"Only include passes which match a specified regular expression in 
the generated optimization record (by default, include all passes)">;
+
 
 def ftest_coverage : Flag<["-"], "ftest-coverage">, Group;
 def fvectorize : Flag<["-"], "fvectorize">, Group,

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=355964=355963=355964=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Tue Mar 12 13:28:50 2019
@@ -1340,6 +1340,7 @@ static void runThinLTOBackend(ModuleSumm
   Conf.DebugPassManager = CGOpts.DebugPassManager;
   Conf.RemarksWithHotness = CGOpts.DiagnosticsWithHotness;
   Conf.RemarksFilename = CGOpts.OptRecordFile;
+  Conf.RemarksPasses = CGOpts.OptRecordPasses;
   Conf.DwoPath = CGOpts.SplitDwarfFile;
   switch (Action) {
   case Backend_EmitNothing:

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=355964=355963=355964=diff

r355514 - Reland "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer"

2019-03-06 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Mar  6 07:20:13 2019
New Revision: 355514

URL: http://llvm.org/viewvc/llvm-project?rev=355514=rev
Log:
Reland "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer"

This allows us to store more info about where we're emitting the remarks
without cluttering LLVMContext. This is needed for future support for
the remark section.

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

Original llvm-svn: 355507

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=355514=355513=355514=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Wed Mar  6 07:20:13 2019
@@ -30,6 +30,7 @@
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/RemarkStreamer.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/Pass.h"
@@ -276,8 +277,8 @@ namespace clang {
   return;
 }
 
-Ctx.setDiagnosticsOutputFile(
-llvm::make_unique(OptRecordFile->os()));
+Ctx.setRemarkStreamer(llvm::make_unique(
+CodeGenOpts.OptRecordFile, OptRecordFile->os()));
 
 if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
   Ctx.setDiagnosticsHotnessRequested(true);


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


r355511 - Revert "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer"

2019-03-06 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Mar  6 06:52:37 2019
New Revision: 355511

URL: http://llvm.org/viewvc/llvm-project?rev=355511=rev
Log:
Revert "[Remarks] Refactor remark diagnostic emission in a RemarkStreamer"

This reverts commit 2e8c4997a2089f8228c843fd81b148d903472e02.

Breaks bots.

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=355511=355510=355511=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Wed Mar  6 06:52:37 2019
@@ -30,7 +30,6 @@
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/IR/RemarkStreamer.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/Pass.h"
@@ -277,8 +276,8 @@ namespace clang {
   return;
 }
 
-Ctx.setRemarkStreamer(llvm::make_unique(
-CodeGenOpts.OptRecordFile, OptRecordFile->os()));
+Ctx.setDiagnosticsOutputFile(
+llvm::make_unique(OptRecordFile->os()));
 
 if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
   Ctx.setDiagnosticsHotnessRequested(true);


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


r355507 - [Remarks] Refactor remark diagnostic emission in a RemarkStreamer

2019-03-06 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Mar  6 06:32:08 2019
New Revision: 355507

URL: http://llvm.org/viewvc/llvm-project?rev=355507=rev
Log:
[Remarks] Refactor remark diagnostic emission in a RemarkStreamer

This allows us to store more info about where we're emitting the remarks
without cluttering LLVMContext. This is needed for future support for
the remark section.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenAction.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=355507=355506=355507=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Wed Mar  6 06:32:08 2019
@@ -30,6 +30,7 @@
 #include "llvm/IR/GlobalValue.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/RemarkStreamer.h"
 #include "llvm/IRReader/IRReader.h"
 #include "llvm/Linker/Linker.h"
 #include "llvm/Pass.h"
@@ -276,8 +277,8 @@ namespace clang {
   return;
 }
 
-Ctx.setDiagnosticsOutputFile(
-llvm::make_unique(OptRecordFile->os()));
+Ctx.setRemarkStreamer(llvm::make_unique(
+CodeGenOpts.OptRecordFile, OptRecordFile->os()));
 
 if (CodeGenOpts.getProfileUse() != CodeGenOptions::ProfileNone)
   Ctx.setDiagnosticsHotnessRequested(true);


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


r355440 - [cmake] Add libRemarks to LLVM_DISTRIBUTION_COMPONENTS

2019-03-05 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Mar  5 12:47:34 2019
New Revision: 355440

URL: http://llvm.org/viewvc/llvm-project?rev=355440=rev
Log:
[cmake] Add libRemarks to LLVM_DISTRIBUTION_COMPONENTS

Add this in the Apple-stage2.cmake to ship the remark tooling library
with the compiler.

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=355440=355439=355440=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue Mar  5 12:47:34 2019
@@ -62,6 +62,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   clang-format
   clang-resource-headers
   cxx-headers
+  Remarks
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")
 


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


Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-15 Thread Francis Visoiu Mistrih via cfe-commits


> On Feb 15, 2019, at 1:53 PM, Richard Smith  wrote:
> 
> On Fri, 15 Feb 2019 at 09:56, Richard Smith  <mailto:rich...@metafoo.co.uk>> wrote:
>> 
>> On Thu, 14 Feb 2019, 18:35 Francis Visoiu Mistrih via cfe-commits, 
>>  wrote:
>>> 
>>> Hi Richard,
>>> 
>>> This seems to now emit an error when building the sanitizer tests: 
>>> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull.
>>> 
>>> I managed to reproduce it locally and when reverting your commit the error 
>>> goes away.
>>> 
>>> I am not sure if the error is in the sanitizer test’s code or actually a 
>>> compiler error. Can you please take a look?
>> 
>> 
>> It's an error in the sanitizer test's code.
> 
> lldb bug fixed in r354173, sanitizer test bug fixed in r354174,
> re-committed as r354176.

Thanks Richard!

> 
>>> Thanks,
>>> 
>>> --
>>> Francis
>>> 
>>> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits 
>>>  wrote:
>>> 
>>> Author: rsmith
>>> Date: Thu Feb 14 16:29:04 2019
>>> New Revision: 354091
>>> 
>>> URL: http://llvm.org/viewvc/llvm-project?rev=354091=rev
>>> Log:
>>> Fix implementation of [temp.local]p4.
>>> 
>>> When a template-name is looked up, we need to give injected-class-name
>>> declarations of class templates special treatment, as they denote a
>>> template rather than a type.
>>> 
>>> Previously we achieved this by applying a filter to the lookup results
>>> after completing name lookup, but that is incorrect in various ways, not
>>> least of which is that it lost all information about access and how
>>> members were named, and the filtering caused us to generally lose
>>> all ambiguity errors between templates and non-templates.
>>> 
>>> We now preserve the lookup results exactly, and the few places that need
>>> to map from a declaration found by name lookup into a declaration of a
>>> template do so explicitly. Deduplication of repeated lookup results of
>>> the same injected-class-name declaration is done by name lookup instead
>>> of after the fact.
>>> 
>>> Modified:
>>>   cfe/trunk/include/clang/Sema/Lookup.h
>>>   cfe/trunk/include/clang/Sema/Sema.h
>>>   cfe/trunk/lib/Sema/SemaDecl.cpp
>>>   cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>>   cfe/trunk/lib/Sema/SemaLookup.cpp
>>>   cfe/trunk/lib/Sema/SemaTemplate.cpp
>>>   cfe/trunk/test/CXX/class.access/p4.cpp
>>>   cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>>>   cfe/trunk/test/SemaTemplate/temp.cpp
>>> 
>>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091=354090=354091=diff
>>> ==
>>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
>>> @@ -172,7 +172,8 @@ public:
>>>  : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
>>>LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
>>>ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
>>> -AllowHidden(Other.AllowHidden) {}
>>> +AllowHidden(Other.AllowHidden),
>>> +TemplateNameLookup(Other.TemplateNameLookup) {}
>>> 
>>>  // FIXME: Remove these deleted methods once the default build includes
>>>  // -Wdeprecated.
>>> @@ -193,7 +194,8 @@ public:
>>>HideTags(std::move(Other.HideTags)),
>>>Diagnose(std::move(Other.Diagnose)),
>>>AllowHidden(std::move(Other.AllowHidden)),
>>> -Shadowed(std::move(Other.Shadowed)) {
>>> +Shadowed(std::move(Other.Shadowed)),
>>> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
>>>Other.Paths = nullptr;
>>>Other.Diagnose = false;
>>>  }
>>> @@ -216,6 +218,7 @@ public:
>>>Diagnose = std::move(Other.Diagnose);
>>>AllowHidden = std::move(Other.AllowHidden);
>>>Shadowed = std::move(Other.Shadowed);
>>> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
>>>Other.Paths = nullptr;
>>>Other.Diagnose = false;
>>>return *this;
>>> @@ -286,6 +289,15 @@ public:
>>>HideTags = Hide;

Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-14 Thread Francis Visoiu Mistrih via cfe-commits
I reverted this temporarily in r354097.

> On Feb 14, 2019, at 6:35 PM, Francis Visoiu Mistrih  
> wrote:
> 
> Hi Richard,
> 
> This seems to now emit an error when building the sanitizer tests: 
> http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull
>  
> .
> 
> I managed to reproduce it locally and when reverting your commit the error 
> goes away.
> 
> I am not sure if the error is in the sanitizer test’s code or actually a 
> compiler error. Can you please take a look?
> 
> Thanks,
> 
> -- 
> Francis
> 
>> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>> Author: rsmith
>> Date: Thu Feb 14 16:29:04 2019
>> New Revision: 354091
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=354091=rev 
>> 
>> Log:
>> Fix implementation of [temp.local]p4.
>> 
>> When a template-name is looked up, we need to give injected-class-name
>> declarations of class templates special treatment, as they denote a
>> template rather than a type.
>> 
>> Previously we achieved this by applying a filter to the lookup results
>> after completing name lookup, but that is incorrect in various ways, not
>> least of which is that it lost all information about access and how
>> members were named, and the filtering caused us to generally lose
>> all ambiguity errors between templates and non-templates.
>> 
>> We now preserve the lookup results exactly, and the few places that need
>> to map from a declaration found by name lookup into a declaration of a
>> template do so explicitly. Deduplication of repeated lookup results of
>> the same injected-class-name declaration is done by name lookup instead
>> of after the fact.
>> 
>> Modified:
>>cfe/trunk/include/clang/Sema/Lookup.h
>>cfe/trunk/include/clang/Sema/Sema.h
>>cfe/trunk/lib/Sema/SemaDecl.cpp
>>cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>cfe/trunk/lib/Sema/SemaLookup.cpp
>>cfe/trunk/lib/Sema/SemaTemplate.cpp
>>cfe/trunk/test/CXX/class.access/p4.cpp
>>cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>>cfe/trunk/test/SemaTemplate/temp.cpp
>> 
>> Modified: cfe/trunk/include/clang/Sema/Lookup.h
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091=354090=354091=diff
>>  
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
>> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
>> @@ -172,7 +172,8 @@ public:
>>   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
>> LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
>> ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
>> -AllowHidden(Other.AllowHidden) {}
>> +AllowHidden(Other.AllowHidden),
>> +TemplateNameLookup(Other.TemplateNameLookup) {}
>> 
>>   // FIXME: Remove these deleted methods once the default build includes
>>   // -Wdeprecated.
>> @@ -193,7 +194,8 @@ public:
>> HideTags(std::move(Other.HideTags)),
>> Diagnose(std::move(Other.Diagnose)),
>> AllowHidden(std::move(Other.AllowHidden)),
>> -Shadowed(std::move(Other.Shadowed)) {
>> +Shadowed(std::move(Other.Shadowed)),
>> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
>> Other.Paths = nullptr;
>> Other.Diagnose = false;
>>   }
>> @@ -216,6 +218,7 @@ public:
>> Diagnose = std::move(Other.Diagnose);
>> AllowHidden = std::move(Other.AllowHidden);
>> Shadowed = std::move(Other.Shadowed);
>> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
>> Other.Paths = nullptr;
>> Other.Diagnose = false;
>> return *this;
>> @@ -286,6 +289,15 @@ public:
>> HideTags = Hide;
>>   }
>> 
>> +  /// Sets whether this is a template-name lookup. For template-name 
>> lookups,
>> +  /// injected-class-names are treated as naming a template rather than a
>> +  /// template specialization.
>> +  void setTemplateNameLookup(bool TemplateName) {
>> +TemplateNameLookup = TemplateName;
>> +  }
>> +
>> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
>> +
>>   bool isAmbiguous() const {
>> return getResultKind() == Ambiguous;
>>   }
>> @@ -739,6 +751,9 @@ private:
>>   /// declaration that we skipped. This only happens when \c LookupKind
>>   /// is \c LookupRedeclarationWithLinkage.
>>   bool Shadowed = false;
>> +
>> +  /// True if we're looking up a template-name.
>> +  bool TemplateNameLookup = false;
>> };
>> 
>> /// Consumes visible declarations found when searching for
>> 
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: 
>> 

r354097 - Revert "Fix implementation of [temp.local]p4."

2019-02-14 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Thu Feb 14 19:06:15 2019
New Revision: 354097

URL: http://llvm.org/viewvc/llvm-project?rev=354097=rev
Log:
Revert "Fix implementation of [temp.local]p4."

This reverts commit 40bd10b770813bd1471d46f514545437516aa4ba.

This seems to now emit an error when building the sanitizer tests:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull.

Modified:
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/class.access/p4.cpp
cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
cfe/trunk/test/SemaTemplate/temp.cpp

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354097=354096=354097=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 19:06:15 2019
@@ -172,8 +172,7 @@ public:
   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
 LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
 ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
-AllowHidden(Other.AllowHidden),
-TemplateNameLookup(Other.TemplateNameLookup) {}
+AllowHidden(Other.AllowHidden) {}
 
   // FIXME: Remove these deleted methods once the default build includes
   // -Wdeprecated.
@@ -194,8 +193,7 @@ public:
 HideTags(std::move(Other.HideTags)),
 Diagnose(std::move(Other.Diagnose)),
 AllowHidden(std::move(Other.AllowHidden)),
-Shadowed(std::move(Other.Shadowed)),
-TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
+Shadowed(std::move(Other.Shadowed)) {
 Other.Paths = nullptr;
 Other.Diagnose = false;
   }
@@ -218,7 +216,6 @@ public:
 Diagnose = std::move(Other.Diagnose);
 AllowHidden = std::move(Other.AllowHidden);
 Shadowed = std::move(Other.Shadowed);
-TemplateNameLookup = std::move(Other.TemplateNameLookup);
 Other.Paths = nullptr;
 Other.Diagnose = false;
 return *this;
@@ -289,15 +286,6 @@ public:
 HideTags = Hide;
   }
 
-  /// Sets whether this is a template-name lookup. For template-name lookups,
-  /// injected-class-names are treated as naming a template rather than a
-  /// template specialization.
-  void setTemplateNameLookup(bool TemplateName) {
-TemplateNameLookup = TemplateName;
-  }
-
-  bool isTemplateNameLookup() const { return TemplateNameLookup; }
-
   bool isAmbiguous() const {
 return getResultKind() == Ambiguous;
   }
@@ -751,9 +739,6 @@ private:
   /// declaration that we skipped. This only happens when \c LookupKind
   /// is \c LookupRedeclarationWithLinkage.
   bool Shadowed = false;
-
-  /// True if we're looking up a template-name.
-  bool TemplateNameLookup = false;
 };
 
 /// Consumes visible declarations found when searching for

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354097=354096=354097=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 14 19:06:15 2019
@@ -6212,21 +6212,9 @@ public:
   // C++ Templates [C++ 14]
   //
   void FilterAcceptableTemplateNames(LookupResult ,
- bool AllowFunctionTemplates = true,
- bool AllowDependent = true);
+ bool AllowFunctionTemplates = true);
   bool hasAnyAcceptableTemplateNames(LookupResult ,
- bool AllowFunctionTemplates = true,
- bool AllowDependent = true);
-  /// Try to interpret the lookup result D as a template-name.
-  ///
-  /// \param D A declaration found by name lookup.
-  /// \param AllowFunctionTemplates Whether function templates should be
-  ///considered valid results.
-  /// \param AllowDependent Whether unresolved using declarations (that might
-  ///name templates) should be considered valid results.
-  NamedDecl *getAsTemplateNameDecl(NamedDecl *D,
-   bool AllowFunctionTemplates = true,
-   bool AllowDependent = true);
+ bool AllowFunctionTemplates = true);
 
   bool LookupTemplateName(LookupResult , Scope *S, CXXScopeSpec ,
   QualType ObjectType, bool EnteringContext,

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=354097=354096=354097=diff

Re: r354091 - Fix implementation of [temp.local]p4.

2019-02-14 Thread Francis Visoiu Mistrih via cfe-commits
Hi Richard,

This seems to now emit an error when building the sanitizer tests: 
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/53965/consoleFull 
.

I managed to reproduce it locally and when reverting your commit the error goes 
away.

I am not sure if the error is in the sanitizer test’s code or actually a 
compiler error. Can you please take a look?

Thanks,

-- 
Francis

> On Feb 14, 2019, at 4:29 PM, Richard Smith via cfe-commits 
>  wrote:
> 
> Author: rsmith
> Date: Thu Feb 14 16:29:04 2019
> New Revision: 354091
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=354091=rev
> Log:
> Fix implementation of [temp.local]p4.
> 
> When a template-name is looked up, we need to give injected-class-name
> declarations of class templates special treatment, as they denote a
> template rather than a type.
> 
> Previously we achieved this by applying a filter to the lookup results
> after completing name lookup, but that is incorrect in various ways, not
> least of which is that it lost all information about access and how
> members were named, and the filtering caused us to generally lose
> all ambiguity errors between templates and non-templates.
> 
> We now preserve the lookup results exactly, and the few places that need
> to map from a declaration found by name lookup into a declaration of a
> template do so explicitly. Deduplication of repeated lookup results of
> the same injected-class-name declaration is done by name lookup instead
> of after the fact.
> 
> Modified:
>cfe/trunk/include/clang/Sema/Lookup.h
>cfe/trunk/include/clang/Sema/Sema.h
>cfe/trunk/lib/Sema/SemaDecl.cpp
>cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>cfe/trunk/lib/Sema/SemaLookup.cpp
>cfe/trunk/lib/Sema/SemaTemplate.cpp
>cfe/trunk/test/CXX/class.access/p4.cpp
>cfe/trunk/test/CXX/temp/temp.decls/temp.friend/p1.cpp
>cfe/trunk/test/SemaTemplate/temp.cpp
> 
> Modified: cfe/trunk/include/clang/Sema/Lookup.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=354091=354090=354091=diff
> ==
> --- cfe/trunk/include/clang/Sema/Lookup.h (original)
> +++ cfe/trunk/include/clang/Sema/Lookup.h Thu Feb 14 16:29:04 2019
> @@ -172,7 +172,8 @@ public:
>   : SemaPtr(Other.SemaPtr), NameInfo(Other.NameInfo),
> LookupKind(Other.LookupKind), IDNS(Other.IDNS), Redecl(Other.Redecl),
> ExternalRedecl(Other.ExternalRedecl), HideTags(Other.HideTags),
> -AllowHidden(Other.AllowHidden) {}
> +AllowHidden(Other.AllowHidden),
> +TemplateNameLookup(Other.TemplateNameLookup) {}
> 
>   // FIXME: Remove these deleted methods once the default build includes
>   // -Wdeprecated.
> @@ -193,7 +194,8 @@ public:
> HideTags(std::move(Other.HideTags)),
> Diagnose(std::move(Other.Diagnose)),
> AllowHidden(std::move(Other.AllowHidden)),
> -Shadowed(std::move(Other.Shadowed)) {
> +Shadowed(std::move(Other.Shadowed)),
> +TemplateNameLookup(std::move(Other.TemplateNameLookup)) {
> Other.Paths = nullptr;
> Other.Diagnose = false;
>   }
> @@ -216,6 +218,7 @@ public:
> Diagnose = std::move(Other.Diagnose);
> AllowHidden = std::move(Other.AllowHidden);
> Shadowed = std::move(Other.Shadowed);
> +TemplateNameLookup = std::move(Other.TemplateNameLookup);
> Other.Paths = nullptr;
> Other.Diagnose = false;
> return *this;
> @@ -286,6 +289,15 @@ public:
> HideTags = Hide;
>   }
> 
> +  /// Sets whether this is a template-name lookup. For template-name lookups,
> +  /// injected-class-names are treated as naming a template rather than a
> +  /// template specialization.
> +  void setTemplateNameLookup(bool TemplateName) {
> +TemplateNameLookup = TemplateName;
> +  }
> +
> +  bool isTemplateNameLookup() const { return TemplateNameLookup; }
> +
>   bool isAmbiguous() const {
> return getResultKind() == Ambiguous;
>   }
> @@ -739,6 +751,9 @@ private:
>   /// declaration that we skipped. This only happens when \c LookupKind
>   /// is \c LookupRedeclarationWithLinkage.
>   bool Shadowed = false;
> +
> +  /// True if we're looking up a template-name.
> +  bool TemplateNameLookup = false;
> };
> 
> /// Consumes visible declarations found when searching for
> 
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=354091=354090=354091=diff
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Thu Feb 14 16:29:04 2019
> @@ -6212,9 +6212,21 @@ public:
>   // C++ Templates [C++ 14]
>   //
>   void FilterAcceptableTemplateNames(LookupResult ,
> - bool AllowFunctionTemplates = true);
> + 

r354008 - [NewPM] Add explicit triple to test

2019-02-13 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Feb 13 20:13:00 2019
New Revision: 354008

URL: http://llvm.org/viewvc/llvm-project?rev=354008=rev
Log:
[NewPM] Add explicit triple to test

This prevents warnings like:

> warning: overriding the module target triple with x86_64-apple-darwin

on macOS.

Modified:
cfe/trunk/test/CodeGen/asan-new-pm.ll

Modified: cfe/trunk/test/CodeGen/asan-new-pm.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-new-pm.ll?rev=354008=354007=354008=diff
==
--- cfe/trunk/test/CodeGen/asan-new-pm.ll (original)
+++ cfe/trunk/test/CodeGen/asan-new-pm.ll Wed Feb 13 20:13:00 2019
@@ -6,6 +6,8 @@
 ; RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=address -flto %s | FileCheck %s --check-prefixes=CHECK,LTO
 ; RUN: %clang_cc1 -S -emit-llvm -o - -O1 -fexperimental-new-pass-manager 
-fsanitize=address -flto=thin %s | FileCheck %s --check-prefixes=CHECK,THINLTO
 
+target triple = "x86_64-unknown-unknown"
+
 ; DAG-CHECK: @llvm.global_ctors = {{.*}}@asan.module_ctor
 
 define i32 @test_load(i32* %a) sanitize_address {


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


[clang-tools-extra] r353760 - [NFC][clangd] Remove unused lambda capture

2019-02-11 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Mon Feb 11 14:36:47 2019
New Revision: 353760

URL: http://llvm.org/viewvc/llvm-project?rev=353760=rev
Log:
[NFC][clangd] Remove unused lambda capture

Avoid this warning:

llvm/clang-tools-extra/clangd/ClangdServer.cpp:365:23: warning: lambda
capture 'this' is not used [-Wunused-lambda-capture]

  auto Action = [Sel, this](decltype(CB) CB, std::string File,
~~^~~~
1 warning generated.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=353760=353759=353760=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Feb 11 14:36:47 2019
@@ -362,7 +362,7 @@ void ClangdServer::enumerateTweaks(PathR
 
 void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
   Callback CB) {
-  auto Action = [Sel, this](decltype(CB) CB, std::string File,
+  auto Action = [Sel](decltype(CB) CB, std::string File,
 std::string TweakID,
 Expected InpAST) {
 if (!InpAST)


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


r349381 - [Driver] Don't override '-march' when using '-arch x86_64h'

2018-12-17 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Mon Dec 17 11:29:27 2018
New Revision: 349381

URL: http://llvm.org/viewvc/llvm-project?rev=349381=rev
Log:
[Driver] Don't override '-march' when using '-arch x86_64h'

On Darwin, using '-arch x86_64h' would always override the option passed
through '-march'.

This patch allows users to use '-march' with x86_64h, while keeping the
default to 'core-avx2'

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/clang-translation.c

Modified: cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp?rev=349381=349380=349381=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Arch/X86.cpp Mon Dec 17 11:29:27 2018
@@ -23,12 +23,8 @@ using namespace llvm::opt;
 const char *x86::getX86TargetCPU(const ArgList ,
  const llvm::Triple ) {
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
-if (StringRef(A->getValue()) != "native") {
-  if (Triple.isOSDarwin() && Triple.getArchName() == "x86_64h")
-return "core-avx2";
-
+if (StringRef(A->getValue()) != "native")
   return A->getValue();
-}
 
 // FIXME: Reject attempts to use -march=native unless the target matches
 // the host.

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=349381=349380=349381=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Mon Dec 17 11:29:27 2018
@@ -2017,12 +2017,8 @@ DerivedArgList *MachO::TranslateArgs(con
 else if (Name == "pentIIm3")
   DAL->AddJoinedArg(nullptr, MArch, "pentium2");
 
-else if (Name == "x86_64")
+else if (Name == "x86_64" || Name == "x86_64h")
   DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_m64));
-else if (Name == "x86_64h") {
-  DAL->AddFlagArg(nullptr, Opts.getOption(options::OPT_m64));
-  DAL->AddJoinedArg(nullptr, MArch, "x86_64h");
-}
 
 else if (Name == "arm")
   DAL->AddJoinedArg(nullptr, MArch, "armv4t");

Modified: cfe/trunk/test/Driver/clang-translation.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/clang-translation.c?rev=349381=349380=349381=diff
==
--- cfe/trunk/test/Driver/clang-translation.c (original)
+++ cfe/trunk/test/Driver/clang-translation.c Mon Dec 17 11:29:27 2018
@@ -33,6 +33,11 @@
 // AVX2: "-target-cpu"
 // AVX2: "core-avx2"
 
+// RUN: %clang -target x86_64h-apple-darwin -march=skx -### %s -o /dev/null 
2>&1 | \
+// RUN: FileCheck -check-prefix=X8664HSKX %s
+// X8664HSKX: "-target-cpu"
+// X8664HSKX: "skx"
+
 // RUN: %clang -target i386-apple-macosx10.12 -### -S %s -o %t.s 2>&1 | \
 // RUN: FileCheck -check-prefix=PENRYN %s
 // RUN: %clang -target x86_64-apple-macosx10.12 -### -S %s -o %t.s 2>&1 | \


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


Re: r345591 - [CodeGen] Disable the machine verifier on a ThinLTO test

2018-11-06 Thread Francis Visoiu Mistrih via cfe-commits
Thanks for the suggestion, I think it’s reasonable since it’s all due to:

* ICALL_BRANCH_FUNNEL: Bad machine code: Explicit definition marked as use 
https://bugs.llvm.org/show_bug.cgi?id=39436 
<https://bugs.llvm.org/show_bug.cgi?id=39436>.

I’ll look into it.

> On 5 Nov 2018, at 19:13, David Blaikie  wrote:
> 
> If ThinLTO doesn't pass the machine verifier - should it maybe be turned off 
> at the thinlto level in general, rather than for this specific test?
> 
> On Tue, Oct 30, 2018 at 5:20 AM Francis Visoiu Mistrih via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Author: thegameg
> Date: Tue Oct 30 05:18:33 2018
> New Revision: 345591
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=345591=rev 
> <http://llvm.org/viewvc/llvm-project?rev=345591=rev>
> Log:
> [CodeGen] Disable the machine verifier on a ThinLTO test
> 
> This allows us to turn the machine verifier on by default on X86.
> 
> Modified:
> cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
> 
> Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=345591=345590=345591=diff
>  
> <http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=345591=345590=345591=diff>
> ==
> --- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
> +++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Tue Oct 30 
> 05:18:33 2018
> @@ -6,7 +6,9 @@
> 
>  ; RUN: opt -thinlto-bc -o %t.o %s
> 
> +; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
> PR39436.
>  ; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
> +; RUN:   -verify-machineinstrs=0 \
>  ; RUN:   -o %t2.index \
>  ; RUN:   -r=%t.o,test,px \
>  ; RUN:   -r=%t.o,_ZN1A1nEi,p \
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org <mailto:cfe-commits@lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits 
> <http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits>

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


r345591 - [CodeGen] Disable the machine verifier on a ThinLTO test

2018-10-30 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Oct 30 05:18:33 2018
New Revision: 345591

URL: http://llvm.org/viewvc/llvm-project?rev=345591=rev
Log:
[CodeGen] Disable the machine verifier on a ThinLTO test

This allows us to turn the machine verifier on by default on X86.

Modified:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=345591=345590=345591=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Tue Oct 30 
05:18:33 2018
@@ -6,7 +6,9 @@
 
 ; RUN: opt -thinlto-bc -o %t.o %s
 
+; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. 
PR39436.
 ; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -verify-machineinstrs=0 \
 ; RUN:   -o %t2.index \
 ; RUN:   -r=%t.o,test,px \
 ; RUN:   -r=%t.o,_ZN1A1nEi,p \


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


r335750 - [NEON] Remove empty test file from r335734

2018-06-27 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Wed Jun 27 09:17:32 2018
New Revision: 335750

URL: http://llvm.org/viewvc/llvm-project?rev=335750=rev
Log:
[NEON] Remove empty test file from r335734

Fails on Green Dragon:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/50174/consoleFull

UNRESOLVED: Clang :: CodeGen/vld_dup.c (5546 of 38947)
 TEST 'Clang :: CodeGen/vld_dup.c' FAILED 

Test has no run line!

Removed:
cfe/trunk/test/CodeGen/vld_dup.c

Removed: cfe/trunk/test/CodeGen/vld_dup.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vld_dup.c?rev=335749=auto
==
(empty)


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


r335628 - Revert "[CMake][Darwin] Match cxx-headers -> cxx_headers libcxx target rename."

2018-06-26 Thread Francis Visoiu Mistrih via cfe-commits
Author: thegameg
Date: Tue Jun 26 10:05:01 2018
New Revision: 335628

URL: http://llvm.org/viewvc/llvm-project?rev=335628=rev
Log:
Revert "[CMake][Darwin] Match cxx-headers -> cxx_headers libcxx target rename."

This reverts commit r334550. Try to fix the stage2 build failing on
Green Dragon for a while.

http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/11124/console

Modified:
cfe/trunk/cmake/caches/Apple-stage2.cmake

Modified: cfe/trunk/cmake/caches/Apple-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Apple-stage2.cmake?rev=335628=335627=335628=diff
==
--- cfe/trunk/cmake/caches/Apple-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Apple-stage2.cmake Tue Jun 26 10:05:01 2018
@@ -61,7 +61,7 @@ set(LLVM_DISTRIBUTION_COMPONENTS
   LTO
   clang-format
   clang-headers
-  cxx_headers
+  cxx-headers
   ${LLVM_TOOLCHAIN_TOOLS}
   CACHE STRING "")
 


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