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

2022-12-22 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

In D137517#4012307 , @craig.topper 
wrote:

> In D137517#4012298 , @pcwang-thead 
> wrote:
>
>> In D137517#4009175 , @fpetrogalli 
>> wrote:
>>
>>> @pcwang-thead, I addressed some of your comments.
>>>
>>> The value of `EnumFeatures` is now computed dynamicaly from the
>>> `Features` field of the `Processor` class.
>>
>> Thanks! That sounds great to me!
>>
>>> As for generating `MArch` out of the `Features` field, @craig.topper
>>> pointed me at
>>> https://github.com/riscv-non-isa/riscv-toolchain-conventions/issues/11. From
>>> the reading of it, it seems that the alphabetical order is enough to
>>> build the string that carries `MArch`. Am I missing something?
>>
>> Currently, I think the alphabetical order is OK. If we relax the checking of 
>> arch string someday, there is no doubt that we should change the 
>> implementation here too.
>
> The currently accepted order isn’t alphabetical. The single letter extensions 
> have a specific order. The z extensions are ordered by looking up the second 
> letter in the single letter order. If we alphabetize here i don’t think it 
> will be accepted by the frontend.

Oops, my mistake.

Here is my PoC to generate march from Features:

  diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
  index d1d0356179f5..b2520f25bfea 100644
  --- a/llvm/lib/Target/RISCV/RISCV.td
  +++ b/llvm/lib/Target/RISCV/RISCV.td
  @@ -556,8 +556,8 @@ include "RISCVSchedSyntacoreSCR1.td"
   class RISCVProcessorModelPROC f,
  -  string default_march = "",
  -  list tunef = []> :  
ProcessorModel {
  +  list tunef = [],
  +  string default_march = ""> :  
ProcessorModel {
 string DefaultMarch = default_march;
   }
  diff --git a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp 
b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  index b216e82cef6c..eea31e6ddea8 100644
  --- a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  +++ b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
  @@ -13,17 +13,33 @@
   
   #include "TableGenBackends.h"
   #include "llvm/TableGen/Record.h"
  +#include "llvm/Support/RISCVISAInfo.h"
   
   using namespace llvm;
   
  -static std::string getEnumFeatures(const Record &Rec) {
  +static int getXLen(const Record &Rec) {
 std::vector Features = Rec.getValueAsListOfDefs("Features");
 if (find_if(Features, [](const Record *R) {
   return R->getName() == "Feature64Bit";
 }) != Features.end())
  -return "FK_64BIT";
  +return 64;
   
  -  return "FK_NONE";
  +  return 32;
  +}
  +
  +static std::string getMArch(int XLen, const Record &Rec) {
  +  std::vector Features = Rec.getValueAsListOfDefs("Features");
  +  std::vector FeatureVector;
  +  // Convert Features to FeatureVector.
  +  for (auto *Feature : Features) {
  +StringRef FeatureName = Feature->getValueAsString("Name");
  +if (llvm::RISCVISAInfo::isSupportedExtensionFeature(FeatureName))
  +  FeatureVector.push_back(std::string("+") + FeatureName.str());
  +  }
  +  auto ISAInfo = llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
  +  if (!ISAInfo)
  +report_fatal_error("Invalid features: ");
  +  return (*ISAInfo)->toString();
   }
   
   void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
  @@ -39,11 +55,17 @@ void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, 
raw_ostream &OS) {
 // Iterate on all definition records.
 for (const MapTy &Def : Map) {
   const Record &Rec = *(Def.second);
  -if (Rec.isSubClassOf("RISCVProcessorModelPROC"))
  +if (Rec.isSubClassOf("RISCVProcessorModelPROC")) {
  +  int XLen = getXLen(Rec);
  +  std::string EnumFeatures = XLen == 64 ? "FK_64BIT" : "FK_NONE";
  +  std::string MArch = Rec.getValueAsString("DefaultMarch").str();
  +  if (MArch == "")
  +MArch = getMArch(XLen, Rec);
 OS << "PROC(" << Rec.getName() << ", "
  - << "{\"" << Rec.getValueAsString("Name") << "\"},"
  - << getEnumFeatures(Rec) << ", "
  - << "{\"" << Rec.getValueAsString("DefaultMarch") << "\"})\n";
  + << "{\"" << Rec.getValueAsString("Name") << "\"}," << EnumFeatures
  + << ", "
  + << "{\"" << MArch << "\"})\n";
  +}
 }
 OS << "\n#undef PROC\n";
 OS << "\n";

The generated file would be like below (the march strings are tedious but I 
think that would be OK):

  #ifndef PROC
  #define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH)
  #endif
  
  PROC(INVALID, {"invalid"}, FK_INVALID, {""})
  PROC(GENERIC_RV32, {"generic-rv32"},FK_NONE, {"rv32i2p0"})
  PROC(GENERIC_RV64, {"generic-rv64"},FK_64BIT, {"rv64i2p0"})
  PROC(ROCKET_RV32, {"rocket-rv32"},FK_NONE, {"rv32i2p0"})
  PROC(ROCKET_RV64, {"rocket-rv64"},FK_64BIT, {"rv64i2p0"})
  PROC(SI

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

2022-12-22 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a subscriber: sammccall.
nridge added a comment.

Thanks, this is pretty neat!

cc @sammccall as a heads up, just to make sure you're cool with having this 
in-tree




Comment at: clang-tools-extra/clangd/schema/config.json:48
+  "description": "Directory to search for compilation database 
(compile_commands.json etc).",
+  "type": "string"
+},

Technically `string` OR `enum [ "Ancestors", "None" ]` would be more accurate

Not sure if it's worth specifying that... from a validation point of view, 
`string` is a superset of the other one, but maybe some people will look at the 
schema for documentation, in which it could be useful to have those "keywords" 
listed?



Comment at: clang-tools-extra/clangd/schema/config.json:72
+  "type": "object",
+  "oneOf": [
+{

I don't think this is quite right:

 * If `File` is specified, `Server` and `MountPoint` should not be
 * If `Server` is specified, `MountPoint` can optionally be specified but 
`File` should not be


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140462

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


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added a subscriber: pengfei.
Herald added a project: All.
FreddyYe requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140531

Files:
  clang/lib/Headers/avx512vlbwintrin.h
  clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c
  clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c

Index: clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c
@@ -0,0 +1,211 @@
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+short test_mm_reduce_max_epi16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_max_epi16
+// CHECK:call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_max_epi16(__W);
+}
+
+short test_mm_reduce_min_epi16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_min_epi16
+// CHECK:call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_min_epi16(__W);
+}
+
+unsigned short test_mm_reduce_max_epu16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_max_epu16
+// CHECK:call i16 @llvm.vector.reduce.umax.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_max_epu16(__W);
+}
+
+unsigned short test_mm_reduce_min_epu16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_min_epu16
+// CHECK:call i16 @llvm.vector.reduce.umin.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_min_epu16(__W);
+}
+
+short test_mm_mask_reduce_max_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_max_epi16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_max_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_min_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_min_epi16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_min_epi16(__M, __W);
+}
+
+unsigned short test_mm_mask_reduce_max_epu16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_max_epu16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.umax.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_max_epu16(__M, __W);
+}
+
+unsigned short test_mm_mask_reduce_min_epu16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_min_epu16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.umin.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_min_epu16(__M, __W);
+}
+
+short test_mm256_reduce_max_epi16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_max_epi16
+// CHECK:call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_max_epi16(__W);
+}
+
+short test_mm256_reduce_min_epi16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_min_epi16
+// CHECK:call i16 @llvm.vector.reduce.smin.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_min_epi16(__W);
+}
+
+unsigned short test_mm256_reduce_max_epu16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_max_epu16
+// CHECK:call i16 @llvm.vector.reduce.umax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_max_epu16(__W);
+}
+
+unsigned short test_mm256_reduce_min_epu16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_min_epu16
+// CHECK:call i16 @llvm.vector.reduce.umin.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_min_epu16(__W);
+}
+
+short test_mm256_mask_reduce_max_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_max_epi16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_max_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_min_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_min_epi16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smin.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_min_epi16(__M, __W);
+}
+
+unsigned short test_mm256_mask_reduce_max_epu16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_max_epu16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.umax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_max_epu16(__M, __W);
+}
+
+unsigned short test_mm256_mask_reduce_min_epu16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_min_epu16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, 

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

2022-12-22 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 484758.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

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";
 if (RVVI->isMasked())
   OS << "IsMasked = true;\n";
 else
@@ -195,13 +195,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";
@@ -209,9 +208,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";
   }
 
@@ -448,7 +446,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());
   });
 
@@ -462,7 +460,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), HasBuiltinAlias(HasBuiltinAlias),
-  ManualCodegen(ManualCodegen.str()), NF(NF),
-  DefaultPolicy(NewDefaultPolicy) {
+  ManualCodegen(ManualCodegen.str()), NF(NF), PolicyAttrs(NewPolicyAttrs) {
 
   // Init BuiltinName, Name and OverloadedName
   BuiltinName = NewName.str();
@@ -868,7 +867,7 @@
 OverloadedName += "_" + OverloadedSuffix.str();
 
   updateNamesAndPolicy(IsMasked, hasPolicy(), IsPrototypeDef

[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 484759.
FreddyYe added a comment.

Add release note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/avx512vlbwintrin.h
  clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c
  clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c

Index: clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c
@@ -0,0 +1,211 @@
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+short test_mm_reduce_max_epi16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_max_epi16
+// CHECK:call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_max_epi16(__W);
+}
+
+short test_mm_reduce_min_epi16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_min_epi16
+// CHECK:call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_min_epi16(__W);
+}
+
+unsigned short test_mm_reduce_max_epu16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_max_epu16
+// CHECK:call i16 @llvm.vector.reduce.umax.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_max_epu16(__W);
+}
+
+unsigned short test_mm_reduce_min_epu16(__m128i __W){
+// CHECK-LABEL: test_mm_reduce_min_epu16
+// CHECK:call i16 @llvm.vector.reduce.umin.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_min_epu16(__W);
+}
+
+short test_mm_mask_reduce_max_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_max_epi16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smax.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_max_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_min_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_min_epi16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smin.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_min_epi16(__M, __W);
+}
+
+unsigned short test_mm_mask_reduce_max_epu16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_max_epu16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.umax.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_max_epu16(__M, __W);
+}
+
+unsigned short test_mm_mask_reduce_min_epu16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: test_mm_mask_reduce_min_epu16
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.umin.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_min_epu16(__M, __W);
+}
+
+short test_mm256_reduce_max_epi16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_max_epi16
+// CHECK:call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_max_epi16(__W);
+}
+
+short test_mm256_reduce_min_epi16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_min_epi16
+// CHECK:call i16 @llvm.vector.reduce.smin.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_min_epi16(__W);
+}
+
+unsigned short test_mm256_reduce_max_epu16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_max_epu16
+// CHECK:call i16 @llvm.vector.reduce.umax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_max_epu16(__W);
+}
+
+unsigned short test_mm256_reduce_min_epu16(__m256i __W){
+// CHECK-LABEL: test_mm256_reduce_min_epu16
+// CHECK:call i16 @llvm.vector.reduce.umin.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_min_epu16(__W);
+}
+
+short test_mm256_mask_reduce_max_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_max_epi16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_max_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_min_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_min_epi16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.smin.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_min_epi16(__M, __W);
+}
+
+unsigned short test_mm256_mask_reduce_max_epu16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_max_epu16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.umax.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_max_epu16(__M, __W);
+}
+
+unsigned short test_mm256_mask_reduce_min_epu16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: test_mm256_mask_reduce_min_epu16
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+//

