[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 532800.
eopXD added a comment.

Fix ManualCodegen for vfadd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fmf.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[clang-tools-extra] ab32cc6 - [include-cleaner] Bailout on invalid code for the command-line tool

2023-06-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-06-20T09:07:27+02:00
New Revision: ab32cc6c02f539bc87e71fefc9670f28a7fc7f56

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

LOG: [include-cleaner] Bailout on invalid code for the command-line tool

The binary tool only works on working source code, if the source code is
not compilable, don't perform any analysis and edits.

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 918f7c968ef90..008da47164092 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -108,10 +108,18 @@ class Action : public clang::ASTFrontendAction {
   }
 
   void EndSourceFile() override {
+const auto &SM = getCompilerInstance().getSourceManager();
+if (SM.getDiagnostics().hasUncompilableErrorOccurred()) {
+  llvm::errs()
+  << "Skipping file " << getCurrentFile()
+  << " due to compiler errors. clang-include-cleaner expects to "
+ "work on compilable source code.\n";
+  return;
+}
+
 if (!HTMLReportPath.empty())
   writeHTML();
 
-const auto &SM = getCompilerInstance().getSourceManager();
 auto &HS = getCompilerInstance().getPreprocessor().getHeaderSearchInfo();
 llvm::StringRef Path =
 SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();



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


[PATCH] D153271: [include-cleaner] Bailout on invalid code for the command-line tool

2023-06-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGab32cc6c02f5: [include-cleaner] Bailout on invalid code for 
the command-line tool (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153271

Files:
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -108,10 +108,18 @@
   }
 
   void EndSourceFile() override {
+const auto &SM = getCompilerInstance().getSourceManager();
+if (SM.getDiagnostics().hasUncompilableErrorOccurred()) {
+  llvm::errs()
+  << "Skipping file " << getCurrentFile()
+  << " due to compiler errors. clang-include-cleaner expects to "
+ "work on compilable source code.\n";
+  return;
+}
+
 if (!HTMLReportPath.empty())
   writeHTML();
 
-const auto &SM = getCompilerInstance().getSourceManager();
 auto &HS = getCompilerInstance().getPreprocessor().getHeaderSearchInfo();
 llvm::StringRef Path =
 SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -108,10 +108,18 @@
   }
 
   void EndSourceFile() override {
+const auto &SM = getCompilerInstance().getSourceManager();
+if (SM.getDiagnostics().hasUncompilableErrorOccurred()) {
+  llvm::errs()
+  << "Skipping file " << getCurrentFile()
+  << " due to compiler errors. clang-include-cleaner expects to "
+ "work on compilable source code.\n";
+  return;
+}
+
 if (!HTMLReportPath.empty())
   writeHTML();
 
-const auto &SM = getCompilerInstance().getSourceManager();
 auto &HS = getCompilerInstance().getPreprocessor().getHeaderSearchInfo();
 llvm::StringRef Path =
 SM.getFileEntryForID(SM.getMainFileID())->tryGetRealPathName();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152696: Prevent deadlocks in death tests.

2023-06-20 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D152696#4430238 , @mgorny wrote:

> This change is causing a lot of unittests to fail on Gentoo. I've tested both 
> on amd64 and arm64; on amd64 additionally the test suite seems to hang.
> ...

Sorry, only just saw this now. I'll revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152696

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


[PATCH] D153321: [OpenMP] Fix lvalue reference type generation in untied task loop

2023-06-20 Thread Zhiheng Xie via Phabricator via cfe-commits
eastb233 created this revision.
eastb233 added a reviewer: ABataev.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
eastb233 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

For variables with lvalue reference type in untied task loop,
it now wrongly sets its actual type as ElementType. It should
be converted to pointer type.

It fixes https://github.com/llvm/llvm-project/issues/62965


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153321

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/taskloop_untied_codegen.cpp


Index: clang/test/OpenMP/taskloop_untied_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/taskloop_untied_codegen.cpp
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 2
+// RUN: %clang_cc1 -verify -triple aarch64-unknown-linux-gnu -fopenmp -x c++ 
-std=c++11 -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local void @_Z15taskloop_untiedv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[WORK:%.*]] = alloca [100 x float], align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr 
@[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr 
@[[GLOB1]], i32 [[TMP0]], i32 0, i64 472, i64 1, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds 
[[STRUCT__KMP_PRIVATES_T:%.*]], ptr [[TMP3]], i32 0, i32 3
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[TMP4]], ptr 
align 4 [[WORK]], i64 400, i1 false)
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = call i32 @__kmpc_omp_task(ptr @[[GLOB1]], i32 
[[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+void taskloop_untied() {
+  float work[100];
+#pragma omp task untied
+  for (auto cb : work)
+cb = 1.0;
+}
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4852,6 +4852,8 @@
   // a pointer to this memory.
   for (auto &Pair : UntiedLocalVars) {
 QualType VDType = Pair.first->getType().getNonReferenceType();
+if (Pair.first->getType()->isLValueReferenceType())
+  VDType = CGF.getContext().getPointerType(VDType);
 if (isAllocatableDecl(Pair.first)) {
   llvm::Value *Ptr = CGF.Builder.CreateLoad(Pair.second.first);
   Address Replacement(


Index: clang/test/OpenMP/taskloop_untied_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/taskloop_untied_codegen.cpp
@@ -0,0 +1,26 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -verify -triple aarch64-unknown-linux-gnu -fopenmp -x c++ -std=c++11 -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+
+// CHECK-LABEL: define dso_local void @_Z15taskloop_untiedv
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[WORK:%.*]] = alloca [100 x float], align 4
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr @[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr @[[GLOB1]], i32 [[TMP0]], i32 0, i64 472, i64 1, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP1]], i32 0, i32 0
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T_WITH_PRIVATES]], ptr [[TMP1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [[STRUCT__KMP_PRIVATES_T:%.*]], ptr [[TMP3]], i32 0, i32 3
+// CHECK-NEXT:call void @llvm.memcpy.p0.p0.i64(ptr align 8 [[TMP4]], ptr align 4 [[WORK]], i64 400, i1 false)
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP2]], i32 0, i32 2
+// CHECK-NEXT:store i32 0, ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = call i32 @__kmpc_omp_task(ptr @[[GLOB1]], i32 [[TMP0]], ptr [[TMP1]])
+// CHECK-NEXT:ret void
+//
+void taskloop_untied() {
+  float work[100];
+#pragma omp task unt

[PATCH] D153251: [clangd] Index the type of a non-type template parameter

2023-06-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153251

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


[PATCH] D153251: [clangd] Index the type of a non-type template parameter

2023-06-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3075023850b: [clangd] Index the type of a non-type template 
parameter (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153251

Files:
  clang/lib/Index/IndexDecl.cpp
  clang/unittests/Index/IndexTests.cpp


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -392,6 +392,20 @@
 Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference),
WrittenAt(Position(4, 16));
 }
+
+TEST(IndexTest, NonTypeTemplateParameter) {
+  std::string Code = R"cpp(
+enum class Foobar { foo };
+template 
+constexpr void func() {}
+  )cpp";
+  auto Index = std::make_shared();
+  tooling::runToolOnCode(std::make_unique(Index), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("Foobar"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 15);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -705,6 +705,7 @@
   IndexCtx.handleReference(C->getNamedConcept(), 
C->getConceptNameLoc(),
Parent, TTP->getLexicalDeclContext());
   } else if (const auto *NTTP = dyn_cast(TP)) {
+IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent);
 if (NTTP->hasDefaultArgument())
   IndexCtx.indexBody(NTTP->getDefaultArgument(), Parent);
   } else if (const auto *TTPD = dyn_cast(TP)) {


Index: clang/unittests/Index/IndexTests.cpp
===
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -392,6 +392,20 @@
 Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference),
WrittenAt(Position(4, 16));
 }
+
+TEST(IndexTest, NonTypeTemplateParameter) {
+  std::string Code = R"cpp(
+enum class Foobar { foo };
+template 
+constexpr void func() {}
+  )cpp";
+  auto Index = std::make_shared();
+  tooling::runToolOnCode(std::make_unique(Index), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("Foobar"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 15);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang
Index: clang/lib/Index/IndexDecl.cpp
===
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -705,6 +705,7 @@
   IndexCtx.handleReference(C->getNamedConcept(), C->getConceptNameLoc(),
Parent, TTP->getLexicalDeclContext());
   } else if (const auto *NTTP = dyn_cast(TP)) {
+IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent);
 if (NTTP->hasDefaultArgument())
   IndexCtx.indexBody(NTTP->getDefaultArgument(), Parent);
   } else if (const auto *TTPD = dyn_cast(TP)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] c307502 - [clangd] Index the type of a non-type template parameter

2023-06-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-06-20T03:22:52-04:00
New Revision: c3075023850bbb7276085198d42b69938d48380d

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

LOG: [clangd] Index the type of a non-type template parameter

Fixes https://github.com/clangd/clangd/issues/1666

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

Added: 


Modified: 
clang/lib/Index/IndexDecl.cpp
clang/unittests/Index/IndexTests.cpp

Removed: 




diff  --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp
index 882e02836d4fb..1c04aa17d53fb 100644
--- a/clang/lib/Index/IndexDecl.cpp
+++ b/clang/lib/Index/IndexDecl.cpp
@@ -705,6 +705,7 @@ class IndexingDeclVisitor : public 
ConstDeclVisitor {
   IndexCtx.handleReference(C->getNamedConcept(), 
C->getConceptNameLoc(),
Parent, TTP->getLexicalDeclContext());
   } else if (const auto *NTTP = dyn_cast(TP)) {
+IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent);
 if (NTTP->hasDefaultArgument())
   IndexCtx.indexBody(NTTP->getDefaultArgument(), Parent);
   } else if (const auto *TTPD = dyn_cast(TP)) {

diff  --git a/clang/unittests/Index/IndexTests.cpp 
b/clang/unittests/Index/IndexTests.cpp
index 88ad63b97b92a..690673a1072b0 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -392,6 +392,20 @@ TEST(IndexTest, EnumBase) {
 Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference),
WrittenAt(Position(4, 16));
 }
+
+TEST(IndexTest, NonTypeTemplateParameter) {
+  std::string Code = R"cpp(
+enum class Foobar { foo };
+template 
+constexpr void func() {}
+  )cpp";
+  auto Index = std::make_shared();
+  tooling::runToolOnCode(std::make_unique(Index), Code);
+  EXPECT_THAT(Index->Symbols,
+  Contains(AllOf(QName("Foobar"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 15);
+}
+
 } // namespace
 } // namespace index
 } // namespace clang



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


[PATCH] D152696: Prevent deadlocks in death tests.

2023-06-20 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152696

___
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-06-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

This change triggers failed asserts when compiling code for at least arm and 
aarch64. It is reproducible with this reduced testcase:

  $ cat repro.c
  typedef long long a;
  typedef int b();
  int c, d;
  long e, f;
  short g, j;
  void *h;
  short i[];
  char k;
  a l, m, n;
  void o();
  int p();
  void r(b u) {
struct {
  a q;
  a s, t
} a;
e || p(c, d);
f = l = a.s;
for (; a.s;)
  if (p(c, a, &a, a))
a.t &&a.q &&p(a, k);
if (g)
  u(i, m, n, 0, h);
f = a.s;
for (; a.s;)
  a.t &&a.q &&p(c, a, k);
if (g && j)
  o(g);
  }
  int v(short *, long long, long long, int, void *) { r(v); } 
  $ clang -target aarch64-linux-gnu -c repro.c -g -O2
  clang: ../lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2334: virtual void 
llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction*): Assertion 
`LScopes.getAbstractScopesList().size() == NumAbstractSubprograms && 
"getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed. 




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] D153314: [clang] Replace uses of CGBuilderTy::CreateElementBitCast (NFC)

2023-06-20 Thread Nikita Popov via Phabricator via cfe-commits
nikic added inline comments.



Comment at: clang/lib/CodeGen/CGNonTrivialStruct.cpp:370
 llvm::Value *DstArrayEnd =
 CGF.Builder.CreateInBoundsGEP(CGF.Int8Ty, BC.getPointer(), 
SizeInBytes);
 DstArrayEnd = CGF.Builder.CreateBitCast(

Only `BC.getPointer()` is used, so you can omit the withElementType.



Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:3121-3123
+  This = This.withElementType(CGM.Int8Ty);
   llvm::Value *VBPtr = Builder.CreateInBoundsGEP(
   This.getElementType(), This.getPointer(), VBPtrOffset, "vbptr");





Comment at: clang/lib/CodeGen/MicrosoftCXXABI.cpp:3126
   VBPtr = Builder.CreateBitCast(VBPtr,
 
CGM.Int32Ty->getPointerTo(0)->getPointerTo(This.getAddressSpace()));
 

Can drop this bitcast while here.



Comment at: clang/lib/CodeGen/Targets/AArch64.cpp:523
 Address Addr = Address(Load, CGF.Int8Ty, SlotSize);
-return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+return Addr.withElementType(CGF.ConvertTypeForMem(Ty));
   }

Can inline this withElementType call into Address ctor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153314

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


[PATCH] D153006: [clang][dataflow] Perform deep copies in copy and move operations.

2023-06-20 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 532812.
mboehme added a comment.

Now that integer literals are associated with `Value`s, use them in tests
instead of using a helper variable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153006

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/RecordOps.h
  clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
  clang/include/clang/Analysis/FlowSensitive/Value.h
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/RecordOps.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
  clang/unittests/Analysis/FlowSensitive/RecordOpsTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -12,7 +12,7 @@
 #include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
-#include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
+#include "clang/Analysis/FlowSensitive/RecordOps.h"
 #include "clang/Analysis/FlowSensitive/StorageLocation.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "clang/Basic/LangStandard.h"
@@ -38,59 +38,22 @@
 using ::testing::NotNull;
 using ::testing::UnorderedElementsAre;
 
-using BuiltinOptions = DataflowAnalysisContext::Options;
-
-template 
-llvm::Error
-runDataflowReturnError(llvm::StringRef Code, Matcher Match,
-   DataflowAnalysisOptions Options,
-   LangStandard::Kind Std = LangStandard::lang_cxx17,
-   llvm::StringRef TargetFun = "target") {
-  using ast_matchers::hasName;
-  llvm::SmallVector ASTBuildArgs = {
-  // -fnodelayed-template-parsing is the default everywhere but on Windows.
-  // Set it explicitly so that tests behave the same on Windows as on other
-  // platforms.
-  "-fsyntax-only", "-fno-delayed-template-parsing",
-  "-std=" +
-  std::string(LangStandard::getLangStandardForKind(Std).getName())};
-  AnalysisInputs AI(
-  Code, hasName(TargetFun),
-  [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext &C,
-  Environment &Env) {
-return NoopAnalysis(
-C,
-DataflowAnalysisOptions{
-UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
-: std::optional()});
-  });
-  AI.ASTBuildArgs = ASTBuildArgs;
-  if (Options.BuiltinOpts)
-AI.BuiltinOptions = *Options.BuiltinOpts;
-  return checkDataflow(
-  std::move(AI),
-  /*VerifyResults=*/
-  [&Match](
-  const llvm::StringMap> &Results,
-  const AnalysisOutputs &AO) { Match(Results, AO.ASTCtx); });
-}
-
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
+template 
+void runDataflow(llvm::StringRef Code, VerifyResultsT VerifyResults,
  DataflowAnalysisOptions Options,
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  llvm::StringRef TargetFun = "target") {
   ASSERT_THAT_ERROR(
-  runDataflowReturnError(Code, Match, Options, Std, TargetFun),
+  runDataflowReturnError(Code, VerifyResults, Options, Std, TargetFun),
   llvm::Succeeded());
 }
 
-template 
-void runDataflow(llvm::StringRef Code, Matcher Match,
+template 
+void runDataflow(llvm::StringRef Code, VerifyResultsT VerifyResults,
  LangStandard::Kind Std = LangStandard::lang_cxx17,
  bool ApplyBuiltinTransfer = true,
  llvm::StringRef TargetFun = "target") {
-  runDataflow(Code, std::move(Match),
+  runDataflow(Code, std::move(VerifyResults),
   {ApplyBuiltinTransfer ? BuiltinOptions{}
 : std::optional()},
   Std, TargetFun);
@@ -2012,22 +1975,19 @@
 };
 
 void target() {
-  A Foo;
-  A Bar;
-  (void)Foo.Baz;
+  A Foo = { 1 };
+  A Bar = { 2 };
   // [[p1]]
   Foo = Bar;
   // [[p2]]
+  Foo.Baz = 3;
+  // [[p3]]
 }
   )";
   runDataflow(
   Code,
   [](const llvm::StringMap> &Results,
  ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p1", "p2"));
-const Environment &Env1 = getEnvironmentAtAnnotation(Results, "p1");
-const Environment &Env2 = getEnvironmentAtAnnotation(Results, "p2");
-
 const ValueDecl *FooD

[PATCH] D153282: [clang][DebugInfo] Emit DW_AT_deleted on any deleted member function

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc146df961876: [clang][DebugInfo] Emit DW_AT_deleted on any 
deleted member function (authored by Michael137).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153282

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-deleted.cpp
  llvm/test/DebugInfo/X86/DW_AT_deleted.ll

Index: llvm/test/DebugInfo/X86/DW_AT_deleted.ll
===
--- llvm/test/DebugInfo/X86/DW_AT_deleted.ll
+++ llvm/test/DebugInfo/X86/DW_AT_deleted.ll
@@ -12,6 +12,9 @@
 ; 
 ;   deleted(deleted &&) = delete;
 ;   deleted &operator=(deleted &&) = delete;
+;
+;   void func() && = delete;
+;   static void bar() = delete;
 ; 
 ;   ~deleted() = default;
 ; };
@@ -48,6 +51,16 @@
 ; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (0008) string = "operator=")
 ; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
 
+; CHECK: DW_TAG_subprogram [10]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000b) string = "_ZNO7deleted4funcEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000c) string = "func")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
+; CHECK: DW_TAG_subprogram [11]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000d) string = "_ZN7deleted3barEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000e) string = "bar")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
 ; ModuleID = 'debug-info-deleted.cpp'
 source_filename = "debug-info-deleted.cpp"
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
@@ -58,8 +71,8 @@
 ; Function Attrs: noinline nounwind optnone uwtable
 define dso_local void @_Z3foov() #0 !dbg !7 {
   %1 = alloca %class.deleted, align 1
-  call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !DIExpression()), !dbg !34
-  ret void, !dbg !35
+  call void @llvm.dbg.declare(metadata ptr %1, metadata !10, metadata !DIExpression()), !dbg !39
+  ret void, !dbg !40
 }
 
 ; Function Attrs: nounwind readnone speculatable willreturn
@@ -84,7 +97,7 @@
 !9 = !{null}
 !10 = !DILocalVariable(name: "obj1", scope: !7, file: !1, line: 15, type: !11)
 !11 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "deleted", file: !1, line: 1, size: 8, flags: DIFlagTypePassByReference, elements: !12, identifier: "_ZTS7deleted")
-!12 = !{!13, !17, !22, !26, !30, !33}
+!12 = !{!13, !17, !22, !26, !30, !33, !34, !36}
 !13 = !DISubprogram(name: "deleted", scope: !11, file: !1, line: 3, type: !14, scopeLine: 3, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
 !14 = !DISubroutineType(types: !15)
 !15 = !{null, !16}
@@ -106,5 +119,10 @@
 !31 = !DISubroutineType(types: !32)
 !32 = !{!25, !16, !29}
 !33 = !DISubprogram(name: "~deleted", scope: !11, file: !1, line: 11, type: !14, scopeLine: 11, flags: DIFlagPublic | DIFlagPrototyped, spFlags: 0)
-!34 = !DILocation(line: 15, column: 13, scope: !7)
-!35 = !DILocation(line: 16, column: 3, scope: !7)
+!34 = !DISubprogram(name: "func", linkageName: "_ZNO7deleted4funcEv", scope: !11, file: !1, line: 13, type: !35, scopeLine: 13, flags: DIFlagPublic | DIFlagPrototyped | DIFlagRValueReference, spFlags: DISPFlagDeleted)   
+!35 = !DISubroutineType(flags: DIFlagRValueReference, types: !15) 
+!36 = !DISubprogram(name: "bar", linkageName: "_ZN7deleted3barEv", scope: !11, file: !1, line: 15, type: !37, scopeLine: 15, flags: DIFlagPublic | DIFlagPrototyped | DIFlagStaticMember, spFlags: DISPFlagDeleted) 
+!37 = !DISubroutineType(types: !38)
+!38 = !{null}
+!39 = !DILocation(line: 15, column: 13, scope: !7)
+!40 = !DILocation(line: 16, column: 3, scope: !7)
Index: clang/test/CodeGenCXX/debug-info-deleted.cpp
===
--- clang/test/CodeGenCXX/debug-info-deleted.cpp
+++ clang/test/CodeGenCXX/debug-info-deleted.cpp
@@ -11,6 +11,8 @@
 // ATTR: DISubprogram(name: "operator=", linkageName: "_ZN7deletedaSERKS_", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "deleted", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "operator=", linkageName: "_ZN7deletedaSEOS_", {{.*}}, flags: DIFlagPublic | DIFlagPrototyped, sp

[clang] c146df9 - [clang][DebugInfo] Emit DW_AT_deleted on any deleted member function

2023-06-20 Thread Michael Buch via cfe-commits

Author: Michael Buch
Date: 2023-06-20T09:19:19+01:00
New Revision: c146df9618764d5548c38ce61edc45147094b26f

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

LOG: [clang][DebugInfo] Emit DW_AT_deleted on any deleted member function

Currently we emit `DW_AT_deleted` for `deleted` special-member
functions (i.e., ctors/dtors). However, in C++ one can mark any
member function as deleted. This patch expands the set of member
functions for which we emit `DW_AT_deleted`.

The DWARFv5 spec section 5.7.8 says:
```

In C++, a member function may be declared as deleted. This prevents the 
compiler from
generating a default implementation of a special member function such as a 
constructor
or destructor, and can affect overload resolution when used on other member 
functions.


