[PATCH] D140294: clang: Replace implementation of __builtin_isnormal

2022-12-20 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

This change can have negative consequences in some cases. Some targets have 
dedicated instruction to test FP class and often this instruction is faster 
than arithmetic operations. Replacement of one operation with two arithmetic 
and two logic plus cost of FP constant materialization does not provide any 
visible benefit.

One of advantages that llvm.is_fpclass provides is the possibility for a target 
to use FCLASS instruction if it is available. Besides, llvm.is_fpclass 
incapsulates semantics of a class check, which is not identical to compare 
operations. Keeping the class checks in IR can facilitate FP-specific 
optimizations which provide different handing depending on possible FP classes. 
Fast math is one example, denormals is another.

I would propose to generate llvm.is_fpclass for all classification intrinsics 
(see D137811 ). Targets then may lower the 
intrinsic in a way most suitable way depending on ISA.


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

https://reviews.llvm.org/D140294

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


[clang] 301f3da - [CLANG] Fix typo in test/CodeGen/c-strings.c

2022-12-20 Thread Muhammad Omair Javaid via cfe-commits

Author: Muhammad Omair Javaid
Date: 2022-12-20T13:59:16+05:00
New Revision: 301f3da5162499965287338a0cd52309fb28e8b8

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

LOG: [CLANG] Fix typo in test/CodeGen/c-strings.c

This patch fixes a typo in test/CodeGen/c-strings.c. Test was failing
on AArch64/Windows.

Added: 


Modified: 
clang/test/CodeGen/c-strings.c

Removed: 




diff  --git a/clang/test/CodeGen/c-strings.c b/clang/test/CodeGen/c-strings.c
index abb4a836477f6..988deee317d4c 100644
--- a/clang/test/CodeGen/c-strings.c
+++ b/clang/test/CodeGen/c-strings.c
@@ -1,4 +1,4 @@
-// XFAIL: taraget=aarch64-pc-windows-{{.*}}
+// XFAIL: target=aarch64-pc-windows-{{.*}}
 // RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -o - %s | FileCheck 
%s --check-prefix=CHECK --check-prefix=ITANIUM
 // RUN: %clang_cc1 -triple %ms_abi_triple -emit-llvm -o - %s | FileCheck %s 
--check-prefix=CHECK --check-prefix=MSABI
 



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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2022-12-20 Thread Paulo Matos via Phabricator via cfe-commits
pmatos added a comment.

In D122215#4000612 , @MoritzS wrote:

> In D122215#3998105 , @pmatos wrote:
>
>> In D122215#3991648 , @MoritzS 
>> wrote:
>>
>>> Thanks for the patch! I just tried it out and I think this enables many 
>>> interesting use cases for WebAssembly when using C/C++.
>>>
>>> Currently the lowering to wasm does not work when using externrefs when 
>>> compiling without optimizations. Is that intended behavior?
>>
>> I have posted a new patch that fixed this. Can you please try it again and 
>> see if it works as you expect?
>
> Thanks for the quick update, it works now!
>
> Does this affect the debugging experience of the generated wasm programs? If 
> you force mem2reg to run for all programs, no function arguments will be 
> written to the "stack" referenced by the __stack_pointer global variable 
> anymore. I don't know whether any wasm runtime actually uses that for 
> debugging, though.

That's a good point, but I don't think that's a large concern at the moment on 
the WebAssembly side. I wonder if @tlively or @sbc100 have more to add with 
respect to the current state of debugging Wasm programs nowadays.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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


[PATCH] D139995: [RISCV] Refactor RVV Policy by structure

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

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139995

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

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -164,8 +164,8 @@
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
   // We had initialized DefaultPolicy as TU/TUMU in CodeGen function.
-  if (RVVI->getDefaultPolicy() != Policy::TU &&
-  RVVI->getDefaultPolicy() != Policy::TUMU && !RVVI->hasPassthruOperand() &&
+  if (!RVVI->getDefaultPolicy().isTUPolicy() &&
+  !RVVI->getDefaultPolicy().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
   !RVVI->hasManualCodegen() && RVVI->hasVL())
 OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
 
@@ -193,11 +193,11 @@
 OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(),"
   " DefaultPolicy));\n";
   if (RVVI->hasMaskedOffOperand() &&
-  RVVI->getDefaultPolicy() == Policy::TAMA)
+  RVVI->getDefaultPolicy().isTAMAPolicy())
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
   // Masked reduction cases.
   if (!RVVI->hasMaskedOffOperand() && RVVI->hasPassthruOperand() &&
-  RVVI->getDefaultPolicy() == Policy::TAMA)
+  RVVI->getDefaultPolicy().isTAMAPolicy())
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
@@ -207,7 +207,7 @@
   OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(), "
 "DefaultPolicy));\n";
 else if (RVVI->hasPassthruOperand() &&
- RVVI->getDefaultPolicy() == Policy::TA)
+ RVVI->getDefaultPolicy().isTAPolicy())
   OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
   }
 
@@ -527,7 +527,11 @@
 unsigned NF = R->getValueAsInt("NF");
 
 // If unmasked builtin supports policy, they should be TU or TA.
-SmallVector SupportedUnMaskedPolicies = {Policy::TU, Policy::TA};
+llvm::SmallVector SupportedUnMaskedPolicies;
+SupportedUnMaskedPolicies.emplace_back(Policy(
+Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
+SupportedUnMaskedPolicies.emplace_back(
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
@@ -544,10 +548,10 @@
 auto Prototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF, IsPrototypeDefaultTU,
-UnMaskedPolicyScheme);
+UnMaskedPolicyScheme, Policy());
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-IsPrototypeDefaultTU, MaskedPolicyScheme);
+IsPrototypeDefaultTU, MaskedPolicyScheme, Policy());
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -569,7 +573,7 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy::PolicyNone, IsPrototypeDefaultTU));
+Policy(), IsPrototypeDefaultTU));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
@@ -596,7 +600,7 @@
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
 SupportOverloading, HasBuiltinAlias, MaskedManualCodegen,
 *MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
-Policy::PolicyNone, IsPrototypeDefaultTU));
+Policy(), IsPrototypeDefaultTU));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -914,30 +914,22 @@
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
   // Update DefaultPolicy if need (TA or TAMA) for compute builtin types.
-  switch (DefaultPolicy) {
-  case Policy::MA:
-DefaultPolicy = Policy::TAMA;
-  

[clang] 0d4c650 - [RISCV] Refactor RVV Policy by structure

2022-12-20 Thread Piyou Chen via cfe-commits

Author: Piyou Chen
Date: 2022-12-20T01:13:13-08:00
New Revision: 0d4c6506100b339311283c10d841d7693287666a

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

LOG: [RISCV] Refactor RVV Policy by structure

RVV intrinsic function has several policy variants.

Include TU, TA, TAMU, TAMA, TUMU, TUMA, MU, MA, TUM, TAM

Currently, the clang side enumerates these policies, but it's hard to add a new 
policy.

This patch use structure to replace the origin policy enumeration, and enhance 
some policy transform logic.

This is a clean-up job that will not affect the RVV intrinsic functionality and 
make sure riscv_vector_builtin_cg.inc is the same as the original one.

Reviewed By: kito-cheng

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

Added: 


Modified: 
clang/include/clang/Support/RISCVVIntrinsicUtils.h
clang/lib/Sema/SemaRISCVVectorLookup.cpp
clang/lib/Support/RISCVVIntrinsicUtils.cpp
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Support/RISCVVIntrinsicUtils.h 
b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
index a3a2a3c068604..8f37aa783aca3 100644
--- a/clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ b/clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -92,19 +92,80 @@ enum class TypeModifier : uint8_t {
   LLVM_MARK_AS_BITMASK_ENUM(LMUL1),
 };
 
-// The Lowerest two bit equal to policy value.
-enum Policy : uint8_t {
-  TU = 0, // For unmasked TU, last two bit is TUMU
-  TA = 1, // // For unmasked TA, last two bit is TAMU
-  TUMA = 2,
-  TAMA = 3,
-  TUMU = 4,
-  TAMU = 5,
-  MU = 6,   // For masked MU, last two bit is TAMU
-  MA = 7,   // For masked MA, last two bit is TAMA
-  TUM = 10, // For masked MA, last two bit is TUMA
-  TAM = 11, // For masked MA, last two bit is TAMA
-  PolicyNone,
+struct Policy {
+  bool PolicyNone = false;
+  enum PolicyType {
+Undisturbed,
+Agnostic,
+Omit, // No policy required.
+  };
+  PolicyType TailPolicy = Omit;
+  PolicyType MaskPolicy = Omit;
+  bool IntrinsicWithoutMU = false;
+  Policy() : PolicyNone(true) {}
+  Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy,
+ bool _IntrinsicWithoutMU = false)
+  : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy),
+IntrinsicWithoutMU(_IntrinsicWithoutMU) {}
+
+  bool isTAMAPolicy() const {
+return TailPolicy == Agnostic && MaskPolicy == Agnostic;
+  }
+
+  bool isTAMUPolicy() const {
+return TailPolicy == Agnostic && MaskPolicy == Undisturbed;
+  }
+
+  bool isTUMAPolicy() const {
+return TailPolicy == Undisturbed && MaskPolicy == Agnostic;
+  }
+
+  bool isTUMUPolicy() const {
+return TailPolicy == Undisturbed && MaskPolicy == Undisturbed;
+  }
+
+  bool isTUMPolicy() const {
+return TailPolicy == Undisturbed && MaskPolicy == Agnostic &&
+   IntrinsicWithoutMU;
+  }
+
+  bool isTAMPolicy() const {
+return TailPolicy == Agnostic && MaskPolicy == Agnostic &&
+   IntrinsicWithoutMU;
+  }
+
+  bool isTAPolicy() const {
+return TailPolicy == Agnostic && MaskPolicy == Omit;
+  }
+
+  bool isTUPolicy() const {
+return TailPolicy == Undisturbed && MaskPolicy == Omit;
+  }
+
+  bool isMAPolicy() const {
+return MaskPolicy == Agnostic && TailPolicy == Omit;
+  }
+
+  bool isMUPolicy() const {
+return MaskPolicy == Undisturbed && TailPolicy == Omit;
+  }
+
+  bool isPolicyNonePolicy() const { return PolicyNone; }
+
+  bool operator==(const Policy &Other) const {
+return PolicyNone == Other.PolicyNone && TailPolicy == Other.TailPolicy &&
+   MaskPolicy == Other.MaskPolicy &&
+   IntrinsicWithoutMU == Other.IntrinsicWithoutMU;
+  }
+
+  bool operator!=(const Policy &Other) const { return !(*this == Other); }
+
+  bool operator<(const Policy &Other) const {
+// Just for maintain the old order for quick test.
+if (MaskPolicy != Other.MaskPolicy)
+  return Other.MaskPolicy < MaskPolicy;
+return TailPolicy < Other.TailPolicy;
+  }
 };
 
 // PrototypeDescriptor is used to compute type info of arguments or return