[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/Headers/avx512vlbwintrin.h:2806-2814
+/* Vector-reduction arithmetic accepts vectors as inputs and produces scalars 
as
+ * outputs. This class of vector operation forms the basis of many scientific
+ * computations. In vector-reduction arithmetic, the evaluation off is
+ * independent of the order of the input elements of V.
+
+ * Used bisection method. At each step, we partition the vector with previous
+ * step in half, and the operation is performed on its two halves.

Do we need such comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

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


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c:1
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin 
-target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+

Should the name starts with `avx512bwvl`?
Or put them into `avx512bwvl-intrinsics.ll`?



Comment at: clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c:1
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin 
-target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+

Maybe not worth a new file?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

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


[PATCH] D140532: .clang-tidy: disable misc-use-anonymous-namespace check.

2022-12-22 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a reviewer: njames93.
Herald added a project: All.
hokein requested review of this revision.
Herald added subscribers: llvm-commits, aheejin.
Herald added a project: LLVM.

The check gives warnings on static functions, this is allowed per LLVM
code style https://llvm.org/docs/CodingStandards.html#anonymous-namespaces


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140532

Files:
  .clang-tidy


Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -1,4 +1,4 @@
-Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
+Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming'
 CheckOptions:
   - key: readability-identifier-naming.ClassCase
 value:   CamelCase


Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -1,4 +1,4 @@
-Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
+Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-const-correctness,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-use-anonymous-namespace,readability-identifier-naming'
 CheckOptions:
   - key: readability-identifier-naming.ClassCase
 value:   CamelCase
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c:1
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin 
-target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+

pengfei wrote:
> Should the name starts with `avx512bwvl`?
> Or put them into `avx512bwvl-intrinsics.ll`?
Sorry, I referred to the backend file. Please ignore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

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


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 484764.
FreddyYe marked 4 inline comments as done.
FreddyYe added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/avx512vlbwintrin.h
  clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c

Index: clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c
@@ -0,0 +1,419 @@
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+short test_mm_reduce_add_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_add_epi16(
+// CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_add_epi16(__W);
+}
+
+short test_mm_reduce_mul_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_mul_epi16(
+// CHECK:call i16 @llvm.vector.reduce.mul.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_mul_epi16(__W);
+}
+
+short test_mm_reduce_or_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_or_epi16(
+// CHECK:call i16 @llvm.vector.reduce.or.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_or_epi16(__W);
+}
+
+short test_mm_reduce_and_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_and_epi16(
+// CHECK:call i16 @llvm.vector.reduce.and.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_and_epi16(__W);
+}
+
+short test_mm_mask_reduce_add_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_add_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_add_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_mul_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_mul_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.mul.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_mul_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_and_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_and_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.and.v8i16(<8 x i16> %{{.*}}
+  return _mm_mask_reduce_and_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_or_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_or_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.or.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_or_epi16(__M, __W);
+}
+
+short test_mm256_reduce_add_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_add_epi16(
+// CHECK:call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_add_epi16(__W);
+}
+
+short test_mm256_reduce_mul_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_mul_epi16(
+// CHECK:call i16 @llvm.vector.reduce.mul.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_mul_epi16(__W);
+}
+
+short test_mm256_reduce_or_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_or_epi16(
+// CHECK:call i16 @llvm.vector.reduce.or.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_or_epi16(__W);
+}
+
+short test_mm256_reduce_and_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_and_epi16(
+// CHECK:call i16 @llvm.vector.reduce.and.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_and_epi16(__W);
+}
+
+short test_mm256_mask_reduce_add_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_add_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_add_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_mul_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_mul_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.mul.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_mul_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_and_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_and_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.and.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_and_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_or_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_or_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.or.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_

[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added inline comments.



Comment at: clang/test/CodeGen/X86/avx512vlbw-reduceMinMaxIntrin.c:1
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin 
-target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+

pengfei wrote:
> Maybe not worth a new file?
Agree


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

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


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM. Please wait some days for other reviewers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

___
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-22 Thread gehry via Phabricator via cfe-commits
Sockke updated this revision to Diff 484765.
Sockke added a comment.

Improved the test file.


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,4 +1,4 @@
-// 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 
 
 // Ensure that function declarations are not changed.
@@ -124,3 +124,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;{{$}}
+
+  UnknownType b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: error: unknown type name 'UnknownType' 
[clang-diagnostic-error]
+  // CHECK-FIXES-NOT: {{^}}  UnknownType b = 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,10 @@
   const ASTContext &Context = *Result.Context;
   const SourceManager &Source = Context.getSourceManager();
 
+  // Clang diagnostic error may cause the 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,4 +1,4 @@
-// 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 
 
 // Ensure that function declarations are not changed.
@@ -124,3 +124,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;{{$}}
+
+  UnknownType b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: error: unknown type name 'UnknownType' [clang-diagnostic-error]
+  // CHECK-FIXES-NOT: {{^}}  UnknownType b = 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,10 @@
   const ASTContext &Context = *Result.Context;
   const SourceManager &Source = Context.getSourceManager();
 
+  // Clang diagnostic error may cause the 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] D139801: [clang-format] Adds 'friend' to QualifierOrder.

2022-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D139801#3991108 , @MyDeveloperDay 
wrote:

> I also appreciate the concessions made by others to allow clang-format to 
> alter code as this has opened the doors in my view to 1 or 2 other great code 
> modification changes.

+1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139801

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


[clang] 4cafc37 - [clang-format] Add 'friend' to QualifierOrder

2022-12-22 Thread Owen Pan via cfe-commits
Author: Micah Weston
Date: 2022-12-22T02:02:09-08:00
New Revision: 4cafc3727b35151e8f676adab11524bb21140939

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

LOG: [clang-format] Add 'friend' to QualifierOrder

For cases of defining friend functions, qualifier ordering can
allow multiple positions for the 'friend' token.

Closes #59450.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/QualifierAlignmentFixer.cpp
clang/unittests/Format/QualifierFixerTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 969fce82781c2..27e93ff504d83 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3712,6 +3712,7 @@ the configuration (without a prefix: ``Auto``).
 * const
 * inline
 * static
+* friend
 * constexpr
 * volatile
 * restrict

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index b7fbe4b97c6db..8b11ae662c707 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2970,6 +2970,7 @@ struct FormatStyle {
   ///   * const
   ///   * inline
   ///   * static
+  ///   * friend
   ///   * constexpr
   ///   * volatile
   ///   * restrict

diff  --git a/clang/lib/Format/QualifierAlignmentFixer.cpp 
b/clang/lib/Format/QualifierAlignmentFixer.cpp
index 6ee0d6da76a48..cef8b36ff7582 100644
--- a/clang/lib/Format/QualifierAlignmentFixer.cpp
+++ b/clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -414,6 +414,7 @@ tok::TokenKind 
LeftRightQualifierAlignmentFixer::getTokenFromQualifier(
   .Case("inline", tok::kw_inline)
   .Case("constexpr", tok::kw_constexpr)
   .Case("restrict", tok::kw_restrict)
+  .Case("friend", tok::kw_friend)
   .Default(tok::identifier);
 }
 

diff  --git a/clang/unittests/Format/QualifierFixerTest.cpp 
b/clang/unittests/Format/QualifierFixerTest.cpp
index b01aff53150da..875ad8353e017 100755
--- a/clang/unittests/Format/QualifierFixerTest.cpp
+++ b/clang/unittests/Format/QualifierFixerTest.cpp
@@ -133,6 +133,8 @@ TEST_F(QualifierFixerTest, RotateTokens) {
 tok::kw_static);
   
EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("restrict"),
 tok::kw_restrict);
+  EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("friend"),
+tok::kw_friend);
 }
 
 TEST_F(QualifierFixerTest, FailQualifierInvalidConfiguration) {
@@ -196,8 +198,8 @@ TEST_F(QualifierFixerTest, QualifierRight) {
 TEST_F(QualifierFixerTest, QualifiersCustomOrder) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Left;
-  Style.QualifierOrder = {"inline", "constexpr", "static",
-  "const",  "volatile",  "type"};
+  Style.QualifierOrder = {"friend", "inline",   "constexpr", "static",
+  "const",  "volatile", "type"};
 
   verifyFormat("const volatile int a;", "const volatile int a;", Style);
   verifyFormat("const volatile int a;", "volatile const int a;", Style);
@@ -216,6 +218,15 @@ TEST_F(QualifierFixerTest, QualifiersCustomOrder) {
   verifyFormat("constexpr static LPINT Bar;", "static constexpr LPINT Bar;",
Style);
   verifyFormat("const const int a;", "const int const a;", Style);
+
+  verifyFormat(
+  "friend constexpr auto operator<=>(const foo &, const foo &) = default;",
+  "constexpr friend auto operator<=>(const foo &, const foo &) = default;",
+  Style);
+  verifyFormat(
+  "friend constexpr bool operator==(const foo &, const foo &) = default;",
+  "constexpr bool friend operator==(const foo &, const foo &) = default;",
+  Style);
 }
 
 TEST_F(QualifierFixerTest, LeftRightQualifier) {
@@ -723,9 +734,10 @@ TEST_F(QualifierFixerTest, IsQualifierType) {
   ConfiguredTokens.push_back(tok::kw_inline);
   ConfiguredTokens.push_back(tok::kw_restrict);
   ConfiguredTokens.push_back(tok::kw_constexpr);
+  ConfiguredTokens.push_back(tok::kw_friend);
 
-  auto Tokens =
-  annotate("const static inline auto restrict int double long constexpr");
+  auto Tokens = annotate(
+  "const static inline auto restrict int double long constexpr friend");
 
   EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
   Tokens[0], ConfiguredTokens));
@@ -745,6 +757,8 @@ TEST_F(QualifierFixerTest, IsQualifierType) {
   Tokens[7], ConfiguredTokens));
   EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
   Tokens[8], ConfiguredTokens));
+  EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
+  Tokens[9], Configu

[PATCH] D139801: [clang-format] Adds 'friend' to QualifierOrder.

2022-12-22 Thread Owen Pan 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 rG4cafc3727b35: [clang-format] Add 'friend' to 
QualifierOrder (authored by red1bluelost, committed by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139801

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -133,6 +133,8 @@
 tok::kw_static);
   
EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("restrict"),
 tok::kw_restrict);
+  EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("friend"),
+tok::kw_friend);
 }
 
 TEST_F(QualifierFixerTest, FailQualifierInvalidConfiguration) {
@@ -196,8 +198,8 @@
 TEST_F(QualifierFixerTest, QualifiersCustomOrder) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Left;
-  Style.QualifierOrder = {"inline", "constexpr", "static",
-  "const",  "volatile",  "type"};
+  Style.QualifierOrder = {"friend", "inline",   "constexpr", "static",
+  "const",  "volatile", "type"};
 
   verifyFormat("const volatile int a;", "const volatile int a;", Style);
   verifyFormat("const volatile int a;", "volatile const int a;", Style);
@@ -216,6 +218,15 @@
   verifyFormat("constexpr static LPINT Bar;", "static constexpr LPINT Bar;",
Style);
   verifyFormat("const const int a;", "const int const a;", Style);
+
+  verifyFormat(
+  "friend constexpr auto operator<=>(const foo &, const foo &) = default;",
+  "constexpr friend auto operator<=>(const foo &, const foo &) = default;",
+  Style);
+  verifyFormat(
+  "friend constexpr bool operator==(const foo &, const foo &) = default;",
+  "constexpr bool friend operator==(const foo &, const foo &) = default;",
+  Style);
 }
 
 TEST_F(QualifierFixerTest, LeftRightQualifier) {
@@ -723,9 +734,10 @@
   ConfiguredTokens.push_back(tok::kw_inline);
   ConfiguredTokens.push_back(tok::kw_restrict);
   ConfiguredTokens.push_back(tok::kw_constexpr);
+  ConfiguredTokens.push_back(tok::kw_friend);
 
-  auto Tokens =
-  annotate("const static inline auto restrict int double long constexpr");
+  auto Tokens = annotate(
+  "const static inline auto restrict int double long constexpr friend");
 
   EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
   Tokens[0], ConfiguredTokens));
@@ -745,6 +757,8 @@
   Tokens[7], ConfiguredTokens));
   EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
   Tokens[8], ConfiguredTokens));
+  EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
+  Tokens[9], ConfiguredTokens));
 
   auto NotTokens = annotate("for while do Foo Bar ");
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -414,6 +414,7 @@
   .Case("inline", tok::kw_inline)
   .Case("constexpr", tok::kw_constexpr)
   .Case("restrict", tok::kw_restrict)
+  .Case("friend", tok::kw_friend)
   .Default(tok::identifier);
 }
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2970,6 +2970,7 @@
   ///   * const
   ///   * inline
   ///   * static
+  ///   * friend
   ///   * constexpr
   ///   * volatile
   ///   * restrict
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3712,6 +3712,7 @@
 * const
 * inline
 * static
+* friend
 * constexpr
 * volatile
 * restrict


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -133,6 +133,8 @@
 tok::kw_static);
   EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("restrict"),
 tok::kw_restrict);
+  EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("friend"),
+tok::kw_friend);
 }
 
 TEST_F(QualifierFixerTest, FailQualifierInvalidConfiguration) {
@@ -196,8 +198,8 @@
 TEST_F(QualifierFixerTest, QualifiersCustomOrder) {
   FormatStyle Style = getLLVMStyle();
   

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

2022-12-22 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



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

shafik wrote:
> tbaeder wrote:
> > shafik wrote:
> > > Can you explain what is going on here? Why do we need to initialize if it 
> > > is not root?
> > Root means that `Base == 0`, so it cannot have a `InlineDescriptor` before 
> > the `Base` offset. That is mainly the case for global variables.
> Can we add a comment that explains this a little better? I still don't get 
> the significance, so I definitely missing something.
> 
> Also, why do we initialized before the store? 


I don't think there's a significance to the order of operations here, some do 
the init after the store, some the other way around.


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

https://reviews.llvm.org/D135750

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


[clang] 0dc4dfa - [clang-format] Add InsertBraces to operator== in Format.h

2022-12-22 Thread Owen Pan via cfe-commits
Author: Owen Pan
Date: 2022-12-22T02:28:25-08:00
New Revision: 0dc4dfabd748ba3bc4d968a88104c686c388f177

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

LOG: [clang-format] Add InsertBraces to operator== in Format.h

Added: 


Modified: 
clang/include/clang/Format/Format.h

Removed: 




diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 8b11ae662c70..8949520f87b0 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -4088,6 +4088,7 @@ struct FormatStyle {
IndentRequiresClause == R.IndentRequiresClause &&
IndentWidth == R.IndentWidth &&
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
+   InsertBraces == R.InsertBraces &&
JavaImportGroups == R.JavaImportGroups &&
JavaScriptQuotes == R.JavaScriptQuotes &&
JavaScriptWrapImports == R.JavaScriptWrapImports &&



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


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Kan Shengchen via Phabricator via cfe-commits
skan added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:806
 - Lift _BitInt() supported max width from 128 to 8388608.
+- Support *_reduce_*_ep[i|u]8/16 series intrinsics.
 

This is not clear to me, try sth like "mm*_reduce_(add|and|max)_epi" and put 
the name in a code-block like the previous lines.



Comment at: clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c:1
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64-apple-darwin 
-target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall 
-Werror | FileCheck %s
+

drop "-apple-darwin"?



Comment at: clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c:115
+
+char test_mm_reduce_mul_epi8(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_mul_epi8(

char has different meaning on different platforms. Should we use "signed char" 
or "unsigned char" explicitly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

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


[PATCH] D140538: [Clang][CodeGen] Use poison instead of undef for dummy values in CGExpr [NFC]

2022-12-22 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito created this revision.
ManuelJBrito added a reviewer: nlopes.
ManuelJBrito added a project: clang.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a project: libc++abi.
Herald added a reviewer: libc++abi.

Replace the following uses of poison with undef where undef is used as a dummy 
value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140538

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  libcxxabi/test/test_demangle.pass.cpp

Index: libcxxabi/test/test_demangle.pass.cpp
===
--- libcxxabi/test/test_demangle.pass.cpp
+++ libcxxabi/test/test_demangle.pass.cpp
@@ -3169,7 +3169,7 @@
 {"_ZN5clang7CodeGen15CodeGenFunction9EmitCheckEPN4llvm5ValueEj", "clang::CodeGen::CodeGenFunction::EmitCheck(llvm::Value*, unsigned int)"},
 {"_ZN5clang7CodeGen15CodeGenFunction9getTrapBBEv", "clang::CodeGen::CodeGenFunction::getTrapBB()"},
 {"_ZN5clang7CodeGen15CodeGenFunction24EmitComplexPrePostIncDecEPKNS_13UnaryOperatorENS0_6LValueEbb", "clang::CodeGen::CodeGenFunction::EmitComplexPrePostIncDec(clang::UnaryOperator const*, clang::CodeGen::LValue, bool, bool)"},
-{"_ZN5clang7CodeGen15CodeGenFunction14GetUndefRValueENS_8QualTypeE", "clang::CodeGen::CodeGenFunction::GetUndefRValue(clang::QualType)"},
+{"_ZN5clang7CodeGen15CodeGenFunction14GetPoisonRValueENS_8QualTypeE", "clang::CodeGen::CodeGenFunction::GetPoisonRValue(clang::QualType)"},
 {"_ZN5clang7CodeGen15CodeGenFunction21EmitUnsupportedRValueEPKNS_4ExprEPKc", "clang::CodeGen::CodeGenFunction::EmitUnsupportedRValue(clang::Expr const*, char const*)"},
 {"_ZN5clang7CodeGen15CodeGenFunction21EmitUnsupportedLValueEPKNS_4ExprEPKc", "clang::CodeGen::CodeGenFunction::EmitUnsupportedLValue(clang::Expr const*, char const*)"},
 {"_ZN5clang7CodeGen15CodeGenFunction17EmitCheckedLValueEPKNS_4ExprE", "clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*)"},
Index: clang/lib/CodeGen/CodeGenFunction.h
===
--- clang/lib/CodeGen/CodeGenFunction.h
+++ clang/lib/CodeGen/CodeGenFunction.h
@@ -3740,8 +3740,8 @@
   /// Create a check that a scalar RValue is non-null.
   llvm::Value *EmitNonNullRValueCheck(RValue RV, QualType T);
 
-  /// GetUndefRValue - Get an appropriate 'undef' rvalue for the given type.
-  RValue GetUndefRValue(QualType Ty);
+  /// GetPoisonRValue - Get an appropriate 'poison' rvalue for the given type.
+  RValue GetPoisonRValue(QualType Ty);
 
   /// EmitUnsupportedRValue - Emit a dummy r-value using the type of E
   /// and issue an ErrorUnsupported style diagnostic (using the
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1624,7 +1624,7 @@
   CGF.ErrorUnsupported(E, "scalar expression");
   if (E->getType()->isVoidType())
 return nullptr;
-  return llvm::UndefValue::get(CGF.ConvertType(E->getType()));
+  return llvm::PoisonValue::get(CGF.ConvertType(E->getType()));
 }
 
 Value *
@@ -4906,7 +4906,7 @@
   // If EmitVAArg fails, emit an error.
   if (!ArgPtr.isValid()) {
 CGF.ErrorUnsupported(VE, "va_arg expression");
-return llvm::UndefValue::get(ArgTy);
+return llvm::PoisonValue::get(ArgTy);
   }
 
   // FIXME Volatility.
Index: clang/lib/CodeGen/CGExprComplex.cpp
===
--- clang/lib/CodeGen/CGExprComplex.cpp
+++ clang/lib/CodeGen/CGExprComplex.cpp
@@ -419,7 +419,7 @@
   CGF.ErrorUnsupported(E, "complex expression");
   llvm::Type *EltTy =
 CGF.ConvertType(getComplexType(E->getType())->getElementType());
-  llvm::Value *U = llvm::UndefValue::get(EltTy);
+  llvm::Value *U = llvm::PoisonValue::get(EltTy);
   return ComplexPairTy(U, U);
 }
 
@@ -1274,7 +1274,7 @@
 CGF.ErrorUnsupported(E, "complex va_arg expression");
 llvm::Type *EltTy =
   CGF.ConvertType(E->getType()->castAs()->getElementType());
-llvm::Value *U = llvm::UndefValue::get(EltTy);
+llvm::Value *U = llvm::PoisonValue::get(EltTy);
 return ComplexPairTy(U, U);
   }
 
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -1169,7 +1169,7 @@
   return Builder.CreateICmpNE(V, llvm::Constant::getNullValue(V->getType()));
 }
 
-RValue CodeGenFunction::GetUndefRValue(QualType Ty) {
+RValue CodeGenFunction::GetPoisonRValue(QualType Ty) {
   if (Ty->isVoidType())
 return RValue::get(nullptr);
 
@@ -1177,7 +1177,7 @@
   case TEK_Complex: {
 llvm::Type *EltTy =
   ConvertType(Ty->

[PATCH] D140538: [Clang][CodeGen] Use poison instead of undef for dummy values in CGExpr [NFC]

2022-12-22 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes accepted this revision.
nlopes added a comment.

LGTM, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140538

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


[PATCH] D140531: [X86] Add reduce_*_ep[i|u]8/16 series intrinsics.

2022-12-22 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 484784.
FreddyYe marked 3 inline comments as done.
FreddyYe added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140531

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/avx512vlbwintrin.h
  clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c

Index: clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/avx512vlbw-reduceIntrin.c
@@ -0,0 +1,420 @@
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=x86_64 -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -ffreestanding %s -O0 -triple=i386 -target-feature +avx512bw -target-feature +avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
+
+#include 
+
+short test_mm_reduce_add_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_add_epi16(
+// CHECK: call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_add_epi16(__W);
+}
+
+short test_mm_reduce_mul_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_mul_epi16(
+// CHECK:call i16 @llvm.vector.reduce.mul.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_mul_epi16(__W);
+}
+
+short test_mm_reduce_or_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_or_epi16(
+// CHECK:call i16 @llvm.vector.reduce.or.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_or_epi16(__W);
+}
+
+short test_mm_reduce_and_epi16(__m128i __W){
+// CHECK-LABEL: @test_mm_reduce_and_epi16(
+// CHECK:call i16 @llvm.vector.reduce.and.v8i16(<8 x i16> %{{.*}})
+  return _mm_reduce_and_epi16(__W);
+}
+
+short test_mm_mask_reduce_add_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_add_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.add.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_add_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_mul_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_mul_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.mul.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_mul_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_and_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_and_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.and.v8i16(<8 x i16> %{{.*}}
+  return _mm_mask_reduce_and_epi16(__M, __W);
+}
+
+short test_mm_mask_reduce_or_epi16(__mmask8 __M, __m128i __W){
+// CHECK-LABEL: @test_mm_mask_reduce_or_epi16(
+// CHECK:select <8 x i1> %{{.*}}, <8 x i16> %{{.*}}, <8 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.or.v8i16(<8 x i16> %{{.*}})
+  return _mm_mask_reduce_or_epi16(__M, __W);
+}
+
+short test_mm256_reduce_add_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_add_epi16(
+// CHECK:call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_add_epi16(__W);
+}
+
+short test_mm256_reduce_mul_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_mul_epi16(
+// CHECK:call i16 @llvm.vector.reduce.mul.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_mul_epi16(__W);
+}
+
+short test_mm256_reduce_or_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_or_epi16(
+// CHECK:call i16 @llvm.vector.reduce.or.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_or_epi16(__W);
+}
+
+short test_mm256_reduce_and_epi16(__m256i __W){
+// CHECK-LABEL: @test_mm256_reduce_and_epi16(
+// CHECK:call i16 @llvm.vector.reduce.and.v16i16(<16 x i16> %{{.*}})
+  return _mm256_reduce_and_epi16(__W);
+}
+
+short test_mm256_mask_reduce_add_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_add_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.add.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_add_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_mul_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_mul_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.mul.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_mul_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_and_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_and_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <16 x i16> %{{.*}}, <16 x i16> %{{.*}}
+// CHECK:call i16 @llvm.vector.reduce.and.v16i16(<16 x i16> %{{.*}})
+  return _mm256_mask_reduce_and_epi16(__M, __W);
+}
+
+short test_mm256_mask_reduce_or_epi16(__mmask16 __M, __m256i __W){
+// CHECK-LABEL: @test_mm256_mask_reduce_or_epi16(
+// CHECK:select <16 x i1> %{{.*}}, <1

[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Closes https://github.com/llvm/llvm-project/issues/58949.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140543

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.h

Index: clang/lib/Format/IntegerLiteralSeparatorFixer.h
===
--- /dev/null
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.h
@@ -0,0 +1,39 @@
+//===--- IntegerLiteralSeparatorFixer.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file declares IntegerLiteralSeparatorFixer that fixes C++ integer
+/// literal separators.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_FORMAT_INTEGERLITERALSEPARATORFIXER_H
+#define LLVM_CLANG_LIB_FORMAT_INTEGERLITERALSEPARATORFIXER_H
+
+#include "TokenAnalyzer.h"
+
+namespace clang {
+namespace format {
+
+class IntegerLiteralSeparatorFixer {
+public:
+  std::pair
+  process(const Environment &Env, const FormatStyle &Style) const;
+
+private:
+  static const auto Separator = '\'';
+
+  bool checkSeparator(const StringRef IntegerLiteral, int DigitsPerGroup) const;
+  std::string format(const StringRef IntegerLiteral, int DigitsPerGroup,
+ bool RemoveSeparator) const;
+};
+
+} // end namespace format
+} // end namespace clang
+
+#endif
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- /dev/null
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -0,0 +1,174 @@
+//===--- IntegerLiteralSeparatorFixer.cpp ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file implements IntegerLiteralSeparatorFixer that fixes C++ integer
+/// literal separators.
+///
+//===--===//
+
+#include "IntegerLiteralSeparatorFixer.h"
+
+namespace clang {
+namespace format {
+
+enum class Base { Binary, Decimal, Hex, Other };
+
+static Base getBase(const StringRef IntegerLiteral) {
+  assert(IntegerLiteral.size() > 1);
+
+  if (IntegerLiteral[0] > '0') {
+assert(IntegerLiteral[0] <= '9');
+return Base::Decimal;
+  }
+
+  assert(IntegerLiteral[0] == '0');
+
+  switch (IntegerLiteral[1]) {
+  case 'b':
+  case 'B':
+return Base::Binary;
+  case 'x':
+  case 'X':
+return Base::Hex;
+  default:
+return Base::Other;
+  }
+}
+
+std::pair
+IntegerLiteralSeparatorFixer::process(const Environment &Env,
+  const FormatStyle &Style) const {
+  const auto &Option = Style.IntegerLiteralSeparator;
+  const auto Binary = Option.Binary;
+  const auto Decimal = Option.Decimal;
+  const auto Hex = Option.Hex;
+  const bool SkipBinary = Binary == 0;
+  const bool SkipDecimal = Decimal == 0;
+  const bool SkipHex = Hex == 0;
+
+  if (SkipBinary && SkipDecimal && SkipHex)
+return {};
+
+  const auto ID = Env.getFileID();
+  const auto &SourceMgr = Env.getSourceManager();
+  std::unique_ptr Lex;
+  Lex.reset(new Lexer(ID, SourceMgr.getBufferOrFake(ID), SourceMgr,
+  getFormattingLangOpts(Style)));
+  Lex->SetCommentRetentionState(true);
+
+  Token Tok;
+  Lex->LexFromRawLexer(Tok);
+
+  tooling::Replacements Result;
+  for (bool Skip = false; Tok.isNot(tok::eof); Lex->LexFromRawLexer(Tok)) {
+auto Length = Tok.getLength();
+if (Length < 2)
+  continue;
+auto Location = Tok.getLocation();
+auto Text = StringRef(SourceMgr.getCharacterData(Location), Length);
+if (Tok.is(tok::comment)) {
+  if (Text == "// clang-format off" || Text == "/* clang-format off */")
+Skip = true;
+  if (Text == "// clang-format on" || Text == "/* clang-format on */")
+Skip = false;
+  continue;
+}
+if (Skip || Tok.isNot(tok::numeric_constant))
+  continue;
+if (Text.find_first_of(".eEpP") != StringRef::npos)
+  continue;
+const auto B = ge

