[PATCH] D156212: [clang][Interp] Implement remaining strcmp builtins

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156212

Files:
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/AST/Interp/builtin-functions.cpp

Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -5,39 +5,228 @@
 // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -fexperimental-new-constant-interpreter -triple i686 %s -verify
 // RUN: %clang_cc1 -std=c++20 -Wno-string-plus-int -verify=ref %s -Wno-constant-evaluated
 
-
-namespace strcmp {
+namespace StrcmpEtc {
   constexpr char kFoobar[6] = {'f','o','o','b','a','r'};
   constexpr char kFoobazfoobar[12] = {'f','o','o','b','a','z','f','o','o','b','a','r'};
 
-  static_assert(__builtin_strcmp("", "") == 0, "");
-  static_assert(__builtin_strcmp("abab", "abab") == 0, "");
-  static_assert(__builtin_strcmp("abab", "abba") == -1, "");
-  static_assert(__builtin_strcmp("abab", "abaa") == 1, "");
-  static_assert(__builtin_strcmp("ababa", "abab") == 1, "");
-  static_assert(__builtin_strcmp("abab", "ababa") == -1, "");
-  static_assert(__builtin_strcmp("a\203", "a") == 1, "");
-  static_assert(__builtin_strcmp("a\203", "a\003") == 1, "");
-  static_assert(__builtin_strcmp("abab\0banana", "abab") == 0, "");
-  static_assert(__builtin_strcmp("abab", "abab\0banana") == 0, "");
-  static_assert(__builtin_strcmp("abab\0banana", "abab\0canada") == 0, "");
-  static_assert(__builtin_strcmp(0, "abab") == 0, ""); // expected-error {{not an integral constant}} \
-   // expected-note {{dereferenced null}} \
-   // expected-note {{in call to}} \
-   // ref-error {{not an integral constant}} \
-   // ref-note {{dereferenced null}}
-  static_assert(__builtin_strcmp("abab", 0) == 0, ""); // expected-error {{not an integral constant}} \
-   // expected-note {{dereferenced null}} \
-   // expected-note {{in call to}} \
-   // ref-error {{not an integral constant}} \
-   // ref-note {{dereferenced null}}
-
-  static_assert(__builtin_strcmp(kFoobar, kFoobazfoobar) == -1, "");
-  static_assert(__builtin_strcmp(kFoobar, kFoobazfoobar + 6) == 0, ""); // expected-error {{not an integral constant}} \
+  static_assert(__builtin_strncmp("abaa", "abba", 5) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 4) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 3) == -1);
+  static_assert(__builtin_strncmp("abaa", "abba", 2) == 0);
+  static_assert(__builtin_strncmp("abaa", "abba", 1) == 0);
+  static_assert(__builtin_strncmp("abaa", "abba", 0) == 0);
+  static_assert(__builtin_strncmp(0, 0, 0) == 0);
+  static_assert(__builtin_strncmp("abab\0banana", "abab\0canada", 100) == 0);
+
+  static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, 6) == -1);
+  static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar, 7) == -1);
+  static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar + 6, 6) == 0);
+  static_assert(__builtin_strncmp(kFoobar, kFoobazfoobar + 6, 7) == 0); // expected-error {{not an integral constant}} \
 // expected-note {{dereferenced one-past-the-end}} \
 // expected-note {{in call to}} \
-// ref-error {{not an integral constant}} \
+// ref-error {{not an integral constant expression}} \
 // ref-note {{dereferenced one-past-the-end}}
+  static_assert(__builtin_memcmp("abaa", "abba", 3) == -1);
+  static_assert(__builtin_memcmp("abaa", "abba", 2) == 0);
+  static_assert(__builtin_memcmp("a\203", "a", 2) == 1);
+  static_assert(__builtin_memcmp("a\203", "a\003", 2) == 1);
+  static_assert(__builtin_memcmp(0, 0, 0) == 0);
+  static_assert(__builtin_memcmp("abab\0banana", "abab\0banana", 100) == 0); // expected-error {{not an integral constant}} \
+ // expected-note {{dereferenced one-past-the-end}} \
+ // expected-note {{in call to}} 

[PATCH] D156053: [Clang] Fix crash in CIndex, when visiting a static_assert without message

2023-07-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D156053#4531015 , @kiloalphaindia 
wrote:

> The test is no more using any includes now. Hopefully this fixes it, 
> otherwise I will have to add something that prints the diagnostic.
>
> I don't have write permissions on the repository. Please commit it when OK.

Will do! (once the test pass) What name / email address should we use for 
commiting?


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

https://reviews.llvm.org/D156053

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


[PATCH] D151547: [RISCV] Remove experimental for zihintntl.

2023-07-25 Thread Jianjian Guan via Phabricator via cfe-commits
jacquesguan added a comment.

https://github.com/riscv-non-isa/riscv-c-api-doc/pull/47 is already merged, any 
more advice about this patch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151547

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


[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

This looks reasonable to me know. should we try to land that today? 
Sorry i could not get to it earlier!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[PATCH] D156053: [Clang] Fix crash in CIndex, when visiting a static_assert without message

2023-07-25 Thread Kai Stierand via Phabricator via cfe-commits
kiloalphaindia added a comment.

Please use Kai Stierand  as in 
5d859a1cdee3c15dce692767ee3e9ad03a8c4c1b 



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

https://reviews.llvm.org/D156053

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


[PATCH] D155394: [clang][Interp] Implement __builtin_fpclassify

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 543854.

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

https://reviews.llvm.org/D155394

Files:
  clang/lib/AST/Interp/Floating.h
  clang/lib/AST/Interp/InterpBuiltin.cpp
  clang/test/AST/Interp/builtin-functions.cpp


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -103,3 +103,17 @@
   char isfpclass_snan_2   [__builtin_isfpclass(__builtin_nansl(""), 0x0207) ? 
1 : -1]; // ~fcFinite
   char isfpclass_snan_3   [!__builtin_isfpclass(__builtin_nans(""), 0x01F8) ? 
1 : -1]; // fcFinite
 }
+
+namespace fpclassify {
+  char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, 
__builtin_nan(""))];
+  char classify_snan[__builtin_fpclassify(+1, -1, -1, -1, -1, 
__builtin_nans(""))];
+  char classify_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, 
__builtin_inf())];
+  char classify_neg_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, 
-__builtin_inf())];
+  char classify_normal  [__builtin_fpclassify(-1, -1, +1, -1, -1, 1.539)];
+  char classify_normal2 [__builtin_fpclassify(-1, -1, +1, -1, -1, 1e-307)];
+  char classify_denorm  [__builtin_fpclassify(-1, -1, -1, +1, -1, 1e-308)];
+  char classify_denorm2 [__builtin_fpclassify(-1, -1, -1, +1, -1, -1e-308)];
+  char classify_zero[__builtin_fpclassify(-1, -1, -1, -1, +1, 0.0)];
+  char classify_neg_zero[__builtin_fpclassify(-1, -1, -1, -1, +1, -0.0)];
+  char classify_subnorm [__builtin_fpclassify(-1, -1, -1, +1, -1, 1.0e-38f)];
+}
Index: clang/lib/AST/Interp/InterpBuiltin.cpp
===
--- clang/lib/AST/Interp/InterpBuiltin.cpp
+++ clang/lib/AST/Interp/InterpBuiltin.cpp
@@ -232,6 +232,37 @@
   return true;
 }
 
+/// Five int32 values followed by one floating value.
+static bool interp__builtin_fpclassify(InterpState &S, CodePtr OpPC,
+   const InterpFrame *Frame,
+   const Function *Func) {
+  const Floating &Val = S.Stk.peek();
+
+  unsigned Index;
+  switch (Val.getCategory()) {
+  case APFloat::fcNaN:
+Index = 0;
+break;
+  case APFloat::fcInfinity:
+Index = 1;
+break;
+  case APFloat::fcNormal:
+Index = Val.isDenormal() ? 3 : 2;
+break;
+  case APFloat::fcZero:
+Index = 4;
+break;
+  }
+
+  // The last argument is first on the stack.
+  unsigned Offset = align(primSize(PT_Float)) +
+((1 + (4 - Index)) * align(primSize(PT_Sint32)));
+
+  const Integral<32, true> &I = S.Stk.peek>(Offset);
+  S.Stk.push>(I);
+  return true;
+}
+
 bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const Function *F) {
   InterpFrame *Frame = S.Current;
   APValue Dummy;
@@ -320,6 +351,10 @@
 if (interp__builtin_isfpclass(S, OpPC, Frame, F))
   return Ret(S, OpPC, Dummy);
 break;
+  case Builtin::BI__builtin_fpclassify:
+if (interp__builtin_fpclassify(S, OpPC, Frame, F))
+  return Ret(S, OpPC, Dummy);
+break;
 
   default:
 return false;
Index: clang/lib/AST/Interp/Floating.h
===
--- clang/lib/AST/Interp/Floating.h
+++ clang/lib/AST/Interp/Floating.h
@@ -97,7 +97,9 @@
   bool isInf() const { return F.isInfinity(); }
   bool isFinite() const { return F.isFinite(); }
   bool isNormal() const { return F.isNormal(); }
+  bool isDenormal() const { return F.isDenormal(); }
   llvm::FPClassTest classify() const { return F.classify(); }
+  APFloat::fltCategory getCategory() const { return F.getCategory(); }
 
   ComparisonCategoryResult compare(const Floating &RHS) const {
 return Compare(F, RHS.F);


Index: clang/test/AST/Interp/builtin-functions.cpp
===
--- clang/test/AST/Interp/builtin-functions.cpp
+++ clang/test/AST/Interp/builtin-functions.cpp
@@ -103,3 +103,17 @@
   char isfpclass_snan_2   [__builtin_isfpclass(__builtin_nansl(""), 0x0207) ? 1 : -1]; // ~fcFinite
   char isfpclass_snan_3   [!__builtin_isfpclass(__builtin_nans(""), 0x01F8) ? 1 : -1]; // fcFinite
 }
+
+namespace fpclassify {
+  char classify_nan [__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nan(""))];
+  char classify_snan[__builtin_fpclassify(+1, -1, -1, -1, -1, __builtin_nans(""))];
+  char classify_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, __builtin_inf())];
+  char classify_neg_inf [__builtin_fpclassify(-1, +1, -1, -1, -1, -__builtin_inf())];
+  char classify_normal  [__builtin_fpclassify(-1, -1, +1, -1, -1, 1.539)];
+  char classify_normal2 [__builtin_fpclassify(-1, -1, +1, -1, -1, 1e-307)];
+  char classify_denorm  [__builtin_fpclassify(-1, -1, -1, +1, -1, 1e-308)];
+  char classify_denorm2 [__builtin_fpclassify(-1, -1, -1, +1, -1, -1e-308)];
+  char classify_zero[__builtin_fpclassify(-1, -1, -1, -1, +1, 0.0)];
+

[PATCH] D145229: [analyzer] Improve the documentation of the alpha.security.taint.TaintPropagation checker

2023-07-25 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

Mostly LGTM, but I'd like to ask you to ensure consistent line wrapping (to 
e.g. 72 or 80 characters) in the free-flowing text that was added or rewritten 
by this commit. (I know that this is a minor question because the linebreaks 
won't be visible in the final output, but the raw markdown is itself a 
human-readable format and we should keep it reasonably clean.)


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

https://reviews.llvm.org/D145229

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


[clang] fae7b98 - [Support] Change SetVector's default template parameter to SmallVector<*, 0>

2023-07-25 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2023-07-25T00:39:17-07:00
New Revision: fae7b98c221b5b28797f7b56b656b6b819d99f27

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

LOG: [Support] Change SetVector's default template parameter to SmallVector<*, 
0>

Similar to D156016 for MapVector.

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
llvm/include/llvm/ADT/SetVector.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.cpp
mlir/include/mlir/Support/LLVM.h
mlir/lib/Analysis/SliceAnalysis.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 07a9dec12f6f25..908dec42afabeb 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2236,7 +2236,7 @@ static bool 
requiresMemberFunctionPointerTypeMetadata(CodeGenModule &CGM,
  !isa(MD);
 }
 
