[PATCH] D137838: [Support] Move TargetParsers to new component

2022-12-28 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added inline comments.



Comment at: llvm/include/llvm/Support/RISCVISAInfo.h:10
+/// \file
+/// This header is deprecated in favour of `llvm/Support/RISCVISAInfo.h`.
+///

I think there is a typo that should be 'in favour of 
`llvm/TargetParser/RISCVISAInfo.h` '


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[clang] 9816c19 - [X86] Rename CMPCCXADD intrinsics.

2022-12-28 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2022-12-28T16:45:50+08:00
New Revision: 9816c1912d56668736a2bd95ce18b7fb41653b92

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

LOG: [X86] Rename CMPCCXADD intrinsics.

"__cmpccxadd_epi*" -> "_cmpccxadd_epi*"
This is to align with other intrinsics to follow single leading "_" style. Gcc
and intrinsic guide website will also apply this change.

Reviewed By: LuoYuanke, skan

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Headers/cmpccxaddintrin.h
clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c
clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
clang/test/CodeGen/X86/cmpccxadd-builtins.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 48ffafafb1bb7..776f0a97d2500 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -778,8 +778,8 @@ X86 Support in Clang
 - Switch ``AVX512-BF16`` intrinsics types from ``short`` to ``__bf16``.
 - Add support for ``PREFETCHI`` instructions.
 - Support ISA of ``CMPCCXADD``.
-  * Support intrinsic of ``__cmpccxadd_epi32``.
-  * Support intrinsic of ``__cmpccxadd_epi64``.
+  * Support intrinsic of ``_cmpccxadd_epi32``.
+  * Support intrinsic of ``_cmpccxadd_epi64``.
 - Add support for ``RAO-INT`` instructions.
   * Support intrinsic of ``_aadd_i32/64``
   * Support intrinsic of ``_aand_i32/64``

diff  --git a/clang/lib/Headers/cmpccxaddintrin.h 
b/clang/lib/Headers/cmpccxaddintrin.h
index 093ca1f64e660..6957498996c89 100644
--- a/clang/lib/Headers/cmpccxaddintrin.h
+++ b/clang/lib/Headers/cmpccxaddintrin.h
@@ -58,11 +58,11 @@ typedef enum {
 ///
 /// \returns a integer which is the original value of first operand.
 
-#define __cmpccxadd_epi32(__A, __B, __C, __D)  
\
+#define _cmpccxadd_epi32(__A, __B, __C, __D)   
\
   ((int)(__builtin_ia32_cmpccxadd32((void *)(__A), (int)(__B), (int)(__C), 
\
 (int)(__D
 
-#define __cmpccxadd_epi64(__A, __B, __C, __D)  
\
+#define _cmpccxadd_epi64(__A, __B, __C, __D)   
\
   ((long long)(__builtin_ia32_cmpccxadd64((void *)(__A), (long long)(__B), 
\
   (long long)(__C), (int)(__D
 

diff  --git a/clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c 
b/clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c
index 1b6c7c412592f..512365b689b79 100644
--- a/clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c
+++ b/clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c
@@ -4,5 +4,5 @@
 #include 
 
 int test_cmpccxadd32(void *__A, int __B, int __C) {
-  return __cmpccxadd_epi32(__A, __B, __C, 0); // expected-error {{call to 
undeclared function '__cmpccxadd_epi32'}}
+  return _cmpccxadd_epi32(__A, __B, __C, 0); // expected-error {{call to 
undeclared function '_cmpccxadd_epi32'}}
 }

diff  --git a/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c 
b/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
index 0b329aa8baa84..30515b48e8589 100644
--- a/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
+++ b/clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
@@ -4,9 +4,9 @@
 #include 
 
 int test_cmpccxadd32(void *__A, int __B, int __C) {
-  return __cmpccxadd_epi32(__A, __B, __C, 16); // expected-error {{argument 
value 16 is outside the valid range [0, 15]}}
+  return _cmpccxadd_epi32(__A, __B, __C, 16); // expected-error {{argument 
value 16 is outside the valid range [0, 15]}}
 }
 
 long long test_cmpccxadd64(void *__A, long long __B, long long __C) {
-  return __cmpccxadd_epi64(__A, __B, __C, 16); // expected-error {{argument 
value 16 is outside the valid range [0, 15]}}
+  return _cmpccxadd_epi64(__A, __B, __C, 16); // expected-error {{argument 
value 16 is outside the valid range [0, 15]}}
 }

diff  --git a/clang/test/CodeGen/X86/cmpccxadd-builtins.c 
b/clang/test/CodeGen/X86/cmpccxadd-builtins.c
index bb7b19c5def85..6daed3a1b17b6 100644
--- a/clang/test/CodeGen/X86/cmpccxadd-builtins.c
+++ b/clang/test/CodeGen/X86/cmpccxadd-builtins.c
@@ -7,191 +7,191 @@
 int test_cmpbexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpbexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 
%{{.*}}, i32 0)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_O);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_O);
 }
 
 long long test_cmpbexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpbexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 
%{{.*}}, i32 0)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_O);
+  return _cmpccxadd_epi64(__A, __B, 

[PATCH] D140281: [X86] Rename CMPCCXADD intrinsics.

2022-12-28 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9816c1912d56: [X86] Rename CMPCCXADD intrinsics. (authored 
by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140281

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/cmpccxaddintrin.h
  clang/test/CodeGen/X86/cmpccxadd-builtins-error-32.c
  clang/test/CodeGen/X86/cmpccxadd-builtins-error.c
  clang/test/CodeGen/X86/cmpccxadd-builtins.c

Index: clang/test/CodeGen/X86/cmpccxadd-builtins.c
===
--- clang/test/CodeGen/X86/cmpccxadd-builtins.c
+++ clang/test/CodeGen/X86/cmpccxadd-builtins.c
@@ -7,191 +7,191 @@
 int test_cmpbexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpbexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 0)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_O);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_O);
 }
 
 long long test_cmpbexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpbexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 0)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_O);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_O);
 }
 
 int test_cmpbxadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpbxadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 1)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NO);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NO);
 }
 
 long long test_cmpbxadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpbxadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 1)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NO);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NO);
 }
 
 int test_cmplexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmplexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 2)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_B);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_B);
 }
 
 long long test_cmplexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmplexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 2)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_B);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_B);
 }
 
 int test_cmplxadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmplxadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 3)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NB);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NB);
 }
 
 long long test_cmplxadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmplxadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 3)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NB);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NB);
 }
 
 int test_cmpnbexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpnbexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 4)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_Z);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_Z);
 }
 
 long long test_cmpnbexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpnbexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 4)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_Z);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_Z);
 }
 
 int test_cmpnbxadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpnbxadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 5)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NZ);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_NZ);
 }
 
 long long test_cmpnbxadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpnbxadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 5)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NZ);
+  return _cmpccxadd_epi64(__A, __B, __C, _CMPCCX_NZ);
 }
 
 int test_cmpnlexadd32(void *__A, int __B, int __C) {
   // CHECK-LABEL: @test_cmpnlexadd32(
   // CHECK: call i32 @llvm.x86.cmpccxadd32(ptr %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 6)
-  return __cmpccxadd_epi32(__A, __B, __C, _CMPCCX_BE);
+  return _cmpccxadd_epi32(__A, __B, __C, _CMPCCX_BE);
 }
 
 long long test_cmpnlexadd64(void *__A, long long __B, long long __C) {
   // CHECK-LABEL: @test_cmpnlexadd64(
   // CHECK: call i64 @llvm.x86.cmpccxadd64(ptr %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i32 6)
-  return __cmpccxadd_epi64(__A, __B, __C, _CMPCCX_BE);
+  return _cmpc

[PATCH] D137838: [Support] Move TargetParsers to new component

2022-12-28 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added inline comments.



Comment at: llvm/include/llvm/Support/RISCVISAInfo.h:10
+/// \file
+/// This header is deprecated in favour of `llvm/Support/RISCVISAInfo.h`.
+///

zixuan-wu wrote:
> I think there is a typo that should be 'in favour of 
> `llvm/TargetParser/RISCVISAInfo.h` '
I may move `RISCVISAInfo` back to `Support` and fix this in D140529.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2022-12-28 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer added a comment.

@nridge, yep, confirming: For Android, --target is being added explicitly as 
part of the command and we'll need to pass through explicit (but not implicit) 
--target flags to the system includes extractor to get the correct paths.


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

https://reviews.llvm.org/D138546

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


[PATCH] D140722: [OpenMP] Prefix outlined and reduction func names with original func's name

2022-12-28 Thread Itay Bookstein via Phabricator via cfe-commits
nextsilicon-itay-bookstein created this revision.
nextsilicon-itay-bookstein added a reviewer: jdoerfert.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
nextsilicon-itay-bookstein requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch attempts to prefix omp outlined helpers and reduction funcs
with the original function's name.

It does not yet update all the CodeGen tests; I'm still trying, but it
seems that some of them are not idempotent under update_cc_test_checks
when I run it on master.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140722

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp

Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1545,7 +1545,8 @@
   llvm::Value *NumThreads = nullptr;
   llvm::Function *OutlinedFn =
   CGF.CGM.getOpenMPRuntime().emitParallelOutlinedFunction(
-  S, *CS->getCapturedDecl()->param_begin(), InnermostKind, CodeGen);
+  CGF, S, *CS->getCapturedDecl()->param_begin(), InnermostKind,
+  CodeGen);
   if (const auto *NumThreadsClause = S.getSingleClause()) {
 CodeGenFunction::RunCleanupsScope NumThreadsScope(CGF);
 NumThreads = CGF.EmitScalarExpr(NumThreadsClause->getNumThreads(),
@@ -6745,7 +6746,8 @@
   const CapturedStmt *CS = S.getCapturedStmt(OMPD_teams);
   llvm::Function *OutlinedFn =
   CGF.CGM.getOpenMPRuntime().emitTeamsOutlinedFunction(
-  S, *CS->getCapturedDecl()->param_begin(), InnermostKind, CodeGen);
+  CGF, S, *CS->getCapturedDecl()->param_begin(), InnermostKind,
+  CodeGen);
 
   const auto *NT = S.getSingleClause();
   const auto *TL = S.getSingleClause();
Index: clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
===
--- clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
+++ clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
@@ -142,13 +142,6 @@
 const Expr *IfCond);
 
 protected:
-  /// Get the function name of an outlined region.
-  //  The name can be customized depending on the target.
-  //
-  StringRef getOutlinedHelperName() const override {
-return "__omp_outlined__";
-  }
-
   /// Check if the default location must be constant.
   /// Constant for NVPTX for better optimization.
   bool isDefaultLocationConstant() const override { return true; }
@@ -197,31 +190,31 @@
   //  directive.
   /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
   /// kmp_int32 BoundID, struct context_vars*).
+  /// \param CGF Reference to current CodeGenFunction.
   /// \param D OpenMP directive.
   /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
   /// \param InnermostKind Kind of innermost directive (for simple directives it
   /// is a directive itself, for combined - its innermost directive).
   /// \param CodeGen Code generation sequence for the \a D directive.
-  llvm::Function *
-  emitParallelOutlinedFunction(const OMPExecutableDirective &D,
-   const VarDecl *ThreadIDVar,
-   OpenMPDirectiveKind InnermostKind,
-   const RegionCodeGenTy &CodeGen) override;
+  llvm::Function *emitParallelOutlinedFunction(
+  CodeGenFunction &CGF, const OMPExecutableDirective &D,
+  const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
+  const RegionCodeGenTy &CodeGen) override;
 
   /// Emits inlined function for the specified OpenMP teams
   //  directive.
   /// \a D. This outlined function has type void(*)(kmp_int32 *ThreadID,
   /// kmp_int32 BoundID, struct context_vars*).
+  /// \param CGF Reference to current CodeGenFunction.
   /// \param D OpenMP directive.
   /// \param ThreadIDVar Variable for thread id in the current OpenMP region.
   /// \param InnermostKind Kind of innermost directive (for simple directives it
   /// is a directive itself, for combined - its innermost directive).
   /// \param CodeGen Code generation sequence for the \a D directive.
-  llvm::Function *
-  emitTeamsOutlinedFunction(const OMPExecutableDirective &D,
-const VarDecl *ThreadIDVar,
-OpenMPDirectiveKind InnermostKind,
-const RegionCodeGenTy &CodeGen) override;
+  llvm::Function *emitTeamsOutlinedFunction(
+  CodeGenFunction &CGF, const OMPExecutableDirective &D,
+  const VarDecl *ThreadIDVar, OpenMPDirectiveKind InnermostKind,
+  const RegionCodeGenTy &CodeGen) override;
 
   /// Emits code for teams call of the \a OutlinedFn with
   /// variables captured in a record which address is stored in \a
Index: clang/

[PATCH] D140723: [clang][Interp] Only check constructors for global variables

2022-12-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a follow-up to https://reviews.llvm.org/D136694. I can also merge the 
two patches.

I couldn't come up with a better way of doing this than adding a new opcode 
which is //only// emitted from `visitGlobalInitializer()`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140723

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/test/AST/Interp/cxx20.cpp

Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -158,21 +158,19 @@
 
   class Derived : public Base {
   public:
-constexpr Derived() : Base() {} // expected-note {{subobject of type 'int' is not initialized}}
-  };
+constexpr Derived() : Base() {}   };
 
-constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \\
- // expected-note {{in call to 'Derived()'}} \
- // ref-error {{must be initialized by a constant expression}} \
- // ref-note {{subobject of type 'int' is not initialized}}
+  constexpr Derived D; // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' is not initialized}} \
+   // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{subobject of type 'int' is not initialized}}
 
   class C2 {
   public:
 A a;
-constexpr C2() {} // expected-note {{subobject of type 'int' is not initialized}}
-  };
+constexpr C2() {}   };
   constexpr C2 c2; // expected-error {{must be initialized by a constant expression}} \
-   // expected-note {{in call to 'C2()'}} \
+   // expected-note {{subobject of type 'int' is not initialized}} \
// ref-error {{must be initialized by a constant expression}} \
// ref-note {{subobject of type 'int' is not initialized}}
 
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -322,6 +322,8 @@
 // [] -> [Pointer]
 def SetLocal : AccessOpcode { let HasCustomEval = 1; }
 
+def CheckGlobalCtor : Opcode {}
+
 // [] -> [Value]
 def GetGlobal : AccessOpcode;
 // [Value] -> []
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1365,6 +1365,11 @@
   return true;
 }
 
+inline bool CheckGlobalCtor(InterpState &S, CodePtr &PC) {
+  const Pointer &Obj = S.Stk.peek();
+  return CheckCtorCall(S, PC, Obj);
+}
+
 inline bool Call(InterpState &S, CodePtr &PC, const Function *Func) {
   auto NewFrame = std::make_unique(S, Func, PC);
   Pointer ThisPtr;
@@ -1388,11 +1393,6 @@
   if (Interpret(S, CallResult)) {
 NewFrame.release(); // Frame was delete'd already.
 assert(S.Current == FrameBefore);
-
-// For constructors, check that all fields have been initialized.
-if (Func->isConstructor() && !CheckCtorCall(S, PC, ThisPtr))
-  return false;
-
 return true;
   }
 
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -512,6 +512,15 @@
   Result = false;
 }
   }
+
+  // Check Fields in all bases
+  for (const Record::Base &B : R->bases()) {
+Pointer P = Pointer(BasePtr.block(), B.Offset);
+Result &= CheckFieldsInitialized(S, OpPC, P, B.R);
+  }
+
+  // TODO: Virtual bases
+
   return Result;
 }
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -177,6 +177,9 @@
 if (!visitInitializer(Init))
   return false;
 
+if (Init->getType()->isRecordType() && !this->emitCheckGlobalCtor(Init))
+  return false;
+
 return this->emitPopPtr(Init);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140724: [clang][Interp] Add back Run() call

2022-12-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  We need to run the functions we compiled immediately after to check if
  they can ever be a constant expression.

I removed this before, thinking it was unneeded. Turns out it is needed to get 
the "constexpr function never produces a constant expression" diagnostics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140724

Files:
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Interp.cpp
  clang/lib/AST/Interp/Interp.h
  clang/test/AST/Interp/arrays.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/Interp/records.cpp
  clang/test/AST/Interp/shifts.cpp