@@ -333,7 +394,7 @@ class RVVIntrinsic {
   // InputTypes. -1 means the return type.
   std::vector IntrinsicTypes;
   unsigned NF = 1;
-  Policy DefaultPolicy = Policy::PolicyNone;
+  Policy DefaultPolicy;
 
 public:
   RVVIntrinsic(llvm::StringRef Name, llvm::StringRef Suffix,
@@ -373,12 +434,33 @@ class RVVIntrinsic {
 return IntrinsicTypes;
   }
   Policy getDefaultPolicy() const {
-assert(DefaultPolicy != Policy::PolicyNone);
+assert(DefaultPolicy.PolicyNone == false);
 return DefaultPolicy;
   }
   unsigned getDefaultPolicyBits() const {
-assert(DefaultPolicy != Policy::PolicyNone);
-return static_cast(DefaultPolicy) & 3;
+// Return following value.
+// constexpr unsig

[PATCH] D139995: [RISCV] Refactor RVV Policy by structure

2022-12-20 Thread Piyou 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 rG0d4c6506100b: [RISCV] Refactor RVV Policy by structure 
(authored by BeMg).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139995

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

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -164,8 +164,8 @@
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
   // We had initialized DefaultPolicy as TU/TUMU in CodeGen function.
-  if (RVVI->getDefaultPolicy() != Policy::TU &&
-  RVVI->getDefaultPolicy() != Policy::TUMU && !RVVI->hasPassthruOperand() &&
+  if (!RVVI->getDefaultPolicy().isTUPolicy() &&
+  !RVVI->getDefaultPolicy().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
   !RVVI->hasManualCodegen() && RVVI->hasVL())
 OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
 
@@ -193,11 +193,11 @@
 OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(),"
   " DefaultPolicy));\n";
   if (RVVI->hasMaskedOffOperand() &&
-  RVVI->getDefaultPolicy() == Policy::TAMA)
+  RVVI->getDefaultPolicy().isTAMAPolicy())
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
   // Masked reduction cases.
   if (!RVVI->hasMaskedOffOperand() && RVVI->hasPassthruOperand() &&
-  RVVI->getDefaultPolicy() == Policy::TAMA)
+  RVVI->getDefaultPolicy().isTAMAPolicy())
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
@@ -207,7 +207,7 @@
   OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(), "
 "DefaultPolicy));\n";
 else if (RVVI->hasPassthruOperand() &&
- RVVI->getDefaultPolicy() == Policy::TA)
+ RVVI->getDefaultPolicy().isTAPolicy())
   OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
   }
 
@@ -527,7 +527,11 @@
 unsigned NF = R->getValueAsInt("NF");
 
 // If unmasked builtin supports policy, they should be TU or TA.
-SmallVector SupportedUnMaskedPolicies = {Policy::TU, Policy::TA};
+llvm::SmallVector SupportedUnMaskedPolicies;
+SupportedUnMaskedPolicies.emplace_back(Policy(
+Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
+SupportedUnMaskedPolicies.emplace_back(
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
@@ -544,10 +548,10 @@
 auto Prototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF, IsPrototypeDefaultTU,
-UnMaskedPolicyScheme);
+UnMaskedPolicyScheme, Policy());
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-IsPrototypeDefaultTU, MaskedPolicyScheme);
+IsPrototypeDefaultTU, MaskedPolicyScheme, Policy());
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -569,7 +573,7 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy::PolicyNone, IsPrototypeDefaultTU));
+Policy(), IsPrototypeDefaultTU));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
@@ -596,7 +600,7 @@
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
 SupportOverloading, HasBuiltinAlias, MaskedManualCodegen,
 *MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
-Policy::PolicyNone, IsPrototypeDefaultTU));
+Policy(), IsPrototypeDefaultTU));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -914,30 +914,22 @@
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
   // Upda

[PATCH] D140377: [clang][Interp] Compound assign operators for FP values

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

I'm not quite sure I got the different computation values correct, so please 
review.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140377

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/const-fpfeatures.cpp
  clang/test/AST/Interp/floats.cpp

Index: clang/test/AST/Interp/floats.cpp
===
--- clang/test/AST/Interp/floats.cpp
+++ clang/test/AST/Interp/floats.cpp
@@ -54,3 +54,27 @@
 // ref-note {{is outside the range of representable values}} \
 // expected-error {{must be initialized by a constant expression}} \
 // expected-note {{is outside the range of representable values}}
+
+namespace compound {
+  constexpr float f1() {
+float f = 0;
+f += 3.0;
+f -= 3.0f;
+
+f += 1;
+f /= 1;
+f /= 1.0;
+f *= f;
+
+f *= 2.0;
+return f;
+  }
+  static_assert(f1() == 2);
+
+  constexpr float f2() {
+float f = __FLT_MAX__;
+f += 1.0;
+return f;
+  }
+  static_assert(f2() == __FLT_MAX__);
+}
Index: clang/test/AST/Interp/const-fpfeatures.cpp
===
--- clang/test/AST/Interp/const-fpfeatures.cpp
+++ clang/test/AST/Interp/const-fpfeatures.cpp
@@ -50,9 +50,6 @@
 // CHECK: @V2 = {{.*}} float 0x3FF02000
 
 
-/// FIXME: The following tests need support for compound assign operators
-///   with LHS and RHS of different semantics.
-#if 0
 constexpr float add_cast_round_down(float x, double y) {
   #pragma STDC FENV_ROUND FE_DOWNWARD
   float res = x;
@@ -70,5 +67,5 @@
 float V3 = add_cast_round_down(1.0F, 0x0.01p0F);
 float V4 = add_cast_round_up(1.0F, 0x0.01p0F);
 
-
-#endif
+// CHECK: @V3 = {{.*}} float 1.00e+00
+// CHECK: @V4 = {{.*}} float 0x3FF02000
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -88,6 +88,7 @@
   bool VisitStringLiteral(const StringLiteral *E);
   bool VisitCharacterLiteral(const CharacterLiteral *E);
   bool VisitCompoundAssignOperator(const CompoundAssignOperator *E);
+  bool VisitFloatCompoundAssignOperator(const CompoundAssignOperator *E);
   bool VisitExprWithCleanups(const ExprWithCleanups *E);
   bool VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E);
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -593,9 +593,86 @@
   return this->emitConst(E->getValue(), E);
 }
 
+template 
+bool ByteCodeExprGen::VisitFloatCompoundAssignOperator(
+const CompoundAssignOperator *E) {
+  assert(E->getType()->isFloatingType());
+
+  const Expr *LHS = E->getLHS();
+  const Expr *RHS = E->getRHS();
+  llvm::RoundingMode RM = getRoundingMode(E);
+  QualType LHSComputationType = E->getComputationLHSType();
+  QualType ResultType = E->getComputationResultType();
+  std::optional LT = classify(LHSComputationType);
+  std::optional RT = classify(ResultType);
+
+  if (!LT || !RT)
+return false;
+
+  // First, visit LHS.
+  if (!visit(LHS))
+return false;
+
+  if (!this->emitLoad(*LT, E))
+return false;
+
+  // If necessary, convert LHS to its computation type.
+  if (LHS->getType() != LHSComputationType) {
+const auto *TargetSemantics =
+&Ctx.getASTContext().getFloatTypeSemantics(LHSComputationType);
+
+if (!this->emitCastFP(TargetSemantics, RM, E))
+  return false;
+  }
+
+  // Now load RHS.
+  if (!visit(RHS))
+return false;
+
+  switch (E->getOpcode()) {
+  case BO_AddAssign:
+if (!this->emitAddf(RM, E))
+  return false;
+break;
+  case BO_SubAssign:
+if (!this->emitSubf(RM, E))
+  return false;
+break;
+  case BO_MulAssign:
+if (!this->emitMulf(RM, E))
+  return false;
+break;
+  case BO_DivAssign:
+if (!this->emitDivf(RM, E))
+  return false;
+break;
+  default:
+return false;
+  }
+
+  // If necessary, convert result to LHS's type.
+  if (LHS->getType() != ResultType) {
+const auto *TargetSemantics =
+&Ctx.getASTContext().getFloatTypeSemantics(LHS->getType());
+
+if (!this->emitCastFP(TargetSemantics, RM, E))
+  return false;
+  }
+
+  if (DiscardResult)
+return this->emitStorePop(*LT, E);
+  return this->emitStore(*LT, E);
+}
+
 template 
 bool ByteCodeExprGen::VisitCompoundAssignOperator(
 const CompoundAssignOperator *E) {
+
+  // Handle floating point o

[PATCH] D132017: [clang][analyzer] Add errno modeling to StreamChecker

2022-12-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske abandoned this revision.
balazske added a comment.

A new solution is in D135247 . The new 
approach is that only `StdLibraryFunctionsChecker` adds the errno modeling 
part, together with other checks (that are applicable if StreamChecker is 
turned off) for pre and post conditions at the stream functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132017

___
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
nridge created this revision.
nridge added a reviewer: sammccall.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
nridge 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/1427


Repository:
  rG LLVM Github Monorepo

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 = &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 = &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


[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
nridge added inline comments.



Comment at: clang-tools-extra/clangd/Quality.cpp:306
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+if (hasUnstableLinkage(ND))
+  return;

Would it be better to reuse [this getSymbolID 
overload](https://searchfox.org/llvm/rev/ec87b7231586865f7b0adfe22a0d056e40ae9264/clang-tools-extra/clangd/CodeComplete.cpp#606-621)
 instead? (Would require plumbing in a SourceManager to this call site.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140379

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


[PATCH] D132249: [clang][analyzer] Add some functions to StreamChecker with errno modeling.

2022-12-20 Thread Balázs Kéri via Phabricator via cfe-commits
balazske abandoned this revision.
balazske added a comment.

See D135247  and related for a new solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132249

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


[PATCH] D140380: [include-cleaner] Respect IWYU pragmas during analyze

2022-12-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added a project: All.
kadircet requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140380

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


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -26,9 +26,9 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::AllOf;
 using testing::Contains;
 using testing::ElementsAre;
-using testing::AllOf;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -181,6 +181,7 @@
   Inputs.Code = R"cpp(
 #include "a.h"
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 
 int x = a + c;
 )cpp";
@@ -190,28 +191,32 @@
 int b;
   )cpp");
   Inputs.ExtraFiles["c.h"] = guard("int c;");
+  Inputs.ExtraFiles["keep.h"] = guard("");
 
   RecordedPP PP;
-  Inputs.MakeAction = [&PP] {
+  PragmaIncludes PI;
+  Inputs.MakeAction = [&PP, &PI] {
 struct Hook : public SyntaxOnlyAction {
 public:
-  Hook(RecordedPP &PP) : PP(PP) {}
+  Hook(RecordedPP &PP, PragmaIncludes &PI) : PP(PP), PI(PI) {}
   bool BeginSourceFileAction(clang::CompilerInstance &CI) override {
 CI.getPreprocessor().addPPCallbacks(PP.record(CI.getPreprocessor()));
+PI.record(CI);
 return true;
   }
 
   RecordedPP &PP;
+  PragmaIncludes &PI;
 };
-return std::make_unique(PP);
+return std::make_unique(PP, PI);
   };
 
   TestAST AST(Inputs);
   auto Decls = AST.context().getTranslationUnitDecl()->decls();
   auto Results =
   analyze(std::vector{Decls.begin(), Decls.end()},
-  PP.MacroReferences, PP.Includes, /*PragmaIncludes=*/nullptr,
-  AST.sourceManager(), AST.preprocessor().getHeaderSearchInfo());
+  PP.MacroReferences, PP.Includes, &PI, AST.sourceManager(),
+  AST.preprocessor().getHeaderSearchInfo());
 
   const Include *B = PP.Includes.atLine(3);
   ASSERT_EQ(B->Spelled, "b.h");
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -101,7 +101,7 @@
 
   AnalysisResults Results;
   for (const Include &I : Inc.all())
-if (!Used.contains(&I))
+if (!Used.contains(&I) && PI && !PI->shouldKeep(I.Line))
   Results.Unused.push_back(&I);
   for (llvm::StringRef S : Missing.keys())
 Results.Missing.push_back(S.str());


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -26,9 +26,9 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::AllOf;
 using testing::Contains;
 using testing::ElementsAre;
-using testing::AllOf;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -181,6 +181,7 @@
   Inputs.Code = R"cpp(
 #include "a.h"
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 
 int x = a + c;
 )cpp";
@@ -190,28 +191,32 @@
 int b;
   )cpp");
   Inputs.ExtraFiles["c.h"] = guard("int c;");
+  Inputs.ExtraFiles["keep.h"] = guard("");
 
   RecordedPP PP;
-  Inputs.MakeAction = [&PP] {
+  PragmaIncludes PI;
+  Inputs.MakeAction = [&PP, &PI] {
 struct Hook : public SyntaxOnlyAction {
 public:
-  Hook(RecordedPP &PP) : PP(PP) {}
+  Hook(RecordedPP &PP, PragmaIncludes &PI) : PP(PP), PI(PI) {}
   bool BeginSourceFileAction(clang::CompilerInstance &CI) override {
 CI.getPreprocessor().addPPCallbacks(PP.record(CI.getPreprocessor()));
+PI.record(CI);
 return true;
   }
 
   RecordedPP &PP;
+  PragmaIncludes &PI;
 };
-return std::make_unique(PP);
+return std::make_unique(PP, PI);
   };
 
   TestAST AST(Inputs);
   auto Decls = AST.context().getTranslationUnitDecl()->decls();
   auto Results =
   analyze(std::vector{Decls.begin(), Decls.end()},
-  PP.MacroReferences, PP.Includes, /*PragmaIncludes=*/nullptr,
-  AST.sourceManager(), AST.preprocessor().getHeaderSearchInfo());
+  PP.MacroReferences, PP.Includes, &PI, AST.sourceManager(),
+  AST.preprocessor().getHeaderSearchInfo());
 
   const Include *B = PP.Includes.atLine(3);
   ASSERT_EQ(B->Spelled, "b.h");
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp

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