-std::vector
+SmallVector
 CodeGenModule::getMostBaseClasses(const CXXRecordDecl *RD) {
   llvm::SetVector MostBases;
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index f5fd94492540f2..c5de947687ea61 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1505,7 +1505,7 @@ class CodeGenModule : public CodeGenTypeCache {
   ///
   /// A most-base class of a class C is defined as a recursive base class of C,
   /// including C itself, that does not have any bases.
-  std::vector
+  SmallVector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
   /// Get the declaration of std::terminate for the platform.

diff  --git a/llvm/include/llvm/ADT/SetVector.h 
b/llvm/include/llvm/ADT/SetVector.h
index 781ca367b97e48..ff083556cf1694 100644
--- a/llvm/include/llvm/ADT/SetVector.h
+++ b/llvm/include/llvm/ADT/SetVector.h
@@ -23,10 +23,10 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
-#include 
 
 namespace llvm {
 
@@ -52,7 +52,7 @@ namespace llvm {
 /// when searching for elements instead of checking Set, due to it being better
 /// for performance. A value of 0 means that this mode of operation is not 
used,
 /// and is the default value.
-template ,
+template ,
   typename Set = DenseSet, unsigned N = 0>
 class SetVector {
   // Much like in SmallPtrSet, this value should not be too high to prevent

diff  --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp 
b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 2076ed48ea342a..775bb95fdda7b0 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -93,7 +93,7 @@ extern cl::opt ScalePartialSampleProfileWorkingSetSize;
 // instruction in it takes an address of any basic block, because instruction
 // can only take an address of basic block located in the same function.
 static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
- SetVector &RefEdges,
+ SetVector> 
&RefEdges,
  SmallPtrSet &Visited) {
   bool HasBlockAddress = false;
   SmallVector Worklist;
@@ -144,9 +144,12 @@ static bool isNonRenamableLocal(const GlobalValue &GV) {
 
 /// Determine whether this call has all constant integer arguments (excluding
 /// "this") and summarize it to VCalls or ConstVCalls as appropriate.
-static void addVCallToSet(DevirtCallSite Call, GlobalValue::GUID Guid,
-  SetVector &VCalls,
-  SetVector &ConstVCalls) 
{
+static void addVCallToSet(
+DevirtCallSite Call, GlobalValue::GUID Guid,
+SetVector>
+&VCalls,
+SetVector> &ConstVCalls) {
   std::vector Args;
   // Start from the second argument to skip the "this" pointer.
   for (auto &Arg : drop_begin(Call.CB.args())) {
@@ -163,11 +166,18 @@ static void addVCallToSet(DevirtCallSite Call, 
GlobalValue::GUID Guid,
 /// If this intrinsic call requires that we add information to the function
 /// summary, do so via the non-constant reference arguments.
 static void addIntrinsicToSummary(
-const CallInst *CI, SetVector &TypeTests,
-SetVector &TypeTestAssumeVCalls,
-SetVector &TypeCheckedLoadVCalls,
-SetVector &TypeTestAssumeConstVCalls,
-SetVector &TypeCheckedLoadConstVCalls,
+const CallInst *CI,
+SetVector> &TypeTests,
+SetVector>
+&TypeTestAssumeVCalls,
+SetVector>
+&TypeCheckedLoadVCalls,
+SetVector>
+&TypeTestAssumeConstVCalls,
+SetVector>
+&TypeCheckedLoadConstVCalls,
 DominatorTree &DT) {
   switch (CI->getCalledFunction()->getIntrinsicID()) {
   case Intrinsic::ty

[PATCH] D152793: [RISCV] Add MC layer support for Zicfiss.

2023-07-25 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 updated this revision to Diff 543857.
fakepaper56 added a comment.

Fix bugs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152793

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/zicfiss-invalid.s
  llvm/test/MC/RISCV/zicfiss-valid.s

Index: llvm/test/MC/RISCV/zicfiss-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/zicfiss-valid.s
@@ -0,0 +1,110 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zicfiss,+c -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zicfiss,+c < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zicfiss -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: ssload x1
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x1
+
+# CHECK-ASM-AND-OBJ: ssload x1
+# CHECK-ASM: encoding: [0xf3,0x40,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload ra
+
+# CHECK-ASM-AND-OBJ: ssload x5
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload x5
+
+# CHECK-ASM-AND-OBJ: ssload x5
+# CHECK-ASM: encoding: [0xf3,0x42,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssload t0
+
+# CHECK-ASM-AND-OBJ: sspopchk x1
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x1
+
+# CHECK-ASM-AND-OBJ: sspopchk x1
+# CHECK-ASM: encoding: [0x73,0xc0,0xc0,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk ra
+
+# CHECK-ASM-AND-OBJ: sspopchk x5
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk x5
+
+# CHECK-ASM-AND-OBJ: sspopchk x5
+# CHECK-ASM: encoding: [0x73,0xc0,0xc2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspopchk t0
+
+# CHECK-ASM-AND-OBJ: sspinc 4
+# CHECK-ASM: encoding: [0x73,0x40,0xd2,0x81]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspinc 4
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x1
+
+# CHECK-ASM-AND-OBJ: sspush ra
+# CHECK-ASM: encoding: [0x73,0x40,0x10,0x8a]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush ra
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush x5
+
+# check-asm-and-obj: sspush t0
+# check-asm: encoding: [0x73,0x40,0x50,0x8a]
+# check-no-ext: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+sspush t0
+
+# CHECK-ASM-AND-OBJ: ssprr ra
+# CHECK-ASM: encoding: [0xf3,0x40,0x00,0x86]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssprr ra
+
+# CHECK-ASM-AND-OBJ: ssamoswap t0, zero, (a0)
+# CHECK-ASM: encoding: [0xf3,0x42,0x05,0x82]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zicfiss' (Shadow stack)
+ssamoswap t0, x0, (a0)
+
+# CHECK-ASM-AND-OBJ: c.sspush x1
+# CHECK-ASM: encoding: [0x81,0x60]
+# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions), 'Zicfiss' (Shadow stack)
+c.sspush x1
+
+# CHECK-ASM-AND-OBJ: c.sspush x

[PATCH] D155574: [clang][ASTImporter] Fix import of recursive field initializer.

2023-07-25 Thread Ding Fei via Phabricator via cfe-commits
danix800 added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3936-3937
+return std::move(Err);
+  if (ToInitializer)
+ToField->setInClassInitializer(ToInitializer);
   return ToField;

Initializer could indirectly depends on this field and set the initializer 
while importing.
`setInClassInitializer()` asserts that initializer should not be set more than 
once:

```
static int ref_A();
static int ref_B();
struct A {
  int a = ref_B();
};
struct B {
  int b = ref_A();
};
int ref_B() { B b; return b.b; }
int ref_A() { A a; return a.a; }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155574

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


[PATCH] D144457: [clang][Interp] Handle global composite temporaries

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144457

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


[PATCH] D152132: [clang][Inter] Fix lifetime diagnostics for dead records

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152132

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


[PATCH] D153653: [clang][Interp] Make CXXTemporaryObjectExprs leave a value behind

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D153653

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


[PATCH] D153693: [clang][Interp] Handle InitListExprs of composite type

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153693

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


[PATCH] D153689: [clang][Interp] Handle CXXConstructExprs

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153689

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


[PATCH] D154189: [clang][Interp] Implement zero-init of record types

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154189

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


[PATCH] D154581: [clang][Interp] Track existing InitMaps in InterpState

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154581

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


[PATCH] D154951: [clang][Interp] __builtin_bit_cast, Take 2

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154951

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


[PATCH] D155270: [clang][Interp] Basic support for bit fields

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


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

https://reviews.llvm.org/D155270

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


[PATCH] D155548: [clang][ExprConst] Short-circuit ConstantExpr evaluation

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155548

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


[PATCH] D155572: [clang][Interp] Start implementing binary operators for complex types

2023-07-25 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155572

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


[PATCH] D145229: [analyzer] Improve the documentation of the alpha.security.taint.TaintPropagation checker

2023-07-25 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp updated this revision to Diff 543862.
dkrupp added a comment.

-lines wrapped to 80 characters


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

https://reviews.llvm.org/D145229

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2359,64 +2359,244 @@
 alpha.security.taint
 
 
-Checkers implementing `taint analysis `_.
+Checkers implementing
+`taint analysis `_.
 
 .. _alpha-security-taint-TaintPropagation:
 
 alpha.security.taint.TaintPropagation (C, C++)
 ""
 
-Taint analysis identifies untrusted sources of information (taint sources), rules as to how the untrusted data flows along the execution path (propagation rules), and points of execution where the use of tainted data is risky (taints sinks).
+Taint analysis identifies potential security vulnerabilities where the
+attacker can inject malicious data to the program to execute an attack
+(privilege escalation, command injection, SQL injection etc.).
+
+The malicious data is injected at the taint source (e.g. ``getenv()`` call)
+which is then propagated through function calls and being used as arguments of
+sensitive operations, also called as taint sinks (e.g. ``system()`` call).
+
+One can defend agains this type of vulnerability by always checking and
+santizing the potentially malicious, untrusted user input.
+
+The goal of the checker is to discover and show to the user these potential
+taint source-sink pairs and the propagation call chain.
+
 The most notable examples of taint sources are:
 
-  - network originating data
+  - data from network
+  - files or standard input
   - environment variables
-  - database originating data
+  - data from databases
 
-``GenericTaintChecker`` is the main implementation checker for this rule, and it generates taint information used by other checkers.
+Let us examine a practical example of a Command Injection attack.
 
 .. code-block:: c
 
- void test() {
-   char x = getchar(); // 'x' marked as tainted
-   system(&x); // warn: untrusted data is passed to a system call
- }
+  // Command Injection Vulnerability Example
+  int main(int argc, char** argv) {
+char cmd[2048] = "/bin/cat ";
+char filename[1024];
+printf("Filename:");
+scanf (" %1023[^\n]", filename); // The attacker can inject a shell escape here
+strcat(cmd, filename);
+system(cmd); // Warning: Untrusted data is passed to a system call
+  }
 
- // note: compiler internally checks if the second param to
- // sprintf is a string literal or not.
- // Use -Wno-format-security to suppress compiler warning.
- void test() {
-   char s[10], buf[10];
-   fscanf(stdin, "%s", s); // 's' marked as tainted
+The program prints the content of any user specified file.
+Unfortunately the attacker can execute arbitrary commands
+with shell escapes. For example with the following input the `ls` command is also
+executed after the contents of `/etc/shadow` is printed.
+`Input: /etc/shadow ; ls /`
 
-   sprintf(buf, s); // warn: untrusted data as a format string
- }
+The analysis implemented in this checker points out this problem.
 
- void test() {
-   size_t ts;
-   scanf("%zd", &ts); // 'ts' marked as tainted
-   int *p = (int *)malloc(ts * sizeof(int));
- // warn: untrusted data as buffer size
- }
+One can protect against such attack by for example checking if the provided
+input refers to a valid file and removing any invalid user input.
+
+.. code-block:: c
+
+  // No vulnerability anymore, but we still get the warning
+  void sanitizeFileName(char* filename){
+if (access(filename,F_OK)){// Verifying user input
+  printf("File does not exist\n");
+  filename[0]='\0';
+  }
+  }
+  int main(int argc, char** argv) {
+char cmd[2048] = "/bin/cat ";
+char filename[1024];
+printf("Filename:");
+scanf (" %1023[^\n]", filename); // The attacker can inject a shell escape here
+sanitizeFileName(filename);// filename is safe after this point
+if (!filename[0])
+  return -1;
+strcat(cmd, filename);
+system(cmd); // Superflous Warning: Untrusted data is passed to a system call
+  }
+
+Unfortunately, the checker cannot discover automatically that the programmer
+have performed data sanitation, so it still emits the warning.
 
-There are built-in sources, propagations and sinks defined in code inside ``GenericTaintChecker``.
-These operations are handled even if no external taint configuration is provided.
+One can get rid of this superflous warning by telling by specifying the
+sanitation functions in the taint configuation file (see
+:doc:`user-docs/TaintAnalysisConfiguration`).
 
-Default sources defined by ``GenericTaintChecker``:
- ``_IO_getc`

[PATCH] D156161: [clang-tidy] Add --enable-module-headers-parsing option

2023-07-25 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Do we want to keep the `experimental` word in the flag?




Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:266
 
+static cl::opt 
EnableModuleHeadersParsing("enable-module-headers-parsing",
+desc(R"(

--experimental-enable-module-headers-parsing



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:270
+for C++20 and above, empowering specific checks
+to detect macro definitions within modules.
+)"),

Should we document the implications/risks of enabling this, so people are 
informed? Also the fact that is experimental and subject to change.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:129
+  functionality using the newly added command line option
+  `--enable-module-headers-parsing`.
+

experimental


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156161

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


[PATCH] D156195: [docs] Add llvm & clang release notes for LoongArch

2023-07-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n added a comment.

Thank you (and your team, and of course other friends) for all your work this 
cycle!




Comment at: llvm/docs/ReleaseNotes.rst:202-203
 
+* Adds assembler/disassembler support for the ``LSX``, ``LASX``, ``LVZ`` and
+  ``LBT`` ISA extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.

The ISA extension acronyms are not identifiers here, so no need to format as 
inline code?



Comment at: llvm/docs/ReleaseNotes.rst:207
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model.
+* Several codegen improvements are made.

I'd suggest mentioning the GCC equivalent, in case people wonder. 
(`-mcmodel=large` is unimplemented GCC-side AFAIK.)



Comment at: llvm/docs/ReleaseNotes.rst:208
+* Adds support for the ``large`` code model.
+* Several codegen improvements are made.
 

"Assorted codegen improvements" sounds more attractive? ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156195

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


[PATCH] D156184: [OpenMP] Add the `ompx_attribute` clause for target directives

2023-07-25 Thread antoine moynault via Phabricator via cfe-commits
antmo added a comment.

Hi, it looks like this patch broke some flang bots:

- https://lab.llvm.org/buildbot/#/builders/176/builds/3408
- https://lab.llvm.org/buildbot/#/builders/198/builds/4028
- https://lab.llvm.org/buildbot/#/builders/197/builds/8491
- https://lab.llvm.org/buildbot/#/builders/197/builds/8491

Could you please take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156184

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


[clang] 9dcd232 - [clang][driver][NFC] Call IsARMBigEndain function only for isARM and isThumb.

2023-07-25 Thread Simi Pallipurath via cfe-commits

Author: Simi Pallipurath
Date: 2023-07-25T09:20:59+01:00
New Revision: 9dcd232f4afabdad46e5bc2d71834765acd7738c

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

LOG: [clang][driver][NFC] Call IsARMBigEndain function only for isARM and 
isThumb.

IsARMBIgEndian function returns true only if:
  1. The triples are either arm or thumb and the
 commandline has the  option -mbig-endian
  2. The triples are either armeb or thumbeb.

Missing the checking of arm or thumb triples in the
first case pass through the --be8 endian flag to
linker For AArch64 as well which is not expected.
This is the regression happened from the previous
patch https://reviews.llvm.org/D154786.

It is better to refactor to only call IsARMBigEndian
for isARM and isthumb satisfying conditions which
keeps ARM and AArch64 separate.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/Gnu.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/BareMetal.cpp 
b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 0d9a103328c130..26a6276ae50aa1 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -443,12 +443,13 @@ void baremetal::Linker::ConstructJob(Compilation &C, 
const JobAction &JA,
 
   CmdArgs.push_back("-Bstatic");
 
-  if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
+  if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
   arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
-IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
+  } else if (Triple.isAArch64()) {
+CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
   Args.AddAllArgs(CmdArgs,

diff  --git a/clang/lib/Driver/ToolChains/Gnu.cpp 
b/clang/lib/Driver/ToolChains/Gnu.cpp
index b58a607d5921cb..b64fff8b14be8a 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -424,12 +424,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation 
&C, const JobAction &JA,
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("-s");
 
-  if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
+  if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
   arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
-IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
+  } else if (Triple.isAArch64()) {
+CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
   // Most Android ARM64 targets should enable the linker fix for erratum



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


[PATCH] D155808: [clang][driver][NFC] Call IsARMBigEndain function only for isARM and isThumb.

2023-07-25 Thread Simi Pallipurath 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 rG9dcd232f4afa: [clang][driver][NFC] Call IsARMBigEndain 
function only for isARM and isThumb. (authored by simpal01).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155808

Files:
  clang/lib/Driver/ToolChains/BareMetal.cpp
  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
@@ -424,12 +424,13 @@
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("-s");
 
-  if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
+  if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
   arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
-IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
+  } else if (Triple.isAArch64()) {
+CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
   // Most Android ARM64 targets should enable the linker fix for erratum
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -443,12 +443,13 @@
 
   CmdArgs.push_back("-Bstatic");
 
-  if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
+  if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
   arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
-IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
+  } else if (Triple.isAArch64()) {
+CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
   Args.AddAllArgs(CmdArgs,


Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -424,12 +424,13 @@
   if (Args.hasArg(options::OPT_s))
 CmdArgs.push_back("-s");
 
-  if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
+  if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
   arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
-IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
+  } else if (Triple.isAArch64()) {
+CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
   // Most Android ARM64 targets should enable the linker fix for erratum
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -443,12 +443,13 @@
 
   CmdArgs.push_back("-Bstatic");
 
-  if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) {
+  if (Triple.isARM() || Triple.isThumb()) {
 bool IsBigEndian = arm::isARMBigEndian(Triple, Args);
 if (IsBigEndian)
   arm::appendBE8LinkFlag(Args, CmdArgs, Triple);
-IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be;
 CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL");
+  } else if (Triple.isAArch64()) {
+CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL");
   }
 
   Args.AddAllArgs(CmdArgs,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151547: [RISCV] Remove experimental for zihintntl.

2023-07-25 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

In D151547#4531062 , @jacquesguan 
wrote:

> https://github.com/riscv-non-isa/riscv-c-api-doc/pull/47 is already merged, 
> any more advice about this patch?

Just that it needs a release note, and we need the newly defined overloaded 
form of the intrinsics to be supported.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151547

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


[PATCH] D142660: [AIX] supporting -X options for llvm-ranlib in AIX OS

2023-07-25 Thread James Henderson via Phabricator via cfe-commits
jhenderson added inline comments.



Comment at: llvm/test/tools/llvm-ranlib/aix-X-option.test:17-18
+## Test the OBJECT_MODE environment variable when adding symbol table.
+# RUN: unset OBJECT_MODE
+# RUN: llvm-ranlib t_X32.a
+# RUN: llvm-nm --print-armap t_X32.a 2>&1 | FileCheck --check-prefixes=GLOB32 
--implicit-check-not="in t64" %s

Assuming the unsetting is intended to be just for the llvm-ranlib line, I 
believe the preferred approach is `env -u OBJECT_MODE llvm-ranlib ...`. That 
way, you don't impact the behaviour in subsequent lines.



Comment at: llvm/test/tools/llvm-ranlib/aix-X-option.test:31
+
+## Test -X option when adding symbol table.
+# RUN: llvm-ranlib -X32 t_X32.a

jhenderson wrote:
> 
Marked as done but not addressed? Please don't do that...



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:74-75
+ << "  -X {32|64|32_64}  - Specifies which archive symbol tables "
+"should"
+"be generated if they do not already exist (AIX OS only)\n";
 }

DiggerLin wrote:
> jhenderson wrote:
> > Please reflow this string. That should make it fairly obvious that there's 
> > a mistake in it too (hint: print the help and spot the missing space...).
> thanks
You didn't actually reflow the string. I believe the following is more correct 
(I haven't checked the column width, so make sure to run clang-format 
afterwards:

```
"should be generated if they do not already exist (AIX OS only)\n";
```



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:1442
+
+// -X option in ranlib do not accept "any"
+if (BitMode == BitModeTy::Unknown || BitMode == BitModeTy::Any)

DiggerLin wrote:
> jhenderson wrote:
> > I know that AIX ranlib doesn't accept "any" whereas I believe AIX ar does. 
> > I wonder though what the benefit is of preventing llvm-ranlib from 
> > accepting "any"? Dropping that special case would simplify the code.
> agree with you. but we discussed about whether to accept `any` in our 
> internal , we decide to keep all the behavior  as AIX `ranlib`
> we decide to keep all the behavior as AIX ranlib

We aren't in your internal company here. This is the open source community, 
therefore you need to be able to justify your decisions in the open source 
conversation. What reason is there to keep rejecting this in llvm-ranlib? 
Perhaps worth asking yourself is "if we could control it, why would we keep 
that behaviour in AIX ranlib?".



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:1463
 
+  if (object::Archive::getDefaultKindForHost() == object::Archive::K_AIXBIG) {
+// If not specify -X option, get BitMode from enviorment variable

DiggerLin wrote:
> jhenderson wrote:
> > Is there a particular reason that this is after the command-line option 
> > parsing for llvm-ranlib, but before it in llvm-ar? If this were before the 
> > option parsing, you wouldn't need the `HasAixXOption` variable.
> in AIX OS  `ranlib` has behavior as
> 
> 
> ```
> -bash-5.0$ env OBJECT_MODE=31 ranlib tmpk.a
> 0654-603 The OBJECT_MODE environment variable has an invalid setting.
> OBJECT_MODE must be 32, 64, or 32_64.
> -bash-5.0$ env OBJECT_MODE=31 ranlib -X32  tmpk.a
> -bash-5.0$
> ```  
> 
> Given invalid env OBJECT_MODE , if there is no -X option in the ranlib 
> command, it will output as 
> 
> ```
> 0654-603 The OBJECT_MODE environment variable has an invalid setting.
> OBJECT_MODE must be 32, 64, or 32_64.
> ```
> 
> Given invalid env OBJECT_MODE , and there is -X option in the ranlib command, 
>  it do not care about the invalid env OBJECT_MODE,  So I has to parse the -X 
> option before the getBitMode(getenv("OBJECT_MODE"))
> 
So with AIX ar, does an invalid OBJECT_MODE environment variable get reported 
if the -X option is specified?

In my opinion, I think it is very unlikely there will be any real users out 
there with an invalid OBJECT_MODE environment variable, because other tools 
will reject it, even if ranlib doesn't. Even if there are, they should be able 
to easily fix their variable, if they start getting an error message after 
switching to llvm-ranlib. I'm therefore thinking that there isn't a need to 
mirror this logic in llvm-ranlib, if it would make the code simpler (which it 
would).



Comment at: llvm/tools/llvm-ar/llvm-ar.cpp:237
 static bool Verbose = false;  ///< 'v' modifier
-static bool Symtab = true;///< 's' modifier
+static WriteSymTabType Symtab = true; ///< 's' modifier
 static bool Deterministic = true; ///< 'D' and 'U' modifiers

DiggerLin wrote:
> jhenderson wrote:
> > DiggerLin wrote:
> > > jhenderson wrote:
> > > > Maybe I'm missing something, but I don't see why you need to make this 
> > > > a custom type. You already have the BitMode value that you read in from 
> > > > the envir

[PATCH] D156205: wasm: link crt1 even in case of -shared

2023-07-25 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

I think we are vearing into somewhat uncharted territory here, but we should 
probably push forward and document the direction we choose.

Should `-shared` modules also link with `crt1-reactor.o` by default then?   Or 
should we add `crt1-shared.o` and use the whenever `-shared` is passed.  Should 
we also make `-shared` incompatible with `-mexec-model`?  It seems like 
`-mexec-model` should only apply to the main module, and not to the shared 
library that it loads.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156205

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


[PATCH] D156214: [LLVM][RISCV] Check more extension dependencies

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

This patch addresses two TODOs in `RISCVISAInfo::checkDependency`:

- Report error when both `e` and `f` (or `d`) extensions are specified in 
`-march`
- Report error when `q` extension is specified when `rv64` is unavailable
- Corresponding unit tests are also updated

Currently, I cannot add a test about the `q` extension case because there's no 
`q` extension registered in either supported extensions or experimental 
extensions,
but the code added here should work fine if we have a proper `q` implementation 
in the future.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156214

Files:
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/unittests/Support/RISCVISAInfoTest.cpp


Index: llvm/unittests/Support/RISCVISAInfoTest.cpp
===
--- llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -474,6 +474,17 @@
 EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
   "'zcf' is only supported for 'rv32'");
   }
+
+  for (StringRef Input : {"rv64efd", "rv32efd", "rv64ed", "rv32ed"}) {
+EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+  "'e' extension is incompatible with 'f' extension"
+  " and 'd' extension");
+  }
+
+  for (StringRef Input : {"rv64ef", "rv32ef"}) {
+EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+  "'e' extension is incompatible with 'f' extension");
+  }
 }
 
 TEST(ToFeatureVector, IIsDroppedAndExperimentalExtensionsArePrefixed) {
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -895,6 +895,7 @@
 Error RISCVISAInfo::checkDependency() {
   bool HasC = Exts.count("c") != 0;
   bool HasF = Exts.count("f") != 0;
+  bool HasD = Exts.count("d") != 0;
   bool HasZfinx = Exts.count("zfinx") != 0;
   bool HasVector = Exts.count("zve32x") != 0;
   bool HasZvl = MinVLen != 0;
@@ -931,7 +932,7 @@
 errc::invalid_argument,
 "'zvknhb' requires 'v' or 'zve64*' extension to also be specified");
 
-  if ((HasZcmt || Exts.count("zcmp")) && Exts.count("d") &&
+  if ((HasZcmt || Exts.count("zcmp")) && HasD &&
   (HasC || Exts.count("zcd")))
 return createStringError(
 errc::invalid_argument,
@@ -944,8 +945,17 @@
  "'zcf' is only supported for 'rv32'");
 
   // Additional dependency checks.
-  // TODO: The 'q' extension requires rv64.
-  // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'.
+  // The 'q' extension requires rv64.
+  if (XLen != 64 && Exts.count("q"))
+return createStringError(errc::invalid_argument,
+ "'q' extension is only supported for 'rv64'");
+
+  // It is illegal to specify 'e' extensions with 'f' and 'd'.
+  if (Exts.count("e") && (HasF || HasD))
+return createStringError(
+errc::invalid_argument,
+Twine("'e' extension is incompatible with ") +
+(HasD ? "'f' extension and 'd' extension" : "'f' extension"));
 
   return Error::success();
 }
Index: clang/test/Driver/riscv-arch.c
===
--- clang/test/Driver/riscv-arch.c
+++ clang/test/Driver/riscv-arch.c
@@ -541,3 +541,14 @@
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-D-ZDINX-ER %s
 // RV32-D-ZDINX-ER: error: invalid arch name 'rv32idzdinx',
 // RV32-D-ZFINX-ER: 'f' and 'zfinx' extensions are incompatible
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32ef -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EF-BADVARS %s
+// RV32-EF-BADVARS: error: invalid arch name 'rv32ef',
+// RV32-EF-BADVARS: 'e' extension is incompatible with 'f' extension
+
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32ed -### %s \
+// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ED-BADVARS %s
+// RV32-ED-BADVARS: error: invalid arch name 'rv32ed',
+// RV32-ED-BADVARS: 'e' extension is incompatible with 'f' extension and 'd' 
extension
+


Index: llvm/unittests/Support/RISCVISAInfoTest.cpp
===
--- llvm/unittests/Support/RISCVISAInfoTes

[PATCH] D146368: [clang-tidy] Add readability-reference-to-constructed-temporary check

2023-07-25 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:20
+
+struct NotExtendedByDeclBoundToPredicate {
+  bool operator()(const internal::BoundNodesMap &Nodes) const {

A comment might be good to describe this struct.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:22
+  bool operator()(const internal::BoundNodesMap &Nodes) const {
+const auto *Other = Nodes.getNode(ID).get();
+if (!Other)

This can be written as `const auto *Other = Nodes.getNodeAs(ID);` 
following other patterns.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:39
+  ID) {
+  NotExtendedByDeclBoundToPredicate Predicate;
+  Predicate.ID = ID;

Can be written using direct initialization as  
`NotExtendedByDeclBoundToPredicate Predicate{ID};`



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:63
+
+bool ReferenceToConstructedTemporaryCheck::isLanguageVersionSupported(
+const LangOptions &LangOpts) const {

This part looks like boilerplate in the middle of a specific implementation., 
`isLanguageVersionSupported` is mostly in the header file.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:69
+std::optional
+ReferenceToConstructedTemporaryCheck::getCheckTraversalKind() const {
+  return TK_AsIs;

This part look like boilerplate in the middle of a specific implementation., 
getCheckTraversalKind() is mostly in the header file.





Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst:10
+This construction is often the result of multiple code refactorings or a lack
+of developer knowledge, leading to confusion or subtle bugs. In most cases,
+what the developer really wanted to do is create a new variable rather than

May be good to mention dangling references and resource leakage as potential 
issues.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst:18
+
+   const std::string& value("hello");
+

The below comment is not matching,  do you want to write - 
`const std::string& str = std::string("hello");`
?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146368

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


[PATCH] D156195: [docs] Add llvm & clang release notes for LoongArch

2023-07-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 543867.
SixWeining added a comment.
Herald added a reviewer: alexander-shaposhnikov.

Address @xen0n's comments and add some more recordable updates.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156195

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,14 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA 
extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's 
``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
+* Several more sanitizers are now ported to LoongArch: MSan DFsan Profile XRay 
libFuzzer.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in 
inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,14 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's ``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
+* Several more sanitizers are now ported to LoongArch: MSan DFsan Profile XRay libFuzzer.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156161: [clang-tidy] Add --enable-module-headers-parsing option

2023-07-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:266
 
+static cl::opt 
EnableModuleHeadersParsing("enable-module-headers-parsing",
+desc(R"(

carlosgalvezp wrote:
> --experimental-enable-module-headers-parsing
I removed 'experimental' because it were messing with the --help output, were 
causing it be very wide. 
And it's no longer hidden option now. so should it be hidden & experimental ? 
Or non hidden...



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:270
+for C++20 and above, empowering specific checks
+to detect macro definitions within modules.
+)"),

carlosgalvezp wrote:
> Should we document the implications/risks of enabling this, so people are 
> informed? Also the fact that is experimental and subject to change.
Something like "May cause performance & parsing issues, and therefore is 
considered experimental." ? I'ts fine with me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156161

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


[PATCH] D156205: wasm: link crt1 even in case of -shared

2023-07-25 Thread YAMAMOTO Takashi via Phabricator via cfe-commits
yamt added a comment.

> Should -shared modules also link with crt1-reactor.o by default then? Or 
> should we add crt1-shared.o and use the whenever -shared is passed. Should we 
> also make -shared incompatible with -mexec-model? It seems like -mexec-model 
> should only apply to the main module, and not to the shared library that it 
> loads.

wasi reactor model is for libraries.
i feel it's natural to make it cover shared libraries as well.

but i agree it can be done as you described too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156205

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


[clang] 86da763 - [Clang] Fix crash in CIndex, when visiting a static_assert without message

2023-07-25 Thread Corentin Jabot via cfe-commits

Author: Kai Stierand
Date: 2023-07-25T10:53:14+02:00
New Revision: 86da763ab6ed19c58349d3f6f62d4bb52becab2c

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

LOG: [Clang] Fix crash in CIndex, when visiting a static_assert without message

After implementation of "[Clang] Implement P2741R3 - user-generated 
static_assert messages"  (47ccfd7a89e2a9a747a7114db18db1376324799c) the c 
indexer crashes when handling a `static_assert` w/o any message.
This is caused by using `dyn_cast` to get the literal string, which isn't 
working on `nullptr`.

Reviewed By: cor3ntin

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

Added: 


Modified: 
clang/tools/libclang/CIndex.cpp
clang/unittests/libclang/LibclangTest.cpp
clang/unittests/libclang/TestUtils.h

Removed: 




diff  --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp
index 120ad4ea39e1a9..1bdc0bf742a8ce 100644
--- a/clang/tools/libclang/CIndex.cpp
+++ b/clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@ bool CursorVisitor::VisitUnresolvedUsingTypenameDecl(
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, 
RegionOfInterest)))
 return true;
-  if (auto *Message = dyn_cast(D->getMessage()))
+  if (auto *Message = D->getMessage())
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;

diff  --git a/clang/unittests/libclang/LibclangTest.cpp 
b/clang/unittests/libclang/LibclangTest.cpp
index f85a72b1c2f702..b1f653441d0efe 100644
--- a/clang/unittests/libclang/LibclangTest.cpp
+++ b/clang/unittests/libclang/LibclangTest.cpp
@@ -1172,6 +1172,80 @@ TEST_F(LibclangParseTest, UnaryOperator) {
   });
 }
 
+TEST_F(LibclangParseTest, VisitStaticAssertDecl_noMessage) {
+  const char testSource[] = R"cpp(static_assert(true))cpp";
+  std::string fileName = "main.cpp";
+  WriteFile(fileName, testSource);
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args, 1,
+   nullptr, 0, TUFlags);
+
+  std::optional staticAssertCsr;
+  Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_StaticAssert) {
+  staticAssertCsr.emplace(cursor);
+  return CXChildVisit_Break;
+}
+return CXChildVisit_Recurse;
+  });
+  ASSERT_TRUE(staticAssertCsr.has_value());
+  Traverse(*staticAssertCsr, [](CXCursor cursor, CXCursor parent) {
+EXPECT_EQ(cursor.kind, CXCursor_CXXBoolLiteralExpr);
+return CXChildVisit_Break;
+  });
+  EXPECT_EQ(fromCXString(clang_getCursorSpelling(*staticAssertCsr)), "");
+}
+
+TEST_F(LibclangParseTest, VisitStaticAssertDecl_exprMessage) {
+  const char testSource[] = R"cpp(
+template 
+constexpr unsigned size(const char (&)[s])
+{
+return s - 1;
+}
+
+struct Message {
+static constexpr char message[] = "Hello World!";
+constexpr const char* data() const { return message;}
+constexpr unsigned size() const
+{
+return ::size(message);
+}
+};
+Message message;
+static_assert(true, message);
+)cpp";
+  std::string fileName = "main.cpp";
+  WriteFile(fileName, testSource);
+  const char *Args[] = {"-xc++", "-std=c++26"};
+  ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
+   std::size(Args), nullptr, 0, TUFlags);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  std::optional staticAssertCsr;
+  Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_StaticAssert) {
+  staticAssertCsr.emplace(cursor);
+}
+return CXChildVisit_Continue;
+  });
+  ASSERT_TRUE(staticAssertCsr.has_value());
+  size_t argCnt = 0;
+  Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
+switch (argCnt) {
+case 0:
+  EXPECT_EQ(cursor.kind, CXCursor_CXXBoolLiteralExpr);
+  break;
+case 1:
+  EXPECT_EQ(cursor.kind, CXCursor_DeclRefExpr);
+  break;
+}
+++argCnt;
+return CXChildVisit_Continue;
+  });
+  ASSERT_EQ(argCnt, 2);
+  EXPECT_EQ(fromCXString(clang_getCursorSpelling(*staticAssertCsr)), "");
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;

diff  --git a/clang/unittests/libclang/TestUtils.h 
b/clang/unittests/libclang/TestUtils.h
index c78351d4afd200..013aad17358211 100644
--- a/clang/unittests/libclang/TestUtils.h
+++ b/clang/unittests/libclang/TestUtils.h
@@ -87,14 +87,18 @@ class LibclangParseTest : public ::testing::Test {
 it.first->second->size()// length
 });
   }
-  template
-  void Traverse(const F &TraversalFunctor) {
-CXCursor TuCursor = clang_getTranslation

[PATCH] D155370: [CodeComplete] Improve FunctionCanBeCall

2023-07-25 Thread Younan Zhang via Phabricator via cfe-commits
zyounan added inline comments.



Comment at: clang/lib/Sema/SemaCodeComplete.cpp:1407
 
   R.FunctionCanBeCall =
   CurrentClassScope &&

The current heuristic results in the following:

```
struct Base {
  void foo(int);
};
struct Derived : Base {
  void foo(float);
};

int main() {
  Derived d;
  d.Base::^// FunctionCanBeCall for `foo` is false.
}
```

In situations where it is intended to invoke base member functions hidden by 
subclasses, we shouldn't remove parentheses, IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155370

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


[PATCH] D156053: [Clang] Fix crash in CIndex, when visiting a static_assert without message

2023-07-25 Thread Corentin Jabot 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 rG86da763ab6ed: [Clang] Fix crash in CIndex, when visiting a 
static_assert without message (authored by kiloalphaindia, committed by 
cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156053

Files:
  clang/tools/libclang/CIndex.cpp
  clang/unittests/libclang/LibclangTest.cpp
  clang/unittests/libclang/TestUtils.h

Index: clang/unittests/libclang/TestUtils.h
===
--- clang/unittests/libclang/TestUtils.h
+++ clang/unittests/libclang/TestUtils.h
@@ -87,14 +87,18 @@
 it.first->second->size()// length
 });
   }
-  template
-  void Traverse(const F &TraversalFunctor) {
-CXCursor TuCursor = clang_getTranslationUnitCursor(ClangTU);
+  template 
+  void Traverse(const CXCursor &cursor, const F &TraversalFunctor) {
 std::reference_wrapper FunctorRef = std::cref(TraversalFunctor);
-clang_visitChildren(TuCursor,
-&TraverseStateless>,
-&FunctorRef);
+clang_visitChildren(cursor,
+&TraverseStateless>,
+&FunctorRef);
   }
+
+  template  void Traverse(const F &TraversalFunctor) {
+Traverse(clang_getTranslationUnitCursor(ClangTU), TraversalFunctor);
+  }
+
   static std::string fromCXString(CXString cx_string) {
 std::string string{clang_getCString(cx_string)};
 clang_disposeString(cx_string);
Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1172,6 +1172,80 @@
   });
 }
 
+TEST_F(LibclangParseTest, VisitStaticAssertDecl_noMessage) {
+  const char testSource[] = R"cpp(static_assert(true))cpp";
+  std::string fileName = "main.cpp";
+  WriteFile(fileName, testSource);
+  const char *Args[] = {"-xc++"};
+  ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args, 1,
+   nullptr, 0, TUFlags);
+
+  std::optional staticAssertCsr;
+  Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_StaticAssert) {
+  staticAssertCsr.emplace(cursor);
+  return CXChildVisit_Break;
+}
+return CXChildVisit_Recurse;
+  });
+  ASSERT_TRUE(staticAssertCsr.has_value());
+  Traverse(*staticAssertCsr, [](CXCursor cursor, CXCursor parent) {
+EXPECT_EQ(cursor.kind, CXCursor_CXXBoolLiteralExpr);
+return CXChildVisit_Break;
+  });
+  EXPECT_EQ(fromCXString(clang_getCursorSpelling(*staticAssertCsr)), "");
+}
+
+TEST_F(LibclangParseTest, VisitStaticAssertDecl_exprMessage) {
+  const char testSource[] = R"cpp(
+template 
+constexpr unsigned size(const char (&)[s])
+{
+return s - 1;
+}
+
+struct Message {
+static constexpr char message[] = "Hello World!";
+constexpr const char* data() const { return message;}
+constexpr unsigned size() const
+{
+return ::size(message);
+}
+};
+Message message;
+static_assert(true, message);
+)cpp";
+  std::string fileName = "main.cpp";
+  WriteFile(fileName, testSource);
+  const char *Args[] = {"-xc++", "-std=c++26"};
+  ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
+   std::size(Args), nullptr, 0, TUFlags);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  std::optional staticAssertCsr;
+  Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
+if (cursor.kind == CXCursor_StaticAssert) {
+  staticAssertCsr.emplace(cursor);
+}
+return CXChildVisit_Continue;
+  });
+  ASSERT_TRUE(staticAssertCsr.has_value());
+  size_t argCnt = 0;
+  Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
+switch (argCnt) {
+case 0:
+  EXPECT_EQ(cursor.kind, CXCursor_CXXBoolLiteralExpr);
+  break;
+case 1:
+  EXPECT_EQ(cursor.kind, CXCursor_DeclRefExpr);
+  break;
+}
+++argCnt;
+return CXChildVisit_Continue;
+  });
+  ASSERT_EQ(argCnt, 2);
+  EXPECT_EQ(fromCXString(clang_getCursorSpelling(*staticAssertCsr)), "");
+}
+
 class LibclangRewriteTest : public LibclangParseTest {
 public:
   CXRewriter Rew = nullptr;
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1294,7 +1294,7 @@
 bool CursorVisitor::VisitStaticAssertDecl(StaticAssertDecl *D) {
   if (Visit(MakeCXCursor(D->getAssertExpr(), StmtParent, TU, RegionOfInterest)))
 return true;
-  if (auto *Message = dyn_cast(D->getMessage()))
+  if (auto *Message = D->getMessage())
 if (Visit(MakeCXCursor(Message, StmtParent, TU, RegionOfInterest)))
   return true;
   return false;
__

[clang] 4cf11d8 - [Clang][SVE] Permit specific predicate-as-counter registers in inline assembly

2023-07-25 Thread David Sherwood via cfe-commits

Author: David Sherwood
Date: 2023-07-25T08:55:45Z
New Revision: 4cf11d8a65dfded59761ec52804a86277b9c0036

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

LOG: [Clang][SVE] Permit specific predicate-as-counter registers in inline 
assembly

This patch adds the predicate-as-counter registers pn0-pn15 to the
list of supported registers used when writing inline assembly.

Tests added to

  clang/test/CodeGen/aarch64-sve-inline-asm.c

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-sve-inline-asm.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index ed0246d6faee16..7c4cc5fb33f886 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1164,7 +1164,11 @@ const char *const AArch64TargetInfo::GCCRegNames[] = {
 
 // SVE predicate registers
 "p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  
"p10",
-"p11", "p12", "p13", "p14", "p15"
+"p11", "p12", "p13", "p14", "p15",
+
+// SVE predicate-as-counter registers
+"pn0",  "pn1",  "pn2",  "pn3",  "pn4",  "pn5",  "pn6",  "pn7",  "pn8",
+"pn9",  "pn10", "pn11", "pn12", "pn13", "pn14", "pn15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {

diff  --git a/clang/test/CodeGen/aarch64-sve-inline-asm.c 
b/clang/test/CodeGen/aarch64-sve-inline-asm.c
index 8f26680e08f4c5..428aa32e7f98d3 100644
--- a/clang/test/CodeGen/aarch64-sve-inline-asm.c
+++ b/clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2p1 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2p1 \
+// RUN:   -S -o /dev/null
 
 void test_sve_asm(void) {
   asm volatile(
@@ -9,5 +13,16 @@ void test_sve_asm(void) {
   :
   :
   : "z0", "z31", "p0", "p15");
+  // CHECK-LABEL: @test_sve_asm
   // CHECK: "~{z0},~{z31},~{p0},~{p15}"
 }
+
+void test_sve2p1_asm(void) {
+  asm("pfalse pn0.b\n"
+  "ptrue pn8.d\n"
+  "ptrue pn15.b\n"
+  "pext p3.b, pn8[1]\n"
+  ::: "pn0", "pn8", "pn15", "p3");
+  // CHECK-LABEL: @test_sve2p1_asm
+  // CHECK: "~{pn0},~{pn8},~{pn15},~{p3}"
+}



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


[PATCH] D156115: [Clang][SVE] Permit specific predicate-as-counter registers in inline assembly

2023-07-25 Thread David Sherwood 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 rG4cf11d8a65df: [Clang][SVE] Permit specific 
predicate-as-counter registers in inline assembly (authored by david-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156115

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-sve-inline-asm.c


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- clang/test/CodeGen/aarch64-sve-inline-asm.c
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | 
FileCheck %s -check-prefix=CHECK
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2p1 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve 
-target-feature +sve2p1 \
+// RUN:   -S -o /dev/null
 
 void test_sve_asm(void) {
   asm volatile(
@@ -9,5 +13,16 @@
   :
   :
   : "z0", "z31", "p0", "p15");
+  // CHECK-LABEL: @test_sve_asm
   // CHECK: "~{z0},~{z31},~{p0},~{p15}"
 }
+
+void test_sve2p1_asm(void) {
+  asm("pfalse pn0.b\n"
+  "ptrue pn8.d\n"
+  "ptrue pn15.b\n"
+  "pext p3.b, pn8[1]\n"
+  ::: "pn0", "pn8", "pn15", "p3");
+  // CHECK-LABEL: @test_sve2p1_asm
+  // CHECK: "~{pn0},~{pn8},~{pn15},~{p3}"
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -1164,7 +1164,11 @@
 
 // SVE predicate registers
 "p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  
"p10",
-"p11", "p12", "p13", "p14", "p15"
+"p11", "p12", "p13", "p14", "p15",
+
+// SVE predicate-as-counter registers
+"pn0",  "pn1",  "pn2",  "pn3",  "pn4",  "pn5",  "pn6",  "pn7",  "pn8",
+"pn9",  "pn10", "pn11", "pn12", "pn13", "pn14", "pn15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {


Index: clang/test/CodeGen/aarch64-sve-inline-asm.c
===
--- clang/test/CodeGen/aarch64-sve-inline-asm.c
+++ clang/test/CodeGen/aarch64-sve-inline-asm.c
@@ -1,4 +1,8 @@
-// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +sve2p1 \
+// RUN:   -emit-llvm -o - %s | FileCheck %s -check-prefix=CHECK
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +sve2p1 \
+// RUN:   -S -o /dev/null
 
 void test_sve_asm(void) {
   asm volatile(
@@ -9,5 +13,16 @@
   :
   :
   : "z0", "z31", "p0", "p15");
+  // CHECK-LABEL: @test_sve_asm
   // CHECK: "~{z0},~{z31},~{p0},~{p15}"
 }
+
+void test_sve2p1_asm(void) {
+  asm("pfalse pn0.b\n"
+  "ptrue pn8.d\n"
+  "ptrue pn15.b\n"
+  "pext p3.b, pn8[1]\n"
+  ::: "pn0", "pn8", "pn15", "p3");
+  // CHECK-LABEL: @test_sve2p1_asm
+  // CHECK: "~{pn0},~{pn8},~{pn15},~{p3}"
+}
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -1164,7 +1164,11 @@
 
 // SVE predicate registers
 "p0",  "p1",  "p2",  "p3",  "p4",  "p5",  "p6",  "p7",  "p8",  "p9",  "p10",
-"p11", "p12", "p13", "p14", "p15"
+"p11", "p12", "p13", "p14", "p15",
+
+// SVE predicate-as-counter registers
+"pn0",  "pn1",  "pn2",  "pn3",  "pn4",  "pn5",  "pn6",  "pn7",  "pn8",
+"pn9",  "pn10", "pn11", "pn12", "pn13", "pn14", "pn15"
 };
 
 ArrayRef AArch64TargetInfo::getGCCRegNames() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156195: [docs] Add llvm & clang release notes for LoongArch

2023-07-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 543876.
SixWeining added a comment.

Move sanitizer changes to clang side.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156195

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA 
extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's 
``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in 
inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
@@ -1095,6 +1097,7 @@
 
 Sanitizers
 --
+- Several more sanitizers are now ported to LoongArch: MSan, DFsan, Profile, 
XRay and libFuzzer.
 
 Python Binding Changes
 --


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's ``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
@@ -1095,6 +1097,7 @@
 
 Sanitizers
 --
+- Several more sanitizers are now ported to LoongArch: MSan, DFsan, Profile, XRay and libFuzzer.
 
 Python Binding Changes
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156195: [docs] Add llvm & clang release notes for LoongArch

2023-07-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n accepted this revision.
xen0n added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156195

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


[clang] 6223050 - [docs] Add llvm & clang release notes for LoongArch

2023-07-25 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-07-25T17:06:12+08:00
New Revision: 6223050db88bc5b41c13a593de67554d1e3b72ae

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

LOG: [docs] Add llvm & clang release notes for LoongArch

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ae2a298d7f439a..0e711cbbd84f33 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@ LoongArch Support
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in 
inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
@@ -1095,6 +1097,7 @@ Static Analyzer
 
 Sanitizers
 --
+- Several more sanitizers are now ported to LoongArch: MSan, DFsan, Profile, 
XRay and libFuzzer.
 
 Python Binding Changes
 --

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index a1b8ff734d41a0..a04cbd2df10b09 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@ Changes to the Hexagon Backend
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA 
extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's 
``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
 
 Changes to the MIPS Backend
 ---



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


[PATCH] D156195: [docs] Add llvm & clang release notes for LoongArch

2023-07-25 Thread Lu Weining 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 rG6223050db88b: [docs] Add llvm & clang release notes for 
LoongArch (authored by SixWeining).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156195

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA 
extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal 
target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's 
``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in 
inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
@@ -1095,6 +1097,7 @@
 
 Sanitizers
 --
+- Several more sanitizers are now ported to LoongArch: MSan, DFsan, Profile, 
XRay and libFuzzer.
 
 Python Binding Changes
 --


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -199,9 +199,13 @@
 Changes to the LoongArch Backend
 
 
+* Adds assembler/disassembler support for the LSX, LASX, LVZ and LBT ISA extensions.
 * The ``lp64s`` ABI is supported now and has been tested on Rust bare-matal target.
 * A target feature ``ual`` is introduced to allow unaligned memory accesses and
   this feature is enabled by default for generic 64-bit processors.
+* Adds support for the ``large`` code model, which is equivalent to GCC's ``extreme`` one.
+* Assorted codegen improvements.
+* llvm-objcopy now supports processing LoongArch objects.
 
 Changes to the MIPS Backend
 ---
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -897,6 +897,8 @@
   on LoongArch.
 - Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
   aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in inlineasm
+  like GCC does.
 
 RISC-V Support
 ^^
@@ -1095,6 +1097,7 @@
 
 Sanitizers
 --
+- Several more sanitizers are now ported to LoongArch: MSan, DFsan, Profile, XRay and libFuzzer.
 
 Python Binding Changes
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156214: [LLVM][RISCV] Check more extension dependencies

2023-07-25 Thread Kiva via Phabricator via cfe-commits
imkiva updated this revision to Diff 543890.
imkiva added a comment.

Removed some tests that used `e` together with `f` or `d`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156214

Files:
  clang/test/Driver/riscv-arch.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/test/MC/RISCV/target-abi-invalid.s
  llvm/unittests/Support/RISCVISAInfoTest.cpp

Index: llvm/unittests/Support/RISCVISAInfoTest.cpp
===
--- llvm/unittests/Support/RISCVISAInfoTest.cpp
+++ llvm/unittests/Support/RISCVISAInfoTest.cpp
@@ -474,6 +474,17 @@
 EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
   "'zcf' is only supported for 'rv32'");
   }
+
+  for (StringRef Input : {"rv64efd", "rv32efd", "rv64ed", "rv32ed"}) {
+EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+  "'e' extension is incompatible with 'f' extension"
+  " and 'd' extension");
+  }
+
+  for (StringRef Input : {"rv64ef", "rv32ef"}) {
+EXPECT_EQ(toString(RISCVISAInfo::parseArchString(Input, true).takeError()),
+  "'e' extension is incompatible with 'f' extension");
+  }
 }
 
 TEST(ToFeatureVector, IIsDroppedAndExperimentalExtensionsArePrefixed) {
Index: llvm/test/MC/RISCV/target-abi-invalid.s
===
--- llvm/test/MC/RISCV/target-abi-invalid.s
+++ llvm/test/MC/RISCV/target-abi-invalid.s
@@ -28,10 +28,6 @@
 # RUN:   | FileCheck -check-prefix=RV32IFD-LP64D %s
 # RUN: llvm-mc -triple=riscv32 -mattr=+e -target-abi lp64 < %s 2>&1 \
 # RUN:   | FileCheck -check-prefix=RV32E-LP64 %s
-# RUN: llvm-mc -triple=riscv32 -mattr=+e,+f -target-abi lp64f < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV32EF-LP64F %s
-# RUN: llvm-mc -triple=riscv32 -mattr=+e,+d -target-abi lp64f < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV32EFD-LP64D %s
 # RUN: llvm-mc -triple=riscv32 -mattr=+e -target-abi lp64e %s 2>&1 \
 # RUN:   | FileCheck -check-prefix=RV32E-LP64E %s
 
@@ -39,8 +35,6 @@
 # RV32IF-LP64F: 64-bit ABIs are not supported for 32-bit targets (ignoring target-abi)
 # RV32IFD-LP64D: 64-bit ABIs are not supported for 32-bit targets (ignoring target-abi)
 # RV32E-LP64: 64-bit ABIs are not supported for 32-bit targets (ignoring target-abi)
-# RV32EF-LP64F: 64-bit ABIs are not supported for 32-bit targets (ignoring target-abi)
-# RV32EFD-LP64D: 64-bit ABIs are not supported for 32-bit targets (ignoring target-abi)
 # RV32E-LP64E: 64-bit ABIs are not supported for 32-bit targets (ignoring target-abi)
 
 # RUN: llvm-mc -triple=riscv32 -target-abi ilp32f < %s 2>&1 \
@@ -66,31 +60,13 @@
 # RV64IF-LP64D: Hard-float 'd' ABI can't be used for a target that doesn't support the D instruction set extension (ignoring target-abi)
 
 # RUN: llvm-mc -triple=riscv32 -mattr=+e -target-abi ilp32 < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV32EF-ILP32F %s
-# RUN: llvm-mc -triple=riscv32 -mattr=+e,+f -target-abi ilp32f < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV32EF-ILP32F %s
-# RUN: llvm-mc -triple=riscv32 -mattr=+e,+d -target-abi ilp32f < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV32EFD-ILP32F %s
-# RUN: llvm-mc -triple=riscv32 -mattr=+e,+d -target-abi ilp32d < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV32EFD-ILP32D %s
+# RUN:   | FileCheck -check-prefix=RV32E-ILP32 %s
 
 # RV32E-ILP32: Only the ilp32e ABI is supported for RV32E (ignoring target-abi)
-# RV32EF-ILP32F: Only the ilp32e ABI is supported for RV32E (ignoring target-abi)
-# RV32EFD-ILP32F: Only the ilp32e ABI is supported for RV32E (ignoring target-abi)
-# RV32EFD-ILP32D: Only the ilp32e ABI is supported for RV32E (ignoring target-abi)
 
 # RUN: llvm-mc -triple=riscv64 -mattr=+e -target-abi lp64 < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV64EF-LP64F %s
-# RUN: llvm-mc -triple=riscv64 -mattr=+e,+f -target-abi lp64f < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV64EF-LP64F %s
-# RUN: llvm-mc -triple=riscv64 -mattr=+e,+d -target-abi lp64f < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV64EFD-LP64F %s
-# RUN: llvm-mc -triple=riscv64 -mattr=+e,+d -target-abi lp64d < %s 2>&1 \
-# RUN:   | FileCheck -check-prefix=RV64EFD-LP64D %s
+# RUN:   | FileCheck -check-prefix=RV64E-LP64 %s
 
 # RV64E-LP64: Only the lp64e ABI is supported for RV64E (ignoring target-abi)
-# RV64EF-LP64F: Only the lp64e ABI is supported for RV64E (ignoring target-abi)
-# RV64EFD-LP64F: Only the lp64e ABI is supported for RV64E (ignoring target-abi)
-# RV64EFD-LP64D: Only the lp64e ABI is supported for RV64E (ignoring target-abi)
 
 nop
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -895,6 +895,7 @@
 Error RISCVISAInfo::checkDependency() {
   bool HasC = Exts.count("c") != 0;
   bool HasF = Exts.cou

[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-25 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

> should we try to land that today?

I'm not sure. It causes failures in libc++ testing:

  Failed Tests (3):
llvm-libc++-shared.cfg.in :: std/ranges/range.access/end.pass.cpp
llvm-libc++-shared.cfg.in :: std/ranges/range.access/rbegin.pass.cpp
llvm-libc++-shared.cfg.in :: std/ranges/range.access/rend.pass.cpp

I haven't figured out why. Trying to compile:

  #include 
  
  using RangeCREndT = decltype(std::ranges::crend);
  static_assert(!std::is_invocable_v);

fails with this patch only using libc++, libstdc++ is fine. I'm not sure it is 
my misunderstanding, bug in the patch or bug in libc++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[clang] 3d83912 - Revert rGfae7b98c221b5b28797f7b56b656b6b819d99f27 "[Support] Change SetVector's default template parameter to SmallVector<*, 0>"

2023-07-25 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2023-07-25T10:22:08+01:00
New Revision: 3d83912c0c7be63d24e54792b300f394931a363b

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

LOG: Revert rGfae7b98c221b5b28797f7b56b656b6b819d99f27 "[Support] Change 
SetVector's default template parameter to SmallVector<*, 0>"

This is failing on Windows MSVC builds:
llvm\unittests\Support\ThreadPool.cpp(380): error C2440: 'return': cannot 
convert from 'Vector' to 
'std::vector>'
with
[
Vector=llvm::SmallVector
]

Added: 


Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
llvm/include/llvm/ADT/SetVector.h
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
llvm/tools/llvm-reduce/deltas/ReduceOperandsSkip.cpp
mlir/include/mlir/Support/LLVM.h
mlir/lib/Analysis/SliceAnalysis.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 908dec42afabeb..07a9dec12f6f25 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2236,7 +2236,7 @@ static bool 
requiresMemberFunctionPointerTypeMetadata(CodeGenModule &CGM,
  !isa(MD);
 }
 
-SmallVector
+std::vector
 CodeGenModule::getMostBaseClasses(const CXXRecordDecl *RD) {
   llvm::SetVector MostBases;
 

diff  --git a/clang/lib/CodeGen/CodeGenModule.h 
b/clang/lib/CodeGen/CodeGenModule.h
index c5de947687ea61..f5fd94492540f2 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1505,7 +1505,7 @@ class CodeGenModule : public CodeGenTypeCache {
   ///
   /// A most-base class of a class C is defined as a recursive base class of C,
   /// including C itself, that does not have any bases.
-  SmallVector
+  std::vector
   getMostBaseClasses(const CXXRecordDecl *RD);
 
   /// Get the declaration of std::terminate for the platform.

diff  --git a/llvm/include/llvm/ADT/SetVector.h 
b/llvm/include/llvm/ADT/SetVector.h
index ff083556cf1694..781ca367b97e48 100644
--- a/llvm/include/llvm/ADT/SetVector.h
+++ b/llvm/include/llvm/ADT/SetVector.h
@@ -23,10 +23,10 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/STLExtras.h"
-#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 #include 
 #include 
+#include 
 
 namespace llvm {
 
@@ -52,7 +52,7 @@ namespace llvm {
 /// when searching for elements instead of checking Set, due to it being better
 /// for performance. A value of 0 means that this mode of operation is not 
used,
 /// and is the default value.
-template ,
+template ,
   typename Set = DenseSet, unsigned N = 0>
 class SetVector {
   // Much like in SmallPtrSet, this value should not be too high to prevent

diff  --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp 
b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 775bb95fdda7b0..2076ed48ea342a 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -93,7 +93,7 @@ extern cl::opt ScalePartialSampleProfileWorkingSetSize;
 // instruction in it takes an address of any basic block, because instruction
 // can only take an address of basic block located in the same function.
 static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
- SetVector> 
&RefEdges,
+ SetVector &RefEdges,
  SmallPtrSet &Visited) {
   bool HasBlockAddress = false;
   SmallVector Worklist;
@@ -144,12 +144,9 @@ static bool isNonRenamableLocal(const GlobalValue &GV) {
 
 /// Determine whether this call has all constant integer arguments (excluding
 /// "this") and summarize it to VCalls or ConstVCalls as appropriate.
-static void addVCallToSet(
-DevirtCallSite Call, GlobalValue::GUID Guid,
-SetVector>
-&VCalls,
-SetVector> &ConstVCalls) {
+static void addVCallToSet(DevirtCallSite Call, GlobalValue::GUID Guid,
+  SetVector &VCalls,
+  SetVector &ConstVCalls) 
{
   std::vector Args;
   // Start from the second argument to skip the "this" pointer.
   for (auto &Arg : drop_begin(Call.CB.args())) {
@@ -166,18 +163,11 @@ static void addVCallToSet(
 /// If this intrinsic call requires that we add information to the function
 /// summary, do so via the non-constant reference arguments.
 static void addIntrinsicToSummary(
-const CallInst *CI,
-SetVector> &TypeTests,
-SetVector>
-&TypeTestAssumeVCalls,
-SetVector>
-&TypeCheckedLoadVCalls,
-SetVector>
-&TypeTestAssumeConstVCalls,
-SetVector>
-&TypeCheckedLoadConstVCalls,
+const CallInst *CI, SetVector &TypeTests,
+SetVector &TypeTestAssumeVCalls,
+SetVector &TypeCheckedLo

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

2023-07-25 Thread Sandeep via Phabricator via cfe-commits
sandeepkosuri updated this revision to Diff 543889.
sandeepkosuri added a comment.

- Added support for `thread_limit` clause on relevant combined directives which 
begin with `target` as per @ABataev 's comments.
- Added additional LIT test cases to check codegen of the `thread_limit` on the 
newly supported directives.
- Updated the runtime LIT as per @jdoerfert 's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152054

Files:
  clang/include/clang/Basic/OpenMPKinds.h
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_tl_codegen.cpp
  clang/test/OpenMP/target_parallel_for_tl_codegen.cpp
  clang/test/OpenMP/target_parallel_generic_loop_tl_codegen.cpp
  clang/test/OpenMP/target_parallel_tl_codegen.cpp
  clang/test/OpenMP/target_simd_tl_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_csupport.cpp
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_global.cpp
  openmp/runtime/src/kmp_runtime.cpp
  openmp/runtime/test/target/target_thread_limit.cpp

Index: openmp/runtime/test/target/target_thread_limit.cpp
===
--- /dev/null
+++ openmp/runtime/test/target/target_thread_limit.cpp
@@ -0,0 +1,168 @@
+// RUN: %libomp-cxx-compile -fopenmp-version=51
+// RUN: %libomp-run | FileCheck %s --check-prefix OMP51
+
+#include 
+#include 
+
+void foo() {
+#pragma omp parallel num_threads(10)
+  { printf("\ntarget: foo(): parallel num_threads(10)"); }
+}
+
+int main(void) {
+
+  int tl = 4;
+  printf("\nmain: thread_limit = %d", omp_get_thread_limit());
+  // OMP51: main: thread_limit = {{[0-9]+}}
+
+#pragma omp target thread_limit(tl)
+  {
+printf("\ntarget: thread_limit = %d", omp_get_thread_limit());
+// OMP51: target: thread_limit = 4
+// check whether thread_limit is honoured
+#pragma omp parallel
+{ printf("\ntarget: parallel"); }
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51-NOT: target: parallel
+
+// check whether num_threads is honoured
+#pragma omp parallel num_threads(2)
+{ printf("\ntarget: parallel num_threads(2)"); }
+// OMP51: target: parallel num_threads(2)
+// OMP51: target: parallel num_threads(2)
+// OMP51-NOT: target: parallel num_threads(2)
+
+// check whether thread_limit is honoured when there is a conflicting
+// num_threads
+#pragma omp parallel num_threads(10)
+{ printf("\ntarget: parallel num_threads(10)"); }
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51-NOT: target: parallel num_threads(10)
+
+// check whether threads are limited across functions
+foo();
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51-NOT: target: foo(): parallel num_threads(10)
+
+// check if user can set num_threads at runtime
+omp_set_num_threads(2);
+#pragma omp parallel
+{ printf("\ntarget: parallel with omp_set_num_thread(2)"); }
+// OMP51: target: parallel with omp_set_num_thread(2)
+// OMP51: target: parallel with omp_set_num_thread(2)
+// OMP51-NOT: target: parallel with omp_set_num_thread(2)
+
+// make sure thread_limit is unaffected by omp_set_num_threads
+printf("\ntarget: thread_limit = %d", omp_get_thread_limit());
+// OMP51: target: thread_limit = 4
+  }
+
+// checking consecutive target regions with different thread_limits
+#pragma omp target thread_limit(3)
+  {
+printf("\nsecond target: thread_limit = %d", omp_get_thread_limit());
+// OMP51: second target: thread_limit = 3
+#pragma omp parallel
+{ printf("\nsecond target: parallel"); }
+// OMP51: second target: parallel
+// OMP51: second target: parallel
+// OMP51: second target: parallel
+// OMP51-NOT: second target: parallel
+  }
+
+  // confirm that thread_limit's effects are limited to target region
+  printf("\nmain: thread_limit = %d", omp_get_thread_limit());
+  // OMP51: main: thread_limit = {{[0-9]+}}
+#pragma omp parallel num_threads(10)
+  { printf("\nmain: parallel num_threads(10)"); }
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: mai

[PATCH] D156214: [LLVM][RISCV] Check more extension dependencies

2023-07-25 Thread Wang Pengcheng via Phabricator via cfe-commits
wangpc added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:948
-  // TODO: The 'q' extension requires rv64.
-  // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'.
 

I think the comment is outdated here. `E` can be combined with all other 
extensions according to spec:
> Unless otherwise stated, standard extensions compatible with RV32I and RV64I 
> are also compatible with RV32E and RV64E, respectively.
And, please see also D70401 for more context.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156214

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


[clang] 4dbe2db - [clang][analyzer] Improved documentation for TaintPropagation Checker

2023-07-25 Thread Daniel Krupp via cfe-commits

Author: Daniel Krupp
Date: 2023-07-25T11:34:11+02:00
New Revision: 4dbe2db02d03ffee27feb43a6ef332ca6a3cbca2

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

LOG: [clang][analyzer] Improved documentation for TaintPropagation Checker

The usage of the taint analysis is described through a command injection attack 
example.
It is explained how to make a variable sanitized through configuration.

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

Added: 


Modified: 
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 73b4967b1ffdeb..97b5369ac86c9b 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2359,64 +2359,244 @@ pointer. These functions include: getenv, localeconv, 
asctime, setlocale, strerr
 alpha.security.taint
 
 
-Checkers implementing `taint analysis 
`_.
+Checkers implementing
+`taint analysis `_.
 
 .. _alpha-security-taint-TaintPropagation:
 
 alpha.security.taint.TaintPropagation (C, C++)
 ""
 
-Taint analysis identifies untrusted sources of information (taint sources), 
rules as to how the untrusted data flows along the execution path (propagation 
rules), and points of execution where the use of tainted data is risky (taints 
sinks).
+Taint analysis identifies potential security vulnerabilities where the
+attacker can inject malicious data to the program to execute an attack
+(privilege escalation, command injection, SQL injection etc.).
+
+The malicious data is injected at the taint source (e.g. ``getenv()`` call)
+which is then propagated through function calls and being used as arguments of
+sensitive operations, also called as taint sinks (e.g. ``system()`` call).
+
+One can defend agains this type of vulnerability by always checking and
+santizing the potentially malicious, untrusted user input.
+
+The goal of the checker is to discover and show to the user these potential
+taint source-sink pairs and the propagation call chain.
+
 The most notable examples of taint sources are:
 
-  - network originating data
+  - data from network
+  - files or standard input
   - environment variables
-  - database originating data
+  - data from databases
 
-``GenericTaintChecker`` is the main implementation checker for this rule, and 
it generates taint information used by other checkers.
+Let us examine a practical example of a Command Injection attack.
 
 .. code-block:: c
 
- void test() {
-   char x = getchar(); // 'x' marked as tainted
-   system(&x); // warn: untrusted data is passed to a system call
- }
+  // Command Injection Vulnerability Example
+  int main(int argc, char** argv) {
+char cmd[2048] = "/bin/cat ";
+char filename[1024];
+printf("Filename:");
+scanf (" %1023[^\n]", filename); // The attacker can inject a shell escape 
here
+strcat(cmd, filename);
+system(cmd); // Warning: Untrusted data is passed to a system call
+  }
 
- // note: compiler internally checks if the second param to
- // sprintf is a string literal or not.
- // Use -Wno-format-security to suppress compiler warning.
- void test() {
-   char s[10], buf[10];
-   fscanf(stdin, "%s", s); // 's' marked as tainted
+The program prints the content of any user specified file.
+Unfortunately the attacker can execute arbitrary commands
+with shell escapes. For example with the following input the `ls` command is 
also
+executed after the contents of `/etc/shadow` is printed.
+`Input: /etc/shadow ; ls /`
 
-   sprintf(buf, s); // warn: untrusted data as a format string
- }
+The analysis implemented in this checker points out this problem.
 
- void test() {
-   size_t ts;
-   scanf("%zd", &ts); // 'ts' marked as tainted
-   int *p = (int *)malloc(ts * sizeof(int));
- // warn: untrusted data as buffer size
- }
+One can protect against such attack by for example checking if the provided
+input refers to a valid file and removing any invalid user input.
+
+.. code-block:: c
+
+  // No vulnerability anymore, but we still get the warning
+  void sanitizeFileName(char* filename){
+if (access(filename,F_OK)){// Verifying user input
+  printf("File does not exist\n");
+  filename[0]='\0';
+  }
+  }
+  int main(int argc, char** argv) {
+char cmd[2048] = "/bin/cat ";
+char filename[1024];
+printf("Filename:");
+scanf (" %1023[^\n]", filename); // The attacker can inject a shell escape 
here
+sanitizeFileName(filename);// filename is safe after this point
+if (!filename[0])
+  return -1;
+strcat(cmd, filename);
+system(cmd); // Superflous Warning: U

[PATCH] D145229: [analyzer] Improve the documentation of the alpha.security.taint.TaintPropagation checker

2023-07-25 Thread Daniel Krupp 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 rG4dbe2db02d03: [clang][analyzer] Improved documentation for 
TaintPropagation Checker (authored by dkrupp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145229

Files:
  clang/docs/analyzer/checkers.rst

Index: clang/docs/analyzer/checkers.rst
===
--- clang/docs/analyzer/checkers.rst
+++ clang/docs/analyzer/checkers.rst
@@ -2359,64 +2359,244 @@
 alpha.security.taint
 
 
-Checkers implementing `taint analysis `_.
+Checkers implementing
+`taint analysis `_.
 
 .. _alpha-security-taint-TaintPropagation:
 
 alpha.security.taint.TaintPropagation (C, C++)
 ""
 
-Taint analysis identifies untrusted sources of information (taint sources), rules as to how the untrusted data flows along the execution path (propagation rules), and points of execution where the use of tainted data is risky (taints sinks).
+Taint analysis identifies potential security vulnerabilities where the
+attacker can inject malicious data to the program to execute an attack
+(privilege escalation, command injection, SQL injection etc.).
+
+The malicious data is injected at the taint source (e.g. ``getenv()`` call)
+which is then propagated through function calls and being used as arguments of
+sensitive operations, also called as taint sinks (e.g. ``system()`` call).
+
+One can defend agains this type of vulnerability by always checking and
+santizing the potentially malicious, untrusted user input.
+
+The goal of the checker is to discover and show to the user these potential
+taint source-sink pairs and the propagation call chain.
+
 The most notable examples of taint sources are:
 
-  - network originating data
+  - data from network
+  - files or standard input
   - environment variables
-  - database originating data
+  - data from databases
 
-``GenericTaintChecker`` is the main implementation checker for this rule, and it generates taint information used by other checkers.
+Let us examine a practical example of a Command Injection attack.
 
 .. code-block:: c
 
- void test() {
-   char x = getchar(); // 'x' marked as tainted
-   system(&x); // warn: untrusted data is passed to a system call
- }
+  // Command Injection Vulnerability Example
+  int main(int argc, char** argv) {
+char cmd[2048] = "/bin/cat ";
+char filename[1024];
+printf("Filename:");
+scanf (" %1023[^\n]", filename); // The attacker can inject a shell escape here
+strcat(cmd, filename);
+system(cmd); // Warning: Untrusted data is passed to a system call
+  }
 
- // note: compiler internally checks if the second param to
- // sprintf is a string literal or not.
- // Use -Wno-format-security to suppress compiler warning.
- void test() {
-   char s[10], buf[10];
-   fscanf(stdin, "%s", s); // 's' marked as tainted
+The program prints the content of any user specified file.
+Unfortunately the attacker can execute arbitrary commands
+with shell escapes. For example with the following input the `ls` command is also
+executed after the contents of `/etc/shadow` is printed.
+`Input: /etc/shadow ; ls /`
 
-   sprintf(buf, s); // warn: untrusted data as a format string
- }
+The analysis implemented in this checker points out this problem.
 
- void test() {
-   size_t ts;
-   scanf("%zd", &ts); // 'ts' marked as tainted
-   int *p = (int *)malloc(ts * sizeof(int));
- // warn: untrusted data as buffer size
- }
+One can protect against such attack by for example checking if the provided
+input refers to a valid file and removing any invalid user input.
+
+.. code-block:: c
+
+  // No vulnerability anymore, but we still get the warning
+  void sanitizeFileName(char* filename){
+if (access(filename,F_OK)){// Verifying user input
+  printf("File does not exist\n");
+  filename[0]='\0';
+  }
+  }
+  int main(int argc, char** argv) {
+char cmd[2048] = "/bin/cat ";
+char filename[1024];
+printf("Filename:");
+scanf (" %1023[^\n]", filename); // The attacker can inject a shell escape here
+sanitizeFileName(filename);// filename is safe after this point
+if (!filename[0])
+  return -1;
+strcat(cmd, filename);
+system(cmd); // Superflous Warning: Untrusted data is passed to a system call
+  }
+
+Unfortunately, the checker cannot discover automatically that the programmer
+have performed data sanitation, so it still emits the warning.
 
-There are built-in sources, propagations and sinks defined in code inside ``GenericTaintChecker``.
-These operations are handled even if no external taint configuration is provided.
+One can get rid of this superflous warning by telling

[PATCH] D156214: [LLVM][RISCV] Check more extension dependencies

2023-07-25 Thread Kiva via Phabricator via cfe-commits
imkiva added a comment.

address review comments




Comment at: llvm/lib/Support/RISCVISAInfo.cpp:948
-  // TODO: The 'q' extension requires rv64.
-  // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'.
 

wangpc wrote:
> I think the comment is outdated here. `E` can be combined with all other 
> extensions according to spec:
> > Unless otherwise stated, standard extensions compatible with RV32I and 
> > RV64I are also compatible with RV32E and RV64E, respectively.
> And, please see also D70401 for more context.
I downloaded the specification from 
[here](https://github.com/riscv/riscv-isa-manual/releases/download/Ratified-IMAFDQC/riscv-spec-20191213.pdf),
 and in page 34 the footnote says:

> RV32E can be combined with all current standard extensions. Defining the F, 
> D, and Q extensions as having a 16-entry floating point register file when 
> combined with RV32E was considered but **decided against**. To support 
> systems with reduced floating-point register state, we intend to define a 
> “Zfinx” extension...

It seems in the spec version 20191213, they rejected the combination of `E` 
with standard floating-point extensions, instead, a separate extension `Zfinx` 
is chosen for the original purpose.
I am not sure if there's any newer specification that decides to allow this 
combination.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156214

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


[clang] c5a13e2 - [NFC][clang] Fix static analyzer concerns

2023-07-25 Thread via cfe-commits

Author: Podchishchaeva, Mariya
Date: 2023-07-25T02:43:41-07:00
New Revision: c5a13e2c7e4c1769831c99ff2bf9f3690328c3d4

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

LOG: [NFC][clang] Fix static analyzer concerns

EHScopeStack doesn't seem to be intended for copy. It frees memory in
the destructor and doesn't have user-written copy c'tor and assignment
operator, so delete them to avoid using default ones which would do
wrong.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/CodeGen/EHScopeStack.h

Removed: 




diff  --git a/clang/lib/CodeGen/EHScopeStack.h 
b/clang/lib/CodeGen/EHScopeStack.h
index 4893689f856ea3..3c8a51590d1b53 100644
--- a/clang/lib/CodeGen/EHScopeStack.h
+++ b/clang/lib/CodeGen/EHScopeStack.h
@@ -278,6 +278,9 @@ class EHScopeStack {
   CGF(nullptr) {}
   ~EHScopeStack() { delete[] StartOfBuffer; }
 
+  EHScopeStack(const EHScopeStack &) = delete;
+  EHScopeStack &operator=(const EHScopeStack &) = delete;
+
   /// Push a lazily-created cleanup on the stack.
   template  void pushCleanup(CleanupKind Kind, As... A) {
 static_assert(alignof(T) <= ScopeStackAlignment,



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


[PATCH] D156133: [NFC][clang] Fix static analyzer concerns

2023-07-25 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc5a13e2c7e4c: [NFC][clang] Fix static analyzer concerns 
(authored by Fznamznon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156133

Files:
  clang/lib/CodeGen/EHScopeStack.h


Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -278,6 +278,9 @@
   CGF(nullptr) {}
   ~EHScopeStack() { delete[] StartOfBuffer; }
 
+  EHScopeStack(const EHScopeStack &) = delete;
+  EHScopeStack &operator=(const EHScopeStack &) = delete;
+
   /// Push a lazily-created cleanup on the stack.
   template  void pushCleanup(CleanupKind Kind, As... A) {
 static_assert(alignof(T) <= ScopeStackAlignment,


Index: clang/lib/CodeGen/EHScopeStack.h
===
--- clang/lib/CodeGen/EHScopeStack.h
+++ clang/lib/CodeGen/EHScopeStack.h
@@ -278,6 +278,9 @@
   CGF(nullptr) {}
   ~EHScopeStack() { delete[] StartOfBuffer; }
 
+  EHScopeStack(const EHScopeStack &) = delete;
+  EHScopeStack &operator=(const EHScopeStack &) = delete;
+
   /// Push a lazily-created cleanup on the stack.
   template  void pushCleanup(CleanupKind Kind, As... A) {
 static_assert(alignof(T) <= ScopeStackAlignment,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156221: [RISCV] Support overloaded version ntlh intrinsic function

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

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156221

Files:
  clang/lib/Headers/riscv_ntlh.h
  clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c


Index: clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
===
--- clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
+++ clang/test/CodeGen/RISCV/ntlh-intrinsics/riscv32-zihintntl.c
@@ -100,6 +100,24 @@
   *scvs1 = __riscv_ntl_load(scvs2, __RISCV_NTLH_ALL);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
   *scvc1 = __riscv_ntl_load(scvc2, __RISCV_NTLH_ALL);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
 
+  uc = __riscv_ntl_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  sc = __riscv_ntl_load(&uc);   // CHECK: load i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  us = __riscv_ntl_load(&ss);   // CHECK: load i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  ss = __riscv_ntl_load(&us);   // CHECK: load i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  ui = __riscv_ntl_load(&si);   // CHECK: load i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  si = __riscv_ntl_load(&ui);   // CHECK: load i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  ull = __riscv_ntl_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  sll = __riscv_ntl_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  h1 = __riscv_ntl_load(&h2);   // CHECK: load half{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  f1 = __riscv_ntl_load(&f2);   // CHECK: load float{{.*}}align 4, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  d1 = __riscv_ntl_load(&d2);   // CHECK: load double{{.*}}align 8, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  v4si1 = __riscv_ntl_load(&v4si2);   // CHECK: load <4 x i32>{{.*}}align 16, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  v8ss1 = __riscv_ntl_load(&v8ss2);   // CHECK: load <8 x i16>{{.*}}align 16, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  v16sc1 = __riscv_ntl_load(&v16sc2);   // CHECK: load <16 x i8>{{.*}}align 
16, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvi1 = __riscv_ntl_load(scvi2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvs1 = __riscv_ntl_load(scvs2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+  *scvc1 = __riscv_ntl_load(scvc2);   // CHECK: load {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
+
   __riscv_ntl_store(&uc, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: 
store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5
   __riscv_ntl_store(&sc, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: 
store i8{{.*}}align 1, !nontemporal !4, !riscv-nontemporal-domain !5
   __riscv_ntl_store(&us, 1, __RISCV_NTLH_INNERMOST_PRIVATE);// CHECK: 
store i16{{.*}}align 2, !nontemporal !4, !riscv-nontemporal-domain !5
@@ -172,6 +190,23 @@
   __riscv_ntl_store(scvs2, *scvs1, __RISCV_NTLH_ALL);  // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
   __riscv_ntl_store(scvc2, *scvc1, __RISCV_NTLH_ALL);  // CHECK: store {{.*}}align 8, !nontemporal !4, !riscv-nontemporal-domain !8
 
+  __riscv_ntl_store(&uc, 1);// CHECK: store i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&sc, 1);// CHECK: store i8{{.*}}align 1, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&us, 1);// CHECK: store i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ss, 1);// CHECK: store i16{{.*}}align 2, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ui, 1);// CHECK: store i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&si, 1);// CHECK: store i32{{.*}}align 4, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&ull, 1);   // CHECK: store i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&sll, 1);   // CHECK: store i64{{.*}}align 8, !nontemporal 
!4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&h1, 1.0);  // CHECK: store half{{.*}}align 2, 
!nontemporal !4, !riscv-nontemporal-domain !8
+  __riscv_ntl_store(&f1, 1.

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 543902.
SixWeining added a comment.

update clang release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/loongarch-mtune-error.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -16,6 +16,9 @@
 using namespace llvm;
 using namespace llvm::LoongArch;
 
+StringRef Arch;
+StringRef TuneCPU;
+
 const FeatureInfo AllFeatures[] = {
 #define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
 #include "llvm/TargetParser/LoongArchTargetParser.def"
@@ -46,3 +49,25 @@
   }
   return false;
 }
+
+bool LoongArch::isValidTuneCPUName(StringRef TuneCPU) {
+  return isValidArchName(TuneCPU);
+}
+
+void LoongArch::fillValidTuneCPUList(SmallVectorImpl &Values) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
+
+void LoongArch::setArch(StringRef Name) { Arch = Name; }
+
+StringRef LoongArch::getArch() { return Arch; }
+
+void LoongArch::setTuneCPU(StringRef Name) { TuneCPU = Name; }
+
+StringRef LoongArch::getTuneCPU() { return TuneCPU; }
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,16 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector &Features);
+bool isValidTuneCPUName(StringRef TuneCPU);
+void fillValidTuneCPUList(SmallVectorImpl &Values);
+StringRef getDefaultArch(bool Is64Bit);
+void setArch(StringRef Arch);
+StringRef getArch();
+void setTuneCPU(StringRef TuneCPU);
+StringRef getTuneCPU();
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_

[PATCH] D156222: [NFC][clang] Fix static analyzer concerns

2023-07-25 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

TypeLocBuilder frees resources in the destructor but doesn't have
user-written copy c'tor or assignment operator, so copying it using
default ones can cause double free.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156222

Files:
  clang/lib/Sema/TypeLocBuilder.h


Index: clang/lib/Sema/TypeLocBuilder.h
===
--- clang/lib/Sema/TypeLocBuilder.h
+++ clang/lib/Sema/TypeLocBuilder.h
@@ -53,6 +53,9 @@
   delete[] Buffer;
   }
 
+  TypeLocBuilder(const TypeLocBuilder &) = delete;
+  TypeLocBuilder &operator=(const TypeLocBuilder &) = delete;
+
   /// Ensures that this buffer has at least as much capacity as described.
   void reserve(size_t Requested) {
 if (Requested > Capacity)


Index: clang/lib/Sema/TypeLocBuilder.h
===
--- clang/lib/Sema/TypeLocBuilder.h
+++ clang/lib/Sema/TypeLocBuilder.h
@@ -53,6 +53,9 @@
   delete[] Buffer;
   }
 
+  TypeLocBuilder(const TypeLocBuilder &) = delete;
+  TypeLocBuilder &operator=(const TypeLocBuilder &) = delete;
+
   /// Ensures that this buffer has at least as much capacity as described.
   void reserve(size_t Requested) {
 if (Requested > Capacity)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145229: [analyzer] Improve the documentation of the alpha.security.taint.TaintPropagation checker

2023-07-25 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:2471
+  #ifdef __clang_analyzer__
+void csa_mark_sanitized(const void *);
+  #endif

Have you considered unconditionally having this function with an empty body?
That way it would have no "noise" at callsite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145229

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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-25 Thread WÁNG Xuěruì via Phabricator via cfe-commits
xen0n accepted this revision.
xen0n added a comment.
This revision is now accepted and ready to land.

Overall LGTM except one small nit, thanks!




Comment at: clang/docs/ReleaseNotes.rst:902
   like GCC does.
+- Adds support for the ``-march=native`` and ``-mtune=`` options and the
+  ``__loongarch_{arch,tune}`` pre-defined macros.

"Added"? Or rephrase like "The ... options and ... macros are now supported".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

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


[PATCH] D156223: [RISCV] Resolve a few bugs in RISCVVIntrinsicUtils.cpp

2023-07-25 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD, MaskRay.
Herald added a project: clang.

This patch does a few things:

1. Add a new type called Undefined to ScalarTypeKind.
2. Make RVVType::applyModifier early return when encounter invalid ScalarType, 
otherwise it could be modified to "non-invalid" type in the following code.
3. When FixedLMULType::SmallerThan is applied, the lmul should be "<" than 
specified one, so lmuls which are ">=" should be marked as invalid.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156223

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -742,6 +742,10 @@
 break;
   }
 
+  // Early return if the current type modifier is already invalid.
+  if (ScalarType == Invalid)
+return;
+
   for (unsigned TypeModifierMaskShift = 0;
TypeModifierMaskShift <= static_cast(TypeModifier::MaxOffset);
++TypeModifierMaskShift) {
@@ -803,13 +807,13 @@
 void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) {
   switch (Type) {
   case FixedLMULType::LargerThan:
-if (Log2LMUL < LMUL.Log2LMUL) {
+if (Log2LMUL <= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
 break;
   case FixedLMULType::SmallerThan:
-if (Log2LMUL > LMUL.Log2LMUL) {
+if (Log2LMUL >= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -133,6 +133,7 @@
 }
 break;
   case Invalid:
+  case Undefined:
 llvm_unreachable("Unhandled type.");
   }
   if (Type->isVector()) {
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -218,6 +218,7 @@
   UnsignedInteger,
   Float,
   Invalid,
+  Undefined,
 };
 
 // Exponential LMUL
@@ -240,7 +241,7 @@
   friend class RVVTypeCache;
 
   BasicType BT;
-  ScalarTypeKind ScalarType = Invalid;
+  ScalarTypeKind ScalarType = Undefined;
   LMULType LMUL;
   bool IsPointer = false;
   // IsConstant indices are "int", but have the constant expression.


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -742,6 +742,10 @@
 break;
   }
 
+  // Early return if the current type modifier is already invalid.
+  if (ScalarType == Invalid)
+return;
+
   for (unsigned TypeModifierMaskShift = 0;
TypeModifierMaskShift <= static_cast(TypeModifier::MaxOffset);
++TypeModifierMaskShift) {
@@ -803,13 +807,13 @@
 void RVVType::applyFixedLog2LMUL(int Log2LMUL, enum FixedLMULType Type) {
   switch (Type) {
   case FixedLMULType::LargerThan:
-if (Log2LMUL < LMUL.Log2LMUL) {
+if (Log2LMUL <= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
 break;
   case FixedLMULType::SmallerThan:
-if (Log2LMUL > LMUL.Log2LMUL) {
+if (Log2LMUL >= LMUL.Log2LMUL) {
   ScalarType = ScalarTypeKind::Invalid;
   return;
 }
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -133,6 +133,7 @@
 }
 break;
   case Invalid:
+  case Undefined:
 llvm_unreachable("Unhandled type.");
   }
   if (Type->isVector()) {
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -218,6 +218,7 @@
   UnsignedInteger,
   Float,
   Invalid,
+  Undefined,
 };
 
 // Exponential LMUL
@@ -240,7 +241,7 @@
   friend class RVVTypeCache;
 
   BasicType BT;
-  ScalarTypeKind ScalarType = Invalid;
+  ScalarTypeKind ScalarType = Undefined;
   LMULType LMUL;
   bool IsPointer = false;
   // IsConstant indi

[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Kai Stierand via Phabricator via cfe-commits
kiloalphaindia created this revision.
kiloalphaindia added a reviewer: cor3ntin.
Herald added a subscriber: shchenz.
Herald added a project: All.
kiloalphaindia requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes:

  
/home/buildbots/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1526:11:
 warning: comparison of integer expressions of different signedness: ‘const 
unsigned int’ and ‘const int’ [-Wsign-compare]
  
/home/buildbots/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1526:11:
 warning: comparison of integer expressions of different signedness: ‘const 
long unsigned int’ and ‘const int’ [-Wsign-compare]


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156224

Files:
  clang/unittests/libclang/LibclangTest.cpp


Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1220,7 +1220,7 @@
   const char *Args[] = {"-xc++", "-std=c++26"};
   ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
std::size(Args), nullptr, 0, TUFlags);
-  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0u);
   std::optional staticAssertCsr;
   Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
 if (cursor.kind == CXCursor_StaticAssert) {
@@ -1229,7 +1229,7 @@
 return CXChildVisit_Continue;
   });
   ASSERT_TRUE(staticAssertCsr.has_value());
-  size_t argCnt = 0;
+  int argCnt = 0;
   Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
 switch (argCnt) {
 case 0:


Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1220,7 +1220,7 @@
   const char *Args[] = {"-xc++", "-std=c++26"};
   ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
std::size(Args), nullptr, 0, TUFlags);
-  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0u);
   std::optional staticAssertCsr;
   Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
 if (cursor.kind == CXCursor_StaticAssert) {
@@ -1229,7 +1229,7 @@
 return CXChildVisit_Continue;
   });
   ASSERT_TRUE(staticAssertCsr.has_value());
-  size_t argCnt = 0;
+  int argCnt = 0;
   Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
 switch (argCnt) {
 case 0:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Kai Stierand via Phabricator via cfe-commits
kiloalphaindia added a comment.

See: https://lab.llvm.org/buildbot/#/builders/57/builds/28680

I couldn't reproduce this on my system. Anyone knows how to test it before 
merging?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[PATCH] D145229: [analyzer] Improve the documentation of the alpha.security.taint.TaintPropagation checker

2023-07-25 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:2471
+  #ifdef __clang_analyzer__
+void csa_mark_sanitized(const void *);
+  #endif

steakhal wrote:
> Have you considered unconditionally having this function with an empty body?
> That way it would have no "noise" at callsite.
But that way the program would not compile, because the definition would not be 
found. Or maybe I misunderstand you.

Maybe in the future we could add an another type of filter function which would 
support validation type of functions: would sanitize the passed parameter only, 
if the function returns with non-null, non-zero.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145229

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


[PATCH] D138263: [clang-format] Supress aligning of trailing namespace comments

2023-07-25 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks updated this revision to Diff 543918.
HazardyKnusperkeks marked 8 inline comments as done.

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

https://reviews.llvm.org/D138263

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/FormatTestComments.cpp

Index: clang/unittests/Format/FormatTestComments.cpp
===
--- clang/unittests/Format/FormatTestComments.cpp
+++ clang/unittests/Format/FormatTestComments.cpp
@@ -3087,6 +3087,118 @@
Style));
 }
 
+TEST_F(FormatTestComments, DontAlignNamespaceComments) {
+  FormatStyle Style = getLLVMStyle();
+  Style.NamespaceIndentation = FormatStyle::NI_All;
+  Style.NamespaceMacros.push_back("TESTSUITE");
+  Style.ShortNamespaceLines = 0;
+
+  StringRef Input = "namespace A {\n"
+"  TESTSUITE(B) {\n"
+"namespace C {\n"
+"  namespace D {} // namespace D\n"
+"  std::string Foo = Bar; // Comment\n"
+"  std::string BazString = Baz;   // C2\n"
+"}  // namespace C\n"
+"  }\n"
+"} // NaMeSpAcE A";
+
+  EXPECT_TRUE(Style.FixNamespaceComments);
+  EXPECT_EQ(Style.AlignTrailingComments.Kind, FormatStyle::TCAS_Always);
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar;   // Comment\n"
+   "  std::string BazString = Baz; // C2\n"
+   "} // namespace C\n"
+   "  } // TESTSUITE(B)\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar; // Comment\n"
+   "  std::string BazString = Baz; // C2\n"
+   "} // namespace C\n"
+   "  } // TESTSUITE(B)\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Leave;
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar; // Comment\n"
+   "  std::string BazString = Baz;   // C2\n"
+   "}  // namespace C\n"
+   "  } // TESTSUITE(B)\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.FixNamespaceComments = false;
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Always;
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar;   // Comment\n"
+   "  std::string BazString = Baz; // C2\n"
+   "} // namespace C\n"
+   "  }\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Never;
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar; // Comment\n"
+   "  std::string BazString = Baz; // C2\n"
+   "} // namespace C\n"
+   "  }\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Leave;
+  verifyFormat("namespace A {\n"
+   "  TESTSUITE(B) {\n"
+   "namespace C {\n"
+   "  namespace D {} // namespace D\n"
+   "  std::string Foo = Bar; // Comment\n"
+   "  std::string BazString = Baz;   // C2\n"
+   "}  // namespace C\n"
+   "  }\n"
+   "} // NaMeSpAcE A",
+   Input, Style);
+
+  Style.AlignTrailingComments.Kind = FormatStyle::TCAS_Always;
+  Style.FixNamespaceComments = true;
+  Input = "namespace A {\n"
+  "  int Foo;\n"
+  "  int Bar;\n"
+  "}\n"
+  "// Comment";
+
+#if 0
+  // FIXME: The following comment is aligned with the namespace comment.
+  verifyFormat("namespace A {\n"
+   "  int Foo;\n"
+   "  int Bar;\n"
+   "} // namespace A\n"
+   " // Comment",
+   Input, Style);
+#endif
+
+  Style.FixNamespaceCommen

[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 543919.
SixWeining added a comment.

Address @xen0n's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/loongarch-mtune-error.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -16,6 +16,9 @@
 using namespace llvm;
 using namespace llvm::LoongArch;
 
+StringRef Arch;
+StringRef TuneCPU;
+
 const FeatureInfo AllFeatures[] = {
 #define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
 #include "llvm/TargetParser/LoongArchTargetParser.def"
@@ -46,3 +49,25 @@
   }
   return false;
 }
+
+bool LoongArch::isValidTuneCPUName(StringRef TuneCPU) {
+  return isValidArchName(TuneCPU);
+}
+
+void LoongArch::fillValidTuneCPUList(SmallVectorImpl &Values) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
+
+void LoongArch::setArch(StringRef Name) { Arch = Name; }
+
+StringRef LoongArch::getArch() { return Arch; }
+
+void LoongArch::setTuneCPU(StringRef Name) { TuneCPU = Name; }
+
+StringRef LoongArch::getTuneCPU() { return TuneCPU; }
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,16 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector &Features);
+bool isValidTuneCPUName(StringRef TuneCPU);
+void fillValidTuneCPUList(SmallVectorImpl &Values);
+StringRef getDefaultArch(bool Is64Bit);
+void setArch(StringRef Arch);
+StringRef getArch();
+void setTuneCPU(StringRef TuneCPU);
+StringRef getTuneCPU();
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_

[PATCH] D146368: [clang-tidy] Add readability-reference-to-constructed-temporary check

2023-07-25 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReferenceToConstructedTemporaryCheck.cpp:39
+  ID) {
+  NotExtendedByDeclBoundToPredicate Predicate;
+  Predicate.ID = ID;

xgupta wrote:
> Can be written using direct initialization as  
> `NotExtendedByDeclBoundToPredicate Predicate{ID};`
Yes, but I followed like others are done.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/reference-to-constructed-temporary.rst:18
+
+   const std::string& value("hello");
+

xgupta wrote:
> The below comment is not matching,  do you want to write - 
> `const std::string& str = std::string("hello");`
> ?
actually comment is +- fine, constructor to std::string will be called anyway, 
and for compiler I think those 2 are equal.
Will verify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146368

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


[PATCH] D156228: [clang-format][NFCish] Obey debug settings

2023-07-25 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks created this revision.
HazardyKnusperkeks added a reviewer: klimek.
HazardyKnusperkeks added a project: clang-format.
Herald added projects: All, clang.
Herald added a subscriber: cfe-commits.
Herald added reviewers: rymiel, owenpan, MyDeveloperDay.
HazardyKnusperkeks requested review of this revision.

Otherwise it will print (in a debug build) always.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156228

Files:
  clang/lib/Format/MacroCallReconstructor.cpp


Index: clang/lib/Format/MacroCallReconstructor.cpp
===
--- clang/lib/Format/MacroCallReconstructor.cpp
+++ clang/lib/Format/MacroCallReconstructor.cpp
@@ -319,30 +319,31 @@
   assert(Token->MacroCtx &&
  (ActiveExpansions.size() >= Token->MacroCtx->EndOfExpansion));
   for (size_t I = 0; I < Token->MacroCtx->EndOfExpansion; ++I) {
-#ifndef NDEBUG
-// Check all remaining tokens but the final closing parenthesis and 
optional
-// trailing comment were already reconstructed at an inner expansion level.
-for (auto T = ActiveExpansions.back().SpelledI;
- T != ActiveExpansions.back().SpelledE; ++T) {
-  FormatToken *Token = T->Tok;
-  bool ClosingParen = (std::next(T) == ActiveExpansions.back().SpelledE ||
-   std::next(T)->Tok->isTrailingComment()) &&
-  !Token->MacroCtx && Token->is(tok::r_paren);
-  bool TrailingComment = Token->isTrailingComment();
-  bool PreviousLevel =
-  Token->MacroCtx &&
-  (ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size());
-  if (!ClosingParen && !TrailingComment && !PreviousLevel)
-llvm::dbgs() << "At token: " << Token->TokenText << "\n";
-  // In addition to the following cases, we can also run into this
-  // when a macro call had more arguments than expected; in that case,
-  // the comma and the remaining tokens in the macro call will potentially
-  // end up in the line when we finish the expansion.
-  // FIXME: Add the information which arguments are unused, and assert
-  // one of the cases below plus reconstructed macro argument tokens.
-  // assert(ClosingParen || TrailingComment || PreviousLevel);
-}
-#endif
+LLVM_DEBUG([&] {
+  // Check all remaining tokens but the final closing parenthesis and
+  // optional trailing comment were already reconstructed at an inner
+  // expansion level.
+  for (auto T = ActiveExpansions.back().SpelledI;
+   T != ActiveExpansions.back().SpelledE; ++T) {
+FormatToken *Token = T->Tok;
+bool ClosingParen = (std::next(T) == ActiveExpansions.back().SpelledE 
||
+ std::next(T)->Tok->isTrailingComment()) &&
+!Token->MacroCtx && Token->is(tok::r_paren);
+bool TrailingComment = Token->isTrailingComment();
+bool PreviousLevel =
+Token->MacroCtx &&
+(ActiveExpansions.size() < Token->MacroCtx->ExpandedFrom.size());
+if (!ClosingParen && !TrailingComment && !PreviousLevel)
+  llvm::dbgs() << "At token: " << Token->TokenText << "\n";
+// In addition to the following cases, we can also run into this
+// when a macro call had more arguments than expected; in that case,
+// the comma and the remaining tokens in the macro call will
+// potentially end up in the line when we finish the expansion.
+// FIXME: Add the information which arguments are unused, and assert
+// one of the cases below plus reconstructed macro argument tokens.
+// assert(ClosingParen || TrailingComment || PreviousLevel);
+  }
+}());
 // Handle the remaining open tokens:
 // - expand the closing parenthesis, if it exists, including an optional
 //   trailing comment


Index: clang/lib/Format/MacroCallReconstructor.cpp
===
--- clang/lib/Format/MacroCallReconstructor.cpp
+++ clang/lib/Format/MacroCallReconstructor.cpp
@@ -319,30 +319,31 @@
   assert(Token->MacroCtx &&
  (ActiveExpansions.size() >= Token->MacroCtx->EndOfExpansion));
   for (size_t I = 0; I < Token->MacroCtx->EndOfExpansion; ++I) {
-#ifndef NDEBUG
-// Check all remaining tokens but the final closing parenthesis and optional
-// trailing comment were already reconstructed at an inner expansion level.
-for (auto T = ActiveExpansions.back().SpelledI;
- T != ActiveExpansions.back().SpelledE; ++T) {
-  FormatToken *Token = T->Tok;
-  bool ClosingParen = (std::next(T) == ActiveExpansions.back().SpelledE ||
-   std::next(T)->Tok->isTrailingComment()) &&
-  !Token->MacroCtx && Token->is(tok::r_paren);
-  bool TrailingComment = Token->isTrailingComment();
-  bool PreviousLevel =
-  Token->MacroCtx &&
-  (ActiveExpan

[PATCH] D155814: Fix the linting problems which causes `clang/utils/ci/run-buildbot check-format` to return 1.

2023-07-25 Thread Amirreza Ashouri via Phabricator via cfe-commits
AMP999 added subscribers: gmail.com, Google.com.
AMP999 added a comment.

BTW my Email in one of my previous patches is inserted incorrectly. I 
appreciate if you could possibly fix that for me.
my Email in this 0fd4175907b40fe63131482c162d7e0f76000521 
 commit, 
is inserted @google.com instead of @gmail.com.
Thank You!


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

https://reviews.llvm.org/D155814

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


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Kai Stierand via Phabricator via cfe-commits
kiloalphaindia added a comment.

Also affects: clang-ppc64-aix
https://lab.llvm.org/buildbot/#/builders/214/builds/8649


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[PATCH] D85917: [MSP430] Fix passing C structs and unions as function arguments

2023-07-25 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Sorry for a hung patch. After getting the approval I had doubts that I 
interpret the corner cases of LLVM IR correctly. Thus, I postponed the patch 
these days to not subtly break the stable targets while fixing one issue on 
MSP430.

I can re-evaluate this patch if it is still relevant.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85917

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


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a subscriber: aaron.ballman.
cor3ntin added a comment.

Thanks for the quick fix. Any idea why it would only show up on ppc64 
@aaron.ballman ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Kai Stierand via Phabricator via cfe-commits
kiloalphaindia added a comment.

It could also be a different version of gtest or so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156224#4531659 , @cor3ntin wrote:

> Thanks for the quick fix. Any idea why it would only show up on ppc64 
> @aaron.ballman ?

Not certain, to be honest. The diagnostic is enabled by `-Wextra` so I would 
have imagined this was enabled all over. My guess is that this bot was 
configured with `-Werror` whereas other bots showed the issue but as a warning.

Changes LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[clang] d031ff3 - [Sema] Fix handling of functions that hide classes

2023-07-25 Thread John Brawn via cfe-commits

Author: John Brawn
Date: 2023-07-25T12:30:41+01:00
New Revision: d031ff38779bd688c514136dbdcce3169ee82b6e

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

LOG: [Sema] Fix handling of functions that hide classes

When a function is declared in the same scope as a class with the same
name then the function hides that class. Currently this is done by a
single check after the main loop in LookupResult::resolveKind, but
this can give the wrong result when we have a using declaration in
multiple namespace scopes in two different ways:

 * When the using declaration is hidden in one namespace but not the
   other we can end up considering only the hidden one when deciding
   if the result is ambiguous, causing an incorrect "not ambiguous"
   result.

 * When two classes with the same name in different namespace scopes
   are both hidden by using declarations this can result in
   incorrectly deciding the result is ambiguous. There's currently a
   comment saying this is expected, but I don't think that's correct.

Solve this by checking each Decl to see if it's hidden by some other
Decl in the same scope. This means we have to delay removing anything
from Decls until after the main loop, in case a Decl is hidden by
another that is removed due to being non-unique.

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

Added: 
clang/test/SemaCXX/using-hiding.cpp

Modified: 
clang/lib/Sema/SemaLookup.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d1ff688c2a21d0..c4f4edbcc1 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -513,21 +513,42 @@ void LookupResult::resolveKind() {
   const NamedDecl *HasNonFunction = nullptr;
 
   llvm::SmallVector EquivalentNonFunctions;
+  llvm::BitVector RemovedDecls(N);
 
-  unsigned UniqueTagIndex = 0;
-
-  unsigned I = 0;
-  while (I < N) {
+  for (unsigned I = 0; I < N; I++) {
 const NamedDecl *D = Decls[I]->getUnderlyingDecl();
 D = cast(D->getCanonicalDecl());
 
 // Ignore an invalid declaration unless it's the only one left.
 // Also ignore HLSLBufferDecl which not have name conflict with other 
Decls.
-if ((D->isInvalidDecl() || isa(D)) && !(I == 0 && N == 1)) 
{
-  Decls[I] = Decls[--N];
+if ((D->isInvalidDecl() || isa(D)) &&
+N - RemovedDecls.count() > 1) {
+  RemovedDecls.set(I);
   continue;
 }
 
+// C++ [basic.scope.hiding]p2:
+//   A class name or enumeration name can be hidden by the name of
+//   an object, function, or enumerator declared in the same
+//   scope. If a class or enumeration name and an object, function,
+//   or enumerator are declared in the same scope (in any order)
+//   with the same name, the class or enumeration name is hidden
+//   wherever the object, function, or enumerator name is visible.
+if (HideTags && isa(D)) {
+  bool Hidden = false;
+  for (auto *OtherDecl : Decls) {
+if (canHideTag(OtherDecl) &&
+getContextForScopeMatching(OtherDecl)->Equals(
+getContextForScopeMatching(Decls[I]))) {
+  RemovedDecls.set(I);
+  Hidden = true;
+  break;
+}
+  }
+  if (Hidden)
+continue;
+}
+
 std::optional ExistingI;
 
 // Redeclarations of types via typedef can occur both within a scope
@@ -560,7 +581,7 @@ void LookupResult::resolveKind() {
   if (isPreferredLookupResult(getSema(), getLookupKind(), Decls[I],
   Decls[*ExistingI]))
 Decls[*ExistingI] = Decls[I];
-  Decls[I] = Decls[--N];
+  RemovedDecls.set(I);
   continue;
 }
 
@@ -571,7 +592,6 @@ void LookupResult::resolveKind() {
 } else if (isa(D)) {
   if (HasTag)
 Ambiguous = true;
-  UniqueTagIndex = I;
   HasTag = true;
 } else if (isa(D)) {
   HasFunction = true;
@@ -587,7 +607,7 @@ void LookupResult::resolveKind() {
 if (getSema().isEquivalentInternalLinkageDeclaration(HasNonFunction,
  D)) {
   EquivalentNonFunctions.push_back(D);
-  Decls[I] = Decls[--N];
+  RemovedDecls.set(I);
   continue;
 }
 
@@ -595,28 +615,6 @@ void LookupResult::resolveKind() {
   }
   HasNonFunction = D;
 }
-I++;
-  }
-
-  // C++ [basic.scope.hiding]p2:
-  //   A class name or enumeration name can be hidden by the name of
-  //   an object, function, or enumerator declared in the same
-  //   scope. If a class or enumeration name and an object, function,
-  //   or enumerator are declared in the same scope (in any order)
-  //   with the same name, the class or enumeration name is hidden
-  //   wherever t

[clang] 71be91e - HIP: Directly call rint builtins

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

Author: Matt Arsenault
Date: 2023-07-25T07:54:11-04:00
New Revision: 71be91eba96d80d15689e4f516141c533c3c086d

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

LOG: HIP: Directly call rint builtins

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h
clang/test/Headers/__clang_hip_math.hip

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index 86013d0ffc2b7a..c12777f0476f1b 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -309,7 +309,7 @@ __DEVICE__
 float lgammaf(float __x) { return __ocml_lgamma_f32(__x); }
 
 __DEVICE__
-long long int llrintf(float __x) { return __ocml_rint_f32(__x); }
+long long int llrintf(float __x) { return __builtin_rintf(__x); }
 
 __DEVICE__
 long long int llroundf(float __x) { return __builtin_roundf(__x); }
@@ -330,7 +330,7 @@ __DEVICE__
 float logf(float __x) { return __builtin_logf(__x); }
 
 __DEVICE__
-long int lrintf(float __x) { return __ocml_rint_f32(__x); }
+long int lrintf(float __x) { return __builtin_rintf(__x); }
 
 __DEVICE__
 long int lroundf(float __x) { return __builtin_roundf(__x); }
@@ -435,7 +435,7 @@ __DEVICE__
 float rhypotf(float __x, float __y) { return __ocml_rhypot_f32(__x, __y); }
 
 __DEVICE__
-float rintf(float __x) { return __ocml_rint_f32(__x); }
+float rintf(float __x) { return __builtin_rintf(__x); }
 
 __DEVICE__
 float rnorm3df(float __x, float __y, float __z) {
@@ -857,7 +857,7 @@ __DEVICE__
 double lgamma(double __x) { return __ocml_lgamma_f64(__x); }
 
 __DEVICE__
-long long int llrint(double __x) { return __ocml_rint_f64(__x); }
+long long int llrint(double __x) { return __builtin_rint(__x); }
 
 __DEVICE__
 long long int llround(double __x) { return __builtin_round(__x); }
@@ -878,7 +878,7 @@ __DEVICE__
 double logb(double __x) { return __ocml_logb_f64(__x); }
 
 __DEVICE__
-long int lrint(double __x) { return __ocml_rint_f64(__x); }
+long int lrint(double __x) { return __builtin_rint(__x); }
 
 __DEVICE__
 long int lround(double __x) { return __builtin_round(__x); }
@@ -991,7 +991,7 @@ __DEVICE__
 double rhypot(double __x, double __y) { return __ocml_rhypot_f64(__x, __y); }
 
 __DEVICE__
-double rint(double __x) { return __ocml_rint_f64(__x); }
+double rint(double __x) { return __builtin_rint(__x); }
 
 __DEVICE__
 double rnorm(int __dim,

diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index bfb66ce27e6171..aa31654deccc43 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -1479,14 +1479,14 @@ extern "C" __device__ double test_lgamma(double x) {
 
 // DEFAULT-LABEL: @test_llrintf(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract float 
@__ocml_rint_f32(float noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi float [[CALL_I]] to i64
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.rint.f32(float [[X:%.*]])
+// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi float [[TMP0]] to i64
 // DEFAULT-NEXT:ret i64 [[CONV_I]]
 //
 // FINITEONLY-LABEL: @test_llrintf(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract 
nofpclass(nan inf) float @__ocml_rint_f32(float noundef nofpclass(nan inf) 
[[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi float [[CALL_I]] to i64
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract float 
@llvm.rint.f32(float [[X:%.*]])
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi float [[TMP0]] to i64
 // FINITEONLY-NEXT:ret i64 [[CONV_I]]
 //
 extern "C" __device__ long long int test_llrintf(float x) {
@@ -1495,14 +1495,14 @@ extern "C" __device__ long long int test_llrintf(float 
x) {
 
 // DEFAULT-LABEL: @test_llrint(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract double 
@__ocml_rint_f64(double noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi double [[CALL_I]] to i64
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract double 
@llvm.rint.f64(double [[X:%.*]])
+// DEFAULT-NEXT:[[CONV_I:%.*]] = fptosi double [[TMP0]] to i64
 // DEFAULT-NEXT:ret i64 [[CONV_I]]
 //
 // FINITEONLY-LABEL: @test_llrint(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract 
nofpclass(nan inf) double @__ocml_rint_f64(double noundef nofpclass(nan inf) 
[[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi double [[CALL_I]] to i64
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract double 
@llvm.rint.f64(double [[X:%.*]])
+// FINITEONLY-NEXT:[[CONV_I:%.*]] = fptosi double [[TMP0]] to i64
 // FINITEONLY

[PATCH] D154503: [Sema] Fix handling of functions that hide classes

2023-07-25 Thread John Brawn via Phabricator via cfe-commits
john.brawn added a comment.

The first version of this that I committed caused a failure in  
clang/test/Modules/stress1.cpp so I reverted it. I've now committed a new 
version that handles the removal of existing decl when isPreferredLookupResult 
is true in a slightly different way, which should fix that failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D154503

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


[PATCH] D156229: [clang][dataflow] Remove checks that test for consistency between `StructValue` and `AggregateStorageLocation`.

2023-07-25 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Now that the redundancy between these two classes has been eliminated, these
checks aren't needed any more.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156229

Files:
  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
@@ -27,11 +27,6 @@
 #include 
 #include 
 
-// FIXME: There are still remaining checks here that check for consistency
-// between `StructValue` and `AggregateStorageLocation`. Now that the redundancy
-// between these two classes has been eliminated, these checks aren't needed any
-// more, so remove them.
-
 namespace {
 
 using namespace clang;
@@ -268,13 +263,7 @@
 
 const auto *FooLoc =
 cast(Env.getStorageLocation(*FooDecl));
-const auto *BarLoc =
-cast(FooLoc->getChild(*BarDecl));
-
-const auto *FooVal = cast(Env.getValue(*FooLoc));
-const auto *BarVal =
-cast(getFieldValue(FooVal, *BarDecl, Env));
-EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env)));
   });
 }
 
@@ -317,13 +306,7 @@
 
 const auto *FooLoc =
 cast(Env.getStorageLocation(*FooDecl));
-const auto *BarLoc =
-cast(FooLoc->getChild(*BarDecl));
-
-const auto *FooVal = cast(Env.getValue(*FooLoc));
-const auto *BarVal =
-cast(getFieldValue(FooVal, *BarDecl, Env));
-EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env)));
   });
 }
 
@@ -365,13 +348,7 @@
 
 const auto *FooLoc =
 cast(Env.getStorageLocation(*FooDecl));
-const auto *BarLoc =
-cast(FooLoc->getChild(*BarDecl));
-
-const auto *FooVal = cast(Env.getValue(*FooLoc));
-const auto *BarVal =
-cast(getFieldValue(FooVal, *BarDecl, Env));
-EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env)));
   });
 }
 
@@ -1046,13 +1023,7 @@
 
 const auto *FooLoc =
 cast(Env.getStorageLocation(*FooDecl));
-const auto *BarLoc =
-cast(FooLoc->getChild(*BarDecl));
-
-const auto *FooVal = cast(Env.getValue(*FooLoc));
-const auto *BarVal =
-cast(getFieldValue(FooVal, *BarDecl, Env));
-EXPECT_EQ(Env.getValue(*BarLoc), BarVal);
+EXPECT_TRUE(isa(getFieldValue(FooLoc, *BarDecl, Env)));
   });
 }
 
@@ -1150,9 +1121,8 @@
 
 const auto *FooLoc =
 cast(Env.getStorageLocation(*FooDecl));
-const auto *FooVal = cast(Env.getValue(*FooLoc));
 const auto *BarVal =
-cast(getFieldValue(FooVal, *BarDecl, Env));
+cast(getFieldValue(FooLoc, *BarDecl, Env));
 
 const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
 ASSERT_THAT(BazDecl, NotNull());
@@ -1392,9 +1362,8 @@
 
 const auto *FooLoc =
 cast(Env.getStorageLocation(*FooDecl));
-const auto *FooVal = cast(Env.getValue(*FooLoc));
 const auto *BarVal =
-cast(getFieldValue(FooVal, *BarDecl, Env));
+cast(getFieldValue(FooLoc, *BarDecl, Env));
 
 const ValueDecl *BazDecl = findValueDecl(ASTCtx, "Baz");
 ASSERT_THAT(BazDecl, NotNull());
@@ -1553,14 +1522,10 @@
 
 const auto *QuxLoc =
 cast(ThisLoc->getChild(*QuxDecl));
-const auto *QuxVal = dyn_cast(Env.getValue(*QuxLoc));
-ASSERT_THAT(QuxVal, NotNull());
+EXPECT_THAT(dyn_cast(Env.getValue(*QuxLoc)), NotNull());
 
-const auto *BazLoc =
-cast(QuxLoc->getChild(*BazDecl));
 const auto *BazVal =
-cast(getFieldValue(QuxVal, *BazDecl, Env));
-EXPECT_EQ(Env.getValue(*BazLoc), BazVal);
+cast(getFieldValue(QuxLoc, *BazDecl, Env));
 
 const ValueDecl *QuuxDecl = findValueDecl(ASTCtx, "Quux");
 ASSERT_THAT(QuuxDecl, NotNull());
@@ -1628,14 +1593,10 @@
 
 const auto *QuxLoc =
 cast(ThisLoc->getChild(*QuxDecl));
-const auto *QuxVal = dyn_cast(Env.getValue(*QuxLoc));
-ASSERT_THAT(QuxVal, NotNull());
+EXPECT_THAT(dyn_cast(Env.getValue(*QuxLoc)), NotNull());
 
-const auto *BazLoc =
-cast(QuxLoc->getChild(*BazDecl));
 const auto *BazVal =
-cast(getFieldValue(QuxVal, *BazDecl, Env));
-EXPECT_EQ(Env.getValue(*BazLoc), BazVal);
+cast(getFieldValue(QuxLoc, *BazDecl, Env));
 
 const ValueDec

[clang] e7ab698 - HIP: Directly call nearbyint builtins

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

Author: Matt Arsenault
Date: 2023-07-25T07:56:31-04:00
New Revision: e7ab6982de87b14c9584e1267cd755561b4c063c

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

LOG: HIP: Directly call nearbyint builtins

Added: 


Modified: 
clang/lib/Headers/__clang_hip_math.h
clang/test/Headers/__clang_hip_math.hip

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_math.h 
b/clang/lib/Headers/__clang_hip_math.h
index c12777f0476f1b..a47dda3327f438 100644
--- a/clang/lib/Headers/__clang_hip_math.h
+++ b/clang/lib/Headers/__clang_hip_math.h
@@ -369,7 +369,7 @@ float nanf(const char *__tagp __attribute__((nonnull))) {
 }
 
 __DEVICE__
-float nearbyintf(float __x) { return __ocml_nearbyint_f32(__x); }
+float nearbyintf(float __x) { return __builtin_nearbyintf(__x); }
 
 __DEVICE__
 float nextafterf(float __x, float __y) {
@@ -925,7 +925,7 @@ double nan(const char *__tagp) {
 }
 
 __DEVICE__
-double nearbyint(double __x) { return __ocml_nearbyint_f64(__x); }
+double nearbyint(double __x) { return __builtin_nearbyint(__x); }
 
 __DEVICE__
 double nextafter(double __x, double __y) {

diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index aa31654deccc43..85d559f161da92 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -1996,13 +1996,13 @@ extern "C" __device__ double test_nan_fill() {
 
 // DEFAULT-LABEL: @test_nearbyintf(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract float 
@__ocml_nearbyint_f32(float noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:ret float [[CALL_I]]
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.nearbyint.f32(float [[X:%.*]])
+// DEFAULT-NEXT:ret float [[TMP0]]
 //
 // FINITEONLY-LABEL: @test_nearbyintf(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract 
nofpclass(nan inf) float @__ocml_nearbyint_f32(float noundef nofpclass(nan inf) 
[[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:ret float [[CALL_I]]
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract float 
@llvm.nearbyint.f32(float [[X:%.*]])
+// FINITEONLY-NEXT:ret float [[TMP0]]
 //
 extern "C" __device__ float test_nearbyintf(float x) {
   return nearbyintf(x);
@@ -2010,13 +2010,13 @@ extern "C" __device__ float test_nearbyintf(float x) {
 
 // DEFAULT-LABEL: @test_nearbyint(
 // DEFAULT-NEXT:  entry:
-// DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract double 
@__ocml_nearbyint_f64(double noundef [[X:%.*]]) #[[ATTR14]]
-// DEFAULT-NEXT:ret double [[CALL_I]]
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract double 
@llvm.nearbyint.f64(double [[X:%.*]])
+// DEFAULT-NEXT:ret double [[TMP0]]
 //
 // FINITEONLY-LABEL: @test_nearbyint(
 // FINITEONLY-NEXT:  entry:
-// FINITEONLY-NEXT:[[CALL_I:%.*]] = tail call nnan ninf contract 
nofpclass(nan inf) double @__ocml_nearbyint_f64(double noundef nofpclass(nan 
inf) [[X:%.*]]) #[[ATTR14]]
-// FINITEONLY-NEXT:ret double [[CALL_I]]
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract double 
@llvm.nearbyint.f64(double [[X:%.*]])
+// FINITEONLY-NEXT:ret double [[TMP0]]
 //
 extern "C" __device__ double test_nearbyint(double x) {
   return nearbyint(x);



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


[PATCH] D156230: [clang][dataflow][NFC] Eliminate variable only used in assertion.

2023-07-25 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This can break release builds that set `-Werror` because they will error out on
an unused variable.

Depends On D156229 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156230

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


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -122,12 +122,11 @@
 
   Value *MergedVal = nullptr;
   if (auto *StructVal1 = dyn_cast(&Val1)) {
-auto *StructVal2 = cast(&Val2);
-
 // Values to be merged are always associated with the same location in
 // `LocToVal`. The location stored in `StructVal` should therefore also
 // be the same.
-assert(&StructVal1->getAggregateLoc() == &StructVal2->getAggregateLoc());
+assert(&StructVal1->getAggregateLoc() ==
+   &cast(&Val2)->getAggregateLoc());
 
 // `StructVal1` and `StructVal2` may have different properties associated
 // with them. Create a new `StructValue` without any properties so that we


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -122,12 +122,11 @@
 
   Value *MergedVal = nullptr;
   if (auto *StructVal1 = dyn_cast(&Val1)) {
-auto *StructVal2 = cast(&Val2);
-
 // Values to be merged are always associated with the same location in
 // `LocToVal`. The location stored in `StructVal` should therefore also
 // be the same.
-assert(&StructVal1->getAggregateLoc() == &StructVal2->getAggregateLoc());
+assert(&StructVal1->getAggregateLoc() ==
+   &cast(&Val2)->getAggregateLoc());
 
 // `StructVal1` and `StructVal2` may have different properties associated
 // with them. Create a new `StructValue` without any properties so that we
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 0d12683 - Revert "[OpenMP] Add the `ompx_attribute` clause for target directives"

2023-07-25 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-07-25T07:57:36-04:00
New Revision: 0d12683046ca75fb08e285f4622f2af5c82609dc

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

LOG: Revert "[OpenMP] Add the `ompx_attribute` clause for target directives"

This reverts commit ef9ec4bbcca2fa4f64df47bc426f1d1c59ea47e2.

The changes broke several bots:
https://lab.llvm.org/buildbot/#/builders/176/builds/3408
https://lab.llvm.org/buildbot/#/builders/198/builds/4028
https://lab.llvm.org/buildbot/#/builders/197/builds/8491
https://lab.llvm.org/buildbot/#/builders/197/builds/8491

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Basic/DiagnosticGroups.td
clang/include/clang/Basic/DiagnosticParseKinds.td
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/Targets/AMDGPU.cpp
clang/lib/CodeGen/Targets/NVPTX.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 
clang/test/OpenMP/ompx_attributes_codegen.cpp
clang/test/OpenMP/ompx_attributes_messages.cpp



diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 31ae3d42e232fc..0bea21270692cf 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -9172,54 +9172,6 @@ class OMPDoacrossClause final
   }
 };
 
-/// This represents 'ompx_attribute' clause in a directive that might generate
-/// an outlined function. An example is given below.
-///
-/// \code
-/// #pragma omp target [...] ompx_attribute(flatten)
-/// \endcode
-class OMPXAttributeClause
-: public OMPNoChildClause {
-  friend class OMPClauseReader;
-
-  /// Location of '('.
-  SourceLocation LParenLoc;
-
-  /// The parsed attributes (clause arguments)
-  SmallVector Attrs;
-
-public:
-  /// Build 'ompx_attribute' clause.
-  ///
-  /// \param Attrs The parsed attributes (clause arguments)
-  /// \param StartLoc Starting location of the clause.
-  /// \param LParenLoc Location of '('.
-  /// \param EndLoc Ending location of the clause.
-  OMPXAttributeClause(ArrayRef Attrs, SourceLocation StartLoc,
-  SourceLocation LParenLoc, SourceLocation EndLoc)
-  : OMPNoChildClause(StartLoc, EndLoc), LParenLoc(LParenLoc), Attrs(Attrs) 
{
-  }
-
-  /// Build an empty clause.
-  OMPXAttributeClause() : OMPNoChildClause() {}
-
-  /// Sets the location of '('.
-  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
-
-  /// Returns the location of '('.
-  SourceLocation getLParenLoc() const { return LParenLoc; }
-
-  /// Returned the attributes parsed from this clause.
-  ArrayRef getAttrs() const { return Attrs; }
-
-private:
-  /// Replace the attributes with \p NewAttrs.
-  void setAttrs(ArrayRef NewAttrs) {
-Attrs.clear();
-Attrs.append(NewAttrs.begin(), NewAttrs.end());
-  }
-};
-
 } // namespace clang
 
 #endif // LLVM_CLANG_AST_OPENMPCLAUSE_H

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index fc2d1ff708bf7a..604875cd6337a4 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3875,12 +3875,6 @@ bool 
RecursiveASTVisitor::VisitOMPDoacrossClause(
   return true;
 }
 
-template 
-bool RecursiveASTVisitor::VisitOMPXAttributeClause(
-OMPXAttributeClause *C) {
-  return true;
-}
-
 // FIXME: look at the following tricky-seeming exprs to see if we
 // need to recurse on anything.  These are ones that have methods
 // returning decls or qualtypes or nestednamespecifier -- though I'm

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 6a0a01e4a981a4..7b4d415bf06494 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -1278,10 +1278,9 @@ def OpenMPMapping : DiagGroup<"openmp-mapping">;
 def OpenMPTarget : DiagGroup<"openmp-target", [OpenMPMapping]>;
 def OpenMPPre51Compat : DiagGroup<"pre-openmp-51-compat">;
 def OpenMP51Ext : DiagGroup<"openmp-51-extensions">;
-def OpenMPExtensions : DiagGroup<"openmp-extensions">;
 def OpenMP : DiagGroup<"openmp", [
 SourceUsesOpenMP, OpenMPClauses, OpenMPLoopForm, OpenMPTarget,
-OpenMPMapping, OpenMP51Ext, OpenMPExtensions
+OpenMPMapping, OpenMP5

[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.
This revision is now accepted and ready to land.

I was able to confirm on my machine that the warnings are no longer emitted. 
They were there when i committed the initial patch, i just missed them. Sorry 
about that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[PATCH] D156184: [OpenMP] Add the `ompx_attribute` clause for target directives

2023-07-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D156184#4531193 , @antmo wrote:

> Hi, it looks like this patch broke some flang bots:
>
> - https://lab.llvm.org/buildbot/#/builders/176/builds/3408
> - https://lab.llvm.org/buildbot/#/builders/198/builds/4028
> - https://lab.llvm.org/buildbot/#/builders/197/builds/8491
> - https://lab.llvm.org/buildbot/#/builders/197/builds/8491
>
> Could you please take a look?

Because the bots are still down, I went ahead and reverted in 
https://github.com/llvm/llvm-project/commit/0d12683046ca75fb08e285f4622f2af5c82609dc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156184

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


[clang] d0b54bb - [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Corentin Jabot via cfe-commits

Author: Kai Stierand
Date: 2023-07-25T13:58:30+02:00
New Revision: d0b54bb50e5110a004b41fc06dadf3fee70834b7

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

LOG: [Clang] use unsigned integer constants in unit-test | fixes build error on 
ppc64le-lld-multistage-test

Fixes:

/home/buildbots/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1526:11:
 warning: comparison of integer expressions of different signedness: ‘const 
unsigned int’ and ‘const int’ [-Wsign-compare]

/home/buildbots/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1526:11:
 warning: comparison of integer expressions of different signedness: ‘const 
long unsigned int’ and ‘const int’ [-Wsign-compare]

Reviewed By: cor3ntin

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

Added: 


Modified: 
clang/unittests/libclang/LibclangTest.cpp

Removed: 




diff  --git a/clang/unittests/libclang/LibclangTest.cpp 
b/clang/unittests/libclang/LibclangTest.cpp
index b1f653441d0efe..295706c9e6ff8b 100644
--- a/clang/unittests/libclang/LibclangTest.cpp
+++ b/clang/unittests/libclang/LibclangTest.cpp
@@ -1220,7 +1220,7 @@ static_assert(true, message);
   const char *Args[] = {"-xc++", "-std=c++26"};
   ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
std::size(Args), nullptr, 0, TUFlags);
-  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0u);
   std::optional staticAssertCsr;
   Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
 if (cursor.kind == CXCursor_StaticAssert) {
@@ -1229,7 +1229,7 @@ static_assert(true, message);
 return CXChildVisit_Continue;
   });
   ASSERT_TRUE(staticAssertCsr.has_value());
-  size_t argCnt = 0;
+  int argCnt = 0;
   Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
 switch (argCnt) {
 case 0:



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


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Corentin Jabot 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 rGd0b54bb50e51: [Clang] use unsigned integer constants in 
unit-test | fixes build error on… (authored by kiloalphaindia, committed by 
cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

Files:
  clang/unittests/libclang/LibclangTest.cpp


Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1220,7 +1220,7 @@
   const char *Args[] = {"-xc++", "-std=c++26"};
   ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
std::size(Args), nullptr, 0, TUFlags);
-  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0u);
   std::optional staticAssertCsr;
   Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
 if (cursor.kind == CXCursor_StaticAssert) {
@@ -1229,7 +1229,7 @@
 return CXChildVisit_Continue;
   });
   ASSERT_TRUE(staticAssertCsr.has_value());
-  size_t argCnt = 0;
+  int argCnt = 0;
   Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
 switch (argCnt) {
 case 0:


Index: clang/unittests/libclang/LibclangTest.cpp
===
--- clang/unittests/libclang/LibclangTest.cpp
+++ clang/unittests/libclang/LibclangTest.cpp
@@ -1220,7 +1220,7 @@
   const char *Args[] = {"-xc++", "-std=c++26"};
   ClangTU = clang_parseTranslationUnit(Index, fileName.c_str(), Args,
std::size(Args), nullptr, 0, TUFlags);
-  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0);
+  ASSERT_EQ(clang_getNumDiagnostics(ClangTU), 0u);
   std::optional staticAssertCsr;
   Traverse([&](CXCursor cursor, CXCursor parent) -> CXChildVisitResult {
 if (cursor.kind == CXCursor_StaticAssert) {
@@ -1229,7 +1229,7 @@
 return CXChildVisit_Continue;
   });
   ASSERT_TRUE(staticAssertCsr.has_value());
-  size_t argCnt = 0;
+  int argCnt = 0;
   Traverse(*staticAssertCsr, [&argCnt](CXCursor cursor, CXCursor parent) {
 switch (argCnt) {
 case 0:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4706251 - Clear release notes for 18.x

2023-07-25 Thread Tobias Hieta via cfe-commits

Author: Tobias Hieta
Date: 2023-07-25T13:58:49+02:00
New Revision: 4706251a3186c34da0ee8fd894f7e6b095da8fdc

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

LOG: Clear release notes for 18.x

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang/docs/ReleaseNotes.rst
flang/docs/ReleaseNotes.md
lld/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst
openmp/docs/ReleaseNotes.rst
polly/docs/ReleaseNotes.rst
pstl/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 236226e8b73a94..e602fceda6b1f7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,451 +94,15 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New global configuration file options `HeaderFileExtensions` and
-  `ImplementationFileExtensions`, replacing the check-local options of the
-  same name.
-
-- Support specifying `Checks` as a YAML list in the `.clang-tidy` configuration
-  file.
-
-- Fix a potential crash when using the `--dump-config` option.
-
-- Support specifying `SystemHeaders` in the `.clang-tidy` configuration file,
-  with the same functionality as the command-line option `--system-headers`.
-
-- `WarningsAsErrors` (`--warnings-as-errors=`) no longer promotes unlisted
-  warnings to errors. Only the warnings listed in `Checks` (`--checks=`) will
-  be promoted to errors. For custom error promotion, use `-Werror=`
-  on the compiler command-line, irrespective of `Checks` (`--checks=`) 
settings.
-
-- Fixed an issue where compiler warnings couldn't be suppressed using
-  `-Wno-` under C++20 and above.
-
 New checks
 ^^
 
-- New :doc:`bugprone-empty-catch
-  ` check.
-
-  Detects and suggests addressing issues with empty catch statements.
-
-- New :doc:`bugprone-multiple-new-in-one-expression
-  ` check.
-
-  Finds multiple ``new`` operator calls in a single expression, where the 
allocated
-  memory by the first ``new`` may leak if the second allocation fails and 
throws exception.
-
-- New :doc:`bugprone-non-zero-enum-to-bool-conversion
-  ` check.
-
-  Detect implicit and explicit casts of ``enum`` type into ``bool`` where 
``enum`` type
-  doesn't have a zero-value enumerator.
-
-- New :doc:`bugprone-switch-missing-default-case
-  ` check.
-
-  Ensures that switch statements without default cases are flagged, focuses 
only
-  on covering cases with non-enums where the compiler may not issue warnings.
-
-- New :doc:`bugprone-unique-ptr-array-mismatch
-  ` check.
-
-  Finds initializations of C++ unique pointers to non-array type that are
-  initialized with an array.
-
-- New :doc:`bugprone-unsafe-functions
-  ` check.
-
-  Checks for functions that have safer, more secure replacements available, or
-  are considered deprecated due to design flaws.
-  This check relies heavily on, but is not exclusive to, the functions from
-  the *Annex K. "Bounds-checking interfaces"* of C11.
-
-- New :doc:`cppcoreguidelines-avoid-capturing-lambda-coroutines
-  ` 
check.
-
-  Flags C++20 coroutine lambdas with non-empty capture lists that may cause
-  use-after-free errors and suggests avoiding captures or ensuring the lambda
-  closure object has a guaranteed lifetime.
-
-- New :doc:`cppcoreguidelines-misleading-capture-default-by-value
-  ` 
check.
-
-  Warns when lambda specify a by-value capture default and capture ``this``.
-
-- New :doc:`cppcoreguidelines-missing-std-forward
-  ` check.
-
-  Warns when a forwarding reference parameter is not forwarded within the
-  function body.
-
-- New :doc:`cppcoreguidelines-rvalue-reference-param-not-moved
-  ` 
check.
-
-  Warns when an rvalue reference function parameter is never moved within
-  the function body.
-
-- New :doc:`llvmlibc-inline-function-decl
-  ` check.
-
-  Checks that all implicit and explicit inline functions in header files are
-  tagged with the ``LIBC_INLINE`` macro.
-
-- New :doc:`misc-header-include-cycle
-  ` check.
-
-  Check detects cyclic ``#include`` dependencies between user-defined headers.
-
-- New :doc:`misc-include-cleaner
-  ` check.
-
-  Checks for unused and missing includes.
-
-- New :doc:`modernize-type-traits
-  ` check.
-
-  Converts standard library type traits of the form ``traits<...>::type`` and
-  ``traits<...>::value`` into ``traits_t<...>`` and ``traits_v<...>`` 
respectively.
-
-- New :doc:`modernize-use-std-print
-  ` check.
-
-  Converts calls to ``printf``, ``fprintf``, ``absl::PrintF``,
-  ``absl::FPrintf`` or other functions via configuration options, to
-  equivalent calls to C++23's ``std::print`` and ``std::println``, or other
-  functions via a configuration option, modifying the format string

[clang-tools-extra] 4706251 - Clear release notes for 18.x

2023-07-25 Thread Tobias Hieta via cfe-commits

Author: Tobias Hieta
Date: 2023-07-25T13:58:49+02:00
New Revision: 4706251a3186c34da0ee8fd894f7e6b095da8fdc

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

LOG: Clear release notes for 18.x

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang/docs/ReleaseNotes.rst
flang/docs/ReleaseNotes.md
lld/docs/ReleaseNotes.rst
llvm/docs/ReleaseNotes.rst
openmp/docs/ReleaseNotes.rst
polly/docs/ReleaseNotes.rst
pstl/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 236226e8b73a94..e602fceda6b1f7 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -94,451 +94,15 @@ The improvements are...
 Improvements to clang-tidy
 --
 
-- New global configuration file options `HeaderFileExtensions` and
-  `ImplementationFileExtensions`, replacing the check-local options of the
-  same name.
-
-- Support specifying `Checks` as a YAML list in the `.clang-tidy` configuration
-  file.
-
-- Fix a potential crash when using the `--dump-config` option.
-
-- Support specifying `SystemHeaders` in the `.clang-tidy` configuration file,
-  with the same functionality as the command-line option `--system-headers`.
-
-- `WarningsAsErrors` (`--warnings-as-errors=`) no longer promotes unlisted
-  warnings to errors. Only the warnings listed in `Checks` (`--checks=`) will
-  be promoted to errors. For custom error promotion, use `-Werror=`
-  on the compiler command-line, irrespective of `Checks` (`--checks=`) 
settings.
-
-- Fixed an issue where compiler warnings couldn't be suppressed using
-  `-Wno-` under C++20 and above.
-
 New checks
 ^^
 
-- New :doc:`bugprone-empty-catch
-  ` check.
-
-  Detects and suggests addressing issues with empty catch statements.
-
-- New :doc:`bugprone-multiple-new-in-one-expression
-  ` check.
-
-  Finds multiple ``new`` operator calls in a single expression, where the 
allocated
-  memory by the first ``new`` may leak if the second allocation fails and 
throws exception.
-
-- New :doc:`bugprone-non-zero-enum-to-bool-conversion
-  ` check.
-
-  Detect implicit and explicit casts of ``enum`` type into ``bool`` where 
``enum`` type
-  doesn't have a zero-value enumerator.
-
-- New :doc:`bugprone-switch-missing-default-case
-  ` check.
-
-  Ensures that switch statements without default cases are flagged, focuses 
only
-  on covering cases with non-enums where the compiler may not issue warnings.
-
-- New :doc:`bugprone-unique-ptr-array-mismatch
-  ` check.
-
-  Finds initializations of C++ unique pointers to non-array type that are
-  initialized with an array.
-
-- New :doc:`bugprone-unsafe-functions
-  ` check.
-
-  Checks for functions that have safer, more secure replacements available, or
-  are considered deprecated due to design flaws.
-  This check relies heavily on, but is not exclusive to, the functions from
-  the *Annex K. "Bounds-checking interfaces"* of C11.
-
-- New :doc:`cppcoreguidelines-avoid-capturing-lambda-coroutines
-  ` 
check.
-
-  Flags C++20 coroutine lambdas with non-empty capture lists that may cause
-  use-after-free errors and suggests avoiding captures or ensuring the lambda
-  closure object has a guaranteed lifetime.
-
-- New :doc:`cppcoreguidelines-misleading-capture-default-by-value
-  ` 
check.
-
-  Warns when lambda specify a by-value capture default and capture ``this``.
-
-- New :doc:`cppcoreguidelines-missing-std-forward
-  ` check.
-
-  Warns when a forwarding reference parameter is not forwarded within the
-  function body.
-
-- New :doc:`cppcoreguidelines-rvalue-reference-param-not-moved
-  ` 
check.
-
-  Warns when an rvalue reference function parameter is never moved within
-  the function body.
-
-- New :doc:`llvmlibc-inline-function-decl
-  ` check.
-
-  Checks that all implicit and explicit inline functions in header files are
-  tagged with the ``LIBC_INLINE`` macro.
-
-- New :doc:`misc-header-include-cycle
-  ` check.
-
-  Check detects cyclic ``#include`` dependencies between user-defined headers.
-
-- New :doc:`misc-include-cleaner
-  ` check.
-
-  Checks for unused and missing includes.
-
-- New :doc:`modernize-type-traits
-  ` check.
-
-  Converts standard library type traits of the form ``traits<...>::type`` and
-  ``traits<...>::value`` into ``traits_t<...>`` and ``traits_v<...>`` 
respectively.
-
-- New :doc:`modernize-use-std-print
-  ` check.
-
-  Converts calls to ``printf``, ``fprintf``, ``absl::PrintF``,
-  ``absl::FPrintf`` or other functions via configuration options, to
-  equivalent calls to C++23's ``std::print`` and ``std::println``, or other
-  functions via a configuration option, modifying the format string

[PATCH] D156214: [LLVM][RISCV] Check more extension dependencies

2023-07-25 Thread Alex Bradbury via Phabricator via cfe-commits
asb added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:948
-  // TODO: The 'q' extension requires rv64.
-  // TODO: It is illegal to specify 'e' extensions with 'f' and 'd'.
 

imkiva wrote:
> wangpc wrote:
> > I think the comment is outdated here. `E` can be combined with all other 
> > extensions according to spec:
> > > Unless otherwise stated, standard extensions compatible with RV32I and 
> > > RV64I are also compatible with RV32E and RV64E, respectively.
> > And, please see also D70401 for more context.
> I downloaded the specification from 
> [here](https://github.com/riscv/riscv-isa-manual/releases/download/Ratified-IMAFDQC/riscv-spec-20191213.pdf),
>  and in page 34 the footnote says:
> 
> > RV32E can be combined with all current standard extensions. Defining the F, 
> > D, and Q extensions as having a 16-entry floating point register file when 
> > combined with RV32E was considered but **decided against**. To support 
> > systems with reduced floating-point register state, we intend to define a 
> > “Zfinx” extension...
> 
> It seems in the spec version 20191213, they rejected the combination of `E` 
> with standard floating-point extensions, instead, a separate extension 
> `Zfinx` is chosen for the original purpose.
> I am not sure if there's any newer specification that decides to allow this 
> combination.
> 
> 
There's a link to the ratified version on 
https://wiki.riscv.org/display/HOME/Recently+Ratified+Extensions - see 
https://drive.google.com/file/d/1GjHmphVKvJlOBJydAt36g0Oc8yCOPtKw/view

As @wangpc says, the restriction was removed and so the comment is out of date.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156214

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


[PATCH] D156230: [clang][dataflow][NFC] Eliminate variable only used in assertion.

2023-07-25 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

(if you prefer to keep the named variable, `(void)StructVal2` is also fine)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156230

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


[PATCH] D152003: [clang] Fix `static_cast` to array of unknown bound

2023-07-25 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: philnik, Mordante, ldionne.
aaron.ballman added a comment.

In D152003#4531404 , @Fznamznon wrote:

>> should we try to land that today?
>
> I'm not sure. It causes failures in libc++ testing:
>
>   Failed Tests (3):
> llvm-libc++-shared.cfg.in :: std/ranges/range.access/end.pass.cpp
> llvm-libc++-shared.cfg.in :: std/ranges/range.access/rbegin.pass.cpp
> llvm-libc++-shared.cfg.in :: std/ranges/range.access/rend.pass.cpp
>
> I haven't figured out why. Trying to compile:
>
>   #include 
>   
>   using RangeCREndT = decltype(std::ranges::crend);
>   static_assert(!std::is_invocable_v);
>
> fails with this patch only using libc++, libstdc++ is fine. I'm not sure it 
> is my misunderstanding, bug in the patch or bug in libc++.

CC @ldionne @philnik @Mordante for libc++ opinions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152003

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


[PATCH] D156221: [RISCV] Support overloaded version ntlh intrinsic function

2023-07-25 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

This seems functionally correct to me, but I'd welcome opinions from others who 
work more with the C intrinsics on if this is the best way to implement the 
overloading.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156221

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


[PATCH] D156224: [Clang] use unsigned integer constants in unit-test | fixes build error on ppc64le-lld-multistage-test

2023-07-25 Thread Kai Stierand via Phabricator via cfe-commits
kiloalphaindia added a comment.

I had copied the warning-flags from the build-bot command line and ended up as 
follows:

  -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -Woverloaded-virtual 
-Wno-nested-anon-types -O2 -DNDEBUG -Wno-variadic-macros 
-Wno-gnu-zero-variadic-macro-arguments -Wno-suggest-override

This obviously includes `-Wextra` ...
Still wondering, why I couldn't see the warning.
Which version of GTEST are you using?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156224

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


[PATCH] D145229: [analyzer] Improve the documentation of the alpha.security.taint.TaintPropagation checker

2023-07-25 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/docs/analyzer/checkers.rst:2469-2472
+  // User csa_mark_sanitize function is for the analyzer only
+  #ifdef __clang_analyzer__
+void csa_mark_sanitized(const void *);
+  #endif

I was thinking of this when I mentioned "function with empty body".
Notice the `inline`, so that one could put this into a header file without 
violating ODR.

---
This way at the callsites, one wouldn't need to ifdef-clutter the code.
I think this would lead to more maintainable code in the long run, with happier 
users.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145229

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


[PATCH] D156161: [clang-tidy] Add --enable-module-headers-parsing option

2023-07-25 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp accepted this revision.
carlosgalvezp added a comment.
This revision is now accepted and ready to land.

LGTM! Feel free to add the comment about the implications of using the flag in 
the docs.




Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:270
+for C++20 and above, empowering specific checks
+to detect macro definitions within modules.
+)"),

PiotrZSL wrote:
> carlosgalvezp wrote:
> > Should we document the implications/risks of enabling this, so people are 
> > informed? Also the fact that is experimental and subject to change.
> Something like "May cause performance & parsing issues, and therefore is 
> considered experimental." ? I'ts fine with me.
Sounds good to me!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156161

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


[clang] 73105a5 - HIP: Fix broken version check for deprecated macro

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

Author: Matt Arsenault
Date: 2023-07-25T08:36:19-04:00
New Revision: 73105a54725ec11165dd8c90ca3b7a0b1b9cd6e3

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

LOG: HIP: Fix broken version check for deprecated macro

Remove test hack that was accidentally pushed.

Added: 


Modified: 
clang/lib/Headers/__clang_hip_libdevice_declares.h

Removed: 




diff  --git a/clang/lib/Headers/__clang_hip_libdevice_declares.h 
b/clang/lib/Headers/__clang_hip_libdevice_declares.h
index ed576027cb5e58..f15198b3d9f93e 100644
--- a/clang/lib/Headers/__clang_hip_libdevice_declares.h
+++ b/clang/lib/Headers/__clang_hip_libdevice_declares.h
@@ -317,7 +317,7 @@ __device__ __attribute__((pure)) __2f16 
__ocml_log_2f16(__2f16);
 __device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16);
 __device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16);
 
-#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 560 || 1
+#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 560
 #define __DEPRECATED_SINCE_HIP_560(X) __attribute__((deprecated(X)))
 #else
 #define __DEPRECATED_SINCE_HIP_560(X)



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


[clang] 18914f7 - OpenMP: Fix broken c++ mode comment

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

Author: Matt Arsenault
Date: 2023-07-25T08:36:19-04:00
New Revision: 18914f795523b7099cad0cf16ac4cd062ac998d4

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

LOG: OpenMP: Fix broken c++ mode comment

Added: 


Modified: 
clang/lib/Headers/openmp_wrappers/cmath

Removed: 




diff  --git a/clang/lib/Headers/openmp_wrappers/cmath 
b/clang/lib/Headers/openmp_wrappers/cmath
index 22a720aca9561b..e1b71516e72c2e 100644
--- a/clang/lib/Headers/openmp_wrappers/cmath
+++ b/clang/lib/Headers/openmp_wrappers/cmath
@@ -1,4 +1,4 @@
-/*===-- __clang_openmp_device_functions.h - OpenMP math declares -- c++ 
-===
+/*===-- __clang_openmp_device_functions.h - OpenMP math declares -*- 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] D154123: [HIP] Start document HIP support by clang

2023-07-25 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked 3 inline comments as done.
yaxunl added inline comments.



Comment at: clang/docs/HIPSupport.rst:30
+
+Clang provides partial HIP support on Intel GPUs using the CHIP-Star project 
``_. CHIP-Star implements the HIP runtime 
over oneAPI Level Zero or OpenCL runtime. The Clang driver uses the HIPSPV 
toolchain to compile HIP device code into LLVM IR, which is subsequently 
translated to SPIRV via the SPIRV backend or the out-of-tree LLVM-SPIRV 
translator. The SPIRV is then bundled and embedded into the host executables.
+

keryell wrote:
> Fix the spelling when we talk about the Khronos SPIR-V standard, by 
> opposition to tool names.
> Perhaps you can split the line in shorter ones so the diff are more obvious.
> Fix the spelling when we talk about the Khronos SPIR-V standard, by 
> opposition to tool names.
> Perhaps you can split the line in shorter ones so the diff are more obvious.

will do



Comment at: clang/docs/HIPSupport.rst:65
+
+   clang++ --offload-arch=gfx906 -xhip sample.cpp -o sample
+

keryell wrote:
> yaxunl wrote:
> > arsenm wrote:
> > > scchan wrote:
> > > > missing --hip-link
> > > What does hip-link do? Why is it needed? I never use it and it works
> > It indicates HIP offloading at the linking stage and creates the HIP 
> > toolchain.
> > 
> > For -fno-gpu-rdc mode, it locates the HIP runtime library and links it.
> > 
> > For -fgpu-rdc mode, it unbundles object files and does device linking and 
> > embedding.
> I am a little lost here.
> I have the feeling that the newbie syntax (compile+link in one invocation) 
> should be
> ```
> clang++ --offload-arch=gfx906 -xhip sample.cpp -o sample
> ```
> since it should be obvious to the Driver that we want to produce a working 
> program for a GPU.
> Or does this work producing a working program with another meaning?
Currently, the linker will only link HIP runtime library when --hip-link is 
specified.

The linker does not see `-xhip sample.cpp`. It only sees the intermediate obj 
files passed to it, therefore it does not know it is for HIP.

This could be improved by letting the clang driver add an implicit `--hip-link` 
option to the linker when the driver sees the linking of HIP input files. 
However, this needs a separate patch.


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

https://reviews.llvm.org/D154123

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


[PATCH] D156234: [clang][deps] provide support for cc1 command line scanning

2023-07-25 Thread Connor Sughrue via Phabricator via cfe-commits
cpsughrue created this revision.
cpsughrue added reviewers: Bigcheese, jansvoboda11.
Herald added a project: All.
cpsughrue requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allow users to run a dependency scan with a cc1 command line in addition to a 
driver command line. The scan was being carried out with a cc1 command line, 
but `DependencyScanningWorker::computeDependencies` assumed that the user 
always provided a driver command line. Now 
`DependencyScanningWorker::computeDependencies` can handle the case where the 
user provides a cc1 command line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156234

Files:
  clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -240,6 +240,42 @@
 "test.cpp.o: /root/test.cpp /root/header.h\n");
 }
 
+TEST(DependencyScanner, ScanDepsWithCC1) {
+  std::vector CommandLine = {"clang",
+  "-cc1", 
+  "-triple",   
+  "x86_64-apple-macosx10.7", 
+  "-x", 
+  "c++",
+  "test.cpp", 
+  "-o",   
+  "test.cpp.o"};
+  StringRef CWD = "/root";
+
+  auto VFS = new llvm::vfs::InMemoryFileSystem();
+  VFS->setCurrentWorkingDirectory(CWD);
+  auto Sept = llvm::sys::path::get_separator();
+  std::string HeaderPath =
+  std::string(llvm::formatv("{0}root{0}header.h", Sept));
+  std::string TestPath = std::string(llvm::formatv("{0}root{0}test.cpp", Sept));
+
+  VFS->addFile(HeaderPath, 0, llvm::MemoryBuffer::getMemBuffer("\n"));
+  VFS->addFile(TestPath, 0,
+   llvm::MemoryBuffer::getMemBuffer("#include \"header.h\"\n"));
+
+  DependencyScanningService Service(ScanningMode::DependencyDirectivesScan,
+ScanningOutputFormat::Make);
+  DependencyScanningTool ScanTool(Service, VFS);
+
+  std::string DepFile;
+  ASSERT_THAT_ERROR(
+  ScanTool.getDependencyFile(CommandLine, CWD).moveInto(DepFile),
+  llvm::Succeeded());
+  using llvm::sys::path::convert_to_slash;
+  EXPECT_EQ(convert_to_slash(DepFile),
+"test.cpp.o: /root/test.cpp /root/header.h\n");
+}
+
 TEST(DependencyScanner, ScanDepsWithModuleLookup) {
   std::vector CommandLine = {
   "clang",
Index: clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp
@@ -385,6 +385,9 @@
   if (!Compilation)
 return false;
 
+  if (Compilation->containsError())
+return false;
+
   for (const driver::Command &Job : Compilation->getJobs()) {
 if (!Callback(Job))
   return false;
@@ -392,6 +395,26 @@
   return true;
 }
 
+static bool createAndRunToolInvocation(
+std::vector CommandLine, DependencyScanningAction &Action,
+FileManager &FM,
+std::shared_ptr &PCHContainerOps,
+DiagnosticsEngine &Diags, DependencyConsumer &Consumer) {
+
+  // Save executable path before providing CommandLine to ToolInvocation
+  std::string Executable = CommandLine[0];
+  ToolInvocation Invocation(std::move(CommandLine), &Action, &FM,
+PCHContainerOps);
+  Invocation.setDiagnosticConsumer(Diags.getClient());
+  Invocation.setDiagnosticOptions(&Diags.getDiagnosticOptions());
+  if (!Invocation.run())
+return false;
+
+  std::vector Args = Action.takeLastCC1Arguments();
+  Consumer.handleBuildCommand({Executable, std::move(Args)});
+  return true;
+}
+
 bool DependencyScanningWorker::computeDependencies(
 StringRef WorkingDirectory, const std::vector &CommandLine,
 DependencyConsumer &Consumer, DependencyActionController &Controller,
@@ -454,37 +477,37 @@
   DependencyScanningAction Action(WorkingDirectory, Consumer, Controller, DepFS,
   Format, OptimizeArgs, EagerLoadModules,
   DisableFree, ModuleName);
-  bool Success = forEachDriverJob(
-  FinalCommandLine, *Diags, *FileMgr, [&](const driver::Command &Cmd) {
-if (StringRef(Cmd.getCreator().getName()) != "clang") {
-  // Non-clang command. Just pass through to the dependency
-  // consumer.
-  Consumer.handleBuildCommand(
-  {Cmd.getExecutable(),
-   {Cmd.getArguments().begin(), Cmd.getArguments().end()}});
-  return true;
- 

[PATCH] D156230: [clang][dataflow][NFC] Eliminate variable only used in assertion.

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

Abandoning. Already fixed at head in 
https://github.com/llvm/llvm-project/commit/e71bae94b04391cb47680622666d448418c0d972


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156230

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


[PATCH] D155824: [LoongArch] Support -march=native and -mtune=

2023-07-25 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 543941.
SixWeining added a comment.

add missing `.`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D155824

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/lib/Basic/Targets/LoongArch.h
  clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/loongarch-mtune-error.c
  clang/test/Driver/loongarch-mtune.c
  clang/test/Preprocessor/init-loongarch.c
  llvm/include/llvm/TargetParser/LoongArchTargetParser.h
  llvm/lib/Target/LoongArch/LoongArch.td
  llvm/lib/TargetParser/LoongArchTargetParser.cpp
  llvm/test/CodeGen/LoongArch/cpus-invalid.ll
  llvm/test/CodeGen/LoongArch/cpus.ll

Index: llvm/test/CodeGen/LoongArch/cpus.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus.ll
@@ -0,0 +1,20 @@
+;; This tests that llc accepts all valid LoongArch CPUs.
+;; Note the 'generic' names have been tested in cpu-name-generic.ll.
+
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=loongarch64 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 --mcpu=la464 2>&1 | FileCheck %s
+; RUN: llc < %s --mtriple=loongarch64 2>&1 | FileCheck %s
+
+; CHECK-NOT: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
+
+define void @tune_cpu_loongarch64() "tune-cpu"="loongarch64" {
+  ret void
+}
+
+define void @tune_cpu_la464() "tune-cpu"="la464" {
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/cpus-invalid.ll
===
--- /dev/null
+++ llvm/test/CodeGen/LoongArch/cpus-invalid.ll
@@ -0,0 +1,7 @@
+; RUN: llc < %s --mtriple=loongarch64 --mattr=+64bit --mcpu=invalidcpu 2>&1 | FileCheck %s
+
+; CHECK: {{.*}} is not a recognized processor for this target
+
+define void @f() {
+  ret void
+}
Index: llvm/lib/TargetParser/LoongArchTargetParser.cpp
===
--- llvm/lib/TargetParser/LoongArchTargetParser.cpp
+++ llvm/lib/TargetParser/LoongArchTargetParser.cpp
@@ -16,6 +16,9 @@
 using namespace llvm;
 using namespace llvm::LoongArch;
 
+StringRef Arch;
+StringRef TuneCPU;
+
 const FeatureInfo AllFeatures[] = {
 #define LOONGARCH_FEATURE(NAME, KIND) {NAME, KIND},
 #include "llvm/TargetParser/LoongArchTargetParser.def"
@@ -46,3 +49,25 @@
   }
   return false;
 }
+
+bool LoongArch::isValidTuneCPUName(StringRef TuneCPU) {
+  return isValidArchName(TuneCPU);
+}
+
+void LoongArch::fillValidTuneCPUList(SmallVectorImpl &Values) {
+  for (const auto A : AllArchs)
+Values.emplace_back(A.Name);
+}
+
+StringRef LoongArch::getDefaultArch(bool Is64Bit) {
+  // TODO: use a real 32-bit arch name.
+  return Is64Bit ? "loongarch64" : "";
+}
+
+void LoongArch::setArch(StringRef Name) { Arch = Name; }
+
+StringRef LoongArch::getArch() { return Arch; }
+
+void LoongArch::setTuneCPU(StringRef Name) { TuneCPU = Name; }
+
+StringRef LoongArch::getTuneCPU() { return TuneCPU; }
Index: llvm/lib/Target/LoongArch/LoongArch.td
===
--- llvm/lib/Target/LoongArch/LoongArch.td
+++ llvm/lib/Target/LoongArch/LoongArch.td
@@ -117,6 +117,11 @@
 def : ProcessorModel<"generic-la32", NoSchedModel, [Feature32Bit]>;
 def : ProcessorModel<"generic-la64", NoSchedModel, [Feature64Bit, FeatureUAL]>;
 
+// Generic 64-bit processor with double-precision floating-point support.
+def : ProcessorModel<"loongarch64", NoSchedModel, [Feature64Bit,
+   FeatureUAL,
+   FeatureBasicD]>;
+
 // Support generic for compatibility with other targets. The triple will be used
 // to change to the appropriate la32/la64 version.
 def : ProcessorModel<"generic", NoSchedModel, []>;
Index: llvm/include/llvm/TargetParser/LoongArchTargetParser.h
===
--- llvm/include/llvm/TargetParser/LoongArchTargetParser.h
+++ llvm/include/llvm/TargetParser/LoongArchTargetParser.h
@@ -66,9 +66,16 @@
 
 bool isValidArchName(StringRef Arch);
 bool getArchFeatures(StringRef Arch, std::vector &Features);
+bool isValidTuneCPUName(StringRef TuneCPU);
+void fillValidTuneCPUList(SmallVectorImpl &Values);
+StringRef getDefaultArch(bool Is64Bit);
+void setArch(StringRef Arch);
+StringRef getArch();
+void setTuneCPU(StringRef TuneCPU);
+StringRef getTuneCPU();
 
 } // namespace LoongArch
 
 } // namespace llvm
 
-#endif // LLVM_SUPPORT_LOONGARCHTARGETPARSER_H
+#endif // LLVM_TARGETPARSER_LOONGARCHTARGETPARSER_H
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -787,3 +787,23 @@
 // LA64-FPU0-LP64S: #define __loongarch_lp64 1
 // 

[clang] 92c0611 - [LoongArch] Support -march=native and -mtune=

2023-07-25 Thread Weining Lu via cfe-commits

Author: Weining Lu
Date: 2023-07-25T21:01:51+08:00
New Revision: 92c06114b2ea9900a3364fb395988dfb065758f7

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

LOG: [LoongArch] Support -march=native and -mtune=

As described in [1][2], `-mtune=` is used to select the type of target
microarchitecture, defaults to the value of `-march`. The set of
possible values should be a superset of `-march` values. Currently
possible values of `-march=` and `-mtune=` are `native`, `loongarch64`
and `la464`.

D136146 has supported `-march={loongarch64,la464}` and this patch adds
support for `-march=native` and `-mtune=`.

A new ProcessorModel called `loongarch64` is defined in LoongArch.td
to support `-mtune=loongarch64`.

`llvm::sys::getHostCPUName()` returns `generic` on unknown or future
LoongArch CPUs, e.g. the not yet added `la664`, leading to
`llvm::LoongArch::isValidArchName()` failing to parse the arch name.
In this case, use `loongarch64` as the default arch name for 64-bit
CPUs.

And these two preprocessor macros are defined:
- __loongarch_arch
- __loongarch_tune

[1]: 
https://github.com/loongson/LoongArch-Documentation/blob/2023.04.20/docs/LoongArch-toolchain-conventions-EN.adoc
[2]: 
https://github.com/loongson/la-softdev-convention/blob/v0.1/la-softdev-convention.adoc

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

Added: 
clang/test/Driver/loongarch-mtune-error.c
clang/test/Driver/loongarch-mtune.c
llvm/test/CodeGen/LoongArch/cpus-invalid.ll
llvm/test/CodeGen/LoongArch/cpus.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/LoongArch.cpp
clang/lib/Basic/Targets/LoongArch.h
clang/lib/Driver/ToolChains/Arch/LoongArch.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Preprocessor/init-loongarch.c
llvm/include/llvm/TargetParser/LoongArchTargetParser.h
llvm/lib/Target/LoongArch/LoongArch.td
llvm/lib/TargetParser/LoongArchTargetParser.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d8655e52aa3235..6bd5e0f8f196c9 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -135,6 +135,15 @@ Windows Support
 LoongArch Support
 ^
 
+- Patchable function entry (``-fpatchable-function-entry``) is now supported
+  on LoongArch.
+- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or 
the
+  aliases ``-m[no-]strict-align``.
+- Non ``$``-prefixed GPR names (e.g. ``r4`` and ``a0``) are allowed in 
inlineasm
+  like GCC does.
+- The ``-march=native`` ``-mtune=`` options and ``__loongarch_{arch,tune}``
+  macros are now supported.
+
 RISC-V Support
 ^^
 

diff  --git a/clang/lib/Basic/Targets/LoongArch.cpp 
b/clang/lib/Basic/Targets/LoongArch.cpp
index 6958479cd7c42d..f08e5e732b0354 100644
--- a/clang/lib/Basic/Targets/LoongArch.cpp
+++ b/clang/lib/Basic/Targets/LoongArch.cpp
@@ -15,7 +15,7 @@
 #include "clang/Basic/MacroBuilder.h"
 #include "clang/Basic/TargetBuiltins.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/TargetParser/TargetParser.h"
+#include "llvm/TargetParser/LoongArchTargetParser.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -198,7 +198,19 @@ void LoongArchTargetInfo::getTargetDefines(const 
LangOptions &Opts,
   else
 Builder.defineMacro("__loongarch_frlen", "0");
 
-  // TODO: define __loongarch_arch and __loongarch_tune.
+  // Define __loongarch_arch.
+  StringRef Arch = llvm::LoongArch::getArch();
+  if (Arch.empty())
+Arch = llvm::LoongArch::getDefaultArch(GRLen == 64);
+  if (!Arch.empty())
+Builder.defineMacro("__loongarch_arch", Arch);
+
+  // Define __loongarch_tune.
+  StringRef TuneCPU = llvm::LoongArch::getTuneCPU();
+  if (TuneCPU.empty())
+TuneCPU = Arch;
+  if (!TuneCPU.empty())
+Builder.defineMacro("__loongarch_tune", TuneCPU);
 
   StringRef ABI = getABI();
   if (ABI == "lp64d" || ABI == "lp64f" || ABI == "lp64s")
@@ -270,3 +282,12 @@ bool LoongArchTargetInfo::handleTargetFeatures(
   }
   return true;
 }
+
+bool LoongArchTargetInfo::isValidTuneCPUName(StringRef Name) const {
+  return llvm::LoongArch::isValidTuneCPUName(Name);
+}
+
+void LoongArchTargetInfo::fillValidTuneCPUList(
+SmallVectorImpl &Values) const {
+  llvm::LoongArch::fillValidTuneCPUList(Values);
+}

diff  --git a/clang/lib/Basic/Targets/LoongArch.h 
b/clang/lib/Basic/Targets/LoongArch.h
index 52c4ce4253689e..60d545566b30fb 100644
--- a/clang/lib/Basic/Targets/LoongArch.h
+++ b/clang/lib/Basic/Targets/LoongArch.h
@@ -80,6 +80,9 @@ class LLVM_LIBRARY_VISIBILITY LoongArchTargetInfo : public 
TargetInfo {
  const std::vector &FeaturesVec) const override;
 
   bool hasFeature(StringRef Feature) const override;
+
+  bool isValidTuneCPUName(StringRef N

  1   2   3   4   >