Index: clang/test/AST/Interp/shifts.cpp
===
--- clang/test/AST/Interp/shifts.cpp
+++ clang/test/AST/Interp/shifts.cpp
@@ -8,7 +8,9 @@
 
 namespace shifts {
   constexpr void test() { // ref-error {{constexpr function never produces a constant expression}} \
-  // ref-cxx17-error {{constexpr function never produces a constant expression}}
+  // ref-cxx17-error {{constexpr function never produces a constant expression}} \
+  // expected-error {{constexpr function never produces a constant expression}} \
+  // cxx17-error {{constexpr function never produces a constant expression}} \
 
 char c; // cxx17-warning {{uninitialized variable}} \
 // ref-cxx17-warning {{uninitialized variable}}
@@ -19,6 +21,8 @@
 c = 1 << -0;
 c = 1 >> -0;
 c = 1 << -1; // expected-warning {{shift count is negative}} \
+ // expected-note {{negative shift count -1}} \
+ // cxx17-note {{negative shift count -1}} \
  // cxx17-warning {{shift count is negative}} \
  // ref-warning {{shift count is negative}} \
  // ref-note {{negative shift count -1}} \
Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -166,10 +166,11 @@
 constexpr int get12() { return 12; }
   };
 
-  constexpr int foo() { // ref-error {{never produces a constant expression}}
+  constexpr int foo() { // ref-error {{never produces a constant expression}} \
+// expected-error {{never produces a constant expression}}
 S *s = nullptr;
 return s->get12(); // ref-note 2{{member call on dereferenced null pointer}} \
-   // expected-note {{member call on dereferenced null pointer}}
+   // expected-note 2{{member call on dereferenced null pointer}}
 
   }
   static_assert(foo() == 12, ""); // ref-error {{not an integral constant expression}} \
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -452,10 +452,11 @@
   static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
// ref-note {{in call to 'uninit()'}}
 
-  constexpr int OverFlow() { // ref-error {{never produces a constant expression}}
+  constexpr int OverFlow() { // ref-error {{never produces a constant expression}} \
+ // expected-error {{never produces a constant expression}}
 int a = INT_MAX;
 ++a; // ref-note 2{{is outside the range}} \
- // expected-note {{is outside the range}}
+ // expected-note 2{{is outside the range}}
 return -1;
   }
   static_assert(OverFlow() == -1, "");  // expected-error {{not an integral constant expression}} \
@@ -464,10 +465,11 @@
 // ref-note {{in call to 'OverFlow()'}}
 
 
-  constexpr int UnderFlow() { // ref-error {{never produces a constant expression}}
+  constexpr int UnderFlow() { // ref-error {{never produces a constant expression}} \
+  // expected-error {{never produces a constant expression}}
 int a = INT_MIN;
 --a; // ref-note 2{{is outside the range}} \
- // expected-note {{is outside the range}}
+ // expected-note 2{{is outside the range}}
 return -1;
   }
   static_assert(UnderFlow() == -1, "");  // expected-error {{not an integral constant expression}} \
Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -209,7 +209,8 @@
 public:
   int a;
   constexpr AU() : a(5 / 0) {} // expected-warning {{division by zero is undefined}} \
-   // expected-note {{division by zer

[clang] 48655f7 - [clang][Interp][NFC] Fix typo in comment

2022-12-28 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-12-28T12:08:29+01:00
New Revision: 48655f72f9c09a6164109bff3197e07a3f3d8a52

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

LOG: [clang][Interp][NFC] Fix typo in comment

Added: 


Modified: 
clang/lib/AST/Interp/Interp.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 224b05ffad190..940e71df138d3 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -1,4 +1,4 @@
-//===--- Interpcpp - Interpreter for the constexpr VM --*- C++ -*-===//
+//===--- Interp.cpp - Interpreter for the constexpr VM --*- C++ 
-*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.



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


[PATCH] D140703: [clang][dataflow] Unify `TransferOptions` and `DataflowAnalysisContext::Options`.

2022-12-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h:35
 struct DataflowAnalysisOptions {
-  /// Options for the built-in transfer functions, or empty to not apply them.
-  // FIXME: Remove this option once the framework supports composing analyses
-  // (at which point the built-in transfer functions can be simply a standalone
-  // analysis).
-  llvm::Optional BuiltinTransferOpts = TransferOptions{};
+  /// Options for the built-in model, or empty to not apply them.  FIXME: 
Remove
+  // this option once the framework supports composing analyses (at which point

Please undo the comment reformatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140703

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


[PATCH] D137894: [clangd] Add extension for adding context (enclosing function or class) in references results

2022-12-28 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders added inline comments.



Comment at: clang-tools-extra/clangd/XRefs.cpp:1484
+LookupRequest ContainerLookup;
+llvm::DenseMap RefIndexForContainer;
 Results.HasMore |= Index->refs(Req, [&](const Ref &R) {

nridge wrote:
> We can have multiple references with the same container (e.g. multiple 
> references in the same function), so I think we need `DenseMap std::vector>` here.
Good catch! Turns out this fixes the FIXME I added in 
FindReferences.RefsToBaseMethod



Comment at: clang-tools-extra/clangd/XRefs.cpp:1501
   }
+  SymbolID Container = R.Container;
+  ContainerLookup.IDs.insert(Container);

nridge wrote:
> For good measure, perhaps condition the container-related logic here on 
> `AddContext`?
Good point, otherwise we're just wasting cycles and memory here if `AddContext` 
is false anyway



Comment at: clang-tools-extra/clangd/unittests/XRefsTests.cpp:2238
   for (const auto &R : Code.ranges())
 ExpectedLocations.push_back(rangeIs(R));
   EXPECT_THAT(findReferences(AST, Code.point(), 0).References,

nridge wrote:
> Did you mean to test the payload here?
Hmm I think I instead missed that this test does not use `checkFindRefs`. 
Removed the payload here, this path is already covered by other tests anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137894

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


[PATCH] D137894: [clangd] Add extension for adding context (enclosing function or class) in references results

2022-12-28 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders updated this revision to Diff 485482.
tom-anders marked 8 inline comments as done.
tom-anders added a comment.

Rebase, fix review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137894

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/test/references-container.test
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -301,6 +301,9 @@
 MATCHER_P(sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(rangeIs, R, "") { return arg.Loc.range == R; }
+MATCHER_P(containerIs, C, "") {
+  return arg.Loc.containerName.value_or("") == C;
+}
 MATCHER_P(attrsAre, A, "") { return arg.Attributes == A; }
 MATCHER_P(hasID, ID, "") { return arg.ID == ID; }
 
@@ -1900,28 +1903,30 @@
 
   auto AST = TU.build();
   std::vector> ExpectedLocations;
-  for (const auto &R : T.ranges())
-ExpectedLocations.push_back(AllOf(rangeIs(R), attrsAre(0u)));
+  for (const auto &[R, Context] : T.rangesWithPayload())
+ExpectedLocations.push_back(
+AllOf(rangeIs(R), containerIs(Context), attrsAre(0u)));
   // $def is actually shorthand for both definition and declaration.
   // If we have cases that are definition-only, we should change this.
-  for (const auto &R : T.ranges("def"))
-ExpectedLocations.push_back(
-AllOf(rangeIs(R), attrsAre(ReferencesResult::Definition |
-   ReferencesResult::Declaration)));
-  for (const auto &R : T.ranges("decl"))
-ExpectedLocations.push_back(
-AllOf(rangeIs(R), attrsAre(ReferencesResult::Declaration)));
-  for (const auto &R : T.ranges("overridedecl"))
+  for (const auto &[R, Context] : T.rangesWithPayload("def"))
+ExpectedLocations.push_back(AllOf(rangeIs(R), containerIs(Context),
+  attrsAre(ReferencesResult::Definition |
+   ReferencesResult::Declaration)));
+  for (const auto &[R, Context] : T.rangesWithPayload("decl"))
+ExpectedLocations.push_back(AllOf(rangeIs(R), containerIs(Context),
+  attrsAre(ReferencesResult::Declaration)));
+  for (const auto &[R, Context] : T.rangesWithPayload("overridedecl"))
 ExpectedLocations.push_back(AllOf(
-rangeIs(R),
+rangeIs(R), containerIs(Context),
 attrsAre(ReferencesResult::Declaration | ReferencesResult::Override)));
-  for (const auto &R : T.ranges("overridedef"))
-ExpectedLocations.push_back(
-AllOf(rangeIs(R), attrsAre(ReferencesResult::Declaration |
-   ReferencesResult::Definition |
-   ReferencesResult::Override)));
+  for (const auto &[R, Context] : T.rangesWithPayload("overridedef"))
+ExpectedLocations.push_back(AllOf(rangeIs(R), containerIs(Context),
+  attrsAre(ReferencesResult::Declaration |
+   ReferencesResult::Definition |
+   ReferencesResult::Override)));
   for (const auto &P : T.points()) {
-EXPECT_THAT(findReferences(AST, P, 0, UseIndex ? TU.index().get() : nullptr)
+EXPECT_THAT(findReferences(AST, P, 0, UseIndex ? TU.index().get() : nullptr,
+   /*AddContext*/ true)
 .References,
 UnorderedElementsAreArray(ExpectedLocations))
 << "Failed for Refs at " << P << "\n"
@@ -1933,18 +1938,18 @@
   const char *Tests[] = {
   R"cpp(// Local variable
 int main() {
-  int $def[[foo]];
-  [[^foo]] = 2;
-  int test1 = [[foo]];
+  int $def(main)[[foo]];
+  $(main)[[^foo]] = 2;
+  int test1 = $(main)[[foo]];
 }
   )cpp",
 
   R"cpp(// Struct
 namespace ns1 {
-struct $def[[Foo]] {};
+struct $def(ns1)[[Foo]] {};
 } // namespace ns1
 int main() {
-  ns1::[[Fo^o]]* Params;
+  ns1::$(main)[[Fo^o]]* Params;
 }
   )cpp",
 
@@ -1952,51 +1957,51 @@
 class $decl[[Foo]];
 class $def[[Foo]] {};
 int main() {
-  [[Fo^o]] foo;
+  $(main)[[Fo^o]] foo;
 }
   )cpp",
 
   R"cpp(// Function
 int $def[[foo]](int) {}
 int m

[PATCH] D138028: [clangd] Fix action `RemoveUsingNamespace` for inline namespace

2022-12-28 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders accepted this revision.
tom-anders 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/D138028/new/

https://reviews.llvm.org/D138028

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


[PATCH] D137894: [clangd] Add extension for adding context (enclosing function or class) in references results

2022-12-28 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders updated this revision to Diff 485483.
tom-anders added a comment.

s/llvm::Optional/std::optional/ for containerName field


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137894

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/index/SymbolCollector.cpp
  clang-tools-extra/clangd/index/SymbolCollector.h
  clang-tools-extra/clangd/test/references-container.test
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -301,6 +301,9 @@
 MATCHER_P(sym, Name, "") { return arg.Name == Name; }
 
 MATCHER_P(rangeIs, R, "") { return arg.Loc.range == R; }
+MATCHER_P(containerIs, C, "") {
+  return arg.Loc.containerName.value_or("") == C;
+}
 MATCHER_P(attrsAre, A, "") { return arg.Attributes == A; }
 MATCHER_P(hasID, ID, "") { return arg.ID == ID; }
 
@@ -1900,28 +1903,30 @@
 
   auto AST = TU.build();
   std::vector> ExpectedLocations;
-  for (const auto &R : T.ranges())
-ExpectedLocations.push_back(AllOf(rangeIs(R), attrsAre(0u)));
+  for (const auto &[R, Context] : T.rangesWithPayload())
+ExpectedLocations.push_back(
+AllOf(rangeIs(R), containerIs(Context), attrsAre(0u)));
   // $def is actually shorthand for both definition and declaration.
   // If we have cases that are definition-only, we should change this.
-  for (const auto &R : T.ranges("def"))
-ExpectedLocations.push_back(
-AllOf(rangeIs(R), attrsAre(ReferencesResult::Definition |
-   ReferencesResult::Declaration)));
-  for (const auto &R : T.ranges("decl"))
-ExpectedLocations.push_back(
-AllOf(rangeIs(R), attrsAre(ReferencesResult::Declaration)));
-  for (const auto &R : T.ranges("overridedecl"))
+  for (const auto &[R, Context] : T.rangesWithPayload("def"))
+ExpectedLocations.push_back(AllOf(rangeIs(R), containerIs(Context),
+  attrsAre(ReferencesResult::Definition |
+   ReferencesResult::Declaration)));
+  for (const auto &[R, Context] : T.rangesWithPayload("decl"))
+ExpectedLocations.push_back(AllOf(rangeIs(R), containerIs(Context),
+  attrsAre(ReferencesResult::Declaration)));
+  for (const auto &[R, Context] : T.rangesWithPayload("overridedecl"))
 ExpectedLocations.push_back(AllOf(
-rangeIs(R),
+rangeIs(R), containerIs(Context),
 attrsAre(ReferencesResult::Declaration | ReferencesResult::Override)));
-  for (const auto &R : T.ranges("overridedef"))
-ExpectedLocations.push_back(
-AllOf(rangeIs(R), attrsAre(ReferencesResult::Declaration |
-   ReferencesResult::Definition |
-   ReferencesResult::Override)));
+  for (const auto &[R, Context] : T.rangesWithPayload("overridedef"))
+ExpectedLocations.push_back(AllOf(rangeIs(R), containerIs(Context),
+  attrsAre(ReferencesResult::Declaration |
+   ReferencesResult::Definition |
+   ReferencesResult::Override)));
   for (const auto &P : T.points()) {
-EXPECT_THAT(findReferences(AST, P, 0, UseIndex ? TU.index().get() : nullptr)
+EXPECT_THAT(findReferences(AST, P, 0, UseIndex ? TU.index().get() : nullptr,
+   /*AddContext*/ true)
 .References,
 UnorderedElementsAreArray(ExpectedLocations))
 << "Failed for Refs at " << P << "\n"
@@ -1933,18 +1938,18 @@
   const char *Tests[] = {
   R"cpp(// Local variable
 int main() {
-  int $def[[foo]];
-  [[^foo]] = 2;
-  int test1 = [[foo]];
+  int $def(main)[[foo]];
+  $(main)[[^foo]] = 2;
+  int test1 = $(main)[[foo]];
 }
   )cpp",
 
   R"cpp(// Struct
 namespace ns1 {
-struct $def[[Foo]] {};
+struct $def(ns1)[[Foo]] {};
 } // namespace ns1
 int main() {
-  ns1::[[Fo^o]]* Params;
+  ns1::$(main)[[Fo^o]]* Params;
 }
   )cpp",
 
@@ -1952,51 +1957,51 @@
 class $decl[[Foo]];
 class $def[[Foo]] {};
 int main() {
-  [[Fo^o]] foo;
+  $(main)[[Fo^o]] foo;
 }
   )cpp",
 
   R"cpp(// Function
 int $def[[foo]](int) {}
 int main() {
-

[clang-tools-extra] 46575f6 - [clangd] Fix action `RemoveUsingNamespace` for inline namespace

2022-12-28 Thread Tom Praschan via cfe-commits

Author: v1nh1shungry
Date: 2022-12-28T13:34:43+01:00
New Revision: 46575f60380b18bf20c5f4cafc5fd06f561c4e7b

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

LOG: [clangd] Fix action `RemoveUsingNamespace` for inline namespace

Existing version ignores symbols declared in an inline namespace `ns`
when removing `using namespace ns`

Reviewed By: tom-anders

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
index f4228ae0be1f..ec02beb7e46f 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -89,16 +89,15 @@ bool isTopLevelDecl(const SelectionTree::Node *Node) {
   return Node->Parent && Node->Parent->ASTNode.get();
 }
 
-// Returns the first visible context that contains this DeclContext.
-// For example: Returns ns1 for S1 and a.
-// namespace ns1 {
-// inline namespace ns2 { struct S1 {}; }
-// enum E { a, b, c, d };
-// }
-const DeclContext *visibleContext(const DeclContext *D) {
-  while (D->isInlineNamespace() || D->isTransparentContext())
+// Return true if `LHS` is declared in `RHS`
+bool isDeclaredIn(const NamedDecl *LHS, const DeclContext *RHS) {
+  const auto *D = LHS->getDeclContext();
+  while (D->isInlineNamespace() || D->isTransparentContext()) {
+if (D->Equals(RHS))
+  return true;
 D = D->getParent();
-  return D;
+  }
+  return D->Equals(RHS);
 }
 
 bool RemoveUsingNamespace::prepare(const Selection &Inputs) {
@@ -152,8 +151,7 @@ Expected RemoveUsingNamespace::apply(const 
Selection &Inputs) {
 return; // This reference is already qualified.
 
   for (auto *T : Ref.Targets) {
-if (!visibleContext(T->getDeclContext())
- ->Equals(TargetDirective->getNominatedNamespace()))
+if (!isDeclaredIn(T, TargetDirective->getNominatedNamespace()))
   return;
 auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.

diff  --git 
a/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp 
b/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
index 03a46d954fcd..b0311534d6d8 100644
--- a/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ b/clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -264,6 +264,17 @@ TEST_F(RemoveUsingNamespaceTest, All) {
   }
   
   int main() { 1.5_w; }
+)cpp"},
+  {
+  R"cpp(
+  namespace a { inline namespace b { void foobar(); } }
+  using namespace a::[[b]];
+  int main() { foobar(); }
+)cpp",
+  R"cpp(
+  namespace a { inline namespace b { void foobar(); } }
+  
+  int main() { a::b::foobar(); }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;



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


[PATCH] D138028: [clangd] Fix action `RemoveUsingNamespace` for inline namespace

2022-12-28 Thread Tom Praschan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46575f60380b: [clangd] Fix action `RemoveUsingNamespace` for 
inline namespace (authored by v1nh1shungry, committed by tom-anders).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138028

Files:
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -264,6 +264,17 @@
   }
   
   int main() { 1.5_w; }
+)cpp"},
+  {
+  R"cpp(
+  namespace a { inline namespace b { void foobar(); } }
+  using namespace a::[[b]];
+  int main() { foobar(); }
+)cpp",
+  R"cpp(
+  namespace a { inline namespace b { void foobar(); } }
+  
+  int main() { a::b::foobar(); }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -89,16 +89,15 @@
   return Node->Parent && Node->Parent->ASTNode.get();
 }
 
-// Returns the first visible context that contains this DeclContext.
-// For example: Returns ns1 for S1 and a.
-// namespace ns1 {
-// inline namespace ns2 { struct S1 {}; }
-// enum E { a, b, c, d };
-// }
-const DeclContext *visibleContext(const DeclContext *D) {
-  while (D->isInlineNamespace() || D->isTransparentContext())
+// Return true if `LHS` is declared in `RHS`
+bool isDeclaredIn(const NamedDecl *LHS, const DeclContext *RHS) {
+  const auto *D = LHS->getDeclContext();
+  while (D->isInlineNamespace() || D->isTransparentContext()) {
+if (D->Equals(RHS))
+  return true;
 D = D->getParent();
-  return D;
+  }
+  return D->Equals(RHS);
 }
 
 bool RemoveUsingNamespace::prepare(const Selection &Inputs) {
@@ -152,8 +151,7 @@
 return; // This reference is already qualified.
 
   for (auto *T : Ref.Targets) {
-if (!visibleContext(T->getDeclContext())
- ->Equals(TargetDirective->getNominatedNamespace()))
+if (!isDeclaredIn(T, TargetDirective->getNominatedNamespace()))
   return;
 auto Kind = T->getDeclName().getNameKind();
 // Avoid adding qualifiers before operators, e.g.


Index: clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/RemoveUsingNamespaceTests.cpp
@@ -264,6 +264,17 @@
   }
   
   int main() { 1.5_w; }
+)cpp"},
+  {
+  R"cpp(
+  namespace a { inline namespace b { void foobar(); } }
+  using namespace a::[[b]];
+  int main() { foobar(); }
+)cpp",
+  R"cpp(
+  namespace a { inline namespace b { void foobar(); } }
+  
+  int main() { a::b::foobar(); }
 )cpp"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -89,16 +89,15 @@
   return Node->Parent && Node->Parent->ASTNode.get();
 }
 
-// Returns the first visible context that contains this DeclContext.
-// For example: Returns ns1 for S1 and a.
-// namespace ns1 {
-// inline namespace ns2 { struct S1 {}; }
-// enum E { a, b, c, d };
-// }
-const DeclContext *visibleContext(const DeclContext *D) {
-  while (D->isInlineNamespace() || D->isTransparentContext())
+// Return true if `LHS` is declared in `RHS`
+bool isDeclaredIn(const NamedDecl *LHS, const DeclContext *RHS) {
+  const auto *D = LHS->getDeclContext();
+  while (D->isInlineNamespace() || D->isTransparentContext()) {
+if (D->Equals(RHS))
+  return true;
 D = D->getParent();
-  return D;
+  }
+  return D->Equals(RHS);
 }
 
 bool RemoveUsingNamespace::prepare(const Selection &Inputs) {
@@ -152,8 +151,7 @@
 return; // This reference is already qualified.
 
   for (auto *T : Ref.Targets) {
-if (!visibleContext(T->getDeclContext())
- ->Equals(TargetDirective->getNominatedNamespace()))
+if (!isDeclaredIn(T, TargetDirectiv

[PATCH] D140696: [clang][dataflow] Treat unions as structs.

2022-12-28 Thread Dani Ferreira Franco Moura via Phabricator via cfe-commits
merrymeerkat updated this revision to Diff 485485.
merrymeerkat added a comment.

Add FIXME


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140696

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  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
@@ -1518,6 +1518,54 @@
   });
 }
 
+TEST(TransferTest, UnionThisMember) {
+  std::string Code = R"(
+union A {
+  int Foo;
+  double Bar;
+
+  void target() {
+(void)0; // [[p]]
+  }
+};
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const auto *ThisLoc = dyn_cast(
+Env.getThisPointeeStorageLocation());
+ASSERT_THAT(ThisLoc, NotNull());
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const auto *FooLoc =
+cast(&ThisLoc->getChild(*FooDecl));
+ASSERT_TRUE(isa_and_nonnull(FooLoc));
+
+const Value *FooVal = Env.getValue(*FooLoc);
+// FIXME: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(FooVal));
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const auto *BarLoc =
+cast(&ThisLoc->getChild(*BarDecl));
+ASSERT_TRUE(isa_and_nonnull(BarLoc));
+
+const Value *BarVal = Env.getValue(*BarLoc);
+// FIXME: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(BarVal));
+  });
+}
+
 TEST(TransferTest, StructThisInLambda) {
   std::string ThisCaptureCode = R"(
 struct A {
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -223,14 +223,12 @@
 if (Parent->isLambda())
   MethodDecl = dyn_cast(Parent->getDeclContext());
 
+// FIXME: Initialize the ThisPointeeLoc of lambdas too.
 if (MethodDecl && !MethodDecl->isStatic()) {
   QualType ThisPointeeType = MethodDecl->getThisObjectType();
-  // FIXME: Add support for union types.
-  if (!ThisPointeeType->isUnionType()) {
-ThisPointeeLoc = &createStorageLocation(ThisPointeeType);
-if (Value *ThisPointeeVal = createValue(ThisPointeeType))
-  setValue(*ThisPointeeLoc, *ThisPointeeVal);
-  }
+  ThisPointeeLoc = &createStorageLocation(ThisPointeeType);
+  if (Value *ThisPointeeVal = createValue(ThisPointeeType))
+setValue(*ThisPointeeLoc, *ThisPointeeVal);
 }
   }
 }


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -1518,6 +1518,54 @@
   });
 }
 
+TEST(TransferTest, UnionThisMember) {
+  std::string Code = R"(
+union A {
+  int Foo;
+  double Bar;
+
+  void target() {
+(void)0; // [[p]]
+  }
+};
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+
+const auto *ThisLoc = dyn_cast(
+Env.getThisPointeeStorageLocation());
+ASSERT_THAT(ThisLoc, NotNull());
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+const auto *FooLoc =
+cast(&ThisLoc->getChild(*FooDecl));
+ASSERT_TRUE(isa_and_nonnull(FooLoc));
+
+const Value *FooVal = Env.getValue(*FooLoc);
+// FIXME: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(FooVal));
+
+const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
+ASSERT_THAT(BarDecl, NotNull());
+
+const auto *BarLoc =
+cast(&ThisLoc->getChild(*BarDecl));
+ASSERT_TRUE(isa_and_nonnull(BarLoc));
+
+const Value *BarVal = Env.getValue(*BarLoc);
+// FIXME: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(BarVal));
+  });
+}

[PATCH] D140696: [clang][dataflow] Treat unions as structs.

2022-12-28 Thread Dani Ferreira Franco Moura via Phabricator via cfe-commits
merrymeerkat added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:1551-1552
+const Value *FooVal = Env.getValue(*FooLoc);
+// TODO: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(FooVal));

merrymeerkat wrote:
> ymandel wrote:
> > merrymeerkat wrote:
> > > ymandel wrote:
> > > > merrymeerkat wrote:
> > > > > ymandel wrote:
> > > > > > Why push this off to another patch?
> > > > > good point! I was pushing it because this is just a quick fix to 
> > > > > avoid a crash, and the current changes are sufficient for that
> > > > SGTM. Please use FIXME instead of TODO, though. But, glad to see this 
> > > > is enough to avoid the crashing!
> > > > 
> > > > That said, can you expand on where the actual crash was happening? I'm 
> > > > concerned that its possible that the crash site should be more robust 
> > > > and that this patch is hiding that weakness.
> > > Done!
> > > 
> > > The crash was happening because of a null pointer cast in the builtin 
> > > transfer function for CFGInitializers: 
> > > https://github.com/llvm/llvm-project/blob/781eabeb40b8e47e3a46b0b927784e63f0aad9ab/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp#L316
> > > 
> > > Hmm so do you think it'd be helpful to add a null check in the file 
> > > above? 
> > Thanks, that's quite helpful! Yes, I think that would be a better fix. It's 
> > a matter of perspective (and opinion) so feel free to push back but I'd say 
> > that the code you pointed to is buggy -- it assumes the `this` loc is 
> > populated, but *by design* it's not populated for unions (I didn't know 
> > that unions could ever have `this` so #TIL?).  I think we're admitting that 
> > we have a class of initializers for which we knowingly don't create the 
> > this pointer and therefore should express that in the code.
> > 
> > Alternatively, you could argue that the complete class of `this` pointer 
> > generating code is structs and unions, so if we just make sure (like your 
> > fix) to generate a this pointer in both cases, we can assert it's 
> > non-nullness (via the cast) and be done.
> > 
> > Given that the framework in general is riddled with places where we don't 
> > know if a value or storage location or... is initialized and we have to 
> > check, I think that's the better (and consistent) approach. Moreover, given 
> > that we're not actually adding support for unions, just trying to avoid a 
> > crash, I think changing that code site better expresses that intent.
> > 
> > Still, it's a matter of opinion, so I'll leave it to you to decide.  WDYT?
> Thanks for the comment!
> 
> What you say makes sense. I guess we introduced the union initialization 
> because it could also be useful in the future, but I don't know if it makes 
> sense to add a feature that doesn't have any semantic use yet.
> 
> If the framework does these kinds of null checks in lots of other places, 
> then I agree that it'd be good to have it here too for consistency. I'm 
> leaning towards making the change you suggested.
Hi @ymandel! Apologies for the late reply.

To clarify, were you suggesting that I remove the support for union and add a 
null check at the site of crash, or keep the support and add the null check? I 
had assumed the former, but now I re-read your comment and I am not sure. 

I thought more about this and I think I'd actually prefer to add support for 
unions and skip the null check. The support could be useful for users. Now, as 
for why I think we should skip the null check: in l. 226 of 
`Analysis/FlowSensitive/DataflowEnvironment.cpp`, we check for methods that are 
not static. These are the prerequisites for something having a "this" pointer*. 
So, since we initialise the `ThisPointeeLoc` there, any intializer we're 
processing in `TypeErasedDataflowAnalysis::builtinTransferInitializer` should 
already have a not-null "this" pointer, making the check unnecessary. What do 
you think?

*lambdas could also have a this pointer, but I will leave them to be the 
subject of another revision (I've added a FIXME for that). And, in any case, 
lambdas wouldn't be passed to `builtinTransferInitializer`, so the old crash is 
avoided anyway.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140696

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


[PATCH] D140696: [clang][dataflow] Treat unions as structs.

2022-12-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:1551-1552
+const Value *FooVal = Env.getValue(*FooLoc);
+// TODO: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(FooVal));

merrymeerkat wrote:
> merrymeerkat wrote:
> > ymandel wrote:
> > > merrymeerkat wrote:
> > > > ymandel wrote:
> > > > > merrymeerkat wrote:
> > > > > > ymandel wrote:
> > > > > > > Why push this off to another patch?
> > > > > > good point! I was pushing it because this is just a quick fix to 
> > > > > > avoid a crash, and the current changes are sufficient for that
> > > > > SGTM. Please use FIXME instead of TODO, though. But, glad to see this 
> > > > > is enough to avoid the crashing!
> > > > > 
> > > > > That said, can you expand on where the actual crash was happening? 
> > > > > I'm concerned that its possible that the crash site should be more 
> > > > > robust and that this patch is hiding that weakness.
> > > > Done!
> > > > 
> > > > The crash was happening because of a null pointer cast in the builtin 
> > > > transfer function for CFGInitializers: 
> > > > https://github.com/llvm/llvm-project/blob/781eabeb40b8e47e3a46b0b927784e63f0aad9ab/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp#L316
> > > > 
> > > > Hmm so do you think it'd be helpful to add a null check in the file 
> > > > above? 
> > > Thanks, that's quite helpful! Yes, I think that would be a better fix. 
> > > It's a matter of perspective (and opinion) so feel free to push back but 
> > > I'd say that the code you pointed to is buggy -- it assumes the `this` 
> > > loc is populated, but *by design* it's not populated for unions (I didn't 
> > > know that unions could ever have `this` so #TIL?).  I think we're 
> > > admitting that we have a class of initializers for which we knowingly 
> > > don't create the this pointer and therefore should express that in the 
> > > code.
> > > 
> > > Alternatively, you could argue that the complete class of `this` pointer 
> > > generating code is structs and unions, so if we just make sure (like your 
> > > fix) to generate a this pointer in both cases, we can assert it's 
> > > non-nullness (via the cast) and be done.
> > > 
> > > Given that the framework in general is riddled with places where we don't 
> > > know if a value or storage location or... is initialized and we have to 
> > > check, I think that's the better (and consistent) approach. Moreover, 
> > > given that we're not actually adding support for unions, just trying to 
> > > avoid a crash, I think changing that code site better expresses that 
> > > intent.
> > > 
> > > Still, it's a matter of opinion, so I'll leave it to you to decide.  WDYT?
> > Thanks for the comment!
> > 
> > What you say makes sense. I guess we introduced the union initialization 
> > because it could also be useful in the future, but I don't know if it makes 
> > sense to add a feature that doesn't have any semantic use yet.
> > 
> > If the framework does these kinds of null checks in lots of other places, 
> > then I agree that it'd be good to have it here too for consistency. I'm 
> > leaning towards making the change you suggested.
> Hi @ymandel! Apologies for the late reply.
> 
> To clarify, were you suggesting that I remove the support for union and add a 
> null check at the site of crash, or keep the support and add the null check? 
> I had assumed the former, but now I re-read your comment and I am not sure. 
> 
> I thought more about this and I think I'd actually prefer to add support for 
> unions and skip the null check. The support could be useful for users. Now, 
> as for why I think we should skip the null check: in l. 226 of 
> `Analysis/FlowSensitive/DataflowEnvironment.cpp`, we check for methods that 
> are not static. These are the prerequisites for something having a "this" 
> pointer*. So, since we initialise the `ThisPointeeLoc` there, any intializer 
> we're processing in `TypeErasedDataflowAnalysis::builtinTransferInitializer` 
> should already have a not-null "this" pointer, making the check unnecessary. 
> What do you think?
> 
> *lambdas could also have a this pointer, but I will leave them to be the 
> subject of another revision (I've added a FIXME for that). And, in any case, 
> lambdas wouldn't be passed to `builtinTransferInitializer`, so the old crash 
> is avoided anyway.
> 
Sounds good!  I had meant the former. But, I think you make a compelling case 
for adding the support and skipping the null check.

> And, in any case, lambdas wouldn't be passed to builtinTransferInitializer, 
> so the old crash is avoided anyway.
Why is this? I'm not sure of the structure of lambda's constructors offhand, so 
I don't have a sense one way or another.


Repository:
  rG LLVM Github Monorepo

CHANGES SINC

[PATCH] D140696: [clang][dataflow] Treat unions as structs.

2022-12-28 Thread Dani Ferreira Franco Moura via Phabricator via cfe-commits
merrymeerkat added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:1551-1552
+const Value *FooVal = Env.getValue(*FooLoc);
+// TODO: Initialise values inside unions, then change below to
+// ASSERT_TRUE.
+ASSERT_FALSE(isa_and_nonnull(FooVal));

ymandel wrote:
> merrymeerkat wrote:
> > merrymeerkat wrote:
> > > ymandel wrote:
> > > > merrymeerkat wrote:
> > > > > ymandel wrote:
> > > > > > merrymeerkat wrote:
> > > > > > > ymandel wrote:
> > > > > > > > Why push this off to another patch?
> > > > > > > good point! I was pushing it because this is just a quick fix to 
> > > > > > > avoid a crash, and the current changes are sufficient for that
> > > > > > SGTM. Please use FIXME instead of TODO, though. But, glad to see 
> > > > > > this is enough to avoid the crashing!
> > > > > > 
> > > > > > That said, can you expand on where the actual crash was happening? 
> > > > > > I'm concerned that its possible that the crash site should be more 
> > > > > > robust and that this patch is hiding that weakness.
> > > > > Done!
> > > > > 
> > > > > The crash was happening because of a null pointer cast in the builtin 
> > > > > transfer function for CFGInitializers: 
> > > > > https://github.com/llvm/llvm-project/blob/781eabeb40b8e47e3a46b0b927784e63f0aad9ab/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp#L316
> > > > > 
> > > > > Hmm so do you think it'd be helpful to add a null check in the file 
> > > > > above? 
> > > > Thanks, that's quite helpful! Yes, I think that would be a better fix. 
> > > > It's a matter of perspective (and opinion) so feel free to push back 
> > > > but I'd say that the code you pointed to is buggy -- it assumes the 
> > > > `this` loc is populated, but *by design* it's not populated for unions 
> > > > (I didn't know that unions could ever have `this` so #TIL?).  I think 
> > > > we're admitting that we have a class of initializers for which we 
> > > > knowingly don't create the this pointer and therefore should express 
> > > > that in the code.
> > > > 
> > > > Alternatively, you could argue that the complete class of `this` 
> > > > pointer generating code is structs and unions, so if we just make sure 
> > > > (like your fix) to generate a this pointer in both cases, we can assert 
> > > > it's non-nullness (via the cast) and be done.
> > > > 
> > > > Given that the framework in general is riddled with places where we 
> > > > don't know if a value or storage location or... is initialized and we 
> > > > have to check, I think that's the better (and consistent) approach. 
> > > > Moreover, given that we're not actually adding support for unions, just 
> > > > trying to avoid a crash, I think changing that code site better 
> > > > expresses that intent.
> > > > 
> > > > Still, it's a matter of opinion, so I'll leave it to you to decide.  
> > > > WDYT?
> > > Thanks for the comment!
> > > 
> > > What you say makes sense. I guess we introduced the union initialization 
> > > because it could also be useful in the future, but I don't know if it 
> > > makes sense to add a feature that doesn't have any semantic use yet.
> > > 
> > > If the framework does these kinds of null checks in lots of other places, 
> > > then I agree that it'd be good to have it here too for consistency. I'm 
> > > leaning towards making the change you suggested.
> > Hi @ymandel! Apologies for the late reply.
> > 
> > To clarify, were you suggesting that I remove the support for union and add 
> > a null check at the site of crash, or keep the support and add the null 
> > check? I had assumed the former, but now I re-read your comment and I am 
> > not sure. 
> > 
> > I thought more about this and I think I'd actually prefer to add support 
> > for unions and skip the null check. The support could be useful for users. 
> > Now, as for why I think we should skip the null check: in l. 226 of 
> > `Analysis/FlowSensitive/DataflowEnvironment.cpp`, we check for methods that 
> > are not static. These are the prerequisites for something having a "this" 
> > pointer*. So, since we initialise the `ThisPointeeLoc` there, any 
> > intializer we're processing in 
> > `TypeErasedDataflowAnalysis::builtinTransferInitializer` should already 
> > have a not-null "this" pointer, making the check unnecessary. What do you 
> > think?
> > 
> > *lambdas could also have a this pointer, but I will leave them to be the 
> > subject of another revision (I've added a FIXME for that). And, in any 
> > case, lambdas wouldn't be passed to `builtinTransferInitializer`, so the 
> > old crash is avoided anyway.
> > 
> Sounds good!  I had meant the former. But, I think you make a compelling case 
> for adding the support and skipping the null check.
> 
> > And, in any case, lambdas wouldn't be passed to builtinTransferInitializer, 
> > so the old crash is avoided anyway.
> Why is this? I'm not sure of the structure of lambda'

[PATCH] D140696: [clang][dataflow] Treat unions as structs.

2022-12-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

> Since (afaik) lambdas don't have these constructors, the input to 
> builtinTransferInitializer shouldn't come from a lambda.

I thought they might because they need to store captured variables. But, 
godbolt doesn't show any custom constructors so seems they don't.  I have no 
idea how they handle captured variables but that's hardly the only mystery 
about lambdas. :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140696

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


[PATCH] D140703: [clang][dataflow] Unify `TransferOptions` and `DataflowAnalysisContext::Options`.

2022-12-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 485488.
ymandel added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140703

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/include/clang/Analysis/FlowSensitive/Transfer.h
  clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.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
@@ -10,6 +10,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #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/StorageLocation.h"
@@ -34,6 +35,8 @@
 using ::testing::NotNull;
 using ::testing::UnorderedElementsAre;
 
+using BuiltinOptions = DataflowAnalysisContext::Options;
+
 template 
 void runDataflow(llvm::StringRef Code, Matcher Match,
  DataflowAnalysisOptions Options,
@@ -45,14 +48,18 @@
   "-std=" +
   std::string(LangStandard::getLangStandardForKind(Std).getName())};
   auto AI =
-  AnalysisInputs(Code, hasName(TargetFun),
-   [&Options](ASTContext &C, Environment &) {
- return NoopAnalysis(C, Options);
-   })
+  AnalysisInputs(
+  Code, hasName(TargetFun),
+  [UseBuiltinModel = Options.BuiltinOpts.has_value()](
+  ASTContext &C, Environment &Env) {
+return NoopAnalysis(C, DataflowAnalysisOptions{
+   UseBuiltinModel
+   ? Env.getAnalysisOptions()
+   : llvm::Optional()});
+  })
   .withASTBuildArgs(ASTBuildArgs);
-  if (Options.BuiltinTransferOpts &&
-  Options.BuiltinTransferOpts->ContextSensitiveOpts)
-AI = std::move(AI).withContextSensitivity();
+  if (Options.BuiltinOpts)
+AI = std::move(AI).withBuiltinOptions(*Options.BuiltinOpts);
   ASSERT_THAT_ERROR(
   checkDataflow(
   std::move(AI),
@@ -69,8 +76,8 @@
  bool ApplyBuiltinTransfer = true,
  llvm::StringRef TargetFun = "target") {
   runDataflow(Code, std::move(Match),
-  {ApplyBuiltinTransfer ? TransferOptions{}
-: llvm::Optional()},
+  {ApplyBuiltinTransfer ? BuiltinOptions{}
+: llvm::Optional()},
   Std, TargetFun);
 }
 
@@ -4053,7 +4060,7 @@
 EXPECT_FALSE(Env.flowConditionImplies(FooVal));
 EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal)));
   },
-  {TransferOptions{/*.ContextSensitiveOpts=*/std::nullopt}});
+  {BuiltinOptions{/*.ContextSensitiveOpts=*/std::nullopt}});
 }
 
 // This test is a regression test, based on a real crash.
@@ -4082,7 +4089,7 @@
 
 EXPECT_THAT(Env.getValue(*Loc), IsNull());
   },