2022-12-20 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez added a comment.

In D140195#4001989 , @aprantl wrote:

> How does this affect the generated DWARF? Have you tested that this does the 
> right thing in LLDB?

It shouldn't affect the generated DWARF on LLVM's main branch.
Currently, LLVM relies on the field size to know if a member is a bitfield or 
not.

However, if we apply the patch https://reviews.llvm.org/D96334 , if the 
`DIFlagBitField` attribute is not added, the members won't be treated as 
bitfields.

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.


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] D140380: [include-cleaner] Respect IWYU pragmas during analyze

2022-12-20 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp:184
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 

add the `export` case as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140380

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


[PATCH] D140380: [include-cleaner] Respect IWYU pragmas during analyze

2022-12-20 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp:184
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 

hokein wrote:
> add the `export` case as well.
i don't think we should be testing the behaviour of 
`PragmaIncludes::shouldKeep` here, hence i think one example is enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140380

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


[PATCH] D140380: [include-cleaner] Respect IWYU pragmas during analyze

2022-12-20 Thread Kadir Cetinkaya 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 rGb76cc30e1585: [include-cleaner] Respect IWYU pragmas during 
analyze (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140380

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


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -26,9 +26,9 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::AllOf;
 using testing::Contains;
 using testing::ElementsAre;
-using testing::AllOf;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -181,6 +181,7 @@
   Inputs.Code = R"cpp(
 #include "a.h"
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 
 int x = a + c;
 )cpp";
@@ -190,28 +191,32 @@
 int b;
   )cpp");
   Inputs.ExtraFiles["c.h"] = guard("int c;");
+  Inputs.ExtraFiles["keep.h"] = guard("");
 
   RecordedPP PP;
-  Inputs.MakeAction = [&PP] {
+  PragmaIncludes PI;
+  Inputs.MakeAction = [&PP, &PI] {
 struct Hook : public SyntaxOnlyAction {
 public:
-  Hook(RecordedPP &PP) : PP(PP) {}
+  Hook(RecordedPP &PP, PragmaIncludes &PI) : PP(PP), PI(PI) {}
   bool BeginSourceFileAction(clang::CompilerInstance &CI) override {
 CI.getPreprocessor().addPPCallbacks(PP.record(CI.getPreprocessor()));
+PI.record(CI);
 return true;
   }
 
   RecordedPP &PP;
+  PragmaIncludes &PI;
 };
-return std::make_unique(PP);
+return std::make_unique(PP, PI);
   };
 
   TestAST AST(Inputs);
   auto Decls = AST.context().getTranslationUnitDecl()->decls();
   auto Results =
   analyze(std::vector{Decls.begin(), Decls.end()},
-  PP.MacroReferences, PP.Includes, /*PragmaIncludes=*/nullptr,
-  AST.sourceManager(), AST.preprocessor().getHeaderSearchInfo());
+  PP.MacroReferences, PP.Includes, &PI, AST.sourceManager(),
+  AST.preprocessor().getHeaderSearchInfo());
 
   const Include *B = PP.Includes.atLine(3);
   ASSERT_EQ(B->Spelled, "b.h");
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp
===
--- clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -101,7 +101,7 @@
 
   AnalysisResults Results;
   for (const Include &I : Inc.all())
-if (!Used.contains(&I))
+if (!Used.contains(&I) && PI && !PI->shouldKeep(I.Line))
   Results.Unused.push_back(&I);
   for (llvm::StringRef S : Missing.keys())
 Results.Missing.push_back(S.str());


Index: clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -26,9 +26,9 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::AllOf;
 using testing::Contains;
 using testing::ElementsAre;
-using testing::AllOf;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -181,6 +181,7 @@
   Inputs.Code = R"cpp(
 #include "a.h"
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 
 int x = a + c;
 )cpp";
@@ -190,28 +191,32 @@
 int b;
   )cpp");
   Inputs.ExtraFiles["c.h"] = guard("int c;");
+  Inputs.ExtraFiles["keep.h"] = guard("");
 
   RecordedPP PP;
-  Inputs.MakeAction = [&PP] {
+  PragmaIncludes PI;
+  Inputs.MakeAction = [&PP, &PI] {
 struct Hook : public SyntaxOnlyAction {
 public:
-  Hook(RecordedPP &PP) : PP(PP) {}
+  Hook(RecordedPP &PP, PragmaIncludes &PI) : PP(PP), PI(PI) {}
   bool BeginSourceFileAction(clang::CompilerInstance &CI) override {
 CI.getPreprocessor().addPPCallbacks(PP.record(CI.getPreprocessor()));
+PI.record(CI);
 return true;
   }
 
   RecordedPP &PP;
+  PragmaIncludes &PI;
 };
-return std::make_unique(PP);
+return std::make_unique(PP, PI);
   };
 
   TestAST AST(Inputs);
   auto Decls = AST.context().getTranslationUnitDecl()->decls();
   auto Results =
   analyze(std::vector{Decls.begin(), Decls.end()},
-  PP.MacroReferences, PP.Includes, /*PragmaIncludes=*/nullptr,
-  AST.sourceManager(), AST.preprocessor().getHeaderSearchInfo());
+  PP.MacroReferences, PP.Includes, &PI, AST.sourceManager(),
+  AST.preprocessor().getHeaderSearchInfo());
 
   const Include *B = PP.Includes.atLine(3);
   ASSERT_EQ(B->Spelled, "b.h");
Index: clang-tools-extra/include-cleaner/lib/Analysis.cpp

[clang-tools-extra] b76cc30 - [include-cleaner] Respect IWYU pragmas during analyze

2022-12-20 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2022-12-20T10:47:22+01:00
New Revision: b76cc30e15855bf3ed094e680448e08e42e7d99d

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

LOG: [include-cleaner] Respect IWYU pragmas during analyze

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

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/lib/Analysis.cpp 
b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
index 9ffa8e7f3a15d..1c7ac33cfa080 100644
--- a/clang-tools-extra/include-cleaner/lib/Analysis.cpp
+++ b/clang-tools-extra/include-cleaner/lib/Analysis.cpp
@@ -101,7 +101,7 @@ AnalysisResults analyze(llvm::ArrayRef ASTRoots,
 
   AnalysisResults Results;
   for (const Include &I : Inc.all())
-if (!Used.contains(&I))
+if (!Used.contains(&I) && PI && !PI->shouldKeep(I.Line))
   Results.Unused.push_back(&I);
   for (llvm::StringRef S : Missing.keys())
 Results.Missing.push_back(S.str());

diff  --git a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp 
b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
index 37d71dd4c5c57..7f87a188be856 100644
--- a/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/AnalysisTest.cpp
@@ -26,9 +26,9 @@
 
 namespace clang::include_cleaner {
 namespace {
+using testing::AllOf;
 using testing::Contains;
 using testing::ElementsAre;
-using testing::AllOf;
 using testing::Pair;
 using testing::UnorderedElementsAre;
 
@@ -181,6 +181,7 @@ TEST(Analyze, Basic) {
   Inputs.Code = R"cpp(
 #include "a.h"
 #include "b.h"
+#include "keep.h" // IWYU pragma: keep
 
 int x = a + c;
 )cpp";
@@ -190,28 +191,32 @@ int x = a + c;
 int b;
   )cpp");
   Inputs.ExtraFiles["c.h"] = guard("int c;");
+  Inputs.ExtraFiles["keep.h"] = guard("");
 
   RecordedPP PP;
-  Inputs.MakeAction = [&PP] {
+  PragmaIncludes PI;
+  Inputs.MakeAction = [&PP, &PI] {
 struct Hook : public SyntaxOnlyAction {
 public:
-  Hook(RecordedPP &PP) : PP(PP) {}
+  Hook(RecordedPP &PP, PragmaIncludes &PI) : PP(PP), PI(PI) {}
   bool BeginSourceFileAction(clang::CompilerInstance &CI) override {
 CI.getPreprocessor().addPPCallbacks(PP.record(CI.getPreprocessor()));
+PI.record(CI);
 return true;
   }
 
   RecordedPP &PP;
+  PragmaIncludes &PI;
 };
-return std::make_unique(PP);
+return std::make_unique(PP, PI);
   };
 
   TestAST AST(Inputs);
   auto Decls = AST.context().getTranslationUnitDecl()->decls();
   auto Results =
   analyze(std::vector{Decls.begin(), Decls.end()},
-  PP.MacroReferences, PP.Includes, /*PragmaIncludes=*/nullptr,
-  AST.sourceManager(), AST.preprocessor().getHeaderSearchInfo());
+  PP.MacroReferences, PP.Includes, &PI, AST.sourceManager(),
+  AST.preprocessor().getHeaderSearchInfo());
 
   const Include *B = PP.Includes.atLine(3);
   ASSERT_EQ(B->Spelled, "b.h");



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


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

2022-12-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: llvm/lib/Support/RISCVISAInfo.cpp:772
+
+  if ((Exts.count("zvkb") || Exts.count("zvknhb")) && !Exts.count("zve64x"))
+return createStringError(

With this check, the check for these extensions on top are redundant.



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoV.td:1675
 
+include "RISCVInstrInfoZvk.td" //SIFIVE
 include "RISCVInstrInfoVPseudos.td"

Got to remove the company name here ;)



Comment at: llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td:8
+//===--===//
+///
+// This file describes the RISC-V instructions from the standard 'Zvk',

`///` -> `//`, and same below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

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


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

2022-12-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added inline comments.



Comment at: llvm/test/MC/RISCV/rvv/rv64zvksed_invalid.s:1
+# RUN: not llvm-mc -triple=riscv64 --mattr=+zve32x 
--mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR

I see similar files uses `-invalid` instead of `_invalid`. Probably good to 
follow that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

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


[PATCH] D139908: [clang] Do not extend i8 return values to i16 on AVR.

2022-12-20 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

On 32-bit / 64-bit machines, a function returning lower types (via a register) 
should an explicit sign/zero extension to full fill the register.

But on AVR, a 8-bit register is used to return 8-bit values, so the sign/zero 
extension is unnecessary, and lead to extra useless assembly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139908

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


[clang] d20101d - [clang][NFC] Clean up createDefaultOutputFile()

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

Author: Timm Bäder
Date: 2022-12-20T11:29:44+01:00
New Revision: d20101db48945e9d7a19ce3edcfd91d7e1aeadab

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

LOG: [clang][NFC] Clean up createDefaultOutputFile()

PathStorage is only used in one of the if branches, so doesn't need to
be a std::optional anyway.

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index a12456640c7ac..858c5805b3abb 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -805,14 +805,13 @@ std::unique_ptr 
CompilerInstance::createDefaultOutputFile(
 bool Binary, StringRef InFile, StringRef Extension, bool 
RemoveFileOnSignal,
 bool CreateMissingDirectories, bool ForceUseTemporary) {
   StringRef OutputPath = getFrontendOpts().OutputFile;
-  std::optional> PathStorage;
   if (OutputPath.empty()) {
 if (InFile == "-" || Extension.empty()) {
   OutputPath = "-";
 } else {
-  PathStorage.emplace(InFile);
-  llvm::sys::path::replace_extension(*PathStorage, Extension);
-  OutputPath = *PathStorage;
+  SmallString<128> PathStorage = InFile;
+  llvm::sys::path::replace_extension(PathStorage, Extension);
+  OutputPath = PathStorage;
 }
   }
 



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


[PATCH] D139908: [clang] Do not extend i8 return values to i16 on AVR.

2022-12-20 Thread LiqinWeng via Phabricator via cfe-commits
Miss_Grape added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139908

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


[clang] 1953c7e - [NFC][RISCV] Extract utility to calculate value through MajorVersion and MinorVersion

2022-12-20 Thread via cfe-commits

Author: eopXD
Date: 2022-12-20T02:35:10-08:00
New Revision: 1953c7e03b086e0680545980ef1c9461a7513e29

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

LOG: [NFC][RISCV] Extract utility to calculate value through MajorVersion and 
MinorVersion

Reviewed By: craig.topper

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 1b244c9b2f253..31817b8b60cb7 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -118,6 +118,10 @@ std::string RISCVTargetInfo::convertConstraint(const char 
*&Constraint) const {
   return R;
 }
 
+static unsigned getVersionValue(unsigned MajorVersion, unsigned MinorVersion) {
+  return MajorVersion * 100 + MinorVersion * 1000;
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
@@ -153,10 +157,10 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   for (auto &Extension : ISAInfo->getExtensions()) {
 auto ExtName = Extension.first;
 auto ExtInfo = Extension.second;
-unsigned Version =
-(ExtInfo.MajorVersion * 100) + (ExtInfo.MinorVersion * 1000);
 
-Builder.defineMacro(Twine("__riscv_", ExtName), Twine(Version));
+Builder.defineMacro(
+Twine("__riscv_", ExtName),
+Twine(getVersionValue(ExtInfo.MajorVersion, ExtInfo.MinorVersion)));
   }
 
   if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul"))
@@ -194,8 +198,7 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (ISAInfo->hasExtension("zve32x")) {
 Builder.defineMacro("__riscv_vector");
 // Currently we support the v0.10 RISC-V V intrinsics.
-unsigned Version = (0 * 100) + (10 * 1000);
-Builder.defineMacro("__riscv_v_intrinsic", Twine(Version));
+Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 10)));
   }
 }
 



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


