[PATCH] D158981: [clang][dataflow][NFC] Eliminate `getStorageLocation()` / `setStorageLocation()` in `DataflowAnalysisContext`.

2023-08-28 Thread Martin Böhme via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaef05a12329c: [clang][dataflow][NFC] Eliminate 
`getStorageLocation()` / `setStorageLocation… (authored by mboehme).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158981

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp


Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -74,19 +74,21 @@
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) {
-  if (auto *Loc = getStorageLocation(D))
+  if (auto *Loc = DeclToLoc.lookup(&D))
 return *Loc;
   auto &Loc = createStorageLocation(D.getType().getNonReferenceType());
-  setStorageLocation(D, Loc);
+  DeclToLoc[&D] = &Loc;
   return Loc;
 }
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(const Expr &E) {
-  if (auto *Loc = getStorageLocation(E))
+  const Expr &CanonE = ignoreCFGOmittedNodes(E);
+
+  if (auto *Loc = ExprToLoc.lookup(&CanonE))
 return *Loc;
-  auto &Loc = createStorageLocation(E.getType());
-  setStorageLocation(E, Loc);
+  auto &Loc = createStorageLocation(CanonE.getType());
+  ExprToLoc[&CanonE] = &Loc;
   return Loc;
 }
 
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -103,39 +103,6 @@
   /// Returns a stable storage location for `E`.
   StorageLocation &getStableStorageLocation(const Expr &E);
 
-  /// Assigns `Loc` as the storage location of `D`.
-  ///
-  /// Requirements:
-  ///
-  ///  `D` must not be assigned a storage location.
-  void setStorageLocation(const ValueDecl &D, StorageLocation &Loc) {
-assert(!DeclToLoc.contains(&D));
-DeclToLoc[&D] = &Loc;
-  }
-
-  /// Returns the storage location assigned to `D` or null if `D` has no
-  /// assigned storage location.
-  StorageLocation *getStorageLocation(const ValueDecl &D) const {
-return DeclToLoc.lookup(&D);
-  }
-
-  /// Assigns `Loc` as the storage location of `E`.
-  ///
-  /// Requirements:
-  ///
-  ///  `E` must not be assigned a storage location.
-  void setStorageLocation(const Expr &E, StorageLocation &Loc) {
-const Expr &CanonE = ignoreCFGOmittedNodes(E);
-assert(!ExprToLoc.contains(&CanonE));
-ExprToLoc[&CanonE] = &Loc;
-  }
-
-  /// Returns the storage location assigned to `E` or null if `E` has no
-  /// assigned storage location.
-  StorageLocation *getStorageLocation(const Expr &E) const {
-return ExprToLoc.lookup(&ignoreCFGOmittedNodes(E));
-  }
-
   /// Returns a pointer value that represents a null pointer. Calls with
   /// `PointeeType` that are canonically equivalent will return the same 
result.
   /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.


Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -74,19 +74,21 @@
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) {
-  if (auto *Loc = getStorageLocation(D))
+  if (auto *Loc = DeclToLoc.lookup(&D))
 return *Loc;
   auto &Loc = createStorageLocation(D.getType().getNonReferenceType());
-  setStorageLocation(D, Loc);
+  DeclToLoc[&D] = &Loc;
   return Loc;
 }
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(const Expr &E) {
-  if (auto *Loc = getStorageLocation(E))
+  const Expr &CanonE = ignoreCFGOmittedNodes(E);
+
+  if (auto *Loc = ExprToLoc.lookup(&CanonE))
 return *Loc;
-  auto &Loc = createStorageLocation(E.getType());
-  setStorageLocation(E, Loc);
+  auto &Loc = createStorageLocation(CanonE.getType());
+  ExprToLoc[&CanonE] = &Loc;
   return Loc;
 }
 
Index: clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
===
--- clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -103,39 +103,6 @@
   /// Returns a stable storage location for `E`.
   StorageLocation &getStableStorageLocation(const Expr &E);
 
-  /// Assigns `Loc` as the storage location of `D`.
-  ///
-  /// Requirements:
-  ///
-  ///  `D` must not be assigned a storage location.
-  void setStorageLocation(const ValueDecl &D, StorageLocation &Loc) {
-assert(

[clang] aef05a1 - [clang][dataflow][NFC] Eliminate `getStorageLocation()` / `setStorageLocation()` in `DataflowAnalysisContext`.

2023-08-28 Thread Martin Braenne via cfe-commits

Author: Martin Braenne
Date: 2023-08-29T06:53:48Z
New Revision: aef05a12329cf83c0a6fe46b464ab6ac08ee3439

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

LOG: [clang][dataflow][NFC] Eliminate `getStorageLocation()` / 
`setStorageLocation()` in `DataflowAnalysisContext`.

Instead, inline them into the `getStableStorageLocation()` overloads, which is 
the only place they were called from (and should be called from).

`getStorageLocation()` / `setStorageLocation()` were confusing because neither 
their name nor their documentation made reference to the fact that the storage 
location is stable.

It didn't make sense to keep these as private member functions either. The code 
for the two `getStableStorageLocation()` overloads has become only marginally 
more complex by inlining these functions, and the `Expr` version is actually 
more efficient because we only call `ignoreCFGOmittedNodes()` once instead of 
twice.

Reviewed By: ymandel, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp

Removed: 




diff  --git 
a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
index e5c325b876bd7a..685bbe486b54e1 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
@@ -103,39 +103,6 @@ class DataflowAnalysisContext {
   /// Returns a stable storage location for `E`.
   StorageLocation &getStableStorageLocation(const Expr &E);
 
-  /// Assigns `Loc` as the storage location of `D`.
-  ///
-  /// Requirements:
-  ///
-  ///  `D` must not be assigned a storage location.
-  void setStorageLocation(const ValueDecl &D, StorageLocation &Loc) {
-assert(!DeclToLoc.contains(&D));
-DeclToLoc[&D] = &Loc;
-  }
-
-  /// Returns the storage location assigned to `D` or null if `D` has no
-  /// assigned storage location.
-  StorageLocation *getStorageLocation(const ValueDecl &D) const {
-return DeclToLoc.lookup(&D);
-  }
-
-  /// Assigns `Loc` as the storage location of `E`.
-  ///
-  /// Requirements:
-  ///
-  ///  `E` must not be assigned a storage location.
-  void setStorageLocation(const Expr &E, StorageLocation &Loc) {
-const Expr &CanonE = ignoreCFGOmittedNodes(E);
-assert(!ExprToLoc.contains(&CanonE));
-ExprToLoc[&CanonE] = &Loc;
-  }
-
-  /// Returns the storage location assigned to `E` or null if `E` has no
-  /// assigned storage location.
-  StorageLocation *getStorageLocation(const Expr &E) const {
-return ExprToLoc.lookup(&ignoreCFGOmittedNodes(E));
-  }
-
   /// Returns a pointer value that represents a null pointer. Calls with
   /// `PointeeType` that are canonically equivalent will return the same 
result.
   /// A null `PointeeType` can be used for the pointee of `std::nullptr_t`.

diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
index 0a6d7792208258..47a994f4bbdb6a 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -74,19 +74,21 @@ StorageLocation 
&DataflowAnalysisContext::createStorageLocation(QualType Type) {
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(const VarDecl &D) {
-  if (auto *Loc = getStorageLocation(D))
+  if (auto *Loc = DeclToLoc.lookup(&D))
 return *Loc;
   auto &Loc = createStorageLocation(D.getType().getNonReferenceType());
-  setStorageLocation(D, Loc);
+  DeclToLoc[&D] = &Loc;
   return Loc;
 }
 
 StorageLocation &
 DataflowAnalysisContext::getStableStorageLocation(const Expr &E) {
-  if (auto *Loc = getStorageLocation(E))
+  const Expr &CanonE = ignoreCFGOmittedNodes(E);
+
+  if (auto *Loc = ExprToLoc.lookup(&CanonE))
 return *Loc;
-  auto &Loc = createStorageLocation(E.getType());
-  setStorageLocation(E, Loc);
+  auto &Loc = createStorageLocation(CanonE.getType());
+  ExprToLoc[&CanonE] = &Loc;
   return Loc;
 }
 



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


[PATCH] D159068: [clang][X86] Update excessive register save diagnostic to more closely follow the interrupt attribute spec

2023-08-28 Thread Antonio Abbatangelo via Phabricator via cfe-commits
antangelo created this revision.
antangelo added reviewers: erichkeane, aaron.ballman, mibintc.
Herald added a project: All.
antangelo requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The original diagnostic does not cover all cases according to my reading
of the spec.

For the interrupt attribute, the spec indicates that if the compiler
does not support saving SSE, MMX, or x87 then the function should
be compiled with '-mgeneral-regs-only' (GCC requires this).
Alternatively, calling functions with the `no_caller_saved_registers`
attribute will not clobber state and can be done without disabling
these features.

The warning as implemented in upstream only detects the latter case but
does not consider that disabling the above features also solves the issue
of these register saves being undesirable due to inefficiency.

For the no_caller_saved_registers attribute, the interrupt spec also
indicates that in the absence of saving SSE, MMX and x87 state, these
functions should be compiled with '-mgeneral-regs-only' (also required
by GCC). It does not make any statements about calling other functions
with the attribute, but by extension the result is the same as with the
interrupt attribute (in clang, at least).

This patch handles the remaining cases by adjusting the diagnostic to:

1. Not be shown if the function is compiled without the SSE, MMX or x87 
features enabled (i.e. with '-mgeneral-regs-only')
2. Also be shown for functions with the 'no_caller_saved_registers' attribute
3. In addition to advising that the function should only call functions with 
the `no_caller_saved_registers` attribute, the text also suggests compiling 
with `-mgeneral-regs-only` as an alternative.

The interrupt spec is available at 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=5ed3cc7b66af4758f7849ed6f65f4365be8223be
and was taken from the issue that resulted in this diagnostic being
added (#26787)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159068

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-x86-interrupt.c
  clang/test/Sema/x86-diag-excessive-regsave.c

Index: clang/test/Sema/x86-diag-excessive-regsave.c
===
--- /dev/null
+++ clang/test/Sema/x86-diag-excessive-regsave.c
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s -DNO_CALLER_SAVED_REGISTERS=1
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -target-feature -x87 -target-feature -mmx -target-feature -sse -fsyntax-only -verify %s -DGPRONLY=1
+
+#if defined(NO_CALLER_SAVED_REGS) || defined(GPRONLY)
+// expected-no-diagnostics
+#else
+#define EXPECT_WARNING
+#endif
+
+#ifdef NO_CALLER_SAVED_REGS
+__attribute__((no_caller_saved_registers))
+#endif
+#ifdef EXPECT_WARNING
+// expected-note@+3 {{'foo' declared here}}
+// expected-note@+2 {{'foo' declared here}}
+#endif
+extern void foo(void *);
+
+__attribute__((no_caller_saved_registers))
+void no_caller_saved_registers(void *arg) {
+#ifdef EXPECT_WARNING
+// expected-warning@+2 {{function with attribute 'no_caller_saved_registers' should only call a function with attribute 'no_caller_saved_registers' or be compiled with '-mgeneral-regs-only'}}
+#endif
+foo(arg);
+}
+
+__attribute__((interrupt))
+void interrupt(void *arg) {
+#ifdef EXPECT_WARNING
+// expected-warning@+2 {{interrupt service routine should only call a function with attribute 'no_caller_saved_registers' or be compiled with '-mgeneral-regs-only'}}
+#endif
+foo(arg);
+}
Index: clang/test/Sema/attr-x86-interrupt.c
===
--- clang/test/Sema/attr-x86-interrupt.c
+++ clang/test/Sema/attr-x86-interrupt.c
@@ -40,23 +40,6 @@
 __attribute__((interrupt)) void foo7(int *a, unsigned b) {}
 __attribute__((interrupt)) void foo8(int *a) {}
 
-#ifdef _LP64
-typedef unsigned long Arg2Type;
-#elif defined(__x86_64__)
-typedef unsigned long long Arg2Type;
-#else
-typedef unsigned int Arg2Type;
-#endif
-#ifndef NOCALLERSAVE
-__attribute__((no_caller_saved_registers))
-#else
-// expected-note@+3 {{'foo9' declared here}}
-// expected-warning@+4 {{interrupt service routine should only call a function with attribute 'no_caller_saved_registers'}}
-#endif
-void foo9(int *a, Arg2Type b) {}
-__attribute__((interrupt)) void fooA(int *a, Arg2Type b) {
-  foo9(a, b);
-}
 void g(void (*fp)(int *));
 int main(int argc, char **argv) {
   void *ptr = (void *)&foo7;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -7413,11 +7413,18 @@
   Diag(FDecl->getLocation(), diag::note_callee_decl) << FDecl;
   }

[clang] 20e6515 - [Coroutines] Mark 'coroutine_handle<>::address' as always-inline

2023-08-28 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-08-29T14:35:27+08:00
New Revision: 20e6515d5c5ff155a54e10f64caef1c76d8d5976

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

LOG: [Coroutines] Mark 'coroutine_handle<>::address' as always-inline

Close https://github.com/llvm/llvm-project/issues/65054

The direct issue is still the call to coroutine_handle<>::address()
after await_suspend(). Without optimizations, the current logic will put
the temporary result of await_suspend() to the coroutine frame since the
middle end feel the temporary is escaped from
coroutine_handle<>::address. To fix this fundamentally, we should wrap
the whole logic about await-suspend into a standalone function. See
https://github.com/llvm/llvm-project/issues/64945

And as a short-term workaround, we probably can mark
coroutine_handle<>::address() as always-inline so that the temporary
result may not be thought to be escaped then it won't be put on the
coroutine frame. Although it looks dirty, it is probably do-able since
the compiler are allowed to do special tricks to standard library
components.

Added: 
clang/test/CodeGenCoroutines/pr65054.cpp

Modified: 
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 0b2987376b8b3b..42e428344888a8 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -344,6 +344,28 @@ static Expr *maybeTailCall(Sema &S, QualType RetType, Expr 
*E,
 
   Expr *JustAddress = AddressExpr.get();
 
+  // FIXME: Without optimizations, the temporary result from `await_suspend()`
+  // may be put on the coroutine frame since the coroutine frame constructor
+  // will think the temporary variable will escape from the
+  // `coroutine_handle<>::address()` call. This is problematic since the
+  // coroutine should be considered to be suspended after it enters
+  // `await_suspend` so it shouldn't access/update the coroutine frame after
+  // that.
+  //
+  // See https://github.com/llvm/llvm-project/issues/65054 for the report.
+  //
+  // The long term solution may wrap the whole logic about `await-suspend`
+  // into a standalone function. This is similar to the proposed solution
+  // in tryMarkAwaitSuspendNoInline. See the comments there for details.
+  //
+  // The short term solution here is to mark `coroutine_handle<>::address()`
+  // function as always-inline so that the coroutine frame constructor won't
+  // think the temporary result is escaped incorrectly.
+  if (auto *FD = cast(JustAddress)->getDirectCallee())
+if (!FD->hasAttr() && !FD->hasAttr())
+  FD->addAttr(AlwaysInlineAttr::CreateImplicit(S.getASTContext(),
+   FD->getLocation()));
+
   // Check that the type of AddressExpr is void*
   if (!JustAddress->getType().getTypePtr()->isVoidPointerType())
 S.Diag(cast(JustAddress)->getCalleeDecl()->getLocation(),

diff  --git a/clang/test/CodeGenCoroutines/pr65054.cpp 
b/clang/test/CodeGenCoroutines/pr65054.cpp
new file mode 100644
index 00..834b71050f59ff
--- /dev/null
+++ b/clang/test/CodeGenCoroutines/pr65054.cpp
@@ -0,0 +1,60 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN:  -O0 -disable-llvm-passes -emit-llvm %s -o - \
+// RUN:  | FileCheck %s --check-prefix=FRONTEND
+
+// The output of O0 is highly redundant and hard to test. Also it is not good
+// limit the output of O0. So we test the optimized output from O0. The idea
+// is the optimizations shouldn't change the semantics of the program.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN:  -O0 -emit-llvm %s -o - -disable-O0-optnone \
+// RUN:  | opt -passes='sroa,mem2reg,simplifycfg' -S | FileCheck %s 
--check-prefix=CHECK-O0
+
+#include "Inputs/coroutine.h"
+
+// A simple awaiter type with an await_suspend method that can't be
+// inlined.
+struct Awaiter {
+  const int& x;
+
+  bool await_ready() { return false; }
+  std::coroutine_handle<> await_suspend(const std::coroutine_handle<> h);
+  void await_resume() {}
+};
+
+struct MyTask {
+  // A lazy promise with an await_transform method that supports awaiting
+  // integer references using the Awaiter struct above.
+  struct promise_type {
+MyTask get_return_object() {
+  return MyTask{
+  std::coroutine_handle::from_promise(*this),
+  };
+}
+
+std::suspend_always initial_suspend() { return {}; }
+std::suspend_always final_suspend() noexcept { return {}; }
+void unhandled_exception();
+
+auto await_transform(const int& x) { return Awaiter{x}; }
+  };
+
+  std::coroutine_handle<> h;
+};
+
+// A global array of integers.
+int g_array[32];
+
+// A coroutine that awaits each integer in the 

[PATCH] D159045: [clang-tidy] Improved documentation for readability-function-size

2023-08-28 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL accepted this revision.
PiotrZSL added a comment.
This revision is now accepted and ready to land.

Change is ok. Interesting thing is that we got more of such issues in many 
checks. I'm thinking, maybe support for optional fields is needed, fields that 
can accept integer or false/no values.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159045

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


[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana added inline comments.



Comment at: clang/lib/Headers/__stddef_null.h:14
+ * __need_NULL and rely on stddef.h to redefine NULL to the correct value 
again.
+ * Modules don't support redefining macros like that, but support that pattern
+ * in the non-modules case.

I couldn't come up with anything clever to support this in modules. If I get 
rid of the guard, `NULL` still doesn't get redefined in modules. If I move the 
`undef` to stddef.h then `NULL` gets undefined, but not redefined. So I think 
precompiled modules must inherently have `#pragma once` semantics. If we really 
had to, we could move this back into stddef.h and let it be textual, but it's 
distasteful that `NULL` gets defined in every single module that includes 
stddef.h and has to be merged later.



Comment at: clang/test/Headers/stdarg.c:4
 // RUN: %clang_cc1 -fsyntax-only -verify=c99 
-Werror=implicit-function-declaration -std=c99 %t/stdarg0.c
+// RUN: %clang_cc1 -fsyntax-only -verify=c89-modules -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t 
-Werror=implicit-function-declaration -std=c89 %t/stdarg0.c
+// RUN: %clang_cc1 -fsyntax-only -verify=c99-modules -fmodules 
-fimplicit-module-maps -fmodules-cache-path=%t 
-Werror=implicit-function-declaration -std=c99 %t/stdarg0.c

I think it's fine to use these same tests to validate that modules mode makes 
the same things visible as non-modules mode depending on the standard and set 
`__need_` macros?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159064

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


[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 554193.
iana added a comment.

Add `@import` tests for all of the new modules


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159064

Files:
  clang/lib/Headers/__stddef_max_align_t.h
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/__stddef_nullptr_t.h
  clang/lib/Headers/__stddef_offsetof.h
  clang/lib/Headers/__stddef_ptrdiff_t.h
  clang/lib/Headers/__stddef_rsize_t.h
  clang/lib/Headers/__stddef_size_t.h
  clang/lib/Headers/__stddef_unreachable.h
  clang/lib/Headers/__stddef_wchar_t.h
  clang/lib/Headers/__stddef_wint_t.h
  clang/lib/Headers/module.modulemap
  clang/lib/Headers/stddef.h
  clang/test/Headers/stdarg.c
  clang/test/Headers/stdargneeds.c
  clang/test/Headers/stddef.c
  clang/test/Headers/stddefneeds.c
  clang/test/Modules/compiler_builtins.m

Index: clang/test/Modules/compiler_builtins.m
===
--- clang/test/Modules/compiler_builtins.m
+++ clang/test/Modules/compiler_builtins.m
@@ -11,3 +11,17 @@
 #ifdef __AVX2__
 @import _Builtin_intrinsics.intel.avx2;
 #endif
+
+@import _Builtin_float;
+@import _Builtin_inttypes;
+@import _Builtin_iso646;
+@import _Builtin_limits;
+@import _Builtin_stdalign;
+@import _Builtin_stdarg;
+@import _Builtin_stdatomic;
+@import _Builtin_stdbool;
+@import _Builtin_stddef;
+@import _Builtin_stdint;
+@import _Builtin_stdnoreturn;
+@import _Builtin_tgmath;
+@import _Builtin_unwind;
Index: clang/test/Headers/stddefneeds.c
===
--- clang/test/Headers/stddefneeds.c
+++ clang/test/Headers/stddefneeds.c
@@ -1,36 +1,73 @@
+// RUN: rm -fR %t
 // RUN: %clang_cc1 -fsyntax-only -verify=c99 -std=c99 %s
 // RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c99-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c23-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c23 %s
 
 // Use C99 to verify that __need_ can be used to get types that wouldn't normally be available.
 
 struct astruct { char member; };
 
-ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}}
-size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}}
-rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}}
-wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}}
-void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}}
-nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}}
-static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}}
-max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}}
+ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}} \
+ c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}} \
+  c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}} \
+   c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}} \
+c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}} \
+c99-modules-error{{undeclared identifier}} c23-modules-error{{undeclared identifier}}
+nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}} \
+ c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}} \
+   c99-modules-error{{undeclared function}} c23-modules-error{{undeclared identifier}}
+max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}} \
+   c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
 size_t o0 = offsetof(struct astruct, member); // c99-error{{unknown type name 'size_t'}} c99-error{{call to undeclared function 'offsetof'}} c99-error{{expected expression}} c99-error{{use of undeclared identifier 'member'}} \
- c23-error{{unknown type name 'size_t'}} c23-error{{undeclared identifier 'offsetof'}} c23-error{{expected expression}} c23-error{{use of undeclared identifier 'member'}}
-wi

[PATCH] D159018: [clang][modules] Add a c23 module feature

2023-08-28 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM!

In D159018#4622598 , @iana wrote:

> Would we want to back port this to llvm 17?

Yes probably.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159018

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


[PATCH] D158475: [driver] Refactor getRuntimePaths. NFC

2023-08-28 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

In D158475#4623842 , @smeenai wrote:

> In D158475#4623471 , @glandium 
> wrote:
>
>> This conflicts with D146664 
>
> It sounds like you want the same logic as D158476 
>  to apply to the stdlib search as well as 
> the runtimes search, right?

Sounds about right.

> I can make both be consistent.

That would be much appreciated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158475

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


[PATCH] D158475: [driver] Refactor getRuntimePaths. NFC

2023-08-28 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D158475#4623471 , @glandium wrote:

> This conflicts with D146664 

It sounds like you want the same logic as D158476 
 to apply to the stdlib search as well as the 
runtimes search, right? I can make both be consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158475

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