[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan planned changes to this revision.
owenpan added a comment.

Will add unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140543

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


[PATCH] D140544: [DebugInfo] make DW_LANG_C11 respect -gstrict-dwarf

2022-12-22 Thread ChenZheng via Phabricator via cfe-commits
shchenz created this revision.
shchenz added reviewers: dblaikie, probinson, aprantl.
shchenz added a project: LLVM.
Herald added a project: All.
shchenz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140544

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-programming-language.c


Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- clang/test/CodeGen/debug-info-programming-language.c
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -4,7 +4,14 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
 // RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-STRICT %s
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s 
-o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-C11 %s
 
+// CHECK-STRICT: !DICompileUnit(language: DW_LANG_C,
 // CHECK-C11: !DICompileUnit(language: DW_LANG_C11
 // Update this check once support for DW_LANG_C17 is broadly supported/known in
 // consumers. Maybe we'll skip this and go to the DWARFv6 language+version
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -579,7 +579,10 @@
   } else if (LO.RenderScript) {
 LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C11) {
-LangTag = llvm::dwarf::DW_LANG_C11;
+if (CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
+  LangTag = llvm::dwarf::DW_LANG_C;
+else
+  LangTag = llvm::dwarf::DW_LANG_C11;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {


Index: clang/test/CodeGen/debug-info-programming-language.c
===
--- clang/test/CodeGen/debug-info-programming-language.c
+++ clang/test/CodeGen/debug-info-programming-language.c
@@ -4,7 +4,14 @@
 // RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
 // RUN:   -x c -std=c17 -O0 -disable-llvm-passes -debug-info-kind=limited \
 // RUN:   | FileCheck --check-prefix=CHECK-C17 %s
+// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-STRICT %s
+// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s -o - \
+// RUN:   -x c -std=c11 -O0 -disable-llvm-passes -debug-info-kind=limited \
+// RUN:   -gstrict-dwarf | FileCheck --check-prefix=CHECK-C11 %s
 
+// CHECK-STRICT: !DICompileUnit(language: DW_LANG_C,
 // CHECK-C11: !DICompileUnit(language: DW_LANG_C11
 // Update this check once support for DW_LANG_C17 is broadly supported/known in
 // consumers. Maybe we'll skip this and go to the DWARFv6 language+version
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -579,7 +579,10 @@
   } else if (LO.RenderScript) {
 LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
   } else if (LO.C11) {
-LangTag = llvm::dwarf::DW_LANG_C11;
+if (CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
+  LangTag = llvm::dwarf::DW_LANG_C;
+else
+  LangTag = llvm::dwarf::DW_LANG_C11;
   } else if (LO.C99) {
 LangTag = llvm::dwarf::DW_LANG_C99;
   } else {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140423: [WIP][clang] Add PrintingPolicy callback for identifying default template arguments

2022-12-22 Thread Michael Buch via Phabricator via cfe-commits
Michael137 created this revision.
Michael137 added reviewers: aprantl, dblaikie.
Herald added a project: All.
Michael137 added a comment.
Michael137 updated this revision to Diff 484341.
Michael137 added a reviewer: labath.
Michael137 edited the summary of this revision.
Michael137 added a reviewer: aaron.ballman.
Michael137 updated this revision to Diff 484434.
Michael137 updated this revision to Diff 484439.
Michael137 published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

An example of how this would be used from LLDB is: 
https://reviews.llvm.org/D140145


Michael137 added a comment.

- Remove debug print in test


aprantl added a comment.

Overall this seems to have a pretty small surface area, so I'd be fine with 
including this.


Michael137 added a comment.

@aaron.ballman we're trying to fix printing of C++ types with default template 
arguments in LLDB. Currently DWARF doesn't have the necessary info to construct 
a `ClassTemplateDecl` with generic parameters, which means the logic for 
suppressing them in the `TypePrinter` doesn't quite work.

This patch outlines of one approach we considered. We add a hook into the 
TypePrinter to allow external AST sources to answer the question "is template 
argument X defaulted?".

Another alternative would be to have a `TemplateArgument::IsDefaulted` which 
gets set in LLDB and read from the TypePrinter.

Do you think either of these approaches would be fine for inclusion?


Michael137 added a comment.

- Fix test. Move variable into loop


Michael137 added a comment.

- Rebase


Michael137 added a comment.

putting into review queue to hear people's opinion on something along these 
lines




Comment at: clang/include/clang/AST/PrettyPrinter.h:52
+
+  enum class TriState : int { kYes, kNo, kUnknown };
+

The TrisState is needed because LLDB has two AST sources:
1. DWARF
2. clang modules

When we import a type from a clang module we would never have consulted DWARF 
about whether a parameter was defaulted. So instead of more complex bookkeeping 
it seemed simpler to say "if we've never seen this decl when parsing DWARF, I 
can't say anything about the default-ness of the arguments"



Comment at: clang/lib/AST/TypePrinter.cpp:2095
+
+  while (!Args.empty()) {
+if (Callbacks != nullptr)

maybe this body becomes slightly less oddly indented when converting it to a 
range-based for with a counter?


This patch adds a hook into the `TypePrinter` to allow clients
decide whether a template argument corresponds to the default
parameter.

**Motivation**

DWARF encodes information about template instantiations, but
not about the generic definition of a template. If an argument
in a template instantiation corresponds to the default parameter
of the generic template then DWARF will attach a `DW_AT_default_value`
to that argument. LLDB uses the Clang TypePrinter for
displaying/formatting C++ types but currently can't give Clang the 
`ClassTemplateDecl`
that it expects. Since LLDB does know whether a particular instantiation has
default arguments, this patch allows LLDB (and other clients with external AST 
sources)
to help Clang in identifying those default arguments.

**Alternatives**

1. Encode information about generic template definitions in DWARF. It's unclear 
how long it would take to get this proposed and implemented and whether 
something like this would work in the first place. If we could construct 
`ClassTemplateDecl`s with the correct generic parameters this patch wouldn't be 
required.

2. Add something like a `bool IsDefaulted` somewhere in Clang, e.g., in 
`TemplateArgument` and consult it from the `TypePrinter`. This would be much 
simpler but requires adding a field on one of the Clang types


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140423

Files:
  clang/include/clang/AST/PrettyPrinter.h
  clang/include/clang/AST/Type.h
  clang/lib/AST/TypePrinter.cpp
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -127,3 +127,39 @@
 Policy.EntireContentsOfLargeArray = true;
   }));
 }
+
+TEST(TypePrinter, TemplateParameterListWithCallback) {
+  constexpr char Code[] = R"cpp(
+template 
+struct Foo {   
+}; 
+   
+Foo X;   
+  )cpp";
+  auto Matcher = classTemplateSpecializationDecl(
+  hasName("Foo"), has(cxxConstructorDecl(
+  has(parmVarDecl(hasType(qualType().bind("id")));
+
+  struct DefaulterCallback final : public PrintingCallbacks {
+virtual TriState
+IsTemplateArgumentDefaulted(clang::ClassTemplateSpecializationDecl const *,
+   

[clang] aeb8f91 - [Clang][LoongArch] Add intrinsic for asrtle, asrtgt, lddir, ldpte and cpucfg

2022-12-22 Thread via cfe-commits
Author: gonglingqin
Date: 2022-12-22T18:56:34+08:00
New Revision: aeb8f911b1695778aa518db4bed471e8447dc57f

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

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

`__cpucfg` is required by Linux [1].

[1]: 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/loongarch/include/asm/loongarch.h#n59

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

Added: 


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

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsLoongArch.def 
b/clang/include/clang/Basic/BuiltinsLoongArch.def
index 5b0dd799a4bc..98b1738b7223 100644
--- a/clang/include/clang/Basic/BuiltinsLoongArch.def
+++ b/clang/include/clang/Basic/BuiltinsLoongArch.def
@@ -21,6 +21,9 @@ TARGET_BUILTIN(__builtin_loongarch_dbar, "vIUi", "nc", "")
 TARGET_BUILTIN(__builtin_loongarch_ibar, "vIUi", "nc", "")
 TARGET_BUILTIN(__builtin_loongarch_break, "vIUi", "nc", "")
 TARGET_BUILTIN(__builtin_loongarch_syscall, "vIUi", "nc", "")
+TARGET_BUILTIN(__builtin_loongarch_cpucfg, "UiUi", "nc", "")
+TARGET_BUILTIN(__builtin_loongarch_asrtle_d, "vLiLi", "nc", "64bit")
+TARGET_BUILTIN(__builtin_loongarch_asrtgt_d, "vLiLi", "nc", "64bit")
 
 TARGET_BUILTIN(__builtin_loongarch_crc_w_b_w, "iii", "nc", "64bit")
 TARGET_BUILTIN(__builtin_loongarch_crc_w_h_w, "iii", "nc", "64bit")
@@ -47,5 +50,8 @@ TARGET_BUILTIN(__builtin_loongarch_iocsrwr_h, "vUiUi", "nc", 
"")
 TARGET_BUILTIN(__builtin_loongarch_iocsrwr_w, "vUiUi", "nc", "")
 TARGET_BUILTIN(__builtin_loongarch_iocsrwr_d, "vULiUi", "nc", "64bit")
 
+TARGET_BUILTIN(__builtin_loongarch_lddir_d, "LiLiIULi", "nc", "64bit")
+TARGET_BUILTIN(__builtin_loongarch_ldpte_d, "vLiIULi", "nc", "64bit")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fc7b73d9ee6e..a194fc7b105c 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -19724,6 +19724,21 @@ Value 
*CodeGenFunction::EmitLoongArchBuiltinExpr(unsigned BuiltinID,
   case LoongArch::BI__builtin_loongarch_iocsrwr_d:
 ID = Intrinsic::loongarch_iocsrwr_d;
 break;
+  case LoongArch::BI__builtin_loongarch_cpucfg:
+ID = Intrinsic::loongarch_cpucfg;
+break;
+  case LoongArch::BI__builtin_loongarch_asrtle_d:
+ID = Intrinsic::loongarch_asrtle_d;
+break;
+  case LoongArch::BI__builtin_loongarch_asrtgt_d:
+ID = Intrinsic::loongarch_asrtgt_d;
+break;
+  case LoongArch::BI__builtin_loongarch_lddir_d:
+ID = Intrinsic::loongarch_lddir_d;
+break;
+  case LoongArch::BI__builtin_loongarch_ldpte_d:
+ID = Intrinsic::loongarch_ldpte_d;
+break;
 // TODO: Support more Intrinsics.
   }
 

diff  --git a/clang/lib/Headers/larchintrin.h b/clang/lib/Headers/larchintrin.h
index 787b7b8deda2..22e6d4025c98 100644
--- a/clang/lib/Headers/larchintrin.h
+++ b/clang/lib/Headers/larchintrin.h
@@ -139,12 +139,38 @@ extern __inline void
   __builtin_loongarch_iocsrwr_w((unsigned int)_1, (unsigned int)_2);
 }
 
+extern __inline unsigned int
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__cpucfg(unsigned int _1) {
+  return (unsigned int)__builtin_loongarch_cpucfg((unsigned int)_1);
+}
+
 #if __loongarch_grlen == 64
 extern __inline void
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
 __iocsrwr_d(unsigned long int _1, unsigned int _2) {
   __builtin_loongarch_iocsrwr_d((unsigned long int)_1, (unsigned int)_2);
 }
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__asrtgt_d(long int _1, long int _2) {
+  __builtin_loongarch_asrtgt_d((long int)_1, (long int)_2);
+}
+
+extern __inline void
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__asrtle_d(long int _1, long int _2) {
+  __builtin_loongarch_asrtle_d((long int)_1, (long int)_2);
+}
+#endif
+
+#if __loongarch_grlen == 64
+#define __lddir_d(/*long int*/ _1, /*ui5*/ _2) 
\
+

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

2022-12-22 Thread Gong LingQin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaeb8f911b169: [Clang][LoongArch] Add intrinsic for asrtle, 
asrtgt, lddir, ldpte and cpucfg (authored by gonglingqin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139915

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

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

[clang] e726703 - [Clang][LoongArch] Add intrinsic for rdtime_d, rdtimeh_w and rdtimel_w

2022-12-22 Thread via cfe-commits
Author: gonglingqin
Date: 2022-12-22T19:21:22+08:00
New Revision: e726703c27c417ffb5917eca4760ea3c4f4a62d5

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

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

Add these intrinsics to keep consistent with GCC [1].

[1]: 
https://github.com/gcc-mirror/gcc/blob/master/gcc/config/loongarch/larchintrin.h#L33

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Headers/larchintrin.h b/clang/lib/Headers/larchintrin.h
index 22e6d4025c98..524c13489db1 100644
--- a/clang/lib/Headers/larchintrin.h
+++ b/clang/lib/Headers/larchintrin.h
@@ -14,6 +14,46 @@
 extern "C" {
 #endif
 
+typedef struct rdtime {
+  unsigned int value;
+  unsigned int timeid;
+} __rdtime_t;
+
+#if __loongarch_grlen == 64
+typedef struct drdtime {
+  unsigned long dvalue;
+  unsigned long dtimeid;
+} __drdtime_t;
+
+extern __inline __drdtime_t
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__rdtime_d(void) {
+  __drdtime_t __drdtime;
+  __asm__ volatile(
+  "rdtime.d %[val], %[tid]\n\t"
+  : [val] "=&r"(__drdtime.dvalue), [tid] "=&r"(__drdtime.dtimeid));
+  return __drdtime;
+}
+#endif
+
+extern __inline __rdtime_t
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__rdtimeh_w(void) {
+  __rdtime_t __rdtime;
+  __asm__ volatile("rdtimeh.w %[val], %[tid]\n\t"
+   : [val] "=&r"(__rdtime.value), [tid] 
"=&r"(__rdtime.timeid));
+  return __rdtime;
+}
+
+extern __inline __rdtime_t
+__attribute__((__gnu_inline__, __always_inline__, __artificial__))
+__rdtimel_w(void) {
+  __rdtime_t __rdtime;
+  __asm__ volatile("rdtimel.w %[val], %[tid]\n\t"
+   : [val] "=&r"(__rdtime.value), [tid] 
"=&r"(__rdtime.timeid));
+  return __rdtime;
+}
+
 #if __loongarch_grlen == 64
 extern __inline int
 __attribute__((__gnu_inline__, __always_inline__, __artificial__))

diff  --git a/clang/test/CodeGen/LoongArch/intrinsic-la32-error.c 
b/clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
index 56ac396624f2..cca7f14c94c4 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la32-error.c
@@ -111,3 +111,7 @@ void lddir_d(long int a, int b) {
 void ldpte_d(long int a, int b) {
   __builtin_loongarch_ldpte_d(a, 1); // expected-error {{this builtin requires 
target: loongarch64}}
 }
+
+void rdtime_d() {
+  __rdtime_d(); // expected-error {{call to undeclared function '__rdtime_d'}}
+}

diff  --git a/clang/test/CodeGen/LoongArch/intrinsic-la32.c 
b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
index 529732ebf648..dbfa554acb4f 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la32.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la32.c
@@ -166,3 +166,14 @@ unsigned int cpucfg(unsigned int a) {
   unsigned int c = __builtin_loongarch_cpucfg(a);
   return 0;
 }
+
+// LA32-LABEL: @rdtime(
+// LA32-NEXT:  entry:
+// LA32-NEXT:[[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect 
"rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
+// LA32-NEXT:[[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect 
"rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
+// LA32-NEXT:ret void
+//
+void rdtime() {
+  __rdtimeh_w();
+  __rdtimel_w();
+}

diff  --git a/clang/test/CodeGen/LoongArch/intrinsic-la64.c 
b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
index 11f54087fab1..da39d45b8667 100644
--- a/clang/test/CodeGen/LoongArch/intrinsic-la64.c
+++ b/clang/test/CodeGen/LoongArch/intrinsic-la64.c
@@ -373,3 +373,23 @@ unsigned int cpucfg(unsigned int a) {
   unsigned int c = __builtin_loongarch_cpucfg(a);
   return 0;
 }
+
+// CHECK-LABEL: @rdtime_d(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { i64, i64 } asm sideeffect 
"rdtime.d $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
+// CHECK-NEXT:ret void
+//
+void rdtime_d() {
+  __rdtime_d();
+}
+
+// CHECK-LABEL: @rdtime(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect 
"rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
+// CHECK-NEXT:[[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect 
"rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !4
+// CHECK-NEXT:ret void
+//
+void rdtime() {
+  __rdtimeh_w();
+  __rdtimel_w();
+}



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


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

2022-12-22 Thread Gong LingQin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe726703c27c4: [Clang][LoongArch] Add intrinsic for rdtime_d, 
rdtimeh_w and rdtimel_w (authored by gonglingqin).

Changed prior to commit:
  https://reviews.llvm.org/D139987?vs=484466&id=484792#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139987

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

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


[PATCH] D138392: clang/HIP: Fix broken implementations of __make_mantissa* functions

2022-12-22 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

4086ea331cad827d74542e52a86b7d7933376e7b


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

https://reviews.llvm.org/D138392

___
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-22 Thread Francesco Petrogalli via Phabricator via cfe-commits
fpetrogalli updated this revision to Diff 484795.
fpetrogalli added a comment.

I added some fixes to make it work when building with modules 
(`-DLLVM_ENABLE_MODULES=On`).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137517

Files:
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  llvm/include/llvm/CMakeLists.txt
  llvm/include/llvm/TargetParser/CMakeLists.txt
  llvm/include/llvm/TargetParser/RISCVTargetParser.def
  llvm/include/llvm/TargetParser/RISCVTargetParser.h
  llvm/include/llvm/TargetParser/TargetParser.h
  llvm/include/llvm/module.extern.modulemap
  llvm/include/llvm/module.install.modulemap
  llvm/include/llvm/module.modulemap
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.h
  llvm/lib/TargetParser/CMakeLists.txt
  llvm/lib/TargetParser/RISCVTargetParser.cpp
  llvm/lib/TargetParser/TargetParser.cpp
  llvm/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(const 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,62 @@
+//===- RISCVTargetDefEmitter.cpp - Generate lists of RISCV CPUs ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This tablegen backend emits the include file needed by the target
+// parser to parse the RISC-V CPUs.
+//
+//===--===//
+
+#include "TableGenBackends.h"
+#include "llvm/TableGen/Record.h"
+
+using namespace llvm;
+
+static std::string getEnumFeatures(const Record &Rec) {
+  std::vector Features = Rec.getValueAsListOfDefs("Features");
+  if (find_if(Features, [](const Record *R) {
+return R->getName() == "Feature64Bit";
+  }) != Features.end())
+return "FK_64BIT";
+
+  return "FK_NONE";
+}
+
+void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
+  using MapTy = std::pair>;
+  using RecordMap = std::map, std::less<>>;
+  const RecordMap &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 (const MapTy &Def : Map) {
+const Record &Rec = *(Def.second);
+if (Rec.isSubClassOf("RISCVProcessorModelPROC"))
+  OS << "PROC(" << Rec.getName() << ", "
+ << "{\"" << Rec.getValueAsString("Name") << "\"},"
+ << getEnumFeatures(Rec) << ", "
+ << "{\"" << Rec.getValueAsString("DefaultMarch") << "\"})\n";
+  }
+  OS << "\n#undef PROC\n";
+  OS << "\n";
+  OS << "#ifndef TUNE_PROC\n"
+ << "#define TUNE_PROC(ENUM, NAME)\n"
+ << "#endif\n\n";
+  OS << "TUNE_PROC(GENERIC, \"generic\")\n";
+  for (const MapTy &Def : Map) {
+const Record &Rec = *(Def.second);
+

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

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

In D137517#4012449 , @pcwang-thead 
wrote:

> In D137517#4012307 , @craig.topper 
> wrote:
>
>> In D137517#4012298 , @pcwang-thead 
>> wrote:
>>
>>> In D137517#4009175 , @fpetrogalli 
>>> wrote:
>>>
 @pcwang-thead, I addressed some of your comments.

 The value of `EnumFeatures` is now computed dynamicaly from the
 `Features` field of the `Processor` class.
>>>
>>> Thanks! That sounds great to me!
>>>
 As for generating `MArch` out of the `Features` field, @craig.topper
 pointed me at
 https://github.com/riscv-non-isa/riscv-toolchain-conventions/issues/11. 
 From
 the reading of it, it seems that the alphabetical order is enough to
 build the string that carries `MArch`. Am I missing something?
>>>
>>> Currently, I think the alphabetical order is OK. If we relax the checking 
>>> of arch string someday, there is no doubt that we should change the 
>>> implementation here too.
>>
>> The currently accepted order isn’t alphabetical. The single letter 
>> extensions have a specific order. The z extensions are ordered by looking up 
>> the second letter in the single letter order. If we alphabetize here i don’t 
>> think it will be accepted by the frontend.
>
> Oops, my mistake.
>
> Here is my PoC to generate march from Features:
>
>   diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td
>   index d1d0356179f5..b2520f25bfea 100644
>   --- a/llvm/lib/Target/RISCV/RISCV.td
>   +++ b/llvm/lib/Target/RISCV/RISCV.td
>   @@ -556,8 +556,8 @@ include "RISCVSchedSyntacoreSCR1.td"
>class RISCVProcessorModelPROC  SchedMachineModel m,
>  list f,
>   -  string default_march = "",
>   -  list tunef = []> :  
> ProcessorModel {
>   +  list tunef = [],
>   +  string default_march = ""> :  
> ProcessorModel {
>  string DefaultMarch = default_march;
>}
>   diff --git a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp 
> b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
>   index b216e82cef6c..eea31e6ddea8 100644
>   --- a/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
>   +++ b/llvm/utils/TableGen/RISCVTargetDefEmitter.cpp
>   @@ -13,17 +13,33 @@
>
>#include "TableGenBackends.h"
>#include "llvm/TableGen/Record.h"
>   +#include "llvm/Support/RISCVISAInfo.h"
>
>using namespace llvm;
>
>   -static std::string getEnumFeatures(const Record &Rec) {
>   +static int getXLen(const Record &Rec) {
>  std::vector Features = Rec.getValueAsListOfDefs("Features");
>  if (find_if(Features, [](const Record *R) {
>return R->getName() == "Feature64Bit";
>  }) != Features.end())
>   -return "FK_64BIT";
>   +return 64;
>
>   -  return "FK_NONE";
>   +  return 32;
>   +}
>   +
>   +static std::string getMArch(int XLen, const Record &Rec) {
>   +  std::vector Features = Rec.getValueAsListOfDefs("Features");
>   +  std::vector FeatureVector;
>   +  // Convert Features to FeatureVector.
>   +  for (auto *Feature : Features) {
>   +StringRef FeatureName = Feature->getValueAsString("Name");
>   +if (llvm::RISCVISAInfo::isSupportedExtensionFeature(FeatureName))
>   +  FeatureVector.push_back(std::string("+") + FeatureName.str());
>   +  }
>   +  auto ISAInfo = llvm::RISCVISAInfo::parseFeatures(XLen, FeatureVector);
>   +  if (!ISAInfo)
>   +report_fatal_error("Invalid features: ");
>   +  return (*ISAInfo)->toString();
>}
>
>void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, raw_ostream &OS) {
>   @@ -39,11 +55,17 @@ void llvm::EmitRISCVTargetDef(const RecordKeeper &RK, 
> raw_ostream &OS) {
>  // Iterate on all definition records.
>  for (const MapTy &Def : Map) {
>const Record &Rec = *(Def.second);
>   -if (Rec.isSubClassOf("RISCVProcessorModelPROC"))
>   +if (Rec.isSubClassOf("RISCVProcessorModelPROC")) {
>   +  int XLen = getXLen(Rec);
>   +  std::string EnumFeatures = XLen == 64 ? "FK_64BIT" : "FK_NONE";
>   +  std::string MArch = Rec.getValueAsString("DefaultMarch").str();
>   +  if (MArch == "")
>   +MArch = getMArch(XLen, Rec);
>  OS << "PROC(" << Rec.getName() << ", "
>   - << "{\"" << Rec.getValueAsString("Name") << "\"},"
>   - << getEnumFeatures(Rec) << ", "
>   - << "{\"" << Rec.getValueAsString("DefaultMarch") << "\"})\n";
>   + << "{\"" << Rec.getValueAsString("Name") << "\"}," << EnumFeatures
>   + << ", "
>   + << "{\"" << MArch << "\"})\n";
>   +}
>  }
>  OS << "\n#undef PROC\n";
>  OS << "\n";
>
> The generated file would be like below (the march strings are tedious but I 
> think that would

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

2022-12-22 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added a comment.

> @pcwang-thead, may I ask you to own these further optimisations of the 
> generative process, and submit a patch for it after the current patch lands? 
> I'd happily review it!
>
> The reason I am asking this is because the current patch is mostly dealing 
> with making sure we can build clang/llvm after removing the def file.  People 
> are discussing dependencies and modules (for example, last update I did was 
> to make the patch work for modules with `-DLLVM_ENABLE_MODULES=On`), and this 
> is already taking quite a number of comments.
> There is value in the discussion on how to build march out of the features, 
> I'd rather keep it in a separate submission so that the threads do not get 
> lost among the other comments for this patch.
>
> Francesco

Yes, I am happy to do it. :-)


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] D127812: [AArch64] FMV support and necessary target features dependencies.

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

In D127812#4012283 , @hctim wrote:

> I'm not sure "MSan didn't handle correctly SmallVector" is the case. Given 
> your diagnosis of 3-elements-vs-2, I'm guessing the root cause is that 
> `clang/lib/Sema/SemaDecl.cpp:11369` is wrong:
>
>   !std::equal(CurClones->featuresStrs_begin(),
>   CurClones->featuresStrs_end(),
>   NewClones->featuresStrs_begin( {
>
> This construction of `std::equal` is very error-prone, as if 
> `NewClones.size() < CurClones.size()`, then this invariable leads to 
> buffer-overflow. I'm wondering if that's the underlying cause, it would seem 
> entirely possible that expanding the in-place elements are always 
> "initialized" from MSan's perspective and so the current code has a 
> false-negative, and your new code made it so that the vector is now 
> heap-based, which is revealing the underlying issue. Maybe worth trying one 
> more thing and adding an `assert(CurClones->size() <= NewClones->size());` to 
> double check?

I don't think `std::equal` is underlying cause here. We have 
featuresStrs_size() comparison before calling it:

  if (CurClones && NewClones &&
(CurClones->featuresStrs_size() != NewClones->featuresStrs_size() ||
 !std::equal(CurClones->featuresStrs_begin(),
 CurClones->featuresStrs_end(),
 NewClones->featuresStrs_begin( {

Also even if we completely remove std::equal the use-of-uninitialized-value 
error still persist.


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] D140547: Perform access checking to private members in simple requirement.

2022-12-22 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 created this revision.
Herald added a project: All.
usaxena95 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140547

Files:
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/class.access/p4.cpp
  clang/test/CXX/drs/dr6xx.cpp
  clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
  clang/test/SemaCXX/access.cpp

Index: clang/test/SemaCXX/access.cpp
===
--- clang/test/SemaCXX/access.cpp
+++ clang/test/SemaCXX/access.cpp
@@ -115,13 +115,13 @@
 namespace N {
 class Y {
   template friend struct X;
-  int t; // expected-note {{here}}
+  int t; // expected-note 2 {{here}}
 };
 }
 template struct X {
-  X() { (void)N::Y().t; } // expected-error {{private}}
+  X() { (void)N::Y().t; } // expected-error 2 {{private}}
 };
-X x;
+X x; // expected-note {{in instantiation of member function}}
   }
   namespace comment2 {
 struct X;
Index: clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
+++ clang/test/CXX/temp/temp.decls/temp.friend/p1.cpp
@@ -97,17 +97,17 @@
 friend class User;
 friend bool transform<>(Bool, bool);
 
-bool value; // expected-note 2 {{declared private here}}
+bool value; // expected-note 4 {{declared private here}}
   };
 
   template  class User {
 static T compute(Bool b) {
-  return b.value; // expected-error {{'value' is a private member of 'test3::Bool'}}
+  return b.value; // expected-error 2 {{'value' is a private member of 'test3::Bool'}}
 }
   };
 
   template  T transform(Bool b, T value) {
-if (b.value) // expected-error {{'value' is a private member of 'test3::Bool'}}
+if (b.value) // expected-error 2 {{'value' is a private member of 'test3::Bool'}}
   return value;
 return value + 1;
   }
@@ -222,7 +222,7 @@
   template  A bar(const T*, const A&);
   template  class A {
   private:
-void foo(); // expected-note {{declared private here}}
+void foo(); // expected-note 2 {{declared private here}}
 friend A bar<>(const T*, const A&);
   };
 
@@ -231,7 +231,7 @@
 l1.foo();
 
 A l2;
-l2.foo(); // expected-error {{'foo' is a private member of 'test10::A'}}
+l2.foo(); // expected-error 2 {{'foo' is a private member of 'test10::A'}}
 
 return l1;
   }
Index: clang/test/CXX/drs/dr6xx.cpp
===
--- clang/test/CXX/drs/dr6xx.cpp
+++ clang/test/CXX/drs/dr6xx.cpp
@@ -882,11 +882,17 @@
 friend int dr674::g(int);
 friend int dr674::h<>(int);
 int n; // expected-note 2{{private}}
+#if __cplusplus  >= 201103L
+  // expected-note@-2 {{private}}
+#endif
   };
 
   template int f(T) { return X().n; }
   int g(int) { return X().n; }
   template int g(T) { return X().n; } // expected-error {{private}}
+  #if __cplusplus  >= 201103L
+// expected-error@-2 {{private}}
+  #endif
   int h(int) { return X().n; } // expected-error {{private}}
   template int h(T) { return X().n; }
 
@@ -910,11 +916,17 @@
 friend int Y::g(int);
 friend int Y::h<>(int);
 int n; // expected-note 2{{private}}
+#if __cplusplus >= 201103L
+  // expected-note@-2 {{private}}
+#endif
   };
 
   template int Y::f(T) { return Z().n; }
   int Y::g(int) { return Z().n; }
   template int Y::g(T) { return Z().n; } // expected-error {{private}}
+  #if __cplusplus  >= 201103L
+// expected-error@-2 {{private}}
+  #endif
   int Y::h(int) { return Z().n; } // expected-error {{private}}
   template int Y::h(T) { return Z().n; }
 
Index: clang/test/CXX/class.access/p4.cpp
===
--- clang/test/CXX/class.access/p4.cpp
+++ clang/test/CXX/class.access/p4.cpp
@@ -503,26 +503,26 @@
 namespace test15 {
   template  class A {
   private:
-int private_foo; // expected-note {{declared private here}}
-static int private_sfoo; // expected-note {{declared private here}}
+int private_foo; // expected-note 2 {{declared private here}}
+static int private_sfoo; // expected-note 2 {{declared private here}}
   protected:
-int protected_foo; // expected-note 3 {{declared protected here}} // expected-note {{can only access this member on an object of type 'test15::B'}}
-static int protected_sfoo; // expected-note 3 {{declared protected here}}
+int protected_foo; // expected-note 6 {{declared protected here}} // expected-note 2 {{can only access this member on an object of type 'test15::B'}}
+static int protected_sfoo; // expected-note 6 {{declared protected here}}
 
 int test1(A &a) {
-  return a.private_foo; // expected-error {{private member}}
+  return a.private_foo;

[PATCH] D140532: .clang-tidy: disable misc-use-anonymous-namespace check.

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

Yeah, good call. Do you mind if I first use this as a trigger to start a thread 
about this style rule on discourse, though? I've been meaning to, it came up in 
a review recently.

I think there's a fair chance of changing the policy from "require static" to 
"allow either" or "require anon namespace", and having the issue "live" in 
clang-tidy might make for a more engaged discussion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140532

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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 484801.
owenpan added a comment.

Fixes a couple of bugs.


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

https://reviews.llvm.org/D140543

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.h

Index: clang/lib/Format/IntegerLiteralSeparatorFixer.h
===
--- /dev/null
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.h
@@ -0,0 +1,39 @@
+//===--- IntegerLiteralSeparatorFixer.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file declares IntegerLiteralSeparatorFixer that fixes C++ integer
+/// literal separators.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_FORMAT_INTEGERLITERALSEPARATORFIXER_H
+#define LLVM_CLANG_LIB_FORMAT_INTEGERLITERALSEPARATORFIXER_H
+
+#include "TokenAnalyzer.h"
+
+namespace clang {
+namespace format {
+
+class IntegerLiteralSeparatorFixer {
+public:
+  std::pair
+  process(const Environment &Env, const FormatStyle &Style) const;
+
+private:
+  static const auto Separator = '\'';
+
+  bool checkSeparator(const StringRef IntegerLiteral, int DigitsPerGroup) const;
+  std::string format(const StringRef IntegerLiteral, int DigitsPerGroup,
+ bool RemoveSeparator) const;
+};
+
+} // end namespace format
+} // end namespace clang
+
+#endif
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- /dev/null
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -0,0 +1,176 @@
+//===--- IntegerLiteralSeparatorFixer.cpp ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file implements IntegerLiteralSeparatorFixer that fixes C++ integer
+/// literal separators.
+///
+//===--===//
+
+#include "IntegerLiteralSeparatorFixer.h"
+
+namespace clang {
+namespace format {
+
+enum class Base { Binary, Decimal, Hex, Other };
+
+static Base getBase(const StringRef IntegerLiteral) {
+  assert(IntegerLiteral.size() > 1);
+
+  if (IntegerLiteral[0] > '0') {
+assert(IntegerLiteral[0] <= '9');
+return Base::Decimal;
+  }
+
+  assert(IntegerLiteral[0] == '0');
+
+  switch (IntegerLiteral[1]) {
+  case 'b':
+  case 'B':
+return Base::Binary;
+  case 'x':
+  case 'X':
+return Base::Hex;
+  default:
+return Base::Other;
+  }
+}
+
+std::pair
+IntegerLiteralSeparatorFixer::process(const Environment &Env,
+  const FormatStyle &Style) const {
+  const auto &Option = Style.IntegerLiteralSeparator;
+  const auto Binary = Option.Binary;
+  const auto Decimal = Option.Decimal;
+  const auto Hex = Option.Hex;
+  const bool SkipBinary = Binary == 0;
+  const bool SkipDecimal = Decimal == 0;
+  const bool SkipHex = Hex == 0;
+
+  if (SkipBinary && SkipDecimal && SkipHex)
+return {};
+
+  const auto ID = Env.getFileID();
+  const auto &SourceMgr = Env.getSourceManager();
+  std::unique_ptr Lex;
+  Lex.reset(new Lexer(ID, SourceMgr.getBufferOrFake(ID), SourceMgr,
+  getFormattingLangOpts(Style)));
+  Lex->SetCommentRetentionState(true);
+
+  Token Tok;
+  Lex->LexFromRawLexer(Tok);
+
+  tooling::Replacements Result;
+  for (bool Skip = false; Tok.isNot(tok::eof); Lex->LexFromRawLexer(Tok)) {
+auto Length = Tok.getLength();
+if (Length < 2)
+  continue;
+auto Location = Tok.getLocation();
+auto Text = StringRef(SourceMgr.getCharacterData(Location), Length);
+if (Tok.is(tok::comment)) {
+  if (Text == "// clang-format off" || Text == "/* clang-format off */")
+Skip = true;
+  if (Text == "// clang-format on" || Text == "/* clang-format on */")
+Skip = false;
+  continue;
+}
+if (Skip || Tok.isNot(tok::numeric_constant))
+  continue;
+const auto B = getBase(Text);
+const bool IsBase2 = B == Base::Binary;
+const bool IsBase10 = B == Base::Decimal;
+const bool IsBase16 = B == Base::Hex;
+if ((IsBase2 && SkipBinary) || (IsBase10 && SkipDecimal) ||
+(IsBase16 && SkipHex) || B == Base::Other) {
+  continue;
+}

[PATCH] D138394: HIP: Directly call fma builtins

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

ping


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

https://reviews.llvm.org/D138394

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


[PATCH] D136554: Implement CWG2631

2022-12-22 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 484802.
cor3ntin added a comment.

Thanks @rupprecht

As all good bugs, this was very confusing up 
until the moment it became obvious.

I did not make the initializer a full expression during parsing,
(but on use), as I thought that was unecessary.
But then if that initializer had any cleanup, the next expression 
being parsed would get cleanups instead.

So here kFooDelimiter initializer would be wrapped in ExprWithCleanup 
(it clearly should not), if an only if Xyz was parsed before hand.

I added an ast dump test for that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/UsedDeclVisitor.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/test/CXX/class/class.local/p1-0x.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/default-arguments-with-immediate.cpp
  clang/test/CodeGenCXX/meminit-initializers-odr.cpp
  clang/test/PCH/default-argument-with-immediate-calls.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers.cpp
  clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15593,7 +15593,7 @@
 https://wg21.link/cwg2631";>2631
 DR
 Immediate function evaluations in default arguments
-Unknown
+Clang 16
   
   
 https://wg21.link/cwg2632";>2632
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -8,15 +9,22 @@
 template 
 struct Printer;
 
+#ifdef USE_CONSTEVAL
+#define SOURCE_LOC_EVAL_KIND consteval
+#else
+#define SOURCE_LOC_EVAL_KIND constexpr
+#endif
+
 namespace std {
 class source_location {
   struct __impl;
 
 public:
-  static constexpr source_location current(const __impl *__p = __builtin_source_location()) noexcept {
-source_location __loc;
-__loc.__m_impl = __p;
-return __loc;
+  static SOURCE_LOC_EVAL_KIND source_location
+current(const __impl *__p = __builtin_source_location()) noexcept {
+  source_location __loc;
+  __loc.__m_impl = __p;
+  return __loc;
   }
   constexpr source_location() = default;
   constexpr source_location(source_location const &) = default;
@@ -593,3 +601,73 @@
   }
   static_assert(test());
 }
+
+namespace Lambda {
+#line 8000 "TestLambda.cpp"
+constexpr int nested_lambda(int l = []{
+  return SL::current().line();
+}()) {
+  return l;
+}
+static_assert(nested_lambda() == __LINE__ - 4);
+
+constexpr int lambda_param(int l = [](int l = SL::current().line()) {
+  return l;
+}()) {
+  return l;
+}
+static_assert(lambda_param() == __LINE__);
+
+
+}
+
+constexpr int compound_literal_fun(int a =
+  (int){ SL::current().line() }
+) { return a ;}
+static_assert(compound_literal_fun() == __LINE__);
+
+struct CompoundLiteral {
+  int a = (int){ SL::current().line() };
+};
+static_assert(CompoundLiteral{}.a == __LINE__);
+
+
+// FIXME
+// Init captures are subexpressions of the lambda expression
+// so according to the standard immediate invocations in init captures
+// should be evaluated at the call site.
+// However Clang does not yet implement this as it would introduce
+// a fair bit of complexity.
+// We intend to implement that functionality once we find real world
+// use cases that require it.
+constexpr int test_init_capture(int a =
+[b = SL::current().line()] { return b; }()) {
+  return a;
+}
+#ifdef USE_CONSTEVAL
+static_assert(test_init_capture() == __LINE__ - 4);
+#else
+static_assert(test_init_capture() == __LINE__ );
+#endif
+
+namespace check_immediate_invocations_in_templates {
+
+template 
+struct G {
+T line = __builtin_LINE();
+};
+template 
+struct S {
+int i = G{}.line;
+};
+static_assert(S{}.i != // intentional new line
+

[PATCH] D139784: [Doc] Refactor descriptions of `min-legal-vector-width`

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 484805.
pengfei added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Move doc to comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139784

Files:
  clang/lib/CodeGen/CodeGenFunction.cpp


Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -492,13 +492,19 @@
   if (CurFnInfo->getMaxVectorWidth() > LargestVectorWidth)
 LargestVectorWidth = CurFnInfo->getMaxVectorWidth();
 
-  // Add the required-vector-width attribute. This contains the max width from:
-  // 1. min-vector-width attribute used in the source program.
+  // Add the min-legal-vector-width attribute. This contains the max width 
from:
+  // 1. min-legal-vector-width attribute used in the source program.
   // 2. Any builtins used that have a vector width specified.
   // 3. Values passed in and out of inline assembly.
   // 4. Width of vector arguments and return types for this function.
-  // 5. Width of vector aguments and return types for functions called by this
+  // 5. Width of vector arguments and return types for functions called by this
   //function.
+  // This attribute is intended for X86 backend use only. The "min legal" in 
the
+  // name means the minimum width in bits that vector types have must be 
treated
+  // as legal types by code generator.
+  // Note: The attribute doesn't guarantee arbitrary vector width specified 
will
+  // be treated as legal type in code generator. Users are not encouraged to
+  // directly pass or return vector types out of the capacity of their targets.
   if (getContext().getTargetInfo().getTriple().isX86())
 CurFn->addFnAttr("min-legal-vector-width",
  llvm::utostr(LargestVectorWidth));


Index: clang/lib/CodeGen/CodeGenFunction.cpp
===
--- clang/lib/CodeGen/CodeGenFunction.cpp
+++ clang/lib/CodeGen/CodeGenFunction.cpp
@@ -492,13 +492,19 @@
   if (CurFnInfo->getMaxVectorWidth() > LargestVectorWidth)
 LargestVectorWidth = CurFnInfo->getMaxVectorWidth();
 
-  // Add the required-vector-width attribute. This contains the max width from:
-  // 1. min-vector-width attribute used in the source program.
+  // Add the min-legal-vector-width attribute. This contains the max width from:
+  // 1. min-legal-vector-width attribute used in the source program.
   // 2. Any builtins used that have a vector width specified.
   // 3. Values passed in and out of inline assembly.
   // 4. Width of vector arguments and return types for this function.
-  // 5. Width of vector aguments and return types for functions called by this
+  // 5. Width of vector arguments and return types for functions called by this
   //function.
+  // This attribute is intended for X86 backend use only. The "min legal" in the
+  // name means the minimum width in bits that vector types have must be treated
+  // as legal types by code generator.
+  // Note: The attribute doesn't guarantee arbitrary vector width specified will
+  // be treated as legal type in code generator. Users are not encouraged to
+  // directly pass or return vector types out of the capacity of their targets.
   if (getContext().getTargetInfo().getTriple().isX86())
 CurFn->addFnAttr("min-legal-vector-width",
  llvm::utostr(LargestVectorWidth));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139701: [Clang] Emit "min-legal-vector-width" attribute for X86 only

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: llvm/docs/LangRef.rst:2235-2241
-``"min-legal-vector-width"=""``
-This attribute indicates the minimum legal vector width required by the
-calling convension. It is the maximum width of vector arguments and
-returnings in the function and functions called by this function. Because
-all the vectors are supposed to be legal type for compatibility.
-Backends are free to ignore the attribute if they don't need to support
-different maximum legal vector types or such information can be inferred by

arsenm wrote:
> This still should be documented somewhere. I don't know if we document any 
> target attributes specifically in the langref
Added in D139784, PTAL.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139701

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


[PATCH] D139784: [Doc] Refactor descriptions of `min-legal-vector-width`

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:502-504
+  // This attribute is intended for X86 backend use only. The "min legal" in 
the
+  // name means the minimum width in bits that vector types have must be 
treated
+  // as legal types by code generator.

I still think the sentence is ill-formed. But I have tried my best. Welcome for 
suggestions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139784

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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

does it have any unit tests?


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

https://reviews.llvm.org/D140543

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


[clang] 9e03115 - clang/HIP: Fix missing test for __frsqrt_rn

2022-12-22 Thread Matt Arsenault via cfe-commits
Author: Matt Arsenault
Date: 2022-12-22T08:43:15-05:00
New Revision: 9e0311561c8ed4df2d67a5a1fba16a148683c3c9

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

LOG: clang/HIP: Fix missing test for __frsqrt_rn

Added: 


Modified: 
clang/test/Headers/__clang_hip_math.hip

Removed: 




diff  --git a/clang/test/Headers/__clang_hip_math.hip 
b/clang/test/Headers/__clang_hip_math.hip
index a8b95cb0f7b0..edc9731de9bb 100644
--- a/clang/test/Headers/__clang_hip_math.hip
+++ b/clang/test/Headers/__clang_hip_math.hip
@@ -767,6 +767,7 @@ extern "C" __device__ float test_exp2f(float x) {
   return exp2f(x);
 }
 
+//
 // DEFAULT-LABEL: @test_exp2(
 // DEFAULT-NEXT:  entry:
 // DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract double 
@__ocml_exp2_f64(double noundef [[X:%.*]]) #[[ATTR14]]
@@ -3388,6 +3389,20 @@ extern "C" __device__ float test___frcp_rn(float x) {
   return __frcp_rn(x);
 }
 
+// DEFAULT-LABEL: @test___frsqrt_rn(
+// DEFAULT-NEXT:  entry:
+// DEFAULT-NEXT:[[TMP0:%.*]] = tail call contract float 
@llvm.amdgcn.rsq.f32(float [[X:%.*]])
+// DEFAULT-NEXT:ret float [[TMP0]]
+//
+// FINITEONLY-LABEL: @test___frsqrt_rn(
+// FINITEONLY-NEXT:  entry:
+// FINITEONLY-NEXT:[[TMP0:%.*]] = tail call nnan ninf contract float 
@llvm.amdgcn.rsq.f32(float [[X:%.*]])
+// FINITEONLY-NEXT:ret float [[TMP0]]
+//
+extern "C" __device__ float test___frsqrt_rn(float x) {
+  return __frsqrt_rn(x);
+}
+
 // DEFAULT-LABEL: @test___fsqrt_rn(
 // DEFAULT-NEXT:  entry:
 // DEFAULT-NEXT:[[CALL_I:%.*]] = tail call contract float 
@__ocml_native_sqrt_f32(float noundef [[X:%.*]]) #[[ATTR13]]



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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

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



Comment at: clang/include/clang/Format/Format.h:2395
+  /// >0: Insert separators between digits, starting from the rightmost digit.
+  struct IntegerLiteralSeparatorStyle {
+/// \code

Also add Octal?



Comment at: clang/include/clang/Format/Format.h:4121
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
+   IntegerLiteralSeparator.Binary == R.IntegerLiteralSeparator.Binary 
&&
+   IntegerLiteralSeparator.Decimal ==

Below Insert, same above.



Comment at: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp:20
+
+enum class Base { Binary, Decimal, Hex, Other };
+

Other is Octal.


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

https://reviews.llvm.org/D140543

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


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

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

In D140462#4012451 , @nridge wrote:

> Thanks, this is pretty neat!
>
> cc @sammccall as a heads up, just to make sure you're cool with having this 
> in-tree

This has been discussed before, unfortunately while I *thought* it was on a 
bug, it was actually in a PR: https://github.com/clangd/vscode-clangd/pull/140

I don't think it's a good idea to add a third (arguably, fourth/fifth) place 
that the config structure and documentation must be maintained by hand, 
especially one that constrains the structure in non-obvious ways. This needs to 
be automatically generated.

This implies moving the source of truth to something we can generate {fragment 
struct, website, parsing code, YAML schema} from.)

I made an attempt at this in https://reviews.llvm.org/D115425 using TableGen, 
which is the closest LLVM has to a standard way to do this, but the language is 
pretty bad (for this purpose).
YAML itself is the best alternative we came up with to express the schema in. 
Using the JSON-schema itself as the source of truth is another interesting 
option, though it might be simpler to have a format we control.
My recollection was that I thought this was valuable to solve in one way or 
other, and @kadircet (whose call it is now, really) didn't see it as a high 
priority.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140462

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


[clang] 0e8d4a6 - [clang][dataflow] Simplify handling of nullopt-optionals.

2022-12-22 Thread Yitzhak Mandelbaum via cfe-commits
Author: Yitzhak Mandelbaum
Date: 2022-12-22T14:19:49Z
New Revision: 0e8d4a6df9598cf0d654c24bbd3901bfb77d91bb

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

LOG: [clang][dataflow] Simplify handling of nullopt-optionals.

Previously, in the case of an optional constructed from `nullopt`, we relied on
the value constructed for the `nullopt`. This complicates the implementation and
exposes it to bugs (indeed, one such was found), yet doesn't improve the
engine. Instead, this patch constructs a fresh optional representation, rather
than relying on the underlying nullopt representation.

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Removed: 




diff  --git 
a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp 
b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
index da3ffce1d1d8e..07ec16c9cc6ef 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -438,12 +438,11 @@ void transferCallReturningOptional(const CallExpr *E,
   Loc, createOptionalValue(State.Env, State.Env.makeAtomicBoolValue()));
 }
 
-void assignOptionalValue(const Expr &E, LatticeTransferState &State,
+void assignOptionalValue(const Expr &E, Environment &Env,
  BoolValue &HasValueVal) {
   if (auto *OptionalLoc =
-  State.Env.getStorageLocation(E, SkipPast::ReferenceThenPointer)) {
-State.Env.setValue(*OptionalLoc,
-   createOptionalValue(State.Env, HasValueVal));
+  Env.getStorageLocation(E, SkipPast::ReferenceThenPointer)) {
+Env.setValue(*OptionalLoc, createOptionalValue(Env, HasValueVal));
   }
 }
 
@@ -479,7 +478,7 @@ void transferValueOrConversionConstructor(
 LatticeTransferState &State) {
   assert(E->getNumArgs() > 0);
 
-  assignOptionalValue(*E, State,
+  assignOptionalValue(*E, State.Env,
   valueOrConversionHasValue(*E->getConstructor(),
 *E->getArg(0), MatchRes,
 State));
@@ -647,35 +646,35 @@ auto buildTransferMatchSwitch() {
   // make_optional
   .CaseOfCFGStmt(isMakeOptionalCall(), transferMakeOptionalCall)
 
-  // optional::optional
+  // optional::optional (in place)
   .CaseOfCFGStmt(
   isOptionalInPlaceConstructor(),
   [](const CXXConstructExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-assignOptionalValue(*E, State, 
State.Env.getBoolLiteralValue(true));
+assignOptionalValue(*E, State.Env,
+State.Env.getBoolLiteralValue(true));
   })
+  // nullopt_t::nullopt_t
   .CaseOfCFGStmt(
   isNulloptConstructor(),
   [](const CXXConstructExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-assignOptionalValue(*E, State,
+assignOptionalValue(*E, State.Env,
 State.Env.getBoolLiteralValue(false));
   })
+  // optional::optional(nullopt_t)
   .CaseOfCFGStmt(
   isOptionalNulloptConstructor(),
   [](const CXXConstructExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-// Shares a temporary with the underlying `nullopt_t` instance.
-if (auto *OptionalLoc =
-State.Env.getStorageLocation(*E, SkipPast::None)) {
-  State.Env.setValue(
-  *OptionalLoc,
-  *State.Env.getValue(*E->getArg(0), SkipPast::None));
-}
+assignOptionalValue(*E, State.Env,
+State.Env.getBoolLiteralValue(false));
   })
+  // optional::optional (value/conversion)
   
.CaseOfCFGStmt(isOptionalValueOrConversionConstructor(),
transferValueOrConversionConstructor)
 
+
   // optional::operator=
   .CaseOfCFGStmt(
   isOptionalValueOrConversionAssignment(),
@@ -714,7 +713,7 @@ auto buildTransferMatchSwitch() {
   isOptionalMemberCallWithName("emplace"),
   [](const CXXMemberCallExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-assignOptionalValue(*E->getImplicitObjectArgument(), State,
+assignOptionalValue(*E->getImplicitObjectArgument(), State.Env,
 State.Env.getBoolLiteralVal

[PATCH] D140506: [clang][dataflow] Simplify handling of nullopt-optionals.

2022-12-22 Thread Yitzhak Mandelbaum 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 rG0e8d4a6df959: [clang][dataflow] Simplify handling of 
nullopt-optionals. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140506

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -1273,7 +1273,6 @@
 ExpectDiagnosticsFor(SourceCode, ast_matchers::hasName("target"));
   }
 
-private:
   template 
   void ExpectDiagnosticsFor(std::string SourceCode,
 FuncDeclMatcher FuncMatcher) {
@@ -2939,6 +2938,38 @@
   )");
 }
 
+TEST_P(UncheckedOptionalAccessTest, CtorInitializerNullopt) {
+  using namespace ast_matchers;
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct Target {
+  Target(): opt($ns::nullopt) {
+opt.value(); // [[unsafe]]
+  }
+  $ns::$optional opt;
+};
+  )",
+  cxxConstructorDecl(ofClass(hasName("Target";
+}
+
+TEST_P(UncheckedOptionalAccessTest, CtorInitializerValue) {
+  using namespace ast_matchers;
+  ExpectDiagnosticsFor(
+  R"(
+#include "unchecked_optional_access_test.h"
+
+struct Target {
+  Target(): opt(3) {
+opt.value();
+  }
+  $ns::$optional opt;
+};
+  )",
+  cxxConstructorDecl(ofClass(hasName("Target";
+}
+
 // FIXME: Add support for:
 // - constructors (copy, move)
 // - assignment operators (default, copy, move)
Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
===
--- clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
+++ clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
@@ -438,12 +438,11 @@
   Loc, createOptionalValue(State.Env, State.Env.makeAtomicBoolValue()));
 }
 
-void assignOptionalValue(const Expr &E, LatticeTransferState &State,
+void assignOptionalValue(const Expr &E, Environment &Env,
  BoolValue &HasValueVal) {
   if (auto *OptionalLoc =
-  State.Env.getStorageLocation(E, SkipPast::ReferenceThenPointer)) {
-State.Env.setValue(*OptionalLoc,
-   createOptionalValue(State.Env, HasValueVal));
+  Env.getStorageLocation(E, SkipPast::ReferenceThenPointer)) {
+Env.setValue(*OptionalLoc, createOptionalValue(Env, HasValueVal));
   }
 }
 
@@ -479,7 +478,7 @@
 LatticeTransferState &State) {
   assert(E->getNumArgs() > 0);
 
-  assignOptionalValue(*E, State,
+  assignOptionalValue(*E, State.Env,
   valueOrConversionHasValue(*E->getConstructor(),
 *E->getArg(0), MatchRes,
 State));
@@ -647,35 +646,35 @@
   // make_optional
   .CaseOfCFGStmt(isMakeOptionalCall(), transferMakeOptionalCall)
 
-  // optional::optional
+  // optional::optional (in place)
   .CaseOfCFGStmt(
   isOptionalInPlaceConstructor(),
   [](const CXXConstructExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-assignOptionalValue(*E, State, State.Env.getBoolLiteralValue(true));
+assignOptionalValue(*E, State.Env,
+State.Env.getBoolLiteralValue(true));
   })
+  // nullopt_t::nullopt_t
   .CaseOfCFGStmt(
   isNulloptConstructor(),
   [](const CXXConstructExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-assignOptionalValue(*E, State,
+assignOptionalValue(*E, State.Env,
 State.Env.getBoolLiteralValue(false));
   })
+  // optional::optional(nullopt_t)
   .CaseOfCFGStmt(
   isOptionalNulloptConstructor(),
   [](const CXXConstructExpr *E, const MatchFinder::MatchResult &,
  LatticeTransferState &State) {
-// Shares a temporary with the underlying `nullopt_t` instance.
-if (auto *OptionalLoc =
-State.Env.getStorageLocation(*E, SkipPast::None)) {
-  State.Env.setValue(
-  *OptionalLoc,
-  *State.Env.getValue(*E->getArg(0), SkipPast::None));
-}
+assignOptionalValue(*E, State.Env,
+State.Env.getBoolLiteralValue(false));
   })
+  // o

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

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

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/dllimport.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/dllimport.cpp
===
--- clang/test/CodeGenCXX/dllimport.cpp
+++ clang/test/CodeGenCXX/dllimport.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 %s
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 --check-prefix=GL32 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 --check-prefix=GL64 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu-fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-gnu  -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -fms-compatibility-version=18.00 -emit-llvm -std=c++1y -O1 -disable-llvm-passes -o - %s -DMSABI -w | FileCheck --check-prefix=MO1 --check-prefix=M18 %s
@@ -737,8 +737,6 @@
 
 namespace PR19933 {
 // Don't dynamically initialize dllimport vars.
-// MSC2-NOT: @llvm.global_ctors
-// GNU2-NOT: @llvm.global_ctors
 
   struct NonPOD { NonPOD(); };
   template  struct A { static NonPOD x; };
@@ -856,6 +854,12 @@
 USEMEMFUNC(PR23770BaseTemplate, f);
 // M32-DAG: declare dllimport x86_thiscallcc void @"?f@?$PR23770BaseTemplat

[PATCH] D140551: [include-cleaner] Don't count references to operators as uses

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140551

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


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -245,6 +245,16 @@
   testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
 }
 
+TEST(WalkAST, Operator) {
+  // References to operators are not counted as uses.
+  testWalk("struct string {}; int operator+(string, string);",
+   "int k = string() ^+ string();");
+  testWalk("struct string {int operator+(string); }; ",
+   "int k = string() ^+ string();");
+  testWalk("struct string { friend int operator+(string, string); }; ",
+   "int k = string() ^+ string();");
+}
+
 TEST(WalkAST, Functions) {
   // Definition uses declaration, not the other way around.
   testWalk("void $explicit^foo();", "void ^foo() {}");
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -66,6 +66,16 @@
 public:
   ASTWalker(DeclCallback Callback) : Callback(Callback) {}
 
+  bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
+// Operators are always ADL extension points, by design references to them
+// doesn't count as uses. Ignore them by traversing arguments instead of
+// children.
+for (auto *Arg : S->arguments())
+  if (!TraverseStmt(Arg))
+return false;
+return true;
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *DRE) {
 report(DRE->getLocation(), DRE->getFoundDecl());
 return true;


Index: clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
===
--- clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
+++ clang-tools-extra/include-cleaner/unittests/WalkASTTest.cpp
@@ -245,6 +245,16 @@
   testWalk("struct S { $implicit^S(int); };", "S t = ^42;");
 }
 
+TEST(WalkAST, Operator) {
+  // References to operators are not counted as uses.
+  testWalk("struct string {}; int operator+(string, string);",
+   "int k = string() ^+ string();");
+  testWalk("struct string {int operator+(string); }; ",
+   "int k = string() ^+ string();");
+  testWalk("struct string { friend int operator+(string, string); }; ",
+   "int k = string() ^+ string();");
+}
+
 TEST(WalkAST, Functions) {
   // Definition uses declaration, not the other way around.
   testWalk("void $explicit^foo();", "void ^foo() {}");
Index: clang-tools-extra/include-cleaner/lib/WalkAST.cpp
===
--- clang-tools-extra/include-cleaner/lib/WalkAST.cpp
+++ clang-tools-extra/include-cleaner/lib/WalkAST.cpp
@@ -66,6 +66,16 @@
 public:
   ASTWalker(DeclCallback Callback) : Callback(Callback) {}
 
+  bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
+// Operators are always ADL extension points, by design references to them
+// doesn't count as uses. Ignore them by traversing arguments instead of
+// children.
+for (auto *Arg : S->arguments())
+  if (!TraverseStmt(Arg))
+return false;
+return true;
+  }
+
   bool VisitDeclRefExpr(DeclRefExpr *DRE) {
 report(DRE->getLocation(), DRE->getFoundDecl());
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f3700bd - [clang][dataflow] Account for global variables in constructor initializers.

2022-12-22 Thread Yitzhak Mandelbaum via cfe-commits
Author: Yitzhak Mandelbaum
Date: 2022-12-22T14:20:50Z
New Revision: f3700bdb7f00d4f2652a7bdc6a99130e8a1b3c59

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

LOG: [clang][dataflow] Account for global variables in constructor initializers.

Previously, the analysis modeled global variables appearing in the _body_ of
any function (including constructors). But, that misses those appearing in
constructor _initializers_. This patch adds the initializers to the set of
expressions used to determine which globals to model.

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

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp 
b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
index 70fcb6be787aa..c883f90f5554b 100644
--- a/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ b/clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -233,6 +233,15 @@ Environment::Environment(DataflowAnalysisContext &DACtx,
   }
 }
   }
+
+  // Look for global variable references in the constructor-initializers.
+  if (const auto *CtorDecl = dyn_cast(&DeclCtx)) {
+for (const auto *Init : CtorDecl->inits()) {
+  const Expr *E = Init->getInit();
+  assert(E != nullptr);
+  initGlobalVars(*E, *this);
+}
+  }
 }
 
 bool Environment::canDescend(unsigned MaxDepth,

diff  --git 
a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
index ae70131a60a57..b237f3b83759f 100644
--- a/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -8,6 +8,8 @@
 
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "TestingSupport.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
@@ -21,19 +23,19 @@ namespace {
 using namespace clang;
 using namespace dataflow;
 using ::testing::ElementsAre;
+using ::testing::NotNull;
 using ::testing::Pair;
 
 class EnvironmentTest : public ::testing::Test {
-  DataflowAnalysisContext Context;
-
 protected:
-  EnvironmentTest()
-  : Context(std::make_unique()), Env(Context) {}
+  EnvironmentTest() : DAContext(std::make_unique()) {}
 
-  Environment Env;
+  DataflowAnalysisContext DAContext;
 };
 
 TEST_F(EnvironmentTest, FlowCondition) {
+  Environment Env(DAContext);
+
   EXPECT_TRUE(Env.flowConditionImplies(Env.getBoolLiteralValue(true)));
   EXPECT_FALSE(Env.flowConditionImplies(Env.getBoolLiteralValue(false)));
 
@@ -76,6 +78,7 @@ TEST_F(EnvironmentTest, CreateValueRecursiveType) {
 
   // Verify that the struct and the field (`R`) with first appearance of the
   // type is created successfully.
+  Environment Env(DAContext);
   Value *Val = Env.createValue(*Ty);
   ASSERT_NE(Val, nullptr);
   StructValue *SVal = clang::dyn_cast(Val);
@@ -86,4 +89,64 @@ TEST_F(EnvironmentTest, CreateValueRecursiveType) {
   EXPECT_NE(PV, nullptr);
 }
 
+TEST_F(EnvironmentTest, InitGlobalVarsFun) {
+  using namespace ast_matchers;
+
+  std::string Code = R"cc(
+ int Global = 0;
+ int Target () { return Global; }
+  )cc";
+
+  auto Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+  auto &Context = Unit->getASTContext();
+
+  ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+  auto Results =
+  match(decl(anyOf(varDecl(hasName("Global")).bind("global"),
+   functionDecl(hasName("Target")).bind("target"))),
+Context);
+  const auto *Fun = selectFirst("target", Results);
+  const auto *Var = selectFirst("global", Results);
+  ASSERT_TRUE(Fun != nullptr);
+  ASSERT_THAT(Var, NotNull());
+
+  // Verify the global variable is populated when we analyze `Target`.
+  Environment Env(DAContext, *Fun);
+  EXPECT_THAT(Env.getValue(*Var, SkipPast::None), NotNull());
+}
+
+TEST_F(EnvironmentTest, InitGlobalVarsConstructor) {
+  using namespace ast_matchers;
+
+  std::string Code = R"cc(
+ int Global = 0;
+ struct Target {
+   Target() : Field(Global) {}
+   int Field;
+ };
+  )cc";
+
+  auto Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+  auto &Context = Unit->getASTContext();
+
+  ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+  auto Results =
+  match(decl(anyOf(
+varDecl(hasName("Glob

[PATCH] D140501: [clang][dataflow] Account for global variables in constructor initializers.

2022-12-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf3700bdb7f00: [clang][dataflow] Account for global variables 
in constructor initializers. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140501

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

Index: clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -8,6 +8,8 @@
 
 #include "clang/Analysis/FlowSensitive/DataflowEnvironment.h"
 #include "TestingSupport.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
 #include "clang/Analysis/FlowSensitive/DataflowAnalysisContext.h"
 #include "clang/Analysis/FlowSensitive/NoopAnalysis.h"
 #include "clang/Analysis/FlowSensitive/Value.h"
@@ -21,19 +23,19 @@
 using namespace clang;
 using namespace dataflow;
 using ::testing::ElementsAre;
+using ::testing::NotNull;
 using ::testing::Pair;
 
 class EnvironmentTest : public ::testing::Test {
-  DataflowAnalysisContext Context;
-
 protected:
-  EnvironmentTest()
-  : Context(std::make_unique()), Env(Context) {}
+  EnvironmentTest() : DAContext(std::make_unique()) {}
 
-  Environment Env;
+  DataflowAnalysisContext DAContext;
 };
 
 TEST_F(EnvironmentTest, FlowCondition) {
+  Environment Env(DAContext);
+
   EXPECT_TRUE(Env.flowConditionImplies(Env.getBoolLiteralValue(true)));
   EXPECT_FALSE(Env.flowConditionImplies(Env.getBoolLiteralValue(false)));
 
@@ -76,6 +78,7 @@
 
   // Verify that the struct and the field (`R`) with first appearance of the
   // type is created successfully.
+  Environment Env(DAContext);
   Value *Val = Env.createValue(*Ty);
   ASSERT_NE(Val, nullptr);
   StructValue *SVal = clang::dyn_cast(Val);
@@ -86,4 +89,64 @@
   EXPECT_NE(PV, nullptr);
 }
 
+TEST_F(EnvironmentTest, InitGlobalVarsFun) {
+  using namespace ast_matchers;
+
+  std::string Code = R"cc(
+ int Global = 0;
+ int Target () { return Global; }
+  )cc";
+
+  auto Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+  auto &Context = Unit->getASTContext();
+
+  ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+  auto Results =
+  match(decl(anyOf(varDecl(hasName("Global")).bind("global"),
+   functionDecl(hasName("Target")).bind("target"))),
+Context);
+  const auto *Fun = selectFirst("target", Results);
+  const auto *Var = selectFirst("global", Results);
+  ASSERT_TRUE(Fun != nullptr);
+  ASSERT_THAT(Var, NotNull());
+
+  // Verify the global variable is populated when we analyze `Target`.
+  Environment Env(DAContext, *Fun);
+  EXPECT_THAT(Env.getValue(*Var, SkipPast::None), NotNull());
+}
+
+TEST_F(EnvironmentTest, InitGlobalVarsConstructor) {
+  using namespace ast_matchers;
+
+  std::string Code = R"cc(
+ int Global = 0;
+ struct Target {
+   Target() : Field(Global) {}
+   int Field;
+ };
+  )cc";
+
+  auto Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+  auto &Context = Unit->getASTContext();
+
+  ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+  auto Results =
+  match(decl(anyOf(
+varDecl(hasName("Global")).bind("global"),
+cxxConstructorDecl(ofClass(hasName("Target"))).bind("target"))),
+Context);
+  const auto *Ctor = selectFirst("target", Results);
+  const auto *Var = selectFirst("global", Results);
+  ASSERT_TRUE(Ctor != nullptr);
+  ASSERT_THAT(Var, NotNull());
+
+  // Verify the global variable is populated when we analyze `Target`.
+  Environment Env(DAContext, *Ctor);
+  EXPECT_THAT(Env.getValue(*Var, SkipPast::None), NotNull());
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -233,6 +233,15 @@
   }
 }
   }
+
+  // Look for global variable references in the constructor-initializers.
+  if (const auto *CtorDecl = dyn_cast(&DeclCtx)) {
+for (const auto *Init : CtorDecl->inits()) {
+  const Expr *E = Init->getInit();
+  assert(E != nullptr);
+  initGlobalVars(*E, *this);
+}
+  }
 }
 
 bool Environment::canDescend(unsigned MaxDepth,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 38404df - [clang][dataflow] Fix bug in handling of `return` statements.

2022-12-22 Thread Yitzhak Mandelbaum via cfe-commits
Author: Yitzhak Mandelbaum
Date: 2022-12-22T14:42:17Z
New Revision: 38404df9d879483784a7024b2b4a366388d6d476

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

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

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

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 43d004697799..336de81b0653 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -429,6 +429,9 @@ class TransferVisitor : public 
ConstStmtVisitor {
   }
 
   void VisitReturnStmt(const ReturnStmt *S) {
+if (!Options.ContextSensitiveOpts)
+  return;
+
 auto *Ret = S->getRetValue();
 if (Ret == nullptr)
   return;
@@ -443,6 +446,10 @@ class TransferVisitor : public 
ConstStmtVisitor {
 
 auto *Loc = Env.getReturnStorageLocation();
 assert(Loc != nullptr);
+// FIXME: Support reference-type returns.
+if (Loc->getType()->isReferenceType())
+  return;
+
 // FIXME: Model NRVO.
 Env.setValue(*Loc, *Val);
   }

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



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


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

2022-12-22 Thread Yitzhak Mandelbaum 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 rG38404df9d879: [clang][dataflow] Fix bug in handling of 
`return` statements. (authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140430

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


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


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

[PATCH] D140551: [include-cleaner] Don't count references to operators as uses

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

Yeah, I think this makes sense.
I think this sort of thing should ideally be captured in the include-cleaner 
design doc if there was one. (Doesn't make sense to create one just for this 
issue, but it seems like a doc that should exist).




Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:69
 
+  bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
+// Operators are always ADL extension points, by design references to them

Rather than override TraverseCXXOperatorCallExpr to do everything *except* call 
WalkUpFrom, maybe override WalkUpFromCXXOperatorCallExpr to call 
VisitCXXOperatorCallExpr but not WalkUpFromCallExpr? (With a comment that we 
don't want to treat operators as calls)




Comment at: clang-tools-extra/include-cleaner/lib/WalkAST.cpp:71
+// Operators are always ADL extension points, by design references to them
+// doesn't count as uses. Ignore them by traversing arguments instead of
+// children.

maybe motivate this a little: `(generally the type should provide them)`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140551

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


[PATCH] D140538: [Clang][CodeGen] Use poison instead of undef for dummy values in CGExpr [NFC]

2022-12-22 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added a comment.

A 2022-12-22 10:51, Nuno Lopes via Phabricator escreveu:

> nlopes accepted this revision.
> nlopes added a comment.
>
> LGTM, thank you!
>
> Repository:
>
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>
>   https://reviews.llvm.org/D140538/new/
>
> https://reviews.llvm.org/D140538

Está a falhar no test_demangle.pass.cpp, espero que alguém do libcxx 
diga alguma coisa ou faço ping a alguém diretamente?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140538

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


[PATCH] D140554: [C++20] Determine the dependency of unevaluated lambdas more accurately

2022-12-22 Thread Liming Liu via Phabricator via cfe-commits
lime created this revision.
lime added reviewers: cor3ntin, shafik, erichkeane, aaron.ballman, 
clang-language-wg.
lime added a project: clang.
Herald added a project: All.
lime requested review of this revision.
Herald added a subscriber: cfe-commits.

During template instantiation, the instantiator will enter constant evaluated 
context before instantiate a template argument originated from an expression, 
and this impedes the instantiator from creating lambdas with independent types.

This patch solves the problem via widening the condition that the instantiator 
marks lambdas as never dependent, and fixes the issue #57960


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140554

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
  clang/test/SemaCXX/lambda-unevaluated.cpp


Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -61,9 +61,7 @@
 // Same.
 template void g(const char (*)[([]{ return N; })()]) {} // 
expected-note {{candidate}}
 template void g(const char (*)[([]{ return N; })()]) {} // 
expected-note {{candidate}}
-// FIXME: We instantiate the lambdas into the context of the function template,
-//  so we think they're dependent and can't evaluate a call to them.
-void use_g() { g<6>(&"hello"); } // expected-error {{no matching function}}
+void use_g() { g<6>(&"hello"); } // expected-error {{ambiguous}}
 }
 
 namespace GH51416 {
Index: clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm 
-o - | FileCheck %s
+
+// CHECK-LABEL: define linkonce_odr void 
@"_ZN10Issue579601EIiEENS_1FILNS_3$_0v"()
+namespace Issue57960{
+template
+class F {};
+
+template
+F<[]{}> E() {
+return {};
+}
+
+static auto f = E();
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -13244,10 +13244,11 @@
   // context that isn't a DeclContext (such as a variable template), or when
   // substituting an unevaluated lambda inside of a function's parameter's type
   // - as parameter types are not instantiated from within a function's DC. We
-  // use isUnevaluatedContext() to distinguish the function parameter case.
+  // use evaluation context to distinguish the function parameter case.
   CXXRecordDecl::LambdaDependencyKind DependencyKind =
   CXXRecordDecl::LDK_Unknown;
-  if (getSema().isUnevaluatedContext() &&
+  if ((getSema().isUnevaluatedContext() ||
+   getSema().isConstantEvaluatedContext()) &&
   (getSema().CurContext->isFileContext() ||
!getSema().CurContext->getParent()->isDependentContext()))
 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9621,6 +9621,12 @@
 return ExprEvalContexts.back().isUnevaluated();
   }
 
+  bool isConstantEvaluatedContext() const {
+assert(!ExprEvalContexts.empty() &&
+   "Must be in an expression evaluation context");
+return ExprEvalContexts.back().isConstantEvaluated();
+  }
+
   bool isImmediateFunctionContext() const {
 assert(!ExprEvalContexts.empty() &&
"Must be in an expression evaluation context");


Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -61,9 +61,7 @@
 // Same.
 template void g(const char (*)[([]{ return N; })()]) {} // expected-note {{candidate}}
 template void g(const char (*)[([]{ return N; })()]) {} // expected-note {{candidate}}
-// FIXME: We instantiate the lambdas into the context of the function template,
-//  so we think they're dependent and can't evaluate a call to them.
-void use_g() { g<6>(&"hello"); } // expected-error {{no matching function}}
+void use_g() { g<6>(&"hello"); } // expected-error {{ambiguous}}
 }
 
 namespace GH51416 {
Index: clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK-LABEL: define linkonce_odr void @"_ZN10Issue579601EIiEENS_1FILNS_3$_0v"()
+namespace Issue57960{
+template
+class F {};
+
+template
+F<[]{}> E() {
+retur

[PATCH] D140467: [X86][Reduce] Preserve fast math flags when change it. NFCI

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 484826.
pengfei added a comment.

Add test case to check FastMathFlagGuard works.

> Tests don't exist for users, they exist for compiler developers...
> I agree with @arsenm. At least for clang irgen, we should have good test 
> coverage.

You are right. Added a test case.

> This test amounts to a builtin header test for immintrin.h. This should move 
> to clang/test/Headers and replaced with a builtin test directly checking the 
> builtin handling

I got your point now, thanks! However, I don't agree with you. Although most 
intrinsics are simple wrappers of builtins, we have many intrinsics are 
combinations of more builtins. It's common in mask intrinsics. We also have 
intrinsics that permute their arguments order when calling to builtins.
IIUC, `-fsyntax-only` only checks for types, builtins existence. It even 
doesn't check if intrinsics mapped to the right builtins. Not to mention above 
cases. So it doesn't sound feasible to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140467

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-x86-reduce.c


Index: clang/test/CodeGen/builtins-x86-reduce.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-x86-reduce.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -target-feature +avx512f 
-emit-llvm -o - | FileCheck %s
+
+typedef double double8 __attribute__((ext_vector_type(8)));
+
+double foo(double8 a, double b) {
+  return __builtin_ia32_reduce_fmax_pd512(a) + b;
+}
+
+// CHECK: fadd
+// CHECK-NOT: nnan
+// CHECK-SAME: double
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13113,6 +13113,8 @@
 return Builder.CreateBitCast(Sext, FPVecTy);
   };
 
+  IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
+
   switch (BuiltinID) {
   default: return nullptr;
   case X86::BI_mm_prefetch: {


Index: clang/test/CodeGen/builtins-x86-reduce.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-x86-reduce.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -target-feature +avx512f -emit-llvm -o - | FileCheck %s
+
+typedef double double8 __attribute__((ext_vector_type(8)));
+
+double foo(double8 a, double b) {
+  return __builtin_ia32_reduce_fmax_pd512(a) + b;
+}
+
+// CHECK: fadd
+// CHECK-NOT: nnan
+// CHECK-SAME: double
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13113,6 +13113,8 @@
 return Builder.CreateBitCast(Sext, FPVecTy);
   };
 
+  IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
+
   switch (BuiltinID) {
   default: return nullptr;
   case X86::BI_mm_prefetch: {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140467: [X86][Reduce] Preserve fast math flags when change it. NFCI

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

In D140467#4013107 , @pengfei wrote:

> Add test case to check FastMathFlagGuard works.
>
> Not to mention above cases. So it doesn't sound feasible to me.

Testing is always feasible. You could even just generate all the combinations




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:13116
 
+  IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
+

Should only do this in the cases that actually set the flags



Comment at: clang/test/CodeGen/builtins-x86-reduce.c:8
+}
+
+// CHECK: fadd

Should test the builtins from both sets



Comment at: clang/test/CodeGen/builtins-x86-reduce.c:9-11
+// CHECK: fadd
+// CHECK-NOT: nnan
+// CHECK-SAME: double

use update_cc_test_checks, check-not is super fragile


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140467

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


[PATCH] D123032: [clang][dataflow] Exclude protobuf types from modeling in the environment.

2022-12-22 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 484830.
ymandel added a comment.
Herald added a subscriber: martong.
Herald added a reviewer: NoQ.

Reviving this patch, addressing some of the earlier concerns. However, I may 
have a better solution which makes this patch irrelevant. So, still WIP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123032

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/DataflowEnvironmentTest.cpp
@@ -23,6 +23,7 @@
 using namespace clang;
 using namespace dataflow;
 using ::testing::ElementsAre;
+using ::testing::IsNull;
 using ::testing::NotNull;
 using ::testing::Pair;
 
@@ -102,7 +103,6 @@
   auto &Context = Unit->getASTContext();
 
   ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
-
   auto Results =
   match(decl(anyOf(varDecl(hasName("Global")).bind("global"),
functionDecl(hasName("Target")).bind("target"))),
@@ -133,7 +133,6 @@
   auto &Context = Unit->getASTContext();
 
   ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
-
   auto Results =
   match(decl(anyOf(
 varDecl(hasName("Global")).bind("global"),
@@ -149,4 +148,117 @@
   EXPECT_THAT(Env.getValue(*Var, SkipPast::None), NotNull());
 }
 
+TEST(ExcludeProtobufTypesTest, ExcludeEnabled) {
+  using namespace ast_matchers;
+
+  DataflowAnalysisContext DAContext(std::make_unique(),
+{/*ExcludeGoogleProtobufs=*/true});
+  Environment Env(DAContext);
+
+  std::string Code = R"cc(
+namespace google {
+namespace protobuf {
+struct Message {};
+}
+}
+
+namespace other {
+namespace google {
+namespace protobuf {
+struct Message {};
+}
+}
+}
+
+struct Bar : public google::protobuf::Message {
+  bool Field;
+};
+
+// Not a protobuf, but looks like it. Verify that it is *not* excluded.
+struct Zab : public other::google::protobuf::Message {
+  bool Field;
+};
+
+void target() {
+  Bar B;
+  Zab Z;
+  (void)0;
+  /*[[check]]*/
+}
+  )cc";
+
+  auto Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+  auto &Context = Unit->getASTContext();
+
+  ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+  auto Results = match(varDecl(eachOf(varDecl(hasName("B")).bind("varB"),
+  varDecl(hasName("Z")).bind("varZ"))),
+   Context);
+  const auto *B = selectFirst("varB", Results);
+  ASSERT_TRUE(B != nullptr);
+  const auto *Z = selectFirst("varZ", Results);
+  ASSERT_TRUE(Z != nullptr);
+
+  EXPECT_THAT(Env.createValue(B->getType()), IsNull());
+  EXPECT_THAT(Env.createValue(Z->getType()), NotNull());
+}
+
+TEST(ExcludeProtobufTypesTest, ExcludeDisabled) {
+  using namespace ast_matchers;
+
+  DataflowAnalysisContext DAContext(std::make_unique(),
+{/*ExcludeGoogleProtobufs=*/false});
+  Environment Env(DAContext);
+
+  std::string Code = R"cc(
+namespace google {
+namespace protobuf {
+struct Message {};
+}
+}
+
+namespace other {
+namespace google {
+namespace protobuf {
+struct Message {};
+}
+}
+}
+
+struct Bar : public google::protobuf::Message {
+  bool Field;
+};
+
+// Not a protobuf, but looks like it. Verify that it is *not* excluded.
+struct Zab : public other::google::protobuf::Message {
+  bool Field;
+};
+
+void target() {
+  Bar B;
+  Zab Z;
+  (void)0;
+  /*[[check]]*/
+}
+  )cc";
+
+  auto Unit =
+  tooling::buildASTFromCodeWithArgs(Code, {"-fsyntax-only", "-std=c++11"});
+  auto &Context = Unit->getASTContext();
+
+  ASSERT_EQ(Context.getDiagnostics().getClient()->getNumErrors(), 0U);
+
+  auto Results = match(varDecl(eachOf(varDecl(hasName("B")).bind("varB"),
+  varDecl(hasName("Z")).bind("varZ"))),
+   Context);
+  const auto *B = selectFirst("varB", Results);
+  ASSERT_TRUE(B != nullptr);
+  const auto *Z = selectFirst("varZ", Results);
+  ASSERT_TRUE(Z != nullptr);
+
+  EXPECT_THAT(Env.createValue(B->getType()), NotNull());
+  EXPECT_THAT(Env.createValue(Z->getType()), NotNull());
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis

[PATCH] D140467: [X86][Reduce] Preserve fast math flags when change it. NFCI

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei updated this revision to Diff 484838.
pengfei marked 2 inline comments as done.
pengfei added a comment.

Address review comments. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140467

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-x86-reduce.c


Index: clang/test/CodeGen/builtins-x86-reduce.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-x86-reduce.c
@@ -0,0 +1,37 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -target-feature +avx512f 
-emit-llvm -o - | FileCheck %s
+
+typedef double double8 __attribute__((ext_vector_type(8)));
+
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x double>, align 64
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store <8 x double> [[A:%.*]], ptr [[A_ADDR]], align 64
+// CHECK-NEXT:store double [[B:%.*]], ptr [[B_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x double>, ptr [[A_ADDR]], align 64
+// CHECK-NEXT:[[TMP1:%.*]] = call reassoc double 
@llvm.vector.reduce.fadd.v8f64(double 0.00e+00, <8 x double> [[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = load double, ptr [[B_ADDR]], align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd double [[TMP1]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double foo(double8 a, double b) {
+  return __builtin_ia32_reduce_fadd_pd512(0.0, a) + b;
+}
+
+#pragma clang fp reassociate(on)
+// CHECK-LABEL: @bar(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x double>, align 64
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store <8 x double> [[A:%.*]], ptr [[A_ADDR]], align 64
+// CHECK-NEXT:store double [[B:%.*]], ptr [[B_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x double>, ptr [[A_ADDR]], align 64
+// CHECK-NEXT:[[TMP1:%.*]] = call reassoc double 
@llvm.vector.reduce.fadd.v8f64(double 0.00e+00, <8 x double> [[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = load double, ptr [[B_ADDR]], align 8
+// CHECK-NEXT:[[ADD:%.*]] = fadd reassoc double [[TMP1]], [[TMP2]]
+// CHECK-NEXT:ret double [[ADD]]
+//
+double bar(double8 a, double b) {
+  return __builtin_ia32_reduce_fadd_pd512(0.0, a) + b;
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -14737,6 +14737,7 @@
   case X86::BI__builtin_ia32_reduce_fadd_ph128: {
 Function *F =
 CGM.getIntrinsic(Intrinsic::vector_reduce_fadd, Ops[1]->getType());
+IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
 Builder.getFastMathFlags().setAllowReassoc();
 return Builder.CreateCall(F, {Ops[0], Ops[1]});
   }
@@ -14747,6 +14748,7 @@
   case X86::BI__builtin_ia32_reduce_fmul_ph128: {
 Function *F =
 CGM.getIntrinsic(Intrinsic::vector_reduce_fmul, Ops[1]->getType());
+IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
 Builder.getFastMathFlags().setAllowReassoc();
 return Builder.CreateCall(F, {Ops[0], Ops[1]});
   }
@@ -14757,6 +14759,7 @@
   case X86::BI__builtin_ia32_reduce_fmax_ph128: {
 Function *F =
 CGM.getIntrinsic(Intrinsic::vector_reduce_fmax, Ops[0]->getType());
+IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
 Builder.getFastMathFlags().setNoNaNs();
 return Builder.CreateCall(F, {Ops[0]});
   }
@@ -14767,6 +14770,7 @@
   case X86::BI__builtin_ia32_reduce_fmin_ph128: {
 Function *F =
 CGM.getIntrinsic(Intrinsic::vector_reduce_fmin, Ops[0]->getType());
+IRBuilder<>::FastMathFlagGuard FMFGuard(Builder);
 Builder.getFastMathFlags().setNoNaNs();
 return Builder.CreateCall(F, {Ops[0]});
   }


Index: clang/test/CodeGen/builtins-x86-reduce.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-x86-reduce.c
@@ -0,0 +1,37 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 %s -triple x86_64-unknown-unknown -target-feature +avx512f -emit-llvm -o - | FileCheck %s
+
+typedef double double8 __attribute__((ext_vector_type(8)));
+
+// CHECK-LABEL: @foo(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <8 x double>, align 64
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca double, align 8
+// CHECK-NEXT:store <8 x double> [[A:%.*]], ptr [[A_ADDR]], align 64
+// CHECK-NEXT:store double [[B:%.*]], ptr [[B_ADDR]], align 8
+// CHECK-NEXT:[[TMP0:%.*]] = load <8 x double>, ptr [[A_ADDR]], align 64
+// CHECK-NEXT:[[TMP1:%.*]] = call reassoc double @llvm.vector.reduce.fadd.v8f64(double 0.00e+00, <8 x double> [[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = load double, ptr [[B_ADDR]], align 8
+// CHECK-NEXT:

[PATCH] D140467: [X86][Reduce] Preserve fast math flags when change it. NFCI

2022-12-22 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added inline comments.



Comment at: clang/test/CodeGen/builtins-x86-reduce.c:8
+}
+
+// CHECK: fadd

arsenm wrote:
> Should test the builtins from both sets
Do you mean this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140467

___
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-22 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 484840.

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/dllimport.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/dllimport.cpp
===
--- clang/test/CodeGenCXX/dllimport.cpp
+++ clang/test/CodeGenCXX/dllimport.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 %s
-// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M32 --check-prefix=GL32 %s
+// RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-msvc -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -DMSABI -w | FileCheck --check-prefix=MSC --check-prefix=M64 --check-prefix=GL64 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-gnu-fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU --check-prefix=G32 %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple x86_64-windows-gnu  -fno-rtti -fno-threadsafe-statics -fms-extensions -emit-llvm -std=c++1y -O0 -o - %s -w | FileCheck --check-prefix=GNU %s
 // RUN: %clang_cc1 -no-enable-noundef-analysis -triple i686-windows-msvc   -fno-rtti -fno-threadsafe-statics -fms-extensions -fms-compatibility-version=18.00 -emit-llvm -std=c++1y -O1 -disable-llvm-passes -o - %s -DMSABI -w | FileCheck --check-prefix=MO1 --check-prefix=M18 %s
@@ -737,8 +737,6 @@
 
 namespace PR19933 {
 // Don't dynamically initialize dllimport vars.
-// MSC2-NOT: @llvm.global_ctors
-// GNU2-NOT: @llvm.global_ctors
 
   struct NonPOD { NonPOD(); };
   template  struct A { static NonPOD x; };
@@ -856,6 +854,12 @@
 USEMEMFUNC(PR23770BaseTemplate, f);
 // M32-DAG: declare dllimport x86_thiscallcc void @"?f@?$PR23770BaseTemplat

[PATCH] D139881: [clang] Use a StringRef instead of a raw char pointer to store builtin and call information

2022-12-22 Thread Nikita Popov via Phabricator via cfe-commits
nikic accepted this revision.
nikic added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D139881

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


[PATCH] D139305: [clang][driver] Support option '-mcpu' on target AVR.

2022-12-22 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

I think having `-mcpu` as an alias for `-mmcu` on AVR is fine, but I don't 
think it's very useful to be honest. The `-mmcu` (or `-mcpu`) flag is 
inherently specific to that particular chip anyway so compatibility is not an 
issue. In fact, having two flags may even introduce noise and confusion.

In D139305#3987969 , @MaskRay wrote:

> Does GCC prefer `-mcpu=` as well? If not, raise a PR there? This seems like a 
> decision we should not unilaterally make on llvm-project side: it's certainly 
> something GCC cares about as well.

I guess, but avr-gcc is already barely maintained. Most people use an older 
version (like 5.2.0) because the newer versions produce absolutely terrible 
code. So I don't think it matters much.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139305

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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 484841.
owenpan added a comment.

Fixed another bug and added some unit tests. Also updated ReleaseNotes.rst and 
addressed some review comments.


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

https://reviews.llvm.org/D140543

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/CMakeLists.txt
  clang/lib/Format/Format.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25121,6 +25121,50 @@
 #endif
 }
 
+TEST_F(FormatTest, IntegerLiteralSeparator) {
+  FormatStyle Style = getLLVMStyle();
+
+  const StringRef Binary("b = 0b10011'11'0110'1u;");
+  EXPECT_EQ(Style.IntegerLiteralSeparator.Binary, 0);
+  verifyFormat(Binary, Style);
+  Style.IntegerLiteralSeparator.Binary = -1;
+  verifyFormat("b = 0b10001101u;", Binary, Style);
+  Style.IntegerLiteralSeparator.Binary = 1;
+  verifyFormat("b = 0b1'0'0'1'1'1'1'0'1'1'0'1u;", Binary, Style);
+  Style.IntegerLiteralSeparator.Binary = 3;
+  verifyFormat("b = 0b100'111'101'101u;", Binary, Style);
+  Style.IntegerLiteralSeparator.Binary = 4;
+  verifyFormat("b = 0b1001'1110'1101u;", Binary, Style);
+
+  const StringRef Decimal("d = 184467'440737'0'95505'92ull;");
+  EXPECT_EQ(Style.IntegerLiteralSeparator.Decimal, 0);
+  verifyFormat(Decimal, Style);
+  Style.IntegerLiteralSeparator.Decimal = -1;
+  verifyFormat("d = 18446744073709550592ull;", Decimal, Style);
+  Style.IntegerLiteralSeparator.Decimal = 3;
+  verifyFormat("d = 18'446'744'073'709'550'592ull;", Decimal, Style);
+
+  const StringRef Hex("h = 0xDEAD'BEEF'DE'AD'BEE'Fuz;");
+  EXPECT_EQ(Style.IntegerLiteralSeparator.Hex, 0);
+  verifyFormat(Hex, Style);
+  Style.IntegerLiteralSeparator.Hex = -1;
+  verifyFormat("h = 0xDEADBEEFDEADBEEFuz;", Hex, Style);
+  Style.IntegerLiteralSeparator.Hex = 2;
+  verifyFormat("h = 0xDE'AD'BE'EF'DE'AD'BE'EFuz;", Hex, Style);
+
+  verifyFormat("i = -1'234;\n"
+   "// clang-format off\n"
+   "j = 123'4;\n"
+   "// clang-format on\n"
+   "k = +1'234;",
+   "i = -12'34;\n"
+   "// clang-format off\n"
+   "j = 123'4;\n"
+   "// clang-format on\n"
+   "k = +1'23'4;",
+   Style);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.h
===
--- /dev/null
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.h
@@ -0,0 +1,39 @@
+//===--- IntegerLiteralSeparatorFixer.h -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file declares IntegerLiteralSeparatorFixer that fixes C++ integer
+/// literal separators.
+///
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_FORMAT_INTEGERLITERALSEPARATORFIXER_H
+#define LLVM_CLANG_LIB_FORMAT_INTEGERLITERALSEPARATORFIXER_H
+
+#include "TokenAnalyzer.h"
+
+namespace clang {
+namespace format {
+
+class IntegerLiteralSeparatorFixer {
+public:
+  std::pair
+  process(const Environment &Env, const FormatStyle &Style) const;
+
+private:
+  static const auto Separator = '\'';
+
+  bool checkSeparator(const StringRef IntegerLiteral, int DigitsPerGroup) const;
+  std::string format(const StringRef IntegerLiteral, int DigitsPerGroup,
+ bool RemoveSeparator) const;
+};
+
+} // end namespace format
+} // end namespace clang
+
+#endif
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- /dev/null
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -0,0 +1,174 @@
+//===--- IntegerLiteralSeparatorFixer.cpp ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+///
+/// \file
+/// This file implements IntegerLiteralSeparatorFixer that fixes C++ integer
+/// literal separators.
+///
+//===--===//
+
+#include "IntegerLiteralSeparatorFixer.h"
+
+namespace clang {
+namespace format {
+
+enum cla

[PATCH] D140547: Perform access checking to private members in simple requirement.

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

Thank you for the fix, can you elaborate on the motivation for this change, it 
looks like setting `setNamingClass` allows for improved diagnostics but I would 
like it explained better in the PR description.




Comment at: clang/lib/Sema/SemaTemplateInstantiate.cpp:2244
 TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) 
{
-  if (!Req->isDependent() && !AlwaysRebuild())
-return Req;

Why this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 Thread Owen Pan via Phabricator via cfe-commits
owenpan marked an inline comment as done.
owenpan added inline comments.



Comment at: clang/include/clang/Format/Format.h:2395
+  /// >0: Insert separators between digits, starting from the rightmost digit.
+  struct IntegerLiteralSeparatorStyle {
+/// \code

HazardyKnusperkeks wrote:
> Also add Octal?
I don't know if anyone would want to group octal digits. I can add it in the 
future if it's really useful.



Comment at: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp:20
+
+enum class Base { Binary, Decimal, Hex, Other };
+

HazardyKnusperkeks wrote:
> Other is Octal.
`Other` includes octal and other ill-formed integers (if any).


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

https://reviews.llvm.org/D140543

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


[PATCH] D140544: [DebugInfo] make DW_LANG_C11 respect -gstrict-dwarf

2022-12-22 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/CodeGen/CGDebugInfo.cpp:582
   } else if (LO.C11) {
-LangTag = llvm::dwarf::DW_LANG_C11;
+if (CGO.DebugStrictDwarf && CGO.DwarfVersion < 5)
+  LangTag = llvm::dwarf::DW_LANG_C;

Generally, I think, we downgrade to the nearest/highest version? (for instance 
today when the user requests C17, they get C11, not C - and when they request 
C++17 they get C_plus_plus_14, not plain C_plus_plus) I see there's the same 
choice up in the C++ case too, but not sure it's the right one?

Should probably do the same thing for strict dwarf, and emit this as C99?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140544

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


[PATCH] D140554: [C++20] Determine the dependency of unevaluated lambdas more accurately

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

I am not sure if this is moving in the right direction or not, I will wait for 
@cor3ntin to chime in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140554

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


[clang] 63aa57d - Small fixes to creduce-clang-crash.py script.

2022-12-22 Thread Amy Huang via cfe-commits
Author: Amy Huang
Date: 2022-12-22T16:33:28Z
New Revision: 63aa57dc57e1d47479025f65a89a5a9da974800f

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

LOG: Small fixes to creduce-clang-crash.py script.

Specify python3, and replace / with // to do integer division.

Added: 


Modified: 
clang/utils/creduce-clang-crash.py

Removed: 




diff  --git a/clang/utils/creduce-clang-crash.py 
b/clang/utils/creduce-clang-crash.py
index 08056e52b8264..77bd4cf0fbfcf 100755
--- a/clang/utils/creduce-clang-crash.py
+++ b/clang/utils/creduce-clang-crash.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 """Calls C-Reduce to create a minimal reproducer for clang crashes.
 
 Output files:
@@ -396,8 +396,8 @@ def main():
   parser.add_argument('--creduce', dest='creduce', type=str,
   help="The path to the `creduce` executable. "
   "Required if `creduce` is not in PATH environment.")
-  parser.add_argument('--n', dest='core_number', type=int, 
-  default=max(4, multiprocessing.cpu_count() / 2),
+  parser.add_argument('--n', dest='core_number', type=int,
+  default=max(4, multiprocessing.cpu_count() // 2),
   help="Number of cores to use.")
   parser.add_argument('-v', '--verbose', action='store_true')
   args = parser.parse_args()



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


[PATCH] D140467: [X86][Reduce] Preserve fast math flags when change it. NFCI

2022-12-22 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGen/builtins-x86-reduce.c:8
+}
+
+// CHECK: fadd

pengfei wrote:
> arsenm wrote:
> > Should test the builtins from both sets
> Do you mean this?
Almost. You added the guard to 4 switch cases, so I would expect at minimum one 
builtin from each of the cases. These are both the same builtin. You also 
should have an fmul, fmin and fmax case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140467

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


[PATCH] D140562: [clang][ASTImporter] Improve import of InjectedClassNameType.

2022-12-22 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, martong, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

During AST import multiple different InjectedClassNameType objects
could be created for a single class template. This can cause problems
and failed assertions when these types are compared and found to be
not the same (because the instance is different and there is no
canonical type).
The import of this type does not use the factory method in ASTContext,
probably because the preconditions are not fulfilled at that state.
The fix tries to make the code in ASTImporter work more like the code
in ASTContext::getInjectedClassNameType. If a type is stored at the
Decl or previous Decl object, it is reused instead of creating a new
one. This avoids crash at least a part of the cases.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140562

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -8075,6 +8075,46 @@
   EXPECT_FALSE(SharedStatePtr->isNewDecl(ToBar));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInjectedClassNameType) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  template 
+  struct A {
+typedef A A1;
+void f(A1 *);
+  };
+  )",
+  Lang_CXX11);
+  Decl *FromTU = getTuDecl(
+  R"(
+  template 
+  struct A {
+typedef A A1;
+void f(A1 *);
+  };
+  template
+  void A::f(A::A1 *) {}
+  )",
+  Lang_CXX11);
+
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f"), isDefinition()));
+  auto *ToF = Import(FromF, Lang_CXX11);
+  EXPECT_TRUE(ToF);
+  ASTContext &ToCtx = ToF->getDeclContext()->getParentASTContext();
+
+  auto *ToA1 =
+  FirstDeclMatcher().match(ToTU, typedefDecl(hasName("A1")));
+  QualType ToInjTypedef = ToA1->getUnderlyingType().getCanonicalType();
+  QualType ToInjParmVar =
+  ToF->parameters()[0]->getType().getDesugaredType(ToCtx);
+  ToInjParmVar =
+  ToInjParmVar->getAs()->getPointeeType().getCanonicalType();
+  EXPECT_TRUE(isa(ToInjTypedef));
+  EXPECT_TRUE(isa(ToInjParmVar));
+  EXPECT_TRUE(ToCtx.hasSameType(ToInjTypedef, ToInjParmVar));
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -1468,6 +1468,22 @@
   // FIXME: ASTContext::getInjectedClassNameType is not suitable for AST 
reading
   // See comments in InjectedClassNameType definition for details
   // return Importer.getToContext().getInjectedClassNameType(D, InjType);
+
+  // Take the actions in ASTContext::getInjectedClassNameType here as far as
+  // possible. Try to reuse a previous type if it exists.
+  // We want to avoid that multiple InjectedClassNameType objects are created
+  // for the same Decl object. It is not verified if this works always because
+  // differences in the import order and chain of PreviousDecl.
+
+  CXXRecordDecl *ToDecl = *ToDeclOrErr;
+  const Type *TypeForDecl = ToDecl->getTypeForDecl();
+  if (!TypeForDecl && ToDecl->getPreviousDecl())
+TypeForDecl = ToDecl->getPreviousDecl()->getTypeForDecl();
+  if (TypeForDecl) {
+assert(isa(TypeForDecl));
+return QualType(TypeForDecl, 0);
+  }
+
   enum {
 TypeAlignmentInBits = 4,
 TypeAlignment = 1 << TypeAlignmentInBits


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -8075,6 +8075,46 @@
   EXPECT_FALSE(SharedStatePtr->isNewDecl(ToBar));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInjectedClassNameType) {
+  Decl *ToTU = getToTuDecl(
+  R"(
+  template 
+  struct A {
+typedef A A1;
+void f(A1 *);
+  };
+  )",
+  Lang_CXX11);
+  Decl *FromTU = getTuDecl(
+  R"(
+  template 
+  struct A {
+typedef A A1;
+void f(A1 *);
+  };
+  template
+  void A::f(A::A1 *) {}
+  )",
+  Lang_CXX11);
+
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f"), isDefinition()));
+  auto *ToF = Import(FromF, Lang_CXX11);
+  EXPECT_TRUE(ToF);
+  ASTContext &ToCtx = ToF->getDeclContext()->getParentASTContext();
+
+  auto *ToA1 =
+  FirstDeclMatcher().match(ToTU, typedefDecl(hasName("A1")));
+  QualType ToInjTypedef = ToA1->getU

[PATCH] D140562: [clang][ASTImporter] Improve import of InjectedClassNameType.

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

This crash is produced if the test is run without the fix:

  [ RUN  ] 
ParameterizedTests/ASTImporterOptionSpecificTestBase.ImportInjectedClassNameType/0
  ASTTests: llvm-project/clang/lib/AST/ASTContext.cpp:4678: clang::QualType 
clang::ASTContext::getTypedefType(const clang::TypedefNameDecl *, 
clang::QualType) const: Assertion `hasSameType(Decl->getUnderlyingType(), 
Underlying)' failed.
   #0 0x7fd8cc15141a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:567:11
   #1 0x7fd8cc1515eb PrintStackTraceSignalHandler(void*) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:641:1
   #2 0x7fd8cc14fb9b llvm::sys::RunSignalHandlers() 
llvm-project/llvm/lib/Support/Signals.cpp:103:5
   #3 0x7fd8cc151d61 SignalHandler(int) 
llvm-project/llvm/lib/Support/Unix/Signals.inc:412:1
   #4 0x7fd8cf630980 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x12980)
   #5 0x7fd8cb018e87 raise 
/build/glibc-CVJwZb/glibc-2.27/signal/../sysdeps/unix/sysv/linux/raise.c:51:0
   #6 0x7fd8cb01a7f1 abort 
/build/glibc-CVJwZb/glibc-2.27/stdlib/abort.c:81:0
   #7 0x7fd8cb00a3fa __assert_fail_base 
/build/glibc-CVJwZb/glibc-2.27/assert/assert.c:89:0
   #8 0x7fd8cb00a472 (/lib/x86_64-linux-gnu/libc.so.6+0x30472)
   #9 0x7fd8cd95cf20 
clang::ASTContext::getTypedefType(clang::TypedefNameDecl const*, 
clang::QualType) const llvm-project/clang/lib/AST/ASTContext.cpp:4680:26
  #10 0x7fd8cda9a574 
clang::ASTNodeImporter::VisitTypedefType(clang::TypedefType const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:1365:34
  #11 0x7fd8cdb05191 clang::TypeVisitor>::Visit(clang::Type const*) 
build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:75:1
  #12 0x7fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8
  #13 0x7fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8
  #14 0x7fd8cdadb809 llvm::Expected 
clang::ASTNodeImporter::import(clang::QualType const&) 
llvm-project/clang/lib/AST/ASTImporter.cpp:219:23
  #15 0x7fd8cda9be49 
clang::ASTNodeImporter::VisitElaboratedType(clang::ElaboratedType const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:1595:8
  #16 0x7fd8cdb04eb9 clang::TypeVisitor>::Visit(clang::Type const*) 
build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:45:1
  #17 0x7fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8
  #18 0x7fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8
  #19 0x7fd8cdadb809 llvm::Expected 
clang::ASTNodeImporter::import(clang::QualType const&) 
llvm-project/clang/lib/AST/ASTImporter.cpp:219:23
  #20 0x7fd8cda98d9b 
clang::ASTNodeImporter::VisitPointerType(clang::PointerType const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:1155:8
  #21 0x7fd8cdb0505d clang::TypeVisitor>::Visit(clang::Type const*) 
build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:62:1
  #22 0x7fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8
  #23 0x7fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8
  #24 0x7fd8cdadb809 llvm::Expected 
clang::ASTNodeImporter::import(clang::QualType const&) 
llvm-project/clang/lib/AST/ASTImporter.cpp:219:23
  #25 0x7fd8cda99d11 
clang::ASTNodeImporter::VisitFunctionProtoType(clang::FunctionProtoType const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:1299:10
  #26 0x7fd8cdb04ef1 clang::TypeVisitor>::Visit(clang::Type const*) 
build/Debug/tools/clang/include/clang/AST/TypeNodes.inc:48:1
  #27 0x7fd8cdad0d35 clang::ASTImporter::Import(clang::Type const*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8651:8
  #28 0x7fd8cdad0ea8 clang::ASTImporter::Import(clang::QualType) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8665:8
  #29 0x7fd8cdadb809 llvm::Expected 
clang::ASTNodeImporter::import(clang::QualType const&) 
llvm-project/clang/lib/AST/ASTImporter.cpp:219:23
  #30 0x7fd8cdaddb5b clang::QualType 
clang::ASTNodeImporter::importChecked(llvm::Error&, 
clang::QualType const&) llvm-project/clang/lib/AST/ASTImporter.cpp:698:12
  #31 0x7fd8cdaa8c38 
clang::ASTNodeImporter::VisitFunctionDecl(clang::FunctionDecl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:3597:12
  #32 0x7fd8cdaaabae 
clang::ASTNodeImporter::VisitCXXMethodDecl(clang::CXXMethodDecl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:3810:10
  #33 0x7fd8cdb04361 clang::declvisitor::Base>::Visit(clang::Decl*) 
build/Debug/tools/clang/include/clang/AST/DeclNodes.inc:443:1
  #34 0x7fd8cdad0a26 clang::ASTImporter::ImportImpl(clang::Decl*) 
llvm-project/clang/lib/AST/ASTImporter.cpp:8619:19
  #35 0x7fd8cdab3a72 clang::ASTImporter::Import(clang::Decl*) 
llvm-project/clang/lib/AST/ASTImporter.

[PATCH] D136554: Implement CWG2631

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

Glad the test case made sense to you, it was convoluted to me :)

Still seeing one more error, and it's not modules-related so I might be able to 
get it reduced today. Generally, it looks like this:

  struct Inner {
Foo& foo;
const std::unique_ptr<...> x = blah(blah(
&foo.bar()));
  };
  
  class Outer {
   private:
Foo foo_;
Inner inner{foo_};
  }

With the error being:

  error: 'Inner::foo' is not a member of class 'Outer'
&foo.bar()));

I think this build failure is wrong? `foo` should be referring to the 
definition inside `Inner`, but clang seems to be expecting it to refer to 
something in `Outer`.

Is it expected that this patch will cause some previously "working" code to no 
longer build? At some point I expect to hand you a reduction that's actually a 
bug in the user code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D136176: Implement support for option 'fexcess-precision'.

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

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

https://reviews.llvm.org/D136176

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/X86/fexcess-precision.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fexcess-precision.c

Index: clang/test/Driver/fexcess-precision.c
===
--- /dev/null
+++ clang/test/Driver/fexcess-precision.c
@@ -0,0 +1,34 @@
+// RUN: %clang -### -target i386 -fexcess-precision=fast -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+// RUN: %clang -### -target i386 -fexcess-precision=standard -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-STD %s
+// RUN: %clang -### -target i386 -fexcess-precision=16 -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang -### -target i386 -fexcess-precision=none -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
+
+// RUN: %clang -### -target x86_64 -fexcess-precision=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+// RUN: %clang -### -target x86_64 -fexcess-precision=standard -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-STD %s
+// RUN: %clang -### -target x86_64 -fexcess-precision=16 -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang -### -target x86_64 -fexcess-precision=none -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefixes=CHECK-ERR-NONE %s
+
+// RUN: %clang -### -target aarch64 -fexcess-precision=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// RUN: %clang -### -target aarch64 -fexcess-precision=standard -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// RUN: %clang -### -target aarch64 -fexcess-precision=16 -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-16 %s
+// RUN: %clang -### -target aarch64 -fexcess-precision=none -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
+
+// CHECK-FAST: "-ffloat16-excess-precision=fast"
+// CHECK-STD: "-ffloat16-excess-precision=standard"
+// CHECK-NONE: "-ffloat16-excess-precision=none"
+// CHECK-ERR-NONE: unsupported argument 'none' to option '-fexcess-precision='
+// CHECK: "-cc1"
+// CHECK-NOT: "-ffloat16-excess-precision=fast"
+// CHECK-ERR-16: unsupported argument '16' to option '-fexcess-precision='
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -398,7 +398,7 @@
 // CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-jumps' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-jumps=100' is not supported
-// CHECK-WARNING-DAG: optimization flag '-fexcess-precision=100' is not supported
+// CHECK-WARNING-DAG: unsupported argument '100' to option '-fexcess-precision='
 // CHECK-WARNING-DAG: optimization flag '-fbranch-count-reg' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-default-inline' is not supported
Index: clang/test/CodeGen/X86/fexcess-precision.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/fexcess-precision.c
@@ -0,0 +1,387 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=fast -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=fast -target-feature +avx512fp16 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=standard -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=standard -target-feature +avx512fp16 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=none -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=none -target-feature +avx512fp16 \
+// RUN: -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN

[PATCH] D140565: [Clang][CMake] Set up distribution target for Clang-BOLT

2022-12-22 Thread Amir Ayupov via Phabricator via cfe-commits
Amir created this revision.
Amir added a reviewer: phosek.
Herald added a subscriber: wenlei.
Herald added a project: All.
Amir requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Provide a way to install usable BOLT-optimized Clang
(clang + resource headers) using
`ninja clang-bolt install-distribution` with BOLT.cmake cache file
or `ninja stage2-clang-bolt stage2-install-distribution`
with BOLT-PGO.cmake cache file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140565

Files:
  clang/cmake/caches/BOLT-PGO.cmake
  clang/cmake/caches/BOLT.cmake


Index: clang/cmake/caches/BOLT.cmake
===
--- clang/cmake/caches/BOLT.cmake
+++ clang/cmake/caches/BOLT.cmake
@@ -15,3 +15,10 @@
 
 set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "")
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+# setup toolchain
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  clang-resource-headers
+  CACHE STRING "")
Index: clang/cmake/caches/BOLT-PGO.cmake
===
--- clang/cmake/caches/BOLT-PGO.cmake
+++ clang/cmake/caches/BOLT-PGO.cmake
@@ -2,10 +2,16 @@
 
 set(CLANG_BOOTSTRAP_TARGETS
   stage2-clang-bolt
+  stage2-distribution
+  stage2-install-distribution
   CACHE STRING "")
 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
   clang-bolt
+  distribution
+  install-distribution
   CACHE STRING "")
 
-set(PGO_BUILD_CONFIGURATION ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake CACHE STRING 
"")
+set(PGO_BUILD_CONFIGURATION
+  ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake
+  CACHE STRING "")
 include(${CMAKE_CURRENT_LIST_DIR}/PGO.cmake)


Index: clang/cmake/caches/BOLT.cmake
===
--- clang/cmake/caches/BOLT.cmake
+++ clang/cmake/caches/BOLT.cmake
@@ -15,3 +15,10 @@
 
 set(LLVM_ENABLE_PROJECTS "bolt;clang" CACHE STRING "")
 set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
+
+# setup toolchain
+set(LLVM_INSTALL_TOOLCHAIN_ONLY ON CACHE BOOL "")
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  clang-resource-headers
+  CACHE STRING "")
Index: clang/cmake/caches/BOLT-PGO.cmake
===
--- clang/cmake/caches/BOLT-PGO.cmake
+++ clang/cmake/caches/BOLT-PGO.cmake
@@ -2,10 +2,16 @@
 
 set(CLANG_BOOTSTRAP_TARGETS
   stage2-clang-bolt
+  stage2-distribution
+  stage2-install-distribution
   CACHE STRING "")
 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
   clang-bolt
+  distribution
+  install-distribution
   CACHE STRING "")
 
-set(PGO_BUILD_CONFIGURATION ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake CACHE STRING "")
+set(PGO_BUILD_CONFIGURATION
+  ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake
+  CACHE STRING "")
 include(${CMAKE_CURRENT_LIST_DIR}/PGO.cmake)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137534: [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/4)

2022-12-22 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

Why is it necessary to add new command-line flags for this? Can't the input and 
output be inherited from the specified Clang command line? Would such command 
line make sense?




Comment at: clang/test/ClangScanDeps/P1689.cppm:9
+//
+// Check the seperated dependency format.
+// RUN: clang-scan-deps -format=p1689 --p1689-targeted-file-name=%t/M.cppm 
--p1689-targeted-output=%t/M.o \

What does "separated" mean in this context?


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

https://reviews.llvm.org/D137534

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


[PATCH] D140363: Remove incorrectly implemented -mibt-seal

2022-12-22 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen accepted this revision.
samitolvanen added a comment.
This revision is now accepted and ready to land.

I agree, it's probably best to temporarily revert this until Joao has time to 
address the issues you mentioned. The Linux kernel doesn't use `-mibt-seal` 
yet, so dropping the feature for now shouldn't be a problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140363

___
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-22 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D138655#4012557 , @Sockke wrote:

> Improved the test file.

Just a general workflow comment, can you please mark comments as done when they 
are addressed, or, if you feel the comment in unjustified, explain why.


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] D137534: [C++20] [Modules] [ClangScanDeps] Allow clang-scan-deps to without specified compilation database in P1689 (3/4)

2022-12-22 Thread Ben Boeckel via Phabricator via cfe-commits
ben.boeckel added inline comments.



Comment at: clang/test/ClangScanDeps/P1689.cppm:9
+//
+// Check the seperated dependency format.
+// RUN: clang-scan-deps -format=p1689 --p1689-targeted-file-name=%t/M.cppm 
--p1689-targeted-output=%t/M.o \

jansvoboda11 wrote:
> What does "separated" mean in this context?
Yeah, this isn't the right term. There are two things being done:

- discovering dependencies for a future compile (P1689)
- collecting deps for the scanning itself to know that "if included file X 
changes, I need to rescan"

Both are required for correct builds.


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

https://reviews.llvm.org/D137534

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


[clang] c348abc - Revert D138179 "MIPS: fix build from IR files, nan2008 and FpAbi"

2022-12-22 Thread Fangrui Song via cfe-commits
Author: Fangrui Song
Date: 2022-12-22T11:48:55-08:00
New Revision: c348abce68ac422bf3842de3943ca7463e3a814f

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

LOG: Revert D138179 "MIPS: fix build from IR files, nan2008 and FpAbi"

This reverts commit 9739bb81aed490bfcbcbbac6970da8fb7232fd34.
It causes `.module is not permitted after generating code`
for Linux kernel's `ARCH=mips 32r1_defconfig` clang+GNU as build.
It's confirmed as a defect, but the proper fix needs time to sort out.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/Mips.cpp
clang/test/Driver/mips-as.c
clang/test/Driver/mips-integrated-as.s
llvm/lib/Target/Mips/MipsAsmPrinter.cpp

Removed: 
llvm/test/CodeGen/Mips/abiflags-2008-fp64.ll



diff  --git a/clang/lib/Driver/ToolChains/Arch/Mips.cpp 
b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
index 7da00a8854006..088eecf79adbc 100644
--- a/clang/lib/Driver/ToolChains/Arch/Mips.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Mips.cpp
@@ -467,6 +467,11 @@ bool mips::isFP64ADefault(const llvm::Triple &Triple, 
StringRef CPUName) {
 
 bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
  StringRef ABIName, mips::FloatABI FloatABI) {
+  if (Triple.getVendor() != llvm::Triple::ImaginationTechnologies &&
+  Triple.getVendor() != llvm::Triple::MipsTechnologies &&
+  !Triple.isAndroid())
+return false;
+
   if (ABIName != "32")
 return false;
 

diff  --git a/clang/test/Driver/mips-as.c b/clang/test/Driver/mips-as.c
index 14fbb18c93500..f4add636e9e89 100644
--- a/clang/test/Driver/mips-as.c
+++ b/clang/test/Driver/mips-as.c
@@ -196,7 +196,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-mips16 -mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-16 %s
-// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mfpxx" "-mips16"
+// MIPS-16: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mips16"
 //
 // RUN: %clang -target mips-linux-gnu -mips16 -mno-mips16 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -207,7 +207,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-micromips -mmicromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MICRO %s
-// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mfpxx" "-mmicromips"
+// MIPS-MICRO: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mmicromips"
 //
 // RUN: %clang -target mips-linux-gnu -mmicromips -mno-micromips -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -218,7 +218,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dsp -mdsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSP %s
-// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mfpxx" "-mdsp"
+// MIPS-DSP: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mdsp"
 //
 // RUN: %clang -target mips-linux-gnu -mdsp -mno-dsp -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -229,7 +229,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-dspr2 -mdspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-DSPR2 %s
-// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mfpxx" "-mdspr2"
+// MIPS-DSPR2: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mdspr2"
 //
 // RUN: %clang -target mips-linux-gnu -mdspr2 -mno-dspr2 -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
@@ -266,7 +266,7 @@
 // RUN: %clang -target mips-linux-gnu -mno-msa -mmsa -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \
 // RUN:   | FileCheck -check-prefix=MIPS-MSA %s
-// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mfpxx" "-mmsa"
+// MIPS-MSA: as{{(.exe)?}}" "-march" "mips32r2" "-mabi" "32" "-mno-shared" 
"-call_nonpic" "-EB" "-mmsa"
 //
 // RUN: %clang -target mips-linux-gnu -mmsa -mno-msa -### \
 // RUN:   -no-integrated-as -fno-pic -c %s 2>&1 \

diff  --git a/clang/test/Driver/mips-integrated-as.s 
b/clang/test/Driver/mips-integrated-as.s
index e248ba7f77e91..46ce5b6871f4e 100644
--- a/clang/test/Driver/mips-integrated-as.s
+++ b/clang/test/Driver/mips-integrated-as.s
@@ -160,8 +160,8 @@
 // RUN: %clang -target mips-linux-gnu -### -fintegrated-as -c %s 2>&1 | \
 // RUN:   FileCheck -check-prefix=FPXX-DEFAULT %s
 // FPXX-DEFAULT: -cc1as
-// FPXX-DEFAULT: "-target-feature" "+fpxx"
-// FPXX-DEFAULT: "-target-feature" "+n

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

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

Hi, we're seeing some build failures after this change. Seems like the 
TargetParser isn't getting added to LLVMExports correctly. Can you take a look 
and address these?

Failing bot 
https://ci.chromium.org/ui/p/fuchsia/builders/prod/llvm-linux-x64/b8794232527428765009/overview

CMAKE invocation can be found here: 
https://logs.chromium.org/logs/fuchsia/buildbucket/cr-buildbucket/8794232527428765009/+/u/configure_x86_64-linux-gnu_llvm/execution_details

Error message:

  CMake Error: install(EXPORT "LLVMExports" ...) includes target "LLVMCore" 
which requires target "LLVMTargetParser" that is not in the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMBinaryFormat" which requires target "LLVMTargetParser" that is not in the 
export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMBitReader" which requires target "LLVMTargetParser" that is not in the 
export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target "LLVMMC" which 
requires target "LLVMTargetParser" that is not in the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target "LLVMMCParser" 
which requires target "LLVMTargetParser" that is not in the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMMCDisassembler" which requires target "LLVMTargetParser" that is not in 
the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target "LLVMObject" 
which requires target "LLVMTargetParser" that is not in the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMDebugInfoDWARF" which requires target "LLVMTargetParser" that is not in 
the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMSymbolize" which requires target "LLVMTargetParser" that is not in the 
export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target "LLVMX86Desc" 
which requires target "LLVMTargetParser" that is not in the export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMAArch64Desc" which requires target "LLVMTargetParser" that is not in the 
export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target 
"LLVMProfileData" which requires target "LLVMTargetParser" that is not in the 
export set.
  CMake Error: install(EXPORT "LLVMExports" ...) includes target "LLVMTextAPI" 
which requires target "LLVMTargetParser" that is not in the export set.


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] D104931: [AArch64] Wire up ILP32 ABI support in Clang

2022-12-22 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.
Herald added a project: All.

The linux kernel uses a build time invocation of the compiler for feature 
detection of the `-mabi=lp64` command line flag, which clang-16 currently 
doesn't support.

Looking at https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html, it looks 
like an alternate value of `-mabi=ilp32`.  Should this patch wire that up in 
clang?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104931

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


[PATCH] D140363: Remove incorrectly implemented -mibt-seal

2022-12-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG69243cdb926b: Remove incorrectly implemented -mibt-seal 
(authored by MaskRay).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140363

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/X86/x86-cf-protection.c
  llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
  llvm/test/CodeGen/X86/ibtseal-kernel.ll
  llvm/test/CodeGen/X86/ibtseal-large.ll
  llvm/test/CodeGen/X86/ibtseal-small.ll

Index: llvm/test/CodeGen/X86/ibtseal-small.ll
===
--- llvm/test/CodeGen/X86/ibtseal-small.ll
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: llc < %s -O2 -mtriple=x86_64-unknown-linux-gnu -x86-indirect-branch-tracking --code-model=small | FileCheck %s --check-prefix=CHECK-SMALL-IBTSEAL
-
-; CHECK-SMALL-IBTSEAL: foo:
-; CHECK-SMALL-IBTSEAL: endbr
-; CHECK-SMALL-IBTSEAL: bar:
-; CHECK-SMALL-IBTSEAL: endbr
-
-target triple = "x86_64-unknown-linux-gnu"
-
-define dso_local void @foo() {
-  ret void
-}
-
-define dso_local ptr @bar() {
-  ret ptr @foo
-}
-
-!llvm.module.flags = !{!1}
-!1 = !{i32 4, !"ibt-seal", i32 1}
Index: llvm/test/CodeGen/X86/ibtseal-large.ll
===
--- llvm/test/CodeGen/X86/ibtseal-large.ll
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: llc < %s -O2 -mtriple=x86_64-unknown-linux-gnu -x86-indirect-branch-tracking --code-model=large | FileCheck %s --check-prefix=CHECK-LARGE-IBTSEAL
-
-; CHECK-LARGE-IBTSEAL: foo:
-; CHECK-LARGE-IBTSEAL: endbr
-; CHECK-LARGE-IBTSEAL: bar:
-; CHECK-LARGE-IBTSEAL: endbr
-
-target triple = "x86_64-unknown-linux-gnu"
-
-define dso_local void @foo() {
-  ret void
-}
-
-define dso_local ptr @bar() {
-  ret ptr @foo
-}
-
-!llvm.module.flags = !{!1}
-!1 = !{i32 4, !"ibt-seal", i32 1}
Index: llvm/test/CodeGen/X86/ibtseal-kernel.ll
===
--- llvm/test/CodeGen/X86/ibtseal-kernel.ll
+++ /dev/null
@@ -1,19 +0,0 @@
-; RUN: llc < %s -O2 -mtriple=x86_64-unknown-linux-gnu -x86-indirect-branch-tracking --code-model=kernel | FileCheck %s --check-prefix=CHECK-KERNEL-IBTSEAL
-
-; CHECK-KERNEL-IBTSEAL: foo:
-; CHECK-KERNEL-IBTSEAL: endbr
-; CHECK-KERNEL-IBTSEAL: bar:
-; CHECK-KERNEL-IBTSEAL-NOT: endbr
-
-target triple = "x86_64-unknown-linux-gnu"
-
-define dso_local void @foo() {
-  ret void
-}
-
-define dso_local ptr @bar() {
-  ret ptr @foo
-}
-
-!llvm.module.flags = !{!1}
-!1 = !{i32 4, !"ibt-seal", i32 1}
Index: llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
===
--- llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
+++ llvm/lib/Target/X86/X86IndirectBranchTracking.cpp
@@ -102,23 +102,10 @@
   if (F.doesNoCfCheck())
 return false;
 
-  const X86TargetMachine *TM =
-  static_cast(&MF.getTarget());
-  Metadata *IBTSeal = M->getModuleFlag("ibt-seal");
-
-  switch (TM->getCodeModel()) {
+  switch (MF.getTarget().getCodeModel()) {
   // Large code model functions always reachable through indirect calls.
   case CodeModel::Large:
 return true;
-  // Only address taken functions in LTO'ed kernel are reachable indirectly.
-  // IBTSeal implies LTO, thus only check if function is address taken.
-  case CodeModel::Kernel:
-// Check if ibt-seal was enabled (implies LTO is being used).
-if (IBTSeal) {
-  return F.hasAddressTaken();
-}
-// if !IBTSeal, fall into default case.
-[[fallthrough]];
   // Address taken or externally linked functions may be reachable.
   default:
 return (F.hasAddressTaken() || !F.hasLocalLinkage());
Index: clang/test/CodeGen/X86/x86-cf-protection.c
===
--- clang/test/CodeGen/X86/x86-cf-protection.c
+++ clang/test/CodeGen/X86/x86-cf-protection.c
@@ -1,17 +1,12 @@
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=return %s | FileCheck %s --check-prefix=RETURN
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=branch %s | FileCheck %s --check-prefix=BRANCH
 // RUN: %clang_cc1 -E -triple i386 -dM -o - -fcf-protection=full %s   | FileCheck %s --check-prefix=FULL
-// RUN: %clang_cc1 -emit-llvm -triple i386 -o - -fcf-protection=branch -mibt-seal -flto %s | FileCheck %s --check-prefixes=CFPROT,IBTSEAL
-// RUN: %clang_cc1 -emit-llvm -triple i386 -o - -fcf-protection=branch -flto %s | FileCheck %s --check-prefixes=CFPROT,NOIBTSEAL
-// RUN: %clang_cc1 -emit-llvm -triple i386 -o - -fcf-protection=branch -mibt-seal %s | FileCheck %s --check-prefixes=CFPROT,NOIBTSEAL
 // RUN: not %clang_cc1 -emit-llvm-only -triple i386 -target-cpu pentium-mmx -fcf-protection=branch %s 2>&1 | FileCheck %s

[clang] 69243cd - Remove incorrectly implemented -mibt-seal

2022-12-22 Thread Fangrui Song via cfe-commits
Author: Fangrui Song
Date: 2022-12-22T12:32:59-08:00
New Revision: 69243cdb926b1057c54522df305ffc195b2863ec

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

LOG: Remove incorrectly implemented -mibt-seal

The option from D116070 does not work as intended and will not be needed when
hidden visibility is used. A function needs ENDBR if it may be reached
indirectly. If we make ThinLTO combine the address-taken property (close to
`!GV.use_empty() && !GV.hasAtLeastLocalUnnamedAddr()`), then the condition can
be expressed with:

`AddressTaken || (!F.hasLocalLinkage() && (VisibleToRegularObj || 
!F.hasHiddenVisibility()))`

The current `F.hasAddressTaken()` condition does not take into acount of
address-significance in another bitcode file or ELF relocatable file.

For the Linux kernel, it uses relocatable linking. lld/ELF uses a
conservative approach by setting all `VisibleToRegularObj` to true.
Using the non-relocatable semantics may under-estimate
`VisibleToRegularObj`. As @pcc mentioned on
https://github.com/ClangBuiltLinux/linux/issues/1737#issuecomment-1343414686
, we probably need a symbol list to supply additional
`VisibleToRegularObj` symbols (not part of the relocatable LTO link).

Reviewed By: samitolvanen

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

Added: 


Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/X86/x86-cf-protection.c
llvm/lib/Target/X86/X86IndirectBranchTracking.cpp

Removed: 
llvm/test/CodeGen/X86/ibtseal-kernel.ll
llvm/test/CodeGen/X86/ibtseal-large.ll
llvm/test/CodeGen/X86/ibtseal-small.ll



diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 81d5ccd4856d4..0545a4d2d17fe 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -105,7 +105,6 @@ CODEGENOPT(CFProtectionReturn , 1, 0) ///< if 
-fcf-protection is
   ///< set to full or return.
 CODEGENOPT(CFProtectionBranch , 1, 0) ///< if -fcf-protection is
   ///< set to full or branch.
-CODEGENOPT(IBTSeal, 1, 0) ///< set to optimize CFProtectionBranch.
 CODEGENOPT(FunctionReturnThunks, 1, 0) ///< 
-mfunction-return={keep|thunk-extern}
 CODEGENOPT(IndirectBranchCSPrefix, 1, 0) ///< if -mindirect-branch-cs-prefix
  ///< is set.

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index f1fd45d8394ab..e7765dbe2c30b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2047,8 +2047,6 @@ def fcf_protection_EQ : Joined<["-"], "fcf-protection=">, 
Flags<[CoreOption, CC1
 def fcf_protection : Flag<["-"], "fcf-protection">, Group, 
Flags<[CoreOption, CC1Option]>,
   Alias, AliasArgs<["full"]>,
   HelpText<"Enable cf-protection in 'full' mode">;
-def mibt_seal : Flag<["-"], "mibt-seal">, Group, Flags<[CoreOption, 
CC1Option]>,
-  HelpText<"Optimize fcf-protection=branch/full (requires LTO).">;
 def mfunction_return_EQ : Joined<["-"], "mfunction-return=">,
   Group, Flags<[CoreOption, CC1Option]>,
   HelpText<"Replace returns with jumps to ``__x86_return_thunk`` (x86 only, 
error otherwise)">,

diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index fcb60e3b4e705..1d93c764cab3c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -775,9 +775,6 @@ void CodeGenModule::Release() {
   1);
   }
 
-  if (CodeGenOpts.IBTSeal)
-getModule().addModuleFlag(llvm::Module::Min, "ibt-seal", 1);
-
   if (CodeGenOpts.FunctionReturnThunks)
 getModule().addModuleFlag(llvm::Module::Override, 
"function_return_thunk_extern", 1);
 

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 61294a8dfd2ac..4aee050d96bbe 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -6361,9 +6361,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 Args.MakeArgString(Twine("-fcf-protection=") + A->getValue()));
   }
 
-  if (IsUsingLTO)
-Args.AddLastArg(CmdArgs, options::OPT_mibt_seal);
-
   if (Arg *A = Args.getLastArg(options::OPT_mfunction_return_EQ))
 CmdArgs.push_back(
 Args.MakeArgString(Twine("-mfunction-return=") + A->getValue()));

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index d89a80ebd6f62..1cabf286f909d

[PATCH] D140224: [Driver] Revert D139717 and add -Xparser instead

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

I'll reject [-\Xparser for a while as well. This is a valid amendment to 
D139717  , so I don't think it needs more 
approval.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140224

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


[clang] 46cd312 - [Driver] Revert D139717 and add -Xparser/-Xcompiler instead

2022-12-22 Thread Fangrui Song via cfe-commits
Author: Fangrui Song
Date: 2022-12-22T12:51:20-08:00
New Revision: 46cd3127fe54ab51f813492017c5acdbeb1baf26

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

LOG: [Driver] Revert D139717 and add -Xparser/-Xcompiler instead

Some macOS projects use -Xparser even if it leads to a
-Wunused-command-line-argument warning. It doesn't justify adding a broad Joined
`-X` (IgnoredGCCCompat) as GCC doesn't really support these arbitrary `-X`
options.

Note: `-Xcompiler foo` is a GNU libtool option, not a driver option.
It is misused by some ChromeOS packages (but not by Gentoo).
Keep it for a while.

It seems that GCC < 4.6 reports g++: unrecognized option '-Xfoo' but exit with 
0.
GCC >= 4.6 reports g++: error: unrecognized option '-Xfoo' and exits with 1.
It never supports -Xcompiler or -Xparser, so `IgnoredGCCCompat` is not 
justified.

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

Added: 
clang/test/Driver/warn-Xparser.c

Modified: 
clang/include/clang/Driver/Options.td

Removed: 
clang/test/Misc/warn-not-error-Xfoo.c



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index e7765dbe2c30b..86ef91c0b7fed 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -846,7 +846,10 @@ def Xoffload_linker : JoinedAndSeparate<["-"], 
"Xoffload-linker">,
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, 
Group,
   HelpText<"Pass  to the preprocessor">, MetaVarName<"">;
 def X_Flag : Flag<["-"], "X">, Group;
-def X_Joined : Joined<["-"], "X">, IgnoredGCCCompat;
+// Used by some macOS projects. IgnoredGCCCompat is a misnomer since GCC 
doesn't allow it.
+def : Flag<["-"], "Xparser">, IgnoredGCCCompat;
+// FIXME -Xcompiler is misused by some ChromeOS packages. Remove it after a 
while.
+def : Flag<["-"], "Xcompiler">, IgnoredGCCCompat;
 def Z_Flag : Flag<["-"], "Z">, Group;
 def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;

diff  --git a/clang/test/Driver/warn-Xparser.c 
b/clang/test/Driver/warn-Xparser.c
new file mode 100644
index 0..191826a6f4af9
--- /dev/null
+++ b/clang/test/Driver/warn-Xparser.c
@@ -0,0 +1,6 @@
+/// Some macOS projects use -Xparser.
+// RUN: %clang -c -Xparser %s 2>&1 | FileCheck %s
+
+// CHECK: warning: argument unused during compilation: '-Xparser' 
[-Wunused-command-line-argument]
+
+void f(void) {}

diff  --git a/clang/test/Misc/warn-not-error-Xfoo.c 
b/clang/test/Misc/warn-not-error-Xfoo.c
deleted file mode 100644
index 54d97c618cddf..0
--- a/clang/test/Misc/warn-not-error-Xfoo.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang -c %s -o /dev/null -Xfoo < %s 2>&1 | FileCheck 
--check-prefix=CHECK_STANDALONE_FOO %s
-// RUN: %clang -c %s -o /dev/null -Xfoo=bar 2>&1 | FileCheck 
--check-prefix=CHECK_JOINED_FOO %s
-
-// This test ensures that we only warn on -X and -X
-// in case it is used downstream. If we error, we can't ignore it and some
-// use of these (ignored) flags are in legacy use.
-// TODO: Deprecate with timebox warning so consumers can respond.
-
-// CHECK_STANDALONE_FOO: warning: argument unused during compilation: '-Xfoo' 
[-Wunused-command-line-argument]
-// CHECK_JOINED_FOO: warning: argument unused during compilation: '-Xfoo=bar' 
[-Wunused-command-line-argument]
-
-// CHECK-NOT: clang{.*}: error: unknown argument:
-
-void f(void) {}



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


[PATCH] D140224: [Driver] Revert D139717 and add -Xparser instead

2022-12-22 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG46cd3127fe54: [Driver] Revert D139717 and add 
-Xparser/-Xcompiler instead (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D140224?vs=483565&id=484938#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140224

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/warn-Xparser.c
  clang/test/Misc/warn-not-error-Xfoo.c


Index: clang/test/Misc/warn-not-error-Xfoo.c
===
--- clang/test/Misc/warn-not-error-Xfoo.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang -c %s -o /dev/null -Xfoo < %s 2>&1 | FileCheck 
--check-prefix=CHECK_STANDALONE_FOO %s
-// RUN: %clang -c %s -o /dev/null -Xfoo=bar 2>&1 | FileCheck 
--check-prefix=CHECK_JOINED_FOO %s
-
-// This test ensures that we only warn on -X and -X
-// in case it is used downstream. If we error, we can't ignore it and some
-// use of these (ignored) flags are in legacy use.
-// TODO: Deprecate with timebox warning so consumers can respond.
-
-// CHECK_STANDALONE_FOO: warning: argument unused during compilation: '-Xfoo' 
[-Wunused-command-line-argument]
-// CHECK_JOINED_FOO: warning: argument unused during compilation: '-Xfoo=bar' 
[-Wunused-command-line-argument]
-
-// CHECK-NOT: clang{.*}: error: unknown argument:
-
-void f(void) {}
Index: clang/test/Driver/warn-Xparser.c
===
--- /dev/null
+++ clang/test/Driver/warn-Xparser.c
@@ -0,0 +1,6 @@
+/// Some macOS projects use -Xparser.
+// RUN: %clang -c -Xparser %s 2>&1 | FileCheck %s
+
+// CHECK: warning: argument unused during compilation: '-Xparser' 
[-Wunused-command-line-argument]
+
+void f(void) {}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -846,7 +846,10 @@
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, 
Group,
   HelpText<"Pass  to the preprocessor">, MetaVarName<"">;
 def X_Flag : Flag<["-"], "X">, Group;
-def X_Joined : Joined<["-"], "X">, IgnoredGCCCompat;
+// Used by some macOS projects. IgnoredGCCCompat is a misnomer since GCC 
doesn't allow it.
+def : Flag<["-"], "Xparser">, IgnoredGCCCompat;
+// FIXME -Xcompiler is misused by some ChromeOS packages. Remove it after a 
while.
+def : Flag<["-"], "Xcompiler">, IgnoredGCCCompat;
 def Z_Flag : Flag<["-"], "Z">, Group;
 def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;


Index: clang/test/Misc/warn-not-error-Xfoo.c
===
--- clang/test/Misc/warn-not-error-Xfoo.c
+++ /dev/null
@@ -1,14 +0,0 @@
-// RUN: %clang -c %s -o /dev/null -Xfoo < %s 2>&1 | FileCheck --check-prefix=CHECK_STANDALONE_FOO %s
-// RUN: %clang -c %s -o /dev/null -Xfoo=bar 2>&1 | FileCheck --check-prefix=CHECK_JOINED_FOO %s
-
-// This test ensures that we only warn on -X and -X
-// in case it is used downstream. If we error, we can't ignore it and some
-// use of these (ignored) flags are in legacy use.
-// TODO: Deprecate with timebox warning so consumers can respond.
-
-// CHECK_STANDALONE_FOO: warning: argument unused during compilation: '-Xfoo' [-Wunused-command-line-argument]
-// CHECK_JOINED_FOO: warning: argument unused during compilation: '-Xfoo=bar' [-Wunused-command-line-argument]
-
-// CHECK-NOT: clang{.*}: error: unknown argument:
-
-void f(void) {}
Index: clang/test/Driver/warn-Xparser.c
===
--- /dev/null
+++ clang/test/Driver/warn-Xparser.c
@@ -0,0 +1,6 @@
+/// Some macOS projects use -Xparser.
+// RUN: %clang -c -Xparser %s 2>&1 | FileCheck %s
+
+// CHECK: warning: argument unused during compilation: '-Xparser' [-Wunused-command-line-argument]
+
+void f(void) {}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -846,7 +846,10 @@
 def Xpreprocessor : Separate<["-"], "Xpreprocessor">, Group,
   HelpText<"Pass  to the preprocessor">, MetaVarName<"">;
 def X_Flag : Flag<["-"], "X">, Group;
-def X_Joined : Joined<["-"], "X">, IgnoredGCCCompat;
+// Used by some macOS projects. IgnoredGCCCompat is a misnomer since GCC doesn't allow it.
+def : Flag<["-"], "Xparser">, IgnoredGCCCompat;
+// FIXME -Xcompiler is misused by some ChromeOS packages. Remove it after a while.
+def : Flag<["-"], "Xcompiler">, IgnoredGCCCompat;
 def Z_Flag : Flag<["-"], "Z">, Group;
 def all__load : Flag<["-"], "all_load">;
 def allowable__client : Separate<["-"], "allowable_client">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://

[PATCH] D140584: [Clang] Refactor "Designators" into a unified implementation [NFC]

2022-12-22 Thread Bill Wendling via Phabricator via cfe-commits
void created this revision.
void added reviewers: aaron.ballman, rjmccall, rsmith, dblaikie.
Herald added subscribers: arphaman, martong.
Herald added a reviewer: shafik.
Herald added a project: All.
void requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The interfaces for designators (i.e. C99 designated initializers) was
done in two slightly different ways. This was rather wasteful as the
differences could be combined into one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D140584

Files:
  clang/include/clang/AST/Designator.h
  clang/include/clang/AST/Expr.h
  clang/include/clang/Sema/Designator.h
  clang/include/clang/Tooling/Refactoring/RecursiveSymbolVisitor.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Index/IndexBody.cpp
  clang/lib/Parse/ParseInit.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2847,8 +2847,7 @@
 }
 void EnqueueVisitor::VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
   AddStmt(E->getInit());
-  for (const DesignatedInitExpr::Designator &D :
-   llvm::reverse(E->designators())) {
+  for (const Designator &D : llvm::reverse(E->designators())) {
 if (D.isFieldDesignator()) {
   if (FieldDecl *Field = D.getField())
 AddMemberRef(Field, D.getFieldLoc());
Index: clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
===
--- clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -227,7 +227,7 @@
   }
 
   bool VisitDesignatedInitExpr(const DesignatedInitExpr *E) {
-for (const DesignatedInitExpr::Designator &D : E->designators()) {
+for (const Designator &D : E->designators()) {
   if (D.isFieldDesignator() && D.getField()) {
 const FieldDecl *Decl = D.getField();
 if (isInUSRSet(Decl)) {
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1085,7 +1085,7 @@
 Record.AddStmt(E->getSubExpr(I));
   Record.AddSourceLocation(E->getEqualOrColonLoc());
   Record.push_back(E->usesGNUSyntax());
-  for (const DesignatedInitExpr::Designator &D : E->designators()) {
+  for (const Designator &D : E->designators()) {
 if (D.isFieldDesignator()) {
   if (FieldDecl *Field = D.getField()) {
 Record.push_back(serialization::DESIG_FIELD_DECL);
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -1198,8 +1198,6 @@
 }
 
 void ASTStmtReader::VisitDesignatedInitExpr(DesignatedInitExpr *E) {
-  using Designator = DesignatedInitExpr::Designator;
-
   VisitExpr(E);
   unsigned NumSubExprs = Record.readInt();
   assert(NumSubExprs == E->getNumSubExprs() && "Wrong number of subexprs");
@@ -1215,8 +1213,8 @@
   auto *Field = readDeclAs();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Field->getIdentifier(), DotLoc,
-   FieldLoc));
+  Designators.push_back(Designator::CreateFieldDesignator(
+  Field->getIdentifier(), DotLoc, FieldLoc));
   Designators.back().setField(Field);
   break;
 }
@@ -1225,7 +1223,8 @@
   const IdentifierInfo *Name = Record.readIdentifier();
   SourceLocation DotLoc = readSourceLocation();
   SourceLocation FieldLoc = readSourceLocation();
-  Designators.push_back(Designator(Name, DotLoc, FieldLoc));
+  Designators.push_back(
+  Designator::CreateFieldDesignator(Name, DotLoc, FieldLoc));
   break;
 }
 
@@ -1233,7 +1232,8 @@
   unsigned Index = Record.readInt();
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  Designators.push_back(Designator(Index, LBracketLoc, RBracketLoc));
+  Designators.push_back(
+  Designator::CreateArrayDesignator(Index, LBracketLoc, RBracketLoc));
   break;
 }
 
@@ -1242,8 +1242,8 @@
   SourceLocation LBracketLoc = readSourceLocation();
   SourceLocation EllipsisLoc = readSourceLocation();
   SourceLocation RBracketLoc = readSourceLocation();
-  De

[PATCH] D140315: [AMDGCN] Update search path for device libraries

2022-12-22 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan updated this revision to Diff 484945.
scchan added a comment.

Remove unused bitcode files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140315

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/asanrtl.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/hip.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/ockl.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_abi_version_400.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_abi_version_500.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_correctly_rounded_sqrt_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_correctly_rounded_sqrt_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_daz_opt_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_daz_opt_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_finite_only_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_finite_only_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_isa_version_1010.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_isa_version_1011.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_isa_version_1012.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_isa_version_803.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_isa_version_900.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_isa_version_908.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_unsafe_math_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_unsafe_math_on.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_wavefrontsize64_off.bc
  
clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/oclc_wavefrontsize64_on.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/ocml.bc
  clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode/opencl.bc
  clang/test/Driver/hip-device-libs.hip

Index: clang/test/Driver/hip-device-libs.hip
===
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -9,7 +9,7 @@
 // RUN:  --cuda-gpu-arch=gfx803 \
 // RUN:  --rocm-path=%S/Inputs/rocm   \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
 
 
 // Test subtarget with flushing off by ddefault.
@@ -17,7 +17,7 @@
 // RUN:  --cuda-gpu-arch=gfx900 \
 // RUN:  --rocm-path=%S/Inputs/rocm \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
 
 
 // Test explicit flag, opposite of target default.
@@ -26,7 +26,7 @@
 // RUN:   -fgpu-flush-denormals-to-zero \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
 
 
 // Test explicit flag, opposite of target default.
@@ -35,7 +35,7 @@
 // RUN:   -fno-gpu-flush-denormals-to-zero \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
 
 
 // Test explicit flag, same as target default.
@@ -44,7 +44,7 @@
 // RUN:   -fno-gpu-flush-denormals-to-zero \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
 
 
 // Test explicit flag, same as target default.
@@ -53,7 +53,7 @@
 // RUN:   -fgpu-flush-denormals-to-zero \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,FLUSHD,ROCMDIR
 
 
 // Test last flag wins, not flushing
@@ -62,7 +62,7 @@
 // RUN:   -fgpu-flush-denormals-to-zero -fno-gpu-flush-denormals-to-zero \
 // RUN:   --rocm-path=%S/Inputs/rocm \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
-// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD
+// RUN: 2>&1 | FileCheck %s --check-prefixes=ALL,NOFLUSHD,ROCMDIR
 
 
 // RUN: %clang -### --target=x86_64-linux-gnu \
@@ -70,7 +70,7 @@
 // RUN:   -fgpu-flush-denormals-to-zero -fno-gpu-flush-denormals-to-zero \
 // RUN:   --rocm-path=%S/Inputs/rocm   \
 // RUN:   %S/Inputs/hip_multiple_inputs/b.hi

[PATCH] D140315: [AMDGCN] Update search path for device libraries

2022-12-22 Thread Siu Chi Chan via Phabricator via cfe-commits
scchan added a comment.

In D140315#4011440 , @yaxunl wrote:

> files under 
> clang/test/Driver/Inputs/rocm_resource_dir/lib/amdgcn/bitcode-no-abi-ver seem 
> not used.

removed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140315

___
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-22 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth added a comment.

Sorry for the noise, I missed that that bot is setting a CMake flag that 
affects LLVM_EXPORTS. Please disregard my earlier message. I just need to 
update the CMake invocation to fix this, so I don't think there is anything 
required on your end.


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] D108265: .clang-tidy: Push variable related readability-identifier-naming options down to projects

2022-12-22 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 484955.
MaskRay edited the summary of this revision.
MaskRay added a comment.
Herald added a reviewer: bollu.
Herald added subscribers: yota9, ayermolo, StephenFan.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: njames93.
Herald added a project: All.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108265

Files:
  .clang-tidy
  bolt/.clang-tidy
  clang-tools-extra/.clang-tidy
  llvm/.clang-tidy
  polly/.clang-tidy


Index: polly/.clang-tidy
===
--- /dev/null
+++ polly/.clang-tidy
@@ -0,0 +1,9 @@
+Checks: 'readability-identifier-naming'
+InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase
Index: llvm/.clang-tidy
===
--- llvm/.clang-tidy
+++ llvm/.clang-tidy
@@ -1 +1,9 @@
+Checks: 'readability-identifier-naming'
 InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase
Index: clang-tools-extra/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/.clang-tidy
@@ -0,0 +1,9 @@
+Checks: 'readability-identifier-naming'
+InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase
Index: bolt/.clang-tidy
===
--- /dev/null
+++ bolt/.clang-tidy
@@ -0,0 +1,9 @@
+Checks: 'readability-identifier-naming'
+InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -10,14 +10,8 @@
   # throughout the code base.
   - key: readability-identifier-naming.FunctionIgnoredRegexp
 value:   "LLVMFuzzerTestOneInput"
-  - key: readability-identifier-naming.MemberCase
-value:   CamelCase
-  - key: readability-identifier-naming.ParameterCase
-value:   CamelCase
   - key: readability-identifier-naming.UnionCase
 value:   CamelCase
-  - key: readability-identifier-naming.VariableCase
-value:   CamelCase
   - key: readability-identifier-naming.IgnoreMainLikeFunctions
 value:   1
   - key: 
readability-redundant-member-init.IgnoreBaseInCopyConstructors


Index: polly/.clang-tidy
===
--- /dev/null
+++ polly/.clang-tidy
@@ -0,0 +1,9 @@
+Checks: 'readability-identifier-naming'
+InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase
Index: llvm/.clang-tidy
===
--- llvm/.clang-tidy
+++ llvm/.clang-tidy
@@ -1 +1,9 @@
+Checks: 'readability-identifier-naming'
 InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase
Index: clang-tools-extra/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/.clang-tidy
@@ -0,0 +1,9 @@
+Checks: 'readability-identifier-naming'
+InheritParentConfig: true
+CheckOptions:
+  - key: readability-identifier-naming.ParameterCase
+value:   CamelCase
+  - key: readab

[PATCH] D108265: .clang-tidy: Push variable related readability-identifier-naming options down to projects

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

Created D140585  to update 
`llvm/docs/CodingStandards.rst`. Changed the summary to mention 
https://discourse.llvm.org/t/top-level-clang-tidy-options-and-variablename-suggestion-on-codingstandards/58783


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108265

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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-22 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/unittests/Format/FormatTest.cpp:25124
 
+TEST_F(FormatTest, IntegerLiteralSeparator) {
+  FormatStyle Style = getLLVMStyle();

I'd like to see `FormatTest.cpp` shrink, maybe add this in a new file?



Comment at: clang/unittests/Format/FormatTest.cpp:25166
+   Style);
+}
+

Add a test that we really don't touch floating points?


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

https://reviews.llvm.org/D140543

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


[PATCH] D108265: .clang-tidy: Push variable related readability-identifier-naming options down to projects

2022-12-22 Thread Amir Ayupov via Phabricator via cfe-commits
Amir accepted this revision.
Amir added a comment.
This revision is now accepted and ready to land.

LGTM for BOLT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108265

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


[clang] 9b050e5 - [clang] Remove redundant initialization of std::optional (NFC)

2022-12-22 Thread Kazu Hirata via cfe-commits
Author: Kazu Hirata
Date: 2022-12-22T13:46:26-08:00
New Revision: 9b050e5011e92be1b953cc1cc1406cfbcb43fb90

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

LOG: [clang] Remove redundant initialization of std::optional (NFC)

Added: 


Modified: 
clang/lib/APINotes/APINotesYAMLCompiler.cpp
clang/lib/Analysis/UnsafeBufferUsage.cpp

Removed: 




diff  --git a/clang/lib/APINotes/APINotesYAMLCompiler.cpp 
b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
index d3e53c4dd191f..ff94f61940bfb 100644
--- a/clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -549,7 +549,7 @@ struct Module {
   TopLevelItems TopLevel;
   VersionedSeq SwiftVersions;
 
-  std::optional SwiftInferImportAsMember = std::nullopt;
+  std::optional SwiftInferImportAsMember;
 
 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
   LLVM_DUMP_METHOD void dump() /*const*/;

diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 88d6ca3eaf0c5..7de2de1c84bc2 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -427,7 +427,7 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
 if (!any_of(VDGadgets, [](const Gadget *G) { return !G->isSafe(); }))
   continue;
 
-std::optional Fixes = std::nullopt;
+std::optional Fixes;
 
 // Avoid suggesting fixes if not all uses of the variable are identified
 // as known gadgets.



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


[PATCH] D140363: Remove incorrectly implemented -mibt-seal

2022-12-22 Thread Joao Moreira via Phabricator via cfe-commits
joaomoreira added a comment.

FWIIW, agreed on removing this until we figure out how to make it work 
properly. Thanks for the patch @MaskRay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140363

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


  1   2   >