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

2022-12-20 Thread Edwin Kofler via Phabricator via cfe-commits
hyperupcall created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
hyperupcall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140462

Files:
  clang-tools-extra/clangd/schema/config.json

Index: clang-tools-extra/clangd/schema/config.json
===
--- /dev/null
+++ clang-tools-extra/clangd/schema/config.json
@@ -0,0 +1,192 @@
+{
+  "$schema": "http://json-schema.org/draft-07/schema;,
+  "$defs": {
+"stringOrArrayOf": {
+  "oneOf": [
+{
+  "type": "string"
+},
+{
+  "type": "array",
+  "items": {
+"type": "string"
+  }
+}
+  ]
+}
+  },
+  "type": "object",
+  "properties": {
+"If": {
+  "description": "Conditions in the If block restrict when a fragment applies.",
+  "type": "object",
+  "properties": {
+"PathMatch": {
+  "description": "The file being processed must fully match a regular expression.",
+  "$ref": "#/$defs/stringOrArrayOf"
+},
+"PathExclude": {
+  "description": "The file being processed must not fully match a regular expression.",
+  "$ref": "#/$defs/stringOrArrayOf"
+}
+  }
+},
+"CompileFlags": {
+  "description": "Affects how a source file is parsed.",
+  "type": "object",
+  "properties": {
+"Add": {
+  "description": "List of flags to append to the compile command.",
+  "$ref": "#/$defs/stringOrArrayOf"
+},
+"Remove": {
+  "description": "List of flags to remove from the compile command",
+  "$ref": "#/$defs/stringOrArrayOf"
+},
+"CompilationDatabase": {
+  "description": "Directory to search for compilation database (compile_commands.json etc).",
+  "type": "string"
+},
+"Compiler": {
+  "description": "String to replace the executable name in the compile flags. The name controls flag parsing (clang vs clang-cl), target inference (gcc-arm-noneabi) etc.",
+  "type": "string"
+}
+  }
+},
+"Index": {
+  "description": "Controls how clangd understands code outside the current file.",
+  "type": "object",
+  "properties": {
+"Background": {
+  "description": "Whether files are built in the background to produce a project index. This is checked for translation units only, not headers they include.",
+  "type": "string",
+  "enum": [
+"Build",
+"Skip"
+  ],
+  "default": "Build"
+},
+"External": {
+  "description": "Used to define an external index source",
+  "type": "object",
+  "oneOf": [
+{
+  "properties": {
+"File": {
+  "type": "string"
+},
+"Server": {
+  "type": "string"
+},
+"MountPoint": {
+  "type": "string"
+}
+  },
+  "required": [
+"File"
+  ]
+},
+{
+  "properties": {
+"File": {
+  "type": "string"
+},
+"Server": {
+  "type": "string"
+},
+"MountPoint": {
+  "type": "string"
+}
+  },
+  "required": [
+"Server"
+  ]
+}
+  ]
+}
+  }
+},
+"Style": {
+  "description": "Describes the style of the codebase, beyond formatting",
+  "type": "object",
+  "properties": {
+"FullyQualifiedNamespaces": {
+  "type": "boolean"
+}
+  }
+},
+"Diagnostics": {
+  "type": "object",
+  "properties": {
+"Suppress": {
+  "description": "Diagnostic codes that should be suppressed.",
+  "$ref": "#/$defs/stringOrArrayOf"
+},
+"ClangTidy": {
+  "description": "Configure how clang-tidy runs over your files. The settings are merged with any settings found in .clang-tidy configuration files with the ones from clangd configs taking precedence.",
+  "type": "object",
+  "properties": {
+"Add": {
+  "description": "List of checks to enable, can be globs.",
+  "$ref": "#/$defs/stringOrArrayOf"
+},
+"Remove": {
+  "description": "List of checks to disable, can be globs.",
+  "$ref": "#/$defs/stringOrArrayOf"
+},
+"CheckOptions": {
+  

[PATCH] D139987: [Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

2022-12-20 Thread Lu Weining via Phabricator via cfe-commits
SixWeining accepted this revision.
SixWeining added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139987

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


[PATCH] D139987: [Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

2022-12-20 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin updated this revision to Diff 484466.
gonglingqin added a comment.

Address @SixWeining's comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139987

Files:
  clang/lib/Headers/larchintrin.h
  clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
  clang/test/CodeGen/LoongArch/intrinsic-la32.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c

Index: clang/test/CodeGen/LoongArch/intrinsic-la64.c
===
--- clang/test/CodeGen/LoongArch/intrinsic-la64.c
+++ clang/test/CodeGen/LoongArch/intrinsic-la64.c
@@ -316,3 +316,23 @@
   __iocsrwr_d(a, b);
   __builtin_loongarch_iocsrwr_d(a, b);
 }
+
+// CHECK-LABEL: @rdtime_d(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { i64, i64 } asm sideeffect "rdtime.d $0, $1\0A\09", "=,="() #[[ATTR1:[0-9]+]], !srcloc !2
+// CHECK-NEXT:ret void
+//
+void rdtime_d() {
+  __rdtime_d();
+}
+
+// CHECK-LABEL: @rdtime(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=,="() #[[ATTR1]], !srcloc !3
+// CHECK-NEXT:[[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=,="() #[[ATTR1]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void rdtime() {
+  __rdtimeh_w();
+  __rdtimel_w();
+}
Index: clang/test/CodeGen/LoongArch/intrinsic-la32.c
===
--- clang/test/CodeGen/LoongArch/intrinsic-la32.c
+++ clang/test/CodeGen/LoongArch/intrinsic-la32.c
@@ -154,3 +154,14 @@
   __iocsrwr_w(a, b);
   __builtin_loongarch_iocsrwr_w(a, b);
 }
+
+// LA32-LABEL: @rdtime(
+// LA32-NEXT:  entry:
+// LA32-NEXT:[[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=,="() #[[ATTR1:[0-9]+]], !srcloc !2
+// LA32-NEXT:[[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=,="() #[[ATTR1]], !srcloc !3
+// LA32-NEXT:ret void
+//
+void rdtime() {
+  __rdtimeh_w();
+  __rdtimel_w();
+}
Index: clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
===
--- clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
+++ clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
@@ -95,3 +95,7 @@
 void iocsrwr_d(unsigned long int a, unsigned int b) {
   __builtin_loongarch_iocsrwr_d(a, b); // expected-error {{this builtin requires target: loongarch64}}
 }
+
+void rdtime_d() {
+  __rdtime_d(); // expected-error {{call to undeclared function '__rdtime_d'}}
+}
Index: clang/lib/Headers/larchintrin.h
===
--- clang/lib/Headers/larchintrin.h
+++ clang/lib/Headers/larchintrin.h
@@ -14,6 +14,46 @@
 extern "C" {
 #endif
 
+typedef struct rdtime {
+  unsigned int value;
+  unsigned int timeid;
+} __rdtime_t;
+
+#if __loongarch_grlen == 64
+typedef struct drdtime {
+  unsigned long dvalue;
+  unsigned long dtimeid;
+} __drdtime_t;
+
+extern __inline __drdtime_t
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__rdtime_d(void) {
+  __drdtime_t __drdtime;
+  __asm__ volatile(
+  "rdtime.d %[val], %[tid]\n\t"
+  : [val] "="(__drdtime.dvalue), [tid] "="(__drdtime.dtimeid));
+  return __drdtime;
+}
+#endif
+
+extern __inline __rdtime_t
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__rdtimeh_w(void) {
+  __rdtime_t __rdtime;
+  __asm__ volatile("rdtimeh.w %[val], %[tid]\n\t"
+   : [val] "="(__rdtime.value), [tid] "="(__rdtime.timeid));
+  return __rdtime;
+}
+
+extern __inline __rdtime_t
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__rdtimel_w(void) {
+  __rdtime_t __rdtime;
+  __asm__ volatile("rdtimel.w %[val], %[tid]\n\t"
+   : [val] "="(__rdtime.value), [tid] "="(__rdtime.timeid));
+  return __rdtime;
+}
+
 #if __loongarch_grlen == 64
 extern __inline int
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139987: [Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

2022-12-20 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin added inline comments.



Comment at: clang/lib/Headers/larchintrin.h:17-20
+typedef struct drdtime {
+  unsigned long dvalue;
+  unsigned long dtimeid;
+} __drdtime_t;

SixWeining wrote:
> Should be moved into the belowing `#if __loongarch_grlen == 64`.
Thanks. I will modify it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139987

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


[PATCH] D137071: [clang][Interp] Implement missing compound assign operators

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM




Comment at: clang/test/AST/Interp/literals.cpp:553
+  static_assert(IntRem(2, 1) == 0, "");
+  static_assert(IntRem(9, 7) == 2, "");
+

aaron.ballman wrote:
> tbaeder wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > ```
> > > > static_assert(IntRem(9, 0) == 12, ""); // Not constexpr
> > > > static_assert(IntRem(__INT_MIN__, -1) == 12, ""); // Not constexpr
> > > > ```
> > > Missed the test for __INT_MIN__ and -1?
> > for rem, clang doesn't diagnose anything: https://godbolt.org/z/rhe5ezc54
> That's a bug per https://eel.is/c++draft/expr.mul#4.sentence-3 because the 
> resulting algebraic value is not representable in the type of the result.
Ok, this bugged me enough I figured out what was going on and put up a PR: 
https://reviews.llvm.org/D140455


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

https://reviews.llvm.org/D137071

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


[PATCH] D139915: [Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg

2022-12-20 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin updated this revision to Diff 484465.
gonglingqin added a comment.

Add comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139915

Files:
  clang/include/clang/Basic/BuiltinsLoongArch.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/larchintrin.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
  clang/test/CodeGen/LoongArch/intrinsic-la32.c
  clang/test/CodeGen/LoongArch/intrinsic-la64-error.c
  clang/test/CodeGen/LoongArch/intrinsic-la64.c
  llvm/include/llvm/IR/IntrinsicsLoongArch.td
  llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
  llvm/lib/Target/LoongArch/LoongArchISelLowering.h
  llvm/lib/Target/LoongArch/LoongArchInstrInfo.td
  llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
  llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
  llvm/test/CodeGen/LoongArch/intrinsic.ll

Index: llvm/test/CodeGen/LoongArch/intrinsic.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic.ll
@@ -15,6 +15,7 @@
 declare void @llvm.loongarch.iocsrwr.b(i32, i32)
 declare void @llvm.loongarch.iocsrwr.h(i32, i32)
 declare void @llvm.loongarch.iocsrwr.w(i32, i32)
+declare i32 @llvm.loongarch.cpucfg(i32)
 
 define void @foo() nounwind {
 ; CHECK-LABEL: foo:
@@ -145,3 +146,13 @@
   tail call void @llvm.loongarch.iocsrwr.w(i32 %a, i32 %b)
   ret void
 }
+
+define i32 @cpucfg(i32 %a) {
+; CHECK-LABEL: cpucfg:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:cpucfg $a0, $a0
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i32 @llvm.loongarch.cpucfg(i32 %a)
+  ret i32 %0
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic-la64.ll
@@ -14,6 +14,10 @@
 declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
 declare i64 @llvm.loongarch.iocsrrd.d(i32)
 declare void @llvm.loongarch.iocsrwr.d(i64, i32)
+declare void @llvm.loongarch.asrtle.d(i64, i64)
+declare void @llvm.loongarch.asrtgt.d(i64, i64)
+declare i64 @llvm.loongarch.lddir.d(i64, i64)
+declare void @llvm.loongarch.ldpte.d(i64, i64)
 
 define i32 @crc_w_b_w(i32 %a, i32 %b) nounwind {
 ; CHECK-LABEL: crc_w_b_w:
@@ -136,3 +140,43 @@
   tail call void @llvm.loongarch.iocsrwr.d(i64 %a, i32 %b)
   ret void
 }
+
+define void @asrtle_d(i64 %a, i64 %b) {
+; CHECK-LABEL: asrtle_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:asrtle.d $a0, $a1
+; CHECK-NEXT:ret
+entry:
+  tail call void @llvm.loongarch.asrtle.d(i64 %a, i64 %b)
+  ret void
+}
+
+define void @asrtgt_d(i64 %a, i64 %b) {
+; CHECK-LABEL: asrtgt_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:asrtgt.d $a0, $a1
+; CHECK-NEXT:ret
+entry:
+  tail call void @llvm.loongarch.asrtgt.d(i64 %a, i64 %b)
+  ret void
+}
+
+define i64 @lddir_d(i64 %a) {
+; CHECK-LABEL: lddir_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:lddir $a0, $a0, 1
+; CHECK-NEXT:ret
+entry:
+  %0 = tail call i64 @llvm.loongarch.lddir.d(i64 %a, i64 1)
+  ret i64 %0
+}
+
+define void @ldpte_d(i64 %a) {
+; CHECK-LABEL: ldpte_d:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:ldpte $a0, 1
+; CHECK-NEXT:ret
+entry:
+  tail call void @llvm.loongarch.ldpte.d(i64 %a, i64 1)
+  ret void
+}
Index: llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
===
--- llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
+++ llvm/test/CodeGen/LoongArch/intrinsic-la32-error.ll
@@ -13,6 +13,10 @@
 declare i64 @llvm.loongarch.csrxchg.d(i64, i64, i32 immarg)
 declare i64 @llvm.loongarch.iocsrrd.d(i32)
 declare void @llvm.loongarch.iocsrwr.d(i64, i32)
+declare void @llvm.loongarch.asrtle.d(i64, i64)
+declare void @llvm.loongarch.asrtgt.d(i64, i64)
+declare i64 @llvm.loongarch.lddir.d(i64, i32)
+declare void @llvm.loongarch.ldpte.d(i64, i32)
 
 define i32 @crc_w_b_w(i32 %a, i32 %b) nounwind {
 ; CHECK: llvm.loongarch.crc.w.b.w requires target: loongarch64
@@ -104,3 +108,31 @@
   tail call void @llvm.loongarch.iocsrwr.d(i64 %a, i32 %b)
   ret void
 }
+
+define void @asrtle_d(i64 %a, i64 %b) {
+; CHECK: llvm.loongarch.asrtle.d requires target: loongarch64
+entry:
+  tail call void @llvm.loongarch.asrtle.d(i64 %a, i64 %b)
+  ret void
+}
+
+define void @asrtgt_d(i64 %a, i64 %b) {
+; CHECK: llvm.loongarch.asrtgt.d requires target: loongarch64
+entry:
+  tail call void @llvm.loongarch.asrtgt.d(i64 %a, i64 %b)
+  ret void
+}
+
+define i64 @lddir_d(i64 %a) {
+; CHECK: llvm.loongarch.lddir.d requires target: loongarch64
+entry:
+  %0 = tail call i64 @llvm.loongarch.lddir.d(i64 %a, i32 1)
+  ret i64 %0
+}
+
+define void @ldpte_d(i64 %a) {
+; CHECK: llvm.loongarch.ldpte.d requires target: loongarch64
+entry:
+  tail call void @llvm.loongarch.ldpte.d(i64 %a, i32 1)
+  ret void
+}

[PATCH] D140455: [Clang] Diagnose undefined behavior in a constant expression while evaluating a compound assignment with remainder as operand

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane, tahonermann.
Herald added a project: All.
shafik requested review of this revision.

Currently we don't diagnose overflow in a constant expression for the case of 
compound assignment with remainder as a operand.

In `handleIntIntBinOp` the arguments `LHS` and `Result` can be the same source 
but in the check for remainder in this function we assigned to `Result` before 
checking for overflow. In all the other operations the check is done before 
`Result` is assigned to.


https://reviews.llvm.org/D140455

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/CXX/expr/expr.const/p2-0x.cpp


Index: clang/test/CXX/expr/expr.const/p2-0x.cpp
===
--- clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -298,6 +298,15 @@
 static_assert(isinf(f6), "");
 static_assert(isinf(f9), "");
   }
+
+#if __cplusplus >= 201703L
+namespace CompoundAssignment {
+int constexpr rem() { // expected-error {{constexpr function never produces a 
constant expression}}
+int x = ~__INT_MAX__;
+return x%=-1; // cxx20-note {{value 2147483648 is outside the range of 
representable values of type 'int'}}
+}
+}
+#endif
 }
 
 // - a lambda-expression (5.1.2);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2756,6 +2756,7 @@
 static bool handleIntIntBinOp(EvalInfo , const Expr *E, const APSInt ,
   BinaryOperatorKind Opcode, APSInt RHS,
   APSInt ) {
+  bool HandleOverflowResult = true;
   switch (Opcode) {
   default:
 Info.FFDiag(E);
@@ -2778,14 +2779,14 @@
   Info.FFDiag(E, diag::note_expr_divide_by_zero);
   return false;
 }
-Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS);
 // Check for overflow case: INT_MIN / -1 or INT_MIN % -1. APSInt supports
 // this operation and gives the two's complement result.
 if (RHS.isNegative() && RHS.isAllOnes() && LHS.isSigned() &&
 LHS.isMinSignedValue())
-  return HandleOverflow(Info, E, -LHS.extend(LHS.getBitWidth() + 1),
-E->getType());
-return true;
+  HandleOverflowResult = HandleOverflow(
+  Info, E, -LHS.extend(LHS.getBitWidth() + 1), E->getType());
+Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS);
+return HandleOverflowResult;
   case BO_Shl: {
 if (Info.getLangOpts().OpenCL)
   // OpenCL 6.3j: shift values are effectively % word size of LHS.


Index: clang/test/CXX/expr/expr.const/p2-0x.cpp
===
--- clang/test/CXX/expr/expr.const/p2-0x.cpp
+++ clang/test/CXX/expr/expr.const/p2-0x.cpp
@@ -298,6 +298,15 @@
 static_assert(isinf(f6), "");
 static_assert(isinf(f9), "");
   }
+
+#if __cplusplus >= 201703L
+namespace CompoundAssignment {
+int constexpr rem() { // expected-error {{constexpr function never produces a constant expression}}
+int x = ~__INT_MAX__;
+return x%=-1; // cxx20-note {{value 2147483648 is outside the range of representable values of type 'int'}}
+}
+}
+#endif
 }
 
 // - a lambda-expression (5.1.2);
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -2756,6 +2756,7 @@
 static bool handleIntIntBinOp(EvalInfo , const Expr *E, const APSInt ,
   BinaryOperatorKind Opcode, APSInt RHS,
   APSInt ) {
+  bool HandleOverflowResult = true;
   switch (Opcode) {
   default:
 Info.FFDiag(E);
@@ -2778,14 +2779,14 @@
   Info.FFDiag(E, diag::note_expr_divide_by_zero);
   return false;
 }
-Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS);
 // Check for overflow case: INT_MIN / -1 or INT_MIN % -1. APSInt supports
 // this operation and gives the two's complement result.
 if (RHS.isNegative() && RHS.isAllOnes() && LHS.isSigned() &&
 LHS.isMinSignedValue())
-  return HandleOverflow(Info, E, -LHS.extend(LHS.getBitWidth() + 1),
-E->getType());
-return true;
+  HandleOverflowResult = HandleOverflow(
+  Info, E, -LHS.extend(LHS.getBitWidth() + 1), E->getType());
+Result = (Opcode == BO_Rem ? LHS % RHS : LHS / RHS);
+return HandleOverflowResult;
   case BO_Shl: {
 if (Info.getLangOpts().OpenCL)
   // OpenCL 6.3j: shift values are effectively % word size of LHS.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139915: [Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg

2022-12-20 Thread Gong LingQin via Phabricator via cfe-commits
gonglingqin added inline comments.



Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.h:91
   IOCSRWR_D,
+
+  CPUCFG,

SixWeining wrote:
> Better to leave some comment like line 82?
Thanks, I'll add comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139915

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


[PATCH] D140361: [RISCV] Merge Masked and unMasked RVV manual codegen

2022-12-20 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 484459.
BeMg added a comment.

Update format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140361

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -171,6 +171,10 @@
 
   if (RVVI->hasManualCodegen()) {
 OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
+if (RVVI->isMasked())
+  OS << "IsMasked = true;\n";
+else
+  OS << "IsMasked = false;\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
@@ -517,7 +521,6 @@
 bool SupportOverloading = R->getValueAsBit("SupportOverloading");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
-StringRef MaskedManualCodegen = R->getValueAsString("MaskedManualCodegen");
 std::vector IntrinsicTypes =
 R->getValueAsListOfInts("IntrinsicTypes");
 std::vector RequiredFeatures =
@@ -594,7 +597,7 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, MaskedManualCodegen,
+SupportOverloading, HasBuiltinAlias, ManualCodegen,
 MaskTypes.value(), IntrinsicTypes, RequiredFeatures, NF,
 Policy::PolicyNone, IsPrototypeDefaultTU));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
@@ -610,7 +613,7 @@
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-  MaskedManualCodegen, PolicyTypes.value(), IntrinsicTypes,
+  ManualCodegen, PolicyTypes.value(), IntrinsicTypes,
   RequiredFeatures, NF, P, IsPrototypeDefaultTU));
 }
   } // End for Log2LMULList
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -19461,6 +19461,7 @@
   constexpr unsigned TAIL_AGNOSTIC = 1;
   constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3;
   int DefaultPolicy = TAIL_UNDISTURBED;
+  bool IsMasked = false;
 
   // Required for overloaded intrinsics.
   llvm::SmallVector IntrinsicTypes;
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -217,7 +217,6 @@
 
   // Manual code in clang codegen riscv_vector_builtin_cg.inc
   code ManualCodegen = [{}];
