[PATCH] D123235: [OpenMP] atomic compare fail : Parser & AST support

2023-11-07 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added inline comments.



Comment at: clang/lib/Basic/OpenMPKinds.cpp:444
+OpenMPClauseKind CK = static_cast(Type);
+switch (CK) {
+case OMPC_unknown:

Hi @koops ,
clang complains on this patch with
```
../../clang/lib/Basic/OpenMPKinds.cpp:444:13: error: 97 enumeration values not 
handled in switch: 'OMPC_adjust_args', 'OMPC_affinity', 'OMPC_align'... 
[-Werror,-Wswitch]
switch (CK) {
^~
1 error generated.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123235

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread Iain Sandoe via cfe-commits

iains wrote:

perhaps in the context we can use "sparse" instead of "thin" - but I do not 
have a good short word replace 'fat'.

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread Timm Baeder via cfe-commits


@@ -270,6 +274,35 @@ namespace clang {
   };
 }
 
+bool clang::MayDefAffectABI(const Decl *D) {
+  if (auto *FD = dyn_cast(D)) {

tbaederr wrote:

```suggestion
  if (const auto *FD = dyn_cast(D)) {
```

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread Timm Baeder via cfe-commits


@@ -270,6 +274,35 @@ namespace clang {
   };
 }
 
+bool clang::MayDefAffectABI(const Decl *D) {
+  if (auto *FD = dyn_cast(D)) {
+if (FD->isInlined() || FD->isConstexpr())
+  return true;
+
+// Non-user-provided functions get emitted as weak definitions with every
+// use, no matter whether they've been explicitly instantiated etc.
+if (!FD->isUserProvided())
+  return true;
+
+if (FD->isDependentContext())
+  return true;
+
+if (FD->getTemplateSpecializationKind() == TSK_ImplicitInstantiation)
+  return true;
+  }
+
+  if (auto *VD = dyn_cast(D)) {

tbaederr wrote:

```suggestion
  if (const auto *VD = dyn_cast(D)) {
```

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


[flang] [clang] [mlir] [llvm] [lld] [ELF] Merge exportDynamic into versionId (PR #71272)

2023-11-07 Thread Alexander Richardson via cfe-commits

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


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


[mlir] [flang] [clang] [llvm] [lld] [ELF] Merge exportDynamic into versionId (PR #71272)

2023-11-07 Thread Alexander Richardson via cfe-commits


@@ -2518,9 +2521,9 @@ static void combineVersionedSymbol(Symbol &sym,
 sym.symbolKind = Symbol::PlaceholderKind;
 sym.isUsedInRegularObj = false;
   } else if (auto *sym1 = dyn_cast(&sym)) {
-if (sym2->versionId > VER_NDX_GLOBAL
-? config->versionDefinitions[sym2->versionId].name == suffix1 + 1
-: sym1->section == sym2->section && sym1->value == sym2->value) {
+if (sym2->versionId == VER_NDX_GLOBAL || sym2->versionId == nonExported

arichardson wrote:

In that case we should keep to the more common style. I think I just found it 
slightly harder to parse since I initially viewed this diff on mobile.

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


[mlir] [clang] [llvm] [flang] [lld] [ELF] Merge exportDynamic into versionId (PR #71272)

2023-11-07 Thread Alexander Richardson via cfe-commits

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


[PATCH] D158824: [RISCV][MC] MC layer support for xcvmem and xcvelw extensions

2023-11-07 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:2509
   // Attempt to parse token as a register.
-  if (parseRegister(Operands, true).isSuccess())
+  if (parseRegister(Operands, true).isSuccess()) {
+// Parse memory base register if present (CORE-V only)

Is it possible to use a custom parser instead of adding a special case to the 
generic parser?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158824

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


[clang] [llvm] [WebAssembly] Refactor Wasm Reference Types as TargetExtType (PR #71540)

2023-11-07 Thread Paulo Matos via cfe-commits

pmatos wrote:

> Very cool! LGTM so far. It's really nice that we can delete that entire pass 
> out of the backend. Where can I read more about these new target extension 
> types?

There's not a lot but there's something here:
https://llvm.org/docs/LangRef.html#target-extension-type

and of course, the api:
https://llvm.org/doxygen/classllvm_1_1TargetExtType.html

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


[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-07 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/71518

>From b12b8ef5b9cc65cabf14eeeb3dacd6f41e5bf54e Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Tue, 7 Nov 2023 16:44:05 +0800
Subject: [PATCH] [clang][analyzer] Support `fputc` in StreamChecker

---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 62 ---
 clang/test/Analysis/stream-error.c| 55 
 clang/test/Analysis/stream.c  | 14 +
 3 files changed, 123 insertions(+), 8 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 898906977ba9bb6..dd54d5d33a3faa4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -245,11 +245,14 @@ class StreamChecker : public CheckerStreamArgNo), C,
@@ -650,7 +656,7 @@ void StreamChecker::preFreadFwrite(const FnDescription 
*Desc,
   if (!State)
 return;
 
-  if (!IsFread) {
+  if (!IsRead) {
 C.addTransition(State);
 return;
   }
@@ -745,6 +751,46 @@ void StreamChecker::evalFreadFwrite(const FnDescription 
*Desc,
 C.addTransition(StateFailed);
 }
 
+void StreamChecker::evalFgetcFputc(const FnDescription *Desc,
+   const CallEvent &Call,
+   CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+  SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
+  if (!StreamSym)
+return;
+
+  const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  const StreamState *OldSS = State->get(StreamSym);
+  if (!OldSS)
+return;
+
+  assertStreamStateOpened(OldSS);
+
+  // `fputc` returns the written character on success, otherwise returns EOF.
+
+  // Generate a transition for the success state.
+  std::optional PutVal = Call.getArgSVal(0).getAs();
+  if (!PutVal)
+return;
+  ProgramStateRef StateNotFailed =
+  State->BindExpr(CE, C.getLocationContext(), *PutVal);
+  StateNotFailed =
+  StateNotFailed->set(StreamSym, StreamState::getOpened(Desc));
+  C.addTransition(StateNotFailed);
+
+  // Add transition for the failed state.
+  // If a (non-EOF) error occurs, the resulting value of the file position
+  // indicator for the stream is indeterminate.
+  ProgramStateRef StateFailed = bindInt(*EofVal, State, C, CE);
+  StreamState NewSS = StreamState::getOpened(
+  Desc, ErrorFError, /*IsFilePositionIndeterminate*/ true);
+  StateFailed = StateFailed->set(StreamSym, NewSS);
+  C.addTransition(StateFailed);
+}
+
 void StreamChecker::preFseek(const FnDescription *Desc, const CallEvent &Call,
  CheckerContext &C) const {
   ProgramStateRef State = C.getState();
diff --git a/clang/test/Analysis/stream-error.c 
b/clang/test/Analysis/stream-error.c
index 3c00e59bb6bd19d..5134be492696813 100644
--- a/clang/test/Analysis/stream-error.c
+++ b/clang/test/Analysis/stream-error.c
@@ -241,6 +241,23 @@ void error_indeterminate_clearerr(void) {
   fclose(F);
 }
 
+void error_indeterminate_fputc(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (feof(F)) {
+  fputc('X', F); // no warning
+} else if (ferror(F)) {
+  fputc('C', F); // expected-warning {{might be 'indeterminate'}}
+} else {
+  fputc('E', F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
 void error_indeterminate_feof1(void) {
   FILE *F = fopen("file", "r+");
   if (!F)
@@ -268,3 +285,41 @@ void error_indeterminate_feof2(void) {
   }
   fclose(F);
 }
+
+void error_indeterminate_feof3(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  char Buf[10];
+  if (fread(Buf, 1, 10, F) < 10) {
+if (feof(F)) {
+  // error is feof, should be non-indeterminate
+  fputc(';', F); // no warning
+}
+if (ferror(F)) {
+  fputc('=', F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
+void error_indeterminate_feof4(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  if (fputc('Y', F) == EOF) {
+fputc('W', F); // expected-warning {{might be 'indeterminate'}}
+  } else {
+fputc('H', F); // no warning
+  }
+  fclose(F);
+}
+
+void determinate_fputc(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  if (fputc('Q', F) == 'Q')
+fputc('X', F); // no warning
+  fclose(F);
+}
diff --git a/clang/test/Analysis/stream.c b/clang/test/Analysis/stream.c
index a01310cfef5dd8a..a2eaaa2bd0142c5 100644
--- a/clang/test/Analysis/stream.c
+++ b/clang/test/Analysis/stream.c
@@ -14,6 +14,12 @@ void check_fwrite(void) {
   fclose(fp);
 }
 
+void check_fgetc(void) {
+  FILE *fp = tmpfile();
+  fputc('A', fp); // expected-warning {{Stream pointer might be NULL}}
+  fclose(fp);
+}
+
 void check_fseek(void) {
   FILE *fp = tmpfile();
   fseek(fp, 0, 0); // expected-wa

[clang] [llvm] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread Wei Wang via cfe-commits


@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN: -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN: -O3 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-O
+
+#include "Inputs/coroutine.h"
+
+using namespace std;
+
+struct A;
+struct A_promise_type {
+  A get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_value(int);
+  void unhandled_exception();
+
+  std::coroutine_handle<> handle;
+};
+
+struct Awaitable{
+  bool await_ready();
+  int await_resume();
+  template 
+  void await_suspend(F);
+};
+Awaitable something();
+
+struct dtor {
+dtor();
+~dtor();
+};
+
+struct [[clang::coro_only_destroy_when_complete]] A {

apolloww wrote:

Since the attribute is on the return type, would that mean it would apply to 
any coroutine returning the particular type? Say user is using some library 
implementation (i.e. `folly::coro::Task`), they would not be able to use the 
attribute because it would mark all the coroutines this way.

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


[PATCH] D154396: [clang] Add support for SerenityOS

2023-11-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Serenity.h:61
+  bool isPICDefault() const override { return true; }
+  bool isPIEDefault(const llvm::opt::ArgList &) const override { return true; }
+  bool isPICDefaultForced() const override { return false; }

Test that the -cc1 line contains `"-pic-level" "2" "-pic-is-pie"`



Comment at: clang/lib/Driver/ToolChains/Serenity.h:68
+  getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const override {
+return UnwindTableLevel::Asynchronous;
+  }

Test that the -cc1 line contains `"-funwind-tables=2"`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154396

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


[PATCH] D154396: [clang] Add support for SerenityOS

2023-11-07 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/serenity.cpp:20
+// SERENITY_X86_64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
+// SERENITY_X86_64: "-pie"
+// SERENITY_X86_64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"

Prefer `-SAME:` whenever applicable

ditto below



Comment at: clang/test/Driver/serenity.cpp:159
+// DEFAULT_LIBCXX: "-z" "pack-relative-relocs"
+// DEFAULT_LIBCXX: "crt0.o" "crti.o" "crtbeginS.o"
+// DEFAULT_LIBCXX: "--push-state"

`TC.GetFilePath("crti.o")` returns a path to `crti.o` if `crti.o` is found, 
otherwise a raw `crti.o` without a patch component. The raw `crti.o` indicates 
that clang driver fails to find `crti.o` in a search path.

I think you need to change `--sysroot=` to pointer to a directory tree in 
`Inputs/` where `crti.o` can be found.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154396

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


[clang] [clang][Interp] Fix stack peek offset for This ptr (PR #70663)

2023-11-07 Thread Timm Baeder via cfe-commits

tbaederr wrote:

Ping

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


[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)

2023-11-07 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,185 @@
+//===-- CodeSnippetHighlighter.cpp - Code snippet highlighting --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Frontend/CodeSnippetHighlighter.h"
+#include "clang/Basic/CharInfo.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace clang;
+
+// Magenta is taken for 'warning'. Red is already 'error' and 'cyan'
+// is already taken for 'note'. Green is already used to underline
+// source ranges. White and black are bad because of the usual
+// terminal backgrounds. Which leaves us only with TWO options.
+static constexpr raw_ostream::Colors CommentColor = raw_ostream::YELLOW;
+static constexpr raw_ostream::Colors LiteralColor = raw_ostream::GREEN;
+static constexpr raw_ostream::Colors KeywordColor = raw_ostream::BLUE;
+/// Maximum size of file we still highlight.
+static constexpr size_t MaxBufferSize = 1024 * 1024; // 1MB.
+
+llvm::SmallVector CodeSnippetHighlighter::highlightLine(
+unsigned LineNumber, const Preprocessor *PP, const LangOptions &LangOpts,
+FileID FID, const SourceManager &SM, const char *LineStart) {
+  std::chrono::steady_clock::time_point begin =
+  std::chrono::steady_clock::now();
+
+  if (!PP)
+return {};
+

tbaederr wrote:

`Preprocessor*` is what's passed to `TextDiagnosticPrinter::BeginSourceFile()`, 
and there are a couple of places that pass `nullptr`, here an excerpt from `ag`:
```
../clang/lib/Frontend/FrontendAction.cpp
580:bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
699:CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
715:if (!BeginSourceFileAction(CI))
759:CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(), nullptr);
763:if (!BeginSourceFileAction(CI))
815:  CI.getDiagnosticClient().BeginSourceFile(CI.getLangOpts(),
914:  if (!BeginSourceFileAction(CI))
1207:bool WrapperFrontendAction::BeginSourceFileAction(CompilerInstance &CI) {
1210:  auto Ret = WrappedAction->BeginSourceFileAction(CI);
1211:  // BeginSourceFileAction may change CurrentInput, e.g. during module 
builds.

``

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


[clang-tools-extra] [clang] [llvm] [clang] Add support for new loop attribute [[clang::code_align()]] (PR #70762)

2023-11-07 Thread Erich Keane via cfe-commits

erichkeane wrote:

> @AaronBallman, @erichkeane I have addressed comments in the PR, could you 
> please revisit this PR? Thank you!

I'm still away at the WG21 meeting, but I've got this on my list of things to 
review when I return.

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


[clang] [clang][Diagnostics] Highlight code snippets (PR #66514)

2023-11-07 Thread Timm Baeder via cfe-commits
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= ,
Timm =?utf-8?q?Bäder?= 
Message-ID:
In-Reply-To: 



@@ -0,0 +1,187 @@
+//===-- CodeSnippetHighlighter.cpp - Code snippet highlighting --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Frontend/CodeSnippetHighlighter.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Lex/Lexer.h"
+#include "clang/Lex/Preprocessor.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace clang;
+
+static constexpr raw_ostream::Colors CommentColor = raw_ostream::GREEN;
+static constexpr raw_ostream::Colors LiteralColor = raw_ostream::CYAN;
+static constexpr raw_ostream::Colors KeywordColor = raw_ostream::BLUE;
+
+llvm::SmallVector CodeSnippetHighlighter::highlightLine(
+unsigned LineNumber, const Preprocessor *PP, const LangOptions &LangOpts,
+FileID FID, const SourceManager &SM, const char *LineStart) {
+  std::chrono::steady_clock::time_point begin =
+  std::chrono::steady_clock::now();
+
+  if (!PP)
+return {};
+
+  // Might cause emission of another diagnostic.
+  if (PP->getIdentifierTable().getExternalIdentifierLookup())
+return {};
+
+  size_t NTokens = 0;
+  // Classify the given token and append it to the given vector.
+  auto appendStyle = [PP, &LangOpts](llvm::SmallVector &Vec,
+ const Token &T, unsigned Start,
+ unsigned Length) -> void {
+if (T.is(tok::raw_identifier)) {
+  StringRef RawIdent = T.getRawIdentifier();
+  // Special case true/false/nullptr literals, since they will otherwise be
+  // treated as keywords.
+  if (RawIdent == "true" || RawIdent == "false" || RawIdent == "nullptr") {
+Vec.push_back(StyleRange{Start, Start + Length, LiteralColor});
+  } else {
+const IdentifierInfo *II = PP->getIdentifierInfo(RawIdent);
+assert(II);
+if (II->isKeyword(LangOpts))
+  Vec.push_back(StyleRange{Start, Start + Length, KeywordColor});
+  }
+} else if (tok::isLiteral(T.getKind())) {
+  Vec.push_back(StyleRange{Start, Start + Length, LiteralColor});
+} else {
+  assert(T.is(tok::comment));
+  Vec.push_back(StyleRange{Start, Start + Length, CommentColor});
+}
+  };
+
+  // Figure out where to start lexing from.
+  auto Buff = SM.getBufferOrNone(FID);
+  assert(Buff);
+  Lexer L = Lexer(FID, *Buff, SM, LangOpts);
+  L.SetKeepWhitespaceMode(true);
+
+  // Seek to the last save point before the start of the line.
+  if (const char *Save = PP->getSaveFor(LineStart);
+  Buff->getBufferStart() <= Save && Save < Buff->getBufferEnd()) {
+size_t Offset = Save - Buff->getBufferStart();
+assert(Save >= Buff->getBufferStart());
+assert(Save <= Buff->getBufferEnd());
+
+L.seek(Offset, /*IsAtStartOfLine=*/true);
+  }
+
+  llvm::SmallVector LineRanges;
+  bool Stop = false;
+  while (!Stop) {
+++NTokens;
+Token T;
+Stop = L.LexFromRawLexer(T);
+if (T.is(tok::unknown))
+  continue;
+
+// We are only interested in identifiers, literals and comments.
+if (!T.is(tok::raw_identifier) && !T.is(tok::comment) &&
+!tok::isLiteral(T.getKind()))
+  continue;
+
+bool Invalid = false;
+unsigned EndLine = SM.getSpellingLineNumber(T.getEndLoc(), &Invalid) - 1;
+if (Invalid)
+  continue;
+
+if (EndLine < LineNumber)
+  continue;
+unsigned StartLine =
+SM.getSpellingLineNumber(T.getLocation(), &Invalid) - 1;
+if (Invalid)
+  continue;
+if (StartLine > LineNumber)
+  break;
+
+// Must have an intersection at this point
+assert(StartLine <= LineNumber && EndLine >= LineNumber);
+
+unsigned StartCol =
+SM.getSpellingColumnNumber(T.getLocation(), &Invalid) - 1;
+if (Invalid)
+  continue;
+
+// Simple tokens.
+if (StartLine == EndLine) {
+  appendStyle(LineRanges, T, StartCol, T.getLength());
+  continue;
+}
+unsigned NumLines = EndLine - StartLine;
+assert(NumLines >= 1);
+
+// For tokens that span multiple lines (think multiline comments), we
+// divide them into multiple StyleRanges.
+unsigned EndCol = SM.getSpellingColum

[clang] c79b544 - [SEH] Fix assertin when return scalar value from __try block. (#71488)

2023-11-07 Thread via cfe-commits

Author: jyu2-git
Date: 2023-11-07T20:43:40-08:00
New Revision: c79b544d2b988e26f35db829088e0e5088c57498

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

LOG: [SEH] Fix assertin when return scalar value from __try block. (#71488)

Current compler assert with `!SI->isAtomic() && !SI->isVolatile()'
failed

This due to following rule:
First, no exception can move in or out of _try region., i.e., no
"potential faulty instruction can be moved across _try boundary. Second,
the order of exceptions for instructions 'directly' under a _try must be
preserved (not applied to those in callees). Finally, global states
(local/global/heap variables) that can be read outside of _try region
must be updated in memory (not just in register) before the subsequent
exception occurs.

All memory instructions inside a _try are considered as 'volatile' to
assure 2nd and 3rd rules for C-code above. This is a little
sub-optimized. But it's acceptable as the amount of code directly under
_try is very small. However during findDominatingStoreToReturnValue:
those are not allowed.

To fix just skip the assertion when current function has seh try.

Added: 


Modified: 
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index e7951b3a3f4d855..8fd876825b7ea08 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3507,7 +3507,9 @@ static llvm::StoreInst 
*findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
   return nullptr;
 // These aren't actually possible for non-coerced returns, and we
 // only care about non-coerced returns on this code path.
-assert(!SI->isAtomic() && !SI->isVolatile());
+// All memory instructions inside __try block are volatile.
+assert(!SI->isAtomic() &&
+   (!SI->isVolatile() || CGF.currentFunctionUsesSEHTry()));
 return SI;
   };
   // If there are multiple uses of the return-value slot, just check

diff  --git a/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp 
b/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
index fab567e763df443..ce2a9528e1908a9 100644
--- a/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
+++ b/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
@@ -67,3 +67,26 @@ void foo()
 }
   }
 }
+
+// CHECK-LABEL:@"?bar@@YAHXZ"()
+// CHECK: invoke.cont:
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke.cont1:
+// CHECK: store volatile i32 1, ptr %cleanup.dest.slot
+// CHECK: invoke void @llvm.seh.try.end()
+// CHECK: invoke.cont2:
+// CHECK: call void @"?fin$0@0@bar@@"
+// CHECK: %cleanup.dest3 = load i32, ptr %cleanup.dest.slot
+// CHECK: return:
+// CHECK: ret i32 11
+int bar()
+{
+  int x;
+  __try {
+return 11;
+  } __finally {
+if (_abnormal_termination()) {
+  x = 9;
+}
+  }
+}



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


[clang] [SEH] Fix assertin when return scalar value from __try block. (PR #71488)

2023-11-07 Thread via cfe-commits

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


[clang] [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options (PR #69133)

2023-11-07 Thread Amir Ayupov via cfe-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/69133

>From 1ca9ce9ef3e90e3d24aea3945ae2d5129682621d Mon Sep 17 00:00:00 2001
From: Amir Aupov 
Date: Mon, 16 Oct 2023 01:08:28 +0200
Subject: [PATCH 1/3] [Clang][CMake] Support perf, LBR, and Instrument
 CLANG_BOLT options

Split up and refactor CLANG_BOLT_INSTRUMENT into support for
perf no-LBR and perf with LBR profiling modes.

Differential Revision: https://reviews.llvm.org/D143617
---
 clang/CMakeLists.txt  | 44 -
 clang/cmake/caches/BOLT.cmake |  2 +-
 clang/utils/perf-training/CMakeLists.txt  | 29 -
 clang/utils/perf-training/bolt.lit.cfg| 53 +---
 .../utils/perf-training/bolt.lit.site.cfg.in  |  2 +
 clang/utils/perf-training/perf-helper.py  | 63 +++
 6 files changed, 167 insertions(+), 26 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 9b52c58be41e7f7..8f64d95cc394ffe 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -850,23 +850,38 @@ if (CLANG_ENABLE_BOOTSTRAP)
   endforeach()
 endif()
 
-if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
+set(CLANG_BOLT "INSTRUMENT" CACHE STRING "Apply BOLT optimization to Clang. \
+  May be specified as Instrument or Perf or LBR to use a particular profiling \
+  mechanism.")
+string(TOUPPER "${CLANG_BOLT}" uppercase_CLANG_BOLT)
+
+if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
   set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
-  set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
+  set(CLANG_INSTRUMENTED 
${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_BOLT_INSTRUMENTED})
   set(BOLT_FDATA ${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/prof.fdata)
 
-  # Instrument clang with BOLT
-  add_custom_target(clang-instrumented
-DEPENDS ${CLANG_INSTRUMENTED}
-  )
-  add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
-DEPENDS clang llvm-bolt
-COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
-  -instrument --instrumentation-file-append-pid
-  --instrumentation-file=${BOLT_FDATA}
-COMMENT "Instrumenting clang binary with BOLT"
-VERBATIM
-  )
+  # Pass extra flag in no-LBR mode
+  if (uppercase_CLANG_BOLT STREQUAL "PERF")
+set(BOLT_NO_LBR "-nl")
+  endif()
+
+  if (uppercase_CLANG_BOLT STREQUAL "INSTRUMENT")
+# Instrument clang with BOLT
+add_custom_target(clang-instrumented
+  DEPENDS ${CLANG_INSTRUMENTED}
+)
+add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
+  DEPENDS clang llvm-bolt
+  COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
+-instrument --instrumentation-file-append-pid
+--instrumentation-file=${BOLT_FDATA}
+  COMMENT "Instrumenting clang binary with BOLT"
+  VERBATIM
+)
+add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented)
+  else() # perf or LBR
+add_custom_target(clang-bolt-training-deps DEPENDS clang)
+  endif()
 
   # Optimize original (pre-bolt) Clang using the collected profile
   set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
@@ -880,6 +895,7 @@ if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   -data ${BOLT_FDATA}
   -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
   -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
+  ${BOLT_NO_LBR}
 COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $
 COMMENT "Optimizing Clang with BOLT"
 VERBATIM
diff --git a/clang/cmake/caches/BOLT.cmake b/clang/cmake/caches/BOLT.cmake
index 0442f73e5426ac7..eba2346b2f4ca12 100644
--- a/clang/cmake/caches/BOLT.cmake
+++ b/clang/cmake/caches/BOLT.cmake
@@ -1,5 +1,5 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
-set(CLANG_BOLT_INSTRUMENT ON CACHE BOOL "")
+set(CLANG_BOLT "INSTRUMENT" CACHE STRING "")
 set(CMAKE_EXE_LINKER_FLAGS "-Wl,--emit-relocs,-znow" CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "")
diff --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index c6d51863fb1b5c2..48fbee62a8636d1 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -62,7 +62,9 @@ if(APPLE AND DTRACE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
 DEPENDS generate-dtrace-logs)
 endif()
 
-if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
+if(CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
+  set(CLANG_BOLT_INSTRUMENTED "clang-bolt.inst" CACHE STRING
+"Name of BOLT-instrumented Clang binary")
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/bolt.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/lit.site.cfg
@@ -71,16 +73,37 @@ if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-bolt-fdata "Generating BOLT profile for Clang"
 ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang-instrumented clear-bolt-fdata
+DEPENDS clang-bolt-training-deps clear-bol

[clang] [clang][dataflow] Expand debug dumping of `Value`s. (PR #71527)

2023-11-07 Thread via cfe-commits

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


[clang] 64ed4ed - [clang][dataflow] Expand debug dumping of `Value`s. (#71527)

2023-11-07 Thread via cfe-commits

Author: martinboehme
Date: 2023-11-08T05:41:26+01:00
New Revision: 64ed4edca8e76e2ce2586584fdcb3b906532aa18

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

LOG: [clang][dataflow] Expand debug dumping of `Value`s. (#71527)

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Value.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Value.cpp 
b/clang/lib/Analysis/FlowSensitive/Value.cpp
index b069c1cd3da1171..80dde7c8d582358 100644
--- a/clang/lib/Analysis/FlowSensitive/Value.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Value.cpp
@@ -34,13 +34,18 @@ bool areEquivalentValues(const Value &Val1, const Value 
&Val2) {
 
 raw_ostream &operator<<(raw_ostream &OS, const Value &Val) {
   switch (Val.getKind()) {
-  case Value::Kind::Pointer: {
-const auto *PV = dyn_cast(&Val);
-return OS << "Pointer(" << &PV->getPointeeLoc() << ")";
-  }
-  // FIXME: support remaining cases.
-  default:
-return OS << debugString(Val.getKind());
+  case Value::Kind::Integer:
+return OS << "Integer(@" << &Val << ")";
+  case Value::Kind::Pointer:
+return OS << "Pointer(" << &cast(Val).getPointeeLoc() << ")";
+  case Value::Kind::Record:
+return OS << "Record(" << &cast(Val).getLoc() << ")";
+  case Value::Kind::TopBool:
+return OS << "TopBool(" << cast(Val).getAtom() << ")";
+  case Value::Kind::AtomicBool:
+return OS << "AtomicBool(" << cast(Val).getAtom() << ")";
+  case Value::Kind::FormulaBool:
+return OS << "FormulaBool(" << cast(Val).formula() << 
")";
   }
 }
 



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


[llvm] [clang] Remove experimental from Vector Crypto extensions (PR #69000)

2023-11-07 Thread Brandon Wu via cfe-commits


@@ -106,6 +106,8 @@ static const RISCVSupportedExtension SupportedExtensions[] 
= {
 
 {"zdinx", RISCVExtensionVersion{1, 0}},
 
+{"zexperimental", RISCVExtensionVersion{1, 0}},
+

4vtomat wrote:

No, we don't~

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


[llvm] [clang] Remove experimental from Vector Crypto extensions (PR #69000)

2023-11-07 Thread Brandon Wu via cfe-commits

4vtomat wrote:

> > Since it's possible that **ISA spec** and **intrinsics spec** are not 
> > synchronized, so the updates add an dummy extension called 
> > **zexperimental**, once `-menable-experimental-extensions` is specified, 
> > the feature `zexperimental` is automatically added.
> > If `let RequiredFeatures = ["Zexperimental"] ` is added in `.td` file, it 
> > will check if `zexperimental` exists, if not, the corresponding intrinsics 
> > would not be added, hence causing an **intrinsics undeclared** error.
> 
> Thanks for looking into this. It's perhaps surprising we've gone so long 
> without having the infrastructure to make an extension non-experimental 
> without making its not-yet-finalized intrinsics non-experimental. Introducing 
> a new required feature seems like a reasonable way of doing this, but 
> introducing a dummy extension seems unnecessary (unless I'm missing 
> something?).
> 
> I could see a solution involving a Clang flag (e.g. 
> `-menable-experimental-intrinsics`), or perhaps a solution where the user 
> must use a certain `#define` (I know riscv_vector.h is implemented using a 
> pragma, but presumably that could still query defines). There may be other 
> options too.
> 
> Another piece of info that would be helpful to better understand is what the 
> process is for finalising intrinsic additions (@eopXD might know?). If it's 
> just the case that we have to wait another month before moving an extension 
> from experimental to experimental then maybe extra infro to separate 
> experimental intrinsics from instructions is less interesting. If it's more 
> indeterminate than that, we probably need it.
> 
> I'll put this on the agenda for Thursday's RISC-V LLVM sync-up call in the 
> hope we can resolve it there.

Yeah, we don't need a new extension actually, thanks for pointing out!

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


[clang] [clang][dataflow] Replace one remaining call to deprecated `addToFlowCondition()`. (PR #71547)

2023-11-07 Thread via cfe-commits

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


[clang] a070053 - [clang][dataflow] Replace one remaining call to deprecated `addToFlowCondition()`. (#71547)

2023-11-07 Thread via cfe-commits

Author: martinboehme
Date: 2023-11-08T05:32:04+01:00
New Revision: a0700532ddcc850ff381e08576590ee26fad1f1e

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

LOG: [clang][dataflow] Replace one remaining call to deprecated 
`addToFlowCondition()`. (#71547)

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 2b000eb7b370868..a1051c529ab0d58 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -115,7 +115,7 @@ static Value *mergeDistinctValues(QualType Type, Value 
&Val1,
 auto &Expr2 = cast(Val2).formula();
 auto &A = MergedEnv.arena();
 auto &MergedVal = A.makeAtomRef(A.makeAtom());
-MergedEnv.addToFlowCondition(
+MergedEnv.assume(
 A.makeOr(A.makeAnd(A.makeAtomRef(Env1.getFlowConditionToken()),
A.makeEquals(MergedVal, Expr1)),
  A.makeAnd(A.makeAtomRef(Env2.getFlowConditionToken()),



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


[clang] [Clang][CMake] Support perf, LBR, and Instrument CLANG_BOLT options (PR #69133)

2023-11-07 Thread Amir Ayupov via cfe-commits

https://github.com/aaupov updated 
https://github.com/llvm/llvm-project/pull/69133

>From 96e644279ccec1970c42cca89c05aac186b872e6 Mon Sep 17 00:00:00 2001
From: Amir Aupov 
Date: Mon, 16 Oct 2023 01:08:28 +0200
Subject: [PATCH 1/3] [Clang][CMake] Support perf, LBR, and Instrument
 CLANG_BOLT options

Split up and refactor CLANG_BOLT_INSTRUMENT into support for
perf no-LBR and perf with LBR profiling modes.

Differential Revision: https://reviews.llvm.org/D143617
---
 clang/CMakeLists.txt  | 44 -
 clang/cmake/caches/BOLT.cmake |  2 +-
 clang/utils/perf-training/CMakeLists.txt  | 29 -
 clang/utils/perf-training/bolt.lit.cfg| 53 +---
 .../utils/perf-training/bolt.lit.site.cfg.in  |  2 +
 clang/utils/perf-training/perf-helper.py  | 63 +++
 6 files changed, 167 insertions(+), 26 deletions(-)

diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 9b52c58be41e7f7..8f64d95cc394ffe 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -850,23 +850,38 @@ if (CLANG_ENABLE_BOOTSTRAP)
   endforeach()
 endif()
 
-if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
+set(CLANG_BOLT "INSTRUMENT" CACHE STRING "Apply BOLT optimization to Clang. \
+  May be specified as Instrument or Perf or LBR to use a particular profiling \
+  mechanism.")
+string(TOUPPER "${CLANG_BOLT}" uppercase_CLANG_BOLT)
+
+if (CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
   set(CLANG_PATH ${LLVM_RUNTIME_OUTPUT_INTDIR}/clang)
-  set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
+  set(CLANG_INSTRUMENTED 
${LLVM_RUNTIME_OUTPUT_INTDIR}/${CLANG_BOLT_INSTRUMENTED})
   set(BOLT_FDATA ${CMAKE_CURRENT_BINARY_DIR}/utils/perf-training/prof.fdata)
 
-  # Instrument clang with BOLT
-  add_custom_target(clang-instrumented
-DEPENDS ${CLANG_INSTRUMENTED}
-  )
-  add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
-DEPENDS clang llvm-bolt
-COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
-  -instrument --instrumentation-file-append-pid
-  --instrumentation-file=${BOLT_FDATA}
-COMMENT "Instrumenting clang binary with BOLT"
-VERBATIM
-  )
+  # Pass extra flag in no-LBR mode
+  if (uppercase_CLANG_BOLT STREQUAL "PERF")
+set(BOLT_NO_LBR "-nl")
+  endif()
+
+  if (uppercase_CLANG_BOLT STREQUAL "INSTRUMENT")
+# Instrument clang with BOLT
+add_custom_target(clang-instrumented
+  DEPENDS ${CLANG_INSTRUMENTED}
+)
+add_custom_command(OUTPUT ${CLANG_INSTRUMENTED}
+  DEPENDS clang llvm-bolt
+  COMMAND llvm-bolt ${CLANG_PATH} -o ${CLANG_INSTRUMENTED}
+-instrument --instrumentation-file-append-pid
+--instrumentation-file=${BOLT_FDATA}
+  COMMENT "Instrumenting clang binary with BOLT"
+  VERBATIM
+)
+add_custom_target(clang-bolt-training-deps DEPENDS clang-instrumented)
+  else() # perf or LBR
+add_custom_target(clang-bolt-training-deps DEPENDS clang)
+  endif()
 
   # Optimize original (pre-bolt) Clang using the collected profile
   set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
@@ -880,6 +895,7 @@ if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   -data ${BOLT_FDATA}
   -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
   -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
+  ${BOLT_NO_LBR}
 COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $
 COMMENT "Optimizing Clang with BOLT"
 VERBATIM
diff --git a/clang/cmake/caches/BOLT.cmake b/clang/cmake/caches/BOLT.cmake
index 0442f73e5426ac7..eba2346b2f4ca12 100644
--- a/clang/cmake/caches/BOLT.cmake
+++ b/clang/cmake/caches/BOLT.cmake
@@ -1,5 +1,5 @@
 set(CMAKE_BUILD_TYPE Release CACHE STRING "")
-set(CLANG_BOLT_INSTRUMENT ON CACHE BOOL "")
+set(CLANG_BOLT "INSTRUMENT" CACHE STRING "")
 set(CMAKE_EXE_LINKER_FLAGS "-Wl,--emit-relocs,-znow" CACHE STRING "")
 
 set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "")
diff --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index c6d51863fb1b5c2..48fbee62a8636d1 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -62,7 +62,9 @@ if(APPLE AND DTRACE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
 DEPENDS generate-dtrace-logs)
 endif()
 
-if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
+if(CLANG_BOLT AND NOT LLVM_BUILD_INSTRUMENTED)
+  set(CLANG_BOLT_INSTRUMENTED "clang-bolt.inst" CACHE STRING
+"Name of BOLT-instrumented Clang binary")
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/bolt.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/lit.site.cfg
@@ -71,16 +73,37 @@ if(CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   add_lit_testsuite(generate-bolt-fdata "Generating BOLT profile for Clang"
 ${CMAKE_CURRENT_BINARY_DIR}/bolt-fdata/
 EXCLUDE_FROM_CHECK_ALL
-DEPENDS clang-instrumented clear-bolt-fdata
+DEPENDS clang-bolt-training-deps clear-bol

[clang] [C++20] [Modules] Bring Decls Hash to BMI for C++20 Module units (PR #71627)

2023-11-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Chuanqi Xu (ChuanqiXu9)


Changes

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

This contains https://github.com/llvm/llvm-project/pull/71622 and so that it is 
not easy to review this until we have stacked reviews. So the main purpose of 
current patch now is to have a feeling about what we want to do.

The motivating example is:

```
// a.cppm
export module a;
export int a() {
return 43;
}

// use.cc
import a;
int use() {
return a();
}
```


After we change the implementation of a() from return 43; to return 44;, we can 
avoid recompiling use.cc to use.o since the interface doesn't change.

To be continued

---

Patch is 157.49 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/71627.diff


122 Files Affected:

- (modified) clang/include/clang/AST/ODRHash.h (+3) 
- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+2) 
- (modified) clang/include/clang/Driver/Options.td (+11-1) 
- (modified) clang/include/clang/Frontend/FrontendActions.h (+45-7) 
- (modified) clang/include/clang/Frontend/FrontendOptions.h (+11-1) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+10) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+33-2) 
- (modified) clang/lib/AST/ODRHash.cpp (+2) 
- (modified) clang/lib/Driver/Driver.cpp (+12-2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+6-1) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+4) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+82-16) 
- (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+4) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+75) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+28-14) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+167-7) 
- (modified) clang/lib/Serialization/GeneratePCH.cpp (+35-2) 
- (modified) clang/test/CXX/basic/basic.link/p10-ex2.cpp (+2-1) 
- (modified) 
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
 (+4-2) 
- (added) clang/test/Driver/thinBMI-output.cppm (+29) 
- (modified) clang/test/Modules/InheritDefaultArguments.cppm (+3) 
- (modified) clang/test/Modules/Reachability-Private.cpp (+10) 
- (modified) clang/test/Modules/Reachability-func-default-arg.cpp (+3) 
- (modified) clang/test/Modules/Reachability-func-ret.cpp (+3) 
- (modified) clang/test/Modules/Reachability-template-default-arg.cpp (+3) 
- (modified) clang/test/Modules/Reachability-template-instantiation.cpp (+4) 
- (modified) clang/test/Modules/Reachability-using-templates.cpp (+3) 
- (modified) clang/test/Modules/Reachability-using.cpp (+3) 
- (modified) clang/test/Modules/concept.cppm (+4) 
- (modified) clang/test/Modules/concept_differ.cppm (+5) 
- (modified) clang/test/Modules/ctor.arg.dep.cppm (+4) 
- (modified) clang/test/Modules/cxx20-10-1-ex1.cpp (+13) 
- (modified) clang/test/Modules/cxx20-10-1-ex2.cpp (+30-6) 
- (modified) clang/test/Modules/cxx20-10-2-ex2.cpp (+12) 
- (modified) clang/test/Modules/cxx20-10-2-ex5.cpp (+12) 
- (modified) clang/test/Modules/cxx20-10-3-ex1.cpp (+14) 
- (modified) clang/test/Modules/cxx20-10-3-ex2.cpp (+10) 
- (modified) clang/test/Modules/cxx20-10-5-ex1.cpp (+12) 
- (modified) clang/test/Modules/cxx20-import-diagnostics-a.cpp (+39) 
- (modified) clang/test/Modules/cxx20-import-diagnostics-b.cpp (+25) 
- (modified) clang/test/Modules/cxx20-module-file-info-macros.cpp (+3) 
- (modified) clang/test/Modules/cxx20-module-file-info.cpp (+3) 
- (added) clang/test/Modules/decls-hash-get-bmi-decls-hash.cppm (+35) 
- (added) clang/test/Modules/decls-hash-module-file-info.cppm (+35) 
- (modified) clang/test/Modules/deduction-guide.cppm (+3) 
- (modified) clang/test/Modules/deduction-guide2.cppm (+3) 
- (modified) clang/test/Modules/deduction-guide3.cppm (+3) 
- (modified) clang/test/Modules/derived_class.cpp (+3) 
- (modified) clang/test/Modules/duplicated-module-file-eq-module-name.cppm (+4) 
- (modified) clang/test/Modules/enum-class.cppm (+3) 
- (modified) clang/test/Modules/explicitly-specialized-template.cpp (+3) 
- (modified) clang/test/Modules/export-language-linkage.cppm (+5) 
- (modified) clang/test/Modules/ftime-trace.cppm (+9) 
- (modified) clang/test/Modules/inconsistent-deduction-guide-linkage.cppm (+6) 
- (modified) clang/test/Modules/inconsistent-export.cppm (+13) 
- (modified) clang/test/Modules/inherited_arg.cppm (+11) 
- (modified) clang/test/Modules/instantiation-argdep-lookup.cppm (+3) 
- (modified) clang/test/Modules/lambdas.cppm (+15) 
- (modified) clang/test/Modules/merge-concepts-cxx-modules.cpp (+12) 
- (modified) clang/test/Modules/merge-constrained-friends.cpp (+3) 
- (modified) clang/test/Modules/merge-lambdas.cppm (+4) 
- (modified) clang/test/Modules/merge-requires-with-lambdas.cppm (+19) 
- (modified) clang/test/Modules/merge-var-template-spec-cxx-modules.cppm (+5) 
- (modified) clang/test/Modules/

[clang] [C++20] [Modules] Bring Decls Hash to BMI for C++20 Module units (PR #71627)

2023-11-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Chuanqi Xu (ChuanqiXu9)


Changes

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

This contains https://github.com/llvm/llvm-project/pull/71622 and so that it is 
not easy to review this until we have stacked reviews. So the main purpose of 
current patch now is to have a feeling about what we want to do.

The motivating example is:

```
// a.cppm
export module a;
export int a() {
return 43;
}

// use.cc
import a;
int use() {
return a();
}
```


After we change the implementation of a() from return 43; to return 44;, we can 
avoid recompiling use.cc to use.o since the interface doesn't change.

To be continued

---

Patch is 157.49 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/71627.diff


122 Files Affected:

- (modified) clang/include/clang/AST/ODRHash.h (+3) 
- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+2) 
- (modified) clang/include/clang/Driver/Options.td (+11-1) 
- (modified) clang/include/clang/Frontend/FrontendActions.h (+45-7) 
- (modified) clang/include/clang/Frontend/FrontendOptions.h (+11-1) 
- (modified) clang/include/clang/Serialization/ASTBitCodes.h (+3) 
- (modified) clang/include/clang/Serialization/ASTReader.h (+10) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+33-2) 
- (modified) clang/lib/AST/ODRHash.cpp (+2) 
- (modified) clang/lib/Driver/Driver.cpp (+12-2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+6-1) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+4) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+82-16) 
- (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+4) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+75) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+28-14) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+167-7) 
- (modified) clang/lib/Serialization/GeneratePCH.cpp (+35-2) 
- (modified) clang/test/CXX/basic/basic.link/p10-ex2.cpp (+2-1) 
- (modified) 
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
 (+4-2) 
- (added) clang/test/Driver/thinBMI-output.cppm (+29) 
- (modified) clang/test/Modules/InheritDefaultArguments.cppm (+3) 
- (modified) clang/test/Modules/Reachability-Private.cpp (+10) 
- (modified) clang/test/Modules/Reachability-func-default-arg.cpp (+3) 
- (modified) clang/test/Modules/Reachability-func-ret.cpp (+3) 
- (modified) clang/test/Modules/Reachability-template-default-arg.cpp (+3) 
- (modified) clang/test/Modules/Reachability-template-instantiation.cpp (+4) 
- (modified) clang/test/Modules/Reachability-using-templates.cpp (+3) 
- (modified) clang/test/Modules/Reachability-using.cpp (+3) 
- (modified) clang/test/Modules/concept.cppm (+4) 
- (modified) clang/test/Modules/concept_differ.cppm (+5) 
- (modified) clang/test/Modules/ctor.arg.dep.cppm (+4) 
- (modified) clang/test/Modules/cxx20-10-1-ex1.cpp (+13) 
- (modified) clang/test/Modules/cxx20-10-1-ex2.cpp (+30-6) 
- (modified) clang/test/Modules/cxx20-10-2-ex2.cpp (+12) 
- (modified) clang/test/Modules/cxx20-10-2-ex5.cpp (+12) 
- (modified) clang/test/Modules/cxx20-10-3-ex1.cpp (+14) 
- (modified) clang/test/Modules/cxx20-10-3-ex2.cpp (+10) 
- (modified) clang/test/Modules/cxx20-10-5-ex1.cpp (+12) 
- (modified) clang/test/Modules/cxx20-import-diagnostics-a.cpp (+39) 
- (modified) clang/test/Modules/cxx20-import-diagnostics-b.cpp (+25) 
- (modified) clang/test/Modules/cxx20-module-file-info-macros.cpp (+3) 
- (modified) clang/test/Modules/cxx20-module-file-info.cpp (+3) 
- (added) clang/test/Modules/decls-hash-get-bmi-decls-hash.cppm (+35) 
- (added) clang/test/Modules/decls-hash-module-file-info.cppm (+35) 
- (modified) clang/test/Modules/deduction-guide.cppm (+3) 
- (modified) clang/test/Modules/deduction-guide2.cppm (+3) 
- (modified) clang/test/Modules/deduction-guide3.cppm (+3) 
- (modified) clang/test/Modules/derived_class.cpp (+3) 
- (modified) clang/test/Modules/duplicated-module-file-eq-module-name.cppm (+4) 
- (modified) clang/test/Modules/enum-class.cppm (+3) 
- (modified) clang/test/Modules/explicitly-specialized-template.cpp (+3) 
- (modified) clang/test/Modules/export-language-linkage.cppm (+5) 
- (modified) clang/test/Modules/ftime-trace.cppm (+9) 
- (modified) clang/test/Modules/inconsistent-deduction-guide-linkage.cppm (+6) 
- (modified) clang/test/Modules/inconsistent-export.cppm (+13) 
- (modified) clang/test/Modules/inherited_arg.cppm (+11) 
- (modified) clang/test/Modules/instantiation-argdep-lookup.cppm (+3) 
- (modified) clang/test/Modules/lambdas.cppm (+15) 
- (modified) clang/test/Modules/merge-concepts-cxx-modules.cpp (+12) 
- (modified) clang/test/Modules/merge-constrained-friends.cpp (+3) 
- (modified) clang/test/Modules/merge-lambdas.cppm (+4) 
- (modified) clang/test/Modules/merge-requires-with-lambdas.cppm (+19) 
- (modified) clang/test/Modules/merge-var-template-spec-cxx-modules.cppm (+5) 
- (modified) clang/test/M

[clang] [C++20] [Modules] Bring Decls Hash to BMI for C++20 Module units (PR #71627)

2023-11-07 Thread Chuanqi Xu via cfe-commits

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-11-07 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D144006#4656383 , @dzhidzhoev 
wrote:

> In D144006#4656371 , @aeubanks 
> wrote:
>
>> Is there any issue with mixing IR built with 
>> `LLVMContext::enableDebugTypeODRUniquing()` and without? I'm suspecting that 
>> ThinLTO is mixing Rust and Clang IR which set that differently.
>
> Apparently, it's an issue with ThinLTO that might be caused by a change in 
> MetadataLoader https://github.com/llvm/llvm-project/pull/68986.
> Is there a way to get a repro like this one 
> https://bugs.chromium.org/p/chromium/issues/detail?id=1487910#c3 if it's not 
> too complicated?

I've shared the repro tar with your commit email address, sorry it's so big. I 
tried linking again with the revert and now it looks like the debug info 
verifier is firing instead. Do you also need a repro tar with everything built 
with the revert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits


@@ -0,0 +1,137 @@
+; RUN: opt < %s -passes='cgscc(coro-split),early-cse,dce,simplifycfg' -S | 
FileCheck %s
+
+%"struct.std::__n4861::noop_coroutine_promise" = type { i8 }
+%struct.Promise = type { %"struct.std::__n4861::coroutine_handle" }
+%"struct.std::__n4861::coroutine_handle" = type { ptr }
+
+define ptr @foo() #1 {
+entry:
+  %__promise = alloca %struct.Promise, align 8
+  %0 = call token @llvm.coro.id(i32 16, ptr nonnull %__promise, ptr nonnull 
@foo, ptr null)
+  %1 = call i1 @llvm.coro.alloc(token %0)
+  br i1 %1, label %coro.alloc, label %init.suspend
+
+coro.alloc:   ; preds = %entry
+  %2 = tail call i64 @llvm.coro.size.i64()
+  %call = call noalias noundef nonnull ptr @_Znwm(i64 noundef %2) #11
+  br label %init.suspend
+
+init.suspend: ; preds = %entry, %coro.alloc
+  %3 = phi ptr [ null, %entry ], [ %call, %coro.alloc ]
+  %4 = call ptr @llvm.coro.begin(token %0, ptr %3) #12
+  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %__promise) #3
+  store ptr null, ptr %__promise, align 8
+  %5 = call token @llvm.coro.save(ptr null)
+  %6 = call i8 @llvm.coro.suspend(token %5, i1 false)
+  switch i8 %6, label %coro.ret [
+  i8 0, label %await.suspend
+  i8 1, label %cleanup1
+  ]
+
+await.suspend:; preds = %init.suspend
+  %7 = call token @llvm.coro.save(ptr null)
+  %8 = call i8 @llvm.coro.suspend(token %7, i1 false)
+  switch i8 %8, label %coro.ret [
+  i8 0, label %await2.suspend
+  i8 1, label %cleanup2
+  ]
+
+await2.suspend:   ; preds = %await.suspend
+  %call27 = call ptr @_Z5Innerv() #3
+  %9 = call token @llvm.coro.save(ptr null)
+  %10 = getelementptr inbounds i8, ptr %__promise, i64 -16
+  store ptr %10, ptr %call27, align 8
+  %11 = getelementptr inbounds i8, ptr %call27, i64 -16
+  %12 = call ptr @llvm.coro.subfn.addr(ptr nonnull %11, i8 0)
+  call fastcc void %12(ptr nonnull %11) #3
+  %13 = call i8 @llvm.coro.suspend(token %9, i1 false)
+  switch i8 %13, label %coro.ret [
+  i8 0, label %final.suspend
+  i8 1, label %cleanup3
+  ]
+
+final.suspend:; preds = %await2.suspend
+  %14 = call ptr @llvm.coro.subfn.addr(ptr nonnull %11, i8 1)
+  call fastcc void %14(ptr nonnull %11) #3
+  %15 = call token @llvm.coro.save(ptr null)
+  %retval.sroa.0.0.copyload.i = load ptr, ptr %__promise, align 8
+  %16 = call ptr @llvm.coro.subfn.addr(ptr %retval.sroa.0.0.copyload.i, i8 0)
+  call fastcc void %16(ptr %retval.sroa.0.0.copyload.i) #3
+  %17 = call i8 @llvm.coro.suspend(token %15, i1 true) #12
+  switch i8 %17, label %coro.ret [
+  i8 0, label %final.ready
+  i8 1, label %cleanup62
+  ]
+
+final.ready:  ; preds = %final.suspend
+  call void @exit(i32 noundef 1)
+  unreachable
+
+cleanup1:
+  call void @dtor1()
+  br label %cleanup62
+
+cleanup2:
+  call void @dtor2()
+  br label %cleanup62
+
+cleanup3:
+  call void @dtor3()
+  br label %cleanup62
+
+cleanup62:; preds = %await2.suspend, 
%await.suspend, %init.suspend, %final.suspend
+  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %__promise) #3
+  %18 = call ptr @llvm.coro.free(token %0, ptr %4)
+  %.not = icmp eq ptr %18, null
+  br i1 %.not, label %coro.ret, label %coro.free
+
+coro.free:; preds = %cleanup62
+  call void @_ZdlPv(ptr noundef nonnull %18) #3
+  br label %coro.ret
+
+coro.ret: ; preds = %coro.free, 
%cleanup62, %final.suspend, %await2.suspend, %await.suspend, %init.suspend
+  %19 = call i1 @llvm.coro.end(ptr null, i1 false, token none) #12
+  ret ptr %__promise
+}
+
+declare token @llvm.coro.id(i32, ptr readnone, ptr nocapture readonly, ptr) #2
+declare i1 @llvm.coro.alloc(token) #3
+declare dso_local noundef nonnull ptr @_Znwm(i64 noundef) local_unnamed_addr #4
+declare i64 @llvm.coro.size.i64() #5
+declare ptr @llvm.coro.begin(token, ptr writeonly) #3
+declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #6
+declare token @llvm.coro.save(ptr) #7
+declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #6
+declare i8 @llvm.coro.suspend(token, i1) #3
+declare ptr @_Z5Innerv() local_unnamed_addr
+declare dso_local void @_ZdlPv(ptr noundef) local_unnamed_addr #8
+declare ptr @llvm.coro.free(token, ptr nocapture readonly) #2
+declare i1 @llvm.coro.end(ptr, i1, token) #3
+declare void @exit(i32 noundef)
+declare ptr @llvm.coro.subfn.addr(ptr nocapture readonly, i8) #10
+declare void @dtor1()
+declare void @dtor2()
+declare void @dtor3()
+
+attributes #0 = { mustprogress nounwind uwtable }
+attributes #1 = { nounwind presplitcoroutine uwtable 
coro_only_destroy_when_done }

h-vetinari wrote:

still `_done` not `_complete`

https://github.com/llvm/llvm-project/pull/71014
___
cfe-commits mailing list
cfe-

[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits




h-vetinari wrote:

filename still has `-done` not `-complete`

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits


@@ -718,6 +718,7 @@ enum AttributeKindCodes {
   ATTR_KIND_NOFPCLASS = 87,
   ATTR_KIND_OPTIMIZE_FOR_DEBUGGING = 88,
   ATTR_KIND_WRITABLE = 89,
+  ATTR_KIND_CORO_ONLY_DESTROY_WHEN_DONE = 90,

h-vetinari wrote:

still `_DONE` not `_COMPLETE` (plus all later usages of it).

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits


@@ -318,6 +318,9 @@ def MustProgress : EnumAttr<"mustprogress", [FnAttr]>;
 /// Function is a presplit coroutine.
 def PresplitCoroutine : EnumAttr<"presplitcoroutine", [FnAttr]>;
 
+/// The coroutine would only be destroyed when it is done.
+def CoroDestroyOnlyWhenComplete : EnumAttr<"coro_only_destroy_when_done", 
[FnAttr]>;

h-vetinari wrote:

still `_done` not `_complete`

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


[clang] [llvm] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits

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


[clang] [llvm] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits


@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN: -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
+// RUN: -O3 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK-O
+
+#include "Inputs/coroutine.h"
+
+using namespace std;
+
+struct A;
+struct A_promise_type {
+  A get_return_object();
+  suspend_always initial_suspend();
+  suspend_always final_suspend() noexcept;
+  void return_value(int);
+  void unhandled_exception();
+
+  std::coroutine_handle<> handle;
+};
+
+struct Awaitable{
+  bool await_ready();
+  int await_resume();
+  template 
+  void await_suspend(F);
+};
+Awaitable something();
+
+struct dtor {
+dtor();
+~dtor();
+};
+
+struct [[clang::coro_only_destroy_when_complete]] A {
+  using promise_type = A_promise_type;
+  A();
+  A(std::coroutine_handle<>);
+  ~A();
+
+  std::coroutine_handle handle;
+};
+
+A foo() {
+dtor d;
+co_await something();
+dtor d1;
+co_await something();
+dtor d2;
+co_return 43;
+}
+
+// CHECK: define{{.*}}@_Z3foov({{.*}}) #[[ATTR_NUM:[0-9]+]]
+// CHECK: attributes #[[ATTR_NUM]] = {{.*}}coro_only_destroy_when_done

h-vetinari wrote:

still `_done` not `_complete`

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


[clang] [llvm] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits

https://github.com/h-vetinari commented:

> > Presumably there should only be one spelling everywhere.
>
> Done

Missed a few. ;-)

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread via cfe-commits


@@ -1775,6 +1775,17 @@ CoroCleanup
 This pass runs late to lower all coroutine related intrinsics not replaced by
 earlier passes.
 
+Attributes
+==
+
+coro_only_destroy_when_done
+---
+
+When the coroutine are marked with coro_only_destroy_when_done, it indicates

h-vetinari wrote:

still `_done` not `_complete`

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


[clang] [SEH] Fix assertin when return scalar value from __try block. (PR #71488)

2023-11-07 Thread Reid Kleckner via cfe-commits

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

Thanks!

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


[clang] Avoid copying Param and Constr (PR #65488)

2023-11-07 Thread Chris B via cfe-commits

https://github.com/llvm-beanz approved this pull request.


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


[clang] [clang][DependencyScanner] Remove all warning flags when suppressing warnings (PR #71612)

2023-11-07 Thread Jan Svoboda via cfe-commits


@@ -0,0 +1,84 @@
+// RUN: rm -rf %t

jansvoboda11 wrote:

Could you add a short summary of what this test is for?

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


[clang] [clang][DependencyScanner] Remove all warning flags when suppressing warnings (PR #71612)

2023-11-07 Thread Jan Svoboda via cfe-commits


@@ -0,0 +1,84 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > 
%t/build/compile-commands.json
+// RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \
+// RUN:   -j 1 -format experimental-full -optimize-args=system-warnings > 
%t/deps.db
+// RUN: cat %t/deps.db | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK:  {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "A"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "B"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK:]
+// CHECK:  }
+
+//--- build/compile-commands.json.in
+
+[
+{
+  "directory": "DIR",
+  "command": "clang -c DIR/A.m -isystem modules/A -I modules/B -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",

jansvoboda11 wrote:

What does this test?

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


[clang] [clang][DependencyScanner] Remove all warning flags when suppressing warnings (PR #71612)

2023-11-07 Thread Jan Svoboda via cfe-commits


@@ -0,0 +1,84 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > 
%t/build/compile-commands.json
+// RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \
+// RUN:   -j 1 -format experimental-full -optimize-args=system-warnings > 
%t/deps.db
+// RUN: cat %t/deps.db | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK:  {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "A"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "B"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK:]
+// CHECK:  }
+
+//--- build/compile-commands.json.in
+
+[
+{
+  "directory": "DIR",
+  "command": "clang -c DIR/A.m -isystem modules/A -I modules/B -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",
+  "file": "DIR/A.m"
+},
+{
+  "directory": "DIR",
+  "command": "clang -c DIR/B.m -isystem modules/A -I modules/B -fmodules 
-fmodules-cache-path=DIR/module-cache -fimplicit-module-maps -Wmaybe-unused",
+  "file": "DIR/B.m"
+}

jansvoboda11 wrote:

I think we should probably also test the case where we don't optimize because 
of "-Wsystem-headers".

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


[clang] [AMDGPU] const-fold imm operands of amdgcn_update_dpp intrinsic (PR #71139)

2023-11-07 Thread Matt Arsenault via cfe-commits


@@ -17632,8 +17632,27 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_mov_dpp:
   case AMDGPU::BI__builtin_amdgcn_update_dpp: {
 llvm::SmallVector Args;
-for (unsigned I = 0; I != E->getNumArgs(); ++I)
-  Args.push_back(EmitScalarExpr(E->getArg(I)));
+// Find out if any arguments are required to be integer constant

arsenm wrote:

Can you factor the existing generic code into a helper function? This is mostly 
copy paste of the default builtin path 

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


[clang] [AMDGPU] const-fold imm operands of amdgcn_update_dpp intrinsic (PR #71139)

2023-11-07 Thread Matt Arsenault via cfe-commits


@@ -17632,8 +17632,20 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   case AMDGPU::BI__builtin_amdgcn_mov_dpp:
   case AMDGPU::BI__builtin_amdgcn_update_dpp: {
 llvm::SmallVector Args;
-for (unsigned I = 0; I != E->getNumArgs(); ++I)
-  Args.push_back(EmitScalarExpr(E->getArg(I)));
+for (unsigned I = 0; I != E->getNumArgs(); ++I) {
+  llvm::Value *Arg = EmitScalarExpr(E->getArg(I));
+  // Except first two input operands, all other are imm operands for dpp
+  // intrinsic.
+  if (llvm::is_contained(std::initializer_list{2, 3, 4, 5}, I)) {

arsenm wrote:

Yes, the others can be fixed separately. 

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


[clang] [clang][DependencyScanner] Remove all warning flags when suppressing warnings (PR #71612)

2023-11-07 Thread Jan Svoboda via cfe-commits


@@ -52,6 +52,28 @@ static void optimizeHeaderSearchOpts(HeaderSearchOptions 
&Opts,
 Opts.UserEntries.push_back(Entries[Idx]);
 }
 
+static void optimizeDiagnosticOpts(DiagnosticOptions &Opts,
+   bool IsSystemModule) {
+  // If this is not a system module or -Wsystem-headers was passed, don't
+  // optimize.
+  if (!IsSystemModule)
+return;
+  bool Wsystem_headers = false;
+  for (StringRef Opt : Opts.Warnings) {
+bool isPositive = !Opt.consume_front("no-");
+if (Opt == "system-headers")
+  Wsystem_headers = isPositive;
+  }
+  if (Wsystem_headers)
+return;

jansvoboda11 wrote:

Could we reuse `clang::ProcessWarningOptions()` to avoid duplicating the logic?

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> It was suggested to avoid "thin" and "fat" terminology (I started using it 
> with LTO as a precedent for the terms), but I suppose something more 
> descriptive could be selected.

Any suggestions? My english is not good, you know.

> I'll also note that my prior usage was in reference to embedding transitive 
> BMI references in the BMI, not about including function definitions.

May you elaborate on this? I don't understand since I feel they are unrelated. 
Are you saying: https://github.com/llvm/llvm-project/issues/62707? I feel they 
are orthogonal.

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


[clang] [Docs][Clang] Missing DR status for C++23-era papers in cxx_status.html (PR #68846)

2023-11-07 Thread A. Jiang via cfe-commits

https://github.com/frederick-vs-ja updated 
https://github.com/llvm/llvm-project/pull/68846

>From 40dca93d3e1f339f3e756e54687ea5506b3d6f2e Mon Sep 17 00:00:00 2001
From: "A. Jiang" 
Date: Tue, 17 Oct 2023 10:41:18 +0800
Subject: [PATCH] [Docs][Clang] DR status in cxx_status.html

---
 clang/www/cxx_status.html | 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index e2cf9ab25465214..8e2869d3fdf8ac6 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -190,7 +190,7 @@ C++23 implementation status
 
 
   Allow duplicate attributes
-  https://wg21.link/P2156R1";>P2156R1
+  https://wg21.link/P2156R1";>P2156R1 (DR)
   Clang 13
 
 
@@ -210,7 +210,7 @@ C++23 implementation status
 
 
   C++ identifier syntax using UAX 31
-  https://wg21.link/P1949R7";>P1949R7
+  https://wg21.link/P1949R7";>P1949R7 (DR)
   Clang 14
 
 
@@ -230,11 +230,11 @@ C++23 implementation status
 
 
   Change scope of lambda trailing-return-type
-  https://wg21.link/P2036R3";>P2036R3
+  https://wg21.link/P2036R3";>P2036R3 (DR)
   Clang 17
 
 
-  https://wg21.link/P2579R0";>P2579R0
+  https://wg21.link/P2579R0";>P2579R0 (DR)
 
 
   Multidimensional subscript operator
@@ -303,12 +303,12 @@ C++23 implementation status
 
 
   The Equality Operator You Are Looking For
-  https://wg21.link/P2468R2";>P2468R2
+  https://wg21.link/P2468R2";>P2468R2 (DR)
   Clang 16
 
 
   De-deprecating volatile compound operations
-  https://wg21.link/P2327R1";>P2327R1
+  https://wg21.link/P2327R1";>P2327R1 (DR)
   Clang 15
 
 
@@ -380,7 +380,7 @@ C++23 implementation status
 
 
   char8_t Compatibility and Portability Fix
-  https://wg21.link/P2513R3";>P2513R3
+  https://wg21.link/P2513R3";>P2513R3 (DR)
   Clang 16
 
 
@@ -522,7 +522,7 @@ C++20 implementation status
 https://wg21.link/p2103r0";>P2103R0
   

-https://wg21.link/p2493r0";>P2493R0
+https://wg21.link/p2493r0";>P2493R0 (DR)
   
   
 https://wg21.link/p2092r0";>P2092R0

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread Ben Boeckel via cfe-commits

mathstuf wrote:

I'll also note that my prior usage was in reference to embedding transitive BMI 
references in the BMI, not about including function definitions.

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread Ben Boeckel via cfe-commits

mathstuf wrote:

It was suggested to avoid "thin" and "fat" terminology (I started using it with 
LTO as a precedent for the terms), but I suppose something more descriptive 
could be selected.

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


[clang] [llvm] [clang-tools-extra] [clang] Add support for new loop attribute [[clang::code_align()]] (PR #70762)

2023-11-07 Thread via cfe-commits

smanna12 wrote:

@AaronBallman, @erichkeane I addressed comments in the PR, could you please 
revisit this PR? Thank you!

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


[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-07 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/71518

>From 3a51a9067e2581e1cb7091e24725439a991fdc78 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Tue, 7 Nov 2023 16:44:05 +0800
Subject: [PATCH] [clang][analyzer] Support `fputc` in StreamChecker

---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 75 +--
 clang/test/Analysis/stream-error.c| 55 ++
 clang/test/Analysis/stream.c  | 14 
 3 files changed, 136 insertions(+), 8 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 898906977ba9bb6..a774b61cc820df1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -245,11 +245,14 @@ class StreamChecker : public CheckerStreamArgNo), C,
@@ -650,7 +656,7 @@ void StreamChecker::preFreadFwrite(const FnDescription 
*Desc,
   if (!State)
 return;
 
-  if (!IsFread) {
+  if (!IsRead) {
 C.addTransition(State);
 return;
   }
@@ -745,6 +751,59 @@ void StreamChecker::evalFreadFwrite(const FnDescription 
*Desc,
 C.addTransition(StateFailed);
 }
 
+void StreamChecker::evalFgetcFputc(const FnDescription *Desc,
+   const CallEvent &Call,
+   CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+  SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
+  if (!StreamSym)
+return;
+
+  const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  const StreamState *OldSS = State->get(StreamSym);
+  if (!OldSS)
+return;
+
+  assertStreamStateOpened(OldSS);
+
+  // `fputc` returns the written character on success, otherwise returns EOF.
+
+  // Generate a transition for the success state.
+  std::optional PutVal = Call.getArgSVal(0).getAs();
+  if (!PutVal)
+return;
+  ProgramStateRef StateNotFailed =
+  State->BindExpr(CE, C.getLocationContext(), *PutVal);
+  StateNotFailed =
+  StateNotFailed->set(StreamSym, StreamState::getOpened(Desc));
+  C.addTransition(StateNotFailed);
+
+  // Add transition for the failed state.
+  SValBuilder &SVB = C.getSValBuilder();
+  NonLoc RetVal = makeRetVal(C, CE).castAs();
+  ProgramStateRef StateFailed =
+  State->BindExpr(CE, C.getLocationContext(), RetVal);
+  auto Cond = SVB.evalBinOp(State, BO_EQ, RetVal,
+SVB.makeIntVal(*EofVal, C.getASTContext().IntTy),
+SVB.getConditionType())
+  .getAs();
+  if (!Cond)
+return;
+  StateFailed = StateFailed->assume(*Cond, true);
+  if (!StateFailed)
+return;
+
+  // If a (non-EOF) error occurs, the resulting value of the file position
+  // indicator for the stream is indeterminate.
+  StreamState NewSS = StreamState::getOpened(
+  Desc, ErrorFError, /*IsFilePositionIndeterminate*/ true);
+  StateFailed = StateFailed->set(StreamSym, NewSS);
+  C.addTransition(StateFailed);
+}
+
 void StreamChecker::preFseek(const FnDescription *Desc, const CallEvent &Call,
  CheckerContext &C) const {
   ProgramStateRef State = C.getState();
diff --git a/clang/test/Analysis/stream-error.c 
b/clang/test/Analysis/stream-error.c
index 3c00e59bb6bd19d..5134be492696813 100644
--- a/clang/test/Analysis/stream-error.c
+++ b/clang/test/Analysis/stream-error.c
@@ -241,6 +241,23 @@ void error_indeterminate_clearerr(void) {
   fclose(F);
 }
 
+void error_indeterminate_fputc(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (feof(F)) {
+  fputc('X', F); // no warning
+} else if (ferror(F)) {
+  fputc('C', F); // expected-warning {{might be 'indeterminate'}}
+} else {
+  fputc('E', F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
 void error_indeterminate_feof1(void) {
   FILE *F = fopen("file", "r+");
   if (!F)
@@ -268,3 +285,41 @@ void error_indeterminate_feof2(void) {
   }
   fclose(F);
 }
+
+void error_indeterminate_feof3(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  char Buf[10];
+  if (fread(Buf, 1, 10, F) < 10) {
+if (feof(F)) {
+  // error is feof, should be non-indeterminate
+  fputc(';', F); // no warning
+}
+if (ferror(F)) {
+  fputc('=', F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
+void error_indeterminate_feof4(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  if (fputc('Y', F) == EOF) {
+fputc('W', F); // expected-warning {{might be 'indeterminate'}}
+  } else {
+fputc('H', F); // no warning
+  }
+  fclose(F);
+}
+
+void determinate_fputc(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  if (fputc('Q', F) == 'Q')
+fputc('X', F); // no warning
+  fclose(F);
+}
diff --git a/clang/test/Analysis/stream.c 

[clang] [OpenMP] Add a missing 'const' (NFC) (PR #71596)

2023-11-07 Thread Mike Rice via cfe-commits

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


[clang] 182b7e6 - [OpenMP] Add a missing 'const' (NFC) (#71596)

2023-11-07 Thread via cfe-commits

Author: Mike Rice
Date: 2023-11-07T18:42:23-08:00
New Revision: 182b7e6ba75055a84544943a06df9964d3a08d81

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

LOG: [OpenMP] Add a missing 'const' (NFC) (#71596)

Added: 


Modified: 
clang/include/clang/AST/StmtOpenMP.h

Removed: 




diff  --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 2725747e051e728..62164339153573c 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -994,7 +994,7 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
   unsigned getNumAssociatedLoops() const { return getLoopsNumber(); }
 
   /// Return the number of loops generated by this loop transformation.
-  unsigned getNumGeneratedLoops() { return NumGeneratedLoops; }
+  unsigned getNumGeneratedLoops() const { return NumGeneratedLoops; }
 
   /// Get the de-sugared statements after the loop transformation.
   ///



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


[clang] [llvm] Remove experimental from Vector Crypto extensions (PR #69000)

2023-11-07 Thread Kito Cheng via cfe-commits


@@ -106,6 +106,8 @@ static const RISCVSupportedExtension SupportedExtensions[] 
= {
 
 {"zdinx", RISCVExtensionVersion{1, 0}},
 
+{"zexperimental", RISCVExtensionVersion{1, 0}},
+

kito-cheng wrote:

I guess we don't really need this dummy extension in RISCVISAInfo?

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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff b85fdc4ffde48f2035e4621d4f9af69bf16f2136 
839d38d96d2275dbc0a9aa9fae3427720a6d3344 -- 
clang/include/clang/Frontend/FrontendActions.h 
clang/include/clang/Frontend/FrontendOptions.h 
clang/include/clang/Serialization/ASTWriter.h clang/lib/Driver/Driver.cpp 
clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Frontend/CompilerInvocation.cpp 
clang/lib/Frontend/FrontendActions.cpp 
clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp 
clang/lib/Serialization/ASTWriter.cpp clang/lib/Serialization/ASTWriterDecl.cpp 
clang/lib/Serialization/GeneratePCH.cpp 
clang/test/CXX/basic/basic.link/p10-ex2.cpp 
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
 clang/test/Modules/Reachability-Private.cpp 
clang/test/Modules/Reachability-func-default-arg.cpp 
clang/test/Modules/Reachability-func-ret.cpp 
clang/test/Modules/Reachability-template-default-arg.cpp 
clang/test/Modules/Reachability-template-instantiation.cpp 
clang/test/Modules/Reachability-using-templates.cpp 
clang/test/Modules/Reachability-using.cpp clang/test/Modules/cxx20-10-1-ex1.cpp 
clang/test/Modules/cxx20-10-1-ex2.cpp clang/test/Modules/cxx20-10-2-ex2.cpp 
clang/test/Modules/cxx20-10-2-ex5.cpp clang/test/Modules/cxx20-10-3-ex1.cpp 
clang/test/Modules/cxx20-10-3-ex2.cpp clang/test/Modules/cxx20-10-5-ex1.cpp 
clang/test/Modules/cxx20-import-diagnostics-a.cpp 
clang/test/Modules/cxx20-import-diagnostics-b.cpp 
clang/test/Modules/cxx20-module-file-info-macros.cpp 
clang/test/Modules/derived_class.cpp 
clang/test/Modules/explicitly-specialized-template.cpp 
clang/test/Modules/merge-concepts-cxx-modules.cpp 
clang/test/Modules/merge-constrained-friends.cpp 
clang/test/Modules/mismatch-diagnostics.cpp 
clang/test/Modules/placement-new-reachable.cpp 
clang/test/Modules/predefined.cpp 
clang/test/Modules/redundant-template-default-arg.cpp 
clang/test/Modules/redundant-template-default-arg2.cpp 
clang/test/Modules/redundant-template-default-arg3.cpp 
clang/test/Modules/search-partitions.cpp 
clang/test/Modules/template-function-specialization.cpp 
clang/test/Modules/template_default_argument.cpp 
clang/unittests/Sema/SemaNoloadLookupTest.cpp 
clang/unittests/Serialization/ForceCheckFileInputTest.cpp 
clang/unittests/Serialization/NoCommentsTest.cpp 
clang/unittests/Serialization/VarDeclConstantInitTest.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Serialization/ASTWriterDecl.cpp 
b/clang/lib/Serialization/ASTWriterDecl.cpp
index 00a04ee2fa73..ca7794b8c5f9 100644
--- a/clang/lib/Serialization/ASTWriterDecl.cpp
+++ b/clang/lib/Serialization/ASTWriterDecl.cpp
@@ -283,7 +283,7 @@ bool clang::MayDefAffectABI(const Decl *D) {
 // use, no matter whether they've been explicitly instantiated etc.
 if (!FD->isUserProvided())
   return true;
-
+
 if (FD->isDependentContext())
   return true;
 

``




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


[clang] [C++20] [Modules] Introduce thin BMI (PR #71622)

2023-11-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-modules

Author: Chuanqi Xu (ChuanqiXu9)


Changes

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

This patch introduces thin BMI, which doesn't contain the definitions of 
functions and variables if its definitions won't contribute to the ABI.

Testing is a big part of the patch. We want to make sure the thin BMI contains 
the same behavior with the existing and relatively stable fatBMI. This is 
pretty helpful for further reduction.

For user interfeaces, this patch introduces `-fthinBMI-output=` arguments to 
specify the position of thin BMI. This should be used when compiling a single 
module unit.

The design is helpful to use thin BMI in two phase compilations too. With thin 
BMI, In two phase compilations, we'll generate 2 BMIs, one thin BMI for being 
used by consumers, one fat BMI for compiling itself to object files. Maybe it 
sounds confusing to have 2 BMIs for one module unit. But only the thin BMI will 
be the BMI we're talking about generally and the fat BMI is only visible by the 
module unit itself.

With one phase compilation, we may find the behavior of `-fthinBMI-output=` is 
pretty similar with `-fmodule-output=`, except one generating thin BMI and the 
other generating fat BMI. The design here is based on 2 things:
(1) The serialization of C++ is pretty complex. We can't be sure we're handling 
every detail correctly in the every beginning.
(2) The fat BMI is relatively widely used and relatively stable. So it looks 
not good to replace the fat BMI immediately with thin BMI.

But, of course, in the end of the day, we want the consumers to use the thin 
BMI only. When that day comes, the `-fmodule-output=` will be an alias to 
`-fthinBMI-output=`.

Another design choice is to reuse `-fmodule-output=` and introduce a flag 
`-femit-thin-BMI`. Then `-femit-thin-BMI -fmodule-output=` will have the same 
effect with `-fthinBMI-output=` now.
The flag `-femit-thin-BMI` should be opt-in now and opt-off later and finally 
deprecated.

The roadmap for thin BMI in my mind is:

(1) In clang18, release thin BMI and mark it as experimental. Also encourage 
users and build systems to try this new mode. (2) In clang19 or clang20 (based 
on the issue feedbacks), remove the experimental mark for thin BMI and mark fat 
BMI as deprecated to be used by consumers.
(3) In clang21 or clang22, error out if we found the users are trying to import 
a fat BMI.

CC: @mathstuf 

---

Patch is 113.03 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/71622.diff


112 Files Affected:

- (modified) clang/include/clang/Basic/DiagnosticDriverKinds.td (+2) 
- (modified) clang/include/clang/Driver/Options.td (+8-1) 
- (modified) clang/include/clang/Frontend/FrontendActions.h (+17-1) 
- (modified) clang/include/clang/Frontend/FrontendOptions.h (+8-1) 
- (modified) clang/include/clang/Serialization/ASTWriter.h (+29-2) 
- (modified) clang/lib/Driver/Driver.cpp (+7) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+2) 
- (modified) clang/lib/Frontend/CompilerInvocation.cpp (+2) 
- (modified) clang/lib/Frontend/FrontendActions.cpp (+47-5) 
- (modified) clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp (+2) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+18-14) 
- (modified) clang/lib/Serialization/ASTWriterDecl.cpp (+46-7) 
- (modified) clang/lib/Serialization/GeneratePCH.cpp (+34-2) 
- (modified) clang/test/CXX/basic/basic.link/p10-ex2.cpp (+2-1) 
- (modified) 
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
 (+4-2) 
- (added) clang/test/Driver/thinBMI-output.cppm (+29) 
- (modified) clang/test/Modules/InheritDefaultArguments.cppm (+3) 
- (modified) clang/test/Modules/Reachability-Private.cpp (+10) 
- (modified) clang/test/Modules/Reachability-func-default-arg.cpp (+3) 
- (modified) clang/test/Modules/Reachability-func-ret.cpp (+3) 
- (modified) clang/test/Modules/Reachability-template-default-arg.cpp (+3) 
- (modified) clang/test/Modules/Reachability-template-instantiation.cpp (+4) 
- (modified) clang/test/Modules/Reachability-using-templates.cpp (+3) 
- (modified) clang/test/Modules/Reachability-using.cpp (+3) 
- (modified) clang/test/Modules/concept.cppm (+4) 
- (modified) clang/test/Modules/concept_differ.cppm (+5) 
- (modified) clang/test/Modules/ctor.arg.dep.cppm (+4) 
- (modified) clang/test/Modules/cxx20-10-1-ex1.cpp (+13) 
- (modified) clang/test/Modules/cxx20-10-1-ex2.cpp (+30-6) 
- (modified) clang/test/Modules/cxx20-10-2-ex2.cpp (+12) 
- (modified) clang/test/Modules/cxx20-10-2-ex5.cpp (+12) 
- (modified) clang/test/Modules/cxx20-10-3-ex1.cpp (+14) 
- (modified) clang/test/Modules/cxx20-10-3-ex2.cpp (+10) 
- (modified) clang/test/Modules/cxx20-10-5-ex1.cpp (+12) 
- (modified) clang/test/Modules/cxx20-import-diagnostics-a.cpp (+39) 
- (modified) clang/test/Modules/cxx20-import-diagnostics-b.cpp (+25) 
- (modified) clang/test/Modules/cxx20-module-file-info-macros.cpp (+

[clang-tools-extra] [clangd] Allow hover over 128-bit variable without crashing (PR #71415)

2023-11-07 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Thanks! Please go ahead and merge it. :-)

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


[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-07 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/71518

>From eb4da0df114586c4099a495e5114ab0c1c9f9e27 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Tue, 7 Nov 2023 16:44:05 +0800
Subject: [PATCH] [clang][analyzer] Support `fputc` in StreamChecker

---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp | 75 +--
 clang/test/Analysis/stream-error.c| 46 
 clang/test/Analysis/stream.c  | 14 
 3 files changed, 127 insertions(+), 8 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index 898906977ba9bb6..a774b61cc820df1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -245,11 +245,14 @@ class StreamChecker : public CheckerStreamArgNo), C,
@@ -650,7 +656,7 @@ void StreamChecker::preFreadFwrite(const FnDescription 
*Desc,
   if (!State)
 return;
 
-  if (!IsFread) {
+  if (!IsRead) {
 C.addTransition(State);
 return;
   }
@@ -745,6 +751,59 @@ void StreamChecker::evalFreadFwrite(const FnDescription 
*Desc,
 C.addTransition(StateFailed);
 }
 
+void StreamChecker::evalFgetcFputc(const FnDescription *Desc,
+   const CallEvent &Call,
+   CheckerContext &C) const {
+  ProgramStateRef State = C.getState();
+  SymbolRef StreamSym = getStreamArg(Desc, Call).getAsSymbol();
+  if (!StreamSym)
+return;
+
+  const CallExpr *CE = dyn_cast_or_null(Call.getOriginExpr());
+  if (!CE)
+return;
+
+  const StreamState *OldSS = State->get(StreamSym);
+  if (!OldSS)
+return;
+
+  assertStreamStateOpened(OldSS);
+
+  // `fputc` returns the written character on success, otherwise returns EOF.
+
+  // Generate a transition for the success state.
+  std::optional PutVal = Call.getArgSVal(0).getAs();
+  if (!PutVal)
+return;
+  ProgramStateRef StateNotFailed =
+  State->BindExpr(CE, C.getLocationContext(), *PutVal);
+  StateNotFailed =
+  StateNotFailed->set(StreamSym, StreamState::getOpened(Desc));
+  C.addTransition(StateNotFailed);
+
+  // Add transition for the failed state.
+  SValBuilder &SVB = C.getSValBuilder();
+  NonLoc RetVal = makeRetVal(C, CE).castAs();
+  ProgramStateRef StateFailed =
+  State->BindExpr(CE, C.getLocationContext(), RetVal);
+  auto Cond = SVB.evalBinOp(State, BO_EQ, RetVal,
+SVB.makeIntVal(*EofVal, C.getASTContext().IntTy),
+SVB.getConditionType())
+  .getAs();
+  if (!Cond)
+return;
+  StateFailed = StateFailed->assume(*Cond, true);
+  if (!StateFailed)
+return;
+
+  // If a (non-EOF) error occurs, the resulting value of the file position
+  // indicator for the stream is indeterminate.
+  StreamState NewSS = StreamState::getOpened(
+  Desc, ErrorFError, /*IsFilePositionIndeterminate*/ true);
+  StateFailed = StateFailed->set(StreamSym, NewSS);
+  C.addTransition(StateFailed);
+}
+
 void StreamChecker::preFseek(const FnDescription *Desc, const CallEvent &Call,
  CheckerContext &C) const {
   ProgramStateRef State = C.getState();
diff --git a/clang/test/Analysis/stream-error.c 
b/clang/test/Analysis/stream-error.c
index 3c00e59bb6bd19d..7e895f3fe947158 100644
--- a/clang/test/Analysis/stream-error.c
+++ b/clang/test/Analysis/stream-error.c
@@ -241,6 +241,23 @@ void error_indeterminate_clearerr(void) {
   fclose(F);
 }
 
+void error_indeterminate_fputc(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+if (feof(F)) {
+  fputc('X', F); // no warning
+} else if (ferror(F)) {
+  fputc('C', F); // expected-warning {{might be 'indeterminate'}}
+} else {
+  fputc('E', F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
 void error_indeterminate_feof1(void) {
   FILE *F = fopen("file", "r+");
   if (!F)
@@ -268,3 +285,32 @@ void error_indeterminate_feof2(void) {
   }
   fclose(F);
 }
+
+void error_indeterminate_feof3(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  char Buf[10];
+  if (fread(Buf, 1, 10, F) < 10) {
+if (feof(F)) {
+  // error is feof, should be non-indeterminate
+  fputc(';', F); // no warning
+}
+if (ferror(F)) {
+  fputc('=', F); // expected-warning {{might be 'indeterminate'}}
+}
+  }
+  fclose(F);
+}
+
+void error_indeterminate_feof4(void) {
+  FILE *F = fopen("file", "r+");
+  if (!F)
+return;
+  if (fputc('Y', F) == EOF) {
+fputc('W', F); // expected-warning {{might be 'indeterminate'}}
+  } else {
+fputc('H', F); // no warning
+  }
+  fclose(F);
+}
diff --git a/clang/test/Analysis/stream.c b/clang/test/Analysis/stream.c
index a01310cfef5dd8a..a2eaaa2bd0142c5 100644
--- a/clang/test/Analysis/stream.c
+++ b/clang/test/Analysis/stream.c
@@ -14,6 +14,12 @@ void che

[clang] [Clang][OpenMP] Return empty QualType when a negative array was created (PR #71552)

2023-11-07 Thread Shilei Tian via cfe-commits

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


[clang] [Clang][OpenMP]Return empty QualType when a negative array was created. (PR #71552)

2023-11-07 Thread via cfe-commits

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


[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-07 Thread Ben Shi via cfe-commits

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

@bcardosolopes @apolloww @rjmccall would you like to take a look for the middle 
end part?

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> There is substantial inconsistency between "coro only destroy when complete" 
> and "... when done" throughout the PR (in various forms; e.g. literal 
> strings, snake_case, CamelCase, ALL_CAPS as well as file names).
> 
> Presumably there should only be one spelling everywhere.

Done

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


[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

2023-11-07 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/71014

>From c69205d54e1a4858211b5bbce69e10bba7063359 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Thu, 2 Nov 2023 11:11:59 +0800
Subject: [PATCH] [Coroutines] Introduce
 [[clang::coro_only_destroy_when_complete]]

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

This patch tries to introduce a light-weight optimizer for coroutines
which are guaranteed to only be destroyed afer it reached the final
suspend.

The rationale behind the patch is simple. See the example:

```C++
A foo() {
  dtor d;
  co_await something();
  dtor d1;
  co_await something();
  dtor d2;
  co_return 43;
}
```

Generally the generated .destroy function may be:

```C++
void foo.destroy(foo.Frame *frame) {
  switch(frame->suspend_index()) {
case 1:
  frame->d.~dtor();
  break;
case 2:
  frame->d.~dtor();
  frame->d1.~dtor();
  break;
case 3:
  frame->d.~dtor();
  frame->d1.~dtor();
  frame->d2.~dtor();
  break;
default: // coroutine completed or haven't started
  break;
  }

  frame->promise.~promise_type();
  delete frame;
}
```

Since the compiler need to be ready for all the cases that the coroutine
may be destroyed in a valid state.

However, from the user's perspective, we can understand that certain
coroutine types may only be destroyed after it reached to the final
suspend point. And we need a method to teach the compiler about this.
Then this is the patch. After the compiler recognized that the
coroutines can only be destroyed after complete, it can optimize the
above example to:

```C++
void foo.destroy(foo.Frame *frame) {
  frame->promise.~promise_type();
  delete frame;
}
```

I spent a lot of time experimenting and experiencing this in the
downstream. The numbers are really good. In a real-world coroutine-heavy
workload, the size of the build dir (including .o files) reduces 14%. And
the size of final libraries (excluding the .o files) reduces 8% in Debug
mode and 1% in Release mode.
---
 clang/docs/ReleaseNotes.rst   |   3 +
 clang/include/clang/Basic/Attr.td |  12 ++
 clang/include/clang/Basic/AttrDocs.td |  66 +
 clang/lib/CodeGen/CGCoroutine.cpp |   4 +
 .../coro-only-destroy-when-complete.cpp   |  59 
 ...a-attribute-supported-attributes-list.test |   1 +
 llvm/docs/Coroutines.rst  |  11 ++
 llvm/include/llvm/Bitcode/LLVMBitCodes.h  |   1 +
 llvm/include/llvm/IR/Attributes.td|   3 +
 llvm/include/llvm/IR/Function.h   |   7 +
 llvm/lib/Bitcode/Reader/BitcodeReader.cpp |   2 +
 llvm/lib/Bitcode/Writer/BitcodeWriter.cpp |   2 +
 llvm/lib/Transforms/Coroutines/CoroSplit.cpp  |  21 ++-
 llvm/lib/Transforms/Utils/CodeExtractor.cpp   |   1 +
 .../Coroutines/coro-only-destroy-when-done.ll | 137 ++
 15 files changed, 323 insertions(+), 7 deletions(-)
 create mode 100644 
clang/test/CodeGenCoroutines/coro-only-destroy-when-complete.cpp
 create mode 100644 
llvm/test/Transforms/Coroutines/coro-only-destroy-when-done.ll

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8bac599f88503af..7a131cb520aa600 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -296,6 +296,9 @@ Attribute Changes in Clang
   is ignored, changed from the former incorrect suggestion to move it past
   declaration specifiers. (`#58637 
`_)
 
+- Clang now introduced ``[[clang::coro_only_destroy_when_complete]]`` attribute
+  to reduce the size of the destroy functions for coroutines which are known to
+  be destroyed after having reached the final suspend point.
 
 Improvements to Clang's diagnostics
 ---
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 60b54c155e5..31434565becaec6 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1082,6 +1082,18 @@ def CFConsumed : InheritableParamAttr {
   let Documentation = [RetainBehaviorDocs];
 }
 
+
+// coro_only_destroy_when_complete indicates the coroutines whose return type
+// is marked by coro_only_destroy_when_complete can only be destroyed when the
+// coroutine completes. Then the space for the destroy functions can be saved.
+def CoroOnlyDestroyWhenComplete : InheritableAttr {
+  let Spellings = [Clang<"coro_only_destroy_when_complete">];
+  let Subjects = SubjectList<[CXXRecord]>;
+  let LangOpts = [CPlusPlus];
+  let Documentation = [CoroOnlyDestroyWhenCompleteDocs];
+  let SimpleHandler = 1;
+}
+
 // OSObject-based attributes.
 def OSConsumed : InheritableParamAttr {
   let Spellings = [Clang<"os_consumed">];
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 05703df2129f612..fa6f6acd0c30e88 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/incl

[PATCH] D154402: [compiler-rt] Enable profile instrumentation for SerenityOS

2023-11-07 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster updated this revision to Diff 558045.
ADKaster added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154402

Files:
  clang/lib/Driver/ToolChains/Serenity.cpp
  clang/test/Driver/instrprof-ld.c
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
  compiler-rt/lib/profile/InstrProfilingPlatformOther.c
  llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp

Index: llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
===
--- llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
+++ llvm/lib/Transforms/Instrumentation/InstrProfiling.cpp
@@ -1042,7 +1042,8 @@
 return false;
   // Use linker script magic to get data/cnts/name start/end.
   if (TT.isOSAIX() || TT.isOSLinux() || TT.isOSFreeBSD() || TT.isOSNetBSD() ||
-  TT.isOSSolaris() || TT.isOSFuchsia() || TT.isPS() || TT.isOSWindows())
+  TT.isOSSolaris() || TT.isOSFuchsia() || TT.isPS() || TT.isOSWindows() ||
+  TT.isOSSerenity())
 return false;
 
   return true;
Index: compiler-rt/lib/profile/InstrProfilingPlatformOther.c
===
--- compiler-rt/lib/profile/InstrProfilingPlatformOther.c
+++ compiler-rt/lib/profile/InstrProfilingPlatformOther.c
@@ -8,7 +8,8 @@
 
 #if !defined(__APPLE__) && !defined(__linux__) && !defined(__FreeBSD__) && \
 !defined(__Fuchsia__) && !(defined(__sun__) && defined(__svr4__)) &&   \
-!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX)
+!defined(__NetBSD__) && !defined(_WIN32) && !defined(_AIX) &&  \
+!defined(__serenity__)
 
 #include 
 #include 
Index: compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
===
--- compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
+++ compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
@@ -8,7 +8,7 @@
 
 #if defined(__linux__) || defined(__FreeBSD__) || defined(__Fuchsia__) || \
 (defined(__sun__) && defined(__svr4__)) || defined(__NetBSD__) || \
-defined(_AIX)
+defined(_AIX) || defined(__serenity__)
 
 #if !defined(_AIX)
 #include 
Index: compiler-rt/cmake/config-ix.cmake
===
--- compiler-rt/cmake/config-ix.cmake
+++ compiler-rt/cmake/config-ix.cmake
@@ -789,7 +789,7 @@
 endif()
 
 if (PROFILE_SUPPORTED_ARCH AND NOT LLVM_USE_SANITIZER AND
-OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX")
+OS_NAME MATCHES "Darwin|Linux|FreeBSD|Windows|Android|Fuchsia|SunOS|NetBSD|AIX|SerenityOS")
   set(COMPILER_RT_HAS_PROFILE TRUE)
 else()
   set(COMPILER_RT_HAS_PROFILE FALSE)
Index: clang/test/Driver/instrprof-ld.c
===
--- clang/test/Driver/instrprof-ld.c
+++ clang/test/Driver/instrprof-ld.c
@@ -54,6 +54,15 @@
 // CHECK-OPENBSD-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-OPENBSD-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}openbsd{{/|}}libclang_rt.profile-x86_64.a"
 
+// RUN: %clang -### %s 2>&1 \
+// RUN: --target=x86_64-pc-serenity -fprofile-instr-generate -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/serenity_x86_64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SERENITY-X86-64 %s
+
+// CHECK-SERENITY-X86-64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
+// CHECK-SERENITY-X86-64: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}serenity{{/|}}libclang_rt.profile-x86_64.a"
+
 // RUN: %clang -### %s 2>&1 \
 // RUN: -shared \
 // RUN: --target=i386-unknown-linux -fprofile-instr-generate -fuse-ld=ld \
@@ -104,6 +113,17 @@
 // CHECK-OPENBSD-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld{{(.exe)?}}"
 // CHECK-OPENBSD-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}openbsd{{/|}}libclang_rt.profile-x86_64.a"
 
+// RUN: %clang -### %s 2>&1 \
+// RUN: -shared \
+// RUN: --target=x86_64-pc-serenity -fprofile-instr-generate -fuse-ld=ld \
+// RUN: -resource-dir=%S/Inputs/resource_dir \
+// RUN: --sysroot=%S/Inputs/serenity_x86_64_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-SERENITY-X86-64-SHARED %s
+
+// CHECK-SERENITY-X86-64-SHARED: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld{{(.exe)?}}"
+// CHECK-SERENITY-X86-64-SHARED: "{{.*}}/Inputs/resource_dir{{/|}}lib{{/|}}serenity{{/|}}libclang_rt.profile-x86_64.a"
+
+
 // RUN: %clang -### %s 2>&1 \
 // RUN: --target=x86_64-apple-darwin14 -fprofile-instr-generate -fuse-ld=ld \
 // RUN: -resource-dir=%S/Inputs/resource_dir \
Index: clang/lib/Driver/ToolChains/Serenity.cpp
===
--- clang/lib/Driver/ToolChains/Serenity.cpp
+++ clang/lib/Driver/ToolChains/Serenity.cpp
@@ -178,6 +178,8 @@
   

[PATCH] D154396: [clang] Add support for SerenityOS

2023-11-07 Thread Andrew Kaster via Phabricator via cfe-commits
ADKaster updated this revision to Diff 558043.
ADKaster added a comment.

test LTO with option fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154396

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Serenity.cpp
  clang/lib/Driver/ToolChains/Serenity.h
  clang/lib/Lex/InitHeaderSearch.cpp
  clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/c++/v1/.keep
  
clang/test/Driver/Inputs/serenity_x86_64_tree/usr/include/x86_64-pc-serenity/c++/v1/.keep
  clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0.o
  clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crt0_shared.o
  clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crti.o
  clang/test/Driver/Inputs/serenity_x86_64_tree/usr/lib/crtn.o
  clang/test/Driver/Inputs/serenity_x86_64_tree/usr/local/.keep
  clang/test/Driver/pic.c
  clang/test/Driver/save-stats.c
  clang/test/Driver/serenity.cpp

Index: clang/test/Driver/serenity.cpp
===
--- /dev/null
+++ clang/test/Driver/serenity.cpp
@@ -0,0 +1,196 @@
+// UNSUPPORTED: system-windows
+
+/// Check default header and linker paths
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot=%S/Inputs/serenity_x86_64_tree \
+// RUN:   -ccc-install-dir %S/Inputs/serenity_x86_64/usr/local/bin -resource-dir=%S/Inputs/resource_dir \
+// RUN:   2>&1 | FileCheck %s --check-prefix=PATHS_X86_64
+// PATHS_X86_64:  "-resource-dir" "[[RESOURCE:[^"]+]]"
+// PATHS_X86_64:  "-internal-isystem"
+// PATHS_X86_64-SAME: {{^}} "[[SYSROOT:[^"]+]]/usr/include/x86_64-pc-serenity/c++/v1"
+// PATHS_X86_64-SAME: {{^}} "-internal-isystem" "[[SYSROOT:[^"]+]]/usr/include/c++/v1"
+// PATHS_X86_64-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]/include"
+// PATHS_X86_64-SAME: {{^}} "-internal-isystem" "[[SYSROOT:[^"]+]]/usr/include"
+// PATHS_X86_64:  "-L
+// PATHS_X86_64-SAME: {{^}}[[SYSROOT]]/usr/lib"
+
+/// Check default linker args for each supported triple
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= 2>&1 | FileCheck %s --check-prefix=SERENITY_X86_64
+// SERENITY_X86_64: "-cc1" "-triple" "x86_64-pc-serenity"
+// SERENITY_X86_64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
+// SERENITY_X86_64: "-pie"
+// SERENITY_X86_64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
+// SERENITY_X86_64: "-o" "a.out"
+// SERENITY_X86_64: "-z" "pack-relative-relocs"
+// SERENITY_X86_64: "crt0.o" "crti.o" "crtbeginS.o"
+// SERENITY_X86_64: "-lc" "crtendS.o" "crtn.o"
+
+// RUN: %clang -### %s --target=aarch64-pc-serenity --sysroot= 2>&1 | FileCheck %s --check-prefix=SERENITY_AARCH64
+// SERENITY_AARCH64: "-cc1" "-triple" "aarch64-pc-serenity"
+// SERENITY_AARCH64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
+// SERENITY_AARCH64: "-pie"
+// SERENITY_AARCH64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
+// SERENITY_AARCH64: "-o" "a.out"
+// SERENITY_AARCH64: "-z" "pack-relative-relocs"
+// SERENITY_AARCH64: "crt0.o" "crti.o" "crtbeginS.o"
+// SERENITY_AARCH64: "-lc" "crtendS.o" "crtn.o"
+
+// RUN: %clang -### %s --target=riscv64-pc-serenity --sysroot= 2>&1 | FileCheck %s --check-prefix=SERENITY_RISCV64
+// SERENITY_RISCV64: "-cc1" "-triple" "riscv64-pc-serenity"
+// SERENITY_RISCV64: "{{(.*[^-.0-9A-Z_a-z])?}}ld.lld"
+// SERENITY_RISCV64: "-pie"
+// SERENITY_RISCV64: "-dynamic-linker" "/usr/lib/Loader.so" "--eh-frame-hdr"
+// SERENITY_RISCV64: "-o" "a.out"
+// SERENITY_RISCV64: "-z" "pack-relative-relocs"
+// SERENITY_RISCV64: "crt0.o" "crti.o" "crtbeginS.o"
+// SERENITY_RISCV64: "-lc" "crtendS.o" "crtn.o"
+
+/// -static-pie suppresses -dynamic-linker
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
+//  -static-pie 2>&1 | FileCheck %s --check-prefix=STATIC_PIE
+// STATIC_PIE: "-pie" "-static"
+// STATIC_PIE-NOT: "-dynamic-linker"
+// STATIC_PIE: "--no-dynamic-linker" "-z" "text"
+// STATIC_PIE:  "--eh-frame-hdr" "-z" "pack-relative-relocs"
+// STATIC_PIE: "crt0.o" "crti.o" "crtbeginS.o"
+// STATIC_PIE: "-lc" "crtendS.o" "crtn.o"
+
+/// -shared forces use of shared crt files
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
+//  -shared 2>&1 | FileCheck %s --check-prefix=SHARED
+// SHARED: "-shared"
+// SHARED:  "--eh-frame-hdr" "-z" "pack-relative-relocs"
+// SHARED: "crt0_shared.o" "crti.o" "crtbeginS.o"
+// SHARED: "-lc" "crtendS.o" "crtn.o"
+
+/// -static forces use of static crt files
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
+//  -static 2>&1 | FileCheck %s --check-prefix=STATIC
+// STATIC: "-static"
+// STATIC:  "--eh-frame-hdr" "-z" "pack-relative-relocs"
+// STATIC: "crt0.o" "crti.o" "crtbegin.o"
+// STATIC: "-lc" "crtend.o" "crtn.o"
+
+/// -rdynamic passes -export-dynamic
+// RUN: %clang -### %s --target=x86_64-pc-serenity --sysroot= \
+// 

[clang] [C++20] [Modules] Don't import function bodies from other module units even with optimizations (PR #71031)

2023-11-07 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

Sorry for being too hurry here. 

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


[clang] [SEH] Fix assertin when return scalar value from __try block. (PR #71488)

2023-11-07 Thread via cfe-commits

https://github.com/jyu2-git updated 
https://github.com/llvm/llvm-project/pull/71488

>From 3313aca0622da3882a9e5bf304b89f28fecce7fe Mon Sep 17 00:00:00 2001
From: Jennifer Yu 
Date: Mon, 6 Nov 2023 20:51:39 -0800
Subject: [PATCH 1/2] [SEH] Fix assertin when return scalar value from __try
 block.

Current compler assert with `!SI->isAtomic() && !SI->isVolatile()' failed

This due to following rule:
First, no exception can move in or out of _try region., i.e., no "potential
faulty instruction can be moved across _try boundary.
Second, the order of exceptions for instructions 'directly' under a _try
must be preserved (not applied to those in callees).
Finally, global states (local/global/heap variables) that can be read
outside of _try region must be updated in memory (not just in register)
before the subsequent exception occurs.

All memory instructions inside a _try are considered as 'volatile' to assure
2nd and 3rd rules for C-code above. This is a little sub-optimized. But it's
acceptable as the amount of code directly under _try is very small.
However during findDominatingStoreToReturnValue: those are not allowed.

To fix just skip the assertion when current function has seh try.
---
 clang/lib/CodeGen/CGCall.cpp  |  3 +++
 .../CodeGen/windows-seh-EHa-TryInFinally.cpp  | 23 +++
 2 files changed, 26 insertions(+)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index e7951b3a3f4d855..bc367b89992bbd9 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3507,6 +3507,9 @@ static llvm::StoreInst 
*findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
   return nullptr;
 // These aren't actually possible for non-coerced returns, and we
 // only care about non-coerced returns on this code path.
+// All memory instructions inside __try block are volatile.
+if (CGF.currentFunctionUsesSEHTry() && SI->isVolatile())
+  return SI;
 assert(!SI->isAtomic() && !SI->isVolatile());
 return SI;
   };
diff --git a/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp 
b/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
index fab567e763df443..ce2a9528e1908a9 100644
--- a/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
+++ b/clang/test/CodeGen/windows-seh-EHa-TryInFinally.cpp
@@ -67,3 +67,26 @@ void foo()
 }
   }
 }
+
+// CHECK-LABEL:@"?bar@@YAHXZ"()
+// CHECK: invoke.cont:
+// CHECK: invoke void @llvm.seh.try.begin()
+// CHECK: invoke.cont1:
+// CHECK: store volatile i32 1, ptr %cleanup.dest.slot
+// CHECK: invoke void @llvm.seh.try.end()
+// CHECK: invoke.cont2:
+// CHECK: call void @"?fin$0@0@bar@@"
+// CHECK: %cleanup.dest3 = load i32, ptr %cleanup.dest.slot
+// CHECK: return:
+// CHECK: ret i32 11
+int bar()
+{
+  int x;
+  __try {
+return 11;
+  } __finally {
+if (_abnormal_termination()) {
+  x = 9;
+}
+  }
+}

>From 4caaaef0ada4d22b91c38704da90a2c1debe8e55 Mon Sep 17 00:00:00 2001
From: Jennifer Yu 
Date: Tue, 7 Nov 2023 15:24:47 -0800
Subject: [PATCH 2/2] Thanks @rnk for the review.  This address his comment.

---
 clang/lib/CodeGen/CGCall.cpp | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index bc367b89992bbd9..8fd876825b7ea08 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3508,9 +3508,8 @@ static llvm::StoreInst 
*findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
 // These aren't actually possible for non-coerced returns, and we
 // only care about non-coerced returns on this code path.
 // All memory instructions inside __try block are volatile.
-if (CGF.currentFunctionUsesSEHTry() && SI->isVolatile())
-  return SI;
-assert(!SI->isAtomic() && !SI->isVolatile());
+assert(!SI->isAtomic() &&
+   (!SI->isVolatile() || CGF.currentFunctionUsesSEHTry()));
 return SI;
   };
   // If there are multiple uses of the return-value slot, just check

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


[clang] [clang][DependencyScanner] Remove all warning flags when suppressing warnings (PR #71612)

2023-11-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Michael Spencer (Bigcheese)


Changes

Since system modules don't emit most warnings, remove the warning flags to 
increase module reuse.

---
Full diff: https://github.com/llvm/llvm-project/pull/71612.diff


4 Files Affected:

- (modified) 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h 
(+5-2) 
- (modified) clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp (+26) 
- (added) clang/test/ClangScanDeps/optimize-system-warnings.m (+84) 
- (modified) clang/tools/clang-scan-deps/ClangScanDeps.cpp (+1) 


``diff
diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
index a4a03b88b205175..dcdf1c171f6d731 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -51,8 +51,11 @@ enum class ScanningOptimizations {
   /// Remove unused header search paths including header maps.
   HeaderSearch = 1,
 
-  LLVM_MARK_AS_BITMASK_ENUM(HeaderSearch),
-  All = HeaderSearch,
+  /// Remove warnings from system modules.
+  SystemWarnings = 2,
+
+  LLVM_MARK_AS_BITMASK_ENUM(SystemWarnings),
+  All = HeaderSearch | SystemWarnings,
   Default = All
 };
 
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 5d95bb305bc38d8..9099c18391e4d29 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -52,6 +52,28 @@ static void optimizeHeaderSearchOpts(HeaderSearchOptions 
&Opts,
 Opts.UserEntries.push_back(Entries[Idx]);
 }
 
+static void optimizeDiagnosticOpts(DiagnosticOptions &Opts,
+   bool IsSystemModule) {
+  // If this is not a system module or -Wsystem-headers was passed, don't
+  // optimize.
+  if (!IsSystemModule)
+return;
+  bool Wsystem_headers = false;
+  for (StringRef Opt : Opts.Warnings) {
+bool isPositive = !Opt.consume_front("no-");
+if (Opt == "system-headers")
+  Wsystem_headers = isPositive;
+  }
+  if (Wsystem_headers)
+return;
+
+  // Remove all warning flags. System modules suppress most, but not all,
+  // warnings.
+  Opts.Warnings.clear();
+  Opts.UndefPrefixes.clear();
+  Opts.Remarks.clear();
+}
+
 static std::vector splitString(std::string S, char Separator) {
   SmallVector Segments;
   StringRef(S).split(Segments, Separator, /*MaxSplit=*/-1, 
/*KeepEmpty=*/false);
@@ -532,6 +554,10 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module 
*M) {
 if (any(MDC.OptimizeArgs & ScanningOptimizations::HeaderSearch))
   
optimizeHeaderSearchOpts(BuildInvocation.getMutHeaderSearchOpts(),
*MDC.ScanInstance.getASTReader(), *MF);
+if (any(MDC.OptimizeArgs & ScanningOptimizations::SystemWarnings))
+  optimizeDiagnosticOpts(
+  BuildInvocation.getMutDiagnosticOpts(),
+  BuildInvocation.getFrontendOpts().IsSystemModule);
   });
 
   MDC.associateWithContextHash(CI, MD);
diff --git a/clang/test/ClangScanDeps/optimize-system-warnings.m 
b/clang/test/ClangScanDeps/optimize-system-warnings.m
new file mode 100644
index 000..d61724c6f18fff8
--- /dev/null
+++ b/clang/test/ClangScanDeps/optimize-system-warnings.m
@@ -0,0 +1,84 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > 
%t/build/compile-commands.json
+// RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \
+// RUN:   -j 1 -format experimental-full -optimize-args=system-warnings > 
%t/deps.db
+// RUN: cat %t/deps.db | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK:  {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "A"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "B"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK:]
+// CHECK:  }
+
+//--- build/compile-commands.json.in
+
+[
+{
+  "directory": "DIR",
+  "command": "clang -c DIR/A.m -isystem modules/A -I modules/B -fmodules 
-fmodule

[clang] [clang][DependencyScanner] Remove all warning flags when suppressing warnings (PR #71612)

2023-11-07 Thread Michael Spencer via cfe-commits

https://github.com/Bigcheese created 
https://github.com/llvm/llvm-project/pull/71612

Since system modules don't emit most warnings, remove the warning flags to 
increase module reuse.

>From 6c8c4cde5698a1693ad64a14a156030f249032a6 Mon Sep 17 00:00:00 2001
From: Michael Spencer 
Date: Tue, 7 Nov 2023 14:02:38 -1000
Subject: [PATCH] [clang][DependencyScanner] Remove all warning flags when
 suppressing warnings

Since system modules don't emit most warnings, remove the warning
flags to increase module reuse.
---
 .../DependencyScanningService.h   |  7 +-
 .../DependencyScanning/ModuleDepCollector.cpp | 26 ++
 .../ClangScanDeps/optimize-system-warnings.m  | 84 +++
 clang/tools/clang-scan-deps/ClangScanDeps.cpp |  1 +
 4 files changed, 116 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/ClangScanDeps/optimize-system-warnings.m

diff --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
index a4a03b88b205175..dcdf1c171f6d731 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -51,8 +51,11 @@ enum class ScanningOptimizations {
   /// Remove unused header search paths including header maps.
   HeaderSearch = 1,
 
-  LLVM_MARK_AS_BITMASK_ENUM(HeaderSearch),
-  All = HeaderSearch,
+  /// Remove warnings from system modules.
+  SystemWarnings = 2,
+
+  LLVM_MARK_AS_BITMASK_ENUM(SystemWarnings),
+  All = HeaderSearch | SystemWarnings,
   Default = All
 };
 
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp 
b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index 5d95bb305bc38d8..9099c18391e4d29 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -52,6 +52,28 @@ static void optimizeHeaderSearchOpts(HeaderSearchOptions 
&Opts,
 Opts.UserEntries.push_back(Entries[Idx]);
 }
 
+static void optimizeDiagnosticOpts(DiagnosticOptions &Opts,
+   bool IsSystemModule) {
+  // If this is not a system module or -Wsystem-headers was passed, don't
+  // optimize.
+  if (!IsSystemModule)
+return;
+  bool Wsystem_headers = false;
+  for (StringRef Opt : Opts.Warnings) {
+bool isPositive = !Opt.consume_front("no-");
+if (Opt == "system-headers")
+  Wsystem_headers = isPositive;
+  }
+  if (Wsystem_headers)
+return;
+
+  // Remove all warning flags. System modules suppress most, but not all,
+  // warnings.
+  Opts.Warnings.clear();
+  Opts.UndefPrefixes.clear();
+  Opts.Remarks.clear();
+}
+
 static std::vector splitString(std::string S, char Separator) {
   SmallVector Segments;
   StringRef(S).split(Segments, Separator, /*MaxSplit=*/-1, 
/*KeepEmpty=*/false);
@@ -532,6 +554,10 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module 
*M) {
 if (any(MDC.OptimizeArgs & ScanningOptimizations::HeaderSearch))
   
optimizeHeaderSearchOpts(BuildInvocation.getMutHeaderSearchOpts(),
*MDC.ScanInstance.getASTReader(), *MF);
+if (any(MDC.OptimizeArgs & ScanningOptimizations::SystemWarnings))
+  optimizeDiagnosticOpts(
+  BuildInvocation.getMutDiagnosticOpts(),
+  BuildInvocation.getFrontendOpts().IsSystemModule);
   });
 
   MDC.associateWithContextHash(CI, MD);
diff --git a/clang/test/ClangScanDeps/optimize-system-warnings.m 
b/clang/test/ClangScanDeps/optimize-system-warnings.m
new file mode 100644
index 000..d61724c6f18fff8
--- /dev/null
+++ b/clang/test/ClangScanDeps/optimize-system-warnings.m
@@ -0,0 +1,84 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > 
%t/build/compile-commands.json
+// RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \
+// RUN:   -j 1 -format experimental-full -optimize-args=system-warnings > 
%t/deps.db
+// RUN: cat %t/deps.db | sed 's:\?:/:g' | FileCheck %s -DPREFIX=%/t
+
+// CHECK:  {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "A"
+// CHECK-NEXT: },
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file":
+// CHECK-NEXT:   "command-line": [
+// CHECK-NOT:  "-W
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "{{.*}}",
+// CHECK-NEXT:   "file-deps": [
+// CHECK:],
+// CHECK-NEXT:   "name": "B"
+// C

[clang] [llvm] [clang][DepScan] Make OptimizeArgs a bit mask enum and enable by default (PR #71588)

2023-11-07 Thread Michael Spencer via cfe-commits

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


[clang] fb07d9c - [clang][DepScan] Make OptimizeArgs a bit mask enum and enable by default (#71588)

2023-11-07 Thread via cfe-commits

Author: Michael Spencer
Date: 2023-11-07T16:06:59-08:00
New Revision: fb07d9cc096f4a0c2473dee064c427edc2a83157

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

LOG: [clang][DepScan] Make OptimizeArgs a bit mask enum and enable by default 
(#71588)

Make it easier to control which optimizations are enabled by making
OptimizeArgs a bit masked enum. There's currently only one such
optimization, but more will be added in followup commits.

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningService.cpp
clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/header-search-pruning-transitive.c
clang/test/ClangScanDeps/header-search-pruning.cpp
clang/test/ClangScanDeps/modules-symlink-dir-from-module.c
clang/test/ClangScanDeps/modules-symlink-dir.c
clang/tools/clang-scan-deps/ClangScanDeps.cpp
clang/tools/clang-scan-deps/Opts.td
llvm/include/llvm/ADT/BitmaskEnum.h

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
index 109cf049a65231e..a4a03b88b205175 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLING_DEPENDENCYSCANNING_DEPENDENCYSCANNINGSERVICE_H
 
 #include "clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h"
+#include "llvm/ADT/BitmaskEnum.h"
 
 namespace clang {
 namespace tooling {
@@ -44,19 +45,31 @@ enum class ScanningOutputFormat {
   P1689,
 };
 
+enum class ScanningOptimizations {
+  None = 0,
+
+  /// Remove unused header search paths including header maps.
+  HeaderSearch = 1,
+
+  LLVM_MARK_AS_BITMASK_ENUM(HeaderSearch),
+  All = HeaderSearch,
+  Default = All
+};
+
 /// The dependency scanning service contains shared configuration and state 
that
 /// is used by the individual dependency scanning workers.
 class DependencyScanningService {
 public:
-  DependencyScanningService(ScanningMode Mode, ScanningOutputFormat Format,
-bool OptimizeArgs = false,
-bool EagerLoadModules = false);
+  DependencyScanningService(
+  ScanningMode Mode, ScanningOutputFormat Format,
+  ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default,
+  bool EagerLoadModules = false);
 
   ScanningMode getMode() const { return Mode; }
 
   ScanningOutputFormat getFormat() const { return Format; }
 
-  bool canOptimizeArgs() const { return OptimizeArgs; }
+  ScanningOptimizations getOptimizeArgs() const { return OptimizeArgs; }
 
   bool shouldEagerLoadModules() const { return EagerLoadModules; }
 
@@ -68,7 +81,7 @@ class DependencyScanningService {
   const ScanningMode Mode;
   const ScanningOutputFormat Format;
   /// Whether to optimize the modules' command-line arguments.
-  const bool OptimizeArgs;
+  const ScanningOptimizations OptimizeArgs;
   /// Whether to set up command-lines to load PCM files eagerly.
   const bool EagerLoadModules;
   /// The global file system cache.

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
index 778d579bfb50154..0f607862194b316 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningWorker.h
@@ -116,7 +116,7 @@ class DependencyScanningWorker {
   llvm::IntrusiveRefCntPtr DepFS;
   ScanningOutputFormat Format;
   /// Whether to optimize the modules' command-line arguments.
-  bool OptimizeArgs;
+  ScanningOptimizations OptimizeArgs;
   /// Whether to set up command-lines to load PCM files eagerly.
   bool EagerLoadModules;
 };

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index f5dbb26452da4e6..051363b075de997 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -16,6 +16,7 @@
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/PPCallbacks.h"
 #include "clang/Serialization/ASTReader.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "ll

[PATCH] D158266: [OpenMP] Patch for Support to loop bind clause : Checking Parent Region

2023-11-07 Thread David Pagan via Phabricator via cfe-commits
ddpagan added a comment.

Is there a github PR associated with this? If yes, what is the PR? If not, one 
should be created that includes a fix for the teams loop/loop error issue. 
Please add me as a reviewer. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158266

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


[clang-tools-extra] [clangd][RFC] Add container field to remote index Refs grpc method (PR #71605)

2023-11-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: dupes (tdupes)


Changes

call hierarchy cannot be enhanced via the remote index because the Refs 
returned by the remote index do not have the ID of its container. 

---
Full diff: https://github.com/llvm/llvm-project/pull/71605.diff


2 Files Affected:

- (modified) clang-tools-extra/clangd/index/remote/Index.proto (+1) 
- (modified) clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
(+1) 


``diff
diff --git a/clang-tools-extra/clangd/index/remote/Index.proto 
b/clang-tools-extra/clangd/index/remote/Index.proto
index 3072299d8f345f2..33bf095d88598f5 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -81,6 +81,7 @@ message Symbol {
 message Ref {
   optional SymbolLocation location = 1;
   optional uint32 kind = 2;
+  optional string container = 3;
 }
 
 message SymbolInfo {
diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 7e31ada18a65797..192d6d08fe58cb1 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -189,6 +189,7 @@ llvm::Expected Marshaller::fromProtobuf(const 
Ref &Message) {
 return Location.takeError();
   Result.Location = *Location;
   Result.Kind = static_cast(Message.kind());
+  Result.Container = SymbolId(Ref.container());
   return Result;
 }
 

``




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


[clang-tools-extra] [clangd][RFC] Add container field to remote index Refs grpc method (PR #71605)

2023-11-07 Thread via cfe-commits

https://github.com/tdupes created 
https://github.com/llvm/llvm-project/pull/71605

call hierarchy cannot be enhanced via the remote index because the Refs 
returned by the remote index do not have the ID of its container. 

>From 4b8ab9e39c974b4cfa6573eb0589116cac3101e5 Mon Sep 17 00:00:00 2001
From: dup 
Date: Fri, 3 Nov 2023 09:03:24 -0700
Subject: [PATCH] Add container field to remote index Refs grpc method

---
 clang-tools-extra/clangd/index/remote/Index.proto| 1 +
 .../clangd/index/remote/marshalling/Marshalling.cpp  | 1 +
 2 files changed, 2 insertions(+)

diff --git a/clang-tools-extra/clangd/index/remote/Index.proto 
b/clang-tools-extra/clangd/index/remote/Index.proto
index 3072299d8f345f2..33bf095d88598f5 100644
--- a/clang-tools-extra/clangd/index/remote/Index.proto
+++ b/clang-tools-extra/clangd/index/remote/Index.proto
@@ -81,6 +81,7 @@ message Symbol {
 message Ref {
   optional SymbolLocation location = 1;
   optional uint32 kind = 2;
+  optional string container = 3;
 }
 
 message SymbolInfo {
diff --git a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp 
b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
index 7e31ada18a65797..192d6d08fe58cb1 100644
--- a/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ b/clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -189,6 +189,7 @@ llvm::Expected Marshaller::fromProtobuf(const 
Ref &Message) {
 return Location.takeError();
   Result.Location = *Location;
   Result.Kind = static_cast(Message.kind());
+  Result.Container = SymbolId(Ref.container());
   return Result;
 }
 

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


[llvm] [clang] [DebugMetadata][DwarfDebug] Clone uniqued function-local types after metadata loading (PR #68986)

2023-11-07 Thread Vladislav Dzhidzhoev via cfe-commits

dzhidzhoev wrote:

Reverted due to Chromium build crash 
https://bugs.chromium.org/p/chromium/issues/detail?id=1500022.

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


[clang] 6beddd6 - Revert "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)"

2023-11-07 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-11-08T00:29:24+01:00
New Revision: 6beddd668adf8e6bddbbc58ec02e4728dd889e9e

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

LOG: Revert "[DebugMetadata][DwarfDebug] Support function-local types in 
lexical block scopes (4/7)"

This caused assert:
llvm/llvm/lib/CodeGen/AsmPrinter/DwarfFile.cpp:110:
void llvm::DwarfFile::addScopeVariable(LexicalScope *, DbgVariable *):
Assertion `Ret.second' failed.

See comments https://reviews.llvm.org/D144006#4656350.

This reverts commit 3b449bd46a11a55a40cbc0016a99b202fa05248e.

Added: 
llvm/test/DebugInfo/Generic/split-dwarf-local-import.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import2.ll
llvm/test/DebugInfo/Generic/split-dwarf-local-import3.ll

Modified: 
clang/test/CodeGen/debug-info-codeview-unnamed.c
clang/test/CodeGen/debug-info-unused-types.c
clang/test/CodeGen/debug-info-unused-types.cpp
clang/test/CodeGenCXX/debug-info-access.cpp
clang/test/CodeGenCXX/debug-info-anon-union-vars.cpp
clang/test/CodeGenCXX/debug-info-codeview-unnamed.cpp
clang/test/CodeGenCXX/debug-info-gline-tables-only-codeview.cpp
clang/test/CodeGenCXX/debug-lambda-this.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/include/llvm/IR/DebugInfo.h
llvm/lib/Bitcode/Reader/MetadataLoader.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/DIBuilder.cpp
llvm/lib/IR/DebugInfo.cpp
llvm/lib/IR/Verifier.cpp
llvm/lib/Transforms/Utils/CloneFunction.cpp
llvm/test/Bitcode/upgrade-cu-locals.ll
llvm/test/Bitcode/upgrade-cu-locals.ll.bc
llvm/test/DebugInfo/Generic/verifier-invalid-disubprogram.ll
llvm/test/DebugInfo/X86/set.ll
llvm/unittests/Transforms/Utils/CloningTest.cpp

Removed: 
llvm/test/Bitcode/clone-local-types.ll
llvm/test/DebugInfo/Generic/inlined-local-type.ll
llvm/test/DebugInfo/Generic/lexical-block-retained-types.ll
llvm/test/DebugInfo/Generic/lexical-block-types.ll
llvm/test/DebugInfo/X86/local-type-as-template-parameter.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import2.ll
llvm/test/DebugInfo/X86/split-dwarf-local-import3.ll



diff  --git a/clang/test/CodeGen/debug-info-codeview-unnamed.c 
b/clang/test/CodeGen/debug-info-codeview-unnamed.c
index 16ffb3682236f18..bd2a7543e56b2ba 100644
--- a/clang/test/CodeGen/debug-info-codeview-unnamed.c
+++ b/clang/test/CodeGen/debug-info-codeview-unnamed.c
@@ -8,23 +8,23 @@ int main(int argc, char* argv[], char* arge[]) {
   //
   struct { int bar; } one = {42};
   //
-  // LINUX:  [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType(
+  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // LINUX-SAME: type: [[TYPE_OF_ONE:![0-9]+]]
+  // LINUX-SAME: )
+  // LINUX:  [[TYPE_OF_ONE]] = distinct !DICompositeType(
   // LINUX-SAME: tag: DW_TAG_structure_type
   // LINUX-NOT:  name:
   // LINUX-NOT:  identifier:
   // LINUX-SAME: )
-  // LINUX:  !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // LINUX-SAME: type: [[TYPE_OF_ONE]]
-  // LINUX-SAME: )
   //
-  // MSVC:   [[TYPE_OF_ONE:![0-9]+]] = distinct !DICompositeType
+  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
+  // MSVC-SAME:  type: [[TYPE_OF_ONE:![0-9]+]]
+  // MSVC-SAME:  )
+  // MSVC:   [[TYPE_OF_ONE]] = distinct !DICompositeType
   // MSVC-SAME:  tag: DW_TAG_structure_type
   // MSVC-NOT:   name:
   // MSVC-NOT:   identifier:
   // MSVC-SAME:  )
-  // MSVC:   !{{[0-9]+}} = !DILocalVariable(name: "one"
-  // MSVC-SAME:  type: [[TYPE_OF_ONE]]
-  // MSVC-SAME:  )
 
   return 0;
 }

diff  --git a/clang/test/CodeGen/debug-info-unused-types.c 
b/clang/test/CodeGen/debug-info-unused-types.c
index 31d608d92a06b41..3e9f7b07658e36e 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,15 +18,13 @@ void quux(void) {
 // CHECK: !DICompileUnit{{.+}}retainedTypes: [[RETTYPES:![0-9]+]]
 // CHECK: [[TYPE0:![0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, 
name: "bar"
 // CHECK: [[TYPE1:![0-9]+]] = !DIEnumerator(name: "BAR"
-// CHECK: [[RETTYPES]] = !{[[TYPE2:![0-9]+]], [[TYPE3:![0-9]+]], [[TYPE0]], 
[[TYPE4:![0-9]+]], {{![0-9]+}}}
-// CHECK: [[TYPE2]] = !DIDerivedType(tag: DW_TAG_typedef, name: "my_int"
-// CHECK: [[TYPE3]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "foo"
-// CHECK: [[TYPE4]] = distinct !DICompositeType(tag: DW_TAG_union_type, name: 
"baz"
-// CHECK: [[SP:![0-9]+]] = distinct !DISubprogram(name: "quux", {{.*}}, 
retainedNodes: [[SPRETNODES:![0-9]+]]
-// CHECK

[clang] Add ability for clang-format-diff to exit with non-0 status (PR #70883)

2023-11-07 Thread via cfe-commits

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

Let go without the option for now

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-11-07 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev added a comment.

In D144006#4656371 , @aeubanks wrote:

> Is there any issue with mixing IR built with 
> `LLVMContext::enableDebugTypeODRUniquing()` and without? I'm suspecting that 
> ThinLTO is mixing Rust and Clang IR which set that differently.

Apparently, it's an issue with ThinLTO that might be caused by a change in 
MetadataLoader https://github.com/llvm/llvm-project/pull/68986.
Is there a way to get a repro like this one 
https://bugs.chromium.org/p/chromium/issues/detail?id=1487910#c3 if it's not 
too complicated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[PATCH] D123235: [OpenMP] atomic compare fail : Parser & AST support

2023-11-07 Thread Chi Chun Chen 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 rG086b65340cca: [OpenMP] atomic compare fail : Parser & 
AST support (authored by koops, committed by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123235

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/atomic_ast_print.cpp
  clang/test/OpenMP/atomic_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -209,6 +209,7 @@
 def OMPC_Update : Clause<"update"> { let clangClass = "OMPUpdateClause"; }
 def OMPC_Capture : Clause<"capture"> { let clangClass = "OMPCaptureClause"; }
 def OMPC_Compare : Clause<"compare"> { let clangClass = "OMPCompareClause"; }
+def OMPC_Fail : Clause<"fail"> { let clangClass = "OMPFailClause"; }
 def OMPC_SeqCst : Clause<"seq_cst"> { let clangClass = "OMPSeqCstClause"; }
 def OMPC_AcqRel : Clause<"acq_rel"> { let clangClass = "OMPAcqRelClause"; }
 def OMPC_Acquire : Clause<"acquire"> { let clangClass = "OMPAcquireClause"; }
@@ -637,7 +638,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Target : Directive<"target"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -2227,6 +2227,7 @@
 CHECK_SIMPLE_CLAUSE(Doacross, OMPC_doacross)
 CHECK_SIMPLE_CLAUSE(OmpxAttribute, OMPC_ompx_attribute)
 CHECK_SIMPLE_CLAUSE(OmpxBare, OMPC_ompx_bare)
+CHECK_SIMPLE_CLAUSE(Fail, OMPC_fail)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
 CHECK_REQ_SCALAR_INT_CLAUSE(NumTasks, OMPC_num_tasks)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2402,6 +2402,8 @@
 
 void OMPClauseEnqueue::VisitOMPCompareClause(const OMPCompareClause *) {}
 
+void OMPClauseEnqueue::VisitOMPFailClause(const OMPFailClause *) {}
+
 void OMPClauseEnqueue::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}
 
 void OMPClauseEnqueue::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Index: clang/test/OpenMP/atomic_messages.cpp
===
--- clang/test/OpenMP/atomic_messages.cpp
+++ clang/test/OpenMP/atomic_messages.cpp
@@ -958,6 +958,24 @@
 // expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'capture' clause}}
 #pragma omp atomic compare compare capture capture
   { v = a; if (a > b) a = b; }
+// expected-error@+1 {{expected 'compare' clause with the 'fail' modifier}}
+#pragma omp atomic fail(seq_cst)
+  if(v == a) { v = a; }
+// expected-error@+1 {{expected '(' after 'fail'}}
+#pragma omp atomic compare fail
+  if(v < a) { v = a; }
+// expected-error@+1 {{expected a memory order clause}}
+#pragma omp atomic compare fail(capture)
+  if(v < a) { v = a; }
+ // expected-error@+2 {{expected ')'}}
+ // expected-note@+1 {{to match this '('}}
+#pragma omp atomic compare fail(seq_cst | acquire)
+  if(v < a) { v = a; }
+// expected-error@+1 {{directive '#pragma omp atomic' cannot contain more than one 'fail' clause}}
+#pragma omp atomic compare fail(relaxed) fail(seq_cst)
+  if(v < a) { v = a; }
+
+
 #endif
   // expected-note@+1 {{in instantiation of function template specialization 'mixed' requested here}}
   return mixed();
Index: clang/test/OpenMP/atomic_ast_print.cpp
===
--- clang/test/OpenMP/atomic_ast_print.cpp
+++ clang/test/OpenMP/atomic_ast_print.cpp
@@ -226,6 +226,16 @@
   { v = a; if (a < b) { a = b; } }
 #pragma omp atomic compare capture hint(6)
   { v = a == b; if (v) a = c; }
+#pragma omp atomic compare fail(acq_rel)
+  { if (a < c) { a = c; } }
+#pragma omp atomic compare fail(acquire)
+  { if (a < c) { a = c; } }
+#pragma omp atomic compare fail(release)
+  { if (a < c) { a = c; } }
+#pragma omp atomic compare fail(relaxed)
+  { if (a < c) { a =

[clang] 086b653 - [OpenMP] atomic compare fail : Parser & AST support

2023-11-07 Thread Chi Chun Chen via cfe-commits

Author: Sunil Kuravinakop
Date: 2023-11-07T16:57:50-06:00
New Revision: 086b65340cca2648a2a91a0a47d28c7d9bafd1e5

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

LOG: [OpenMP] atomic compare fail : Parser & AST support

This is a support for " #pragma omp atomic compare fail ". It has Parser & AST 
support for now.

Reviewed By: tianshilei1992, ABataev

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

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/OpenMPKinds.def
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/atomic_ast_print.cpp
clang/test/OpenMP/atomic_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 549f12e87df597a..f7ecffe6154af80 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -2513,6 +2513,104 @@ class OMPRelaxedClause final : public OMPClause {
   }
 };
 
+/// This represents 'fail' clause in the '#pragma omp atomic'
+/// directive.
+///
+/// \code
+/// #pragma omp atomic compare fail
+/// \endcode
+/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
+class OMPFailClause final : public OMPClause {
+
+  // FailParameter is a memory-order-clause. Storing the ClauseKind is
+  // sufficient for our purpose.
+  OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
+  SourceLocation FailParameterLoc;
+  SourceLocation LParenLoc;
+
+  friend class OMPClauseReader;
+
+  /// Sets the location of '(' in fail clause.
+  void setLParenLoc(SourceLocation Loc) {
+LParenLoc = Loc;
+  }
+
+  /// Sets the location of memoryOrder clause argument in fail clause.
+  void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }
+
+  /// Sets the mem_order clause for 'atomic compare fail' directive.
+  void setFailParameter(OpenMPClauseKind FailParameter) {
+switch (FailParameter) {
+case llvm::omp::OMPC_acq_rel:
+case llvm::omp::OMPC_acquire:
+  this->FailParameter = llvm::omp::OMPC_acquire;
+  break;
+case llvm::omp::OMPC_relaxed:
+case llvm::omp::OMPC_release:
+  this->FailParameter = llvm::omp::OMPC_relaxed;
+  break;
+case llvm::omp::OMPC_seq_cst:
+  this->FailParameter = llvm::omp::OMPC_seq_cst;
+  break;
+default:
+  this->FailParameter = llvm::omp::OMPC_unknown;
+  break;
+}
+  }
+
+public:
+  /// Build 'fail' clause.
+  ///
+  /// \param StartLoc Starting location of the clause.
+  /// \param EndLoc Ending location of the clause.
+  OMPFailClause(SourceLocation StartLoc, SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}
+
+  OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation 
FailParameterLoc,
+SourceLocation StartLoc, SourceLocation LParenLoc,
+SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
+FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {
+
+setFailParameter(FailParameter);
+  }
+
+  /// Build an empty clause.
+  OMPFailClause()
+  : OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}
+
+  child_range children() {
+return child_range(child_iterator(), child_iterator());
+  }
+
+  const_child_range children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  child_range used_children() {
+return child_range(child_iterator(), child_iterator());
+  }
+  const_child_range used_children() const {
+return const_child_range(const_child_iterator(), const_child_iterator());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == llvm::omp::OMPC_fail;
+  }
+
+  /// Gets the location of '(' (for the parameter) in fail clause.
+  SourceLocation getLParenLoc() const {
+return LParenLoc;
+  }
+
+  /// Gets the location of Fail Parameter (type memory-order-clause) in
+  /// fail clause.
+  SourceLocation getFailParameterLoc() const { return FailParameterLoc; }
+
+  /// Gets the parameter (type memory-order-clause) in Fail clause.
+  OpenMPClauseKind getFailParameter() const { return Fai

[clang] [OpenMP] Add a missing 'const' (NFC) (PR #71596)

2023-11-07 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mike Rice (mikerice1969)


Changes



---
Full diff: https://github.com/llvm/llvm-project/pull/71596.diff


1 Files Affected:

- (modified) clang/include/clang/AST/StmtOpenMP.h (+1-1) 


``diff
diff --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 2725747e051e728..62164339153573c 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -994,7 +994,7 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
   unsigned getNumAssociatedLoops() const { return getLoopsNumber(); }
 
   /// Return the number of loops generated by this loop transformation.
-  unsigned getNumGeneratedLoops() { return NumGeneratedLoops; }
+  unsigned getNumGeneratedLoops() const { return NumGeneratedLoops; }
 
   /// Get the de-sugared statements after the loop transformation.
   ///

``




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


[clang] [OpenMP] Add a missing 'const' (NFC) (PR #71596)

2023-11-07 Thread Mike Rice via cfe-commits

https://github.com/mikerice1969 created 
https://github.com/llvm/llvm-project/pull/71596

None

>From 41f147c79a0a32fa541e7fb99cb2053b8f4b7ea2 Mon Sep 17 00:00:00 2001
From: Mike Rice 
Date: Tue, 7 Nov 2023 14:51:55 -0800
Subject: [PATCH] [OpenMP] Add a missing 'const' (NFC)

---
 clang/include/clang/AST/StmtOpenMP.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/StmtOpenMP.h 
b/clang/include/clang/AST/StmtOpenMP.h
index 2725747e051e728..62164339153573c 100644
--- a/clang/include/clang/AST/StmtOpenMP.h
+++ b/clang/include/clang/AST/StmtOpenMP.h
@@ -994,7 +994,7 @@ class OMPLoopTransformationDirective : public 
OMPLoopBasedDirective {
   unsigned getNumAssociatedLoops() const { return getLoopsNumber(); }
 
   /// Return the number of loops generated by this loop transformation.
-  unsigned getNumGeneratedLoops() { return NumGeneratedLoops; }
+  unsigned getNumGeneratedLoops() const { return NumGeneratedLoops; }
 
   /// Get the de-sugared statements after the loop transformation.
   ///

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-11-07 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

F30438826: i.ll 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[clang] [SEH] Fix assertin when return scalar value from __try block. (PR #71488)

2023-11-07 Thread Reid Kleckner via cfe-commits

https://github.com/rnk commented:

Makes sense, small nit

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


[clang] [SEH] Fix assertin when return scalar value from __try block. (PR #71488)

2023-11-07 Thread Reid Kleckner via cfe-commits


@@ -3507,6 +3507,9 @@ static llvm::StoreInst 
*findDominatingStoreToReturnValue(CodeGenFunction &CGF) {
   return nullptr;
 // These aren't actually possible for non-coerced returns, and we
 // only care about non-coerced returns on this code path.
+// All memory instructions inside __try block are volatile.

rnk wrote:

Functionally, this is adjusting the conditions of the assert, can you move the 
change into the assert? Essentially, make the assert be:
```
  assert(!SI->isAtomic() && (!SI->isVolatile() || 
CGF.currentFunctionUsesSEHTry()));
```

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


[clang] [SEH] Fix assertin when return scalar value from __try block. (PR #71488)

2023-11-07 Thread Reid Kleckner via cfe-commits

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


[clang] [clang][analyzer] Support `fputc` in StreamChecker (PR #71518)

2023-11-07 Thread Michael Maitland via cfe-commits

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


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-07 Thread Amy Huang via cfe-commits

https://github.com/amykhuang updated 
https://github.com/llvm/llvm-project/pull/70877

>From 18369263a3160963b943cd8574edaa212b6d0996 Mon Sep 17 00:00:00 2001
From: Amy Huang 
Date: Tue, 31 Oct 2023 16:45:17 -0700
Subject: [PATCH 1/2] Fix attribute plugins

---
 clang/lib/Sema/ParsedAttr.cpp | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index f59b01efe7ed8f4..ad95a61d7587264 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -193,11 +193,20 @@ bool ParsedAttr::isTypeAttr() const { return 
getInfo().IsType; }
 bool ParsedAttr::isStmtAttr() const { return getInfo().IsStmt; }
 
 bool ParsedAttr::existsInTarget(const TargetInfo &Target) const {
-  return getInfo().existsInTarget(Target) &&
- getInfo().spellingExistsInTarget(Target,
-  getAttributeSpellingListIndex());
+  Kind K = getParsedKind();
+
+  // If the attribute has a target-specific spelling, check that it exists.
+  // Only call this if the attr is not ignored/unknown. For most targets, this
+  // function just returns true.
+  bool HasSpelling = K != IgnoredAttribute && K != UnknownAttribute &&
+ K != NoSemaHandlerAttribute;
+  bool TargetSpecificSpellingExists = !HasSpelling ||
+getInfo().spellingExistsInTarget(Target, getAttributeSpellingListIndex());
+
+  return getInfo().existsInTarget(Target) && TargetSpecificSpellingExists;
 }
 
+
 bool ParsedAttr::isKnownToGCC() const { return getInfo().IsKnownToGCC; }
 
 bool ParsedAttr::isSupportedByPragmaAttribute() const {

>From f068257dac770959b130bc8b33eb4689e5dd47db Mon Sep 17 00:00:00 2001
From: Amy Huang 
Date: Tue, 7 Nov 2023 14:51:06 -0800
Subject: [PATCH 2/2] clang-format

---
 clang/lib/Sema/ParsedAttr.cpp | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index ad95a61d7587264..06c213267c7ef5d 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -200,13 +200,13 @@ bool ParsedAttr::existsInTarget(const TargetInfo &Target) 
const {
   // function just returns true.
   bool HasSpelling = K != IgnoredAttribute && K != UnknownAttribute &&
  K != NoSemaHandlerAttribute;
-  bool TargetSpecificSpellingExists = !HasSpelling ||
-getInfo().spellingExistsInTarget(Target, getAttributeSpellingListIndex());
+  bool TargetSpecificSpellingExists =
+  !HasSpelling ||
+  getInfo().spellingExistsInTarget(Target, 
getAttributeSpellingListIndex());
 
   return getInfo().existsInTarget(Target) && TargetSpecificSpellingExists;
 }
 
-
 bool ParsedAttr::isKnownToGCC() const { return getInfo().IsKnownToGCC; }
 
 bool ParsedAttr::isSupportedByPragmaAttribute() const {

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


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-07 Thread Amy Huang via cfe-commits

amykhuang wrote:

Updated the PR description and the patch. The existing 
`clang/test/Frontend/plugin-attribute.cpp` seems sufficient for test coverage. 
(I guess it wasn't being tested on bots though, otherwise we would have seen 
it?)

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


[clang-tools-extra] [clangd] Allow hover over 128-bit variable without crashing (PR #71415)

2023-11-07 Thread Björn Pettersson via cfe-commits


@@ -0,0 +1,29 @@
+# RUN: clangd -lit-test < %s | FileCheck %s

bjope wrote:

Thanks. I'm not that familiar with the clangd test cases. But I've update the 
pull-request with a unittest instead.

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


[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-07 Thread Amy Huang via cfe-commits

https://github.com/amykhuang updated 
https://github.com/llvm/llvm-project/pull/70877

>From 18369263a3160963b943cd8574edaa212b6d0996 Mon Sep 17 00:00:00 2001
From: Amy Huang 
Date: Tue, 31 Oct 2023 16:45:17 -0700
Subject: [PATCH] Fix attribute plugins

---
 clang/lib/Sema/ParsedAttr.cpp | 15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp
index f59b01efe7ed8f4..ad95a61d7587264 100644
--- a/clang/lib/Sema/ParsedAttr.cpp
+++ b/clang/lib/Sema/ParsedAttr.cpp
@@ -193,11 +193,20 @@ bool ParsedAttr::isTypeAttr() const { return 
getInfo().IsType; }
 bool ParsedAttr::isStmtAttr() const { return getInfo().IsStmt; }
 
 bool ParsedAttr::existsInTarget(const TargetInfo &Target) const {
-  return getInfo().existsInTarget(Target) &&
- getInfo().spellingExistsInTarget(Target,
-  getAttributeSpellingListIndex());
+  Kind K = getParsedKind();
+
+  // If the attribute has a target-specific spelling, check that it exists.
+  // Only call this if the attr is not ignored/unknown. For most targets, this
+  // function just returns true.
+  bool HasSpelling = K != IgnoredAttribute && K != UnknownAttribute &&
+ K != NoSemaHandlerAttribute;
+  bool TargetSpecificSpellingExists = !HasSpelling ||
+getInfo().spellingExistsInTarget(Target, getAttributeSpellingListIndex());
+
+  return getInfo().existsInTarget(Target) && TargetSpecificSpellingExists;
 }
 
+
 bool ParsedAttr::isKnownToGCC() const { return getInfo().IsKnownToGCC; }
 
 bool ParsedAttr::isSupportedByPragmaAttribute() const {

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


[clang-tools-extra] [clangd] Allow hover over 128-bit variable without crashing (PR #71415)

2023-11-07 Thread Björn Pettersson via cfe-commits

https://github.com/bjope updated https://github.com/llvm/llvm-project/pull/71415

From 2b1af2bff6432a50eb725adf86e6cfcc52cc020b Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson 
Date: Mon, 6 Nov 2023 17:27:28 +0100
Subject: [PATCH 1/2] [clangd] Allow hover over 128-bit variable without
 crashing

When hovering over variables larger than 64 bits, with more than
64 active bits, there were assertion failures since Hover is trying
to print the value as a 64-bit hex value.

There is already protection avoiding to call printHex if there is
more than 64 significant bits. And we already truncate and print
negative values using only 32 bits, when possible. So we can simply
truncate values with more than 64 bits to avoid the assert when using
getZExtValue. The result will be that for example a negative 128 bit
variable is printed using 64 bits, when possible.

There is still no support for printing more than 64 bits. That would
involve more changes since for example llvm::FormatterNumber is
limited to 64 bits.
---
 clang-tools-extra/clangd/Hover.cpp|  4 +++-
 clang-tools-extra/clangd/test/hover2.test | 29 +++
 2 files changed, 32 insertions(+), 1 deletion(-)
 create mode 100644 clang-tools-extra/clangd/test/hover2.test

diff --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 7f7b5513dff6fee..a868d3bb4e3fa1d 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -408,7 +408,9 @@ void fillFunctionTypeAndParams(HoverInfo &HI, const Decl *D,
 // -2=> 0xfffe
 // -2^32 => 0x
 static llvm::FormattedNumber printHex(const llvm::APSInt &V) {
-  uint64_t Bits = V.getZExtValue();
+  assert(V.getSignificantBits() <= 64 && "Can't print more than 64 bits.");
+  uint64_t Bits =
+  V.getBitWidth() > 64 ? V.trunc(64).getZExtValue() : V.getZExtValue();
   if (V.isNegative() && V.getSignificantBits() <= 32)
 return llvm::format_hex(uint32_t(Bits), 0);
   return llvm::format_hex(Bits, 0);
diff --git a/clang-tools-extra/clangd/test/hover2.test 
b/clang-tools-extra/clangd/test/hover2.test
new file mode 100644
index 000..24d82bde20a7823
--- /dev/null
+++ b/clang-tools-extra/clangd/test/hover2.test
@@ -0,0 +1,29 @@
+# RUN: clangd -lit-test < %s | FileCheck %s
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"__int128_t
 bar = -4;\n"}}}
+---
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":13}}}
+#  CHECK:  "id": 1,
+# CHECK-NEXT:  "jsonrpc": "2.0",
+# CHECK-NEXT:  "result": {
+# CHECK-NEXT:"contents": {
+# CHECK-NEXT:  "kind": "plaintext",
+# CHECK-NEXT:   "value": "variable bar\n\nType: __int128_t (aka 
__int128)\nValue = -4 (0xfffc)\n\n__int128_t bar = -4"
+# CHECK-NEXT: },
+# CHECK-NEXT: "range": {
+# CHECK-NEXT:   "end": {
+# CHECK-NEXT: "character": 14,
+# CHECK-NEXT: "line": 0
+# CHECK-NEXT:   },
+# CHECK-NEXT:   "start": {
+# CHECK-NEXT: "character": 11,
+# CHECK-NEXT: "line": 0
+# CHECK-NEXT:   }
+# CHECK-NEXT: }
+# CHECK-NEXT:   }
+# CHECK-NEXT: }
+---
+{"jsonrpc":"2.0","id":3,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}

From 6e2347e28284e0b7e582fc2d51180b4340f15910 Mon Sep 17 00:00:00 2001
From: Bjorn Pettersson 
Date: Tue, 7 Nov 2023 23:38:19 +0100
Subject: [PATCH 2/2] Fixup (should be squashed)

Replace the test case a with a unittest.
---
 clang-tools-extra/clangd/test/hover2.test | 29 ---
 .../clangd/unittests/HoverTests.cpp   | 11 +++
 2 files changed, 11 insertions(+), 29 deletions(-)
 delete mode 100644 clang-tools-extra/clangd/test/hover2.test

diff --git a/clang-tools-extra/clangd/test/hover2.test 
b/clang-tools-extra/clangd/test/hover2.test
deleted file mode 100644
index 24d82bde20a7823..000
--- a/clang-tools-extra/clangd/test/hover2.test
+++ /dev/null
@@ -1,29 +0,0 @@
-# RUN: clangd -lit-test < %s | FileCheck %s
-{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}

-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"__int128_t
 bar = -4;\n"}}}

-{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"test:///main.cpp"},"position":{"line":0,"character":13}}}
-#  CHECK:  "id": 1,
-# CHECK-NEXT:  "jsonrpc": "2.0",
-# CHECK-NEXT:  "result": {
-# CHECK-NEXT:"contents": {
-# CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:   "value": "variable bar\n\nType: __int128_t (aka 
__int128)\nValue = -4 (0xfffc)\n\n__int128_t bar 

[clang] Fix to attribute plugins reaching an unreachable (PR #70877)

2023-11-07 Thread Amy Huang via cfe-commits

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


[llvm] [clang] [WebAssembly] Refactor Wasm Reference Types as TargetExtType (PR #71540)

2023-11-07 Thread Thomas Lively via cfe-commits

https://github.com/tlively commented:

Very cool! LGTM so far. It's really nice that we can delete that entire pass 
out of the backend. Where can I read more about these new target extension 
types?

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-11-07 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev added a comment.

In D144006#4656350 , @aeubanks wrote:

> Heads up, we're seeing issues from this in Chrome again, will try to post a 
> reduced repro (https://crbug.com/1500022)
>
> The reduced repro I found crashed very far back, so I'm guessing this patch 
> caused bad debug info which triggers an existing issue that doesn't handle 
> bad debug info.

Could you provide a reproducer for that crash?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[clang] [BoundsSafety] Initial documentation for -fbounds-safety (PR #70749)

2023-11-07 Thread Dan Liew via cfe-commits

delcypher wrote:

@rapidsna The CI is complaining about trailing whitespace

https://buildkite.com/llvm-project/clang-ci/builds/5817#018b830d-fb91-40df-8956-9e4dd325d27f

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


[llvm] [clang] [clang][DepScan] Make OptimizeArgs a bit mask enum and enable by default (PR #71588)

2023-11-07 Thread Ben Langmuir via cfe-commits

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


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


  1   2   3   4   >