[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Hey Aaron, do you have any more comments on this?


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

https://reviews.llvm.org/D97362

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


[PATCH] D99062: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

2021-03-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 332551.
balazske added a comment.

Rebase and changed test code format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99062

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
@@ -6261,6 +6261,25 @@
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void declToImport(int N) {
+int VLA[N];
+[&VLA] {}; // FieldDecl inside the lambda.
+  }
+  )",
+  Lang_CXX14);
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,10 @@
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3645,6 +3649,8 @@
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6261,6 +6261,25 @@
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void declToImport(int N) {
+int VLA[N];
+[&VLA] {}; // FieldDecl inside the lambda.
+  }
+  )",
+  Lang_CXX14);
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,10 @@
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3645,6 +3649,8 @@
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D98498: [clangd] Enable modules to contribute tweaks.

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 332552.
kadircet marked 4 inline comments as done.
kadircet added a comment.
Herald added a subscriber: mgorny.

- Add test
- Move forward declarations out of signatures
- Move FeatureModuleSets to the last parameter in prepareTweaks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98498

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/FeatureModule.h
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
  clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/TweakTesting.cpp
@@ -75,7 +75,7 @@
 Range.second, [&](SelectionTree ST) {
   Tweak::Selection S(Index, AST, Range.first,
  Range.second, std::move(ST));
-  if (auto T = prepareTweak(TweakID, S)) {
+  if (auto T = prepareTweak(TweakID, S, nullptr)) {
 Result = (*T)->apply(S);
 return true;
   } else {
Index: clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/FeatureModulesTests.cpp
@@ -0,0 +1,55 @@
+//===--- FeatureModulesTests.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
+//
+//===--===//
+
+#include "FeatureModule.h"
+#include "Selection.h"
+#include "TestTU.h"
+#include "refactor/Tweak.h"
+#include "support/Logger.h"
+#include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TEST(FeatureModulesTest, ContributesTweak) {
+  static constexpr const char *TweakID = "ModuleTweak";
+  struct TweakContributingModule final : public FeatureModule {
+struct ModuleTweak final : public Tweak {
+  const char *id() const override { return TweakID; }
+  bool prepare(const Selection &Sel) override { return true; }
+  Expected apply(const Selection &Sel) override {
+return error("not implemented");
+  }
+  std::string title() const override { return id(); }
+  llvm::StringLiteral kind() const override { return ""; };
+};
+
+void contributeTweaks(std::vector> &Out) override {
+  Out.emplace_back(new ModuleTweak);
+}
+  };
+
+  FeatureModuleSet Set;
+  Set.add(std::make_unique());
+
+  auto AST = TestTU::withCode("").build();
+  auto Tree =
+  SelectionTree::createRight(AST.getASTContext(), AST.getTokens(), 0, 0);
+  auto Actual = prepareTweak(
+  TweakID, Tweak::Selection(nullptr, AST, 0, 0, std::move(Tree)), &Set);
+  ASSERT_TRUE(bool(Actual));
+  EXPECT_EQ(Actual->get()->id(), TweakID);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -55,6 +55,7 @@
   DraftStoreTests.cpp
   DumpASTTests.cpp
   ExpectedTypeTest.cpp
+  FeatureModulesTests.cpp
   FileDistanceTests.cpp
   FileIndexTests.cpp
   FindSymbolsTests.cpp
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -206,7 +206,8 @@
   auto Tree = SelectionTree::createRight(AST->getASTContext(),
  AST->getTokens(), Start, End);
   Tweak::Selection Selection(&Index, *AST, Start, End, std::move(Tree));
-  for (const auto &T : prepareTweaks(Selection, Opts.TweakFilter)) {
+  for (const auto &T :
+   prepareTweaks(Selection, Opts.TweakFilter, Opts.FeatureModules)) {
 auto Result = T->apply(Selection);
 if (!Result) {
   elog("tweak: {0} ==> FAIL: {1}", T->id(), Result.takeError());
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ c

[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke created this revision.
Herald added a subscriber: pengfei.
LuoYuanke requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Introduce new intrinsic to cast vector and amx. This can prevent
middle-end optimization on bitcast. However sometimes we need the
optimizaton for bitcast. For inner_product of amx_cast.c, we have to
deal with llvm.x86.vector.amx.cast.v256i32.x86amx by ourselves.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99152

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/amx_cast.c
  llvm/include/llvm/IR/IntrinsicsX86.td

Index: llvm/include/llvm/IR/IntrinsicsX86.td
===
--- llvm/include/llvm/IR/IntrinsicsX86.td
+++ llvm/include/llvm/IR/IntrinsicsX86.td
@@ -5085,6 +5085,8 @@
 [llvm_i16_ty, llvm_i16_ty, llvm_i16_ty,
  llvm_x86amx_ty, llvm_x86amx_ty,
  llvm_x86amx_ty], []>;
+  def int_x86_vector_amx_cast :
+  Intrinsic<[llvm_any_ty], [llvm_any_ty], [IntrNoMem]>;
 }
 
 //===--===//
Index: clang/test/CodeGen/X86/amx_cast.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/amx_cast.c
@@ -0,0 +1,90 @@
+// RUN: %clang_cc1 %s -O2 -ffreestanding -triple=x86_64-unknown-unknown  -target-feature +avx512f  -target-feature +amx-int8  \
+// RUN: -target-feature +amx-bf16 -emit-llvm -o - -Werror -pedantic | FileCheck %s --check-prefixes=CHECK
+
+#include 
+
+char buf[1024];
+#define STRIDE 32
+
+char buf2[1024];
+
+void test1() {
+//CHECK: %0 = tail call x86_amx @llvm.x86.tileloadd64.internal(i16 8, i16 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @buf, i64 0, i64 0), i64 32) #1
+//CHECK: %1 = tail call <256 x i32> @llvm.x86.vector.amx.cast.v256i32.x86amx(x86_amx %0) #1
+//CHECK: %2 = tail call x86_amx @llvm.x86.vector.amx.cast.x86amx.v256i32(<256 x i32> %1) #1
+//CHECK: tail call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @buf, i64 0, i64 0), i64 32, x86_amx %2) #1
+  __tile1024i a = {8, 8};
+  __tile1024i b = {8, 8};
+
+  __tile_loadd(&a, buf, STRIDE);
+  __tile_stored(buf, STRIDE, a);
+}
+
+void test2() {
+//CHECK:  %0 = tail call x86_amx @llvm.x86.vector.amx.cast.x86amx.v256i32(<256 x i32> zeroinitializer) #1
+//CHECK:  tail call void @llvm.x86.tilestored64.internal(i16 8, i16 8, i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @buf, i64 0, i64 0), i64 32, x86_amx %0) #1
+  __tile1024i a = {8, 8};
+
+  __tile_stored(buf, STRIDE, a);
+}
+
+#define TILE_SZ 16
+void inner_product(int *A_mem, int *B_mem, int *C_mem, int M, int N, int K) {
+//CHECK: for.body6:; preds = %for.body6.lr.ph, %for.cond.cleanup9
+//CHECK:   %indvars.iv200 = phi i64 [ 0, %for.body6.lr.ph ], [ %indvars.iv.next201, %for.cond.cleanup9 ]
+//CHECK:   %1 = tail call x86_amx @llvm.x86.tilezero.internal(i16 16, i16 64) #1
+//CHECK:   %2 = tail call <256 x i32> @llvm.x86.vector.amx.cast.v256i32.x86amx(x86_amx %1) #1
+//CHECK:   %3 = shl nsw i64 %indvars.iv200, 4
+//CHECK:   br i1 %cmp8163, label %for.body10.lr.ph, label %for.cond.cleanup9
+//CHECK: for.body10.lr.ph: ; preds = %for.body6
+//CHECK:   %add.ptr19 = getelementptr inbounds i32, i32* %B_mem, i64 %3
+//CHECK:   br label %for.body10
+//CHECK: for.cond.cleanup9:; preds = %for.body10, %for.body6
+//CHECK:   %c.sroa.8127.2.lcssa = phi <256 x i32> [ %2, %for.body6 ], [ %18, %for.body10 ]
+//CHECK:   %add.ptr31 = getelementptr inbounds i32, i32* %add.ptr28, i64 %3
+//CHECK:   %4 = bitcast i32* %add.ptr31 to i8*
+//CHECK:   %5 = tail call x86_amx @llvm.x86.vector.amx.cast.x86amx.v256i32(<256 x i32> %c.sroa.8127.2.lcssa) #1
+//CHECK:   tail call void @llvm.x86.tilestored64.internal(i16 16, i16 64, i8* %4, i64 %mul24, x86_amx %5) #1
+//CHECK:   %indvars.iv.next201 = add nuw nsw i64 %indvars.iv200, 1
+//CHECK:   %exitcond205.not = icmp eq i64 %indvars.iv.next201, %wide.trip.count204
+//CHECK:   br i1 %exitcond205.not, label %for.cond.cleanup5, label %for.body6, !llvm.loop !4
+//CHECK: for.body10:   ; preds = %for.body10.lr.ph, %for.body10
+//CHECK:   %indvars.iv = phi i64 [ 0, %for.body10.lr.ph ], [ %indvars.iv.next, %for.body10 ]
+//CHECK:   %c.sroa.8127.2164 = phi <256 x i32> [ %2, %for.body10.lr.ph ], [ %18, %for.body10 ]
+//CHECK:   %6 = shl nsw i64 %indvars.iv, 4
+//CHECK:   %add.ptr14 = getelementptr inbounds i32, i32* %add.ptr, i64 %6
+//CHECK:   %7 = bitcast i32* %add.ptr14 to i8*
+//CHECK:   %8 = tail call x86_amx @llvm.x86.tileloadd64.internal(i16 16, i16 64, i8* %7, i64 %mul15) #1
+//CHECK:   %9 = tail call <256 x i32> @llvm.x86.vector.amx.cast.v256i32.x86amx(x86_amx %8) #1
+//CHECK:

[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

I'm a little bit lost with all this AMX stuff.
Could you please explain in normal human words, what does `__tile_loadd()` do?
I.e. given

  void wrapper(__tile& dst, const void *base, int stride) {
_tile_loadd(dst, const void *base, int stride);
  }

which bytes from `base` will be loaded?




Comment at: clang/test/CodeGen/X86/amx_cast.c:1
+// RUN: %clang_cc1 %s -O2 -ffreestanding -triple=x86_64-unknown-unknown  
-target-feature +avx512f  -target-feature +amx-int8  \
+// RUN: -target-feature +amx-bf16 -emit-llvm -o - -Werror -pedantic | 
FileCheck %s --check-prefixes=CHECK

Please don't use llvm optimizations in clang tests.



Comment at: clang/test/CodeGen/X86/amx_cast.c:4
+
+#include 
+

The tests should be hermetic.
Which `immintrin.h` is being used there?
Hopefully the one from clang, not the one from system?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99145: [clang] Fix a crash when CTAD fails

2021-03-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks!




Comment at: clang/test/Sema/check-arg-alignment.cpp:1
+// Ensure we don't crash when CTAD fails.
+// RUN: %clang_cc1 -std=c++17 -verify %s

I'd move this test case to the existing file 
`llvm-project/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99145

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


[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-23 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 332558.
curdeius added a comment.

- Format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseExprCXX.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.lambda/p4-1y.cpp
  clang/test/FixIt/fixit-c++11.cpp
  clang/test/Parser/cxx-concepts-requires-clause.cpp
  clang/test/Parser/cxx0x-lambda-expressions.cpp
  clang/test/Parser/cxx1z-constexpr-lambdas.cpp
  clang/test/Parser/cxx2a-template-lambdas.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/test/SemaOpenCLCXX/address-space-lambda.cl
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -63,7 +63,7 @@
 
  C++2b (tentatively C++23)
  -std=c++2b
- No
+ Partial
 
 
 
@@ -1276,7 +1276,7 @@
 
   Make () in lambdas optional in all cases
   https://wg21.link/p1102r2";>P1102R2
-  No
+  Clang 13
 
 
 
Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- clang/test/SemaOpenCLCXX/address-space-lambda.cl
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -61,7 +61,10 @@
   [&] () __global {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__global'}}
   [&] () __private {} (); //expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
 
-  [&] __private {} (); //expected-error{{lambda requires '()' before attribute specifier}} expected-error{{expected body of lambda expression}}
+  [&] __private {} (); // expected-error{{no matching function for call to object of type '(lambda at}} expected-note{{candidate function not viable: 'this' object is in default address space, but method expects object in address space '__private'}}
+#if __cplusplus <= 202002L
+// expected-warning@-2{{lambda without a parameter clause is a C++2b extension}}
+#endif
 
   [&] () mutable __private {} ();
   [&] () __private mutable {} (); //expected-error{{expected body of lambda expression}}
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
+
+auto LL0 = [] {};
+auto LL1 = []() {};
+auto LL2 = []() mutable {};
+auto LL3 = []() constexpr {};
+
+auto L0 = [] constexpr {};
+auto L1 = [] mutable {};
+auto L2 = [] noexcept {};
+auto L3 = [] constexpr mutable {};
+auto L4 = [] mutable constexpr {};
+auto L5 = [] constexpr mutable noexcept {};
+auto L6 = [s = 1] mutable {};
+auto L7 = [s = 1] constexpr mutable noexcept {};
+auto L8 = [] -> bool { return true; };
+auto L9 = [] { return true; };
+auto L10 = [] noexcept { return true; };
+auto L11 = [] -> bool { return true; };
+auto L12 = [] consteval {};
+auto L13 = [] requires requires() { true; }
+{};
+auto L15 = [] [[maybe_unused]]{};
+
+auto XL0 = [] mutable constexpr mutable {};// expected-error{{cannot appear multiple times}}
+auto XL1 = [] constexpr mutable constexpr {};  // expected-error{{cannot appear multiple times}}
+auto XL2 = []) constexpr mutable constexpr {}; // expected-error{{expected body}}
+auto XL3 = []( constexpr mutable constexpr {}; // expected-error{{invalid storage class specifier}} \
+   // expected-error{{function parameter cannot be constexpr}} \
+   // expected-error{{C++ requires}} \
+   // expected-error{{expected ')'}} \
+   // expected-note{{to match this '('}} \
+   // expected-error{{expected body}} \
+   // expected-warning{{duplicate 'constexpr'}}
Index: clang/test/Parser/cxx2a-template-lambdas.cpp
===
--- clang/test/Parser/cxx2a-template-lambdas.cpp
+++ clang/test/Parser/cxx2a-template-lambdas.cpp
@@ -1,3 +1,4 @@
+// RUN: %clang_cc1 -std=c++2b %s -verify
 // RUN: %clang_cc1 -std=c++2a %s -verify
 
 auto L0 = []<> { }; //expected-error {{cannot be empty}}
Index: clang/test/Parser/cxx1z-constexpr-lambdas.cpp
===
--- clang/test/Parser/cxx1z-constexpr-lambdas.cpp
+++ clang/test/Parser/cxx1z-constexpr-lambdas.cpp
@@ -1,12 +1,19 @@
-// RUN: %clang_cc1 -std=c++17 %s -verify 
-// RUN: %clan

[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-03-23 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: llvm/lib/Transforms/Utils/RelLookupTableConverter.cpp:91
+  ArrayType::get(Type::getInt32Ty(M.getContext()), NumElts);
+  GlobalVariable *RelLookupTable = new GlobalVariable(
+  M, IntArrayTy, LookupTable.isConstant(), LookupTable.getLinkage(),

This should use the same address space as the original global.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D94355

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-23 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

If you follow people tweeting about clang-format (as I do) and you look through 
the bug tracking system, one major criticism of clang-format is that the second 
clang-format can be different from the first, sometimes an equilibrium can be 
found sometimes not.

When I started working on clang-format I was encouraged to use verifyFormat() 
as it tests that scenario and also tries to mess up the format and ensure it 
returns to the desired state. It found bugs in my code which would have made 
clang-format worse.

Apart from it being the convention I believe it makes for much more readable 
code, even if there is repetition as I don't need to keep cross referencing 
variables with rather obscure names `NL_B_3_A_0_I_0` this is unnecessary noise 
and makes the code overly verbose.

No you'll need to check out what the messUp() function is actually doing but I 
think by and large IMHO we should stick with verifyFormat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

@lebedev.ri, this patch is mainly for discussing the approach that Florian 
proposed, so I didn't polish my code. Nevertheless your comments for amx_cast.c 
is right. For __tile_loadd() is to load a 2d tile from memory. There is an 
extra parameter stride. As I explain in llvm-dev, it load each row from memory 
to tile register and then base += stride. So the data is not contiguous in 
memory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99031: [clang-format] Fix CompactNamespaces corner case when AllowShortLambdasOnASingleLine/BraceWrapping.BeforeLambdaBody are set

2021-03-23 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D99031#2640654 , 
@HazardyKnusperkeks wrote:

> In D99031#2640425 , @aybassiouny 
> wrote:
>
>>> How about verifyFormat? Would that fail without your patch?
>>
>> @HazardyKnusperkeks sorry, but not sure that I understand your point. Are 
>> you suggesting to use verifyFormat in my UT instead of EXPECT_EQ?
>
> I'm pretty sure @MyDeveloperDay would ask for that. I would maybe use both. 
> But what it really interesting for me if verifyFormat would fail, i.e. would 
> clang-format misformat something previously correctly formatted.

I would, see D98237: [clang-format] Option for empty lines after an access 
modifier.  as to why.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99031

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


[clang] 3cde27b - [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

2021-03-23 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2021-03-23T09:54:25+01:00
New Revision: 3cde27bc563ce82ba081be5b650bec523df2c928

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

LOG: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

Update ASTImporter to import value of FieldDecl::getCapturedVLAType.

Reviewed By: shafik, martong

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

Added: 


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

Removed: 




diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index f9b1910552ee..c4f36b50db9d 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,10 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl 
*D) {
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3645,6 +3649,8 @@ ExpectedDecl ASTNodeImporter::VisitFieldDecl(FieldDecl 
*D) {
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 9458fc226580..94cec2c140e1 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -6261,6 +6261,25 @@ TEST_P(ASTImporterOptionSpecificTestBase,
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void declToImport(int N) {
+int VLA[N];
+[&VLA] {}; // FieldDecl inside the lambda.
+  }
+  )",
+  Lang_CXX14);
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 



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


[PATCH] D99062: [clang][ASTImporter] Import "CapturedVLAType" in FieldDecl.

2021-03-23 Thread Balázs Kéri 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 rG3cde27bc563c: [clang][ASTImporter] Import 
"CapturedVLAType" in FieldDecl. (authored by balazske).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99062

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
@@ -6261,6 +6261,25 @@
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void declToImport(int N) {
+int VLA[N];
+[&VLA] {}; // FieldDecl inside the lambda.
+  }
+  )",
+  Lang_CXX14);
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,10 @@
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3645,6 +3649,8 @@
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -6261,6 +6261,25 @@
   EXPECT_TRUE(To2);
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportOfCapturedVLAType) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  void declToImport(int N) {
+int VLA[N];
+[&VLA] {}; // FieldDecl inside the lambda.
+  }
+  )",
+  Lang_CXX14);
+  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+  ASSERT_TRUE(FromFD);
+  ASSERT_TRUE(FromFD->hasCapturedVLAType());
+
+  auto *ToFD = Import(FromFD, Lang_CXX14);
+  EXPECT_TRUE(ToFD);
+  EXPECT_TRUE(ToFD->hasCapturedVLAType());
+  EXPECT_NE(FromFD->getCapturedVLAType(), ToFD->getCapturedVLAType());
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,10 @@
   auto ToInitializer = importChecked(Err, D->getInClassInitializer());
   if (Err)
 return std::move(Err);
+  const Type *ToCapturedVLAType = nullptr;
+  if (Error Err = Importer.importInto(
+  ToCapturedVLAType, cast_or_null(D->getCapturedVLAType(
+return std::move(Err);
 
   FieldDecl *ToField;
   if (GetImportedOrCreateDecl(ToField, D, Importer.getToContext(), DC,
@@ -3645,6 +3649,8 @@
   if (ToInitializer)
 ToField->setInClassInitializer(ToInitializer);
   ToField->setImplicit(D->isImplicit());
+  if (ToCapturedVLAType)
+ToField->setCapturedVLAType(cast(ToCapturedVLAType));
   LexicalDC->addDeclInternal(ToField);
   return ToField;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri requested changes to this revision.
lebedev.ri added a comment.
This revision now requires changes to proceed.

In D99152#2643821 , @LuoYuanke wrote:

> @lebedev.ri, this patch is mainly for discussing the approach that Florian 
> proposed, so I didn't polish my code. Nevertheless your comments for 
> amx_cast.c is right.



> For __tile_loadd() is to load a 2d tile from memory. There is an extra 
> parameter stride. As I explain in llvm-dev, it load each row from memory to 
> tile register and then base += stride. So the data is not contiguous in 
> memory.

Aha. Finally. So i was right and you are hiding a bug.
Bitcast is a red herring.
You should not be producing a plain load, that is a miscompile already.
You should be either ideally producing LLVM IR's native tile load instruction 
(is there one? i thought),
or introduce `@llvm.x86.vector.amx.load` and produce it instead.

Full stop. I'm going to block any further AMX patches until this is addressed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99009: [RISCV] [1/2] Add intrinsic for Zbr extension

2021-03-23 Thread LevyHsu via Phabricator via cfe-commits
LevyHsu updated this revision to Diff 332562.
LevyHsu edited the summary of this revision.
LevyHsu added a comment.

1. Fix format issue
2. For

  SemaChecking.cpp 

now it should allow Diag to print all missing features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbr.ll
  llvm/test/CodeGen/RISCV/rv64zbr.ll

Index: llvm/test/CodeGen/RISCV/rv64zbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbr.ll
@@ -0,0 +1,91 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=experimental-zbr -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64ZBR
+
+declare i64 @llvm.riscv.crc32.b.i64(i64)
+
+define i64 @crc32b(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32b:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.b a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.b.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32.h.i64(i64)
+
+define i64 @crc32h(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32h:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.h a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.h.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32.w.i64(i64)
+
+define i64 @crc32w(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32w:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.w a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.w.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.b.i64(i64)
+
+define i64 @crc32cb(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32cb:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.b a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.b.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.h.i64(i64)
+
+define i64 @crc32ch(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32ch:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.h a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.h.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.w.i64(i64)
+
+define i64 @crc32cw(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32cw:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.w a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.w.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32.d.i64(i64)
+
+define i64 @crc32d(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32d:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32.d a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32.d.i64(i64 %a)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.crc32c.d.i64(i64)
+
+define i64 @crc32cd(i64 %a) nounwind {
+; RV64ZBR-LABEL: crc32cd:
+; RV64ZBR:   # %bb.0:
+; RV64ZBR-NEXT:crc32c.d a0, a0
+; RV64ZBR-NEXT:ret
+  %tmp = call i64 @llvm.riscv.crc32c.d.i64(i64 %a)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbr.ll
@@ -0,0 +1,69 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=experimental-zbr -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32ZBR
+
+declare i32 @llvm.riscv.crc32.b.i32(i32)
+
+define i32 @crc32b(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32b:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32.b a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32.b.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32.h.i32(i32)
+
+define i32 @crc32h(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32h:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32.h a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32.h.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32.w.i32(i32)
+
+define i32 @crc32w(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32w:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32.w a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32.w.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32c.b.i32(i32)
+
+define i32 @crc32cb(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32cb:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT:crc32c.b a0, a0
+; RV32ZBR-NEXT:ret
+  %tmp = call i32 @llvm.riscv.crc32c.b.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.crc32c.h.i32(i32)
+
+define i32 @crc32ch(i32 %a) nounwind {
+; RV32ZBR-LABEL: crc32ch:
+; RV32ZBR:   # %bb.0:
+; RV32ZBR-NEXT: 

[PATCH] D99008: [RISCV] [2/2] Add intrinsic for Zbr extension

2021-03-23 Thread LevyHsu via Phabricator via cfe-commits
LevyHsu updated this revision to Diff 332565.
LevyHsu edited the summary of this revision.
LevyHsu added a comment.

1. Format fix
2. rvintrin.c is moved to the second part of the pach


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99008

Files:
  clang-tools-extra/clang-include-fixer/find-all-symbols/STLPostfixHeaderMap.cpp
  clang-tools-extra/clangd/index/CanonicalIncludes.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/riscv_zbr_intrin.h
  clang/lib/Headers/rvintrin.h
  clang/test/Headers/rvintrin.c

Index: clang/test/Headers/rvintrin.c
===
--- /dev/null
+++ clang/test/Headers/rvintrin.c
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple riscv32 -fsyntax-only \
+// RUN:   -target-feature +experimental-v %s
+// RUN: %clang_cc1 -triple riscv64 -fsyntax-only \
+// RUN:   -target-feature +experimental-v %s
+
+#include 
Index: clang/lib/Headers/rvintrin.h
===
--- /dev/null
+++ clang/lib/Headers/rvintrin.h
@@ -0,0 +1,28 @@
+/* === rvintrin.h --===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#ifndef __RVINTRIN_H
+#define __RVINTRIN_H
+
+// Long is 32 bit on riscv32 and 64 bit on riscv64 according to calling 
+// convention.
+#define int_xlen_t long
+#define uint_xlen_t unsigned int_xlen_t
+
+#define __DEFAULT_FN_ATTRS \
+  __attribute__((__always_inline__, __artificial__, __nodebug__))
+
+#if defined(__riscv_zbr)
+#include "riscv_zbr_intrin.h"
+#endif
+
+#undef __DEFAULT_FN_ATTRS
+#undef uint_xlen_t
+#undef int_xlen_t
+#endif // __RVINTRIN_H
Index: clang/lib/Headers/riscv_zbr_intrin.h
===
--- /dev/null
+++ clang/lib/Headers/riscv_zbr_intrin.h
@@ -0,0 +1,60 @@
+/* === riscv_zbr_intrin.h --===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#ifndef __RISCV_ZBR_INTRIN_H
+#define __RISCV_ZBR_INTRIN_H
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+// Zbr
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_b(int_xlen_t rs1) {
+  return __builtin_riscv_crc32_b(rs1);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_h(int_xlen_t rs1) {
+  return __builtin_riscv_crc32_h(rs1);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_w(int_xlen_t rs1) {
+  return __builtin_riscv_crc32_w(rs1);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_b(int_xlen_t rs1) {
+  return __builtin_riscv_crc32c_b(rs1);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_h(int_xlen_t rs1) {
+  return __builtin_riscv_crc32c_h(rs1);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_w(int_xlen_t rs1) {
+  return __builtin_riscv_crc32c_w(rs1);
+}
+
+// RV64 only intrinsics
+
+#if __riscv_xlen == 64
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32_d(int_xlen_t rs1) {
+return __builtin_riscv_crc32_d(rs1);
+}
+
+static __inline__ int_xlen_t __DEFAULT_FN_ATTRS _rv_crc32c_d(int_xlen_t rs1) {
+return __builtin_riscv_crc32c_d(rs1);
+}
+
+#endif // if defined(__riscv64__)
+
+#if defined(__cplusplus)
+}
+#endif // if defined(__cplusplus)
+
+#endif // __RISCV_ZBR_INTRIN_H
\ No newline at end of file
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -97,6 +97,8 @@
   ptwriteintrin.h
   rdseedintrin.h
   rtmintrin.h
+  rvintrin.h
+  riscv_zbr_intrin.h
   serializeintrin.h
   sgxintrin.h
   s390intrin.h
Index: clang-tools-extra/clangd/index/CanonicalIncludes.cpp
===
--- clang-tools-extra/clangd/index/CanonicalIncludes.cpp
+++ clang-tools-extra/clangd/index/CanonicalIncludes.cpp
@@ -152,6 +152,8 @@
   {"include/prfchwintrin.h", ""},
   {"include/rdseedintrin.h", ""},
   {"include/rtmintrin.h", ""},
+

[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-03-23 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

A quick search of github shows over 1 billion hits to the word struct, in a 
variety of flavours, I'm just not convinced we want a separate option for each 
and every case,

Could we not look for a sequence of 
"tok::kw_struct,tok::identifier,tok::lbrace" or kw_strcut,tok::lbrace? rather 
than using the rather fragile Line->StartsWith which is only going to capture 
some of the cases.

  typedef struct  Foo{
 ..
  }
  
  static struct Foo {
 ..
  }
  
  static constexpr struct Foo {
 ..
  }
  
  template <> struct  Foo{
...
  }
  
  struct {
  }




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

https://reviews.llvm.org/D91949

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-23 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

I'd be quite interested to understand what the impact (if any) would be on 
javascript and C# formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-23 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz updated this revision to Diff 332567.
glaubitz edited the summary of this revision.
Herald added subscribers: arichardson, emaste.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

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


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3557,12 +3552,10 @@
 // RUN: -target sparcv9-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: clang/lib/Basic/Targets/Sparc.cpp
===
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,8 +156,6 @@
   Builder.defineMacro("__sparcv8__");
   break;
 case CG_V9:
-  Builder.defineMacro("__sparcv9");
-  Builder.defineMacro("__sparcv9__");
   Builder.defineMacro("__sparc_v9__");
   break;
 }
@@ -239,13 +237,25 @@
 void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
  MacroBuilder &Builder) const {
   SparcTargetInfo::getTargetDefines(Opts, Builder);
-  Builder.defineMacro("__sparcv9");
   Builder.defineMacro("__arch64__");
-  // Solaris doesn't need these variants, but the BSDs do.
-  if (getTriple().getOS() != llvm::Triple::Solaris) {
+  switch (getTriple().getOS()) {
+  case llvm::Triple::Linux:
+Builder.defineMacro("__sparc_v9__");
+break;
+  case llvm::Triple::FreeBSD:
+  case llvm::Triple::NetBSD:
 Builder.defineMacro("__sparc64__");
 Builder.defineMacro("__sparc_v9__");
+Builder.defineMacro("__sparcv9");
+break;
+  case llvm::Triple::OpenBSD:
+Builder.defineMacro("__sparc64__");
 Builder.defineMacro("__sparcv9__");
+Builder.defineMacro("__sparc_v9__");
+break;
+  case llvm::Triple::Solaris:
+Builder.defineMacro("__sparcv9");
+break;
   }
 
   Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -3457,11 +3457,8 @@
 // CHECK_SPARC: #define __BIG_ENDIAN__ 1
 // CHECK_SPARC: #define __sparc 1
 // CHECK_SPARC: #define __sparc__ 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
 // CHECK_SPARC: #define __sparcv8 1
-// CHECK_SPARC-NOT: #define __sparcv9 1
-// CHECK_SPARC-NOT: #define __sparcv9__ 1
+// CHECK_SPARC-NOT: #define __sparc_v9__ 1
 
 // RUN: %clang -mcpu=v9 -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-unknown-linux \
@@ -3469,8 +3466,6 @@
 // CHECK_SPARC-V9-NOT: #define __sparcv8 1
 // CHECK_SPARC-V9-NOT: #define __sparcv8__ 1
 // CHECK_SPARC-V9: #define __sparc_v9__ 1
-// CHECK_SPARC-V9: #define __sparcv9 1
-// CHECK_SPARC-V9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparc-sun-solaris \
@@ -3557,12 +3552,10 @@
 // RUN: -target sparcv9-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARCV9
 // CHECK_SPARCV9: #define __BIG_ENDIAN__ 1
+// CHECK_SPARCV9: #define __arch64__ 1
 // CHECK_SPARCV9: #define __sparc 1
-// CHECK_SPARCV9: #define __sparc64__ 1
 // CHECK_SPARCV9: #define __sparc__ 1
 // CHECK_SPARCV9: #define __sparc_v9__ 1
-// CHECK_SPARCV9: #define __sparcv9 1
-// CHECK_SPARCV9: #define __sparcv9__ 1
 
 // RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target sparcv9-unknown-linux \
Index: cl

[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux and the BSDs

2021-03-23 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

Updated as I previously forgot to account for FreeBSD as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98574

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


[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-03-23 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok created this revision.
alok added reviewers: aprantl, jmorse, djtodoro.
alok added a project: debug-info.
Herald added subscribers: jansvoboda11, pengfei, ormris, hiraditya.
Herald added a reviewer: sscalpone.
alok requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

DW_OP_entry_value and DW_TAG_call_site_parameter work together to preserve 
optimized out paramters value for debugging purpose.
There is always some level of optimization happening even with -O0.
 Currently DW_OP_entry_value is generated at all the options but 
DW_TAG_call_site_parameter is not generated with FastISEL.
 This causes debuggers to show optimized out parameters value at higher 
optimization but not at lower optimization.

Adding support to it now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99160

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/lib/Target/X86/X86FastISel.cpp
  llvm/test/CodeGen/X86/call-site-info-output.ll
  llvm/test/DebugInfo/X86/callsitepar-fastisel.ll

Index: llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/callsitepar-fastisel.ll
@@ -0,0 +1,215 @@
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for fastIsel.
+; REQUIRES: x86_64-linux
+;RUN: llc -mtriple=x86_64-pc-linux-gnu -emit-call-site-info -fast-isel=true -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
+;CHECK: DW_TAG_GNU_call_site
+;CHECK: DW_AT_abstract_origin
+;CHECK-SAME: "foo"
+;CHECK: DW_AT_low_pc
+;CHECK: DW_TAG_GNU_call_site_parameter
+;CHECK: DW_AT_location (DW_OP_reg4 RSI)
+;CHECK: DW_AT_GNU_call_site_value
+
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for option -O0
+;RUN: clang -cc1 -triple x86_64-unknown-linux-gnu -emit-obj  -main-file-name %s -debug-info-kind=limited -dwarf-version=4 -debugger-tuning=gdb -O0 -x ir %s -o - | llvm-dwarfdump - | FileCheck %s --check-prefix=CLANG
+
+;CLANG: DW_TAG_GNU_call_site
+;CLANG: DW_AT_abstract_origin
+;CLANG-SAME: "foo"
+;CLANG: DW_AT_low_pc
+;CLANG: DW_TAG_GNU_call_site_parameter
+;CLANG: DW_AT_location (DW_OP_reg4 RSI)
+;CLANG: DW_AT_GNU_call_site_value
+
+;;The IR is generated from below source program
+;
+;;subroutine foo (array)
+;;  integer :: array(:,:)
+;;  array(:,:) = 5
+;;  array(1,1) = 30
+;;end subroutine
+;;
+;;program vla_sub
+;;  interface
+;;subroutine foo (array)
+;;  integer :: array (:,:)
+;;end subroutine
+;;  end interface
+;;
+;;  integer :: sub_arr(42,42)
+;;  sub_arr(:,:) = 1
+;;  call foo(sub_arr)
+;;end program vla_sub
+;
+
+; ModuleID = 'fast.ll'
+source_filename = "/tmp/fast.ll"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%struct.BSS2 = type <{ [7056 x i8] }>
+
+@.BSS2 = internal global %struct.BSS2 zeroinitializer, align 32, !dbg !0
+@.C359_MAIN_ = internal constant i64 42
+@.C333_MAIN_ = internal constant i64 1
+@.C368_MAIN_ = internal constant i64 4
+@.C367_MAIN_ = internal constant i64 25
+@.C331_MAIN_ = internal constant i64 0
+@.C330_MAIN_ = internal constant i32 0
+
+; Function Attrs: nofree norecurse nounwind
+define void @foo_(i64* noalias nocapture %array, i64* noalias nocapture readonly %"array$sd") local_unnamed_addr #0 !dbg !15 {
+L.entry:
+  call void @llvm.dbg.value(metadata i64* %array, metadata !28, metadata !DIExpression()), !dbg !29
+  call void @llvm.dbg.declare(metadata i64* %"array$sd", metadata !30, metadata !DIExpression()), !dbg !29
+  %0 = getelementptr i64, i64* %"array$sd", i64 11
+  %1 = load i64, i64* %0, align 8
+  call void @llvm.dbg.value(metadata i64 %1, metadata !21, metadata !DIExpression()), !dbg !29
+  %2 = getelementptr i64, i64* %"array$sd", i64 20
+  %3 = load i64, i64* %2, align 8
+  %4 = getelementptr i64, i64* %"array$sd", i64 17
+  %5 = load i64, i64* %4, align 8
+  call void @llvm.dbg.value(metadata i64 %5, metadata !24, metadata !DIExpression()), !dbg !29
+  %6 = getelementptr i64, i64* %"array$sd", i64 7
+  %7 = load i64, i64* %6, align 8
+  %8 = getelementptr i64, i64* %"array$sd", i64 16
+  %9 = load i64, i64* %8, align 8
+  %10 = add nsw i64 %9, -1
+  %11 = mul nsw i64 %10, %3
+  %12 = getelementptr i64, i64* %"array$sd", i64 10
+  %13 = load i64, i64* %12, align 8
+  %14 = add i64 %7, -1
+  %15 = add i64 %14, %13
+  %16 = add i64 %15, %11
+  %17 = icmp slt i64 %1, 1, !dbg !35
+  %18 = icmp slt i64 %5, 1, !dbg !35
+  %19 = or i1 %17, %18, !dbg !35
+  br i1 %19, label %L.LB1_372, label %L.LB1_371.preheader, !dbg !35
+
+L.LB1_371.preheader:  ; preds = %L.entry
+  %20 = bitcast i64* %array to i8*
+  %21 = getelementptr i8, i8* %20, i64 -4
+  %22 = bitcast i8* %21 to i32*
+  br label %L.LB1_371
+
+L.LB1_371:  

[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

@lebedev.ri, our goal is seeking a ideal solution, not arguing who is right. I 
hope there is no bias during the discussion. I hope Florian and James set a 
role model for you. They are trying to understand the problem and helping solve 
the problem. I don't know if it is the right way to stop other's patch based on 
your own preference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

load  instruction loads 
contigious bytes.
If that is not what is AMX is trying to use it for, then it is being used 
incorrectly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-23 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 requested changes to this revision.
jansvoboda11 added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Driver/Options.td:4872
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,

Please, update the new options to use the marshalling infrastructure. You can 
then remove the code from `CompilerInvocation`.

https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option


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

https://reviews.llvm.org/D82547

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


[clang] 54e4654 - [PowerPC] Add more missing overloads to altivec.h

2021-03-23 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-23T05:09:19-05:00
New Revision: 54e4654f0465a960c1a6aeb02bb4ca33a3f19e67

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

LOG: [PowerPC] Add more missing overloads to altivec.h

Add overloads that perform addition on v1i128 that take and produce
vector unsigned char to avoid needing to use __int128. The overloads
are suffixed with _u128 and are needed for targets where __int128
isn't supported (AIX).

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-p8vector.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index cabb7b225b84..f3340f20b7b4 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -304,6 +304,12 @@ static __inline__ vector unsigned __int128 __ATTRS_o_ai
 vec_add(vector unsigned __int128 __a, vector unsigned __int128 __b) {
   return __a + __b;
 }
+
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_add_u128(vector unsigned char __a, vector unsigned char __b) {
+  return (vector unsigned char)((vector unsigned __int128)__a +
+(vector unsigned __int128)__b);
+}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 static __inline__ vector float __ATTRS_o_ai vec_add(vector float __a,
@@ -332,6 +338,14 @@ vec_adde(vector unsigned __int128 __a, vector unsigned 
__int128 __b,
  vector unsigned __int128 __c) {
   return __builtin_altivec_vaddeuqm(__a, __b, __c);
 }
+
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_adde_u128(vector unsigned char __a, vector unsigned char __b,
+  vector unsigned char __c) {
+  return (vector unsigned char)__builtin_altivec_vaddeuqm(
+  (vector unsigned __int128)__a, (vector unsigned __int128)__b,
+  (vector unsigned __int128)__c);
+}
 #endif
 
 static __inline__ vector signed int __ATTRS_o_ai
@@ -365,6 +379,14 @@ vec_addec(vector unsigned __int128 __a, vector unsigned 
__int128 __b,
   return __builtin_altivec_vaddecuq(__a, __b, __c);
 }
 
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_addec_u128(vector unsigned char __a, vector unsigned char __b,
+   vector unsigned char __c) {
+  return (vector unsigned char)__builtin_altivec_vaddecuq(
+  (vector unsigned __int128)__a, (vector unsigned __int128)__b,
+  (vector unsigned __int128)__c);
+}
+
 static __inline__ vector signed int __ATTRS_o_ai
 vec_addec(vector signed int __a, vector signed int __b,
   vector signed int __c) {
@@ -545,6 +567,12 @@ static __inline__ vector unsigned __int128 __ATTRS_o_ai
 vec_addc(vector unsigned __int128 __a, vector unsigned __int128 __b) {
   return __builtin_altivec_vaddcuq(__a, __b);
 }
+
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_addc_u128(vector unsigned char __a, vector unsigned char __b) {
+  return (vector unsigned char)__builtin_altivec_vaddcuq(
+  (vector unsigned __int128)__a, (vector unsigned __int128)__b);
+}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 /* vec_vaddcuw */

diff  --git a/clang/test/CodeGen/builtins-ppc-p8vector.c 
b/clang/test/CodeGen/builtins-ppc-p8vector.c
index ea73cefc0706..07494c22f23b 100644
--- a/clang/test/CodeGen/builtins-ppc-p8vector.c
+++ b/clang/test/CodeGen/builtins-ppc-p8vector.c
@@ -84,6 +84,10 @@ void test1() {
 // CHECK-LE: add <2 x i64>
 // CHECK-PPC: error: call to 'vec_add' is ambiguous
 
+  res_vuc = vec_add_u128(vuc, vuc);
+// CHECK: add <1 x i128>
+// CHECK-LE: add <1 x i128>
+
   /* vec_addc */
   res_vsi = vec_addc(vsi, vsi);
 // CHECK: @llvm.ppc.altivec.vaddcuw
@@ -99,6 +103,10 @@ void test1() {
 
   res_vux = vec_addc(vux, vux);
 // CHECK: @llvm.ppc.altivec.vaddcuq
+// CHECK-LE: @llvm.ppc.altivec.vaddcuq
+
+  res_vuc = vec_addc_u128(vuc, vuc);
+// CHECK: @llvm.ppc.altivec.vaddcuq
 // CHECK-LE: @llvm.ppc.altivec.vaddcuq
 
   /* vec_adde */
@@ -108,11 +116,19 @@ void test1() {
 
   res_vux = vec_adde(vux, vux, vux);
 // CHECK: @llvm.ppc.altivec.vaddeuqm
+// CHECK-LE: @llvm.ppc.altivec.vaddeuqm
+
+  res_vuc = vec_adde_u128(vuc, vuc, vuc);
+// CHECK: @llvm.ppc.altivec.vaddeuqm
 // CHECK-LE: @llvm.ppc.altivec.vaddeuqm
 
   /* vec_addec */
   res_vsx = vec_addec(vsx, vsx, vsx);
 // CHECK: @llvm.ppc.altivec.vaddecuq
+// CHECK-LE: @llvm.ppc.altivec.vaddecuq
+
+  res_vuc = vec_addec_u128(vuc, vuc, vuc);
+// CHECK: @llvm.ppc.altivec.vaddecuq
 // CHECK-LE: @llvm.ppc.altivec.vaddecuq
 
   /* vec_mergee */  



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


[clang] 1c6521a - [OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h

2021-03-23 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-03-23T10:20:13Z
New Revision: 1c6521a0ddfabb9c451f57164369e49b2826ee6d

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

LOG: [OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h

The OpenCL C specification v3.0.6 s6.15.12.7.5 mentions:

For atomic_fetch and modify functions with key = or, xor, and, min
and max on atomic type atomic_intptr_t, M is intptr_t, and on
atomic type atomic_uintptr_t, M is uintptr_t.

Remove the atomic_fetch_* overloads from opencl-c.h that mix intptr_t
and uintptr_t in the same declaration.

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

Added: 


Modified: 
clang/lib/Headers/opencl-c.h

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 8bc669214f4f..c0b7072d5b0a 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -13393,7 +13393,6 @@ ulong __ovld atomic_fetch_max_explicit(volatile 
atomic_ulong *object, ulong oper
 
 // OpenCL v2.0 s6.13.11.7.5:
 // add/sub: atomic type argument can be uintptr_t/intptr_t, value type 
argument can be ptr
diff _t.
-// or/xor/and/min/max: atomic type argument can be intptr_t/uintptr_t, value 
type argument can be intptr_t/uintptr_t.
 
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptr
diff _t operand);
@@ -13402,38 +13401,6 @@ uintptr_t __ovld atomic_fetch_add_explicit(volatile 
atomic_uintptr_t *object, pt
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptr
diff _t operand);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptr
diff _t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptr
diff _t operand, memory_order order, memory_scope scope);
-
-uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t *object, intptr_t 
opermax);
-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder);
-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder, memory_scope scope);
-uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t *object, intptr_t 
opermax);
-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder);
-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder, memory_scope scope);
-
-intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t *object, uintptr_t 
opermax);
-intptr_t _

[PATCH] D98418: [OpenCL] Remove mixed signedness atomic_fetch_ from opencl-c.h

2021-03-23 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c6521a0ddfa: [OpenCL] Remove mixed signedness atomic_fetch_ 
from opencl-c.h (authored by svenvh).
Herald added a subscriber: ldrumm.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98418

Files:
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13393,7 +13393,6 @@
 
 // OpenCL v2.0 s6.13.11.7.5:
 // add/sub: atomic type argument can be uintptr_t/intptr_t, value type 
argument can be ptrdiff_t.
-// or/xor/and/min/max: atomic type argument can be intptr_t/uintptr_t, value 
type argument can be intptr_t/uintptr_t.
 
 #if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 uintptr_t __ovld atomic_fetch_add(volatile atomic_uintptr_t *object, ptrdiff_t 
operand);
@@ -13402,38 +13401,6 @@
 uintptr_t __ovld atomic_fetch_sub(volatile atomic_uintptr_t *object, ptrdiff_t 
operand);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptrdiff_t operand, memory_order order);
 uintptr_t __ovld atomic_fetch_sub_explicit(volatile atomic_uintptr_t *object, 
ptrdiff_t operand, memory_order order, memory_scope scope);
-
-uintptr_t __ovld atomic_fetch_or(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_or_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_xor(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_and(volatile atomic_uintptr_t *object, intptr_t 
operand);
-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order);
-uintptr_t __ovld atomic_fetch_and_explicit(volatile atomic_uintptr_t *object, 
intptr_t operand, memory_order order, memory_scope scope);
-uintptr_t __ovld atomic_fetch_min(volatile atomic_uintptr_t *object, intptr_t 
opermax);
-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder);
-uintptr_t __ovld atomic_fetch_min_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder, memory_scope scope);
-uintptr_t __ovld atomic_fetch_max(volatile atomic_uintptr_t *object, intptr_t 
opermax);
-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder);
-uintptr_t __ovld atomic_fetch_max_explicit(volatile atomic_uintptr_t *object, 
intptr_t opermax, memory_order minder, memory_scope scope);
-
-intptr_t __ovld atomic_fetch_or(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_or_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_xor(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_xor_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_and(volatile atomic_intptr_t *object, uintptr_t 
operand);
-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order);
-intptr_t __ovld atomic_fetch_and_explicit(volatile atomic_intptr_t *object, 
uintptr_t operand, memory_order order, memory_scope scope);
-intptr_t __ovld atomic_fetch_min(volatile atomic_intptr_t *object, uintptr_t 
opermax);
-intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, 
uintptr_t opermax, memory_order minder);
-intptr_t __ovld atomic_fetch_min_explicit(volatile atomic_intptr_t *object, 
uintptr_t opermax, memory_order minder, memory_scope scope);
-intptr_t __ovld atomic_fetch_max(volatile atomic_intptr_t *object, uintptr_t 
opermax);
-intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, 
uintptr_t opermax, memory_order minder);
-intptr_t __ovld atomic_fetch_max_explicit(volatile atomic_intptr_t *object, 
uintptr_t opermax, memory_order minder, memory_scope scope);
 #endif
 
 // atomic_store()


Index: clang/lib/Headers/opencl-c.h

[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.

2021-03-23 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
hokein requested review of this revision.
Herald added a project: clang.

The LookupDestructor requires a complete class definition, the
callside (checkDesturctorReference) didnt't guarantee that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99165

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp


Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,11 @@
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in 
scalar initializer}}
 }
+
+namespace no_crash {
+template 
+class Foo {};
+void test(int foo) {
+  Foo array[foo] = {0}; // expected-error {{variable-sized object may not 
be initialized}}
+}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1831,6 +1831,8 @@
   auto *CXXRD = ElementType->getAsCXXRecordDecl();
   if (!CXXRD)
 return false;
+  if (!CXXRD->isCompleteDefinition())
+return false;
 
   CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(CXXRD);
   SemaRef.CheckDestructorAccess(Loc, Destructor,


Index: clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
===
--- clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
+++ clang/test/SemaCXX/cxx0x-initializer-aggregates.cpp
@@ -133,3 +133,11 @@
 namespace PR24816 {
   struct { int i; } ne = {{0, 1}}; // expected-error{{excess elements in scalar initializer}}
 }
+
+namespace no_crash {
+template 
+class Foo {};
+void test(int foo) {
+  Foo array[foo] = {0}; // expected-error {{variable-sized object may not be initialized}}
+}
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -1831,6 +1831,8 @@
   auto *CXXRD = ElementType->getAsCXXRecordDecl();
   if (!CXXRD)
 return false;
+  if (!CXXRD->isCompleteDefinition())
+return false;
 
   CXXDestructorDecl *Destructor = SemaRef.LookupDestructor(CXXRD);
   SemaRef.CheckDestructorAccess(Loc, Destructor,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

In D99152#2644017 , @lebedev.ri wrote:

> load  instruction loads 
> contigious bytes.
> If that is not what is AMX is trying to use it for, then it is being used 
> incorrectly.

Isn't it a reason that we can't cast "load <256 x i32>*" to "load x86_amx*"? 
The load memory for <256 x i32> is contiguous, and load memory for x86_amx is 
not contiguous.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99121: [IR][InstCombine] IntToPtr Produces Typeless Pointer To Byte

2021-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 332600.
lebedev.ri marked an inline comment as done.
lebedev.ri added a comment.
Herald added subscribers: cfe-commits, pengfei.
Herald added a project: clang.

Also update a few clang tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99121

Files:
  clang/test/CodeGen/X86/ms-x86-intrinsics.c
  clang/test/CodeGen/arm64_32-vaarg.c
  clang/test/CodeGen/pointer-signext.c
  clang/test/CodeGenCXX/RelativeVTablesABI/member-function-pointer.cpp
  clang/test/CodeGenOpenCL/as_type.cl
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/test/Transforms/InstCombine/2009-02-20-InstCombine-SROA.ll
  llvm/test/Transforms/InstCombine/PR30597.ll
  llvm/test/Transforms/InstCombine/align-addr.ll
  llvm/test/Transforms/InstCombine/apint-call-cast-target.ll
  llvm/test/Transforms/InstCombine/cast_ptr.ll
  llvm/test/Transforms/InstCombine/indexed-gep-compares.ll
  llvm/test/Transforms/InstCombine/intptr1.ll
  llvm/test/Transforms/InstCombine/intptr3.ll
  llvm/test/Transforms/InstCombine/intptr7.ll
  llvm/test/Transforms/InstCombine/load-bitcast32.ll
  llvm/test/Transforms/InstCombine/load-bitcast64.ll
  llvm/test/Transforms/InstCombine/multi-use-load-casts.ll
  llvm/test/Transforms/InstCombine/ptr-int-cast.ll
  llvm/test/Transforms/InstCombine/type_pun-inseltpoison.ll
  llvm/test/Transforms/InstCombine/type_pun.ll

Index: llvm/test/Transforms/InstCombine/type_pun.ll
===
--- llvm/test/Transforms/InstCombine/type_pun.ll
+++ llvm/test/Transforms/InstCombine/type_pun.ll
@@ -57,8 +57,9 @@
 ; CHECK-LABEL: @type_pun_pointer(
 ; CHECK-NEXT:[[SROA_BC:%.*]] = bitcast <16 x i8> [[IN:%.*]] to <4 x i32>
 ; CHECK-NEXT:[[SROA_EXTRACT:%.*]] = extractelement <4 x i32> [[SROA_BC]], i32 0
-; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i32 [[SROA_EXTRACT]] to i32*
-; CHECK-NEXT:ret i32* [[TMP1]]
+; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i32 [[SROA_EXTRACT]] to i8*
+; CHECK-NEXT:[[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32*
+; CHECK-NEXT:ret i32* [[TMP2]]
 ;
   %sroa = shufflevector <16 x i8> %in, <16 x i8> undef, <4 x i32> 
   %1 = bitcast <4 x i8> %sroa to i32
Index: llvm/test/Transforms/InstCombine/type_pun-inseltpoison.ll
===
--- llvm/test/Transforms/InstCombine/type_pun-inseltpoison.ll
+++ llvm/test/Transforms/InstCombine/type_pun-inseltpoison.ll
@@ -57,8 +57,9 @@
 ; CHECK-LABEL: @type_pun_pointer(
 ; CHECK-NEXT:[[SROA_BC:%.*]] = bitcast <16 x i8> [[IN:%.*]] to <4 x i32>
 ; CHECK-NEXT:[[SROA_EXTRACT:%.*]] = extractelement <4 x i32> [[SROA_BC]], i32 0
-; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i32 [[SROA_EXTRACT]] to i32*
-; CHECK-NEXT:ret i32* [[TMP1]]
+; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i32 [[SROA_EXTRACT]] to i8*
+; CHECK-NEXT:[[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32*
+; CHECK-NEXT:ret i32* [[TMP2]]
 ;
   %sroa = shufflevector <16 x i8> %in, <16 x i8> poison, <4 x i32> 
   %1 = bitcast <4 x i8> %sroa to i32
Index: llvm/test/Transforms/InstCombine/ptr-int-cast.ll
===
--- llvm/test/Transforms/InstCombine/ptr-int-cast.ll
+++ llvm/test/Transforms/InstCombine/ptr-int-cast.ll
@@ -19,8 +19,9 @@
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP0:%.*]] = trunc i128 [[X:%.*]] to i64
-; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to i32*
-; CHECK-NEXT:ret i32* [[TMP1]]
+; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i64 [[TMP0]] to i8*
+; CHECK-NEXT:[[TMP2:%.*]] = bitcast i8* [[TMP1]] to i32*
+; CHECK-NEXT:ret i32* [[TMP2]]
 ;
 entry:
   %0 = inttoptr i128 %x to i32*
Index: llvm/test/Transforms/InstCombine/multi-use-load-casts.ll
===
--- llvm/test/Transforms/InstCombine/multi-use-load-casts.ll
+++ llvm/test/Transforms/InstCombine/multi-use-load-casts.ll
@@ -15,11 +15,13 @@
 ; CHECK-NEXT:tail call void @abort()
 ; CHECK-NEXT:unreachable
 ; CHECK:   bb5:
-; CHECK-NEXT:[[PTR0:%.*]] = inttoptr i64 [[DATA]] to i32*
+; CHECK-NEXT:[[TMP0:%.*]] = inttoptr i64 [[DATA]] to i8*
+; CHECK-NEXT:[[PTR0:%.*]] = bitcast i8* [[TMP0]] to i32*
 ; CHECK-NEXT:tail call void @sink0(i32* [[PTR0]])
 ; CHECK-NEXT:br label [[BB9:%.*]]
 ; CHECK:   bb7:
-; CHECK-NEXT:[[PTR1:%.*]] = inttoptr i64 [[DATA]] to i32*
+; CHECK-NEXT:[[TMP1:%.*]] = inttoptr i64 [[DATA]] to i8*
+; CHECK-NEXT:[[PTR1:%.*]] = bitcast i8* [[TMP1]] to i32*
 ; CHECK-NEXT:tail call void @sink1(i32* [[PTR1]])
 ; CHECK-NEXT:br label [[BB9]]
 ; CHECK:   bb9:
@@ -62,7 +64,8 @@
 ; CHECK-NEXT:tail call void @abort()
 ; CHECK-NEXT:unreachable
 ; CHECK:   bb5:
-; CHECK-NEXT:[[PTR0:%.*]] = inttoptr i64 [[DATA]] to i32*
+; CHECK-NEXT:[[TMP0:%.*]

[PATCH] D99160: [X86][FastISEL] Support DW_TAG_call_site_parameter with FastISEL

2021-03-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

Cool -- thanks for working on this!




Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1645
 
-  if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() &&
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))

I think this should be a different patch.

Are you saying this is useful for some -O0 cases? Can you please provide a test 
case? Is this related to Fortran only?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99160

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


[clang] 2f782a7 - [PowerPC] Add more missing overloads to altivec.h

2021-03-23 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-23T05:52:36-05:00
New Revision: 2f782a796a2b0a4bb5ff772577f96eacdb9254c1

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

LOG: [PowerPC] Add more missing overloads to altivec.h

Add overloads that perform subtraction on v1i128 that take and
produce vector unsigned char to avoid needing to use __int128.
The overloads are suffixed with _u128 and are needed for targets
where __int128 isn't supported (AIX).

Added: 


Modified: 
clang/lib/Headers/altivec.h
clang/test/CodeGen/builtins-ppc-quadword.c

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index f3340f20b7b4..c5674413e483 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -11636,6 +11636,12 @@ static __inline__ vector signed __int128 __ATTRS_o_ai
 vec_subc(vector signed __int128 __a, vector signed __int128 __b) {
   return __builtin_altivec_vsubcuq(__a, __b);
 }
+
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_subc_u128(vector unsigned char __a, vector unsigned char __b) {
+  return (vector unsigned char)__builtin_altivec_vsubcuq(
+  (vector unsigned __int128)__a, (vector unsigned __int128)__b);
+}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 /* vec_vsubcuw */
@@ -11852,6 +11858,12 @@ vec_vsubuqm(vector unsigned __int128 __a, vector 
unsigned __int128 __b) {
   return __a - __b;
 }
 
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_sub_u128(vector unsigned char __a, vector unsigned char __b) {
+  return (vector unsigned char)((vector unsigned __int128)__a -
+(vector unsigned __int128)__b);
+}
+
 /* vec_vsubeuqm */
 
 
@@ -11879,6 +11891,14 @@ vec_sube(vector unsigned __int128 __a, vector unsigned 
__int128 __b,
   return __builtin_altivec_vsubeuqm(__a, __b, __c);
 }
 
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_sube_u128(vector unsigned char __a, vector unsigned char __b,
+  vector unsigned char __c) {
+  return (vector unsigned char)__builtin_altivec_vsubeuqm(
+  (vector unsigned __int128)__a, (vector unsigned __int128)__b,
+  (vector unsigned __int128)__c);
+}
+
 /* vec_vsubcuq */
 
 static __inline__ vector signed __int128 __ATTRS_o_ai
@@ -11928,6 +11948,14 @@ vec_subec(vector unsigned __int128 __a, vector 
unsigned __int128 __b,
  vector unsigned __int128 __c) {
   return __builtin_altivec_vsubecuq(__a, __b, __c);
 }
+
+static __inline__ vector unsigned char __attribute__((__always_inline__))
+vec_subec_u128(vector unsigned char __a, vector unsigned char __b,
+   vector unsigned char __c) {
+  return (vector unsigned char)__builtin_altivec_vsubecuq(
+  (vector unsigned __int128)__a, (vector unsigned __int128)__b,
+  (vector unsigned __int128)__c);
+}
 #endif // defined(__POWER8_VECTOR__) && defined(__powerpc64__)
 
 static __inline__ vector signed int __ATTRS_o_ai

diff  --git a/clang/test/CodeGen/builtins-ppc-quadword.c 
b/clang/test/CodeGen/builtins-ppc-quadword.c
index 66cc9e8c7a88..561f0c28f225 100644
--- a/clang/test/CodeGen/builtins-ppc-quadword.c
+++ b/clang/test/CodeGen/builtins-ppc-quadword.c
@@ -14,6 +14,7 @@
 vector signed __int128 vlll = { -1 };
 // CHECK-PPC: error: __int128 is not supported on this target
 vector unsigned __int128 vulll = { 1 };
+vector unsigned char vuc;
 
 signed long long param_sll;
 // CHECK-PPC: error: __int128 is not supported on this target
@@ -25,6 +26,7 @@ unsigned __int128 param_ulll;
 vector signed __int128 res_vlll;
 // CHECK-PPC: error: __int128 is not supported on this target
 vector unsigned __int128 res_vulll;
+vector unsigned char res_vuc;
 
 
 // CHECK-LABEL: define{{.*}} void @test1
@@ -119,6 +121,10 @@ void test1() {
 // CHECK-LE: sub <1 x i128> 
 // CHECK-PPC: error: assigning to '__vector unsigned __int128' (vector of 1 
'unsigned __int128' value) from incompatible type 'int'
   
+  res_vuc = vec_sub_u128(vuc, vuc);
+// CHECK: sub <1 x i128>
+// CHECK-LE: sub <1 x i128>
+
   /* vec_vsubeuqm */
   res_vlll = vec_vsubeuqm(vlll, vlll, vlll);
 // CHECK: @llvm.ppc.altivec.vsubeuqm
@@ -151,6 +157,10 @@ void test1() {
 // CHECK-LE: @llvm.ppc.altivec.vsubeuqm
 // CHECK-PPC: error: call to 'vec_sube' is ambiguous
 
+  res_vuc = vec_sube_u128(vuc, vuc, vuc);
+// CHECK: @llvm.ppc.altivec.vsubeuqm
+// CHECK-LE: @llvm.ppc.altivec.vsubeuqm
+
   /* vec_subc */
   res_vlll = vec_subc(vlll, vlll);
 // CHECK: @llvm.ppc.altivec.vsubcuq
@@ -162,6 +172,10 @@ void test1() {
 // CHECK-LE: @llvm.ppc.altivec.vsubcuq
 // KCHECK-PPC: error: call to 'vec_subc' is ambiguous
 
+  res_vuc = vec_subc_u128(vuc, vuc);
+// CHECK: @llvm.ppc.altivec.vsubcuq
+// CHECK-LE: @llvm.ppc.altivec.vsu

[PATCH] D99121: [IR][InstCombine] IntToPtr Produces Typeless Pointer To Byte

2021-03-23 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes added a comment.

The pointee type in LLVM doesn't really matter. It's even supposed to disappear 
one day after the migration is completed.
E.g., i8* and i64* are exactly the same thing: they are pointers to data.
So, I don't understand the motivation for this patch. It doesn't solve the root 
cause of the problem (which one btw?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99121

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


[PATCH] D93377: [Clang] Add __ibm128 type to represent ppc_fp128

2021-03-23 Thread Jonathan Wakely via Phabricator via cfe-commits
jwakely added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:2668
   // ::= g  # __float128
+  // ::= g  # __ibm128
   // UNSUPPORTED:::= Dd # IEEE 754r decimal floating point (64 bits)

steven.zhang wrote:
> This is a bit confusing as the 'g' is for both __float128 and __ibm128. I 
> know that PowerPC will mangle the __float128 as "u9__ieee128", and "g" for 
> __ibm128. But c++filt demangle the "g" as __float128 which seems not right. 
The (de)mangling is very confusing, but that's consistent with gcc.
See comment 3 and 4 at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98389#c3

I think double-double should never have used `g` it should have been something 
else (e.g. `u8__ibm128`), and then we could have `g` for the `__ieee128` (aka 
`__float128`) type. But it is many years too late to change that now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93377

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


[PATCH] D99165: [clang] Fix a crash on checkDestructorReference.

2021-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: erik.pilkington.
sammccall added a comment.

The fix doesn't look obviously correct: the side effect of marking the 
destructor reference seems important if we actually generate code. It's not 
obvious to me why the type can only be incomplete if there are errors.

This was introduced between clang 8 and clang 9, I would guess by 
f8ccf052935adaf405e581fd31e8bc634cc5bbc7.
@erik.pilkington 
Looking at that patch, mostly this function was just a rename, but there's a 
new callsite for array-types that seems to be what we're hitting here.
Maybe a slightly less-invasive version would be to guard that callsite with 
"and if the element type is complete"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99165

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


[clang] a234d03 - [NFC] Formatting changes

2021-03-23 Thread Abhina Sreeskantharajan via cfe-commits

Author: Abhina Sreeskantharajan
Date: 2021-03-23T07:17:54-04:00
New Revision: a234d0319891ae25cdf020dc32bce1c37c0e9867

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

LOG: [NFC] Formatting changes

This patch addresses some formatting changes from the comments in 
https://reviews.llvm.org/D97785.

Reviewed By: anirudhp

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

Added: 


Modified: 
clang/tools/arcmt-test/arcmt-test.cpp
llvm/lib/IRReader/IRReader.cpp
llvm/lib/TableGen/Main.cpp
llvm/utils/FileCheck/FileCheck.cpp

Removed: 




diff  --git a/clang/tools/arcmt-test/arcmt-test.cpp 
b/clang/tools/arcmt-test/arcmt-test.cpp
index e4764ad1f457..778587d4f111 100644
--- a/clang/tools/arcmt-test/arcmt-test.cpp
+++ b/clang/tools/arcmt-test/arcmt-test.cpp
@@ -208,14 +208,14 @@ static bool filesCompareEqual(StringRef fname1, StringRef 
fname2) {
   using namespace llvm;
 
   ErrorOr> file1 = MemoryBuffer::getFile(
-  fname1, /*FileSize*/ -1, /*RequiresNullTerminator*/ true,
-  /*IsVolatile*/ false, /*IsText*/ true);
+  fname1, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+  /*IsVolatile=*/false, /*IsText=*/true);
   if (!file1)
 return false;
 
   ErrorOr> file2 = MemoryBuffer::getFile(
-  fname2, /*FileSize*/ -1, /*RequiresNullTerminator*/ true,
-  /*IsVolatile*/ false, /*IsText*/ true);
+  fname2, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+  /*IsVolatile=*/false, /*IsText=*/true);
   if (!file2)
 return false;
 
@@ -244,9 +244,9 @@ static bool verifyTransformedFiles(ArrayRef 
resultFiles) {
   if (RemappingsFile.empty())
 inputBuf = MemoryBuffer::getSTDIN();
   else
-inputBuf = MemoryBuffer::getFile(RemappingsFile, /*FileSize*/ -1,
- /*RequiresNullTerminator*/ true,
- /*IsVolatile*/ false, /*IsText*/ true);
+inputBuf = MemoryBuffer::getFile(RemappingsFile, /*FileSize=*/-1,
+ /*RequiresNullTerminator=*/true,
+ /*IsVolatile=*/false, /*IsText=*/true);
   if (!inputBuf) {
 errs() << "error: could not read remappings input\n";
 return true;

diff  --git a/llvm/lib/IRReader/IRReader.cpp b/llvm/lib/IRReader/IRReader.cpp
index 69757a5f136b..cc3b20681034 100644
--- a/llvm/lib/IRReader/IRReader.cpp
+++ b/llvm/lib/IRReader/IRReader.cpp
@@ -92,9 +92,9 @@ std::unique_ptr
 llvm::parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
   DataLayoutCallbackTy DataLayoutCallback) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(Filename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(Filename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError()) {
 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + EC.message());

diff  --git a/llvm/lib/TableGen/Main.cpp b/llvm/lib/TableGen/Main.cpp
index 75f4d423d4d2..289af936cf65 100644
--- a/llvm/lib/TableGen/Main.cpp
+++ b/llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,9 @@ int llvm::TableGenMain(const char *argv0, TableGenMainFn 
*MainFn) {
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,8 +139,9 @@ int llvm::TableGenMain(const char *argv0, TableGenMainFn 
*MainFn) {
 // Only updates the real output file if there are any 
diff erences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
+if (auto ExistingOrErr = MemoryBuffer::getFile(
+OutputFilename, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+/*IsVolatile=*/false, /*IsText=*/true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }

diff  --git a/llvm/utils/FileCheck/FileCheck.cpp 
b/llvm/utils/FileCheck/FileCheck.cpp
index 0ee105d0bf46..12365e03db55 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llv

[PATCH] D99072: [NFC] Formatting changes

2021-03-23 Thread Abhina Sree 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 rGa234d0319891: [NFC] Formatting changes (authored by 
abhina.sreeskantharajan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99072

Files:
  clang/tools/arcmt-test/arcmt-test.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,9 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +845,9 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/lib/TableGen/Main.cpp
===
--- llvm/lib/TableGen/Main.cpp
+++ llvm/lib/TableGen/Main.cpp
@@ -93,7 +93,9 @@
 
   Records.startTimer("Parse, build records");
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, -1, true, true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(argv0, "Could not open input file '" + InputFilename +
   "': " + EC.message() + "\n");
@@ -137,8 +139,9 @@
 // Only updates the real output file if there are any differences.
 // This prevents recompilation of all the files depending on it if there
 // aren't any.
-if (auto ExistingOrErr =
-MemoryBuffer::getFile(OutputFilename, -1, true, false, true))
+if (auto ExistingOrErr = MemoryBuffer::getFile(
+OutputFilename, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+/*IsVolatile=*/false, /*IsText=*/true))
   if (std::move(ExistingOrErr.get())->getBuffer() == Out.str())
 WriteFile = false;
   }
Index: llvm/lib/IRReader/IRReader.cpp
===
--- llvm/lib/IRReader/IRReader.cpp
+++ llvm/lib/IRReader/IRReader.cpp
@@ -92,9 +92,9 @@
 llvm::parseIRFile(StringRef Filename, SMDiagnostic &Err, LLVMContext &Context,
   DataLayoutCallbackTy DataLayoutCallback) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(Filename, /*FileSize*/ -1,
-   /*RequiresNullTerminator*/ true,
-   /*IsText*/ true);
+  MemoryBuffer::getFileOrSTDIN(Filename, /*FileSize=*/-1,
+   /*RequiresNullTerminator=*/true,
+   /*IsText=*/true);
   if (std::error_code EC = FileOrErr.getError()) {
 Err = SMDiagnostic(Filename, SourceMgr::DK_Error,
"Could not open input file: " + EC.message());
Index: clang/tools/arcmt-test/arcmt-test.cpp
===
--- clang/tools/arcmt-test/arcmt-test.cpp
+++ clang/tools/arcmt-test/arcmt-test.cpp
@@ -208,14 +208,14 @@
   using namespace llvm;
 
   ErrorOr> file1 = MemoryBuffer::getFile(
-  fname1, /*FileSize*/ -1, /*RequiresNullTerminator*/ true,
-  /*IsVolatile*/ false, /*IsText*/ true);
+  fname1, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+  /*IsVolatile=*/false, /*IsText=*/true);
   if (!file1)
 return false;
 
   ErrorOr> file2 = MemoryBuffer::getFile(
-  fname2, /*FileSize*/ -1, /*RequiresNullTerminator*/ true,
-  /*IsVolatile*/ false, /*IsText*/ true);
+  fname2, /*FileSize=*/-1, /*RequiresNullTerminator=*/true,
+  /*IsVolatile=*/false, /*Is

[PATCH] D98499: [clangd] Introduce ASTHooks to FeatureModules

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added a comment.

In D98499#2626502 , @sammccall wrote:

> My model for modules using this diagnostic stuff (apart from the build-system 
> stuff which sadly can't be meaningfully upstreamed) are IncludeFixer, 
> ClangTidy, and IWYU - worth thinking about how we'd build those on top of 
> this model. (Doesn't mean we need to add a hook to emit diagnostics, but it 
> probably means we should know where it would go)

Agreed. I believe they all would need extra end points to ASTHooks though.

`ClangTidy`:

- needs extra hooks to register PP callbacks, and take in a diagnostics engine
- needs a new endpoint to traverse ast and *emit* diags
- CTContext needs to be alive until the parsing is done: so we can:
  - make ASTHooks own it and instantiate a new one on every parse (i think the 
cleanest and most explicit)
  - make the module own them and control the lifetime with entry/exit calls on 
the asthooks. (there's more burden on the modules now, and they'll need extra 
synchronisation on enter/exit calls)
  - return some other object on parsing entry hook that'll be kept alive by the 
caller (needs design around semantics of that object).

`IncludeFixer`:

- needs a new hook to act as an external sema source, so that it can fix 
unresolved names.
- similar to CTContext issue, it references per-tu state like HeaderSearchInfo, 
so will need to incorporate these into entry hook, and somehow disambiguate 
hooks for different TUs (all the options proposed for tidy).

`IWYU`:

- I'd expect this to make use of ~same API as `IncludeFixer`.

`PreamblePatching`:

- can mutate compiler instance via a hook
- drop diagnostics from ParsedAST on exit (requires some mutation on parsedast 
though)




Comment at: clang-tools-extra/clangd/FeatureModule.h:112
+  };
+  /// Can be called asynchronously before building an AST.
+  virtual std::unique_ptr astHooks() { return nullptr; }

sammccall wrote:
> This comment hints at what I *thought* was the idea: astHooks() is called 
> each time we parse a file, the returned object has methods called on it while 
> the file is being parsed, and is then destroyed.
> 
> But the code suggests we call once globally and it has effectively the same 
> lifetime as the module.
> This seems much less useful, e.g. if we want to observe several diagnostics, 
> examine the preamble, and emit new diagnostics, then we have to plumb around 
> some notion of "AST identity" rather than just tying it to the identity of 
> the ParseASTHooks object itself.
> 
> (Lots of natural extensions here like providing ParseInputs to astHooks(), 
> but YAGNI for now)
> This comment hints at what I *thought* was the idea: astHooks() is called 
> each time we parse a file, the returned object has methods called on it while 
> the file is being parsed, and is then destroyed.

This was the intent actually (to enable modularization of other features like 
clangtidy, includefixer, etc. as mentioned above), but looks like i got 
confused while integrating this into clangdserver :/

While trying to resolve my confusion i actually noticed that we cannot uphold 
the contract of "hooks being called synchronously", because we actually have 
both a preamblethread and astworker that can invoke hooks (embarrassing of me 
to forget that 😓).

So we can:
- Give up on that promise and make life slightly complicated for module 
implementers
- Don't invoke hooks from preamblethread, (at the cost of limiting 
functionality, we can still have downstream users that act on PPCallbacks, but 
no direct integration with compiler, and that's where layering violations are 
generated :/)
- Handle the synchronization ourselves, only complicates TUScheduler more, 
rather than all the module implementers.
- Propogate FeatureModuleSet into TUScheduler and create 2 set of hooks on each 
thread :)

I am leaning towards 4, but unsure (mostly hesitant about dependency schema, as 
featuremodules also depend on TUScheduler..). WDYT?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98499

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


[PATCH] D98499: [clangd] Introduce ASTHooks to FeatureModules

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 332613.
kadircet added a comment.

- Rename ParsedASTHooks to Listeners.
- Generate list of hooks on each parse.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98499

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/FeatureModule.h
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/tool/Check.cpp
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h

Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -25,6 +25,7 @@
 #include "support/Path.h"
 #include "llvm/ADT/StringMap.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 #include 
@@ -76,6 +77,8 @@
   // to eliminate this option some day.
   bool OverlayRealFileSystemForModules = false;
 
+  std::vector> Hooks;
+
   // By default, build() will report Error diagnostics as GTest errors.
   // Suppress this behavior by adding an 'error-ok' comment to the code.
   // The result will always have getDiagnostics() populated.
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -36,6 +36,7 @@
   FS.Files[ImportThunk] = ThunkContents;
 
   ParseInputs Inputs;
+  Inputs.ASTHooks = Hooks;
   auto &Argv = Inputs.CompileCommand.CommandLine;
   Argv = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
@@ -97,6 +98,7 @@
   MockFS FS;
   auto Inputs = inputs(FS);
   StoreDiags Diags;
+  Diags.setASTHooks(Inputs.ASTHooks);
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   if (OverlayRealFileSystemForModules)
Index: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
===
--- clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
+++ clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
@@ -1346,6 +1346,24 @@
  });
 }
 
+TEST(ParsedASTTest, ModuleSawDiag) {
+  static constexpr const llvm::StringLiteral KDiagMsg = "StampedDiag";
+  struct Hooks : public FeatureModule::ASTListener {
+void sawDiagnostic(const clang::Diagnostic &Info,
+   clangd::Diag &Diag) override {
+  Diag.Message = KDiagMsg.str();
+}
+  };
+
+  Annotations Code("[[test]]; /* error-ok */");
+  TestTU TU;
+  TU.Code = Code.code().str();
+  TU.Hooks.emplace_back(new Hooks);
+
+  auto AST = TU.build();
+  EXPECT_THAT(*AST.getDiagnostics(),
+  testing::Contains(Diag(Code.range(), KDiagMsg.str(;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -365,6 +365,27 @@
   // And immediately shut down. FeatureModule destructor verifies we blocked.
 }
 
+TEST_F(LSPTest, DiagModuleTest) {
+  static constexpr llvm::StringLiteral DiagMsg = "DiagMsg";
+  class DiagModule final : public FeatureModule {
+struct DiagHooks : public ASTListener {
+  void sawDiagnostic(const clang::Diagnostic &, clangd::Diag &D) override {
+D.Message = DiagMsg.str();
+  }
+};
+
+  public:
+std::unique_ptr astHooks() override {
+  return std::make_unique();
+}
+  };
+  FeatureModules.add(std::make_unique());
+
+  auto &Client = start();
+  Client.didOpen("foo.cpp", "test;");
+  EXPECT_THAT(Client.diagnostics("foo.cpp"),
+  llvm::ValueIs(testing::ElementsAre(DiagMessage(DiagMsg;
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/tool/Check.cpp
===
--- clang-tools-extra/clangd/tool/Check.cpp
+++ clang-tools-extra/clangd/tool/Check.cpp
@@ -46,6 +46,7 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/Path.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -119,13 +120,17 @@
   }
 
   // Prepare inputs and build CompilerInvocation (parsed compile command).
-  bool buildInvocation(const ThreadsafeFS &TFS,
-   llvm::Option

[PATCH] D97555: [clangd] Add diagnostic augmentation hook to Modules

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet abandoned this revision.
kadircet added a comment.

> Is this entirely obsoleted by the approach in D98499 
> ?

yes it is!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97555

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


[PATCH] D98538: [clangd] Perform merging for stale symbols in MergeIndex

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.
Herald added a project: clang-tools-extra.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98538

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


[PATCH] D96245: [clangd] Propagate CodeActions in addition to Fixes for diagnostics

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet abandoned this revision.
kadircet added a comment.
Herald added a project: clang-tools-extra.

abandoning in favor of D98498 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96245

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


[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D99152#2644171 , @LuoYuanke wrote:

> In D99152#2644017 , @lebedev.ri 
> wrote:
>
>> load  instruction loads 
>> contigious bytes.
>> If that is not what is AMX is trying to use it for, then it is being used 
>> incorrectly.
>
> Isn't it a reason that we can't cast "load <256 x i32>*" to "load x86_amx*"? 
> The load memory for <256 x i32> is contiguous, and load memory for x86_amx is 
> not contiguous.

To be honest i don't really understand why `x86_amx` type is even there.
It seems to me that if you just directly used `@llvm.x86.tileloadd64.internal` 
/ `@llvm.x86.tilestored64.internal`,
and `s/x86_amx/<256 x i32>/`, none of these problems would be here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D99145: [clang] Fix a crash when CTAD fails

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 332619.
kadircet added a comment.

- Move test into existing file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99145

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -543,6 +543,18 @@
   int m = n;
 }
 
+// Ensure we don't crash when CTAD fails.
+template 
+struct Foo {   // expected-note{{candidate function template not viable}}
+  Foo(T1, T2); // expected-note{{candidate function template not viable}}
+};
+
+template 
+void insert(Args &&...args);
+
+void foo() {
+  insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction 
guide}}
+}
 #else
 
 // expected-no-diagnostics
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4492,7 +4492,8 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -543,6 +543,18 @@
   int m = n;
 }
 
+// Ensure we don't crash when CTAD fails.
+template 
+struct Foo {   // expected-note{{candidate function template not viable}}
+  Foo(T1, T2); // expected-note{{candidate function template not viable}}
+};
+
+template 
+void insert(Args &&...args);
+
+void foo() {
+  insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction guide}}
+}
 #else
 
 // expected-no-diagnostics
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4492,7 +4492,8 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99121: [IR][InstCombine] IntToPtr Produces Typeless Pointer To Byte

2021-03-23 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added subscribers: t.p.northover, dblaikie.
lebedev.ri added a comment.

In D99121#2644223 , @nlopes wrote:

> The pointee type in LLVM doesn't really matter. It's even supposed to 
> disappear one day after the migration is completed.
> E.g., i8* and i64* are exactly the same thing: they are pointers to data.

Yep. That will be indeed a great to see.

> So, I don't understand the motivation for this patch. It doesn't solve the 
> root cause of the problem (which one btw?).

It is indeed temporary until Opaque pointers are here.
The problem has been stated last time in D99051 
 by @ruiling:
https://godbolt.org/z/x7E1EjWvv, i.e. given the same integer,
there can be any number of pointers `inttoptr`'d from it,
and passes won't be able to tell that they are identical.

@dblaikie @t.p.northover can anyone comment on the Opaque Pointers progress? Is 
there a checklist somewhere?




Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:278-280
+  if (firstOp == Instruction::IntToPtr && secondOp == Instruction::BitCast)
+Res = 0;
+

ruiling wrote:
> If we want to disable int2ptr + bitcast unconditionally, then why not 
> directly make it in CastInst::isEliminableCastPair()?
Because technically that is still legal, much like changing integer types of 
the `inttoptr`/`ptrtoint`,
which also aren't prohibited in `isEliminableCastPair()`.



Comment at: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp:1949-1953
+  if (CI.getType() != BytePtrTy) {
+Value *P = Builder.CreateIntToPtr(CI.getOperand(0), BytePtrTy);
+return new BitCastInst(P, CI.getType());
+  }
+

ruiling wrote:
> The idea here sounds good to me, but seems causing some new problems for the 
> regression tests. I am not sure the whether the regressions are easy to fix?
FWIW all the problems are temporary until LLVM IR is migrated to typeless 
pointer types.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99121

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


[PATCH] D99086: [clang][Syntax] Optimize expandedTokens for token ranges.

2021-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Thanks for finding and working on this hotspot. (I'm curious *why* 
`isBeforeInTranslationUnit` is slow if you have any insight - it has sad 
worst-case but I thought we'd hit the one-element cache often enough in 
practice).

I don't see a better way to optimize this, main question is where to do it.
In favor of TokenBuffer initializer (this patch):

- it produces the simplest API
- no code duplicated between callers
- when a TokenBuffer gets reused and it's awkward for its users to share other 
state, the same cache can be reused

In favor of in the caller (e.g. SelectionTree)

- users that never call expandedTokens(SourceRange) pay nothing
- users that call expandedTokens(SourceRange) once pay `log(N) * 
isBeforeInTranslationUnit` instead of `N`, which may come out ahead for large 
files.

It's a bit unfortunate that TokenBuffer is enough of a grab-bag of features 
that we can't really reason about which structures to build :-(

Can we get the best of both worlds?
Ideally we'd build this cache only when it's profitable. But building on-demand 
messes with const (and it's unclear whether to do it on the first call).
What about making this optional via a non-const 
`TokenBuffer::indexExpandedTokens(); // Optimizes future calls to 
expandedTokens(SourceRange). Idempotent.`?
It's a slightly weird API, but not actually hard to use (I imagine clangd would 
always call it when building ParsedAST).




Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:372
+  // useful while finding expanded tokens in a 'token range'.
+  llvm::DenseMap ExpandedTokIndex;
   llvm::DenseMap Files;

kadircet wrote:
> usaxena95 wrote:
> > kadircet wrote:
> > > this definitely makes sense, but most of the users of `TokenBuffers` are 
> > > currently invoking `expandedTokens(Range)` only once, so i am not sure if 
> > > this is a huge benefit on their-side, whereas they'll likely end up 
> > > seeing some short-lived memory consumption (and an extra traversal of all 
> > > the expanded tokens).
> > > 
> > > Any reasons for not moving this logic to the application? 
> > > `expandedTokens()` endpoint will return all the tokens, no questions 
> > > asked. Then the application can build whatever acceleration structure it 
> > > wants. If you think there are in-tree use cases that can benefit from 
> > > this caching, maybe even provide that as a separate helper?
> > > this definitely makes sense, but most of the users of TokenBuffers are 
> > > currently invoking expandedTokens(Range) only once
> > I didn't get that users are invoking it only once. This is not caching the 
> > results of `expandedTokens(Range)`. We are precomputing these to completely 
> > avoid a binary search which uses `isBeforeInTranslationUnit` (considerably 
> > slower). Doing an extra traversal of expandedTokens is not noticeable as 
> > compared to `isBeforeInTranslationUnit` latency. Users like SelectionTree 
> > (GoToDefinition, Hover,..) can directly benefit from this even though they 
> > query this only once per some range.
> > 
> > Umm. If you meant use cases like: build token buffer -> use 
> > expandedTokens(Range) -> destroy TokenBuffer.
> > I don't immediately see such use cases. But I think it is still better than 
> > using isBeforeInTranslationUnit.
> > My mental model is that TokenBuffer is a long lived object (example in 
> > ParsedAST in clangd). And using it only once and then discarding it is 
> > expensive in itself.
> > 
> > > Any reasons for not moving this logic to the application?
> > > If you think there are in-tree use cases that can benefit from this 
> > > caching, maybe even provide that as a separate helper?
> > This can basically benefit all users of `expandedToken(Range)`. Since 
> > expandedToken(Range) is provided by TokenBuffer, the optimization must also 
> > remain in the TokenBuffer as compared to the application.
> > Although users which only use this for non-token ranges will pay additional 
> > cost. We can potentially make this precomputation optional for such cases.
> > 
> > 
> > 
> > I didn't get that users are invoking it only once.
> 
> Sorry that was confusing, I was trying to say that on use cases like 
> Hover/Go-To etc. clangd builds selection tree only once and you are right, 
> that might actually involve multiple calls to `expandedTokens(Range)` but 
> that shouldn't be the bottleneck of these features.
> 
> 
> > This is not caching the results of `expandedTokens(Range)`. We are 
> > precomputing these to completely avoid a binary search
> 
> right, i was saying that all that precomputation is also probably unneeded, 
> as normally features are only interested in a single token, which should nest 
> properly in AST under normal circumstances and doesn't require calling 
> expandedTokens for all possible ranges.
> 
> > Doing an extra traversal of expandedTokens is not noticeable as compared to 
> > `isBeforeInTranslationUnit` latency. Users like Sele

[PATCH] D99152: [AMX] Prototype for vector and amx bitcast.

2021-03-23 Thread LuoYuanke via Phabricator via cfe-commits
LuoYuanke added a comment.

> To be honest i don't really understand why `x86_amx` type is even there.
> It seems to me that if you just directly used 
> `@llvm.x86.tileloadd64.internal` / `@llvm.x86.tilestored64.internal`,
> and `s/x86_amx/<256 x i32>/`, none of these problems would be here.

I explained in llvm-dev. I copy the content below.

Bitcasts is introduced by the frontend call amx intrinsics. We use vector to 
represent 2D amx tile in C language, on the other hand we don’t want to mix our 
amx tile to other vector operation, so x86_amx is introduced to isolate amx 
intrinsics from normal vector operation. The bitcast is to monitor that a 
normal vector is passed to amx intrinsics. In below example, we need to 
transform the bitcast to a vector store and an amx load intrinsic. The x86_amx* 
is unexpected at the beginning, but in the pass of InstrCombine the middle-end 
generate the x86_amx pointer.

define dso_local void @test_src_add(<256 x i32> %x, <256 x i32> %y, i16 %r, i16 
%c, i8* %buf, i64 %s) {
; CHECK-LABEL: @test_src_add(
; CHECK-NEXT:  entry:
; CHECK-NEXT:[[TMP0:%.*]] = alloca <256 x i32>, align 64
; CHECK-NEXT:[[ADD:%.*]] = add <256 x i32> [[Y:%.*]], [[X:%.*]]
; CHECK-NEXT:[[TMP1:%.*]] = bitcast <256 x i32>* [[TMP0]] to i8*
; CHECK-NEXT:store <256 x i32> [[ADD]], <256 x i32>* [[TMP0]], align 1024
; CHECK-NEXT:[[TMP2:%.*]] = call x86_amx @llvm.x86.tileloadd64.internal(i16 
[[R:%.*]], i16 [[C:%.*]], i8* [[TMP1]], i64 64)
; CHECK-NEXT:call void @llvm.x86.tilestored64.internal(i16 [[R]], i16 
[[C]], i8* [[BUF:%.*]], i64 [[S:%.*]], x86_amx [[TMP2]])
; CHECK-NEXT:ret void
;
entry:

  %add = add <256 x i32> %y, %x
  %t = bitcast <256 x i32> %add to x86_amx
  call void @llvm.x86.tilestored64.internal(i16 %r, i16 %c, i8* %buf, i64 %s, 
x86_amx %t)
  ret void

}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99152

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


[PATCH] D97462: [clang][cli] Round-trip cc1 arguments in assert builds

2021-03-23 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

How expensive are these checks? If it is non-trivial overhead, maybe it should 
default to `${LLVM_ENABLE_EXPENSIVE_CHECKS}` instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97462

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


[clang] 8f80c66 - [clang] Fix a crash when CTAD fails

2021-03-23 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2021-03-23T13:03:30+01:00
New Revision: 8f80c66bd2982788a8eede4419684ca72f48b9a2

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

LOG: [clang] Fix a crash when CTAD fails

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

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp
clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 46315d3ccaaf7..0570f61458a26 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4492,7 +4492,8 @@ void Sema::CheckArgAlignment(SourceLocation Loc, 
NamedDecl *FDecl,
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);

diff  --git a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
index 161944f9e64f6..62b1c166e954c 100644
--- a/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ b/clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -543,6 +543,18 @@ namespace PR47175 {
   int m = n;
 }
 
+// Ensure we don't crash when CTAD fails.
+template 
+struct Foo {   // expected-note{{candidate function template not viable}}
+  Foo(T1, T2); // expected-note{{candidate function template not viable}}
+};
+
+template 
+void insert(Args &&...args);
+
+void foo() {
+  insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction 
guide}}
+}
 #else
 
 // expected-no-diagnostics



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


[PATCH] D99145: [clang] Fix a crash when CTAD fails

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8f80c66bd298: [clang] Fix a crash when CTAD fails (authored 
by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99145

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -543,6 +543,18 @@
   int m = n;
 }
 
+// Ensure we don't crash when CTAD fails.
+template 
+struct Foo {   // expected-note{{candidate function template not viable}}
+  Foo(T1, T2); // expected-note{{candidate function template not viable}}
+};
+
+template 
+void insert(Args &&...args);
+
+void foo() {
+  insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction 
guide}}
+}
 #else
 
 // expected-no-diagnostics
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4492,7 +4492,8 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
===
--- clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
+++ clang/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
@@ -543,6 +543,18 @@
   int m = n;
 }
 
+// Ensure we don't crash when CTAD fails.
+template 
+struct Foo {   // expected-note{{candidate function template not viable}}
+  Foo(T1, T2); // expected-note{{candidate function template not viable}}
+};
+
+template 
+void insert(Args &&...args);
+
+void foo() {
+  insert(Foo(2, 2, 2)); // expected-error{{no viable constructor or deduction guide}}
+}
 #else
 
 // expected-no-diagnostics
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4492,7 +4492,8 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType())
+  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
+  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99086: [clang][Syntax] Optimize expandedTokens for token ranges.

2021-03-23 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Tokens.h:372
+  // useful while finding expanded tokens in a 'token range'.
+  llvm::DenseMap ExpandedTokIndex;
   llvm::DenseMap Files;

sammccall wrote:
> kadircet wrote:
> > usaxena95 wrote:
> > > kadircet wrote:
> > > > this definitely makes sense, but most of the users of `TokenBuffers` 
> > > > are currently invoking `expandedTokens(Range)` only once, so i am not 
> > > > sure if this is a huge benefit on their-side, whereas they'll likely 
> > > > end up seeing some short-lived memory consumption (and an extra 
> > > > traversal of all the expanded tokens).
> > > > 
> > > > Any reasons for not moving this logic to the application? 
> > > > `expandedTokens()` endpoint will return all the tokens, no questions 
> > > > asked. Then the application can build whatever acceleration structure 
> > > > it wants. If you think there are in-tree use cases that can benefit 
> > > > from this caching, maybe even provide that as a separate helper?
> > > > this definitely makes sense, but most of the users of TokenBuffers are 
> > > > currently invoking expandedTokens(Range) only once
> > > I didn't get that users are invoking it only once. This is not caching 
> > > the results of `expandedTokens(Range)`. We are precomputing these to 
> > > completely avoid a binary search which uses `isBeforeInTranslationUnit` 
> > > (considerably slower). Doing an extra traversal of expandedTokens is not 
> > > noticeable as compared to `isBeforeInTranslationUnit` latency. Users like 
> > > SelectionTree (GoToDefinition, Hover,..) can directly benefit from this 
> > > even though they query this only once per some range.
> > > 
> > > Umm. If you meant use cases like: build token buffer -> use 
> > > expandedTokens(Range) -> destroy TokenBuffer.
> > > I don't immediately see such use cases. But I think it is still better 
> > > than using isBeforeInTranslationUnit.
> > > My mental model is that TokenBuffer is a long lived object (example in 
> > > ParsedAST in clangd). And using it only once and then discarding it is 
> > > expensive in itself.
> > > 
> > > > Any reasons for not moving this logic to the application?
> > > > If you think there are in-tree use cases that can benefit from this 
> > > > caching, maybe even provide that as a separate helper?
> > > This can basically benefit all users of `expandedToken(Range)`. Since 
> > > expandedToken(Range) is provided by TokenBuffer, the optimization must 
> > > also remain in the TokenBuffer as compared to the application.
> > > Although users which only use this for non-token ranges will pay 
> > > additional cost. We can potentially make this precomputation optional for 
> > > such cases.
> > > 
> > > 
> > > 
> > > I didn't get that users are invoking it only once.
> > 
> > Sorry that was confusing, I was trying to say that on use cases like 
> > Hover/Go-To etc. clangd builds selection tree only once and you are right, 
> > that might actually involve multiple calls to `expandedTokens(Range)` but 
> > that shouldn't be the bottleneck of these features.
> > 
> > 
> > > This is not caching the results of `expandedTokens(Range)`. We are 
> > > precomputing these to completely avoid a binary search
> > 
> > right, i was saying that all that precomputation is also probably unneeded, 
> > as normally features are only interested in a single token, which should 
> > nest properly in AST under normal circumstances and doesn't require calling 
> > expandedTokens for all possible ranges.
> > 
> > > Doing an extra traversal of expandedTokens is not noticeable as compared 
> > > to `isBeforeInTranslationUnit` latency. Users like SelectionTree 
> > > (GoToDefinition, Hover,..) can directly benefit from this even though 
> > > they query this only once per some range.
> > 
> > I was suggesting to move this into application because that felt 
> > counter-intuitive, as the benchmark you provided is actually running 
> > Hover(and other feautres) on every (spelled) token of the file. If you say 
> > that it is beneficial even for the normal hover case, sure let's go (but 
> > i'd be happier if you proved me wrong first 😅 )
> > 
> > > Umm. If you meant use cases like: build token buffer -> use 
> > > expandedTokens(Range) -> destroy TokenBuffer.
> > > I don't immediately see such use cases. But I think it is still better 
> > > than using isBeforeInTranslationUnit.
> > > My mental model is that TokenBuffer is a long lived object (example in 
> > > ParsedAST in clangd). And using it only once and then discarding it is 
> > > expensive in itself.
> > 
> > That's what clangd does though (not sure if Tokenbuffers have any other 
> > users ATM). It literally builds a new ParsedAST after every edit(It also 
> > has a cache to skip some work if contents didn't change between requests). 
> > But usually all of those requests are user-initiated, so an extra latency 
> > of a couple ms on ev

[PATCH] D97362: [clang][parser] Allow attributes in explicit template instantiations

2021-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:1618
+
+if (Tok && (*Tok).is(tok::l_square)) {
+  Diag(Attrs.Range.getBegin(), diag::err_attributes_not_allowed) << 
Attrs.Range;

tbaeder wrote:
> aaron.ballman wrote:
> > This will incorrectly classify an empty MS attribute `[]` as being a 
> > prohibited `[[]]` attribute. I think we need something like:
> > ```
> > if (Tok && Tok->is(tok::l_square)) {  
> >  SourceLocation NextTokLoc = 
> > Lexer::findLocationAfterToken(Attrs.Range.getBegin(), Tok.getKind(), SM, 
> > getLangOpts(), true);
> >  auto NextTok = Lexer::findNextToken(NextTokLoc, SM, getLangOpts());
> >  if (NextTok && NextTok->is(tok::l_square)) {
> >...
> >  }
> > }
> > ```
> > Also, I think it should use `DiagID` rather than hard-coding the diagnostic 
> > to use.
> The `findNextToken()` here returns the second `[` in `[[]]`, so would return 
> the `]` for `[]`. The code you proposed doesn't work because the second 
> `findNextToken()` returns the first `]`, so not a `tok::l_square`. I know 
> your code makes more sense since we're looking for `[[`, but I couldn't find 
> a way to get the first `[` from the Lexer.
Hrm, that surprises me -- we have the correct range when printing diagnostics, 
such as https://godbolt.org/z/r8rTKhY7f.

What happens if you use `Lexer::getRawToken()` on `Attrs.Range.getBegin()`? 
Does that find the first `[` or the second one?


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

https://reviews.llvm.org/D97362

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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM!


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

https://reviews.llvm.org/D97371

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


[PATCH] D98505: [clangd] Propagate data in diagnostics

2021-03-23 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 332636.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Ignore capability
- Store data as a json::Object rather than an Array.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98505

Files:
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Diagnostics.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/refactor/Tweak.h

Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -26,6 +26,7 @@
 #include "index/Index.h"
 #include "support/Path.h"
 #include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
@@ -66,6 +67,8 @@
 unsigned SelectionEnd;
 /// The AST nodes that were selected.
 SelectionTree ASTSelection;
+/// Diagnostics related to this selection.
+llvm::ArrayRef Diags;
 // FIXME: provide a way to get sources and ASTs for other files.
   };
 
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -406,6 +406,12 @@
   /// textDocument.publishDiagnostics.relatedInformation.
   bool DiagnosticRelatedInformation = false;
 
+  /// Whether the client supports the `data` property which is preserved between
+  /// a `textDocument/publishDiagnostics` and * `textDocument/codeAction`
+  /// request.
+  /// textDocument.publishDiagnostics.dataSupport
+  bool DiagnosticDataSupport = false;
+
   /// Whether the client accepts diagnostics with category attached to it
   /// using the "category" extension.
   /// textDocument.publishDiagnostics.categorySupport
@@ -844,6 +850,13 @@
   /// Only with capability textDocument.publishDiagnostics.codeActionsInline.
   /// (These actions can also be obtained using textDocument/codeAction).
   llvm::Optional> codeActions;
+
+  /// A data entry field that is preserved between a
+  /// `textDocument/publishDiagnostics` notification
+  /// and`textDocument/codeAction` request.
+  /// Mutating users should associate their data with a unique key they can use
+  /// to retrieve later on.
+  llvm::json::Object data;
 };
 llvm::json::Value toJSON(const Diagnostic &);
 
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -331,6 +331,8 @@
 R.DiagnosticFixes = *CodeActions;
   if (auto RelatedInfo = Diagnostics->getBoolean("relatedInformation"))
 R.DiagnosticRelatedInformation = *RelatedInfo;
+  if (auto DataSupport = Diagnostics->getBoolean("dataSupport"))
+R.DiagnosticDataSupport = *DataSupport;
 }
 if (auto *Completion = TextDocument->getObject("completion")) {
   if (auto *Item = Completion->getObject("completionItem")) {
@@ -599,6 +601,8 @@
 Diag["source"] = D.source;
   if (D.relatedInformation)
 Diag["relatedInformation"] = *D.relatedInformation;
+  if (!D.data.empty())
+Diag["data"] = llvm::json::Object(D.data);
   // FIXME: workaround for older gcc/clang
   return std::move(Diag);
 }
@@ -606,7 +610,11 @@
 bool fromJSON(const llvm::json::Value &Params, Diagnostic &R,
   llvm::json::Path P) {
   llvm::json::ObjectMapper O(Params, P);
-  return O && O.map("range", R.range) && O.map("message", R.message) &&
+  if (!O)
+return false;
+  if (auto *Data = Params.getAsObject()->getObject("data"))
+R.data = std::move(*Data);
+  return O.map("range", R.range) && O.map("message", R.message) &&
  mapOptOrNull(Params, "severity", R.severity, P) &&
  mapOptOrNull(Params, "category", R.category, P) &&
  mapOptOrNull(Params, "code", R.code, P) &&
Index: clang-tools-extra/clangd/Diagnostics.h
===
--- clang-tools-extra/clangd/Diagnostics.h
+++ clang-tools-extra/clangd/Diagnostics.h
@@ -21,10 +21,12 @@
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/Support/JSON.h"
 #include "llvm/Support/SourceMgr.h"
 #include 
 #include 
 #include 
+#include 
 
 namespace clang {
 namespace tidy {
@@ -69,6 +71,10 @@
   // diags from the main file.
   bool InsideMainFile = false;
   unsigned ID; // e.g. member of clang::diag, or clang-tidy assigned ID.
+  // Feature modules can make use of this field to propagate data from a
+  // diagnostic to a CodeAction request. Each module should only append to the
+  // list.
+  std::vector OpaqueData;
 };
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, 

[PATCH] D99181: [analyzer] Fix crash on spaceship operator (PR47511)

2021-03-23 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, steakhal, xazax.hun, ASDenysPetrov, martong.
Herald added subscribers: Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, yaxunl.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

rdar://68954187


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99181

Files:
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/BasicValueFactory.cpp
  clang/test/Analysis/Inputs/std-compare.h
  clang/test/Analysis/PR47511.cpp

Index: clang/test/Analysis/PR47511.cpp
===
--- /dev/null
+++ clang/test/Analysis/PR47511.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_analyze_cc1 -std=c++20 -w -analyzer-checker=core -verify %s
+
+// expected-no-diagnostics
+
+#include "Inputs/std-compare.h"
+
+void test() {
+  // no crash
+  (void)(0 <=> 0);
+}
Index: clang/test/Analysis/Inputs/std-compare.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/std-compare.h
@@ -0,0 +1,307 @@
+#ifndef STD_COMPARE_H
+#define STD_COMPARE_H
+
+namespace std {
+inline namespace __1 {
+
+// exposition only
+enum class _EqResult : unsigned char {
+  __equal = 0,
+  __equiv = __equal,
+};
+
+enum class _OrdResult : signed char {
+  __less = -1,
+  __greater = 1
+};
+
+enum class _NCmpResult : signed char {
+  __unordered = -127
+};
+
+struct _CmpUnspecifiedType;
+using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
+
+class partial_ordering {
+  using _ValueT = signed char;
+  explicit constexpr partial_ordering(_EqResult __v) noexcept
+  : __value_(_ValueT(__v)) {}
+  explicit constexpr partial_ordering(_OrdResult __v) noexcept
+  : __value_(_ValueT(__v)) {}
+  explicit constexpr partial_ordering(_NCmpResult __v) noexcept
+  : __value_(_ValueT(__v)) {}
+
+  constexpr bool __is_ordered() const noexcept {
+return __value_ != _ValueT(_NCmpResult::__unordered);
+  }
+
+public:
+  // valid values
+  static const partial_ordering less;
+  static const partial_ordering equivalent;
+  static const partial_ordering greater;
+  static const partial_ordering unordered;
+
+  // comparisons
+  friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+
+  friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+
+  // test helper
+  constexpr bool test_eq(partial_ordering const &other) const noexcept {
+return __value_ == other.__value_;
+  }
+
+private:
+  _ValueT __value_;
+};
+
+inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
+inline constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
+inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
+inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
+constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ == 0;
+}
+constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ < 0;
+}
+constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ <= 0;
+}
+constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ > 0;
+}
+constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ >= 0;
+}
+constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
+  return __v.__is_ordered() && 0 == __v.__value_;
+}
+constexpr bool operator<(_CmpUnspec

[PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-23 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added subscribers: dexonsmith, thopre, rupprecht, steven_wu, hiraditya, 
arichardson, emaste.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
abhina.sreeskantharajan requested review of this revision.
Herald added projects: clang, LLDB, LLVM.
Herald added subscribers: llvm-commits, lldb-commits, cfe-commits.

In future patches I will be setting the OF_Flag parameter frequently so I will 
refactor the args to be in the following order:

  getFile(const Twine &Filename, bool IsText = false,
  bool RequiresNullTerminator = true, int64_t FileSize = -1,
  bool IsVolatile = false);
  
  getFileOrSTDIN(const Twine &Filename, bool IsText = false,
 bool RequiresNullTerminator = true, int64_t FileSize = -1);


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99182

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/InputFiles.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/unittests/TestingSupport/TestUtilities.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/BinaryFormat/Magic.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
  llvm/lib/FuzzMutate/FuzzerCLI.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Object/Binary.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/obj2yaml/obj2yaml.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,7 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +843,7 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/tools/sanstats/sanstats.cpp
===
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -125,8 +125,8 @@
   cl::ParseCommandLineOptions(argc, argv,
   "Sanitizer Statistics Processing Tool");
 
-  ErrorOr> MBOrErr =
-  MemoryBuffer::getFile(ClInputFile, -1, false);
+  ErrorOr> MBOrErr = MemoryBuffer::getFile(
+  ClInputFile, /*IsText=*/false, /*RequiresNullTerminator=*/false);
   if (!MBOrErr) {
 errs() << argv[0] << ": " << ClInputFile << ": "
<< MBOrErr.getError().message() << '\n';
Index: llvm/tools/obj2yaml/obj2yaml.cpp
===
--- llvm/tools/obj2yaml/obj2yaml.cpp
+++ llvm/tools/obj2yaml/obj2yaml.cpp
@@ -36,7 +36,7 @@
 
 static Error dumpInput(StringRef File) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return errorCodeToError(EC);
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -653,7 +653,7 @@
 /// Opens \a File and dumps it.
 static void dumpInput(StringRef File, ScopedPrinter &Writer) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())

[clang] 274907c - [ASTImporter] Split out Objective-C related unit tests

2021-03-23 Thread Raphael Isemann via cfe-commits

Author: Raphael Isemann
Date: 2021-03-23T13:58:45+01:00
New Revision: 274907c0a4d6dbdc8815f9a37ea2e444bdfee528

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

LOG: [ASTImporter] Split out Objective-C related unit tests

This moves the two tests we have for importing Objective-C nodes to their own
file. The motivation is that this means I can add more Objective-C tests without
making the compilation time of ASTImporterTest even longer. Also it seems nice
to separate the Apple-specific stuff from the ASTImporter test.

Reviewed By: martong

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

Added: 
clang/unittests/AST/ASTImporterObjCTest.cpp

Modified: 
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/AST/CMakeLists.txt

Removed: 




diff  --git a/clang/unittests/AST/ASTImporterObjCTest.cpp 
b/clang/unittests/AST/ASTImporterObjCTest.cpp
new file mode 100644
index 0..2d848dcf754ed
--- /dev/null
+++ b/clang/unittests/AST/ASTImporterObjCTest.cpp
@@ -0,0 +1,89 @@
+//===- unittest/AST/ASTImporterObjCTest.cpp 
---===//
+//
+// 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
+//
+//===--===//
+//
+// Tests for the correct import of AST nodes related to Objective-C and
+// Objective-C++.
+//
+//===--===//
+
+#include "clang/AST/DeclContextInternals.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "gtest/gtest.h"
+
+#include "ASTImporterFixtures.h"
+
+using namespace clang::ast_matchers;
+using namespace clang;
+
+namespace {
+struct ImportObjCDecl : ASTImporterOptionSpecificTestBase {};
+} // namespace
+
+TEST_P(ImportObjCDecl, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+   @interface C : Root
+ -(void)method;
+   @end
+   @implementation C
+ -(void)method {}
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromMethod = LastDeclMatcher().match(
+  FromTU, namedDecl(hasName("method")));
+  ASSERT_TRUE(FromMethod);
+  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
+  ASSERT_TRUE(ToMethod);
+
+  // Both methods should have their implicit parameters.
+  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
+  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
+}
+
+TEST_P(ImportObjCDecl, ObjPropertyNameConflict) {
+  // Tests that properties that share the same name are correctly imported.
+  // This is only possible with one instance and one class property.
+  Decl *FromTU = getTuDecl(R"(
+   @interface DupProp{}
+   @property (class) int prop;
+   @property int prop;
+   @end
+   )",
+   Lang_OBJCXX, "input.mm");
+  auto *FromClass = FirstDeclMatcher().match(
+  FromTU, namedDecl(hasName("DupProp")));
+  auto ToClass = Import(FromClass, Lang_OBJCXX);
+  ASSERT_TRUE(ToClass);
+  // We should have one class and one instance property.
+  ASSERT_EQ(
+  1, std::distance(ToClass->classprop_begin(), ToClass->classprop_end()));
+  ASSERT_EQ(1,
+std::distance(ToClass->instprop_begin(), ToClass->instprop_end()));
+  for (clang::ObjCPropertyDecl *prop : ToClass->properties()) {
+// All properties should have a getter and a setter.
+ASSERT_TRUE(prop->getGetterMethodDecl());
+ASSERT_TRUE(prop->getSetterMethodDecl());
+// The getters/setters should be able to find the right associated 
property.
+ASSERT_EQ(prop->getGetterMethodDecl()->findPropertyDecl(), prop);
+ASSERT_EQ(prop->getSetterMethodDecl()->findPropertyDecl(), prop);
+  }
+}
+
+static const auto ObjCTestArrayForRunOptions =
+std::array, 2>{
+{std::vector{"-fno-objc-arc"},
+ std::vector{"-fobjc-arc"}}};
+
+const auto ObjCTestValuesForRunOptions =
+::testing::ValuesIn(ObjCTestArrayForRunOptions);
+
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportObjCDecl,
+ObjCTestValuesForRunOptions, );

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 94cec2c140e12..40383bcabc3f0 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTe

[PATCH] D99162: [ASTImporter] Split out Objective-C related unit tests

2021-03-23 Thread Raphael Isemann 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 rG274907c0a4d6: [ASTImporter] Split out Objective-C related 
unit tests (authored by teemperor).
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99162

Files:
  clang/unittests/AST/ASTImporterObjCTest.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/CMakeLists.txt

Index: clang/unittests/AST/CMakeLists.txt
===
--- clang/unittests/AST/CMakeLists.txt
+++ clang/unittests/AST/CMakeLists.txt
@@ -8,6 +8,7 @@
   ASTContextParentMapTest.cpp
   ASTImporterFixtures.cpp
   ASTImporterTest.cpp
+  ASTImporterObjCTest.cpp
   ASTImporterGenericRedeclTest.cpp
   ASTImporterODRStrategiesTest.cpp
   ASTImporterVisibilityTest.cpp
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5615,59 +5615,6 @@
 2u);
 }
 
-TEST_P(ASTImporterOptionSpecificTestBase, ImplicitlyDeclareSelf) {
-  Decl *FromTU = getTuDecl(R"(
-   __attribute__((objc_root_class))
-   @interface Root
-   @end
-   @interface C : Root
- -(void)method;
-   @end
-   @implementation C
- -(void)method {}
-   @end
-   )",
-   Lang_OBJCXX, "input.mm");
-  auto *FromMethod = LastDeclMatcher().match(
-  FromTU, namedDecl(hasName("method")));
-  ASSERT_TRUE(FromMethod);
-  auto ToMethod = Import(FromMethod, Lang_OBJCXX);
-  ASSERT_TRUE(ToMethod);
-
-  // Both methods should have their implicit parameters.
-  EXPECT_TRUE(FromMethod->getSelfDecl() != nullptr);
-  EXPECT_TRUE(ToMethod->getSelfDecl() != nullptr);
-}
-
-TEST_P(ASTImporterOptionSpecificTestBase, ObjPropertyNameConflict) {
-  // Tests that properties that share the same name are correctly imported.
-  // This is only possible with one instance and one class property.
-  Decl *FromTU = getTuDecl(R"(
-   @interface DupProp{}
-   @property (class) int prop;
-   @property int prop;
-   @end
-   )",
-   Lang_OBJCXX, "input.mm");
-  auto *FromClass = FirstDeclMatcher().match(
-  FromTU, namedDecl(hasName("DupProp")));
-  auto ToClass = Import(FromClass, Lang_OBJCXX);
-  ASSERT_TRUE(ToClass);
-  // We should have one class and one instance property.
-  ASSERT_EQ(
-  1, std::distance(ToClass->classprop_begin(), ToClass->classprop_end()));
-  ASSERT_EQ(1,
-std::distance(ToClass->instprop_begin(), ToClass->instprop_end()));
-  for (clang::ObjCPropertyDecl *prop : ToClass->properties()) {
-// All properties should have a getter and a setter.
-ASSERT_TRUE(prop->getGetterMethodDecl());
-ASSERT_TRUE(prop->getSetterMethodDecl());
-// The getters/setters should be able to find the right associated property.
-ASSERT_EQ(prop->getGetterMethodDecl()->findPropertyDecl(), prop);
-ASSERT_EQ(prop->getSetterMethodDecl()->findPropertyDecl(), prop);
-  }
-}
-
 struct ImportAutoFunctions : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(ImportAutoFunctions, ReturnWithTypedefDeclaredInside) {
Index: clang/unittests/AST/ASTImporterObjCTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/ASTImporterObjCTest.cpp
@@ -0,0 +1,89 @@
+//===- unittest/AST/ASTImporterObjCTest.cpp ---===//
+//
+// 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
+//
+//===--===//
+//
+// Tests for the correct import of AST nodes related to Objective-C and
+// Objective-C++.
+//
+//===--===//
+
+#include "clang/AST/DeclContextInternals.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "gtest/gtest.h"
+
+#include "ASTImporterFixtures.h"
+
+using namespace clang::ast_matchers;
+using namespace clang;
+
+namespace {
+struct ImportObjCDecl : ASTImporterOptionSpecificTestBase {};
+} // namespace
+
+TEST_P(ImportObjCDecl, ImplicitlyDeclareSelf) {
+  Decl *FromTU = getTuDecl(R"(
+   __attribute__((objc_root_class))
+   @interface Root
+   @end
+  

[PATCH] D99182: [NFC] Reordering parameters in getFile and getFileOrSTDIN

2021-03-23 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 332644.
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.
Herald added a subscriber: JDevlieghere.

Move FileSize to the end because it is never used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99182

Files:
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/tools/arcmt-test/arcmt-test.cpp
  lld/COFF/Driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/InputFiles.cpp
  lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.cpp
  lldb/unittests/TestingSupport/TestUtilities.cpp
  llvm/include/llvm/Support/MemoryBuffer.h
  llvm/lib/BinaryFormat/Magic.cpp
  llvm/lib/DebugInfo/PDB/Native/NativeSession.cpp
  llvm/lib/FuzzMutate/FuzzerCLI.cpp
  llvm/lib/IRReader/IRReader.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/Object/Binary.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/TableGen/Main.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-cov/gcov.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-pdbutil/InputFile.cpp
  llvm/tools/llvm-pdbutil/llvm-pdbutil.cpp
  llvm/tools/llvm-rc/ResourceFileWriter.cpp
  llvm/tools/llvm-readobj/llvm-readobj.cpp
  llvm/tools/obj2yaml/obj2yaml.cpp
  llvm/tools/sanstats/sanstats.cpp
  llvm/utils/FileCheck/FileCheck.cpp

Index: llvm/utils/FileCheck/FileCheck.cpp
===
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -821,9 +821,7 @@
 
   // Read the expected strings from the check file.
   ErrorOr> CheckFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(CheckFilename, /*IsText=*/true);
   if (std::error_code EC = CheckFileOrErr.getError()) {
 errs() << "Could not open check file '" << CheckFilename
<< "': " << EC.message() << '\n';
@@ -845,9 +843,7 @@
 
   // Open the file to check and add it to SourceMgr.
   ErrorOr> InputFileOrErr =
-  MemoryBuffer::getFileOrSTDIN(InputFilename, /*FileSize=*/-1,
-   /*RequiresNullTerminator=*/true,
-   /*IsText=*/true);
+  MemoryBuffer::getFileOrSTDIN(InputFilename, /*IsText=*/true);
   if (InputFilename == "-")
 InputFilename = ""; // Overwrite for improved diagnostic messages
   if (std::error_code EC = InputFileOrErr.getError()) {
Index: llvm/tools/sanstats/sanstats.cpp
===
--- llvm/tools/sanstats/sanstats.cpp
+++ llvm/tools/sanstats/sanstats.cpp
@@ -125,8 +125,8 @@
   cl::ParseCommandLineOptions(argc, argv,
   "Sanitizer Statistics Processing Tool");
 
-  ErrorOr> MBOrErr =
-  MemoryBuffer::getFile(ClInputFile, -1, false);
+  ErrorOr> MBOrErr = MemoryBuffer::getFile(
+  ClInputFile, /*IsText=*/false, /*RequiresNullTerminator=*/false);
   if (!MBOrErr) {
 errs() << argv[0] << ": " << ClInputFile << ": "
<< MBOrErr.getError().message() << '\n';
Index: llvm/tools/obj2yaml/obj2yaml.cpp
===
--- llvm/tools/obj2yaml/obj2yaml.cpp
+++ llvm/tools/obj2yaml/obj2yaml.cpp
@@ -36,7 +36,7 @@
 
 static Error dumpInput(StringRef File) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return errorCodeToError(EC);
Index: llvm/tools/llvm-readobj/llvm-readobj.cpp
===
--- llvm/tools/llvm-readobj/llvm-readobj.cpp
+++ llvm/tools/llvm-readobj/llvm-readobj.cpp
@@ -653,7 +653,7 @@
 /// Opens \a File and dumps it.
 static void dumpInput(StringRef File, ScopedPrinter &Writer) {
   ErrorOr> FileOrErr =
-  MemoryBuffer::getFileOrSTDIN(File, /*FileSize=*/-1,
+  MemoryBuffer::getFileOrSTDIN(File, /*IsText=*/false,
/*RequiresNullTerminator=*/false);
   if (std::error_code EC = FileOrErr.getError())
 return reportError(errorCodeToError(EC), File);
Index: llvm/tools/llvm-rc/ResourceFileWriter.cpp
===
--- llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1524,14 +1524,16 @@
   // properly though, so if using that to append paths below, this early
   // exception case could be removed.)
   if (sys::path::has_root_directory(File))
-return errorOrToExpected(MemoryBuffer::getFi

[PATCH] D98433: [clang] [C++2b] [P1102] Accept lambdas without parameter list ().

2021-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseExprCXX.cpp:1453
-
-Diag(Tok, diag::err_lambda_missing_parens)
-  << TokKind

I believe you can remove this diagnostic from DiagnosticParseKinds.td now.



Comment at: clang/test/Parser/cxx-concepts-requires-clause.cpp:161
+#endif
\ No newline at end of file


Because you're touching the end of the file anyway, can you add the newline?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98433

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


[clang] 0bc1959 - [RISCV][NFC] Fix RVV intrinsic tests.

2021-03-23 Thread Zakk Chen via cfe-commits

Author: Zakk Chen
Date: 2021-03-23T06:06:05-07:00
New Revision: 0bc1959f51e9adcd8de1f89cc93144caa57bd653

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

LOG: [RISCV][NFC] Fix RVV intrinsic tests.

1. Skip the temporary file
2. Test cc1 with -S to verify codegen work well. Add '-target-feature
   +m' because the backend requires it to calculate the vscaled size/offset.

Reviewed By: craig.topper

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vle.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vse.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvl.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vsetvlmax.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
index 33073587e74c6..5dc562b14680f 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
@@ -1,11 +1,11 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
 // RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s 
-o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
 // RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s 
-o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
-// RUN:   -target-feature +experimental-zfh -Werror -Wall -o - %s >/dev/null 
2>%t
-// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -triple riscv64 -target-feature +m -target-feature 
+experimental-v \
+// RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck 
--check-prefix=ASM --allow-empty %s
 
 // ASM-NOT: warning
 #include 

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
index d0389a333686a..8c5fb7a2df08e 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
@@ -1,11 +1,11 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
 // RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s 
-o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
 // RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s 
-o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
-// RUN:   -target-feature +experimental-zfh -Werror -Wall -o - %s >/dev/null 
2>%t
-// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+// RUN: %clang_cc1 -triple riscv64 -target-feature +m -target-feature +f 
-target-feature +d -target-feature +experimental-v \
+// RUN:   -Werror -Wall -o - %s -S >/dev/null 2>&1 | FileCheck 
--check-prefix=ASM --allow-empty %s
 
 // ASM-NOT: warning
 #include 

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
index d3d73e8d7bba3..902f5e0bf2ed7 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
@@ -1,11 +1,11 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
 // RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s 
-o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
 // RUN:   -target-feature +experimental-zfh -disable-O0-optnone -emit-llvm %s 
-o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-f

[PATCH] D52050: [Driver] Fix architecture triplets and search paths for Linux x32

2021-03-23 Thread John Paul Adrian Glaubitz via Phabricator via cfe-commits
glaubitz added a comment.

Hmm, there recently were quite some changes in the MultiArch and GCC search 
path functionality in the Driver and I can unfortunately no longer get it to 
work on x32.

I had a relatively simple approach but I cannot get it to add the path for the 
crt.o objects and so on. It's always searching in the wrong paths.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D52050

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


[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332649.
arnamoy10 added a comment.

Addressing minor issues


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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,37 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+! REQUIRES: new-flang-driver
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -83,6 +85,8 @@
 ! HELP-FC1-NEXT: -fget-symbols-sources   Dump symbols and their source code locations
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHECK-NEXT: -fno-color-diagnostics Disable colors in diagnostics
Index: flang/test/Driver/Inputs/iso_fortran_env.mod
===
--- /dev/null
+++ flang/test/Driver/Inputs/iso_fortran_env.mod
@@ -0,0

[PATCH] D97993: [Driver] Suppress GCC detection under -B

2021-03-23 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Also broke something in chromium: 
https://bugs.chromium.org/p/chromium/issues/detail?id=1191244 (since fixed by 
switching something from `-B` to `--gcc-toolchain`. This only landed 4 days ago 
and already broke a lot of things (see above) -- chances are it's going to 
break many more things once it makes it into a release. Is this really worth 
the churn? The benefits seem fairly small from what I understand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97993

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2021-03-23 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 332658.
yaxunl added a comment.

Re-use existing warning instead of introducing new diagnostics.

Ping. Can some one help review this patch? I believe all comments addressed. 
Thanks.


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

https://reviews.llvm.org/D71726

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/fp-atomic-ops.c
  clang/test/CodeGenCUDA/amdgpu-atomic-ops.cu
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/Driver/hip-options.hip
  clang/test/Sema/atomic-ops.c
  clang/test/SemaCUDA/amdgpu-atomic-ops.cu
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -1,10 +1,13 @@
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=spir64
-// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only -triple=amdgcn-amdhsa-amd-opencl
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify=expected,spir \
+// RUN:   -fsyntax-only -triple=spir64
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -verify -fsyntax-only \
+// RUN:   -triple=amdgcn-amd-amdhsa
 
 // Basic parsing/Sema tests for __opencl_atomic_*
 
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : enable
 #pragma OPENCL EXTENSION cl_khr_int64_extended_atomics : enable
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
 
 typedef __INTPTR_TYPE__ intptr_t;
 typedef int int8 __attribute__((ext_vector_type(8)));
@@ -36,7 +39,7 @@
 
 atomic_int gn;
 void f(atomic_int *i, const atomic_int *ci,
-   atomic_intptr_t *p, atomic_float *d,
+   atomic_intptr_t *p, atomic_float *f, atomic_double *d, atomic_half *h, // expected-error {{unknown type name 'atomic_half'}}
int *I, const int *CI,
intptr_t *P, float *D, struct S *s1, struct S *s2,
global atomic_int *i_g, local atomic_int *i_l, private atomic_int *i_p,
@@ -57,37 +60,38 @@
 
   __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(p, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_load(d, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_load(f, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(ci, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_load(i_c, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to non-constant _Atomic type ('__constant atomic_int *' (aka '__constant _Atomic(int) *') invalid)}}
 
   __opencl_atomic_store(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_store(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  (int)__opencl_atomic_store(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
+  (int)__opencl_atomic_store(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{operand of type 'void' where arithmetic or pointer type is required}}
 
   int exchange_1 = __opencl_atomic_exchange(i, 1, memory_order_seq_cst, memory_scope_work_group);
   int exchange_2 = __opencl_atomic_exchange(I, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to _Atomic}}
 
   __opencl_atomic_fetch_add(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_add(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_add(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer or pointer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_add(f, 1.0f, memory_order_seq_cst, memory_scope_work_group);
+  __opencl_atomic_fetch_add(d, 1.0, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_and(p, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_and(d, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
+  __opencl_atomic_fetch_and(f, 1, memory_order_seq_cst, memory_scope_work_group); // expected-error {{address argument to atomic operation must be a pointer to atomic integer ('__generic atomic_float *' (aka '__generic _Atomic(float) *') invalid)}}
 
   __opencl_atomic_fetch_min(i, 1, memory_order_seq_cst, memory_scope_work_group);
   __opencl_atomic_fetch_max(i, 1, memory_order_seq_cst, memory_scope_work_group);
-  __opencl_atomic_fetch_min(d, 1, 

[PATCH] D99185: [PowerPC] Change option to mrop-protect

2021-03-23 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp created this revision.
stefanp added a reviewer: nemanjai.
Herald added subscribers: jansvoboda11, dang, shchenz, kbarton, hiraditya.
stefanp requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

In order to have the same option on power PC LLVM and power PC gcc
the option will be changed from -mrop-protection to -mrop-protect.

The feature will be off by default and turned on when the option is used.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99185

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-mrop-protection-support-check.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protection \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protection \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -112,7 +112,7 @@
   bool HasPrefixInstrs;
   bool HasPCRelativeMemops;
   bool HasMMA;
-  bool HasROPProtection;
+  bool HasROPProtect;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -274,7 +274,7 @@
   bool hasPrefixInstrs() const { return HasPrefixInstrs; }
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMMA() const { return HasMMA; }
-  bool hasROPProtection() const { return HasROPProtection; }
+  bool hasROPProtect() const { return HasROPProtect; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -87,7 +87,7 @@
   HasP9Vector = false;
   HasP9Altivec = false;
   HasMMA = false;
-  HasROPProtection = false;
+  HasROPProtect = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -252,9 +252,9 @@
   "Enable MMA instructions",
   [FeatureP8Vector, FeatureP9Altivec,
FeaturePairedVectorMemops]>;
-def FeatureROPProtection :
-  SubtargetFeature<"rop-protection", "HasROPProtection", "false",
-   "Add ROP protection">;
+def FeatureROPProtect :
+  SubtargetFeature<"rop-protect", "HasROPProtect", "true",
+   "Add ROP protect">;
 
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
@@ -323,8 +323,7 @@
  FeatureDirectMove,
  FeatureICBT,
  FeaturePartwordAtomic,
- FeaturePredictableSelectIsExpensive,
- FeatureROPProtection
+ FeaturePredictableSelectIsExpensive
 ];
 
   list P8SpecificFeatures = [FeatureAddiLoadFusion,
Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -566,7 +566,7 @@
 // PPCPWR8-NOT:#define _ARCH_PWR6X 1
 // PPCPWR8:#define _ARCH_PWR7 1
 // PPCPWR8:#define _ARCH_PWR8 1
-// PPCPWR8-NOT:#define __ROP_PROTECTION__ 1
+// PPCPWR8-NOT:#define __ROP_PROTECT__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER8 %s
 //
@@ -584,7 +584,7 @@
 // PPCPOWER8-NOT:#define _ARCH_PWR6X 1
 // PPCPOWER8:#define _ARCH_PWR7 1
 // PPCPOWER8:#define _ARCH_PWR8 1
-// PPCPOWER8-NOT:#define __ROP_PROTECTION__ 1
+// PPCPOWER8-NOT:#define __ROP_PROTECT__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffre

[clang] 4146864 - [PowerPC][NFC] Use valid type for offset in altivec.h

2021-03-23 Thread Nemanja Ivanovic via cfe-commits

Author: Nemanja Ivanovic
Date: 2021-03-23T08:45:37-05:00
New Revision: 4146864735443a827490c7715191f3b8ba16f0e3

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

LOG: [PowerPC][NFC] Use valid type for offset in altivec.h

We currently use signed long long instead of ptrdiff_t for offsets
in altivec.h. This has never really presented a problem because
all platforms where we use these are 64-bit. However, now that
we have 32-bit targets, we need to use a meaningful type.

Added: 


Modified: 
clang/lib/Headers/altivec.h

Removed: 




diff  --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index c5674413e4832..84a85888422a0 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -41,9 +41,7 @@
 
 #define __ATTRS_o_ai __attribute__((__overloadable__, __always_inline__))
 
-#ifdef __POWER9_VECTOR__
 #include 
-#endif
 
 static __inline__ vector signed char __ATTRS_o_ai vec_perm(
 vector signed char __a, vector signed char __b, vector unsigned char __c);
@@ -17136,41 +17134,41 @@ typedef vector signed int unaligned_vec_sint 
__attribute__((aligned(1)));
 typedef vector unsigned int unaligned_vec_uint __attribute__((aligned(1)));
 typedef vector float unaligned_vec_float __attribute__((aligned(1)));
 
-static inline __ATTRS_o_ai vector signed char vec_xl(signed long long __offset,
+static inline __ATTRS_o_ai vector signed char vec_xl(ptr
diff _t __offset,
  const signed char *__ptr) 
{
   return *(unaligned_vec_schar *)(__ptr + __offset);
 }
 
 static inline __ATTRS_o_ai vector unsigned char
-vec_xl(signed long long __offset, const unsigned char *__ptr) {
+vec_xl(ptr
diff _t __offset, const unsigned char *__ptr) {
   return *(unaligned_vec_uchar*)(__ptr + __offset);
 }
 
-static inline __ATTRS_o_ai vector signed short vec_xl(signed long long 
__offset,
-  const signed short 
*__ptr) {
+static inline __ATTRS_o_ai vector signed short
+vec_xl(ptr
diff _t __offset, const signed short *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_sshort *)__addr;
 }
 
 static inline __ATTRS_o_ai vector unsigned short
-vec_xl(signed long long __offset, const unsigned short *__ptr) {
+vec_xl(ptr
diff _t __offset, const unsigned short *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_ushort *)__addr;
 }
 
-static inline __ATTRS_o_ai vector signed int vec_xl(signed long long __offset,
+static inline __ATTRS_o_ai vector signed int vec_xl(ptr
diff _t __offset,
 const signed int *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_sint *)__addr;
 }
 
-static inline __ATTRS_o_ai vector unsigned int vec_xl(signed long long 
__offset,
-  const unsigned int 
*__ptr) {
+static inline __ATTRS_o_ai vector unsigned int
+vec_xl(ptr
diff _t __offset, const unsigned int *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_uint *)__addr;
 }
 
-static inline __ATTRS_o_ai vector float vec_xl(signed long long __offset,
+static inline __ATTRS_o_ai vector float vec_xl(ptr
diff _t __offset,
const float *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_float *)__addr;
@@ -17182,18 +17180,18 @@ typedef vector unsigned long long unaligned_vec_ull 
__attribute__((aligned(1)));
 typedef vector double unaligned_vec_double __attribute__((aligned(1)));
 
 static inline __ATTRS_o_ai vector signed long long
-vec_xl(signed long long __offset, const signed long long *__ptr) {
+vec_xl(ptr
diff _t __offset, const signed long long *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_sll *)__addr;
 }
 
 static inline __ATTRS_o_ai vector unsigned long long
-vec_xl(signed long long __offset, const unsigned long long *__ptr) {
+vec_xl(ptr
diff _t __offset, const unsigned long long *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_ull *)__addr;
 }
 
-static inline __ATTRS_o_ai vector double vec_xl(signed long long __offset,
+static inline __ATTRS_o_ai vector double vec_xl(ptr
diff _t __offset,
 const double *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_double *)__addr;
@@ -17205,13 +17203,13 @@ typedef vector signed __int128 unaligned_vec_si128 
__attribute__((aligned(1)));
 typedef vector unsigned __int128 unaligned_vec_ui128
 __attribute__((aligned(1)));
 stat

[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

FWIW, LibreOffice `make check` (which started to consistently fail with D88220 
) succeeds with this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

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


[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

2021-03-23 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 332660.
khchen marked 8 inline comments as done.
khchen added a comment.

1. address Craig's comments.
2. add 'REQUIRES: riscv-registered-target' for tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98848

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vluxei.c
  clang/utils/TableGen/RISCVVEmitter.cpp

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


[PATCH] D99158: [RISCV][WIP] Implement intrinsics for P extension

2021-03-23 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11170-11175
 // RISC-V V-extension
 def err_riscvv_builtin_requires_v : Error<
"builtin requires 'V' extension support to be enabled">;
+// RISC-V P-extension
+def err_riscvv_builtin_requires_p : Error<
+   "builtin requires 'P' extension support to be enabled">;

I seem to recall another patch that includes generalising this to take the 
extension name rather than adding multiple copies of the same thing



Comment at: clang/lib/AST/ASTContext.cpp:4037
+QualType
+ASTContext::getRegisterSizedVectorType(QualType vecType,
+   VectorType::VectorKind VecKind) const {

Upper-case parameter name



Comment at: clang/test/CodeGen/builtins-riscv-rv32p.c:63
+
+  // RV32: call i32 @llvm.riscv.add8.i32
+  ul_r = __rv__add8(ul_a, ul_b);

One function per test and update_cc_test_checks.py would be a lot nicer IMO



Comment at: llvm/lib/Target/RISCV/RISCVISelLowering.cpp:715-732
+if (Subtarget.is64Bit()) {
+  addTypeForP(MVT::v8i8, MVT::i64);
+  addTypeForP(MVT::v4i16, MVT::i64);
+  addTypeForP(MVT::v2i32, MVT::i64);
+} else {
+  addTypeForP(MVT::v4i8, MVT::i32);
+  addTypeForP(MVT::v2i16, MVT::i32);

This seems like it will interact poorly with V if both are present



Comment at: llvm/test/CodeGen/RISCV/intrinsics-rv32p.ll:5
+
+define void @test() nounwind {
+; RV32P-LABEL: test:

This is an awful test. One function per intrinsic, and no unnecessary alloca's.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99158

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


[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 332663.
Quuxplusone added a comment.

Shrink the code by one line, by introducing another local named variable.
Still hoping for an "accept" here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/CXX/class/class.init/class.copy.elision/p3.cpp

Index: clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
===
--- clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
+++ clang/test/CXX/class/class.init/class.copy.elision/p3.cpp
@@ -292,3 +292,108 @@
   return b; // cxx20-error {{calling a private constructor of class 'test_ctor_param_rvalue_ref::B2'}}
 }
 } // namespace test_ctor_param_rvalue_ref
+
+namespace test_lvalue_ref_is_not_moved_from {
+
+struct Target {};
+  // expected-note@-1 {{candidate constructor (the implicit copy constructor) not viable}}
+  // expected-note@-2 {{candidate constructor (the implicit move constructor) not viable}}
+  // cxx11_14_17-note@-3 {{candidate constructor (the implicit copy constructor) not viable}}
+  // cxx11_14_17-note@-4 {{candidate constructor (the implicit move constructor) not viable}}
+
+struct CopyOnly {
+  CopyOnly(CopyOnly&&) = delete; // cxx20-note {{has been explicitly marked deleted here}}
+  CopyOnly(CopyOnly&);
+  operator Target() && = delete; // cxx20-note {{has been explicitly marked deleted here}}
+  operator Target() &;
+};
+
+struct MoveOnly {
+  MoveOnly(MoveOnly&&); // expected-note {{copy constructor is implicitly deleted because}}
+// cxx11_14_17-note@-1 {{copy constructor is implicitly deleted because}}
+  operator Target() &&; // expected-note {{candidate function not viable}}
+// cxx11_14_17-note@-1 {{candidate function not viable}}
+};
+
+extern CopyOnly copyonly;
+extern MoveOnly moveonly;
+
+CopyOnly t1() {
+CopyOnly& r = copyonly;
+return r;
+}
+
+CopyOnly t2() {
+CopyOnly&& r = static_cast(copyonly);
+return r; // cxx20-error {{call to deleted constructor}}
+}
+
+MoveOnly t3() {
+MoveOnly& r = moveonly;
+return r; // expected-error {{call to implicitly-deleted copy constructor}}
+}
+
+MoveOnly t4() {
+MoveOnly&& r = static_cast(moveonly);
+return r; // cxx11_14_17-error {{call to implicitly-deleted copy constructor}}
+}
+
+Target t5() {
+CopyOnly& r = copyonly;
+return r;
+}
+
+Target t6() {
+CopyOnly&& r = static_cast(copyonly);
+return r; // cxx20-error {{invokes a deleted function}}
+}
+
+Target t7() {
+MoveOnly& r = moveonly;
+return r; // expected-error {{no viable conversion}}
+}
+
+Target t8() {
+MoveOnly&& r = static_cast(moveonly);
+return r; // cxx11_14_17-error {{no viable conversion}}
+}
+
+} // namespace test_lvalue_ref_is_not_moved_from
+
+namespace test_rvalue_ref_to_nonobject {
+
+struct CopyOnly {};
+struct MoveOnly {};
+
+struct Target {
+Target(CopyOnly (&)());
+Target(CopyOnly (&&)()) = delete;
+Target(MoveOnly (&)()) = delete; // expected-note {{has been explicitly marked deleted here}}
+  // expected-note@-1 {{has been explicitly marked deleted here}}
+Target(MoveOnly (&&)());
+};
+
+CopyOnly make_copyonly();
+MoveOnly make_moveonly();
+
+Target t1() {
+CopyOnly (&r)() = make_copyonly;
+return r;
+}
+
+Target t2() {
+CopyOnly (&&r)() = static_cast(make_copyonly);
+return r; // OK in all modes; not subject to implicit move
+}
+
+Target t3() {
+MoveOnly (&r)() = make_moveonly;
+return r; // expected-error {{invokes a deleted function}}
+}
+
+Target t4() {
+MoveOnly (&&r)() = static_cast(make_moveonly);
+return r; // expected-error {{invokes a deleted function}}
+}
+
+} // namespace test_rvalue_ref_to_nonobject
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -3092,24 +3092,30 @@
   if (VD->hasAttr())
 return false;
 
-  // ...non-volatile...
-  if (VD->getType().isVolatileQualified())
-return false;
-
-  // C++20 [class.copy.elision]p3:
-  // ...rvalue reference to a non-volatile...
-  if (VD->getType()->isRValueReferenceType() &&
-  (!(CESK & CES_AllowRValueReferenceType) ||
-   VD->getType().getNonReferenceType().isVolatileQualified()))
+  if (VDType->isObjectType()) {
+// C++17 [class.copy.elision]p3:
+// ...non-volatile automatic object...
+if (VDType.isVolatileQualified())
+  return false;
+  } else if (VDType->isRValueReferenceType()) {
+// C++20 [class.copy.elision]p3:
+// ...either a non-volatile object or an rvalue reference to a non-volatile object type...
+if (!(CESK & CES_AllowRValueReferenceType))
+  return false;
+QualType VDReferencedType = VDType.getNonReferenceType();
+if (VDReferencedType.isVolatileQualified() || !VDReferencedType->isObjectType())
+ 

[clang] bc6b139 - [clang][parser] Don't prohibit attributes on objc @try/@throw

2021-03-23 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2021-03-23T15:26:25+01:00
New Revision: bc6b139392f638a69e85a474eb0eb59e13d9791a

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

LOG: [clang][parser] Don't prohibit attributes on objc @try/@throw

This line has a TODO comment, but the answer to it seems to be "no"
given that clang itself uses attributes on @try statements in its tests.

This ProhibitAttributes() statement is also dead code since
ProhibitAttributs() does not handle GNU attributes at the moment but
those are the only attributes valid in objc.

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

Added: 
clang/test/CodeGenObjC/attr-nomerge.m

Modified: 
clang/lib/Parse/ParseStmt.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseStmt.cpp b/clang/lib/Parse/ParseStmt.cpp
index 798b8d0d7eb1..bcda3560ce63 100644
--- a/clang/lib/Parse/ParseStmt.cpp
+++ b/clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@ StmtResult 
Parser::ParseStatementOrDeclarationAfterAttributes(
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }

diff  --git a/clang/test/CodeGenObjC/attr-nomerge.m 
b/clang/test/CodeGenObjC/attr-nomerge.m
new file mode 100644
index ..7d053d0b1d69
--- /dev/null
+++ b/clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -triple x86_64-unknown-linux 
-o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(...) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+
+  return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}



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


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-23 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbc6b139392f6: [clang][parser] Don't prohibit attributes 
on objc @try/@throw (authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97371

Files:
  clang/lib/Parse/ParseStmt.cpp
  clang/test/CodeGenObjC/attr-nomerge.m


Index: clang/test/CodeGenObjC/attr-nomerge.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -triple x86_64-unknown-linux 
-o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(...) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+
+  return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }


Index: clang/test/CodeGenObjC/attr-nomerge.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/attr-nomerge.m
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -emit-llvm -fobjc-exceptions -triple x86_64-unknown-linux -o - %s | FileCheck %s
+
+// Test that the nomerge attribute is applied to function calls
+// in @try, @catch and @finally
+void opaque(void);
+void opaque2(void);
+void opaque3(void);
+
+int main(int argc, const char * argv[]) {
+  __attribute__((nomerge)) @try {
+opaque();
+  } @catch(...) {
+opaque2();
+  } @finally {
+opaque3();
+  }
+
+  return 0;
+}
+
+// CHECK: call void @opaque() #[[ATTR0:[0-9]+]]
+// CHECK-DAG: call void @opaque2() #[[ATTR0]]
+// CHECK-DAG: call void @opaque3() #[[ATTR0]]
+// CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -172,7 +172,6 @@
   switch (Kind) {
   case tok::at: // May be a @try or @throw statement
 {
-  ProhibitAttributes(Attrs); // TODO: is it correct?
   AtLoc = ConsumeToken();  // consume @
   return ParseObjCAtStatement(AtLoc, StmtCtx);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D97371: [clang][parser] Remove questionable ProhibitAttributes() call in objc parsing

2021-03-23 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

Thanks everyone!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97371

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


[PATCH] D98848: [RISCV][Clang] Add RVV Vector Indexed Load intrinsic functions.

2021-03-23 Thread Liao Chunyu via Phabricator via cfe-commits
liaolucy added a comment.

LGTM, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98848

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


[PATCH] D99188: [clang][ASTImporter] Add import of DeducedTemplateSpecializationType.

2021-03-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: whisperity, martong, teemperor, gamesh411, Szelethus, 
dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
balazske 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/D99188

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
@@ -631,6 +631,15 @@
  
fieldDecl(hasType(dependentTemplateSpecializationType(;
 }
 
+TEST_P(ImportType, ImportDeducedTemplateSpecialization) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "class C { public: C(T); };"
+ "C declToImport(123);",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ varDecl(hasType(deducedTemplateSpecializationType(;
+}
+
 const internal::VariadicDynCastAllOfMatcher
 sizeOfPackExpr;
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@
 ExpectedType VisitDecltypeType(const DecltypeType *T);
 ExpectedType VisitUnaryTransformType(const UnaryTransformType *T);
 ExpectedType VisitAutoType(const AutoType *T);
+ExpectedType VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T);
 ExpectedType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 ExpectedType VisitRecordType(const RecordType *T);
@@ -1376,6 +1378,20 @@
   ToTemplateArgs);
 }
 
+ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T) {
+  // FIXME: Make sure that the "to" context supports C++17!
+  Expected ToTemplateNameOrErr = import(T->getTemplateName());
+  if (!ToTemplateNameOrErr)
+return ToTemplateNameOrErr.takeError();
+  ExpectedType ToDeducedTypeOrErr = import(T->getDeducedType());
+  if (!ToDeducedTypeOrErr)
+return ToDeducedTypeOrErr.takeError();
+
+  return Importer.getToContext().getDeducedTemplateSpecializationType(
+  *ToTemplateNameOrErr, *ToDeducedTypeOrErr, T->isDependentType());
+}
+
 ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
 const InjectedClassNameType *T) {
   Expected ToDeclOrErr = import(T->getDecl());


Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -631,6 +631,15 @@
  fieldDecl(hasType(dependentTemplateSpecializationType(;
 }
 
+TEST_P(ImportType, ImportDeducedTemplateSpecialization) {
+  MatchVerifier Verifier;
+  testImport("template "
+ "class C { public: C(T); };"
+ "C declToImport(123);",
+ Lang_CXX17, "", Lang_CXX17, Verifier,
+ varDecl(hasType(deducedTemplateSpecializationType(;
+}
+
 const internal::VariadicDynCastAllOfMatcher
 sizeOfPackExpr;
 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -358,6 +358,8 @@
 ExpectedType VisitDecltypeType(const DecltypeType *T);
 ExpectedType VisitUnaryTransformType(const UnaryTransformType *T);
 ExpectedType VisitAutoType(const AutoType *T);
+ExpectedType VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T);
 ExpectedType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 ExpectedType VisitRecordType(const RecordType *T);
@@ -1376,6 +1378,20 @@
   ToTemplateArgs);
 }
 
+ExpectedType ASTNodeImporter::VisitDeducedTemplateSpecializationType(
+const DeducedTemplateSpecializationType *T) {
+  // FIXME: Make sure that the "to" context supports C++17!
+  Expected ToTemplateNameOrErr = import(T->getTemplateName());
+  if (!ToTemplateNameOrErr)
+return ToTemplateNameOrErr.takeError();
+  ExpectedType ToDeducedTypeOrErr = import(T->getDeducedType());
+  if (!ToDeducedTypeOrErr)
+return ToDeducedTypeOrErr.takeError();
+
+  return Importer.getToContext().getDeducedTemplateSpecializationType(
+  *ToTemplateNameOrErr, *ToDeducedTypeOrErr, T->isDependentType());
+}
+
 ExpectedType ASTNodeImporter::VisitInjectedClassNameType(
 const InjectedClassNameType *T) {
   Expected ToDeclOrErr = import(T->getDecl());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99189: [RISCV][Clang] Update new overloading rules for RVV intrinsics.

2021-03-23 Thread Zakk Chen via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: craig.topper, rogfer01, HsiangKai, evandro, liaolucy, 
jrtc27.
Herald added subscribers: vkmr, frasercrmck, dexonsmith, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, shiva0217, kito-cheng, niosHD, 
sabuasal, simoncook, johnrusso, rbar, asb, mgorny.
khchen requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

RVV intrinsics has new overloading rule, please see
https://github.com/riscv/rvv-intrinsic-doc/commit/82aac7dad4c6c1c351ed5b17ca6007c395843ed7

Changed:

1. Rename `generic` to `overloaded` because the new rule is not using C11 
generic.
2. Change HasGeneric to HasNoMaskedOverloaded because all masked operations 
support overloading api.
3. Add more overloaded tests due to overloading rule changed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99189

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vle.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vloxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vluxei.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vse.c
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst
  llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

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


[PATCH] D97869: [OpenCL][Draft] Add OpenCL builtin test generator

2021-03-23 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 332675.
svenvh added a comment.

Emit `#if` guards for extensions and versions.


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

https://reviews.llvm.org/D97869

Files:
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -123,6 +123,8 @@
 
 void EmitClangOpenCLBuiltins(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
+void EmitClangOpenCLBuiltinTests(llvm::RecordKeeper &Records,
+ llvm::raw_ostream &OS);
 
 void EmitClangDataCollectors(llvm::RecordKeeper &Records,
  llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -63,6 +63,7 @@
   GenClangCommentCommandInfo,
   GenClangCommentCommandList,
   GenClangOpenCLBuiltins,
+  GenClangOpenCLBuiltinTests,
   GenArmNeon,
   GenArmFP16,
   GenArmBF16,
@@ -195,6 +196,8 @@
"documentation comments"),
 clEnumValN(GenClangOpenCLBuiltins, "gen-clang-opencl-builtins",
"Generate OpenCL builtin declaration handlers"),
+clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
+   "Generate OpenCL builtin declaration tests"),
 clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
 clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
 clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -375,6 +378,9 @@
   case GenClangOpenCLBuiltins:
 EmitClangOpenCLBuiltins(Records, OS);
 break;
+  case GenClangOpenCLBuiltinTests:
+EmitClangOpenCLBuiltinTests(Records, OS);
+break;
   case GenClangSyntaxNodeList:
 EmitClangSyntaxNodeList(Records, OS);
 break;
Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -228,6 +228,64 @@
   // same entry ().
   MapVector SignatureListMap;
 };
+
+// OpenCL builtin test generator.  This class processes the same TableGen input
+// as BuiltinNameEmitter, but generates a .cl file that contains a call to each
+// builtin function described in the .td input.
+class OpenCLBuiltinTestEmitter {
+public:
+  OpenCLBuiltinTestEmitter(RecordKeeper &Records, raw_ostream &OS)
+  : Records(Records), OS(OS) {}
+
+  // Entrypoint to generate the functions for testing all OpenCL builtin
+  // functions.
+  void Emit();
+
+private:
+  struct TypeFlags {
+TypeFlags() : IsConst(false), IsVolatile(false), IsPointer(false) {}
+bool IsConst : 1;
+bool IsVolatile : 1;
+bool IsPointer : 1;
+StringRef AddrSpace;
+  };
+
+  // Return a string representation of the given type, such that it can be
+  // used as a type in OpenCL C code.
+  std::string getTypeString(const Record *Type, TypeFlags Flags,
+int VectorSize) const;
+
+  // Return the type(s) and vector size(s) for the given type.  For
+  // non-GenericTypes, the resulting vectors will contain 1 element.  For
+  // GenericTypes, the resulting vectors typically contain multiple elements.
+  void getTypeLists(Record *Type, TypeFlags &Flags,
+std::vector &TypeList,
+std::vector &VectorList) const;
+
+  // Expand the TableGen Records representing a builtin function signature into
+  // one or more function signatures.  Return them as a vector of a vector of
+  // strings, with each string containing an OpenCL C type and optional
+  // qualifiers.
+  //
+  // The Records may contain GenericTypes, which expand into multiple
+  // signatures.  Repeated occurrences of GenericType in a signature expand to
+  // the same types.  For example [char, FGenType, FGenType] expands to:
+  //   [char, float, float]
+  //   [char, float2, float2]
+  //   [char, float3, float3]
+  //   ...
+  void
+  expandTypesInSignature(const std::vector &Signature,
+ SmallVectorImpl> &Types);
+
+  // Contains OpenCL builtin functions and related information, stored as
+  // Record instances. They are coming from the associated TableGen file.
+  RecordKeeper &Records;
+
+  // The output file.
+  raw_ostream &OS;
+};
+
 } // namespace
 
 void BuiltinNameEmitter::Emit() {
@@ -816,7 +874,221 @@
   OS << "\n} // OCL2Qual\n";
 }
 
+std::string OpenCLBuiltinTestEmitter::getTypeString(const Record *Type,
+TypeFlags Flags,
+   

[PATCH] D99190: [SYCL] Add design document for SYCL mode

2021-03-23 Thread Alexey Bader via Phabricator via cfe-commits
bader created this revision.
Herald added subscribers: mstorsjo, Anastasia, ebevhan, yaxunl.
bader requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Initial version of the document covers most of the compiler components.
SYCL runtime library part is to be defined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99190

Files:
  clang/docs/SYCLSupport.md
  clang/docs/images/Compiler-HLD.svg
  clang/docs/images/DeviceCodeSplit.svg
  clang/docs/images/DeviceLinkAndWrap.svg
  clang/docs/images/DevicePTXProcessing.svg
  clang/docs/images/SplitCompileAndLink.svg

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


[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert accepted this revision.
aaronpuchert added a comment.
This revision is now accepted and ready to land.

I thought maybe you wanted to follow @mizvekov's proposal to simplify, but I 
understand you want to stick close to the standard language.

So LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

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


[PATCH] D98971: [C++20] [P1825] Fix bugs with implicit-move from variables of reference type

2021-03-23 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D98971#2644747 , @Quuxplusone wrote:

> Shrink the code by one line, by introducing another local named variable.
> Still hoping for an "accept" here.

My two cents:

Functionality-wise I think it is OK, but like I said before, I think the extra 
repetition / verbosity hurts more than helps.

I think the suggested shortening captures the intention of the standard better: 
The object itself should be non-volatile, no matter if we have it by value or 
rvalue reference.

It does not look like to me that the clang code is in general styled to spell 
the wording that precisely, or else those comments quoting the standard wording 
would not be of much use.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98971

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


[PATCH] D98237: [clang-format] Option for empty lines after an access modifier.

2021-03-23 Thread Max Sagebaum via Phabricator via cfe-commits
Max_S added a comment.

In D98237#2643815 , @MyDeveloperDay 
wrote:

> If you follow people tweeting about clang-format (as I do) and you look 
> through the bug tracking system, one major criticism of clang-format is that 
> the second clang-format can be different from the first, sometimes an 
> equilibrium can be found sometimes not.
>
> When I started working on clang-format I was encouraged to use verifyFormat() 
> as it tests that scenario and also tries to mess up the format and ensure it 
> returns to the desired state. It found bugs in my code which would have made 
> clang-format worse.
>
> Apart from it being the convention I believe it makes for much more readable 
> code, even if there is repetition as I don't need to keep cross referencing 
> variables with rather obscure names `NL_B_3_A_0_I_0` this is unnecessary 
> noise and makes the code overly verbose.
>
> No you'll need to check out what the messUp() function is actually doing but 
> I think by and large IMHO we should stick with verifyFormat.

Ok then I will change the tests accordingly. This reasoning should be written 
down somewhere.

In D98237#2643880 , @MyDeveloperDay 
wrote:

> I'd be quite interested to understand what the impact (if any) would be on 
> javascript and C# formatting

I have not done anything in javascript a quick google search showed no such 
modifiers in classes. Do you have an example? C# seems to handle it like java 
and then the modifiers become properties of the functions member, there should 
be no influence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98237

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


[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added inline comments.



Comment at: clang/include/clang/Driver/Options.td:4872
+   "optimizations.">;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fverify-debuginfo-preserve-export=">,

jansvoboda11 wrote:
> Please, update the new options to use the marshalling infrastructure. You can 
> then remove the code from `CompilerInvocation`.
> 
> https://clang.llvm.org/docs/InternalsManual.html#adding-new-command-line-option
Sure. Thanks!



Comment at: clang/lib/Frontend/CompilerInvocation.cpp:1644-1650
+  Opts.EnableDIPreservationVerify = 
Args.hasArg(OPT_fverify_debuginfo_preserve);
+  // Ignore the option if the -fverify-debuginfo-preserve wasn't enabled.
+  if (Opts.EnableDIPreservationVerify &&
+  Args.hasArg(OPT_fverify_debuginfo_preserve_export)) {
+Opts.DIBugsReportFilePath = std::string(
+Args.getLastArgValue(OPT_fverify_debuginfo_preserve_export));
+  }

StephenTozer wrote:
> Any particular behaviour if the user specifies a file for 
> `-fverify-debuginfo-preserve-export` but doesn't set 
> `-fverify-debuginfo-preserve`? It seems like it would be worth emitting a 
> warning in this case, though I'm not sure if that's an established precedent.
it makes sense


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

https://reviews.llvm.org/D82547

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


[PATCH] D82547: [Debugify] Expose original debug info preservation check as CC1 option

2021-03-23 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro updated this revision to Diff 332679.
djtodoro added a comment.

- addressing comments


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

https://reviews.llvm.org/D82547

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Driver/verify-debug-info-preservation.c
  llvm/docs/HowToUpdateDebugInfo.rst

Index: llvm/docs/HowToUpdateDebugInfo.rst
===
--- llvm/docs/HowToUpdateDebugInfo.rst
+++ llvm/docs/HowToUpdateDebugInfo.rst
@@ -376,6 +376,17 @@
 
   $ llvm-original-di-preservation.py sample.json sample.html
 
+Testing of original debug info preservation can be invoked from front-end level
+as follows:
+
+.. code-block:: bash
+
+  # Test each pass.
+  $ clang -Xclang -fverify-debuginfo-preserve -g -O2 sample.c
+
+  # Test each pass and export the issues report into the JSON file.
+  $ clang -Xclang -fverify-debuginfo-preserve -Xclang -fverify-debuginfo-preserve-export=sample.json -g -O2 sample.c
+
 Mutation testing for MIR-level transformations
 --
 
Index: clang/test/Driver/verify-debug-info-preservation.c
===
--- /dev/null
+++ clang/test/Driver/verify-debug-info-preservation.c
@@ -0,0 +1,19 @@
+// We support the CC1 options for testing whether each LLVM pass preserves
+// original debug info.
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE %s
+
+// VERIFYDIPRESERVE: "-fverify-debuginfo-preserve"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve \
+// RUN: -Xclang -fverify-debuginfo-preserve-export=%t.json -### %s 2>&1 \
+// RUN: | FileCheck --check-prefix=VERIFYDIPRESERVE-JSON-EXPORT %s
+
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve"
+// VERIFYDIPRESERVE-JSON-EXPORT: "-fverify-debuginfo-preserve-export={{.*}}"
+
+// RUN: %clang -g -Xclang -fverify-debuginfo-preserve-export=%t.json %s -S 2>&1 \
+// RUN: | FileCheck --check-prefix=WARN %s
+
+// WARN: warning: ignoring -fverify-debuginfo-preserve-export
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1641,6 +1641,12 @@
   llvm::is_contained(DebugEntryValueArchs, T.getArch()))
 Opts.EmitCallSiteInfo = true;
 
+  if (!Opts.EnableDIPreservationVerify && Opts.DIBugsReportFilePath.size()) {
+Diags.Report(diag::warn_ignoring_verify_debuginfo_preserve_export)
+<< Opts.DIBugsReportFilePath;
+Opts.DIBugsReportFilePath = "";
+  }
+
   Opts.NewStructPathTBAA = !Args.hasArg(OPT_no_struct_path_tbaa) &&
Args.hasArg(OPT_new_struct_path_tbaa);
   Opts.OptimizeSize = getOptimizationLevelSize(Args);
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -81,6 +81,7 @@
 #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
 #include "llvm/Transforms/Utils.h"
 #include "llvm/Transforms/Utils/CanonicalizeAliases.h"
+#include "llvm/Transforms/Utils/Debugify.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/NameAnonGlobals.h"
 #include "llvm/Transforms/Utils/SymbolRewriter.h"
@@ -945,7 +946,16 @@
   if (TM)
 TheModule->setDataLayout(TM->createDataLayout());
 
-  legacy::PassManager PerModulePasses;
+  DebugifyCustomPassManager PerModulePasses;
+  DebugInfoPerPassMap DIPreservationMap;
+  if (CodeGenOpts.EnableDIPreservationVerify) {
+PerModulePasses.setDebugifyMode(DebugifyMode::OriginalDebugInfo);
+PerModulePasses.setDIPreservationMap(DIPreservationMap);
+
+if (!CodeGenOpts.DIBugsReportFilePath.empty())
+  PerModulePasses.setOrigDIVerifyBugsReportFilePath(
+  CodeGenOpts.DIBugsReportFilePath);
+  }
   PerModulePasses.add(
   createTargetTransformInfoWrapperPass(getTargetIRAnalysis()));
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4865,6 +4865,18 @@
 "fexperimental-debug-variable-locations">,
 HelpText<"Use experimental new value-tracking variable locations">,
 MarshallingInfoFlag>;
+def fverify_debuginfo_preserve
+: Flag<["-"], "fverify-debuginfo-preserve">,
+  HelpText<"Enable Debug Info Metadata preservation testing in "
+   "optimizations.">,
+  MarshallingInfoFlag>;
+def fverify_debuginfo_preserve_export
+: Joined<["-"], "fv

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 332686.
balazske added a comment.

Fixed according to the comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

Files:
  clang/lib/AST/Expr.cpp
  clang/unittests/Tooling/SourceCodeTest.cpp


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,63 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedLookupExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+f_overload(p); // UnresolvedLookupExpr
+// CalleeType in getCallReturntype is Overload and not dependent
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedMemberExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+A a;
+a.f_overload(p); // UnresolvedMemberExpr
+// CalleeType in getCallReturntype is BoundMember and has overloads
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1383,6 +1383,7 @@
 QualType CallExpr::getCallReturnType(const ASTContext &Ctx) const {
   const Expr *Callee = getCallee();
   QualType CalleeType = Callee->getType();
+
   if (const auto *FnTypePtr = CalleeType->getAs()) {
 CalleeType = FnTypePtr->getPointeeType();
   } else if (const auto *BPT = CalleeType->getAs()) {
@@ -1391,8 +1392,16 @@
 if (isa(Callee->IgnoreParens()))
   return Ctx.VoidTy;
 
+if (isa(Callee->IgnoreParens()))
+  return Ctx.DependentTy;
+
 // This should never be overloaded and so should never return null.
 CalleeType = Expr::findBoundMemberType(Callee);
+assert(!CalleeType.isNull());
+
+  } else if (CalleeType->isDependentType() ||
+ CalleeType->isSpecificPlaceholderType(BuiltinType::Overload)) {
+return Ctx.DependentTy;
   }
 
   const FunctionType *FnType = CalleeType->castAs();


Index: clang/unittests/Tooling/SourceCodeTest.cpp
===
--- clang/unittests/Tooling/SourceCodeTest.cpp
+++ clang/unittests/Tooling/SourceCodeTest.cpp
@@ -621,4 +621,63 @@
   };
   Visitor.runOver(Code);
 }
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedLookupExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+int f_overload(int) { return 1; }
+int f_overload(double) { return 2; }
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+f_overload(p); // UnresolvedLookupExpr
+// CalleeType in getCallReturntype is Overload and not dependent
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
+TEST(SourceCodeTest, GetCallReturnType_Callee_UnresolvedMemberExpr) {
+  llvm::StringRef Code = R"cpp(
+template
+void templ(const T& t, F f) {
+  f(t);
+  // CalleeType in getCallReturntype is Overload and dependent
+}
+
+struct A {
+  void f_overload(int);
+  void f_overload(double);
+};
+
+void f() {
+  int i = 0;
+  templ(i, [](const auto &p) {
+A a;
+a.f_overload(p); // UnresolvedMemberExpr
+// CalleeType in getCallReturntype is BoundMember and has overloads
+  });
+}
+)cpp";
+
+  CallsVisitor Visitor;
+  Visitor.OnCall = [](CallExpr *Expr, ASTContext *Context) {
+// Should not crash.
+(void)Expr->getCallReturnType(*Context);
+  };
+  Visitor.runOver(Code, CallsVisitor::Lang_CXX14);
+}
+
 } // end anonymous namespace
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -1383,6 +1383,7 @@
 QualType C

[PATCH] D99106: [ASTMatchers][NFC] Use SmallVector when building variadic matcher descriptor

2021-03-23 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99106

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


[PATCH] D99193: [PowerPC] Add mprivileged option

2021-03-23 Thread Stefan Pintilie via Phabricator via cfe-commits
stefanp created this revision.
stefanp added a reviewer: nemanjai.
Herald added subscribers: jansvoboda11, dang, shchenz, kbarton, hiraditya.
stefanp requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

Add an option to tell the compiler that it can use privileged instructions.

This patch only adds the option. Backend implementation will be added in a
future patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99193

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/test/Driver/ppc-mprivileged-support-check.c
  clang/test/Preprocessor/init-ppc64.c
  llvm/lib/Target/PowerPC/PPC.td
  llvm/lib/Target/PowerPC/PPCSubtarget.cpp
  llvm/lib/Target/PowerPC/PPCSubtarget.h
  llvm/test/CodeGen/PowerPC/future-check-features.ll

Index: llvm/test/CodeGen/PowerPC/future-check-features.ll
===
--- llvm/test/CodeGen/PowerPC/future-check-features.ll
+++ llvm/test/CodeGen/PowerPC/future-check-features.ll
@@ -1,7 +1,7 @@
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64le-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
-; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect \
+; RUN: llc -mattr=pcrelative-memops,prefix-instrs,paired-vector-memops,mma,rop-protect,privileged \
 ; RUN:   -verify-machineinstrs -mtriple=powerpc64-unknown-unknown \
 ; RUN:   -ppc-asm-full-reg-names %s -o - 2>&1 | FileCheck %s
 
Index: llvm/lib/Target/PowerPC/PPCSubtarget.h
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.h
+++ llvm/lib/Target/PowerPC/PPCSubtarget.h
@@ -113,6 +113,7 @@
   bool HasPCRelativeMemops;
   bool HasMMA;
   bool HasROPProtect;
+  bool HasPrivileged;
   bool HasFCPSGN;
   bool HasFSQRT;
   bool HasFRE, HasFRES, HasFRSQRTE, HasFRSQRTES;
@@ -275,6 +276,7 @@
   bool hasPCRelativeMemops() const { return HasPCRelativeMemops; }
   bool hasMMA() const { return HasMMA; }
   bool hasROPProtect() const { return HasROPProtect; }
+  bool hasPrivileged() const { return HasPrivileged; }
   bool pairedVectorMemops() const { return PairedVectorMemops; }
   bool hasMFOCRF() const { return HasMFOCRF; }
   bool hasISEL() const { return HasISEL; }
Index: llvm/lib/Target/PowerPC/PPCSubtarget.cpp
===
--- llvm/lib/Target/PowerPC/PPCSubtarget.cpp
+++ llvm/lib/Target/PowerPC/PPCSubtarget.cpp
@@ -88,6 +88,7 @@
   HasP9Altivec = false;
   HasMMA = false;
   HasROPProtect = false;
+  HasPrivileged = false;
   HasP10Vector = false;
   HasPrefixInstrs = false;
   HasPCRelativeMemops = false;
Index: llvm/lib/Target/PowerPC/PPC.td
===
--- llvm/lib/Target/PowerPC/PPC.td
+++ llvm/lib/Target/PowerPC/PPC.td
@@ -256,6 +256,10 @@
   SubtargetFeature<"rop-protect", "HasROPProtect", "true",
"Add ROP protect">;
 
+def FeaturePrivileged :
+  SubtargetFeature<"privileged", "HasPrivileged", "true",
+   "Add privileged instructions">;
+
 def FeaturePredictableSelectIsExpensive :
   SubtargetFeature<"predictable-select-expensive",
"PredictableSelectIsExpensive",
Index: clang/test/Preprocessor/init-ppc64.c
===
--- clang/test/Preprocessor/init-ppc64.c
+++ clang/test/Preprocessor/init-ppc64.c
@@ -567,6 +567,7 @@
 // PPCPWR8:#define _ARCH_PWR7 1
 // PPCPWR8:#define _ARCH_PWR8 1
 // PPCPWR8-NOT:#define __ROP_PROTECT__ 1
+// PPCPWR8-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power8 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER8 %s
 //
@@ -585,6 +586,7 @@
 // PPCPOWER8:#define _ARCH_PWR7 1
 // PPCPOWER8:#define _ARCH_PWR8 1
 // PPCPOWER8-NOT:#define __ROP_PROTECT__ 1
+// PPCPOWER8-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu pwr9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPWR9 %s
 //
@@ -600,6 +602,7 @@
 // PPCPWR9:#define _ARCH_PWR7 1
 // PPCPWR9:#define _ARCH_PWR9 1
 // PPCPWR9-NOT:#define __ROP_PROTECT__ 1
+// PPCPWR9-NOT:#define __PRIVILEGED__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu power9 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPCPOWER9 %s
 //
@@ -615,6 +618,7 @@
 // PPCPOWER9:#define _ARCH_PWR7 1
 // PPCPOWER9:#define _ARCH_PWR9 1
 // PPCPOWER9-NOT:#define __ROP_PROTECT__ 1
+// PPCPOWER9-NOT:#define __PRIVILEGED__ 1
 //

[PATCH] D95244: [clang][AST] Handle overload callee type in CallExpr::getCallReturnType.

2021-03-23 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 3 inline comments as done.
balazske added a comment.

Ping.
I am not sure how to the test should be changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95244

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


[PATCH] D98950: [clang][deps] NFC: Document collector, rename members

2021-03-23 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

Thanks for the cleanup. Code makes more sense now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98950

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


[PATCH] D99194: [analyzer] Fix body farm for Obj-C++ properties

2021-03-23 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, xazax.hun, steakhal, ASDenysPetrov.
Herald added subscribers: Charusso, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, kristof.beyls.
vsavchenko requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When property is declared in a superclass (or in a protocol),
it still can be of CXXRecord type and Sema could've already
generated a body for us.  This patch joins two branches and
two ways of acquiring IVar in order to reuse the existing code.
And prevent us from generating l-value to r-value casts for
C++ types.

rdar://67416721


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99194

Files:
  clang/lib/Analysis/BodyFarm.cpp
  clang/test/Analysis/properties.mm

Index: clang/test/Analysis/properties.mm
===
--- clang/test/Analysis/properties.mm
+++ clang/test/Analysis/properties.mm
@@ -77,3 +77,23 @@
 
   clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}
 }
+
+@protocol NoDirectPropertyDecl
+@property IntWrapperStruct inner;
+@end
+@interface NoDirectPropertyDecl 
+@end
+@implementation NoDirectPropertyDecl
+@synthesize inner;
+@end
+
+// rdar://67416721
+void testNoDirectPropertyDecl(NoDirectPropertyDecl *w) {
+  clang_analyzer_eval(w.inner.value == w.inner.value); // expected-warning{{TRUE}}
+
+  int origValue = w.inner.value;
+  if (origValue != 42)
+return;
+
+  clang_analyzer_eval(w.inner.value == 42); // expected-warning{{TRUE}}
+}
Index: clang/lib/Analysis/BodyFarm.cpp
===
--- clang/lib/Analysis/BodyFarm.cpp
+++ clang/lib/Analysis/BodyFarm.cpp
@@ -742,8 +742,9 @@
 
 static Stmt *createObjCPropertyGetter(ASTContext &Ctx,
   const ObjCMethodDecl *MD) {
-// First, find the backing ivar.
+  // First, find the backing ivar.
   const ObjCIvarDecl *IVar = nullptr;
+  const ObjCPropertyDecl *Prop = nullptr;
 
   // Property accessor stubs sometimes do not correspond to any property decl
   // in the current interface (but in a superclass). They still have a
@@ -751,54 +752,56 @@
   if (MD->isSynthesizedAccessorStub()) {
 const ObjCInterfaceDecl *IntD = MD->getClassInterface();
 const ObjCImplementationDecl *ImpD = IntD->getImplementation();
-for (const auto *PI: ImpD->property_impls()) {
-  if (const ObjCPropertyDecl *P = PI->getPropertyDecl()) {
-if (P->getGetterName() == MD->getSelector())
-  IVar = P->getPropertyIvarDecl();
+for (const auto *PI : ImpD->property_impls()) {
+  if (PI->getPropertyDecl()) {
+Prop = PI->getPropertyDecl();
+if (Prop->getGetterName() == MD->getSelector())
+  IVar = Prop->getPropertyIvarDecl();
   }
 }
   }
 
   if (!IVar) {
-const ObjCPropertyDecl *Prop = MD->findPropertyDecl();
+Prop = MD->findPropertyDecl();
 IVar = findBackingIvar(Prop);
-if (!IVar)
-  return nullptr;
+  }
 
-// Ignore weak variables, which have special behavior.
-if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
-  return nullptr;
+  if (!IVar || !Prop)
+return nullptr;
 
-// Look to see if Sema has synthesized a body for us. This happens in
-// Objective-C++ because the return value may be a C++ class type with a
-// non-trivial copy constructor. We can only do this if we can find the
-// @synthesize for this property, though (or if we know it's been auto-
-// synthesized).
-const ObjCImplementationDecl *ImplDecl =
+  // Ignore weak variables, which have special behavior.
+  if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
+return nullptr;
+
+  // Look to see if Sema has synthesized a body for us. This happens in
+  // Objective-C++ because the return value may be a C++ class type with a
+  // non-trivial copy constructor. We can only do this if we can find the
+  // @synthesize for this property, though (or if we know it's been auto-
+  // synthesized).
+  const ObjCImplementationDecl *ImplDecl =
   IVar->getContainingInterface()->getImplementation();
-if (ImplDecl) {
-  for (const auto *I : ImplDecl->property_impls()) {
-if (I->getPropertyDecl() != Prop)
-  continue;
-
-if (I->getGetterCXXConstructor()) {
-  ASTMaker M(Ctx);
-  return M.makeReturn(I->getGetterCXXConstructor());
-}
+  if (ImplDecl) {
+for (const auto *I : ImplDecl->property_impls()) {
+  if (I->getPropertyDecl() != Prop)
+continue;
+
+  if (I->getGetterCXXConstructor()) {
+ASTMaker M(Ctx);
+return M.makeReturn(I->getGetterCXXConstructor());
   }
 }
-
-// Sanity check that the property is the same type as the ivar, or a
-// reference to it, and that it is either an object pointer or triv

[PATCH] D99194: [analyzer] Fix body farm for Obj-C++ properties

2021-03-23 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.
Herald added a subscriber: steakhal.

I'm not familiar with Objective-C.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99194

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


[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



Comment at: flang/test/Semantics/dosemantics03.f90:1-2
 ! RUN: %S/test_errors.sh %s %t %f18 -Mstandard -Werror
+! RUN: %S/test_errors.sh %s %t %flang_fc1 -Werror
 

awarzynski wrote:
> Rather than adding the 2nd line, could you update the first line to use 
> `%flang_fc1` instead of `%f18`?
I am not modifying this test case, as it would create a dependency on 
`-std=f2018` up-streamed (due to this particular test case having dependency on 
language standard).  I create a new test case, we can come back to it later.


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

https://reviews.llvm.org/D98657

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


[PATCH] D98657: [flang][driver] Add options for -Werror

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332692.
arnamoy10 added a comment.

Thanks @awarzynski for the comments.

1. Moving diagnostics options parsing to a separate function
2. Adding a check so that `-Wblah` does not trigger the treatment of warnings 
as werrors, only `-Werror` triggers it
3. Adding a new test case.


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

https://reviews.llvm.org/D98657

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/werror.f90

Index: flang/test/Driver/werror.f90
===
--- /dev/null
+++ flang/test/Driver/werror.f90
@@ -0,0 +1,27 @@
+! Ensure argument -Werror work as expected.
+! TODO: Modify test cases in test/Semantics/ related to f18 when -std= is upstreamed
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang_fc1 -Werror %s  2>&1 | FileCheck %s --check-prefix=WITH
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+
+!-
+! EXPECTED OUTPUT WITH -Werror
+!-
+! WITH: Semantic errors in
+
+!-
+! EXPECTED OUTPUT WITHOUT -Werror
+!-
+! WITHOUT-NOT: Semantic errors in
+
+PROGRAM werror
+REAL, DIMENSION(20, 10) :: A
+FORALL (J=1:N)  A(I, I) = 1
+END PROGRAM werror
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -47,6 +47,7 @@
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
+! HELP-NEXT: -WEnable the specified warning
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
@@ -95,6 +96,7 @@
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
+! HELP-FC1-NEXT: -WEnable the specified warning
 
 !---
 ! EXPECTED ERROR
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -47,6 +47,7 @@
 ! CHECK-NEXT: -o  Write output to 
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHECK-NEXT: --version Print version information
+! CHECK-NEXT: -WEnable the specified warning
 ! CHECK-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -64,7 +64,9 @@
   // Prescan. In case of failure, report and return.
   ci.parsing().Prescan(currentInputPath, parserOptions);
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 const unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not scan %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -97,7 +99,9 @@
   // Prescan. In case of failure, report and return.
   ci.parsing().Prescan(currentInputPath, parserOptions);
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 const unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not scan %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -109,7 +113,9 @@
   // Parse. In case of failure, report and return.
   ci.parsing().Parse(llvm::outs());
 
-  if (ci.parsing().messages().AnyFatalError()) {
+  if (!ci.parsing().messages().empty() &&
+  (ci.invocation().warnAsErr() ||
+  ci.parsing().messages().AnyFatalError())) {
 unsigned diagID = ci.diagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "Could not parse %0");
 ci.diagnostics().Report(diagID) << GetCurrentFileOrBufferName();
@@ -264,7 

[clang] cd4abc5 - [flang][driver] Add -fintrinsic-modules-path option

2021-03-23 Thread Arnamoy Bhattacharyya via cfe-commits

Author: Arnamoy Bhattacharyya
Date: 2021-03-23T12:28:19-04:00
New Revision: cd4abc5242c03804b3d88277b03b52215a899f75

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

LOG: [flang][driver] Add -fintrinsic-modules-path option

Reviewed By: awarzynski

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

Added: 
flang/test/Driver/Inputs/ieee_arithmetic.mod
flang/test/Driver/Inputs/iso_fortran_env.mod
flang/test/Driver/intrinsic_module_path.f90

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Flang.cpp
flang/include/flang/Frontend/PreprocessorOptions.h
flang/lib/Frontend/CompilerInvocation.cpp
flang/test/Driver/driver-help-hidden.f90
flang/test/Driver/driver-help.f90

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2e9d0f53f9a31..25de15f484952 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4256,7 +4256,6 @@ defm f2c : BooleanFFlag<"f2c">, Group;
 defm frontend_optimize : BooleanFFlag<"frontend-optimize">, 
Group;
 defm init_local_zero : BooleanFFlag<"init-local-zero">, Group;
 defm integer_4_integer_8 : BooleanFFlag<"integer-4-integer-8">, 
Group;
-defm intrinsic_modules_path : BooleanFFlag<"intrinsic-modules-path">, 
Group;
 defm max_identifier_length : BooleanFFlag<"max-identifier-length">, 
Group;
 defm module_private : BooleanFFlag<"module-private">, Group;
 defm pack_derived : BooleanFFlag<"pack-derived">, Group;
@@ -4338,6 +4337,10 @@ def fimplicit_none : Flag<["-"], "fimplicit-none">, 
Group,
 def fno_implicit_none : Flag<["-"], "fno-implicit-none">, Group;
 def falternative_parameter_statement : Flag<["-"], 
"falternative-parameter-statement">, Group,
   HelpText<"Enable the old style PARAMETER statement">;
+def fintrinsic_modules_path : Separate<["-"], "fintrinsic-modules-path">,  
Group, MetaVarName<"">,
+  HelpText<"Specify where to find the compiled intrinsic modules">,
+  DocBrief<[{This option specifies the location of pre-compiled intrinsic 
modules, 
+  if they are not in the default location expected by the compiler.}]>;
 }
 
 def J : JoinedOrSeparate<["-"], "J">,

diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 153a1dfc85927..1fa62030b1134 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -42,7 +42,8 @@ void Flang::AddPreprocessingOptions(const ArgList &Args,
 
 void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const 
{
   Args.AddAllArgs(CmdArgs,
-  {options::OPT_module_dir, 
options::OPT_fdebug_module_writer});
+  {options::OPT_module_dir, options::OPT_fdebug_module_writer,
+   options::OPT_fintrinsic_modules_path});
 }
 
 void Flang::ConstructJob(Compilation &C, const JobAction &JA,

diff  --git a/flang/include/flang/Frontend/PreprocessorOptions.h 
b/flang/include/flang/Frontend/PreprocessorOptions.h
index 39ea4d3d3c6cf..3a3877bf0b286 100644
--- a/flang/include/flang/Frontend/PreprocessorOptions.h
+++ b/flang/include/flang/Frontend/PreprocessorOptions.h
@@ -29,6 +29,8 @@ class PreprocessorOptions {
   // consider collecting them in a separate aggregate. For now we keep it here
   // as there is no point creating a class for just one field.
   std::vector searchDirectoriesFromDashI;
+  // Search directories specified by the user with -fintrinsic-modules-path
+  std::vector searchDirectoriesFromIntrModPath;
 
 public:
   PreprocessorOptions() {}
@@ -44,4 +46,4 @@ class PreprocessorOptions {
 
 } // namespace Fortran::frontend
 
-#endif // LLVM_FLANG_PREPROCESSOROPTIONS_H
\ No newline at end of file
+#endif // LLVM_FLANG_PREPROCESSOROPTIONS_H

diff  --git a/flang/lib/Frontend/CompilerInvocation.cpp 
b/flang/lib/Frontend/CompilerInvocation.cpp
index d2318d3d683d2..69c78bde7ff11 100644
--- a/flang/lib/Frontend/CompilerInvocation.cpp
+++ b/flang/lib/Frontend/CompilerInvocation.cpp
@@ -21,6 +21,8 @@
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
 #include "llvm/Option/OptTable.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -285,6 +287,16 @@ static InputKind ParseFrontendArgs(FrontendOptions &opts,
   return dashX;
 }
 
+// Generate the path to look for intrinsic modules
+static std::string getIntrinsicDir() {
+  // TODO: Find a system independent API
+  llvm::SmallString<128> driverPath;
+  driverPath.assign(llvm::sys::fs::getMainExecutable(nullptr, nullptr));
+  llvm::sys::path::remove_filename(driverPath);
+  driverPath.append("/../include/flang/");
+  return std::string(driverPath);
+}
+

[PATCH] D97080: [flang][driver] Add -fintrinsic-modules-path option

2021-03-23 Thread Arnamoy B 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 rGcd4abc5242c0: [flang][driver] Add -fintrinsic-modules-path 
option (authored by Arnamoy Bhattacharyya 
, committed by arnamoy10).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97080

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/PreprocessorOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/Inputs/ieee_arithmetic.mod
  flang/test/Driver/Inputs/iso_fortran_env.mod
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/intrinsic_module_path.f90

Index: flang/test/Driver/intrinsic_module_path.f90
===
--- /dev/null
+++ flang/test/Driver/intrinsic_module_path.f90
@@ -0,0 +1,37 @@
+! Ensure argument -fintrinsic-modules-path works as expected.
+! WITHOUT the option, the default location for the module is checked and no error generated.
+! With the option GIVEN, the module with the same name is PREPENDED, and considered over the
+! default one, causing a CHECKSUM error.
+
+! REQUIRES: new-flang-driver
+
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: %flang-new -fsyntax-only %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fsyntax-only -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang-new -fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: not %flang-new -fc1 -fintrinsic-modules-path %S/Inputs/ %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: 'ieee_arithmetic.mod' was not found
+! WITHOUT-NOT: 'iso_fortran_env.mod' was not found
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: error: Cannot read module file for module 'ieee_arithmetic': File has invalid checksum
+! GIVEN: error: Cannot read module file for module 'iso_fortran_env': File has invalid checksum
+
+
+program test_intrinsic_module_path
+   use ieee_arithmetic, only: ieee_round_type
+   use iso_fortran_env, only: team_type, event_type, lock_type
+end program
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -35,6 +35,8 @@
 ! HELP-NEXT: -ffree-formProcess source files in free form
 ! HELP-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-NEXT: -fintrinsic-modules-path 
+! HELP-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
@@ -83,6 +85,8 @@
 ! HELP-FC1-NEXT: -fget-symbols-sources   Dump symbols and their source code locations
 ! HELP-FC1-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! HELP-FC1-NEXT: -finput-charset= Specify the default character set for source files
+! HELP-FC1-NEXT: -fintrinsic-modules-path 
+! HELP-FC1-NEXT:Specify where to find the compiled intrinsic modules
 ! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! HELP-FC1-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -35,6 +35,8 @@
 ! CHECK-NEXT: -ffree-formProcess source files in free form
 ! CHECK-NEXT: -fimplicit-noneNo implicit typing allowed unless overridden by IMPLICIT statements
 ! CHECK-NEXT: -finput-charset= Specify the default character set for source files
+! CHECK-NEXT: -fintrinsic-modules-path 
+! CHECK-NEXT:Specify where to find the compiled intrinsic modules
 ! CHECK-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics
 ! CHECK-NEXT: -flogical-abbreviations Enable logical abbreviations
 ! CHEC

[PATCH] D98712: [Utils] Support lit-like substitutions in update_cc_test_checks

2021-03-23 Thread Giorgis Georgakoudis via Phabricator via cfe-commits
ggeorgakoudis added inline comments.



Comment at: llvm/utils/update_cc_test_checks.py:228
+  '%t' : tempfile.NamedTemporaryFile().name,
+  '%S' : os.getcwd(),
+}

arichardson wrote:
> Shouldn't this be the directory containing the test? 
You are right, I will submit a patch soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98712

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


[PATCH] D99106: [ASTMatchers][NFC] Use SmallVector when building variadic matcher descriptor

2021-03-23 Thread Nathan James via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8298899e56cd: [ASTMatchers][NFC] Use SmallVector when 
building variadic matcher descriptor (authored by njames93).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99106

Files:
  clang/lib/ASTMatchers/Dynamic/Marshallers.h


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -492,9 +492,11 @@
 VariantMatcher
 variadicMatcherDescriptor(StringRef MatcherName, SourceRange NameRange,
   ArrayRef Args, Diagnostics *Error) {
-  ArgT **InnerArgs = new ArgT *[Args.size()]();
+  SmallVector InnerArgsPtr;
+  InnerArgsPtr.resize_for_overwrite(Args.size());
+  SmallVector InnerArgs;
+  InnerArgs.reserve(Args.size());
 
-  bool HasError = false;
   for (size_t i = 0, e = Args.size(); i != e; ++i) {
 using ArgTraits = ArgTypeTraits;
 
@@ -503,8 +505,7 @@
 if (!ArgTraits::hasCorrectType(Value)) {
   Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
   << (i + 1) << ArgTraits::getKind().asString() << 
Value.getTypeAsString();
-  HasError = true;
-  break;
+  return {};
 }
 if (!ArgTraits::hasCorrectValue(Value)) {
   if (llvm::Optional BestGuess =
@@ -521,24 +522,12 @@
 << (i + 1) << ArgTraits::getKind().asString()
 << Value.getTypeAsString();
   }
-  HasError = true;
-  break;
+  return {};
 }
-
-InnerArgs[i] = new ArgT(ArgTraits::get(Value));
-  }
-
-  VariantMatcher Out;
-  if (!HasError) {
-Out = outvalueToVariantMatcher(Func(llvm::makeArrayRef(InnerArgs,
-   Args.size(;
+InnerArgs.set_size(i + 1);
+InnerArgsPtr[i] = new (&InnerArgs[i]) ArgT(ArgTraits::get(Value));
   }
-
-  for (size_t i = 0, e = Args.size(); i != e; ++i) {
-delete InnerArgs[i];
-  }
-  delete[] InnerArgs;
-  return Out;
+  return outvalueToVariantMatcher(Func(InnerArgsPtr));
 }
 
 /// Matcher descriptor for variadic functions.


Index: clang/lib/ASTMatchers/Dynamic/Marshallers.h
===
--- clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -492,9 +492,11 @@
 VariantMatcher
 variadicMatcherDescriptor(StringRef MatcherName, SourceRange NameRange,
   ArrayRef Args, Diagnostics *Error) {
-  ArgT **InnerArgs = new ArgT *[Args.size()]();
+  SmallVector InnerArgsPtr;
+  InnerArgsPtr.resize_for_overwrite(Args.size());
+  SmallVector InnerArgs;
+  InnerArgs.reserve(Args.size());
 
-  bool HasError = false;
   for (size_t i = 0, e = Args.size(); i != e; ++i) {
 using ArgTraits = ArgTypeTraits;
 
@@ -503,8 +505,7 @@
 if (!ArgTraits::hasCorrectType(Value)) {
   Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
   << (i + 1) << ArgTraits::getKind().asString() << Value.getTypeAsString();
-  HasError = true;
-  break;
+  return {};
 }
 if (!ArgTraits::hasCorrectValue(Value)) {
   if (llvm::Optional BestGuess =
@@ -521,24 +522,12 @@
 << (i + 1) << ArgTraits::getKind().asString()
 << Value.getTypeAsString();
   }
-  HasError = true;
-  break;
+  return {};
 }
-
-InnerArgs[i] = new ArgT(ArgTraits::get(Value));
-  }
-
-  VariantMatcher Out;
-  if (!HasError) {
-Out = outvalueToVariantMatcher(Func(llvm::makeArrayRef(InnerArgs,
-   Args.size(;
+InnerArgs.set_size(i + 1);
+InnerArgsPtr[i] = new (&InnerArgs[i]) ArgT(ArgTraits::get(Value));
   }
-
-  for (size_t i = 0, e = Args.size(); i != e; ++i) {
-delete InnerArgs[i];
-  }
-  delete[] InnerArgs;
-  return Out;
+  return outvalueToVariantMatcher(Func(InnerArgsPtr));
 }
 
 /// Matcher descriptor for variadic functions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8298899 - [ASTMatchers][NFC] Use SmallVector when building variadic matcher descriptor

2021-03-23 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2021-03-23T16:38:45Z
New Revision: 8298899e56cdf89c68215853010352c45398ab10

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

LOG: [ASTMatchers][NFC] Use SmallVector when building variadic matcher 
descriptor

Saves having to manually deallocate storage and keeps InnerArgs will have good 
cache locality.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang/lib/ASTMatchers/Dynamic/Marshallers.h

Removed: 




diff  --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h 
b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
index 3ffa0d6af217..783fb203c408 100644
--- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h
+++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h
@@ -492,9 +492,11 @@ template  Args, Diagnostics *Error) {
-  ArgT **InnerArgs = new ArgT *[Args.size()]();
+  SmallVector InnerArgsPtr;
+  InnerArgsPtr.resize_for_overwrite(Args.size());
+  SmallVector InnerArgs;
+  InnerArgs.reserve(Args.size());
 
-  bool HasError = false;
   for (size_t i = 0, e = Args.size(); i != e; ++i) {
 using ArgTraits = ArgTypeTraits;
 
@@ -503,8 +505,7 @@ variadicMatcherDescriptor(StringRef MatcherName, 
SourceRange NameRange,
 if (!ArgTraits::hasCorrectType(Value)) {
   Error->addError(Arg.Range, Error->ET_RegistryWrongArgType)
   << (i + 1) << ArgTraits::getKind().asString() << 
Value.getTypeAsString();
-  HasError = true;
-  break;
+  return {};
 }
 if (!ArgTraits::hasCorrectValue(Value)) {
   if (llvm::Optional BestGuess =
@@ -521,24 +522,12 @@ variadicMatcherDescriptor(StringRef MatcherName, 
SourceRange NameRange,
 << (i + 1) << ArgTraits::getKind().asString()
 << Value.getTypeAsString();
   }
-  HasError = true;
-  break;
+  return {};
 }
-
-InnerArgs[i] = new ArgT(ArgTraits::get(Value));
-  }
-
-  VariantMatcher Out;
-  if (!HasError) {
-Out = outvalueToVariantMatcher(Func(llvm::makeArrayRef(InnerArgs,
-   Args.size(;
+InnerArgs.set_size(i + 1);
+InnerArgsPtr[i] = new (&InnerArgs[i]) ArgT(ArgTraits::get(Value));
   }
-
-  for (size_t i = 0, e = Args.size(); i != e; ++i) {
-delete InnerArgs[i];
-  }
-  delete[] InnerArgs;
-  return Out;
+  return outvalueToVariantMatcher(Func(InnerArgsPtr));
 }
 
 /// Matcher descriptor for variadic functions.



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


[PATCH] D97119: [flang][driver] Add options for -std=f2018

2021-03-23 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 332703.
arnamoy10 added a comment.

1. Leaning out the "wrong-option" test case
2. Adding aliases in f18 (`-pedantic` and `-std=2018` for `-Mstandard`)


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

https://reviews.llvm.org/D97119

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/std2018.f90
  flang/test/Driver/std2018_wrong.f90
  flang/tools/f18/f18.cpp

Index: flang/tools/f18/f18.cpp
===
--- flang/tools/f18/f18.cpp
+++ flang/tools/f18/f18.cpp
@@ -487,7 +487,8 @@
   options.features.Enable(
   Fortran::common::LanguageFeature::BackslashEscapes, true);
 } else if (arg == "-Mstandard" || arg == "-std=f95" ||
-arg == "-std=f2003" || arg == "-std=f2008" || arg == "-std=legacy") {
+arg == "-std=f2003" || arg == "-std=f2008" || arg == "-std=legacy" ||
+arg == "-std=f2018" || arg == "-pedantic") {
   driver.warnOnNonstandardUsage = true;
 } else if (arg == "-fopenacc") {
   options.features.Enable(Fortran::common::LanguageFeature::OpenACC);
Index: flang/test/Driver/std2018_wrong.f90
===
--- /dev/null
+++ flang/test/Driver/std2018_wrong.f90
@@ -0,0 +1,12 @@
+! REQUIRES: new-flang-driver
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang_fc1 -std=90 %s  2>&1 | FileCheck %s --check-prefix=WRONG
+
+!-
+! EXPECTED OUTPUT WITH WRONG
+!-
+! WRONG: Only -std=f2018 is allowed currently.
Index: flang/test/Driver/std2018.f90
===
--- /dev/null
+++ flang/test/Driver/std2018.f90
@@ -0,0 +1,28 @@
+! Ensure argument -std=f2018 works as expected.
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: %flang_fc1 %s  2>&1 | FileCheck %s --allow-empty --check-prefix=WITHOUT
+! RUN: %flang_fc1 -std=f2018 %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+! RUN: %flang_fc1 -pedantic %s  2>&1 | FileCheck %s --check-prefix=GIVEN
+
+!-
+! EXPECTED OUTPUT WITHOUT
+!-
+! WITHOUT-NOT: A DO loop should terminate with an END DO or CONTINUE
+
+!-
+! EXPECTED OUTPUT WITH
+!-
+! GIVEN: A DO loop should terminate with an END DO or CONTINUE
+
+subroutine foo2()
+do 01 m=1,2
+  select case (m)
+  case default
+print*, "default", m
+  case (1)
+print*, "start"
+01end select
+end subroutine
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -45,6 +45,8 @@
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-NEXT: -module-dir   Put MODULE files in 
 ! HELP-NEXT: -o   Write output to 
+! HELP-NEXT: -pedantic  Warn on language extensions
+! HELP-NEXT: -std=   Language standard to compile for
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
 ! HELP-NEXT: -Xflang   Pass  to the flang compiler
@@ -92,6 +94,8 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -pedantic  Warn on language extensions
+! HELP-FC1-NEXT: -std=   Language standard to compile for
 ! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
Index: flang/test/Driver/driver-help-hidden.f90
===
--- flang/test/Driver/driver-help-hidden.f90
+++ flang/test/Driver/driver-help-hidden.f90
@@ -45,6 +45,8 @@
 ! CHECK-NEXT: -IAdd directory to the end of the list of include search paths
 ! CHECK-NEXT: -module-dir   Put MODULE files in 
 ! CHECK-NEXT: -o  Write output to 
+! CHECK-NEXT: -pedantic  Warn on language extensions
+! CHECK-NEXT: -std=   Language standard to compile for
 ! CHECK-NEXT: -U  Undefine macro 
 ! CHE

[PATCH] D33029: [clang-format] add option for dangling parenthesis

2021-03-23 Thread Jake Harr via Phabricator via cfe-commits
jakar added a comment.

@catskul can you share your changes somehow? If you did, sorry, I'm new to 
Phabricator.

Before I saw @catskul's comment, I rebased @stringham's diff and got the 
existing unit tests to work. But after some experimentation, I found that it 
didn't always behave like I expected. It would sometimes do things like this:

  someFunction(anotherLongFunctionName(arg1, arg2, "this is a description")
  );
  
  void SomeClass::someMemberFunction(const std::string& whatever, int blah
  ) const {
  }

I think it should only break before closing when the matching opening was 
followed by a new line (with possible whitespace or comment).

And it also didn't handle brace-initialized vars consistently:

  LongClassName longVarName1(
somethingElseThatIsLong(arg1, arg2, arg3, arg4),
anotherLongVarName
  );
  
  LongClassName longVarName2{
somethingElseThatIsLong(arg1, arg2, arg3, arg4),
anotherLongVarName};

So I think there is still a bit of work here to be done. And unit tests could 
definitely help.

I can take my best stab at this, when I get time, but I'm honestly not familiar 
with any of it. Any suggestions would be great. Please let me know how I can 
help.

Anyhow, I'm excited about this feature, mostly because I find it more readable, 
but also because it allows consistency with other languages, like Python (see 
PEP8):

  my_list = [
  1, 2, 3,
  4, 5, 6,
  ]
  result = some_function_that_takes_arguments(
  'a', 'b', 'c',
  'd', 'e', 'f',
  )


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

https://reviews.llvm.org/D33029

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


  1   2   >