-  code MaskedManualCodegen = [{}];
 
   // When emit the automatic clang codegen, it describes what types we have to use
   // to obtain the specific LLVM intrinsic. -1 means the return type, otherwise,
@@ -627,31 +626,18 @@
   UnMaskedPolicyScheme = HasPassthruOperand,
   ManualCodegen = [{
   {
-if (DefaultPolicy == TAIL_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-IntrinsicTypes = {ResultType, Ops[3]->getType()};
-Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-Value *NewVL = Ops[2];
-Ops.erase(Ops.begin() + 2);
-llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
-llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
-llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
-// Store new_vl.
-clang::CharUnits Align =
-CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
-llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
-Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
-return V;
-  }
-  }],
-  MaskedManualCodegen = [{
-  {
-// Move mask to right before vl.
-std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
-IntrinsicTypes = {ResultType, Ops[4]->getType()};
+if (IsMasked) {
+  // Move mask to right before vl.
+  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
+  if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
+Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
+  

[PATCH] D139987: [Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

2022-12-20 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/Headers/larchintrin.h:17-20
+typedef struct drdtime {
+  unsigned long dvalue;
+  unsigned long dtimeid;
+} __drdtime_t;

Should be moved into the belowing `#if __loongarch_grlen == 64`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139987

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


[PATCH] D139915: [Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg

2022-12-20 Thread Lu Weining via Phabricator via cfe-commits
SixWeining accepted this revision.
SixWeining added a comment.
This revision is now accepted and ready to land.

LGTM except a small nit.




Comment at: llvm/lib/Target/LoongArch/LoongArchISelLowering.h:91
   IOCSRWR_D,
+
+  CPUCFG,

Better to leave some comment like line 82?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139915

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


[PATCH] D140379: [clangd] Avoid triggering linkage computation for decl with unstable linkage in SymbolRelevanceSignals::computeASTSignals()

2022-12-20 Thread Nathan Ridge 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 rG6761ba7639a4: [clangd] Avoid triggering linkage computation 
for decl with unstable linkage in… (authored by nridge).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140379

Files:
  clang-tools-extra/clangd/Quality.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1100,6 +1100,21 @@
 )cpp");
 }
 
+TEST(CompletionTest, Issue1427Crash) {
+// Need to provide main file signals to ensure that the branch in
+// SymbolRelevanceSignals::computeASTSignals() that tries to
+// compute a symbol ID is taken.
+ASTSignals MainFileSignals;
+CodeCompleteOptions Opts;
+Opts.MainFileSignals = 
+completions(R"cpp(
+  auto f = []() {
+1.0_^
+  };
+)cpp",
+{}, Opts);
+}
+
 TEST(CompletionTest, BacktrackCrashes) {
   // Sema calls code completion callbacks twice in these cases.
   auto Results = completions(R"cpp(
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -303,6 +303,8 @@
   (SemaResult.Kind != CodeCompletionResult::RK_Pattern))
 return;
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+if (hasUnstableLinkage(ND))
+  return;
 auto ID = getSymbolID(ND);
 if (!ID)
   return;


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1100,6 +1100,21 @@
 )cpp");
 }
 
+TEST(CompletionTest, Issue1427Crash) {
+// Need to provide main file signals to ensure that the branch in
+// SymbolRelevanceSignals::computeASTSignals() that tries to
+// compute a symbol ID is taken.
+ASTSignals MainFileSignals;
+CodeCompleteOptions Opts;
+Opts.MainFileSignals = 
+completions(R"cpp(
+  auto f = []() {
+1.0_^
+  };
+)cpp",
+{}, Opts);
+}
+
 TEST(CompletionTest, BacktrackCrashes) {
   // Sema calls code completion callbacks twice in these cases.
   auto Results = completions(R"cpp(
Index: clang-tools-extra/clangd/Quality.cpp
===
--- clang-tools-extra/clangd/Quality.cpp
+++ clang-tools-extra/clangd/Quality.cpp
@@ -303,6 +303,8 @@
   (SemaResult.Kind != CodeCompletionResult::RK_Pattern))
 return;
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+if (hasUnstableLinkage(ND))
+  return;
 auto ID = getSymbolID(ND);
 if (!ID)
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 6761ba7 - [clangd] Avoid triggering linkage computation for decl with unstable linkage in SymbolRelevanceSignals::computeASTSignals()

2022-12-20 Thread Nathan Ridge via cfe-commits

Author: Nathan Ridge
Date: 2022-12-20T21:56:36-05:00
New Revision: 6761ba7639a4a1285a2e86a4beaad70569a6c222

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

LOG: [clangd] Avoid triggering linkage computation for decl with unstable 
linkage in SymbolRelevanceSignals::computeASTSignals()

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

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

Added: 


Modified: 
clang-tools-extra/clangd/Quality.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Quality.cpp 
b/clang-tools-extra/clangd/Quality.cpp
index 70a85d73a4823..da8e60ef8d88e 100644
--- a/clang-tools-extra/clangd/Quality.cpp
+++ b/clang-tools-extra/clangd/Quality.cpp
@@ -303,6 +303,8 @@ void SymbolRelevanceSignals::computeASTSignals(
   (SemaResult.Kind != CodeCompletionResult::RK_Pattern))
 return;
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+if (hasUnstableLinkage(ND))
+  return;
 auto ID = getSymbolID(ND);
 if (!ID)
   return;

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index 4c788ea7efbc4..a8e2916107af8 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1100,6 +1100,21 @@ TEST(CompletionTests, EmptySnippetDoesNotCrash) {
 )cpp");
 }
 
+TEST(CompletionTest, Issue1427Crash) {
+// Need to provide main file signals to ensure that the branch in
+// SymbolRelevanceSignals::computeASTSignals() that tries to
+// compute a symbol ID is taken.
+ASTSignals MainFileSignals;
+CodeCompleteOptions Opts;
+Opts.MainFileSignals = 
+completions(R"cpp(
+  auto f = []() {
+1.0_^
+  };
+)cpp",
+{}, Opts);
+}
+
 TEST(CompletionTest, BacktrackCrashes) {
   // Sema calls code completion callbacks twice in these cases.
   auto Results = completions(R"cpp(



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


[PATCH] D137235: [clang][Interp] Fix ImplicitValueInitExprs for pointer types

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137235

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


[PATCH] D140389: [NFC][RISCV] Rename data member 'DefaultPolicy' to 'PolicyAttrs'

2022-12-20 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng added a comment.

Could you rebase with D140361 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140389

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


[PATCH] D136554: Implement CWG2631

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

Sorry for the delay, I was out on vacation for a bit. I have a repro for this 
new issue now: F25778542: repro.tar.gz 

  $ CLANG=~/dev/clang ./repro.sh
  ++ dirname /tmp/repro/repro.sh
  + DIR=/tmp/repro
  + : /tmp/D136554
  + rm -rf /tmp/D136554
  + mkdir -p /tmp/D136554
  + cd /tmp/D136554
  + cp /tmp/repro/lib.h /tmp/repro/outer.h /tmp/repro/x.h /tmp/repro/y.h 
/tmp/repro/z.h /tmp/repro/lib.cppmap /tmp/repro/outer.cppmap 
/tmp/repro/x.cppmap /tmp/repro/y.cppmap /tmp/repro/z.cppmap .
  + COMMON_ARGS=('-Wno-mismatched-tags' '-Xclang=-fmodules-embed-all-files' 
'-Xclang=-fmodules-local-submodule-visibility' '-fmodules' 
'-fno-implicit-modules' '-fno-implicit-module-maps' '-std=gnu++17' 
'-Xclang=-fmodule-map-file-home-is-cwd')
  + export COMMON_ARGS
  + /home/rupprecht/dev/clang -Wno-mismatched-tags 
-Xclang=-fmodules-embed-all-files -Xclang=-fmodules-local-submodule-visibility 
-fmodules -fno-implicit-modules -fno-implicit-module-maps -std=gnu++17 
-Xclang=-fmodule-map-file-home-is-cwd -fmodule-name=x 
-fmodule-map-file=x.cppmap -fmodule-map-file=lib.cppmap -xc++ 
-Xclang=-emit-module -c x.cppmap -o x.pcm
  + /home/rupprecht/dev/clang -Wno-mismatched-tags 
-Xclang=-fmodules-embed-all-files -Xclang=-fmodules-local-submodule-visibility 
-fmodules -fno-implicit-modules -fno-implicit-module-maps -std=gnu++17 
-Xclang=-fmodule-map-file-home-is-cwd -fmodule-name=y 
-fmodule-map-file=y.cppmap -fmodule-map-file=lib.cppmap 
-fmodule-map-file=z.cppmap -xc++ -Xclang=-emit-module -c y.cppmap -o y.pcm
  + /home/rupprecht/dev/clang -Wno-mismatched-tags 
-Xclang=-fmodules-embed-all-files -Xclang=-fmodules-local-submodule-visibility 
-fmodules -fno-implicit-modules -fno-implicit-module-maps -std=gnu++17 
-Xclang=-fmodule-map-file-home-is-cwd -fmodule-name=outer 
-fmodule-map-file=outer.cppmap -Xclang=-fmodule-file=x.pcm 
-Xclang=-fmodule-file=y.pcm -fmodule-map-file=lib.cppmap 
-fmodule-map-file=x.cppmap -fmodule-map-file=y.cppmap -xc++-header 
-fsyntax-only -c outer.h -o outer.h.processed
  In module 'x':
  ./lib.h:5:25: error: 'Foo' has different definitions in different modules; 
first difference is definition in module 'x.x.h' found data member 'kConstant' 
with an initializer
static constexpr char kConstant = '+';
~~^~~
  ./lib.h:5:25: note: but in 'y.y.h' found data member 'kConstant' with a 
different initializer
static constexpr char kConstant = '+';
~~^~~
  1 error generated.



In D136554#4000654 , @cor3ntin wrote:

> In D136554#4000363 , @rupprecht 
> wrote:
>
>> I applied this version of the patch and the crash is now gone 
>>
>> However, now I get this inexplicable error -- I'm not entirely sure it's 
>> related, maybe I'm holding it wrong:
>>
>>   In module '':
>>   foo.h$line:$num: error: 'foo::FooClass' has different definitions in 
>> different modules; first difference is definition in module 'something.h' 
>> found data member 'kFooDelimiter' with an initializer
>> static constexpr char kFooDelimiter = '+';
>> ~~^~~
>>   foo.h:$line:$num note: but in 'other.h' found data member 'kFooDelimiter' 
>> with a different initializer
>> static constexpr char kFooDelimiter = '+';
>> ~~^~~
>>
>> The definition seems straightforward:
>>
>>   class FooClass final {
>> ...
>> static constexpr char kFooDelimiter = '+';
>> ...
>>   };
>
> This is *very* surprising to me.
> I could explain it if  the member was not static though, as it would be the 
> kind of things the patch affects. But static data members are handled very 
> differently.
>
> Was that liking chrome? It didn't come up in my tests

No, it's some other internal target. There isn't any way for you to be able to 
test against these targets, so unfortunately the best I can offer is I'll patch 
in any updated versions of this patch, see what breaks, and try to reduce it 
when reporting.

There's barely any code in the repro I attached, it's just a bunch of 
header/module layering. My guess is that clang is usually able to see that the 
two definitions in different modules is the same and therefore dedupes them, 
but this change adds some unique bit of information that makes clang think it's 
different. Note that the headers need to be in a particular order to break.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D140361: [RISCV] Merge Masked and unMasked RVV manual codegen

2022-12-20 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for clean up this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140361

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


[PATCH] D140361: [RISCV] Merge Masked and unMasked RVV manual codegen

2022-12-20 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 484437.
BeMg added a comment.

Update format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140361

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -171,6 +171,10 @@
 
   if (RVVI->hasManualCodegen()) {
 OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
+if (RVVI->isMasked())
+  OS << "IsMasked = true;\n";
+else
+  OS << "IsMasked = false;\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
@@ -517,7 +521,6 @@
 bool SupportOverloading = R->getValueAsBit("SupportOverloading");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
-StringRef MaskedManualCodegen = R->getValueAsString("MaskedManualCodegen");
 std::vector IntrinsicTypes =
 R->getValueAsListOfInts("IntrinsicTypes");
 std::vector RequiredFeatures =
@@ -594,7 +597,7 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, MaskedManualCodegen,
+SupportOverloading, HasBuiltinAlias, ManualCodegen,
 MaskTypes.value(), IntrinsicTypes, RequiredFeatures, NF,
 Policy::PolicyNone, IsPrototypeDefaultTU));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
@@ -610,7 +613,7 @@
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-  MaskedManualCodegen, PolicyTypes.value(), IntrinsicTypes,
+  ManualCodegen, PolicyTypes.value(), IntrinsicTypes,
   RequiredFeatures, NF, P, IsPrototypeDefaultTU));
 }
   } // End for Log2LMULList
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -19461,6 +19461,7 @@
   constexpr unsigned TAIL_AGNOSTIC = 1;
   constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3;
   int DefaultPolicy = TAIL_UNDISTURBED;
+  bool IsMasked = false;
 
   // Required for overloaded intrinsics.
   llvm::SmallVector IntrinsicTypes;
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -217,7 +217,6 @@
 
   // Manual code in clang codegen riscv_vector_builtin_cg.inc
   code ManualCodegen = [{}];
-  code MaskedManualCodegen = [{}];
 
   // When emit the automatic clang codegen, it describes what types we have to use
   // to obtain the specific LLVM intrinsic. -1 means the return type, otherwise,
@@ -627,31 +626,18 @@
   UnMaskedPolicyScheme = HasPassthruOperand,
   ManualCodegen = [{
   {
-if (DefaultPolicy == TAIL_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-IntrinsicTypes = {ResultType, Ops[3]->getType()};
-Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-Value *NewVL = Ops[2];
-Ops.erase(Ops.begin() + 2);
-llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
-llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
-llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
-// Store new_vl.
-clang::CharUnits Align =
-CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
-llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
-Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
-return V;
-  }
-  }],
-  MaskedManualCodegen = [{
-  {
-// Move mask to right before vl.
-std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
-IntrinsicTypes = {ResultType, Ops[4]->getType()};
+if (IsMasked) {
+  // Move mask to right before vl.
+  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
+  if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
+Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
+  

[PATCH] D140361: [RISCV] Merge Masked and unMasked RVV manual codegen

2022-12-20 Thread Piyou Chen via Phabricator via cfe-commits
BeMg updated this revision to Diff 484436.
BeMg added a comment.

Update format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140361

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -171,6 +171,10 @@
 
   if (RVVI->hasManualCodegen()) {
 OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
+if (RVVI->isMasked())
+  OS << "IsMasked = true;\n";
+else
+  OS << "IsMasked = false;\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
@@ -517,7 +521,6 @@
 bool SupportOverloading = R->getValueAsBit("SupportOverloading");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
-StringRef MaskedManualCodegen = R->getValueAsString("MaskedManualCodegen");
 std::vector IntrinsicTypes =
 R->getValueAsListOfInts("IntrinsicTypes");
 std::vector RequiredFeatures =
@@ -594,7 +597,7 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, MaskedManualCodegen,
+SupportOverloading, HasBuiltinAlias, ManualCodegen,
 MaskTypes.value(), IntrinsicTypes, RequiredFeatures, NF,
 Policy::PolicyNone, IsPrototypeDefaultTU));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
@@ -610,7 +613,7 @@
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-  MaskedManualCodegen, PolicyTypes.value(), IntrinsicTypes,
+  ManualCodegen, PolicyTypes.value(), IntrinsicTypes,
   RequiredFeatures, NF, P, IsPrototypeDefaultTU));
 }
   } // End for Log2LMULList
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -19461,6 +19461,7 @@
   constexpr unsigned TAIL_AGNOSTIC = 1;
   constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3;
   int DefaultPolicy = TAIL_UNDISTURBED;
+  bool IsMasked = false;
 
   // Required for overloaded intrinsics.
   llvm::SmallVector IntrinsicTypes;
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -217,7 +217,6 @@
 
   // Manual code in clang codegen riscv_vector_builtin_cg.inc
   code ManualCodegen = [{}];
-  code MaskedManualCodegen = [{}];
 
   // When emit the automatic clang codegen, it describes what types we have to use
   // to obtain the specific LLVM intrinsic. -1 means the return type, otherwise,