[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0cfc2dba93b1: [OpenMP] Allow exceptions in target regions 
when offloading to GPUs (authored by AntonRydahl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CGException.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/OpenMP/amdgpu_exceptions.cpp
  clang/test/OpenMP/amdgpu_throw.cpp
  clang/test/OpenMP/amdgpu_throw_trap.cpp
  clang/test/OpenMP/amdgpu_try_catch.cpp
  clang/test/OpenMP/nvptx_exceptions.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
  clang/test/OpenMP/nvptx_throw.cpp
  clang/test/OpenMP/nvptx_throw_trap.cpp
  clang/test/OpenMP/nvptx_try_catch.cpp
  clang/test/OpenMP/x86_target_exceptions.cpp
  clang/test/OpenMP/x86_target_throw.cpp
  clang/test/OpenMP/x86_target_try_catch.cpp

Index: clang/test/OpenMP/x86_target_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_try_catch.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		error = 1;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_throw.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_throw.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+void foo(void) {
+	throw 404;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_exceptions.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_exceptions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		throw 404;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/nvptx_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_try_catch.cpp
@@ -0,0 +1,45 @@
+/**
+ * The first four lines test that a warning is produced when enabling 
+ * -Wopenmp-target-exception no matter what combination of -fexceptions and 
+ * -fcxx-exceptions are set, as we want OpenMP to always allow exceptions in the
+ * target region but emit a warning instead.
+*/
+
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+
+/**
+ * The following four lines test that no warning is emitted when providing 
+ * -Wno-openmp-target-exception no matter the combination of -fexceptions and 
+ * -fcxx-exceptions.
+*/
+
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+
+/**
+ * Finally we should test that we only ignore exceptions in the OpenMP 
+ * offloading tool-chain
+*/
+
+// RUN: %clang_cc1 -triple nvptx64 %s -emit-llvm -S -verify=noexceptions -o -
+
+// noexceptions-error@36 {{cannot use 'try' with exceptions disabled}}
+
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try { // with-warning {{target 'nvptx64' does not support except

[clang] 0cfc2db - [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread via cfe-commits

Author: Anton Rydahl
Date: 2023-08-28T22:36:13-07:00
New Revision: 0cfc2dba93b172802b580713a492ea14148a0218

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

LOG: [OpenMP] Allow exceptions in target regions when offloading to GPUs

The motivation for this patch is that many code bases use exception handling. 
As GPUs are not expected to support exception handling in the near future, we 
can experiment with compiling the code for GPU targets anyway. This will
allow us to run the code, as long as no exception is thrown.

The overall idea is very simple:
- If a throw expression is compiled to AMDGCN or NVPTX, it is replaced with a 
trap during code generation.
- If a try/catch statement is compiled to AMDGCN or AMDHSA, we ganerate code 
for the try statement as if it were a basic block.

With this patch, the compilation of the following example
```{C++}
int gaussian_sum(int a,int b){
if ((a + b) % 2 == 0) {throw -1;};
return (a+b) * ((a+b)/2);
}

int main(void) {
int gauss = 0;
#pragma omp target map(from:gauss)
{
try {
gauss = gaussian_sum(1,100);
}
catch (int e){
gauss = e;
}
}
std::cout << "GaussianSum(1,100)=";
 def err_opencl_feature_requires : Error<
   "feature %0 requires support of %1 feature">;
+
+def warn_throw_not_valid_on_target : Warning<
+  "target '%0' does not support exception handling;"
+  " 'throw' is assumed to be never reached">,
+  InGroup;
+def warn_try_not_valid_on_target : Warning<
+  "target '%0' does not support exception handling;"
+  " 'catch' block is ignored">,
+  InGroup;
 }

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index d1aa51393ef357..00c458fb23e73e 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1292,9 +1292,10 @@ def OpenMPTarget : DiagGroup<"openmp-target", 
[OpenMPMapping]>;
 def OpenMPPre51Compat : DiagGroup<"pre-openmp-51-compat">;
 def OpenMP51Ext : DiagGroup<"openmp-51-extensions">;
 def OpenMPExtensions : DiagGroup<"openmp-extensions">;
+def OpenMPTargetException : DiagGroup<"openmp-target-exception">;
 def OpenMP : DiagGroup<"openmp", [
 SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget,
-OpenMPMapping, OpenMP51Ext, OpenMPExtensions
+OpenMPMapping, OpenMP51Ext, OpenMPExtensions, OpenMPTargetException
   ]>;
 
 // Backend warnings.

diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index 9cb7d4c7731deb..3996f2948349cb 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -440,6 +440,15 @@ llvm::Value *CodeGenFunction::getSelectorFromSlot() {
 
 void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E,
bool KeepInsertionPoint) {
+  // If the exception is being emitted in an OpenMP target region,
+  // and the target is a GPU, we do not support exception handling.
+  // Therefore, we emit a trap which will abort the program, and
+  // prompt a warning indicating that a trap will be emitted.
+  const llvm::Triple &T = Target.getTriple();
+  if (CGM.getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN())) 
{
+EmitTrapCall(llvm::Intrinsic::trap);
+return;
+  }
   if (const Expr *SubExpr = E->getSubExpr()) {
 QualType ThrowType = SubExpr->getType();
 if (ThrowType->isObjCObjectPointerType()) {

[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 554183.
iana added a comment.

Remove the module cache before running the stdarg/stddef unit tests in module 
mode


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159064

Files:
  clang/lib/Headers/__stddef_max_align_t.h
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/__stddef_nullptr_t.h
  clang/lib/Headers/__stddef_offsetof.h
  clang/lib/Headers/__stddef_ptrdiff_t.h
  clang/lib/Headers/__stddef_rsize_t.h
  clang/lib/Headers/__stddef_size_t.h
  clang/lib/Headers/__stddef_unreachable.h
  clang/lib/Headers/__stddef_wchar_t.h
  clang/lib/Headers/__stddef_wint_t.h
  clang/lib/Headers/module.modulemap
  clang/lib/Headers/stddef.h
  clang/test/Headers/stdarg.c
  clang/test/Headers/stdargneeds.c
  clang/test/Headers/stddef.c
  clang/test/Headers/stddefneeds.c

Index: clang/test/Headers/stddefneeds.c
===
--- clang/test/Headers/stddefneeds.c
+++ clang/test/Headers/stddefneeds.c
@@ -1,36 +1,73 @@
+// RUN: rm -fR %t
 // RUN: %clang_cc1 -fsyntax-only -verify=c99 -std=c99 %s
 // RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c99-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c23-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c23 %s
 
 // Use C99 to verify that __need_ can be used to get types that wouldn't normally be available.
 
 struct astruct { char member; };
 
-ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}}
-size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}}
-rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}}
-wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}}
-void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}}
-nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}}
-static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}}
-max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}}
+ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}} \
+ c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}} \
+  c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}} \
+   c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}} \
+c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}} \
+c99-modules-error{{undeclared identifier}} c23-modules-error{{undeclared identifier}}
+nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}} \
+ c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}} \
+   c99-modules-error{{undeclared function}} c23-modules-error{{undeclared identifier}}
+max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}} \
+   c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
 size_t o0 = offsetof(struct astruct, member); // c99-error{{unknown type name 'size_t'}} c99-error{{call to undeclared function 'offsetof'}} c99-error{{expected expression}} c99-error{{use of undeclared identifier 'member'}} \
- c23-error{{unknown type name 'size_t'}} c23-error{{undeclared identifier 'offsetof'}} c23-error{{expected expression}} c23-error{{use of undeclared identifier 'member'}}
-wint_t wi0; // c99-error{{unknown type name 'wint_t'}} c23-error{{unknown type}}
+ c23-error{{unknown type name 'size_t'}} c23-error{{undeclared identifier 'offsetof'}} c23-error{{expected expression}} c23-error{{use of undeclared identifier 'member'}} \
+ c99-modules-error{{unknown type}} c99-modules-error{{undeclared function}} c99-modules-error{{expected expression}} c99-modules-error{{undeclared identifier}} \
+ c23-modules-error{{unknown type}} c23-modules-error{{undeclared identifier}} c2

[PATCH] D159064: [Modules] Make clang modules for the C standard library headers

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana created this revision.
iana added reviewers: aaron.ballman, rsmith, efriedma, ldionne, ChuanqiXu, 
Bigcheese, vsapsai, benlangmuir, dexonsmith.
Herald added a subscriber: ributzka.
Herald added a project: All.
iana requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Make top level modules for all the C standard library headers. Now that the 
stddef headers are modular, they can lose all of the __has_feature(modules) 
checks and declare their include guards.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159064

Files:
  clang/lib/Headers/__stddef_max_align_t.h
  clang/lib/Headers/__stddef_null.h
  clang/lib/Headers/__stddef_nullptr_t.h
  clang/lib/Headers/__stddef_offsetof.h
  clang/lib/Headers/__stddef_ptrdiff_t.h
  clang/lib/Headers/__stddef_rsize_t.h
  clang/lib/Headers/__stddef_size_t.h
  clang/lib/Headers/__stddef_unreachable.h
  clang/lib/Headers/__stddef_wchar_t.h
  clang/lib/Headers/__stddef_wint_t.h
  clang/lib/Headers/module.modulemap
  clang/lib/Headers/stddef.h
  clang/test/Headers/stdarg.c
  clang/test/Headers/stdargneeds.c
  clang/test/Headers/stddef.c
  clang/test/Headers/stddefneeds.c

Index: clang/test/Headers/stddefneeds.c
===
--- clang/test/Headers/stddefneeds.c
+++ clang/test/Headers/stddefneeds.c
@@ -1,36 +1,72 @@
 // RUN: %clang_cc1 -fsyntax-only -verify=c99 -std=c99 %s
 // RUN: %clang_cc1 -fsyntax-only -verify=c23 -std=c23 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c99-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c99 %s
+// RUN: %clang_cc1 -fsyntax-only -verify=c23-modules -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -std=c23 %s
 
 // Use C99 to verify that __need_ can be used to get types that wouldn't normally be available.
 
 struct astruct { char member; };
 
-ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}}
-size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}}
-rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}}
-wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}}
-void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}}
-nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}}
-static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}}
-max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}}
+ptrdiff_t p0; // c99-error{{unknown type name 'ptrdiff_t'}} c23-error{{unknown type}} \
+ c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+size_t s0; // c99-error{{unknown type name 'size_t'}} c23-error{{unknown type}} \
+  c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+rsize_t r0; // c99-error{{unknown type name 'rsize_t'}} c23-error{{unknown type}} \
+   c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+wchar_t wc0; // c99-error{{unknown type name 'wchar_t'}} c23-error{{unknown type}} \
+c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+void *v0 = NULL; // c99-error{{use of undeclared identifier 'NULL'}} c23-error{{undeclared identifier}} \
+c99-modules-error{{undeclared identifier}} c23-modules-error{{undeclared identifier}}
+nullptr_t n0; // c99-error{{unknown type name 'nullptr_t'}} c23-error{{unknown type}} \
+ c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
+static void f0(void) { unreachable(); } // c99-error{{call to undeclared function 'unreachable'}} c23-error{{undeclared identifier 'unreachable'}} \
+   c99-modules-error{{undeclared function}} c23-modules-error{{undeclared identifier}}
+max_align_t m0; // c99-error{{unknown type name 'max_align_t'}} c23-error{{unknown type}} \
+   c99-modules-error{{unknown type}} c23-modules-error{{unknown type}}
 size_t o0 = offsetof(struct astruct, member); // c99-error{{unknown type name 'size_t'}} c99-error{{call to undeclared function 'offsetof'}} c99-error{{expected expression}} c99-error{{use of undeclared identifier 'member'}} \
- c23-error{{unknown type name 'size_t'}} c23-error{{undeclared identifier 'offsetof'}} c23-error{{expected expression}} c23-error{{use of undeclared identifier 'member'}}
-wint_t wi0; // c99-error{{unknown type name 'wint_t'}} c23-error{{unknown type}}
+ c23-error{{unknown type name 'size_t'}} c23-error{{undeclared identifier 'offsetof'}} c23-error{{expected expression}} c23-error{{use of undeclared identifier 'member'}} \
+ c99-

[PATCH] D152054: [OpenMP] Codegen support for thread_limit on target directive

2023-08-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D152054#4622642 , @vadikp-intel 
wrote:

> Windows importing is now done by name, and new exports do not need to have an 
> ordinal specified for them i.e. you can add a line with just the API name to 
> dllexports.

Oh, right, thanks. Will do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152054

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


[PATCH] D159018: [clang][modules] Add a c23 module feature

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana updated this revision to Diff 554158.
iana added a comment.

remove the extra #endif (which oddly didn't produce an error locally so I 
must've ran the tests wrong the first time...)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159018

Files:
  clang/docs/Modules.rst
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Module.cpp
  clang/test/Modules/Inputs/DependsOnModule.framework/module.map
  clang/test/Modules/requires.m


Index: clang/test/Modules/requires.m
===
--- clang/test/Modules/requires.m
+++ clang/test/Modules/requires.m
@@ -35,4 +35,6 @@
 @import DependsOnModule.C11; // expected-note {{module imported here}}
 // expected-error@DependsOnModule.framework/module.map:64 {{module 
'DependsOnModule.C17' requires feature 'c17'}}
 @import DependsOnModule.C17; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:67 {{module 
'DependsOnModule.C23' requires feature 'c23'}}
+@import DependsOnModule.C23; // expected-note {{module imported here}}
 #endif
Index: clang/test/Modules/Inputs/DependsOnModule.framework/module.map
===
--- clang/test/Modules/Inputs/DependsOnModule.framework/module.map
+++ clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -64,4 +64,7 @@
   explicit module C17 {
 requires c17
   }
+  explicit module C23 {
+requires c23
+  }
 }
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -113,6 +113,7 @@
 .Case("c99", LangOpts.C99)
 .Case("c11", LangOpts.C11)
 .Case("c17", LangOpts.C17)
+.Case("c23", LangOpts.C23)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -107,6 +107,7 @@
   and the ``__STDC_VERSION__`` macro now expands to ``202311L`` instead of its
   previous placeholder value. Clang continues to accept ``-std=c2x`` and
   ``-std=gnu2x`` as aliases for C23 and GNU C23, respectively.
+- Clang now supports `requires c23` for module maps.
 
 Non-comprehensive list of changes in this release
 -
Index: clang/docs/Modules.rst
===
--- clang/docs/Modules.rst
+++ clang/docs/Modules.rst
@@ -588,6 +588,9 @@
 c17
   C17 support is available.
 
+c23
+  C23 support is available.
+
 freestanding
   A freestanding environment is available.
 


Index: clang/test/Modules/requires.m
===
--- clang/test/Modules/requires.m
+++ clang/test/Modules/requires.m
@@ -35,4 +35,6 @@
 @import DependsOnModule.C11; // expected-note {{module imported here}}
 // expected-error@DependsOnModule.framework/module.map:64 {{module 'DependsOnModule.C17' requires feature 'c17'}}
 @import DependsOnModule.C17; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:67 {{module 'DependsOnModule.C23' requires feature 'c23'}}
+@import DependsOnModule.C23; // expected-note {{module imported here}}
 #endif
Index: clang/test/Modules/Inputs/DependsOnModule.framework/module.map
===
--- clang/test/Modules/Inputs/DependsOnModule.framework/module.map
+++ clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -64,4 +64,7 @@
   explicit module C17 {
 requires c17
   }
+  explicit module C23 {
+requires c23
+  }
 }
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -113,6 +113,7 @@
 .Case("c99", LangOpts.C99)
 .Case("c11", LangOpts.C11)
 .Case("c17", LangOpts.C17)
+.Case("c23", LangOpts.C23)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -107,6 +107,7 @@
   and the ``__STDC_VERSION__`` macro now expands to ``202311L`` instead of its
   previous placeholder value. Clang continues to accept ``-std=c2x`` and
   ``-std=gnu2x`` as aliases for C23 an

[PATCH] D159054: [Driver] Removal of C_INCLUDE_DIRS feature

2023-08-28 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 554156.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159054

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Haiku.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OHOS.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Lex/InitHeaderSearch.cpp

Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -13,7 +13,6 @@
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Config/config.h" // C_INCLUDE_DIRS
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
@@ -260,16 +259,6 @@
   if (!HSOpts.UseStandardSystemIncludes)
 return;
 
-  // Add dirs specified via 'configure --with-c-include-dirs'.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs)
-  AddPath(dir, ExternCSystem, false);
-return;
-  }
-
   switch (os) {
   case llvm::Triple::CloudABI: {
 // //include
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -10,7 +10,6 @@
 #include "CommonArgs.h"
 #include "Gnu.h"
 #include "clang/Basic/Version.h"
-#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -413,19 +412,6 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Check for configure-time C include directories.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-}
-return;
-  }
-
   if (getTriple().getOS() != llvm::Triple::UnknownOS) {
 const std::string MultiarchTriple =
 getMultiarchTriple(D, getTriple(), D.SysRoot);
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -9,7 +9,6 @@
 #include "Solaris.h"
 #include "CommonArgs.h"
 #include "clang/Basic/LangStandard.h"
-#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -296,19 +295,6 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Check for configure-time C include directories.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-}
-return;
-  }
-
   // Add include directories specific to the selected multilib set and multilib.
   if (GCCInstallation.isValid()) {
 const MultilibSet::IncludeDirsFunc &Callback =
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -11,7 +11,6 @@
 #include "Arch/Mips.h"
 #include "Arch/Sparc.h"
 #include "CommonArgs.h"
-#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
@@ -307,19 +306,6 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Check for configure-time C include directories.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-}
-return;
-  }
-
   addExternCSystemInclude(DriverArgs, CC1Args,
   concat(D.SysRoot, "/usr/include"));
 }
Index: clang/lib

[PATCH] D158739: AIX: Issue an error when specifying an alias for a common symbol

2023-08-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added a comment.

Aside from the comments Digger has made, I have no additional concerns about 
this patch. It is an improvement (although there are adjacent cases that need 
further handling).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158739

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


[PATCH] D112921: [clang] Enable sized deallocation by default in C++14 onwards

2023-08-28 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc marked 2 inline comments as done.
wangpc added inline comments.



Comment at: clang/include/clang/Basic/SizedDeallocation.h:23
+namespace clang {
+inline llvm::VersionTuple sizedDeallocMinVersion(llvm::Triple::OSType OS) {
+  switch (OS) {

MaskRay wrote:
> Does this need to be in Basic/? It's only used by 
> clang/lib/Driver/ToolChains/Darwin.cpp
> 
> 
This file is just copied and changed from 
`clang/include/clang/Basic/AlignedAllocation.h` actually, I don't know which 
directory is more suitable.



Comment at: clang/include/clang/Basic/SizedDeallocation.h:36
+  case llvm::Triple::ZOS:
+return llvm::VersionTuple(); // All z/OS versions have no support.
+  }

MaskRay wrote:
> This is major=minor=0, which is probably not desired.
> 
> We can just omit ZOS.
We have ZOS in `alignedAllocMinVersion` in 
`clang/include/clang/Basic/AlignedAllocation.h` too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112921

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


[PATCH] D159054: [Driver] Removal of C_INCLUDE_DIRS feature

2023-08-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added a comment.
This revision is now accepted and ready to land.

Technically there is some risk but I think the blast radius, if present, is 
extremely small.

`C_INCLUDE_DIRS` is not recognized by GCC.

If I use 
https://sourcegraph.com/search?q=context:global+%5CbC_INCLUDE_DIRS%3D+-f:clang/&patternType=regexp&case=yes&sm=1&groupBy=repo
 to find the use cases, one project has a use like add_opt 
C_INCLUDE_DIRS=$C_INCLUDES, but the search patch seems likely redundant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159054

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


[PATCH] D159054: [Driver] Removal of C_INCLUDE_DIRS feature

2023-08-28 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: MaskRay, tstellar, probinson.
brad added a project: clang.
Herald added subscribers: pmatos, asb, abrachet, jgravelle-google, sbc100, 
dschuff, emaste.
Herald added a project: All.
brad requested review of this revision.
Herald added a subscriber: aheejin.

Removing the C_INCLUDE_DIRS feature.

Fix https://github.com/llvm/llvm-project/issues/61328


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159054

Files:
  clang/CMakeLists.txt
  clang/include/clang/Config/config.h.cmake
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Haiku.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/OHOS.cpp
  clang/lib/Driver/ToolChains/OpenBSD.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/lib/Lex/InitHeaderSearch.cpp

Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -13,7 +13,6 @@
 #include "clang/Basic/DiagnosticFrontend.h"
 #include "clang/Basic/FileManager.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Config/config.h" // C_INCLUDE_DIRS
 #include "clang/Lex/HeaderMap.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/HeaderSearchOptions.h"
@@ -260,16 +259,6 @@
   if (!HSOpts.UseStandardSystemIncludes)
 return;
 
-  // Add dirs specified via 'configure --with-c-include-dirs'.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs)
-  AddPath(dir, ExternCSystem, false);
-return;
-  }
-
   switch (os) {
   case llvm::Triple::CloudABI: {
 // //include
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -10,7 +10,6 @@
 #include "CommonArgs.h"
 #include "Gnu.h"
 #include "clang/Basic/Version.h"
-#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -413,19 +412,6 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Check for configure-time C include directories.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-}
-return;
-  }
-
   if (getTriple().getOS() != llvm::Triple::UnknownOS) {
 const std::string MultiarchTriple =
 getMultiarchTriple(D, getTriple(), D.SysRoot);
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -9,7 +9,6 @@
 #include "Solaris.h"
 #include "CommonArgs.h"
 #include "clang/Basic/LangStandard.h"
-#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
@@ -296,19 +295,6 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Check for configure-time C include directories.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs) {
-  StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
-  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
-}
-return;
-  }
-
   // Add include directories specific to the selected multilib set and multilib.
   if (GCCInstallation.isValid()) {
 const MultilibSet::IncludeDirsFunc &Callback =
Index: clang/lib/Driver/ToolChains/OpenBSD.cpp
===
--- clang/lib/Driver/ToolChains/OpenBSD.cpp
+++ clang/lib/Driver/ToolChains/OpenBSD.cpp
@@ -11,7 +11,6 @@
 #include "Arch/Mips.h"
 #include "Arch/Sparc.h"
 #include "CommonArgs.h"
-#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Options.h"
 #include "clang/Driver/SanitizerArgs.h"
@@ -307,19 +306,6 @@
   if (DriverArgs.hasArg(options::OPT_nostdlibinc))
 return;
 
-  // Check for configure-time C include directories.
-  StringRef CIncludeDirs(C_INCLUDE_DIRS);
-  if (CIncludeDirs != "") {
-SmallVector dirs;
-CIncludeDirs.split(dirs, ":");
-for (StringRef dir : dirs) {
-  StringRef Prefix =
-  

[clang] 6f1b2e4 - [NFC] Correct the test code in pr65018

2023-08-28 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-08-29T11:30:47+08:00
New Revision: 6f1b2e4e97e2d6e8f19a9a6d64547b027617fa39

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

LOG: [NFC] Correct the test code in pr65018

The test code in pr65018 is actually incorrect since the optimizier are
free to optimize the whole coroutine body away. This patch corrected
this.

Added: 


Modified: 
clang/test/CodeGenCoroutines/pr65018.cpp

Removed: 




diff  --git a/clang/test/CodeGenCoroutines/pr65018.cpp 
b/clang/test/CodeGenCoroutines/pr65018.cpp
index 03d123e1e7e2f7..2fdfe684b592fb 100644
--- a/clang/test/CodeGenCoroutines/pr65018.cpp
+++ b/clang/test/CodeGenCoroutines/pr65018.cpp
@@ -17,13 +17,20 @@ struct MyTask {
   // A lazy promise with an await_transform method that supports awaiting
   // integer references using the Awaiter struct above.
   struct promise_type {
-MyTask get_return_object() { return {}; }
+MyTask get_return_object() {
+  return MyTask{
+  std::coroutine_handle::from_promise(*this),
+  };
+}
+
 std::suspend_always initial_suspend() { return {}; }
 std::suspend_always final_suspend() noexcept { return {}; }
 void unhandled_exception();
 
 auto await_transform(const int& x) { return Awaiter{x}; }
   };
+
+  std::coroutine_handle<> h;
 };
 
 // A global array of integers.



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


[PATCH] D158709: [Headers][Modules] Make separate headers for the stdarg.h and stddef.h pieces so that they can be modularized

2023-08-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.

LGTM too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158709

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


[PATCH] D159042: [Driver] Add LiteOS and z/OS to ShouldAddDefaultIncludePaths()

2023-08-28 Thread Brad Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG196ff0c7ddac: [Driver] Add LiteOS and z/OS to 
ShouldAddDefaultIncludePaths() (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159042

Files:
  clang/lib/Lex/InitHeaderSearch.cpp


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -341,17 +341,19 @@
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
+  case llvm::Triple::Hurd:
+  case llvm::Triple::Linux:
+  case llvm::Triple::LiteOS:
   case llvm::Triple::NaCl:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
-  case llvm::Triple::Fuchsia:
-  case llvm::Triple::Haiku:
-  case llvm::Triple::Hurd:
-  case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::ZOS:
 return false;
 
   case llvm::Triple::Win32:


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -341,17 +341,19 @@
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
+  case llvm::Triple::Hurd:
+  case llvm::Triple::Linux:
+  case llvm::Triple::LiteOS:
   case llvm::Triple::NaCl:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
-  case llvm::Triple::Fuchsia:
-  case llvm::Triple::Haiku:
-  case llvm::Triple::Hurd:
-  case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::ZOS:
 return false;
 
   case llvm::Triple::Win32:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 196ff0c - [Driver] Add LiteOS and z/OS to ShouldAddDefaultIncludePaths()

2023-08-28 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-08-28T23:01:50-04:00
New Revision: 196ff0c7ddacf571a3fc6c9163e85fd91ecab6b3

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

LOG: [Driver] Add LiteOS and z/OS to ShouldAddDefaultIncludePaths()

LiteOS (OHOS) and z/ZOS already have header path handling in the Driver, so add
the OS's to ShouldAddDefaultIncludePaths().

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Lex/InitHeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/InitHeaderSearch.cpp 
b/clang/lib/Lex/InitHeaderSearch.cpp
index dc5554844f8482..f7a319bdc14c4a 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -341,17 +341,19 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
+  case llvm::Triple::Hurd:
+  case llvm::Triple::Linux:
+  case llvm::Triple::LiteOS:
   case llvm::Triple::NaCl:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
-  case llvm::Triple::Fuchsia:
-  case llvm::Triple::Haiku:
-  case llvm::Triple::Hurd:
-  case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::ZOS:
 return false;
 
   case llvm::Triple::Win32:



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


[PATCH] D158475: [driver] Refactor getRuntimePaths. NFC

2023-08-28 Thread Mike Hommey via Phabricator via cfe-commits
glandium added a comment.

This conflicts with D146664 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158475

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


[PATCH] D158376: [Driver] move DragonFly header search path management to the driver

2023-08-28 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 554140.
brad added a comment.

Remove C_INCLUDE_DIRS bits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158376

Files:
  clang/lib/Driver/ToolChains/DragonFly.cpp
  clang/lib/Driver/ToolChains/DragonFly.h
  clang/lib/Lex/InitHeaderSearch.cpp


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -327,9 +327,6 @@
   break;
 }
 break;
-  case llvm::Triple::DragonFly:
-AddPath("/usr/include/c++/5.0", CXXSystem, false);
-break;
   default:
 break;
   }
@@ -339,6 +336,7 @@
 const llvm::Triple &triple) {
   switch (triple.getOS()) {
   case llvm::Triple::AIX:
+  case llvm::Triple::DragonFly:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
   case llvm::Triple::NaCl:
Index: clang/lib/Driver/ToolChains/DragonFly.h
===
--- clang/lib/Driver/ToolChains/DragonFly.h
+++ clang/lib/Driver/ToolChains/DragonFly.h
@@ -55,6 +55,13 @@
 
   bool IsMathErrnoDefault() const override { return false; }
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void addLibStdCxxIncludePaths(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -12,6 +12,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -195,6 +196,33 @@
   getFilePaths().push_back("/usr/lib/gcc80");
 }
 
+void DragonFly::AddClangSystemIncludeArgs(
+const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const {
+  const Driver &D = getDriver();
+
+  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  addExternCSystemInclude(DriverArgs, CC1Args,
+  concat(D.SysRoot, "/usr/include"));
+}
+
+void DragonFly::addLibStdCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args) 
const {
+  addLibStdCXXIncludePaths(concat(getDriver().SysRoot, 
"/usr/include/c++/8.0"), "", "",
+   DriverArgs, CC1Args);
+}
+
 Tool *DragonFly::buildAssembler() const {
   return new tools::dragonfly::Assembler(*this);
 }


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -327,9 +327,6 @@
   break;
 }
 break;
-  case llvm::Triple::DragonFly:
-AddPath("/usr/include/c++/5.0", CXXSystem, false);
-break;
   default:
 break;
   }
@@ -339,6 +336,7 @@
 const llvm::Triple &triple) {
   switch (triple.getOS()) {
   case llvm::Triple::AIX:
+  case llvm::Triple::DragonFly:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
   case llvm::Triple::NaCl:
Index: clang/lib/Driver/ToolChains/DragonFly.h
===
--- clang/lib/Driver/ToolChains/DragonFly.h
+++ clang/lib/Driver/ToolChains/DragonFly.h
@@ -55,6 +55,13 @@
 
   bool IsMathErrnoDefault() const override { return false; }
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
+  void addLibStdCxxIncludePaths(
+  const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
 protected:
   Tool *buildAssembler() const override;
   Tool *buildLinker() const override;
Index: clang/lib/Driver/ToolChains/DragonFly.cpp
===
--- clang/lib/Driver/ToolChains/DragonFly.cpp
+++ clang/lib/Driver/ToolChains/DragonFly.cpp
@@ -12,6 +12,7 @@
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Path.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -195,6 +196,33 @@
   getFilePaths().push_back("/usr/lib/gcc80");
 }
 
+

[PATCH] D133361: [BPF] Attribute btf_decl_tag("ctx") for structs

2023-08-28 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

I will try to review other parts of code in the next few days.




Comment at: llvm/include/llvm/IR/Intrinsics.td:2432
   ImmArg>]>;
+def int_context_marker_bpf : DefaultAttrsIntrinsic<[llvm_ptr_ty],
+   [llvm_ptr_ty],

eddyz87 wrote:
> yonghong-song wrote:
> > Is it possible to make this builtin as BPF specific one?
> Currently `llvm::Intrinsic::context_marker_bpf` gets defined in 
> `llvm/IR/Intrinsics.h` (via include of generated file `IntrinsicEnums.inc`, 
> same as `preserve_{struct,union,array}_access_index`).
> 
> BPF specific intrinsics are defined in `llvm/IR/IntrinsicsBPF.h` (generated 
> directly w/o .inc intermediary).
> 
> Thus, if I move `context_marker_bpf` to `IntrinsicsBPF.td` I would have to 
> include `IntrinsicsBPF.h` in `CGExpr.cpp`. However, I don't see any target 
> specific includes in that file.
> 
I went through the related clang code and indeed found it is hard to get a BPF 
target defined function in CGF or CGM. On the other hand, we can consider this 
new builtin under the umbrella "Intrinsics that are used to preserve debug 
information".  Maybe we can rename the intrinsic name
to 'int_preserve_context_marker'? The goal of this builtin to preserve certain 
load/store which should be immune from optimizations. I try to generalize this 
so your function name 'wrapWithBPFContextMarker' can be renamed to
'wrapWithContextMarker'. There is no need to mention BPF any more.

In the commit message, you can mention that
similar to int_preserve_array_access_index, int_preserve_context_marker is only 
implemented in BPF backend. But other architectures can implement processing 
these intrinsics if they want to achieve some results similar to bpf backend.

WDYT? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133361

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


[PATCH] D158977: [clang][dataflow] Don't associate prvalue expressions with storage locations.

2023-08-28 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun accepted this revision.
xazax.hun added a comment.
This revision is now accepted and ready to land.

Thanks! Sometimes I am wondering whether we actually need a full map for 
PRValues. E.g., once we processed a `MaterializeTemporaryExpr`, we now have a 
location for the value, and it feels like we represent the same thing twice, 
once in `ExprToLoc + LocToVal` and once in `ExprToVal`. It is probably not too 
bad and might be extra work to clean this up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158977

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


[clang] c1b5674 - [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-28 Thread via cfe-commits

Author: Anton Rydahl
Date: 2023-08-28T19:05:55-07:00
New Revision: c1b5674fbb76c4b137a1e856441019605668f1ca

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

LOG: [OpenMP] Change OpenMP default version in documentation and help text for 
-fopenmp-version

As discussed on the weekly OpenMP meeting on the second of August 2023, the 
default version
in the OpenMP documentation shoud be changed from OpenMP 5.0 to 5.1.

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst
clang/include/clang/Driver/Options.td
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90
openmp/docs/CommandLineArgumentReference.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index be3894389a3517..641ec78a56da8e 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -26,7 +26,8 @@ PPC64[LE] and has `basic support for Cuda devices`_.
 In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools
 Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and 
macOS.
 
-For the list of supported features from OpenMP 5.0 see `OpenMP implementation 
details`_.
+For the list of supported features from OpenMP 5.0 and 5.1
+see `OpenMP implementation details`_ and `OpenMP 51 implementation details`_.
 
 General improvements
 
@@ -252,6 +253,8 @@ implementation.
 
+--+--+--+---+
 
 
+.. _OpenMP 51 implementation details:
+
 OpenMP 5.1 Implementation Details
 =
 

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index da2dc934e37cfd..c367d515cbdcdc 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3200,7 +3200,7 @@ def fno_openmp : Flag<["-"], "fno-openmp">, 
Group,
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group,
   Flags<[NoArgumentUnused]>,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). 
Default value is 50 for Clang and 11 for Flang">;
+  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 51 for OpenMP 5.1). 
Default value is 51 for Clang">;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlag
 ! CHECK-NEXT: Specify comma-separated list of triples 
OpenMP offloading targets to be supported
 ! CHECK-NEXT: -fopenmp-version=
-! CHECK-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! CHECK-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! CHECK-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! CHECK-NEXT: -foptimization-record-file=
 ! CHECK-NEXT: Specify the output name of the file 
containing the optimization remarks. Implies -fsave-optimization-record. On 
Darwin platforms, this cannot be used with multiple -arch  options.

diff  --git a/flang/test/Driver/driver-help.f90 
b/flang/test/Driver/driver-help.f90
index b1da592ca0bd8a..c82f72dff164d7 100644
--- a/flang/test/Driver/driver-help.f90
+++ b/flang/test/Driver/driver-help.f90
@@ -62,7 +62,7 @@
 ! HELP-NEXT: -fopenmp-targets=
 ! HELP-NEXT: Specify comma-separated list of triples 
OpenMP offloading targets to be supported
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! HELP-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! HELP-NEXT: -foptimization-record-file=
 ! HELP-NEXT: Specify the output name of the file 
containing the optimization remarks. Implies -fsave-optimization-record. On 
Darwin platforms, this cannot be used with multiple -arch  options.
@@ -202,7 +202,7 @@
 ! HELP-FC1-NEXT: Generate code only for an OpenMP 
target device.
 ! HELP-FC1-NEXT: -fopenmp-target-debug   Enable debugging in the OpenMP 
offloading device RTL
 ! HELP-FC1-NEXT: -fopenmp-version=
-! HELP-FC1-NEXT: Set OpenMP version (e.g. 45 for 
OpenMP 4.5, 50 for OpenMP 5.0). D

[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl added a comment.

In D153924#4623357 , @jhuber6 wrote:

> The libcxx tests are always broken randomly in my experience. I wouldn't 
> worry about it.

Thanks a bunch! I did not know that. Shall I just land the patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

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


[PATCH] D156901: [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc1b5674fbb76: [OpenMP] Change OpenMP default version in 
documentation and help text for… (authored by AntonRydahl).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156901

Files:
  clang/docs/OpenMPSupport.rst
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  openmp/docs/CommandLineArgumentReference.rst


Index: openmp/docs/CommandLineArgumentReference.rst
===
--- openmp/docs/CommandLineArgumentReference.rst
+++ openmp/docs/CommandLineArgumentReference.rst
@@ -37,8 +37,7 @@
 ^^
 Set the OpenMP version to a specific version  of the OpenMP standard. 
 For example, you may use ``-fopenmp-version=45`` to select version 4.5 of 
-the OpenMP standard. The default value is ``-fopenmp-version=50`` for 
``Clang`` 
-and ``-fopenmp-version=11`` for ``flang-new``.
+the OpenMP standard. The default value is ``-fopenmp-version=51`` for 
``Clang``.
 
 .. _offload_command_line_arguments:
 
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -62,7 +62,7 @@
 ! HELP-NEXT: -fopenmp-targets=
 ! HELP-NEXT: Specify comma-separated list of triples 
OpenMP offloading targets to be supported
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! HELP-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! HELP-NEXT: -foptimization-record-file=
 ! HELP-NEXT: Specify the output name of the file 
containing the optimization remarks. Implies -fsave-optimization-record. On 
Darwin platforms, this cannot be used with multiple -arch  options.
@@ -202,7 +202,7 @@
 ! HELP-FC1-NEXT: Generate code only for an OpenMP 
target device.
 ! HELP-FC1-NEXT: -fopenmp-target-debug   Enable debugging in the OpenMP 
offloading device RTL
 ! HELP-FC1-NEXT: -fopenmp-version=
-! HELP-FC1-NEXT: Set OpenMP version (e.g. 45 for 
OpenMP 4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-FC1-NEXT: Set OpenMP version (e.g. 45 for 
OpenMP 4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! HELP-FC1-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic 
shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -fppc-native-vector-element-order
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -74,7 +74,7 @@
 ! CHECK-NEXT: -fopenmp-targets=
 ! CHECK-NEXT: Specify comma-separated list of triples 
OpenMP offloading targets to be supported
 ! CHECK-NEXT: -fopenmp-version=
-! CHECK-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! CHECK-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! CHECK-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! CHECK-NEXT: -foptimization-record-file=
 ! CHECK-NEXT: Specify the output name of the file 
containing the optimization remarks. Implies -fsave-optimization-record. On 
Darwin platforms, this cannot be used with multiple -arch  options.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3200,7 +3200,7 @@
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group,
   Flags<[NoArgumentUnused]>,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). 
Default value is 50 for Clang and 11 for Flang">;
+  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 51 for OpenMP 5.1). 
Default value is 51 for Clang">;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlagIndex: openmp/docs/CommandLineArgumentReference.rst
=

[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

The libcxx tests are always broken randomly in my experience. I wouldn't worry 
about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

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


[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl updated this revision to Diff 554132.
AntonRydahl added a comment.

Rebased on main to see if libc++ CI is still failing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CGException.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/OpenMP/amdgpu_exceptions.cpp
  clang/test/OpenMP/amdgpu_throw.cpp
  clang/test/OpenMP/amdgpu_throw_trap.cpp
  clang/test/OpenMP/amdgpu_try_catch.cpp
  clang/test/OpenMP/nvptx_exceptions.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
  clang/test/OpenMP/nvptx_throw.cpp
  clang/test/OpenMP/nvptx_throw_trap.cpp
  clang/test/OpenMP/nvptx_try_catch.cpp
  clang/test/OpenMP/x86_target_exceptions.cpp
  clang/test/OpenMP/x86_target_throw.cpp
  clang/test/OpenMP/x86_target_try_catch.cpp

Index: clang/test/OpenMP/x86_target_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_try_catch.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		error = 1;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_throw.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_throw.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+void foo(void) {
+	throw 404;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_exceptions.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_exceptions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		throw 404;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/nvptx_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_try_catch.cpp
@@ -0,0 +1,45 @@
+/**
+ * The first four lines test that a warning is produced when enabling 
+ * -Wopenmp-target-exception no matter what combination of -fexceptions and 
+ * -fcxx-exceptions are set, as we want OpenMP to always allow exceptions in the
+ * target region but emit a warning instead.
+*/
+
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+
+/**
+ * The following four lines test that no warning is emitted when providing 
+ * -Wno-openmp-target-exception no matter the combination of -fexceptions and 
+ * -fcxx-exceptions.
+*/
+
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+
+/**
+ * Finally we should test that we only ignore exceptions in the OpenMP 
+ * offloading tool-chain
+*/
+
+// RUN: %clang_cc1 -triple nvptx64 %s -emit-llvm -S -verify=noexceptions -o -
+
+// noexceptions-error@36 {{cannot use 'try' with exceptions disabled}}
+
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try { // with-warning {{target 'nvptx64' does not support exception handling; 'catch' block is ignored}}
+		error = 1;
+	}
+	catch (

[PATCH] D137213: [clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead of SourceLocation

2023-08-28 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

Now that the behaviour change is understood, maybe it'd be useful to split the 
patch in two:

- First, this patch, plus a call to `ASTReader::getInputFile()` only for its 
side effects, to make this patch actually NFC.
- Second, committed a few days later, a patch that removes the call and adds a 
test confirming `-I` is no longer implied by `-fembed-all-input-files`.

That way, the future temporary reverts won't churn the file format. For 
example, downstreams that hit problems and need to temporarily revert can just 
revert the second patch.

(... assuming that @rsmith/others confirm that implying `-I` is undesirable... 
or, if it's desired, surely there's a more explicit way to implement it.)




Comment at: clang/lib/Serialization/ASTWriter.cpp:3013
 
-SourceLocation Loc = Diag.SourceMgr->getComposedLoc(FileIDAndFile.first, 
0);
-assert(!Loc.isInvalid() && "start loc for valid FileID is invalid");
-AddSourceLocation(Loc, Record);
+AddFileID(FileIDAndFile.first, Record);
 

This is where I'm suggesting a side-effects-only call to 
`ASTReader::getInputFile()` could be added. (Or to something that transitively 
will call it.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137213

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


[PATCH] D126586: [InstrProf] Single byte counters in coverage

2023-08-28 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao added a comment.

In D126586#4622003 , @gulfem wrote:

> Fixed the issue that causes a crash in InstCombinePHI.cpp. Phi instructions 
> need to be inserted at the beginning of basic blocks, and profile increments 
> need to be inserted after phis for conditional operators.

I can confirm that this fixes the crash reported in 
https://reviews.llvm.org/D126586#4615344. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126586

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


[PATCH] D158538: [MS-ABI] Remove comdat attribute for inheriting ctor.

2023-08-28 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 marked an inline comment as done.
jyu2 added a comment.

Thanks.  @rnk




Comment at: clang/test/CodeGenCXX/ms-inheriting-ctor.cpp:41
+
+// CHECK-LABEL: define internal noundef ptr 
@"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"(ptr noundef nonnull returned align 1 
dereferenceable(1) %this, ptr noundef nonnull align 1 dereferenceable(1) %0, 
ptr noundef nonnull align 1 dereferenceable(1) %1) unnamed_addr #2 align 2
+// CHECK-LABEL: define linkonce_odr dso_local noundef ptr 
@"??0?$c@_NUbQEAA@AEBVF@@AEBUA@@@Z"(ptr noundef nonnull returned align 1 
dereferenceable(1) %this, ptr noundef nonnull align 1 dereferenceable(1) %p1, 
ptr noundef nonnull align 1 dereferenceable(1) %d) unnamed_addr #2 comdat align 
2

rnk wrote:
> jyu2 wrote:
> > rnk wrote:
> > > To make this less fragile, can you come up with a way to use `CHECK-NOT: 
> > > comdat` since that's the key thing we're testing for here? You will need 
> > > some subsequent anchor like `entry:` or something else.
> > Thanks.  I changed.
> This isn't quite what I was trying to suggest, I was thinking something more 
> like:
> 
> ```
> // CHECK-LABEL: define internal noundef ptr 
> @"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"
> // CHECK-NOT: comdat
> // CHECK-SAME: {{\{$}}
> ```
> 
> So, it finds the class with the inheriting constructor, and then checks that 
> the word "comdat" does not appear  anywhere on that line. I haven't tested 
> the CHECK-SAME pattern, it may need some adjustment.
I see.  Thanks!!  I changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158538

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


[PATCH] D159045: [clang-tidy] Improved documentation for readability-function-size

2023-08-28 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 554124.
felix642 added a comment.

Linked issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159045

Files:
  clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst


Index: clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
@@ -12,8 +12,8 @@
 
 .. option:: LineThreshold
 
-   Flag functions exceeding this number of lines. The default is `-1` (ignore
-   the number of lines).
+   Flag functions exceeding this number of lines. This option is disabled by 
+   default.
 
 .. option:: StatementThreshold
 
@@ -23,23 +23,23 @@
 
 .. option:: BranchThreshold
 
-   Flag functions exceeding this number of control statements. The default is
-   `-1` (ignore the number of branches).
+   Flag functions exceeding this number of control statements. This option is 
+   disabled by default.
 
 .. option:: ParameterThreshold
 
-   Flag functions that exceed a specified number of parameters. The default
-   is `-1` (ignore the number of parameters).
+   Flag functions that exceed a specified number of parameters. This option 
+   is disabled by default.
 
 .. option:: NestingThreshold
 
 Flag compound statements which create next nesting level after
 `NestingThreshold`. This may differ significantly from the expected value
-for macro-heavy code. The default is `-1` (ignore the nesting level).
+for macro-heavy code. This option is disabled by default.
 
 .. option:: VariableThreshold
 
Flag functions exceeding this number of variables declared in the body.
-   The default is `-1` (ignore the number of variables).
Please note that function parameters and variables declared in lambdas,
-   GNU Statement Expressions, and nested class inline functions are not 
counted.
+   GNU Statement Expressions, and nested class inline functions are not 
+   counted. This option is disabled by default.


Index: clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
@@ -12,8 +12,8 @@
 
 .. option:: LineThreshold
 
-   Flag functions exceeding this number of lines. The default is `-1` (ignore
-   the number of lines).
+   Flag functions exceeding this number of lines. This option is disabled by 
+   default.
 
 .. option:: StatementThreshold
 
@@ -23,23 +23,23 @@
 
 .. option:: BranchThreshold
 
-   Flag functions exceeding this number of control statements. The default is
-   `-1` (ignore the number of branches).
+   Flag functions exceeding this number of control statements. This option is 
+   disabled by default.
 
 .. option:: ParameterThreshold
 
-   Flag functions that exceed a specified number of parameters. The default
-   is `-1` (ignore the number of parameters).
+   Flag functions that exceed a specified number of parameters. This option 
+   is disabled by default.
 
 .. option:: NestingThreshold
 
 Flag compound statements which create next nesting level after
 `NestingThreshold`. This may differ significantly from the expected value
-for macro-heavy code. The default is `-1` (ignore the nesting level).
+for macro-heavy code. This option is disabled by default.
 
 .. option:: VariableThreshold
 
Flag functions exceeding this number of variables declared in the body.
-   The default is `-1` (ignore the number of variables).
Please note that function parameters and variables declared in lambdas,
-   GNU Statement Expressions, and nested class inline functions are not counted.
+   GNU Statement Expressions, and nested class inline functions are not 
+   counted. This option is disabled by default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159045: [clang-tidy] Improved documentation for readability-function-size

2023-08-28 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 554122.
felix642 added a comment.

Fixed commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159045

Files:
  clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst


Index: clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
@@ -12,8 +12,8 @@
 
 .. option:: LineThreshold
 
-   Flag functions exceeding this number of lines. The default is `-1` (ignore
-   the number of lines).
+   Flag functions exceeding this number of lines. This option is disabled by 
+   default.
 
 .. option:: StatementThreshold
 
@@ -23,23 +23,23 @@
 
 .. option:: BranchThreshold
 
-   Flag functions exceeding this number of control statements. The default is
-   `-1` (ignore the number of branches).
+   Flag functions exceeding this number of control statements. This option is 
+   disabled by default.
 
 .. option:: ParameterThreshold
 
-   Flag functions that exceed a specified number of parameters. The default
-   is `-1` (ignore the number of parameters).
+   Flag functions that exceed a specified number of parameters. This option 
+   is disabled by default.
 
 .. option:: NestingThreshold
 
 Flag compound statements which create next nesting level after
 `NestingThreshold`. This may differ significantly from the expected value
-for macro-heavy code. The default is `-1` (ignore the nesting level).
+for macro-heavy code. This option is disabled by default.
 
 .. option:: VariableThreshold
 
Flag functions exceeding this number of variables declared in the body.
-   The default is `-1` (ignore the number of variables).
Please note that function parameters and variables declared in lambdas,
-   GNU Statement Expressions, and nested class inline functions are not 
counted.
+   GNU Statement Expressions, and nested class inline functions are not 
+   counted. This option is disabled by default.


Index: clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
@@ -12,8 +12,8 @@
 
 .. option:: LineThreshold
 
-   Flag functions exceeding this number of lines. The default is `-1` (ignore
-   the number of lines).
+   Flag functions exceeding this number of lines. This option is disabled by 
+   default.
 
 .. option:: StatementThreshold
 
@@ -23,23 +23,23 @@
 
 .. option:: BranchThreshold
 
-   Flag functions exceeding this number of control statements. The default is
-   `-1` (ignore the number of branches).
+   Flag functions exceeding this number of control statements. This option is 
+   disabled by default.
 
 .. option:: ParameterThreshold
 
-   Flag functions that exceed a specified number of parameters. The default
-   is `-1` (ignore the number of parameters).
+   Flag functions that exceed a specified number of parameters. This option 
+   is disabled by default.
 
 .. option:: NestingThreshold
 
 Flag compound statements which create next nesting level after
 `NestingThreshold`. This may differ significantly from the expected value
-for macro-heavy code. The default is `-1` (ignore the nesting level).
+for macro-heavy code. This option is disabled by default.
 
 .. option:: VariableThreshold
 
Flag functions exceeding this number of variables declared in the body.
-   The default is `-1` (ignore the number of variables).
Please note that function parameters and variables declared in lambdas,
-   GNU Statement Expressions, and nested class inline functions are not counted.
+   GNU Statement Expressions, and nested class inline functions are not 
+   counted. This option is disabled by default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159045: [clang-tidy] Improved documentation for readability-function-size

2023-08-28 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 created this revision.
Herald added subscribers: PiotrZSL, carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
felix642 requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

The documentation would say that that default value for most parameters is -1. 
But since the parameter used in clang-tidy is an unsigned the value would get 
implicitly converted to 4294967295.

If a user tried to use -1 to disable this check he would receive an error 
saying that
the parameter is invalid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159045

Files:
  clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst


Index: clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
@@ -12,8 +12,8 @@
 
 .. option:: LineThreshold
 
-   Flag functions exceeding this number of lines. The default is `-1` (ignore
-   the number of lines).
+   Flag functions exceeding this number of lines. This option is disabled by 
+   default.
 
 .. option:: StatementThreshold
 
@@ -23,23 +23,23 @@
 
 .. option:: BranchThreshold
 
-   Flag functions exceeding this number of control statements. The default is
-   `-1` (ignore the number of branches).
+   Flag functions exceeding this number of control statements. This option is 
+   disabled by default.
 
 .. option:: ParameterThreshold
 
-   Flag functions that exceed a specified number of parameters. The default
-   is `-1` (ignore the number of parameters).
+   Flag functions that exceed a specified number of parameters. This option 
+   is disabled by default.
 
 .. option:: NestingThreshold
 
 Flag compound statements which create next nesting level after
 `NestingThreshold`. This may differ significantly from the expected value
-for macro-heavy code. The default is `-1` (ignore the nesting level).
+for macro-heavy code. This option is disabled by default.
 
 .. option:: VariableThreshold
 
Flag functions exceeding this number of variables declared in the body.
-   The default is `-1` (ignore the number of variables).
Please note that function parameters and variables declared in lambdas,
-   GNU Statement Expressions, and nested class inline functions are not 
counted.
+   GNU Statement Expressions, and nested class inline functions are not 
+   counted. This option is disabled by default.


Index: clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
+++ clang-tools-extra/docs/clang-tidy/checks/readability/function-size.rst
@@ -12,8 +12,8 @@
 
 .. option:: LineThreshold
 
-   Flag functions exceeding this number of lines. The default is `-1` (ignore
-   the number of lines).
+   Flag functions exceeding this number of lines. This option is disabled by 
+   default.
 
 .. option:: StatementThreshold
 
@@ -23,23 +23,23 @@
 
 .. option:: BranchThreshold
 
-   Flag functions exceeding this number of control statements. The default is
-   `-1` (ignore the number of branches).
+   Flag functions exceeding this number of control statements. This option is 
+   disabled by default.
 
 .. option:: ParameterThreshold
 
-   Flag functions that exceed a specified number of parameters. The default
-   is `-1` (ignore the number of parameters).
+   Flag functions that exceed a specified number of parameters. This option 
+   is disabled by default.
 
 .. option:: NestingThreshold
 
 Flag compound statements which create next nesting level after
 `NestingThreshold`. This may differ significantly from the expected value
-for macro-heavy code. The default is `-1` (ignore the nesting level).
+for macro-heavy code. This option is disabled by default.
 
 .. option:: VariableThreshold
 
Flag functions exceeding this number of variables declared in the body.
-   The default is `-1` (ignore the number of variables).
Please note that function parameters and variables declared in lambdas,
-   GNU Statement Expressions, and nested class inline functions are not counted.
+   GNU Statement Expressions, and nested class inline functions are not 
+   counted. This option is disabled by default.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158475: [driver] Refactor getRuntimePaths. NFC

2023-08-28 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb6a1473f97d3: [driver] Refactor getRuntimePaths. NFC 
(authored by smeenai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158475

Files:
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp

Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -86,8 +86,8 @@
   List.push_back(Path);
   };
 
-  for (const auto &Path : getRuntimePaths())
-addIfExists(getLibraryPaths(), Path);
+  if (std::optional Path = getRuntimePath())
+getLibraryPaths().push_back(*Path);
   for (const auto &Path : getStdlibPaths())
 addIfExists(getFilePaths(), Path);
   for (const auto &Path : getArchSpecificLibPaths())
@@ -677,15 +677,18 @@
   return Args.MakeArgString(getCompilerRT(Args, Component, Type));
 }
 
-ToolChain::path_list ToolChain::getRuntimePaths() const {
-  path_list Paths;
-  auto addPathForTriple = [this, &Paths](const llvm::Triple &Triple) {
+std::optional ToolChain::getRuntimePath() const {
+  auto getPathForTriple =
+  [this](const llvm::Triple &Triple) -> std::optional {
 SmallString<128> P(D.ResourceDir);
 llvm::sys::path::append(P, "lib", Triple.str());
-Paths.push_back(std::string(P.str()));
+if (getVFS().exists(P))
+  return std::string(P);
+return {};
   };
 
-  addPathForTriple(getTriple());
+  if (auto Path = getPathForTriple(getTriple()))
+return *Path;
 
   // When building with per target runtime directories, various ways of naming
   // the Arm architecture may have been normalised to simply "arm".
@@ -705,7 +708,8 @@
   if (getTriple().getArch() == Triple::arm && !getTriple().isArmMClass()) {
 llvm::Triple ArmTriple = getTriple();
 ArmTriple.setArch(Triple::arm);
-addPathForTriple(ArmTriple);
+if (auto Path = getPathForTriple(ArmTriple))
+  return *Path;
   }
 
   // Android targets may include an API level at the end. We still want to fall
@@ -714,10 +718,11 @@
   getTriple().getEnvironmentName() != "android") {
 llvm::Triple TripleWithoutLevel = getTriple();
 TripleWithoutLevel.setEnvironmentName("android");
-addPathForTriple(TripleWithoutLevel);
+if (auto Path = getPathForTriple(TripleWithoutLevel))
+  return *Path;
   }
 
-  return Paths;
+  return {};
 }
 
 ToolChain::path_list ToolChain::getStdlibPaths() const {
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2163,16 +2163,8 @@
   }
 
   if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
-std::string RuntimePath;
-// Get the first existing path, if any.
-for (auto Path : TC.getRuntimePaths()) {
-  if (getVFS().exists(Path)) {
-RuntimePath = Path;
-break;
-  }
-}
-if (!RuntimePath.empty())
-  llvm::outs() << RuntimePath << '\n';
+if (std::optional RuntimePath = TC.getRuntimePath())
+  llvm::outs() << *RuntimePath << '\n';
 else
   llvm::outs() << TC.getCompilerRTPath() << '\n';
 return false;
Index: clang/include/clang/Driver/ToolChain.h
===
--- clang/include/clang/Driver/ToolChain.h
+++ clang/include/clang/Driver/ToolChain.h
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -500,8 +501,8 @@
 StringRef Component,
 FileType Type = ToolChain::FT_Static) const;
 
-  // Returns target specific runtime paths.
-  path_list getRuntimePaths() const;
+  // Returns the target specific runtime path if it exists.
+  std::optional getRuntimePath() const;
 
   // Returns target specific standard library paths.
   path_list getStdlibPaths() const;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b6a1473 - [driver] Refactor getRuntimePaths. NFC

2023-08-28 Thread Shoaib Meenai via cfe-commits

Author: Shoaib Meenai
Date: 2023-08-28T17:34:50-07:00
New Revision: b6a1473f97d38471b08331dee7ae7f6112c495c0

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

LOG: [driver] Refactor getRuntimePaths. NFC

This used to be getRuntimePath till https://reviews.llvm.org/D115049
added a fallback search path for Android. As far as I can tell, the
intent has always been to use the first existing path though instead of
actually supporting multiple runtime paths. We can move the existence
checks into getRuntimePath and have it return std::optional, which also
makes the `--print-runtime-dir` behavior much cleaner.

The motivation is a follow-up change to Android runtime path searches,
which is much nicer with this in place.

Reviewed By: phosek, MaskRay

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

Added: 


Modified: 
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/ToolChain.h 
b/clang/include/clang/Driver/ToolChain.h
index 2e74507f71267c..0b38b939a188ae 100644
--- a/clang/include/clang/Driver/ToolChain.h
+++ b/clang/include/clang/Driver/ToolChain.h
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -500,8 +501,8 @@ class ToolChain {
 StringRef Component,
 FileType Type = ToolChain::FT_Static) 
const;
 
-  // Returns target specific runtime paths.
-  path_list getRuntimePaths() const;
+  // Returns the target specific runtime path if it exists.
+  std::optional getRuntimePath() const;
 
   // Returns target specific standard library paths.
   path_list getStdlibPaths() const;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 7b64ef4cc5db6e..07c4561c990aba 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -2163,16 +2163,8 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
   }
 
   if (C.getArgs().hasArg(options::OPT_print_runtime_dir)) {
-std::string RuntimePath;
-// Get the first existing path, if any.
-for (auto Path : TC.getRuntimePaths()) {
-  if (getVFS().exists(Path)) {
-RuntimePath = Path;
-break;
-  }
-}
-if (!RuntimePath.empty())
-  llvm::outs() << RuntimePath << '\n';
+if (std::optional RuntimePath = TC.getRuntimePath())
+  llvm::outs() << *RuntimePath << '\n';
 else
   llvm::outs() << TC.getCompilerRTPath() << '\n';
 return false;

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 8dafc3d481c2e0..f40cee195fa559 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -86,8 +86,8 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
   List.push_back(Path);
   };
 
-  for (const auto &Path : getRuntimePaths())
-addIfExists(getLibraryPaths(), Path);
+  if (std::optional Path = getRuntimePath())
+getLibraryPaths().push_back(*Path);
   for (const auto &Path : getStdlibPaths())
 addIfExists(getFilePaths(), Path);
   for (const auto &Path : getArchSpecificLibPaths())
@@ -677,15 +677,18 @@ const char *ToolChain::getCompilerRTArgString(const 
llvm::opt::ArgList &Args,
   return Args.MakeArgString(getCompilerRT(Args, Component, Type));
 }
 
-ToolChain::path_list ToolChain::getRuntimePaths() const {
-  path_list Paths;
-  auto addPathForTriple = [this, &Paths](const llvm::Triple &Triple) {
+std::optional ToolChain::getRuntimePath() const {
+  auto getPathForTriple =
+  [this](const llvm::Triple &Triple) -> std::optional {
 SmallString<128> P(D.ResourceDir);
 llvm::sys::path::append(P, "lib", Triple.str());
-Paths.push_back(std::string(P.str()));
+if (getVFS().exists(P))
+  return std::string(P);
+return {};
   };
 
-  addPathForTriple(getTriple());
+  if (auto Path = getPathForTriple(getTriple()))
+return *Path;
 
   // When building with per target runtime directories, various ways of naming
   // the Arm architecture may have been normalised to simply "arm".
@@ -705,7 +708,8 @@ ToolChain::path_list ToolChain::getRuntimePaths() const {
   if (getTriple().getArch() == Triple::arm && !getTriple().isArmMClass()) {
 llvm::Triple ArmTriple = getTriple();
 ArmTriple.setArch(Triple::arm);
-addPathForTriple(ArmTriple);
+if (auto Path = getPathForTriple(ArmTriple))
+  return *Path;
   }
 
   // Android targets may include an API level at the end. We still want to fall
@@ -714,10 +718,11 @@ ToolChain::path_list ToolChain::getRuntimePaths() const {
   getTriple().getEnvironmentName() != "android") {
 llvm::Triple TripleWithoutLevel = getTriple();
 TripleWithoutLevel.setEnvironmentName("

[PATCH] D158872: [clang][ASTMatchers] Add a few type-related Matchers

2023-08-28 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

In D158872#4622124 , @aaron.ballman 
wrote:

> Are these matchers going to be used in-tree (by clang-tidy, or something 
> else)? We typically do not add new AST matches until there's a need for them 
> because the AST matchers have a pretty big impact on build times of Clang 
> itself.

They are used in `ASTImporter` testcases as shown in 
https://reviews.llvm.org/D158948. Though this might not be a strong reason to
add these matchers and bring on too much bad impact.

ASTImporter is more urgent since we still lack support for some of the AST 
nodes so I considered adding them batchly and started with
type-related nodes. I thought that matchers're OK to use in unittests as 
actually they are used a lot there, but I wasn't aware of the impact
on build of Clang.

If not acceptable, I'm OK with it. We can still test importing with other ways. 
Matchers are not mandatory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158872

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


[PATCH] D158995: [clang] Add a Windows build in the Clang pre-commit CI

2023-08-28 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 554115.
ldionne added a comment.

Poke CI -- it seemed to time out this afternoon due to Phab.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158995

Files:
  clang/utils/ci/buildkite-pipeline.yml
  clang/utils/ci/run-buildbot


Index: clang/utils/ci/run-buildbot
===
--- clang/utils/ci/run-buildbot
+++ clang/utils/ci/run-buildbot
@@ -95,6 +95,24 @@
 
 ninja -C ${BUILD_DIR} check-clang
 ;;
+build-clang-windows)
+cmake -S llvm -B ${BUILD_DIR} -G Ninja 
 \
+-D CMAKE_C_COMPILER_LAUNCHER=sccache   
 \
+-D CMAKE_CXX_COMPILER_LAUNCHER=sccache 
 \
+-D CMAKE_BUILD_TYPE=Release
 \
+-D CMAKE_INSTALL_PREFIX=install-windows
 \
+-D LLVM_ENABLE_PROJECTS="clang;compiler-rt"
 \
+-D LLVM_ENABLE_ASSERTIONS=ON   
 \
+-D LLVM_BUILD_EXAMPLES=ON  
 \
+-D COMPILER_RT_BUILD_LIBFUZZER=OFF 
 \
+-D COMPILER_RT_BUILD_ORC=OFF
+
+ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
+tar -cJvf install-windows.tar.xz install-windows/
+buildkite-agent artifact upload --debug install-windows.tar.xz
+
+ninja -C ${BUILD_DIR} check-clang
+;;
 generic-cxx03)
 buildkite-agent artifact download install.tar.xz .
 tar -xvf install.tar.xz
Index: clang/utils/ci/buildkite-pipeline.yml
===
--- clang/utils/ci/buildkite-pipeline.yml
+++ clang/utils/ci/buildkite-pipeline.yml
@@ -31,7 +31,7 @@
 
   - wait
 
-  - label: "Building and testing clang"
+  - label: "Building and testing clang (Linux)"
 commands:
   - "clang/utils/ci/run-buildbot build-clang"
 agents:
@@ -42,6 +42,18 @@
   limit: 2
 timeout_in_minutes: 120
 
+  - label: "Building and testing clang (Windows)"
+commands:
+  - "C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 
-host_arch=amd64"
+  - "bash clang/utils/ci/run-buildbot build-clang-windows"
+agents:
+  queue: "windows"
+retry:
+  automatic:
+- exit_status: -1  # Agent was lost
+  limit: 2
+timeout_in_minutes: 120
+
   - wait
 
   - label: "Running libc++ test suite in C++03"


Index: clang/utils/ci/run-buildbot
===
--- clang/utils/ci/run-buildbot
+++ clang/utils/ci/run-buildbot
@@ -95,6 +95,24 @@
 
 ninja -C ${BUILD_DIR} check-clang
 ;;
+build-clang-windows)
+cmake -S llvm -B ${BUILD_DIR} -G Ninja  \
+-D CMAKE_C_COMPILER_LAUNCHER=sccache\
+-D CMAKE_CXX_COMPILER_LAUNCHER=sccache  \
+-D CMAKE_BUILD_TYPE=Release \
+-D CMAKE_INSTALL_PREFIX=install-windows \
+-D LLVM_ENABLE_PROJECTS="clang;compiler-rt" \
+-D LLVM_ENABLE_ASSERTIONS=ON\
+-D LLVM_BUILD_EXAMPLES=ON   \
+-D COMPILER_RT_BUILD_LIBFUZZER=OFF  \
+-D COMPILER_RT_BUILD_ORC=OFF
+
+ninja -C ${BUILD_DIR} install-clang install-clang-resource-headers
+tar -cJvf install-windows.tar.xz install-windows/
+buildkite-agent artifact upload --debug install-windows.tar.xz
+
+ninja -C ${BUILD_DIR} check-clang
+;;
 generic-cxx03)
 buildkite-agent artifact download install.tar.xz .
 tar -xvf install.tar.xz
Index: clang/utils/ci/buildkite-pipeline.yml
===
--- clang/utils/ci/buildkite-pipeline.yml
+++ clang/utils/ci/buildkite-pipeline.yml
@@ -31,7 +31,7 @@
 
   - wait
 
-  - label: "Building and testing clang"
+  - label: "Building and testing clang (Linux)"
 commands:
   - "clang/utils/ci/run-buildbot build-clang"
 agents:
@@ -42,6 +42,18 @@
   limit: 2
 timeout_in_minutes: 120
 
+  - label: "Building and testing clang (Windows)"
+commands:
+  - "C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64"
+  - "bash clang/utils/ci/run-buildbot build-clang-windows"
+agents:
+  queue: "windows"
+retry:
+  automatic:
+- exit_status: -1  # Agent was lost
+  limit: 2
+timeout_in_minutes: 120
+
   - wait
 
   - label: "Running libc++ test suite in C++03"
___
cfe-commi

[PATCH] D158376: [Driver] move DragonFly header search path management to the driver

2023-08-28 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

David? Frederic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158376

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


[PATCH] D137213: [clang][modules] NFCI: Pragma diagnostic mappings: write/read FileID instead of SourceLocation

2023-08-28 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a subscriber: rsmith.
jansvoboda11 added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:6343
  "Invalid data, missing pragma diagnostic states");
-  SourceLocation Loc = ReadSourceLocation(F, Record[Idx++]);
-  auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc);
-  assert(IDAndOffset.first.isValid() && "invalid FileID for transition");
-  assert(IDAndOffset.second == 0 && "not a start location for a FileID");
+  FileID FID = ReadFileID(F, Record, Idx);
+  assert(FID.isValid() && "invalid FileID for transition");

dexonsmith wrote:
> alexfh wrote:
> > alexfh wrote:
> > > dexonsmith wrote:
> > > > alexfh wrote:
> > > > > alexfh wrote:
> > > > > > jansvoboda11 wrote:
> > > > > > > alexfh wrote:
> > > > > > > > dexonsmith wrote:
> > > > > > > > > eaeltsin wrote:
> > > > > > > > > > This doesn't work as before, likely because ReadFileID 
> > > > > > > > > > doesn't do TranslateSourceLocation.
> > > > > > > > > > 
> > > > > > > > > > Our tests fail.
> > > > > > > > > > 
> > > > > > > > > > I tried calling TranslateSourceLocation here and the tests 
> > > > > > > > > > passed:
> > > > > > > > > > ```
> > > > > > > > > >   SourceLocation Loc = 
> > > > > > > > > > Diag.SourceMgr->getComposedLoc(FID, 0);
> > > > > > > > > >   SourceLocation Loc2 = TranslateSourceLocation(F, Loc);
> > > > > > > > > >   auto IDAndOffset = SourceMgr.getDecomposedLoc(Loc2);
> > > > > > > > > > 
> > > > > > > > > >   // Note that we don't need to set up 
> > > > > > > > > > Parent/ParentOffset here, because
> > > > > > > > > >   // we won't be changing the diagnostic state within 
> > > > > > > > > > imported FileIDs
> > > > > > > > > >   // (other than perhaps appending to the main source 
> > > > > > > > > > file, which has no
> > > > > > > > > >   // parent).
> > > > > > > > > >   auto &F = 
> > > > > > > > > > Diag.DiagStatesByLoc.Files[IDAndOffset.first];
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > Sorry I don't know the codebase, so this fix is definitely 
> > > > > > > > > > ugly :) But it shows the problem.
> > > > > > > > > > 
> > > > > > > > > I don't think that's the issue, since `ReadFileID()` calls 
> > > > > > > > > `TranslateFileID`, which should seems like it should be 
> > > > > > > > > equivalent.
> > > > > > > > > 
> > > > > > > > > However, I notice that the post-increment for `Idx` got 
> > > > > > > > > dropped! Can you try replacing the line of code with the 
> > > > > > > > > following and see if that fixes your tests (without any extra 
> > > > > > > > > TranslateSourceLocation logic)?
> > > > > > > > > ```
> > > > > > > > > lang=c++
> > > > > > > > > FileID FID = ReadFileID(F, Record, Idx++);
> > > > > > > > > ```
> > > > > > > > > 
> > > > > > > > > If so, maybe you can contribute that fix with a reduced 
> > > > > > > > > testcase? I suggest adding me, @vsapsai, @Bigcheese, and 
> > > > > > > > > @jansvoboda11 as reviewers.
> > > > > > > > > 
> > > > > > > > > @alexfh, maybe you can check if this fixes your tests as well?
> > > > > > > > > 
> > > > > > > > > (If this is the issue, it's a bit surprising we don't have 
> > > > > > > > > existing tests covering this case... and embarrassing I 
> > > > > > > > > missed it when reviewing initially!)
> > > > > > > > I've noticed the dropped `Idx` post-increment as well, but I 
> > > > > > > > went a step further and looked at the `ReadFileID` 
> > > > > > > > implementation, which is actually doing a post-increment 
> > > > > > > > itself, and accepts `Idx` by reference:
> > > > > > > > ```
> > > > > > > >   FileID ReadFileID(ModuleFile &F, const RecordDataImpl &Record,
> > > > > > > > unsigned &Idx) const {
> > > > > > > > return TranslateFileID(F, FileID::get(Record[Idx++]));
> > > > > > > >   }
> > > > > > > > ```
> > > > > > > > 
> > > > > > > > Thus, it seems to be correct. But what @eaeltsin  has found is 
> > > > > > > > actually a problem for us.  I'm currently trying to make an 
> > > > > > > > isolated test case, but it's quite tricky (as header modules 
> > > > > > > > are =\). It may be the case that our build setup relies on 
> > > > > > > > something clang doesn't explicitly promises, but the fact is 
> > > > > > > > that the behavior (as observed by our build setup) has changed. 
> > > > > > > > I'll try to revert the commit for now to get us unblocked and 
> > > > > > > > provide a test case as soon as I can.
> > > > > > > Thanks for helping out @dexonsmith, we did have the week off.
> > > > > > > 
> > > > > > > @eaeltsin @alexfhDone, are you able to provide the failing test 
> > > > > > > case? I'm happy to look into it and re-land this with a fix.
> > > > > > I've spent multiple hours trying to extract an observable test 
> > > > > > case. It turned out to be too hairy of a yaq to shave: for each 
> > > > > > compilation a separate sandboxed environment is created

[PATCH] D159042: [Driver] Add LiteOS and z/OS to ShouldAddDefaultIncludePaths()

2023-08-28 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: MaskRay, kpdev42, abhina.sreeskantharajan.
brad added a project: clang.
Herald added subscribers: abrachet, phosek.
Herald added a project: All.
brad requested review of this revision.

LiteOS (OHOS) and z/ZOS already have header path handling in the Driver, so add 
the OS's to ShouldAddDefaultIncludePaths().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159042

Files:
  clang/lib/Lex/InitHeaderSearch.cpp


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -332,17 +332,19 @@
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
+  case llvm::Triple::Hurd:
+  case llvm::Triple::Linux:
+  case llvm::Triple::LiteOS:
   case llvm::Triple::NaCl:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
-  case llvm::Triple::Fuchsia:
-  case llvm::Triple::Haiku:
-  case llvm::Triple::Hurd:
-  case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::ZOS:
 return false;
 
   case llvm::Triple::Win32:


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -332,17 +332,19 @@
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::Fuchsia:
+  case llvm::Triple::Haiku:
+  case llvm::Triple::Hurd:
+  case llvm::Triple::Linux:
+  case llvm::Triple::LiteOS:
   case llvm::Triple::NaCl:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
   case llvm::Triple::PS4:
   case llvm::Triple::PS5:
-  case llvm::Triple::Fuchsia:
-  case llvm::Triple::Haiku:
-  case llvm::Triple::Hurd:
-  case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
+  case llvm::Triple::ZOS:
 return false;
 
   case llvm::Triple::Win32:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 554100.
dhoekwater edited the summary of this revision.
dhoekwater added a comment.

Remove the dependency again


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 554099.
dhoekwater edited the summary of this revision.
dhoekwater added a comment.

Add the old dependency to hopefully get the change to propagate when I remove it


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 554098.
dhoekwater edited the summary of this revision.
dhoekwater added a comment.

Remove a dependency to see if that fixes things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 554094.
dhoekwater added a comment.

Hopefully get rid of a dead dependency


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154014: [SpecialCaseList] Use Globs instead of Regex

2023-08-28 Thread Ellis Hoag via Phabricator via cfe-commits
ellis updated this revision to Diff 554089.
ellis added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154014

Files:
  clang/docs/SanitizerSpecialCaseList.rst
  clang/lib/Basic/ProfileList.cpp
  clang/lib/Basic/SanitizerSpecialCaseList.cpp
  llvm/include/llvm/Support/SpecialCaseList.h
  llvm/lib/Support/SpecialCaseList.cpp
  llvm/unittests/Support/SpecialCaseListTest.cpp

Index: llvm/unittests/Support/SpecialCaseListTest.cpp
===
--- llvm/unittests/Support/SpecialCaseListTest.cpp
+++ llvm/unittests/Support/SpecialCaseListTest.cpp
@@ -10,8 +10,11 @@
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/VirtualFileSystem.h"
+#include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
+using testing::HasSubstr;
+using testing::StartsWith;
 using namespace llvm;
 
 namespace {
@@ -19,24 +22,32 @@
 class SpecialCaseListTest : public ::testing::Test {
 protected:
   std::unique_ptr makeSpecialCaseList(StringRef List,
-   std::string &Error) {
-std::unique_ptr MB = MemoryBuffer::getMemBuffer(List);
+   std::string &Error,
+   bool UseGlobs = true) {
+auto S = List.str();
+if (UseGlobs)
+  S = (Twine("#!special-case-list-v2\n") + S).str();
+std::unique_ptr MB = MemoryBuffer::getMemBuffer(S);
 return SpecialCaseList::create(MB.get(), Error);
   }
 
-  std::unique_ptr makeSpecialCaseList(StringRef List) {
+  std::unique_ptr makeSpecialCaseList(StringRef List,
+   bool UseGlobs = true) {
 std::string Error;
-auto SCL = makeSpecialCaseList(List, Error);
+auto SCL = makeSpecialCaseList(List, Error, UseGlobs);
 assert(SCL);
 assert(Error == "");
 return SCL;
   }
 
-  std::string makeSpecialCaseListFile(StringRef Contents) {
+  std::string makeSpecialCaseListFile(StringRef Contents,
+  bool UseGlobs = true) {
 int FD;
 SmallString<64> Path;
 sys::fs::createTemporaryFile("SpecialCaseListTest", "temp", FD, Path);
 raw_fd_ostream OF(FD, true, true);
+if (UseGlobs)
+  OF << "#!special-case-list-v2\n";
 OF << Contents;
 OF.close();
 return std::string(Path.str());
@@ -59,10 +70,10 @@
   EXPECT_FALSE(SCL->inSection("", "fun", "hello"));
   EXPECT_FALSE(SCL->inSection("", "src", "hello", "category"));
 
-  EXPECT_EQ(3u, SCL->inSectionBlame("", "src", "hello"));
-  EXPECT_EQ(4u, SCL->inSectionBlame("", "src", "bye"));
-  EXPECT_EQ(5u, SCL->inSectionBlame("", "src", "hi", "category"));
-  EXPECT_EQ(6u, SCL->inSectionBlame("", "src", "", "category"));
+  EXPECT_EQ(4u, SCL->inSectionBlame("", "src", "hello"));
+  EXPECT_EQ(5u, SCL->inSectionBlame("", "src", "bye"));
+  EXPECT_EQ(6u, SCL->inSectionBlame("", "src", "hi", "category"));
+  EXPECT_EQ(7u, SCL->inSectionBlame("", "src", "", "category"));
   EXPECT_EQ(0u, SCL->inSectionBlame("", "src", "hi"));
   EXPECT_EQ(0u, SCL->inSectionBlame("", "fun", "hello"));
   EXPECT_EQ(0u, SCL->inSectionBlame("", "src", "hello", "category"));
@@ -74,31 +85,31 @@
  "\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 3:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 4:"));
 
   EXPECT_EQ(nullptr, makeSpecialCaseList("\n\n\n"
  "[not valid\n",
  Error));
-  EXPECT_TRUE(
-  ((StringRef)Error).startswith("malformed section header on line 4:"));
+  EXPECT_THAT(Error, StartsWith("malformed section header on line 5:"));
 }
 
-TEST_F(SpecialCaseListTest, SectionRegexErrorHandling) {
+TEST_F(SpecialCaseListTest, SectionGlobErrorHandling) {
   std::string Error;
   EXPECT_EQ(makeSpecialCaseList("[address", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed section header "));
+  EXPECT_THAT(Error, StartsWith("malformed section header "));
 
   EXPECT_EQ(makeSpecialCaseList("[[]", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).startswith("malformed regex for section [: "));
+  EXPECT_EQ(
+  Error,
+  "malformed section at line 2: '[': invalid glob pattern, unmatched '['");
 
   EXPECT_EQ(makeSpecialCaseList("src:=", Error), nullptr);
-  EXPECT_TRUE(((StringRef)Error).endswith("Supplied regexp was blank"));
+  EXPECT_THAT(Error, HasSubstr("Supplied glob was blank"));
 }
 
 TEST_F(SpecialCaseListTest, Section) {
   std::unique_ptr SCL = makeSpecialCaseList("src:global\n"
- "[sect1|sect

[PATCH] D158869: [clang] Fix timing of propagation of MSInheritanceAttr for template instantiation declarations.

2023-08-28 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann marked 2 inline comments as done.
tahonermann added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10110-10111
+// propagated to the new node prior to instantiation.
+if (PrevDecl && PrevDecl->hasAttr()) {
+  Specialization->addAttr(PrevDecl->getAttr());
+  Consumer.AssignInheritanceModel(Specialization);

rnk wrote:
> `hasAttr()` is O(n) in the attribute list size, so I would recommend this 
> pattern:
> ```
>   if (PrevDecl) {
> if (const auto *A = PrevDecl->getAttr()) {
>   Specialization->addAttr(A);
>   ...
> ```
Sounds good, I'll make that change.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10112
+  Specialization->addAttr(PrevDecl->getAttr());
+  Consumer.AssignInheritanceModel(Specialization);
+}

rnk wrote:
> tahonermann wrote:
> > erichkeane wrote:
> > > tahonermann wrote:
> > > > I am concerned that moving the call to 
> > > > `Consumer.AssignInheritanceModel()` to immediately after the creation 
> > > > of the node, but before it is populated might be problematic. 
> > > > Previously, this call was still made before the node was completely 
> > > > constructed (e.g., before `setTemplateSpecializationKind()` is called 
> > > > for it). It is difficult to tell if any consumers might be dependent on 
> > > > more of the definition being present. 
> > > SO I think we still need to do this off of the definition, right?  Else 
> > > if `PrevDecl` ends up being a declaration (followed later by a definition 
> > > that has the attribute), we'll end up missing it?  Typically attributes 
> > > are 'added' by later decls, so only the 'latest one' (though attributes 
> > > can't be added after definition IIRC) has 'them all'.
> > This handles the situation where a new node is created for either an 
> > explicit template instantiation declaration or definition; that matches 
> > prior behavior. The goal is to ensure each node, regardless of the reason 
> > for its creation, inherits the attribute from the previous declaration; 
> > that ensures that any explicitly declared attributes are checked for 
> > consistency (see `Sema::mergeMSInheritanceAttr()`).
> > 
> > Note that an explicit class template specialization is not allowed to 
> > follow an explicit template instantiation declaration or definition. 
> > https://godbolt.org/z/cbvaac717.
> I think it is safe to call `AssignInheritanceModel` earlier. We mostly just 
> use it to invalidate some clang AST -> LLVM IR type translation cache.
Great, thank you for confirming that.



Comment at: clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp:958
+extern template class a;
+template class a;
+}

rnk wrote:
> My expectation here is that we assign the unknown inheritance model to 
> `a`, is that right? Can you add a static_assert to that effect, or add 
> some CHECK lines for the structure,  maybe make an alloca of type `void 
> (a::*var)()`  and check for the allocated type (it should be a struct 
> with a pointer with lots of i32s)?
Yes, when a pointer to member is formed for an incomplete class, in the absence 
of a `#pragma pointers_to_members` directive, use of inheritance keywords like 
`__single_inheritance`, or use of the `/vmb` or `/vmg` options (or 
equivalents), the "full_generality" / "virtual_inheritance" model is selected. 
I did verify that manually.

I can add a `static_assert` so long as it follows the explicit template 
instantiation definition. If it is placed earlier, then code related to 
obtaining a complete type is run and that ends up avoiding the assertion 
failure. See https://godbolt.org/z/qzTTfdfY1. This might indicate there is a 
bug elsewhere; I find it surprising that the early `static_assert` has that 
effect.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158869

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


[PATCH] D158778: [CUDA] Propagate __float128 support from the host.

2023-08-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a subscriber: ABataev.
tra added a comment.

@ABataev

This patch breaks breaks two tests:

- 
github.com/llvm/llvm-project/blob/main/clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
- 
github.com/llvm/llvm-project/blob/main/clang/test/OpenMP/nvptx_unsupported_type_messages.cpp

It's not clear what exactly these tests are testing for and I can't tell 
whether I should just remove the checks related to `__float128`, or if there's 
something else that would need to be done on the OpenMP side.

AFAICT, OpenMP will pick up `double` format for `__float128` after my patch. 
This suggests that we would only have `long double` left as an unsupported type 
on GPU-supporting targets, which suggests that I should just remove the checks 
related to `__float128` from those tests.

Am I missing something? Is there anything else that may need to be done on the 
OpenMP side?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158778

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


[PATCH] D148381: [WIP][Clang] Add counted_by attribute

2023-08-28 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 554083.
void added a comment.

Move the isFlexibleArrayMemberLike fully into Decl and fix tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148381

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Misc/warning-flags.c

Index: clang/test/Misc/warning-flags.c
===
--- clang/test/Misc/warning-flags.c
+++ clang/test/Misc/warning-flags.c
@@ -18,7 +18,7 @@
 
 The list of warnings below should NEVER grow.  It should gradually shrink to 0.
 
-CHECK: Warnings without flags (65):
+CHECK: Warnings without flags (66):
 
 CHECK-NEXT:   ext_expected_semi_decl_list
 CHECK-NEXT:   ext_explicit_specialization_storage_class
@@ -41,6 +41,7 @@
 CHECK-NEXT:   warn_char_constant_too_large
 CHECK-NEXT:   warn_collection_expr_type
 CHECK-NEXT:   warn_conflicting_variadic
+CHECK-NEXT:   warn_counted_by_placeholder
 CHECK-NEXT:   warn_delete_array_type
 CHECK-NEXT:   warn_double_const_requires_fp64
 CHECK-NEXT:   warn_drv_assuming_mfloat_abi_is
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -56,6 +56,7 @@
 // CHECK-NEXT: ConsumableAutoCast (SubjectMatchRule_record)
 // CHECK-NEXT: ConsumableSetOnRead (SubjectMatchRule_record)
 // CHECK-NEXT: Convergent (SubjectMatchRule_function)
+// CHECK-NEXT: CountedBy (SubjectMatchRule_field)
 // CHECK-NEXT: DLLExport (SubjectMatchRule_function, SubjectMatchRule_variable, SubjectMatchRule_record, SubjectMatchRule_objc_interface)
 // CHECK-NEXT: DLLImport (SubjectMatchRule_function, SubjectMatchRule_variable, SubjectMatchRule_record, SubjectMatchRule_objc_interface)
 // CHECK-NEXT: Destructor (SubjectMatchRule_function)
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -8380,6 +8380,21 @@
   D->addAttr(ZeroCallUsedRegsAttr::Create(S.Context, Kind, AL));
 }
 
+static void handleCountedByAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
+  // TODO: Probably needs more processing here. See Sema::AddAlignValueAttr.
+  if (!AL.isArgIdent(0)) {
+S.Diag(AL.getLoc(), diag::err_attribute_argument_type)
+<< AL << AANT_ArgumentIdentifier;
+return;
+  }
+
+  IdentifierLoc *IL = AL.getArgAsIdent(0);
+  CountedByAttr *CBA =
+  ::new (S.Context) CountedByAttr(S.Context, AL, IL->Ident);
+  CBA->setCountedByFieldLoc(IL->Loc);
+  D->addAttr(CBA);
+}
+
 static void handleFunctionReturnThunksAttr(Sema &S, Decl *D,
const ParsedAttr &AL) {
   StringRef KindStr;
@@ -9326,6 +9341,10 @@
 handleAvailableOnlyInDefaultEvalMethod(S, D, AL);
 break;
 
+  case ParsedAttr::AT_CountedBy:
+handleCountedByAttr(S, D, AL);
+break;
+
   // Microsoft attributes:
   case ParsedAttr::AT_LayoutVersion:
 handleLayoutVersion(S, D, AL);
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -17903,6 +17903,40 @@
  "Broken injected-class-name");
 }
 
+static const FieldDecl *FindFieldWithCountedByAttr(const RecordDecl *RD) {
+  for (const Decl *D : RD->decls()) {
+if (const auto *FD = dyn_cast(D)) {
+  if (FD->hasAttr())
+return FD;
+}
+
+if (const auto *SubRD = dyn_cast(D)) {
+  return FindFieldWithCountedByAttr(SubRD);
+}
+  }
+
+  return nullptr;
+}
+
+/// CheckCountedByAttr - Return an \p IdentifierInfo if the attribute field
+/// doesn't exist in the enclosing structure. Returns \p nullptr if the
+/// attribute field does exist.
+static const IdentifierInfo *CheckCountedByAttr(const RecordDecl *RD,
+const FieldDecl *FD,
+SourceRange &Loc) {
+  const CountedByAttr *ECA = FD->getAttr();
+
+  auto It = llvm::find_if(RD->fields(), [&](const FieldDecl *Field) {
+return Field->getName() == ECA->getCountedByField()->getName();
+  });
+  if (It == RD->field_end()) {
+Loc = ECA->getCountedByFieldLoc();
+return ECA->getCountedByField();
+  }
+
+  return 

[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 554082.
dhoekwater added a comment.

Rebase onto main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,4 +1,5 @@
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata -fsplit-machine-functions %s 2>&1 | FileCheck %s --check-prefixes=CHECK,LTO-NEG
 // RUN: %clang -### --target=x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=NEG %s
 
 // CHECK:  "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5872,8 +5872,8 @@
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
 if (!A->getOption().matches(options::OPT_fno_split_machine_functions)) {
-  // This codegen pass is only available on x86-elf targets.
-  if (Triple.isX86() && Triple.isOSBinFormatELF())
+  // This codegen pass is only available on x86 and AArch64 ELF targets.
+  if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF())
 A->render(Args, CmdArgs);
   else
 D.Diag(diag::err_drv_unsupported_opt_for_target)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5852
options::OPT_fno_split_machine_functions)) {
-// This codegen pass is only available on x86-elf targets.
-if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+// This codegen pass is only available on x86 and Arm ELF targets.
+if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF()) {

MaskRay wrote:
> AArch64.
> 
> Arm can mean AArch32 (often written as "ARM").
Nice catch, fixed.



Comment at: clang/test/Driver/fsplit-machine-functions.c:4
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### -target aarch64-unknown-linux 
-fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-AARCH64 %s
 // RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s

MaskRay wrote:
> mingmingl wrote:
> > nit: would `-target aarch64` be sufficient here? if yes it's more general.
> Use `--target=` for new tests. `--target=aarch64` is sufficient and preferred 
> for generic ELF features.
Thanks for the feedback! Fixed.



Comment at: clang/test/Driver/fsplit-machine-functions.c:9
 // CHECK-NOOPT-NOT: "-fsplit-machine-functions"
+// CHECK-AARCH64:   "-fsplit-machine-functions"
 // CHECK-TRIPLE:error: unsupported option '-fsplit-machine-functions' for 
target

MaskRay wrote:
> Just reuse CHECK-OPT
Fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

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


[PATCH] D158071: [clang] Remove rdar links; NFC

2023-08-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158071

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


[PATCH] D158538: [MS-ABI] Remove comdat attribute for inheriting ctor.

2023-08-28 Thread Jennifer Yu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d0bd8e51be2: [MSABI] Remove comdat attribute for inheriting 
ctor. (authored by jyu2).

Changed prior to commit:
  https://reviews.llvm.org/D158538?vs=554025&id=554075#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158538

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/ms-inheriting-ctor.cpp


Index: clang/test/CodeGenCXX/ms-inheriting-ctor.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-inheriting-ctor.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fcxx-exceptions -triple=x86_64-windows-msvc -emit-llvm %s 
-o - | FileCheck %s
+
+class F {
+public:
+  F(wchar_t *);
+};
+using a = F;
+struct A {};
+struct b {
+  b(a, F, A);
+};
+template  struct c : b {
+  c(const a &p1, const A &d) : b(p1, 0, d) {}
+};
+template  struct B : c {
+  using c::c;
+};
+class f {
+public:
+  f(...);
+}
+
+typedef g;
+class C {
+public:
+  C(g, f);
+};
+static wchar_t h;
+class D {
+public:
+  static C E();
+};
+
+C D::E() {
+  C i(B(&h, {}), f());
+  return i;
+}
+
+// Inheriting ctor has internal linkage without comdat.
+
+// CHECK-LABEL: define internal noundef ptr @"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"
+// CHECK-NOT:comdat
+// CHECK-SAME: {{\{$}}
+
+// non-inheriting ctro should has linkonce_odr with comdat attribute.
+
+// CHECK-LABEL: define linkonce_odr dso_local noundef ptr 
@"??0?$c@_NUbQEAA@AEBVF@@AEBUA@@@Z"
+// CHECK:comdat
+// CHECK-SAME: {{\{$}}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1970,15 +1970,6 @@
   if (const auto *Dtor = dyn_cast(D))
 return getCXXABI().getCXXDestructorLinkage(Linkage, Dtor, 
GD.getDtorType());
 
-  if (isa(D) &&
-  cast(D)->isInheritingConstructor() &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-// Our approach to inheriting constructors is fundamentally different from
-// that used by the MS ABI, so keep our inheriting constructor thunks
-// internal rather than trying to pick an unambiguous mangling for them.
-return llvm::GlobalValue::InternalLinkage;
-  }
-
   return getLLVMLinkageForDeclarator(D, Linkage);
 }
 
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -11688,6 +11688,14 @@
   if (FD->isMSExternInline())
 return GVA_StrongODR;
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  isa(FD) &&
+  cast(FD)->isInheritingConstructor())
+// Our approach to inheriting constructors is fundamentally different from
+// that used by the MS ABI, so keep our inheriting constructor thunks
+// internal rather than trying to pick an unambiguous mangling for them.
+return GVA_Internal;
+
   return GVA_DiscardableODR;
 }
 


Index: clang/test/CodeGenCXX/ms-inheriting-ctor.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/ms-inheriting-ctor.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fcxx-exceptions -triple=x86_64-windows-msvc -emit-llvm %s -o - | FileCheck %s
+
+class F {
+public:
+  F(wchar_t *);
+};
+using a = F;
+struct A {};
+struct b {
+  b(a, F, A);
+};
+template  struct c : b {
+  c(const a &p1, const A &d) : b(p1, 0, d) {}
+};
+template  struct B : c {
+  using c::c;
+};
+class f {
+public:
+  f(...);
+}
+
+typedef g;
+class C {
+public:
+  C(g, f);
+};
+static wchar_t h;
+class D {
+public:
+  static C E();
+};
+
+C D::E() {
+  C i(B(&h, {}), f());
+  return i;
+}
+
+// Inheriting ctor has internal linkage without comdat.
+
+// CHECK-LABEL: define internal noundef ptr @"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"
+// CHECK-NOT:comdat
+// CHECK-SAME: {{\{$}}
+
+// non-inheriting ctro should has linkonce_odr with comdat attribute.
+
+// CHECK-LABEL: define linkonce_odr dso_local noundef ptr @"??0?$c@_NUbQEAA@AEBVF@@AEBUA@@@Z"
+// CHECK:comdat
+// CHECK-SAME: {{\{$}}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1970,15 +1970,6 @@
   if (const auto *Dtor = dyn_cast(D))
 return getCXXABI().getCXXDestructorLinkage(Linkage, Dtor, GD.getDtorType());
 
-  if (isa(D) &&
-  cast(D)->isInheritingConstructor() &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-// Our approach to inheriting constructors is fundamentally different from
-// that used by the MS ABI, so keep our inheriting constructor thunks
-// internal rather than trying to pick an unambiguous mangling fo

[clang] 1d0bd8e - [MSABI] Remove comdat attribute for inheriting ctor.

2023-08-28 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2023-08-28T15:19:23-07:00
New Revision: 1d0bd8e51be2627f79bede54735c38b917ea04ee

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

LOG: [MSABI] Remove comdat attribute for inheriting ctor.

Currently, for MS, the linkage for the inheriting constructors is set to
internal.  However, the comdat attribute is also set like:

define internal noundef ptr @"??0?$B@_N@@qeaa@AEBVF@@aebua@@@z"(ptr noundef 
nonnull returned align 1 dereferenceable(1) %this, ptr noundef nonnull align 1 
dereferenceable(1) %0, ptr noundef nonnull align 1 dereferenceable(1) %1) 
unnamed_addr comdat

This could cause linker to fail.

The change is to remove comdat attribute for the inheriting constructor
to make linker happy.

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

Added: 
clang/test/CodeGenCXX/ms-inheriting-ctor.cpp

Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/CodeGenModule.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 42cc68c9b66285..8ab499be1ed2c7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -11688,6 +11688,14 @@ static GVALinkage basicGVALinkageForFunction(const 
ASTContext &Context,
   if (FD->isMSExternInline())
 return GVA_StrongODR;
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  isa(FD) &&
+  cast(FD)->isInheritingConstructor())
+// Our approach to inheriting constructors is fundamentally 
diff erent from
+// that used by the MS ABI, so keep our inheriting constructor thunks
+// internal rather than trying to pick an unambiguous mangling for them.
+return GVA_Internal;
+
   return GVA_DiscardableODR;
 }
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 9b241165b7c579..08bc1a8d018606 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1970,15 +1970,6 @@ CodeGenModule::getFunctionLinkage(GlobalDecl GD) {
   if (const auto *Dtor = dyn_cast(D))
 return getCXXABI().getCXXDestructorLinkage(Linkage, Dtor, 
GD.getDtorType());
 
-  if (isa(D) &&
-  cast(D)->isInheritingConstructor() &&
-  Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-// Our approach to inheriting constructors is fundamentally 
diff erent from
-// that used by the MS ABI, so keep our inheriting constructor thunks
-// internal rather than trying to pick an unambiguous mangling for them.
-return llvm::GlobalValue::InternalLinkage;
-  }
-
   return getLLVMLinkageForDeclarator(D, Linkage);
 }
 

diff  --git a/clang/test/CodeGenCXX/ms-inheriting-ctor.cpp 
b/clang/test/CodeGenCXX/ms-inheriting-ctor.cpp
new file mode 100644
index 00..6c6cdcf2c358c2
--- /dev/null
+++ b/clang/test/CodeGenCXX/ms-inheriting-ctor.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -fcxx-exceptions -triple=x86_64-windows-msvc -emit-llvm %s 
-o - | FileCheck %s
+
+class F {
+public:
+  F(wchar_t *);
+};
+using a = F;
+struct A {};
+struct b {
+  b(a, F, A);
+};
+template  struct c : b {
+  c(const a &p1, const A &d) : b(p1, 0, d) {}
+};
+template  struct B : c {
+  using c::c;
+};
+class f {
+public:
+  f(...);
+}
+
+typedef g;
+class C {
+public:
+  C(g, f);
+};
+static wchar_t h;
+class D {
+public:
+  static C E();
+};
+
+C D::E() {
+  C i(B(&h, {}), f());
+  return i;
+}
+
+// Inheriting ctor has internal linkage without comdat.
+
+// CHECK-LABEL: define internal noundef ptr @"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"
+// CHECK-NOT:comdat
+// CHECK-SAME: {{\{$}}
+
+// non-inheriting ctro should has linkonce_odr with comdat attribute.
+
+// CHECK-LABEL: define linkonce_odr dso_local noundef ptr 
@"??0?$c@_NUbQEAA@AEBVF@@AEBUA@@@Z"
+// CHECK:comdat
+// CHECK-SAME: {{\{$}}



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


[PATCH] D158857: [clang][aarch64] Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr for aarch64

2023-08-28 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If you don't have autoupgrade, that means you can't link IR built with older 
versions of LLVM to IR built with newer versions.  
llvm::UpgradeDataLayoutString is designed to fix this incompatibility.  It's 
probably worth doing here given that it's relatively straightforward.

The issue with the i128 datalayout ugrade isn't the datalayout string itself, 
it's that the datalayout change affects existing code in a non-trivial way.  
That isn't really an issue here: there shouldn't be any existing AArch64 IR 
using address-space 270, so changing its meaning won't have any effect.


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

https://reviews.llvm.org/D158857

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


[PATCH] D157157: [clang] Add clang support for Machine Function Splitting on AArch64

2023-08-28 Thread Daniel Hoekwater via Phabricator via cfe-commits
dhoekwater updated this revision to Diff 554070.
dhoekwater marked 4 inline comments as done.
dhoekwater edited the summary of this revision.
dhoekwater added a comment.

Make a comment more accurate and simplify test command functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157157

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/fsplit-machine-functions.c


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,6 +1,7 @@
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | 
FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata 
-fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck 
-check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata 
-fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 
2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 
 // CHECK-OPT:   "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5849,8 +5849,8 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
-// This codegen pass is only available on x86-elf targets.
-if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+// This codegen pass is only available on x86 and AArch64 ELF targets.
+if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF()) {
   if (A->getOption().matches(options::OPT_fsplit_machine_functions))
 A->render(Args, CmdArgs);
 } else {


Index: clang/test/Driver/fsplit-machine-functions.c
===
--- clang/test/Driver/fsplit-machine-functions.c
+++ clang/test/Driver/fsplit-machine-functions.c
@@ -1,6 +1,7 @@
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: %clang -### -target x86_64 -fprofile-use=default.profdata -fsplit-machine-functions -fno-split-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-NOOPT %s
+// RUN: %clang -### --target=aarch64 -fprofile-use=default.profdata -fsplit-machine-functions %s -c 2>&1 | FileCheck -check-prefix=CHECK-OPT %s
 // RUN: not %clang -c -target arm-unknown-linux -fsplit-machine-functions %s 2>&1 | FileCheck -check-prefix=CHECK-TRIPLE %s
 
 // CHECK-OPT:   "-fsplit-machine-functions"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5849,8 +5849,8 @@
 
   if (Arg *A = Args.getLastArg(options::OPT_fsplit_machine_functions,
options::OPT_fno_split_machine_functions)) {
-// This codegen pass is only available on x86-elf targets.
-if (Triple.isX86() && Triple.isOSBinFormatELF()) {
+// This codegen pass is only available on x86 and AArch64 ELF targets.
+if ((Triple.isX86() || Triple.isAArch64()) && Triple.isOSBinFormatELF()) {
   if (A->getOption().matches(options::OPT_fsplit_machine_functions))
 A->render(Args, CmdArgs);
 } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D159024: [Parser] Parse string literal arguments of 'availability', 'external_source_symbol' and 'uuid' attributes as unevaluated

2023-08-28 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 created this revision.
barannikov88 added reviewers: cor3ntin, aaron.ballman.
Herald added a subscriber: jdoerfert.
Herald added a project: All.
barannikov88 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a complementary to D156237 .
These attributes have custom parsing logic.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159024

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/Parser/attr-availability.c
  clang/test/Parser/attr-external-source-symbol.m
  clang/test/Parser/ms-square-bracket-attributes.mm

Index: clang/test/Parser/ms-square-bracket-attributes.mm
===
--- clang/test/Parser/ms-square-bracket-attributes.mm
+++ clang/test/Parser/ms-square-bracket-attributes.mm
@@ -17,9 +17,9 @@
 )] struct struct_with_uuid_brace;
 
 // uuids must be ascii string literals.
-// expected-error@+1 {{uuid attribute contains a malformed GUID}}
+// expected-warning@+1 {{encoding prefix 'u8' on an unevaluated string literal has no effect and is incompatible with c++2c}}
 [uuid(u8"00A0---C000-0049")] struct struct_with_uuid_u8;
-// expected-error@+1 {{uuid attribute contains a malformed GUID}}
+// expected-warning@+1 {{encoding prefix 'L' on an unevaluated string literal has no effect and is incompatible with c++2c}}
 [uuid(L"00A0---C000-0049")] struct struct_with_uuid_L;
 
 // cl.exe doesn't allow raw string literals in []-style attributes, but does
Index: clang/test/Parser/attr-external-source-symbol.m
===
--- clang/test/Parser/attr-external-source-symbol.m
+++ clang/test/Parser/attr-external-source-symbol.m
@@ -95,6 +95,27 @@
 void f28(void)
 __attribute__((external_source_symbol(USR="")));
 
+void f29(void)
+__attribute__((external_source_symbol(language=L"Swift"))); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
+
+void f30(void)
+__attribute__((external_source_symbol(language="Swift", language=L"Swift"))); // expected-error {{duplicate 'language' clause in an 'external_source_symbol' attribute}} \
+  // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
+
+void f31(void)
+__attribute__((external_source_symbol(USR=u"foo"))); // expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect}}
+
+void f32(void)
+__attribute__((external_source_symbol(USR="foo", USR=u"foo"))); // expected-error {{duplicate 'USR' clause in an 'external_source_symbol' attribute}} \
+// expected-warning {{encoding prefix 'u' on an unevaluated string literal has no effect}}
+
+void f33(void)
+__attribute__((external_source_symbol(defined_in=U"module"))); // expected-warning {{encoding prefix 'U' on an unevaluated string literal has no effect}}
+
+void f34(void)
+__attribute__((external_source_symbol(defined_in="module", defined_in=U"module"))); // expected-error {{duplicate 'defined_in' clause in an 'external_source_symbol' attribute}} \
+// expected-warning {{encoding prefix 'U' on an unevaluated string literal has no effect}}
+
 #if __has_attribute(external_source_symbol) != 20230206
 # error "invalid __has_attribute version"
 #endif
Index: clang/test/Parser/attr-availability.c
===
--- clang/test/Parser/attr-availability.c
+++ clang/test/Parser/attr-availability.c
@@ -18,17 +18,17 @@
 
 void f6(void) __attribute__((availability(macosx,unavailable,introduced=10.5))); // expected-warning{{'unavailable' availability overrides all other availability information}}
 
-void f7(void) __attribute__((availability(macosx,message=L"wide"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f7(void) __attribute__((availability(macosx,message=L"wide"))); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
 
-void f8(void) __attribute__((availability(macosx,message="a" L"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f8(void) __attribute__((availability(macosx,message="a" L"b"))); // expected-warning {{encoding prefix 'L' on an unevaluated string literal has no effect}}
 
-void f9(void) __attribute__((availability(macosx,message=u8"b"))); // expected-error {{expected string literal for optional message in 'availability' attribute}}
+void f9(void) __attribute__((availability(macosx,message=u8"b"))); // expected-warning {{encoding prefix 'u8' on an unevaluated string literal has no effec

[PATCH] D158641: [AArch64][Android][DRAFT] Fix FMV ifunc resolver usage on old Android APIs.

2023-08-28 Thread Ryan Prichard via Phabricator via cfe-commits
rprichard added inline comments.



Comment at: compiler-rt/lib/builtins/cpu_model.c:1382
+return;
+#if defined(__ANDROID__)
+  // ifunc resolvers don't have hwcaps in arguments on Android API lower

enh wrote:
> srhines wrote:
> > MaskRay wrote:
> > > enh wrote:
> > > > ilinpv wrote:
> > > > > MaskRay wrote:
> > > > > > I am unfamiliar with how Android ndk builds compiler-rt.
> > > > > > 
> > > > > > If `__ANDROID_API__ >= 30`, shall we use the regular Linux code 
> > > > > > path?
> > > > > I think that leads to shipping different compile-rt libraries depend 
> > > > > on ANDROID_API. If this is an option to consider than runtime check 
> > > > > android_get_device_api_level() < 30 can be replaced by 
> > > > > `__ANDROID_API__ < 30`
> > > > depends what you mean... in 10 years or so, yes, no-one is likely to 
> > > > still care about the older API levels and we can just delete this. but 
> > > > until then, no, there's _one_ copy of compiler-rt that everyone uses, 
> > > > and although _OS developers_ don't need to support anything more than a 
> > > > couple of years old, most app developers are targeting far lower API 
> > > > levels than that (to maximize the number of possible customers).
> > > > 
> > > > TL;DR: "you could add that condition to the `#if`, but no-one would use 
> > > > it for a decade". (and i think the comment and `if` below should make 
> > > > it clear enough to future archeologists when this code block can be 
> > > > removed :-) )
> > > My thought was that people build Android with a specific 
> > > `__ANDROID_API__`, and only systems >= this level are supported.
> > > ```
> > > #If __ANDROID_API__ < 30
> > > ...
> > > #endif
> > > ```
> > > 
> > > This code has a greater chance to be removed when it becomes obsoleted. 
> > > The argument is similar to how we find obsoleted GCC workarounds.
> > Yes, the NDK currently just ships the oldest supported target API level for 
> > compiler-rt, while the Android platform build does have access to both the 
> > oldest supported target API level + the most recent target API level, so 
> > that we can make better use of features there.
> > 
> > Maybe I'm missing something, but it's feeling like the NDK users won't be 
> > able to make great use of FMV without us either bumping the minimum level 
> > or shipping multiple runtimes (and then using the #ifdefs properly here).
> > Maybe I'm missing something, but it's feeling like the NDK users won't be 
> > able to make great use of FMV without us either bumping the minimum level 
> > or shipping multiple runtimes (and then using the #ifdefs properly here).
> 
> yeah, that's the point of this code --- it's a runtime check so the NDK "just 
> works".
> 
> but if people want the `__ANDROID_API__` `#if` too, that's fine. (and, like 
> you say, the platform's two variants mean that we'll be testing both code 
> paths, so i'm not worried about "one of these is the only one that anyone's 
> actually building" problem.)
> 
> i have no opinion on whether anyone llvm is more/less likely to understand 
> if/when `if (android_get_device_api_level() < 30)` versus `#if 
> __ANDROID_API__ < 30` can be deleted.
> 
> i think the best argument for leaving this change as-is would be "anyone 
> building their own is less likely to screw up" (since developers struggle all 
> the time with the difference between "target" and "min" api, because the ndk 
> terminology is different to the AndroidManifest.xml stuff that developers are 
> more familiar with, which causes confusion). so if this was in libc++ (where 
> i know people do build their own), i'd argue for the code as-is. but since 
> it's compiler-rt (and i'm not aware that anyone's building that themselves) i 
> don't think it matters either way?
> 
> to be clear, i'm imagining:
> ```
> #if __ANDROID_API__ < 30
>   if (android_get_device_api_level() < 30) {
> setCPUFeature(FEAT_MAX);
> return;
>   }
> #endif
> ```
> (which brings us back to the "this is confusing" --- _just_ having the `#if` 
> would be subtly different, which is why if i'd written this, i'd have written 
> it as-is too!)
Unless I'm missing something, calling android_get_device_api_level doesn't 
work, because (a) the loader hasn't performed the necessary relocations and (b) 
that API reads system properties, which haven't been initialized yet.

Maybe the device API could/should be exported to a /dev file, which is how we 
exported the CPU variant to ifunc resolvers.

We could redesign Bionic so that an ifunc resolver can call 
android_get_device_api_level: e.g:
 - Relocate objects in bottom-up order.
 - Collect ifunc relocations and defer them until after non-ifunc relocations.
 - Have android_get_device_api_level in libc.so call into the loader, which has 
already initialized its copy of the system properties code.

However, with that approach, we can't call android_get_device_api_level unless 
`__ANDROID_API__` is new enough to have the loader e

[PATCH] D141714: Fix ast print of variables with attributes

2023-08-28 Thread Giuliano Belinassi via Phabricator via cfe-commits
giulianobelinassi added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141714

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


[PATCH] D156821: [CodeGen] [ubsan] Respect integer overflow handling in abs builtin

2023-08-28 Thread Brooks Moses via Phabricator via cfe-commits
brooksmoses added a comment.

Just as an FYI note, this found a bug in one of our random-number generators 
that was taking a random 32-bit integer and applying abs() to it.  Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156821

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


[PATCH] D157118: [NFC][Clang] Fix static analyzer concerns

2023-08-28 Thread Elizabeth Andrews via Phabricator via cfe-commits
eandrews updated this revision to Diff 554063.
eandrews added a comment.

Changed a dyn_cast to cast and handled ObjCAtFinallyStmt similar to how 
ObjCAtTryStmt is handled, i.e. just check that it exists before calling 
PrintRawCompoundStmt


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

https://reviews.llvm.org/D157118

Files:
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/PathDiagnostic.cpp


Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -584,6 +584,7 @@
 PathDiagnosticLocation::createBegin(const Stmt *S,
 const SourceManager &SM,
 LocationOrAnalysisDeclContext LAC) {
+  assert(S && "Statement cannot be null");
   return PathDiagnosticLocation(getValidSourceLocation(S, LAC),
 SM, SingleLocK);
 }
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -175,6 +175,7 @@
 /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
 /// with no newline after the }.
 void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
+  assert(Node && "Compound statement cannot be null");
   OS << "{" << NL;
   PrintFPPragmas(Node);
   for (auto *I : Node->body())
@@ -599,8 +600,10 @@
 
   if (auto *FS = static_cast(Node->getFinallyStmt())) {
 Indent() << "@finally";
-PrintRawCompoundStmt(dyn_cast(FS->getFinallyBody()));
-OS << NL;
+if (auto *CS = dyn_cast(FS->getFinallyBody())) {
+  PrintRawCompoundStmt(CS);
+  OS << NL;
+}
   }
 }
 
@@ -635,7 +638,7 @@
 
 void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
   Indent() << "@autoreleasepool";
-  PrintRawCompoundStmt(dyn_cast(Node->getSubStmt()));
+  PrintRawCompoundStmt(cast(Node->getSubStmt()));
   OS << NL;
 }
 


Index: clang/lib/Analysis/PathDiagnostic.cpp
===
--- clang/lib/Analysis/PathDiagnostic.cpp
+++ clang/lib/Analysis/PathDiagnostic.cpp
@@ -584,6 +584,7 @@
 PathDiagnosticLocation::createBegin(const Stmt *S,
 const SourceManager &SM,
 LocationOrAnalysisDeclContext LAC) {
+  assert(S && "Statement cannot be null");
   return PathDiagnosticLocation(getValidSourceLocation(S, LAC),
 SM, SingleLocK);
 }
Index: clang/lib/AST/StmtPrinter.cpp
===
--- clang/lib/AST/StmtPrinter.cpp
+++ clang/lib/AST/StmtPrinter.cpp
@@ -175,6 +175,7 @@
 /// PrintRawCompoundStmt - Print a compound stmt without indenting the {, and
 /// with no newline after the }.
 void StmtPrinter::PrintRawCompoundStmt(CompoundStmt *Node) {
+  assert(Node && "Compound statement cannot be null");
   OS << "{" << NL;
   PrintFPPragmas(Node);
   for (auto *I : Node->body())
@@ -599,8 +600,10 @@
 
   if (auto *FS = static_cast(Node->getFinallyStmt())) {
 Indent() << "@finally";
-PrintRawCompoundStmt(dyn_cast(FS->getFinallyBody()));
-OS << NL;
+if (auto *CS = dyn_cast(FS->getFinallyBody())) {
+  PrintRawCompoundStmt(CS);
+  OS << NL;
+}
   }
 }
 
@@ -635,7 +638,7 @@
 
 void StmtPrinter::VisitObjCAutoreleasePoolStmt(ObjCAutoreleasePoolStmt *Node) {
   Indent() << "@autoreleasepool";
-  PrintRawCompoundStmt(dyn_cast(Node->getSubStmt()));
+  PrintRawCompoundStmt(cast(Node->getSubStmt()));
   OS << NL;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158869: [clang] Fix timing of propagation of MSInheritanceAttr for template instantiation declarations.

2023-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:10110-10111
+// propagated to the new node prior to instantiation.
+if (PrevDecl && PrevDecl->hasAttr()) {
+  Specialization->addAttr(PrevDecl->getAttr());
+  Consumer.AssignInheritanceModel(Specialization);

`hasAttr()` is O(n) in the attribute list size, so I would recommend this 
pattern:
```
  if (PrevDecl) {
if (const auto *A = PrevDecl->getAttr()) {
  Specialization->addAttr(A);
  ...
```



Comment at: clang/lib/Sema/SemaTemplate.cpp:10112
+  Specialization->addAttr(PrevDecl->getAttr());
+  Consumer.AssignInheritanceModel(Specialization);
+}

tahonermann wrote:
> erichkeane wrote:
> > tahonermann wrote:
> > > I am concerned that moving the call to 
> > > `Consumer.AssignInheritanceModel()` to immediately after the creation of 
> > > the node, but before it is populated might be problematic. Previously, 
> > > this call was still made before the node was completely constructed 
> > > (e.g., before `setTemplateSpecializationKind()` is called for it). It is 
> > > difficult to tell if any consumers might be dependent on more of the 
> > > definition being present. 
> > SO I think we still need to do this off of the definition, right?  Else if 
> > `PrevDecl` ends up being a declaration (followed later by a definition that 
> > has the attribute), we'll end up missing it?  Typically attributes are 
> > 'added' by later decls, so only the 'latest one' (though attributes can't 
> > be added after definition IIRC) has 'them all'.
> This handles the situation where a new node is created for either an explicit 
> template instantiation declaration or definition; that matches prior 
> behavior. The goal is to ensure each node, regardless of the reason for its 
> creation, inherits the attribute from the previous declaration; that ensures 
> that any explicitly declared attributes are checked for consistency (see 
> `Sema::mergeMSInheritanceAttr()`).
> 
> Note that an explicit class template specialization is not allowed to follow 
> an explicit template instantiation declaration or definition. 
> https://godbolt.org/z/cbvaac717.
I think it is safe to call `AssignInheritanceModel` earlier. We mostly just use 
it to invalidate some clang AST -> LLVM IR type translation cache.



Comment at: clang/test/CodeGenCXX/microsoft-abi-member-pointers.cpp:958
+extern template class a;
+template class a;
+}

My expectation here is that we assign the unknown inheritance model to 
`a`, is that right? Can you add a static_assert to that effect, or add 
some CHECK lines for the structure,  maybe make an alloca of type `void 
(a::*var)()`  and check for the allocated type (it should be a struct with 
a pointer with lots of i32s)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158869

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


[PATCH] D158929: [clang-tidy] Add exit code support to clang-tidy-diff.py

2023-08-28 Thread Flash Sheridan via Phabricator via cfe-commits
FlashSheridan added a comment.

Thank you kindly, this is looking very good on our recent changes in my manual 
usage.  (It will take some more work before I can run it in our GitHub Action, 
which I’m looking forward to.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158929

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


[PATCH] D152054: [OpenMP] Codegen support for thread_limit on target directive

2023-08-28 Thread Vadim Paretsky via Phabricator via cfe-commits
vadikp-intel added a comment.

Windows importing is now done by name, and new exports do not need to have an 
ordinal specified for them i.e. you can add a line with just the API name to 
dllexports.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152054

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


[PATCH] D158857: [clang][aarch64] Add support for the MS qualifiers __ptr32, __ptr64, __sptr, __uptr for aarch64

2023-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: efriedma.
rnk added a comment.

+@efriedma, since I think we had that ongoing thread about what to do with i128 
alignment in data layout. Is this a reasonable way to handle the datalayout 
migration?


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

https://reviews.llvm.org/D158857

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


[PATCH] D158933: [clang] Implement -funsigned-bitfields

2023-08-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added reviewers: aaron.ballman, clang-language-wg.
shafik added a comment.

Adding more reviewers for visibility.


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

https://reviews.llvm.org/D158933

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


[PATCH] D159018: [clang][modules] Add a c23 module feature

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana added a comment.

Would we want to back port this to llvm 17?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159018

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


[PATCH] D157963: [clang-format] Annotate constructor/destructor names

2023-08-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 554051.
owenpan added a comment.

Fixed the crash and added a test case in `TokenAnnotatorTest.cpp`.


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

https://reviews.llvm.org/D157963

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1589,6 +1589,59 @@
   Tokens = annotate("void f [[noreturn]] () {}");
   ASSERT_EQ(Tokens.size(), 12u) << Tokens;
   EXPECT_TOKEN(Tokens[1], tok::identifier, TT_FunctionDeclarationName);
+
+  Tokens = annotate("class Foo { public: Foo(); };");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_FunctionDeclarationName);
+
+  Tokens = annotate("class Foo { public: ~Foo(); };");
+  ASSERT_EQ(Tokens.size(), 13u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::identifier, TT_FunctionDeclarationName);
+
+  Tokens = annotate("struct Foo { [[deprecated]] Foo() {} };");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[8], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[11], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("struct Foo { [[deprecated]] ~Foo() {} };");
+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[12], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("struct Foo { Foo() [[deprecated]] {} };");
+  ASSERT_EQ(Tokens.size(), 16u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[11], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("struct Foo { ~Foo() [[deprecated]] {} };");
+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[12], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("struct Foo { [[deprecated]] explicit Foo() {} };");
+  ASSERT_EQ(Tokens.size(), 17u) << Tokens;
+  EXPECT_TOKEN(Tokens[9], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[12], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("struct Foo { virtual [[deprecated]] ~Foo() {} };");
+  ASSERT_EQ(Tokens.size(), 18u) << Tokens;
+  EXPECT_TOKEN(Tokens[10], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("Foo::Foo() {}");
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[2], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("Foo::~Foo() {}");
+  ASSERT_EQ(Tokens.size(), 9u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_FunctionDeclarationName);
+  EXPECT_TOKEN(Tokens[6], tok::l_brace, TT_FunctionLBrace);
+
+  Tokens = annotate("#define FOO Foo::\n"
+"FOO Foo();");
+  ASSERT_EQ(Tokens.size(), 11u) << Tokens;
+  EXPECT_TOKEN(Tokens[6], tok::identifier, TT_FunctionDeclarationName);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsC11GenericSelection) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -16541,7 +16541,7 @@
 
   verifyFormat("int f();", SpaceFuncDef);
   verifyFormat("void f (int a, T b) {}", SpaceFuncDef);
-  verifyFormat("A::A() : a(1) {}", SpaceFuncDef);
+  verifyFormat("A::A () : a(1) {}", SpaceFuncDef);
   verifyFormat("void f() __attribute__((asdf));", SpaceFuncDef);
   verifyFormat("#define A(x) x", SpaceFuncDef);
   verifyFormat("#define A (x) x", SpaceFuncDef);
@@ -16566,7 +16566,7 @@
   // verifyFormat("T A::operator() () {}", SpaceFuncDef);
   verifyFormat("auto lambda = [] () { return 0; };", SpaceFuncDef);
   verifyFormat("int x = int(y);", SpaceFuncDef);
-  verifyFormat("M(std::size_t R, std::size_t C) : C(C), data(R) {}",
+  verifyFormat("M (std::size_t R, std::size_t C) : C(C), data(R) {}",
SpaceFuncDef);
 
   FormatStyle SpaceIfMacros = getLLVMStyle();
@@ -26239,18 +26239,18 @@
   FormatStyle Style = getLLVMStyle();
   EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Never);
 
-  const StringRef Code("[[nodiscard]] inline int f(int &i);\n"
-   "[[foo([[]])]] [[nodiscard]]\n"
-   "int g(int &i);\n"
-   "[[nodiscard]]\n"
-   "inline int f(int &i) {\n"
-   "  i = 1;\n"
-   "  return 0;\n"
-   "}\n"
-   "[[foo([[]])]] [[nodiscard]] int g(int &i) {\n"
-   "  i = 0;\n"
-   "  return 1;\n"
-   

[PATCH] D158223: [clang] Add clang::unnamed_addr attribute that marks globals' address as not significant

2023-08-28 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:1416-1417
+not significant. This allows global constants with the same contents to be
+merged. This can break global pointer identity, i.e. two different globals have
+the same address.
+

rnk wrote:
> aaron.ballman wrote:
> > aeubanks wrote:
> > > rnk wrote:
> > > > erichkeane wrote:
> > > > > aeubanks wrote:
> > > > > > erichkeane wrote:
> > > > > > > aeubanks wrote:
> > > > > > > > aaron.ballman wrote:
> > > > > > > > > aeubanks wrote:
> > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > aeubanks wrote:
> > > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > > What happens for tentative definitions where the 
> > > > > > > > > > > > > value isn't known? e.g.,
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > [[clang::unnamed_addr]] int i1, i2;
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > 
> > > > > > > > > > > > > What happens if the types are similar but not the 
> > > > > > > > > > > > > same?
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > [[clang::unnamed_addr]] signed int i1 = 32;
> > > > > > > > > > > > > [[clang::unnamed_addr]] unsigned int i2 = 32;
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Should we diagnose taking the address of such an 
> > > > > > > > > > > > > attributed variable so users have some hope of 
> > > > > > > > > > > > > spotting the non-conforming situations?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > Does this attribute have impacts across translation 
> > > > > > > > > > > > > unit boundaries (perhaps only when doing LTO) or only 
> > > > > > > > > > > > > within a single TU?
> > > > > > > > > > > > > 
> > > > > > > > > > > > > What does this attribute do in C++ in the presence of 
> > > > > > > > > > > > > constructors and destructors? e.g.,
> > > > > > > > > > > > > ```
> > > > > > > > > > > > > struct S {
> > > > > > > > > > > > >   S();
> > > > > > > > > > > > >   ~S();
> > > > > > > > > > > > > };
> > > > > > > > > > > > > 
> > > > > > > > > > > > > [[clang::unnamed_addr]] S s1, s2; // Are these merged 
> > > > > > > > > > > > > and there's only one ctor/dtor call?
> > > > > > > > > > > > > ```
> > > > > > > > > > > > globals are only mergeable if they're known to be 
> > > > > > > > > > > > constant and have the same value/size. this can be done 
> > > > > > > > > > > > at compile time only if the optimizer can see the 
> > > > > > > > > > > > constant values, or at link time
> > > > > > > > > > > > 
> > > > > > > > > > > > so nothing would happen in any of the cases you've 
> > > > > > > > > > > > given.
> > > > > > > > > > > > 
> > > > > > > > > > > > but yeah that does imply that we should warn when the 
> > > > > > > > > > > > attribute is used on non const, non-POD globals. I'll 
> > > > > > > > > > > > update this patch to do that
> > > > > > > > > > > > 
> > > > > > > > > > > > as mentioned in the description, we actually do want to 
> > > > > > > > > > > > take the address of these globals for table-driven 
> > > > > > > > > > > > parsing, but we don't care about identity equality
> > > > > > > > > > > > globals are only mergeable if they're known to be 
> > > > > > > > > > > > constant and have the same value/size. this can be done 
> > > > > > > > > > > > at compile time only if the optimizer can see the 
> > > > > > > > > > > > constant values, or at link time
> > > > > > > > > > > >
> > > > > > > > > > > > so nothing would happen in any of the cases you've 
> > > > > > > > > > > > given.
> > > > > > > > > > > 
> > > > > > > > > > > A that's good to know. So I assume we *will* merge 
> > > > > > > > > > > these?
> > > > > > > > > > > 
> > > > > > > > > > > ```
> > > > > > > > > > > struct S {
> > > > > > > > > > >   int i, j;
> > > > > > > > > > >   float f;
> > > > > > > > > > > };
> > > > > > > > > > > 
> > > > > > > > > > > [[clang::unnamed_addr]] const S s1 = { 1, 2, 3.0f };
> > > > > > > > > > > [[clang::unnamed_addr]] const S s2 = { 1, 2, 3.0f };
> > > > > > > > > > > [[clang::unnamed_addr]] const S s3 = s2;
> > > > > > > > > > > ```
> > > > > > > > > > > 
> > > > > > > > > > > > but yeah that does imply that we should warn when the 
> > > > > > > > > > > > attribute is used on non const, non-POD globals. I'll 
> > > > > > > > > > > > update this patch to do that
> > > > > > > > > > > 
> > > > > > > > > > > Thank you, I think that will be more user-friendly
> > > > > > > > > > > 
> > > > > > > > > > > > as mentioned in the description, we actually do want to 
> > > > > > > > > > > > take the address of these globals for table-driven 
> > > > > > > > > > > > parsing, but we don't care about identity equality
> > > > > > > > > > > 
> > > > > > > > > > > Yeah, I still wonder if we want to diagnose just the same 
> > > > > > > > > > > -- if the address is never taken, there's not really a 
> > > > > > > > > > > way to notice the optimization,

[PATCH] D159018: [clang][modules] Add a c23 module feature

2023-08-28 Thread Ian Anderson via Phabricator via cfe-commits
iana created this revision.
iana added reviewers: ChuanqiXu, Bigcheese, v.g.vassilev, aaron.ballman.
Herald added a subscriber: ributzka.
Herald added a project: All.
iana requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add a c23 module feature for `requires`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159018

Files:
  clang/docs/Modules.rst
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Module.cpp
  clang/test/Modules/Inputs/DependsOnModule.framework/module.map
  clang/test/Modules/requires.m


Index: clang/test/Modules/requires.m
===
--- clang/test/Modules/requires.m
+++ clang/test/Modules/requires.m
@@ -36,3 +36,6 @@
 // expected-error@DependsOnModule.framework/module.map:64 {{module 
'DependsOnModule.C17' requires feature 'c17'}}
 @import DependsOnModule.C17; // expected-note {{module imported here}}
 #endif
+// expected-error@DependsOnModule.framework/module.map:67 {{module 
'DependsOnModule.C23' requires feature 'c23'}}
+@import DependsOnModule.C23; // expected-note {{module imported here}}
+#endif
Index: clang/test/Modules/Inputs/DependsOnModule.framework/module.map
===
--- clang/test/Modules/Inputs/DependsOnModule.framework/module.map
+++ clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -64,4 +64,7 @@
   explicit module C17 {
 requires c17
   }
+  explicit module C23 {
+requires c23
+  }
 }
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -113,6 +113,7 @@
 .Case("c99", LangOpts.C99)
 .Case("c11", LangOpts.C11)
 .Case("c17", LangOpts.C17)
+.Case("c23", LangOpts.C23)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -107,6 +107,7 @@
   and the ``__STDC_VERSION__`` macro now expands to ``202311L`` instead of its
   previous placeholder value. Clang continues to accept ``-std=c2x`` and
   ``-std=gnu2x`` as aliases for C23 and GNU C23, respectively.
+- Clang now supports `requires c23` for module maps.
 
 Non-comprehensive list of changes in this release
 -
Index: clang/docs/Modules.rst
===
--- clang/docs/Modules.rst
+++ clang/docs/Modules.rst
@@ -588,6 +588,9 @@
 c17
   C17 support is available.
 
+c23
+  C23 support is available.
+
 freestanding
   A freestanding environment is available.
 


Index: clang/test/Modules/requires.m
===
--- clang/test/Modules/requires.m
+++ clang/test/Modules/requires.m
@@ -36,3 +36,6 @@
 // expected-error@DependsOnModule.framework/module.map:64 {{module 'DependsOnModule.C17' requires feature 'c17'}}
 @import DependsOnModule.C17; // expected-note {{module imported here}}
 #endif
+// expected-error@DependsOnModule.framework/module.map:67 {{module 'DependsOnModule.C23' requires feature 'c23'}}
+@import DependsOnModule.C23; // expected-note {{module imported here}}
+#endif
Index: clang/test/Modules/Inputs/DependsOnModule.framework/module.map
===
--- clang/test/Modules/Inputs/DependsOnModule.framework/module.map
+++ clang/test/Modules/Inputs/DependsOnModule.framework/module.map
@@ -64,4 +64,7 @@
   explicit module C17 {
 requires c17
   }
+  explicit module C23 {
+requires c23
+  }
 }
Index: clang/lib/Basic/Module.cpp
===
--- clang/lib/Basic/Module.cpp
+++ clang/lib/Basic/Module.cpp
@@ -113,6 +113,7 @@
 .Case("c99", LangOpts.C99)
 .Case("c11", LangOpts.C11)
 .Case("c17", LangOpts.C17)
+.Case("c23", LangOpts.C23)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC)
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -107,6 +107,7 @@
   and the ``__STDC_VERSION__`` macro now expands to ``202311L`` instead of its
   previous placeholder value. Clang continues to accept ``-std=c2x`` and
   ``-std=gnu2x`` as aliases for C23 and GNU C23, respectively.
+- Clang now supports `requires c23` f

[PATCH] D157963: [clang-format] Annotate constructor/destructor names

2023-08-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:3135
+  if (!Tok)
+break;
+}

When simplifying the function, I forgot that we are in the inner loop here and 
thus `break` won't exit the outer loop.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157963

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


[PATCH] D139730: [OpenMP][DeviceRTL][AMDGPU] Support code object version 5

2023-08-28 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.

LGTM. Thanks




Comment at: clang/test/CodeGenCUDA/amdgpu-code-object-version-linking.cu:12
+// RUN: llvm-link %t_0 %t_5 -o -| llvm-dis -o - | FileCheck 
-check-prefix=LINKED5 %s
+
+#include "Inputs/cuda.h"

saiislam wrote:
> yaxunl wrote:
> > need to test using clang -cc1 with -O3 and -mlink-builtin-bitcode to link 
> > the device lib and verify the load of llvm.amdgcn.abi.version being 
> > eliminated after optimization.
> > 
> > I think currently it cannot do that since llvm.amdgcn.abi.version is not 
> > internalized by the internalization pass. This can cause some significant 
> > perf drops since loading is expensive. Need to tweak the function 
> > controlling what variables can be internalized for amdgpu so that this 
> > variable gets internalized, or having a generic way to tell that function 
> > which variables should be internalized, e.g. by adding a metadata 
> > amdgcn.internalize
> load of llvm.amdgcn.abi.version is being eliminated with cc1, -O3, and 
> mlink-builtin-bitcode of device lib.
It seems being eliminated by IPSCCP. It makes sense since it is constant 
weak_odr without externally_initialized. Either changing it to weak or adding 
externally_initialized will keep the load. Normal `__constant__` var in device 
code may be changed by host code, therefore they are emitted with 
externally_initialized and do not have the load eliminated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139730

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


[PATCH] D156901: [OpenMP] Change OpenMP default version in documentation and help text for -fopenmp-version

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl updated this revision to Diff 554049.
AntonRydahl added a comment.

Rebased on main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156901

Files:
  clang/docs/OpenMPSupport.rst
  clang/include/clang/Driver/Options.td
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  openmp/docs/CommandLineArgumentReference.rst


Index: openmp/docs/CommandLineArgumentReference.rst
===
--- openmp/docs/CommandLineArgumentReference.rst
+++ openmp/docs/CommandLineArgumentReference.rst
@@ -37,8 +37,7 @@
 ^^
 Set the OpenMP version to a specific version  of the OpenMP standard. 
 For example, you may use ``-fopenmp-version=45`` to select version 4.5 of 
-the OpenMP standard. The default value is ``-fopenmp-version=50`` for 
``Clang`` 
-and ``-fopenmp-version=11`` for ``flang-new``.
+the OpenMP standard. The default value is ``-fopenmp-version=51`` for 
``Clang``.
 
 .. _offload_command_line_arguments:
 
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -62,7 +62,7 @@
 ! HELP-NEXT: -fopenmp-targets=
 ! HELP-NEXT: Specify comma-separated list of triples 
OpenMP offloading targets to be supported
 ! HELP-NEXT: -fopenmp-version=
-! HELP-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! HELP-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! HELP-NEXT: -foptimization-record-file=
 ! HELP-NEXT: Specify the output name of the file 
containing the optimization remarks. Implies -fsave-optimization-record. On 
Darwin platforms, this cannot be used with multiple -arch  options.
@@ -202,7 +202,7 @@
 ! HELP-FC1-NEXT: Generate code only for an OpenMP 
target device.
 ! HELP-FC1-NEXT: -fopenmp-target-debug   Enable debugging in the OpenMP 
offloading device RTL
 ! HELP-FC1-NEXT: -fopenmp-version=
-! HELP-FC1-NEXT: Set OpenMP version (e.g. 45 for 
OpenMP 4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! HELP-FC1-NEXT: Set OpenMP version (e.g. 45 for 
OpenMP 4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! HELP-FC1-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! HELP-FC1-NEXT: -fpass-plugin= Load pass plugin from a dynamic 
shared object file (only with new pass manager).
 ! HELP-FC1-NEXT: -fppc-native-vector-element-order
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -74,7 +74,7 @@
 ! CHECK-NEXT: -fopenmp-targets=
 ! CHECK-NEXT: Specify comma-separated list of triples 
OpenMP offloading targets to be supported
 ! CHECK-NEXT: -fopenmp-version=
-! CHECK-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 50 for OpenMP 5.0). Default value is 50 for Clang and 11 for Flang
+! CHECK-NEXT: Set OpenMP version (e.g. 45 for OpenMP 
4.5, 51 for OpenMP 5.1). Default value is 51 for Clang
 ! CHECK-NEXT: -fopenmpParse OpenMP pragmas and generate 
parallel code.
 ! CHECK-NEXT: -foptimization-record-file=
 ! CHECK-NEXT: Specify the output name of the file 
containing the optimization remarks. Implies -fsave-optimization-record. On 
Darwin platforms, this cannot be used with multiple -arch  options.
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -3200,7 +3200,7 @@
 def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group,
   Flags<[NoArgumentUnused]>,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 50 for OpenMP 5.0). 
Default value is 50 for Clang and 11 for Flang">;
+  HelpText<"Set OpenMP version (e.g. 45 for OpenMP 4.5, 51 for OpenMP 5.1). 
Default value is 51 for Clang">;
 defm openmp_extensions: BoolFOption<"openmp-extensions",
   LangOpts<"OpenMPExtensions">, DefaultTrue,
   PosFlagIndex: openmp/docs/CommandLineArgumentReference.rst
===
--- openmp/docs/CommandLineArgumentReference.rst
+++ openmp/docs/CommandLineArgumentReference.rst
@@ -37,8 +37,7 @@
 ^^
 Set the OpenMP vers

[PATCH] D157913: [WIP][Coverage] Allow Clang coverage to be used with debug info correlation.

2023-08-28 Thread Zequan Wu via Phabricator via cfe-commits
zequanwu updated this revision to Diff 554048.
zequanwu added a comment.

__llvm_prf_names section in the binary could be non-zero because 
non-instrumented function names are store there to indicate execution of 0.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157913

Files:
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/test/CodeGen/coverage-debug-info-correlate.c
  compiler-rt/lib/profile/InstrProfilingWriter.c
  compiler-rt/test/profile/Darwin/coverage-debug-info-correlate.cpp
  compiler-rt/test/profile/Linux/coverage-debug-info-correlate.cpp
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/InstrProfReader.cpp

Index: llvm/lib/ProfileData/InstrProfReader.cpp
===
--- llvm/lib/ProfileData/InstrProfReader.cpp
+++ llvm/lib/ProfileData/InstrProfReader.cpp
@@ -574,8 +574,8 @@
   if (Correlator) {
 // These sizes in the raw file are zero because we constructed them in the
 // Correlator.
-assert(DataSize == 0 && NamesSize == 0);
-assert(CountersDelta == 0 && NamesDelta == 0);
+assert(DataSize == 0 && (!isIRLevelProfile() || NamesSize == 0));
+assert(CountersDelta == 0 && (!isIRLevelProfile() || NamesDelta == 0));
 Data = Correlator->getDataPointer();
 DataEnd = Data + Correlator->getDataSize();
 NamesStart = Correlator->getNamesPointer();
Index: llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
@@ -25,6 +25,7 @@
 #include "llvm/Object/MachOUniversal.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/ProfileData/InstrProf.h"
+#include "llvm/ProfileData/InstrProfReader.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Compression.h"
 #include "llvm/Support/Debug.h"
@@ -981,7 +982,8 @@
 }
 
 static Expected>
-loadBinaryFormat(std::unique_ptr Bin, StringRef Arch,
+loadBinaryFormat(std::unique_ptr Bin,
+ IndexedInstrProfReader &ProfileReader, StringRef Arch,
  StringRef CompilationDir = "",
  object::BuildIDRef *BinaryID = nullptr) {
   std::unique_ptr OF;
@@ -1010,11 +1012,21 @@
 
   // Look for the sections that we are interested in.
   auto ObjFormat = OF->getTripleObjectFormat();
+  InstrProfSymtab ProfileNames = ProfileReader.getSymtab();
   auto NamesSection =
   lookupSections(*OF, getInstrProfSectionName(IPSK_name, ObjFormat,
  /*AddSegmentInfo=*/false));
-  if (auto E = NamesSection.takeError())
-return std::move(E);
+  if (auto E = NamesSection.takeError()) {
+if (ProfileNames.isEmpty())
+  return std::move(E);
+consumeError(std::move(E));
+  } else {
+std::vector NamesSectionRefs = *NamesSection;
+if (NamesSectionRefs.size() != 1)
+  return make_error(coveragemap_error::malformed);
+if (Error E = ProfileNames.create(NamesSectionRefs.back()))
+  return std::move(E);
+  }
   auto CoverageSection =
   lookupSections(*OF, getInstrProfSectionName(IPSK_covmap, ObjFormat,
   /*AddSegmentInfo=*/false));
@@ -1028,13 +1040,6 @@
 return CoverageMappingOrErr.takeError();
   StringRef CoverageMapping = CoverageMappingOrErr.get();
 
-  InstrProfSymtab ProfileNames;
-  std::vector NamesSectionRefs = *NamesSection;
-  if (NamesSectionRefs.size() != 1)
-return make_error(coveragemap_error::malformed);
-  if (Error E = ProfileNames.create(NamesSectionRefs.back()))
-return std::move(E);
-
   // Look for the coverage records section (Version4 only).
   auto CoverageRecordsSections =
   lookupSections(*OF, getInstrProfSectionName(IPSK_covfun, ObjFormat,
@@ -1104,7 +1109,8 @@
 
 Expected>>
 BinaryCoverageReader::create(
-MemoryBufferRef ObjectBuffer, StringRef Arch,
+MemoryBufferRef ObjectBuffer, IndexedInstrProfReader &ProfileReader,
+StringRef Arch,
 SmallVectorImpl> &ObjectFileBuffers,
 StringRef CompilationDir, SmallVectorImpl *BinaryIDs) {
   std::vector> Readers;
@@ -1150,8 +1156,8 @@
   }
 
   return BinaryCoverageReader::create(
-  ArchiveOrErr.get()->getMemoryBufferRef(), Arch, ObjectFileBuffers,
-  CompilationDir, BinaryIDs);
+  ArchiveOrErr.get()->getMemoryBufferRef(), ProfileReader, Arch,
+  ObjectFileBuffers, CompilationDir, BinaryIDs);
 }
   }
 
@@ -1164,8 +1170,8 @@
 return ChildBufOrErr.takeError();
 
   auto ChildReadersOrErr = BinaryCoverageReader::create(
-  ChildBufOrErr.get(), Arch, ObjectFileBuffers, CompilationDir,
-  BinaryIDs

[PATCH] D159016: [clang] Fix assertion failure using -MJ with -fsyntax-only

2023-08-28 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added a reviewer: MaskRay.
Herald added a project: All.
benlangmuir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If there is no output filename we should not assert when writing output for -MJ.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D159016

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/compilation_database_fsyntax_only.c


Index: clang/test/Driver/compilation_database_fsyntax_only.c
===
--- /dev/null
+++ clang/test/Driver/compilation_database_fsyntax_only.c
@@ -0,0 +1,16 @@
+// RUN: mkdir -p %t.workdir && cd %t.workdir
+// RUN: %clang -fsyntax-only %s -MJ - 2>&1 | FileCheck %s
+
+// CHECK:  {
+// CHECK-SAME: "directory": "{{[^"]*}}workdir",
+// CHECK-SAME: "file": "{{[^"]*}}compilation_database_fsyntax_only.c"
+// CHECK-NOT:  "output"
+// CHECK-SAME: "arguments": [
+// CHECK-NOT:"-o"
+// CHECK-SAME: ]
+// CHECK-SAME: }
+
+
+int main(void) {
+  return 0;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2426,7 +2426,8 @@
 CWD = ".";
   CDB << "{ \"directory\": \"" << escape(*CWD) << "\"";
   CDB << ", \"file\": \"" << escape(Input.getFilename()) << "\"";
-  CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
+  if (Output.isFilename())
+CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
   CDB << ", \"arguments\": [\"" << escape(D.ClangExecutable) << "\"";
   SmallString<128> Buf;
   Buf = "-x";
@@ -2438,7 +2439,8 @@
 CDB << ", \"" << escape(Buf) << "\"";
   }
   CDB << ", \"" << escape(Input.getFilename()) << "\"";
-  CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\"";
+  if (Output.isFilename())
+CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\"";
   for (auto &A: Args) {
 auto &O = A->getOption();
 // Skip language selection, which is positional.


Index: clang/test/Driver/compilation_database_fsyntax_only.c
===
--- /dev/null
+++ clang/test/Driver/compilation_database_fsyntax_only.c
@@ -0,0 +1,16 @@
+// RUN: mkdir -p %t.workdir && cd %t.workdir
+// RUN: %clang -fsyntax-only %s -MJ - 2>&1 | FileCheck %s
+
+// CHECK:  {
+// CHECK-SAME: "directory": "{{[^"]*}}workdir",
+// CHECK-SAME: "file": "{{[^"]*}}compilation_database_fsyntax_only.c"
+// CHECK-NOT:  "output"
+// CHECK-SAME: "arguments": [
+// CHECK-NOT:"-o"
+// CHECK-SAME: ]
+// CHECK-SAME: }
+
+
+int main(void) {
+  return 0;
+}
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -2426,7 +2426,8 @@
 CWD = ".";
   CDB << "{ \"directory\": \"" << escape(*CWD) << "\"";
   CDB << ", \"file\": \"" << escape(Input.getFilename()) << "\"";
-  CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
+  if (Output.isFilename())
+CDB << ", \"output\": \"" << escape(Output.getFilename()) << "\"";
   CDB << ", \"arguments\": [\"" << escape(D.ClangExecutable) << "\"";
   SmallString<128> Buf;
   Buf = "-x";
@@ -2438,7 +2439,8 @@
 CDB << ", \"" << escape(Buf) << "\"";
   }
   CDB << ", \"" << escape(Input.getFilename()) << "\"";
-  CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\"";
+  if (Output.isFilename())
+CDB << ", \"-o\", \"" << escape(Output.getFilename()) << "\"";
   for (auto &A: Args) {
 auto &O = A->getOption();
 // Skip language selection, which is positional.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158223: [clang] Add clang::unnamed_addr attribute that marks globals' address as not significant

2023-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: dblaikie.
rnk added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:1416-1417
+not significant. This allows global constants with the same contents to be
+merged. This can break global pointer identity, i.e. two different globals have
+the same address.
+

aaron.ballman wrote:
> aeubanks wrote:
> > rnk wrote:
> > > erichkeane wrote:
> > > > aeubanks wrote:
> > > > > erichkeane wrote:
> > > > > > aeubanks wrote:
> > > > > > > aaron.ballman wrote:
> > > > > > > > aeubanks wrote:
> > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > aeubanks wrote:
> > > > > > > > > > > aaron.ballman wrote:
> > > > > > > > > > > > What happens for tentative definitions where the value 
> > > > > > > > > > > > isn't known? e.g.,
> > > > > > > > > > > > ```
> > > > > > > > > > > > [[clang::unnamed_addr]] int i1, i2;
> > > > > > > > > > > > ```
> > > > > > > > > > > > 
> > > > > > > > > > > > What happens if the types are similar but not the same?
> > > > > > > > > > > > ```
> > > > > > > > > > > > [[clang::unnamed_addr]] signed int i1 = 32;
> > > > > > > > > > > > [[clang::unnamed_addr]] unsigned int i2 = 32;
> > > > > > > > > > > > ```
> > > > > > > > > > > > 
> > > > > > > > > > > > Should we diagnose taking the address of such an 
> > > > > > > > > > > > attributed variable so users have some hope of spotting 
> > > > > > > > > > > > the non-conforming situations?
> > > > > > > > > > > > 
> > > > > > > > > > > > Does this attribute have impacts across translation 
> > > > > > > > > > > > unit boundaries (perhaps only when doing LTO) or only 
> > > > > > > > > > > > within a single TU?
> > > > > > > > > > > > 
> > > > > > > > > > > > What does this attribute do in C++ in the presence of 
> > > > > > > > > > > > constructors and destructors? e.g.,
> > > > > > > > > > > > ```
> > > > > > > > > > > > struct S {
> > > > > > > > > > > >   S();
> > > > > > > > > > > >   ~S();
> > > > > > > > > > > > };
> > > > > > > > > > > > 
> > > > > > > > > > > > [[clang::unnamed_addr]] S s1, s2; // Are these merged 
> > > > > > > > > > > > and there's only one ctor/dtor call?
> > > > > > > > > > > > ```
> > > > > > > > > > > globals are only mergeable if they're known to be 
> > > > > > > > > > > constant and have the same value/size. this can be done 
> > > > > > > > > > > at compile time only if the optimizer can see the 
> > > > > > > > > > > constant values, or at link time
> > > > > > > > > > > 
> > > > > > > > > > > so nothing would happen in any of the cases you've given.
> > > > > > > > > > > 
> > > > > > > > > > > but yeah that does imply that we should warn when the 
> > > > > > > > > > > attribute is used on non const, non-POD globals. I'll 
> > > > > > > > > > > update this patch to do that
> > > > > > > > > > > 
> > > > > > > > > > > as mentioned in the description, we actually do want to 
> > > > > > > > > > > take the address of these globals for table-driven 
> > > > > > > > > > > parsing, but we don't care about identity equality
> > > > > > > > > > > globals are only mergeable if they're known to be 
> > > > > > > > > > > constant and have the same value/size. this can be done 
> > > > > > > > > > > at compile time only if the optimizer can see the 
> > > > > > > > > > > constant values, or at link time
> > > > > > > > > > >
> > > > > > > > > > > so nothing would happen in any of the cases you've given.
> > > > > > > > > > 
> > > > > > > > > > A that's good to know. So I assume we *will* merge 
> > > > > > > > > > these?
> > > > > > > > > > 
> > > > > > > > > > ```
> > > > > > > > > > struct S {
> > > > > > > > > >   int i, j;
> > > > > > > > > >   float f;
> > > > > > > > > > };
> > > > > > > > > > 
> > > > > > > > > > [[clang::unnamed_addr]] const S s1 = { 1, 2, 3.0f };
> > > > > > > > > > [[clang::unnamed_addr]] const S s2 = { 1, 2, 3.0f };
> > > > > > > > > > [[clang::unnamed_addr]] const S s3 = s2;
> > > > > > > > > > ```
> > > > > > > > > > 
> > > > > > > > > > > but yeah that does imply that we should warn when the 
> > > > > > > > > > > attribute is used on non const, non-POD globals. I'll 
> > > > > > > > > > > update this patch to do that
> > > > > > > > > > 
> > > > > > > > > > Thank you, I think that will be more user-friendly
> > > > > > > > > > 
> > > > > > > > > > > as mentioned in the description, we actually do want to 
> > > > > > > > > > > take the address of these globals for table-driven 
> > > > > > > > > > > parsing, but we don't care about identity equality
> > > > > > > > > > 
> > > > > > > > > > Yeah, I still wonder if we want to diagnose just the same 
> > > > > > > > > > -- if the address is never taken, there's not really a way 
> > > > > > > > > > to notice the optimization, but if the address is taken, 
> > > > > > > > > > you basically get UB (and I think we should explicitly 
> > > > > > > > > > document it as such). Given how easy it is to accidentally 
> > > > > > > > > > take the address of something (lik

[PATCH] D158803: [Sema][HLSL] Consolidate handling of HLSL attributes

2023-08-28 Thread Justin Bogner via Phabricator via cfe-commits
bogner updated this revision to Diff 554044.
bogner added a comment.

- Now with more const
- Added DiagnoseHLSLAttrStageMismatch and avoided using raw strings in 
diagnostics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158803

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGenHLSL/GlobalDestructors.hlsl
  clang/test/SemaHLSL/Semantics/entry_parameter.hlsl
  clang/test/SemaHLSL/Semantics/groupindex.hlsl
  clang/test/SemaHLSL/entry.hlsl
  clang/test/SemaHLSL/entry_shader_redecl.hlsl
  clang/test/SemaHLSL/num_threads.hlsl

Index: clang/test/SemaHLSL/num_threads.hlsl
===
--- clang/test/SemaHLSL/num_threads.hlsl
+++ clang/test/SemaHLSL/num_threads.hlsl
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s 
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-mesh -x hlsl -ast-dump -o - %s | FileCheck %s 
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-amplification -x hlsl -ast-dump -o - %s | FileCheck %s 
-// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -o - %s | FileCheck %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-mesh -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-amplification -x hlsl -ast-dump -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -ast-dump -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-pixel -x hlsl -ast-dump -o - %s -verify
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-vertex -x hlsl -ast-dump -o - %s -verify
 // RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-hull -x hlsl -ast-dump -o - %s -verify
@@ -97,14 +97,20 @@
   return 1;
 }
 
+[numthreads(4,2,1)]
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  4 2 1
+int onlyOnForwardDecl();
+
+// CHECK: HLSLNumThreadsAttr 0x{{[0-9a-fA-F]+}}  Inherited 4 2 1
+int onlyOnForwardDecl() {
+  return 1;
+}
 
 #else // Vertex and Pixel only beyond here
-// expected-error-re@+1 {{attribute 'numthreads' is unsupported in {{[A-Za-z]+}} shaders, requires Compute, Amplification, Mesh or Library}}
+// expected-error-re@+1 {{attribute 'numthreads' is unsupported in '{{[A-Za-z]+}}' shaders, requires one of the following: compute, amplification, mesh}}
 [numthreads(1,1,1)]
 int main() {
  return 1;
 }
 
 #endif
-
-
Index: clang/test/SemaHLSL/entry_shader_redecl.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/entry_shader_redecl.hlsl
@@ -0,0 +1,75 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry cs1 -o - %s -ast-dump -verify | FileCheck -DSHADERFN=cs1 -check-prefix=CHECK-ENV %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry cs2 -o - %s -ast-dump -verify | FileCheck -DSHADERFN=cs2 -check-prefix=CHECK-ENV %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-compute -x hlsl -hlsl-entry cs3 -o - %s -ast-dump -verify | FileCheck -DSHADERFN=cs3 -check-prefix=CHECK-ENV %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -o - %s -ast-dump -verify | FileCheck -check-prefix=CHECK-LIB %s
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3 -x hlsl -o - %s -ast-dump -verify | FileCheck -check-prefix=CHECK-LIB %s
+
+// expected-no-diagnostics
+
+// CHECK-ENV: FunctionDecl [[PROTO:0x[0-9a-f]+]] {{.*}} [[SHADERFN]] 'void ()'
+// CHECK-ENV: FunctionDecl 0x{{.*}} prev [[PROTO]] {{.*}} [[SHADERFN]] 'void ()'
+// CHECK-ENV-NEXT: CompoundStmt 0x
+// CHECK-ENV-NEXT: HLSLNumThreadsAttr 0x
+// CHECK-ENV-NEXT: HLSLShaderAttr 0x{{.*}} Implicit Compute
+void cs1();
+[numthreads(1,1,1)] void cs1() {}
+[numthreads(1,1,1)] void cs2();
+void cs2() {}
+[numthreads(1,1,1)] void cs3();
+[numthreads(1,1,1)] void cs3() {}
+
+// CHECK-LIB: FunctionDecl [[PROTO:0x[0-9a-f]+]] {{.*}} s1 'void ()'
+// CHECK-LIB: FunctionDecl 0x{{.*}} prev [[PROTO]] {{.*}} s1 'void ()'
+// CHECK-LIB-NEXT: CompoundStmt 0x
+// CHECK-LIB-NEXT: HLSLShaderAttr 0x{{.*}} Compute
+// CHECK-LIB-NEXT: HLSLNumThreadsAttr 0x
+void s1();
+[shader("compute"), numthreads(1,1,1)] void s1() {}
+
+// CHECK-LIB: FunctionDecl [[PROTO:0x[0-9a-f]+]] {{.*}} s2 'void ()'
+// CHECK-LIB: FunctionDecl 0x{{.*}} prev [[PROTO]] {{.*}} s2 'void ()'
+// CHECK-LIB-NEXT: CompoundStmt 0x
+// CHECK-LIB-NEXT: HLSLShaderAttr 0x{{.*}} Compute
+// CHECK-LIB-NEXT: HLSLNumThreadsAttr 0x
+[shader("compute")] void s2();
+[shader("compute"), numthreads(1,1,1)] void s2() {}
+
+// CHECK-LIB: FunctionDecl [[PROTO:0x[0-9a-f]+]] {{.*}} s3 'void ()'
+// CHECK-LIB: FunctionDecl 0x{{.*}} prev [[PROTO]] {{.*

[PATCH] D152054: [OpenMP] Codegen support for thread_limit on target directive

2023-08-28 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added subscribers: vadikp-intel, natgla.
mstorsjo added a comment.

In D152054#4620927 , @mstorsjo wrote:

> This new test is failing on Windows, due to `__kmpc_set_thread_limit` not 
> being exported - see e.g. 
> https://github.com/mstorsjo/llvm-mingw/actions/runs/5994183421/job/16264501555.
>  Can someone add it to `openmp/runtime/src/dllexports`?

CC @vadikp-intel @natgla about this. What's the procedure for allocating new 
ordinal numbers for new exported functions here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152054

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


[PATCH] D158407: [clang][dataflow] #llvm #flow-analysis Simplify formula at CNF construction time, and short-cut solving of known contradictory formulas.

2023-08-28 Thread Burak Emir via Phabricator via cfe-commits
burakemir added a comment.

Thanks for the review. PTAL.




Comment at: clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp:426
+  // considered for the simplification of earlier clauses. Do a final
+  // pass to find more opportunities for simplification.
+  CNFFormula FinalCNF(NextVar - 1, std::move(CNF.Atomics));

sammccall wrote:
> the issue is that info only propagates forward (earlier to later clauses, 
> right?)
> 
> so by running this again, and sorting units first, we allow simplifications 
> that propagate info backwards *once*, but we still don't have all 
> simplifications.
> 
> ```
> D
> Av!B
> Bv!C
> Cv!D
> 
> // first simplification pass
> 
> Av!B
> Bv!C
> C // hoist new unit
> 
> // second simplification pass
> 
> Av!B
> B // hoist new unit
> 
> // third simplification pass
> A
> ```
> 
> I think this is worth being explicit about: we're going to find some more 
> simplifications, but we won't find them all, because running this to fixed 
> point is too inefficient.
> 
> Is 2 experimentally determined to be the right number of passes? a guess? or 
> am I misunderstanding :-)
You are right that one could do more work but it is better to leave this to the 
solver algorithm.

We know empirically that there will be a few unit clauses, so might as well 
spend *linear time* (in number of unit clauses) to save some work.

This won't be enough to determine whether all formulas are satisfiable, but it 
catches a few obvious contradictions.

Doing this twice (as opposed to once) catches more formulas that are obvious 
contradictions in our unit tests and some real sources. I picked two simply 
because when we obtain unit clauses "later", we had no opportunity to apply 
them to earlier clauses.

Doing full-blow mutations seems more complicated, esp. given that the Clauses 
data structure has been written for the actual solver algorithm. I think your 
concern on optimizing for a certain pattern of input formulas, which may well 
change in the future, is valid; therefore one should leave the "real" solving 
work to the solver algorithm, which systematically explores all cases.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158407

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


[PATCH] D158407: [clang][dataflow] #llvm #flow-analysis Simplify formula at CNF construction time, and short-cut solving of known contradictory formulas.

2023-08-28 Thread Burak Emir via Phabricator via cfe-commits
burakemir updated this revision to Diff 554040.
burakemir marked 2 inline comments as done.
burakemir added a comment.

Addressing reviewer comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158407

Files:
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -369,4 +369,32 @@
   EXPECT_TRUE(solver.reachedLimit());
 }
 
+TEST(SolverTest, SimpleButLargeContradiction) {
+  // This test ensures that the solver takes a short-cut on known
+  // contradictory inputs, without using max_iterations. At the time
+  // this test is added, formulas that are easily recognized to be
+  // contradictory at CNF construction time would lead to timeout.
+  WatchedLiteralsSolver solver(10);
+  ConstraintContext Ctx;
+  auto first = Ctx.atom();
+  auto last = first;
+  for (int i = 1; i < 1; ++i) {
+last = Ctx.conj(last, Ctx.atom());
+  }
+  last = Ctx.conj(Ctx.neg(first), last);
+  ASSERT_EQ(solver.solve({last}).getStatus(),
+Solver::Result::Status::Unsatisfiable);
+  EXPECT_FALSE(solver.reachedLimit());
+
+  first = Ctx.atom();
+  last = Ctx.neg(first);
+  for (int i = 1; i < 1; ++i) {
+last = Ctx.conj(last, Ctx.neg(Ctx.atom()));
+  }
+  last = Ctx.conj(first, last);
+  ASSERT_EQ(solver.solve({last}).getStatus(),
+Solver::Result::Status::Unsatisfiable);
+  EXPECT_FALSE(solver.reachedLimit());
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
===
--- clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
+++ clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
@@ -12,8 +12,8 @@
 //===--===//
 
 #include 
+#include 
 #include 
-#include 
 #include 
 #include 
 
@@ -62,6 +62,10 @@
 /// Returns the positive literal `V`.
 static constexpr Literal posLit(Variable V) { return 2 * V; }
 
+static constexpr bool isPosLit(Literal L) { return 0 == (L & 1); }
+
+static constexpr bool isNegLit(Literal L) { return 1 == (L & 1); }
+
 /// Returns the negative literal `!V`.
 static constexpr Literal negLit(Variable V) { return 2 * V + 1; }
 
@@ -125,9 +129,14 @@
   /// formula.
   llvm::DenseMap Atomics;
 
+  /// Indicates that we already know the formula is unsatisfiable.
+  /// During construction, we catch simple cases of conflicting unit-clauses.
+  bool KnownContradictory;
+
   explicit CNFFormula(Variable LargestVar,
   llvm::DenseMap Atomics)
-  : LargestVar(LargestVar), Atomics(std::move(Atomics)) {
+  : LargestVar(LargestVar), Atomics(std::move(Atomics)),
+KnownContradictory(false) {
 Clauses.push_back(0);
 ClauseStarts.push_back(0);
 NextWatched.push_back(0);
@@ -135,33 +144,24 @@
 WatchedHead.resize(NumLiterals + 1, 0);
   }
 
-  /// Adds the `L1 v L2 v L3` clause to the formula. If `L2` or `L3` are
-  /// `NullLit` they are respectively omitted from the clause.
-  ///
+  /// Adds the `L1 v ... v Ln` clause to the formula.
   /// Requirements:
   ///
-  ///  `L1` must not be `NullLit`.
+  ///  `Li` must not be `NullLit`.
   ///
   ///  All literals in the input that are not `NullLit` must be distinct.
-  void addClause(Literal L1, Literal L2 = NullLit, Literal L3 = NullLit) {
-// The literals are guaranteed to be distinct from properties of Formula
-// and the construction in `buildCNF`.
-assert(L1 != NullLit && L1 != L2 && L1 != L3 &&
-   (L2 != L3 || L2 == NullLit));
+  void addClause(ArrayRef lits) {
+assert(!lits.empty());
+assert(llvm::all_of(lits, [](Literal L) { return L != NullLit; }));
 
 const ClauseID C = ClauseStarts.size();
 const size_t S = Clauses.size();
 ClauseStarts.push_back(S);
-
-Clauses.push_back(L1);
-if (L2 != NullLit)
-  Clauses.push_back(L2);
-if (L3 != NullLit)
-  Clauses.push_back(L3);
+Clauses.insert(Clauses.end(), lits.begin(), lits.end());
 
 // Designate the first literal as the "watched" literal of the clause.
-NextWatched.push_back(WatchedHead[L1]);
-WatchedHead[L1] = C;
+NextWatched.push_back(WatchedHead[lits.front()]);
+WatchedHead[lits.front()] = C;
   }
 
   /// Returns the number of literals in clause `C`.
@@ -176,6 +176,94 @@
   }
 };
 
+/// Applies simplifications while building up a BooleanFormula.
+/// We keep track of unit clauses, which tell us variables that must be
+/// true/false in any model that satisfies the overall formula.
+/// Such variables can be dropped from subsequently-added clauses, which
+/// may in turn yield more unit claus

[PATCH] D159010: [Driver,X86] Ignore -mfpmath= for assembler input

2023-08-28 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG081afa3d04a4: [Driver,X86] Ignore -mfpmath= for assembler 
input (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D159010?vs=554010&id=554037#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159010

Files:
  clang/lib/Driver/ToolChains/Arch/X86.cpp
  clang/lib/Driver/ToolChains/Arch/X86.h
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/x86-mfpmath.c


Index: clang/test/Driver/x86-mfpmath.c
===
--- /dev/null
+++ clang/test/Driver/x86-mfpmath.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c --target=x86_64 -mfpmath=sse %s 2>&1 | FileCheck %s
+// CHECK: "-mfpmath" "sse"
+
+/// Don't warn for assembler input.
+// RUN: %clang -### -Werror -c --target=x86_64 -mfpmath=sse -x assembler %s 
2>&1 | FileCheck /dev/null --implicit-check-not='"-mfpmath"'
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -528,7 +528,7 @@
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
-x86::getX86TargetFeatures(D, Triple, Args, Features);
+x86::getX86TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::hexagon:
 hexagon::getHexagonTargetFeatures(D, Triple, Args, Features);
Index: clang/lib/Driver/ToolChains/Arch/X86.h
===
--- clang/lib/Driver/ToolChains/Arch/X86.h
+++ clang/lib/Driver/ToolChains/Arch/X86.h
@@ -26,7 +26,7 @@
 
 void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  std::vector &Features);
+  std::vector &Features, bool ForAS);
 
 } // end namespace x86
 } // end namespace target
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -118,7 +118,13 @@
 
 void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
-   std::vector &Features) {
+   std::vector &Features, bool ForAS) {
+  if (ForAS) {
+// Some target-specific options are only handled in AddX86TargetArgs, which
+// is not called by ClangAs::ConstructJob. Claim them here.
+Args.claimAllArgs(options::OPT_mfpmath_EQ);
+  }
+
   // Claim and report unsupported -mabi=. Note: we don't support "sysv_abi" or
   // "ms_abi" as default function attributes.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {


Index: clang/test/Driver/x86-mfpmath.c
===
--- /dev/null
+++ clang/test/Driver/x86-mfpmath.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c --target=x86_64 -mfpmath=sse %s 2>&1 | FileCheck %s
+// CHECK: "-mfpmath" "sse"
+
+/// Don't warn for assembler input.
+// RUN: %clang -### -Werror -c --target=x86_64 -mfpmath=sse -x assembler %s 2>&1 | FileCheck /dev/null --implicit-check-not='"-mfpmath"'
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -528,7 +528,7 @@
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
-x86::getX86TargetFeatures(D, Triple, Args, Features);
+x86::getX86TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::hexagon:
 hexagon::getHexagonTargetFeatures(D, Triple, Args, Features);
Index: clang/lib/Driver/ToolChains/Arch/X86.h
===
--- clang/lib/Driver/ToolChains/Arch/X86.h
+++ clang/lib/Driver/ToolChains/Arch/X86.h
@@ -26,7 +26,7 @@
 
 void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  std::vector &Features);
+  std::vector &Features, bool ForAS);
 
 } // end namespace x86
 } // end namespace target