If the member function entry has been declared as deleted, then that entry has a
DW_AT_deleted attribute.
```

Thus this change is conforming.

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

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGenCXX/debug-info-deleted.cpp
llvm/test/DebugInfo/X86/DW_AT_deleted.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 2fd2227720a2a..f049a682cfed6 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1945,27 +1945,8 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
 ContainingType = RecordTy;
   }
 
-  // We're checking for deleted C++ special member functions
-  // [Ctors,Dtors, Copy/Move]
-  auto checkAttrDeleted = [&](const auto *Method) {
-if (Method->getCanonicalDecl()->isDeleted())
-  SPFlags |= llvm::DISubprogram::SPFlagDeleted;
-  };
-
-  switch (Method->getKind()) {
-
-  case Decl::CXXConstructor:
-  case Decl::CXXDestructor:
-checkAttrDeleted(Method);
-break;
-  case Decl::CXXMethod:
-if (Method->isCopyAssignmentOperator() ||
-Method->isMoveAssignmentOperator())
-  checkAttrDeleted(Method);
-break;
-  default:
-break;
-  }
+  if (Method->getCanonicalDecl()->isDeleted())
+SPFlags |= llvm::DISubprogram::SPFlagDeleted;
 
   if (Method->isNoReturn())
 Flags |= llvm::DINode::FlagNoReturn;

diff  --git a/clang/test/CodeGenCXX/debug-info-deleted.cpp 
b/clang/test/CodeGenCXX/debug-info-deleted.cpp
index d7d0b6dba49ea..564f7fff00fb9 100644
--- a/clang/test/CodeGenCXX/debug-info-deleted.cpp
+++ b/clang/test/CodeGenCXX/debug-info-deleted.cpp
@@ -11,6 +11,8 @@
 // ATTR: DISubprogram(name: "operator=", linkageName: "_ZN7deletedaSERKS_", 
{{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "deleted", {{.*}}, flags: DIFlagPublic | 
DIFlagPrototyped, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "operator=", linkageName: "_ZN7deletedaSEOS_", 
{{.*}}, flags: DIFlagPublic | DIFlagPrototyped, spFlags: DISPFlagDeleted
+// ATTR: DISubprogram(name: "func", {{.*}}, flags: DIFlagPublic | 
DIFlagPrototyped | DIFlagRValueReference, spFlags: DISPFlagDeleted
+// ATTR: DISubprogram(name: "bar", {{.*}}, flags: DIFlagPublic | 
DIFlagPrototyped | DIFlagStaticMember, spFlags: DISPFlagDeleted
 // ATTR: DISubprogram(name: "~deleted", {{.*}}, flags: DIFlagPublic | 
DIFlagPrototyped,
 class deleted {
 public:
@@ -23,6 +25,9 @@ class deleted {
   deleted(deleted &&) = delete;
   deleted &operator=(deleted &&) = delete;
 
+  void func() && = delete;
+  static int bar() = delete;
+
   ~deleted() = default;
 };
 

diff  --git a/llvm/test/DebugInfo/X86/DW_AT_deleted.ll 
b/llvm/test/DebugInfo/X86/DW_AT_deleted.ll
index 805655f25813f..0311458ee5223 100644
--- a/llvm/test/DebugInfo/X86/DW_AT_deleted.ll
+++ b/llvm/test/DebugInfo/X86/DW_AT_deleted.ll
@@ -12,6 +12,9 @@
 ; 
 ;   deleted(deleted &&) = delete;
 ;   deleted &operator=(deleted &&) = delete;
+;
+;   void func() && = delete;
+;   static void bar() = delete;
 ; 
 ;   ~deleted() = default;
 ; };
@@ -48,6 +51,16 @@
 ; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (0008) string = 
"operator=")
 ; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
 
+; CHECK: DW_TAG_subprogram [10]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000b) string 
= "_ZNO7deleted4funcEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000c) string = 
"func")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
+; CHECK: DW_TAG_subprogram [11]
+; CHECK-NEXT: DW_AT_linkage_name [DW_FORM_strx1](indexed (000d) string 
= "_ZN7deleted3barEv")
+; CHECK-NEXT: DW_AT_name [DW_FORM_strx1](indexed (000e) string = "bar")
+; CHECK:  DW_AT_deleted [DW_FORM_flag_present]  (true)
+
 ; ModuleID = 'debug-info-deleted.cpp'
 source_filename = "debug-info-deleted.cpp"
 target datalayout = 
"

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-20 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

There are some test failures.

I believe there is one bug with the handling of unnamed globals. Previously we 
produced this:

  ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
UTC_ARGS: --check-globals --version 2
  ; RUN: opt -S < %s | FileCheck %s
  @0 = global i32 0
  
  ;.
  ; CHECK: @[[GLOB0:[0-9]+]] = global i32 0
  ;.
  define i32 @test() {
  ; CHECK-LABEL: define i32 @test() {
  ; CHECK-NEXT:[[V:%.*]] = load i32, ptr @[[GLOB0]], align 4
  ; CHECK-NEXT:ret i32 [[V]]
  ;
%v = load i32, ptr @0
ret i32 %v
  }

And now we instead check `CHECK: @0 = global i32 0`, so there is a mismatch 
between definition and use. I believe it does make sense to keep the wildcard 
names for unnamed globals.

On the same test case, if I keep rerunning update_test_checks on the same file, 
it keeps adding extra `CHECK: @0 = global i32 0` lines at the start (before the 
first `;.`. That didn't happen previously.




Comment at: clang/test/utils/update_cc_test_checks/Inputs/annotations.c:1
+// UTC_ARGS: --version 3
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s

It would be more typical to pass `--version 3` when calling 
update_cc_test_checks. (Note that this is only a quirk of the test setup. 
Outside tests the `--version 3` is implied for new tests.)



Comment at: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected:9
 define ptr @foo(ptr %s) nounwind uwtable readnone optsize ssp {
-; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind optsize 
ssp willreturn memory(none) uwtable
+; CHECK: Function Attrs: nofree norecurse nosync nounwind optsize ssp 
willreturn memory(none) uwtable
 ; CHECK-LABEL: define {{[^@]+}}@foo

Huh, where does this change come from?



Comment at: llvm/utils/UpdateTestChecks/common.py:991
+NamelessValue(r"META"   , "!" , r"![a-z.]+ "   , r"![0-9]+"
 , None ) ,
+]
+

Does this still comply with the formatter?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D153197: [AVR] Expand shifts during AVRISelLowering

2023-06-20 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: llvm/lib/Target/AVR/AVRISelLowering.cpp:2207
+  MF->push_back(LoopBB);
+  MachineBasicBlock *ExitBB = EntryBB->splitAt(MI, false);
+

Patryk27 wrote:
> Alright, this is wrong, after all - I've just tested it on a more elaborate 
> code in rustc and `EntryBB->removeSuccessor(ExitBB);` triggers an LLVM panic 
> (presumably because EntryBB == ExitBB).
> 
> I kinda don't understand why doing something like this:
> 
> ```
> MachineBasicBlock *ExitBB = EntryBB->splitAt(MI, false);
> 
> if (EntryBB == ExitBB) {
>   assert(EntryBB->canFallThrough() && "Expected a fallthrough block!");
>   ExitBB = EntryBB->getFallThrough();
> }
> ```
> 
> ... is not sufficient, though 👀
Is it possible to fix the 32-bit shift issue in moderate way? for example, keep 
the pass in `AVRShiftExpand.cpp`. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153197

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


[PATCH] D151397: [3/3][RISCV][POC] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd, vasub

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 532828.
eopXD added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasubu.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaaddu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasub-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasubu-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd.ll
  llvm/test/CodeGen/RISCV/rvv/vaaddu.ll
  llvm/test/CodeGen/RISCV/rvv/vasub.ll
  llvm/test/CodeGen/RISCV/rvv/vasubu.ll

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


[PATCH] D152879: [RISCV] Model vxrm control for vsmul, vssra, vssrl, vnclip, and vnclipu

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 532830.
eopXD added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152879

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vnclip-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vnclipu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-eew64-overloaded.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-eew64.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vssra-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vssrl-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/mutate-prior-vsetvli-avl.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vnclip.ll
  llvm/test/CodeGen/RISCV/rvv/vnclipu.ll
  llvm/test/CodeGen/RISCV/rvv/vsmul-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsmul-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssra-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssra-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssrl-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssrl-rv64.ll

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


[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-20 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 532831.
Fznamznon added a comment.

Rebase, fix nit, expand the test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGenCXX/consteval-cleanup.cpp
  clang/test/SemaCXX/consteval-cleanup.cpp

Index: clang/test/SemaCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/consteval-cleanup.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump | FileCheck %s
+
+// expected-no-diagnostics
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','
+  // CHECK-NEXT: BinaryOperator {{.*}} 'P':'P' ','
+  // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'A':'A'
+  // CHECK-NEXT: CXXConstructExpr {{.*}} 'A':'A'
+  // CHECK: ConstantExpr {{.*}} 'P':'P'
+  // CHECK-NOT: ExprWithCleanups
+}
+
+struct B {
+  int *p = new int(38);
+  consteval int get() { return *p; }
+  constexpr ~B() { delete p; }
+};
+
+void bar() {
+  // CHECK: bar
+  // CHECK: ExprWithCleanups
+  // CHECK-NEXT: ConstantExpr
+  int k = B().get();
+}
Index: clang/test/CodeGenCXX/consteval-cleanup.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/consteval-cleanup.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -Wno-unused-value -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s
+
+struct P {
+  consteval P() {}
+};
+
+struct A {
+  A(int v) { this->data = new int(v); }
+  ~A() { delete data; }
+private:
+  int *data;
+};
+
+void foo() {
+  for (;A(1), P(), false;);
+  // CHECK: foo
+  // CHECK: for.cond:
+  // CHECK: call void @_ZN1AC1Ei
+  // CHECK: call void @_ZN1AD1Ev
+  // CHECK: for.body
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -18170,13 +18170,11 @@
 return E;
   }
 
-  E = MaybeCreateExprWithCleanups(E);
-
   ConstantExpr *Res = ConstantExpr::Create(
   getASTContext(), E.get(),
   ConstantExpr::getStorageKind(Decl->getReturnType().getTypePtr(),
getASTContext()),
-  /*IsImmediateInvocation*/ true);
+  /*IsImmediateInvocation=*/true);
   if (Cached.hasValue())
 Res->MoveIntoResult(Cached, getASTContext());
   /// Value-dependent constant expressions should not be immediately
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -524,6 +524,10 @@
   type by the default argument promotions, and thus this is UB. Clang's
   behavior now matches GCC's behavior in C++.
   (`#38717 _`).
+- Fix missing destructor calls and therefore memory leaks in generated code
+  when an immediate invocation appears as a part of an expression that produces
+  temporaries.
+  (`#60709 _`).
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153292: [Driver][BareMetal] Error if no matching multilib

2023-06-20 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

LGTM.

One of the thoughts I mentioned offline before this patch was written was that 
maybe the error would need to be conditional, via a directive inside 
`multilib.yaml` itself – perhaps some users want to fall off the end of the 
multilib list without error and continue using the default sysroot, whereas 
others want to diagnose "sorry, no library at all is available to support your 
flags"? But I suppose there won't be a large user base who were already using 
this particular YAML technique in the former mode, or at all, because it's so 
new. And if necessary one could reorganise to put `multilib.yaml` in its own 
directory, and add a final catch-all entry pointing at the fallback sysroot. So 
it should be OK to have the error unconditional.




Comment at: clang/test/Driver/baremetal-multilib.yaml:88-90
+- Dir: arm-none-eabi/arm/v4t
+  Flags: [--target=armv4t-none-unknown-eabi]
+