[PATCH] D139025: [NFC][RISCV] Extract utility to calculate value through MajorVersion and MinorVersion

2022-12-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1953c7e03b08: [NFC][RISCV] Extract utility to calculate 
value through MajorVersion and… (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139025

Files:
  clang/lib/Basic/Targets/RISCV.cpp


Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -118,6 +118,10 @@
   return R;
 }
 
+static unsigned getVersionValue(unsigned MajorVersion, unsigned MinorVersion) {
+  return MajorVersion * 100 + MinorVersion * 1000;
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
@@ -153,10 +157,10 @@
   for (auto &Extension : ISAInfo->getExtensions()) {
 auto ExtName = Extension.first;
 auto ExtInfo = Extension.second;
-unsigned Version =
-(ExtInfo.MajorVersion * 100) + (ExtInfo.MinorVersion * 1000);
 
-Builder.defineMacro(Twine("__riscv_", ExtName), Twine(Version));
+Builder.defineMacro(
+Twine("__riscv_", ExtName),
+Twine(getVersionValue(ExtInfo.MajorVersion, ExtInfo.MinorVersion)));
   }
 
   if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul"))
@@ -194,8 +198,7 @@
   if (ISAInfo->hasExtension("zve32x")) {
 Builder.defineMacro("__riscv_vector");
 // Currently we support the v0.10 RISC-V V intrinsics.
-unsigned Version = (0 * 100) + (10 * 1000);
-Builder.defineMacro("__riscv_v_intrinsic", Twine(Version));
+Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 10)));
   }
 }
 


Index: clang/lib/Basic/Targets/RISCV.cpp
===
--- clang/lib/Basic/Targets/RISCV.cpp
+++ clang/lib/Basic/Targets/RISCV.cpp
@@ -118,6 +118,10 @@
   return R;
 }
 
+static unsigned getVersionValue(unsigned MajorVersion, unsigned MinorVersion) {
+  return MajorVersion * 100 + MinorVersion * 1000;
+}
+
 void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
   Builder.defineMacro("__ELF__");
@@ -153,10 +157,10 @@
   for (auto &Extension : ISAInfo->getExtensions()) {
 auto ExtName = Extension.first;
 auto ExtInfo = Extension.second;
-unsigned Version =
-(ExtInfo.MajorVersion * 100) + (ExtInfo.MinorVersion * 1000);
 
-Builder.defineMacro(Twine("__riscv_", ExtName), Twine(Version));
+Builder.defineMacro(
+Twine("__riscv_", ExtName),
+Twine(getVersionValue(ExtInfo.MajorVersion, ExtInfo.MinorVersion)));
   }
 
   if (ISAInfo->hasExtension("m") || ISAInfo->hasExtension("zmmul"))
@@ -194,8 +198,7 @@
   if (ISAInfo->hasExtension("zve32x")) {
 Builder.defineMacro("__riscv_vector");
 // Currently we support the v0.10 RISC-V V intrinsics.
-unsigned Version = (0 * 100) + (10 * 1000);
-Builder.defineMacro("__riscv_v_intrinsic", Twine(Version));
+Builder.defineMacro("__riscv_v_intrinsic", Twine(getVersionValue(0, 10)));
   }
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1a24bbe - Revert "[clang][NFC] Clean up createDefaultOutputFile()"

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

Author: Timm Bäder
Date: 2022-12-20T11:46:09+01:00
New Revision: 1a24bbeefd2ad29e579f871144cfb17a4afb4320

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

LOG: Revert "[clang][NFC] Clean up createDefaultOutputFile()"

This reverts commit d20101db48945e9d7a19ce3edcfd91d7e1aeadab.

Lifetime of the string is not what I thought it was it seems.

Added: 


Modified: 
clang/lib/Frontend/CompilerInstance.cpp

Removed: 




diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 858c5805b3abb..a12456640c7ac 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -805,13 +805,14 @@ std::unique_ptr 
CompilerInstance::createDefaultOutputFile(
 bool Binary, StringRef InFile, StringRef Extension, bool 
RemoveFileOnSignal,
 bool CreateMissingDirectories, bool ForceUseTemporary) {
   StringRef OutputPath = getFrontendOpts().OutputFile;
+  std::optional> PathStorage;
   if (OutputPath.empty()) {
 if (InFile == "-" || Extension.empty()) {
   OutputPath = "-";
 } else {
-  SmallString<128> PathStorage = InFile;
-  llvm::sys::path::replace_extension(PathStorage, Extension);
-  OutputPath = PathStorage;
+  PathStorage.emplace(InFile);
+  llvm::sys::path::replace_extension(*PathStorage, Extension);
+  OutputPath = *PathStorage;
 }
   }
 



___
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.

This caused an issue in the libc benchmarks, fix here: 2a261a7b5764 



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 Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: llvm/include/llvm/ADT/Triple.h:11
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/AArch64TargetParser.h`.
 ///

Invalid comment.


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] D138655: [clang-tidy] Fix `cppcoreguidelines-init-variables` for invalid vardecl

2022-12-20 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 484210.
Sockke added a comment.

Added comments


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

https://reviews.llvm.org/D138655

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
@@ -1,6 +1,16 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- 
-fno-delayed-template-parsing -fexceptions
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables -fix-errors %t 
-- -- -fno-delayed-template-parsing -fexceptions
 // CHECK-FIXES: {{^}}#include 
 
+// Header file error causes stl container variable to be invalid int vardecl
+#include "unknown.h" 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: error: 'unknown.h' file not found 
[clang-diagnostic-error]
+
+namespace std {
+template 
+struct vector {
+  vector();
+};
+
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
 
@@ -124,3 +134,13 @@
   Fruit fruit;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'fruit' is not 
initialized [cppcoreguidelines-init-variables]
 }
+
+void test_clang_diagnostic_error() {
+  int a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'a' is not initialized 
[cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int a = 0;{{$}}
+
+  // The stl object has been initialized
+  std::vector arr;
+  // CHECK-FIXES-NOT: {{^}}  std::vector arr = 0;{{$}}
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -60,6 +60,9 @@
   const ASTContext &Context = *Result.Context;
   const SourceManager &Source = Context.getSourceManager();
 
+  // Header file error causes the stl container variable to be an invalid int 
vardecl
+  if (MatchedDecl->isInvalidDecl())
+return;
   // We want to warn about cases where the type name
   // comes from a macro like this:
   //


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/init-variables.cpp
@@ -1,6 +1,16 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t -- -- -fno-delayed-template-parsing -fexceptions
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables -fix-errors %t -- -- -fno-delayed-template-parsing -fexceptions
 // CHECK-FIXES: {{^}}#include 
 
+// Header file error causes stl container variable to be invalid int vardecl
+#include "unknown.h" 
+// CHECK-MESSAGES: :[[@LINE-1]]:10: error: 'unknown.h' file not found [clang-diagnostic-error]
+
+namespace std {
+template 
+struct vector {
+  vector();
+};
+
 // Ensure that function declarations are not changed.
 void some_func(int x, double d, bool b, const char *p);
 
@@ -124,3 +134,13 @@
   Fruit fruit;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'fruit' is not initialized [cppcoreguidelines-init-variables]
 }
+
+void test_clang_diagnostic_error() {
+  int a;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'a' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int a = 0;{{$}}
+
+  // The stl object has been initialized
+  std::vector arr;
+  // CHECK-FIXES-NOT: {{^}}  std::vector arr = 0;{{$}}
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -60,6 +60,9 @@
   const ASTContext &Context = *Result.Context;
   const SourceManager &Source = Context.getSourceManager();
 
+  // Header file error causes the stl container variable to be an invalid int vardecl
+  if (MatchedDecl->isInvalidDecl())
+return;
   // We want to warn about cases where the type name
   // comes from a macro like this:
   //
___
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 Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang-tools-extra/clangd/Quality.cpp:306
   if (const NamedDecl *ND = SemaResult.getDeclaration()) {
+if (hasUnstableLinkage(ND))
+  return;

nridge wrote:
> Would it be better to reuse [this getSymbolID 
> overload](https://searchfox.org/llvm/rev/ec87b7231586865f7b0adfe22a0d056e40ae9264/clang-tools-extra/clangd/CodeComplete.cpp#606-621)
>  instead? (Would require plumbing in a SourceManager to this call site.)
Ah, that requirement is unfortunate. It'd be nice if it worked but not worth 
changing signature I think.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140379

___
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 Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 484212.

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

https://reviews.llvm.org/D135750

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Context.cpp
  clang/lib/AST/Interp/Descriptor.cpp
  clang/lib/AST/Interp/Descriptor.h
  clang/lib/AST/Interp/EvalEmitter.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/InterpBlock.h
  clang/lib/AST/Interp/InterpFrame.cpp
  clang/lib/AST/Interp/InterpFrame.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Pointer.h
  clang/lib/AST/Interp/Program.cpp
  clang/lib/AST/Interp/Program.h
  clang/test/AST/Interp/cxx20.cpp
  clang/test/AST/Interp/literals.cpp
  clang/test/AST/Interp/loops.cpp

Index: clang/test/AST/Interp/loops.cpp
===
--- clang/test/AST/Interp/loops.cpp
+++ clang/test/AST/Interp/loops.cpp
@@ -5,6 +5,7 @@
 
 // ref-no-diagnostics
 // expected-no-diagnostics
+// expected-cpp20-no-diagnostics
 
 namespace WhileLoop {
   constexpr int f() {
@@ -165,8 +166,6 @@
   static_assert(f5(true) == 8, "");
   static_assert(f5(false) == 5, "");
 
-  /// FIXME: This should be accepted in C++20 but is currently being rejected
-  ///   because the variable declaration doesn't have an initializier.
 #if __cplusplus >= 202002L
   constexpr int f6() {
 int i;
@@ -176,7 +175,7 @@
 } while (true);
 return i;
   }
-  static_assert(f6() == 5, ""); // expected-cpp20-error {{not an integral constant}}
+  static_assert(f6() == 5, "");
 #endif
 
 #if 0
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -407,8 +407,7 @@
 return 1;
   }
   static_assert(uninit(), ""); // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'uninit()'}} \
-   // expected-error {{not an integral constant expression}}
+   // ref-note {{in call to 'uninit()'}}
 
   constexpr int OverFlow() { // ref-error {{never produces a constant expression}}
 int a = INT_MAX;
Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -56,33 +56,51 @@
 }
 static_assert(pointerAssign2() == 12, "");
 
-
 constexpr int unInitLocal() {
   int a;
-  return a; // ref-note{{read of uninitialized object}}
+  return a; // ref-note {{read of uninitialized object}} \
+// expected-note {{read of object outside its lifetime}}
+// FIXME: ^^^ Wrong diagnostic.
 }
-static_assert(unInitLocal() == 0, ""); // expected-error {{not an integral constant expression}} \
-   // ref-error {{not an integral constant expression}} \
-   // ref-note {{in call to 'unInitLocal()'}}
-
-/// TODO: The example above is correctly rejected by the new constexpr
-///   interpreter, but for the wrong reasons. We don't reject it because
-///   it is an uninitialized read, we reject it simply because
-///   the local variable does not have an initializer.
-///
-///   The code below should be accepted but is also being rejected
-///   right now.
-#if 0
+static_assert(unInitLocal() == 0, ""); // ref-error {{not an integral constant expression}} \
+   // ref-note {{in call to 'unInitLocal()'}} \
+   // expected-error {{not an integral constant expression}} \
+   // expected-note {{in call to 'unInitLocal()'}} \
+
 constexpr int initializedLocal() {
   int a;
-  int b;
-
   a = 20;
   return a;
 }
 static_assert(initializedLocal() == 20);
 
-/// Similar here, but the uninitialized local is passed as a function parameter.
+constexpr int initializedLocal2() {
+  int a[2];
+  return *a; // expected-note {{read of object outside its lifetime}} \
+ // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+}
+static_assert(initializedLocal2() == 20); // expected-error {{not an integral constant expression}} \
+  // expected-note {{in call to}} \
+  // ref-error {{not an integral constant expression}} \
+  // ref-note {{in call to}}
+
+
+struct Int { int a; };
+constexpr int initializedLocal3() {
+  Int i;
+  return i.a; // expected-note {{read of object outside its lifetime}} \
+  // ref-note {{read of uninitialized object is not allowed in a constant expression}}
+}
+static_assert(initializedLocal3() == 20); // expected-error {{not an integral constant expression}} \
+  // ex

[PATCH] D140294: clang: Replace implementation of __builtin_isnormal

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

In D140294#4007073 , @sepavloff wrote:

> This change can have negative consequences in some cases. Some targets have 
> dedicated instruction to test FP class and often this instruction is faster 
> than arithmetic operations. Replacement of one operation with two arithmetic 
> and two logic plus cost of FP constant materialization does not provide any 
> visible benefit.

Not sure what you're talking about, there's no class call here. Besides, 
optimal codegen is not clang's concern

> One of advantages that llvm.is_fpclass provides is the possibility for a 
> target to use FCLASS instruction if it is available. Besides, llvm.is_fpclass 
> incapsulates semantics of a class check, which is not identical to compare 
> operations. Keeping the class checks in IR can facilitate FP-specific 
> optimizations which provide different handing depending on possible FP 
> classes. Fast math is one example, denormals is another.

It's almost but not quite the same. The middle end can swap back to fcmp as 
long as we don't have FP exceptions to worry about (in the denormal case we can 
reform compares against 0/smallest_normal depending on the known denormal 
mode). I have patches ready to swap between all of these cases

> I would propose to generate llvm.is_fpclass for all classification intrinsics 
> (see D137811 ). Targets then may lower the 
> intrinsic in a way most suitable way depending on ISA.

Right, I think clang emitting is.fpclass and letting the middle and and backend 
fold back into fcmp as legal is a reasonable strategy. In cases surrounding 
denormals we just need to know the floating point mode. The possible downside 
to always emitting class upfront in clang is you immediately lose fast math 
flags (I'm not entirely sure having fast math flags on fcmp is a good idea 
though)


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

https://reviews.llvm.org/D140294

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


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

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

Additional stream handling functions are added.
These are partially evaluated by StreamChecker, result of the addition is
check for more preconditions and construction of success and failure branches
with specific errno handling.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140387

Files:
  clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-vs-stream-checker.c

Index: clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
===
--- clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
+++ clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
@@ -45,12 +45,13 @@
   clang_analyzer_eval(x <= 10); // \
  // stream-warning{{TRUE}} \
  // stdLib-warning{{TRUE}} \
- // both-warning{{TRUE}} \
+ // both-warning{{TRUE}}
 
   clang_analyzer_eval(x == 10); // \
   // stream-warning{{TRUE}} \
   // stream-warning{{FALSE}} \
-  // stdLib-warning{{UNKNOWN}} \
+  // stdLib-warning{{TRUE}} \
+  // stdLib-warning{{FALSE}} \
   // both-warning{{TRUE}} \
   // both-warning{{FALSE}}
 
Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -7,6 +7,12 @@
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple i686-unknown-linux 2>&1 | FileCheck %s
 
+// CHECK: Loaded summary for: FILE *fopen(const char *restrict pathname, const char *restrict mode)
+// CHECK: Loaded summary for: FILE *tmpfile(void)
+// CHECK: Loaded summary for: FILE *freopen(const char *restrict pathname, const char *restrict mode, FILE *restrict stream)
+// CHECK: Loaded summary for: int fclose(FILE *stream)
+// CHECK: Loaded summary for: int fseek(FILE *stream, long offset, int whence)
+// CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: long a64l(const char *str64)
 // CHECK: Loaded summary for: char *l64a(long value)
 // CHECK: Loaded summary for: int access(const char *pathname, int amode)
@@ -63,7 +69,6 @@
 // CHECK: Loaded summary for: void rewinddir(DIR *dir)
 // CHECK: Loaded summary for: void seekdir(DIR *dirp, long loc)
 // CHECK: Loaded summary for: int rand_r(unsigned int *seedp)
-// CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: int fseeko(FILE *stream, off_t offset, int whence)
 // CHECK: Loaded summary for: off_t ftello(FILE *stream)
 // CHECK: Loaded summary for: void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
@@ -121,6 +126,16 @@
 // CHECK: Loaded summary for: int pthread_mutex_trylock(pthread_mutex_t *mutex)
 // CHECK: Loaded summary for: int pthread_mutex_unlock(pthread_mutex_t *mutex)
 
+typedef struct {
+  int x;
+} FILE;
+FILE *fopen(const char *restrict pathname, const char *restrict mode);
+FILE *tmpfile(void);
+FILE *freopen(const char *restrict pathname, const char *restrict mode,
+  FILE *restrict stream);
+int fclose(FILE *stream);
+int fseek(FILE *stream, long offset, int whence);
+int fileno(FILE *stream);
 long a64l(const char *str64);
 char *l64a(long value);
 int access(const char *pathname, int amode);
@@ -181,9 +196,6 @@
 DIR *opendir(const char *name);
 DIR *fdopendir(int fd);
 int isatty(int fildes);
-typedef struct {
-  int x;
-} FILE;
 FILE *popen(const char *command, const char *type);
 int pclose(FILE *stream);
 int close(int fildes);
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -254,6 +254,8 @@
 bool CannotBeNull = true;
 
   public:
+NotNullConstraint(ArgNo ArgN, bool CannotBeNull = true)
+: ValueConstraint(ArgN), CannotBeNull(CannotBeNull) {}
 std::string describe(DescriptionKind DK, ProgramStateRef State,
  const Summary &Summary) const override;
 StringRef getName() const override { return "NonNull"; }
@@ -285,6 +287,45 @@
 }
   };
 
+  class NotZeroConstraint : public ValueConstraint {
+using ValueConstraint::ValueConstraint;

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

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



Comment at: llvm/include/llvm/ADT/Triple.h:11
+/// This header is deprecated in favour of
+/// `llvm/TargetParser/AArch64TargetParser.h`.
 ///

barannikov88 wrote:
> Invalid comment.
Fixed in https://reviews.llvm.org/rG741396af16d1


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] D139973: [llvm] Make llvm::Any similar to std::any

2022-12-20 Thread Sebastian Neubauer 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 rGbb7940e25f6c: [llvm] Make llvm::Any similar to std::any 
(authored by sebastian-ne).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139973

Files:
  clang/unittests/Tooling/RefactoringTest.cpp
  clang/unittests/Tooling/TransformerTest.cpp
  lldb/include/lldb/Core/RichManglingContext.h
  llvm/include/llvm/ADT/Any.h
  llvm/lib/CodeGen/MachinePassManager.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
  llvm/lib/Transforms/Scalar/LoopPassManager.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/unittests/ADT/AnyTest.cpp
  llvm/unittests/IR/PassBuilderCallbacksTest.cpp

Index: llvm/unittests/IR/PassBuilderCallbacksTest.cpp
===
--- llvm/unittests/IR/PassBuilderCallbacksTest.cpp
+++ llvm/unittests/IR/PassBuilderCallbacksTest.cpp
@@ -290,17 +290,17 @@
   return std::string(name);
 }
 
-template <> std::string getName(const llvm::Any &WrappedIR) {
-  if (any_isa(WrappedIR))
-return any_cast(WrappedIR)->getName().str();
-  if (any_isa(WrappedIR))
-return any_cast(WrappedIR)->getName().str();
-  if (any_isa(WrappedIR))
-return any_cast(WrappedIR)->getName().str();
-  if (any_isa(WrappedIR))
-return any_cast(WrappedIR)->getName().str();
-  if (any_isa(WrappedIR))
-return any_cast(WrappedIR)->getName();
+template <> std::string getName(const Any &WrappedIR) {
+  if (const auto *const *M = any_cast(&WrappedIR))
+return (*M)->getName().str();
+  if (const auto *const *F = any_cast(&WrappedIR))
+return (*F)->getName().str();
+  if (const auto *const *L = any_cast(&WrappedIR))
+return (*L)->getName().str();
+  if (const auto *const *L = any_cast(&WrappedIR))
+return (*L)->getName().str();
+  if (const auto *const *C = any_cast(&WrappedIR))
+return (*C)->getName();
   return "";
 }
 /// Define a custom matcher for objects which support a 'getName' method.
Index: llvm/unittests/ADT/AnyTest.cpp
===
--- llvm/unittests/ADT/AnyTest.cpp
+++ llvm/unittests/ADT/AnyTest.cpp
@@ -24,55 +24,55 @@
 
   // An empty Any is not anything.
   EXPECT_FALSE(A.has_value());
-  EXPECT_FALSE(any_isa(A));
+  EXPECT_FALSE(any_cast(&A));
 
   // An int is an int but not something else.
   EXPECT_TRUE(B.has_value());
-  EXPECT_TRUE(any_isa(B));
-  EXPECT_FALSE(any_isa(B));
+  EXPECT_TRUE(any_cast(&B));
+  EXPECT_FALSE(any_cast(&B));
 
   EXPECT_TRUE(C.has_value());
-  EXPECT_TRUE(any_isa(C));
+  EXPECT_TRUE(any_cast(&C));
 
   // A const char * is a const char * but not an int.
   EXPECT_TRUE(D.has_value());
-  EXPECT_TRUE(any_isa(D));
-  EXPECT_FALSE(any_isa(D));
+  EXPECT_TRUE(any_cast(&D));
+  EXPECT_FALSE(any_cast(&D));
 
   // A double is a double but not a float.
   EXPECT_TRUE(E.has_value());
-  EXPECT_TRUE(any_isa(E));
-  EXPECT_FALSE(any_isa(E));
+  EXPECT_TRUE(any_cast(&E));
+  EXPECT_FALSE(any_cast(&E));
 
   // After copy constructing from an int, the new item and old item are both
   // ints.
   llvm::Any F(B);
   EXPECT_TRUE(B.has_value());
   EXPECT_TRUE(F.has_value());
-  EXPECT_TRUE(any_isa(F));
-  EXPECT_TRUE(any_isa(B));
+  EXPECT_TRUE(any_cast(&F));
+  EXPECT_TRUE(any_cast(&B));
 
   // After move constructing from an int, the new item is an int and the old one
   // isn't.
   llvm::Any G(std::move(C));
   EXPECT_FALSE(C.has_value());
   EXPECT_TRUE(G.has_value());
-  EXPECT_TRUE(any_isa(G));
-  EXPECT_FALSE(any_isa(C));
+  EXPECT_TRUE(any_cast(&G));
+  EXPECT_FALSE(any_cast(&C));
 
   // After copy-assigning from an int, the new item and old item are both ints.
   A = F;
   EXPECT_TRUE(A.has_value());
   EXPECT_TRUE(F.has_value());
-  EXPECT_TRUE(any_isa(A));
-  EXPECT_TRUE(any_isa(F));
+  EXPECT_TRUE(any_cast(&A));
+  EXPECT_TRUE(any_cast(&F));
 
   // After move-assigning from an int, the new item and old item are both ints.
   B = std::move(G);
   EXPECT_TRUE(B.has_value());
   EXPECT_FALSE(G.has_value());
-  EXPECT_TRUE(any_isa(B));
-  EXPECT_FALSE(any_isa(G));
+  EXPECT_TRUE(any_cast(&B));
+  EXPECT_FALSE(any_cast(&G));
 }
 
 TEST(AnyTest, GoodAnyCast) {
Index: llvm/lib/Transforms/Utils/Debugify.cpp
===
--- llvm/lib/Transforms/Utils/Debugify.cpp
+++ llvm/lib/Transforms/Utils/Debugify.cpp
@@ -1031,19 +1031,19 @@
   PIC.registerBeforeNonSkippedPassCallback([this](StringRef P, Any IR) {
 if (isIgnoredPass(P))
   return;
-if (any_isa(IR))
-  applyDebugify(*const_cast(any_cast(IR)),
+if (const auto **F = any_cast(&IR))
+  applyDebugify(*const_cast(*F),
 Mode, DebugInfoBeforePass, P);
-else if (any_isa(IR))
-  applyDebugify(*const_cast(

[clang] bb7940e - [llvm] Make llvm::Any similar to std::any

2022-12-20 Thread Sebastian Neubauer via cfe-commits

Author: Sebastian Neubauer
Date: 2022-12-20T13:28:30+01:00
New Revision: bb7940e25f6ca201ca57943544016390f1d2e504

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

LOG: [llvm] Make llvm::Any similar to std::any

This facilitates replacing llvm::Any with std::any.
- Deprecate any_isa in favor of using any_cast(Any*) and checking for
  nullptr because C++17 has no any_isa.
- Remove the assert from any_cast(Any*), so it returns nullptr if the
  type is not correct. This aligns it with std::any_cast(any*).

Use any_cast(Any*) throughout LLVM instead of checks with any_isa.

This is the first part outlined in
https://discourse.llvm.org/t/rfc-switching-from-llvm-any-to-std-any/67176

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

Added: 


Modified: 
clang/unittests/Tooling/RefactoringTest.cpp
clang/unittests/Tooling/TransformerTest.cpp
lldb/include/lldb/Core/RichManglingContext.h
llvm/include/llvm/ADT/Any.h
llvm/lib/CodeGen/MachinePassManager.cpp
llvm/lib/IR/LLVMContextImpl.h
llvm/lib/Passes/StandardInstrumentations.cpp
llvm/lib/Transforms/IPO/SampleProfileProbe.cpp
llvm/lib/Transforms/Scalar/LoopPassManager.cpp
llvm/lib/Transforms/Utils/Debugify.cpp
llvm/unittests/ADT/AnyTest.cpp
llvm/unittests/IR/PassBuilderCallbacksTest.cpp

Removed: 




diff  --git a/clang/unittests/Tooling/RefactoringTest.cpp 
b/clang/unittests/Tooling/RefactoringTest.cpp
index e38afc148a7b8..c7a02e195d04a 100644
--- a/clang/unittests/Tooling/RefactoringTest.cpp
+++ b/clang/unittests/Tooling/RefactoringTest.cpp
@@ -1288,7 +1288,7 @@ TEST_F(AtomicChangeTest, InsertAfterWithInvalidLocation) {
 TEST_F(AtomicChangeTest, Metadata) {
   AtomicChange Change(Context.Sources, DefaultLoc, 17);
   const llvm::Any &Metadata = Change.getMetadata();
-  ASSERT_TRUE(llvm::any_isa(Metadata));
+  ASSERT_TRUE(llvm::any_cast(&Metadata));
   EXPECT_EQ(llvm::any_cast(Metadata), 17);
 }
 

diff  --git a/clang/unittests/Tooling/TransformerTest.cpp 
b/clang/unittests/Tooling/TransformerTest.cpp
index 6d6ed33d8fd67..4d5e22d944988 100644
--- a/clang/unittests/Tooling/TransformerTest.cpp
+++ b/clang/unittests/Tooling/TransformerTest.cpp
@@ -806,7 +806,7 @@ TEST_F(TransformerTest, WithMetadata) {
   "clang-tool", std::make_shared(), {}));
   ASSERT_EQ(Changes.size(), 1u);
   const llvm::Any &Metadata = Changes[0].getMetadata();
-  ASSERT_TRUE(llvm::any_isa(Metadata));
+  ASSERT_TRUE(llvm::any_cast(&Metadata));
   EXPECT_THAT(llvm::any_cast(Metadata), 5);
 }
 

diff  --git a/lldb/include/lldb/Core/RichManglingContext.h 
b/lldb/include/lldb/Core/RichManglingContext.h
index 9636b7898f8f5..3b79924e88a9a 100644
--- a/lldb/include/lldb/Core/RichManglingContext.h
+++ b/lldb/include/lldb/Core/RichManglingContext.h
@@ -87,8 +87,8 @@ class RichManglingContext {
   /// can't access CPlusPlusLanguage::MethodName from within the header.
   template  static ParserT *get(llvm::Any parser) {
 assert(parser.has_value());
-assert(llvm::any_isa(parser));
-return llvm::any_cast(parser);
+assert(llvm::any_cast(&parser));
+return *llvm::any_cast(&parser);
   }
 };
 

diff  --git a/llvm/include/llvm/ADT/Any.h b/llvm/include/llvm/ADT/Any.h
index 934dfc142d376..acb7101a5145f 100644
--- a/llvm/include/llvm/ADT/Any.h
+++ b/llvm/include/llvm/ADT/Any.h
@@ -107,6 +107,13 @@ class LLVM_EXTERNAL_VISIBILITY Any {
   void reset() { Storage.reset(); }
 
 private:
+  // Only used for the internal llvm::Any implementation
+  template  bool isa() const {
+if (!Storage)
+  return false;
+return Storage->id() == &Any::TypeId>::Id;
+  }
+
   template  friend T any_cast(const Any &Value);
   template  friend T any_cast(Any &Value);
   template  friend T any_cast(Any &&Value);
@@ -119,36 +126,37 @@ class LLVM_EXTERNAL_VISIBILITY Any {
 
 template  char Any::TypeId::Id = 0;
 
-template  bool any_isa(const Any &Value) {
-  if (!Value.Storage)
-return false;
-  return Value.Storage->id() == &Any::TypeId>::Id;
+template 
+LLVM_DEPRECATED("Use any_cast(Any*) != nullptr instead", "any_cast")
+bool any_isa(const Any &Value) {
+  return Value.isa();
 }
 
 template  T any_cast(const Any &Value) {
+  assert(Value.isa() && "Bad any cast!");
   return static_cast(*any_cast>(&Value));
 }
 
 template  T any_cast(Any &Value) {
+  assert(Value.isa() && "Bad any cast!");
   return static_cast(*any_cast>(&Value));
 }
 
 template  T any_cast(Any &&Value) {
+  assert(Value.isa() && "Bad any cast!");
   return static_cast(std::move(*any_cast>(&Value)));
 }
 
 template  const T *any_cast(const Any *Value) {
   using U = remove_cvref_t;
-  assert(Value && any_isa(*Value) && "Bad any cast!");
-  if (!Value || !any_isa(*Value))
+  if (!Value || !Value->isa())
 return nullptr;
   return &static_cast &>(*Value-

[PATCH] D80144: [clang-format] @lefticus just taught the world how to use [[unlikely]] but we forgot to teach clang-format

2022-12-20 Thread Roel Vercammen via Phabricator via cfe-commits
Roelio81 added a comment.
Herald added a project: All.

This change also has impact which was undesired on our code base as it now 
considers all attributes to be "bound" to the if-expression rather than to the 
if-body.
For example, we had this in our code base

  if (condition)
 [[maybe_unused]] auto result = x->setValue(0.0);

This became the following after upgrading from clang 10:

  if (condition) [[maybe_unused]] 
 auto result = x->setValue(0.0);

The [[maybe_unused]] is actually referring to the result variable, hence I 
think it makes more sense to have it on the second line.
We worked around the issue by adding curly braces, i.e.,

  if (condition)
  {
 [[maybe_unused]] auto result = x->setValue(0.0);
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80144

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


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

2022-12-20 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 484217.
4vtomat added a comment.

Update to final draft 20221208


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/rv64zvkb.s
  llvm/test/MC/RISCV/rvv/rv64zvkg.s
  llvm/test/MC/RISCV/rvv/rv64zvknh.s
  llvm/test/MC/RISCV/rvv/rv64zvkns.s
  llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
  llvm/test/MC/RISCV/rvv/rv64zvksed.s
  llvm/test/MC/RISCV/rvv/rv64zvksed_invalid.s
  llvm/test/MC/RISCV/rvv/rv64zvksh.s

Index: llvm/test/MC/RISCV/rvv/rv64zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/rv64zvksed_invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksed_invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv64 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/rv64zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vaeskf1.vi v10, v9, 0
+# CHECK-ERROR: immediate must be an integer in the range [1, 10]
+
+vaeskf2.vi v10, v9, 0
+# CHECK-ERROR: immediate must be an integer in the range [2, 14]
Index: llvm/test/MC/RISCV/rvv/rv64zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv

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

2022-12-20 Thread Tomas Matheson via Phabricator via cfe-commits
tmatheson accepted this revision.
tmatheson added a comment.
This revision is now accepted and ready to land.

Couple of nits, since you will be updating this anyway after dropping D140221 
, otherwise LGTM.




Comment at: clang/lib/Sema/SemaChecking.cpp:8297
  << Arg->getSourceRange();
   } else if (IsAArch64Builtin && Fields.size() == 1) {
+// If this is a write ...

It might be more readable to outline this whole branch and remove the redundant 
"else".



Comment at: clang/lib/Sema/SemaChecking.cpp:8298
   } else if (IsAArch64Builtin && Fields.size() == 1) {
-// If the register name is one of those that appear in the condition below
-// and the special register builtin being used is one of the write 
builtins,
-// then we require that the argument provided for writing to the register
-// is an integer constant expression. This is because it will be lowered to
-// an MSR (immediate) instruction, so we need to know the immediate at
-// compile time.
+// If this is a write ...
 if (TheCall->getNumArgs() != 2)

This comment style is a bit confusing; the actual code says if(NOT a write) 
return false; imo the code is readable enough without them.



Comment at: clang/lib/Sema/SemaChecking.cpp:8334-8340
+if (MaxLimit)
+  return SemaBuiltinConstantArgRange(TheCall, 1, 0, MaxLimit.value());
+
+// Otherwise, no checking is needed as we we lower to some kind of MSR
+// (register) rather than an MSR (immediate).
+return false;
   }

nit: stick to early return pattern



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] D140389: [NFC][RISCV] Rename data member 'DefaultPolicy' to 'PolicyAttrs'

2022-12-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The naming here is strange since the value may still be updated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140389

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,14 +163,14 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized DefaultPolicy as TU/TUMU in CodeGen function.
-  if (!RVVI->getDefaultPolicy().isTUPolicy() &&
-  !RVVI->getDefaultPolicy().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
+  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
+  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
+  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
   !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
+OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  DefaultPolicy = " << RVVI->getDefaultPolicyBits() << ";\n";
+OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
@@ -191,13 +191,12 @@
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end() - 1);\n";
   if (RVVI->hasPolicyOperand())
 OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(),"
-  " DefaultPolicy));\n";
-  if (RVVI->hasMaskedOffOperand() &&
-  RVVI->getDefaultPolicy().isTAMAPolicy())
+  " PolicyAttrs));\n";
+  if (RVVI->hasMaskedOffOperand() && RVVI->getPolicyAttrs().isTAMAPolicy())
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
   // Masked reduction cases.
   if (!RVVI->hasMaskedOffOperand() && RVVI->hasPassthruOperand() &&
-  RVVI->getDefaultPolicy().isTAMAPolicy())
+  RVVI->getPolicyAttrs().isTAMAPolicy())
 OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
 } else {
   OS << "  std::rotate(Ops.begin(), Ops.begin() + 1, Ops.end());\n";
@@ -205,9 +204,8 @@
   } else {
 if (RVVI->hasPolicyOperand())
   OS << "  Ops.push_back(ConstantInt::get(Ops.back()->getType(), "
-"DefaultPolicy));\n";
-else if (RVVI->hasPassthruOperand() &&
- RVVI->getDefaultPolicy().isTAPolicy())
+"PolicyAttrs));\n";
+else if (RVVI->hasPassthruOperand() && RVVI->getPolicyAttrs().isTAPolicy())
   OS << "  Ops.insert(Ops.begin(), llvm::UndefValue::get(ResultType));\n";
   }
 
@@ -444,7 +442,7 @@
   llvm::stable_sort(Defs, [](const std::unique_ptr &A,
  const std::unique_ptr &B) {
 if (A->getIRName() == B->getIRName())
-  return (A->getDefaultPolicy() < B->getDefaultPolicy());
+  return (A->getPolicyAttrs() < B->getPolicyAttrs());
 return (A->getIRName() < B->getIRName());
   });
 
@@ -458,7 +456,7 @@
 StringRef CurIRName = Def->getIRName();
 if (CurIRName != PrevDef->getIRName() ||
 (Def->getManualCodegen() != PrevDef->getManualCodegen()) ||
-(Def->getDefaultPolicy() != PrevDef->getDefaultPolicy())) {
+(Def->getPolicyAttrs() != PrevDef->getPolicyAttrs())) {
   emitCodeGenSwitchBody(PrevDef, OS);
 }
 PrevDef = Def.get();
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -848,12 +848,11 @@
 bool SupportOverloading, bool HasBuiltinAlias, StringRef ManualCodegen,
 const RVVTypes &OutInTypes, const std::vector &NewIntrinsicTypes,
 const std::vector &RequiredFeatures, unsigned NF,
-Policy NewDefaultPolicy, bool IsPrototypeDefaultTU)
+Policy NewPolicyAttrs, bool IsPrototypeDefaultTU)
 : IRName(IRName), IsMasked(IsMasked),
   HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL), Scheme(Scheme),
   SupportOverloading(SupportOverloading), Ha

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

2022-12-20 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Just throwing out the question here, I would be happy to rename it to anything 
else that makes sense rather than the current.


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] D137838: [Support] Move TargetParsers to new component

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

Another fixup for the llvm examples was required, landed in 
https://reviews.llvm.org/rG16c4c4e04c14


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] D138807: [RISCV] Support vector crypto extension ISA string and assembly

2022-12-20 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 484224.
4vtomat added a comment.

Address Eop's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/rv64zvkb.s
  llvm/test/MC/RISCV/rvv/rv64zvkg.s
  llvm/test/MC/RISCV/rvv/rv64zvknh.s
  llvm/test/MC/RISCV/rvv/rv64zvkns.s
  llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
  llvm/test/MC/RISCV/rvv/rv64zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/rv64zvksed.s
  llvm/test/MC/RISCV/rvv/rv64zvksh.s

Index: llvm/test/MC/RISCV/rvv/rv64zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/rv64zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/rv64zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv64 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vaeskf1.vi v10, v9, 0
+# CHECK-ERROR: immediate must be an integer in the range [1, 10]
+
+vaeskf2.vi v10, v9, 0
+# CHECK-ERROR: immediate must be an integer in the range [2, 14]
Index: llvm/test/MC/RISCV/rvv/rv64zvkns.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zv

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

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

Ken has updated spec to clarify requirements of those vector crypto extensions: 
https://github.com/riscv/riscv-crypto/commit/40695306f628e6dc764d1d0f35392eac792d2c3b

  These Vector Crypto Extensions can be built on any RISC-V base. However, 
XLEN=32 implementations
  will only be able to provide 32 bit values to the .vx vector-scalar 
instructions. 
  
  With the exception of Zvknhb, each of these Vector Crypto Extensions can be 
build on _any_ 
  base Vector Extension, embedded (Zve*) or application ("V"). Zvknhb requires 
ELEN=64 and therefore cannot be implemented on a Zve32* base.
  
  While the Zvkb extension can be built on an Zve32* base, the vclmul[h] 
instructions will not be
  supported in such a case as they require SEW=64.
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

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


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

2022-12-20 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 484226.
4vtomat added a comment.

Correct OPERAND_LAST_RISCV_IMM in OperandType


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138807

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrFormats.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZvk.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rvv/rv64zvkb.s
  llvm/test/MC/RISCV/rvv/rv64zvkg.s
  llvm/test/MC/RISCV/rvv/rv64zvknh.s
  llvm/test/MC/RISCV/rvv/rv64zvkns.s
  llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
  llvm/test/MC/RISCV/rvv/rv64zvksed-invalid.s
  llvm/test/MC/RISCV/rvv/rv64zvksed.s
  llvm/test/MC/RISCV/rvv/rv64zvksh.s

Index: llvm/test/MC/RISCV/rvv/rv64zvksh.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksh.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksh  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksh %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm3c.vi v10, v9, 7
+# CHECK-INST: vsm3c.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0xae]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 a5 93 ae   
+
+vsm3me.vv v10, v9, v8
+# CHECK-INST: vsm3me.vv v10, v9, v8
+# CHECK-ENCODING: [0x77,0x25,0x94,0x82]
+# CHECK-ERROR: instruction requires the following: 'Zvksh'
+# CHECK-UNKNOWN: 77 25 94 82   
Index: llvm/test/MC/RISCV/rvv/rv64zvksed.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksed.s
@@ -0,0 +1,27 @@
+# RUN: llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| FileCheck %s --check-prefixes=CHECK-ENCODING,CHECK-INST
+# RUN: not llvm-mc -triple=riscv64 -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d --mattr=+zve32x --mattr=+experimental-zvksed  - \
+# RUN:| FileCheck %s --check-prefix=CHECK-INST
+# RUN: llvm-mc -triple=riscv64 -filetype=obj --mattr=+zve32x --mattr=+experimental-zvksed %s \
+# RUN:| llvm-objdump -d - | FileCheck %s --check-prefix=CHECK-UNKNOWN
+
+vsm4k.vi v10, v9, 7
+# CHECK-INST: vsm4k.vi v10, v9, 7
+# CHECK-ENCODING: [0x77,0xa5,0x93,0x86]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 a5 93 86   
+
+vsm4r.vv v10, v9
+# CHECK-INST: vsm4r.vv v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa2]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a2   
+
+vsm4r.vs v10, v9
+# CHECK-INST: vsm4r.vs v10, v9
+# CHECK-ENCODING: [0x77,0x25,0x98,0xa6]
+# CHECK-ERROR: instruction requires the following: 'Zvksed'
+# CHECK-UNKNOWN: 77 25 98 a6   
Index: llvm/test/MC/RISCV/rvv/rv64zvksed-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvksed-invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv64 --mattr=+zve32x --mattr=+experimental-zvksed -show-encoding %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vsm4k.vi v10, v9, 8
+# CHECK-ERROR: immediate must be an integer in the range [0, 7]
Index: llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvv/rv64zvkns_invalid.s
@@ -0,0 +1,8 @@
+# RUN: not llvm-mc -triple=riscv64 -show-encoding --mattr=+zve32x --mattr=+experimental-zvkns %s 2>&1 \
+# RUN:| FileCheck %s --check-prefix=CHECK-ERROR
+
+vaeskf1.vi v10, v9, 0
+# CHECK-ERROR: immediate must be an integer in the range [1, 10]
+
+vaeskf2.vi v10, v9, 0
+# CHECK-ERROR: immediate must be an integer in the range [2, 14]
Index: llvm/test/MC/RISCV/rvv/rv64zvkns.s
===
--- /dev/null
+++ llvm/t

[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 reviewer: gamesh411.
Szelethus added a comment.

Some of the changes are also present in D135247 
. I suppose you're in the middle of splitting 
those patches apart and remaking the patch stack?


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.

And a fixup for the compiler-rt symbolizer: 
https://reviews.llvm.org/rGecaab107e4d0


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] D140395: [clang][analyzer] Extend StreamChecker with some new functions.

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

The stream handling functions `ftell`, `rewind`, `fgetpos`, `fsetpos`
are evaluated in the checker more exactly than before.
New tests are added to test behavior of the checker together with
StdLibraryFunctionsChecker. The option ModelPOSIX of that checker
affects if (most of) the stream functions are recognized, and checker
StdLibraryFunctionArgs generates warnings if constraints for arguments
are not satisfied. The state of `errno` is set by StdLibraryFunctionsChecker
too for every case in the stream functions.
StreamChecker works with the stream state only, does not set the errno state,
and is not dependent on other checkers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140395

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator.h
  clang/test/Analysis/stream-errno-note.c
  clang/test/Analysis/stream-errno.c
  clang/test/Analysis/stream-error.c
  clang/test/Analysis/stream-noopen.c

Index: clang/test/Analysis/stream-noopen.c
===
--- /dev/null
+++ clang/test/Analysis/stream-noopen.c
@@ -0,0 +1,157 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.unix.Errno \
+// RUN:   -analyzer-checker=alpha.unix.Stream \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -analyzer-checker=debug.ExprInspection
+
+// enable only StdCLibraryFunctions checker
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=alpha.unix.Errno \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true \
+// RUN:   -analyzer-checker=debug.ExprInspection
+
+#include "Inputs/system-header-simulator.h"
+#include "Inputs/errno_var.h"
+
+void clang_analyzer_eval(int);
+
+const char *WBuf = "123456789";
+char RBuf[10];
+
+void test_freopen(FILE *F) {
+  F = freopen("xxx", "w", F);
+  if (F) {
+if (errno) {} // expected-warning{{undefined}}
+  } else {
+clang_analyzer_eval(errno != 0); // expected-warning {{TRUE}}
+  }
+}
+
+void test_fread(FILE *F) {
+  size_t Ret = fread(RBuf, 1, 10, F);
+  if (Ret == 10) {
+if (errno) {} // expected-warning{{undefined}}
+  } else {
+clang_analyzer_eval(errno != 0); // expected-warning {{TRUE}}
+  }
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void test_fwrite(FILE *F) {
+  size_t Ret = fwrite(WBuf, 1, 10, F);
+  if (Ret == 10) {
+if (errno) {} // expected-warning{{undefined}}
+  } else {
+clang_analyzer_eval(errno != 0); // expected-warning {{TRUE}}
+  }
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void test_fclose(FILE *F) {
+  int Ret = fclose(F);
+  if (Ret == 0) {
+if (errno) {} // expected-warning{{undefined}}
+  } else {
+clang_analyzer_eval(Ret == EOF); // expected-warning {{TRUE}}
+clang_analyzer_eval(errno != 0); // expected-warning {{TRUE}}
+  }
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void test_fseek(FILE *F) {
+  int Ret = fseek(F, SEEK_SET, 1);
+  if (Ret == 0) {
+if (errno) {} // expected-warning{{undefined}}
+  } else {
+clang_analyzer_eval(Ret == -1); // expected-warning {{TRUE}}
+clang_analyzer_eval(errno != 0); // expected-warning {{TRUE}}
+  }
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void check_fgetpos(FILE *F) {
+  errno = 0;
+  fpos_t Pos;
+  int Ret = fgetpos(F, &Pos);
+  if (Ret)
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+ // expected-warning@-1{{FALSE}}
+  if (errno) {} // no-warning
+  clang_analyzer_eval(feof(F)); // expected-warning {{UNKNOWN}}
+  clang_analyzer_eval(ferror(F)); // expected-warning {{UNKNOWN}}
+}
+
+void check_fsetpos(FILE *F) {
+  errno = 0;
+  fpos_t Pos;
+  int Ret = fsetpos(F, &Pos);
+  if (Ret)
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+  else
+clang_analyzer_eval(errno == 0); // expected-warning{{TRUE}}
+

[PATCH] D138511: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-20 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

Thanks @efriedma , I'm wait to see if there is any objection before landing it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138511

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


[PATCH] D137790: [clang][analyzer] Remove report of null stream from StreamChecker.

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

The changes D135360  and D135247 
 are now replaced by D140387 
 and D140395 
. The two new patches together add out almost 
the same code as the two old ones, except small differences in comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137790

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


[PATCH] D138511: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-20 Thread Yurong via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGebe530ef7a49: [CodeGen][AArch64] Fix 
AArch64ABIInfo::EmitAAPCSVAArg crash with empty record… (authored by yronglin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138511

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-varargs.c


Index: clang/test/CodeGen/aarch64-varargs.c
===
--- clang/test/CodeGen/aarch64-varargs.c
+++ clang/test/CodeGen/aarch64-varargs.c
@@ -894,4 +894,10 @@
 // CHECK: call void @llvm.va_start(i8* [[VOIDP_THE_LIST]])
 }
 
-
+typedef struct {} empty;
+empty empty_record_test(void) {
+// CHECK-LABEL: define{{.*}} void @empty_record_test()
+  return va_arg(the_list, empty);
+// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds 
(%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0)
+// CHECK: [[ADDR:%[a-z._0-9]+]] = bitcast i8* [[GR_OFFS]] to %struct.empty*
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5998,6 +5998,16 @@
CodeGenFunction &CGF) const {
   ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true,
CGF.CurFnInfo->getCallingConvention());
+  // Empty records are ignored for parameter passing purposes.
+  if (AI.isIgnore()) {
+uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8;
+CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
+VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy);
+auto *Load = CGF.Builder.CreateLoad(VAListAddr);
+Address Addr = Address(Load, CGF.Int8Ty, SlotSize);
+return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+  }
+
   bool IsIndirect = AI.isIndirect();
 
   llvm::Type *BaseTy = CGF.ConvertType(Ty);


Index: clang/test/CodeGen/aarch64-varargs.c
===
--- clang/test/CodeGen/aarch64-varargs.c
+++ clang/test/CodeGen/aarch64-varargs.c
@@ -894,4 +894,10 @@
 // CHECK: call void @llvm.va_start(i8* [[VOIDP_THE_LIST]])
 }
 
-
+typedef struct {} empty;
+empty empty_record_test(void) {
+// CHECK-LABEL: define{{.*}} void @empty_record_test()
+  return va_arg(the_list, empty);
+// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds (%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0)
+// CHECK: [[ADDR:%[a-z._0-9]+]] = bitcast i8* [[GR_OFFS]] to %struct.empty*
+}
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -5998,6 +5998,16 @@
CodeGenFunction &CGF) const {
   ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true,
CGF.CurFnInfo->getCallingConvention());
+  // Empty records are ignored for parameter passing purposes.
+  if (AI.isIgnore()) {
+uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8;
+CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
+VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy);
+auto *Load = CGF.Builder.CreateLoad(VAListAddr);
+Address Addr = Address(Load, CGF.Int8Ty, SlotSize);
+return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+  }
+
   bool IsIndirect = AI.isIndirect();
 
   llvm::Type *BaseTy = CGF.ConvertType(Ty);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ebe530e - [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-20 Thread via cfe-commits

Author: yronglin
Date: 2022-12-20T22:06:01+08:00
New Revision: ebe530ef7a49988a531a8928eac3ce0925f1c199

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

LOG: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty 
record type in variadic arg

Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

Open issue: https://github.com/llvm/llvm-project/issues/59034

Reviewed By: rjmccall

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

Added: 


Modified: 
clang/lib/CodeGen/TargetInfo.cpp
clang/test/CodeGen/aarch64-varargs.c

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index bcb0e7b08574..98b54dfb1651 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -5998,6 +5998,16 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address 
VAListAddr, QualType Ty,
CodeGenFunction &CGF) const {
   ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true,
CGF.CurFnInfo->getCallingConvention());
+  // Empty records are ignored for parameter passing purposes.
+  if (AI.isIgnore()) {
+uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8;
+CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
+VAListAddr = CGF.Builder.CreateElementBitCast(VAListAddr, CGF.Int8PtrTy);
+auto *Load = CGF.Builder.CreateLoad(VAListAddr);
+Address Addr = Address(Load, CGF.Int8Ty, SlotSize);
+return CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+  }
+
   bool IsIndirect = AI.isIndirect();
 
   llvm::Type *BaseTy = CGF.ConvertType(Ty);

diff  --git a/clang/test/CodeGen/aarch64-varargs.c 
b/clang/test/CodeGen/aarch64-varargs.c
index ad457750c1e0..e4f54039dff3 100644
--- a/clang/test/CodeGen/aarch64-varargs.c
+++ b/clang/test/CodeGen/aarch64-varargs.c
@@ -894,4 +894,10 @@ void check_start(int n, ...) {
 // CHECK: call void @llvm.va_start(i8* [[VOIDP_THE_LIST]])
 }
 
-
+typedef struct {} empty;
+empty empty_record_test(void) {
+// CHECK-LABEL: define{{.*}} void @empty_record_test()
+  return va_arg(the_list, empty);
+// CHECK: [[GR_OFFS:%[a-z_0-9]+]] = load i8*, i8** getelementptr inbounds 
(%struct.__va_list, %struct.__va_list* @the_list, i32 0, i32 0)
+// CHECK: [[ADDR:%[a-z._0-9]+]] = bitcast i8* [[GR_OFFS]] to %struct.empty*
+}



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


[PATCH] D138511: [CodeGen][AArch64] Fix AArch64ABIInfo::EmitAAPCSVAArg crash with empty record type in variadic arg

2022-12-20 Thread Yurong via Phabricator via cfe-commits
yronglin added a comment.

commit in ebe530ef7a49988a531a8928eac3ce0925f1c199 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138511

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


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

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

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.


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] D140339: [clang-format] Remove special logic for parsing concept definitions.

2022-12-20 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1683
 
-if (Tok->isOneOf(tok::kw_class, tok::kw_enum, tok::kw_concept,
- tok::kw_struct, tok::kw_using)) {
+if (Tok->isOneOf(tok::kw_class, tok::kw_enum, tok::kw_struct,
+ tok::kw_using)) {

rymiel wrote:
> HazardyKnusperkeks wrote:
> > Does this change anything, besides the penalties and by that the wrapping?
> > 
> > While I can live with both, I think we should not format code differently, 
> > if it's not by a bugfix.
> The only changes I could see:
>  - the change in `Context.IsExpression`, which causes the change in penalties;
>  - the fact that a new `AnnotatedLine` isn't created for the body of a 
> `concept` (i.e. the stuff after the equals sign), where as it previously was.
>  - some invalid syntax is formatted differently
> 
> It's very likely I don't have a "sample size" large enough.
> 
> I am also okay with doing both; I made this issue to gauge what is the 
> preferred direction by the reviewers.
Let's hear from @owenpan @MyDeveloperDay 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140339

___
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 a comment.

In D140312#4006106 , @rymiel wrote:

> What if I make this depend on D140339 ? 
> Then this change would no longer impact concept definitions.

Yep, that would be right. It seems I can't put decltype directly in a requires 
clause.


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] D136515: [builtins] Add __builtin_assume_separate_storage.

2022-12-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno requested changes to this revision.
bruno added a comment.
This revision now requires changes to proceed.

Nice, thanks for adding the builtin layer.




Comment at: clang/lib/Sema/SemaChecking.cpp:7808
+/// Handle __builtin_assume_separate_storage. For now this is a no-op, but
+/// eventually we expect an optional multi-arg variadic version (to handle an
+/// excluded range).

Can you prefix this with a `FIXME`/`TODO`?



Comment at: clang/lib/Sema/SemaChecking.cpp:7810
+/// excluded range).
+bool Sema::SemaBuiltinAssumeSeparateStorage(CallExpr *TheCall) { return false; 
}
+

IIUC, seems like there a two pieces here you can already cover as part of this 
patch:

- Check for exact two arguments. If in the future an optional multi-arg 
variadic version is to be supported the checking could be enhanced/changed to 
support that.
- Check both are pointers. I noticed that in the testcase you rely on 
`incompatible integer to pointer conversion` and friends to catch some of 
these, but a more user friendly diagnostic could be explicit about the 
expectations. In case these current error diagnostics you are relying run 
before this sema check, perhaps a note diagnostic could help clarify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136515

___
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 484251.
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));
+  Ops.push_back(ConstantInt::get(Ops.back()->getTyp

[PATCH] D138655: [clang-tidy] Fix `cppcoreguidelines-init-variables` for invalid vardecl

2022-12-20 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

Now that I think a bit better about this I wonder - does it really make sense 
that we increase the complexity of the check to cover for cases where code does 
not compile? If it fails to include a header, there's many other things that 
can possibly go wrong - should clang-tidy checks in general really be defensive 
against that? @njames93 WDYT?


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

https://reviews.llvm.org/D138655

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


[PATCH] D136515: [builtins] Add __builtin_assume_separate_storage.

2022-12-20 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Additionally, this likely deserves an entry in `./clang/docs/ReleaseNotes.rst`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136515

___
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 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


[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)() = &imported_func;
-// expected-error@+1{{must be initialized by a constant expression}}
 constexpr int *constexpr_import_int = &imported_int;
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (Foo::*constexpr_memptr)() = &Foo::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 = &var; // expected-error {{must be initialized by a constant expression}}
+constexpr int *varp = &var;
 
 extern __attribute__((dllimport)) void fun();
 constexpr void (*funp)(void) = &fun; // 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=

[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] 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] 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] 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] 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] 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] 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)() = &imported_func;
-// expected-error@+1{{must be initialized by a constant expression}}
 constexpr int *constexpr_import_int = &imported_int;
 // expected-error@+1{{must be initialized by a constant expression}}
 constexpr void (Foo::*constexpr_memptr)() = &Foo::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 = &var; // expected-error {{must be initialized by a constant expression}}
+constexpr int *varp = &var;
 
 extern __attribute__((dllimport)) void fun();
 constexpr void (*funp)(void) = &fun; // 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 | FileChec

[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] 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] 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] 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 &RK, raw_ostream &OS);
 void EmitDirectivesImpl(RecordKeeper &RK, raw_ostream &OS);
 void EmitDXILOperation(RecordKeeper &RK, raw_ostream &OS);
-
+void EmitRISCVTargetDef(RecordKeeper &RK, raw_ostream &OS);
 } // 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 &RK, raw_ostream &OS) {
+  const auto &Map = 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 &Def : Map) {
+const auto &Record = 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

[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] 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] 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, &node, NULL, ¤t_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 __kmpc

[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


[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 &Args, 
StringRef BoundArch,
   // First get the generic Apple args, before moving onto Darwin-specific ones.
   DerivedArgList *DAL =
   MachO::TranslateArgs(Args, BoundArch, DeviceOffloadKind);
+  const OptTable &Opts = 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 &Args, 
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-libcx

[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


[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] 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] 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] 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 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] 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 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


[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


[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 &CGF, 
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 &CGF, 
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 &M = CGM.getModule();
   auto &&ElseCodeGen = [this, &M, &TaskArgs, ThreadID, NewTaskNewTaskTTy,
@@ -4776,9 +4778,9 @@ void CGOpenMPRuntime::emitTaskCall(CodeGenFunction &CGF, 
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 &&CodeGen = [TaskEntry, ThreadID, NewTaskNewTaskTTy,
   Loc](CodeGenFunction &CGF, PrePostActionTy &Action) {
@@ -5826,24 +5828,26 @@ void CGOpenMPRuntime::emitTaskwaitCall(CodeGenFunction 
&CGF, SourceLocation Loc,
 llvm::Value *NumOfElements;
 std::tie(NumOfElements, DependenciesArray) =
 emitDependClause(CGF, Data.Dependences, Loc);
-llvm::Value *DepWaitTaskArgs[6];
 if (!Data.Dependences.empty()) {
+ 

[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, &node, NULL, ¤t_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 __kmpc_omp_t

[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


[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 &DT,
 
 SyncDepe

[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


[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 = [&ExtKnown, &OS, &PP](const Expr *Size) {
+Size->printPretty(OS, nullptr, PP);





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





Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:625
+  };
+  std::function PrintOne = [&ExtKnown, &OS](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 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] 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] 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 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 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] 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] 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] 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


  1   2   >