[clang] [clang] All {con, de}structor attributes to use template args (PR #67376)

2024-05-14 Thread Alex Brachet via cfe-commits

abrachet wrote:

No, feel free to commandeer this patch 

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


[clang] [Fuchsia] Change driver build to default to off (PR #68341)

2023-10-05 Thread Alex Brachet via cfe-commits

https://github.com/abrachet created 
https://github.com/llvm/llvm-project/pull/68341

We use this cache file for local builds too where the driver build is not a 
sensible default because it makes incremental links take too long. Instead lets 
change this option to be opt in.

>From f8464ee99b3b2b36754cb3c46e4419daf9482232 Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Thu, 5 Oct 2023 14:27:59 -0400
Subject: [PATCH] [Fuchsia] Change driver build to default to off

We use this cache file for local builds too where the driver build
is not a sensible default because it makes incremental links take
too long. Instead lets change this option to be opt in.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 0dcc35ee1495f55..cca53be3dc45e33 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -29,11 +29,7 @@ set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
 set(LLDB_ENABLE_LIBEDIT OFF CACHE BOOL "")
 
-if(WIN32)
-  set(FUCHSIA_DISABLE_DRIVER_BUILD ON)
-endif()
-
-if (NOT FUCHSIA_DISABLE_DRIVER_BUILD)
+if (FUCHSIA_ENABLE_DRIVER_BUILD)
   set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
   set(LLVM_DRIVER_TARGET llvm-driver)
 endif()

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


[clang] [clang] All {con, de}structor attributes to use template args (PR #67376)

2023-09-25 Thread Alex Brachet via cfe-commits

https://github.com/abrachet created 
https://github.com/llvm/llvm-project/pull/67376

Fixes #67154

>From 5317e66d8997c0406994809901429d5a88c0e0c6 Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Mon, 25 Sep 2023 17:35:13 -0400
Subject: [PATCH] [clang] All {con,de}structor attributes to use template args

Fixes #67154
---
 clang/include/clang/Basic/Attr.td  |  8 --
 clang/lib/CodeGen/CodeGenModule.cpp| 17 +--
 clang/lib/Sema/SemaDeclAttr.cpp| 33 ++
 clang/test/CodeGenCXX/constructor-attr.cpp | 14 +
 clang/test/CodeGenCXX/destructor-attr.cpp  | 20 +
 clang/test/Sema/ctor-dtor-attr.cpp | 13 +
 6 files changed, 89 insertions(+), 16 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/destructor-attr.cpp
 create mode 100644 clang/test/Sema/ctor-dtor-attr.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index dd4d45171db4899..8c4e63bebf110cf 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1156,9 +1156,11 @@ def ConstInit : InheritableAttr {
 
 def Constructor : InheritableAttr {
   let Spellings = [GCC<"constructor">];
-  let Args = [DefaultIntArgument<"Priority", 65535>];
+  let Args = [ExprArgument<"Priority", 1>];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [CtorDtorDocs];
+  let TemplateDependent = 1;
+  let AdditionalMembers = [{ static const int DefaultPriority = 65535; }];
 }
 
 def CPUSpecific : InheritableAttr {
@@ -1422,9 +1424,11 @@ def Deprecated : InheritableAttr {
 
 def Destructor : InheritableAttr {
   let Spellings = [GCC<"destructor">];
-  let Args = [DefaultIntArgument<"Priority", 65535>];
+  let Args = [ExprArgument<"Priority", 1>];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [CtorDtorDocs];
+  let TemplateDependent = 1;
+  let AdditionalMembers = [{ static const int DefaultPriority = 65535; }];
 }
 
 def EmptyBases : InheritableAttr, TargetSpecificAttr {
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 130cedcd4f2bf68..e93c36bbce95ec6 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -32,6 +32,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtVisitor.h"
@@ -5661,10 +5662,20 @@ void 
CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
   setNonAliasAttributes(GD, Fn);
   SetLLVMFunctionAttributesForDefinition(D, Fn);
 
-  if (const ConstructorAttr *CA = D->getAttr())
-AddGlobalCtor(Fn, CA->getPriority());
+  auto getPrio = [this](auto *Attr) -> int {
+Expr *E = Attr->getPriority();
+if (!E)
+  return Attr->DefaultPriority;
+if (auto CE = E->getIntegerConstantExpr(getContext()))
+  return CE->getExtValue();
+return Attr->DefaultPriority;
+  };
+
+  if (const ConstructorAttr *CA = D->getAttr()) {
+AddGlobalCtor(Fn, getPrio(CA));
+  }
   if (const DestructorAttr *DA = D->getAttr())
-AddGlobalDtor(Fn, DA->getPriority(), true);
+AddGlobalDtor(Fn, getPrio(DA), true);
   if (D->hasAttr())
 AddGlobalAnnotations(D, Fn);
   if (getLangOpts().OpenMP && D->hasAttr())
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 090a54eedaa07d0..d857f5e78ae97a3 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2352,26 +2352,37 @@ static void handleUnusedAttr(Sema , Decl *D, const 
ParsedAttr ) {
   D->addAttr(::new (S.Context) UnusedAttr(S.Context, AL));
 }
 
+template 
+static void handleCtorDtorAttr(Sema , Decl *D, const ParsedAttr ) {
+  uint32_t priority = Attr::DefaultPriority;
+  Expr *E = nullptr;
+  if (AL.getNumArgs()) {
+E = AL.getArgAsExpr(0);
+if (E->isValueDependent()) {
+  if (!E->isTypeDependent() && !E->getType()->isIntegerType()) {
+S.Diag(getAttrLoc(AL), diag::err_attribute_argument_type)
+<<  << AANT_ArgumentIntegerConstant << E->getSourceRange();
+return;
+  }
+} else if (!checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority)) {
+  return;
+}
+  }
+
+  D->addAttr(::new (S.Context) Attr(S.Context, AL, E));
+}
+
 static void handleConstructorAttr(Sema , Decl *D, const ParsedAttr ) {
-  uint32_t priority = ConstructorAttr::DefaultPriority;
   if (S.getLangOpts().HLSL && AL.getNumArgs()) {
 S.Diag(AL.getLoc(), diag::err_hlsl_init_priority_unsupported);
 return;
   }
-  if (AL.getNumArgs() &&
-  !checkUInt32Argument(S, AL, AL.getArgAsExpr(0), priority))
-return;
 
-  D->addAttr(::new (S.Context) ConstructorAttr(S.Context, AL, priority));
+  handleCtorDtorAttr(S, D, AL);
 }
 
 static void handleDestructorAttr(Sema , Decl *D, const ParsedAttr ) {
-  uint32_t priority = DestructorAttr::DefaultPriority;
-  if 

[clang] [Fuchsia] Build with -fvisibility=default (PR #67067)

2023-09-22 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Build with -fvisibility=default (PR #67067)

2023-09-22 Thread Alex Brachet via cfe-commits

abrachet wrote:

I think the code formatting failure is because there are no source files 
changed in this commit. I feel fine pushing this.

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


[clang] [Fuchsia] Build with -fvisibility=default (PR #67067)

2023-09-22 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Build with -fvisibility=default (PR #67067)

2023-09-22 Thread Alex Brachet via cfe-commits

https://github.com/abrachet updated 
https://github.com/llvm/llvm-project/pull/67067

>From 62f1432f09ba4844fb2e826c73ce5748c34c6daf Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Wed, 20 Sep 2023 17:55:44 -0400
Subject: [PATCH] [Fuchsia] Build with -fvisibility=default

There was an issue with relative vtables when two TU's which define
the same vtable object are built with different default visibilities.
Some TU's are built with -fvisibility=hidden in the code base, grep
for CMAKE_CXX_VISIBILITY_PRESET to find them. Our whole toolchain,
is statically linked, and built with -fPIE anyway, so the cost of
overriding local CMAKE_CXX_VISIBILITY_PRESET properties is not high.
I've counted that adding this flag increases our llvm binary by 13
relocations. Frankly I'm not sure where those are even coming from.

It would be preferable to use hidden visibility, but that breaks
liblld. This can be solved by setting LLDB_EXPORT_ALL_SYMBOLS.
After that some ORC tests fail which do symbolic lookup in the
tests. It seems that setting CMAKE_CXX_VISIBILITY_PRESET=hidden
will not be worth the maintenance burden. Setting it to default
works to unblock using relative vtables, so we can just go with
that.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index bc4d9f1462b1814..a58d3823eeeaf9c 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -51,6 +51,12 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
+# TODO(#67176): relative-vtables doesn't play well with different default
+# visibilities. Making everything hidden visibility causes other complications
+# let's choose default visibility for our entire toolchain.
+set(CMAKE_C_VISIBILITY_PRESET default CACHE STRING "")
+set(CMAKE_CXX_VISIBILITY_PRESET default CACHE STRING "")
+
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if (APPLE)
   set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")

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


[clang] [Fuchsia] Build with -fvisibility=default (PR #67067)

2023-09-21 Thread Alex Brachet via cfe-commits

https://github.com/abrachet updated 
https://github.com/llvm/llvm-project/pull/67067

>From 3aa0af93dfe73edd2b6cba62c55e7797320665da Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Wed, 20 Sep 2023 17:55:44 -0400
Subject: [PATCH] [Fuchsia] Build with -fvisibility=default

There was an issue with relative vtables when two TU's which define
the same vtable object are built with different default visibilities.
Some TU's are built with -fvisibility=hidden in the code base, grep
for CMAKE_CXX_VISIBILITY_PRESET to find them. Our whole toolchain,
is statically linked, and built with -fPIE anyway, so the cost of
overriding local CMAKE_CXX_VISIBILITY_PRESET properties is not high.
I've counted that adding this flag increases our llvm binary by 13
relocations. Frankly I'm not sure where those are even coming from.

It would be preferable to use hidden visibility, but that breaks
liblld. This can be solved by setting LLDB_EXPORT_ALL_SYMBOLS.
After that some ORC tests fail which do symbolic lookup in the
tests. It seems that setting CMAKE_CXX_VISIBILITY_PRESET=hidden
will not be worth the maintenance burden. Setting it to default
works to unblock using relative vtables, so we can just go with
that.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 1 +
 1 file changed, 1 insertion(+)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index bc4d9f1462b1814..28931fef012775a 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -52,6 +52,7 @@ set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(CMAKE_CXX_VISIBILITY_PRESET default CACHE STRING "")
 if (APPLE)
   set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
 elseif(WIN32)

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


[clang] [Fuchsia] Build with -fvisibility=default (PR #67067)

2023-09-21 Thread Alex Brachet via cfe-commits

https://github.com/abrachet created 
https://github.com/llvm/llvm-project/pull/67067

There was an issue with relative vtables when two TU's which define the same 
vtable object are built with different default visibilities. Some TU's are 
built with -fvisibility=hidden in the code base, grep for 
CMAKE_CXX_VISIBILITY_PRESET to find them. Our whole toolchain, is statically 
linked, and built with -fPIE anyway, so the cost of overriding local 
CMAKE_CXX_VISIBILITY_PRESET properties is not high. I've counted that adding 
this flag increases our llvm binary by 13 relocations. Frankly I'm not sure 
where those are even coming from.

It would be preferable to use hidden visibility, but that breaks liblld. This 
can be solved by setting LLDB_EXPORT_ALL_SYMBOLS. After that some ORC tests 
fail which do symbolic lookup in the tests. It seems that setting 
CMAKE_CXX_VISIBILITY_PRESET=hidden will not be worth the maintenance burden. 
Setting it to default works to unblock using relative vtables, so we can just 
go with that.

>From 3d54dc44c1cf0eb5a115b93737070ad8142dcf5b Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Wed, 20 Sep 2023 17:55:44 -0400
Subject: [PATCH] [Fuchsia] Build with -fvisibility=default

There was an issue with relative vtables when two TU's which define
the same vtable object are built with different default visibilities.
Some TU's are built with -fvisibility=hidden in the code base, grep
for CMAKE_CXX_VISIBILITY_PRESET to find them. Our whole toolchain,
is statically linked, and built with -fPIE anyway, so the cost of
overriding local CMAKE_CXX_VISIBILITY_PRESET properties is not high.
I've counted that adding this flag increases our llvm binary by 13
relocations. Frankly I'm not sure where those are even coming from.

It would be preferable to use hidden visibility, but that breaks
liblld. This can be solved by setting LLDB_EXPORT_ALL_SYMBOLS.
After that some ORC tests fail which do symbolic lookup in the
tests. It seems that setting CMAKE_CXX_VISIBILITY_PRESET=hidden
will not be worth the maintenance burden. Setting it to default
works to unblock using relative vtables, so we can just go with
that.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index bc4d9f1462b1814..a3b7a4cb1c59886 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -28,6 +28,7 @@ set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 set(LLDB_ENABLE_CURSES OFF CACHE BOOL "")
 set(LLDB_ENABLE_LIBEDIT OFF CACHE BOOL "")
+# set(LLDB_EXPORT_ALL_SYMBOLS ON CACHE BOOL "")
 
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
@@ -52,6 +53,7 @@ set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(CMAKE_CXX_VISIBILITY_PRESET default CACHE STRING "")
 if (APPLE)
   set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
 elseif(WIN32)

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


[clang] [Sema] Fix fixit cast printing inside macros (PR #66853)

2023-09-20 Thread Alex Brachet via cfe-commits

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

Awesome! I couldn't figure this out when I looked :)

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


[clang] [Fuchsia] Support building runtimes for RISC-V on Linux (PR #66025)

2023-09-11 Thread Alex Brachet via cfe-commits

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


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


[clang] [Fuchsia] Re-enable libcxx timezone database (PR #65981)

2023-09-11 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Re-enable libcxx timezone database (PR #65981)

2023-09-11 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Re-enable libcxx timezone database (PR #65981)

2023-09-11 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Re-enable libcxx timezone database (PR #65981)

2023-09-11 Thread Alex Brachet via cfe-commits

https://github.com/abrachet created 
https://github.com/llvm/llvm-project/pull/65981:

None

>From 8e289774f65d49fbc3bfb11a0d51d9f706ed3ef2 Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Mon, 11 Sep 2023 13:05:53 -0400
Subject: [PATCH] [Fuchsia] Re-enable libcxx timezone database

---
 clang/cmake/caches/Fuchsia-stage2.cmake | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 10e5cacf51c4b7b..4890040b1b6a2b4 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -181,9 +181,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
-# TODO: Remove this once #65859 lands.
-set(RUNTIMES_${target}_LIBCXX_ENABLE_TIME_ZONE_DATABASE OFF CACHE STRING 
"")
-
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endif()

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


[clang] [Fuchsia] Disable libcxx timezone database (PR #65870)

2023-09-10 Thread Alex Brachet via cfe-commits

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


[clang] [Haiku] Don't assume clang was build with libstdc++ as default (PR #65871)

2023-09-09 Thread Alex Brachet via cfe-commits

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


[clang] [Haiku] Don't assume clang was build with libstdc++ as default (PR #65871)

2023-09-09 Thread Alex Brachet via cfe-commits

https://github.com/abrachet created 
https://github.com/llvm/llvm-project/pull/65871:

This test fails with `CLANG_DEFAULT_CXX_STDLIB=libc++`

>From 01607fcb02df7e9f91f39c01938c8b67247703bd Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Sat, 9 Sep 2023 23:27:33 -0400
Subject: [PATCH] [Haiku] Don't assume clang was build with libstdc++ as
 default

This test fails with `CLANG_DEFAULT_CXX_STDLIB=libc++`
---
 clang/test/Driver/haiku.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/test/Driver/haiku.cpp b/clang/test/Driver/haiku.cpp
index f022013d1ef79b7..64018e8236b2824 100644
--- a/clang/test/Driver/haiku.cpp
+++ b/clang/test/Driver/haiku.cpp
@@ -1,5 +1,5 @@
 // Check the C++ header path (libstdc++)
-// RUN: %clangxx --target=x86_64-unknown-haiku -### %s 2>&1 \
+// RUN: %clangxx --target=x86_64-unknown-haiku --stdlib=libstdc++ -### %s 2>&1 
\
 // RUN:   --sysroot=%S/Inputs/haiku_x86_64_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-LIBSTDCXX-HEADER-PATH %s
 // CHECK-LIBSTDCXX-HEADER-PATH: "-internal-isystem" 
"[[SYSROOT:[^"]+]]/boot/system/develop/headers/c++"

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


[clang] [Haiku] Don't assume clang was build with libstdc++ as default (PR #65871)

2023-09-09 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Disable libcxx timezone database (PR #65870)

2023-09-09 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Disable libcxx timezone database (PR #65870)

2023-09-09 Thread Alex Brachet via cfe-commits

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


[clang] [Fuchsia] Disable libcxx timezone database (PR #65870)

2023-09-09 Thread Alex Brachet via cfe-commits

https://github.com/abrachet created 
https://github.com/llvm/llvm-project/pull/65870:

tzdb is currently broken when cross compiling from non Linux to Linux. Lets 
just disable it totally in our toolchain for now. We should remove this when 
#65859 lands.

>From b75d844d09076f2a7f170454782662cfebd7d16e Mon Sep 17 00:00:00 2001
From: Alex Brachet 
Date: Sat, 9 Sep 2023 23:16:21 -0400
Subject: [PATCH] [Fuchsia] Disable libcxx timezone database

tzdb is currently broken when cross compiling from non Linux
to Linux. Lets just disable it totally in our toolchain for now.
We should remove this when #65859 lands.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 4890040b1b6a2b4..10e5cacf51c4b7b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -181,6 +181,9 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_LLVM_TOOLS_DIR "${CMAKE_BINARY_DIR}/bin" CACHE BOOL 
"")
 set(RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
 
+# TODO: Remove this once #65859 lands.
+set(RUNTIMES_${target}_LIBCXX_ENABLE_TIME_ZONE_DATABASE OFF CACHE STRING 
"")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${target}")
   endif()

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


[clang] c7cc756 - [CMake] Add option to disable driver build in Fuchsia cache file

2023-09-05 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-09-05T15:22:15Z
New Revision: c7cc756ce343808d0369de1b45e2b0747f62

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

LOG: [CMake] Add option to disable driver build in Fuchsia cache file

Linking the driver binary can take a long time, particularly with debug
info. This adds an option to disable the driver build meant for local use.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 3283c551ccb7cf..4890040b1b6a2b 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -31,7 +31,10 @@ set(LLDB_ENABLE_LIBEDIT OFF CACHE BOOL "")
 
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
-else()
+  set(FUCHSIA_DISABLE_DRIVER_BUILD ON)
+endif()
+
+if (NOT FUCHSIA_DISABLE_DRIVER_BUILD)
   set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
   set(LLVM_DRIVER_TARGET llvm-driver)
 endif()



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


[clang] d5ca160 - [Driver] Fix test usages of --rtlib= without --unwindlib=

2023-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-08-01T18:39:40Z
New Revision: d5ca1602f64114f612ad5630f04e4aa90591c78d

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

LOG: [Driver] Fix test usages of --rtlib= without --unwindlib=

These errors surfaced after D156363. The error
"--rtlib=libgcc requires --unwindlib=libgcc" happens only when
`CLANG_DEFAULT_UNWINDLIB` has been specified at build time.

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

Added: 


Modified: 
clang/test/Driver/csky-toolchain.c
clang/test/Driver/env.c
clang/test/Driver/gcc-install-dir.cpp
clang/test/Driver/gcc-toolchain.cpp
clang/test/Driver/linux-cross.cpp
clang/test/Driver/linux-ld.c
clang/test/Driver/loongarch-toolchain.c
clang/test/Driver/miamcu-opt.c
clang/test/Driver/nolibc.c
clang/test/Driver/pic.c
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain.c
clang/test/OpenMP/linking.c

Removed: 




diff  --git a/clang/test/Driver/csky-toolchain.c 
b/clang/test/Driver/csky-toolchain.c
index 386317ad3e0c67..66485464652ac8 100644
--- a/clang/test/Driver/csky-toolchain.c
+++ b/clang/test/Driver/csky-toolchain.c
@@ -7,7 +7,7 @@
 // In the below tests, --rtlib=platform is used so that the driver ignores
 // the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib
 
-// RUN: %clang -### %s -fuse-ld=ld -no-pie --target=csky-unknown-linux-gnu 
--rtlib=platform  \
+// RUN: %clang -### %s -fuse-ld=ld -no-pie --target=csky-unknown-linux-gnu 
--rtlib=platform --unwindlib=platform \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_csky_linux_sdk  2>&1 | FileCheck 
-check-prefix=C-CSKY-LINUX-MULTI %s
 
 // C-CSKY-LINUX-MULTI: 
"{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/bin{{/|}}ld"
@@ -23,7 +23,7 @@
 // C-CSKY-LINUX-MULTI: 
"-L{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/libc/lib"
 // C-CSKY-LINUX-MULTI: 
"-L{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/libc/usr/lib"
 
-// RUN: %clang -### %s -fuse-ld=ld -fno-pic -no-pie 
--target=csky-unknown-linux-gnu --rtlib=platform -march=ck860v \
+// RUN: %clang -### %s -fuse-ld=ld -fno-pic -no-pie 
--target=csky-unknown-linux-gnu --rtlib=platform --unwindlib=platform 
-march=ck860v \
 // RUN:   --gcc-toolchain=%S/Inputs/multilib_csky_linux_sdk 2>&1 | FileCheck 
-check-prefix=C-CSKY-LINUX-CK860V %s
 
 // C-CSKY-LINUX-CK860V: 
"{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/bin{{/|}}ld"

diff  --git a/clang/test/Driver/env.c b/clang/test/Driver/env.c
index 0a60739db8718a..40a42dc9618576 100644
--- a/clang/test/Driver/env.c
+++ b/clang/test/Driver/env.c
@@ -7,13 +7,13 @@
 // RUN: env -i LC_ALL=C LD_LIBRARY_PATH="$LD_LIBRARY_PATH" 
CLANG_NO_DEFAULT_CONFIG=1 \
 // RUN:   %clang %s -### -o %t.o --target=i386-unknown-linux \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: --rtlib=platform -no-pie \
+// RUN: --rtlib=platform --unwindlib=platform -no-pie \
 // RUN: --gcc-toolchain="" 2>&1 | FileCheck --check-prefix=CHECK-LD-32 %s
 //
 // RUN: env -i LC_ALL=C PATH="" LD_LIBRARY_PATH="$LD_LIBRARY_PATH" 
CLANG_NO_DEFAULT_CONFIG=1 \
 // RUN:   %clang %s -### -o %t.o --target=i386-unknown-linux \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree \
-// RUN: --rtlib=platform -no-pie \
+// RUN: --rtlib=platform --unwindlib=platform -no-pie \
 // RUN: --gcc-toolchain="" 2>&1 | FileCheck --check-prefix=CHECK-LD-32 %s
 //
 // CHECK-LD-32-NOT: warning:

diff  --git a/clang/test/Driver/gcc-install-dir.cpp 
b/clang/test/Driver/gcc-install-dir.cpp
index 0d7094255812b4..5d45037860f771 100644
--- a/clang/test/Driver/gcc-install-dir.cpp
+++ b/clang/test/Driver/gcc-install-dir.cpp
@@ -2,7 +2,7 @@
 
 /// Test native GCC installation on Arch Linux i686.
 // RUN: %clang -### %s --target=i686-linux-gnu 
--sysroot=%S/Inputs/archlinux_i686_tree -ccc-install-dir 
%S/Inputs/basic_linux_tree/usr/bin \
-// RUN:   --stdlib=platform --rtlib=platform \
+// RUN:   --stdlib=platform --rtlib=platform --unwindlib=platform \
 // RUN:   
--gcc-install-dir=%S/Inputs/archlinux_i686_tree/usr/lib/gcc/i686-pc-linux-gnu/11.1.0
 2>&1 | FileCheck %s --check-prefix=ARCH_I686
 // ARCH_I686:  "-internal-isystem"
 // ARCH_I686-SAME: {{^}} 
"[[SYSROOT:[^"]+]]/usr/lib/gcc/i686-pc-linux-gnu/11.1.0/../../../../include/c++/11.1.0"
@@ -14,7 +14,7 @@
 
 /// Test native GCC installation on Debian amd64. --gcc-install-dir= may end 
with /.
 // RUN: %clangxx %s -### --target=x86_64-unknown-linux-gnu 

[clang] 563a23c - [clang][Sema] Add fixit for scoped enum format error

2023-07-14 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-07-14T16:23:22Z
New Revision: 563a23c824db22da3ea378e8179fcc7072e897ec

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

LOG: [clang][Sema] Add fixit for scoped enum format error

This helps transition code bases to handle the new warning added in 3632e2f5179

Before:
```
clang/test/FixIt/format.cpp:10:16: warning: format specifies type 'int' but the 
argument has type 'N::E' [-Wformat]
   10 |   printf("%d", N::E::One); // expected-warning{{format specifies type 
'int' but the argument has type 'N::E'}}
  |   ~~   ^
  |   %d
```
After:
```
clang/test/FixIt/format.cpp:10:16: warning: format specifies type 'int' but the 
argument has type 'N::E' [-Wformat]
   10 |   printf("%d", N::E::One); // expected-warning{{format specifies type 
'int' but the argument has type 'N::E'}}
  |   ~~   ^
  |static_cast( )
```

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

Added: 
clang/test/FixIt/format.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0423c054bd0b58..d55757183d58e9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -417,6 +417,9 @@ Improvements to Clang's diagnostics
  ^~~
 - ``-Wformat`` cast fix-its will now suggest ``static_cast`` instead of 
C-style casts
   for C++ code.
+- ``-Wformat`` will no longer suggest a no-op fix-it for fixing scoped enum 
format
+  warnings. Instead, it will suggest casting the enum object to the type 
specified
+  in the format string.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 66a1a8f3f90ee3..b09d0383b4bd9a 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11077,12 +11077,15 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   assert(Match != ArgType::MatchPromotion);
   // Look through unscoped enums to their underlying type.
   bool IsEnum = false;
+  bool IsScopedEnum = false;
   if (auto EnumTy = ExprTy->getAs()) {
 if (EnumTy->isUnscopedEnumerationType()) {
   ExprTy = EnumTy->getDecl()->getIntegerType();
   // This controls whether we're talking about the underlying type or not,
   // which we only want to do when it's an unscoped enum.
   IsEnum = true;
+} else {
+  IsScopedEnum = true;
 }
   }
 
@@ -11148,7 +11151,7 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 
 CharSourceRange SpecRange = getSpecifierRange(StartSpecifier, 
SpecifierLen);
 
-if (IntendedTy == ExprTy && !ShouldNotPrintDirectly) {
+if (IntendedTy == ExprTy && !ShouldNotPrintDirectly && !IsScopedEnum) {
   unsigned Diag;
   switch (Match) {
   case ArgType::Match:
@@ -11185,11 +11188,17 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   SmallString<16> CastBuf;
   llvm::raw_svector_ostream CastFix(CastBuf);
   CastFix << (S.LangOpts.CPlusPlus ? "static_cast<" : "(");
-  IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
+  if (IsScopedEnum) {
+CastFix << AT.getRepresentativeType(S.Context).getAsString(
+S.Context.getPrintingPolicy());
+  } else {
+IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
+  }
   CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
 
   SmallVector Hints;
-  if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly)
+  if ((!AT.matchesType(S.Context, IntendedTy) && !IsScopedEnum) ||
+  ShouldNotPrintDirectly)
 Hints.push_back(FixItHint::CreateReplacement(SpecRange, os.str()));
 
   if (const CStyleCastExpr *CCast = dyn_cast(E)) {

diff  --git a/clang/test/FixIt/format.cpp b/clang/test/FixIt/format.cpp
new file mode 100644
index 00..9cc4c2600eb667
--- /dev/null
+++ b/clang/test/FixIt/format.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits -Wformat %s 
2>&1 | FileCheck %s
+
+extern "C" int printf(const char *, ...);
+
+namespace N {
+  enum class E { One };
+}
+
+void a() {
+  printf("%d", N::E::One); // expected-warning{{format specifies type 'int' 
but the argument has type 'N::E'}}
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:25-[[@LINE-2]]:25}:")"
+
+  printf("%hd", N::E::One);
+  // CHECK: "static_cast("
+
+  printf("%hu", N::E::One);
+  // CHECK: "static_cast("
+}



___
cfe-commits mailing list

[clang] 3c0a136 - [clang][Sema] Suggest static_cast in C++ code

2023-07-14 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-07-14T16:22:06Z
New Revision: 3c0a136ce4b724221a7f75b656b9f7af3de6b64c

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

LOG: [clang][Sema] Suggest static_cast in C++ code

This patch changes the -Wformat diagnostic to suggest static_cast over
a C-style cast for {,Objective}C++ when recommending the argument be
casted rather than changing the format string.

Before:
```
clang/test/FixIt/format.mm:11:16: warning: format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'wchar_t' [-Wformat]
   11 |   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
  |   ~~   ^~
  |(unsigned short)
```
After:
```
clang/test/FixIt/format.mm:11:16: warning: format specifies type 'unichar' (aka 
'unsigned short') but the argument has type 'wchar_t' [-Wformat]
   11 |   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
  |   ~~   ^~
  |static_cast( )
```

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaChecking.cpp
clang/test/FixIt/format.mm

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 53a83b9c94176d..0423c054bd0b58 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -415,6 +415,8 @@ Improvements to Clang's diagnostics
 source:1:6: note: candidate function not viable: no known conversion from 
'const char[4]' to 'int' for 2nd argument
 void func(int aa, int bb);
  ^~~
+- ``-Wformat`` cast fix-its will now suggest ``static_cast`` instead of 
C-style casts
+  for C++ code.
 
 Bug Fixes in This Version
 -

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index f9a50f6ef3be6f..66a1a8f3f90ee3 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -11184,9 +11184,9 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
   // if necessary).
   SmallString<16> CastBuf;
   llvm::raw_svector_ostream CastFix(CastBuf);
-  CastFix << "(";
+  CastFix << (S.LangOpts.CPlusPlus ? "static_cast<" : "(");
   IntendedTy.print(CastFix, S.Context.getPrintingPolicy());
-  CastFix << ")";
+  CastFix << (S.LangOpts.CPlusPlus ? ">" : ")");
 
   SmallVector Hints;
   if (!AT.matchesType(S.Context, IntendedTy) || ShouldNotPrintDirectly)
@@ -11197,7 +11197,7 @@ CheckPrintfHandler::checkFormatExpr(const 
analyze_printf::PrintfSpecifier ,
 SourceRange CastRange(CCast->getLParenLoc(), CCast->getRParenLoc());
 Hints.push_back(FixItHint::CreateReplacement(CastRange, 
CastFix.str()));
 
-  } else if (!requiresParensToAddCast(E)) {
+  } else if (!requiresParensToAddCast(E) && !S.LangOpts.CPlusPlus) {
 // If the expression has high enough precedence,
 // just write the C-style cast.
 Hints.push_back(

diff  --git a/clang/test/FixIt/format.mm b/clang/test/FixIt/format.mm
index eed7c981f2c455..f630db41b37844 100644
--- a/clang/test/FixIt/format.mm
+++ b/clang/test/FixIt/format.mm
@@ -9,22 +9,22 @@ void test_percent_C() {
 
   const wchar_t wchar_data = L'a';
   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unsigned short)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast(
 
   NSLog(@"%C", 0x260300);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'int'}}
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unsigned short)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"static_cast(
 
   typedef unsigned short unichar;
 
   NSLog(@"%C", wchar_data);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'wchar_t'}}
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"(unichar)"
+  // CHECK: 
fix-it:"{{.*}}":{[[@LINE-1]]:16-[[@LINE-1]]:16}:"static_cast(
 
   NSLog(@"%C", 0x260300);  // expected-warning{{format specifies type 
'unichar' (aka 'unsigned short') but the argument has type 'int'}}
   // CHECK-NOT: fix-it:"{{.*}}":{[[@LINE-1]]:11-[[@LINE-1]]:13}:"%d"
-  // CHECK: fix-it:"{{.*}}":{[[@LINE-2]]:16-[[@LINE-2]]:16}:"(unichar)"
+  // CHECK: 

[clang] 68f5d1b - [UTC] Adapt version matcher to glob CLANG_VENDOR

2023-07-05 Thread Alex Brachet via cfe-commits

Author: Henrik G. Olsson
Date: 2023-07-05T17:10:47Z
New Revision: 68f5d1be3d8f9b2ee2f25098203b24a32057b4e6

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

LOG: [UTC] Adapt version matcher to glob CLANG_VENDOR

Both the pattern for finding the clang version metadata, and the emitted
checker, are now more robust, to handle a vendor prefix.

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

Added: 


Modified: 

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected

clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected

llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
llvm/utils/UpdateTestChecks/common.py

Removed: 




diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
index 66959811660d65..6ec61165377512 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.all.expected
@@ -247,12 +247,12 @@ void foo(void) {
 //.
 // OMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // OMP: [[META1:![0-9]+]] = !{i32 7, !"openmp", i32 51}
-// OMP: [[META2:![0-9]+]] = !{!"clang version {{.*}}"}
+// OMP: [[META2:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // OMP: [[META3:![0-9]+]] = !{[[META4:![0-9]+]]}
 // OMP: [[META4]] = !{i64 2, i64 -1, i64 -1, i1 true}
 //.
 // NOOMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-// NOOMP: [[META1:![0-9]+]] = !{!"clang version {{.*}}"}
+// NOOMP: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // NOOMP: [[LOOP2]] = distinct !{[[LOOP2]], [[META3:![0-9]+]]}
 // NOOMP: [[META3]] = !{!"llvm.loop.mustprogress"}
 // NOOMP: [[LOOP4]] = distinct !{[[LOOP4]], [[META3]]}

diff  --git 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
index 219e5ceee6c784..1b0074023a60cb 100644
--- 
a/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
+++ 
b/clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.all.expected
@@ -118,12 +118,12 @@ void foo(void) {
 //.
 // OMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
 // OMP: [[META1:![0-9]+]] = !{i32 7, !"openmp", i32 51}
-// OMP: [[META2:![0-9]+]] = !{!"clang version {{.*}}"}
+// OMP: [[META2:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // OMP: [[META3:![0-9]+]] = !{[[META4:![0-9]+]]}
 // OMP: [[META4]] = !{i64 2, i64 -1, i64 -1, i1 true}
 //.
 // NOOMP: [[META0:![0-9]+]] = !{i32 1, !"wchar_size", i32 4}
-// NOOMP: [[META1:![0-9]+]] = !{!"clang version {{.*}}"}
+// NOOMP: [[META1:![0-9]+]] = !{!"{{.*}}clang version {{.*}}"}
 // NOOMP: [[LOOP2]] = distinct !{[[LOOP2]], [[META3:![0-9]+]]}
 // NOOMP: [[META3]] = !{!"llvm.loop.mustprogress"}
 // NOOMP: [[LOOP4]] = distinct !{[[LOOP4]], [[META3]]}

diff  --git 
a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
 
b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
index a867c34090123d..ea35ec593720e7 100644
--- 
a/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
+++ 
b/llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
@@ -250,13 +250,13 @@ attributes #3 = { nounwind }
 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { nocallback nofree nosync nounwind 
willreturn memory(argmem: readwrite) }
 ; CHECK: attributes #[[ATTR3]] = { nounwind }
 ;.
-; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "clang version {{.*}}", isOptimized: true, 
runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
+; CHECK: [[META0:![0-9]+]] = distinct !DICompileUnit(language: DW_LANG_C99, 
file: [[META1:![0-9]+]], producer: "{{.*}}clang version {{.*}}", isOptimized: 
true, runtimeVersion: 0, emissionKind: FullDebug, enums: [[META2:![0-9]+]], 
splitDebugInlining: false, nameTableKind: None)
 ; CHECK: [[META1]] = !DIFile(filename: "various_ir_values.c", directory: 
{{.*}})
 ; CHECK: [[META2]] = !{}
 ; CHECK: [[META3:![0-9]+]] = !{i32 7, !"Dwarf Version", i32 4}
 ; CHECK: [[META4:![0-9]+]] = !{i32 2, !"Debug Info Version", i32 3}
 ; 

[clang] 1be27bd - [CMake][Fuchsia] Enable standalone libatomic

2023-06-26 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-06-26T13:49:22Z
New Revision: 1be27bd8ce085a81090041b324fb19a4a6261724

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

LOG: [CMake][Fuchsia] Enable standalone libatomic

BUILTINS_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC
actually builds libatomic, and
RUNTIMES_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC
tells the compiler-rt tests that we built it and it is
safe to use in tests.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 9bacd27d31eaa..763a79eee9cea 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -143,6 +143,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_EXE_LINKER_FLAG "-fuse-ld=lld" CACHE STRING 
"")
+set(BUILTINS_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC ON CACHE 
BOOL "")
 
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
@@ -159,6 +160,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 set(RUNTIMES_${target}_COMPILER_RT_USE_BUILTINS_LIBRARY ON CACHE BOOL "")
 set(RUNTIMES_${target}_COMPILER_RT_USE_LLVM_UNWINDER ON CACHE BOOL "")
 set(RUNTIMES_${target}_COMPILER_RT_CAN_EXECUTE_TESTS ON CACHE BOOL "")
+set(RUNTIMES_${target}_COMPILER_RT_BUILD_STANDALONE_LIBATOMIC ON CACHE 
BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
 set(RUNTIMES_${target}_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
 set(RUNTIMES_${target}_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")



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


[clang-tools-extra] 54d45dd - [clang-tidy][docs] Fix link to libc style guide

2023-05-30 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-05-30T18:22:26Z
New Revision: 54d45ddc89f1e2d3250b4d5093bea28e6e475cb7

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

LOG: [clang-tidy][docs] Fix link to libc style guide

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h 
b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
index 85d87a59e3733..662a592abd9be 100644
--- a/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
+++ b/clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
@@ -18,7 +18,7 @@ namespace clang::tidy::llvm_libc {
 /// are tagged with the LIBC_INLINE macro.
 ///
 /// For more information about the LIBC_INLINE macro, see
-/// https://libc.llvm.org/code_style.html.
+/// https://libc.llvm.org/dev/code_style.html.
 ///
 /// For the user-facing documentation see:
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/llvmlibc/inline-function-decl-check.html

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst 
b/clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
index da60a1fcdb112..101217b64c828 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
@@ -5,4 +5,4 @@ llvmlibc-inline-function-decl
 
 Checks that all implicit and explicit inline functions in header files are
 tagged with the ``LIBC_INLINE`` macro. See the `libc style guide
-`_ for more information about this 
macro.
+`_ for more information about this 
macro.



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


[clang] 30c57e2 - [Fuchsia] Correctly pass lists from STAGE2_ vars

2023-05-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-05-17T17:24:58Z
New Revision: 30c57e275e5aea5ec4c021f1a53687c3ae97b6f9

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

LOG: [Fuchsia] Correctly pass lists from STAGE2_ vars

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 1032dc82e740e..5596cc61359cd 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -182,7 +182,8 @@ get_cmake_property(variableNames VARIABLES)
 foreach(variableName ${variableNames})
   if(variableName MATCHES "^STAGE2_")
 string(REPLACE "STAGE2_" "" new_name ${variableName})
-list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
+string(REPLACE ";" "|" value "${${variableName}}")
+list(APPEND EXTRA_ARGS "-D${new_name}=${value}")
   endif()
 endforeach()
 



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


[clang] 1fab236 - [CMake] Switch to -fPIE for Fuchsia Toolchain

2023-03-30 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-03-30T18:00:50Z
New Revision: 1fab236e6e4575d5af4f4722216df4dd6a872795

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

LOG: [CMake] Switch to -fPIE for Fuchsia Toolchain

This is a reland of D135471, save for dropping libLTO which was
already done in a separate change.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 7778a7f84b051..c6debed5007b8 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -16,6 +16,7 @@ set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
+set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
 set(LLVM_ENABLE_PLUGINS OFF CACHE BOOL "")
 set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
@@ -135,6 +136,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING 
"")
 set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING 
"")
@@ -147,6 +149,7 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING 
"")
 set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING 
"")
@@ -197,6 +200,7 @@ if(FUCHSIA_SDK)
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(BUILTINS_${target}_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
@@ -212,6 +216,7 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
+set(RUNTIMES_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(RUNTIMES_${target}_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")



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


[clang] df405db - [Driver] Make -X default for baremetal riscv

2023-03-13 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-03-14T05:17:54Z
New Revision: df405dbfd316a598474b73f8c57f0d1051b4b51e

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

LOG: [Driver] Make -X default for baremetal riscv

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 3175b15a48ca7..c935758adb2ba 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -339,6 +339,9 @@ void baremetal::Linker::ConstructJob(Compilation , const 
JobAction ,
 TC.AddLinkRuntimeLib(Args, CmdArgs);
   }
 
+  if (TC.getTriple().isRISCV())
+CmdArgs.push_back("-X");
+
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 

diff  --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index 24890e87c313c..7f2334493c529 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -135,7 +135,7 @@
 // CHECK-RV64-SAME: 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-RV64-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-RV64-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
-// CHECK-RV64-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-o" 
"{{.*}}.tmp.out"
+// CHECK-RV64-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-X" "-o" 
"{{.*}}.tmp.out"
 
 // RUN: %clangxx %s -### --target=riscv64-unknown-elf 2>&1 \
 // RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
@@ -145,7 +145,7 @@
 // CHECK-RV64-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}basic_riscv64_tree{{[/\\]+}}riscv64-unknown-elf{{[/\\]+}}lib"
 // CHECK-RV64-DEFAULTCXX-SAME: 
"-L[[RESOURCE_DIR]]{{.*}}{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-RV64-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-RV64-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-o" 
"a.out"
+// CHECK-RV64-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-X" 
"-o" "a.out"
 
 // RUN: %clangxx %s -### --target=riscv64-unknown-elf 2>&1 \
 // RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
@@ -158,7 +158,7 @@
 // CHECK-RV64-LIBCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}basic_riscv64_tree{{[/\\]+}}riscv64-unknown-elf{{[/\\]+}}lib"
 // CHECK-RV64-LIBCXX-SAME: "-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-RV64-LIBCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-RV64-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-o" 
"a.out"
+// CHECK-RV64-LIBCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-X" "-o" 
"a.out"
 
 // RUN: %clangxx %s -### 2>&1 --target=riscv64-unknown-elf \
 // RUN: --sysroot=%S/Inputs/basic_riscv64_tree/riscv64-unknown-elf \
@@ -171,7 +171,7 @@
 // CHECK-RV64-LIBSTDCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}basic_riscv64_tree{{[/\\]+}}riscv64-unknown-elf{{[/\\]+}}lib"
 // CHECK-RV64-LIBSTDCXX-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-RV64-LIBSTDCXX-SAME: "-lstdc++" "-lsupc++" "-lunwind"
-// CHECK-RV64-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-o" 
"a.out"
+// CHECK-RV64-LIBSTDCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv64" "-X" 
"-o" "a.out"
 
 // RUN: %clang %s -### 2>&1 --target=riscv32-unknown-elf \
 // RUN: -L some/directory/user/asked/for \
@@ -187,7 +187,7 @@
 // CHECK-RV32-SAME: 
"-Lsome{{[/\\]+}}directory{{[/\\]+}}user{{[/\\]+}}asked{{[/\\]+}}for"
 // CHECK-RV32-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}lib"
 // CHECK-RV32-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
-// CHECK-RV32-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv32" "-o" "a.out"
+// CHECK-RV32-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv32" "-X" "-o" "a.out"
 
 // RUN: %clangxx %s -### 2>&1 --target=riscv32-unknown-elf \
 // RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf \
@@ -197,7 +197,7 @@
 // CHECK-RV32-DEFAULTCXX-SAME: 
"-L{{[^"]*}}{{[/\\]+}}Inputs{{[/\\]+}}basic_riscv32_tree{{[/\\]+}}riscv32-unknown-elf{{[/\\]+}}lib"
 // CHECK-RV32-DEFAULTCXX-SAME: 
"-L[[RESOURCE_DIR]]{{[/\\]+}}lib{{[/\\]+}}baremetal"
 // CHECK-RV32-DEFAULTCXX-SAME: "-lc++" "-lc++abi" "-lunwind"
-// CHECK-RV32-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv32" "-o" 
"a.out"
+// CHECK-RV32-DEFAULTCXX-SAME: "-lc" "-lm" "-lclang_rt.builtins-riscv32" "-X" 
"-o" "a.out"
 
 // RUN: %clangxx %s -### 2>&1 --target=riscv32-unknown-elf \
 // RUN: --sysroot=%S/Inputs/basic_riscv32_tree/riscv32-unknown-elf \
@@ -210,7 +210,7 @@
 // CHECK-RV32-LIBCXX-SAME: 

[clang] a489e11 - [Fuchsia] Use cleaner method of adding driver binary

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-20T03:57:23Z
New Revision: a489e11439e36c7e0ec83b28a6fb1596a5c21faa

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

LOG: [Fuchsia] Use cleaner method of adding driver binary

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 464f7f89fcea..54a64a84f231 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -28,6 +28,7 @@ if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
 else()
   set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
+  set(LLVM_DRIVER_TARGET llvm-driver)
 endif()
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
@@ -294,6 +295,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
+  ${LLVM_DRIVER_TARGET}
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs
@@ -322,10 +324,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   scan-build-py
   CACHE STRING "")
 
-if(NOT WIN32)
-  list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-driver)
-endif()
-
 set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld



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


[clang] 6bb8668 - [Fuchsia] Fix driver build on Windows

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-20T03:34:26Z
New Revision: 6bb86689af7e31b23b432f3941d5ce447819ef3b

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

LOG: [Fuchsia] Fix driver build on Windows

Don't include llvm-driver when building for Windows

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 8a0d19e14a31..464f7f89fcea 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
-  llvm-driver
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs
@@ -323,6 +322,10 @@ set(LLVM_TOOLCHAIN_TOOLS
   scan-build-py
   CACHE STRING "")
 
+if(NOT WIN32)
+  list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-driver)
+endif()
+
 set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld



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


[clang] 55ab77d - Reland "[Fuchsia] Enable llvm-driver build".

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-20T01:57:40Z
New Revision: 55ab77d279a1b77ff85d0d040f867d4e764aba3b

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

LOG: Reland "[Fuchsia] Enable llvm-driver build".

The MacOS problem has been fixed. Additionally, don't enable the
driver build on Windows. We can look into enabling it later if
symlinks work better than I think on Windows.

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5a7cf6cf2c887..8a0d19e14a31e 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -26,6 +26,8 @@ set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+else()
+  set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
 endif()
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
@@ -292,6 +294,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
+  llvm-driver
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs



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


[clang] a98cafd - [CMake] Fix driver build on MacOS

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-19T23:42:11Z
New Revision: a98cafd1d0f1144bc9149f7781de41c1abf7c960

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

LOG: [CMake] Fix driver build on MacOS

Added: 


Modified: 
clang/tools/driver/CMakeLists.txt
clang/utils/perf-training/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 237ed453e28fb..2182486f93a55 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -84,7 +84,14 @@ if (APPLE)
   set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
 
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
-  target_link_libraries(clang
+
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND clang IN_LIST LLVM_DRIVER_TOOLS)
+set(TARGET_NAME llvm-driver)
+  else()
+set(TARGET_NAME clang)
+  endif()
+
+  target_link_libraries(${TARGET_NAME}
 PRIVATE
 "-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)

diff  --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index 4cd469ddde3ed..0d551baba2ccf 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -33,7 +33,9 @@ if(LLVM_BUILD_INSTRUMENTED)
 endif()
 
 find_program(DTRACE dtrace)
-if(APPLE AND DTRACE)
+# TODO: Look into supporting this for the driver build. It will require 
changing
+# the perf-helper.py file to understand to call `llvm` as `llvm clang`.
+if(APPLE AND DTRACE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg



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


[clang] c0f3ac1 - Revert "[Fuchsia] Enable llvm-driver build"

2023-02-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-17T21:29:14Z
New Revision: c0f3ac1d0015fd051144a987ff500b888a32be86

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

LOG: Revert "[Fuchsia] Enable llvm-driver build"

This reverts commit 4eadd19cc423b860f7ce0217000276da769b7809.

Doesn't work on macos. I'll investigate more

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 3369b42d17bd7..5a7cf6cf2c887 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -22,7 +22,6 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
-set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 
 if(WIN32)
@@ -293,7 +292,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
-  llvm-driver
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs



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


[clang] 4eadd19 - [Fuchsia] Enable llvm-driver build

2023-02-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-17T21:02:18Z
New Revision: 4eadd19cc423b860f7ce0217000276da769b7809

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

LOG: [Fuchsia] Enable llvm-driver build

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5a7cf6cf2c88..3369b42d17bd 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -22,6 +22,7 @@ set(LLVM_ENABLE_ZLIB ON CACHE BOOL "")
 set(LLVM_INCLUDE_DOCS OFF CACHE BOOL "")
 set(LLVM_INCLUDE_EXAMPLES OFF CACHE BOOL "")
 set(LLVM_STATIC_LINK_CXX_STDLIB ON CACHE BOOL "")
+set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
 set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 
 if(WIN32)
@@ -292,6 +293,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
+  llvm-driver
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs



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


[clang] 8704674 - [Driver] Allow test to use lld-link.exe not just lld-link

2023-02-14 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-14T23:54:25Z
New Revision: 87046744e6a8f7b78dffb61c29cbac1e0abd6921

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

LOG: [Driver] Allow test to use lld-link.exe not just lld-link

Added: 


Modified: 
clang/test/Driver/msvc-link.c

Removed: 




diff  --git a/clang/test/Driver/msvc-link.c b/clang/test/Driver/msvc-link.c
index 52efaf5ece266..b0bc837d57a62 100644
--- a/clang/test/Driver/msvc-link.c
+++ b/clang/test/Driver/msvc-link.c
@@ -34,5 +34,5 @@
 // RUN: %clang_cl -fuse-ld=lld --vfsoverlay %s -### -- %s 2>&1 | FileCheck 
--check-prefix=VFSOVERLAY %s
 // VFSOVERLAY: -cc1"
 // VFSOVERLAY: "--vfsoverlay"
-// VFSOVERLAY: lld-link"
+// VFSOVERLAY: lld-link
 // VFSOVERLAY: "/vfsoverlay:



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


[clang] df5beeb - [Driver] Add --vfsoverlay flag

2023-02-13 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-13T17:25:45Z
New Revision: df5beebc98bbe76312e3a416d5fbc563c037923c

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

LOG: [Driver] Add --vfsoverlay flag

This flag implies `-ivfsoverlay`, and additionally passes the same
argument to the linker if it supports it. At present the only linker
which does is lld-link, so this functionality has only been added to
the MSVC toolchain. Additionally this option has been made a
CoreOption so that clang-cl can use it without `-Xclang`

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

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/MSVC.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/msvc-link.c
clang/test/Driver/vfsoverlay.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 96904518a51d7..9b7f30454534b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3400,6 +3400,9 @@ def iwithsysroot : JoinedOrSeparate<["-"], 
"iwithsysroot">, Group
   Flags<[CC1Option]>;
 def ivfsoverlay : JoinedOrSeparate<["-"], "ivfsoverlay">, 
Group, Flags<[CC1Option]>,
   HelpText<"Overlay the virtual filesystem described by file over the real 
file system">;
+def vfsoverlay : JoinedOrSeparate<["-", "--"], "vfsoverlay">, 
Flags<[CC1Option, CoreOption]>,
+  HelpText<"Overlay the virtual filesystem described by file over the real 
file system. "
+   "Additionally, pass this overlay file to the linker if it supports 
it">;
 def imultilib : Separate<["-"], "imultilib">, Group;
 def keep__private__externs : Flag<["-"], "keep_private_externs">;
 def l : JoinedOrSeparate<["-"], "l">, Flags<[LinkerInput, RenderJoined]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c97856a47686a..7b91fdf933286 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7038,6 +7038,13 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 A->claim();
   }
 
+  // Forward --vfsoverlay to -cc1.
+  for (const Arg *A : Args.filtered(options::OPT_vfsoverlay)) {
+CmdArgs.push_back("--vfsoverlay");
+CmdArgs.push_back(A->getValue());
+A->claim();
+  }
+
   // Setup statistics file output.
   SmallString<128> StatsFile = getStatsFileName(Args, Output, Input, D);
   if (!StatsFile.empty())

diff  --git a/clang/lib/Driver/ToolChains/MSVC.cpp 
b/clang/lib/Driver/ToolChains/MSVC.cpp
index 223a4e8a1560f..13a7a2f47cf49 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -312,6 +312,11 @@ void visualstudio::Linker::ConstructJob(Compilation , 
const JobAction ,
   if (Linker.equals_insensitive("lld"))
 Linker = "lld-link";
 
+  if (Linker == "lld-link")
+for (Arg *A : Args.filtered(options::OPT_vfsoverlay))
+  CmdArgs.push_back(
+  Args.MakeArgString(std::string("/vfsoverlay:") + A->getValue()));
+
   if (Linker.equals_insensitive("link")) {
 // If we're using the MSVC linker, it's not sufficient to just use link
 // from the program PATH, because other environments like GnuWin32 install

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 86717cc6ebfbf..84b2345266036 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -3167,7 +3167,7 @@ static bool ParseHeaderSearchArgs(HeaderSearchOptions 
, ArgList ,
 Opts.AddSystemHeaderPrefix(
 A->getValue(), A->getOption().matches(OPT_system_header_prefix));
 
-  for (const auto *A : Args.filtered(OPT_ivfsoverlay))
+  for (const auto *A : Args.filtered(OPT_ivfsoverlay, OPT_vfsoverlay))
 Opts.AddVFSOverlayFile(A->getValue());
 
   return Diags.getNumErrors() == NumErrorsBefore;

diff  --git a/clang/test/Driver/msvc-link.c b/clang/test/Driver/msvc-link.c
index 1ee17fc63c321..52efaf5ece266 100644
--- a/clang/test/Driver/msvc-link.c
+++ b/clang/test/Driver/msvc-link.c
@@ -30,3 +30,9 @@
 // NOREPRO: "-out:msvc-link.exe"
 // NOREPRO: "-nologo"
 // NOREPRO-NOT: "-Brepro"
+
+// RUN: %clang_cl -fuse-ld=lld --vfsoverlay %s -### -- %s 2>&1 | FileCheck 
--check-prefix=VFSOVERLAY %s
+// VFSOVERLAY: -cc1"
+// VFSOVERLAY: "--vfsoverlay"
+// VFSOVERLAY: lld-link"
+// VFSOVERLAY: "/vfsoverlay:

diff  --git a/clang/test/Driver/vfsoverlay.c b/clang/test/Driver/vfsoverlay.c
index 6ae494544f9fd..694cf623c4476 100644
--- a/clang/test/Driver/vfsoverlay.c
+++ b/clang/test/Driver/vfsoverlay.c
@@ -1,5 +1,8 @@
 // RUN: %clang -ivfsoverlay foo.h -### %s 2>&1 | FileCheck %s
 // CHECK: "-ivfsoverlay" "foo.h"
 
+// 

[clang] 043550e - [Driver] Stop stack use after free

2023-02-10 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-10T22:42:12Z
New Revision: 043550e33509fb3179cfcd6516e8d93240553582

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

LOG: [Driver] Stop stack use after free

In reality this would have always been fine because main's
stack frame will always be live when another thread is
executing the cc1_reproducer_main. But ASan and HWASan
were upset

Added: 


Modified: 
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 52d391fc6971..3ec2bcc0bd75 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -537,7 +537,7 @@ int clang_main(int Argc, char **Argv, const 
llvm::ToolContext ) {
 return 1;
 
   if (!UseNewCC1Process) {
-TheDriver.CC1Main = [](SmallVectorImpl ) {
+TheDriver.CC1Main = [ToolContext](SmallVectorImpl ) {
   return ExecuteCC1Tool(ArgV, ToolContext);
 };
 // Ensure the CC1Command actually catches cc1 crashes



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


[clang] 3e57aa3 - [llvm-driver] Reinvoke clang as described by llvm driver extra args

2023-02-10 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-10T19:42:32Z
New Revision: 3e57aa304f15a0821e5bcc90bd346529fed6658d

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

LOG: [llvm-driver] Reinvoke clang as described by llvm driver extra args

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

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Job.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/Job.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Analysis/scan-build/lit.local.cfg
clang/test/CodeGen/debug-info-codeview-buildinfo.c
clang/test/Driver/check-time-trace.cpp
clang/tools/driver/cc1gen_reproducer_main.cpp
clang/tools/driver/driver.cpp
clang/tools/scan-build/libexec/ccc-analyzer
llvm/cmake/modules/llvm-driver-template.cpp.in
llvm/include/llvm/Support/LLVMDriver.h
llvm/lib/Support/Path.cpp
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc
llvm/tools/llvm-driver/llvm-driver.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 4bbb113b6cf59..c9136ec4ae690 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -21,6 +21,7 @@
 #include "clang/Driver/Types.h"
 #include "clang/Driver/Util.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Arg.h"
@@ -261,7 +262,8 @@ class Driver {
   /// When the clangDriver lib is used through clang.exe, this provides a
   /// shortcut for executing the -cc1 command-line directly, in the same
   /// process.
-  typedef int (*CC1ToolFunc)(SmallVectorImpl );
+  using CC1ToolFunc =
+  llvm::function_ref )>;
   CC1ToolFunc CC1Main = nullptr;
 
 private:
@@ -286,6 +288,12 @@ class Driver {
   /// Arguments originated from command line.
   std::unique_ptr CLOptions;
 
+  /// If this is non-null, the driver will prepend this argument before
+  /// reinvoking clang. This is useful for the llvm-driver where clang's
+  /// realpath will be to the llvm binary and not clang, so it must pass
+  /// "clang" as it's first argument.
+  const char *PrependArg;
+
   /// Whether to check that input files exist when constructing compilation
   /// jobs.
   unsigned CheckInputsExist : 1;
@@ -383,6 +391,9 @@ class Driver {
   bool getProbePrecompiled() const { return ProbePrecompiled; }
   void setProbePrecompiled(bool Value) { ProbePrecompiled = Value; }
 
+  const char *getPrependArg() const { return PrependArg; }
+  void setPrependArg(const char *Value) { PrependArg = Value; }
+
   void setTargetAndMode(const ParsedClangName ) { ClangNameParts = TM; }
 
   const std::string () { return DriverTitle; }

diff  --git a/clang/include/clang/Driver/Job.h 
b/clang/include/clang/Driver/Job.h
index e3fa92d6ad5fd..e866679dc1a91 100644
--- a/clang/include/clang/Driver/Job.h
+++ b/clang/include/clang/Driver/Job.h
@@ -116,6 +116,9 @@ class Command {
   /// The executable to run.
   const char *Executable;
 
+  /// Optional argument to prepend.
+  const char *PrependArg;
+
   /// The list of program arguments (not including the implicit first
   /// argument, which will be the executable).
   llvm::opt::ArgStringList Arguments;
@@ -169,7 +172,8 @@ class Command {
   Command(const Action , const Tool ,
   ResponseFileSupport ResponseSupport, const char *Executable,
   const llvm::opt::ArgStringList , ArrayRef 
Inputs,
-  ArrayRef Outputs = std::nullopt);
+  ArrayRef Outputs = std::nullopt,
+  const char *PrependArg = nullptr);
   // FIXME: This really shouldn't be copyable, but is currently copied in some
   // error handling in Driver::generateCompilationDiagnostics.
   Command(const Command &) = default;
@@ -242,7 +246,8 @@ class CC1Command : public Command {
  ResponseFileSupport ResponseSupport, const char *Executable,
  const llvm::opt::ArgStringList ,
  ArrayRef Inputs,
- ArrayRef Outputs = std::nullopt);
+ ArrayRef Outputs = std::nullopt,
+ const char *PrependArg = nullptr);
 
   void Print(llvm::raw_ostream , const char *Terminator, bool Quote,
  CrashReportInfo *CrashInfo = nullptr) const override;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 8d8bd55cabae6..0567441225d0c 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -200,7 +200,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef 
TargetTriple,
   DriverTitle(Title), CCCPrintBindings(false), CCPrintOptions(false),
   CCLogDiagnostics(false), CCGenDiagnostics(false),
   CCPrintProcessStats(false), 

[clang] 1f173a0 - [llvm-driver] Pass extra arguments to tools

2023-02-10 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-10T19:42:32Z
New Revision: 1f173a0653e7f0c3800033edfa16ffe4c35cde85

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

LOG: [llvm-driver] Pass extra arguments to tools

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

Added: 
llvm/include/llvm/Support/LLVMDriver.h

Modified: 
clang/tools/driver/driver.cpp
lld/tools/lld/lld.cpp
llvm/cmake/modules/llvm-driver-template.cpp.in
llvm/tools/dsymutil/CMakeLists.txt
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-ar/llvm-ar.cpp
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-driver/llvm-driver.cpp
llvm/tools/llvm-ifs/llvm-ifs.cpp
llvm/tools/llvm-lipo/llvm-lipo.cpp
llvm/tools/llvm-mt/llvm-mt.cpp
llvm/tools/llvm-nm/llvm-nm.cpp
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
llvm/tools/llvm-profdata/llvm-profdata.cpp
llvm/tools/llvm-rc/llvm-rc.cpp
llvm/tools/llvm-readobj/llvm-readobj.cpp
llvm/tools/llvm-size/llvm-size.cpp

Removed: 




diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 59d9ac0ff54db..7124742795501 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
@@ -369,7 +370,7 @@ static int ExecuteCC1Tool(SmallVectorImpl 
) {
   return 1;
 }
 
-int clang_main(int Argc, char **Argv) {
+int clang_main(int Argc, char **Argv, const llvm::ToolContext &) {
   noteBottomOfStack();
   llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL

diff  --git a/lld/tools/lld/lld.cpp b/lld/tools/lld/lld.cpp
index 3600afedddb6d..292fd9d0f9c61 100644
--- a/lld/tools/lld/lld.cpp
+++ b/lld/tools/lld/lld.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/LLVMDriver.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/PluginLoader.h"
 #include "llvm/Support/Process.h"
@@ -214,7 +215,7 @@ static unsigned inTestVerbosity() {
   return v;
 }
 
-int lld_main(int argc, char **argv) {
+int lld_main(int argc, char **argv, const llvm::ToolContext &) {
   InitLLVM x(argc, argv);
   sys::Process::UseANSIEscapeCodes(true);
 

diff  --git a/llvm/cmake/modules/llvm-driver-template.cpp.in 
b/llvm/cmake/modules/llvm-driver-template.cpp.in
index 2164fb00d168f..a828b6dadfbde 100644
--- a/llvm/cmake/modules/llvm-driver-template.cpp.in
+++ b/llvm/cmake/modules/llvm-driver-template.cpp.in
@@ -6,6 +6,9 @@
 //
 
//===--===//
 
-int @TOOL_NAME@_main(int argc, char **argv);
+#include "llvm/Support/LLVMDriver.h"
+#include "llvm/ADT/ArrayRef.h"
 
-int main(int argc, char **argv) { return @TOOL_NAME@_main(argc, argv); }
+int @TOOL_NAME@_main(int argc, char **, const llvm::ToolContext &);
+
+int main(int argc, char **argv) { return @TOOL_NAME@_main(argc, argv, {}); }

diff  --git a/llvm/include/llvm/Support/LLVMDriver.h 
b/llvm/include/llvm/Support/LLVMDriver.h
new file mode 100644
index 0..1e00c056ec4d1
--- /dev/null
+++ b/llvm/include/llvm/Support/LLVMDriver.h
@@ -0,0 +1,18 @@
+//===- LLVMDriver.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_SUPPORT_LLVMDRIVER_H
+#define LLVM_SUPPORT_LLVMDRIVER_H
+
+namespace llvm {
+
+struct ToolContext {};
+
+} // namespace llvm
+
+#endif

diff  --git a/llvm/tools/dsymutil/CMakeLists.txt 
b/llvm/tools/dsymutil/CMakeLists.txt
index ae92e3fd62671..37290d962454f 100644
--- a/llvm/tools/dsymutil/CMakeLists.txt
+++ b/llvm/tools/dsymutil/CMakeLists.txt
@@ -41,4 +41,4 @@ if(APPLE)
   target_link_libraries(dsymutil PRIVATE "-framework CoreFoundation")
 endif(APPLE)
 
-target_link_libraries(dsymutil PRIVATE ${LLVM_ATOMIC_LIB})
+# target_link_libraries(dsymutil PRIVATE ${LLVM_ATOMIC_LIB})

diff  --git a/llvm/tools/dsymutil/dsymutil.cpp 
b/llvm/tools/dsymutil/dsymutil.cpp
index 2a3a2c6613702..1c11297f940a6 100644
--- a/llvm/tools/dsymutil/dsymutil.cpp
+++ b/llvm/tools/dsymutil/dsymutil.cpp
@@ -36,6 +36,7 @@
 #include "llvm/Support/FileCollector.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/InitLLVM.h"
+#include 

[clang] 7aa2708 - [CMake] Remove libLTO from Fuchsia toolchain

2023-01-26 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-01-26T18:18:21Z
New Revision: 7aa27081e43f13d7d55d36ca6ffd83ad7b87976b

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

LOG: [CMake] Remove libLTO from Fuchsia toolchain

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 9694a0f598565..354f374e350b0 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -289,7 +289,6 @@ set(LLVM_TOOLCHAIN_TOOLS
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   lld
-  LTO
   clang-apply-replacements
   clang-doc
   clang-format



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


[clang] b712aef - [llvm-driver] Mark some tests unsupported

2023-01-07 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-01-07T17:45:26Z
New Revision: b712aef5b37e4e98fcc7bd1a6cfc3bac2d7af0d0

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

LOG: [llvm-driver] Mark some tests unsupported

These tests rely on making symlinks to unkown tool names which will
fail when in the llvm-driver build.

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/Driver/parse-progname.c
clang/test/lit.cfg.py
clang/test/lit.site.cfg.py.in
llvm/test/tools/llvm-objcopy/tool-name.test

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index b963a7542589..1d6377b5f2d8 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -16,6 +16,7 @@ llvm_canonicalize_cmake_booleans(
   LLVM_ENABLE_THREADS
   LLVM_WITH_Z3
   PPC_LINUX_DEFAULT_IEEELONGDOUBLE
+  LLVM_TOOL_LLVM_DRIVER_BUILD
   )
 
 configure_lit_site_cfg(

diff  --git a/clang/test/Driver/parse-progname.c 
b/clang/test/Driver/parse-progname.c
index ed907ea12e00..34040b81dc73 100644
--- a/clang/test/Driver/parse-progname.c
+++ b/clang/test/Driver/parse-progname.c
@@ -1,4 +1,5 @@
 // REQUIRES: shell, arm-registered-target
+// UNSUPPORTED: llvm-driver
 
 // RUN: mkdir -p %t
 

diff  --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py
index 8088ceff5c00..cc55c3c44a41 100644
--- a/clang/test/lit.cfg.py
+++ b/clang/test/lit.cfg.py
@@ -238,6 +238,9 @@ def calculate_arch_features(arch_string):
 if config.clang_vendor_uti:
 config.available_features.add('clang-vendor=' + config.clang_vendor_uti)
 
+if config.have_llvm_driver:
+  config.available_features.add('llvm-driver')
+
 def exclude_unsupported_files_for_aix(dirname):
 for filename in os.listdir(dirname):
 source_path = os.path.join( dirname, filename)

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index b9ddd0392c2f..89fedd47b008 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -39,6 +39,7 @@ config.clang_vendor_uti = "@CLANG_VENDOR_UTI@"
 config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@")
 config.standalone_build = @CLANG_BUILT_STANDALONE@
 config.ppc_linux_default_ieeelongdouble = @PPC_LINUX_DEFAULT_IEEELONGDOUBLE@
+config.have_llvm_driver = @LLVM_TOOL_LLVM_DRIVER_BUILD@
 
 import lit.llvm
 lit.llvm.initialize(lit_config, config)

diff  --git a/llvm/test/tools/llvm-objcopy/tool-name.test 
b/llvm/test/tools/llvm-objcopy/tool-name.test
index 4364d083061a..6a1f72588e23 100644
--- a/llvm/test/tools/llvm-objcopy/tool-name.test
+++ b/llvm/test/tools/llvm-objcopy/tool-name.test
@@ -1,5 +1,5 @@
 ## Don't make symlinks on Windows.
-# UNSUPPORTED: system-windows
+# UNSUPPORTED: system-windows, llvm-driver
 
 # RUN: rm -rf %t
 # RUN: mkdir %t



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


[clang] 0dff945 - Fix debug-info test

2022-11-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-11-17T16:02:54Z
New Revision: 0dff945bbca9e1c00ac76eafd1af61235272b7dd

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

LOG: Fix debug-info test

Added: 


Modified: 
clang/test/CodeGen/debug-info-sysroot-sdk.c

Removed: 




diff  --git a/clang/test/CodeGen/debug-info-sysroot-sdk.c 
b/clang/test/CodeGen/debug-info-sysroot-sdk.c
index c3e00ca4a6f0e..b52d2e1de9c1d 100644
--- a/clang/test/CodeGen/debug-info-sysroot-sdk.c
+++ b/clang/test/CodeGen/debug-info-sysroot-sdk.c
@@ -9,7 +9,7 @@ void foo(void) {}
 
 // The sysroot and sdk are LLDB-tuning-specific attributes.
 
-// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT/MacOSX.sdk",
+// LLDB: distinct !DICompileUnit({{.*}}sysroot: "/CLANG_SYSROOT/MacOSX.sdk"
 // LLDB-SAME:  sdk: "MacOSX.sdk"
 // GDB: distinct !DICompileUnit(
 // GDB-NOT: sysroot: "/CLANG_SYSROOT/MacOSX.sdk"



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


[clang] 925eaeb - Revert "[CMake] Drop libLTO and switch to PIE for Fuchsia toolchain"

2022-11-16 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-11-17T03:37:58Z
New Revision: 925eaeb3f4867c735f61d4937075b3129ece3e1d

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

LOG: Revert "[CMake] Drop libLTO and switch to PIE for Fuchsia toolchain"

This reverts commit a6f621b8cacca926d809010c135be038fd05652c.

We suspect that this patch might be the culprit that is causing
every llvm executable to be sigkill'd immediately on Apple Silicon
machines. Notably, the only other cache file with 
CMAKE_POSITION_INDEPENDENT_CODE
is Apple's and they have it off.

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 27d7d675970be..7a09e4798309e 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -14,7 +14,6 @@ set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")
 set(LLVM_ENABLE_LTO ON CACHE BOOL "")
 set(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR ON CACHE BOOL "")
-set(LLVM_ENABLE_PIC OFF CACHE BOOL "")
 set(LLVM_ENABLE_PLUGINS OFF CACHE BOOL "")
 set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
 set(LLVM_ENABLE_UNWIND_TABLES OFF CACHE BOOL "")
@@ -93,7 +92,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(BUILTINS_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING 
"")
 set(BUILTINS_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING 
"")
@@ -106,7 +104,6 @@ foreach(target 
aarch64-unknown-linux-gnu;armv7-unknown-linux-gnueabihf;i386-unkn
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(RUNTIMES_${target}_CMAKE_C_FLAGS "--target=${target}" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_CXX_FLAGS "--target=${target}" CACHE STRING 
"")
 set(RUNTIMES_${target}_CMAKE_ASM_FLAGS "--target=${target}" CACHE STRING 
"")
@@ -157,7 +154,6 @@ if(FUCHSIA_SDK)
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(BUILTINS_${target}_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
@@ -173,7 +169,6 @@ if(FUCHSIA_SDK)
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
-set(RUNTIMES_${target}_CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "")
 set(RUNTIMES_${target}_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_C_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_COMPILER_FLAGS} 
CACHE STRING "")
@@ -293,6 +288,7 @@ set(LLVM_TOOLCHAIN_TOOLS
 set(LLVM_DISTRIBUTION_COMPONENTS
   clang
   lld
+  LTO
   clang-apply-replacements
   clang-doc
   clang-format



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


[clang] 28e0798 - Revert "[Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin ARM64 platforms."

2022-11-11 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-11-11T19:40:08Z
New Revision: 28e07984c3427908c9b423c7ed0cf6ac3064c5d8

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

LOG: Revert "[Clang][AArch64][Darwin] Enable GlobalISel by default for Darwin 
ARM64 platforms."

This reverts commit f64802e8d3e9db299cad913ffcb734c8d35dc5f0.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/global-isel.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 217a277b1f2d..90c4bb51c6ec 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7225,29 +7225,15 @@ void Clang::ConstructJob(Compilation , const 
JobAction ,
   if (SplitLTOUnit)
 CmdArgs.push_back("-fsplit-lto-unit");
 
-  A = Args.getLastArg(options::OPT_fglobal_isel, options::OPT_fno_global_isel);
-  // If a configuration is fully supported, we don't issue any warnings or
-  // remarks.
-  bool IsFullySupported = getToolChain().getTriple().isOSDarwin() &&
-  Triple.getArch() == llvm::Triple::aarch64;
-  if (IsFullySupported) {
-if (A && A->getOption().matches(options::OPT_fno_global_isel)) {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-global-isel=0");
-} else {
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-global-isel=1");
-  CmdArgs.push_back("-mllvm");
-  CmdArgs.push_back("-global-isel-abort=0");
-}
-  } else if (A) {
+  if (Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
+   options::OPT_fno_global_isel)) {
 CmdArgs.push_back("-mllvm");
 if (A->getOption().matches(options::OPT_fglobal_isel)) {
   CmdArgs.push_back("-global-isel=1");
 
   // GISel is on by default on AArch64 -O0, so don't bother adding
   // the fallback remarks for it. Other combinations will add a warning of
-  // some kind, unless we're on Darwin.
+  // some kind.
   bool IsArchSupported = Triple.getArch() == llvm::Triple::aarch64;
   bool IsOptLevelSupported = false;
 

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 848b81ab54a2..333d99842e23 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -381,11 +381,10 @@ void darwin::Linker::AddLinkArgs(Compilation , const 
ArgList ,
   D.Diag(diag::err_drv_bitcode_unsupported_on_toolchain);
   }
 
-  // GlobalISel is enabled by default on AArch64 Darwin.
-  if (getToolChain().getArch() == llvm::Triple::aarch64) {
-Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
- options::OPT_fno_global_isel);
-if (!A || !A->getOption().matches(options::OPT_fno_global_isel)) {
+  // If GlobalISel is enabled, pass it through to LLVM.
+  if (Arg *A = Args.getLastArg(options::OPT_fglobal_isel,
+   options::OPT_fno_global_isel)) {
+if (A->getOption().matches(options::OPT_fglobal_isel)) {
   CmdArgs.push_back("-mllvm");
   CmdArgs.push_back("-global-isel");
   // Disable abort and fall back to SDAG silently.

diff  --git a/clang/test/Driver/global-isel.c b/clang/test/Driver/global-isel.c
index 0d3bd2b2fe26..66f196b03c1e 100644
--- a/clang/test/Driver/global-isel.c
+++ b/clang/test/Driver/global-isel.c
@@ -6,7 +6,6 @@
 // RUN: %clang -target aarch64 -fglobal-isel -S %s -### 2>&1 | FileCheck 
--check-prefix=ARM64-DEFAULT %s
 // RUN: %clang -target aarch64 -fglobal-isel -S -O0 %s -### 2>&1 | FileCheck 
--check-prefix=ARM64-O0 %s
 // RUN: %clang -target aarch64 -fglobal-isel -S -O2 %s -### 2>&1 | FileCheck 
--check-prefix=ARM64-O2 %s
-// RUN: %clang -arch arm64 -fglobal-isel -S -O2 %s -### 2>&1 | FileCheck 
--check-prefixes=DARWIN-ARM64-O2,ENABLED %s
 // RUN: %clang -target aarch64 -fglobal-isel -Wno-global-isel -S -O2 %s -### 
2>&1 | FileCheck --check-prefix=ARM64-O2-NOWARN %s
 
 // RUN: %clang -target x86_64 -fglobal-isel -S %s -### 2>&1 | FileCheck 
--check-prefix=X86_64 %s
@@ -28,7 +27,6 @@
 // ARM64-DEFAULT-NOT: warning: -fglobal-isel
 // ARM64-DEFAULT-NOT: "-global-isel-abort=2"
 // ARM64-O0-NOT: warning: -fglobal-isel
-// DARWIN-ARM64-O2-NOT: warning: -fglobal-isel
 // ARM64-O2: warning: -fglobal-isel support is incomplete for this 
architecture at the current optimization level
 // ARM64-O2: "-mllvm" "-global-isel-abort=2"
 // ARM64-O2-NOWARN-NOT: warning: -fglobal-isel



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


[clang] 78ed64d - [Driver] Don't preprocess source files when reproducing linker crashes

2022-11-02 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-11-03T00:12:10Z
New Revision: 78ed64d89fd6ea348a963516a2e49028e4079f65

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

LOG: [Driver] Don't preprocess source files when reproducing linker crashes

It's not necessary to redo the source file preprocessing for reproducing linker
crashes because we must have successfully created the object file by this point.
Skip this step, and also don't report the preprocessed source file or create
the clang invocation shell script. The latter is no longer sensible without the
preprocessed source, or helpful given the linker reproducer will have it's own
shell script.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 80e6ec76d16f7..5704902b1cc5a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1527,6 +1527,11 @@ bool Driver::getCrashDiagnosticFile(StringRef 
ReproCrashFilename,
   return false;
 }
 
+static const char BugReporMsg[] =
+"\n\n\n"
+"PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
+"Preprocessed source(s) and associated run script(s) are located at:";
+
 // When clang crashes, produce diagnostic information including the fully
 // preprocessed source file(s).  Request that the developer attach the
 // diagnostic information to a bug report.
@@ -1582,6 +1587,29 @@ void Driver::generateCompilationDiagnostics(
   // Suppress tool output.
   C.initCompilationForDiagnostics();
 
+  // If lld failed, rerun it again with --reproduce.
+  if (IsLLD) {
+const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
+Command NewLLDInvocation = Cmd;
+llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
+StringRef ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce=";
+ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
+NewLLDInvocation.replaceArguments(std::move(ArgList));
+
+// Redirect stdout/stderr to /dev/null.
+NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
+Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
+Diag(clang::diag::note_drv_command_failed_diag_msg) << TmpName;
+Diag(clang::diag::note_drv_command_failed_diag_msg)
+<< "\n\n";
+if (Report)
+  Report->TemporaryFiles.push_back(TmpName);
+return;
+  }
+
   // Construct the list of inputs.
   InputList Inputs;
   BuildInputs(C.getDefaultToolChain(), C.getArgs(), Inputs);
@@ -1659,22 +1687,6 @@ void Driver::generateCompilationDiagnostics(
 return;
   }
 
-  // If lld failed, rerun it again with --reproduce.
-  if (IsLLD) {
-const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
-Command NewLLDInvocation = Cmd;
-llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-StringRef ReproduceOption =
-C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
-? "/reproduce:"
-: "--reproduce=";
-ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
-NewLLDInvocation.replaceArguments(std::move(ArgList));
-
-// Redirect stdout/stderr to /dev/null.
-NewLLDInvocation.Execute({None, {""}, {""}}, nullptr, nullptr);
-  }
-
   const ArgStringList  = C.getTempFiles();
   if (TempFiles.empty()) {
 Diag(clang::diag::note_drv_command_failed_diag_msg)
@@ -1682,10 +1694,7 @@ void Driver::generateCompilationDiagnostics(
 return;
   }
 
-  Diag(clang::diag::note_drv_command_failed_diag_msg)
-  << "\n\n\n"
- "PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:\n"
- "Preprocessed source(s) and associated run script(s) are located at:";
+  Diag(clang::diag::note_drv_command_failed_diag_msg) << BugReporMsg;
 
   SmallString<128> VFS;
   SmallString<128> ReproCrashFilename;

diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 7436d1a1f59be..1333f68d911ee 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,22 +1,28 @@
 // REQUIRES: lld
 // UNSUPPORTED: ps4, ps5
 
-// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: echo "-nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t" \
+// RUN:   | sed -e 's/\\//g' > %t.rsp
+
+// RUN: not %clang %s @%t.rsp -fcrash-diagnostics=all 2>&1 \
+// RUN:   | FileCheck %s
+
+// Test that the reproducer 

[clang] 443e2a1 - Reland "[PGO] Make emitted symbols hidden"

2022-10-26 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-10-26T17:13:05Z
New Revision: 443e2a10f69caeedb9fa621366b16fe0d4358279

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

LOG: Reland "[PGO] Make emitted symbols hidden"

This was reverted because it was breaking when targeting Darwin which
tried to export these symbols which are now hidden. It should be safe
to just stop attempting to export these symbols in the clang driver,
though Apple folks will need to change their TAPI allow list described
in the commit where these symbols were originally exported
https://github.com/llvm/llvm-project/commit/f5380185623be243ba0f1b18d4bd594ac5cc7163

Then reverted again because it broke tests on MacOS, they should be
fixed now.

Bug: https://github.com/llvm/llvm-project/issues/58265

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

Added: 
llvm/test/Transforms/PGOProfile/filename.ll

Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c
compiler-rt/lib/profile/InstrProfilingNameVar.c
compiler-rt/lib/profile/InstrProfilingVersionVar.c
compiler-rt/test/profile/instrprof-darwin-dead-strip.c
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/branch1.ll
llvm/test/Transforms/PGOProfile/branch2.ll
llvm/test/Transforms/PGOProfile/comdat_internal.ll
llvm/test/Transforms/PGOProfile/criticaledge.ll
llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
llvm/test/Transforms/PGOProfile/landingpad.ll
llvm/test/Transforms/PGOProfile/loop1.ll
llvm/test/Transforms/PGOProfile/loop2.ll
llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
llvm/test/Transforms/PGOProfile/single_bb.ll
llvm/test/Transforms/PGOProfile/switch.ll
llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 1a02d3cfbac7c..39f459e9ef652 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1353,16 +1353,11 @@ void Darwin::addProfileRTLibs(const ArgList ,
   // If we have a symbol export directive and we're linking in the profile
   // runtime, automatically export symbols necessary to implement some of the
   // runtime's functionality.
-  if (hasExportSymbolDirective(Args)) {
-if (ForGCOV) {
-  addExportedSymbol(CmdArgs, "___gcov_dump");
-  addExportedSymbol(CmdArgs, "___gcov_reset");
-  addExportedSymbol(CmdArgs, "_writeout_fn_list");
-  addExportedSymbol(CmdArgs, "_reset_fn_list");
-} else {
-  addExportedSymbol(CmdArgs, "___llvm_profile_filename");
-  addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-}
+  if (hasExportSymbolDirective(Args) && ForGCOV) {
+addExportedSymbol(CmdArgs, "___gcov_dump");
+addExportedSymbol(CmdArgs, "___gcov_reset");
+addExportedSymbol(CmdArgs, "_writeout_fn_list");
+addExportedSymbol(CmdArgs, "_reset_fn_list");
   }
 
   // Align __llvm_prf_{cnts,data} sections to the maximum expected page

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index 5be119a545a63..13ec69b2db1ab 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -338,18 +338,6 @@
 // RUN: FileCheck -check-prefix=PROFILE_SECTALIGN %s < %t.log
 // PROFILE_SECTALIGN: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x4000" 
"-sectalign" "__DATA" "__llvm_prf_data" "0x4000"
 
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-exported_symbols_list /dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbol,foo -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbol -Xlinker foo -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version"
-//
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
--coverage -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
 // NO_PROFILE_EXPORT-NOT: "-exported_symbol"

diff  

[clang] 4981a18 - [Driver][Fuchsia] Make -mfix-cortex-a53-835769 default when targeting Fuchsia

2022-10-25 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-10-25T19:17:52Z
New Revision: 4981a186b3aa5fbe207dce4902d4dce504974f3f

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

LOG: [Driver][Fuchsia] Make -mfix-cortex-a53-835769 default when targeting 
Fuchsia

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Driver/aarch64-fix-cortex-a53-835769.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 7956a0be46280..514db4ca4f7e3 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "AArch64.h"
+#include "../CommonArgs.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -615,6 +616,10 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
   } else if (Triple.isAndroid()) {
 // Enabled A53 errata (835769) workaround by default on android
 Features.push_back("+fix-cortex-a53-835769");
+  } else if (Triple.isOSFuchsia()) {
+std::string CPU = getCPUName(D, Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  Features.push_back("+fix-cortex-a53-835769");
   }
 
   if (Args.getLastArg(options::OPT_mno_bti_at_return_twice))

diff  --git a/clang/test/Driver/aarch64-fix-cortex-a53-835769.c 
b/clang/test/Driver/aarch64-fix-cortex-a53-835769.c
index 287d9bcd5797e..7e809866fc502 100644
--- a/clang/test/Driver/aarch64-fix-cortex-a53-835769.c
+++ b/clang/test/Driver/aarch64-fix-cortex-a53-835769.c
@@ -8,6 +8,12 @@
 // RUN: %clang -target aarch64-android-eabi %s -### 2>&1 \
 // RUN:   | FileCheck --check-prefix=CHECK-YES %s
 
+// RUN: %clang --target=aarch64-fuchsia %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-YES %s
+
+// RUN: %clang --target=aarch64-fuchsia -mcpu=cortex-a73 %s -### 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-DEF %s
+
 // CHECK-DEF-NOT: "{[+-]}fix-cortex-a53-835769"
 // CHECK-YES: "+fix-cortex-a53-835769"
 // CHECK-NO: "-fix-cortex-a53-835769"



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


[clang] 0487728 - [PGO] Make emitted symbols hidden

2022-10-24 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-10-24T19:05:10Z
New Revision: 04877284b4592e9286cab43467662c1b4ff81861

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

LOG: [PGO] Make emitted symbols hidden

This was reverted because it was breaking when targeting Darwin which
tried to export these symbols which are now hidden. It should be safe
to just stop attempting to export these symbols in the clang driver,
though Apple folks will need to change their TAPI allow list described
in the commit where these symbols were originally exported
https://github.com/llvm/llvm-project/commit/f5380185623be243ba0f1b18d4bd594ac5cc7163

Bug: https://github.com/llvm/llvm-project/issues/58265

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c
compiler-rt/lib/profile/InstrProfilingNameVar.c
compiler-rt/lib/profile/InstrProfilingVersionVar.c
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/branch1.ll
llvm/test/Transforms/PGOProfile/branch2.ll
llvm/test/Transforms/PGOProfile/comdat_internal.ll
llvm/test/Transforms/PGOProfile/criticaledge.ll
llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
llvm/test/Transforms/PGOProfile/landingpad.ll
llvm/test/Transforms/PGOProfile/loop1.ll
llvm/test/Transforms/PGOProfile/loop2.ll
llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
llvm/test/Transforms/PGOProfile/single_bb.ll
llvm/test/Transforms/PGOProfile/switch.ll
llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 1a02d3cfbac7c..39f459e9ef652 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1353,16 +1353,11 @@ void Darwin::addProfileRTLibs(const ArgList ,
   // If we have a symbol export directive and we're linking in the profile
   // runtime, automatically export symbols necessary to implement some of the
   // runtime's functionality.
-  if (hasExportSymbolDirective(Args)) {
-if (ForGCOV) {
-  addExportedSymbol(CmdArgs, "___gcov_dump");
-  addExportedSymbol(CmdArgs, "___gcov_reset");
-  addExportedSymbol(CmdArgs, "_writeout_fn_list");
-  addExportedSymbol(CmdArgs, "_reset_fn_list");
-} else {
-  addExportedSymbol(CmdArgs, "___llvm_profile_filename");
-  addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-}
+  if (hasExportSymbolDirective(Args) && ForGCOV) {
+addExportedSymbol(CmdArgs, "___gcov_dump");
+addExportedSymbol(CmdArgs, "___gcov_reset");
+addExportedSymbol(CmdArgs, "_writeout_fn_list");
+addExportedSymbol(CmdArgs, "_reset_fn_list");
   }
 
   // Align __llvm_prf_{cnts,data} sections to the maximum expected page

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index 5be119a545a63..13ec69b2db1ab 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -338,18 +338,6 @@
 // RUN: FileCheck -check-prefix=PROFILE_SECTALIGN %s < %t.log
 // PROFILE_SECTALIGN: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x4000" 
"-sectalign" "__DATA" "__llvm_prf_data" "0x4000"
 
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-exported_symbols_list /dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbol,foo -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbol -Xlinker foo -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version"
-//
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
--coverage -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
 // NO_PROFILE_EXPORT-NOT: "-exported_symbol"

diff  --git a/compiler-rt/lib/profile/InstrProfilingNameVar.c 
b/compiler-rt/lib/profile/InstrProfilingNameVar.c
index 2d67a55b985cf..407272806ba3c 100644
--- 

[clang] ecac223 - [PGO] Make emitted symbols hidden

2022-10-13 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-10-13T19:47:15Z
New Revision: ecac223b0e4b05a65cf918f90824380db6b9ce64

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

LOG: [PGO] Make emitted symbols hidden

This was reverted because it was breaking when targeting Darwin which
tried to export these symbols which are now hidden. It should be safe
to just stop attempting to export these symbols in the clang driver,
though Apple folks will need to change their TAPI allow list described
in the commit where these symbols were originally exported
https://github.com/llvm/llvm-project/commit/f5380185623be243ba0f1b18d4bd594ac5cc7163

Bug: https://github.com/llvm/llvm-project/issues/58265

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

Added: 
llvm/test/Transforms/PGOProfile/filename.ll

Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c
llvm/lib/ProfileData/InstrProf.cpp
llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
llvm/test/Transforms/PGOProfile/branch1.ll
llvm/test/Transforms/PGOProfile/branch2.ll
llvm/test/Transforms/PGOProfile/comdat_internal.ll
llvm/test/Transforms/PGOProfile/criticaledge.ll
llvm/test/Transforms/PGOProfile/instr_entry_bb.ll
llvm/test/Transforms/PGOProfile/landingpad.ll
llvm/test/Transforms/PGOProfile/loop1.ll
llvm/test/Transforms/PGOProfile/loop2.ll
llvm/test/Transforms/PGOProfile/lto_cspgo_gen.ll
llvm/test/Transforms/PGOProfile/single_bb.ll
llvm/test/Transforms/PGOProfile/switch.ll
llvm/test/Transforms/PGOProfile/thinlto_cspgo_gen.ll

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 758961d3bf79a..2bb8132a9a6b4 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1353,16 +1353,11 @@ void Darwin::addProfileRTLibs(const ArgList ,
   // If we have a symbol export directive and we're linking in the profile
   // runtime, automatically export symbols necessary to implement some of the
   // runtime's functionality.
-  if (hasExportSymbolDirective(Args)) {
-if (ForGCOV) {
-  addExportedSymbol(CmdArgs, "___gcov_dump");
-  addExportedSymbol(CmdArgs, "___gcov_reset");
-  addExportedSymbol(CmdArgs, "_writeout_fn_list");
-  addExportedSymbol(CmdArgs, "_reset_fn_list");
-} else {
-  addExportedSymbol(CmdArgs, "___llvm_profile_filename");
-  addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-}
+  if (hasExportSymbolDirective(Args) && ForGCOV) {
+addExportedSymbol(CmdArgs, "___gcov_dump");
+addExportedSymbol(CmdArgs, "___gcov_reset");
+addExportedSymbol(CmdArgs, "_writeout_fn_list");
+addExportedSymbol(CmdArgs, "_reset_fn_list");
   }
 
   // Align __llvm_prf_{cnts,data} sections to the maximum expected page

diff  --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index 5be119a545a63..13ec69b2db1ab 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -338,18 +338,6 @@
 // RUN: FileCheck -check-prefix=PROFILE_SECTALIGN %s < %t.log
 // PROFILE_SECTALIGN: "-sectalign" "__DATA" "__llvm_prf_cnts" "0x4000" 
"-sectalign" "__DATA" "__llvm_prf_data" "0x4000"
 
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-exported_symbols_list /dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbols_list,/dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
-Wl,-exported_symbol,foo -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbol -Xlinker foo -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
-// RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version"
-//
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
--coverage -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log
 // NO_PROFILE_EXPORT-NOT: "-exported_symbol"

diff  --git a/llvm/lib/ProfileData/InstrProf.cpp 
b/llvm/lib/ProfileData/InstrProf.cpp
index 9c04bcb8416f5..eab1eab82ac2f 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -1210,6 +1210,7 @@ void 

[clang] 3b0df70 - [llvm-driver] Support single distributions

2022-10-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-10-01T20:20:28Z
New Revision: 3b0df701b0d95612e5da3544e2361808b78a6015

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

LOG: [llvm-driver] Support single distributions

`LLVM_DISTRIBUTION_COMPONENTS` now influences the llvm binary in the
normal cmake output directory when it is set. This allows for
distribution targets to only include tools they want in the llvm
binary. It must be done this way because only one target can be
associated with a specific output name.

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/LLVMDistributionSupport.cmake

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 823b6dc1b9796..495ed1c6f18a1 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -153,7 +153,10 @@ macro(add_clang_tool name)
   if (NOT CLANG_BUILD_TOOLS)
 set(EXCLUDE_FROM_ALL ON)
   endif()
-  if(ARG_GENERATE_DRIVER AND LLVM_TOOL_LLVM_DRIVER_BUILD)
+  if(ARG_GENERATE_DRIVER
+ AND LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 set(get_obj_args ${ARGN})
 list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
 generate_llvm_objects(${name} ${get_obj_args})
@@ -181,7 +184,10 @@ endmacro()
 
 macro(add_clang_symlink name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
-  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND ${dest} IN_LIST LLVM_DRIVER_TOOLS
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${dest} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} 
${name})
   else()
 llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE)

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 67806e16814da..152325beca760 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -910,7 +910,9 @@ macro(generate_llvm_objects name)
 
 list(APPEND ALL_FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-driver.cpp)
 
-if (LLVM_TOOL_LLVM_DRIVER_BUILD)
+if (LLVM_TOOL_LLVM_DRIVER_BUILD
+AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+   )
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_COMPONENTS 
${LLVM_LINK_COMPONENTS})
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_DEPS ${ARG_DEPENDS} 
${LLVM_COMMON_DEPENDS})
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_OBJLIBS "${obj_name}")
@@ -1301,7 +1303,10 @@ macro(llvm_add_tool project name)
   if( NOT LLVM_BUILD_TOOLS )
 set(EXCLUDE_FROM_ALL ON)
   endif()
-  if(ARG_GENERATE_DRIVER AND LLVM_TOOL_LLVM_DRIVER_BUILD)
+  if(ARG_GENERATE_DRIVER
+ AND LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${name} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 generate_llvm_objects(${name} ${ARGN})
 add_custom_target(${name} DEPENDS llvm-driver)
   else()
@@ -2032,7 +2037,10 @@ endfunction()
 
 function(llvm_install_symlink project name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
-  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD
+ AND ${dest} IN_LIST LLVM_DRIVER_TOOLS
+ AND (NOT LLVM_DISTRIBUTION_COMPONENTS OR ${dest} IN_LIST 
LLVM_DISTRIBUTION_COMPONENTS)
+)
 return()
   endif()
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})

diff  --git a/llvm/cmake/modules/LLVMDistributionSupport.cmake 
b/llvm/cmake/modules/LLVMDistributionSupport.cmake
index 526f36dcda830..0b78f8f9137c5 100644
--- a/llvm/cmake/modules/LLVMDistributionSupport.cmake
+++ b/llvm/cmake/modules/LLVMDistributionSupport.cmake
@@ -244,6 +244,8 @@ function(llvm_distribution_add_targets)
 set(distributions "")
   endif()
 
+  get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY 
LLVM_DRIVER_TOOL_SYMLINKS)
+
   foreach(distribution ${distributions})
 if(distribution STREQUAL "")
   set(distribution_target distribution)
@@ -268,12 +270,16 @@ function(llvm_distribution_add_targets)
 
   if(TARGET install-${target})
 add_dependencies(install-${distribution_target} install-${target})
+  elseif(TARGET install-llvm-driver AND ${target} IN_LIST 
LLVM_DRIVER_TOOL_SYMLINKS)
+add_dependencies(install-${distribution_target} install-llvm-driver)
   else()
 message(SEND_ERROR "Specified distribution component '${target}' 
doesn't have an install 

[clang] aa1c58b - [llvm-driver][NFC] Simplify handling of tool symlinks

2022-10-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-10-01T20:18:49Z
New Revision: aa1c58b9c67a30228a59df18e004d0c6e2c02d3e

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

LOG: [llvm-driver][NFC] Simplify handling of tool symlinks

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
llvm/cmake/modules/AddLLVM.cmake
llvm/tools/llvm-driver/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index d952ff3165587..823b6dc1b9796 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -182,7 +182,7 @@ endmacro()
 macro(add_clang_symlink name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
-set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${dest} 
${name})
   else()
 llvm_add_tool_symlink(CLANG ${name} ${dest} ALWAYS_GENERATE)
 # Always generate install targets

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 946d66140fa3e..67806e16814da 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -916,6 +916,7 @@ macro(generate_llvm_objects name)
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_OBJLIBS "${obj_name}")
 
   set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOLS ${name})
+  set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${name} 
${name})
   target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB})
   llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
 endif()
@@ -2032,7 +2033,6 @@ endfunction()
 function(llvm_install_symlink project name dest)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
-set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
 return()
   endif()
   cmake_parse_arguments(ARG "ALWAYS_GENERATE" "COMPONENT" "" ${ARGN})
@@ -2079,11 +2079,7 @@ function(llvm_add_tool_symlink project link_name target)
   get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
 
   if (${target} IN_LIST LLVM_DRIVER_TOOLS)
-string(REPLACE "-" "_" tool_entry ${target})
-string(REPLACE "-" "_" key ${link_name})
-string(REPLACE "llvm-" "" tool_name ${link_name})
-set_property(GLOBAL APPEND_STRING PROPERTY
- LLVM_EXTRA_DRIVER_ENTRIES "LLVM_DRIVER_TOOL(\"${tool_name}\", 
${tool_entry})\n")
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_ALIASES_${target} 
${link_name})
   endif()
   set(dest_binary "$")
 

diff  --git a/llvm/tools/llvm-driver/CMakeLists.txt 
b/llvm/tools/llvm-driver/CMakeLists.txt
index 148e54b33b0e3..e709cd7fdb56d 100644
--- a/llvm/tools/llvm-driver/CMakeLists.txt
+++ b/llvm/tools/llvm-driver/CMakeLists.txt
@@ -5,15 +5,17 @@ get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY 
LLVM_DRIVER_TOOLS)
 
 foreach(tool ${LLVM_DRIVER_TOOLS})
   string(REPLACE "-" "_" tool_entry ${tool})
-  string(REPLACE "llvm-" "" tool ${tool})
-  set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${tool}\", ${tool_entry})\n")
+  get_property(tool_aliases GLOBAL PROPERTY LLVM_DRIVER_TOOL_ALIASES_${tool})
+  foreach(alias ${tool_aliases})
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${alias})
+string(REPLACE "llvm-" "" alias ${alias})
+set(def_decl "${def_decl}LLVM_DRIVER_TOOL(\"${alias}\", ${tool_entry})\n")
+  endforeach()
 endforeach()
 
-get_property(LLVM_EXTRA_DRIVER_ENTRIES GLOBAL PROPERTY 
LLVM_EXTRA_DRIVER_ENTRIES)
-
 file(WRITE
   "${CMAKE_CURRENT_BINARY_DIR}/LLVMDriverTools.def"
-  "${def_decl}${LLVM_EXTRA_DRIVER_ENTRIES}#undef LLVM_DRIVER_TOOL\n")
+  "${def_decl}#undef LLVM_DRIVER_TOOL\n")
 
 target_include_directories(llvm-driver PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
 target_sources(llvm-driver PRIVATE llvm-driver.cpp)
@@ -28,9 +30,8 @@ if(APPLE)
 endif(APPLE)
 
 macro(generate_driver_tool_targets)
-  get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
   get_property(LLVM_DRIVER_TOOL_SYMLINKS GLOBAL PROPERTY 
LLVM_DRIVER_TOOL_SYMLINKS)
-  foreach(name IN LISTS LLVM_DRIVER_TOOLS LLVM_DRIVER_TOOL_SYMLINKS)
+  foreach(name ${LLVM_DRIVER_TOOL_SYMLINKS})
 add_llvm_tool_symlink(${name} llvm-driver ALWAYS_GENERATE)
 # Always generate install targets
 llvm_install_symlink(LLVM ${name} llvm-driver ALWAYS_GENERATE)



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


[clang] 9ec7272 - Revert "[Driver][Fuchsia] Add default linker flags"

2022-09-30 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-09-30T14:54:48Z
New Revision: 9ec7272fc5eab5295372d46f2f1d59b10907c093

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

LOG: Revert "[Driver][Fuchsia] Add default linker flags"

This reverts commit 5dfc8ebee5d688ee94607ccce655672c1a198b82.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 2e47a96bcfe3..6f4fa2ce7c40 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -65,12 +65,6 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rel");
 CmdArgs.push_back("--pack-dyn-relocs=relr");
-  } else {
-// The following are already the default in lld
-CmdArgs.push_back("-z");
-CmdArgs.push_back("combreloc");
-CmdArgs.push_back("-z");
-CmdArgs.push_back("text");
   }
 
   if (!D.SysRoot.empty())

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 00c763a140c3..099a88c2e4e3 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -1,35 +1,27 @@
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
-// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
-// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN: --sysroot=%S/platform 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
-// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
-// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
-// RUN: --sysroot=%S/platform -fuse-ld=gold 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LD,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
 // RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
 // RUN: %clang -### %s --target=riscv64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
 // RUN: %clang -### %s --target=x86_64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
 // RUN: %clang -### %s --target=aarch64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
 // RUN: %clang -### %s --target=riscv64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
 // CHECK: "-cc1"
 // CHECK-X86_64: "-triple" "x86_64-unknown-fuchsia"
 // CHECK-AARCH64: "-triple" "aarch64-unknown-fuchsia"
@@ -44,8 +36,7 @@
 // CHECK: "-stack-protector" "2"
 // CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
-// CHECK-LLD: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
-// CHECK-LD: {{.*}}ld.gold{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"combreloc" "-z" "text"
+// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"

diff  --git a/clang/test/Driver/fuchsia.cpp b/clang/test/Driver/fuchsia.cpp
index e247c76dabdd..e5640f582627 100644
--- a/clang/test/Driver/fuchsia.cpp
+++ b/clang/test/Driver/fuchsia.cpp
@@ -2,42 +2,32 @@
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: 

[clang] 5dfc8eb - [Driver][Fuchsia] Add default linker flags

2022-09-30 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-09-30T14:07:41Z
New Revision: 5dfc8ebee5d688ee94607ccce655672c1a198b82

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

LOG: [Driver][Fuchsia] Add default linker flags

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c
clang/test/Driver/fuchsia.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 6f4fa2ce7c40a..2e47a96bcfe3f 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -65,6 +65,12 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rel");
 CmdArgs.push_back("--pack-dyn-relocs=relr");
+  } else {
+// The following are already the default in lld
+CmdArgs.push_back("-z");
+CmdArgs.push_back("combreloc");
+CmdArgs.push_back("-z");
+CmdArgs.push_back("text");
   }
 
   if (!D.SysRoot.empty())

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index 099a88c2e4e36..00c763a140c30 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -1,27 +1,35 @@
 // RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
+// RUN: %clang -### %s --target=x86_64-unknown-fuchsia \
+// RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
+// RUN: --sysroot=%S/platform -fuse-ld=gold 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LD,CHECK-X86_64 %s
 // RUN: %clang -### %s --target=aarch64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
 // RUN: %clang -### %s --target=riscv64-unknown-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
 // RUN: %clang -### %s --target=x86_64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-X86_64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-X86_64 %s
 // RUN: %clang -### %s --target=aarch64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-AARCH64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-AARCH64 %s
 // RUN: %clang -### %s --target=riscv64-fuchsia \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_per_target_subdir \
 // RUN: --sysroot=%S/platform -fuse-ld=lld 2>&1 \
-// RUN: | FileCheck -check-prefixes=CHECK,CHECK-RISCV64 %s
+// RUN: | FileCheck -check-prefixes=CHECK,CHECK-LLD,CHECK-RISCV64 %s
 // CHECK: "-cc1"
 // CHECK-X86_64: "-triple" "x86_64-unknown-fuchsia"
 // CHECK-AARCH64: "-triple" "aarch64-unknown-fuchsia"
@@ -36,7 +44,8 @@
 // CHECK: "-stack-protector" "2"
 // CHECK-AARCH64: "-target-feature" "+outline-atomics"
 // CHECK-NOT: "-fcommon"
-// CHECK: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
+// CHECK-LLD: {{.*}}ld.lld{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"rodynamic" "-z" "separate-loadable-segments" "-z" "rel" 
"--pack-dyn-relocs=relr"
+// CHECK-LD: {{.*}}ld.gold{{.*}}" "-z" "max-page-size=4096" "-z" "now" "-z" 
"combreloc" "-z" "text"
 // CHECK: "--sysroot=[[SYSROOT]]"
 // CHECK: "-pie"
 // CHECK: "--build-id"

diff  --git a/clang/test/Driver/fuchsia.cpp b/clang/test/Driver/fuchsia.cpp
index e5640f5826271..e247c76dabdd7 100644
--- a/clang/test/Driver/fuchsia.cpp
+++ b/clang/test/Driver/fuchsia.cpp
@@ -2,32 +2,42 @@
 // RUN: -ccc-install-dir %S/Inputs/basic_fuchsia_tree/bin \
 // RUN: 

[clang] 16f735d - [Driver] Make --execute-only the default for aarch64-fuchsia

2022-09-20 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-09-20T18:25:16Z
New Revision: 16f735d2fbe8660659f1dde10eea79b0f0f7c11d

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

LOG: [Driver] Make --execute-only the default for aarch64-fuchsia

Clang already generates code that doesn't use writeable data in executable
sections so the linker flag is all that is necessary.

-Wl,--no-execute-only can be used to turn this default off.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Fuchsia.cpp
clang/test/Driver/fuchsia.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index d63c69c63b1f..6f4fa2ce7c40 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -87,6 +87,8 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   }
 
   if (ToolChain.getArch() == llvm::Triple::aarch64) {
+CmdArgs.push_back("--execute-only");
+
 std::string CPU = getCPUName(D, Args, Triple);
 if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
   CmdArgs.push_back("--fix-cortex-a53-843419");

diff  --git a/clang/test/Driver/fuchsia.c b/clang/test/Driver/fuchsia.c
index ce356a4faca1..099a88c2e4e3 100644
--- a/clang/test/Driver/fuchsia.c
+++ b/clang/test/Driver/fuchsia.c
@@ -41,7 +41,7 @@
 // CHECK: "-pie"
 // CHECK: "--build-id"
 // CHECK: "--hash-style=gnu"
-// CHECK-AARCH64: "--fix-cortex-a53-843419"
+// CHECK-AARCH64: "--execute-only" "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
 // CHECK-RISCV64: "-X"
 // CHECK: Scrt1.o



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


[clang] f6d6e33 - [clang] Give better message for unsupported no_sanitize on globals

2022-09-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-09-01T22:35:42Z
New Revision: f6d6e33abc2e8657b04721841d15191b7c3ff3d1

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

LOG: [clang] Give better message for unsupported no_sanitize on globals

Previously if you specified no_sanitize("known_sanitizer") on a global you
would yield a misleading error "'no_sanitize' attribute only applies to
functions and methods", but no_sanitize("unknown") would simply be a warning,
"unknown sanitizer 'unknown' ignored". This changes the former to a warning
"'no_sanitize' attribute argument not supported for globals: known_sanitizer".

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/SemaCXX/attr-no-sanitize.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8034e79860182..41fb9e4035e69 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -127,6 +127,9 @@ Improvements to Clang's diagnostics
   supports both c and c++ language.
 - When diagnosing multi-level pack expansions of mismatched lengths, Clang will
   now, in most cases, be able to point to the relevant outer parameter.
+- no_sanitize("...") on a global variable for known but not relevant sanitizers
+  is now just a warning. It now says that this will be ignored instead of
+  incorrectly saying no_sanitize only applies to functions and methods.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 160b931007adf..f6e89b5219f83 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4052,6 +4052,9 @@ def warn_transparent_union_attribute_zero_fields : 
Warning<
 def warn_attribute_type_not_supported : Warning<
   "%0 attribute argument not supported: %1">,
   InGroup;
+def warn_attribute_type_not_supported_global : Warning<
+  "%0 attribute argument '%1' not supported on a global variable">,
+  InGroup;
 def warn_attribute_unknown_visibility : Warning<"unknown visibility %0">,
   InGroup;
 def warn_attribute_protected_visibility :

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 9318437e19915..5b3d4aec6d54d 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -7877,8 +7877,8 @@ static void handleNoSanitizeAttr(Sema , Decl *D, const 
ParsedAttr ) {
 SanitizerName != "coverage")
   S.Diag(LiteralLoc, diag::warn_unknown_sanitizer_ignored) << 
SanitizerName;
 else if (isGlobalVar(D) && 
!isSanitizerAttributeAllowedOnGlobals(SanitizerName))
-  S.Diag(D->getLocation(), diag::err_attribute_wrong_decl_type)
-  << AL << ExpectedFunctionOrMethod;
+  S.Diag(D->getLocation(), diag::warn_attribute_type_not_supported_global)
+  << AL << SanitizerName;
 Sanitizers.push_back(SanitizerName);
   }
 

diff  --git a/clang/test/SemaCXX/attr-no-sanitize.cpp 
b/clang/test/SemaCXX/attr-no-sanitize.cpp
index feff7ef6163dc..9e13fd3c02702 100644
--- a/clang/test/SemaCXX/attr-no-sanitize.cpp
+++ b/clang/test/SemaCXX/attr-no-sanitize.cpp
@@ -6,6 +6,9 @@ int f1() __attribute__((no_sanitize)); // 
expected-error{{'no_sanitize' attribut
 
 int f2() __attribute__((no_sanitize(1))); // expected-error{{'no_sanitize' 
attribute requires a string}}
 
+__attribute__((no_sanitize("all"))) int global; // 
expected-warning{{'no_sanitize' attribute argument 'all' not supported on a 
global variable}}
+__attribute__((no_sanitize("unknown"))) int global2; // 
expected-warning{{unknown sanitizer 'unknown' ignored}}
+
 // DUMP-LABEL: FunctionDecl {{.*}} f3
 // DUMP: NoSanitizeAttr {{.*}} address
 // PRINT: int f3() __attribute__((no_sanitize("address")))



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


[clang] c175d80 - [clang][test] Recognize leading unscore for macos

2022-08-18 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-18T21:03:28Z
New Revision: c175d80be2ed496debb98d47f315aa5e60116768

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

LOG: [clang][test] Recognize leading unscore for macos

Additionally mark this test unsupported for ps5 in addition
to ps4, niether support -fuse-ld=

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 26b5846e8a49..7436d1a1f59b 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,11 +1,11 @@
 // REQUIRES: lld
-// UNSUPPORTED: ps4
+// UNSUPPORTED: ps4, ps5
 
 // RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
-// CHECK: error: undefined symbol: a
+// CHECK: error: undefined symbol: {{_?}}a
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.c



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


[clang] 377dddf - [clang][Driver] Pass correct reproduce flag to lld-link

2022-08-18 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-18T20:12:23Z
New Revision: 377dddf4a08335a79180dd1d7907cb98ceaa641a

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

LOG: [clang][Driver] Pass correct reproduce flag to lld-link

Additionally, the explicit linux target has been removed from the test.

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

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 31cd5865c8168..d00f08d15ae58 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1631,7 +1631,11 @@ void Driver::generateCompilationDiagnostics(
 const char *TmpName = CreateTempFile(C, "linker-crash", "tar");
 Command NewLLDInvocation = Cmd;
 llvm::opt::ArgStringList ArgList = NewLLDInvocation.getArguments();
-ArgList.push_back(Saver.save(Twine{"--reproduce="} + TmpName).data());
+StringRef ReproduceOption =
+C.getDefaultToolChain().getTriple().isWindowsMSVCEnvironment()
+? "/reproduce:"
+: "--reproduce=";
+ArgList.push_back(Saver.save(Twine(ReproduceOption) + TmpName).data());
 NewLLDInvocation.replaceArguments(std::move(ArgList));
 
 // Redirect stdout/stderr to /dev/null.

diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 65d562996e62f..26b5846e8a496 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,6 +1,7 @@
-// REQUIRES: lld, x86-registered-target
+// REQUIRES: lld
+// UNSUPPORTED: ps4
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +14,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -nostartfiles -nostdlib -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[clang] 9bf6ecc - [clang] Only run test on x86

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-02T00:56:05Z
New Revision: 9bf6eccae112476d953180e814781b99237bd0bb

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

LOG: [clang] Only run test on x86

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 7db0e2e188c2..65d562996e62 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,4 +1,4 @@
-// REQUIRES: lld
+// REQUIRES: lld, x86-registered-target
 
 // RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s



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


[clang] 6b3fa58 - [clang] Make test agnostic to file seperator character

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T22:12:04Z
New Revision: 6b3fa58fde5962f00523e2a8f2498b1206345db2

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

LOG: [clang] Make test agnostic to file seperator character

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 733a6f9d1305..7db0e2e188c2 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -7,9 +7,9 @@
 // CHECK: error: undefined symbol: a
 
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
-// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.c
-// CHECK-NEXT: note: diagnostic msg: {{.*}}/linker-crash-{{.*}}.tar
-// CHECK-NEXT: note: diagnostic msg: {{.*}}/lld-repro-{{.*}}.sh
+// CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.c
+// CHECK-NEXT: note: diagnostic msg: {{.*}}linker-crash-{{.*}}.tar
+// CHECK-NEXT: note: diagnostic msg: {{.*}}lld-repro-{{.*}}.sh
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 



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


[clang] 71f2d5c - [clang] Re-enable test after marking it XFAIL

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T22:09:13Z
New Revision: 71f2d5c2d195256f27f293aefdc1d4f6c117065d

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

LOG: [clang] Re-enable test after marking it XFAIL

This test had to be disabled because ps4 targets don't support
-fuse-ld. Preferably, this should just be unsupported for ps4
targets. However no such lit feature exists so I have just gone
ahead and set the target explicitly. Moreover, this needs
to create a terminal link step, either an executable or shared
object to get the link error. With the change to the explicit
target I've had to also add -nostartfiles -nostdlib so that
clang doesn't pull crt files into the link which may not be
present. Again, this would likely be solved if this test
was unsupported for the one platform that disables -fuse-ld

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 2643ad871835..733a6f9d1305 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,7 +1,6 @@
 // REQUIRES: lld
-// XFAIL: *
 
-// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -14,9 +13,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
+// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 
-fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -nostartfiles -nostdlib 
-fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[clang] 4b8f375 - [clang] Temporarily expect failure from test

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T21:11:21Z
New Revision: 4b8f375c9f9ece32106da899bc2debf31ed20970

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

LOG: [clang] Temporarily expect failure from test

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index 401564013563..2643ad871835 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,4 +1,5 @@
 // REQUIRES: lld
+// XFAIL: *
 
 // RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s



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


[clang] 9028966 - [clang] Don't create executable in test

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T20:59:40Z
New Revision: 9028966a717239cf586d6c4f606965d444176dc4

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

LOG: [clang] Don't create executable in test

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index c0a4e14d2437..401564013563 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,6 +1,6 @@
 // REQUIRES: lld
 
-// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +13,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 
2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -c -fuse-ld=lld 
-gen-reproducer=error -fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[clang] 1ccded0 - [clang] Fix build when targeting ps4

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T20:31:01Z
New Revision: 1ccded0fc111700f72ffa36b5d0160a86c65ec3a

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

LOG: [clang] Fix build when targeting ps4

-fuse-ld is not available for ps4 targets

Added: 


Modified: 
clang/test/Driver/lld-repro.c

Removed: 




diff  --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c
index f558b780fb23..c0a4e14d2437 100644
--- a/clang/test/Driver/lld-repro.c
+++ b/clang/test/Driver/lld-repro.c
@@ -1,6 +1,6 @@
 // REQUIRES: lld
 
-// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=all 2>&1 \
 // RUN:   | FileCheck %s
 
 // check that we still get lld's output
@@ -13,9 +13,9 @@
 // CHECK-NEXT: note: diagnostic msg:
 // CHECK: 
 
-// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t -fcrash-diagnostics=compiler 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
-// RUN: not %clang %s -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t 2>&1 \
+// RUN: not %clang %s -target x86_64-linux -fuse-ld=lld -gen-reproducer=error 
-fcrash-diagnostics-dir=%t 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-LINKER
 
 // NO-LINKER-NOT: Preprocessed source(s) and associated run script(s) are 
located at:



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


[clang] 5fd03b0 - [Driver] Re-run lld with --reproduce when it crashes

2022-08-01 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-08-01T20:01:01Z
New Revision: 5fd03b00ee029b4cc958ae8e6c970a6123bd12f6

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

LOG: [Driver] Re-run lld with --reproduce when it crashes

This was discussed on 
https://discourse.llvm.org/t/rfc-generating-lld-reproducers-on-crashes/58071/12

When lld crashes, or errors when -gen-reproducer=error
and -fcrash-diagnostics=all clang will re-run lld with
--reproduce=$temp_file for easily reproducing the
crash/error.

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

Added: 
clang/test/Driver/lld-repro.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/Driver/Compilation.h
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/crash-report.cpp
clang/test/Driver/lit.local.cfg

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 1d11b00a1a78d..15df488e802de 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -667,6 +667,14 @@ a crash. These files should be attached to a bug report to 
ease
 reproducibility of the failure. Below are the command line options to
 control the crash diagnostics.
 
+.. option:: -fcrash-diagnostics=
+
+  Valid values are:
+
+  * ``off`` (Disable auto-generation of preprocessed source files during a 
clang crash.)
+  * ``compiler`` (Generate diagnostics for compiler crashes (default))
+  * ``all`` (Generate diagnostics for all tools which support it)
+
 .. option:: -fno-crash-diagnostics
 
   Disable auto-generation of preprocessed source files during a clang crash.

diff  --git a/clang/include/clang/Driver/Compilation.h 
b/clang/include/clang/Driver/Compilation.h
index c5714d3208884..842efda9f0774 100644
--- a/clang/include/clang/Driver/Compilation.h
+++ b/clang/include/clang/Driver/Compilation.h
@@ -216,6 +216,7 @@ class Compilation {
 
   void addCommand(std::unique_ptr C) { Jobs.addJob(std::move(C)); }
 
+  llvm::opt::ArgStringList () { return TempFiles; }
   const llvm::opt::ArgStringList () const { return TempFiles; }
 
   const ArgStringMap () const { return ResultFiles; }

diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 0781d476ec4a0..59c2f1f52cecf 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -600,6 +600,11 @@ class Driver {
   /// Returns the default name for linked images (e.g., "a.out").
   const char *getDefaultImageName() const;
 
+  // Creates a temp file with $Prefix-%%.$Suffix
+  const char *CreateTempFile(Compilation , StringRef Prefix, StringRef 
Suffix,
+ bool MultipleArchs = false,
+ StringRef BoundArch = {}) const;
+
   /// GetNamedOutputPath - Return the name to use for the output of
   /// the action \p JA. The result is appended to the compilation's
   /// list of temporary or result files, as appropriate.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1718234a56988..3312f999a33f7 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1433,6 +1433,10 @@ def fexperimental_new_constant_interpreter : Flag<["-"], 
"fexperimental-new-cons
   MarshallingInfoFlag>;
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,
 Group;
+def fcrash_diagnostics_EQ : Joined<["-"], "fcrash-diagnostics=">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Set level of crash diagnostic reporting, (option: off, compiler, 
all)">;
+def fcrash_diagnostics : Flag<["-"], "fcrash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Enable crash diagnostic reporting (default)">, 
Alias, AliasArgs<["compiler"]>;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
   Alias, AliasArgs<["off"]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 3f29afd359718..7c727ba65ada6 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1507,11 +1507,36 @@ void Driver::generateCompilationDiagnostics(
   if (C.getArgs().hasArg(options::OPT_fno_crash_diagnostics))
 return;
 
-  // Don't try to generate diagnostics for link or dsymutil jobs.
-  if (FailingCommand.getCreator().isLinkJob() ||
-  FailingCommand.getCreator().isDsymutilJob())
+  unsigned Level = 1;
+  if (Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_EQ)) {
+Level = 

[clang] 0df7d8b - [CMake][Fuchsia] Enable assertions and backtraces in stage 1 build

2022-07-26 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-07-26T06:09:38Z
New Revision: 0df7d8bc355dd506bb1a330b9f73e611f0deaf9f

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

LOG: [CMake][Fuchsia] Enable assertions and backtraces in stage 1 build

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

Added: 


Modified: 
clang/cmake/caches/Fuchsia.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia.cmake 
b/clang/cmake/caches/Fuchsia.cmake
index 73ef571507179..1978195c267d9 100644
--- a/clang/cmake/caches/Fuchsia.cmake
+++ b/clang/cmake/caches/Fuchsia.cmake
@@ -34,8 +34,8 @@ set(CLANG_PLUGIN_SUPPORT OFF CACHE BOOL "")
 set(ENABLE_LINKER_BUILD_ID ON CACHE BOOL "")
 set(ENABLE_X86_RELAX_RELOCATIONS ON CACHE BOOL "")
 
-set(LLVM_ENABLE_ASSERTIONS OFF CACHE BOOL "")
-set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
+set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
+set(LLVM_ENABLE_BACKTRACES ON CACHE BOOL "")
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
 if(APPLE)
   set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")



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


[clang] 09d4dbc - [llvm-driver] Generate symlinks instead of executables for tools

2022-07-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-07-20T01:42:56Z
New Revision: 09d4dbc3829e91397f96d7d7f243440555adee87

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

LOG: [llvm-driver] Generate symlinks instead of executables for tools

When LLVM_TOOL_LLVM_DRIVER_BUILD is On, create symlinks
to llvm instead of creating the executables. Currently
this only works for install and not
install-distribution, the work for the later will be
split up into a second patch.

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

Added: 


Modified: 
clang/cmake/modules/AddClang.cmake
llvm/cmake/modules/AddLLVM.cmake
llvm/tools/CMakeLists.txt
llvm/tools/llvm-driver/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 299f8ce6e2fb4..0b3c64c32cfc5 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -149,43 +149,60 @@ macro(add_clang_executable name)
 endmacro(add_clang_executable)
 
 macro(add_clang_tool name)
+  cmake_parse_arguments(ARG "DEPENDS;GENERATE_DRIVER" "" "" ${ARGN})
   if (NOT CLANG_BUILD_TOOLS)
 set(EXCLUDE_FROM_ALL ON)
   endif()
-
-  add_clang_executable(${name} ${ARGN})
-  add_dependencies(${name} clang-resource-headers)
-
-  if (CLANG_BUILD_TOOLS)
-get_target_export_arg(${name} Clang export_to_clangtargets)
-install(TARGETS ${name}
-  ${export_to_clangtargets}
-  RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
-  COMPONENT ${name})
-
-if(NOT LLVM_ENABLE_IDE)
-  add_llvm_install_targets(install-${name}
-   DEPENDS ${name}
-   COMPONENT ${name})
+  if(ARG_GENERATE_DRIVER AND LLVM_TOOL_LLVM_DRIVER_BUILD)
+set(get_obj_args ${ARGN})
+list(FILTER get_obj_args EXCLUDE REGEX "^SUPPORT_PLUGINS$")
+generate_llvm_objects(${name} ${get_obj_args})
+add_custom_target(${name} DEPENDS llvm-driver clang-resource-headers)
+  else()
+add_clang_executable(${name} ${ARGN})
+add_dependencies(${name} clang-resource-headers)
+
+if (CLANG_BUILD_TOOLS)
+  get_target_export_arg(${name} Clang export_to_clangtargets)
+  install(TARGETS ${name}
+${export_to_clangtargets}
+RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+COMPONENT ${name})
+
+  if(NOT LLVM_ENABLE_IDE)
+add_llvm_install_targets(install-${name}
+ DEPENDS ${name}
+ COMPONENT ${name})
+  endif()
+  set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
 endif()
-set_property(GLOBAL APPEND PROPERTY CLANG_EXPORTS ${name})
   endif()
 endmacro()
 
 macro(add_clang_symlink name dest)
-  add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
-  # Always generate install targets
-  llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${dest} IN_LIST LLVM_DRIVER_TOOLS)
+set_property(GLOBAL APPEND PROPERTY LLVM_DRIVER_TOOL_SYMLINKS ${name})
+  else()
+add_llvm_tool_symlink(${name} ${dest} ALWAYS_GENERATE)
+# Always generate install targets
+llvm_install_symlink(${name} ${dest} ALWAYS_GENERATE)
+  endif()
 endmacro()
 
 function(clang_target_link_libraries target type)
+  if (TARGET obj.${target})
+target_link_libraries(obj.${target} ${ARGN})
+  endif()
+
+  get_property(LLVM_DRIVER_TOOLS GLOBAL PROPERTY LLVM_DRIVER_TOOLS)
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND ${target} IN_LIST LLVM_DRIVER_TOOLS)
+set(target llvm-driver)
+  endif()
+
   if (CLANG_LINK_CLANG_DYLIB)
 target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
-  if (TARGET obj.${target})
-target_link_libraries(obj.${target} ${ARGN})
-  endif()
-
 endfunction()

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 8e1385e90b82d..6a8e13032bdea 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -863,12 +863,8 @@ macro(add_llvm_library name)
   endif()
 endmacro(add_llvm_library name)
 
-macro(add_llvm_executable name)
-  cmake_parse_arguments(ARG
-
"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS;GENERATE_DRIVER"
-"ENTITLEMENTS;BUNDLE_PATH"
-"DEPENDS"
-${ARGN})
+macro(generate_llvm_objects name)
+  cmake_parse_arguments(ARG "GENERATE_DRIVER" "" "DEPENDS" ${ARGN})
 
   llvm_process_sources( ALL_FILES ${ARG_UNPARSED_ARGUMENTS} )
 
@@ -911,7 +907,15 @@ macro(add_llvm_executable name)
 target_link_libraries(${obj_name} ${LLVM_PTHREAD_LIB})
 llvm_config(${obj_name} ${USE_SHARED} ${LLVM_LINK_COMPONENTS} )
   

[clang] f4f6adc - [clang] Don't emit IFUNC when targeting Fuchsia

2022-06-16 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-06-16T15:38:12Z
New Revision: f4f6adc451a2dc901c08c2fdac81ef2cf98a5cc6

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

LOG: [clang] Don't emit IFUNC when targeting Fuchsia

Fuchsia's dynamic linker does not and will never support IFUNC's.

Differential revision: https://reviews.llvm.org/D127933

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h
clang/test/CodeGen/attr-target-mv-va-args.c

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index 5877123dab249..32a330a044c45 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1355,7 +1355,9 @@ class TargetInfo : public virtual TransferrableTargetInfo,
   bool supportsMultiVersioning() const { return getTriple().isX86(); }
 
   /// Identify whether this target supports IFuncs.
-  bool supportsIFunc() const { return getTriple().isOSBinFormatELF(); }
+  bool supportsIFunc() const {
+return getTriple().isOSBinFormatELF() && !getTriple().isOSFuchsia();
+  }
 
   // Validate the contents of the __builtin_cpu_supports(const char*)
   // argument.

diff  --git a/clang/test/CodeGen/attr-target-mv-va-args.c 
b/clang/test/CodeGen/attr-target-mv-va-args.c
index db3f4da079cfb..c51eaffcdde74 100644
--- a/clang/test/CodeGen/attr-target-mv-va-args.c
+++ b/clang/test/CodeGen/attr-target-mv-va-args.c
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-linux-gnu -emit-llvm %s 
-o - | FileCheck %s --check-prefix=LINUX
-// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s 
-o - | FileCheck %s --check-prefix=WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-windows-pc -emit-llvm %s 
-o - | FileCheck %s --check-prefixes=NO-IFUNC,WINDOWS
+// RUN: %clang_cc1 -no-opaque-pointers -triple x86_64-fuchsia -emit-llvm %s -o 
- | FileCheck %s --check-prefixes=NO-IFUNC,FUCHSIA
 int __attribute__((target("sse4.2"))) foo(int i, ...) { return 0; }
 int __attribute__((target("arch=sandybridge"))) foo(int i, ...);
 int __attribute__((target("arch=ivybridge"))) foo(int i, ...) {return 1;}
@@ -27,19 +28,21 @@ int bar(void) {
 // LINUX: ret i32 (i32, ...)* @foo
 // LINUX: declare i32 @foo.arch_sandybridge(i32 noundef, ...)
 
-// WINDOWS: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...)
-// WINDOWS: ret i32 0
-// WINDOWS: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...)
-// WINDOWS: ret i32 1
-// WINDOWS: define dso_local i32 @foo(i32 noundef %i, ...)
-// WINDOWS: ret i32 2
-// WINDOWS: define dso_local i32 @bar()
-// WINDOWS: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, 
double
-// WINDOWS: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 
2.2{{[0-9Ee+]+}}, i8* noundef getelementptr inbounds
+// NO-IFUNC: define dso_local i32 @foo.sse4.2(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 0
+// NO-IFUNC: define dso_local i32 @foo.arch_ivybridge(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 1
+// NO-IFUNC: define dso_local i32 @foo(i32 noundef %i, ...)
+// NO-IFUNC: ret i32 2
+// NO-IFUNC: define dso_local i32 @bar()
+// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 1, i32 noundef 97, 
double
+// NO-IFUNC: call i32 (i32, ...) @foo.resolver(i32 noundef 2, double noundef 
2.2{{[0-9Ee+]+}}, i8* noundef getelementptr inbounds
 
 // WINDOWS: define weak_odr dso_local i32 @foo.resolver(i32 %0, ...) comdat
-// WINDOWS: musttail call i32 (i32, ...) @foo.arch_sandybridge
-// WINDOWS: musttail call i32 (i32, ...) @foo.arch_ivybridge
-// WINDOWS: musttail call i32 (i32, ...) @foo.sse4.2
-// WINDOWS: musttail call i32 (i32, ...) @foo
+// FUCHSIA: define weak_odr i32 @foo.resolver(i32 %0, ...) comdat
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_sandybridge
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.arch_ivybridge
+// NO-IFUNC: musttail call i32 (i32, ...) @foo.sse4.2
+// NO-IFUNC: musttail call i32 (i32, ...) @foo
 // WINDOWS: declare dso_local i32 @foo.arch_sandybridge(i32 noundef, ...)
+// FUCHSIA: declare i32 @foo.arch_sandybridge(i32 noundef, ...)



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


[clang] fac39d1 - [clang] Allow CLANG_MODULE_CACHE_PATH env var to override module caching behavior

2022-06-09 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-06-09T16:55:37Z
New Revision: fac39d14b129fa545fc7633ef8e0be9ddf45cab2

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

LOG: [clang] Allow CLANG_MODULE_CACHE_PATH env var to override module caching 
behavior

CLANG_MODULE_CACHE_PATH can be used to change where clang should
put the module cache, or can be set to "" to disable caching entirely.

Differential revision: https://reviews.llvm.org/D126678

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/modules-cache-path.m

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index fe79921524727..ceac142653ebe 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3600,6 +3600,11 @@ static void RenderBuiltinOptions(const ToolChain , 
const llvm::Triple ,
 }
 
 bool Driver::getDefaultModuleCachePath(SmallVectorImpl ) {
+  if (const char *Str = std::getenv("CLANG_MODULE_CACHE_PATH")) {
+Twine Path{Str};
+Path.toVector(Result);
+return Path.getSingleStringRef() != "";
+  }
   if (llvm::sys::path::cache_directory(Result)) {
 llvm::sys::path::append(Result, "clang");
 llvm::sys::path::append(Result, "ModuleCache");

diff  --git a/clang/test/Driver/modules-cache-path.m 
b/clang/test/Driver/modules-cache-path.m
index 51df6739a5055..1da27d2143631 100644
--- a/clang/test/Driver/modules-cache-path.m
+++ b/clang/test/Driver/modules-cache-path.m
@@ -1,2 +1,10 @@
 // RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s 
-check-prefix=CHECK-DEFAULT
 // CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
+
+// RUN: env CLANG_MODULE_CACHE_PATH=/dev/null \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=OVERRIDE
+// OVERRIDE: -fmodules-cache-path=/dev/null
+
+// RUN: env CLANG_MODULE_CACHE_PATH= \
+// RUN:   %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=DISABLE
+// DISABLE-NOT: -fmodules-cache-path=



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


[clang] f06abbb - LLVM Driver Multicall tool

2022-06-05 Thread Alex Brachet via cfe-commits

Author: Chris Bieneman
Date: 2022-06-06T04:27:32Z
New Revision: f06abbb393800b0d466c88e283c06f75561c432c

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

LOG: LLVM Driver Multicall tool

This patch adds an llvm-driver multicall tool that can combine multiple
LLVM-based tools. The build infrastructure is enabled for a tool by
adding the GENERATE_DRIVER option to the add_llvm_executable CMake
call, and changing the tool's main function to a canonicalized
tool_name_main format (i.e. llvm_ar_main, clang_main, etc...).

As currently implemented llvm-driver contains dsymutil, llvm-ar,
llvm-cxxfilt, llvm-objcopy, and clang (if clang is included in the
build).

llvm-driver can be enabled from builds by setting
LLVM_TOOL_LLVM_DRIVER_BUILD=On.

There are several limitations in the current implementation, which can
be addressed in subsequent patches:

(1) the multicall binary cannot currently properly handle
multi-dispatch tools. This means symlinking llvm-ranlib to llvm-driver
will not properly result in llvm-ar's main being called.
(2) the multicall binary cannot be comprised of tools containing
conflicting cl::opt options as the global cl::opt option list cannot
contain duplicates.

These limitations can be addressed in subsequent patches.

Differential revision: https://reviews.llvm.org/D109977

Added: 
llvm/cmake/driver-template.cpp.in
llvm/test/tools/llvm-driver/help-passthrough.test
llvm/test/tools/llvm-driver/help.test
llvm/test/tools/llvm-driver/symlink-call.test
llvm/tools/llvm-driver/CMakeLists.txt
llvm/tools/llvm-driver/llvm-driver.cpp

Modified: 
clang/cmake/modules/AddClang.cmake
clang/tools/driver/CMakeLists.txt
clang/tools/driver/driver.cpp
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/lib/Support/Path.cpp
llvm/lib/Support/Unix/Path.inc
llvm/lib/Support/Windows/Path.inc
llvm/test/CMakeLists.txt
llvm/test/lit.cfg.py
llvm/test/lit.site.cfg.py.in
llvm/tools/CMakeLists.txt
llvm/tools/dsymutil/CMakeLists.txt
llvm/tools/dsymutil/dsymutil.cpp
llvm/tools/llvm-ar/CMakeLists.txt
llvm/tools/llvm-ar/llvm-ar.cpp
llvm/tools/llvm-cxxfilt/CMakeLists.txt
llvm/tools/llvm-cxxfilt/llvm-cxxfilt.cpp
llvm/tools/llvm-objcopy/CMakeLists.txt
llvm/tools/llvm-objcopy/llvm-objcopy.cpp
utils/bazel/llvm-project-overlay/clang/BUILD.bazel
utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Removed: 




diff  --git a/clang/cmake/modules/AddClang.cmake 
b/clang/cmake/modules/AddClang.cmake
index 9bbbfc032b7df..299f8ce6e2fb4 100644
--- a/clang/cmake/modules/AddClang.cmake
+++ b/clang/cmake/modules/AddClang.cmake
@@ -184,5 +184,8 @@ function(clang_target_link_libraries target type)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
+  if (TARGET obj.${target})
+target_link_libraries(obj.${target} ${ARGN})
+  endif()
 
 endfunction()

diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 6b3e159d1b648..d05b71db13f21 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -31,6 +31,7 @@ add_clang_tool(clang
   DEPENDS
   intrinsics_gen
   ${support_plugins}
+  GENERATE_DRIVER
   )
 
 clang_target_link_libraries(clang

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index d361457f8cecd..fa1f09b44f4da 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -327,7 +327,7 @@ static int ExecuteCC1Tool(SmallVectorImpl 
) {
   return 1;
 }
 
-int main(int Argc, const char **Argv) {
+int clang_main(int Argc, char **Argv) {
   noteBottomOfStack();
   llvm::InitLLVM X(Argc, Argv);
   llvm::setBugReportMsg("PLEASE submit a bug report to " BUG_REPORT_URL

diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 1effbde06b80e..fab16edd7d532 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -269,6 +269,8 @@ include(VersionFromVCS)
 option(LLVM_APPEND_VC_REV
   "Embed the version control system revision in LLVM" ON)
 
+option(LLVM_TOOL_LLVM_DRIVER_BUILD "Enables building the llvm multicall tool" 
OFF)
+
 set(PACKAGE_NAME LLVM)
 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
 set(PACKAGE_BUGREPORT "https://github.com/llvm/llvm-project/issues/;)

diff  --git a/llvm/cmake/driver-template.cpp.in 
b/llvm/cmake/driver-template.cpp.in
new file mode 100644
index 0..2164fb00d168f
--- /dev/null
+++ b/llvm/cmake/driver-template.cpp.in
@@ -0,0 +1,11 @@
+//===-- driver-template.cpp 
---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH 

[clang] a0ef52c - Fix windows build

2022-05-31 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-05-31T17:31:55Z
New Revision: a0ef52cc102504c4282dec7001664ee020396681

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

LOG: Fix windows build

Added: 


Modified: 
clang/test/Driver/emit-reproducer.c

Removed: 




diff  --git a/clang/test/Driver/emit-reproducer.c 
b/clang/test/Driver/emit-reproducer.c
index fa9d71463a66..b8d6841077c4 100644
--- a/clang/test/Driver/emit-reproducer.c
+++ b/clang/test/Driver/emit-reproducer.c
@@ -1,6 +1,6 @@
 // RUN: rm -rf %t && mkdir %t
 
-// RUN: echo "%s -fcrash-diagnostics-dir=%t -fsyntax-only" > %t.rsp
+// RUN: echo "%s -fcrash-diagnostics-dir=%t -fsyntax-only" | sed -e 
's/\\//g' > %t.rsp
 
 // RUN: not %clang -DFATAL @%t.rsp -gen-reproducer=off2>&1 | FileCheck %s 
--check-prefix=NOT
 // RUN: not %clang -DFATAL @%t.rsp -fno-crash-diagnostics 2>&1 | FileCheck %s 
--check-prefix=NOT
@@ -29,8 +29,8 @@
 // RUN: not %clang -gen-reproducer=badvalue 2>&1 | FileCheck %s 
--check-prefix=BAD-VALUE
 // BAD-VALUE: Unknown value for -gen-reproducer=: 'badvalue'
 
-// CHECK:   note: diagnostic msg: {{.*}}emit-reproducer{{.*}}.c
-// NOT-NOT: note: diagnostic msg: {{.*}}emit-reproducer{{.*}}.c
+// CHECK:   note: diagnostic msg: {{.*}}emit-reproducer-{{.*}}.c
+// NOT-NOT: note: diagnostic msg: {{.*}}emit-reproducer-{{.*}}.c
 
 #ifdef FATAL
 #pragma clang __debug crash



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


[clang] c4d9698 - [clang][Driver] Fix SIE builders

2022-05-31 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-05-31T17:26:18Z
New Revision: c4d9698f3c8db47ac7a0bee8bba6b9b8b91f7d58

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

LOG: [clang][Driver] Fix SIE builders

Added: 


Modified: 
clang/test/Driver/emit-reproducer.c

Removed: 




diff  --git a/clang/test/Driver/emit-reproducer.c 
b/clang/test/Driver/emit-reproducer.c
index 18846108459f..fa9d71463a66 100644
--- a/clang/test/Driver/emit-reproducer.c
+++ b/clang/test/Driver/emit-reproducer.c
@@ -29,8 +29,8 @@
 // RUN: not %clang -gen-reproducer=badvalue 2>&1 | FileCheck %s 
--check-prefix=BAD-VALUE
 // BAD-VALUE: Unknown value for -gen-reproducer=: 'badvalue'
 
-// CHECK:   note: diagnostic msg: {{.*}}emit-reproducer-{{.*}}.c
-// NOT-NOT: note: diagnostic msg: {{.*}}emit-reproducer-{{.*}}.c
+// CHECK:   note: diagnostic msg: {{.*}}emit-reproducer{{.*}}.c
+// NOT-NOT: note: diagnostic msg: {{.*}}emit-reproducer{{.*}}.c
 
 #ifdef FATAL
 #pragma clang __debug crash



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


[clang] 35a032e - [InstrProf] Stop exporting lprofDirMode

2022-05-31 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-05-31T17:13:00Z
New Revision: 35a032eaf429abd2b9785b2d989f5a42c89bc6a8

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

LOG: [InstrProf] Stop exporting lprofDirMode

This symbol should not be exposed and doesn't need to be.

Differential revision: https://reviews.llvm.org/D126548

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
compiler-rt/lib/profile/InstrProfilingUtil.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index b0d72c74dcb74..665a3894302ab 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1349,7 +1349,6 @@ void Darwin::addProfileRTLibs(const ArgList ,
   addExportedSymbol(CmdArgs, "___llvm_profile_filename");
   addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
 }
-addExportedSymbol(CmdArgs, "_lprofDirMode");
   }
 
   // Align __llvm_prf_{cnts,data} sections to the maximum expected page

diff  --git a/compiler-rt/lib/profile/InstrProfilingUtil.c 
b/compiler-rt/lib/profile/InstrProfilingUtil.c
index cd179d03bc831..cd18cba3e268f 100644
--- a/compiler-rt/lib/profile/InstrProfilingUtil.c
+++ b/compiler-rt/lib/profile/InstrProfilingUtil.c
@@ -46,7 +46,7 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
-COMPILER_RT_WEAK unsigned lprofDirMode = 0755;
+COMPILER_RT_VISIBILITY unsigned lprofDirMode = 0755;
 
 COMPILER_RT_VISIBILITY
 void __llvm_profile_recursive_mkdir(char *path) {



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


[clang] 7d76d60 - [Clang] Extend -gen-reproducer flag

2022-05-31 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-05-31T17:10:16Z
New Revision: 7d76d6095880f34914d85d876b260cc4a4ea640d

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

LOG: [Clang] Extend -gen-reproducer flag

`-gen-reproducer` causes crash reproduction to be emitted
even when clang didn't crash, and now can optionally take an
argument of never, on-crash (default), on-error and always.

Differential revision: https://reviews.llvm.org/D120201

Added: 
clang/test/Driver/emit-reproducer.c

Modified: 
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/crash-report-crashfile.m
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index f0f294a669d98..67ff4dc2e01e8 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -12,6 +12,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Driver/Action.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/Phases.h"
@@ -276,11 +277,6 @@ class Driver {
   unsigned ProbePrecompiled : 1;
 
 public:
-  /// Force clang to emit reproducer for driver invocation. This is enabled
-  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
-  /// or when using the -gen-reproducer driver flag.
-  unsigned GenReproducer : 1;
-
   // getFinalPhase - Determine which compilation mode we are in and record
   // which option we used to determine the final phase.
   // TODO: Much of what getFinalPhase returns are not actually true compiler
@@ -505,6 +501,35 @@ class Driver {
   StringRef AdditionalInformation = "",
   CompilationDiagnosticReport *GeneratedReport = nullptr);
 
+  enum class CommandStatus {
+Crash = 1,
+Error,
+Ok,
+  };
+
+  enum class ReproLevel {
+Off = 0,
+OnCrash = static_cast(CommandStatus::Crash),
+OnError = static_cast(CommandStatus::Error),
+Always = static_cast(CommandStatus::Ok),
+  };
+
+  bool maybeGenerateCompilationDiagnostics(
+  CommandStatus CS, ReproLevel Level, Compilation ,
+  const Command , StringRef AdditionalInformation = "",
+  CompilationDiagnosticReport *GeneratedReport = nullptr) {
+if (static_cast(CS) > static_cast(Level))
+  return false;
+if (CS != CommandStatus::Crash)
+  Diags.Report(diag::err_drv_force_crash)
+  << !::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH");
+// Hack to ensure that diagnostic notes get emitted.
+Diags.setLastDiagnosticIgnored(false);
+generateCompilationDiagnostics(C, FailingCommand, AdditionalInformation,
+   GeneratedReport);
+return true;
+  }
+
   /// @}
   /// @name Helper Methods
   /// @{

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0343e48c1a9d1..26d003b001a61 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -558,7 +558,10 @@ def arcmt_migrate_report_output : Separate<["-"], 
"arcmt-migrate-report-output">
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
+def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">, 
Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Emit reproducer on (option: off, crash (default), error, always)">;
 def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
+  Alias, AliasArgs<["always"]>,
   HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, 
InternalDebugOpt,
   HelpText<"Emit a compilation database fragment to the specified directory">;
@@ -1397,6 +1400,7 @@ def fexperimental_new_constant_interpreter : Flag<["-"], 
"fexperimental-new-cons
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
+  Alias, AliasArgs<["off"]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
 def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
   Group, Flags<[NoArgumentUnused, CoreOption]>,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 94925568aec23..aaef2e1ded327 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -198,8 +198,7 @@ 

[clang] 4dc3893 - Revert "[Clang] Extend -gen-reproducer flag"

2022-05-27 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-05-27T17:03:32Z
New Revision: 4dc3893eeb47bef9298c34cdc993165af88721a5

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

LOG: Revert "[Clang] Extend -gen-reproducer flag"

This reverts commit 684c080108766b4f112f172fed4a49059484614d.

Added: 


Modified: 
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/tools/driver/driver.cpp

Removed: 
clang/test/Driver/emit-reproducer.c



diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index 86eea9375f673..f0f294a669d98 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -276,6 +276,11 @@ class Driver {
   unsigned ProbePrecompiled : 1;
 
 public:
+  /// Force clang to emit reproducer for driver invocation. This is enabled
+  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
+  /// or when using the -gen-reproducer driver flag.
+  unsigned GenReproducer : 1;
+
   // getFinalPhase - Determine which compilation mode we are in and record
   // which option we used to determine the final phase.
   // TODO: Much of what getFinalPhase returns are not actually true compiler
@@ -500,32 +505,6 @@ class Driver {
   StringRef AdditionalInformation = "",
   CompilationDiagnosticReport *GeneratedReport = nullptr);
 
-  enum class CommandStatus {
-Crash = 1,
-Error,
-Ok,
-  };
-
-  enum class ReproLevel {
-Off = 0,
-OnCrash = static_cast(CommandStatus::Crash),
-OnError = static_cast(CommandStatus::Error),
-Always = static_cast(CommandStatus::Ok),
-  };
-
-  bool maybeGenerateCompilationDiagnostics(
-  CommandStatus CS, ReproLevel Level, Compilation ,
-  const Command , StringRef AdditionalInformation = "",
-  CompilationDiagnosticReport *GeneratedReport = nullptr) {
-if (static_cast(CS) > static_cast(Level))
-  return false;
-// Hack to ensure that diagnostic notes get emitted.
-Diags.setLastDiagnosticIgnored(false);
-generateCompilationDiagnostics(C, FailingCommand, AdditionalInformation,
-   GeneratedReport);
-return true;
-  }
-
   /// @}
   /// @name Helper Methods
   /// @{

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2a5e8bf27e353..e19baac5860aa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -558,10 +558,7 @@ def arcmt_migrate_report_output : Separate<["-"], 
"arcmt-migrate-report-output">
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
-def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">, 
Flags<[NoArgumentUnused, CoreOption]>,
-  HelpText<"Emit reproducer on (option: off, crash (default), error, always)">;
 def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
-  Alias, AliasArgs<["always"]>,
   HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, 
InternalDebugOpt,
   HelpText<"Emit a compilation database fragment to the specified directory">;
@@ -1400,7 +1397,6 @@ def fexperimental_new_constant_interpreter : Flag<["-"], 
"fexperimental-new-cons
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
-  Alias, AliasArgs<["off"]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
 def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
   Group, Flags<[NoArgumentUnused, CoreOption]>,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index aaef2e1ded327..94925568aec23 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -198,7 +198,8 @@ Driver::Driver(StringRef ClangExecutable, StringRef 
TargetTriple,
   CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), CCPrintProcessStats(false),
   TargetTriple(TargetTriple), Saver(Alloc), CheckInputsExist(true),
-  ProbePrecompiled(true), SuppressMissingInputWarning(false) {
+  ProbePrecompiled(true), GenReproducer(false),
+  SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no VFS is specified.
   if (!this->VFS)
 this->VFS = llvm::vfs::getRealFileSystem();
@@ -1216,6 +1217,9 @@ Compilation *Driver::BuildCompilation(ArrayRef 

[clang] 684c080 - [Clang] Extend -gen-reproducer flag

2022-05-27 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-05-27T15:49:13Z
New Revision: 684c080108766b4f112f172fed4a49059484614d

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

LOG: [Clang] Extend -gen-reproducer flag

-gen-reproducer causes crash reproduction to be emitted even
when clang didn't crash, and now can optionally take an argument
of never, on-crash (default), on-error and always.

Differential revision: https://reviews.llvm.org/D120201

Added: 
clang/test/Driver/emit-reproducer.c

Modified: 
clang/include/clang/Driver/Driver.h
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Driver.h 
b/clang/include/clang/Driver/Driver.h
index f0f294a669d9..86eea9375f67 100644
--- a/clang/include/clang/Driver/Driver.h
+++ b/clang/include/clang/Driver/Driver.h
@@ -276,11 +276,6 @@ class Driver {
   unsigned ProbePrecompiled : 1;
 
 public:
-  /// Force clang to emit reproducer for driver invocation. This is enabled
-  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
-  /// or when using the -gen-reproducer driver flag.
-  unsigned GenReproducer : 1;
-
   // getFinalPhase - Determine which compilation mode we are in and record
   // which option we used to determine the final phase.
   // TODO: Much of what getFinalPhase returns are not actually true compiler
@@ -505,6 +500,32 @@ class Driver {
   StringRef AdditionalInformation = "",
   CompilationDiagnosticReport *GeneratedReport = nullptr);
 
+  enum class CommandStatus {
+Crash = 1,
+Error,
+Ok,
+  };
+
+  enum class ReproLevel {
+Off = 0,
+OnCrash = static_cast(CommandStatus::Crash),
+OnError = static_cast(CommandStatus::Error),
+Always = static_cast(CommandStatus::Ok),
+  };
+
+  bool maybeGenerateCompilationDiagnostics(
+  CommandStatus CS, ReproLevel Level, Compilation ,
+  const Command , StringRef AdditionalInformation = "",
+  CompilationDiagnosticReport *GeneratedReport = nullptr) {
+if (static_cast(CS) > static_cast(Level))
+  return false;
+// Hack to ensure that diagnostic notes get emitted.
+Diags.setLastDiagnosticIgnored(false);
+generateCompilationDiagnostics(C, FailingCommand, AdditionalInformation,
+   GeneratedReport);
+return true;
+  }
+
   /// @}
   /// @name Helper Methods
   /// @{

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e19baac5860a..2a5e8bf27e35 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -558,7 +558,10 @@ def arcmt_migrate_report_output : Separate<["-"], 
"arcmt-migrate-report-output">
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
+def gen_reproducer_eq: Joined<["-"], "gen-reproducer=">, 
Flags<[NoArgumentUnused, CoreOption]>,
+  HelpText<"Emit reproducer on (option: off, crash (default), error, always)">;
 def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
+  Alias, AliasArgs<["always"]>,
   HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 def gen_cdb_fragment_path: Separate<["-"], "gen-cdb-fragment-path">, 
InternalDebugOpt,
   HelpText<"Emit a compilation database fragment to the specified directory">;
@@ -1397,6 +1400,7 @@ def fexperimental_new_constant_interpreter : Flag<["-"], 
"fexperimental-new-cons
 def fconstexpr_backtrace_limit_EQ : Joined<["-"], 
"fconstexpr-backtrace-limit=">,
 Group;
 def fno_crash_diagnostics : Flag<["-"], "fno-crash-diagnostics">, 
Group, Flags<[NoArgumentUnused, CoreOption]>,
+  Alias, AliasArgs<["off"]>,
   HelpText<"Disable auto-generation of preprocessed source files and a script 
for reproduction during a clang crash">;
 def fcrash_diagnostics_dir : Joined<["-"], "fcrash-diagnostics-dir=">,
   Group, Flags<[NoArgumentUnused, CoreOption]>,

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 94925568aec2..aaef2e1ded32 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -198,8 +198,7 @@ Driver::Driver(StringRef ClangExecutable, StringRef 
TargetTriple,
   CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
   CCGenDiagnostics(false), CCPrintProcessStats(false),
   TargetTriple(TargetTriple), Saver(Alloc), CheckInputsExist(true),
-  ProbePrecompiled(true), GenReproducer(false),
-  SuppressMissingInputWarning(false) {
+  ProbePrecompiled(true), SuppressMissingInputWarning(false) {
   // Provide a sane fallback if no 

[clang] 50de659 - [clang] Use -triple, not -target for %clang_cc1

2022-04-07 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-04-07T18:19:54Z
New Revision: 50de659adcc19c4c197ba5e9a7719325af7151ee

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

LOG: [clang] Use -triple, not -target for %clang_cc1

Added: 


Modified: 
clang/test/CodeGen/debug-info-alias.c

Removed: 




diff  --git a/clang/test/CodeGen/debug-info-alias.c 
b/clang/test/CodeGen/debug-info-alias.c
index 5d26b4b8f93d4..1f5e477af96aa 100644
--- a/clang/test/CodeGen/debug-info-alias.c
+++ b/clang/test/CodeGen/debug-info-alias.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -target 
x86_64-unknown-linux-gnu -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -triple 
x86_64-unknown-linux-gnu -o - | FileCheck %s
 
 // CHECK-DAG: [[ENTITY1:![0-9]+]] = distinct !DIGlobalVariable(name: 
"aliased_global"
 // CHECK-DAG: [[ENTITY2:![0-9]+]] = distinct !DIGlobalVariable(name: 
"aliased_global_2"



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


[clang] 3329dae - [clang] Fix macos build broken after D120989

2022-04-07 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-04-07T18:17:29Z
New Revision: 3329dae5cb8a8c91c518dd87c09e88c4fad507bd

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

LOG: [clang] Fix macos build broken after D120989

Added: 


Modified: 
clang/test/CodeGen/debug-info-alias.c

Removed: 




diff  --git a/clang/test/CodeGen/debug-info-alias.c 
b/clang/test/CodeGen/debug-info-alias.c
index 45e9fbec83d70..5d26b4b8f93d4 100644
--- a/clang/test/CodeGen/debug-info-alias.c
+++ b/clang/test/CodeGen/debug-info-alias.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -target 
x86_64-unknown-linux-gnu -o - | FileCheck %s
 
 // CHECK-DAG: [[ENTITY1:![0-9]+]] = distinct !DIGlobalVariable(name: 
"aliased_global"
 // CHECK-DAG: [[ENTITY2:![0-9]+]] = distinct !DIGlobalVariable(name: 
"aliased_global_2"



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


[clang] 5364b36 - Revert "[Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld"

2022-02-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-02-17T18:41:49Z
New Revision: 5364b36868210364b2ccf8e9f9169ed1fd545ae0

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

LOG: Revert "[Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld"

This reverts commit b9f4dff8ab40250aac2343e86c1289de46af5585.

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 1b60541ee846..9e0b259dfcae 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -53,9 +53,9 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   CmdArgs.push_back("-z");
   CmdArgs.push_back("now");
 
-  bool IsLLD;
-  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
-  if (IsLLD) {
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
+  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rodynamic");
 CmdArgs.push_back("-z");



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


[clang] b9f4dff - [Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld

2022-02-17 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-02-17T18:20:23Z
New Revision: b9f4dff8ab40250aac2343e86c1289de46af5585

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

LOG: [Driver][Fuchsia][NFC] Use GetLinkerPath to see if linker is lld

Reviewed By: phosek

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp 
b/clang/lib/Driver/ToolChains/Fuchsia.cpp
index 9e0b259dfcae..1b60541ee846 100644
--- a/clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -53,9 +53,9 @@ void fuchsia::Linker::ConstructJob(Compilation , const 
JobAction ,
   CmdArgs.push_back("-z");
   CmdArgs.push_back("now");
 
-  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
-  if (llvm::sys::path::filename(Exec).equals_insensitive("ld.lld") ||
-  llvm::sys::path::stem(Exec).equals_insensitive("ld.lld")) {
+  bool IsLLD;
+  const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
+  if (IsLLD) {
 CmdArgs.push_back("-z");
 CmdArgs.push_back("rodynamic");
 CmdArgs.push_back("-z");



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


[clang] cd4e600 - [Sema] Warn about printf %n on Android and Fuchsia

2022-01-21 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2022-01-21T21:00:39Z
New Revision: cd4e600f5f5cedd092c8ff19c208897034494f3d

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

LOG: [Sema] Warn about printf %n on Android and Fuchsia

The `printf` specifier `%n` is not supported on Android's libc and will soon be 
removed from Fuchsia's

Reviewed By: enh

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

Added: 


Modified: 
clang/include/clang/AST/FormatString.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/OSLog.cpp
clang/lib/AST/PrintfFormatString.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/FixIt/format.m
clang/test/Sema/format-strings.c

Removed: 




diff  --git a/clang/include/clang/AST/FormatString.h 
b/clang/include/clang/AST/FormatString.h
index 5a407b9261922..d7933382f13d6 100644
--- a/clang/include/clang/AST/FormatString.h
+++ b/clang/include/clang/AST/FormatString.h
@@ -726,7 +726,8 @@ class FormatStringHandler {
 
   virtual bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier ,
  const char *startSpecifier,
- unsigned specifierLen) {
+ unsigned specifierLen,
+ const TargetInfo ) {
 return true;
   }
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 19ce0ffcec51d..88e430d8eb09f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9369,6 +9369,9 @@ def warn_printf_ObjCflags_without_ObjCConversion: Warning<
 def warn_printf_invalid_objc_flag: Warning<
 "'%0' is not a valid object format flag">,
 InGroup;
+def warn_printf_narg_not_supported : Warning<
+"'%%n' specifier not supported on this platform">,
+InGroup;
 def warn_scanf_scanlist_incomplete : Warning<
   "no closing ']' for '%%[' in scanf format string">,
   InGroup;

diff  --git a/clang/lib/AST/OSLog.cpp b/clang/lib/AST/OSLog.cpp
index 094c0102854b1..4cc5def0651f7 100644
--- a/clang/lib/AST/OSLog.cpp
+++ b/clang/lib/AST/OSLog.cpp
@@ -56,8 +56,8 @@ class OSLogFormatStringHandler
   }
 
   bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier ,
- const char *StartSpecifier,
- unsigned SpecifierLen) override {
+ const char *StartSpecifier, unsigned SpecifierLen,
+ const TargetInfo &) override {
 if (!FS.consumesDataArgument() &&
 FS.getConversionSpecifier().getKind() !=
 clang::analyze_format_string::ConversionSpecifier::PrintErrno)

diff  --git a/clang/lib/AST/PrintfFormatString.cpp 
b/clang/lib/AST/PrintfFormatString.cpp
index a286db3b9b9f1..c6c41abc7e9a5 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -428,7 +428,7 @@ bool 
clang::analyze_format_string::ParsePrintfString(FormatStringHandler ,
   continue;
 // We have a format specifier.  Pass it to the callback.
 if (!H.HandlePrintfSpecifier(FSR.getValue(), FSR.getStart(),
- I - FSR.getStart()))
+ I - FSR.getStart(), Target))
   return true;
   }
   assert(I == E && "Format string not exhausted");

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 27653464110aa..e2b78fa212b81 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -499,7 +499,8 @@ class EstimateSizeFormatHandler
  1 /* null byte always written by sprintf */) {}
 
   bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier ,
- const char *, unsigned SpecifierLen) override {
+ const char *, unsigned SpecifierLen,
+ const TargetInfo &) override {
 
 const size_t FieldWidth = computeFieldWidth(FS);
 const size_t Precision = computePrecision(FS);
@@ -8909,8 +8910,8 @@ class CheckPrintfHandler : public CheckFormatHandler {
   void handleInvalidMaskType(StringRef MaskType) override;
 
   bool HandlePrintfSpecifier(const analyze_printf::PrintfSpecifier ,
- const char *startSpecifier,
- unsigned specifierLen) override;
+ const char *startSpecifier, unsigned specifierLen,
+ const TargetInfo ) override;
   bool checkFormatExpr(const analyze_printf::PrintfSpecifier ,
const char *StartSpecifier,
unsigned SpecifierLen,
@@ -9169,11 +9170,9 @@ bool