Index: clang/lib/Driver/ToolChains/Arch/X86.cpp
===
--- clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -118,7 +118,13 @@
 
 void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
-   std::vector &Features) {
+   std::vector &Features, bool ForAS) {
+  if (F

[clang] 081afa3 - [Driver,X86] Ignore -mfpmath= for assembler input

2023-08-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-08-28T13:37:33-07:00
New Revision: 081afa3d04a4bc0d43c62b5b0e5a84f86a8a70ec

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

LOG: [Driver,X86] Ignore -mfpmath= for assembler input

Some options are only claimed in AddX86TargetArgs/etc (called by
Clang::RenderTargetOptions).
For assembler input, `Add*TargetArgs` is not called. If an option is
unclaimed, it either leads to a -Wunused-command-line-argument warning
or an error (if `TargetSpecific` is set)
```
// clang '-###' --target=x86_64 -mfpmath=sse -c a.s
clang: error: unsupported option '-mfpmath=sse' for target 'x86_64'
```

For -mfpmath=, it's actually claimed by RenderFloatingPointOptions,
which should be moved to AddARMTargetArgs/AddX86TargetArgs later
(non-AArch32-non-x86 targets give a frontend error).
This change is localized and similar to D153691, for release/17.x
backporting.

Fix https://github.com/llvm/llvm-project/issues/65023

Reviewed By: thesamesam

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

Added: 
clang/test/Driver/x86-mfpmath.c

Modified: 
clang/lib/Driver/ToolChains/Arch/X86.cpp
clang/lib/Driver/ToolChains/Arch/X86.h
clang/lib/Driver/ToolChains/CommonArgs.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp 
b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index cf2bc63d74ada9..4383b800414356 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -118,7 +118,13 @@ std::string x86::getX86TargetCPU(const Driver &D, const 
ArgList &Args,
 
 void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args,
-   std::vector &Features) {
+   std::vector &Features, bool ForAS) {
+  if (ForAS) {
+// Some target-specific options are only handled in AddX86TargetArgs, which
+// is not called by ClangAs::ConstructJob. Claim them here.
+Args.claimAllArgs(options::OPT_mfpmath_EQ);
+  }
+
   // Claim and report unsupported -mabi=. Note: we don't support "sysv_abi" or
   // "ms_abi" as default function attributes.
   if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mabi_EQ)) {

diff  --git a/clang/lib/Driver/ToolChains/Arch/X86.h 
b/clang/lib/Driver/ToolChains/Arch/X86.h
index e07387f3ece3df..762a1fa6f4d5f9 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.h
+++ b/clang/lib/Driver/ToolChains/Arch/X86.h
@@ -26,7 +26,7 @@ std::string getX86TargetCPU(const Driver &D, const 
llvm::opt::ArgList &Args,
 
 void getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  std::vector &Features);
+  std::vector &Features, bool ForAS);
 
 } // end namespace x86
 } // end namespace target

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 813f80223bd830..6fa16cac4cbb26 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -528,7 +528,7 @@ void tools::getTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
-x86::getX86TargetFeatures(D, Triple, Args, Features);
+x86::getX86TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::hexagon:
 hexagon::getHexagonTargetFeatures(D, Triple, Args, Features);