I'm not sure what the purpose of this addition is. It doesn't seem to be listed 
in the expected error messages (but it's presumably being printed anyway, and 
skipped over because the checks don't say `-NEXT`?). Did it sneak in here from 
another commit, perhaps?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153292

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


[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 532836.
eopXD added a comment.

Rebase: Add `sew` parameter that other templates have added too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fmf.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[PATCH] D153292: [Driver][BareMetal] Error if no matching multilib

2023-06-20 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings marked an inline comment as done.
michaelplatings added a comment.

Thanks @simon_tatham. I agree there's definitely scope to improve this. The 
behaviour is quite specific so I kept the code in the BareMetal toolchain 
rather than as part of the core Multilib class. Other toolchains may require 
different behaviour as you say.

This change also doesn't address the layered multilib scenario. In that 
scenario multiple multilibs may be required to match to get a complete set of 
headers and libraries. But this change moves us in the right direction.




Comment at: clang/test/Driver/baremetal-multilib.yaml:88-90
+- Dir: arm-none-eabi/arm/v4t
+  Flags: [--target=armv4t-none-unknown-eabi]
+

simon_tatham wrote:
> I'm not sure what the purpose of this addition is. It doesn't seem to be 
> listed in the expected error messages (but it's presumably being printed 
> anyway, and skipped over because the checks don't say `-NEXT`?). Did it sneak 
> in here from another commit, perhaps?
Sorry I forgot to explain this already. With the new error, 
CHECK-NO-EXECUTE-ONLY-ASM started failing because no multilib variant matched. 
I added this variant to fix that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153292

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


[PATCH] D153314: [clang] Replace uses of CGBuilderTy::CreateElementBitCast (NFC)

2023-06-20 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: clang/lib/CodeGen/CGAtomic.cpp:1474
 
 Address AtomicInfo::emitCastToAtomicIntPointer(Address addr) const {
   llvm::IntegerType *ty =

as it no longer emits anything.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153314

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-20 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 532837.
abel-bernabeu added a comment.

I just this flashback...

For code coverage of one of the Lex() calls in ParseInstruction we needed one 
case
where an instruction has no operands.

We had, not one, but three. Am keeping just the "nop" case, which is the 
simplest
and most known instruction and moving it to the top of the test suite, so the 
tests
are listed in increasing complexity (from the simplest to reach test points to
the most sophisticated and least frequently used parser features).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,61 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s  --match-full-lines
+
+/*c0*/ nop /*c1*/
+# CHECK: nop	#c0	#c1
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li	a0, 0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s	ft0, nan	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s	ft0, 1.0	#c0	#c1	#c2	#c3	#c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5	#c6
+# CHECK-NEXT: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK-NEXT: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s --match-full-lines
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+# CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -107,6 +107,8 @@
 

[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 532839.
eopXD added a comment.

Add SemaChecking and corresponding test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfadd-out-of-range.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fmf.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[PATCH] D144970: [llvm-c] Remove bindings for creating legacy passes

2023-06-20 Thread YAMAMOTO Takashi via Phabricator via cfe-commits
yamt added a comment.

at least some of these stuff is used by wasm-micro-runtime. do you have a 
suggestion about how to adapt it?
https://github.com/bytecodealliance/wasm-micro-runtime/blob/72fc872afe9a51228b2a32bc7b08475b176f187f/core/iwasm/compilation/aot_compiler.c#L2666-L2670


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144970

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


[PATCH] D144970: [llvm-c] Remove bindings for creating legacy passes

2023-06-20 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D144970#4434305 , @yamt wrote:

> at least some of these stuff is used by wasm-micro-runtime. do you have a 
> suggestion about how to adapt it?
> https://github.com/bytecodealliance/wasm-micro-runtime/blob/72fc872afe9a51228b2a32bc7b08475b176f187f/core/iwasm/compilation/aot_compiler.c#L2666-L2670

You can use `LLVMRunPasses` with `lower-atomic,lower-switch` or so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144970

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


[PATCH] D153176: [Frontend] Remove ShowIncludesPretendHeader

2023-06-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153176

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


[clang] 1c64c41 - [clang][index] Fix cast warning

2023-06-20 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2023-06-20T12:22:18+02:00
New Revision: 1c64c414ed6a7ba2973f881a380d322adb5767a2

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

LOG: [clang][index] Fix cast warning

This is a follow-up to D151938 that should fix GCC's -Wcast-qual warning.

Added: 


Modified: 
clang/tools/libclang/CXFile.h

Removed: 




diff  --git a/clang/tools/libclang/CXFile.h b/clang/tools/libclang/CXFile.h
index 8cb28a7ad0051..888593b7bc751 100644
--- a/clang/tools/libclang/CXFile.h
+++ b/clang/tools/libclang/CXFile.h
@@ -15,7 +15,8 @@
 namespace clang {
 namespace cxfile {
 inline CXFile makeCXFile(OptionalFileEntryRef FE) {
-  return CXFile(FE ? &FE->getMapEntry() : nullptr);
+  return CXFile(FE ? const_cast(&FE->getMapEntry())
+   : nullptr);
 }
 
 inline OptionalFileEntryRef getFileEntryRef(CXFile File) {



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


[PATCH] D151938: [clang][index] NFCI: Make `CXFile` a `FileEntryRef`

2023-06-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/tools/libclang/CXFile.h:18
+inline CXFile makeCXFile(OptionalFileEntryRef FE) {
+  return CXFile(FE ? &FE->getMapEntry() : nullptr);
+}

uabelho wrote:
> Gcc warns here:
> ```
> ../../clang/tools/libclang/CXFile.h:18:50: warning: cast from type 'const 
> MapEntry*' {aka 'const 
> llvm::StringMapEntry >*'} to 
> type 'CXFile' {aka 'void*'} casts away qualifiers [-Wcast-qual]
> ```
> Anything that should be fixed?
Thanks, should be fixed in 1c64c414.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151938

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


[PATCH] D153296: [AST] Stop evaluate constant expression if the condition expression which in switch statement contains errors

2023-06-20 Thread Yurong via Phabricator via cfe-commits
yronglin updated this revision to Diff 532853.
yronglin added a comment.

Fix test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153296

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/switch.cpp


Index: clang/test/SemaCXX/switch.cpp
===
--- clang/test/SemaCXX/switch.cpp
+++ clang/test/SemaCXX/switch.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
 
 void test() {
   bool x = true;
@@ -146,3 +147,17 @@
 }
 
 } // namespace EmptyEnum
+
+#if __cplusplus >= 201703L
+constexpr int foo(unsigned char c) {
+switch (unknown_value) { // expected-error {{use of undeclared identifier}}
+case 0:
+return 7;
+default:
+break;
+}
+return 0;
+}
+
+static_assert(foo('d')); // expected-error {{static assertion expression is 
not an integral constant expression}}
+#endif
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4983,7 +4983,9 @@
 !EvaluateDecl(Info, SS->getConditionVariable()))
   return ESR_Failed;
 if (SS->getCond()->isValueDependent()) {
-  if (!EvaluateDependentExpr(SS->getCond(), Info))
+  // Stop evaluate if condition expression contains errors.
+  if (SS->getCond()->containsErrors() ||
+  !EvaluateDependentExpr(SS->getCond(), Info))
 return ESR_Failed;
 } else {
   if (!EvaluateInteger(SS->getCond(), Value, Info))


Index: clang/test/SemaCXX/switch.cpp
===
--- clang/test/SemaCXX/switch.cpp
+++ clang/test/SemaCXX/switch.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 %s
 
 void test() {
   bool x = true;
@@ -146,3 +147,17 @@
 }
 
 } // namespace EmptyEnum
+
+#if __cplusplus >= 201703L
+constexpr int foo(unsigned char c) {
+switch (unknown_value) { // expected-error {{use of undeclared identifier}}
+case 0:
+return 7;
+default:
+break;
+}
+return 0;
+}
+
+static_assert(foo('d')); // expected-error {{static assertion expression is not an integral constant expression}}
+#endif
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4983,7 +4983,9 @@
 !EvaluateDecl(Info, SS->getConditionVariable()))
   return ESR_Failed;
 if (SS->getCond()->isValueDependent()) {
-  if (!EvaluateDependentExpr(SS->getCond(), Info))
+  // Stop evaluate if condition expression contains errors.
+  if (SS->getCond()->containsErrors() ||
+  !EvaluateDependentExpr(SS->getCond(), Info))
 return ESR_Failed;
 } else {
   if (!EvaluateInteger(SS->getCond(), Value, Info))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 36d5034 - [clang][NFC] Drop alignment in builtin-nondeterministic-value test

2023-06-20 Thread via cfe-commits

Author: ManuelJBrito
Date: 2023-06-20T11:38:37+01:00
New Revision: 36d50348a8b12db01d786c5fa3d0ed7a911e1f68

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

LOG: [clang][NFC] Drop alignment in builtin-nondeterministic-value test

Drop alignment to allow test to run in different platforms.

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

Added: 


Modified: 
clang/test/CodeGen/builtins-nondeterministic-value.c

Removed: 




diff  --git a/clang/test/CodeGen/builtins-nondeterministic-value.c 
b/clang/test/CodeGen/builtins-nondeterministic-value.c
index aa040edf73d98..cc12f95997f04 100644
--- a/clang/test/CodeGen/builtins-nondeterministic-value.c
+++ b/clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@ typedef _Bool bool4 __attribute__((ext_vector_type(4)));
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32
+// CHECK: store i32 [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@ int clang_nondet_i( int x ) {
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float
+// CHECK: store float [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@ float clang_nondet_f( float x ) {
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double
+// CHECK: store double [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@ double clang_nondet_d( double x ) {
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -42,19 +42,19 @@ _Bool clang_nondet_b( _Bool x) {
 
 void clang_nondet_fv( ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca <4 x float>, align
+// CHECK: [[A:%.*]] = alloca <4 x float>
 // CHECK: [[R:%.*]] = freeze <4 x float> poison
-// CHECK: store <4 x float> [[R]], ptr [[A]], align
+// CHECK: store <4 x float> [[R]], ptr [[A]]
 // CHECK: ret void
   float4 x = __builtin_nondeterministic_value(x);
 }
 
 void clang_nondet_bv( ) {
-// CHECK: [[A:%.*]] = alloca i8, align
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[V:%.*]] = freeze <4 x i1> poison
 // CHECK: [[SV:%.*]] = shufflevector <4 x i1> [[V]], <4 x i1> poison, <8 x 
i32> 
 // CHECK: [[BC:%.*]] = bitcast <8 x i1> [[SV]] to i8
-// CHECK: store i8 [[BC]], ptr [[A]], align
+// CHECK: store i8 [[BC]], ptr [[A]]
 // CHECK: ret void
   bool4 x = __builtin_nondeterministic_value(x);
 }



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


[PATCH] D152547: [clang][NFC] Drop alignment in builtin-nondeterministic-value test

2023-06-20 Thread Manuel Brito via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG36d50348a8b1: [clang][NFC] Drop alignment in 
builtin-nondeterministic-value test (authored by ManuelJBrito).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152547

Files:
  clang/test/CodeGen/builtins-nondeterministic-value.c


Index: clang/test/CodeGen/builtins-nondeterministic-value.c
===
--- clang/test/CodeGen/builtins-nondeterministic-value.c
+++ clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32
+// CHECK: store i32 [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float
+// CHECK: store float [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double
+// CHECK: store double [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -42,19 +42,19 @@
 
 void clang_nondet_fv( ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca <4 x float>, align
+// CHECK: [[A:%.*]] = alloca <4 x float>
 // CHECK: [[R:%.*]] = freeze <4 x float> poison
-// CHECK: store <4 x float> [[R]], ptr [[A]], align
+// CHECK: store <4 x float> [[R]], ptr [[A]]
 // CHECK: ret void
   float4 x = __builtin_nondeterministic_value(x);
 }
 
 void clang_nondet_bv( ) {
-// CHECK: [[A:%.*]] = alloca i8, align
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[V:%.*]] = freeze <4 x i1> poison
 // CHECK: [[SV:%.*]] = shufflevector <4 x i1> [[V]], <4 x i1> poison, <8 x 
i32> 
 // CHECK: [[BC:%.*]] = bitcast <8 x i1> [[SV]] to i8
-// CHECK: store i8 [[BC]], ptr [[A]], align
+// CHECK: store i8 [[BC]], ptr [[A]]
 // CHECK: ret void
   bool4 x = __builtin_nondeterministic_value(x);
 }


Index: clang/test/CodeGen/builtins-nondeterministic-value.c
===
--- clang/test/CodeGen/builtins-nondeterministic-value.c
+++ clang/test/CodeGen/builtins-nondeterministic-value.c
@@ -5,8 +5,8 @@
 
 int clang_nondet_i( int x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i32, align 4
-// CHECK: store i32 [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca i32
+// CHECK: store i32 [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i32 poison
 // CHECK: ret i32 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -14,8 +14,8 @@
 
 float clang_nondet_f( float x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca float, align 4
-// CHECK: store float [[X:%.*]], ptr [[A]], align 4
+// CHECK: [[A:%.*]] = alloca float
+// CHECK: store float [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze float poison
 // CHECK: ret float [[R]]
   return __builtin_nondeterministic_value(x);
@@ -23,8 +23,8 @@
 
 double clang_nondet_d( double x ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca double, align 8
-// CHECK: store double [[X:%.*]], ptr [[A]], align 8
+// CHECK: [[A:%.*]] = alloca double
+// CHECK: store double [[X:%.*]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze double poison
 // CHECK: ret double [[R]]
   return __builtin_nondeterministic_value(x);
@@ -32,9 +32,9 @@
 
 _Bool clang_nondet_b( _Bool x) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca i8, align 1
+// CHECK: [[A:%.*]] = alloca i8
 // CHECK: [[B:%.*]] = zext i1 %x to i8
-// CHECK: store i8 [[B]], ptr [[A]], align 1
+// CHECK: store i8 [[B]], ptr [[A]]
 // CHECK: [[R:%.*]] = freeze i1 poison
 // CHECK: ret i1 [[R]]
   return __builtin_nondeterministic_value(x);
@@ -42,19 +42,19 @@
 
 void clang_nondet_fv( ) {
 // CHECK-LABEL: entry
-// CHECK: [[A:%.*]] = alloca <4 x float>, align
+// CHECK: [[A:%.*]] = alloca <4 x float>
 // CHECK: [[R:%.*]] = freeze <4 x float> poison
-// CHECK: store <4 x float> [[R]], ptr [[A]], align
+// CHECK: store <4 x fl

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

2023-06-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

We're seeing assertion failures in Chromium too. Reproducer for x86_64 Linux 
here: https://bugs.chromium.org/p/chromium/issues/detail?id=1456288#c2


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] 6bea833 - Revert "Reland "[DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)" (2)"

2023-06-20 Thread Vladislav Dzhidzhoev via cfe-commits

Author: Vladislav Dzhidzhoev
Date: 2023-06-20T13:08:47+02:00
New Revision: 6bea8331f9e09ba94a225c65becd4224a1a473af

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

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

This reverts commit cb9ac7051589ea0d05507f9370d0716bef86b4ae.
It causes an assert in clang:
virtual void llvm::DwarfDebug::endFunctionImpl(const llvm::MachineFunction*): 
Assertion `LScopes.getAbstractScopesList().size() == NumAbstractSubprograms && 
"getOrCreateAbstractScope() inserted an abstract subprogram scope"' failed.
https://bugs.chromium.org/p/chromium/issues/detail?id=1456288#c2

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/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/Verifier.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

Removed: 
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 16ffb3682236f..bd2a7543e56b2 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 5bcc71f710a5c..3e9f7b07658e3 100644
--- a/clang/test/CodeGen/debug-info-unused-types.c
+++ b/clang/test/CodeGen/debug-info-unused-types.c
@@ -18,13 +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]+}}, [[TYPE5:![0-9]+]], [[TYPE6:![0-9]+]], 
[[TYPE8:![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: [[TYPE5]] = distinct !DICompositeType(tag: DW_TAG_structure_type, 
name: "y"
-// CHECK: [[TYPE6]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "z"
-

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

2023-06-20 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev added a comment.

Thank you for reports! I've reverted it.


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] D153330: [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp

2023-06-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

This will fix a false positive where a ParamVarDecl happend to be the
same name of some C standard symbol and has a global namespace.

  using A = int(int time); // we suggest  for the `int time`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153330

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -91,12 +91,14 @@
   #include "header.h"
   #include "private.h"
 
-  void $bar^bar($private^Private $p^p) {
+  void $bar^bar($private^Private p) {
 $foo^foo();
 std::$vector^vector $vconstructor^$v^v;
 $builtin^__builtin_popcount(1);
 std::$move^move(3);
   }
+  // No reference reported for the Parameter.
+  using A = int(int time);
   )cpp");
   Inputs.Code = Code.code();
   Inputs.ExtraFiles["header.h"] = guard(R"cpp(
@@ -120,7 +122,6 @@
   offsetToProviders(AST, SM),
   UnorderedElementsAre(
   Pair(Code.point("bar"), UnorderedElementsAre(MainFile)),
-  Pair(Code.point("p"), UnorderedElementsAre(MainFile)),
   Pair(Code.point("private"),
UnorderedElementsAre(PublicFile, PrivateFile)),
   Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -214,6 +214,10 @@
 return true;
   }
   bool VisitVarDecl(VarDecl *VD) {
+// Ignore the parameter decl itself (its children were handled elsewhere),
+// as they don't contribute to the main-file #include.
+if (isa(VD))
+  return true;
 // Mark declaration from definition as it needs type-checking.
 if (VD->isThisDeclarationADefinition())
   report(VD->getLocation(), VD);


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -91,12 +91,14 @@
   #include "header.h"
   #include "private.h"
 
-  void $bar^bar($private^Private $p^p) {
+  void $bar^bar($private^Private p) {
 $foo^foo();
 std::$vector^vector $vconstructor^$v^v;
 $builtin^__builtin_popcount(1);
 std::$move^move(3);
   }
+  // No reference reported for the Parameter.
+  using A = int(int time);
   )cpp");
   Inputs.Code = Code.code();
   Inputs.ExtraFiles["header.h"] = guard(R"cpp(
@@ -120,7 +122,6 @@
   offsetToProviders(AST, SM),
   UnorderedElementsAre(
   Pair(Code.point("bar"), UnorderedElementsAre(MainFile)),
-  Pair(Code.point("p"), UnorderedElementsAre(MainFile)),
   Pair(Code.point("private"),
UnorderedElementsAre(PublicFile, PrivateFile)),
   Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -214,6 +214,10 @@
 return true;
   }
   bool VisitVarDecl(VarDecl *VD) {
+// Ignore the parameter decl itself (its children were handled elsewhere),
+// as they don't contribute to the main-file #include.
+if (isa(VD))
+  return true;
 // Mark declaration from definition as it needs type-checking.
 if (VD->isThisDeclarationADefinition())
   report(VD->getLocation(), VD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Jens Massberg via Phabricator via cfe-commits
massberg created this revision.
massberg added a reviewer: kadircet.
Herald added a subscriber: arphaman.
Herald added a project: All.
massberg requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

In C++20 some binary operations can be rewritten, e.g. `a != b`
can be rewritten to `!(a == b)` if `!=` is not explicitly defined.
The `TargetFinder` hasn't considered the corresponding 
`CXXRewrittenBinaryOperator` yet. This resulted that the definition of such 
operators couldn't be found
when navigating to such a `!=` operator, see 
https://github.com/clangd/clangd/issues/1476.

In this patch we add support of `CXXRewrittenBinaryOperator` in `FindTarget`.
In such a case we redirect to the inner binary operator of the decomposed form.
E.g. in case that `a != b` has been rewritten to `!(a == b)` we go to the
`==` operator. The `==` operator might be implicitly defined (e.g. by a `<=>`
operator), but this case is already handled, see the new test.

I'm not sure if I the hover test which is added in this patch is the right one,
but at least is passed with this patch and fails without it :)

Note, that it might be a bit missleading that hovering over a `!=` refers to
"instance method operator==".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153331

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -4048,6 +4048,38 @@
   EXPECT_TRUE(H->Type);
 }
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  static_assert(Foo(1) !^= Foo(2));
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -4048,6 +4048,38 @@
   EXPECT_TRUE(H->Type);
 }
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  static_assert(Foo(1) !^= Foo(2));
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(con

[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks, this looks pretty good!

> I'm not sure if I the hover test which is added in this patch is the right 
> one,
> but at least is passed with this patch and fails without it :)

This is nice to have, but you add a unittest to FindTargetTest too? That's the 
most direct way to test this code.

This won't affect find-refs BTW, that would be handled in `refInStmt()` in 
FindTarget.cpp




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

no need to sign your work :-)



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

sammccall wrote:
> no need to sign your work :-)
can you add this to HoverTest__All instead? That way we test all details of the 
hover card



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4079
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");

if we're describing this as the spaceship operator, then the type looks wrong


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 532867.
massberg added a comment.

Fix test name


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -4048,6 +4048,38 @@
   EXPECT_TRUE(H->Type);
 }
 
+TEST(Hover, RewrittenBinaryOperatorSpaceship) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  static_assert(Foo(1) !^= Foo(2));
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -4048,6 +4048,38 @@
   EXPECT_TRUE(H->Type);
 }
 
+TEST(Hover, RewrittenBinaryOperatorSpaceship) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  static_assert(Foo(1) !^= Foo(2));
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-20 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn updated this revision to Diff 532868.
hnrklssn marked 4 inline comments as done.
hnrklssn added a comment.

Added back regex matchers for anonymous global values


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

Files:
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c
  clang/test/utils/update_cc_test_checks/Inputs/annotations.c.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.generated.expected
  
clang/test/utils/update_cc_test_checks/Inputs/generated-funcs.c.no-generated.expected
  clang/test/utils/update_cc_test_checks/annotations.test
  clang/test/utils/update_cc_test_checks/check-globals.test
  clang/test/utils/update_cc_test_checks/generated-funcs.test
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.generated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/generated_funcs_prefix_reuse.ll.nogenerated.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.globals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.noglobals.expected
  
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/various_ir_values.ll.funcsig.transitiveglobals.expected
  llvm/test/tools/UpdateTestChecks/update_test_checks/various_ir_values.test
  llvm/utils/UpdateTestChecks/common.py
  llvm/utils/update_cc_test_checks.py
  llvm/utils/update_test_checks.py

Index: llvm/utils/update_test_checks.py
===
--- llvm/utils/update_test_checks.py
+++ llvm/utils/update_test_checks.py
@@ -79,7 +79,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -195,7 +198,7 @@
 common.dump_input_lines(output_lines, ti, prefix_set, ";")
 
 args = ti.args
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -205,6 +208,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 
@@ -272,6 +276,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 True,
+args.check_globals,
 )
 )
 has_checked_pre_function_globals = True
@@ -301,7 +306,7 @@
 continue
 is_in_function = is_in_function_start = True
 
-if args.check_globals:
+if args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -311,6 +316,7 @@
 global_vars_seen_dict,
 args.preserve_names,
 False,
+args.check_globals,
 )
 )
 if ti.args.gen_unused_prefix_body:
Index: llvm/utils/update_cc_test_checks.py
===
--- llvm/utils/update_cc_test_checks.py
+++ llvm/utils/update_cc_test_checks.py
@@ -205,7 +205,10 @@
 )
 parser.add_argument(
 "--check-globals",
-action="store_true",
+nargs="?",
+const="all",
+default="default",
+choices=["none", "smart", "all"],
 help="Check global entries (global variables, metadata, attribute sets, ...) for functions",
 )
 parser.add_argument("tests", nargs="+")
@@ -436,7 +439,7 @@
 is_filtered=builder.is_filtered(),
 )
 
-if ti.args.check_globals:
+if ti.args.check_globals != 'none':
 generated_prefixes.extend(
 common.add_global_checks(
 builder.global_var_dict(),
@@ -444,8 +447,9 @@
 run_list,
 output_lines,
 global_vars_seen_dict,
+False,
 True,
-True,
+  

[PATCH] D148216: Add support for annotations in UpdateTestChecks (NFC)

2023-06-20 Thread Henrik G Olsson via Phabricator via cfe-commits
hnrklssn added a comment.

In D148216#4434171 , @nikic wrote:

> There are some test failures.
>
> I believe there is one bug with the handling of unnamed globals. Previously 
> we produced this:
>
>   ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 
> UTC_ARGS: --check-globals --version 2
>   ; RUN: opt -S < %s | FileCheck %s
>   @0 = global i32 0
>   
>   ;.
>   ; CHECK: @[[GLOB0:[0-9]+]] = global i32 0
>   ;.
>   define i32 @test() {
>   ; CHECK-LABEL: define i32 @test() {
>   ; CHECK-NEXT:[[V:%.*]] = load i32, ptr @[[GLOB0]], align 4
>   ; CHECK-NEXT:ret i32 [[V]]
>   ;
> %v = load i32, ptr @0
> ret i32 %v
>   }
>
> And now we instead check `CHECK: @0 = global i32 0`, so there is a mismatch 
> between definition and use. I believe it does make sense to keep the wildcard 
> names for unnamed globals.
>
> On the same test case, if I keep rerunning update_test_checks on the same 
> file, it keeps adding extra `CHECK: @0 = global i32 0` lines at the start 
> (before the first `;.`. That didn't happen previously.

Fixed. Does this test case exist somewhere? I couldn't find it upstream.




Comment at: 
llvm/test/tools/UpdateTestChecks/update_test_checks/Inputs/check_attrs.ll.funcattrs.expected:9
 define ptr @foo(ptr %s) nounwind uwtable readnone optsize ssp {
-; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind optsize 
ssp willreturn memory(none) uwtable
+; CHECK: Function Attrs: nofree norecurse nosync nounwind optsize ssp 
willreturn memory(none) uwtable
 ; CHECK-LABEL: define {{[^@]+}}@foo

nikic wrote:
> Huh, where does this change come from?
I thought it was an existing test failure upstream, but it seems to have 
disappeared after doing a full rebuild clang+llvm.



Comment at: llvm/utils/UpdateTestChecks/common.py:991
+NamelessValue(r"META"   , "!" , r"![a-z.]+ "   , r"![0-9]+"
 , None ) ,
+]
+

nikic wrote:
> Does this still comply with the formatter?
No, I guess maintaining this structure isn't worth it long term with the 
autoformatter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148216

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


[PATCH] D153330: [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp

2023-06-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks!




Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:219
+// as they don't contribute to the main-file #include.
+if (isa(VD))
+  return true;

s/isa/llvm::isa/



Comment at: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp:101
+  // No reference reported for the Parameter.
+  using A = int(int time);
   )cpp");

no need for this one, as we already have a param in `bar`. can you just move 
the comment near that one instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153330

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-06-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

I think this may not hard break mesa. I believe mesa bypasses the intrinsic 
creation API, and just declares the string name of the intrinsic. The type name 
mangling suffix is technically irrelevant, and as long as you use a consistent 
type with a consistent suffix things should work out (and the null suffix also 
works). After committing mesa should still move to adding the type suffix




Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll:13
 define amdgpu_kernel void @test_readlane_sreg_sreg(i32 %src0, i32 %src1) #1 {
   %readlane = call i32 @llvm.amdgcn.readlane(i32 %src0, i32 %src1)
   call void asm sideeffect "; use $0", "s"(i32 %readlane)

This is a hint mesa won't break


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[clang-tools-extra] 149f309 - [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp

2023-06-20 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-06-20T14:26:55+02:00
New Revision: 149f309f50cd981ed320c948f772aa571eaa9afa

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

LOG: [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp

This fixes a false positive where a ParamVarDecl happend to be the
same name of some C standard symbol and has a global namespace.

```
using A = int(int time); // we suggest  for the `int time`.
```

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

Added: 


Modified: 
clang-tools-extra/include-cleaner/lib/WalkAST.cpp
clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp 
b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
index fc392fec36865..8cfda506fc254 100644
--- a/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ b/clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -214,6 +214,10 @@ class ASTWalker : public RecursiveASTVisitor {
 return true;
   }
   bool VisitVarDecl(VarDecl *VD) {
+// Ignore the parameter decl itself (its children were handled elsewhere),
+// as they don't contribute to the main-file #include.
+if (llvm::isa(VD))
+  return true;
 // Mark declaration from definition as it needs type-checking.
 if (VD->isThisDeclarationADefinition())
   report(VD->getLocation(), VD);

diff  --git a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
index bad55e1433549..5b5f77b5fdea8 100644
--- a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -91,7 +91,8 @@ TEST_F(WalkUsedTest, Basic) {
   #include "header.h"
   #include "private.h"
 
-  void $bar^bar($private^Private $p^p) {
+  // No reference reported for the Parameter "p".
+  void $bar^bar($private^Private p) {
 $foo^foo();
 std::$vector^vector $vconstructor^$v^v;
 $builtin^__builtin_popcount(1);
@@ -120,7 +121,6 @@ TEST_F(WalkUsedTest, Basic) {
   offsetToProviders(AST, SM),
   UnorderedElementsAre(
   Pair(Code.point("bar"), UnorderedElementsAre(MainFile)),
-  Pair(Code.point("p"), UnorderedElementsAre(MainFile)),
   Pair(Code.point("private"),
UnorderedElementsAre(PublicFile, PrivateFile)),
   Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),



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


[PATCH] D153330: [include-cleaner] Ignore the ParmVarDecl itself in WalkAST.cpp

2023-06-20 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG149f309f50cd: [include-cleaner] Ignore the ParmVarDecl 
itself in WalkAST.cpp (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D153330?vs=532863&id=532870#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153330

Files:
  clang-tools-extra/include-cleaner/lib/WalkAST.cpp
  clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -91,7 +91,8 @@
   #include "header.h"
   #include "private.h"
 
-  void $bar^bar($private^Private $p^p) {
+  // No reference reported for the Parameter "p".
+  void $bar^bar($private^Private p) {
 $foo^foo();
 std::$vector^vector $vconstructor^$v^v;
 $builtin^__builtin_popcount(1);
@@ -120,7 +121,6 @@
   offsetToProviders(AST, SM),
   UnorderedElementsAre(
   Pair(Code.point("bar"), UnorderedElementsAre(MainFile)),
-  Pair(Code.point("p"), UnorderedElementsAre(MainFile)),
   Pair(Code.point("private"),
UnorderedElementsAre(PublicFile, PrivateFile)),
   Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -214,6 +214,10 @@
 return true;
   }
   bool VisitVarDecl(VarDecl *VD) {
+// Ignore the parameter decl itself (its children were handled elsewhere),
+// as they don't contribute to the main-file #include.
+if (llvm::isa(VD))
+  return true;
 // Mark declaration from definition as it needs type-checking.
 if (VD->isThisDeclarationADefinition())
   report(VD->getLocation(), VD);


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -91,7 +91,8 @@
   #include "header.h"
   #include "private.h"
 
-  void $bar^bar($private^Private $p^p) {
+  // No reference reported for the Parameter "p".
+  void $bar^bar($private^Private p) {
 $foo^foo();
 std::$vector^vector $vconstructor^$v^v;
 $builtin^__builtin_popcount(1);
@@ -120,7 +121,6 @@
   offsetToProviders(AST, SM),
   UnorderedElementsAre(
   Pair(Code.point("bar"), UnorderedElementsAre(MainFile)),
-  Pair(Code.point("p"), UnorderedElementsAre(MainFile)),
   Pair(Code.point("private"),
UnorderedElementsAre(PublicFile, PrivateFile)),
   Pair(Code.point("foo"), UnorderedElementsAre(HeaderFile)),
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -214,6 +214,10 @@
 return true;
   }
   bool VisitVarDecl(VarDecl *VD) {
+// Ignore the parameter decl itself (its children were handled elsewhere),
+// as they don't contribute to the main-file #include.
+if (llvm::isa(VD))
+  return true;
 // Mark declaration from definition as it needs type-checking.
 if (VD->isThisDeclarationADefinition())
   report(VD->getLocation(), VD);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8784b6a - [Clang] Allow bitcode linking when the input is LLVM-IR

2023-06-20 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-06-20T08:02:58-05:00
New Revision: 8784b6a8540f4a333690e7233587859f1d82f620

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

LOG: [Clang] Allow bitcode linking when the input is LLVM-IR

Clang provides the `-mlink-bitcode-file` and `-mlink-builtin-bitcode`
options to insert LLVM-IR into the current TU. These are usefuly
primarily for including LLVM-IR files that require special handling to
be correct and cannot be linked normally, such as GPU vendor libraries
like `libdevice.10.bc`. Currently these options can only be used if the
source input goes through the AST consumer path. This patch makes the
changes necessary to also support this when the input is LLVM-IR. This
will allow the following operation:

```
clang in.bc -Xclang -mlink-builtin-bitcode -Xclang libdevice.10.bc
```

Reviewed By: yaxunl

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

Added: 
clang/test/CodeGen/link-builtin-bitcode.c

Modified: 
clang/include/clang/CodeGen/CodeGenAction.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGCall.h
clang/lib/CodeGen/CodeGenAction.cpp
clang/test/CodeGen/link-bitcode-file.c

Removed: 




diff  --git a/clang/include/clang/CodeGen/CodeGenAction.h 
b/clang/include/clang/CodeGen/CodeGenAction.h
index b5721344046d0..821e80919fc84 100644
--- a/clang/include/clang/CodeGen/CodeGenAction.h
+++ b/clang/include/clang/CodeGen/CodeGenAction.h
@@ -53,6 +53,9 @@ class CodeGenAction : public ASTFrontendAction {
 
   std::unique_ptr loadModule(llvm::MemoryBufferRef MBRef);
 
+  /// Load bitcode modules to link into our module from the options.
+  bool loadLinkModules(CompilerInstance &CI);
+
 protected:
   /// Create a new code generation action.  If the optional \p _VMContext
   /// parameter is supplied, the action uses it without taking ownership,

diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index fc77566c790c1..61029c9226d7b 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -1845,8 +1845,9 @@ addMergableDefaultFunctionAttributes(const CodeGenOptions 
&CodeGenOpts,
FuncAttrs);
 }
 
-void CodeGenModule::getTrivialDefaultFunctionAttributes(
-StringRef Name, bool HasOptnone, bool AttrOnCallSite,
+static void getTrivialDefaultFunctionAttributes(
+StringRef Name, bool HasOptnone, const CodeGenOptions &CodeGenOpts,
+const LangOptions &LangOpts, bool AttrOnCallSite,
 llvm::AttrBuilder &FuncAttrs) {
   // OptimizeNoneAttr takes precedence over -Os or -Oz. No warning needed.
   if (!HasOptnone) {
@@ -1967,7 +1968,7 @@ void CodeGenModule::getTrivialDefaultFunctionAttributes(
 }
   }
 
-  if (getLangOpts().assumeFunctionsAreConvergent()) {
+  if (LangOpts.assumeFunctionsAreConvergent()) {
 // Conservatively, mark all functions and calls in CUDA and OpenCL as
 // convergent (meaning, they may call an intrinsically convergent op, such
 // as __syncthreads() / barrier(), and so can't have certain optimizations
@@ -1978,8 +1979,8 @@ void CodeGenModule::getTrivialDefaultFunctionAttributes(
 
   // TODO: NoUnwind attribute should be added for other GPU modes HIP,
   // OpenMP offload. AFAIK, neither of them support exceptions in device code.
-  if ((getLangOpts().CUDA && getLangOpts().CUDAIsDevice) ||
-  getLangOpts().OpenCL || getLangOpts().SYCLIsDevice) {
+  if ((LangOpts.CUDA && LangOpts.CUDAIsDevice) || LangOpts.OpenCL ||
+  LangOpts.SYCLIsDevice) {
 FuncAttrs.addAttribute(llvm::Attribute::NoUnwind);
   }
 
@@ -1990,36 +1991,25 @@ void CodeGenModule::getTrivialDefaultFunctionAttributes(
   }
 }
 
-void CodeGenModule::getDefaultFunctionAttributes(StringRef Name,
- bool HasOptnone,
- bool AttrOnCallSite,
- llvm::AttrBuilder &FuncAttrs) 
{
-  getTrivialDefaultFunctionAttributes(Name, HasOptnone, AttrOnCallSite,
-  FuncAttrs);
-  if (!AttrOnCallSite) {
-// If we're just getting the default, get the default values for mergeable
-// attributes.
-addMergableDefaultFunctionAttributes(CodeGenOpts, FuncAttrs);
-  }
-}
+/// Adds attributes to \p F according to our \p CodeGenOpts and \p LangOpts, as
+/// though we had emitted it ourselves. We remove any attributes on F that
+/// conflict with the attributes we add here.
+static void mergeDefaultFunctionDefinitionAttributes(
+llvm::Function &F, const CodeGenOptions CodeGenOpts,
+const LangOptions &LangOpts, const TargetOptions &TargetOpts,
+bool WillInternalize) {
 
-void CodeGenModule::addDefaultFunctionDefinitionAttributes(llvm::Function &F) {
   llvm::AttrBuilder FuncAttrs(F.

[clang] efacdfc - [LinkerWrapper] Support linking vendor bitcode late

2023-06-20 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-06-20T08:02:59-05:00
New Revision: efacdfc235e327341d2b8a733d9963fb526cf17b

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

LOG: [LinkerWrapper] Support linking vendor bitcode late

The GPU vendors currently provide bitcode files for their device
runtime. These files need to be handled specially as they are not built
to be linked in with a standard `llvm-link` call or through LTO linking.
This patch adds an alternative to use the existing clang handling of
these libraries that does the necessary magic to make this work.

We do this by causing the LTO backend to emit bitcode before running the
backend. We then pass this through to clang which uses the existing
support which has been fixed to support this by D152391. The backend
will then be run with the merged module.

This patch adds the `--builtin-bitcode==file.bc` to specify a single
file, or just `--clang-backend` to let the toolchain handle its defaults
(currently nothing for NVPTX and the ROCm device libs for AMDGPU). This may have
a performance impact due to running the optimizations again, we could
potentially disable optimizations in LTO and only do the linking if this is an
issue.

This should allow us to resolve issues when relying on the `linker-wrapper` to
do a late linking that may depend on vendor libraries.

Depends on D152391

Reviewed By: JonChesterfield

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

Added: 


Modified: 
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td

Removed: 




diff  --git a/clang/test/Driver/linker-wrapper.c 
b/clang/test/Driver/linker-wrapper.c
index 97058a96465f8..140cc72886692 100644
--- a/clang/test/Driver/linker-wrapper.c
+++ b/clang/test/Driver/linker-wrapper.c
@@ -130,3 +130,12 @@
 // RUN:   -o a.out 2>&1 | FileCheck %s --check-prefix=MISSING-LIBRARY
 
 // MISSING-LIBRARY: error: unable to find library -ldummy
+
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--clang-backend \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=CLANG-BACKEND
+
+// CLANG-BACKEND: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa 
-mcpu=gfx908 -O2 -Wl,--no-undefined {{.*}}.bc

diff  --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp 
b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 0af0f2e371b18..c553cf86da8e3 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -427,6 +427,17 @@ Expected clang(ArrayRef InputFiles, 
const ArgList &Args) {
   for (StringRef Arg : Args.getAllArgValues(OPT_linker_arg_EQ))
 CmdArgs.push_back(Args.MakeArgString("-Wl," + Arg));
 
+  for (StringRef Arg : Args.getAllArgValues(OPT_builtin_bitcode_EQ)) {
+if (llvm::Triple(Arg.split('=').first) == Triple)
+  CmdArgs.append({"-Xclang", "-mlink-builtin-bitcode", "-Xclang",
+  Args.MakeArgString(Arg.split('=').second)});
+  }
+
+  // The OpenMPOpt pass can introduce new calls and is expensive, we do not 
want
+  // this when running CodeGen through clang.
+  if (Args.hasArg(OPT_clang_backend) || Args.hasArg(OPT_builtin_bitcode_EQ))
+CmdArgs.append({"-mllvm", "-openmp-opt-disable"});
+
   if (Error Err = executeCommands(*ClangPath, CmdArgs))
 return std::move(Err);
 
@@ -629,7 +640,7 @@ Error linkBitcodeFiles(SmallVectorImpl 
&InputFiles,
   llvm::erase_if(InputFiles, [](OffloadFile &F) { return !F.getBinary(); });
 
   // LTO Module hook to output bitcode without running the backend.
-  SmallVector BitcodeOutput;
+  SmallVector BitcodeOutput;
   auto OutputBitcode = [&](size_t, const Module &M) {
 auto TempFileOrErr = createOutputFile(sys::path::filename(ExecutableName) +
   "-jit-" + Triple.getTriple(),
@@ -648,7 +659,9 @@ Error linkBitcodeFiles(SmallVectorImpl 
&InputFiles,
 
   // We assume visibility of the whole program if every input file was bitcode.
   auto Features = getTargetFeatures(BitcodeInputFiles);
-  auto LTOBackend = Args.hasArg(OPT_embed_bitcode)
+  auto LTOBackend = Args.hasArg(OPT_embed_bitcode) ||
+Args.hasArg(OPT_builtin_bitcode_EQ) ||
+Args.hasArg(OPT_clang_backend)
 ? createLTO(Args, Features, Out

[PATCH] D152391: [Clang] Allow bitcode linking when the input is LLVM-IR

2023-06-20 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8784b6a8540f: [Clang] Allow bitcode linking when the input 
is LLVM-IR (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152391

Files:
  clang/include/clang/CodeGen/CodeGenAction.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGCall.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/test/CodeGen/link-bitcode-file.c
  clang/test/CodeGen/link-builtin-bitcode.c

Index: clang/test/CodeGen/link-builtin-bitcode.c
===
--- /dev/null
+++ clang/test/CodeGen/link-builtin-bitcode.c
@@ -0,0 +1,42 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --check-attributes --check-globals --include-generated-funcs --version 2
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx803 -DBITCODE -emit-llvm-bc -o %t-lib.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm-bc -o %t.bc %s
+// RUN: %clang_cc1 -triple amdgcn-- -target-cpu gfx90a -emit-llvm \
+// RUN:   -mlink-builtin-bitcode %t-lib.bc -o - %t.bc | FileCheck %s
+
+#ifdef BITCODE
+int foo(void) { return 42; }
+int x = 12;
+#endif
+
+extern int foo(void);
+extern int x;
+
+int bar() { return foo() + x; }
+//.
+// CHECK: @x = internal addrspace(1) global i32 12, align 4
+//.
+// CHECK: Function Attrs: noinline nounwind optnone
+// CHECK-LABEL: define dso_local i32 @bar
+// CHECK-SAME: () #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
+// CHECK-NEXT:[[CALL:%.*]] = call i32 @foo()
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr addrspacecast (ptr addrspace(1) @x to ptr), align 4
+// CHECK-NEXT:[[ADD:%.*]] = add nsw i32 [[CALL]], [[TMP0]]
+// CHECK-NEXT:ret i32 [[ADD]]
+//
+//
+// CHECK: Function Attrs: convergent noinline nounwind optnone
+// CHECK-LABEL: define internal i32 @foo
+// CHECK-SAME: () #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca i32, align 4, addrspace(5)
+// CHECK-NEXT:[[RETVAL_ASCAST:%.*]] = addrspacecast ptr addrspace(5) [[RETVAL]] to ptr
+// CHECK-NEXT:ret i32 42
+//
+//.
+// CHECK: attributes #0 = { noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+atomic-buffer-global-pk-add-f16-insts,+atomic-fadd-rtn-insts,+ci-insts,+dl-insts,+dot1-insts,+dot10-insts,+dot2-insts,+dot3-insts,+dot4-insts,+dot5-insts,+dot6-insts,+dot7-insts,+dpp,+gfx8-insts,+gfx9-insts,+gfx90a-insts,+mai-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
+// CHECK: attributes #1 = { convergent noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx90a" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
+//.
Index: clang/test/CodeGen/link-bitcode-file.c
===
--- clang/test/CodeGen/link-bitcode-file.c
+++ clang/test/CodeGen/link-bitcode-file.c
@@ -11,6 +11,14 @@
 // RUN: not %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file no-such-file.bc \
 // RUN:-emit-llvm -o - %s 2>&1 | FileCheck -check-prefix=CHECK-NO-FILE %s
 
+// Make sure we can perform the same options if the input is LLVM-IR
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm-bc -o %t-in.bc %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -mlink-bitcode-file %t.bc \
+// RUN: -O3 -emit-llvm -o - %t-in.bc | FileCheck -check-prefix=CHECK-NO-BC %s
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -O3 -emit-llvm -o - \
+// RUN: -mlink-bitcode-file %t.bc -mlink-bitcode-file %t-2.bc %t-in.bc \
+// RUN: | FileCheck -check-prefix=CHECK-NO-BC -check-prefix=CHECK-NO-BC2 %s
+
 int f(void);
 
 #ifdef BITCODE
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang/CodeGen/CodeGenAction.h"
+#include "CGCall.h"
 #include "CodeGenModule.h"
 #include "CoverageMappingGen.h"
 #include "MacroPPCallbacks.h"
@@ -262,7 +263,7 @@
 }
 
 // Links each entry in LinkModules into our module.  Returns true on error.
-bool LinkInModules() {
+bool LinkInModules(llvm::Module *M) {
   for (auto &LM : LinkModules) {
 assert(LM.Module && "LinkModule does not actually have a module");
 if (LM.PropagateAttrs)
@@ -271,8 +272,8 @@
 // in LLVM IR.
 if (F.isIntrinsic())
   continue;
-Gen->CGM().mergeDefaultFunctionDefin

[PATCH] D152442: [LinkerWrapper] Support linking vendor bitcode late

2023-06-20 Thread Joseph Huber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGefacdfc235e3: [LinkerWrapper] Support linking vendor bitcode 
late (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152442

Files:
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td


Index: clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
===
--- clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
+++ clang/tools/clang-linker-wrapper/LinkerWrapperOpts.td
@@ -25,9 +25,16 @@
 def bitcode_library_EQ : Joined<["--"], "bitcode-library=">,
   Flags<[WrapperOnlyOption]>, MetaVarName<"--=">,
   HelpText<"Extra bitcode library to link">;
+def builtin_bitcode_EQ : Joined<["--"], "builtin-bitcode=">,
+  Flags<[WrapperOnlyOption]>, MetaVarName<"=">,
+  HelpText<"Perform a special internalizing link on the bitcode file. "
+   "This is necessary for some vendor libraries to be linked 
correctly">;
 def device_linker_args_EQ : Joined<["--"], "device-linker=">,
   Flags<[WrapperOnlyOption]>, MetaVarName<" or =">,
   HelpText<"Arguments to pass to the device linker invocation">;
+def clang_backend : Flag<["--"], "clang-backend">,
+  Flags<[WrapperOnlyOption]>,
+  HelpText<"Run the backend using clang rather than the LTO backend">;
 def dry_run : Flag<["--"], "dry-run">,
   Flags<[WrapperOnlyOption]>,
   HelpText<"Print program arguments without running">;
Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -427,6 +427,17 @@
   for (StringRef Arg : Args.getAllArgValues(OPT_linker_arg_EQ))
 CmdArgs.push_back(Args.MakeArgString("-Wl," + Arg));
 
+  for (StringRef Arg : Args.getAllArgValues(OPT_builtin_bitcode_EQ)) {
+if (llvm::Triple(Arg.split('=').first) == Triple)
+  CmdArgs.append({"-Xclang", "-mlink-builtin-bitcode", "-Xclang",
+  Args.MakeArgString(Arg.split('=').second)});
+  }
+
+  // The OpenMPOpt pass can introduce new calls and is expensive, we do not 
want
+  // this when running CodeGen through clang.
+  if (Args.hasArg(OPT_clang_backend) || Args.hasArg(OPT_builtin_bitcode_EQ))
+CmdArgs.append({"-mllvm", "-openmp-opt-disable"});
+
   if (Error Err = executeCommands(*ClangPath, CmdArgs))
 return std::move(Err);
 
@@ -629,7 +640,7 @@
   llvm::erase_if(InputFiles, [](OffloadFile &F) { return !F.getBinary(); });
 
   // LTO Module hook to output bitcode without running the backend.
-  SmallVector BitcodeOutput;
+  SmallVector BitcodeOutput;
   auto OutputBitcode = [&](size_t, const Module &M) {
 auto TempFileOrErr = createOutputFile(sys::path::filename(ExecutableName) +
   "-jit-" + Triple.getTriple(),
@@ -648,7 +659,9 @@
 
   // We assume visibility of the whole program if every input file was bitcode.
   auto Features = getTargetFeatures(BitcodeInputFiles);
-  auto LTOBackend = Args.hasArg(OPT_embed_bitcode)
+  auto LTOBackend = Args.hasArg(OPT_embed_bitcode) ||
+Args.hasArg(OPT_builtin_bitcode_EQ) ||
+Args.hasArg(OPT_clang_backend)
 ? createLTO(Args, Features, OutputBitcode)
 : createLTO(Args, Features);
 
@@ -757,8 +770,12 @@
 return Error::success();
   }
 
-  // Append the new inputs to the device linker input.
-  for (StringRef File : Files)
+  // Append the new inputs to the device linker input. If the user requested an
+  // internalizing link we need to pass the bitcode to clang.
+  for (StringRef File :
+   Args.hasArg(OPT_clang_backend) || Args.hasArg(OPT_builtin_bitcode_EQ)
+   ? BitcodeOutput
+   : Files)
 OutputFiles.push_back(File);
 
   return Error::success();
Index: clang/test/Driver/linker-wrapper.c
===
--- clang/test/Driver/linker-wrapper.c
+++ clang/test/Driver/linker-wrapper.c
@@ -130,3 +130,12 @@
 // RUN:   -o a.out 2>&1 | FileCheck %s --check-prefix=MISSING-LIBRARY
 
 // MISSING-LIBRARY: error: unable to find library -ldummy
+
+// RUN: clang-offload-packager -o %t.out \
+// RUN:   
--image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908 \
+// RUN:   
--image=file=%t.amdgpu.bc,kind=openmp,triple=amdgcn-amd-amdhsa,arch=gfx908
+// RUN: %clang -cc1 %s -triple x86_64-unknown-linux-gnu -emit-obj -o %t.o 
-fembed-offload-object=%t.out
+// RUN: clang-linker-wrapper --host-triple=x86_64-unknown-linux-gnu --dry-run 
--clang-backend \
+// RUN:   --linker-path=/usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=CLANG-BACKEND

[PATCH] D153338: [clang-format] vim integration: Mention python3 variant of bindings

2023-06-20 Thread Jannik Silvanus via Phabricator via cfe-commits
jsilvanus created this revision.
Herald added projects: All, clang, clang-format.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
jsilvanus requested review of this revision.
Herald added a comment.

NOTE: Clang-Format Team Automated Review Comment

It looks like your clang-format review does not contain any unit tests, please 
try to ensure all code changes have a unit test (unless this is an `NFC` or 
refactoring, adding documentation etc..)

Add your unit tests in `clang/unittests/Format` and you can build with `ninja 
FormatTests`.  We recommend using the `verifyFormat(xxx)` format of unit tests 
rather than `EXPECT_EQ` as this will ensure you change is tolerant to random 
whitespace changes (see FormatTest.cpp as an example)

For situations where your change is altering the TokenAnnotator.cpp which can 
happen if you are trying to improve the annotation phase to ensure we are 
correctly identifying the type of a token, please add a token annotator test in 
`TokenAnnotatorTest.cpp`


The instructions in the documentation only mentioned how to include
bindings for clang-format into vim using python2. Add the instructions
for python3 which were already present in the source comments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153338

Files:
  clang/docs/ClangFormat.rst


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -145,8 +145,13 @@
 
 .. code-block:: vim
 
-  map  :pyf /clang-format.py
-  imap  :pyf /clang-format.py
+  if has('python')
+map  :pyf /clang-format.py
+imap  :pyf /clang-format.py
+  elseif has('python3')
+map  :py3f /clang-format.py
+imap  :py3f /clang-format.py
+  endif
 
 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
 second line adds support for INSERT mode. Change "C-K" to another binding if


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -145,8 +145,13 @@
 
 .. code-block:: vim
 
-  map  :pyf /clang-format.py
-  imap  :pyf /clang-format.py
+  if has('python')
+map  :pyf /clang-format.py
+imap  :pyf /clang-format.py
+  elseif has('python3')
+map  :py3f /clang-format.py
+imap  :py3f /clang-format.py
+  endif
 
 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
 second line adds support for INSERT mode. Change "C-K" to another binding if
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153339: [clang] Support vectors in __builtin_isfpclass

2023-06-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, aaron.ballman, arsenm, kpn, qiucf, 
efriedma.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: clang.

Builtin function `__builtin_isfpclass` now can be called for a vector
of floating-point values. In this case it is applied to the vector
elementwise and produces vector of boolean values.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153339

Files:
  clang/docs/LanguageExtensions.rst
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/isfpclass.c

Index: clang/test/CodeGen/isfpclass.c
===
--- clang/test/CodeGen/isfpclass.c
+++ clang/test/CodeGen/isfpclass.c
@@ -1,5 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
-// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature +avx512fp16 -S -O1 -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple aarch64-linux-gnu -target-feature -S -O1 -emit-llvm %s -o - | FileCheck %s
 
 // CHECK-LABEL: define dso_local i1 @check_isfpclass_finite
 // CHECK-SAME: (float noundef [[X:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
@@ -84,3 +84,27 @@
 #pragma STDC FENV_ACCESS ON
   return __builtin_isfpclass(x, 96 /*Zero*/);
 }
+
+typedef float __attribute__((ext_vector_type(4))) float4;
+typedef _Bool __attribute__((ext_vector_type(4))) bool4;
+
+// CHECK-LABEL: define dso_local <4 x i1> @check_isfpclass_nan_v4f32
+// CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR3]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = fcmp uno <4 x float> [[X]], zeroinitializer
+// CHECK-NEXT:ret <4 x i1> [[TMP0]]
+//
+bool4 check_isfpclass_nan_v4f32(float4 x) {
+  return __builtin_isfpclass(x, 3 /*NaN*/);
+}
+
+// CHECK-LABEL: define dso_local <4 x i1> @check_isfpclass_nan_strict_v4f32
+// CHECK-SAME: (<4 x float> noundef [[X:%.*]]) local_unnamed_addr #[[ATTR2]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call <4 x i1> @llvm.is.fpclass.v4f32(<4 x float> [[X]], i32 3) #[[ATTR4]]
+// CHECK-NEXT:ret <4 x i1> [[TMP0]]
+//
+bool4 check_isfpclass_nan_strict_v4f32(float4 x) {
+#pragma STDC FENV_ACCESS ON
+  return __builtin_isfpclass(x, 3 /*NaN*/);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -7687,14 +7687,15 @@
 
 /// SemaBuiltinSemaBuiltinFPClassification - Handle functions like
 /// __builtin_isnan and friends.  This is declared to take (...), so we have
-/// to check everything. We expect the last argument to be a floating point
-/// value.
+/// to check everything.
 bool Sema::SemaBuiltinFPClassification(CallExpr *TheCall, unsigned NumArgs) {
   if (checkArgCount(*this, TheCall, NumArgs))
 return true;
 
+  bool IsFPClass = NumArgs == 2;
+
   // Find out position of floating-point argument.
-  unsigned FPArgNo = (NumArgs == 2) ? 0 : NumArgs - 1;
+  unsigned FPArgNo = IsFPClass ? 0 : NumArgs - 1;
 
   // We can count on all parameters preceding the floating-point just being int.
   // Try all of those.
@@ -7725,18 +7726,36 @@
 OrigArg = DefaultFunctionArrayLvalueConversion(OrigArg).get();
   TheCall->setArg(FPArgNo, OrigArg);
 
+  const VectorType *VectorArgTy = nullptr;
+  QualType ElementTy = OrigArg->getType();
+  // TODO: When all classification function are implemented with is_fpclass,
+  // vector argument can be supported in all of them.
+  if (ElementTy->isVectorType() && IsFPClass) {
+VectorArgTy = ElementTy->getAs();
+ElementTy = VectorArgTy->getElementType();
+  }
+
   // This operation requires a non-_Complex floating-point number.
-  if (!OrigArg->getType()->isRealFloatingType())
+  if (!ElementTy->isRealFloatingType())
 return Diag(OrigArg->getBeginLoc(),
 diag::err_typecheck_call_invalid_unary_fp)
<< OrigArg->getType() << OrigArg->getSourceRange();
 
   // __builtin_isfpclass has integer parameter that specify test mask. It is
   // passed in (...), so it should be analyzed completely here.
-  if (NumArgs == 2)
+  if (IsFPClass)
 if (SemaBuiltinConstantArgRange(TheCall, 1, 0, llvm::fcAllFlags))
   return true;
 
+  // TODO: enable this code to all classification functions.
+  if (IsFPClass) {
+QualType ResultTy = Context.BoolTy;
+if (VectorArgTy)
+  ResultTy = Context.getVectorType(ResultTy, VectorArgTy->getNumElements(),
+   VectorType::GenericVector);
+TheCall->setType(ResultTy);
+  }
+
   return false;
 }
 
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -3496,18 +3496,15 @@
 ``__builtin_isfpclass``
 ---
 
-``__bu

[PATCH] D153340: [include-cleaner] Add an IgnoreHeaders flag to the command-line tool.

2023-06-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: kadircet.
Herald added a project: All.
hokein requested review of this revision.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153340

Files:
  clang-tools-extra/include-cleaner/test/tool.cpp
  clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -14,8 +14,10 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -47,6 +49,13 @@
 cl::cat(IncludeCleaner),
 };
 
+cl::opt IgnoreHeaders{
+"ignore-headers",
+cl::desc("A comma-separated list of headers to ignore."),
+cl::init(""),
+cl::cat(IncludeCleaner),
+};
+
 enum class PrintStyle { Changes, Final };
 cl::opt Print{
 "print",
@@ -117,6 +126,27 @@
   return;
 }
 
+std::vector HeaderFilters;
+llvm::SmallVector Headers;
+llvm::StringRef(IgnoreHeaders).split(Headers, ',', -1, /*KeepEmpty*/ 
false);
+for (auto HeaderPattern : Headers) {
+  std::string AnchoredPattern = "(" + HeaderPattern.str() + ")$";
+  llvm::Regex CompiledRegex(AnchoredPattern);
+  std::string RegexError;
+  if (!CompiledRegex.isValid(RegexError)) {
+llvm::errs() << llvm::formatv("Invalid regular expression '{0}': 
{1}\n",
+  HeaderPattern, RegexError);
+return;
+  }
+  HeaderFilters.push_back(std::move(CompiledRegex));
+}
+auto Filter = [&HeaderFilters](llvm::StringRef Path) {
+  for (const auto &F : HeaderFilters)
+if (F.match(Path))
+  return true;
+  return false;
+};
+
 if (!HTMLReportPath.empty())
   writeHTML();
 
@@ -137,10 +167,16 @@
 if (Print.getNumOccurrences()) {
   switch (Print) {
   case PrintStyle::Changes:
-for (const Include *I : Results.Unused)
+for (const Include *I : Results.Unused) {
+  if (Filter(I->Resolved->tryGetRealPathName()))
+continue;
   llvm::outs() << "- " << I->quote() << " @Line:" << I->Line << "\n";
-for (const auto &I : Results.Missing)
+}
+for (const auto &I : Results.Missing) {
+  if (Filter(llvm::StringRef(I).trim("<>\"")))
+continue;
   llvm::outs() << "+ " << I << "\n";
+}
 break;
   case PrintStyle::Final:
 llvm::outs() << Final;
Index: clang-tools-extra/include-cleaner/test/tool.cpp
===
--- clang-tools-extra/include-cleaner/test/tool.cpp
+++ clang-tools-extra/include-cleaner/test/tool.cpp
@@ -14,6 +14,10 @@
 //  REMOVE: - "foobar.h"
 //  REMOVE-NOT: + "foo.h"
 
+//RUN: clang-include-cleaner -print=changes %s 
--ignore-headers="foobar\.h,foo\.h" -- -I%S/Inputs/ | FileCheck 
--match-full-lines --allow-empty --check-prefix=IGNORE %s
+// IGNORE-NOT: - "foobar.h"
+// IGNORE-NOT: + "foo.h"
+
 //RUN: clang-include-cleaner -print %s -- -I%S/Inputs/ | FileCheck 
--match-full-lines --check-prefix=PRINT %s
 //  PRINT: #include "foo.h"
 //  PRINT-NOT: {{^}}#include "foobar.h"{{$}}


Index: clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
===
--- clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -14,8 +14,10 @@
 #include "clang/Lex/Preprocessor.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -47,6 +49,13 @@
 cl::cat(IncludeCleaner),
 };
 
+cl::opt IgnoreHeaders{
+"ignore-headers",
+cl::desc("A comma-separated list of headers to ignore."),
+cl::init(""),
+cl::cat(IncludeCleaner),
+};
+
 enum class PrintStyle { Changes, Final };
 cl::opt Print{
 "print",
@@ -117,6 +126,27 @@
   return;
 }
 
+std::vector HeaderFilters;
+llvm::SmallVector Headers;
+llvm::StringRef(IgnoreHeaders).split(Headers, ',', -1, /*KeepEmpty*/ false);
+for (auto HeaderPattern : Headers) {
+  std::string AnchoredPattern = "(" + HeaderPattern.str() + ")$";
+  llvm::Regex CompiledRegex(AnchoredPattern);
+  std::string RegexError;
+  if (!CompiledRegex.isValid(RegexError)) {
+

[PATCH] D153248: [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base specifier during heuristic resolution

2023-06-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

OK, fair enough. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153248

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


[PATCH] D152720: [clangd][ObjC] Support ObjC class rename from implementation decls

2023-06-20 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:131
 return HighlightingKind::Interface;
-  if (isa(D))
+  if (isa(D))
 return HighlightingKind::Namespace;

kadircet wrote:
> let's do this in a separate change, with some tests
Given the other changes, this is needed otherwise the semantic highlighting 
test fails.



Comment at: clang-tools-extra/clangd/refactor/Rename.cpp:171-177
+if (const auto *C = dyn_cast(D)) {
+  if (C->getLocation() == TokenStartLoc)
+D = C->getClassInterface();
+  else if (const auto *I = C->getImplementation())
+if (I->getLocation() == TokenStartLoc)
+  D = C->getClassInterface();
+}

kadircet wrote:
> sorry i don't follow what's the logic doing here and we're likely doing these 
> in the wrong layer.
> 
> we should either:
> - Fix selection tree to pick the correct ASTNode, if it's picking the wrong 
> one due to not having special cases for these locations here
> - Fix the `targetDecl` logic to make sure it emits all the declarations that 
> might be referenced by this ast node, if it's missing ClassInterface.
> - Fix the canonicalRenameDecl, if we should always prefer `ClassInterface` in 
> these cases.
Replied to you in chat, LMK what you think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152720

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-06-20 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp:213
+
+Value *Result = UndefValue::get(Ty);
+for (int i = 0; i < EC; i += 1 + is16Bit) {

Please use poison wherever possible. In this case it seems it's just a 
placeholder, so it can be poison.
We're trying to get rid of poison. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-06-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp:209
+bool is16Bit =
+(EltType->isIntegerTy() && EltType->getIntegerBitWidth() == 16) ||
+(EltType->isHalfTy());

isIntegerTy(16). Also, just check the bitsize is 16. Might as well also handle 
bfloat



Comment at: llvm/lib/Target/AMDGPU/AMDGPULateCodeGenPrepare.cpp:301-310
+  if (Ty->isPointerTy()) {
+unsigned BitWidth = DL->getTypeSizeInBits(Ty);
+auto ResTy = Result->getType();
+if (ResTy->isVectorTy()) {
+  auto Scalarized = B.CreateBitCast(
+  Result, IntegerType::get(Mod->getContext(), BitWidth));
+  return B.CreateIntToPtr(Scalarized, Ty);

Just let pointer types pass through to codegen, we try really hard to never 
introduce ptrtoint/inttoptr



Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll:5
+declare i16 @llvm.amdgcn.readlane.i16(i16, i32) #0
+declare half @llvm.amdgcn.readlane.f16(half, i32) #0
+declare float @llvm.amdgcn.readlane.f32(float, i32) #0

Add bfloat and <2 x i16>, <2 x half>, <2 x bfloat> tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D147732: [AMDGPU] Add type mangling for {read, write, readfirst, perm}lane intrinsics

2023-06-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: llvm/test/CodeGen/AMDGPU/llvm.amdgcn.readlane.ll:5
+declare i16 @llvm.amdgcn.readlane.i16(i16, i32) #0
+declare half @llvm.amdgcn.readlane.f16(half, i32) #0
+declare float @llvm.amdgcn.readlane.f32(float, i32) #0

arsenm wrote:
> Add bfloat and <2 x i16>, <2 x half>, <2 x bfloat> tests
Also p2, p3, p5, p6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147732

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


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 532921.
massberg added a comment.

Add test to FindTargetTests and extend test in HoverTests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -4048,6 +4048,41 @@
   EXPECT_TRUE(H->Type);
 }
 
+TEST(Hover, RewrittenBinaryOperatorSpaceship) {
+  Annotations T(R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  static_assert(Foo(1) !^= Foo(2));
+  )cpp");
+
+  TestTU TU = TestTU::withCode(T.code());
+  TU.ExtraArgs.push_back("-std=c++20");
+  auto AST = TU.build();
+  auto HI = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Name, "operator==");
+  EXPECT_EQ(HI->Definition,
+"bool operator==(const Foo &) const noexcept = default");
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -618,6 +618,36 @@
   EXPECT_DECLS("RecordTypeLoc", "struct executor");
 }
 
+TEST_F(TargetDeclTest, RewrittenBinaryOperator) {
+  Flags.push_back("-std=c++20");
+
+  Code = R"cpp(
+  namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+}
+
+struct Foo
+{
+  int x;
+  auto operator<=>(const Foo&) const = default;
+};
+
+bool x = (Foo(1) [[!=]] Foo(2));
+  )cpp";
+  EXPECT_DECLS("CXXRewrittenBinaryOperator",
+   {"std::strong_ordering operator<=>(const Foo &) const = default",
+Rel::TemplatePattern},
+   {"bool operator==(const Foo &) const noexcept = default",
+Rel::TemplateInstantiation});
+}
+
 TEST_F(TargetDeclTest, FunctionTemplate) {
   Code = R"cpp(
 // Implicit specialization.
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked 2 inline comments as done.
massberg added a comment.

Thanks for the comments, I have added an additional test to FindTargetTest. See 
also my other comments.




Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

sammccall wrote:
> sammccall wrote:
> > no need to sign your work :-)
> can you add this to HoverTest__All instead? That way we test all details of 
> the hover card
Upps, sorry.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

massberg wrote:
> sammccall wrote:
> > sammccall wrote:
> > > no need to sign your work :-)
> > can you add this to HoverTest__All instead? That way we test all details of 
> > the hover card
> Upps, sorry.
> can you add this to HoverTest__All instead? That way we test all details of 
> the hover card

The (Hover, All) test tests with `std=c++17` while this test tests c++20 
features.
We could add an additional field with the version to the struct in the (Hover, 
All) test.
Or add a (Hover, All_Cpp20) test for testing C++20 (what is probably not worth 
at the moment with just one test requiring C++20).



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4079
+  EXPECT_EQ(HI->Type,
+HoverInfo::PrintedType("bool (const Foo &) const noexcept"));
+  EXPECT_EQ(HI->Documentation, "Foo spaceship");

sammccall wrote:
> if we're describing this as the spaceship operator, then the type looks wrong
I have added a test checking the whole definition.
Actually the following is happening here:
The `!=` operator isn't explicitly defined, so the binary operator is rewritten 
to `!(Foo(1) == Foo(2)`,
i.e. we are now using the `==` operator.
However, the `==`  operator is also not explicitly defined, but there is a 
defaulted spaceship operator.
Thus the `==` operator is implicitly defined through the `<=>` operator.
So the type and definition here are from the implicitly defined `==` operator, 
while the original source of it is the `<=>` operator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:648
+   {"bool operator==(const Foo &) const noexcept = default",
+Rel::TemplateInstantiation});
+}

this template pattern vs instantiation is really surprising, but it's a 
reasonable analogy, I don't see any particular problems.  (Also, `operator<=>` 
looks like a template over whatever `=` is!)

Do you know whether this means go-to-definition gives you two options to 
navigate to?
(No need to write a test, just curious)



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

massberg wrote:
> massberg wrote:
> > sammccall wrote:
> > > sammccall wrote:
> > > > no need to sign your work :-)
> > > can you add this to HoverTest__All instead? That way we test all details 
> > > of the hover card
> > Upps, sorry.
> > can you add this to HoverTest__All instead? That way we test all details of 
> > the hover card
> 
> The (Hover, All) test tests with `std=c++17` while this test tests c++20 
> features.
> We could add an additional field with the version to the struct in the 
> (Hover, All) test.
> Or add a (Hover, All_Cpp20) test for testing C++20 (what is probably not 
> worth at the moment with just one test requiring C++20).
Does anything break if you switch everything to C++20?
The intention of "std=c++17" there was certainly "not 14", rather than "not 20" 
:-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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


[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

2023-06-20 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet created this revision.
hazohelet added reviewers: aaron.ballman, tbaeder, cjdb, shafik.
Herald added a project: All.
hazohelet requested review of this revision.
Herald added a project: clang.

Now that clang supports printing of multiple lines of code snippet in 
diagnostics, source ranges in diagnostics that are located in different lines 
from the diagnosed source location get to be printed if the gap happened to be 
less than the maximum number of lines clang is allowed to print in.
Many of the bad-conversion notes in overload resolution failures have their 
source location in the function declaration and source range in the argument of 
function call. This can cause an unnecessarily many lines of snippet printing.
e.g.

  void func(int num);
  
  
  void test() { func("hello"); }

Live demo: https://godbolt.org/z/fdj6WWsef

This patch fixes it by changing the source range from function callsite to the 
problematic parameter in function declaration.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153359

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Misc/diag-overload-cand-ranges.cpp
  clang/test/Misc/diag-overload-cand-ranges.mm

Index: clang/test/Misc/diag-overload-cand-ranges.mm
===
--- /dev/null
+++ clang/test/Misc/diag-overload-cand-ranges.mm
@@ -0,0 +1,26 @@
+// RUN: not %clang_cc1 -fobjc-runtime-has-weak -fobjc-arc -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace -check-prefixes=CHECK,ARC
+// RUN: not %clang_cc1 -fobjc-runtime-has-weak -fobjc-gc -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace -check-prefixes=CHECK,GC
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:15-[[@LINE+1]]:28}: note: {{.*}}: 1st argument
+void powerful(__strong id &);
+void lifetime_gcattr_mismatch() {
+  static __weak id weak_id;
+  powerful(weak_id);
+}
+
+// CHECK:  error: no matching function
+// ARC::{[[@LINE+2]]:11-[[@LINE+2]]:21}: note: {{.*}}: cannot implicitly convert
+// GC: :{[[@LINE+1]]:11-[[@LINE+1]]:21}: note: {{.*}}: no known conversion
+void func(char *uiui);
+
+__attribute__((objc_root_class))
+@interface Interface
+- (void)something;
+@end
+
+@implementation Interface
+- (void)something{
+func(self);
+}
+@end
Index: clang/test/Misc/diag-overload-cand-ranges.cpp
===
--- /dev/null
+++ clang/test/Misc/diag-overload-cand-ranges.cpp
@@ -0,0 +1,72 @@
+// RUN: not %clang_cc1 -fsyntax-only -fdiagnostics-print-source-range-info %s 2>&1 | FileCheck %s --strict-whitespace
+// CHECK:  error: no matching function
+template  struct mcdata {
+  typedef int result_type;
+};
+template  typename mcdata::result_type wrap_mean(mcdata const &);
+// CHECK:  :{[[@LINE+1]]:19-[[@LINE+1]]:53}: note: {{.*}}: no overload of 'wrap_mean'
+void add_property(double (*)(mcdata const &));
+void f() { add_property(&wrap_mean); }
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:10-[[@LINE+1]]:51}: note: {{.*}}: cannot pass pointer to generic address space
+void baz(__attribute__((opencl_private)) int *Data) {}
+void fizz() {
+  int *Nop;
+  baz(Nop);
+  // CHECK:error: no matching function
+  // CHECK::[[@LINE+1]]:53: note: {{.*}}: 'this' object is in address space '__private'
+  __attribute__((opencl_private)) static auto err = [&]() {};
+  err();
+}
+
+// CHECK:  error: no matching function
+struct Bar {
+// CHECK:  :{[[@LINE+1]]:26-[[@LINE+1]]:32}: note: {{.*}} would lose const qualifier
+static void foo(int num, int *X) {}
+// CHECK:  :{[[@LINE+1]]:17-[[@LINE+1]]:25}: note: {{.*}} no known conversion
+static void foo(int *err, int *x) {}
+};
+void bar(const int *Y) {
+  Bar::foo(5, Y);
+}
+
+struct InComp;
+
+struct A {};
+struct B : public A{};
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+5]]:36-[[@LINE+5]]:50}: note: {{.*}}: cannot convert initializer
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+3]]:36-[[@LINE+3]]:50}: note: {{.*}}: cannot convert argument
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:11-[[@LINE+1]]:18}: note: {{.*}}: no known conversion
+void hoge(char aa, const char *bb, const A& third);
+
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE+1]]:14-[[@LINE+1]]:16}: note: {{.*}}: cannot convert from base class
+void derived(B*);
+
+void func(const A &arg) {
+  hoge(1, "pass", {{{arg}}});
+  InComp *a;
+  hoge(1, "pass", a);
+  hoge("first", 5, 6);
+  A *b;
+  derived(b);
+}
+
+struct Q {
+  // CHECK:error: invalid operands
+  // CHECK::[[@LINE+1]]:6: note: {{.*}}: 'this' argument has type 'const Q'
+  Q &operator+(void*);
+};
+
+void fuga(const Q q) { q + 3; }
+
+template  class Type1 {};
+// CHECK:  error: no matching function
+// CHECK:  :{[[@LINE

[clang] bca11ba - [clang-format] Add InsertNewlineAtEOF to .clang-format files

2023-06-20 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-06-20T08:30:09-07:00
New Revision: bca11bafba9788dd80135b76a187c5f00e64f735

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

LOG: [clang-format] Add InsertNewlineAtEOF to .clang-format files

Also, reformat all clang-format related files.

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

Added: 


Modified: 
clang/include/clang/Format/.clang-format
clang/lib/Format/.clang-format
clang/tools/clang-format/.clang-format
clang/unittests/Format/.clang-format
clang/unittests/Format/FormatTestMacroExpansion.cpp

Removed: 




diff  --git a/clang/include/clang/Format/.clang-format 
b/clang/include/clang/Format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/include/clang/Format/.clang-format
+++ b/clang/include/clang/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/lib/Format/.clang-format b/clang/lib/Format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/lib/Format/.clang-format
+++ b/clang/lib/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/tools/clang-format/.clang-format 
b/clang/tools/clang-format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/tools/clang-format/.clang-format
+++ b/clang/tools/clang-format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/unittests/Format/.clang-format 
b/clang/unittests/Format/.clang-format
index 60f4950c01a59..63d45e0307a3d 100644
--- a/clang/unittests/Format/.clang-format
+++ b/clang/unittests/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true

diff  --git a/clang/unittests/Format/FormatTestMacroExpansion.cpp 
b/clang/unittests/Format/FormatTestMacroExpansion.cpp
index feafadb1593e2..1ac5ac0d84f12 100644
--- a/clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ b/clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -259,4 +259,4 @@ TEST_F(FormatTestMacroExpansion,
 } // namespace
 } // namespace test
 } // namespace format
-} // namespace clang
\ No newline at end of file
+} // namespace clang



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


[PATCH] D153208: [clang-format] Add InsertNewlineAtEOF to .clang-format files

2023-06-20 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbca11bafba97: [clang-format] Add InsertNewlineAtEOF to 
.clang-format files (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153208

Files:
  clang/include/clang/Format/.clang-format
  clang/lib/Format/.clang-format
  clang/tools/clang-format/.clang-format
  clang/unittests/Format/.clang-format
  clang/unittests/Format/FormatTestMacroExpansion.cpp


Index: clang/unittests/Format/FormatTestMacroExpansion.cpp
===
--- clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -259,4 +259,4 @@
 } // namespace
 } // namespace test
 } // namespace format
-} // namespace clang
\ No newline at end of file
+} // namespace clang
Index: clang/unittests/Format/.clang-format
===
--- clang/unittests/Format/.clang-format
+++ clang/unittests/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/tools/clang-format/.clang-format
===
--- clang/tools/clang-format/.clang-format
+++ clang/tools/clang-format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/lib/Format/.clang-format
===
--- clang/lib/Format/.clang-format
+++ clang/lib/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/include/clang/Format/.clang-format
===
--- clang/include/clang/Format/.clang-format
+++ clang/include/clang/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true


Index: clang/unittests/Format/FormatTestMacroExpansion.cpp
===
--- clang/unittests/Format/FormatTestMacroExpansion.cpp
+++ clang/unittests/Format/FormatTestMacroExpansion.cpp
@@ -259,4 +259,4 @@
 } // namespace
 } // namespace test
 } // namespace format
-} // namespace clang
\ No newline at end of file
+} // namespace clang
Index: clang/unittests/Format/.clang-format
===
--- clang/unittests/Format/.clang-format
+++ clang/unittests/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/tools/clang-format/.clang-format
===
--- clang/tools/clang-format/.clang-format
+++ clang/tools/clang-format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/lib/Format/.clang-format
===
--- clang/lib/Format/.clang-format
+++ clang/lib/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
Index: clang/include/clang/Format/.clang-format
===
--- clang/include/clang/Format/.clang-format
+++ clang/include/clang/Format/.clang-format
@@ -1,4 +1,5 @@
 BasedOnStyle: LLVM
 InsertBraces: true
+InsertNewlineAtEOF: true
 LineEnding: LF
 RemoveBracesLLVM: true
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: dblaikie, aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Michael137 requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

This patch implements the DWARFv5 feature where a
`DW_AT_defaulted` is attached to `DW_TAG_subprogram`s
which are explicitly defaulted in C++, i.e., member
functions such as the following:

  class C {
C() = default;
~C() = default;
  };

We add two new `spFlags`, one for each possible value of
`DW_AT_defaulted` (see table in section 5.7.8 of DWARFv5
specification).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153362

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-defaulted.cpp
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/DW_AT_defaulted.ll

Index: llvm/test/DebugInfo/DW_AT_defaulted.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/DW_AT_defaulted.ll
@@ -0,0 +1,130 @@
+; RUN: llc < %s -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v %t | FileCheck %s
+
+; C++ source to regenerate:
+; struct defaulted {
+;   // inline defaulted
+;   defaulted() = default;
+; 
+;   // out-of-line defaulted (inline keyword
+;   // shouldn't change that)
+;   inline ~defaulted();
+; 
+;   // These shouldn't produce a defaulted-ness DI flag
+;   // (though technically they are DW_DEFAULTED_no)
+;   defaulted& operator=(defaulted const&) { return *this; }
+;   defaulted& operator=(defaulted &&);
+; 
+;   bool operator==(defaulted const&) const = default;
+; };
+; 
+; defaulted::~defaulted() = default;
+; defaulted& defaulted::operator=(defaulted &&) { return *this; }
+; 
+; void foo() {
+;   defaulted d;
+; }
+; $ clang++ -O0 -g -gdwarf-5 debug-info-defaulted.cpp -c
+
+; CHECK: .debug_info contents:
+
+; CHECK:  DW_TAG_structure_type
+; CHECK:DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "~defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_out_of_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [9]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator==")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:NULL
+
+%struct.defaulted = type { i8 }
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+define void @_Z3foov() !dbg !39 {
+entry:
+  %d = alloca %struct.defaulted, align 1
+  call void @llvm.dbg.declare(metadata ptr %d, metadata !42, metadata !DIExpression()), !dbg !43
+  ret void, !dbg !47
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.linker.options = !{}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "../llvm-project/clang/test/CodeGenCXX/debug-info-defaulted.cpp", directory: "/tmp", checksumkind: CSK_MD5, checksum: "ee982c44dd268333101243e050103fb8")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 1}
+!8 = !{!"clang version 17.0.0"}
+!9 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN9defaultedaSEOS_", scope: !10, file: !1, line: 29, type: !24, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !23, retainedNodes: !32)
+!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "defaulted", file: !1, line: 12, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !11, identifier: "_ZTS9defaulted")
+!11 = !{!12, !16, !17, !23, !27}
+!12 = !DISubprogram(name: "defaulted", scope: !10, file: !1, line: 14, type: !13, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null, !15}
+!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size:

[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 532952.
Michael137 added a comment.
Herald added a subscriber: ormris.

- remove redundant includes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153362

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-defaulted.cpp
  llvm/include/llvm/IR/DebugInfoFlags.def
  llvm/include/llvm/IR/DebugInfoMetadata.h
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/DW_AT_defaulted.ll

Index: llvm/test/DebugInfo/DW_AT_defaulted.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/DW_AT_defaulted.ll
@@ -0,0 +1,130 @@
+; RUN: llc < %s -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v %t | FileCheck %s
+
+; C++ source to regenerate:
+; struct defaulted {
+;   // inline defaulted
+;   defaulted() = default;
+; 
+;   // out-of-line defaulted (inline keyword
+;   // shouldn't change that)
+;   inline ~defaulted();
+; 
+;   // These shouldn't produce a defaulted-ness DI flag
+;   // (though technically they are DW_DEFAULTED_no)
+;   defaulted& operator=(defaulted const&) { return *this; }
+;   defaulted& operator=(defaulted &&);
+; 
+;   bool operator==(defaulted const&) const = default;
+; };
+; 
+; defaulted::~defaulted() = default;
+; defaulted& defaulted::operator=(defaulted &&) { return *this; }
+; 
+; void foo() {
+;   defaulted d;
+; }
+; $ clang++ -O0 -g -gdwarf-5 debug-info-defaulted.cpp -c
+
+; CHECK: .debug_info contents:
+
+; CHECK:  DW_TAG_structure_type
+; CHECK:DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [5]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "~defaulted")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_out_of_class)
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [7]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator=")
+; CHECK-NOT:  DW_AT_defaulted
+; CHECK:  NULL
+
+; CHECK:DW_TAG_subprogram [9]
+; CHECK:  DW_AT_name [DW_FORM_strx1]	(indexed ({{.*}}) string = "operator==")
+; CHECK:  DW_AT_defaulted [DW_FORM_data1]	(DW_DEFAULTED_in_class)
+; CHECK:  NULL
+
+; CHECK:NULL
+
+%struct.defaulted = type { i8 }
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata)
+
+define void @_Z3foov() !dbg !39 {
+entry:
+  %d = alloca %struct.defaulted, align 1
+  call void @llvm.dbg.declare(metadata ptr %d, metadata !42, metadata !DIExpression()), !dbg !43
+  ret void, !dbg !47
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.linker.options = !{}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: Apple, sysroot: "/")
+!1 = !DIFile(filename: "../llvm-project/clang/test/CodeGenCXX/debug-info-defaulted.cpp", directory: "/tmp", checksumkind: CSK_MD5, checksum: "ee982c44dd268333101243e050103fb8")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"uwtable", i32 1}
+!7 = !{i32 7, !"frame-pointer", i32 1}
+!8 = !{!"clang version 17.0.0"}
+!9 = distinct !DISubprogram(name: "operator=", linkageName: "_ZN9defaultedaSEOS_", scope: !10, file: !1, line: 29, type: !24, scopeLine: 29, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, declaration: !23, retainedNodes: !32)
+!10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "defaulted", file: !1, line: 12, size: 8, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !11, identifier: "_ZTS9defaulted")
+!11 = !{!12, !16, !17, !23, !27}
+!12 = !DISubprogram(name: "defaulted", scope: !10, file: !1, line: 14, type: !13, scopeLine: 14, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+!13 = !DISubroutineType(types: !14)
+!14 = !{null, !15}
+!15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !10, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
+!16 = !DISubprogram(name: "~defaulted", scope: !10, file: !1, line: 18, type: !13, scopeLine: 18, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedOutOfClass)
+!17 = !DISubprogram(name: "operator=", linkageName: "_ZN9defaultedaSERKS_", scope: !10, file: !1, line: 22, type: !18, scopeLine: 22, flags: DIFlagPrototyped, spFlags: 0)
+!18 = !DISubroutineType(types: !19)
+!19 = !{!20, !15, !21}
+!20 =

[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/FormatToken.cpp:79
 bool FormatToken::opensBlockOrBlockTypeList(const FormatStyle &Style) const {
+  auto bk = getBlockKind();
   // C# Does not indent object initialisers as continuations.

HazardyKnusperkeks wrote:
> 
why pull this out? if you are worried about speed now you do it EVERY time 
whereas before we wouldn't do it unless limited conditions, for me I'd get rid 
of bk and just use getBlockKind() directly everytime, the compiler should I 
hope optimise it away



Comment at: clang/unittests/Format/FormatTest.cpp:25625
+   "SomeArrayT{},\n"
+   "}\n",
+   Style);

should there be a semi colon here?



Comment at: clang/unittests/Format/FormatTest.cpp:25642
+   "{baz},\n"
+   "}\n",
+   Style);

should there be a semi colon here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:25511
+  // Designated initializers.
+  verifyFormat("int LongVariable[1] = {\n"
+   "[0] = 1000, [1] = 2000\n"

nit [2]


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In principle I like this as its annoyed me for years


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153363: [clang][analyzer] No end-of-file when seek to file begin.

2023-06-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, manas, ASDenysPetrov, martong, gamesh411, 
dkrupp, donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, 
baloghadamsoftware, xazax.hun.
Herald added a reviewer: Szelethus.
Herald added a reviewer: NoQ.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

If `fseek` is used with 0 position and SEEK_SET it sets the position
to the start of the file. This should not cause FEOF (end of file) error.
The case of an empty file is not handled for simplification.
It is not exactly defined in what cases `fseek` produces the different
error states. Normally feof should not happen at all because it is
possible to set the position after the end of file, but previous tests
showed that still feof (and any other error cases) can happen.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153363

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-error.c

Index: clang/test/Analysis/stream-error.c
===
--- clang/test/Analysis/stream-error.c
+++ clang/test/Analysis/stream-error.c
@@ -146,7 +146,7 @@
   FILE *F = fopen("file", "r");
   if (!F)
 return;
-  int rc = fseek(F, 0, SEEK_SET);
+  int rc = fseek(F, 1, SEEK_SET);
   if (rc) {
 int IsFEof = feof(F), IsFError = ferror(F);
 // Get feof or ferror or no error.
@@ -173,6 +173,35 @@
   fclose(F);
 }
 
+void error_fseek_0(void) {
+  FILE *F = fopen("file", "r");
+  if (!F)
+return;
+  int rc = fseek(F, 0, SEEK_SET);
+  if (rc) {
+int IsFEof = feof(F), IsFError = ferror(F);
+// Get ferror or no error, but not feof.
+clang_analyzer_eval(IsFError);
+// expected-warning@-1 {{FALSE}}
+// expected-warning@-2 {{TRUE}}
+clang_analyzer_eval(IsFEof);
+// expected-warning@-1 {{FALSE}}
+// Error flags should not change.
+clang_analyzer_eval(feof(F)); // expected-warning {{FALSE}}
+if (IsFError)
+  clang_analyzer_eval(ferror(F)); // expected-warning {{TRUE}}
+else
+  clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  } else {
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+// Error flags should not change.
+clang_analyzer_eval(feof(F));   // expected-warning {{FALSE}}
+clang_analyzer_eval(ferror(F)); // expected-warning {{FALSE}}
+  }
+  fclose(F);
+}
+
 void error_indeterminate(void) {
   FILE *F = fopen("file", "r+");
   if (!F)
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -285,7 +285,14 @@
 0}},
   };
 
+  /// Expanded value of EOF, empty before initialization.
   mutable std::optional EofVal;
+  /// Expanded value of SEEK_SET, 0 if not found.
+  mutable int SeekSetVal = 0;
+  /// Expanded value of SEEK_CUR, 1 if not found.
+  mutable int SeekCurVal = 1;
+  /// Expanded value of SEEK_END, 2 if not found.
+  mutable int SeekEndVal = 2;
 
   void evalFopen(const FnDescription *Desc, const CallEvent &Call,
  CheckerContext &C) const;
@@ -432,7 +439,7 @@
 });
   }
 
-  void initEof(CheckerContext &C) const {
+  void initMacroValues(CheckerContext &C) const {
 if (EofVal)
   return;
 
@@ -441,6 +448,15 @@
   EofVal = *OptInt;
 else
   EofVal = -1;
+if (const std::optional OptInt =
+tryExpandAsInteger("SEEK_SET", C.getPreprocessor()))
+  SeekSetVal = *OptInt;
+if (const std::optional OptInt =
+tryExpandAsInteger("SEEK_END", C.getPreprocessor()))
+  SeekEndVal = *OptInt;
+if (const std::optional OptInt =
+tryExpandAsInteger("SEEK_CUR", C.getPreprocessor()))
+  SeekCurVal = *OptInt;
   }
 
   /// Searches for the ExplodedNode where the file descriptor was acquired for
@@ -488,7 +504,7 @@
 
 void StreamChecker::checkPreCall(const CallEvent &Call,
  CheckerContext &C) const {
-  initEof(C);
+  initMacroValues(C);
 
   const FnDescription *Desc = lookupFn(Call);
   if (!Desc || !Desc->PreFn)
@@ -786,6 +802,11 @@
   if (!State->get(StreamSym))
 return;
 
+  const llvm::APSInt *PosV =
+  C.getSValBuilder().getKnownValue(State, Call.getArgSVal(1));
+  const llvm::APSInt *WhenceV =
+  C.getSValBuilder().getKnownValue(State, Call.getArgSVal(2));
+
   DefinedSVal RetVal = makeRetVal(C, CE);
 
   // Make expression result.
@@ -804,9 +825,12 @@
   // It is possible that fseek fails but sets none of the error flags.
   // If fseek failed, assume that the file position becomes indeterminate in any
   // case.
+  StreamErrorState NewErrS = ErrorNone | ErrorFError;
+  // Setting the position to start of file ne

[PATCH] D153362: [clang][DebugInfo] Emit DW_AT_defaulted for defaulted C++ member functions

2023-06-20 Thread Michael Buch via Phabricator via cfe-commits
Michael137 updated this revision to Diff 532957.
Michael137 added a comment.

- clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153362

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGenCXX/debug-info-defaulted.cpp


Index: clang/test/CodeGenCXX/debug-info-defaulted.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-defaulted.cpp
@@ -0,0 +1,38 @@
+// Test for debug info for C++ defaulted member functions
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu %s -o - \
+// RUN:   -O0 -debug-info-kind=standalone -std=c++20 | FileCheck %s
+
+// CHECK: DISubprogram(name: "defaulted", {{.*}}, flags: DIFlagPrototyped, 
spFlags: DISPFlagDefaultedInClass)
+// CHECK: DISubprogram(name: "~defaulted", {{.*}}, flags: 
DIFlagPrototyped, spFlags: DISPFlagDefaultedOutOfClass)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, 
spFlags: 0)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, 
spFlags: 0)
+// CHECK: DISubprogram(name: "operator==", {{.*}}, flags: 
DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+// CHECK-NOT: DISubprogram(name: "implicit_defaulted"
+struct defaulted {
+  // inline defaulted
+  defaulted() = default;
+
+  // out-of-line defaulted (inline keyword
+  // shouldn't change that)
+  inline ~defaulted();
+
+  // These shouldn't produce a defaulted-ness DI flag
+  // (though technically they are DW_DEFAULTED_no)
+  defaulted& operator=(defaulted const&) { return *this; }
+  defaulted& operator=(defaulted &&);
+
+  bool operator==(defaulted const&) const = default;
+};
+
+defaulted::~defaulted() = default;
+defaulted& defaulted::operator=(defaulted &&) { return *this; }
+
+// All ctors/dtors are implicitly defatuled.
+// So no DW_AT_defaulted expected for these.
+struct implicit_defaulted {};
+
+void foo() {
+  defaulted d;
+  implicit_defaulted i;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1948,6 +1948,14 @@
   if (Method->getCanonicalDecl()->isDeleted())
 SPFlags |= llvm::DISubprogram::SPFlagDeleted;
 
+  // The defaulted-ness of an out-of-class method is a property of its
+  // definition. Hence, query the definition instead.
+  if (auto const *Def = Method->getDefinition())
+if (Def->isExplicitlyDefaulted())
+  SPFlags |= (Def->isOutOfLine())
+ ? llvm::DISubprogram::SPFlagDefaultedOutOfClass
+ : llvm::DISubprogram::SPFlagDefaultedInClass;
+
   if (Method->isNoReturn())
 Flags |= llvm::DINode::FlagNoReturn;
 


Index: clang/test/CodeGenCXX/debug-info-defaulted.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-defaulted.cpp
@@ -0,0 +1,38 @@
+// Test for debug info for C++ defaulted member functions
+
+// RUN: %clang_cc1 -emit-llvm -triple x86_64-linux-gnu %s -o - \
+// RUN:   -O0 -debug-info-kind=standalone -std=c++20 | FileCheck %s
+
+// CHECK: DISubprogram(name: "defaulted", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+// CHECK: DISubprogram(name: "~defaulted", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedOutOfClass)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, spFlags: 0)
+// CHECK: DISubprogram(name: "operator=", {{.*}}, flags: DIFlagPrototyped, spFlags: 0)
+// CHECK: DISubprogram(name: "operator==", {{.*}}, flags: DIFlagPrototyped, spFlags: DISPFlagDefaultedInClass)
+// CHECK-NOT: DISubprogram(name: "implicit_defaulted"
+struct defaulted {
+  // inline defaulted
+  defaulted() = default;
+
+  // out-of-line defaulted (inline keyword
+  // shouldn't change that)
+  inline ~defaulted();
+
+  // These shouldn't produce a defaulted-ness DI flag
+  // (though technically they are DW_DEFAULTED_no)
+  defaulted& operator=(defaulted const&) { return *this; }
+  defaulted& operator=(defaulted &&);
+
+  bool operator==(defaulted const&) const = default;
+};
+
+defaulted::~defaulted() = default;
+defaulted& defaulted::operator=(defaulted &&) { return *this; }
+
+// All ctors/dtors are implicitly defatuled.
+// So no DW_AT_defaulted expected for these.
+struct implicit_defaulted {};
+
+void foo() {
+  defaulted d;
+  implicit_defaulted i;
+}
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1948,6 +1948,14 @@
   if (Method->getCanonicalDecl()->isDeleted())
 SPFlags |= llvm::DISubprogram::SPFlagDeleted;
 
+  // The defaulted-ness of an out-of-class method is a property of its
+  // definition. Hence, query the definition instead.
+  if (auto const *D

[PATCH] D92797: APINotes: add initial stub of APINotesWriter

2023-06-20 Thread Egor Zhdan via Phabricator via cfe-commits
egorzhdan added a comment.

@compnerd @martong would you be OK with merging this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92797

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


[PATCH] D151963: [clang][NFC] Remove trailing whitespaces and enforce it in lib, include and docs

2023-06-20 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth accepted this revision.
paulkirth added a comment.
Herald added a subscriber: wangpc.

Also LGTM for the changes in MisExpect.rst, modulo feedback from @erichkeane.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151963

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


[PATCH] D153236: [NFC] Fix potential dereferencing of nullptr.

2023-06-20 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:887
+  else {
+assert(DeepestParsedCaseStmt && "DeepestParsedCaseStmt cannot be 
null");
 Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, Case.get());

Fznamznon wrote:
> The assert that looks like `assert(x && "x should not be null")` seems 
> strange. Failed `assert(x)` implies that `x` should not be null. If there is 
> a message, a message saying what is wrong and why is much more useful.
Would you suggest removing the message and changing it to 
```
assert(DeepestParsedCaseStmt);
``` 


I am not sure what message would be useful here. 



Comment at: clang/lib/Sema/SemaExprObjC.cpp:2441
 
+  assert(receiverTypeInfo && "receiverTypeInfo cannot be null");
   return BuildClassMessage(receiverTypeInfo, ReceiverType,

Fznamznon wrote:
> That seems to be a strange place before and after changes. With or without 
> change, when `ReceiverType.isNull()` is true we just end up passing `nullptr` 
>  as `receiverTypeInfo ` to the `BuildClassMessage` which doesn't seem to be 
> checking its non-nullness before dereferencing it, even though its 
> description says that `receiverTypeInfo` can be null. 
> I guess it is fine to pass `nullptr` to a function whose description says so, 
> but the non-nullness check inside of it should be probably a bit more obvious 
> than it is right now.
I see your point about passing `ReceiverTypeInfo` as nullptr to 
`BuildClassMessage` method - it seems ok to do that. 
Would it make sense to add an `assert(ReceiverTypeInfo);` inside the method as 
way of making the non-nullness check more obvious? 


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

https://reviews.llvm.org/D153236

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


[PATCH] D153235: [RISCV] Change the type of argument to clz and ctz from ZiZi/WiWi to iUZi/iUWi

2023-06-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153235

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


[PATCH] D153366: [dataflow] Add dedicated representation of boolean formulas

2023-06-20 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: martong, mgrang, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is the first step in untangling the two current jobs of BoolValue:

- BoolValue will model C++ booleans e.g. held in StorageLocations. this 
includes describing uncertainty (e.g. "top" is a Value concern)
- Formula describes analysis-level assertions in terms of SAT atoms.

These can still be linked together: a BoolValue may have a corresponding
SAT atom which is constrained by formulas.

For now, BoolValue is left intact, Formula is just the input type to the
SAT solver, and we build formulas as needed to invoke the solver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153366

Files:
  clang/include/clang/Analysis/FlowSensitive/Arena.h
  clang/include/clang/Analysis/FlowSensitive/DebugSupport.h
  clang/include/clang/Analysis/FlowSensitive/Formula.h
  clang/include/clang/Analysis/FlowSensitive/Solver.h
  clang/include/clang/Analysis/FlowSensitive/WatchedLiteralsSolver.h
  clang/lib/Analysis/FlowSensitive/Arena.cpp
  clang/lib/Analysis/FlowSensitive/CMakeLists.txt
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DebugSupport.cpp
  clang/lib/Analysis/FlowSensitive/Formula.cpp
  clang/lib/Analysis/FlowSensitive/WatchedLiteralsSolver.cpp
  clang/unittests/Analysis/FlowSensitive/DebugSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.h

Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.h
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -42,6 +42,7 @@
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Allocator.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -404,55 +405,51 @@
 
 /// Creates and owns constraints which are boolean values.
 class ConstraintContext {
-public:
-  // Creates an atomic boolean value.
-  BoolValue *atom() {
-Vals.push_back(std::make_unique());
-return Vals.back().get();
+  unsigned NextAtom;
+  llvm::BumpPtrAllocator A;
+
+  const Formula *make(Formula::Kind K, llvm::ArrayRef Operands) {
+return &Formula::create(A, K, Operands);
   }
 
+public:
+#if 0 // XXX
   // Creates an instance of the Top boolean value.
   BoolValue *top() {
 Vals.push_back(std::make_unique());
 return Vals.back().get();
   }
+#endif
+
+  // Creates a reference to a fresh atomic variable.
+  const Formula *atom() {
+return &Formula::create(A, Formula::AtomRef, {}, ++NextAtom);
+  }
 
   // Creates a boolean conjunction value.
-  BoolValue *conj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *conj(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::And, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean disjunction value.
-  BoolValue *disj(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula*disj(const Formula*LeftSubVal, const Formula*RightSubVal) {
+return make(Formula::Or, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean negation value.
-  BoolValue *neg(BoolValue *SubVal) {
-Vals.push_back(std::make_unique(*SubVal));
-return Vals.back().get();
+  const Formula *neg(const Formula *SubVal) {
+return make(Formula::Not, {SubVal});
   }
 
   // Creates a boolean implication value.
-  BoolValue *impl(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *impl(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Implies, {LeftSubVal, RightSubVal});
   }
 
   // Creates a boolean biconditional value.
-  BoolValue *iff(BoolValue *LeftSubVal, BoolValue *RightSubVal) {
-Vals.push_back(
-std::make_unique(*LeftSubVal, *RightSubVal));
-return Vals.back().get();
+  const Formula *iff(const Formula *LeftSubVal, const Formula *RightSubVal) {
+return make(Formula::Equal, {LeftSubVal, RightSubVal});
   }
-
-private:
-  std::vector> Vals;
 };
 
 } // namespace test
Index: clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
@@ -30,19 +30,23 @@
 
 // Chec

[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

As mentioned in the GH issue, I think this change looks fine.
But I would suggest waiting for feedback from @rsmith to ensure there isn't a 
reason for cleanups being removed that we are missing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

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


[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-20 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 532964.
VitaNuo marked 8 inline comments as done.
VitaNuo added a comment.
Herald added a subscriber: javed.absar.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152900

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/IndexAction.cpp
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CanonicalIncludesTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/SymbolCollectorTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestWorkspace.cpp

Index: clang-tools-extra/clangd/unittests/TestWorkspace.cpp
===
--- clang-tools-extra/clangd/unittests/TestWorkspace.cpp
+++ clang-tools-extra/clangd/unittests/TestWorkspace.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "TestWorkspace.h"
+#include "clang-include-cleaner/Record.h"
 #include "index/FileIndex.h"
 #include "gtest/gtest.h"
 #include 
@@ -22,9 +23,10 @@
 TU.Code = Input.second.Code;
 TU.Filename = Input.first().str();
 TU.preamble([&](ASTContext &Ctx, Preprocessor &PP,
-const CanonicalIncludes &CanonIncludes) {
+const CanonicalIncludes &CanonIncludes,
+const include_cleaner::PragmaIncludes *PI) {
   Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
-CanonIncludes);
+CanonIncludes, PI);
 });
 ParsedAST MainAST = TU.build();
 Index->updateMain(testPath(Input.first()), MainAST);
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -164,9 +164,9 @@
 
 SymbolSlab TestTU::headerSymbols() const {
   auto AST = build();
-  return std::get<0>(indexHeaderSymbols(/*Version=*/"null", AST.getASTContext(),
-AST.getPreprocessor(),
-AST.getCanonicalIncludes()));
+  return std::get<0>(indexHeaderSymbols(
+  /*Version=*/"null", AST.getASTContext(), AST.getPreprocessor(),
+  AST.getCanonicalIncludes(), AST.getPragmaIncludes()));
 }
 
 RefSlab TestTU::headerRefs() const {
@@ -179,7 +179,7 @@
   auto Idx = std::make_unique();
   Idx->updatePreamble(testPath(Filename), /*Version=*/"null",
   AST.getASTContext(), AST.getPreprocessor(),
-  AST.getCanonicalIncludes());
+  AST.getCanonicalIncludes(), AST.getPragmaIncludes());
   Idx->updateMain(testPath(Filename), AST);
   return std::move(Idx);
 }
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -18,6 +18,7 @@
 #include "TUScheduler.h"
 #include "TestFS.h"
 #include "TestIndex.h"
+#include "clang-include-cleaner/Record.h"
 #include "support/Cancellation.h"
 #include "support/Context.h"
 #include "support/Path.h"
@@ -1131,7 +1132,8 @@
 : BlockVersion(BlockVersion), N(N) {}
 void onPreambleAST(PathRef Path, llvm::StringRef Version,
const CompilerInvocation &, ASTContext &Ctx,
-   Preprocessor &, const CanonicalIncludes &) override {
+   Preprocessor &, const CanonicalIncludes &,
+   const include_cleaner::PragmaIncludes *) override {
   if (Version == BlockVersion)
 N.wait();
 }
@@ -1210,7 +1212,8 @@
 
 void onPreambleAST(PathRef Path, llvm::StringRef Version,
const CompilerInvocation &, ASTContext &Ctx,
-   Preprocessor &, const CanonicalIncludes &) override {
+   Preprocessor &, const CanonicalIncludes &,
+   const include_cleaner::PragmaIncludes *) override {
   if (BuildBefore)
 ASSERT_TRUE(UnblockPreamble.wait(timeoutSeconds(5)))
 << "Expected notification";
@@

[PATCH] D152900: [clangd] Update symbol collector to use include-cleaner.

2023-06-20 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks for the comments!




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:393-395
+const auto *FileEntry = SM.getFileEntryForID(FID);
+for (const auto *Export : PI.getExporters(FileEntry, SM.getFileManager()))
+  return toURI(Export->tryGetRealPathName());

kadircet wrote:
> sorry i don't understand what this logic is trying to achieve.
> 
> we seem to be prefering "first" exporting header, over the headers that 
> directly provide the symbol. Also comment says it's done for objc, but 
> there's nothing limiting this logic to ObjC. any chance this is unintended?
No, this was intended, but possibly I didn't get it right.

>  comment says it's done for objc, but there's nothing limiting this logic to 
> objc

AFAIU this whole code path will now only be reachable for objc symbols.  I have 
removed pragma includes from the canonical include mapping now, leaving the 
pragma handling to include cleaner. However, that only triggers for C/C++, so 
in case we need the `export` and `private` pragmas for objc, we need to 
re-insert the handling for them somewhere. 
There is no pre-existing test case for pragmas in objc and there is no usage of 
these pragmas for objc code in the code base either,  so I have no way of 
knowing if this is actually needed. But I believe you've mentioned in some 
discussion we should still handle the pragmas for objc.

> we seem to be preferring "first" exporting header, over the headers that 
> directly provide the symbol.

Isn't that correct if there's an `IWYU export` pragma involved? The snippet 
comes from `include_cleaner::findHeaders`, with the only difference that it 
stops at the first exporter (since the canonical include mapping also just 
stored one mapping for the header).

Let me know how to do it better, or maybe if this is necessary at all. 
Honestly, I am not sure about this, since, as mentioned, there are no `export` 
or `private/public` pragmas in objc files in the codebase atm.




Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:903
+NewSym = *S;
+if (!IncludeHeader.empty()) {
   NewSym.IncludeHeaders.push_back({IncludeHeader, 1, Directives});

kadircet wrote:
> this is using legacy mappings for non-objc symbols too
Removed this whole passage.



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:934-936
+  SymbolIncludeSpelling[SID] = HeaderFileURIs->getIncludeHeader(
+  ASTCtx->getSourceManager().getOrCreateFileID(
+  H.physical(), SrcMgr::CharacteristicKind::C_User));

kadircet wrote:
> we actually only want to use `HeaderFileURIs->toURI` here and not the 
> `getIncludeHeader`, because:
> - We want to make use of mapping logic in include-cleaner solely, and we 
> already have all that information in Providers mapping.
> - The extra logic we want to apply for ObjC symbols are already applied 
> before reaching here.
> 
> the way we create a FileID here is a little bit iffy, by using `toURI`, 
> hopefully we can avoid that conversion.
> 
> the only remaining issue is, we actually still want to use system header 
> mappings inside `CanonicalIncludes` until we have better support for them in 
> include-cleaner library itself. So I think we should still call 
> `Includes->mapHeader(H.physical())` before using `toURI`.
Ok SGTM. It seems, though, that we still need the "iffy" FID for the canonical 
mapping.. Let me know if you know a better way. 





Comment at: clang-tools-extra/clangd/index/SymbolCollector.h:131
+  }
+  void setPreprocessor(Preprocessor &PP) {
+this->PP = &PP;

kadircet wrote:
> unfortunately this alternative is called after we've parsed the file, from 
> `clangd/index/FileIndex.cpp`, `indexSymbols`. hence attaching `PI` to 
> `PPCallbacks` won't have any effect.
> 
> This is working unintentionally because we're still populating 
> `CanonicalIncludes` with legacy IWYUPragmaHandler in clangd, and using that 
> to perform private -> public mappings.
> 
> We should instead propagate the `PragmaIncludes` we have in `ParsedAST` and 
> in preamble builds here. You should be able to test the new behaviour 
> `clang-tools-extra/clangd/unittests/FileIndexTests.cpp` to make sure pragma 
> handling through dynamic indexing code paths keep working as expected using 
> an `export` pragma.
Ok thank you. I'm using `PragmaIncludes` from AST and preamble builds for the 
dynamic index now.

For the background index, I've finally managed to move pragma recording to the 
`IndexAction` now.

I've also removed the redundant (to include cleaner) comment handlers from the 
AST build and preamble building logic. 

Also removed the `mapSymbol` method from `CanonicalIncludes`, since it had one 
usage which should now be covered by the include cleaner, I believe. 


Repository:
  rG LLVM Github Mo

[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread Gedare Bloom via Phabricator via cfe-commits
gedare added a comment.

In D153205#4431235 , 
@HazardyKnusperkeks wrote:

> You add a lot of checks and I honestly can't say if it does not affect other 
> code that is not covered by the tests.

Not much I can do about that. I guess it is worth noting that all the checks I 
add are predicated on either BK_ListInit or BK_BracedInit.  I have reduced the 
checks to what minimally works to address the Issue.  Technically, this has two 
distinct changes included:

- Allow BlockIndent to work with Braces.
- Allow BlockIndent to work with array/struct initializers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-20 Thread Gedare Bloom via Phabricator via cfe-commits
gedare updated this revision to Diff 532967.
gedare added a comment.

Do not use temporary variable for getBlockKind().
Fix test case syntax errors.
Fix formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

Files:
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -4929,7 +4929,7 @@
"  \"\"};\n",
Style);
   // Designated initializers.
-  verifyFormat("int LongVariable[1] = {\n"
+  verifyFormat("int LongVariable[2] = {\n"
"  [0] = 1000, [1] = 2000};",
Style);
   verifyFormat("SomeStruct s{\n"
@@ -5039,7 +5039,7 @@
"bar,\n"
"  },\n"
"  SomeArrayT{},\n"
-   "}\n",
+   "};\n",
Style);
   verifyFormat("SomeArrayT a[3] = {\n"
"  {foo},\n"
@@ -5056,7 +5056,7 @@
"},\n"
"  },\n"
"  {baz},\n"
-   "}\n",
+   "};\n",
Style);
 
   // Aligning after open braces unaffected by BracedInitializerIndentWidth.
@@ -25494,6 +25494,155 @@
Style);
 }
 
+TEST_F(FormatTest, AlignAfterOpenBracketBlockIndentInitializers) {
+  auto Style = getLLVMStyleWithColumns(60);
+  Style.AlignAfterOpenBracket = FormatStyle::BAS_BlockIndent;
+  // Aggregate initialization.
+  verifyFormat("int LongVariable[2] = {\n"
+   "1000, 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   "\"\", \"\",\n"
+   "\"\"\n"
+   "};",
+   Style);
+  // Designated initializers.
+  verifyFormat("int LongVariable[2] = {\n"
+   "[0] = 1000, [1] = 2000\n"
+   "};",
+   Style);
+  verifyFormat("SomeStruct s{\n"
+   ".foo = \"x\",\n"
+   ".bar = \"y\",\n"
+   ".baz = \"z\"\n"
+   "};\n",
+   Style);
+  // List initialization.
+  verifyFormat("SomeStruct s{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  verifyFormat("new SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Member initializer.
+  verifyFormat("class SomeClass {\n"
+   "  SomeStruct s{\n"
+   "  \"x\",\n"
+   "  \"y\",\n"
+   "  \"z\",\n"
+   "  };\n"
+   "};\n",
+   Style);
+  // Constructor member initializer.
+  verifyFormat("SomeClass::SomeClass : strct{\n"
+   "   \"x\",\n"
+   "   \"y\",\n"
+   "   \"z\",\n"
+   "   } {}\n",
+   Style);
+  // Copy initialization.
+  verifyFormat("SomeStruct s = SomeStruct{\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Copy list initialization.
+  verifyFormat("SomeStruct s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Assignment operand initialization.
+  verifyFormat("s = {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+   Style);
+  // Returned object initialization.
+  verifyFormat("return {\n"
+   "\"x\",\n"
+   "\"y\",\n"
+   "\"z\",\n"
+   "};\n",
+ 

[PATCH] D142994: [UsersManual] Add llvm-progen as an alternative tool for AutoFDO profile generation.

2023-06-20 Thread David Li via Phabricator via cfe-commits
davidxl accepted this revision.
davidxl added a comment.
This revision is now accepted and ready to land.

lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142994

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


[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

2023-06-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, JonChesterfield, tra, 
ABataev, carlo.bertolli.
Herald added subscribers: sunshaoce, guansong.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

This patch changes the handling of OpenMP to add the device attributes
to the canonical definitions when we encounter a non-canonical
definition. Previously, the following code would not work because it
would find the non-canonical definition first which would then not be
used anywhere else.

  int x;
  extern int x;

This patch now adds the attribute to both of them. This allows us to
perform the following operation if, for example, there were an
implementation of `stderr` on the device.

  #include 
  
  // List of libc symbols supported on the device.
  extern FILE *stderr;

Unfortunately I cannot think of an equivalent solution to HIP / CUDA
device declarations as those are done with simple attributes. Attributes
themselves cannot be used to affect a definition once its canonical
definition has already been seen. Some help on that front would be
appreciated.

Fixes https://github.com/llvm/llvm-project/issues/63355


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153369

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/dump.cpp


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To 
DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  
col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare target
+extern int dy;
+#pragma omp end declare target
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dy 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+// CHECK:  `-VarDecl {{.+}} prev {{.+}}  
col:12 dy 'int' extern
+// CHECK-NEXT:   `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -22986,6 +22986,9 @@
   Context, MT, DTCI.DT, IndirectE, IsIndirect, Level,
   SourceRange(Loc, Loc));
   ND->addAttr(A);
+  if (auto *CD = dyn_cast(ND->getCanonicalDecl()))
+if (!CD->hasAttr())
+  CD->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
   checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc);
@@ -23090,6 +23093,9 @@
 DTCI.DT, IndirectE, IsIndirect, Level,
 SourceRange(DTCI.Loc, DTCI.Loc));
 D->addAttr(A);
+if (auto *CD = dyn_cast(D->getCanonicalDecl()))
+  if (!CD->hasAttr())
+CD->addAttr(A);
 if (ASTMutationListener *ML = Context.getASTMutationListener())
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
   }


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  line:[[@LINE-6]]:

[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6784
+  if (II->getInterestingIdentifierID() != 0)
+NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
 }

Please switch over the interesting identifiers here; we don't want to assume 
this feature is only used for these two names.

In fact, should we go ahead and immediately apply it to the four identifiers 
above this?  That would be nice, because then we could actually do this in two 
patches: one patch that does the refactor to track interesting identifiers but 
doesn't cause any functionality changes and a second, very small patch that 
just introduces the new special treatment for `float_t` and `double_t`.


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

https://reviews.llvm.org/D146148

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


[clang-tools-extra] 6fe9cfe - [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base specifier during heuristic resolution

2023-06-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2023-06-20T13:40:26-04:00
New Revision: 6fe9cfe4137bc140c909850c26b52e9406495566

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

LOG: [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base 
specifier during heuristic resolution

The code for resolving the type of a base specifier was inside
CXXRecordDecl::lookupDependentName(), so this patch reimplements
lookupDependentName() in HeuristicResolver.

Fixes https://github.com/clangd/clangd/issues/1657

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

Added: 


Modified: 
clang-tools-extra/clangd/HeuristicResolver.cpp
clang-tools-extra/clangd/HeuristicResolver.h
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/HeuristicResolver.cpp 
b/clang-tools-extra/clangd/HeuristicResolver.cpp
index 7960ab92ba9e6..719094dbf2b7e 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.cpp
+++ b/clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -8,6 +8,7 @@
 
 #include "HeuristicResolver.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
@@ -264,6 +265,68 @@ const Type 
*HeuristicResolver::resolveNestedNameSpecifierToType(
   return nullptr;
 }
 
+namespace {
+
+bool isOrdinaryMember(const NamedDecl *ND) {
+  return ND->isInIdentifierNamespace(Decl::IDNS_Ordinary | Decl::IDNS_Tag |
+ Decl::IDNS_Member);
+}
+
+bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path,
+DeclarationName Name) {
+  Path.Decls = RD->lookup(Name).begin();
+  for (DeclContext::lookup_iterator I = Path.Decls, E = I.end(); I != E; ++I)
+if (isOrdinaryMember(*I))
+  return true;
+
+  return false;
+}
+
+} // namespace
+
+bool HeuristicResolver::findOrdinaryMemberInDependentClasses(
+const CXXBaseSpecifier *Specifier, CXXBasePath &Path,
+DeclarationName Name) const {
+  CXXRecordDecl *RD =
+  resolveTypeToRecordDecl(Specifier->getType().getTypePtr());
+  if (!RD)
+return false;
+  return findOrdinaryMember(RD, Path, Name);
+}
+
+std::vector HeuristicResolver::lookupDependentName(
+CXXRecordDecl *RD, DeclarationName Name,
+llvm::function_ref Filter) const {
+  std::vector Results;
+
+  // Lookup in the class.
+  bool AnyOrdinaryMembers = false;
+  for (const NamedDecl *ND : RD->lookup(Name)) {
+if (isOrdinaryMember(ND))
+  AnyOrdinaryMembers = true;
+if (Filter(ND))
+  Results.push_back(ND);
+  }
+  if (AnyOrdinaryMembers)
+return Results;
+
+  // Perform lookup into our base classes.
+  CXXBasePaths Paths;
+  Paths.setOrigin(RD);
+  if (!RD->lookupInBases(
+  [&](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
+return findOrdinaryMemberInDependentClasses(Specifier, Path, Name);
+  },
+  Paths, /*LookupInDependent=*/true))
+return Results;
+  for (DeclContext::lookup_iterator I = Paths.front().Decls, E = I.end();
+   I != E; ++I) {
+if (isOrdinaryMember(*I) && Filter(*I))
+  Results.push_back(*I);
+  }
+  return Results;
+}
+
 std::vector HeuristicResolver::resolveDependentMember(
 const Type *T, DeclarationName Name,
 llvm::function_ref Filter) const {
@@ -277,7 +340,7 @@ std::vector 
HeuristicResolver::resolveDependentMember(
 if (!RD->hasDefinition())
   return {};
 RD = RD->getDefinition();
-return RD->lookupDependentName(Name, Filter);
+return lookupDependentName(RD, Name, Filter);
   }
   return {};
 }

diff  --git a/clang-tools-extra/clangd/HeuristicResolver.h 
b/clang-tools-extra/clangd/HeuristicResolver.h
index 6e3a8349a8606..dc04123d37593 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.h
+++ b/clang-tools-extra/clangd/HeuristicResolver.h
@@ -16,6 +16,7 @@ namespace clang {
 
 class ASTContext;
 class CallExpr;
+class CXXBasePath;
 class CXXDependentScopeMemberExpr;
 class DeclarationName;
 class DependentScopeDeclRefExpr;
@@ -99,6 +100,20 @@ class HeuristicResolver {
   // which takes a possibly-dependent type `T` and heuristically
   // resolves it to a CXXRecordDecl in which we can try name lookup.
   CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) const;
+
+  // This is a reimplementation of CXXRecordDecl::lookupDependentName()
+  // so that the implementation can call into other HeuristicResolver helpers.
+  // FIXME: Once HeuristicResolver is upstreamed to the clang libraries
+  // (https://github.com/clangd/clangd/discussions/1662),
+  // CXXRecordDecl::lookupDepenedentName() can be removed, and its call sites
+  // can be modified to benefit from the more comprehensive heuristics offered
+  // by Heuri

[PATCH] D153248: [clangd] Use resolveTypeToRecordDecl() to resolve the type of a base specifier during heuristic resolution

2023-06-20 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6fe9cfe4137b: [clangd] Use resolveTypeToRecordDecl() to 
resolve the type of a base specifier… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153248

Files:
  clang-tools-extra/clangd/HeuristicResolver.cpp
  clang-tools-extra/clangd/HeuristicResolver.h
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -893,6 +893,19 @@
 }
   )cpp";
   EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+
+  Code = R"cpp(
+struct Waldo {
+  void find();
+};
+template 
+using Wally = Waldo;
+template 
+struct S : Wally {
+  void Foo() { this->[[find]](); }
+};
+  )cpp";
+  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
Index: clang-tools-extra/clangd/HeuristicResolver.h
===
--- clang-tools-extra/clangd/HeuristicResolver.h
+++ clang-tools-extra/clangd/HeuristicResolver.h
@@ -16,6 +16,7 @@
 
 class ASTContext;
 class CallExpr;
+class CXXBasePath;
 class CXXDependentScopeMemberExpr;
 class DeclarationName;
 class DependentScopeDeclRefExpr;
@@ -99,6 +100,20 @@
   // which takes a possibly-dependent type `T` and heuristically
   // resolves it to a CXXRecordDecl in which we can try name lookup.
   CXXRecordDecl *resolveTypeToRecordDecl(const Type *T) const;
+
+  // This is a reimplementation of CXXRecordDecl::lookupDependentName()
+  // so that the implementation can call into other HeuristicResolver helpers.
+  // FIXME: Once HeuristicResolver is upstreamed to the clang libraries
+  // (https://github.com/clangd/clangd/discussions/1662),
+  // CXXRecordDecl::lookupDepenedentName() can be removed, and its call sites
+  // can be modified to benefit from the more comprehensive heuristics offered
+  // by HeuristicResolver instead.
+  std::vector lookupDependentName(
+  CXXRecordDecl *RD, DeclarationName Name,
+  llvm::function_ref Filter) const;
+  bool findOrdinaryMemberInDependentClasses(const CXXBaseSpecifier *Specifier,
+CXXBasePath &Path,
+DeclarationName Name) const;
 };
 
 } // namespace clangd