-  {TransferOptions{ContextSensitiveOptions{}}});
+  {BuiltinOptions{ContextSensitiveOptions{}}});
 }
 
 TEST(TransferTest, ContextSensitiveDepthZero) {
@@ -4110,7 +4117,7 @@
 EXPECT_FALSE(Env.flowConditionImplies(FooVal));
 EXPECT_FALSE(Env.flowConditionImplies(Env.makeNot(FooVal)));
   },
-  {TransferOptions{ContextSensitiveOptions{/*.Depth=*/0}}});
+  {BuiltinOptions{ContextSensitiveOptions{/*.Depth=*/0}}});
 }
 
 TEST(TransferTest, ContextSensitiveSetTrue) {
@@ -4137,7 +4144,7 @@
 auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None));
 EXPECT_TRUE(Env.flowConditionImplies(FooVal));
   },
-  {TransferOptions{ContextSensitiveOptions{}}});
+  {BuiltinOptions{ContextSensitiveOptions{}}});
 }
 
 TEST(TransferTest, ContextSensitiveSetFalse) {
@@ -4164,7 +4171,7 @@
 auto &FooVal = *cast(Env.getValue(*FooDecl, SkipPast::None));
 EXPECT_TRUE(Env.flowConditionImplies(Env.makeNot(FooVal)));
   },