diff  --git a/clang/test/Driver/x86-mfpmath.c b/clang/test/Driver/x86-mfpmath.c
new file mode 100644
index 00..7df594477a92c9
--- /dev/null
+++ b/clang/test/Driver/x86-mfpmath.c
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c --target=x86_64 -mfpmath=sse %s 2>&1 | FileCheck %s
+// CHECK: "-mfpmath" "sse"
+
+/// Don't warn for assembler input.
+// RUN: %clang -### -Werror -c --target=x86_64 -mfpmath=sse -x assembler %s 
2>&1 | FileCheck /dev/null --implicit-check-not='"-mfpmath"'



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


[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-28 Thread Zequan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf52f8e817ea3: [Profile] Allow online merging with debug info 
correlation. (authored by zequanwu).

Changed prior to commit:
  https://reviews.llvm.org/D157632?vs=550051&id=554035#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157632

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  compiler-rt/lib/profile/InstrProfilingMerge.c
  compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
  compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
  compiler-rt/test/profile/instrprof-merge-empty-data.test
  compiler-rt/test/profile/instrprof-merge-error.c

Index: compiler-rt/test/profile/instrprof-merge-error.c
===
--- compiler-rt/test/profile/instrprof-merge-error.c
+++ compiler-rt/test/profile/instrprof-merge-error.c
@@ -1,11 +1,5 @@
 // RUN: rm -rf %t; mkdir %t
 
-// RUN: %clang_pgogen -o %t/dbg -g -mllvm --debug-info-correlate -mllvm --disable-vp=true %s
-// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | count 0
-// RUN: env LLVM_PROFILE_FILE=%t/dbg_%m.profdata %run %t/dbg 2>&1 | FileCheck %s --check-prefix=DBG
-
-// DBG: Debug info correlation does not support profile merging at runtime.
-
 // RUN: %clang_pgogen -o %t/timeprof -mllvm -pgo-temporal-instrumentation %s
 // RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | count 0
 // RUN: env LLVM_PROFILE_FILE=%t/timeprof_%m.profdata %run %t/timeprof 2>&1 | FileCheck %s --check-prefix=TIMEPROF
Index: compiler-rt/test/profile/instrprof-merge-empty-data.test
===
--- /dev/null
+++ compiler-rt/test/profile/instrprof-merge-empty-data.test
@@ -0,0 +1,14 @@
+// Test online merging with empty data section.
+// RUN: rm -rf %t.dir && split-file %s %t.dir && cd %t.dir
+// RUN: %clangxx_profgen -fcoverage-mapping -o %t main.c -fprofile-list=funlist
+// RUN: env LLVM_PROFILE_FILE='a%m.profraw' %t
+// RUN: env LLVM_PROFILE_FILE='a%m.profraw' %t 2>&1 | FileCheck %s --allow-empty
+
+// CHECK-NOT: LLVM Profile Error
+
+//--- main.c
+int main() {}
+
+//--- funlist
+[clang]
+default:skip
Index: compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
===
--- compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
+++ compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
@@ -24,3 +24,23 @@
 // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
 
 // RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
+
+// Test debug info correlate with online merging.
+
+// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
+// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
+// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t %t.profdir/
+
+// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata show --all-functions --counts %t.profdata)
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.cov.proflite %run %t.cov
+// RUN: llvm-profdata merge -o %t.cov.profdata --debug-info=%t.cov %t.profdir/
+
+// RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
Index: compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
===
--- compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
+++ compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
@@ -18,3 +18,23 @@
 // RUN: llvm-profdata merge -o %t.cov.normal.profdata %t.cov.profraw
 
 // RUN: diff <(llvm-profdata show --all-functions --counts %t.cov.normal.profdata) <(llvm-profdata show --all-functions --counts %t.cov.profdata)
+
+// Test debug info correlate with online merging.
+
+// RUN: env LLVM_PROFILE_FILE=%t-1.profraw %run %t.normal
+// RUN: env LLVM_PROFILE_FILE=%t-2.profraw %run %t.normal
+// RUN: llvm-profdata merge -o %t.normal.profdata %t-1.profraw %t-2.profraw
+
+// RUN: rm -rf %t.profdir && mkdir %t.profdir
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: env LLVM_PROFILE_FILE=%t.profdir/%m.proflite %run %t
+// RUN: llvm-profdata merge -o %t.profdata --debug-info=%t.dSYM %t.profdir/
+
+// RUN: diff <(llvm-profdata show --all-functions --counts %t.normal.profdata) <(llvm-profdata sh

[clang] f52f8e8 - [Profile] Allow online merging with debug info correlation.

2023-08-28 Thread Zequan Wu via cfe-commits

Author: Zequan Wu
Date: 2023-08-28T16:35:41-04:00
New Revision: f52f8e817ea36e003e8f09672de48c3c460093f4

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

LOG: [Profile] Allow online merging with debug info correlation.

When using debug info correlation, value profiling needs to be switched off.
So, we are only merging counter sections. In that case the existance of data
section is just used to provide an extra check in case of corrupted profile.

This patch performs counter merging by iterating the counter section by counter
size and add them together.

Reviewed By: ellis, MaskRay

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

Added: 
compiler-rt/test/profile/instrprof-merge-empty-data.test

Modified: 
clang/lib/CodeGen/BackendUtil.cpp
compiler-rt/lib/profile/InstrProfilingMerge.c
compiler-rt/test/profile/Darwin/instrprof-debug-info-correlate.c
compiler-rt/test/profile/Linux/instrprof-debug-info-correlate.c
compiler-rt/test/profile/instrprof-merge-error.c

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 373d38672284d6..3e8b2b78a3928b 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -102,7 +102,7 @@ namespace {
 
 // Default filename used for profile generation.
 std::string getDefaultProfileGenName() {
-  return DebugInfoCorrelate ? "default_%p.proflite" : "default_%m.profraw";
+  return DebugInfoCorrelate ? "default_%m.proflite" : "default_%m.profraw";
 }
 
 class EmitAssemblyHelper {

diff  --git a/compiler-rt/lib/profile/InstrProfilingMerge.c 
b/compiler-rt/lib/profile/InstrProfilingMerge.c
index 241891da454bb4..9cf12f251f7262 100644
--- a/compiler-rt/lib/profile/InstrProfilingMerge.c
+++ b/compiler-rt/lib/profile/InstrProfilingMerge.c
@@ -47,7 +47,6 @@ uint64_t lprofGetLoadModuleSignature(void) {
 COMPILER_RT_VISIBILITY
 int __llvm_profile_check_compatibility(const char *ProfileData,
uint64_t ProfileSize) {
-  /* Check profile header only for now  */
   __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
   __llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
   SrcDataStart =
@@ -102,13 +101,6 @@ static uintptr_t signextIfWin64(void *V) {
 COMPILER_RT_VISIBILITY
 int __llvm_profile_merge_from_buffer(const char *ProfileData,
  uint64_t ProfileSize) {
-  if (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) {
-PROF_ERR(
-"%s\n",
-"Debug info correlation does not support profile merging at runtime. "
-"Instead, merge raw profiles using the llvm-profdata tool.");
-return 1;
-  }
   if (__llvm_profile_get_version() & VARIANT_MASK_TEMPORAL_PROF) {
 PROF_ERR("%s\n",
  "Temporal profiles do not support profile merging at runtime. "
@@ -118,7 +110,8 @@ int __llvm_profile_merge_from_buffer(const char 
*ProfileData,
 
   __llvm_profile_data *SrcDataStart, *SrcDataEnd, *SrcData, *DstData;
   __llvm_profile_header *Header = (__llvm_profile_header *)ProfileData;
-  char *SrcCountersStart;
+  char *SrcCountersStart, *DstCounter;
+  const char *SrcCountersEnd, *SrcCounter;
   const char *SrcNameStart;
   const char *SrcValueProfDataStart, *SrcValueProfData;
   uintptr_t CountersDelta = Header->CountersDelta;
@@ -128,14 +121,32 @@ int __llvm_profile_merge_from_buffer(const char 
*ProfileData,
   Header->BinaryIdsSize);
   SrcDataEnd = SrcDataStart + Header->NumData;
   SrcCountersStart = (char *)SrcDataEnd;
-  SrcNameStart = SrcCountersStart +
- Header->NumCounters * __llvm_profile_counter_entry_size();
+  SrcCountersEnd = SrcCountersStart +
+   Header->NumCounters * __llvm_profile_counter_entry_size();
+  SrcNameStart = SrcCountersEnd;
   SrcValueProfDataStart =
   SrcNameStart + Header->NamesSize +
   __llvm_profile_get_num_padding_bytes(Header->NamesSize);
   if (SrcNameStart < SrcCountersStart)
 return 1;
 
+  // Merge counters by iterating the entire counter section when debug info
+  // correlation is enabled.
+  if (__llvm_profile_get_version() & VARIANT_MASK_DBG_CORRELATE) {
+for (SrcCounter = SrcCountersStart,
+DstCounter = __llvm_profile_begin_counters();
+ SrcCounter < SrcCountersEnd;) {
+  if (__llvm_profile_get_version() & VARIANT_MASK_BYTE_COVERAGE) {
+*DstCounter &= *SrcCounter;
+  } else {
+*(uint64_t *)DstCounter += *(uint64_t *)SrcCounter;
+  }
+  SrcCounter += __llvm_profile_counter_entry_size();
+  DstCounter += __llvm_profile_counter_entry_size();
+}
+return 0;
+  }
+
   for (SrcData = SrcDataStart,
   DstData = (__llvm_profile_data *)__llvm_pr

[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl marked 2 inline comments as done.
AntonRydahl added inline comments.



Comment at: clang/lib/Sema/SemaExprCXX.cpp:869
bool IsThrownVarInScope) {
-  // Don't report an error if 'throw' is used in system headers.
-  if (!getLangOpts().CXXExceptions &&
+  const llvm::Triple T = Context.getTargetInfo().getTriple();
+  const bool IsOpenMPGPUTarget =

jdoerfert wrote:
> 
Good point! They should of course both be aliases. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

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


[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Anton Rydahl via Phabricator via cfe-commits
AntonRydahl updated this revision to Diff 554034.
AntonRydahl marked 2 inline comments as done.
AntonRydahl added a comment.

Replaced instances of `const llvm::Triple T` with `const llvm::Triple &T`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/lib/CodeGen/CGException.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/test/OpenMP/amdgpu_exceptions.cpp
  clang/test/OpenMP/amdgpu_throw.cpp
  clang/test/OpenMP/amdgpu_throw_trap.cpp
  clang/test/OpenMP/amdgpu_try_catch.cpp
  clang/test/OpenMP/nvptx_exceptions.cpp
  clang/test/OpenMP/nvptx_target_exceptions_messages.cpp
  clang/test/OpenMP/nvptx_throw.cpp
  clang/test/OpenMP/nvptx_throw_trap.cpp
  clang/test/OpenMP/nvptx_try_catch.cpp
  clang/test/OpenMP/x86_target_exceptions.cpp
  clang/test/OpenMP/x86_target_throw.cpp
  clang/test/OpenMP/x86_target_try_catch.cpp

Index: clang/test/OpenMP/x86_target_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_try_catch.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		error = 1;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_throw.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_throw.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+void foo(void) {
+	throw 404;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/x86_target_exceptions.cpp
===
--- /dev/null
+++ clang/test/OpenMP/x86_target_exceptions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fopenmp -triple x86_64-pc-linux-gnu -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify -Wopenmp-target-exception -analyze
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try {
+		throw 404;
+	}
+	catch (int e){ 
+		error = e;
+	}
+	return error;
+}
+#pragma omp end declare target
+// expected-no-diagnostics
Index: clang/test/OpenMP/nvptx_try_catch.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_try_catch.cpp
@@ -0,0 +1,45 @@
+/**
+ * The first four lines test that a warning is produced when enabling 
+ * -Wopenmp-target-exception no matter what combination of -fexceptions and 
+ * -fcxx-exceptions are set, as we want OpenMP to always allow exceptions in the
+ * target region but emit a warning instead.
+*/
+
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=with -Wopenmp-target-exception -analyze
+
+/**
+ * The following four lines test that no warning is emitted when providing 
+ * -Wno-openmp-target-exception no matter the combination of -fexceptions and 
+ * -fcxx-exceptions.
+*/
+
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fcxx-exceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device -fexceptions %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+// RUN: %clang_cc1 -fopenmp -triple nvptx64 -fopenmp-is-target-device %s -emit-llvm -S -verify=without -Wno-openmp-target-exception -analyze
+
+/**
+ * Finally we should test that we only ignore exceptions in the OpenMP 
+ * offloading tool-chain
+*/
+
+// RUN: %clang_cc1 -triple nvptx64 %s -emit-llvm -S -verify=noexceptions -o -
+
+// noexceptions-error@36 {{cannot use 'try' with exceptions disabled}}
+
+#pragma omp declare target
+int foo(void) {
+	int error = -1;
+	try { // with-warning {{target 'nvptx64' does not support excepti

[PATCH] D159010: [Driver,X86] Ignore -mfpmath= for assembler input

2023-08-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Tested by parona on Libera Chat IRC. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159010

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


[clang] dd850f0 - [llvm][clang][modules] Fix test failure on big-endian bots

2023-08-28 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-08-28T13:18:40-07:00
New Revision: dd850f0bae8f38b721e9ae6b8ba915dbf7d9bac7

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

LOG: [llvm][clang][modules] Fix test failure on big-endian bots

After 
6fb08d8f558a6f28db7835acdb88cab83aea2eb4,`clang/test/Modules/ModuleDebugInfoDwoId.cpp`
 started failing on a number of big-endian build bots 
(clang-ppc64be-linux-multistage, clang-ppc64be-linux-test-suite). This patch 
attempts to fix that by creating an API on `llvm::BitstreamWriter` that allows 
backpatching individual bytes. This API is then used from `clang::ASTWriter` to 
avoid endianness mismatch.

Added: 


Modified: 
clang/lib/Serialization/ASTWriter.cpp
llvm/include/llvm/Bitstream/BitstreamWriter.h

Removed: 




diff  --git a/clang/lib/Serialization/ASTWriter.cpp 
b/clang/lib/Serialization/ASTWriter.cpp
index c9148b67c06ea9..8eac78408188d2 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -1148,13 +1148,9 @@ ASTFileSignature ASTWriter::backpatchSignature() {
   // For implicit modules, write the hash of the PCM as its signature.
 
   auto BackpatchSignatureAt = [&](const ASTFileSignature &S, uint64_t BitNo) {
-using WordT = unsigned;
-std::array Words;
-static_assert(sizeof(Words) == sizeof(S));
-std::memcpy(Words.data(), S.data(), sizeof(ASTFileSignature));
-for (WordT Word : Words) {
-  Stream.BackpatchWord(BitNo, Word);
-  BitNo += sizeof(WordT) * 8;
+for (uint8_t Byte : S) {
+  Stream.BackpatchByte(BitNo, Byte);
+  BitNo += 8;
 }
   };
 

diff  --git a/llvm/include/llvm/Bitstream/BitstreamWriter.h 
b/llvm/include/llvm/Bitstream/BitstreamWriter.h
index d802b73e97e0f5..423af4c2cc6c00 100644
--- a/llvm/include/llvm/Bitstream/BitstreamWriter.h
+++ b/llvm/include/llvm/Bitstream/BitstreamWriter.h
@@ -129,20 +129,20 @@ class BitstreamWriter {
   // Basic Primitives for emitting bits to the stream.
   
//======//
 
-  /// Backpatch a 32-bit word in the output at the given bit offset
-  /// with the specified value.
-  void BackpatchWord(uint64_t BitNo, unsigned NewWord) {
+  /// Backpatch a byte in the output at the given bit offset with the specified
+  /// value.
+  void BackpatchByte(uint64_t BitNo, uint8_t NewByte) {
 using namespace llvm::support;
 uint64_t ByteNo = BitNo / 8;
 uint64_t StartBit = BitNo & 7;
 uint64_t NumOfFlushedBytes = GetNumOfFlushedBytes();
 
 if (ByteNo >= NumOfFlushedBytes) {
-  assert((!endian::readAtBitAlignment(
+  assert((!endian::readAtBitAlignment(
  &Out[ByteNo - NumOfFlushedBytes], StartBit)) &&
  "Expected to be patching over 0-value placeholders");
-  endian::writeAtBitAlignment(
-  &Out[ByteNo - NumOfFlushedBytes], NewWord, StartBit);
+  endian::writeAtBitAlignment(
+  &Out[ByteNo - NumOfFlushedBytes], NewByte, StartBit);
   return;
 }
 
@@ -151,8 +151,8 @@ class BitstreamWriter {
 uint64_t CurPos = FS->tell();
 
 // Copy data to update into Bytes from the file FS and the buffer Out.
-char Bytes[9]; // Use one more byte to silence a warning from Visual C++.
-size_t BytesNum = StartBit ? 8 : 4;
+char Bytes[3]; // Use one more byte to silence a warning from Visual C++.
+size_t BytesNum = StartBit ? 2 : 1;
 size_t BytesFromDisk = std::min(static_cast(BytesNum), 
NumOfFlushedBytes - ByteNo);
 size_t BytesFromBuffer = BytesNum - BytesFromDisk;
 
@@ -170,14 +170,14 @@ class BitstreamWriter {
   assert(BytesRead >= 0 && static_cast(BytesRead) == 
BytesFromDisk);
   for (size_t i = 0; i < BytesFromBuffer; ++i)
 Bytes[BytesFromDisk + i] = Out[i];
-  assert((!endian::readAtBitAlignment(
+  assert((!endian::readAtBitAlignment(
  Bytes, StartBit)) &&
  "Expected to be patching over 0-value placeholders");
 }
 
 // Update Bytes in terms of bit offset and value.
-endian::writeAtBitAlignment(Bytes, NewWord,
- StartBit);
+endian::writeAtBitAlignment(Bytes, NewByte,
+StartBit);
 
 // Copy updated data back to the file FS and the buffer Out.
 FS->seek(ByteNo);
@@ -189,6 +189,16 @@ class BitstreamWriter {
 FS->seek(CurPos);
   }
 
+  void BackpatchHalfWord(uint64_t BitNo, uint16_t Val) {
+BackpatchByte(BitNo, (uint8_t)Val);
+BackpatchByte(BitNo + 8, (uint8_t)(Val >> 8));
+  }
+
+  void BackpatchWord(uint64_t BitNo, unsigned Val) {
+BackpatchHalfWord(BitNo, (uint16_t)Val);
+BackpatchHalfWord(BitNo + 16, (uint16_t)(Val >> 16));
+  }
+
   

[clang] 79af92b - Reland "[clang-repl] support code completion at a REPL."

2023-08-28 Thread Vassil Vassilev via cfe-commits

Author: Fred Fu
Date: 2023-08-28T20:09:03Z
New Revision: 79af92bb99dd86cc36d6a81066063fb9cd77c78a

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

LOG: Reland "[clang-repl] support code completion at a REPL."

Original commit message:
"
This patch enabled code completion for ClangREPL. The feature was built upon
three existing Clang components: a list completer for LineEditor, a
CompletionConsumer from SemaCodeCompletion, and the ASTUnit::codeComplete 
method.
The first component serves as the main entry point of handling interactive 
inputs.

Because a completion point for a compiler instance has to be unchanged once it
is set, an incremental compiler instance is created for each code
completion. Such a compiler instance carries over AST context source from the
main interpreter compiler in order to obtain declarations or bindings from
previous input in the same REPL session.

The most important API codeComplete in Interpreter/CodeCompletion is a thin
wrapper that calls with ASTUnit::codeComplete with necessary arguments, such as
a code completion point and a ReplCompletionConsumer, which communicates
completion results from SemaCodeCompletion back to the list completer for the
REPL.

In addition, PCC_TopLevelOrExpression and CCC_TopLevelOrExpression` top levels
were added so that SemaCodeCompletion can treat top level statements like
expression statements at the REPL. For example,

clang-repl> int foo = 42;
clang-repl> f

>From a parser's persective, the cursor is at a top level. If we used code
completion without any changes, PCC_Namespace would be supplied to
Sema::CodeCompleteOrdinaryName, and thus the completion results would not
include foo.

Currently, the way we use PCC_TopLevelOrExpression and
CCC_TopLevelOrExpression is no different from the way we use PCC_Statement
and CCC_Statement respectively.

Differential revision: https://reviews.llvm.org/D154382
"

The new patch also fixes clangd and several memory issues that the bots reported
and upload the missing files.

Added: 
clang/include/clang/Interpreter/CodeCompletion.h
clang/lib/Interpreter/CodeCompletion.cpp
clang/test/CodeCompletion/incrememal-mode-completion-no-error.cpp
clang/test/CodeCompletion/incremental-top-level.cpp
clang/unittests/Interpreter/CodeCompletionTest.cpp

Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang/include/clang/Frontend/ASTUnit.h
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Interpreter/CMakeLists.txt
clang/lib/Interpreter/IncrementalParser.cpp
clang/lib/Interpreter/IncrementalParser.h
clang/lib/Interpreter/Interpreter.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/CodeCompleteConsumer.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/tools/clang-repl/ClangRepl.cpp
clang/tools/libclang/CIndexCodeCompletion.cpp
clang/unittests/Interpreter/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 68e12b2fb00167..1a0023d4b453a1 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -821,6 +821,7 @@ bool contextAllowsIndex(enum CodeCompletionContext::Kind K) 
{
   case CodeCompletionContext::CCC_Symbol:
   case CodeCompletionContext::CCC_SymbolOrNewName:
   case CodeCompletionContext::CCC_ObjCClassForwardDecl:
+  case CodeCompletionContext::CCC_TopLevelOrExpression:
 return true;
   case CodeCompletionContext::CCC_OtherWithMacros:
   case CodeCompletionContext::CCC_DotMemberAccess:

diff  --git a/clang/include/clang/Frontend/ASTUnit.h 
b/clang/include/clang/Frontend/ASTUnit.h
index b762be1c9b1d6d..c6d0d4d7e90233 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -77,6 +77,7 @@ class Preprocessor;
 class PreprocessorOptions;
 class Sema;
 class TargetInfo;
+class SyntaxOnlyAction;
 
 /// \brief Enumerates the available scopes for skipping function bodies.
 enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
@@ -887,6 +888,10 @@ class ASTUnit {
   /// \param IncludeBriefComments Whether to include brief documentation within
   /// the set of code completions returned.
   ///
+  /// \param Act If supplied, this argument is used to parse the input file,
+  /// allowing customized parsing by overriding SyntaxOnlyAction lifecycle
+  /// methods.
+  ///
   /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and
   /// OwnedBuffers parameters are all disgusting hacks. They will go away.
   void CodeComplete(StringRef File, unsigned Line, unsigned Column,
@@ -897,7 +902,8 @@ class ASTUnit {
  

[PATCH] D158538: [MS-ABI] Remove comdat attribute for inheriting ctor.

2023-08-28 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm with some tweaks to the test.




Comment at: clang/test/CodeGenCXX/ms-inheriting-ctor.cpp:41
+
+// CHECK-LABEL: define internal noundef ptr 
@"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"(ptr noundef nonnull returned align 1 
dereferenceable(1) %this, ptr noundef nonnull align 1 dereferenceable(1) %0, 
ptr noundef nonnull align 1 dereferenceable(1) %1) unnamed_addr #2 align 2
+// CHECK-LABEL: define linkonce_odr dso_local noundef ptr 
@"??0?$c@_NUbQEAA@AEBVF@@AEBUA@@@Z"(ptr noundef nonnull returned align 1 
dereferenceable(1) %this, ptr noundef nonnull align 1 dereferenceable(1) %p1, 
ptr noundef nonnull align 1 dereferenceable(1) %d) unnamed_addr #2 comdat align 
2

jyu2 wrote:
> rnk wrote:
> > To make this less fragile, can you come up with a way to use `CHECK-NOT: 
> > comdat` since that's the key thing we're testing for here? You will need 
> > some subsequent anchor like `entry:` or something else.
> Thanks.  I changed.
This isn't quite what I was trying to suggest, I was thinking something more 
like:

```
// CHECK-LABEL: define internal noundef ptr @"??0?$B@_N@@QEAA@AEBVF@@AEBUA@@@Z"
// CHECK-NOT: comdat
// CHECK-SAME: {{\{$}}
```

So, it finds the class with the inheriting constructor, and then checks that 
the word "comdat" does not appear  anywhere on that line. I haven't tested the 
CHECK-SAME pattern, it may need some adjustment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158538

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


[clang-tools-extra] 752f87c - Revert "Reland "[clang-repl] support code completion at a REPL.""

2023-08-28 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2023-08-28T20:05:14Z
New Revision: 752f87cd6a1a354790f4728848827077467ac15d

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

LOG: Revert "Reland "[clang-repl] support code completion at a REPL.""

This reverts commit 5ab25a42ba70c4b50214b0e78eaaccd30696fa09 due to forgotten
files.

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang/include/clang/Frontend/ASTUnit.h
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Sema.h
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Interpreter/CMakeLists.txt
clang/lib/Interpreter/IncrementalParser.cpp
clang/lib/Interpreter/IncrementalParser.h
clang/lib/Interpreter/Interpreter.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/Parser.cpp
clang/lib/Sema/CodeCompleteConsumer.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/tools/clang-repl/ClangRepl.cpp
clang/tools/libclang/CIndexCodeCompletion.cpp
clang/unittests/Interpreter/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 1a0023d4b453a1..68e12b2fb00167 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -821,7 +821,6 @@ bool contextAllowsIndex(enum CodeCompletionContext::Kind K) 
{
   case CodeCompletionContext::CCC_Symbol:
   case CodeCompletionContext::CCC_SymbolOrNewName:
   case CodeCompletionContext::CCC_ObjCClassForwardDecl:
-  case CodeCompletionContext::CCC_TopLevelOrExpression:
 return true;
   case CodeCompletionContext::CCC_OtherWithMacros:
   case CodeCompletionContext::CCC_DotMemberAccess:

diff  --git a/clang/include/clang/Frontend/ASTUnit.h 
b/clang/include/clang/Frontend/ASTUnit.h
index c6d0d4d7e90233..b762be1c9b1d6d 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -77,7 +77,6 @@ class Preprocessor;
 class PreprocessorOptions;
 class Sema;
 class TargetInfo;
-class SyntaxOnlyAction;
 
 /// \brief Enumerates the available scopes for skipping function bodies.
 enum class SkipFunctionBodiesScope { None, Preamble, PreambleAndMainFile };
@@ -888,10 +887,6 @@ class ASTUnit {
   /// \param IncludeBriefComments Whether to include brief documentation within
   /// the set of code completions returned.
   ///
-  /// \param Act If supplied, this argument is used to parse the input file,
-  /// allowing customized parsing by overriding SyntaxOnlyAction lifecycle
-  /// methods.
-  ///
   /// FIXME: The Diag, LangOpts, SourceMgr, FileMgr, StoredDiagnostics, and
   /// OwnedBuffers parameters are all disgusting hacks. They will go away.
   void CodeComplete(StringRef File, unsigned Line, unsigned Column,
@@ -902,8 +897,7 @@ class ASTUnit {
 DiagnosticsEngine &Diag, LangOptions &LangOpts,
 SourceManager &SourceMgr, FileManager &FileMgr,
 SmallVectorImpl &StoredDiagnostics,
-SmallVectorImpl &OwnedBuffers,
-std::unique_ptr Act = nullptr);
+SmallVectorImpl &OwnedBuffers);
 
   /// Save this translation unit to a file with the given name.
   ///

diff  --git a/clang/include/clang/Sema/CodeCompleteConsumer.h 
b/clang/include/clang/Sema/CodeCompleteConsumer.h
index 274eaac819af1b..bb4b638050383c 100644
--- a/clang/include/clang/Sema/CodeCompleteConsumer.h
+++ b/clang/include/clang/Sema/CodeCompleteConsumer.h
@@ -336,12 +336,7 @@ class CodeCompletionContext {
 CCC_Recovery,
 
 /// Code completion in a @class forward declaration.
-CCC_ObjCClassForwardDecl,
-
-/// Code completion at a top level, i.e. in a namespace or global scope,
-/// but also in expression statements. This is because REPL inputs can be
-/// declarations or expression statements.
-CCC_TopLevelOrExpression,
+CCC_ObjCClassForwardDecl
   };
 
   using VisitedContextSet = llvm::SmallPtrSet;

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index e5083ddf1847f0..04c2faddec5bf4 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -13456,9 +13456,7 @@ class Sema final {
 PCC_ParenthesizedExpression,
 /// Code completion occurs within a sequence of declaration
 /// specifiers within a function, method, or block.
-PCC_LocalDeclarationSpecifiers,
-/// Code completion occurs at top-level in a REPL session
-PCC_TopLevelOrExpression,
+PCC_LocalDeclarationSpecifiers
   };
 
   void CodeCompleteModuleImport(SourceLocation ImportLoc, ModuleIdPath Path);

diff  --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index 98d6c08146d6c8..aece72243d17e0 100644
--- a/clang/lib/Fronten

[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Reverted cd591e02d4563d4b90792ed5f441e1cf5b30443e 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D157632

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


[PATCH] D159000: Reland "[Profile] Allow online merging with debug info correlation."

2023-08-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Reverted. Please continue on original review: `arc diff HEAD^ --revision 
D157632`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D159000

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


[PATCH] D153924: [OpenMP] Allow exceptions in target regions when offloading to GPUs

2023-08-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG, see below.




Comment at: clang/lib/Sema/SemaExprCXX.cpp:869
bool IsThrownVarInScope) {
-  // Don't report an error if 'throw' is used in system headers.
-  if (!getLangOpts().CXXExceptions &&
+  const llvm::Triple T = Context.getTargetInfo().getTriple();
+  const bool IsOpenMPGPUTarget =





Comment at: clang/lib/Sema/SemaStmt.cpp:4474
   ArrayRef Handlers) {
-  // Don't report an error if 'try' is used in system headers.
-  if (!getLangOpts().CXXExceptions &&
+  const llvm::Triple T = Context.getTargetInfo().getTriple();
+  const bool IsOpenMPGPUTarget =




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153924

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


  1   2   3   >