Index: clang-tools-extra/clangd/HeuristicResolver.cpp
===
--- clang-tools-extra/clangd/HeuristicResolver.cpp
+++ clang-tools-extra/clangd/HeuristicResolver.cpp
@@ -8,6 +8,7 @@
 
 #include "HeuristicResolver.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/Type.h"
@@ -264,6 +265,68 @@
   return nullptr;
 }
 
+namespace {
+
+bool isOrdinaryMember(const NamedDecl *ND) {
+  return ND->isInIdentifierNamespace(Decl::IDNS_Ordinary | Decl::IDNS_Tag |
+ Decl::IDNS_Member);
+}
+
+bool findOrdinaryMember(const CXXRecordDecl *RD, CXXBasePath &Path,
+DeclarationName Name) {
+  Path.Decls = RD->lookup(Name).begin();
+  for (DeclContext::lookup_iterator I = Path.Decls, E = I.end(); I != E; ++I)
+if (isOrdinaryMember(*I))
+  return true;
+
+  return false;
+}
+
+} // namespace
+
+bool HeuristicResolver::findOrdinaryMemberInDependentClasses(
+const CXXBaseSpecifier *Specifier, CXXBasePath &Path,
+DeclarationName Name) const {
+  CXXRecordDecl *RD =
+  resolveTypeToRecordDecl(Specifier->getType().getTypePtr());
+  if (!RD)
+return false;
+  return findOrdinaryMember(RD, Path, Name);
+}
+
+std::vector HeuristicResolver::lookupDependentName(
+CXXRecordDecl *RD, DeclarationName Name,
+llvm::function_ref Filter) const {
+  std::vector Results;
+
+  // Lookup in the class.
+  bool AnyOrdinaryMembers = false;
+  for (const NamedDecl *ND : RD->lookup(Name)) {
+if (isOrdinaryMember(ND))
+  AnyOrdinaryMembers = true;
+if (Filter(ND))
+  Results.push_back(ND);
+  }
+  if (AnyOrdinaryMembers)
+return Results;
+
+  // Perform lookup into our base classes.
+  CXXBasePaths Paths;
+  Paths.setOrigin(RD);
+  if (!RD->lookupInBases(
+  [&](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
+return findOrdinaryMemberInDependentClasses(Specifier, Path, Name);
+  },
+  Paths, /*LookupInDependent=*/true))
+return Results;
+  for (DeclContext::lookup_iterator I = Paths.front().Decls, E = I.end();
+   I != E; ++I) {
+if (isOrdinaryMember(*I) && Filter(*I))
+  Results.push_back

[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-20 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

In D150803#4419436 , @sbc100 wrote:

> Did you mean to comment on the old PR?  This new PR doesn't propose either 
> "jspi" or "async", but adds that ability to define custom attributes.. since 
> that was deemed more flexible and forward thinking.   The decision as to 
> which name emscripten will use for what can then be part of  different 
> discussion/PR we hope.

Ah, I think I somehow was looking at the old PR, and thought there was a test 
with `custom_section.func_attr.async` in it.

This patch looks ok, though my initial impression is that if we're going to 
have a fully general-purpose mechanism like this, we might want to plan ahead 
for attributes that have parameters. We don't need to implement it now though; 
if there's a reasonable way to evolve in that direction, then this LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D153370: [RISCV] Add support for custom instructions for Sifive S76.

2023-06-20 Thread garvit gupta via Phabricator via cfe-commits
garvitgupta08 created this revision.
garvitgupta08 added reviewers: asb, apazos, jrtc27.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya, 
arichardson.
Herald added a project: All.
garvitgupta08 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, wangpc, eopXD, MaskRay.
Herald added projects: clang, LLVM.

Support for below instruction is added

1. CFLUSH.D.L1 
2. CDISCARD.D.L1 
3. CEASE

Additionally, Zihintpause extension is added to sifive s76 for pause
instruction.

Spec - 
https://sifive.cdn.prismic.io/sifive/767804da-53b2-4893-97d5-b7c030ae0a94_s76mc_core_complex_manual_21G3.pdf


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153370

Files:
  clang/test/Driver/riscv-cpus.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoXSf.td
  llvm/lib/Target/RISCV/RISCVProcessors.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/xsfcie-invalid.s
  llvm/test/MC/RISCV/xsfcie-valid.s

Index: llvm/test/MC/RISCV/xsfcie-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/xsfcie-valid.s
@@ -0,0 +1,38 @@
+# SFCIE - SiFive S76 Custom Instructions and CSRs.
+# RUN: llvm-mc %s -triple=riscv64 -mcpu=sifive-s76 -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+xsfcie -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ENC,CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mcpu=sifive-s76 < %s \
+# RUN: | llvm-objdump --mcpu=sifive-s76 -M no-aliases -d - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+xsfcie < %s \
+# RUN: | llvm-objdump --mattr=+xsfcie -M no-aliases -d - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+
+# CHECK-INST: cflush.d.l1 zero
+# CHECK-ENC: encoding: [0x73,0x00,0x00,0xfc]
+# CHECK-INST: cflush.d.l1 zero
+# CHECK-ENC: encoding: [0x73,0x00,0x00,0xfc]
+cflush.d.l1 x0
+cflush.d.l1
+
+# CHECK-INST: cflush.d.l1 t2
+# CHECK-ENC: encoding: [0x73,0x80,0x03,0xfc]
+cflush.d.l1 x7
+
+# CHECK-INST: cdiscard.d.l1   zero
+# CHECK-ENC: encoding: [0x73,0x00,0x20,0xfc]
+# CHECK-INST: cdiscard.d.l1 zero
+# CHECK-ENC: encoding: [0x73,0x00,0x20,0xfc]
+cdiscard.d.l1 x0
+cdiscard.d.l1
+
+# CHECK-INST: cdiscard.d.l1   t2
+# CHECK-ENC: encoding: [0x73,0x80,0x23,0xfc]
+cdiscard.d.l1 x7
+
+# CHECK-INST: cease
+# CHECK-ENC: encoding: [0x73,0x00,0x50,0x30]
+cease
+
Index: llvm/test/MC/RISCV/xsfcie-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/xsfcie-invalid.s
@@ -0,0 +1,24 @@
+# SFCIE - SiFive S76 Custom Instructions and CSRs.
+# RUN: not llvm-mc -triple riscv64 -mattr=-xsfcie < %s 2>&1 | FileCheck %s
+
+cflush.d.l1 0x10 # CHECK: :[[@LINE]]:13: error: invalid operand for instruction
+
+cdiscard.d.l1 0x10 # CHECK: :[[@LINE]]:15: error: invalid operand for instruction
+
+cflush.d.l1 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cdiscard.d.l1 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cflush.d.l1 x0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cflush.d.l1 x7 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cdiscard.d.l1 x0 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cdiscard.d.l1 x7 # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76.)
+
+cease x1 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction
+
+cease 0x10 # CHECK: :[[@LINE]]:7: error: invalid operand for instruction
+
+cease # CHECK: :[[@LINE]]:1: error: instruction requires the following: 'XSfcie' (SiFive Custom Instruction Extension SFCIE for S76 MC)
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -278,3 +278,6 @@
 
 .attribute arch, "rv32i_zvfbfwma0p6"
 # CHECK: .attribute 5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfwma0p6_zvl3

[PATCH] D152953: [clang-tidy] Introduce fuchsia-global-variables check

2023-06-20 Thread Caslyn Tonelli via Phabricator via cfe-commits
Caslyn created this revision.
Herald added subscribers: PiotrZSL, carlosgalvezp, abrachet, phosek, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
Caslyn updated this revision to Diff 531489.
Caslyn added a comment.
Caslyn updated this revision to Diff 531932.
Caslyn updated this revision to Diff 532713.
Caslyn added reviewers: ymandel, Prabhuk.
Caslyn published this revision for review.
Herald added projects: LLVM, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

Fixes, cleanups.


Caslyn added a comment.

Include exception for variables declared in macros; cleanups.


Caslyn added a comment.

Add constinit exception, remove G3 exceptions


Introduce a clang-tidy check to the fuchsia module to warn of any static
or global variables that do not have trivial destructors.

The implementation is a pared down version of the Google3
check 

 with configurable options to add types for the check to ignore
(e.g. LazyRE2).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152953

Files:
  clang-tools-extra/clang-tidy/fuchsia/CMakeLists.txt
  clang-tools-extra/clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.cpp
  clang-tools-extra/clang-tidy/fuchsia/GlobalVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/fuchsia/global-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
  llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn

Index: llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
===
--- llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
+++ llvm/utils/gn/secondary/clang-tools-extra/clang-tidy/fuchsia/BUILD.gn
@@ -16,6 +16,7 @@
 "DefaultArgumentsDeclarationsCheck.cpp",
 "FuchsiaTidyModule.cpp",
 "MultipleInheritanceCheck.cpp",
+"GlobalVariablesCheck.cpp",
 "OverloadedOperatorCheck.cpp",
 "StaticallyConstructedObjectsCheck.cpp",
 "TrailingReturnCheck.cpp",
Index: clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/fuchsia/global-variables.cpp
@@ -0,0 +1,160 @@
+// RUN: %check_clang_tidy %s fuchsia-global-variables %t \
+// RUN: -config="{CheckOptions: \
+// RUN:   [{key: fuchsia-global-variables.Ignore, value: 'LazyRE2;ThreadLocal'}] \
+// RUN:  }"
+
+using size_t = decltype(sizeof(int));
+
+namespace std {
+template
+struct array {
+  ~array() {};
+  T Element;
+};
+template
+struct array {};
+}  // namespace std */
+
+class TriviallyDestructibleClass {
+ public:
+  // This is a trivially destructible class.
+  TriviallyDestructibleClass() : I(0) {}
+  TriviallyDestructibleClass(int I) : I(I) {}
+
+  int I;
+  float F;
+  char C;
+  char Cs[10];
+};
+
+class NonTriviallyDestructibleClass {
+ public:
+  NonTriviallyDestructibleClass() : Var(0) {}
+  NonTriviallyDestructibleClass(int Var) : Var(Var) {}
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleClass() {}
+  int Var;
+};
+
+template 
+class NonTriviallyDestructibleTemplateClass {
+ public:
+  // We need a destructor to make the class non trivially destructible.
+  ~NonTriviallyDestructibleTemplateClass() {}
+  int Var;
+  T Var2;
+};
+
+int global_i;
+_Atomic size_t global_atomic;
+
+TriviallyDestructibleClass trivially_destructible_class;
+
+NonTriviallyDestructibleClass non_trivially_destructible;
+// CHECK-MESSAGES: [[@LINE-1]]:31: warning: static and global variables are forbidden unless they are trivially destructible [fuchsia-global-variables]
+
+[[clang::no_destroy]] NonTriviallyDestructibleClass non_trivially_destructible_no_destroy;
+
+TriviallyDestructibleClass trivially_destructible_array[2] = {
+TriviallyDestructibleClass(1), TriviallyDestructibleClass(2)};
+
+NonTriviallyDestructibleClass non_trivially_destructible_array[2] = {
+NonTriviallyDestructibleClass(1), NonTriviallyDestructibleClass(2)};
+// CHECK-MESSAGES: [[@LINE-2]]:31: warning: static and global variables are forbidden unless they are trivially destructible [fuchsia-global-variables]
+
+const TriviallyDestructibleClass trivially_destructible_const_array[2] = {
+TriviallyDestructibleClass(1), TriviallyDestructibleClass(2)};
+
+const NonTriviallyDestructibleClass non_trivially_destructible_const_array[2] = {
+NonTriviallyDestructibleClass(1), NonTriviallyDestructibleClass(2)};
+// CHECK-MESSAGES: [[@LINE-2]]:37: warning: static and global variables are forbidden unless they are trivially destructible [fuchsia-global-variables]
+
+TriviallyDestructibleClass trivially_destruct

[PATCH] D151397: [3/3][RISCV][POC] Model vxrm in C intrinsics for RVV fixed-point instruction vaadd, vasub

2023-06-20 Thread Yueh-Ting (eop) 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 rG5510f0b8f4b1: [3/3][RISCV][POC] Model vxrm in C intrinsics 
for RVV fixed-point instruction… (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151397

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vasubu.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaadd-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vaaddu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasub-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vasubu-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/vaadd.ll
  llvm/test/CodeGen/RISCV/rvv/vaaddu.ll
  llvm/test/CodeGen/RISCV/rvv/vasub.ll
  llvm/test/CodeGen/RISCV/rvv/vasubu.ll

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


[PATCH] D152879: [RISCV] Model vxrm control for vsmul, vssra, vssrl, vnclip, and vnclipu

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9ed668ad9321: [RISCV] Model vxrm control for vsmul, vssra, 
vssrl, vnclip, and vnclipu (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152879

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vssrl.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnclip.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vnclipu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vsmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssra.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vssrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vnclip-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vnclipu-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-eew64-overloaded.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-eew64.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vsmul-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vssra-out-of-range.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vssrl-out-of-range.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/mutate-prior-vsetvli-avl.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vnclip.ll
  llvm/test/CodeGen/RISCV/rvv/vnclipu.ll
  llvm/test/CodeGen/RISCV/rvv/vsmul-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vsmul-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssra-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssra-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vssrl-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vssrl-rv64.ll

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


[PATCH] D152996: [RISCV][POC] Model frm control for vfadd

2023-06-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 532996.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152996

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/vfadd-out-of-range.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp
  llvm/lib/Target/RISCV/RISCVInsertReadWriteCSR.cpp
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVPseudos.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td
  llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
  llvm/test/CodeGen/RISCV/rvv/alloca-load-store-scalable-struct.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-fmf.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tama.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tamu.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tuma.ll
  llvm/test/CodeGen/RISCV/rvv/masked-tumu.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-peephole-vmerge-masked-vops.ll
  llvm/test/CodeGen/RISCV/rvv/unmasked-tu.ll
  llvm/test/CodeGen/RISCV/rvv/vfadd.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert.ll

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


[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

2023-06-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:23099
+CD->addAttr(A);
 if (ASTMutationListener *ML = Context.getASTMutationListener())
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);

Need to use   ML->DeclarationMarkedOpenMPDeclareTarget for CD too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153369

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


[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

2023-06-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 533000.
jhuber6 added a comment.

Adding AST mutation listener to the other modified declaration to signal that 
it was changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153369

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/dump.cpp


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To 
DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  
col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare target
+extern int dy;
+#pragma omp end declare target
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dy 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+// CHECK:  `-VarDecl {{.+}} prev {{.+}}  
col:12 dy 'int' extern
+// CHECK-NEXT:   `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -22986,6 +22986,9 @@
   Context, MT, DTCI.DT, IndirectE, IsIndirect, Level,
   SourceRange(Loc, Loc));
   ND->addAttr(A);
+  if (auto *CD = dyn_cast(ND->getCanonicalDecl()))
+if (!CD->hasAttr())
+  CD->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
   checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc);
@@ -23090,8 +23093,15 @@
 DTCI.DT, IndirectE, IsIndirect, Level,
 SourceRange(DTCI.Loc, DTCI.Loc));
 D->addAttr(A);
-if (ASTMutationListener *ML = Context.getASTMutationListener())
+if (auto *CD = dyn_cast(D->getCanonicalDecl()))
+  if (!CD->hasAttr())
+CD->addAttr(A);
+if (ASTMutationListener *ML = Context.getASTMutationListener()) {
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
+  if (auto *CD = dyn_cast(D->getCanonicalDecl()))
+if (!CD->hasAttr())
+  ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+}
   }
   return;
 }


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+
+int d

[PATCH] D153369: [OpenMP] Always apply target declarations to canonical definitions

2023-06-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 533002.
jhuber6 added a comment.

Fix logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153369

Files:
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/dump.cpp


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To 
DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  
line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 
'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  
col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare target
+extern int dy;
+#pragma omp end declare target
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dy 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
+// CHECK:  `-VarDecl {{.+}} prev {{.+}}  
col:12 dy 'int' extern
+// CHECK-NEXT:   `-OMPDeclareTargetDeclAttr {{.+}}  
Implicit MT_To DT_Any 1
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -22988,6 +22988,15 @@
   ND->addAttr(A);
   if (ASTMutationListener *ML = Context.getASTMutationListener())
 ML->DeclarationMarkedOpenMPDeclareTarget(ND, A);
+
+  // If this was not a canonical definition we need to update it as well.
+  if (auto *CD = dyn_cast(ND->getCanonicalDecl())) {
+if (!CD->hasAttr()) {
+  CD->addAttr(A);
+  if (ASTMutationListener *ML = Context.getASTMutationListener())
+ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+}
+  }
   checkDeclIsAllowedInOpenMPTarget(nullptr, ND, Loc);
 }
 