-  {TransferOptions{ContextSensitiveOptions{}}});
+  {BuiltinOptions{ContextSensitiveOptions{}}});
 }
 
 TEST(TransferTest, ContextSensitiveSetBothTrueAndFalse) {
@@ -4201,7 +4208,7 @@
 EXPECT_FAL

[PATCH] D140727: [XRay] Add initial support for loongarch64

2022-12-28 Thread Lu Weining via Phabricator via cfe-commits
SixWeining created this revision.
SixWeining added reviewers: MaskRay, xen0n, xry111.
Herald added subscribers: Enna1, StephenFan, hiraditya, dberris.
Herald added a project: All.
SixWeining requested review of this revision.
Herald added projects: clang, Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits.

Only support patching FunctionEntry/FunctionExit/FunctionTailExit for now.

Currently version 0 (which uses absolute address) is used because
LoongArch doesn't have a single 64bit PC-relative reloction type like
32bit version R_LARCH_32_PCREL.
Perhaps we can use a pair of relocations (R_LARCH_ADD64/R_LARCH_SUB64)
as replacement but that needs some changes to the backend.

Depends on D140725 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140727

Files:
  clang/lib/Driver/XRayArgs.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/lib/xray/CMakeLists.txt
  compiler-rt/lib/xray/xray_interface.cpp
  compiler-rt/lib/xray/xray_loongarch64.cpp
  compiler-rt/lib/xray/xray_trampoline_loongarch64.S
  compiler-rt/lib/xray/xray_tsc.h
  compiler-rt/test/xray/TestCases/Posix/always-never-instrument.cpp
  compiler-rt/test/xray/TestCases/Posix/arg1-arg0-logging.cpp
  compiler-rt/test/xray/TestCases/Posix/arg1-logger.cpp
  compiler-rt/test/xray/TestCases/Posix/arg1-logging-implicit-this.cpp
  compiler-rt/test/xray/TestCases/Posix/basic-filtering.cpp
  compiler-rt/test/xray/TestCases/Posix/c-test.cpp
  compiler-rt/test/xray/TestCases/Posix/clang-no-xray-instrument.cpp
  compiler-rt/test/xray/TestCases/Posix/fdr-mode-inmemory.cpp
  compiler-rt/test/xray/TestCases/Posix/fdr-mode-multiple.cpp
  compiler-rt/test/xray/TestCases/Posix/fdr-single-thread.cpp
  compiler-rt/test/xray/TestCases/Posix/fdr-thread-order.cpp
  compiler-rt/test/xray/TestCases/Posix/profiling-multi-threaded.cpp
  compiler-rt/test/xray/TestCases/Posix/profiling-single-threaded.cpp
  compiler-rt/test/xray/TestCases/Posix/quiet-start.cpp
  llvm/lib/CodeGen/XRayInstrumentation.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.cpp
  llvm/lib/Target/LoongArch/LoongArchAsmPrinter.h
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.cpp
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.h
  llvm/lib/Target/LoongArch/LoongArchSubtarget.h
  llvm/lib/XRay/InstrumentationMap.cpp
  llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll

Index: llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/xray-attribute-instrumentation.ll
@@ -0,0 +1,71 @@
+; RUN: llc --mtriple=loongarch64 %s -o - | FileCheck %s
+; RUN: llc --mtriple=loongarch64 -filetype=obj %s -o %t
+; RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=RELOC
+
+define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK-LABEL: foo:
+; CHECK-LABEL: .Lfunc_begin0:
+; CHECK:   .p2align 2
+; CHECK-LABEL: .Lxray_sled_begin0:
+; CHECK-NEXT:  b .Lxray_sled_end0
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-LABEL: .Lxray_sled_end0:
+  ret i32 0
+; CHECK-LABEL: .Lxray_sled_begin1:
+; CHECK-NEXT:  b .Lxray_sled_end1
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT:  nop
+; CHECK-NEXT: .Lxray_sled_end1:
+; CHECK-NEXT:  ret
+; CHECK-NEXT: .Lfunc_end0:
+}
+
+; CHECK-LABEL: .section xray_instr_map
+; CHECK-NEXT: .Lxray_sleds_start0:
+; CHECK-NEXT: .dword .Lxray_sled_begin0
+; CHECK-NEXT: .dword foo
+; CHECK-NEXT: .byte 0x00
+; CHECK-NEXT: .byte 0x01
+; CHECK-NEXT: .byte 0x00
+; CHECK-NEXT: .space 13
+; CHECK-NEXT: .dword .Lxray_sled_begin1
+; CHECK-NEXT: .dword foo
+; CHECK-NEXT: .byte 0x01
+; CHECK-NEXT: .byte 0x01
+; CHECK-NEXT: .byte 0x00
+; CHECK-NEXT: .space 13
+; CHECK-NEXT: .Lxray_sleds_end0:
+
+; CHECK-LABEL:  .section xray_fn_idx
+; CHECK:  .dword .Lxray_sleds_start0
+; CHECK-NEXT: .dword .Lxray_sleds_end0
+
+; RELOC:  Section ([[#]]) .relaxray_instr_map {
+; RELOC-NEXT:   0x0 R_LARCH_64 .text 0x0
+; RELOC-NEXT:   0x8 R_LARCH_64 foo 0x0
+; RELOC-NEXT:   0x20 R_LARCH_64 .text 0x34
+; RELOC-NEXT:   0x28 R_LARCH_64 foo 0x0
+; RELOC-NEXT: }
+; RELOC-NEXT: Section ([[#]]) .relaxray_fn_idx {
+; RELOC-NEXT:   0x0 R_LARCH_64 xray_instr_map 0x0
+; RELOC-NEXT:   0x8 R_LARCH_64 xray_instr_map 0x40
+; RELOC-NEXT: }
Index: llvm/lib/XRay/InstrumentationMap.cpp
===
--- llvm/lib/XRay/InstrumentationMap.cpp
+++ llvm/lib/XRay/InstrumentationMap.cpp
@@ -60,6 +60,7 @@
   // Find the section named "xray_instr_map".
   if ((!ObjFile.getBinary()->isELF() && !O

[PATCH] D139986: [clang][TypePrinter] Teach isSubstitutedDefaultArgument about integral types

2022-12-28 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D139986#4017650 , @Mordante wrote:

> In D139986#4017467 , @dblaikie 
> wrote:
>
>> In D139986#4008169 , @Mordante 
>> wrote:
>>
>>> In D139986#4005997 , @dblaikie 
>>> wrote:
>>>
 In D139986#4003873 , @Mordante 
 wrote:

> In D139986#4001180 , 
> @Michael137 wrote:
>
>> Missed couple of test cases in libcxx
>> About to fix those
>
> There were more breakage due to this patch, which I fixed in D140272 
> .
>
> Next time please don't commit patches when the pre-commit CI is red. This 
> build https://buildkite.com/llvm-project/libcxx-ci/builds/16118 shows the 
> patch will break libc++. These pre-commit CI jobs were added specifically 
> to aid the Clang developers to validate whether their changes break 
> libc++. Libc++ heavily relies on its pre-commit CI so breaking the CI has 
> a huge impact.
>>
>>
>>
> Note that when libc++ breaks there might be other projects that use the 
> latest Clang HEAD that will be affected too. (Not likely with 
> diagnostics, but likely when the modular build fails.)
>
> When you have issues resolving the libc++ issues you can always reach out 
> to us for assistance.

 Perhaps these LibC++ tests shouldn't be testing/using clang warnings? 
 (could the warnings be turned off in the libc++ tests?)
>>>
>>> In the failing tests we want to make sure we marked a struct as 
>>> `[[deprecated]]`.
>>
>> At least looking at 
>> https://reviews.llvm.org/rG54d7c4dc870c5822df3d5ce538ad3936ac6405fe - that 
>> could be made more robust to clang changes by perhaps using `// 
>> expected-warning {{deprecated}}` - unlikely that the word deprecated will be 
>> removed from a deprecation warning, or that we'll emit a deprecation warning 
>> on some unrelated line from the usage. This would make the test more 
>> resilient to phrasing/spelling changes without, imho, significantly reducing 
>> the functionality of the test.
>>
>> Though even more generally, I could see a test being written to use 
>> `-Werror` and various single uses of deprecated entities, checking that 
>> they're rejected - though that'd probably slow things down too much (singel 
>> process invocations for each deprecated entity) - so I'd say the above 
>> (`{{deprecated}}`) is probably a fairly good balance of making the tests 
>> less brittle while keeping them fast/functional.
>>
>> (for `locale.convenience` for instance - I think that test could be 
>> simplified to name each type separately, rather than using them together - 
>> so they're on separate lines. Or maybe you can separate them onto different 
>> lines despite the nesting, splitting the outer templtae name over multiple 
>> lines)
>
> I don't see how that helps to validate whether we have the expected error or 
> an error due to ill-formed code. For example just forgetting a semicolon.

reducing the wording checked for wouldn't have that problem - but yeah, going 
to totally wording agnostic testing wouldbe trickier. It could still avoid the 
"missing semicolon" problem by compiling with/without -Wdeprecated - expecting 
success without it, and failure with it. But I suspect the process launching 
overhead wouldn't be ideal for that direction anyway. At least reducing the 
dependence on specific warning wording/spelling would be help make the testing 
less brittle.

>>> In other tests we validate error messages to make sure things are 
>>> ill-formed as mandated. We test the diagnostic to make sure the compilation 
>>> fails for the expected reason and not a different compilation error. Do you 
>>> have a suggestion how we can do that without checking Clang diagnostics?
>>>
>>> In general I consider it bad practice to commit code when the CI is red.
>>
>> My take on this is that, at least to my understanding, libc++ implemented 
>> this CI without discussiong/buy-in from other LLVM subprojects that libc++ 
>> depends on - that I'm not sure were/are willing to accept this extra 
>> constraint on their development. It's not suitable to bring up a CI in that 
>> way and then say "make sure you don't break this" - we didn't agree not to 
>> break it. Especially with tests like these that could/should be written 
>> differently to be less brittle. Perhaps I've misunderstood this & there is 
>> more explicit buy-in from Clang developers/owners about this relationship 
>> between the two subprojects?
>>
>> Generally prior to this it was up to libc++ folks to cleanup after upstream 
>> project's breakage (like lldb still does, to some extent) - though 
>> buildbots, etc, do provide llvm/clang contributors some chance to 
>> proactively provide fixes.
>

[PATCH] D127812: [AArch64] FMV support and necessary target features dependencies.

2022-12-28 Thread Mariusz Ceier via Phabricator via cfe-commits
mceier added a comment.

Checked the changes I'm suggesting and they fix the standalone build.




Comment at: clang/lib/Basic/Targets/AArch64.cpp:650
+  .Case(NAME, FMV_PRIORITY)
+#include "../../../../llvm/include/llvm/TargetParser/AArch64TargetParser.def"
+  ;

That doesn't work for standalone builds. Instead maybe use `#include 
"llvm/TargetParser/AArch64TargetParser.def"` ?




Comment at: clang/lib/Basic/Targets/AArch64.cpp:669
+  .Case(NAME, DEP_FEATURES)
+#include "../../../../llvm/include/llvm/TargetParser/AArch64TargetParser.def"
+   .Default("");

Same comment as on line 650. `#include 
"llvm/TargetParser/AArch64TargetParser.def"` 



Comment at: clang/lib/Basic/Targets/AArch64.cpp:679
+  .Case(NAME, llvm::AArch64::FEAT_##FMV_ID)
+#include "../../../../llvm/include/llvm/TargetParser/AArch64TargetParser.def"
+  .Default(llvm::AArch64::FEAT_MAX);

Same comment as on line 650. `#include 
"llvm/TargetParser/AArch64TargetParser.def"` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D139287: [OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-28 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

Got tons of runtime failure

  target doesn't support jit
  UNREACHABLE executed at 
/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project-nightly/openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h:543!

on AMD GPU gfx908 when running miniqmc ctest


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

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


[PATCH] D140730: 59559 Explain code coverage with Lit in docs/SourceBasedCodeCoverage.rst

2022-12-28 Thread Flash Sheridan via Phabricator via cfe-commits
FlashSheridan created this revision.
Herald added a project: All.
FlashSheridan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The documentation for code coverage in docs/SourceBasedCodeCoverage.rst omits a 
couple of crucial steps when using it with Lit. I’d suggest the following 
additions:
At the end of “Running the instrumented program”:

> For a program such as the :doc:Lit  testing tool which
> invokes other programs, it may be necessary to set LLVM_PROFILE_FILE for
> each invocation. The pattern strings "%p" or "%Nm" may help to avoid
> corruption due to concurrency.

18 lines later, after “code-block:: console”:

> For an example of merging multiple profiles created by testing,
> see the LLVM coverage build script 
> https://github.com/llvm/llvm-zorg/blob/main/zorg/jenkins/jobs/jobs/llvm-coverage_.




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140730

Files:
  clang/docs/SourceBasedCodeCoverage.rst


Index: clang/docs/SourceBasedCodeCoverage.rst
===
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -127,6 +127,11 @@
 other platforms by passing the ``-runtime-counter-relocation`` option to the
 backend during compilation.
 
+For a program such as the :doc:`Lit ` testing tool which
+invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
+each invocation. The pattern strings "%p" or "%Nm" may help to avoid
+corruption due to concurrency.
+
 .. code-block:: console
 
 % clang++ -fprofile-instr-generate -fcoverage-mapping -mllvm 
-runtime-counter-relocation foo.cc -o foo
@@ -143,6 +148,9 @@
 # Step 3(a): Index the raw profile.
 % llvm-profdata merge -sparse foo.profraw -o foo.profdata
 
+For an example of merging multiple profiles created by testing,
+see the LLVM `coverage build script 
`_.
+
 There are multiple different ways to render coverage reports. The simplest
 option is to generate a line-oriented report:
 


Index: clang/docs/SourceBasedCodeCoverage.rst
===
--- clang/docs/SourceBasedCodeCoverage.rst
+++ clang/docs/SourceBasedCodeCoverage.rst
@@ -127,6 +127,11 @@
 other platforms by passing the ``-runtime-counter-relocation`` option to the
 backend during compilation.
 
+For a program such as the :doc:`Lit ` testing tool which
+invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
+each invocation. The pattern strings "%p" or "%Nm" may help to avoid
+corruption due to concurrency.
+
 .. code-block:: console
 
 % clang++ -fprofile-instr-generate -fcoverage-mapping -mllvm -runtime-counter-relocation foo.cc -o foo
@@ -143,6 +148,9 @@
 # Step 3(a): Index the raw profile.
 % llvm-profdata merge -sparse foo.profraw -o foo.profdata
 
+For an example of merging multiple profiles created by testing,
+see the LLVM `coverage build script `_.
+
 There are multiple different ways to render coverage reports. The simplest
 option is to generate a line-oriented report:
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137205: [clang-tidy] Add performance-unnecessary-copy-on-last-use check

2022-12-28 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

@Febbe - Really glad to see this phab up! Not having realized this phab was in 
progress, I implemented this a few months back (though, originally not as a 
clang-tidy tool and never published) and thought it'd be worth sharing notes. I 
recently turned my non-clang-tidy implementation into a clang-tidy one here 
.
 A couple suggestions based on my experience writing a similar tool,

- Should we detect "escaped" values, i.e., values who have their address taken, 
and not apply a FixIt in these cases? See this test 
.
- I took a slightly more conservative approach in only moving values whose 
`QualType.isTrivialType()` is true, which addresses the 
`shared_ptr` problem. We can then apply FixIts for containers 
(std::vector etc) and algebraic types (tuple/optional) of said types (and 
containers of containers of ...). In general, the approach I was aiming for was 
to define a classification of "safe to move types" (inferred from 
isTrivialType, and/or using a list of safe types of in the tool configuration 
as you have done). Containers/algebraic types of safe to move types, or smart 
pointers of safe to move types (being careful with any custom allocator which 
might lead to a similar problem as the scope guard case) are also safe to move, 
etc. Having the tool be able to distinguish "safe to move" FixIts from 
"potentially unsafe" (as a tool mode, potentially with "safe" as the default) 
would ensure safe refactoring.
- This might be a nitpick, but in the diagnostic message `warning: Parameter 
'...'`, "Parameter" typically means something more specific (the names given to 
function variables, aka, function parameters). How about `warning: Value '...'`

Would you be interested in collaborating on this? I'm not sure the status of 
when this phab would land, but I could contribute my suggestions after, or 
into, this phab depending on feedback. I wrote up a few more notes on 
https://discourse.llvm.org/t/new-clang-tidy-check-finding-move-candidates/67252 
(again, before I realized that you had started this work already).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137205

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


[clang] 2184fcf - [AArch64] Fix AArch64TargetParser.def includes for standalone builds.

2022-12-28 Thread Pavel Iliin via cfe-commits

Author: Pavel Iliin
Date: 2022-12-28T17:38:35Z
New Revision: 2184fcf17ee00a939b3bde98a28ef586c67d6b1a

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

LOG: [AArch64] Fix AArch64TargetParser.def includes for standalone builds.

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index dfbff695b09ad..d3c56e3a3ea6e 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -647,7 +647,7 @@ unsigned 
AArch64TargetInfo::multiVersionSortPriority(StringRef Name) const {
 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE, FMV_ID,   
\
   DEP_FEATURES, FMV_PRIORITY)  
\
   .Case(NAME, FMV_PRIORITY)
-#include "../../../../llvm/include/llvm/TargetParser/AArch64TargetParser.def"
+#include "llvm/TargetParser/AArch64TargetParser.def"
   ;
   assert((Name == "none" || Priority < multiVersionFeatureCost()) &&
  "FMV priority is out of bounds!");
@@ -666,7 +666,7 @@ bool AArch64TargetInfo::getFeatureDepOptions(StringRef Name,
 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE, FMV_ID,   
\
   DEP_FEATURES, FMV_PRIORITY)  
\
   .Case(NAME, DEP_FEATURES)
-#include "../../../../llvm/include/llvm/TargetParser/AArch64TargetParser.def"
+#include "llvm/TargetParser/AArch64TargetParser.def"
.Default("");
   return FeatureVec != "";
 }
@@ -676,7 +676,7 @@ bool AArch64TargetInfo::validateCpuSupports(StringRef 
FeatureStr) const {
 #define AARCH64_ARCH_EXT_NAME(NAME, ID, FEATURE, NEGFEATURE, FMV_ID,   
\
   DEP_FEATURES, FMV_PRIORITY)  
\
   .Case(NAME, llvm::AArch64::FEAT_##FMV_ID)
-#include "../../../../llvm/include/llvm/TargetParser/AArch64TargetParser.def"
+#include "llvm/TargetParser/AArch64TargetParser.def"
   .Default(llvm::AArch64::FEAT_MAX);
   return Feat != llvm::AArch64::FEAT_MAX;
 }



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


[PATCH] D127812: [AArch64] FMV support and necessary target features dependencies.

2022-12-28 Thread Pavel Iliin via Phabricator via cfe-commits
ilinpv added a comment.

In D127812#4018490 , @mceier wrote:

> Checked the changes I'm suggesting and they fix the standalone build.

Thanks! Fix committed 2184fcf17ee00a939b3bde98a28ef586c67d6b1a 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D140690: [compiler-rt][dfsan] Enable loongarch64 and add test support

2022-12-28 Thread Andrew via Phabricator via cfe-commits
browneee added a comment.

In D140690#4018043 , @SixWeining 
wrote:

> We notice that DFSan is a work in progress 
> , 
> currently under development for x86_64 Linux. So maybe we can defer the 
> change until DFSan development is finished and there is a use case on 
> loongarch64?

This sounds like a reasonable option.

DFSan development is now fairly mature. We don't support other platforms due to 
lack of demand (all the users I'm aware of are x86_64).

As a side note: I am pleased to see that the patch required to add this support 
is as small as I'd expect (even if we add the pieces in D140689 
 not shown here atm).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140690

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


[PATCH] D140696: [clang][dataflow] Treat unions as structs.

2022-12-28 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

another thought: please verify that `createStorageLoction` and `createValue` 
can correctly handle union types. Otherwise, you'll likely end up with other 
(surprising) crashes in the system. E.g. 
https://github.com/llvm/llvm-project/blob/781eabeb40b8e47e3a46b0b927784e63f0aad9ab/clang/lib/Analysis/FlowSensitive/Transfer.cpp#L457
assumes that the base of a member expression is an `AggregateStorageLocation`, 
which means that in the case that `this` is such a base and it's a union type, 
you need to be sure that `createStorageLocation` has allocated an 
`AggregateStorageLocation`.

Unfortunately, we don't have written down anywhere (aside from the code itself) 
the invariants we require.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140696

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


[PATCH] D137756: [z/OS][pg] Throw error when using -pg on z/OS

2022-12-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

Most targets reject `-p` now. It's unnecessary to have another z/OS specific 
diagnostic. So this patch can be abandoned.

  % fclang -p a.cc
  clang-16: error: unsupported option '-p' for target 'x86_64-unknown-linux-gnu'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137756

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


[PATCH] D113638: [xray] Add support for hexagon architecture

2022-12-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.
Herald added a subscriber: Enna1.
Herald added a project: All.

`recordSled(CurSled, MI, Kind, 0);` is not intended. All new ports should use 
version 2.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113638

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


[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2022-12-28 Thread Eric Gouriou via Phabricator via cfe-commits
ego added a comment.

See my comment below where I can trigger an MC-layer assertion when using 
"vaeskf1 v0, ...".




Comment at: llvm/test/MC/RISCV/rvv/rv64zvkns.s:1-9
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x 
--mattr=+experimental-zvkns %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x 
--mattr=+experimental-zvkns %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvkns  - 
\
+# RUN:| FileCheck %s --check-prefix=CHECK-INST

See Kito's comment. For most of those tests, and to avoid duplicating the logic 
between RV32 and RV64 files, we could drop the "rv64" prefix, cut/paste the RUN 
section to duplicate it and replace "riscv64" with "riscv32" in one of the 
copies.



Comment at: llvm/test/MC/RISCV/rvv/rv64zvkns.s:59
+
+vaeskf1.vi v10, v9, 1
+# CHECK-INST: vaeskf1.vi v10, v9, 1

If I replaces "v10" with "v0", the test fails with an assertion failure. My own 
patch uses a slightly different class hierarchy but hits the same assertion.


```
FAIL: LLVM :: MC/RISCV/rvv/rv64zvkns.s (3 of 8)
 TEST 'LLVM :: MC/RISCV/rvv/rv64zvkns.s' FAILED 

Script:
--
: 'RUN: at line 1';   
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
-triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 | 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 --check-prefixes=CHECK-ENCODING,CHECK-INST
: 'RUN: at line 3';   not 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
-triple=riscv64 -show-encoding 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 2>&1 | 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 --check-prefix=CHECK-ERROR
: 'RUN: at line 5';   
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
-triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 | 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-objdump -d 
--mattr=+zve32x --mattr=+experimental-zvkns  - | 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 --check-prefix=CHECK-INST
: 'RUN: at line 8';   
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
-triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 | 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-objdump -d - 
| /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
 --check-prefix=CHECK-UNKNOWN
--
Exit Code: 2

Command Output (stderr):
--
Assertion failed: (isReg() && "This is not a register operand!"), function 
getReg, file MCInst.h, line 70.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace.
Stack dump:
0.  Program arguments: 
/Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
-triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns 
/Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH 
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  libLLVMSupport.dylib0x0001023015e8 
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  libLLVMSupport.dylib0x000102300840 
llvm::sys::RunSignalHandlers() + 112
2  libLLVMSupport.dylib0x000102301c28 SignalHandler(int) + 304
3  libsystem_platform.dylib0x0001914f82a4 _sigtramp + 56
4  libsystem_pthread.dylib 0x0001914c9cec pthread_kill + 288
5  libsystem_c.dylib   0x0001914032c8 abort + 180
6  libsystem_c.dylib   0x000191402620 err + 0
7  libLLVMRISCVAsmParser.dylib 0x000100666208 (anonymous 
namespace)::RISCVAsmParser::MatchAndEmitInstruction(llvm::SMLoc, unsigned int&, 
llvm::SmallVectorImpl>>&, llvm::MCStreamer&, 
unsigned long long&, bool) (.cold.42) + 0
8  libLLVMRISCVAsmParser.dylib 0x000100655084 (anonymous 
namespace)::RISCVAsmParser::MatchAndEmitInstruction(llvm:

[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2022-12-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVSubtarget.h:97
   bool HasRV32 = false;
+  bool HasStdExtZvkb = false;
+  bool HasStdExtZvkg = false;

This needs to be rebased, it's all autogenerated by tablegen now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

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


[PATCH] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2022-12-28 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/test/MC/RISCV/rvv/rv64zvkns.s:59
+
+vaeskf1.vi v10, v9, 1
+# CHECK-INST: vaeskf1.vi v10, v9, 1

ego wrote:
> If I replaces "v10" with "v0", the test fails with an assertion failure. My 
> own patch uses a slightly different class hierarchy but hits the same 
> assertion.
> 
> 
> ```
> FAIL: LLVM :: MC/RISCV/rvv/rv64zvkns.s (3 of 8)
>  TEST 'LLVM :: MC/RISCV/rvv/rv64zvkns.s' FAILED 
> 
> Script:
> --
> : 'RUN: at line 1';   
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
> -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  | 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  --check-prefixes=CHECK-ENCODING,CHECK-INST
> : 'RUN: at line 3';   not 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
> -triple=riscv64 -show-encoding 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  2>&1 | 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  --check-prefix=CHECK-ERROR
> : 'RUN: at line 5';   
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
> -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  | 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-objdump -d 
> --mattr=+zve32x --mattr=+experimental-zvkns  - | 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  --check-prefix=CHECK-INST
> : 'RUN: at line 8';   
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
> -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvkns 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  | 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-objdump -d 
> - | /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/FileCheck 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
>  --check-prefix=CHECK-UNKNOWN
> --
> Exit Code: 2
> 
> Command Output (stderr):
> --
> Assertion failed: (isReg() && "This is not a register operand!"), function 
> getReg, file MCInst.h, line 70.
> PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
> and include the crash backtrace.
> Stack dump:
> 0.Program arguments: 
> /Users/ego/root-dirs/scratch/projects/llvm-project/build/bin/llvm-mc 
> -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns 
> /Users/ego/root-dirs/scratch/projects/llvm-project/llvm/test/MC/RISCV/rvv/rv64zvkns.s
> Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH 
> or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
> 0  libLLVMSupport.dylib0x0001023015e8 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
> 1  libLLVMSupport.dylib0x000102300840 
> llvm::sys::RunSignalHandlers() + 112
> 2  libLLVMSupport.dylib0x000102301c28 SignalHandler(int) + 304
> 3  libsystem_platform.dylib0x0001914f82a4 _sigtramp + 56
> 4  libsystem_pthread.dylib 0x0001914c9cec pthread_kill + 288
> 5  libsystem_c.dylib   0x0001914032c8 abort + 180
> 6  libsystem_c.dylib   0x000191402620 err + 0
> 7  libLLVMRISCVAsmParser.dylib 0x000100666208 (anonymous 
> namespace)::RISCVAsmParser::MatchAndEmitInstruction(llvm::SMLoc, unsigned 
> int&, llvm::SmallVectorImpl std::__1::default_delete>>&, llvm::MCStreamer&, 
> unsigned long long&, bool) (.cold.42) + 0
> 8  libLLVMRISCVAsmParser.dylib 0x000100655084 (anonymous 
> namespace)::RISCVAsmParser::MatchAndEmitInstruction(llvm::SMLoc, unsigned 
> int&, llvm::SmallVectorImpl std::__1::default_delete>>&, llvm::MCStreamer&, 
> unsigned long long&, bool) + 7268
> 9  libLLVMMCParser.dylib   0x000100c36c08 (anonymous 
> namespace)::AsmParser::parseAndMatchAndEmitTargetInstruction((anonymous 
> namespace)::ParseStatementInfo&, llvm::StringRef, llvm::AsmToken, 
> llvm::SMLoc) + 1356
> 10 libLLVMMCParser.dylib   0x000100c2d1d0 (anonymous 
> namespace)::AsmParser::parseStatement((anonymous 
> namespace)::ParseStatementInfo&, llvm::MCAsmParserSemaCallback*) + 3492
> 11 libLLVMMCParser.dylib   0x000100c27884 (anonymous 
> namespace)::AsmParser::Run(bool, bool) + 500
> 12 llvm-mc 0x00010051ffc8 main + 6608
> 13 dyld   

[PATCH] D140690: [compiler-rt][dfsan] Enable loongarch64 and add test support

2022-12-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

In D140690#4018617 , @browneee wrote:

> In D140690#4018043 , @SixWeining 
> wrote:
>
>> We notice that DFSan is a work in progress 
>> , 
>> currently under development for x86_64 Linux. So maybe we can defer the 
>> change until DFSan development is finished and there is a use case on 
>> loongarch64?
>
> This sounds like a reasonable option.
>
> DFSan development is now fairly mature. We don't support other platforms due 
> to lack of demand (all the users I'm aware of are x86_64).
>
> As a side note: I am pleased to see that the patch required to add this 
> support is as small as I'd expect (even if we add the pieces in D140689 
>  not shown here atm).

@browneee Instead of marking tests as `REQUIRES: x86_64-target-arch`, it'd be 
better to use an opt-out model (`UNSUPPORTED: ...` or `XFAIL: ...`)? The 
majority of tests should be architecture-agnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140690

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


[PATCH] D136554: Implement CWG2631

2022-12-28 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

All good now! The latest revision of this patch doesn't seem to break anything, 
unless I ran our tests wrong. From my perspective this is OK to reland now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D140743: [DFSan] Fix overuse of REQUIRES: in tests.

2022-12-28 Thread Andrew via Phabricator via cfe-commits
browneee created this revision.
browneee added a reviewer: MaskRay.
Herald added subscribers: Enna1, StephenFan.
Herald added a project: All.
browneee requested review of this revision.
Herald added projects: clang, Sanitizers.
Herald added subscribers: Sanitizers, cfe-commits.

Following suggestion on D140690 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140743

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/test/dfsan/atomic.cpp
  compiler-rt/test/dfsan/basic.c
  compiler-rt/test/dfsan/conditional_callbacks.c
  compiler-rt/test/dfsan/conditional_callbacks_sig.c
  compiler-rt/test/dfsan/custom.cpp
  compiler-rt/test/dfsan/dfsan_get_track_origins.c
  compiler-rt/test/dfsan/event_callbacks.c
  compiler-rt/test/dfsan/fast8labels.c
  compiler-rt/test/dfsan/flags.c
  compiler-rt/test/dfsan/flush.c
  compiler-rt/test/dfsan/fncall.c
  compiler-rt/test/dfsan/force_zero.c
  compiler-rt/test/dfsan/fork.cpp
  compiler-rt/test/dfsan/gep.c
  compiler-rt/test/dfsan/interceptors.c
  compiler-rt/test/dfsan/libatomic.c
  compiler-rt/test/dfsan/lookup_table.c
  compiler-rt/test/dfsan/mmap_at_init.c
  compiler-rt/test/dfsan/origin_add_label.c
  compiler-rt/test/dfsan/origin_branch.c
  compiler-rt/test/dfsan/origin_disabled.c
  compiler-rt/test/dfsan/origin_id_stack_trace.c
  compiler-rt/test/dfsan/origin_invalid.c
  compiler-rt/test/dfsan/origin_ld_lost.c
  compiler-rt/test/dfsan/origin_ldst.c
  compiler-rt/test/dfsan/origin_limit.c
  compiler-rt/test/dfsan/origin_memcpy.c
  compiler-rt/test/dfsan/origin_memmove.c
  compiler-rt/test/dfsan/origin_memset.c
  compiler-rt/test/dfsan/origin_of_first_taint.c
  compiler-rt/test/dfsan/origin_overlapped.c
  compiler-rt/test/dfsan/origin_set_label.c
  compiler-rt/test/dfsan/origin_stack_trace.c
  compiler-rt/test/dfsan/origin_track_ld.c
  compiler-rt/test/dfsan/origin_unaligned_memtrans.c
  compiler-rt/test/dfsan/origin_untainted.c
  compiler-rt/test/dfsan/origin_with_sigactions.c
  compiler-rt/test/dfsan/origin_with_signals.cpp
  compiler-rt/test/dfsan/pair.cpp
  compiler-rt/test/dfsan/propagate.c
  compiler-rt/test/dfsan/pthread.c
  compiler-rt/test/dfsan/reaches_function.c
  compiler-rt/test/dfsan/release_shadow_space.c
  compiler-rt/test/dfsan/sigaction.c
  compiler-rt/test/dfsan/sigaction_stress_test.c
  compiler-rt/test/dfsan/stack_trace.c
  compiler-rt/test/dfsan/struct.c
  compiler-rt/test/dfsan/threaded_flush.c
  compiler-rt/test/dfsan/trace-cmp.c
  compiler-rt/test/dfsan/vararg.c
  compiler-rt/test/dfsan/write_callback.c

Index: compiler-rt/test/dfsan/write_callback.c
===
--- compiler-rt/test/dfsan/write_callback.c
+++ compiler-rt/test/dfsan/write_callback.c
@@ -1,6 +1,4 @@
 // RUN: %clang_dfsan %s -o %t && %run %t | FileCheck %s
-//
-// REQUIRES: x86_64-target-arch
 
 // Tests that the custom implementation of write() does writes with or without
 // a callback set using dfsan_set_write_callback().
Index: compiler-rt/test/dfsan/vararg.c
===
--- compiler-rt/test/dfsan/vararg.c
+++ compiler-rt/test/dfsan/vararg.c
@@ -1,8 +1,6 @@
 // RUN: %clang_dfsan %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 // RUN: %run %t foo
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 
Index: compiler-rt/test/dfsan/trace-cmp.c
===
--- compiler-rt/test/dfsan/trace-cmp.c
+++ compiler-rt/test/dfsan/trace-cmp.c
@@ -3,8 +3,6 @@
 //
 // RUN: %clang_dfsan -fsanitize-coverage=trace-pc-guard,pc-table,func,trace-cmp %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/threaded_flush.c
===
--- compiler-rt/test/dfsan/threaded_flush.c
+++ compiler-rt/test/dfsan/threaded_flush.c
@@ -1,8 +1,6 @@
 // Tests that doing dfsan_flush() while another thread is executing doesn't
 // segfault.
 // RUN: %clang_dfsan %s -o %t && %run %t
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/struct.c
===
--- compiler-rt/test/dfsan/struct.c
+++ compiler-rt/test/dfsan/struct.c
@@ -1,7 +1,5 @@
 // RUN: %clang_dfsan %s -O1 -o %t && %run %t
 // RUN: %clang_dfsan %s -O0 -DO0 -o %t && %run %t
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/stack_trace.c
===
--- compiler-rt/test/dfsan/stack_trace.c
+++ compiler-rt/test/dfsan/stack_trace.c
@@ -1,7 +1,5 @@
 // RUN: %clang_dfsan -gmlt %s -o %t && %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/sigaction_stress_test.c
===

[PATCH] D140743: [DFSan] Fix overuse of REQUIRES: in tests.

2022-12-28 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 485547.
browneee added a comment.

Fix updated line numbers in test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140743

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/test/dfsan/atomic.cpp
  compiler-rt/test/dfsan/basic.c
  compiler-rt/test/dfsan/conditional_callbacks.c
  compiler-rt/test/dfsan/conditional_callbacks_sig.c
  compiler-rt/test/dfsan/custom.cpp
  compiler-rt/test/dfsan/dfsan_get_track_origins.c
  compiler-rt/test/dfsan/event_callbacks.c
  compiler-rt/test/dfsan/fast8labels.c
  compiler-rt/test/dfsan/flags.c
  compiler-rt/test/dfsan/flush.c
  compiler-rt/test/dfsan/fncall.c
  compiler-rt/test/dfsan/force_zero.c
  compiler-rt/test/dfsan/fork.cpp
  compiler-rt/test/dfsan/gep.c
  compiler-rt/test/dfsan/interceptors.c
  compiler-rt/test/dfsan/libatomic.c
  compiler-rt/test/dfsan/lookup_table.c
  compiler-rt/test/dfsan/mmap_at_init.c
  compiler-rt/test/dfsan/origin_add_label.c
  compiler-rt/test/dfsan/origin_branch.c
  compiler-rt/test/dfsan/origin_disabled.c
  compiler-rt/test/dfsan/origin_id_stack_trace.c
  compiler-rt/test/dfsan/origin_invalid.c
  compiler-rt/test/dfsan/origin_ld_lost.c
  compiler-rt/test/dfsan/origin_ldst.c
  compiler-rt/test/dfsan/origin_limit.c
  compiler-rt/test/dfsan/origin_memcpy.c
  compiler-rt/test/dfsan/origin_memmove.c
  compiler-rt/test/dfsan/origin_memset.c
  compiler-rt/test/dfsan/origin_of_first_taint.c
  compiler-rt/test/dfsan/origin_overlapped.c
  compiler-rt/test/dfsan/origin_set_label.c
  compiler-rt/test/dfsan/origin_stack_trace.c
  compiler-rt/test/dfsan/origin_track_ld.c
  compiler-rt/test/dfsan/origin_unaligned_memtrans.c
  compiler-rt/test/dfsan/origin_untainted.c
  compiler-rt/test/dfsan/origin_with_sigactions.c
  compiler-rt/test/dfsan/origin_with_signals.cpp
  compiler-rt/test/dfsan/pair.cpp
  compiler-rt/test/dfsan/propagate.c
  compiler-rt/test/dfsan/pthread.c
  compiler-rt/test/dfsan/reaches_function.c
  compiler-rt/test/dfsan/release_shadow_space.c
  compiler-rt/test/dfsan/sigaction.c
  compiler-rt/test/dfsan/sigaction_stress_test.c
  compiler-rt/test/dfsan/stack_trace.c
  compiler-rt/test/dfsan/struct.c
  compiler-rt/test/dfsan/threaded_flush.c
  compiler-rt/test/dfsan/trace-cmp.c
  compiler-rt/test/dfsan/vararg.c
  compiler-rt/test/dfsan/write_callback.c

Index: compiler-rt/test/dfsan/write_callback.c
===
--- compiler-rt/test/dfsan/write_callback.c
+++ compiler-rt/test/dfsan/write_callback.c
@@ -1,6 +1,4 @@
 // RUN: %clang_dfsan %s -o %t && %run %t | FileCheck %s
-//
-// REQUIRES: x86_64-target-arch
 
 // Tests that the custom implementation of write() does writes with or without
 // a callback set using dfsan_set_write_callback().
Index: compiler-rt/test/dfsan/vararg.c
===
--- compiler-rt/test/dfsan/vararg.c
+++ compiler-rt/test/dfsan/vararg.c
@@ -1,8 +1,6 @@
 // RUN: %clang_dfsan %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 // RUN: %run %t foo
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 
Index: compiler-rt/test/dfsan/trace-cmp.c
===
--- compiler-rt/test/dfsan/trace-cmp.c
+++ compiler-rt/test/dfsan/trace-cmp.c
@@ -3,8 +3,6 @@
 //
 // RUN: %clang_dfsan -fsanitize-coverage=trace-pc-guard,pc-table,func,trace-cmp %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/threaded_flush.c
===
--- compiler-rt/test/dfsan/threaded_flush.c
+++ compiler-rt/test/dfsan/threaded_flush.c
@@ -1,8 +1,6 @@
 // Tests that doing dfsan_flush() while another thread is executing doesn't
 // segfault.
 // RUN: %clang_dfsan %s -o %t && %run %t
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/struct.c
===
--- compiler-rt/test/dfsan/struct.c
+++ compiler-rt/test/dfsan/struct.c
@@ -1,7 +1,5 @@
 // RUN: %clang_dfsan %s -O1 -o %t && %run %t
 // RUN: %clang_dfsan %s -O0 -DO0 -o %t && %run %t
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/stack_trace.c
===
--- compiler-rt/test/dfsan/stack_trace.c
+++ compiler-rt/test/dfsan/stack_trace.c
@@ -1,7 +1,5 @@
 // RUN: %clang_dfsan -gmlt %s -o %t && %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
@@ -36,9 +34,9 @@
   printf("==OUTPUT==\n%s==EOS==\n", buf);
 
   // CHECK: ==OUTPUT==
-  // CHECK: #0 {{.*}} in bar.dfsan [[FILEPATH]]/stack_trace.c:15
+  // CHECK: #0 {{.*}} in bar.dfsan [[FILEPATH]]/stack_trace.c:11
   // CHECK-COU

[PATCH] D140743: [DFSan] Fix overuse of REQUIRES: in tests.

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

Looks great!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140743

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


[PATCH] D137838: [Support] Move TargetParsers to new component

2022-12-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

This bot is broken after the patch 
https://lab.llvm.org/buildbot/#/builders/236/builds/1480


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[clang] 14b42f2 - [Clang] Move AMDGPU IAS enabling to Generic_GCC::IsIntegratedAssemblerDefault, NFC

2022-12-28 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2022-12-28T17:57:14-05:00
New Revision: 14b42f21a25ccc3c5ce8c1fd2bdf44b018088a42

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

LOG: [Clang] Move AMDGPU IAS enabling to 
Generic_GCC::IsIntegratedAssemblerDefault, NFC

Reviewed By: scott.linder

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/AMDGPU.h
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/AMDGPU.h 
b/clang/lib/Driver/ToolChains/AMDGPU.h
index 3f5461a1c5696..153dc75092c7e 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.h
+++ b/clang/lib/Driver/ToolChains/AMDGPU.h
@@ -61,10 +61,8 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUToolChain : public 
Generic_ELF {
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
   unsigned GetDefaultDwarfVersion() const override { return 5; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
-  bool IsMathErrnoDefault() const override { return false; }
 
-  bool useIntegratedAs() const override { return true; }
+  bool IsMathErrnoDefault() const override { return false; }
   bool isCrossCompiling() const override { return true; }
   bool isPICDefault() const override { return false; }
   bool isPIEDefault(const llvm::opt::ArgList &Args) const override {

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index d03b4f47a61f5..e64bf70a06e8d 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2892,6 +2892,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   switch (getTriple().getArch()) {
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
+  case llvm::Triple::amdgcn:
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
   case llvm::Triple::avr:
@@ -2912,6 +2913,7 @@ bool Generic_GCC::IsIntegratedAssemblerDefault() const {
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
+  case llvm::Triple::r600:
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
   case llvm::Triple::sparc:



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


[PATCH] D140657: [Clang] Move AMDGPU IAS enabling to Generic_GCC::IsIntegratedAssemblerDefault, NFC

2022-12-28 Thread Brad Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG14b42f21a25c: [Clang] Move AMDGPU IAS enabling to 
Generic_GCC::IsIntegratedAssemblerDefault… (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140657

Files:
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/Gnu.cpp


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2892,6 +2892,7 @@
   switch (getTriple().getArch()) {
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
+  case llvm::Triple::amdgcn:
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
   case llvm::Triple::avr:
@@ -2912,6 +2913,7 @@
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
+  case llvm::Triple::r600:
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
   case llvm::Triple::sparc:
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -61,10 +61,8 @@
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
   unsigned GetDefaultDwarfVersion() const override { return 5; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
-  bool IsMathErrnoDefault() const override { return false; }
 
-  bool useIntegratedAs() const override { return true; }
+  bool IsMathErrnoDefault() const override { return false; }
   bool isCrossCompiling() const override { return true; }
   bool isPICDefault() const override { return false; }
   bool isPIEDefault(const llvm::opt::ArgList &Args) const override {


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2892,6 +2892,7 @@
   switch (getTriple().getArch()) {
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_be:
+  case llvm::Triple::amdgcn:
   case llvm::Triple::arm:
   case llvm::Triple::armeb:
   case llvm::Triple::avr:
@@ -2912,6 +2913,7 @@
   case llvm::Triple::ppcle:
   case llvm::Triple::ppc64:
   case llvm::Triple::ppc64le:
+  case llvm::Triple::r600:
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
   case llvm::Triple::sparc:
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -61,10 +61,8 @@
   AMDGPUToolChain(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args);
   unsigned GetDefaultDwarfVersion() const override { return 5; }
-  bool IsIntegratedAssemblerDefault() const override { return true; }
-  bool IsMathErrnoDefault() const override { return false; }
 
-  bool useIntegratedAs() const override { return true; }
+  bool IsMathErrnoDefault() const override { return false; }
   bool isCrossCompiling() const override { return true; }
   bool isPICDefault() const override { return false; }
   bool isPIEDefault(const llvm::opt::ArgList &Args) const override {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140695: [M68k] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2022-12-28 Thread Min-Yih Hsu via Phabricator via cfe-commits
myhsu requested changes to this revision.
myhsu added a comment.
This revision now requires changes to proceed.

In D140695#4018127 , @0x59616e wrote:

> FYI the pre-merge checks seem to have some issues. Here is the output:
>
>   Command Output (stderr):
>   --
>   
> /var/lib/buildkite-agent/builds/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c:4322:28:
>  error: CHECK_M68K_GCC_ATOMICS: expected string not found in input
>   // CHECK_M68K_GCC_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
>  ^
>   :1:1: note: scanning from here
>   #define _ILP32 1
>   ^
>   :62:1: note: possible intended match here
>   #define __GCC_ATOMIC_CHAR_LOCK_FREE 1
>   ^
>
>   Input file: 
>   Check file: 
> /var/lib/buildkite-agent/builds/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
>
>   -dump-input=help explains the following input dump.
>
>   Input was:
>   <<
> 1: #define _ILP32 1
>   check:4322'0 X error: no match found
> 2: #define __ATOMIC_ACQUIRE 2
>   check:4322'0 ~~~
> 3: #define __ATOMIC_ACQ_REL 4
>   check:4322'0 ~~~
> 4: #define __ATOMIC_CONSUME 1
>   check:4322'0 ~~~
> 5: #define __ATOMIC_RELAXED 0
>   check:4322'0 ~~~
> 6: #define __ATOMIC_RELEASE 3
>   check:4322'0 ~~~
> .
> .
> .
>57: #define __FLT_MIN__ 1.17549435e-38F
>   check:4322'0 
>58: #define __FLT_RADIX__ 2
>   check:4322'0 
>59: #define __GCC_ATOMIC_BOOL_LOCK_FREE 1
>   check:4322'0 ~~
>60: #define __GCC_ATOMIC_CHAR16_T_LOCK_FREE 1
>   check:4322'0 ~~
>61: #define __GCC_ATOMIC_CHAR32_T_LOCK_FREE 1
>   check:4322'0 ~~
>62: #define __GCC_ATOMIC_CHAR_LOCK_FREE 1
>   check:4322'0 ~~
>   check:4322'1 ?  possible intended 
> match
>63: #define __GCC_ATOMIC_INT_LOCK_FREE 1
>   check:4322'0 ~
>64: #define __GCC_ATOMIC_LLONG_LOCK_FREE 1
>   check:4322'0 ~~~
>65: #define __GCC_ATOMIC_LONG_LOCK_FREE 1
>   check:4322'0 ~~
>66: #define __GCC_ATOMIC_POINTER_LOCK_FREE 1
>   check:4322'0 ~
>67: #define __GCC_ATOMIC_SHORT_LOCK_FREE 1
>   check:4322'0 ~~~
> .
> .
> .
>   >>
>
>   --

This is probably caused by the fact that you didn't use CPU later than 68020. 
Please update your test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140695

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


[PATCH] D140743: [DFSan] Fix overuse of REQUIRES: in tests.

2022-12-28 Thread Andrew via Phabricator via cfe-commits
browneee updated this revision to Diff 485552.
browneee added a comment.

Fix other line number.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140743

Files:
  clang/lib/Driver/ToolChains/Linux.cpp
  compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake
  compiler-rt/test/dfsan/atomic.cpp
  compiler-rt/test/dfsan/basic.c
  compiler-rt/test/dfsan/conditional_callbacks.c
  compiler-rt/test/dfsan/conditional_callbacks_sig.c
  compiler-rt/test/dfsan/custom.cpp
  compiler-rt/test/dfsan/dfsan_get_track_origins.c
  compiler-rt/test/dfsan/event_callbacks.c
  compiler-rt/test/dfsan/fast8labels.c
  compiler-rt/test/dfsan/flags.c
  compiler-rt/test/dfsan/flush.c
  compiler-rt/test/dfsan/fncall.c
  compiler-rt/test/dfsan/force_zero.c
  compiler-rt/test/dfsan/fork.cpp
  compiler-rt/test/dfsan/gep.c
  compiler-rt/test/dfsan/interceptors.c
  compiler-rt/test/dfsan/libatomic.c
  compiler-rt/test/dfsan/lookup_table.c
  compiler-rt/test/dfsan/mmap_at_init.c
  compiler-rt/test/dfsan/origin_add_label.c
  compiler-rt/test/dfsan/origin_branch.c
  compiler-rt/test/dfsan/origin_disabled.c
  compiler-rt/test/dfsan/origin_id_stack_trace.c
  compiler-rt/test/dfsan/origin_invalid.c
  compiler-rt/test/dfsan/origin_ld_lost.c
  compiler-rt/test/dfsan/origin_ldst.c
  compiler-rt/test/dfsan/origin_limit.c
  compiler-rt/test/dfsan/origin_memcpy.c
  compiler-rt/test/dfsan/origin_memmove.c
  compiler-rt/test/dfsan/origin_memset.c
  compiler-rt/test/dfsan/origin_of_first_taint.c
  compiler-rt/test/dfsan/origin_overlapped.c
  compiler-rt/test/dfsan/origin_set_label.c
  compiler-rt/test/dfsan/origin_stack_trace.c
  compiler-rt/test/dfsan/origin_track_ld.c
  compiler-rt/test/dfsan/origin_unaligned_memtrans.c
  compiler-rt/test/dfsan/origin_untainted.c
  compiler-rt/test/dfsan/origin_with_sigactions.c
  compiler-rt/test/dfsan/origin_with_signals.cpp
  compiler-rt/test/dfsan/pair.cpp
  compiler-rt/test/dfsan/propagate.c
  compiler-rt/test/dfsan/pthread.c
  compiler-rt/test/dfsan/reaches_function.c
  compiler-rt/test/dfsan/release_shadow_space.c
  compiler-rt/test/dfsan/sigaction.c
  compiler-rt/test/dfsan/sigaction_stress_test.c
  compiler-rt/test/dfsan/stack_trace.c
  compiler-rt/test/dfsan/struct.c
  compiler-rt/test/dfsan/threaded_flush.c
  compiler-rt/test/dfsan/trace-cmp.c
  compiler-rt/test/dfsan/vararg.c
  compiler-rt/test/dfsan/write_callback.c

Index: compiler-rt/test/dfsan/write_callback.c
===
--- compiler-rt/test/dfsan/write_callback.c
+++ compiler-rt/test/dfsan/write_callback.c
@@ -1,6 +1,4 @@
 // RUN: %clang_dfsan %s -o %t && %run %t | FileCheck %s
-//
-// REQUIRES: x86_64-target-arch
 
 // Tests that the custom implementation of write() does writes with or without
 // a callback set using dfsan_set_write_callback().
Index: compiler-rt/test/dfsan/vararg.c
===
--- compiler-rt/test/dfsan/vararg.c
+++ compiler-rt/test/dfsan/vararg.c
@@ -1,8 +1,6 @@
 // RUN: %clang_dfsan %s -o %t
 // RUN: not %run %t 2>&1 | FileCheck %s
 // RUN: %run %t foo
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 
Index: compiler-rt/test/dfsan/trace-cmp.c
===
--- compiler-rt/test/dfsan/trace-cmp.c
+++ compiler-rt/test/dfsan/trace-cmp.c
@@ -3,8 +3,6 @@
 //
 // RUN: %clang_dfsan -fsanitize-coverage=trace-pc-guard,pc-table,func,trace-cmp %s -o %t
 // RUN: %run %t 2>&1 | FileCheck %s
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/threaded_flush.c
===
--- compiler-rt/test/dfsan/threaded_flush.c
+++ compiler-rt/test/dfsan/threaded_flush.c
@@ -1,8 +1,6 @@
 // Tests that doing dfsan_flush() while another thread is executing doesn't
 // segfault.
 // RUN: %clang_dfsan %s -o %t && %run %t
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/struct.c
===
--- compiler-rt/test/dfsan/struct.c
+++ compiler-rt/test/dfsan/struct.c
@@ -1,7 +1,5 @@
 // RUN: %clang_dfsan %s -O1 -o %t && %run %t
 // RUN: %clang_dfsan %s -O0 -DO0 -o %t && %run %t
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
Index: compiler-rt/test/dfsan/stack_trace.c
===
--- compiler-rt/test/dfsan/stack_trace.c
+++ compiler-rt/test/dfsan/stack_trace.c
@@ -1,7 +1,5 @@
 // RUN: %clang_dfsan -gmlt %s -o %t && %run %t >%t.out 2>&1
 // RUN: FileCheck %s < %t.out
-//
-// REQUIRES: x86_64-target-arch
 
 #include 
 #include 
@@ -36,9 +34,9 @@
   printf("==OUTPUT==\n%s==EOS==\n", buf);
 
   // CHECK: ==OUTPUT==
-  // CHECK: #0 {{.*}} in bar.dfsan [[FILEPATH]]/stack_trace.c:15
-  // CHECK-COUNT-8: #{{[1-9]+}} {{.*}} in bar.dfsan [[FILEPATH]]/stack_trace.c:18
-  // CHE

[PATCH] D114865: [AMDGPU][OpenMP] Use -amdgpu-fixed-function-abi

2022-12-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm resigned from this revision.
arsenm added a comment.
This revision is now accepted and ready to land.
Herald added subscribers: kosarev, MaskRay.
Herald added a project: All.

This should be abandoned, the flag is gone


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114865

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


[PATCH] D140462: [clangd] Add schema for `.clangd` config

2022-12-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

The difficulty in testing is that:

- JSON-schema is totally unknown in llvm-project, so there are no tools but 
also no expectation that contributors understand it
- llvm-project doesn't like dependencies, particularly those that aren't in C++ 
or python
- having done some digging, interop seems really poor...

I tried 3 consumers (`ajv-cli`, `yaml-language-server`, and `yajsv`) and **hit 
different blocking bugs in all of them** when using obvious, spec-compliant 
approaches to writing schemas.

> My feeling is that, at the end of the day, the schema format is relatively 
> straightforward compared to other things that a clangd reviewer needs to know

But this is additional, it's obscure (unrelated to all the other knowledge), 
and as it's untested, the reviewer needs to reliably catch problems, including 
subtle interop problems.
It has the "python problem", where it's readable and you can see at a glance 
why the code is correct - even if it isn't.
(Having spent a couple of days with json-schema now, I **don't** think it's 
straightforward. That file seems simple so far, but there are simple C++ 
programs too! And it carefully dodges the interop issues, which is *subtle*).

Meanwhile, changing config **already** is a sea of boilerplate that's hard to 
review and bugs/divergences have crept in. (Config settings that are compiled 
but not parsed, things missing from the web docs, web docs being reworded but 
internal docs staying the same, etc).

---

Fixing this is an unreasonable burden to place on a new contributor, I've taken 
a shot at this and have something almost working: 
https://reviews.llvm.org/D140745.

It's pretty draft-ish:

- That patch just checks in the generated files {`Fragment.inc`, `YAML.inc`, 
`doc.md`, `schema.json`}, (maybe) that belongs in the build system
- the schema is correct but `yaml-language-server` chokes on it due to 
https://github.com/redhat-developer/yaml-language-server/issues/823, so need to 
restructure
- files would need to be moved around etc
- tests need to be added/updated
- i'm not sure whether having a json-schema for `schema.yaml` is actually a 
good idea, it was mostly a learning exercise




Comment at: clang-tools-extra/clangd/schema/config.json:20
+  "properties": {
+"If": {
+  "description": "Conditions in the If block restrict when a fragment 
applies.",

disabling `additionalProperties` probably yields useful diagnostics



Comment at: clang-tools-extra/clangd/schema/config.json:25
+"PathMatch": {
+  "description": "The file being processed must fully match a regular 
expression.",
+  "$ref": "#/$defs/stringOrArrayOf"

Unfortunately it's not valid to specify description together with $ref 
(implementations are required to ignore it)

https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3



Comment at: clang-tools-extra/clangd/schema/config.json:81
+  "description": "Used to define an external index source",
+  "type": "object",
+  "oneOf": [

external can also be the case-insensitive string "None"



Comment at: clang-tools-extra/clangd/schema/config.json:115
+"FullyQualifiedNamespaces": {
+  "type": "boolean"
+}

this is rather a list of strings



Comment at: clang-tools-extra/clangd/schema/config.json:172
+},
+"ParameterNames": {
+  "description": "A boolean that enables/disables inlay-hints for 
parameter names in function calls.",

hmm, there are two more categories here - were they missing somewhere?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140462

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


[PATCH] D136554: Implement CWG2631

2022-12-28 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

In D136554#4018870 , @rupprecht wrote:

> All good now! The latest revision of this patch doesn't seem to break 
> anything, unless I ran our tests wrong. From my perspective this is OK to 
> reland now.

... and yep, I was holding it wrong. There are still build failures, this time 
in linking, where LLD reports some symbols are undefined. I'm not certain yet 
if this really a problem with this patch (e.g. sometimes we see files break 
like this when users put their template code in the .cpp files and not the .h 
files), but the source code doesn't look immediately wrong. Once again, I'll 
try to reduce something.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D140692: [RISCV] Add Svpbmt extension support.

2022-12-28 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng 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/D140692/new/

https://reviews.llvm.org/D140692

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


[PATCH] D140727: [XRay] Add initial support for loongarch64

2022-12-28 Thread Lu Weining via Phabricator via cfe-commits
SixWeining planned changes to this revision.
SixWeining added a comment.

D140725  is abandoned. Let me defer this 
change until we support 64bit PC-relative relocation for `SymA - SymB`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140727

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


[PATCH] D140462: [clangd] Add schema for `.clangd` config

2022-12-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D140462#4018983 , @sammccall wrote:

> I tried 3 consumers (`ajv-cli`, `yaml-language-server`, and `yajsv`) and 
> **hit different blocking bugs in all of them** when using obvious, 
> spec-compliant approaches to writing schemas.

Thanks for experimenting. Happy to defer to your judgment on the best course of 
action given this state of affairs (and also the mentioned difficulty in 
accessing these tools from an LLVM test suite).

> I've taken a shot at this and have something almost working: 
> https://reviews.llvm.org/D140745.

Neat!




Comment at: clang-tools-extra/clangd/schema/config.json:20
+  "properties": {
+"If": {
+  "description": "Conditions in the If block restrict when a fragment 
applies.",

sammccall wrote:
> disabling `additionalProperties` probably yields useful diagnostics
One question here is, do we want diagnostics from the schema validation to 
duplicate or replace clangd's own diagnostics for the config file?



Comment at: clang-tools-extra/clangd/schema/config.json:25
+"PathMatch": {
+  "description": "The file being processed must fully match a regular 
expression.",
+  "$ref": "#/$defs/stringOrArrayOf"

sammccall wrote:
> Unfortunately it's not valid to specify description together with $ref 
> (implementations are required to ignore it)
> 
> https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3
Hmmm... the spec draft at 
https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.3.1, 
which is newer (2022 rather than 2018) does not seem to have this wording, and 
the example at 
https://json-schema.org/learn/getting-started-step-by-step.html#references uses 
`$ref` together with `description`.



Comment at: clang-tools-extra/clangd/schema/config.json:172
+},
+"ParameterNames": {
+  "description": "A boolean that enables/disables inlay-hints for 
parameter names in function calls.",

sammccall wrote:
> hmm, there are two more categories here - were they missing somewhere?
`Designators` is missing from https://clangd.llvm.org/config.html#inlayhints

What's the other one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140462

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


[PATCH] D140462: [clangd] Add schema for `.clangd` config

2022-12-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/schema/config.json:20
+  "properties": {
+"If": {
+  "description": "Conditions in the If block restrict when a fragment 
applies.",

nridge wrote:
> sammccall wrote:
> > disabling `additionalProperties` probably yields useful diagnostics
> One question here is, do we want diagnostics from the schema validation to 
> duplicate or replace clangd's own diagnostics for the config file?
I'm not totally sure.

It's tempting to call these a failed experiment. The UX for clangd-emitted 
diags is pretty sad (since they only generate/update when we happen to process 
the config file again).

However there are definitely going to be things you can get wrong that the 
schema won't catch, and we should make them visible *somehow*.



Comment at: clang-tools-extra/clangd/schema/config.json:25
+"PathMatch": {
+  "description": "The file being processed must fully match a regular 
expression.",
+  "$ref": "#/$defs/stringOrArrayOf"

nridge wrote:
> sammccall wrote:
> > Unfortunately it's not valid to specify description together with $ref 
> > (implementations are required to ignore it)
> > 
> > https://datatracker.ietf.org/doc/html/draft-handrews-json-schema-01#section-8.3
> Hmmm... the spec draft at 
> https://json-schema.org/draft/2020-12/json-schema-core.html#section-8.2.3.1, 
> which is newer (2022 rather than 2018) does not seem to have this wording, 
> and the example at 
> https://json-schema.org/learn/getting-started-step-by-step.html#references 
> uses `$ref` together with `description`.
Yeah, one of the complexities here is the version skew :-(
Different versions are (partially) supported by different tools. Some of them 
pay attention to what the file is self-declared as, others don't.

draft-07 looks like the lowest-common-denominator (and is what this file claims 
to be), and in particular `yaml-language-server` [always validates against 
draft-07](https://github.com/redhat-developer/yaml-language-server/issues/780) 
regardless of what the file claims.



Comment at: clang-tools-extra/clangd/schema/config.json:172
+},
+"ParameterNames": {
+  "description": "A boolean that enables/disables inlay-hints for 
parameter names in function calls.",

nridge wrote:
> sammccall wrote:
> > hmm, there are two more categories here - were they missing somewhere?
> `Designators` is missing from https://clangd.llvm.org/config.html#inlayhints
> 
> What's the other one?
There isn't one, I was confused.
(I think I was thinking of type-param hints, but we never added it :-()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140462

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


[PATCH] D136554: Implement CWG2631

2022-12-28 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

I'm not sure what to make of the new failure when I try it out this time. Given 
a source like this:

  #include 
  
  struct Options {
std::function identity = [](bool x) -> bool { return x; };
  };
  
  struct Wrapper {
explicit Wrapper(const Options& options = Options()) {}
  };
  
  void Func() { Options options; }

The object file reports many fewer symbols as a result of this patch, but one 
new problematic one. Before:

   T Func()
   W 
std::__1::__function::__func, bool 
(bool)>::target_type() const
   W 
std::__1::__function::__func, bool 
(bool)>::target(std::type_info const&) const
   W 
std::__1::__function::__func, bool 
(bool)>::__clone(std::__1::__function::__base*) const
   W 
std::__1::__function::__func, bool (bool)>::__clone() 
const
   W std::__1::__function::__base::~__base[abi:v16]()
   W 
std::__1::__function::__func, bool 
(bool)>::destroy_deallocate()
   W 
std::__1::__function::__func, bool (bool)>::destroy()
   W 
std::__1::__function::__func, bool (bool)>::~__func()
   W 
std::__1::__function::__func, bool 
(bool)>::operator()(bool&&)
   V typeinfo for Options::identity::'lambda'(bool)
   V typeinfo for std::__1::__function::__base
   V typeinfo for 
std::__1::__function::__func, bool (bool)>
   V typeinfo name for Options::identity::'lambda'(bool)
   V typeinfo name for std::__1::__function::__base
   V typeinfo name for 
std::__1::__function::__func, bool (bool)>
   U vtable for __cxxabiv1::__class_type_info
   U vtable for __cxxabiv1::__si_class_type_info
   V vtable for 
std::__1::__function::__func, bool (bool)>
   U operator delete(void*)
   U operator new(unsigned long)

And after:

   T Func()
   U std::__1::function::function(Options::identity::'lambda'(bool))

The undefined symbols before are all provided by libc++, so those are fine. 
After, the new undefined symbol for the lambda cannot be resolved. Depending on 
how the linker is invoked, this may or may not be fine -- IIUC the linker can 
sometimes recognize that it doesn't actually need the undefined symbol, so it 
doesn't matter if it can't find it.

Here is the build script I'm using, although you will likely need to tweak it 
for your own environment:

  ${CLANG} \
-std=gnu++17 -stdlib=libc++ \
-c main.cc \
-o /tmp/main.o
  
  echo "main.o symbols:"
  llvm-nm -C /tmp/main.o
  
  echo Building b.cc
  
  ${CLANG} \
-std=gnu++17 -stdlib=libc++ \
-O1 -fno-exceptions \
-c b.cc \
-o /tmp/b.o
  
  echo "b.o symbols:"
  llvm-nm -C /tmp/b.o
  
  echo Linking, and expecting success
  
  ${CLANG} \
-fuse-ld=lld \
-o /tmp/main \
/tmp/main.o \
-Wl,--start-lib /tmp/b.o -Wl,--end-lib \
/usr/lib/x86_64-linux-gnu/libc++.so
  
  echo Linking, and expecting failure with D136554
  
  ${CLANG} \
-fuse-ld=lld \
-o /tmp/main \
/tmp/main.o \
/tmp/b.o \
/usr/lib/x86_64-linux-gnu/libc++.so \
-Wl,--export-dynamic

(Here `b.cc` is the first snippet above, and `main.cc` is a trivial file with 
just `int main(int argc, char* argv[]) { return 0; }`)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D140695: [M68k] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2022-12-28 Thread Brad Smith via Phabricator via cfe-commits
brad added a comment.

How come the Clang M68k backend defaults to 68000? GCC defaults to 68020 for 
all targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140695

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


[PATCH] D140695: [M68k] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2022-12-28 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 485582.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140695

Files:
  clang/lib/Basic/Targets/M68k.cpp
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4313,3 +4313,20 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_R600_FP64
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
+
+// Begin M68k tests 
+
+// RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefix=CHECK_M68K_68000_ATOMICS
+// RUN: %clang -mcpu=68010 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefix=CHECK_M68K_68000_ATOMICS
+// RUN: %clang -mcpu=68020 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s 
-check-prefix=CHECK_M68K_68020_ATOMICS
+
+// CHECK_M68K_68000_ATOMICS-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
Index: clang/lib/Basic/Targets/M68k.cpp
===
--- clang/lib/Basic/Targets/M68k.cpp
+++ clang/lib/Basic/Targets/M68k.cpp
@@ -113,6 +113,12 @@
   default:
 break;
   }
+
+  if (CPU >= CK_68020) {
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  }
 }
 
 ArrayRef M68kTargetInfo::getTargetBuiltins() const {


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4313,3 +4313,20 @@
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_R600_FP64
 // CHECK_R600_FP64-DAG: #define __R600__ 1
 // CHECK_R600_FP64-DAG: #define __HAS_FMAF__ 1
+
+// Begin M68k tests 
+
+// RUN: %clang -mcpu=68000 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_M68K_68000_ATOMICS
+// RUN: %clang -mcpu=68010 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_M68K_68000_ATOMICS
+// RUN: %clang -mcpu=68020 -E -dM %s -o - 2>&1 \
+// RUN: -target m68k-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_M68K_68020_ATOMICS
+
+// CHECK_M68K_68000_ATOMICS-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
Index: clang/lib/Basic/Targets/M68k.cpp
===
--- clang/lib/Basic/Targets/M68k.cpp
+++ clang/lib/Basic/Targets/M68k.cpp
@@ -113,6 +113,12 @@
   default:
 break;
   }
+
+  if (CPU >= CK_68020) {
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  }
 }
 
 ArrayRef M68kTargetInfo::getTargetBuiltins() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140687: [Clang][RISCV] Use poison instead of undef

2022-12-28 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1972fb23cb36: [Clang][RISCV] Use poison instead of undef 
(authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140687

Files:
  clang/test/CodeGen/RISCV/riscv-attr-builtin-alias.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vaadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vasub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfclass.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfncvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrdiv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrec7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsqrt7.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsgnj.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsqrt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwcvt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfwsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfeq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmflt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsbf.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmseq.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsif.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmslt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsne.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsof.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmul-eew64.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnclip.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsra.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vnsrl.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredand.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredmax.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredmin.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredsum.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vredxor.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrem.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrgather.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vrsub.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsbc.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsext.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslide1down.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vslide1up.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsll.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsmul-eew64.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vsmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overl

[clang] bd9c0f0 - [RISCV] Add Svpbmt extension support.

2022-12-28 Thread Yeting Kuo via cfe-commits

Author: Yeting Kuo
Date: 2022-12-28T23:57:54-08:00
New Revision: bd9c0f082b20d96ced1e5f5ddc1506afffc0f8d3

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

LOG: [RISCV] Add Svpbmt extension support.

Spec of Svpbmt: 
https://github.com/riscv/riscv-isa-manual/blob/master/src/supervisor.tex#L2399

Reviewed By: kito-cheng

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

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/TargetParser/RISCVISAInfo.cpp
llvm/test/CodeGen/RISCV/attributes.ll

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 7791703cbbe46..c514ad889d0b2 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -41,6 +41,7 @@
 // CHECK-NOT: __riscv_zicbom
 // CHECK-NOT: __riscv_zicboz
 // CHECK-NOT: __riscv_svnapot
+// CHECK-NOT: __riscv_svpbmt
 // CHECK-NOT: __riscv_svinval
 // CHECK-NOT: __riscv_xventanacondops
 // CHECK-NOT: __riscv_zcd
@@ -436,6 +437,12 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-SVNAPOT-EXT %s
 // CHECK-SVNAPOT-EXT: __riscv_svnapot 100{{$}}
 
+// RUN: %clang -target riscv32 -march=rv32isvpbmt -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
+// RUN: %clang -target riscv64 -march=rv64isvpbmt -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-SVPBMT-EXT %s
+// CHECK-SVPBMT-EXT: __riscv_svpbmt 100{{$}}
+
 // RUN: %clang -target riscv32 -march=rv32isvinval -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SVINVAL-EXT %s
 // RUN: %clang -target riscv64 -march=rv64isvinval -x c -E -dM %s \

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 522988f8b053d..70e86ed6a30c8 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -53,6 +53,7 @@ on support follow.
  ``F``Supported
  ``M``Supported
  ``Svinval``  Assembly Support
+ ``Svpbmt``   Supported
  ``V``Supported
  ``Zba``  Supported
  ``Zbb``  Supported

diff  --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
index c94d426fb72e3..eb851a7e1ed92 100644
--- a/llvm/lib/Target/RISCV/RISCV.td
+++ b/llvm/lib/Target/RISCV/RISCV.td
@@ -413,6 +413,10 @@ def FeatureStdExtSvnapot
 : SubtargetFeature<"svnapot", "HasStdExtSvnapot", "true",
"'Svnapot' (NAPOT Translation Contiguity)">;
 
+def FeatureStdExtSvpbmt
+: SubtargetFeature<"svpbmt", "HasStdExtSvpbmt", "true",
+   "'Svpbmt' (Page-Based Memory Types)">;
+
 def FeatureStdExtSvinval
 : SubtargetFeature<"svinval", "HasStdExtSvinval", "true",
"'Svinval' (Fine-Grained Address-Translation Cache 
Invalidation)">;

diff  --git a/llvm/lib/TargetParser/RISCVISAInfo.cpp 
b/llvm/lib/TargetParser/RISCVISAInfo.cpp
index 328749b12845c..4f56d1aa00955 100644
--- a/llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ b/llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -103,6 +103,7 @@ static const RISCVSupportedExtension SupportedExtensions[] 
= {
 {"zicbop", RISCVExtensionVersion{1, 0}},
 
 {"svnapot", RISCVExtensionVersion{1, 0}},
+{"svpbmt", RISCVExtensionVersion{1, 0}},
 {"svinval", RISCVExtensionVersion{1, 0}},
 {"xventanacondops", RISCVExtensionVersion{1, 0}},
 {"xtheadvdot", RISCVExtensionVersion{1, 0}},

diff  --git a/llvm/test/CodeGen/RISCV/attributes.ll 
b/llvm/test/CodeGen/RISCV/attributes.ll
index dda8d65350658..4acb1ad2fc3bb 100644
--- a/llvm/test/CodeGen/RISCV/attributes.ll
+++ b/llvm/test/CodeGen/RISCV/attributes.ll
@@ -37,6 +37,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zicboz %s -o - | FileCheck 
--check-prefix=RV32ZICBOZ %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zicbop %s -o - | FileCheck 
--check-prefix=RV32ZICBOP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefix=RV32SVNAPOT %s
+; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefix=RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefix=RV32SVINVAL %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zca %s -o - | FileCheck 
--check-prefix=RV32ZCA %s
 
@@ -77,6 +78,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zicboz %s -o - | FileCheck 
--check-prefix=RV64ZICBOZ %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zicbop %s -o - | FileCheck 
--check-prefix=RV64ZICBOP %s
 ; RUN: llc -mtriple=riscv64 -mattr=+svnapot %s -o - | FileCheck 
--check-prefix=RV64SVNAPOT %s
+; RUN: llc -mtriple=riscv64 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefix=RV64SVPBMT %s
 ; RUN: llc -mtriple=riscv64 -matt

[PATCH] D140692: [RISCV] Add Svpbmt extension support.

2022-12-28 Thread Yeting Kuo 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 rGbd9c0f082b20: [RISCV] Add Svpbmt extension support. 
(authored by fakepaper56).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140692

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/TargetParser/RISCVISAInfo.cpp
  llvm/test/CodeGen/RISCV/attributes.ll


Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -37,6 +37,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zicboz %s -o - | FileCheck 
--check-prefix=RV32ZICBOZ %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zicbop %s -o - | FileCheck 
--check-prefix=RV32ZICBOP %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svnapot %s -o - | FileCheck 
--check-prefix=RV32SVNAPOT %s
+; RUN: llc -mtriple=riscv32 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefix=RV32SVPBMT %s
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck 
--check-prefix=RV32SVINVAL %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zca %s -o - | FileCheck 
--check-prefix=RV32ZCA %s
 
@@ -77,6 +78,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zicboz %s -o - | FileCheck 
--check-prefix=RV64ZICBOZ %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zicbop %s -o - | FileCheck 
--check-prefix=RV64ZICBOP %s
 ; RUN: llc -mtriple=riscv64 -mattr=+svnapot %s -o - | FileCheck 
--check-prefix=RV64SVNAPOT %s
+; RUN: llc -mtriple=riscv64 -mattr=+svpbmt %s -o - | FileCheck 
--check-prefix=RV64SVPBMT %s
 ; RUN: llc -mtriple=riscv64 -mattr=+svinval %s -o - | FileCheck 
--check-prefix=RV64SVINVAL %s
 ; RUN: llc -mtriple=riscv64 -mattr=+xventanacondops %s -o - | FileCheck 
--check-prefix=RV64XVENTANACONDOPS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+xtheadvdot %s -o - | FileCheck 
--check-prefix=RV64XTHEADVDOT %s
@@ -121,6 +123,7 @@
 ; RV32ZICBOZ: .attribute 5, "rv32i2p0_zicboz1p0"
 ; RV32ZICBOP: .attribute 5, "rv32i2p0_zicbop1p0"
 ; RV32SVNAPOT: .attribute 5, "rv32i2p0_svnapot1p0"
+; RV32SVPBMT: .attribute 5, "rv32i2p0_svpbmt1p0"
 ; RV32SVINVAL: .attribute 5, "rv32i2p0_svinval1p0"
 ; RV32ZCA: .attribute 5, "rv32i2p0_zca0p70"
 
@@ -162,6 +165,7 @@
 ; RV64ZAWRS: .attribute 5, "rv64i2p0_zawrs1p0"
 ; RV64ZICBOP: .attribute 5, "rv64i2p0_zicbop1p0"
 ; RV64SVNAPOT: .attribute 5, "rv64i2p0_svnapot1p0"
+; RV64SVPBMT: .attribute 5, "rv64i2p0_svpbmt1p0"
 ; RV64SVINVAL: .attribute 5, "rv64i2p0_svinval1p0"
 ; RV64XVENTANACONDOPS: .attribute 5, "rv64i2p0_xventanacondops1p0"
 ; RV64XTHEADVDOT: .attribute 5, 
"rv64i2p0_f2p0_d2p0_v1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_xtheadvdot1p0"
Index: llvm/lib/TargetParser/RISCVISAInfo.cpp
===
--- llvm/lib/TargetParser/RISCVISAInfo.cpp
+++ llvm/lib/TargetParser/RISCVISAInfo.cpp
@@ -103,6 +103,7 @@
 {"zicbop", RISCVExtensionVersion{1, 0}},
 
 {"svnapot", RISCVExtensionVersion{1, 0}},
+{"svpbmt", RISCVExtensionVersion{1, 0}},
 {"svinval", RISCVExtensionVersion{1, 0}},
 {"xventanacondops", RISCVExtensionVersion{1, 0}},
 {"xtheadvdot", RISCVExtensionVersion{1, 0}},
Index: llvm/lib/Target/RISCV/RISCV.td
===
--- llvm/lib/Target/RISCV/RISCV.td
+++ llvm/lib/Target/RISCV/RISCV.td
@@ -413,6 +413,10 @@
 : SubtargetFeature<"svnapot", "HasStdExtSvnapot", "true",
"'Svnapot' (NAPOT Translation Contiguity)">;
 
+def FeatureStdExtSvpbmt
+: SubtargetFeature<"svpbmt", "HasStdExtSvpbmt", "true",
+   "'Svpbmt' (Page-Based Memory Types)">;
+
 def FeatureStdExtSvinval
 : SubtargetFeature<"svinval", "HasStdExtSvinval", "true",
"'Svinval' (Fine-Grained Address-Translation Cache 
Invalidation)">;
Index: llvm/docs/RISCVUsage.rst
===
--- llvm/docs/RISCVUsage.rst
+++ llvm/docs/RISCVUsage.rst
@@ -53,6 +53,7 @@
  ``F``Supported
  ``M``Supported
  ``Svinval``  Assembly Support
+ ``Svpbmt``   Supported
  ``V``Supported
  ``Zba``  Supported
  ``Zbb``  Supported
Index: clang/test/Preprocessor/riscv-target-features.c
===
--- clang/test/Preprocessor/riscv-target-features.c
+++ clang/test/Preprocessor/riscv-target-features.c
@@ -41,6 +41,7 @@
 // CHECK-NOT: __riscv_zicbom
 // CHECK-NOT: __riscv_zicboz
 // CHECK-NOT: __riscv_svnapot
+// CHECK-NOT: __riscv_svpbmt
 // CHECK-NOT: __riscv_svinval
 // CHECK-NOT: __riscv_xventanacondops
 // CHECK-NOT: __riscv_zcd
@@ -436,6 +437,12 @@
 // RUN: -o - | FileCheck --check-prefix