@@ -627,31 +626,18 @@
   UnMaskedPolicyScheme = HasPassthruOperand,
   ManualCodegen = [{
   {
-if (DefaultPolicy == TAIL_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-IntrinsicTypes = {ResultType, Ops[3]->getType()};
-Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-Value *NewVL = Ops[2];
-Ops.erase(Ops.begin() + 2);
-llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
-llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
-llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
-// Store new_vl.
-clang::CharUnits Align =
-CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
-llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
-Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
-return V;
-  }
-  }],
-  MaskedManualCodegen = [{
-  {
-// Move mask to right before vl.
-std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
-IntrinsicTypes = {ResultType, Ops[4]->getType()};
+if (IsMasked) {
+  // Move mask to right before vl.
+  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
+  if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
+Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
+  

[PATCH] D137070: [clang][Interp] Support destructors

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/test/AST/Interp/cxx20.cpp:279
+  static_assert(testInc2() == 1, "");
+};




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

https://reviews.llvm.org/D137070

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


[PATCH] D137070: [clang][Interp] Support destructors

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:30
 /// Scope used to handle temporaries in toplevel variable declarations.
-template  class DeclScope final : public LocalScope {
+template  class DeclScope final : public VariableScope 
{
 public:

Why the change from `LocalScope` to `VariableScope`?



Comment at: clang/lib/AST/Interp/ByteCodeExprGen.h:369
+
+  if (const auto *DtorDecl = RDecl->getDestructor()) {
+const Function *Dtor = this->Ctx->getFunction(DtorDecl);




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

https://reviews.llvm.org/D137070

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


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

2022-12-20 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

In D127812#4009447 , @hctim wrote:

> Hi, this looks like a candidate for breaking the MSan bot: 
> https://lab.llvm.org/buildbot/#/builders/5/builds/30139
>
> Still looking into it and bisecting, will let you know when I have more info. 
> To reproduce the bots, the best way (because MSan setup is tricky because it 
> requires an instrumented libcxx) is to use the scripts from 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild 
> (buildbot_fast.sh is the right one).

Yeah, unfortunately I did track this failure down to this commit and reverted 
it upstream. If you need help figuring it out, please let me know. You may find 
that adding `-fsanitize-memory-track-origins=2` useful to add to the 
buildscript as well (which can be done by changing `check_stage2_msan` to 
`check_stage2_msan_track_origins` in `buildbot_fast.sh`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[clang] 74dd8c1 - Revert "[AArch64][NFC] Fix aarch64 target features test."

2022-12-20 Thread Mitch Phillips via cfe-commits

Author: Mitch Phillips
Date: 2022-12-20T17:16:17-08:00
New Revision: 74dd8c1bf80bbc415f8f6f45cb8f3f9bd83b3850

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

LOG: Revert "[AArch64][NFC] Fix aarch64 target features test."

This reverts commit bf94eac6a3f7c5cd8941956d44c15524fa3751bd.

Reason: Depends on reverted change https://reviews.llvm.org/D127812

Added: 


Modified: 
clang/test/Driver/aarch64-features.c

Removed: 




diff  --git a/clang/test/Driver/aarch64-features.c 
b/clang/test/Driver/aarch64-features.c
index b5ffc95f26d04..5c079b62768ae 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -13,7 +13,7 @@
 // RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt -mno-fmv \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
 
-// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
+// RUN: %clang -target aarch64-linux-gnu \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
 
 // RUN: %clang -target arm64-unknown-linux -rtlib=libgcc \



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


[PATCH] D139938: [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin

2022-12-20 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG52aab0e4b4a5: [clang] Re-apply change to avoid passing 
-stdlib=libc++ spuriously to CC1 on… (authored by ldionne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-stdlib-dont-pass-in-c.c
  clang/test/Driver/darwin-stdlib.cpp
  compiler-rt/test/profile/lit.cfg.py

Index: compiler-rt/test/profile/lit.cfg.py
===
--- compiler-rt/test/profile/lit.cfg.py
+++ compiler-rt/test/profile/lit.cfg.py
@@ -42,6 +42,14 @@
 clang_cflags = target_cflags + extra_link_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 
+# TODO: target_cflags can sometimes contain C++ only flags like -stdlib=, which are
+#   ignored when compiling as C code. Passing this flag when compiling as C results in
+#   warnings that break tests that use -Werror.
+#   We remove -stdlib= from the cflags here to avoid problems, but the interaction between
+#   CMake and compiler-rt's tests should be reworked so that cflags don't contain C++ only
+#   flags.
+clang_cflags = [flag.replace('-stdlib=libc++', '').replace('-stdlib=libstdc++', '') for flag in clang_cflags]
+
 def build_invocation(compile_flags, with_lto = False):
   lto_flags = []
   if with_lto and config.lto_supported:
Index: clang/test/Driver/darwin-stdlib.cpp
===
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -1,10 +1,29 @@
-// This test will fail if CLANG_DEFAULT_CXX_STDLIB is set to libstdc++.
-// XFAIL: default-cxx-stdlib=libstdc++
+// Make sure that the Driver passes down -stdlib=libc++ to CC1 when specified explicitly.
+//
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64  -miphoneos-version-min=7.0 -stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/  -mmacosx-version-min=10.9  -stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 -stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k-stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// CHECK-LIBCXX: "-stdlib=libc++"
+// CHECK-LIBCXX-NOT: "-stdlib=libstdc++"
 
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s
+// Make sure that the Driver passes down -stdlib=libstdc++ to CC1 when specified explicitly. Note that this
+// shouldn't really be used on Darwin because libstdc++ is not supported anymore, but we still pin down the
+// Driver behavior for now.
+//
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64  -miphoneos-version-min=7.0 -stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/  -mmacosx-version-min=10.9  -stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 -stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k-stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// CHECK-LIBSTDCXX: "-stdlib=libstdc++"
+// CHECK-LIBSTDCXX-NOT: "-stdlib=libc++"
 
-// CHECK: "-stdlib=libc++"
-// CHECK-NOT: "-stdlib=libstdc++"
+// Make sure that the Driver does not spuriously pass down any -stdlib=<...> option to CC1 if none is
+// specified on the command-line. In that case, CC1 should use the 

[clang] 52aab0e - [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin

2022-12-20 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2022-12-20T19:56:28-05:00
New Revision: 52aab0e4b4a5d6728f4bb9c7b3340133f585fc15

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

LOG: [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 
on Darwin

Previously, we would be passing down -stdlib=libc++ from the Driver
to CC1 whenever the default standard library on the platform was libc++,
even if -stdlib= had not been passed to the Driver. This meant that we
would pass -stdlib=libc++ in nonsensical circumstances, such as when
compiling C code.

This logic had been added in b534ce46bd40 to make sure that header
search paths were set up properly. However, since libc++ is now the
default Standard Library on Darwin, passing this explicitly is not
required anymore. Indeed, if no -stdlib= is specified, CC1 will end
up using libc++ if it queries which standard library to use, without
having to be told.

Not passing -stdlib= at all to CC1 on Darwin should become possible
once CC1 stops relying on it to set up framework search paths.

Furthermore, this commit also removes a diagnostic checking whether the
deployment target is too old to support libc++. Nowadays, all supported
deployment targets use libc++ and compiling with libstdc++ is not
supported anymore. The Driver was the wrong place to issue this
diagnostic since it doesn't know whether libc++ will actually be linked
against (e.g. C vs C++), which would lead to spurious diagnostics.
Given that these targets are not supported anymore, we simply drop
the diagnostic instead of trying to refactor it into CC1.

This is a re-application of 6540f32db09c which had been reverted in
49dd02bd0819 because it broke a compiler-rt test. The test had broken
because we were compiling C code and passing -stdlib=libc++, which Clang
will now warn about.

rdar://103198514

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

Added: 
clang/test/Driver/darwin-stdlib-dont-pass-in-c.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-header-search-libcxx.cpp
clang/test/Driver/darwin-stdlib.cpp
compiler-rt/test/profile/lit.cfg.py

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index e8927161dcbe1..4e86a5ec46b99 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,8 +203,6 @@ def warn_drv_missing_plugin_name : Warning<
 def warn_drv_missing_plugin_arg : Warning<
   "missing plugin argument for plugin %0 in %1">,
   InGroup;
-def err_drv_invalid_libcxx_deployment : Error<
-  "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
 def err_drv_invalid_argument_to_option : Error<
   "invalid argument '%0' to -%1">;
 def err_drv_missing_sanitizer_ignorelist : Error<

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index eba602529a086..ffa45d49b489a 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2869,7 +2869,6 @@ Darwin::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
   // First get the generic Apple args, before moving onto Darwin-specific ones.
   DerivedArgList *DAL =
   MachO::TranslateArgs(Args, BoundArch, DeviceOffloadKind);
-  const OptTable  = getDriver().getOpts();
 
   // If no architecture is bound, none of the translations here are relevant.
   if (BoundArch.empty())
@@ -2901,26 +2900,6 @@ Darwin::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
 }
   }
 
-  if (!Args.getLastArg(options::OPT_stdlib_EQ) &&
-  GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
-DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
-  "libc++");
-
-  // Validate the C++ standard library choice.
-  CXXStdlibType Type = GetCXXStdlibType(*DAL);
-  if (Type == ToolChain::CST_Libcxx) {
-// Check whether the target provides libc++.
-StringRef where;
-
-// Complain about targeting iOS < 5.0 in any way.
-if (isTargetIOSBased() && isIPhoneOSVersionLT(5, 0))
-  where = "iOS 5.0";
-
-if (where != StringRef()) {
-  getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment) << 
where;
-}
-  }
-
   auto Arch = tools::darwin::getArchTypeForMachOArchName(BoundArch);
   if ((Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)) {
 if (Args.hasFlag(options::OPT_fomit_frame_pointer,

diff  --git a/clang/test/Driver/darwin-header-search-libcxx.cpp 
b/clang/test/Driver/darwin-header-search-libcxx.cpp
index 32474495bbb5b..cc8ec9ceb89b3 100644
--- a/clang/test/Driver/darwin-header-search-libcxx.cpp
+++ 

[PATCH] D139938: [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin

2022-12-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

I'll ship this now since CI seems happy and I reproduced the issue and saw it 
was fixed by my new change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

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


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

2022-12-20 Thread Mitch Phillips via Phabricator via cfe-commits
hctim added a comment.

Hi, this looks like a candidate for breaking the MSan bot: 
https://lab.llvm.org/buildbot/#/builders/5/builds/30139

Still looking into it and bisecting, will let you know when I have more info. 
To reproduce the bots, the best way (because MSan setup is tricky because it 
requires an instrumented libcxx) is to use the scripts from 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild 
(buildbot_fast.sh is the right one).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D138253: [-Wunsafe-buffer-usage] NFC: Implement fix-strategies and variable-use-claiming.

2022-12-20 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I suppressed the assertion in rG8fd62e7 
. It looks 
like we'll need a deeper investigation into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138253

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


[clang] 8fd62e7 - [-Wunsafe-buffer-usage] Suppress an assertion for visiting VarDecl twice.

2022-12-20 Thread Artem Dergachev via cfe-commits

Author: Artem Dergachev
Date: 2022-12-20T16:05:13-08:00
New Revision: 8fd62e70cde135943e54d80851984988cb0a

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

LOG: [-Wunsafe-buffer-usage] Suppress an assertion for visiting VarDecl twice.

The assertion doesn't seem to hold due to ASTMatchers traversing code
inside GNU StmtExpr twice. This can screw up our algorithm's invariants.
We need a further investigation to properly fix this issue, but for now
let's avoid the crash.

Added: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c

Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 85449c4c5b1c4..88d6ca3eaf0c5 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -245,7 +245,11 @@ class DeclUseTracker {
   void discoverDecl(const DeclStmt *DS) {
 for (const Decl *D : DS->decls()) {
   if (const auto *VD = dyn_cast(D)) {
-assert(Defs.count(VD) == 0 && "Definition already discovered!");
+// FIXME: Assertion temporarily disabled due to a bug in
+// ASTMatcher internal behavior in presence of GNU
+// statement-expressions. We need to properly investigate this
+// because it can screw up our algorithm in other ways.
+// assert(Defs.count(VD) == 0 && "Definition already discovered!");
 Defs[VD] = DS;
   }
 }

diff  --git a/clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c 
b/clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c
new file mode 100644
index 0..225e67f7ba1c4
--- /dev/null
+++ b/clang/test/SemaCXX/warn-unsafe-buffer-usage-crashes.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -Wunsafe-buffer-usage %s -verify %s
+
+void gnu_stmtexpr_crash(void) {
+  struct A {};
+  struct B {
+struct A a;
+  };
+
+  struct B b = {{
+// This is a statement-expression (GNU extension).
+({ int x; }) // no-crash // expected-warning{{excess elements in struct 
initializer}}
+  }};
+}



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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2022-12-20 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 updated this revision to Diff 484412.
ziqingluo-90 added a comment.

To follow LLVM's convention that global variables better have types that do NOT 
require construction, I change the type of the global variable from 
`std::string` to `constexpr const char * const`.


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

https://reviews.llvm.org/D139737

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits.cpp
  clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp

Index: clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
===
--- clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage.cpp
@@ -67,21 +67,21 @@
 void testArraySubscriptsWithAuto(int *p, int **pp) {
   int a[10];
 
-  auto ap1 = a;
+  auto ap1 = a; // expected-warning{{'ap1' participates in unchecked buffer operations}}
 
-  foo(ap1[1]);  // expected-warning{{unchecked operation on raw buffer in expression}}
+  foo(ap1[1]);
 
-  auto ap2 = p;
+  auto ap2 = p; // expected-warning{{'ap2' participates in unchecked buffer operations}}
 
-  foo(ap2[1]);  // expected-warning{{unchecked operation on raw buffer in expression}}
+  foo(ap2[1]);
 
-  auto ap3 = pp;
+  auto ap3 = pp; // expected-warning{{'ap3' participates in unchecked buffer operations}}
 
-  foo(ap3[1][1]); // expected-warning2{{unchecked operation on raw buffer in expression}}
+  foo(ap3[1][1]); // expected-warning{{unchecked operation on raw buffer in expression}}
 
-  auto ap4 = *pp;
+  auto ap4 = *pp; // expected-warning{{'ap4' participates in unchecked buffer operations}}
 
-  foo(ap4[1]);  // expected-warning{{unchecked operation on raw buffer in expression}}
+  foo(ap4[1]);
 }
 
 void testUnevaluatedContext(int * p) {
Index: clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits.cpp
@@ -0,0 +1,73 @@
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -verify %s
+// RUN: cp %s %t.cpp
+// RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -fixit %t.cpp
+// RUN: grep -v CHECK %t.cpp | FileCheck %s
+
+void foo(...);
+typedef int * Int_ptr_t;
+typedef int Int_t;
+
+void local_array_subscript_simple() {
+// CHECK: std::span p{new int [10], 10};
+// CHECK: p[5] = 5;
+  int *p = new int[10]; // expected-warning{{variable 'p' participates in unchecked buffer operations}}
+  p[5] = 5;
+
+// CHECK: std::span q{new int [10], 10};
+// CHECK: std::span x{new int [10], 10};
+// CHECK: std::span y{new int, 1};
+// CHECK: std::span z{new int [10], 10};
+// CHECK: std::span w{new Int_t [10], 10};
+// CHECK: foo(q[5], x[5], y[5], z[5], w[5]);
+  const int *q = new int[10]; // expected-warning{{variable 'q' participates in unchecked buffer operations}}
+  Int_ptr_t x = new int[10];  // expected-warning{{variable 'x' participates in unchecked buffer operations}}
+  Int_ptr_t y = new int;  // expected-warning{{variable 'y' participates in unchecked buffer operations}}
+  Int_t * z = new int[10];// expected-warning{{variable 'z' participates in unchecked buffer operations}}
+  Int_t * w = new Int_t[10];  // expected-warning{{variable 'w' participates in unchecked buffer operations}}
+  foo(q[5], x[5], y[5], z[5], w[5]);
+  // y[5] will crash after being span
+}
+
+void local_array_subscript_auto() {
+// CHECK: std::span p{new int [10], 10};
+// CHECK: p[5] = 5;
+  auto p = new int[10]; // expected-warning{{variable 'p' participates in unchecked buffer operations}}
+  p[5] = 5;
+}
+
+void local_array_subscript_variable_extent() {
+  int n = 10;
+// CHECK: std::span p{new int [n], n};
+// CHECK: std::span q{new int [n++], ...};
+// CHECK: foo(p[5], q[5]);
+  int *p = new int[n]; // expected-warning{{variable 'p' participates in unchecked buffer operations}}
+  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+  int *q = new int[n++]; // expected-warning{{variable 'q' participates in unchecked buffer operations}}
+  foo(p[5], q[5]);
+}
+
+
+void local_ptr_to_array() {
+  int n = 10;
+  int a[10];
+  int b[n];  // If the extent expression does not have a constant value, we cannot fill the extent for users...
+// CHECK: std::span p{a, 10};
+// CHECK: std::span q{b, ...};
+// CHECK: foo(p[5], q[5]);
+  int *p = a; // expected-warning{{variable 'p' participates in unchecked buffer operations}}
+  int *q = b; // expected-warning{{variable 'q' participates in unchecked buffer operations}}
+  foo(p[5], q[5]);
+}
+
+void local_ptr_addrof_init() {
+  int a[10];
+  int var;
+// CHECK: std::span p{, 1};
+// CHECK: std::span q{, 1};
+// CHECK: foo(p[5], q[5]);
+  int (*p)[10] =  // expected-warning{{variable 'p' participates in unchecked buffer operations}}
+  int * q =  // 

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

2022-12-20 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Thanks! I think we're good now. At least one of our builders is green now. 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8794218564332891457/overview

I'll let you know if anything pops up, but this looks squared away to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D140361: [RISCV] Merge Masked and unMasked RVV manual codegen

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



Comment at: clang/include/clang/Basic/riscv_vector.td:629
   {
-if (DefaultPolicy == TAIL_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-IntrinsicTypes = {ResultType, Ops[3]->getType()};
-Ops[1] = Builder.CreateBitCast(Ops[1], ResultType->getPointerTo());
-Value *NewVL = Ops[2];
-Ops.erase(Ops.begin() + 2);
-llvm::Function *F = CGM.getIntrinsic(ID, IntrinsicTypes);
-llvm::Value *LoadValue = Builder.CreateCall(F, Ops, "");
-llvm::Value *V = Builder.CreateExtractValue(LoadValue, {0});
-// Store new_vl.
-clang::CharUnits Align =
-CGM.getNaturalPointeeTypeAlignment(E->getArg(1)->getType());
-llvm::Value *Val = Builder.CreateExtractValue(LoadValue, {1});
-Builder.CreateStore(Val, Address(NewVL, Val->getType(), Align));
-return V;
-  }
-  }],
-  MaskedManualCodegen = [{
-  {
-// Move mask to right before vl.
-std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);
-if (DefaultPolicy == TAIL_AGNOSTIC_MASK_AGNOSTIC)
-  Ops.insert(Ops.begin(), llvm::PoisonValue::get(ResultType));
-Ops.push_back(ConstantInt::get(Ops.back()->getType(), DefaultPolicy));
-IntrinsicTypes = {ResultType, Ops[4]->getType()};
+if(IsMasked) {
+  // Move mask to right before vl.

space after `if`



Comment at: clang/include/clang/Basic/riscv_vector.td:649
+clang::CharUnits Align;
+if(IsMasked) {
+  Align = CGM.getNaturalPointeeTypeAlignment(

space after `if`



Comment at: clang/include/clang/Basic/riscv_vector.td:714
 ManualCodegen = [{
-  // Builtin: (ptr, value, vl). Intrinsic: (value, ptr, vl)
-  std::swap(Ops[0], Ops[1]);
-  Ops[1] = Builder.CreateBitCast(Ops[1], 
Ops[0]->getType()->getPointerTo());
-  IntrinsicTypes = {Ops[0]->getType(), Ops[2]->getType()};
-}],
-MaskedManualCodegen= [{
-  // Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)
-  std::swap(Ops[0], Ops[2]);
+  if(IsMasked) {
+// Builtin: (mask, ptr, value, vl). Intrinsic: (value, ptr, mask, vl)

space after `if`



Comment at: clang/include/clang/Basic/riscv_vector.td:722
   Ops[1] = Builder.CreateBitCast(Ops[1], 
Ops[0]->getType()->getPointerTo());
-  IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
+  if(IsMasked) {
+IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};

space after `if`

Drop the curly brace since the bodies are single lines



Comment at: clang/include/clang/Basic/riscv_vector.td:754
   ManualCodegen = [{
-// Builtin: (ptr, stride, value, vl). Intrinsic: (value, ptr, stride, 
vl)
-std::rotate(Ops.begin(), Ops.begin() + 2, Ops.begin() + 3);
-Ops[1] = Builder.CreateBitCast(Ops[1], 
Ops[0]->getType()->getPointerTo());
-IntrinsicTypes = {Ops[0]->getType(), Ops[3]->getType()};
-  }],
-  MaskedManualCodegen= [{
-// Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, 
stride, mask, vl)
-std::swap(Ops[0], Ops[3]);
+if(IsMasked) {
+  // Builtin: (mask, ptr, stride, value, vl). Intrinsic: (value, ptr, 
stride, mask, vl)

space after `if`



Comment at: clang/include/clang/Basic/riscv_vector.td:762
 Ops[1] = Builder.CreateBitCast(Ops[1], 
Ops[0]->getType()->getPointerTo());
-IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};
+if(IsMasked) {
+  IntrinsicTypes = {Ops[0]->getType(), Ops[4]->getType()};

Space after `if`

Drop the curly braces since the bodies are single lines



Comment at: clang/include/clang/Basic/riscv_vector.td:1229
 {
-  // Builtin: (ptr, stride, val0, val1, ..., vl).
-  // Intrinsic: (val0, val1, ..., ptr, stride, vl)
-  std::rotate(Ops.begin(), Ops.begin() + 2, Ops.end() - 1);
-  IntrinsicTypes = {Ops[0]->getType(), Ops[NF + 1]->getType()};
-  assert(Ops.size() == NF + 3);
-}
-}],
-MaskedManualCodegen = [{
-{
-  // Builtin: (mask, ptr, stride, val0, val1, ..., vl).
-  // Intrinsic: (val0, val1, ..., ptr, stride, mask, vl)
-  std::rotate(Ops.begin(), Ops.begin() + 3, Ops.end() - 1);
-  std::rotate(Ops.begin() + NF, Ops.begin() + NF + 1, Ops.begin() + NF + 
3);
+  if(IsMasked) {
+// Builtin: (mask, ptr, stride, val0, val1, ..., vl).

Space after `if`



Comment at: clang/include/clang/Basic/riscv_vector.td:1278
+   } else {
+// Builtin: (ptr, index, val0, val1, ..., vl)
+// Intrinsic: (val0, val1, ..., ptr, index, vl)

Indentation looks wrong. The body is only indented once 

[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Hm, this means that llvm/lib/Target/$TARGET/$TARGET.td needs to remain working 
(or at least mostly working, things like ISel patterns can fail to type check) 
in order for Clang to build, since we're now introducing a dependency on 
llvm/lib/Target/$TARGET in Clang where there didn't used to be (regardless of 
whether you care about that target). That's probably fine but worth pointing 
out, especially in the context of experimental targets that are supposed to be 
mostly ignorable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

fpetrogalli wrote:
> lenary wrote:
> > fpetrogalli wrote:
> > > craig.topper wrote:
> > > > fpetrogalli wrote:
> > > > > lenary wrote:
> > > > > > craig.topper wrote:
> > > > > > > Why do we need to touch CMake file that aren't RISC-V?
> > > > > > Yeah, this shouldn't be needed.
> > > > > > 
> > > > > > We do have some fixes for the modules build which recently landed, 
> > > > > > maybe they fix the issues you were seeing, including:
> > > > > > - 
> > > > > > https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
> > > > > > - 
> > > > > > https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
> > > > > > - https://reviews.llvm.org/D140420 (this isn't landed, but it might 
> > > > > > clear up some weird things about the quicker modulemap fixes)
> > > > > This is unrelated to Modules. The .inc file generated by tablegen is 
> > > > > created in `{make_build_folder}/lib/TargetParser`. The file is then 
> > > > > included in `TargetParser.cpp` but also in `TargetParser.h` -> this 
> > > > > means that every time we include the latter in a cpp file we need to 
> > > > > make the inc file visible for inclusion.
> > > > Can we split RISC-V out of TargetParser.cpp and TargetParser.h?
> > > Of course! :) I'll do it in a separate patch.
> > I think, if that is the case, we should add 
> > `{make_build_folder}/lib/TargetParser` as a public include directory of the 
> > LLVMTargetParser library, which should mean anything depending on it gets 
> > that as an include directory they can rely on.
> > I think, if that is the case, we should add 
> > `{make_build_folder}/lib/TargetParser` as a public include directory of the 
> > LLVMTargetParser library, which should mean anything depending on it gets 
> > that as an include directory they can rely on.
> 
> How do I do that?I tried `target_include_directories(LLVMTargetParser PUBLIC 
> ${LLVM_LIBRARY_DIR}/TargetParser/)` but I got: 
> ```
> CMake Error in lib/TargetParser/CMakeLists.txt:
>   Target "LLVMTargetParser" INTERFACE_INCLUDE_DIRECTORIES property contains
>   path:
> 
> "/Users/fpetrogalli/<...>/build-shared/./lib/TargetParser/"
> 
>   which is prefixed in the build directory.
> 
> ```
I think https://stackoverflow.com/a/25681179 points to how to do this in such a 
way that it works properly for people using cmake install. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D139938: [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin

2022-12-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: compiler-rt/test/profile/lit.cfg.py:45-51
+# TODO: target_cflags can sometimes contain C++ only flags like -stdlib=, 
which are
+#   ignored when compiling as C code. Passing this flag when compiling as 
C results in
+#   warnings that break tests that use -Werror.
+#   We remove -stdlib= from the cflags here to avoid problems, but the 
interaction between
+#   CMake and compiler-rt's tests should be reworked so that cflags don't 
contain C++ only
+#   flags.
+clang_cflags = [flag.replace('-stdlib=libc++', 
'').replace('-stdlib=libstdc++', '') for flag in clang_cflags]

This is not great, but I think this is OK as a stopgap. I don't want to remove 
`-stdlib=libc++` from `target_cflags` in this patch since it may cause other 
issues in the test suite.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

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


[PATCH] D139938: [clang] Re-apply change to avoid passing -stdlib=libc++ spuriously to CC1 on Darwin

2022-12-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 484403.
ldionne retitled this revision from "[clang] Don't spuriously pass 
-stdlib=libc++ to CC1 on Darwin" to "[clang] Re-apply change to avoid passing 
-stdlib=libc++ spuriously to CC1 on Darwin".
ldionne edited the summary of this revision.
ldionne added a comment.
Herald added subscribers: Sanitizers, Enna1.
Herald added a project: Sanitizers.

Fix compiler-rt test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/darwin-header-search-libcxx.cpp
  clang/test/Driver/darwin-stdlib-dont-pass-in-c.c
  clang/test/Driver/darwin-stdlib.cpp
  compiler-rt/test/profile/lit.cfg.py

Index: compiler-rt/test/profile/lit.cfg.py
===
--- compiler-rt/test/profile/lit.cfg.py
+++ compiler-rt/test/profile/lit.cfg.py
@@ -42,6 +42,14 @@
 clang_cflags = target_cflags + extra_link_flags
 clang_cxxflags = config.cxx_mode_flags + clang_cflags
 
+# TODO: target_cflags can sometimes contain C++ only flags like -stdlib=, which are
+#   ignored when compiling as C code. Passing this flag when compiling as C results in
+#   warnings that break tests that use -Werror.
+#   We remove -stdlib= from the cflags here to avoid problems, but the interaction between
+#   CMake and compiler-rt's tests should be reworked so that cflags don't contain C++ only
+#   flags.
+clang_cflags = [flag.replace('-stdlib=libc++', '').replace('-stdlib=libstdc++', '') for flag in clang_cflags]
+
 def build_invocation(compile_flags, with_lto = False):
   lto_flags = []
   if with_lto and config.lto_supported:
Index: clang/test/Driver/darwin-stdlib.cpp
===
--- clang/test/Driver/darwin-stdlib.cpp
+++ clang/test/Driver/darwin-stdlib.cpp
@@ -1,10 +1,29 @@
-// This test will fail if CLANG_DEFAULT_CXX_STDLIB is set to libstdc++.
-// XFAIL: default-cxx-stdlib=libstdc++
+// Make sure that the Driver passes down -stdlib=libc++ to CC1 when specified explicitly.
+//
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64  -miphoneos-version-min=7.0 -stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/  -mmacosx-version-min=10.9  -stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 -stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k-stdlib=libc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBCXX %s
+// CHECK-LIBCXX: "-stdlib=libc++"
+// CHECK-LIBCXX-NOT: "-stdlib=libstdc++"
 
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64 -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -mmacosx-version-min=10.9 %s -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 %s -### 2>&1 | FileCheck %s
-// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k %s -### 2>&1 | FileCheck %s
+// Make sure that the Driver passes down -stdlib=libstdc++ to CC1 when specified explicitly. Note that this
+// shouldn't really be used on Darwin because libstdc++ is not supported anymore, but we still pin down the
+// Driver behavior for now.
+//
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch arm64  -miphoneos-version-min=7.0 -stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/  -mmacosx-version-min=10.9  -stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7s -miphoneos-version-min=7.0 -stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// RUN: %clang -target x86_64-apple-darwin -ccc-install-dir %S/Inputs/darwin_toolchain_tree/bin/ -arch armv7k-stdlib=libstdc++ %s -### 2>&1 | FileCheck --check-prefix=CHECK-LIBSTDCXX %s
+// CHECK-LIBSTDCXX: "-stdlib=libstdc++"
+// CHECK-LIBSTDCXX-NOT: "-stdlib=libc++"
 
-// CHECK: "-stdlib=libc++"
-// 

[PATCH] D139938: [clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin

2022-12-20 Thread Louis Dionne via Phabricator via cfe-commits
ldionne reopened this revision.
ldionne added a comment.
This revision is now accepted and ready to land.

In D139938#4008909 , @steven_wu wrote:

> In D139938#4008232 , @hans wrote:
>
>> This seems to have broken the instrprof-darwin-exports.c test, see e.g. 
>> https://green.lab.llvm.org/green/job/clang-stage1-RA/32351/
>>
>> I'll revert for now.
>
> It seems you still need to claim `OPT_stdlib_EQ` so it doesn't complain about 
> unused argument when you pass stdlib when compiling C code.

Thanks for taking a look. I actually think that the current behavior is correct 
-- we don't use `-stdlib=libc++` in C mode, and I don't think we should be 
silencing the warning. If someone compiles C code with `-stdlib=libc++`, I 
think it's OK to tell them that we're ignoring the flag.

Instead, I think the "fix" needs to be done within compiler-rt.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

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


[PATCH] D140332: [ADT] Alias llvm::Optional to std::optional

2022-12-20 Thread Kazu Hirata via Phabricator via cfe-commits
kazu added a comment.

Thank you for this patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140332

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a subscriber: aprantl.
fpetrogalli added inline comments.



Comment at: llvm/include/llvm/module.modulemap:420
 textual header "Support/CSKYTargetParser.def"
-textual header "Support/RISCVTargetParser.def"
 textual header "Support/TargetOpcodes.def"

@aprantl - I have removed a `def` file that was needed to build part of the 
interface of the `TargetParser` in `LLVMSupport`. I suspect this might have 
consequences on the Modules? The correspondent file is now created in the build 
folder as `lib/TargetParser/RISCVTargetParserDef.inc`.

Just giving you heads up in case any of the builders that use modules start 
failing once this code lands in `main`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli marked an inline comment as done.
fpetrogalli added inline comments.



Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

lenary wrote:
> fpetrogalli wrote:
> > craig.topper wrote:
> > > fpetrogalli wrote:
> > > > lenary wrote:
> > > > > craig.topper wrote:
> > > > > > Why do we need to touch CMake file that aren't RISC-V?
> > > > > Yeah, this shouldn't be needed.
> > > > > 
> > > > > We do have some fixes for the modules build which recently landed, 
> > > > > maybe they fix the issues you were seeing, including:
> > > > > - https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
> > > > > - https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
> > > > > - https://reviews.llvm.org/D140420 (this isn't landed, but it might 
> > > > > clear up some weird things about the quicker modulemap fixes)
> > > > This is unrelated to Modules. The .inc file generated by tablegen is 
> > > > created in `{make_build_folder}/lib/TargetParser`. The file is then 
> > > > included in `TargetParser.cpp` but also in `TargetParser.h` -> this 
> > > > means that every time we include the latter in a cpp file we need to 
> > > > make the inc file visible for inclusion.
> > > Can we split RISC-V out of TargetParser.cpp and TargetParser.h?
> > Of course! :) I'll do it in a separate patch.
> I think, if that is the case, we should add 
> `{make_build_folder}/lib/TargetParser` as a public include directory of the 
> LLVMTargetParser library, which should mean anything depending on it gets 
> that as an include directory they can rely on.
> I think, if that is the case, we should add 
> `{make_build_folder}/lib/TargetParser` as a public include directory of the 
> LLVMTargetParser library, which should mean anything depending on it gets 
> that as an include directory they can rely on.

How do I do that?I tried `target_include_directories(LLVMTargetParser PUBLIC 
${LLVM_LIBRARY_DIR}/TargetParser/)` but I got: 
```
CMake Error in lib/TargetParser/CMakeLists.txt:
  Target "LLVMTargetParser" INTERFACE_INCLUDE_DIRECTORIES property contains
  path:

"/Users/fpetrogalli/<...>/build-shared/./lib/TargetParser/"

  which is prefixed in the build directory.

```



Comment at: llvm/lib/Target/RISCV/CMakeLists.txt:69
+  DEPENDS
+  LLVMTargetParser
   )

lenary wrote:
> Why is this needed? I already added TargetParser to the list of required 
> components, on (new) line 61, is this doing something else?
My bad - removed!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 484391.
fpetrogalli added a comment.

@pcwang-thead, I addressed some of your comments.

The value of `EnumFeatures` is now computed dynamicaly from the
`Features` field of the `Processor` class.

As for generating `MArch` out of the `Features` field, @craig.topper
pointed me at
https://github.com/riscv-non-isa/riscv-toolchain-conventions/issues/11. From
the reading of it, it seems that the alphabetical order is enough to
build the string that carries `MArch`. Am I missing something?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/TargetParser/RISCVTargetParser.def
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/include/llvm/module.modulemap
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/unittests/Target/AMDGPU/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  llvm/utils/TableGen/TableGen.cpp
  llvm/utils/TableGen/TableGenBackends.h

Index: llvm/utils/TableGen/TableGenBackends.h
===
--- llvm/utils/TableGen/TableGenBackends.h
+++ llvm/utils/TableGen/TableGenBackends.h
@@ -94,7 +94,7 @@
 void EmitDirectivesDecl(RecordKeeper , raw_ostream );
 void EmitDirectivesImpl(RecordKeeper , raw_ostream );
 void EmitDXILOperation(RecordKeeper , raw_ostream );
-
+void EmitRISCVTargetDef(RecordKeeper , raw_ostream );
 } // End llvm namespace
 
 #endif
Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -58,6 +58,7 @@
   GenDirectivesEnumDecl,
   GenDirectivesEnumImpl,
   GenDXILOperation,
+  GenRISCVTargetDef,
 };
 
 namespace llvm {
@@ -141,8 +142,9 @@
 clEnumValN(GenDirectivesEnumImpl, "gen-directive-impl",
"Generate directive related implementation code"),
 clEnumValN(GenDXILOperation, "gen-dxil-operation",
-   "Generate DXIL operation information")));
-
+   "Generate DXIL operation information"),
+clEnumValN(GenRISCVTargetDef, "gen-riscv-target-def",
+   "Generate the list of CPU for RISCV")));
 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
 cl::opt Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"),
@@ -278,6 +280,9 @@
   case GenDXILOperation:
 EmitDXILOperation(Records, OS);
 break;
+  case GenRISCVTargetDef:
+EmitRISCVTargetDef(Records, OS);
+break;
   }
 
   return false;
Index: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
===
--- /dev/null
+++ llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -0,0 +1,60 @@
+//===- RISCVTargetDefEmitter.cpp - Generate lists of RISCV CPUs ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This tablegen backend emits the include file needed by the target
+// parser to parse the RISC-V CPUs.
+//
+//===--===//
+
+#include "llvm/TableGen/Record.h"
+#include 
+namespace llvm {
+
+std::string getEnumFeatures(Record ) {
+  std::vector Features = Rec.getValueAsListOfDefs("Features");
+  if (std::find_if(Features.begin(), Features.end(), [](Record *R) {
+return R->getName() == "Feature64Bit";
+  }) != Features.end())
+return "FK_64BIT";
+
+  return "FK_NONE";
+}
+
+void EmitRISCVTargetDef(RecordKeeper , raw_ostream ) {
+  const auto  = RK.getDefs();
+
+  OS << "#ifndef PROC\n"
+ << "#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)\n"
+ << "#endif\n\n";
+
+  OS << "PROC(INVALID, {\"invalid\"}, FK_INVALID, {\"\"})\n";
+  // Iterate on all definition records.
+  for (auto  : Map) {
+const auto  = Def.second;
+if (Record->isSubClassOf("RISCVProcessorModelPROC"))
+  OS << "PROC(" << Record->getName() << ", "
+ << "{\"" << Record->getValueAsString("Name") << "\"},"
+ << getEnumFeatures(*Record) << ", "
+ << "{\"" << 

[PATCH] D140434: readability-const-return-type: don't diagnose a template function returning T, even if sometimes instantiated with e.g. T = const int.

2022-12-20 Thread Andy Getz via Phabricator via cfe-commits
suertreus created this revision.
suertreus added a reviewer: ymandel.
Herald added a subscriber: carlosgalvezp.
Herald added a reviewer: njames93.
Herald added a project: All.
suertreus requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

It's not really a readability problem since there's no `const` to read at the 
declaration site, and returning std::remove_const_t instead usually only 
hurts readability.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140434

Files:
  clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -340,3 +340,18 @@
 __typeof__(const int) n21() {
   return 21;
 }
+
+template 
+struct n25 {
+  T foo() const { return 2; }
+};
+template struct n25;
+
+template 
+struct p41 {
+  const T foo() const { return 2; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const
+  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: return type 'const
+  // CHECK-FIXES: T foo() const { return 2; }
+};
+template struct p41;
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -112,9 +112,10 @@
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
   // qualified, ignoring decltype types.
-  auto NonLocalConstType = qualType(
-  unless(isLocalConstQualified()),
-  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
+  auto NonLocalConstType =
+  qualType(unless(isLocalConstQualified()),
+   anyOf(decltypeType(), autoType(), isTypeOfType(),
+ isTypeOfExprType(), substTemplateTypeParmType()));
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),


Index: clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -340,3 +340,18 @@
 __typeof__(const int) n21() {
   return 21;
 }
+
+template 
+struct n25 {
+  T foo() const { return 2; }
+};
+template struct n25;
+
+template 
+struct p41 {
+  const T foo() const { return 2; }
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: return type 'const
+  // CHECK-MESSAGES: [[@LINE-2]]:3: warning: return type 'const
+  // CHECK-FIXES: T foo() const { return 2; }
+};
+template struct p41;
Index: clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ConstReturnTypeCheck.cpp
@@ -112,9 +112,10 @@
 void ConstReturnTypeCheck::registerMatchers(MatchFinder *Finder) {
   // Find all function definitions for which the return types are `const`
   // qualified, ignoring decltype types.
-  auto NonLocalConstType = qualType(
-  unless(isLocalConstQualified()),
-  anyOf(decltypeType(), autoType(), isTypeOfType(), isTypeOfExprType()));
+  auto NonLocalConstType =
+  qualType(unless(isLocalConstQualified()),
+   anyOf(decltypeType(), autoType(), isTypeOfType(),
+ isTypeOfExprType(), substTemplateTypeParmType()));
   Finder->addMatcher(
   functionDecl(
   returns(allOf(isConstQualified(), unless(NonLocalConstType))),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

In D127812#4009014 , @paulkirth wrote:

> Hi, thanks for the fix. that unblocked our builder. Unfortunately, we still 
> see some errors in tests.
>
>   FAIL: Clang :: Driver/aarch64-features.c (7460 of 16622)
>    TEST 'Clang :: Driver/aarch64-features.c' FAILED 
> 
>   Script:
>   --
>   : 'RUN: at line 1';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-none-linux-gnu -### 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 
> -fsyntax-only 2>&1 | /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 2';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> arm64-none-linux-gnu -### 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 
> -fsyntax-only 2>&1 | /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 10';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-linux-android -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 13';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-linux-android -rtlib=compiler-rt -mno-fmv  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV-OFF 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 16';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-linux-gnu  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV-OFF 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 19';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> arm64-unknown-linux -rtlib=libgcc  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV-OFF 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 26';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-linux-android -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-ON 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 29';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-linux-gnu -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-ON 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 32';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> arm64-unknown-linux -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-ON 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 35';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64--none-eabi -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 38';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-apple-darwin -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 41';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-windows-gnu -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
>   : 'RUN: at line 44';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
> aarch64-unknown-openbsd -rtlib=compiler-rt  -### -c 
> /b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
> /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
> -check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
> 

[clang] bf94eac - [AArch64][NFC] Fix aarch64 target features test.

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

Author: Pavel Iliin
Date: 2022-12-20T22:29:16Z
New Revision: bf94eac6a3f7c5cd8941956d44c15524fa3751bd

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

LOG: [AArch64][NFC] Fix aarch64 target features test.

Added: 


Modified: 
clang/test/Driver/aarch64-features.c

Removed: 




diff  --git a/clang/test/Driver/aarch64-features.c 
b/clang/test/Driver/aarch64-features.c
index 5c079b62768ae..b5ffc95f26d04 100644
--- a/clang/test/Driver/aarch64-features.c
+++ b/clang/test/Driver/aarch64-features.c
@@ -13,7 +13,7 @@
 // RUN: %clang -target aarch64-linux-android -rtlib=compiler-rt -mno-fmv \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
 
-// RUN: %clang -target aarch64-linux-gnu \
+// RUN: %clang -target aarch64-linux-gnu -rtlib=libgcc \
 // RUN: -### -c %s 2>&1 | FileCheck -check-prefix=CHECK-FMV-OFF %s
 
 // RUN: %clang -target arm64-unknown-linux -rtlib=libgcc \



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


[PATCH] D136815: [clang][Interp] Unify visiting variable declarations

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM




Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:1218
+auto GlobalIndex = P.getGlobal(VD);
+assert(GlobalIndex); // visitVarDecl() didn't return false.
+if (!this->emitGetPtrGlobal(*GlobalIndex, VD))

I don't get the comment.


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

https://reviews.llvm.org/D136815

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


[PATCH] D140433: [Clang] Add `nvptx-arch` tool to query installed NVIDIA GPUs

2022-12-20 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: JonChesterfield, tra, yaxunl, jdoerfert, 
tianshilei1992, MaskRay.
Herald added subscribers: kosarev, mattd, gchakrabarti, asavonic, StephenFan, 
tpr.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, jholewinski.
Herald added a project: clang.

We already have a tool called `amdgpu-arch` which returns the GPUs on
the system. This is used to determine the default architecture when
doing offloading. This patch introduces a similar tool `nvptx-arch`.
Right now we use the detected GPU at compile time. This is unhelpful
when building on a login node and moving execution to a compute node for
example. This will allow us to better choose a default architecture when
targeting NVPTX. Also we can probably use this with CMake's `native`
setting for CUDA now.

CUDA since 11.6 provides `__nvcc_device_query` which has a similar
function but it is probably better to define this locally if we want to
depend on it in clang.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140433

Files:
  clang/tools/CMakeLists.txt
  clang/tools/nvptx-arch/CMakeLists.txt
  clang/tools/nvptx-arch/NVPTXArch.cpp

Index: clang/tools/nvptx-arch/NVPTXArch.cpp
===
--- /dev/null
+++ clang/tools/nvptx-arch/NVPTXArch.cpp
@@ -0,0 +1,67 @@
+//===- NVPTXArch.cpp - list installed NVPTX devies --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements a tool for detecting name of AMDGPU installed in system
+// using HSA. This tool is used by AMDGPU OpenMP driver.
+//
+//===--===//
+
+#if defined(__has_include)
+#if __has_include("cuda.h")
+#include "cuda.h"
+#define CUDA_HEADER_FOUND 1
+#else
+#define CUDA_HEADER_FOUND 0
+#endif
+#else
+#define CUDA_HEADER_FOUND 0
+#endif
+
+#if !CUDA_HEADER_FOUND
+int main() { return 1; }
+#else
+
+#include 
+#include 
+
+static int handleError(CUresult Err) {
+  const char *ErrStr = nullptr;
+  CUresult Result = cuGetErrorString(Err, );
+  if (Result != CUDA_SUCCESS)
+return 1;
+  printf("CUDA error: %s\n", ErrStr);
+  return 1;
+}
+
+int main() {
+  if (CUresult Err = cuInit(0))
+return 1;
+
+  int Count = 0;
+  if (cuDeviceGetCount())
+return 1;
+  if (Count == 0)
+return 0;
+  for (int DeviceId = 0; DeviceId < Count; ++DeviceId) {
+CUdevice Device;
+if (CUresult Err = cuDeviceGet(, DeviceId))
+  return handleError(Err);
+
+int32_t Major, Minor;
+if (CUresult Err = cuDeviceGetAttribute(
+, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR, Device))
+  return handleError(Err);
+if (CUresult Err = cuDeviceGetAttribute(
+, CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR, Device))
+  return handleError(Err);
+
+printf("sm_%d%d\n", Major, Minor);
+  }
+  return 0;
+}
+#endif
Index: clang/tools/nvptx-arch/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/nvptx-arch/CMakeLists.txt
@@ -0,0 +1,28 @@
+# //======//
+# //
+# // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+# // See https://llvm.org/LICENSE.txt for details.
+# // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+# //
+# //======//
+
+
+# TODO: This is deprecated. Since CMake 3.17 we can use FindCUDAToolkit instead.
+find_package(CUDA QUIET)
+find_library(cuda-library NAMES cuda PATHS /lib64)
+if (NOT cuda-library AND CUDA_FOUND)
+  get_filename_component(CUDA_LIBDIR "${CUDA_cudart_static_LIBRARY}" DIRECTORY)
+  find_library(cuda-library NAMES cuda HINTS "${CUDA_LIBDIR}/stubs")
+endif()
+
+if (NOT CUDA_FOUND OR NOT cuda-library)
+  message(STATUS "Not building nvptx-arch: cuda runtime not found")
+  return()
+endif()
+
+add_clang_tool(nvptx-arch NVPTXArch.cpp)
+
+set_target_properties(nvptx-arch PROPERTIES INSTALL_RPATH_USE_LINK_PATH ON)
+target_include_directories(nvptx-arch PRIVATE ${CUDA_INCLUDE_DIRS})
+
+clang_target_link_libraries(nvptx-arch PRIVATE ${cuda-library})
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -50,3 +50,4 @@
 add_clang_subdirectory(libclang)
 
 add_clang_subdirectory(amdgpu-arch)
+add_clang_subdirectory(nvptx-arch)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 484380.
fpetrogalli marked 8 inline comments as done.
fpetrogalli added a comment.

1. I have split the RISCV bits of the target parser out of TargetParser.cpp so 
that none of the non-RISCV components need to include

the folder with the autogenerated .inc file.

2. I have removed the hard-coded RISCVTargetParser.def
3. Minor cosmetic changes requested from review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/TargetParser/RISCVTargetParser.def
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/include/llvm/module.modulemap
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/unittests/Target/AMDGPU/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  llvm/utils/TableGen/TableGen.cpp
  llvm/utils/TableGen/TableGenBackends.h

Index: llvm/utils/TableGen/TableGenBackends.h
===
--- llvm/utils/TableGen/TableGenBackends.h
+++ llvm/utils/TableGen/TableGenBackends.h
@@ -94,7 +94,7 @@
 void EmitDirectivesDecl(RecordKeeper , raw_ostream );
 void EmitDirectivesImpl(RecordKeeper , raw_ostream );
 void EmitDXILOperation(RecordKeeper , raw_ostream );
-
+void EmitRISCVTargetDef(RecordKeeper , raw_ostream );
 } // End llvm namespace
 
 #endif
Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -58,6 +58,7 @@
   GenDirectivesEnumDecl,
   GenDirectivesEnumImpl,
   GenDXILOperation,
+  GenRISCVTargetDef,
 };
 
 namespace llvm {
@@ -141,8 +142,9 @@
 clEnumValN(GenDirectivesEnumImpl, "gen-directive-impl",
"Generate directive related implementation code"),
 clEnumValN(GenDXILOperation, "gen-dxil-operation",
-   "Generate DXIL operation information")));
-
+   "Generate DXIL operation information"),
+clEnumValN(GenRISCVTargetDef, "gen-riscv-target-def",
+   "Generate the list of CPU for RISCV")));
 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
 cl::opt Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"),
@@ -278,6 +280,9 @@
   case GenDXILOperation:
 EmitDXILOperation(Records, OS);
 break;
+  case GenRISCVTargetDef:
+EmitRISCVTargetDef(Records, OS);
+break;
   }
 
   return false;
Index: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
===
--- /dev/null
+++ llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -0,0 +1,49 @@
+//===- RISCVTargetDefEmitter.cpp - Generate lists of RISCV CPUs ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This tablegen backend emits the include file needed by the target
+// parser to parse the RISC-V CPUs.
+//
+//===--===//
+
+#include "llvm/TableGen/Record.h"
+
+namespace llvm {
+void EmitRISCVTargetDef(RecordKeeper , raw_ostream ) {
+  const auto  = RK.getDefs();
+
+  OS << "#ifndef PROC\n"
+ << "#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)\n"
+ << "#endif\n\n";
+
+  OS << "PROC(INVALID, {\"invalid\"}, FK_INVALID, {\"\"})\n";
+  // Iterate on all definition records.
+  for (auto  : Map) {
+const auto  = Def.second;
+if (Record->isSubClassOf("RISCVProcessorModelPROC"))
+  OS << "PROC(" << Record->getName() << ", "
+ << "{\"" << Record->getValueAsString("Name") << "\"},"
+ << Record->getValueAsString("EnumFeatures") << ", "
+ << "{\"" << Record->getValueAsString("DefaultMarch") << "\"})\n";
+  }
+  OS << "\n#undef PROC\n";
+  OS << "\n";
+  OS << "#ifndef TUNE_PROC\n"
+ << "#define TUNE_PROC(ENUM, NAME)\n"
+ << "#endif\n\n";
+  OS << "TUNE_PROC(GENERIC, \"generic\")\n";
+  for (auto  : Map) {
+const auto  = Def.second;
+if (Record->isSubClassOf("RISCVProcessorModelTUNE_PROC"))
+  OS << "TUNE_PROC(" << Record->getName() << ", "
+ << "\"" << 

[PATCH] D140432: [AArch64] Guard {vmull_p64, vmull_high_p64} with 'aes' target guard.

2022-12-20 Thread Mingming Liu via Phabricator via cfe-commits
mingmingl updated this revision to Diff 484373.
mingmingl added a comment.

indent intrinsic definition in arm_neon.td


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140432

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/Sema/aarch64-neon-target.c

Index: clang/test/Sema/aarch64-neon-target.c
===
--- clang/test/Sema/aarch64-neon-target.c
+++ clang/test/Sema/aarch64-neon-target.c
@@ -60,7 +60,7 @@
   vrnd32xq_f32(v4f32);
 }
 
-void undefined(uint32x2_t v2i32, uint32x4_t v4i32, uint16x8_t v8i16, uint8x16_t v16i8, uint8x8_t v8i8, float32x2_t v2f32, float32x4_t v4f32, float16x4_t v4f16, float64x2_t v2f64, bfloat16x4_t v4bf16, __bf16 bf16) {
+void undefined(uint32x2_t v2i32, uint32x4_t v4i32, uint16x8_t v8i16, uint8x16_t v16i8, uint8x8_t v8i8, float32x2_t v2f32, float32x4_t v4f32, float16x4_t v4f16, float64x2_t v2f64, bfloat16x4_t v4bf16, __bf16 bf16, poly64_t poly64, poly64x2_t poly64x2) {
   // dotprod
   vdot_u32(v2i32, v8i8, v8i8); // expected-error {{always_inline function 'vdot_u32' requires target feature 'dotprod'}}
   vdot_laneq_u32(v2i32, v8i8, v16i8, 1); // expected-error {{always_inline function 'vdot_u32' requires target feature 'dotprod'}}
@@ -92,4 +92,8 @@
   vcmlaq_rot270_laneq_f64(v2f64, v2f64, v2f64, 1); // expected-error {{always_inline function 'vcmlaq_rot270_f64' requires target feature 'v8.3a'}}
   // 8.5 - frint
   vrnd32xq_f32(v4f32); // expected-error {{always_inline function 'vrnd32xq_f32' requires target feature 'v8.5a'}}
+
+  vmull_p64(poly64, poly64);  // expected-error {{always_inline function 'vmull_p64' requires target feature 'aes'}}
+  vmull_high_p64(poly64x2, poly64x2);  // expected-error {{always_inline function 'vmull_high_p64' requires target feature 'aes'}}
+
 }
Index: clang/test/CodeGen/aarch64-poly128.c
===
--- clang/test/CodeGen/aarch64-poly128.c
+++ clang/test/CodeGen/aarch64-poly128.c
@@ -28,8 +28,8 @@
 // CHECK-LABEL: define {{[^@]+}}@test_vldrq_p128
 // CHECK-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP2:%.*]] = load i128, ptr [[PTR]], align 16
-// CHECK-NEXT:ret i128 [[TMP2]]
+// CHECK-NEXT:[[TMP0:%.*]] = load i128, ptr [[PTR]], align 16
+// CHECK-NEXT:ret i128 [[TMP0]]
 //
 poly128_t test_vldrq_p128(poly128_t * ptr) {
   return vldrq_p128(ptr);
@@ -39,9 +39,9 @@
 // CHECK-LABEL: define {{[^@]+}}@test_ld_st_p128
 // CHECK-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP2:%.*]] = load i128, ptr [[PTR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load i128, ptr [[PTR]], align 16
 // CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds i128, ptr [[PTR]], i64 1
-// CHECK-NEXT:store i128 [[TMP2]], ptr [[ADD_PTR]], align 16
+// CHECK-NEXT:store i128 [[TMP0]], ptr [[ADD_PTR]], align 16
 // CHECK-NEXT:ret void
 //
 void test_ld_st_p128(poly128_t * ptr) {
@@ -50,18 +50,18 @@
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vmull_p64
-// CHECK-SAME: (i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) #[[ATTR0]] {
+// CHECK-SAME: (i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) #[[ATTR1:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[VMULL_P64_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.pmull64(i64 [[A]], i64 [[B]])
 // CHECK-NEXT:[[VMULL_P641_I:%.*]] = bitcast <16 x i8> [[VMULL_P64_I]] to i128
 // CHECK-NEXT:ret i128 [[VMULL_P641_I]]
 //
-poly128_t test_vmull_p64(poly64_t a, poly64_t b) {
+__attribute__((target("aes"))) poly128_t test_vmull_p64(poly64_t a, poly64_t b) {
   return vmull_p64(a, b);
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vmull_high_p64
-// CHECK-SAME: (<2 x i64> noundef [[A:%.*]], <2 x i64> noundef [[B:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK-SAME: (<2 x i64> noundef [[A:%.*]], <2 x i64> noundef [[B:%.*]]) #[[ATTR2:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[SHUFFLE_I5:%.*]] = shufflevector <2 x i64> [[A]], <2 x i64> [[A]], <1 x i32> 
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[SHUFFLE_I5]] to i64
@@ -71,12 +71,12 @@
 // CHECK-NEXT:[[VMULL_P641_I_I:%.*]] = bitcast <16 x i8> [[VMULL_P64_I_I]] to i128
 // CHECK-NEXT:ret i128 [[VMULL_P641_I_I]]
 //
-poly128_t test_vmull_high_p64(poly64x2_t a, poly64x2_t b) {
+__attribute__((target("aes"))) poly128_t test_vmull_high_p64(poly64x2_t a, poly64x2_t b) {
   return vmull_high_p64(a, b);
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vreinterpretq_p128_s8
-// CHECK-SAME: (<16 x i8> noundef [[A:%.*]]) #[[ATTR1]] {
+// CHECK-SAME: (<16 x i8> noundef [[A:%.*]]) #[[ATTR3:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <16 x i8> [[A]] to i128
 // CHECK-NEXT:ret i128 [[TMP0]]
@@ -86,7 +86,7 @@
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vreinterpretq_p128_s16
-// CHECK-SAME: (<8 x 

[PATCH] D140432: [AArch64] Guard {vmull_p64, vmull_high_p64} with 'aes' target guard.

2022-12-20 Thread Mingming Liu via Phabricator via cfe-commits
mingmingl created this revision.
mingmingl added a reviewer: dmgreen.
Herald added a subscriber: kristof.beyls.
Herald added a project: All.
mingmingl requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In this way, cpp code that uses these intrinsics without specifying the 
required extension gets better hint.

- Before, compile crashes with LLVM ISel internal message (see issue 59599).
- After, clang hints that target 'aes' is required.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140432

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/test/CodeGen/aarch64-poly128.c
  clang/test/Sema/aarch64-neon-target.c

Index: clang/test/Sema/aarch64-neon-target.c
===
--- clang/test/Sema/aarch64-neon-target.c
+++ clang/test/Sema/aarch64-neon-target.c
@@ -60,7 +60,7 @@
   vrnd32xq_f32(v4f32);
 }
 
-void undefined(uint32x2_t v2i32, uint32x4_t v4i32, uint16x8_t v8i16, uint8x16_t v16i8, uint8x8_t v8i8, float32x2_t v2f32, float32x4_t v4f32, float16x4_t v4f16, float64x2_t v2f64, bfloat16x4_t v4bf16, __bf16 bf16) {
+void undefined(uint32x2_t v2i32, uint32x4_t v4i32, uint16x8_t v8i16, uint8x16_t v16i8, uint8x8_t v8i8, float32x2_t v2f32, float32x4_t v4f32, float16x4_t v4f16, float64x2_t v2f64, bfloat16x4_t v4bf16, __bf16 bf16, poly64_t poly64, poly64x2_t poly64x2) {
   // dotprod
   vdot_u32(v2i32, v8i8, v8i8); // expected-error {{always_inline function 'vdot_u32' requires target feature 'dotprod'}}
   vdot_laneq_u32(v2i32, v8i8, v16i8, 1); // expected-error {{always_inline function 'vdot_u32' requires target feature 'dotprod'}}
@@ -92,4 +92,8 @@
   vcmlaq_rot270_laneq_f64(v2f64, v2f64, v2f64, 1); // expected-error {{always_inline function 'vcmlaq_rot270_f64' requires target feature 'v8.3a'}}
   // 8.5 - frint
   vrnd32xq_f32(v4f32); // expected-error {{always_inline function 'vrnd32xq_f32' requires target feature 'v8.5a'}}
+
+  vmull_p64(poly64, poly64);  // expected-error {{always_inline function 'vmull_p64' requires target feature 'aes'}}
+  vmull_high_p64(poly64x2, poly64x2);  // expected-error {{always_inline function 'vmull_high_p64' requires target feature 'aes'}}
+
 }
Index: clang/test/CodeGen/aarch64-poly128.c
===
--- clang/test/CodeGen/aarch64-poly128.c
+++ clang/test/CodeGen/aarch64-poly128.c
@@ -28,8 +28,8 @@
 // CHECK-LABEL: define {{[^@]+}}@test_vldrq_p128
 // CHECK-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP2:%.*]] = load i128, ptr [[PTR]], align 16
-// CHECK-NEXT:ret i128 [[TMP2]]
+// CHECK-NEXT:[[TMP0:%.*]] = load i128, ptr [[PTR]], align 16
+// CHECK-NEXT:ret i128 [[TMP0]]
 //
 poly128_t test_vldrq_p128(poly128_t * ptr) {
   return vldrq_p128(ptr);
@@ -39,9 +39,9 @@
 // CHECK-LABEL: define {{[^@]+}}@test_ld_st_p128
 // CHECK-SAME: (ptr noundef [[PTR:%.*]]) #[[ATTR0]] {
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP2:%.*]] = load i128, ptr [[PTR]], align 16
+// CHECK-NEXT:[[TMP0:%.*]] = load i128, ptr [[PTR]], align 16
 // CHECK-NEXT:[[ADD_PTR:%.*]] = getelementptr inbounds i128, ptr [[PTR]], i64 1
-// CHECK-NEXT:store i128 [[TMP2]], ptr [[ADD_PTR]], align 16
+// CHECK-NEXT:store i128 [[TMP0]], ptr [[ADD_PTR]], align 16
 // CHECK-NEXT:ret void
 //
 void test_ld_st_p128(poly128_t * ptr) {
@@ -50,18 +50,18 @@
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vmull_p64
-// CHECK-SAME: (i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) #[[ATTR0]] {
+// CHECK-SAME: (i64 noundef [[A:%.*]], i64 noundef [[B:%.*]]) #[[ATTR1:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[VMULL_P64_I:%.*]] = call <16 x i8> @llvm.aarch64.neon.pmull64(i64 [[A]], i64 [[B]])
 // CHECK-NEXT:[[VMULL_P641_I:%.*]] = bitcast <16 x i8> [[VMULL_P64_I]] to i128
 // CHECK-NEXT:ret i128 [[VMULL_P641_I]]
 //
-poly128_t test_vmull_p64(poly64_t a, poly64_t b) {
+__attribute__((target("aes"))) poly128_t test_vmull_p64(poly64_t a, poly64_t b) {
   return vmull_p64(a, b);
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vmull_high_p64
-// CHECK-SAME: (<2 x i64> noundef [[A:%.*]], <2 x i64> noundef [[B:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK-SAME: (<2 x i64> noundef [[A:%.*]], <2 x i64> noundef [[B:%.*]]) #[[ATTR2:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[SHUFFLE_I5:%.*]] = shufflevector <2 x i64> [[A]], <2 x i64> [[A]], <1 x i32> 
 // CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[SHUFFLE_I5]] to i64
@@ -71,12 +71,12 @@
 // CHECK-NEXT:[[VMULL_P641_I_I:%.*]] = bitcast <16 x i8> [[VMULL_P64_I_I]] to i128
 // CHECK-NEXT:ret i128 [[VMULL_P641_I_I]]
 //
-poly128_t test_vmull_high_p64(poly64x2_t a, poly64x2_t b) {
+__attribute__((target("aes"))) poly128_t test_vmull_high_p64(poly64x2_t a, poly64x2_t b) {
   return vmull_high_p64(a, b);
 }
 
 // CHECK-LABEL: define {{[^@]+}}@test_vreinterpretq_p128_s8
-// CHECK-SAME: (<16 x i8> noundef [[A:%.*]]) 

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

2022-12-20 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Hi, thanks for the fix. that unblocked our builder. Unfortunately, we still see 
some errors in tests.

  FAIL: Clang :: Driver/aarch64-features.c (7460 of 16622)
   TEST 'Clang :: Driver/aarch64-features.c' FAILED 

  Script:
  --
  : 'RUN: at line 1';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-none-linux-gnu -### 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 
-fsyntax-only 2>&1 | /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 2';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
arm64-none-linux-gnu -### 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 
-fsyntax-only 2>&1 | /b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 10';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-linux-android -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 13';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-linux-android -rtlib=compiler-rt -mno-fmv  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 16';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-linux-gnu  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 19';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
arm64-unknown-linux -rtlib=libgcc  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck -check-prefix=CHECK-FMV-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 26';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-linux-android -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-ON 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 29';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-linux-gnu -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-ON 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 32';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
arm64-unknown-linux -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-ON 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 35';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64--none-eabi -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 38';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-apple-darwin -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 41';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-windows-gnu -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 44';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-unknown-openbsd -rtlib=compiler-rt  -### -c 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c 2>&1 | 
/b/s/w/ir/x/w/staging/llvm_build/bin/FileCheck 
-check-prefix=CHECK-OUTLINE-ATOMICS-OFF 
/b/s/w/ir/x/w/llvm-llvm-project/clang/test/Driver/aarch64-features.c
  : 'RUN: at line 47';   /b/s/w/ir/x/w/staging/llvm_build/bin/clang -target 
aarch64-linux-gnu -rtlib=libgcc  

[PATCH] D140430: [clang][dataflow] Fix bug in handling of `return` statements.

2022-12-20 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added reviewers: xazax.hun, gribozavr2.
Herald added subscribers: martong, rnkovacs.
Herald added a reviewer: NoQ.
Herald added a project: All.
ymandel requested review of this revision.
Herald added a project: clang.

The handling of return statements, added in support of context-sensitive
analysis, has a bug relating to functions that return reference
types. Specifically, interpretation of such functions can result in a crash from
a bad cast. This patch fixes the bug and guards all of that code with the
context-sensitive option, since there's no reason to execute at all when
context-sensitive analysis is off.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140430

Files:
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -4018,6 +4018,35 @@
   {TransferOptions{/*.ContextSensitiveOpts=*/std::nullopt}});
 }
 
+// This test is a regression test, based on a real crash.
+TEST(TransferTest, ContextSensitiveReturnReferenceFromNonReferenceLvalue) {
+  // This code exercises an unusual code path. If we return an lvalue directly,
+  // the code will catch that it's an l-value based on the `Value`'s kind. If 
we
+  // pass through a dummy function, the framework won't populate a value at
+  // all. In contrast, this code results in a (fresh) value, but it is not
+  // `ReferenceValue`. This test verifies that we catch this case as well.
+  std::string Code = R"(
+class S {};
+S& target(bool b, S ) {
+  return b ? s : s;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> ,
+ ASTContext ) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment  = getEnvironmentAtAnnotation(Results, "p");
+
+auto *Loc = Env.getReturnStorageLocation();
+ASSERT_THAT(Loc, NotNull());
+
+EXPECT_THAT(Env.getValue(*Loc), IsNull());
+  },
+  {TransferOptions{ContextSensitiveOptions{}}});
+}
+
 TEST(TransferTest, ContextSensitiveDepthZero) {
   std::string Code = R"(
 bool GiveBool();
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -429,6 +429,9 @@
   }
 
   void VisitReturnStmt(const ReturnStmt *S) {
+if (!Options.ContextSensitiveOpts)
+  return;
+
 auto *Ret = S->getRetValue();
 if (Ret == nullptr)
   return;
@@ -443,6 +446,10 @@
 
 auto *Loc = Env.getReturnStorageLocation();
 assert(Loc != nullptr);
+// FIXME: Support reference-type returns.
+if (Loc->getType()->isReferenceType())
+  return;
+
 // FIXME: Model NRVO.
 Env.setValue(*Loc, *Val);
   }


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -4018,6 +4018,35 @@
   {TransferOptions{/*.ContextSensitiveOpts=*/std::nullopt}});
 }
 
+// This test is a regression test, based on a real crash.
+TEST(TransferTest, ContextSensitiveReturnReferenceFromNonReferenceLvalue) {
+  // This code exercises an unusual code path. If we return an lvalue directly,
+  // the code will catch that it's an l-value based on the `Value`'s kind. If we
+  // pass through a dummy function, the framework won't populate a value at
+  // all. In contrast, this code results in a (fresh) value, but it is not
+  // `ReferenceValue`. This test verifies that we catch this case as well.
+  std::string Code = R"(
+class S {};
+S& target(bool b, S ) {
+  return b ? s : s;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> ,
+ ASTContext ) {
+ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
+const Environment  = getEnvironmentAtAnnotation(Results, "p");
+
+auto *Loc = Env.getReturnStorageLocation();
+ASSERT_THAT(Loc, NotNull());
+
+EXPECT_THAT(Env.getValue(*Loc), IsNull());
+  },
+  {TransferOptions{ContextSensitiveOptions{}}});
+}
+
 TEST(TransferTest, ContextSensitiveDepthZero) {
   std::string Code = R"(
 bool GiveBool();
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -429,6 +429,9 @@
   }
 
   void VisitReturnStmt(const ReturnStmt *S) {
+if (!Options.ContextSensitiveOpts)
+  return;
+
 auto *Ret = 

[PATCH] D77470: [clang] NFC: Fix trivial typo in comments and document

2022-12-20 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.
Herald added a project: All.



Comment at: clang/lib/Lex/PPDirectives.cpp:115
 // vends a module map, one might want to avoid hitting intermediate build
-// products containing the the module map or avoid finding the system installed
+// products containimg the module map or avoid finding the system installed
 // modulemap for that library.

This commit actually created new typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77470

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


[PATCH] D139938: [clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin

2022-12-20 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D139938#4008232 , @hans wrote:

> This seems to have broken the instrprof-darwin-exports.c test, see e.g. 
> https://green.lab.llvm.org/green/job/clang-stage1-RA/32351/
>
> I'll revert for now.

It seems you still need to claim `OPT_stdlib_EQ` so it doesn't complain about 
unused argument when you pass stdlib when compiling C code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

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


[PATCH] D140312: [clang-format] Disallow decltype in the middle of constraints

2022-12-20 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3494
 ///
 /// This is either the definition of a concept, or the body of a requires
 /// clause. It returns, when the parsing is complete, or the expression is

HazardyKnusperkeks wrote:
> The comment needs to be adapted.
> 
> But I think it could just be merged into the parsing of the requires clause, 
> or not?
Actually this needs to be done on D140339.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140312

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


[PATCH] D140312: [clang-format] Disallow decltype in the middle of constraints

2022-12-20 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:3494
 ///
 /// This is either the definition of a concept, or the body of a requires
 /// clause. It returns, when the parsing is complete, or the expression is

The comment needs to be adapted.

But I think it could just be merged into the parsing of the requires clause, or 
not?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140312

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


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

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D137838#4008605 , @lenary wrote:

> I'm working on a follow-up, which should make the split a bit clearer, but 
> I'm also not a modulemap expert and the `-DLLVM_ENABLE_MODULES=On` 
> configuration is broken on my linux dev box. I'll post it for review if those 
> two patches have at least made the build greener.

Here: https://reviews.llvm.org/D140420 - I'm not sure how urgent this is, if 
your patches did get your builds green. I think in e.g. the bazel build, 
there's still a bunch of places where TargetParser is closely entwined with 
Support that we can fix in the same way we intend to fix the forwarding headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

fpetrogalli wrote:
> craig.topper wrote:
> > fpetrogalli wrote:
> > > lenary wrote:
> > > > craig.topper wrote:
> > > > > Why do we need to touch CMake file that aren't RISC-V?
> > > > Yeah, this shouldn't be needed.
> > > > 
> > > > We do have some fixes for the modules build which recently landed, 
> > > > maybe they fix the issues you were seeing, including:
> > > > - https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
> > > > - https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
> > > > - https://reviews.llvm.org/D140420 (this isn't landed, but it might 
> > > > clear up some weird things about the quicker modulemap fixes)
> > > This is unrelated to Modules. The .inc file generated by tablegen is 
> > > created in `{make_build_folder}/lib/TargetParser`. The file is then 
> > > included in `TargetParser.cpp` but also in `TargetParser.h` -> this means 
> > > that every time we include the latter in a cpp file we need to make the 
> > > inc file visible for inclusion.
> > Can we split RISC-V out of TargetParser.cpp and TargetParser.h?
> Of course! :) I'll do it in a separate patch.
I think, if that is the case, we should add 
`{make_build_folder}/lib/TargetParser` as a public include directory of the 
LLVMTargetParser library, which should mean anything depending on it gets that 
as an include directory they can rely on.



Comment at: llvm/lib/Target/RISCV/CMakeLists.txt:69
+  DEPENDS
+  LLVMTargetParser
   )

Why is this needed? I already added TargetParser to the list of required 
components, on (new) line 61, is this doing something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:254
 
+def warn_for_global_ctor_for_dllimport : Warning<
+  "global constructor is generated for dllimport global var %0">,

Missing code to emit this warning?



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5006
+if (NeedsGlobalCtor || NeedsGlobalDtor)
+  DelayedCXXInitPosition[D] = ~0U;
+  } else {

zahiraam wrote:
> Do you agree this should be done only when one of those flags is on?
Yes, that's fine; I wasn't really paying close attention to the exact code.  
Just wanted to make the point about the structure of the if statements, and 
code was the easiest way to explain it.

Maybe the outer if statement should actually be `if (isStaticInit(D, 
getLangOpts()) && NeedsGlobalCtor) {`.

On a related note, we might want to avoid the name "ctor", in case that 
accidentally conflicts with some user code; an "__"-prefixed name would be 
appropriate.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5009
+  if (isStaticInit(D, getLangOpts()) && NeedsGlobalCtor && NeedsGlobalDtor) {
+EmitCXXCtorInit(D, GV, true, 201, llvm::StringLiteral("ctor"), false);
+EmitCXXCtorInit(D, GV, false, 65535, llvm::StringLiteral("dtor"), true);

zahiraam wrote:
> efriedma wrote:
> > zahiraam wrote:
> > > efriedma wrote:
> > > > I think you want to use priority 201 whether or not there's a 
> > > > destructor.
> > > Is that what you mean?
> > I think it should look something more like this:
> > 
> > ```
> > if (isStaticInit(D, getLangOpts()) {
> >   if (NeedsGlobalCtor)
> > EmitCXXCtorInit(D, GV, true, 201, llvm::StringLiteral("ctor"), false);
> >   if (NeedsGlobalDtor)
> > EmitCXXCtorInit(D, GV, false, 65535, llvm::StringLiteral("dtor"), true);
> >   DelayedCXXInitPosition[D] = ~0U;
> > } else {
> >   EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor);
> > }
> If you agree with the generated IR for this case, then I will start editing 
> the LIT tests accordingly.
> 
>   // CHECK: @"?b@@3UB@@A" = dso_local global %struct.B undef
>   // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
> i32, ptr, ptr } { i32 65535, ptr @dtor, ptr null }]
> 
>   // CHECK: define internal void @dtor()
>   // CHECK: entry:
>   // CHECK: %0 = call i32 @atexit(ptr @"??__Fb@@YAXXZ")
>   // CHECK:   ret void
> 
>   // CHECk: define linkonce_odr dso_local x86_thiscallcc void @"??1B@@QAE@XZ"
>   // CHECK: entry:
>   // CHECK:  %this.addr = alloca ptr, align 4
>   // CHECK:  store ptr %this, ptr %this.addr, align 4
>   // CHECK:  %this1 = load ptr, ptr %this.addr, align 4
>   // CHECK:  ret void
> 
> 
>   // CHECK: define internal void @"??__Fb@@YAXXZ"() #0 {
>   // CHECK: entry:
>   // CHECK:   call x86_thiscallcc void @"??1B@@QAE@XZ"(ptr @"?b@@3UB@@A")
>   // CHECK:   ret void
> 
> 
>   struct B {
> constexpr B() {}
> ~B() {};
>   };
>   constinit B b;
> 
> 
> The ctor with priority 201 is generated only when tryEmitForInitializer 
> returns a nullptr (that's the only time when NeedsGlobalCtor is set to true). 
> Correct?
Right, we only need the priority 201 ctor if tryEmitForInitializer fails, but 
we need constant initialization anyway to meet the C++ language requirements.

Updated code seems much cleaner.



Comment at: clang/test/CodeGenCXX/PR19955.cpp:16
+
+// CHECK: define internal void @ctor()
+// CHECK: entry

It's easier to debug FileCheck failures if you use CHECK-LABEL for function 
definitions.

You probably want to use a different prefix that's used for both 32-bit and 
64-bit for lines like this.

CHECK-64 isn't used by any FileCheck invocation.


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

https://reviews.llvm.org/D137107

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


[PATCH] D135750: [clang][Interp] Track initialization state of local variables

2022-12-20 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

This looks good to me but I see at least one concern that Aaron had that he did 
not get back on, so I will wait for him to approve.




Comment at: clang/lib/AST/Interp/ByteCodeExprGen.cpp:835
 IsTemporary = true;
 Ty = E->getType();
   }

tbaeder wrote:
> shafik wrote:
> > Do we really want to the type of the expression? If we have a `ValueDecl` 
> > don't we want that type? I think they should be the same, do you have any 
> > examples where the expression is the type we want? I am looking at the AST 
> > from ` int x = 1+1L;` 
> > 
> > https://godbolt.org/z/q3Tr7Kxoq
> I don't have a counter example but I didn't write that line either. The Expr 
> case is for temporary values created for AST expressions, not sure what other 
> type to use.
I think it should be an `else if` we either have a `Decl` or an `Expr` right?



Comment at: clang/lib/AST/Interp/ByteCodeStmtGen.cpp:408
 // Compile the initializer in its own scope.
-{
+if (Init) {
   ExprScope Scope(this);

So by moving the check for `Init` forward, we will still allocate but we may 
not initialize.



Comment at: clang/lib/AST/Interp/Descriptor.h:73
+  /// Flag indicating if the field is mutable (if in a record).
+  unsigned IsMutable : 1;
+

aaron.ballman wrote:
> tbaeder wrote:
> > shafik wrote:
> > > Maybe `IsFieldMutable` b/c we call `CreateDescriptor` it is a little 
> > > confusing why we have `IsConst` and `IsMutable`
> > Agreed, but this code was just moved up in this patch, the field was 
> > introduced earlier.
> We can do a renaming pass once this lands, but FWIW, I'm also fine clarifying 
> the names of things as we refactor code.
I am happy fixing this separately, please leave a `TODO` 



Comment at: clang/lib/AST/Interp/Interp.h:918
 return false;
+  if (!Ptr.isRoot())
+Ptr.initialize();

Can you explain what is going on here? Why do we need to initialize if it is 
not root?


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

https://reviews.llvm.org/D135750

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


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

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

In D127812#4008451 , @paulkirth wrote:

> Hi, we're seeing a build failure in Fuchsia's Clang CI. We're seeing this on 
> all of our builders: arm64 & x64 linux, mac and windows
>
>   FAILED: CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o 
>   /b/s/w/ir/x/w/recipe_cleanup/cxx-rbevgw5lbzc/reclient-cxx-wrapper.sh 
> /b/s/w/ir/x/w/staging/llvm_build/./bin/clang 
> --target=aarch64-unknown-linux-gnu --sysroot=/b/s/w/ir/x/w/cipd/linux 
> -DHAS_ASM_LSE -DVISIBILITY_HIDDEN  --target=aarch64-unknown-linux-gnu -O2 -g 
> -DNDEBUG -DCOMPILER_RT_HAS_FLOAT16 -std=c11 -fPIC -fno-builtin 
> -fvisibility=hidden -fomit-frame-pointer -MD -MT 
> CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o -MF 
> CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o.d -o 
> CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o -c 
> /b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model.c
>   ../../../../llvm-llvm-project/compiler-rt/lib/builtins/cpu_model.c:1233:15: 
> error: use of undeclared identifier 'HWCAP_CPUID'
> if (hwcap & HWCAP_CPUID) {
> ^
>   1 error generated.
>
> Bot: 
> https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64-rbe/b8794244402291698129/overview
>
> Can you revert if the fix is going to be hard. I imagine in this case the 
> preprocessor logic is slightly off, so a forward fix may be easy.

Thanks for report, fixed in a43f36142c501e2d3f4797ef938db4e0c5e0eeec 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D140195: [Clang][CGDebugInfo][ObjC] Mark objc bitfields with the DIFlagBitfield flag

2022-12-20 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl accepted this revision.
aprantl added a comment.
This revision is now accepted and ready to land.

> Unluckly, I wasn't able to test the combination of 
> https://reviews.llvm.org/D96334 and this patch together. If you have some 
> pointers about how to trigger a test job on "Green Dragon", or how to test 
> lldb's objective-c tests on Linux I'd be happy to test.

There's no way to request a test from green dragon. There is also no way to 
test LLDB's Objective-C support on Linux, or at least I'm not aware of anyone 
maintaining a port of LLDB to the GNUstep Objective-C runtime.
So I tried out the patch on a Mac locally and the entire LLDB testsuite still 
passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140195

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


[PATCH] D139973: [llvm] Make llvm::Any similar to std::any

2022-12-20 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

Sorry for the delay here; this patch LGTM!  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139973

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added inline comments.



Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

craig.topper wrote:
> fpetrogalli wrote:
> > lenary wrote:
> > > craig.topper wrote:
> > > > Why do we need to touch CMake file that aren't RISC-V?
> > > Yeah, this shouldn't be needed.
> > > 
> > > We do have some fixes for the modules build which recently landed, maybe 
> > > they fix the issues you were seeing, including:
> > > - https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
> > > - https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
> > > - https://reviews.llvm.org/D140420 (this isn't landed, but it might clear 
> > > up some weird things about the quicker modulemap fixes)
> > This is unrelated to Modules. The .inc file generated by tablegen is 
> > created in `{make_build_folder}/lib/TargetParser`. The file is then 
> > included in `TargetParser.cpp` but also in `TargetParser.h` -> this means 
> > that every time we include the latter in a cpp file we need to make the inc 
> > file visible for inclusion.
> Can we split RISC-V out of TargetParser.cpp and TargetParser.h?
Of course! :) I'll do it in a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

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



Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

fpetrogalli wrote:
> lenary wrote:
> > craig.topper wrote:
> > > Why do we need to touch CMake file that aren't RISC-V?
> > Yeah, this shouldn't be needed.
> > 
> > We do have some fixes for the modules build which recently landed, maybe 
> > they fix the issues you were seeing, including:
> > - https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
> > - https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
> > - https://reviews.llvm.org/D140420 (this isn't landed, but it might clear 
> > up some weird things about the quicker modulemap fixes)
> This is unrelated to Modules. The .inc file generated by tablegen is created 
> in `{make_build_folder}/lib/TargetParser`. The file is then included in 
> `TargetParser.cpp` but also in `TargetParser.h` -> this means that every time 
> we include the latter in a cpp file we need to make the inc file visible for 
> inclusion.
Can we split RISC-V out of TargetParser.cpp and TargetParser.h?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli added a comment.

Hi - gentle ping on reviewing this




Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

lenary wrote:
> craig.topper wrote:
> > Why do we need to touch CMake file that aren't RISC-V?
> Yeah, this shouldn't be needed.
> 
> We do have some fixes for the modules build which recently landed, maybe they 
> fix the issues you were seeing, including:
> - https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
> - https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
> - https://reviews.llvm.org/D140420 (this isn't landed, but it might clear up 
> some weird things about the quicker modulemap fixes)
This is unrelated to Modules. The .inc file generated by tablegen is created in 
`{make_build_folder}/lib/TargetParser`. The file is then included in 
`TargetParser.cpp` but also in `TargetParser.h` -> this means that every time 
we include the latter in a cpp file we need to make the inc file visible for 
inclusion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

One comment on the build changes, I don't have opinions on the RISC-V changes.




Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

craig.topper wrote:
> Why do we need to touch CMake file that aren't RISC-V?
Yeah, this shouldn't be needed.

We do have some fixes for the modules build which recently landed, maybe they 
fix the issues you were seeing, including:
- https://reviews.llvm.org/rG9cd6fbee7ed881f8e80b735e95567040e56f189e
- https://reviews.llvm.org/rG6bdf378dcd349d97152846bb687c1d1de511d138
- https://reviews.llvm.org/D140420 (this isn't landed, but it might clear up 
some weird things about the quicker modulemap fixes)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


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

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

I'm working on a follow-up, which should make the split a bit clearer, but I'm 
also not a modulemap expert and the `-DLLVM_ENABLE_MODULES=On` configuration is 
broken on my linux dev box. I'll post it for review if those two patches have 
at least made the build greener.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[PATCH] D139737: [-Wunsafe-buffer-usage] Initiate Fix-it generation for local variable declarations

2022-12-20 Thread Jan Korous via Phabricator via cfe-commits
jkorous added a comment.

Thanks for the rebase!

Nit: I'd just replace `std::function` with `auto` as it saves us repeating the 
parameter types (and `#include `).




Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:617
+  // Printers that print extent into OS and sets ExtKnown to true:
+  std::function PrintExpr = [, , ](const Expr *Size) {
+Size->printPretty(OS, nullptr, PP);





Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:621
+  };
+  std::function PrintAPInt = [, ](const APInt ) {
+Size.print(OS, false);





Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:625
+  };
+  std::function PrintOne = [, ](void) {
+OS << "1";




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

https://reviews.llvm.org/D139737

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


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

2022-12-20 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

Also needed a follow up fix to completely fix module `9cd6fbee7ed8`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[clang] 9cd6fbe - Fix module build after TargetParser

2022-12-20 Thread Steven Wu via cfe-commits

Author: Steven Wu
Date: 2022-12-20T10:31:19-08:00
New Revision: 9cd6fbee7ed881f8e80b735e95567040e56f189e

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

LOG: Fix module build after TargetParser

Need to include the textual header from the correct module.

Added: 


Modified: 
clang/lib/Basic/Targets/X86.cpp
clang/lib/CodeGen/CGBuiltin.cpp
llvm/lib/Analysis/SyncDependenceAnalysis.cpp

Removed: 




diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index b0802b2e37b4..ebbbef2ed005 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -1123,7 +1123,7 @@ bool X86TargetInfo::hasFeature(StringRef Feature) const {
 bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const {
   return llvm::StringSwitch(FeatureStr)
 #define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY) .Case(STR, true)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default(false);
 }
 
@@ -1132,7 +1132,7 @@ static llvm::X86::ProcessorFeatures getFeature(StringRef 
Name) {
 #define X86_FEATURE_COMPAT(ENUM, STR, PRIORITY)
\
   .Case(STR, llvm::X86::FEATURE_##ENUM)
 
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   ;
   // Note, this function should only be used after ensuring the value is
   // correct, so it asserts if the value is out of range.
@@ -1157,21 +1157,21 @@ bool 
X86TargetInfo::validateCPUSpecificCPUDispatch(StringRef Name) const {
   return llvm::StringSwitch(Name)
 #define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, true)
 #define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, true)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default(false);
 }
 
 static StringRef CPUSpecificCPUDispatchNameDealias(StringRef Name) {
   return llvm::StringSwitch(Name)
 #define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, NAME)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default(Name);
 }
 
 char X86TargetInfo::CPUSpecificManglingCharacter(StringRef Name) const {
   return llvm::StringSwitch(CPUSpecificCPUDispatchNameDealias(Name))
 #define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, MANGLING)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default(0);
 }
 
@@ -1180,7 +1180,7 @@ void X86TargetInfo::getCPUSpecificCPUDispatchFeatures(
   StringRef WholeList =
   llvm::StringSwitch(CPUSpecificCPUDispatchNameDealias(Name))
 #define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, FEATURES)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default("");
   WholeList.split(Features, ',', /*MaxSplit=*/-1, /*KeepEmpty=*/false);
 }
@@ -1189,7 +1189,7 @@ StringRef X86TargetInfo::getCPUSpecificTuneName(StringRef 
Name) const {
   return llvm::StringSwitch(Name)
 #define CPU_SPECIFIC(NAME, TUNE_NAME, MANGLING, FEATURES) .Case(NAME, 
TUNE_NAME)
 #define CPU_SPECIFIC_ALIAS(NEW_NAME, TUNE_NAME, NAME) .Case(NEW_NAME, 
TUNE_NAME)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default("");
 }
 
@@ -1204,7 +1204,7 @@ bool X86TargetInfo::validateCpuIs(StringRef FeatureStr) 
const {
 #define X86_CPU_TYPE(ENUM, STR) .Case(STR, true)
 #define X86_CPU_SUBTYPE_ALIAS(ENUM, ALIAS) .Case(ALIAS, true)
 #define X86_CPU_SUBTYPE(ENUM, STR) .Case(STR, true)
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
   .Default(false);
 }
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 7cf7bd2c21f4..ed782de5400a 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -12956,7 +12956,7 @@ Value *CodeGenFunction::EmitX86CpuIs(StringRef CPUStr) {
   .Case(ALIAS, {2u, static_cast(llvm::X86::ENUM)})
 #define X86_CPU_SUBTYPE(ENUM, STR) 
\
   .Case(STR, {2u, static_cast(llvm::X86::ENUM)})
-#include "llvm/Support/X86TargetParser.def"
+#include "llvm/TargetParser/X86TargetParser.def"
.Default({0, 0});
   assert(Value != 0 && "Invalid CPUStr passed to CpuIs");
 

diff  --git a/llvm/lib/Analysis/SyncDependenceAnalysis.cpp 
b/llvm/lib/Analysis/SyncDependenceAnalysis.cpp
index 3446e50a4344..17d7676024a5 100644
--- a/llvm/lib/Analysis/SyncDependenceAnalysis.cpp
+++ b/llvm/lib/Analysis/SyncDependenceAnalysis.cpp
@@ -257,6 +257,7 @@ SyncDependenceAnalysis::SyncDependenceAnalysis(const 
DominatorTree ,
 
 

[PATCH] D138868: AMDGPU/clang: Remove target features from address space test builtins

2022-12-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D138868

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


[PATCH] D131830: [OpenMP] Clang Support for taskwait nowait clause

2022-12-20 Thread Chi Chun Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe9babe757160: [OpenMP] Clang Support for taskwait nowait 
clause (authored by koops, committed by cchen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131830

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  clang/test/OpenMP/taskwait_ast_print.cpp
  clang/test/OpenMP/taskwait_depend_codegen.cpp
  clang/test/OpenMP/taskwait_depend_nowait_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_taskdeps.cpp

Index: openmp/runtime/src/kmp_taskdeps.cpp
===
--- openmp/runtime/src/kmp_taskdeps.cpp
+++ openmp/runtime/src/kmp_taskdeps.cpp
@@ -744,10 +744,24 @@
 void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps,
   kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias,
   kmp_depend_info_t *noalias_dep_list) {
-  KA_TRACE(10, ("__kmpc_omp_wait_deps(enter): T#%d loc=%p\n", gtid, loc_ref));
+  __kmpc_omp_taskwait_deps_51(loc_ref, gtid, ndeps, dep_list, ndeps_noalias,
+  noalias_dep_list, false);
+}
 
+/* __kmpc_omp_taskwait_deps_51 : Function for OpenMP 5.1 nowait clause.
+ Placeholder for taskwait with nowait clause.
+ Earlier code of __kmpc_omp_wait_deps() is now
+ in this function.
+*/
+void __kmpc_omp_taskwait_deps_51(ident_t *loc_ref, kmp_int32 gtid,
+ kmp_int32 ndeps, kmp_depend_info_t *dep_list,
+ kmp_int32 ndeps_noalias,
+ kmp_depend_info_t *noalias_dep_list,
+ kmp_int32 has_no_wait) {
+  KA_TRACE(10, ("__kmpc_omp_taskwait_deps(enter): T#%d loc=%p nowait#%d\n",
+gtid, loc_ref, has_no_wait));
   if (ndeps == 0 && ndeps_noalias == 0) {
-KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no dependences to "
+KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d has no dependences to "
   "wait upon : loc=%p\n",
   gtid, loc_ref));
 return;
@@ -839,7 +853,7 @@
   ignore = ignore || current_task->td_dephash == NULL;
 
   if (ignore) {
-KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking "
+KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d has no blocking "
   "dependences : loc=%p\n",
   gtid, loc_ref));
 #if OMPT_SUPPORT
@@ -854,7 +868,7 @@
   if (!__kmp_check_deps(gtid, , NULL, _task->td_dephash,
 DEP_BARRIER, ndeps, dep_list, ndeps_noalias,
 noalias_dep_list)) {
-KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking "
+KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d has no blocking "
   "dependences : loc=%p\n",
   gtid, loc_ref));
 #if OMPT_SUPPORT
@@ -875,6 +889,7 @@
 #if OMPT_SUPPORT
   __ompt_taskwait_dep_finish(current_task, taskwait_task_data);
 #endif /* OMPT_SUPPORT */
-  KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d finished waiting : loc=%p\n",
+  KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d finished waiting : loc=%p\
+\n",
 gtid, loc_ref));
 }
Index: openmp/runtime/src/kmp.h
===
--- openmp/runtime/src/kmp.h
+++ openmp/runtime/src/kmp.h
@@ -3982,7 +3982,6 @@
 KMP_EXPORT kmp_int32 __kmpc_omp_task_parts(ident_t *loc_ref, kmp_int32 gtid,
kmp_task_t *new_task);
 KMP_EXPORT kmp_int32 

[clang] e9babe7 - [OpenMP] Clang Support for taskwait nowait clause

2022-12-20 Thread Chi Chun Chen via cfe-commits

Author: Sunil Kuravinakop
Date: 2022-12-20T12:13:56-06:00
New Revision: e9babe7571609c9de41d4d0dfc1bc4d2f02021d0

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

LOG: [OpenMP] Clang Support for taskwait nowait clause

Support for taskwait nowait clause with placeholder for runtime changes.

Reviewed By: cchen, ABataev

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

Added: 
clang/test/OpenMP/taskwait_depend_nowait_codegen.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGOpenMPRuntime.h
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/target_depend_codegen.cpp
clang/test/OpenMP/target_enter_data_depend_codegen.cpp
clang/test/OpenMP/target_exit_data_depend_codegen.cpp
clang/test/OpenMP/target_parallel_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp

clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
clang/test/OpenMP/target_update_depend_codegen.cpp
clang/test/OpenMP/task_if_codegen.cpp
clang/test/OpenMP/taskwait_ast_print.cpp
clang/test/OpenMP/taskwait_depend_codegen.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
openmp/runtime/src/dllexports
openmp/runtime/src/kmp.h
openmp/runtime/src/kmp_taskdeps.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index ff68514621327..60ff607a3edc6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -10733,6 +10733,8 @@ def note_omp_nested_statement_here : Note<
   "%select{statement|directive}0 outside teams construct here">;
 def err_omp_single_copyprivate_with_nowait : Error<
   "the 'copyprivate' clause must not be used with the 'nowait' clause">;
+def err_omp_nowait_clause_without_depend: Error<
+  "directive '#pragma omp taskwait' cannot use 'nowait' clause without 
'depend' clause">;
 def note_omp_nowait_clause_here : Note<
   "'nowait' clause is here">;
 def err_omp_single_decl_in_declare_simd_variant : Error<

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 3b62beddcaa58..573367c646fc5 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -4757,7 +4757,7 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction , 
SourceLocation Loc,
   Region->emitUntiedSwitch(CGF);
   };
 
-  llvm::Value *DepWaitTaskArgs[6];
+  llvm::Value *DepWaitTaskArgs[7];
   if (!Data.Dependences.empty()) {
 DepWaitTaskArgs[0] = UpLoc;
 DepWaitTaskArgs[1] = ThreadID;
@@ -4765,6 +4765,8 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction , 
SourceLocation Loc,
 DepWaitTaskArgs[3] = DependenciesArray.getPointer();
 DepWaitTaskArgs[4] = CGF.Builder.getInt32(0);
 DepWaitTaskArgs[5] = llvm::ConstantPointerNull::get(CGF.VoidPtrTy);
+DepWaitTaskArgs[6] =
+llvm::ConstantInt::get(CGF.Int32Ty, Data.HasNowaitClause);
   }
   auto  = CGM.getModule();
   auto & = [this, , , ThreadID, NewTaskNewTaskTTy,
@@ -4776,9 +4778,9 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction , 
SourceLocation Loc,
 // ndeps_noalias, kmp_depend_info_t *noalias_dep_list); if dependence info
 // is specified.
 if (!Data.Dependences.empty())
-  CGF.EmitRuntimeCall(
-  OMPBuilder.getOrCreateRuntimeFunction(M, 
OMPRTL___kmpc_omp_wait_deps),
-  DepWaitTaskArgs);
+  CGF.EmitRuntimeCall(OMPBuilder.getOrCreateRuntimeFunction(
+  M, OMPRTL___kmpc_omp_taskwait_deps_51),
+  DepWaitTaskArgs);
 // Call proxy_task_entry(gtid, new_task);
 auto & = [TaskEntry, ThreadID, NewTaskNewTaskTTy,
   Loc](CodeGenFunction , PrePostActionTy ) {
@@ -5826,24 +5828,26 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
, SourceLocation Loc,
 llvm::Value *NumOfElements;
 std::tie(NumOfElements, DependenciesArray) =
 emitDependClause(CGF, Data.Dependences, Loc);
-llvm::Value *DepWaitTaskArgs[6];
 if (!Data.Dependences.empty()) {
+  llvm::Value *DepWaitTaskArgs[7];
   DepWaitTaskArgs[0] 

[clang] 2cf550a - Add missing textual header to module map

2022-12-20 Thread Adrian Prantl via cfe-commits

Author: Adrian Prantl
Date: 2022-12-20T10:05:55-08:00
New Revision: 2cf550a80a0177f8a1aa9ae45c40b0d17ef7f11d

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

LOG: Add missing textual header to module map

Added: 


Modified: 
clang/include/clang/module.modulemap

Removed: 




diff  --git a/clang/include/clang/module.modulemap 
b/clang/include/clang/module.modulemap
index 227beafabcb0..c182da1d830a 100644
--- a/clang/include/clang/module.modulemap
+++ b/clang/include/clang/module.modulemap
@@ -94,7 +94,10 @@ module Clang_Diagnostics {
   requires cplusplus
 
   module All { header "Basic/AllDiagnostics.h" export * }
-  module Analysis { header "Analysis/AnalysisDiagnostic.h" export * }
+  module Analysis {
+header "Analysis/AnalysisDiagnostic.h" export *
+textual header "Analysis/Analyses/UnsafeBufferUsageGadgets.def"
+  }
   module AST { header "AST/ASTDiagnostic.h" export * }
   module Comment { header "AST/CommentDiagnostic.h" export * }
   module Driver { header "Driver/DriverDiagnostic.h" export * }



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


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

2022-12-20 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Sorry, I pasted in the wrong hash: 6bdf378dcd349d97152846bb687c1d1de511d138 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


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

2022-12-20 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

I think I fixed it in a685bb8e333e 
, but 
please take another look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


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

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D137838#4008443 , @aprantl wrote:

> Can you please update `llvm/include/llvm/module.modulemap` for this change or 
> revert the patch? This is breaking all bots that build with 
> `-DLLVM_ENABLE_MODULES=On`.
>
> For example: 
> https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/lastFailedBuild/consoleFull#111065754949ba4694-19c4-4d7e-bec5-911270d8a58c

Looking at this now. Thanks for pointing it out as I didn't get a notification 
for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


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

2022-12-20 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Hi, we're seeing a build failure in Fuchsia's Clang CI. We're seeing this on 
all of our builders: arm64 & x64 linux, mac and windows

  FAILED: CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o 
  /b/s/w/ir/x/w/recipe_cleanup/cxx-rbevgw5lbzc/reclient-cxx-wrapper.sh 
/b/s/w/ir/x/w/staging/llvm_build/./bin/clang --target=aarch64-unknown-linux-gnu 
--sysroot=/b/s/w/ir/x/w/cipd/linux -DHAS_ASM_LSE -DVISIBILITY_HIDDEN  
--target=aarch64-unknown-linux-gnu -O2 -g -DNDEBUG -DCOMPILER_RT_HAS_FLOAT16 
-std=c11 -fPIC -fno-builtin -fvisibility=hidden -fomit-frame-pointer -MD -MT 
CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o -MF 
CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o.d -o 
CMakeFiles/clang_rt.builtins-aarch64.dir/cpu_model.c.o -c 
/b/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/builtins/cpu_model.c
  ../../../../llvm-llvm-project/compiler-rt/lib/builtins/cpu_model.c:1233:15: 
error: use of undeclared identifier 'HWCAP_CPUID'
if (hwcap & HWCAP_CPUID) {
^
  1 error generated.

Bot: 
https://ci.chromium.org/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64-rbe/b8794244402291698129/overview

Can you revert if the fix is going to be hard. I imagine in this case the 
preprocessor logic is slightly off, so a forward fix may be easy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


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

2022-12-20 Thread Adrian Prantl via Phabricator via cfe-commits
aprantl added a comment.

Can you please update `llvm/include/llvm/module.modulemap` for this change or 
revert the patch? This is breaking all bots that build with 
`-DLLVM_ENABLE_MODULES=On`.

For example: 
https://green.lab.llvm.org/green/view/LLDB/job/lldb-cmake/lastFailedBuild/consoleFull#111065754949ba4694-19c4-4d7e-bec5-911270d8a58c

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[PATCH] D131830: [OpenMP] Clang Support for taskwait nowait clause

2022-12-20 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.

LG


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

https://reviews.llvm.org/D131830

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


[PATCH] D137517: [TargetParser] Generate the defs for RISCV CPUs using llvm-tblgen.

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



Comment at: llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt:19
 
+target_include_directories(LLVMAArch64AsmParser PRIVATE 
${LLVM_LIBRARY_DIR}/TargetParser/)

Why do we need to touch CMake file that aren't RISC-V?



Comment at: llvm/lib/Target/RISCV/RISCV.td:580
+def SIFIVE_7 : RISCVProcessorModelTUNE_PROC<"sifive-7-series", SiFive7Model, 
[],
  [TuneSiFive7]>;
 

Line this up to the column after the `<` on the previous line.



Comment at: llvm/lib/Target/RISCV/RISCV.td:587
+def SIFIVE_E21 : RISCVProcessorModelPROC<"sifive-e21", RocketModel, 
[Feature32Bit,
  FeatureStdExtM,
  FeatureStdExtA,

Line this up under `Feature32Bit` on the previous line.



Comment at: llvm/utils/TableGen/CMakeLists.txt:63
   CTagsEmitter.cpp
+  RISCVTargetDefEmitter.cpp
   )

I think this list might be in alphabetical order except for the placement of 
CTagsEmitter. Can you move RISCVTargetDefEmitter.cpp into the right place?



Comment at: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp:10
+// This tablegen backend emits the include file needed by the target
+// parser to parse the RISCV CPUs.
+//

RISCV->RISC-V


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

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


[PATCH] D135360: [clang][analyzer] Add some more functions to StreamChecker and StdLibraryFunctionsChecker.

2022-12-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:1818-1857
+// int fgetpos(FILE *restrict stream, fpos_t *restrict pos);
+// From 'The Open Group Base Specifications Issue 7, 2018 edition':
+// "The fgetpos() function shall not change the setting of errno if
+// successful."
+addToFunctionSummaryMap(
+"fgetpos",
+Signature(ArgTypes{FilePtrRestrictTy, FPosTPtrRestrictTy},

Szelethus wrote:
> martong wrote:
> > It is very good to see these new summaries! Would they be meaningful and 
> > usable without the changes in the StreamChecker? If yes, then I think we 
> > should split this into 2 patches.
> Can you please do this?
This is done now. There were 2 consecutive patches that modify 
`StdLibraryFunctionsChecker` and other checkers. These are rearranged into 2 
new patches. One for all changes in `StdLibraryFunctionsChecker` (and related 
changes in ErrnoModeling): D140387. Other for all other changes, 
`StreamChecker` and many of the tests that exercise both checkers: D140395.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135360

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


[clang] 49dd02b - Revert "[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin"

2022-12-20 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-12-20T17:45:07+01:00
New Revision: 49dd02bd081901db6011bdbe676573bfd5482627

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

LOG: Revert "[clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin"

This broke the instrprof-darwin-exports.c test on mac, see e.g.
https://green.lab.llvm.org/green/job/clang-stage1-RA/32351/

> Previously, we would be passing down -stdlib=libc++ from the Driver
> to CC1 whenever the default standard library on the platform was libc++,
> even if -stdlib= had not been passed to the Driver. This meant that we
> would pass -stdlib=libc++ in nonsensical circumstances, such as when
> compiling C code.
>
> This logic had been added in b534ce46bd40 to make sure that header
> search paths were set up properly. However, since libc++ is now the
> default Standard Library on Darwin, passing this explicitly is not
> required anymore. Indeed, if no -stdlib= is specified, CC1 will end
> up using libc++ if it queries which standard library to use, without
> having to be told.
>
> Not passing -stdlib= at all to CC1 on Darwin should become possible
> once CC1 stops relying on it to set up framework search paths.
>
> Furthermore, this commit also removes a diagnostic checking whether the
> deployment target is too old to support libc++. Nowadays, all supported
> deployment targets use libc++ and compiling with libstdc++ is not
> supported anymore. The Driver was the wrong place to issue this
> diagnostic since it doesn't know whether libc++ will actually be linked
> against (e.g. C vs C++), which would lead to spurious diagnostics.
> Given that these targets are not supported anymore, we simply drop
> the diagnostic instead of trying to refactor it into CC1.
>
> rdar://103198514
>
> Differential Revision: https://reviews.llvm.org/D139938

This reverts commit 6540f32db09cf6b367812642fbd91d44cbb6638d.

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-header-search-libcxx.cpp
clang/test/Driver/darwin-stdlib.cpp

Removed: 
clang/test/Driver/darwin-stdlib-dont-pass-in-c.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 4e86a5ec46b9..e8927161dcbe 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -203,6 +203,8 @@ def warn_drv_missing_plugin_name : Warning<
 def warn_drv_missing_plugin_arg : Warning<
   "missing plugin argument for plugin %0 in %1">,
   InGroup;
+def err_drv_invalid_libcxx_deployment : Error<
+  "invalid deployment target for -stdlib=libc++ (requires %0 or later)">;
 def err_drv_invalid_argument_to_option : Error<
   "invalid argument '%0' to -%1">;
 def err_drv_missing_sanitizer_ignorelist : Error<

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index ffa45d49b489..eba602529a08 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -2869,6 +2869,7 @@ Darwin::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
   // First get the generic Apple args, before moving onto Darwin-specific ones.
   DerivedArgList *DAL =
   MachO::TranslateArgs(Args, BoundArch, DeviceOffloadKind);
+  const OptTable  = getDriver().getOpts();
 
   // If no architecture is bound, none of the translations here are relevant.
   if (BoundArch.empty())
@@ -2900,6 +2901,26 @@ Darwin::TranslateArgs(const DerivedArgList , 
StringRef BoundArch,
 }
   }
 
+  if (!Args.getLastArg(options::OPT_stdlib_EQ) &&
+  GetCXXStdlibType(Args) == ToolChain::CST_Libcxx)
+DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_stdlib_EQ),
+  "libc++");
+
+  // Validate the C++ standard library choice.
+  CXXStdlibType Type = GetCXXStdlibType(*DAL);
+  if (Type == ToolChain::CST_Libcxx) {
+// Check whether the target provides libc++.
+StringRef where;
+
+// Complain about targeting iOS < 5.0 in any way.
+if (isTargetIOSBased() && isIPhoneOSVersionLT(5, 0))
+  where = "iOS 5.0";
+
+if (where != StringRef()) {
+  getDriver().Diag(clang::diag::err_drv_invalid_libcxx_deployment) << 
where;
+}
+  }
+
   auto Arch = tools::darwin::getArchTypeForMachOArchName(BoundArch);
   if ((Arch == llvm::Triple::arm || Arch == llvm::Triple::thumb)) {
 if (Args.hasFlag(options::OPT_fomit_frame_pointer,

diff  --git a/clang/test/Driver/darwin-header-search-libcxx.cpp 
b/clang/test/Driver/darwin-header-search-libcxx.cpp
index cc8ec9ceb89b..32474495bbb5 100644
--- a/clang/test/Driver/darwin-header-search-libcxx.cpp
+++ b/clang/test/Driver/darwin-header-search-libcxx.cpp
@@ 

[PATCH] D139938: [clang] Don't spuriously pass -stdlib=libc++ to CC1 on Darwin

2022-12-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This seems to have broken the instrprof-darwin-exports.c test, see e.g. 
https://green.lab.llvm.org/green/job/clang-stage1-RA/32351/

I'll revert for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139938

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


[PATCH] D131830: [OpenMP] Clang Support for taskwait nowait clause

2022-12-20 Thread Sunil K via Phabricator via cfe-commits
koops updated this revision to Diff 484290.
koops added a comment.

Taking care of :

1. "The nowait clause may only appear on a taskwait directive if the depend 
clause is present.".
2. "Please do not add any new tests using -no-opaque-pointers".
3. Added a new test to expect failure for point 1.


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

https://reviews.llvm.org/D131830

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_enter_data_depend_codegen.cpp
  clang/test/OpenMP/target_exit_data_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_simd_depend_codegen.cpp
  clang/test/OpenMP/target_update_depend_codegen.cpp
  clang/test/OpenMP/task_if_codegen.cpp
  clang/test/OpenMP/taskwait_ast_print.cpp
  clang/test/OpenMP/taskwait_depend_codegen.cpp
  clang/test/OpenMP/taskwait_depend_nowait_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  openmp/runtime/src/dllexports
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_taskdeps.cpp

Index: openmp/runtime/src/kmp_taskdeps.cpp
===
--- openmp/runtime/src/kmp_taskdeps.cpp
+++ openmp/runtime/src/kmp_taskdeps.cpp
@@ -744,10 +744,24 @@
 void __kmpc_omp_wait_deps(ident_t *loc_ref, kmp_int32 gtid, kmp_int32 ndeps,
   kmp_depend_info_t *dep_list, kmp_int32 ndeps_noalias,
   kmp_depend_info_t *noalias_dep_list) {
-  KA_TRACE(10, ("__kmpc_omp_wait_deps(enter): T#%d loc=%p\n", gtid, loc_ref));
+  __kmpc_omp_taskwait_deps_51(loc_ref, gtid, ndeps, dep_list, ndeps_noalias,
+  noalias_dep_list, false);
+}
 
+/* __kmpc_omp_taskwait_deps_51 : Function for OpenMP 5.1 nowait clause.
+ Placeholder for taskwait with nowait clause.
+ Earlier code of __kmpc_omp_wait_deps() is now
+ in this function.
+*/
+void __kmpc_omp_taskwait_deps_51(ident_t *loc_ref, kmp_int32 gtid,
+ kmp_int32 ndeps, kmp_depend_info_t *dep_list,
+ kmp_int32 ndeps_noalias,
+ kmp_depend_info_t *noalias_dep_list,
+ kmp_int32 has_no_wait) {
+  KA_TRACE(10, ("__kmpc_omp_taskwait_deps(enter): T#%d loc=%p nowait#%d\n",
+gtid, loc_ref, has_no_wait));
   if (ndeps == 0 && ndeps_noalias == 0) {
-KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no dependences to "
+KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d has no dependences to "
   "wait upon : loc=%p\n",
   gtid, loc_ref));
 return;
@@ -839,7 +853,7 @@
   ignore = ignore || current_task->td_dephash == NULL;
 
   if (ignore) {
-KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking "
+KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d has no blocking "
   "dependences : loc=%p\n",
   gtid, loc_ref));
 #if OMPT_SUPPORT
@@ -854,7 +868,7 @@
   if (!__kmp_check_deps(gtid, , NULL, _task->td_dephash,
 DEP_BARRIER, ndeps, dep_list, ndeps_noalias,
 noalias_dep_list)) {
-KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d has no blocking "
+KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d has no blocking "
   "dependences : loc=%p\n",
   gtid, loc_ref));
 #if OMPT_SUPPORT
@@ -875,6 +889,7 @@
 #if OMPT_SUPPORT
   __ompt_taskwait_dep_finish(current_task, taskwait_task_data);
 #endif /* OMPT_SUPPORT */
-  KA_TRACE(10, ("__kmpc_omp_wait_deps(exit): T#%d finished waiting : loc=%p\n",
+  KA_TRACE(10, ("__kmpc_omp_taskwait_deps(exit): T#%d finished waiting : loc=%p\
+\n",
 gtid, loc_ref));
 }
Index: openmp/runtime/src/kmp.h
===
--- openmp/runtime/src/kmp.h
+++ openmp/runtime/src/kmp.h
@@ -3982,7 +3982,6 @@
 KMP_EXPORT kmp_int32 __kmpc_omp_task_parts(ident_t *loc_ref, kmp_int32 gtid,
kmp_task_t *new_task);
 KMP_EXPORT kmp_int32 

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

2022-12-20 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

In D139986#4005997 , @dblaikie wrote:

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

In the failing tests we want to make sure we marked a struct as 
`[[deprecated]]`. In other tests we validate error messages to make sure things 
are ill-formed as mandated. We test the diagnostic to make sure the compilation 
fails for the expected reason and not a different compilation error. Do you 
have a suggestion how we can do that without checking Clang diagnostics?

In general I consider it bad practice to commit code when the CI is red.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139986

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


[PATCH] D137516: [TargetSupport] Move TargetParser API in a separate LLVM component.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli abandoned this revision.
fpetrogalli added a comment.

Replaced by D137838 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137516

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


[PATCH] D137517: [TargetSupport] Generate the defs for RISCV CPUs using llvm-tblgen.

2022-12-20 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 484283.
fpetrogalli added a comment.
Herald added a subscriber: pengfei.

This update is not based anymore on D137516 , 
but uses the refactoring of `TargetParser` as part of `LLVMSupport` 
into the new component `LLVMTargetPArser` introduced in D137838 
. NFCI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

Files:
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Driver/CMakeLists.txt
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/include/llvm/module.modulemap
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
  llvm/lib/Target/AMDGPU/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
  llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/X86/MCA/CMakeLists.txt
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/unittests/Support/CMakeLists.txt
  llvm/unittests/Target/AMDGPU/CMakeLists.txt
  llvm/unittests/TargetParser/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  llvm/utils/TableGen/TableGen.cpp
  llvm/utils/TableGen/TableGenBackends.h

Index: llvm/utils/TableGen/TableGenBackends.h
===
--- llvm/utils/TableGen/TableGenBackends.h
+++ llvm/utils/TableGen/TableGenBackends.h
@@ -94,7 +94,7 @@
 void EmitDirectivesDecl(RecordKeeper , raw_ostream );
 void EmitDirectivesImpl(RecordKeeper , raw_ostream );
 void EmitDXILOperation(RecordKeeper , raw_ostream );
-
+void EmitRISCVTargetDef(RecordKeeper , raw_ostream );
 } // End llvm namespace
 
 #endif
Index: llvm/utils/TableGen/TableGen.cpp
===
--- llvm/utils/TableGen/TableGen.cpp
+++ llvm/utils/TableGen/TableGen.cpp
@@ -58,6 +58,7 @@
   GenDirectivesEnumDecl,
   GenDirectivesEnumImpl,
   GenDXILOperation,
+  GenRISCVTargetDef,
 };
 
 namespace llvm {
@@ -141,8 +142,9 @@
 clEnumValN(GenDirectivesEnumImpl, "gen-directive-impl",
"Generate directive related implementation code"),
 clEnumValN(GenDXILOperation, "gen-dxil-operation",
-   "Generate DXIL operation information")));
-
+   "Generate DXIL operation information"),
+clEnumValN(GenRISCVTargetDef, "gen-riscv-target-def",
+   "Generate the list of CPU for RISCV")));
 cl::OptionCategory PrintEnumsCat("Options for -print-enums");
 cl::opt Class("class", cl::desc("Print Enum list for this class"),
cl::value_desc("class name"),
@@ -278,6 +280,9 @@
   case GenDXILOperation:
 EmitDXILOperation(Records, OS);
 break;
+  case GenRISCVTargetDef:
+EmitRISCVTargetDef(Records, OS);
+break;
   }
 
   return false;
Index: llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
===
--- /dev/null
+++ llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
@@ -0,0 +1,49 @@
+//===- RISCVTargetDefEmitter.cpp - Generate lists of RISCV CPUs ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This tablegen backend emits the include file needed by the target
+// parser to parse the RISCV CPUs.
+//
+//===--===//
+
+#include "llvm/TableGen/Record.h"
+
+namespace llvm {
+void EmitRISCVTargetDef(RecordKeeper , raw_ostream ) {
+  const auto  = RK.getDefs();
+
+  OS << "#ifndef PROC\n"
+ << "#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)\n"
+ << "#endif\n\n";
+
+  OS << "PROC(INVALID, {\"invalid\"}, FK_INVALID, {\"\"})\n";
+  // Iterate on all definition records.
+  for (auto  : Map) {
+const auto  = Def.second;
+if (Record->isSubClassOf("RISCVProcessorModelPROC"))
+  OS << "PROC(" << Record->getName() << ", "
+ << "{\"" << Record->getValueAsString("Name") << "\"},"
+ << Record->getValueAsString("EnumFeatures") << ", "
+ << "{\"" << Record->getValueAsString("DefaultMarch") << "\"})\n";
+  }
+  OS << "\n#undef PROC\n";
+  OS << "\n";
+  OS << "#ifndef TUNE_PROC\n"
+ << "#define TUNE_PROC(ENUM, NAME)\n"
+ << "#endif\n\n";
+  OS << "TUNE_PROC(GENERIC, 

[PATCH] D140222: [AArch64] Check 128-bit Sysreg Builtins

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary marked 3 inline comments as done.
lenary added a comment.

Nits addressed. Will land in the new year, when I'm back at work. Right now 
it's time for a break!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140222

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


[PATCH] D140222: [AArch64] Check 128-bit Sysreg Builtins

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary edited the summary of this revision.
lenary updated this revision to Diff 484281.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140222

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Headers/arm_acle.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/aarch64-sysregs-target.c
  clang/test/Sema/aarch64-special-register.c

Index: clang/test/Sema/aarch64-special-register.c
===
--- clang/test/Sema/aarch64-special-register.c
+++ clang/test/Sema/aarch64-special-register.c
@@ -16,6 +16,10 @@
   __builtin_arm_wsr64("sysreg", v);
 }
 
+void wsr128_1(__uint128_t v) {
+  __builtin_arm_wsr128("sysreg", v);
+}
+
 unsigned rsr_1(void) {
   return __builtin_arm_rsr("sysreg");
 }
@@ -28,6 +32,10 @@
   return __builtin_arm_rsr64("sysreg");
 }
 
+__uint128_t rsr128_1(void) {
+  return __builtin_arm_rsr128("sysreg");
+}
+
 void wsr_2(unsigned v) {
   __builtin_arm_wsr("0:1:2:3:4", v);
 }
@@ -52,6 +60,10 @@
   return __builtin_arm_rsr64("0:1:15:15:4");
 }
 
+__uint128_t rsr128_2(void) {
+  return __builtin_arm_rsr128("0:1:15:15:4");
+}
+
 void wsr_3(unsigned v) {
   __builtin_arm_wsr("0:1:2", v); //expected-error {{invalid special register for builtin}}
 }
@@ -64,6 +76,10 @@
   __builtin_arm_wsr64("0:1:2", v); //expected-error {{invalid special register for builtin}}
 }
 
+void wsr128_3(__uint128_t v) {
+  __builtin_arm_wsr128("0:1:2", v); //expected-error {{invalid special register for builtin}}
+}
+
 unsigned rsr_3(void) {
   return __builtin_arm_rsr("0:1:2"); //expected-error {{invalid special register for builtin}}
 }
@@ -99,3 +115,101 @@
 unsigned long rsr64_6(void) {
   return __builtin_arm_rsr64("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
 }
+
+__uint128_t rsr128_3(void) {
+  return __builtin_arm_rsr128("0:1:2"); //expected-error {{invalid special register for builtin}}
+}
+
+__uint128_t rsr128_4(void) {
+  return __builtin_arm_rsr128("0:1:2:3:8"); //expected-error {{invalid special register for builtin}}
+}
+
+__uint128_t rsr128_5(void) {
+  return __builtin_arm_rsr128("0:8:2:3:4"); //expected-error {{invalid special register for builtin}}
+}
+
+__uint128_t rsr128_6(void) {
+  return __builtin_arm_rsr128("0:1:16:16:2"); //expected-error {{invalid special register for builtin}}
+}
+
+void wsr_4(void) {
+  __builtin_arm_wsr("spsel", 15);
+  __builtin_arm_wsr("daifclr", 15);
+  __builtin_arm_wsr("daifset", 15);
+  __builtin_arm_wsr("pan", 15);
+  __builtin_arm_wsr("uao", 15);
+  __builtin_arm_wsr("dit", 15);
+  __builtin_arm_wsr("ssbs", 15);
+  __builtin_arm_wsr("tco", 15);
+
+  __builtin_arm_wsr("allint", 1);
+  __builtin_arm_wsr("pm", 1);
+}
+
+void wsr64_4(void) {
+  __builtin_arm_wsr("spsel", 15);
+  __builtin_arm_wsr("daifclr", 15);
+  __builtin_arm_wsr("daifset", 15);
+  __builtin_arm_wsr("pan", 15);
+  __builtin_arm_wsr("uao", 15);
+  __builtin_arm_wsr("dit", 15);
+  __builtin_arm_wsr("ssbs", 15);
+  __builtin_arm_wsr("tco", 15);
+
+  __builtin_arm_wsr("allint", 1);
+  __builtin_arm_wsr("pm", 1);
+}
+
+void wsr_5(unsigned v) {
+  __builtin_arm_wsr("spsel", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("daifclr", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("daifset", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("pan", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("uao", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("dit", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("ssbs", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("tco", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("allint", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr("pm", v); // expected-error {{must be a constant integer}}
+}
+
+void wsr64_5(unsigned long v) {
+  __builtin_arm_wsr64("spsel", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("daifclr", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("daifset", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("pan", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("uao", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("dit", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("ssbs", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("tco", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("allint", v); // expected-error {{must be a constant integer}}
+  __builtin_arm_wsr64("pm", v); // expected-error {{must be a constant integer}}
+}
+
+void wsr_6(void) {
+  __builtin_arm_wsr("spsel", 16); // expected-error {{outside the valid range}}
+  

[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/test/CodeGenCXX/PR19955.cpp:20
+// CHECK-64: store ptr @"?var@@3HA", ptr @"?varp@@3PEAHEA"
+// CHECK:   ret void
 

@rnk was concerned about varp pointing to dllimport var. That does it I think.


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

https://reviews.llvm.org/D137107

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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 484278.

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

https://reviews.llvm.org/D137107

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCXX/PR19955.cpp
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/call-conv-thru-alias.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/ctor-dtor-alias.cpp
  clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
  clang/test/SemaCXX/PR19955.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/dllimport-constexpr.cpp

Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- clang/test/SemaCXX/dllimport-constexpr.cpp
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -40,7 +40,6 @@
 // constexpr initialization doesn't work for dllimport things.
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (*constexpr_import_func)() = _func;
-// expected-error@+1{{must be initialized by a constant expression}}
 constexpr int *constexpr_import_int = _int;
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (Foo::*constexpr_memptr)() = ::imported_method;
@@ -60,3 +59,11 @@
   // expected-note@+1 {{requested here}}
   StaticConstexpr::g_fp();
 }
+
+extern int __declspec(dllimport) val;
+constexpr int& val_ref = val;
+
+void assigndllimporttoconst () {
+  extern int _declspec(dllimport) val;
+  constexpr int& val_ref = val;
+}
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1595,7 +1595,7 @@
   void f(int k) { // expected-note {{here}}
 int arr[k]; // expected-warning {{C99}} expected-note {{function parameter 'k'}}
 constexpr int n = 1 +
-sizeof(arr) // expected-error {{constant expression}}
+sizeof(arr) // expected-error{{constexpr variable 'n' must be initialized by a constant expression}}
 * 3;
   }
 }
Index: clang/test/SemaCXX/PR19955.cpp
===
--- clang/test/SemaCXX/PR19955.cpp
+++ clang/test/SemaCXX/PR19955.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i686-mingw32 -verify -std=c++11 %s
 
 extern int __attribute__((dllimport)) var;
-constexpr int *varp =  // expected-error {{must be initialized by a constant expression}}
+constexpr int *varp = 
 
 extern __attribute__((dllimport)) void fun();
 constexpr void (*funp)(void) =  // expected-error {{must be initialized by a constant expression}}
Index: clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
===
--- clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
+++ clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
@@ -7,6 +7,6 @@
 
 A g;
 
-// CHECK: define internal void @__cxx_global_var_init() [[ATTR0:#[0-9]+]]
-// CHECK: define internal void @_GLOBAL__sub_I_funcattrs_global_ctor_dtor.cpp() [[ATTR0]]
+// CHECK: define internal void @ctor() [[ATTR0:#[0-9]+]]
+// CHECK: define internal void @dtor() [[ATTR0]]
 // CHECK: attributes [[ATTR0]] = {{{.*}} sspstrong {{.*}}}
Index: clang/test/CodeGenCXX/dllimport.cpp
===
--- clang/test/CodeGenCXX/dllimport.cpp
+++ clang/test/CodeGenCXX/dllimport.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 %s
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 --check-prefix=GL32 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 --check-prefix=GL64 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu-fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU 

[PATCH] D140387: [clang][analyzer] Add stream related functions to StdLibraryFunctionsChecker.

2022-12-20 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D140387#4007751 , @balazske wrote:

> This patch and D140395  is (almost) the 
> same code as D135360  and D135247 
> . The changes are separated for the 
> different checkers. Tests are added at the second patch.

Well, that is confusing. Which patches should I review? Can you please only 
have a single opened differential per change, and a single patch stack? If you 
decided that this patch is **the ONE** for the `ErrnoModeling` changes, please 
abandon the other patch with the very same change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140387

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


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

2022-12-20 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

In D137838#4007920 , @thakis wrote:

> Thanks for the heads-up. I updated the GN build in 
> 4ac51dd53d93b8dd18c58093766483c657fe3a08 
>  and 
> 2aa998d22fe09191cd6c1b697e373266c1131502 
> . The 
> latter commit has a python script in the commit message that might be useful 
> to others who want to port this to other build systems.

Thanks! Much appreciated!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[PATCH] D137337: Replace LLVM_LIBDIR_SUFFIX by CMAKE_INSTALL_LIBDIR

2022-12-20 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: bolt/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc.in:17
 
-#define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define CMAKE_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"

barannikov88 wrote:
> The prefix must remain LLVM_*
> In other components accordingly
> The prefix must remain LLVM_*
> In other components accordingly

To clarify, I mean the C++ macro name and not CMake variable name


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

https://reviews.llvm.org/D137337

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


[PATCH] D137337: Replace LLVM_LIBDIR_SUFFIX by CMAKE_INSTALL_LIBDIR

2022-12-20 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: bolt/include/bolt/RuntimeLibs/RuntimeLibraryVariables.inc.in:17
 
-#define LLVM_LIBDIR_SUFFIX "@LLVM_LIBDIR_SUFFIX@"
+#define CMAKE_INSTALL_LIBDIR "@CMAKE_INSTALL_LIBDIR@"

The prefix must remain LLVM_*
In other components accordingly


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

https://reviews.llvm.org/D137337

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


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

2022-12-20 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Thanks for the heads-up. I updated the GN build in 
4ac51dd53d93b8dd18c58093766483c657fe3a08 
 and 
2aa998d22fe09191cd6c1b697e373266c1131502 
. The 
latter commit has a python script in the commit message that might be useful to 
others who want to port this to other build systems.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137838

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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5006
+if (NeedsGlobalCtor || NeedsGlobalDtor)
+  DelayedCXXInitPosition[D] = ~0U;
+  } else {

Do you agree this should be done only when one of those flags is on?


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

https://reviews.llvm.org/D137107

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


[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 484258.

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

https://reviews.llvm.org/D137107

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/CodeGenCXX/aix-static-init.cpp
  clang/test/CodeGenCXX/call-conv-thru-alias.cpp
  clang/test/CodeGenCXX/const-init-cxx11.cpp
  clang/test/CodeGenCXX/ctor-dtor-alias.cpp
  clang/test/CodeGenCXX/cxx2a-thread-local-constinit.cpp
  clang/test/CodeGenCXX/dllimport.cpp
  clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
  clang/test/SemaCXX/PR19955.cpp
  clang/test/SemaCXX/constant-expression-cxx11.cpp
  clang/test/SemaCXX/dllimport-constexpr.cpp

Index: clang/test/SemaCXX/dllimport-constexpr.cpp
===
--- clang/test/SemaCXX/dllimport-constexpr.cpp
+++ clang/test/SemaCXX/dllimport-constexpr.cpp
@@ -40,7 +40,6 @@
 // constexpr initialization doesn't work for dllimport things.
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (*constexpr_import_func)() = _func;
-// expected-error@+1{{must be initialized by a constant expression}}
 constexpr int *constexpr_import_int = _int;
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (Foo::*constexpr_memptr)() = ::imported_method;
@@ -60,3 +59,11 @@
   // expected-note@+1 {{requested here}}
   StaticConstexpr::g_fp();
 }
+
+extern int __declspec(dllimport) val;
+constexpr int& val_ref = val;
+
+void assigndllimporttoconst () {
+  extern int _declspec(dllimport) val;
+  constexpr int& val_ref = val;
+}
Index: clang/test/SemaCXX/constant-expression-cxx11.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx11.cpp
+++ clang/test/SemaCXX/constant-expression-cxx11.cpp
@@ -1595,7 +1595,7 @@
   void f(int k) { // expected-note {{here}}
 int arr[k]; // expected-warning {{C99}} expected-note {{function parameter 'k'}}
 constexpr int n = 1 +
-sizeof(arr) // expected-error {{constant expression}}
+sizeof(arr) // expected-error{{constexpr variable 'n' must be initialized by a constant expression}}
 * 3;
   }
 }
Index: clang/test/SemaCXX/PR19955.cpp
===
--- clang/test/SemaCXX/PR19955.cpp
+++ clang/test/SemaCXX/PR19955.cpp
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple i686-mingw32 -verify -std=c++11 %s
 
 extern int __attribute__((dllimport)) var;
-constexpr int *varp =  // expected-error {{must be initialized by a constant expression}}
+constexpr int *varp = 
 
 extern __attribute__((dllimport)) void fun();
 constexpr void (*funp)(void) =  // expected-error {{must be initialized by a constant expression}}
Index: clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
===
--- clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
+++ clang/test/CodeGenCXX/funcattrs-global-ctor-dtor.cpp
@@ -7,6 +7,6 @@
 
 A g;
 
-// CHECK: define internal void @__cxx_global_var_init() [[ATTR0:#[0-9]+]]
-// CHECK: define internal void @_GLOBAL__sub_I_funcattrs_global_ctor_dtor.cpp() [[ATTR0]]
+// CHECK: define internal void @ctor() [[ATTR0:#[0-9]+]]
+// CHECK: define internal void @dtor() [[ATTR0]]
 // CHECK: attributes [[ATTR0]] = {{{.*}} sspstrong {{.*}}}
Index: clang/test/CodeGenCXX/dllimport.cpp
===
--- clang/test/CodeGenCXX/dllimport.cpp
+++ clang/test/CodeGenCXX/dllimport.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 %s
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 --check-prefix=GL32 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 --check-prefix=GL64 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu-fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 

[PATCH] D137107: Allow MS extension: support of constexpr with __declspec(dllimport).

2022-12-20 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam marked an inline comment as done.
zahiraam added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5009
+  if (isStaticInit(D, getLangOpts()) && NeedsGlobalCtor && NeedsGlobalDtor) {
+EmitCXXCtorInit(D, GV, true, 201, llvm::StringLiteral("ctor"), false);
+EmitCXXCtorInit(D, GV, false, 65535, llvm::StringLiteral("dtor"), true);

efriedma wrote:
> zahiraam wrote:
> > efriedma wrote:
> > > I think you want to use priority 201 whether or not there's a destructor.
> > Is that what you mean?
> I think it should look something more like this:
> 
> ```
> if (isStaticInit(D, getLangOpts()) {
>   if (NeedsGlobalCtor)
> EmitCXXCtorInit(D, GV, true, 201, llvm::StringLiteral("ctor"), false);
>   if (NeedsGlobalDtor)
> EmitCXXCtorInit(D, GV, false, 65535, llvm::StringLiteral("dtor"), true);
>   DelayedCXXInitPosition[D] = ~0U;
> } else {
>   EmitCXXGlobalVarDeclInitFunc(D, GV, NeedsGlobalCtor);
> }
If you agree with the generated IR for this case, then I will start editing the 
LIT tests accordingly.

  // CHECK: @"?b@@3UB@@A" = dso_local global %struct.B undef
  // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }] [{ 
i32, ptr, ptr } { i32 65535, ptr @dtor, ptr null }]

  // CHECK: define internal void @dtor()
  // CHECK: entry:
  // CHECK: %0 = call i32 @atexit(ptr @"??__Fb@@YAXXZ")
  // CHECK:   ret void

  // CHECk: define linkonce_odr dso_local x86_thiscallcc void @"??1B@@QAE@XZ"
  // CHECK: entry:
  // CHECK:  %this.addr = alloca ptr, align 4
  // CHECK:  store ptr %this, ptr %this.addr, align 4
  // CHECK:  %this1 = load ptr, ptr %this.addr, align 4
  // CHECK:  ret void


  // CHECK: define internal void @"??__Fb@@YAXXZ"() #0 {
  // CHECK: entry:
  // CHECK:   call x86_thiscallcc void @"??1B@@QAE@XZ"(ptr @"?b@@3UB@@A")
  // CHECK:   ret void


  struct B {
constexpr B() {}
~B() {};
  };
  constinit B b;


The ctor with priority 201 is generated only when tryEmitForInitializer returns 
a nullptr (that's the only time when NeedsGlobalCtor is set to true). Correct?


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

https://reviews.llvm.org/D137107

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


  1   2   >