@@ -23092,6 +23101,15 @@
 D->addAttr(A);
 if (ASTMutationListener *ML = Context.getASTMutationListener())
   ML->DeclarationMarkedOpenMPDeclareTarget(D, A);
+
+// If this was not a canonical definition we need to update it as well.
+if (auto *CD = dyn_cast(D->getCanonicalDecl())) {
+  if (!CD->hasAttr()) {
+CD->addAttr(A);
+if (ASTMutationListener *ML = Context.getASTMutationListener())
+  ML->DeclarationMarkedOpenMPDeclareTarget(CD, A);
+  }
+}
   }
   return;
 }


Index: clang/test/AST/dump.cpp
===
--- clang/test/AST/dump.cpp
+++ clang/test/AST/dump.cpp
@@ -79,11 +79,32 @@
 }
 #pragma omp end declare target
 
-// CHECK:   `-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
-// CHECK-NEXT:  |-CompoundStmt {{.+}} 
-// CHECK-NEXT:  | |-DeclStmt {{.+}} 
-// CHECK-NEXT:  | | `-VarDecl {{.+}}  col:7 used f 'int'
-// CHECK-NEXT:  | `-ReturnStmt {{.+}} 
-// CHECK-NEXT:  |   `-ImplicitCastExpr {{.+}}  'int' 
-// CHECK-NEXT:  | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
-// CHECK-NEXT:  `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+// CHECK:  |-FunctionDecl {{.+}}  line:[[@LINE-6]]:5 bar 'int ()'
+// CHECK-NEXT: | |-CompoundStmt {{.+}} 
+// CHECK-NEXT: | | |-DeclStmt {{.+}} 
+// CHECK-NEXT: | | | `-VarDecl {{.+}}  col:7 used f 'int'
+// CHECK-NEXT: | | `-ReturnStmt {{.+}} 
+// CHECK-NEXT: | |   `-ImplicitCastExpr {{.+}}  'int' 
+// CHECK-NEXT: | | `-DeclRefExpr {{.+}}  'int' lvalue Var {{.+}} 'f' 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 1
+
+int dx;
+
+extern int dx;
+#pragma omp declare target to(dx)
+
+// CHECK:  |-VarDecl {{.+}}  col:5 dx 'int'
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+// CHECK:  |-VarDecl {{.+}} prev {{.+}}  col:12 dx 'int' extern
+// CHECK-NEXT: | `-OMPDeclareTargetDeclAttr {{.+}}  Implicit MT_To DT_Any 4294967295
+
+int dy;
+
+#pragma omp begin declare targ

[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6784
+  if (II->getInterestingIdentifierID() != 0)
+NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
 }

rjmccall wrote:
> Please switch over the interesting identifiers here; we don't want to assume 
> this feature is only used for these two names.
> 
> In fact, should we go ahead and immediately apply it to the four identifiers 
> above this?  That would be nice, because then we could actually do this in 
> two patches: one patch that does the refactor to track interesting 
> identifiers but doesn't cause any functionality changes and a second, very 
> small patch that just introduces the new special treatment for `float_t` and 
> `double_t`.
> Please switch over the interesting identifiers here; we don't want to assume 
> this feature is only used for these two names.
> 
> In fact, should we go ahead and immediately apply it to the four identifiers 
> above this?  That would be nice, because then we could actually do this in 
> two patches: one patch that does the refactor to track interesting 
> identifiers but doesn't cause any functionality changes and a second, very 
> small patch that just introduces the new special treatment for `float_t` and 
> `double_t`.

Are you saying that "FILE", "jmp_buf"," sigjmp_buf" and "ucontext_t" are also 
interesting identifiers? If yes, they should be added to the list of 
interesting identifiers in TokenKinds.def?


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

https://reviews.llvm.org/D146148

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


[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-20 Thread Brendan Dahl via Phabricator via cfe-commits
brendandahl added a comment.

@aaron.ballman or @erichkeane Did you want to re-review after that latest 
changes (more generic attribute) or are things good to go?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D153233: clang: Add __builtin_elementwise_rint and nearbyint

2023-06-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 533007.
arsenm marked an inline comment as done.
arsenm added a comment.

Keep fixing documentation


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

https://reviews.llvm.org/D153233

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-elementwise-math.c
  clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
  clang/test/Sema/builtins-elementwise-math.c

Index: clang/test/Sema/builtins-elementwise-math.c
===
--- clang/test/Sema/builtins-elementwise-math.c
+++ clang/test/Sema/builtins-elementwise-math.c
@@ -460,7 +460,6 @@
 }
 
 void test_builtin_elementwise_round(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
-
   struct Foo s = __builtin_elementwise_round(f);
   // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
 
@@ -485,6 +484,56 @@
   // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
 }
 
+void test_builtin_elementwise_rint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+  struct Foo s = __builtin_elementwise_rint(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_rint();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_rint(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_rint(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_rint(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_rint(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+
+  // FIXME: Error should not mention integer
+  _Complex float c1, c2;
+  c1 = __builtin_elementwise_rint(c1);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
+}
+
+void test_builtin_elementwise_nearbyint(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
+  struct Foo s = __builtin_elementwise_nearbyint(f);
+  // expected-error@-1 {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+
+  i = __builtin_elementwise_nearbyint();
+  // expected-error@-1 {{too few arguments to function call, expected 1, have 0}}
+
+  i = __builtin_elementwise_nearbyint(i);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'int')}}
+
+  i = __builtin_elementwise_nearbyint(f, f);
+  // expected-error@-1 {{too many arguments to function call, expected 1, have 2}}
+
+  u = __builtin_elementwise_nearbyint(u);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned int')}}
+
+  uv = __builtin_elementwise_nearbyint(uv);
+  // expected-error@-1 {{1st argument must be a floating point type (was 'unsigned4' (vector of 4 'unsigned int' values))}}
+
+  // FIXME: Error should not mention integer
+  _Complex float c1, c2;
+  c1 = __builtin_elementwise_nearbyint(c1);
+  // expected-error@-1 {{1st argument must be a vector, integer or floating point type (was '_Complex float')}}
+}
+
 void test_builtin_elementwise_sin(int i, float f, double d, float4 v, int3 iv, unsigned u, unsigned4 uv) {
 
   struct Foo s = __builtin_elementwise_sin(f);
Index: clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
===
--- /dev/null
+++ clang/test/CodeGen/strictfp-elementwise-bulitins.cpp
@@ -0,0 +1,216 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -emit-llvm -o - %s | FileCheck %s
+
+typedef float float4 __attribute__((ext_vector_type(4)));
+
+// Sanity check we're getting constrained ops for a non-builtin.
+// CHECK-LABEL: define dso_local noundef <4 x float> @_Z11strict_faddDv4_fS_
+// CHECK-SAME: (<4 x float> noundef [[A:%.*]], <4 x float> noundef [[B:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[ADD:%.*]] = tail call <4 x float> @llvm.experimental.constrained.fadd.v4f32(<4 x float> [[A]], <4 x float> [[B]], metadata !"round.dynamic", metadata !"fpexcept.strict") #[[ATTR4:[0-9]+]]
+// CHECK-NEXT:ret <4 x float> [[ADD]]
+//
+float4 strict_fadd(float4 a, float4 b) {
+  return a + b;
+}
+
+// CHECK-LABEL: define dso_local noundef <4 x float> @_Z22strict_elementwise_absDv4_f
+// CHECK-SAME: (<4 x float> noundef [[A:%.*]]) local

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

2023-06-20 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added a comment.

Hello, I'm seeing a build failure that seems related to this patch. I'm seeing 
the patch has been relanded and reverted a couple times and not sure where it 
is right now. Can you please confirm if the failure is related and fixed? 
Thanks.

2023-06-20T05:19:14.441-07:00] Stderr: PLEASE submit a bug report to 
https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, 
preprocessed source, and associated run script.
[2023-06-20T05:19:14.441-07:00] Stack dump:
[2023-06-20T05:19:14.441-07:00] 1.  Running pass 'Function Pass Manager' on 
module 
'buck-out/v2/gen/fbcode/c475d21d0247c4b4/f3/share/udaf/aggregators/utils/__f3_udaf_aggregation_utils__/__objects__/HybridHistAdditiveNoiseDPState.cpp.o'.
[2023-06-20T05:19:14.441-07:00] 2.  Running pass 'X86 Assembly Printer' on 
function 
'@_ZN8facebook2f37xstream11aggregation5utils15HybridTopKStateIlE4bumpERKll'
[2023-06-20T05:19:14.441-07:00]  #0 0x055513d5 
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:602:13
[2023-06-20T05:19:14.441-07:00]  #1 0x055517d6 
llvm::sys::RunSignalHandlers() llvm-project/llvm/lib/Support/Signals.cpp:103:5
[2023-06-20T05:19:14.441-07:00]  #2 0x055517d6 SignalHandler(int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:403:3
[2023-06-20T05:19:14.441-07:00]  #3 0x7f028da4459f 
glibc/2.34/src/glibc-2.34/signal/../sysdeps/unix/sysv/linux/libc_sigaction.c:8:0
[2023-06-20T05:19:14.441-07:00]  #4 0x07c7411e 
llvm::DILexicalBlockFile::classof(llvm::Metadata const*) 
llvm-project/llvm/include/llvm/IR/DebugInfoMetadata.h:2271:32
[2023-06-20T05:19:14.441-07:00]  #5 0x07c7411e 
llvm::isa_impl::doit(llvm::DILocalScope const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:64:53
[2023-06-20T05:19:14.441-07:00]  #6 0x07c7411e 
llvm::isa_impl_cl::doit(llvm::DILocalScope const*) 
llvm-project/llvm/include/llvm/Support/Casting.h:110:12
[2023-06-20T05:19:14.441-07:00]  #7 0x07c7411e 
llvm::isa_impl_wrap::doit(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:137:12
[2023-06-20T05:19:14.441-07:00]  #8 0x07c7411e 
llvm::isa_impl_wrap::doit(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:127:12
[2023-06-20T05:19:14.441-07:00]  #9 0x07c7411e 
llvm::CastIsPossible::isPossible(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:255:12
[2023-06-20T05:19:14.441-07:00] #10 0x07c7411e 
llvm::CastInfo::doCastIfPossible(llvm::DILocalScope const* const&) 
llvm-project/llvm/include/llvm/Support/Casting.h:493:10
[2023-06-20T05:19:14.441-07:00] #11 0x07c7411e decltype(auto) 
llvm::dyn_cast(llvm::DILocalScope const*) 
llvm-project/llvm/include/llvm/Support/Casting.h:663:10
[2023-06-20T05:19:14.441-07:00] #12 0x07c7411e 
llvm::DILocalScope::getNonLexicalBlockFileScope() const 
llvm-project/llvm/lib/IR/DebugInfoMetadata.cpp:1037:20
[2023-06-20T05:19:14.441-07:00] #13 0x07c7411e 
getRetainedNodeScope(llvm::MDNode const*) 
llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1549:33
[2023-06-20T05:19:14.441-07:00] #14 0x07c7411e 
llvm::DwarfDebug::endFunctionImpl(llvm::MachineFunction const*) 
llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:2327:24
[2023-06-20T05:19:14.441-07:00] #15 0x07f45860 
llvm::DebugHandlerBase::endFunction(llvm::MachineFunction const*) 
llvm-project/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp:411:5
[2023-06-20T05:19:14.441-07:00] #16 0x07af45e7 
llvm::AsmPrinter::emitFunctionBody() 
llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1894:17
[2023-06-20T05:19:14.441-07:00] #17 0x07af30ca 
llvm::X86AsmPrinter::runOnMachineFunction(llvm::MachineFunction&) 
llvm-project/llvm/lib/Target/X86/X86AsmPrinter.cpp:86:3
[2023-06-20T05:19:14.441-07:00] #18 0x078612f5 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) 
llvm-project/llvm/lib/CodeGen/MachineFunctionPass.cpp:92:13
[2023-06-20T05:19:14.441-07:00] #19 0x07860981 
llvm::FPPassManager::runOnFunction(llvm::Function&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1455:27
[2023-06-20T05:19:14.441-07:00] #20 0x07860078 
llvm::FPPassManager::runOnModule(llvm::Module&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1514:16
[2023-06-20T05:19:14.441-07:00] #21 0x07de90b4 (anonymous 
namespace)::MPPassManager::runOnModule(llvm::Module&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:1583:27
[2023-06-20T05:19:14.441-07:00] #22 0x07de90b4 
llvm::legacy::PassManagerImpl::run(llvm::Module&) 
llvm-project/llvm/lib/IR/LegacyPassManager.cpp:538:44
[2023-06-20T05:19:14.441-07:00] #23 0x05dd8d5a 
codegen(llvm::lto::Config const&, llvm::TargetMachine*, 
std::function>> (unsigned int, llvm::Twine 
const&)>, unsigned int, llvm::Module&, llvm::ModuleSummaryIndex const&) 
llvm-project/llvm/lib/LTO/LTOBacke

[PATCH] D153281: [flang] add -flang-experimental-polymorphism flag to flang-new

2023-06-20 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.

LGTM, thanks David!

Could you also add a test in 
https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/frontend-forwarding.f90?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153281

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


  1   2   >