[clang] a89fb29 - [clang][ItaniumMangle] Check SizeExpr for DependentSizedArrayType

2021-04-02 Thread via cfe-commits

Author: oToToT
Date: 2021-04-02T15:31:20+08:00
New Revision: a89fb29398dc0ce48dfe6f45f99d6ae7df4c6b46

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

LOG: [clang][ItaniumMangle] Check SizeExpr for DependentSizedArrayType
(PR49478)

As ArrayType::ArrayType mentioned in clang/lib/AST/Type.cpp, a
DependentSizedArrayType might not have size expression because it it
used as the type of a dependent array of unknown bound with a dependent
braced initializer.

Thus, I add a check when mangling array of that type.

This should fix https://bugs.llvm.org/show_bug.cgi?id=49478

Reviewed By: Richard Smith - zygoloid

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

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp
clang/unittests/AST/DeclTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 3e6e29207f08c..6415fcab52c1c 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@ void CXXNameMangler::mangleType(const VariableArrayType 
*T) {
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }

diff  --git a/clang/unittests/AST/DeclTest.cpp 
b/clang/unittests/AST/DeclTest.cpp
index 08b1fbb5eb8ae..55d0a3fc065d5 100644
--- a/clang/unittests/AST/DeclTest.cpp
+++ b/clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@ TEST(Decl, AsmLabelAttr) {
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", 
"i386-apple-darwin"});
+  ASTContext &Ctx = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine &Diags = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}



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


[PATCH] D99407: [clang][ItaniumMangle] Check SizeExpr for DependentSizedArrayType (PR49478)

2021-04-02 Thread Tommy Chiang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa89fb29398dc: [clang][ItaniumMangle] Check SizeExpr for 
DependentSizedArrayType (authored by oToToT).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99407

Files:
  clang/lib/AST/ItaniumMangle.cpp
  clang/unittests/AST/DeclTest.cpp


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", 
"i386-apple-darwin"});
+  ASTContext &Ctx = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine &Diags = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }


Index: clang/unittests/AST/DeclTest.cpp
===
--- clang/unittests/AST/DeclTest.cpp
+++ clang/unittests/AST/DeclTest.cpp
@@ -104,3 +104,37 @@
   ASSERT_TRUE(0 == MangleF.compare("\x01" "foo"));
   ASSERT_TRUE(0 == MangleG.compare("goo"));
 }
+
+TEST(Decl, MangleDependentSizedArray) {
+  StringRef Code = R"(
+template 
+int A[] = {N...};
+
+template 
+struct S {
+  T B[N];
+};
+  )";
+  auto AST =
+  tooling::buildASTFromCodeWithArgs(Code, {"-target", "i386-apple-darwin"});
+  ASTContext &Ctx = AST->getASTContext();
+  assert(Ctx.getTargetInfo().getDataLayout().getGlobalPrefix() &&
+ "Expected target to have a global prefix");
+  DiagnosticsEngine &Diags = AST->getDiagnostics();
+
+  const auto *DeclA =
+  selectFirst("A", match(varDecl().bind("A"), Ctx));
+  const auto *DeclB =
+  selectFirst("B", match(fieldDecl().bind("B"), Ctx));
+
+  std::string MangleA, MangleB;
+  llvm::raw_string_ostream OS_A(MangleA), OS_B(MangleB);
+  std::unique_ptr MC(
+  ItaniumMangleContext::create(Ctx, Diags));
+
+  MC->mangleTypeName(DeclA->getType(), OS_A);
+  MC->mangleTypeName(DeclB->getType(), OS_B);
+
+  ASSERT_TRUE(0 == MangleA.compare("_ZTSA_i"));
+  ASSERT_TRUE(0 == MangleB.compare("_ZTSAT0__T_"));
+}
Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3204,7 +3204,11 @@
 }
 void CXXNameMangler::mangleType(const DependentSizedArrayType *T) {
   Out << 'A';
-  mangleExpression(T->getSizeExpr());
+  // A DependentSizedArrayType might not have size expression as below
+  //
+  // template int arr[] = {N...};
+  if (T->getSizeExpr())
+mangleExpression(T->getSizeExpr());
   Out << '_';
   mangleType(T->getElementType());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D80344: [Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 1

2021-04-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/include/clang/Driver/Options.td:886
   HelpText<"Enable C++ exceptions">, Flags<[CC1Option]>;
+def fasync_exceptions: Flag<["-"], "fasync-exceptions">, Group,
+  HelpText<"Enable EH Asynchronous exceptions">, Flags<[CC1Option]>;

Can you rebase and use the new option marshalling infrastructure instead?

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80344

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


[PATCH] D91950: [clang-format] Add BreakBeforeInlineASMColon configuration

2021-04-02 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko updated this revision to Diff 334918.
anastasiia_lukianenko edited the summary of this revision.

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

https://reviews.llvm.org/D91950

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5069,6 +5069,26 @@
 format(Input, Style));
 }
 
+TEST_F(FormatTest, BreakBeforeInlineASMColon) {
+  FormatStyle Style = getLLVMStyle();
+
+  Style.BreakBeforeInlineASMColon = false;
+  verifyFormat("asm volatile(\"string\", : : val);",
+   Style);
+  verifyFormat("asm volatile(\"string\", : val1 : val2);",
+   Style);
+
+  Style.BreakBeforeInlineASMColon = true;
+  verifyFormat("asm volatile(\"string\",\n"
+   " :\n"
+   " : val);",
+   Style);
+  verifyFormat("asm volatile(\"string\",\n"
+   " : val1\n"
+   " : val2);",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3514,6 +3514,9 @@
   const FormatToken &Left = *Right.Previous;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
+  if (Line.startsWith(tok::kw_asm) && Right.is(TT_InlineASMColon) &&
+  Style.BreakBeforeInlineASMColon)
+return true;
 
   if (Style.isCSharp()) {
 if (Right.is(TT_CSharpNamedArgumentColon) ||
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -554,6 +554,9 @@
 Style.BreakInheritanceList == FormatStyle::BILS_BeforeColon)
   Style.BreakInheritanceList = FormatStyle::BILS_BeforeComma;
 
+IO.mapOptional("BreakBeforeInlineASMColon",
+   Style.BreakBeforeInlineASMColon);
+
 IO.mapOptional("BreakBeforeTernaryOperators",
Style.BreakBeforeTernaryOperators);
 
@@ -940,6 +943,7 @@
   LLVMStyle.BinPackParameters = true;
   LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
   LLVMStyle.BreakBeforeConceptDeclarations = true;
+  LLVMStyle.BreakBeforeInlineASMColon = false;
   LLVMStyle.BreakBeforeTernaryOperators = true;
   LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
   LLVMStyle.BraceWrapping = {/*AfterCaseLabel=*/false,
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -1685,6 +1685,18 @@
   /// \endcode
   bool BreakBeforeConceptDeclarations;
 
+  /// If ``true``, colons in ASM parameters will be placed after line breaks.
+  /// \code
+  ///true:
+  ///asm volatile("string",
+  /// :
+  /// : val);
+  ///
+  ///false:
+  ///asm volatile("string", : : val);
+  /// \endcode
+  bool BreakBeforeInlineASMColon;
+
   /// If ``true``, ternary operators will be placed after line breaks.
   /// \code
   ///true:
@@ -3184,6 +3196,7 @@
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations &&
+   BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
BreakConstructorInitializers == R.BreakConstructorInitializers &&
CompactNamespaces == R.CompactNamespaces &&
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -1899,7 +1899,18 @@
   * ``BS_Custom`` (in configuration: ``Custom``)
 Configure each individual brace in `BraceWrapping`.
 
+**BreakBeforeInlineASMColon** (``bool``)
+  If ``true``, colons in ASM parameters will be placed after line breaks.
 
+  .. code-block:: c
+
+ true:
+  asm volatile("string",
+   :
+   : val);
+
+ false:
+  asm volatile("string", : : val);
 
 **BreakBeforeConceptDeclarations** (``bool``)
   If ``true``, concept will be placed on a new line.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https:/

[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-04-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, rjmccall, rsmith, erichkeane, nikic.
lebedev.ri added a project: LLVM.
Herald added a subscriber: lxfind.
lebedev.ri requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

As it is being noted in D99249 , lack of 
alignment information on `this` has been preventing LICM from happening.
For some time now, lack of alignment attribute does *not* imply natural 
alignment, but an alignment of `1`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99790

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/attr-nomerge.cpp
  clang/test/CodeGenCXX/this-nonnull.cpp
  clang/test/CodeGenCoroutines/coro-symmetric-transfer-01.cpp
  clang/test/CodeGenObjCXX/objc-struct-cxx-abi.mm
  clang/test/OpenMP/irbuilder_for_iterator.cpp
  clang/test/OpenMP/irbuilder_for_rangefor.cpp
  clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected

Index: clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
===
--- clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
+++ clang/test/utils/update_cc_test_checks/Inputs/basic-cplusplus.cpp.expected
@@ -35,7 +35,7 @@
 // CHECK-NEXT:store i32 [[X:%.*]], i32* [[X_ADDR]], align 4
 // CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* [[X_ADDR]], align 4
-// CHECK-NEXT:call void @_ZN3FooC2Ei(%class.Foo* nonnull dereferenceable(4) [[THIS1]], i32 [[TMP0]])
+// CHECK-NEXT:call void @_ZN3FooC2Ei(%class.Foo* nonnull align 4 dereferenceable(4) [[THIS1]], i32 [[TMP0]])
 // CHECK-NEXT:ret void
 //
 Foo::Foo(int x) : x(x) {}
@@ -44,7 +44,7 @@
 // CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca %class.Foo*, align 8
 // CHECK-NEXT:store %class.Foo* [[THIS:%.*]], %class.Foo** [[THIS_ADDR]], align 8
 // CHECK-NEXT:[[THIS1:%.*]] = load %class.Foo*, %class.Foo** [[THIS_ADDR]], align 8
-// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* nonnull dereferenceable(4) [[THIS1]]) #[[ATTR3:[0-9]+]]
+// CHECK-NEXT:call void @_ZN3FooD2Ev(%class.Foo* nonnull align 4 dereferenceable(4) [[THIS1]]) #[[ATTR3:[0-9]+]]
 // CHECK-NEXT:ret void
 //
 Foo::~Foo() {}
@@ -67,10 +67,10 @@
 // CHECK-LABEL: @main(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[F:%.*]] = alloca [[CLASS_FOO:%.*]], align 4
-// CHECK-NEXT:call void @_ZN3FooC1Ei(%class.Foo* nonnull dereferenceable(4) [[F]], i32 1)
-// CHECK-NEXT:[[CALL:%.*]] = call i32 @_ZNK3Foo23function_defined_inlineEi(%class.Foo* nonnull dereferenceable(4) [[F]], i32 2)
-// CHECK-NEXT:[[CALL1:%.*]] = call i32 @_ZNK3Foo28function_defined_out_of_lineEi(%class.Foo* nonnull dereferenceable(4) [[F]], i32 3)
-// CHECK-NEXT:call void @_ZN3FooD1Ev(%class.Foo* nonnull dereferenceable(4) [[F]]) #[[ATTR3]]
+// CHECK-NEXT:call void @_ZN3FooC1Ei(%class.Foo* nonnull align 4 dereferenceable(4) [[F]], i32 1)
+// CHECK-NEXT:[[CALL:%.*]] = call i32 @_ZNK3Foo23function_defined_inlineEi(%class.Foo* nonnull align 4 dereferenceable(4) [[F]], i32 2)
+// CHECK-NEXT:[[CALL1:%.*]] = call i32 @_ZNK3Foo28function_defined_out_of_lineEi(%class.Foo* nonnull align 4 dereferenceable(4) [[F]], i32 3)
+// CHECK-NEXT:call void @_ZN3FooD1Ev(%class.Foo* nonnull align 4 dereferenceable(4) [[F]]) #[[ATTR3]]
 // CHECK-NEXT:ret i32 0
 //
 int main() {
Index: clang/test/OpenMP/irbuilder_for_rangefor.cpp
===
--- clang/test/OpenMP/irbuilder_for_rangefor.cpp
+++ clang/test/OpenMP/irbuilder_for_rangefor.cpp
@@ -34,7 +34,7 @@
 
 #endif // HEADER
 // CHECK-LABEL: define {{[^@]+}}@workshareloop_rangefor
-// CHECK-SAME: (float* [[A:%.*]], float* [[B:%.*]], float* [[C:%.*]]) [[ATTR0:#.*]] {
+// CHECK-SAME: (float* [[A:%.*]], float* [[B:%.*]], float* [[C:%.*]]) #[[ATTR0:[0-9]+]] {
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[A_ADDR:%.*]] = alloca float*, align 8
 // CHECK-NEXT:[[B_ADDR:%.*]] = alloca float*, align 8
@@ -54,20 +54,20 @@
 // CHECK-NEXT:store float* [[A]], float** [[A_ADDR]], align 8
 // CHECK-NEXT:store float* [[B]], float** [[B_ADDR]], align 8
 // CHECK-NEXT:store float* [[C]], float** [[C_ADDR]], align 8
-// CHECK-NEXT:call void @_ZN7MyRangeC1Ei(%struct.MyRange* nonnull dereferenceable(1) [[REF_TMP]], i32 42)
+// CHECK-NEXT:call void @_ZN7MyRangeC1Ei(%struct.MyRange* nonnull align 1 dereferenceable(1) [[REF_TMP]], i32 42)
 // CHECK-NEXT:store %struct.MyRange* [[REF_TMP]], %struct.MyRange** [[__RANGE2]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load %struct.MyRange*, %struct.MyRange** [[__RANGE2]], align 8
-// CHECK-NEXT:call void @_ZN7MyRange5beginEv(%struct.MyIterator* sret(%struct.MyIterator) align 1 [[__BEGIN2]], %struct.MyRange* nonnull

[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-04-02 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2314
+  llvm::Align Alignment =
+  getNaturalTypeAlignment(ThisTy, /*BaseInfo=*/nullptr,
+  /*TBAAInfo=*/nullptr,

Shouldn't the alignment also be valid for non-zero address spaces?


This reminds me that I need to upstream our local CHERI changes to take the 
branch for all address spaces with an all-zero null pointer representation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[PATCH] D99791: [CGCall] Annotate pointer argument with alignment

2021-04-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, rjmccall, rsmith, erichkeane, 
aaron.ballman, nikic.
lebedev.ri added a project: LLVM.
lebedev.ri requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Same idea as D99790 .

As it is being noted in D99249 , lack of 
alignment information on this has been preventing LICM from happening.
For some time now, lack of alignment attribute does *not* imply natural 
alignment, but an alignment of 1.

This causes quite a bit of clang tests to tail:

  Testing Time: 167.48s
Unsupported  :69
Passed   : 27038
Expectedly Failed:29
Failed   :   370
  FAILED: tools/clang/test/CMakeFiles/check-clang 

so before i go mad updating each one of them,
is this generally correct, or are we not allowed to do this?
Are there some further preconditions missing?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99791

Files:
  clang/lib/CodeGen/CGCall.cpp


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2445,6 +2445,15 @@
   }
 }
 
+if (const auto *PtrTy = ParamType->getAs()) {
+  QualType PTy = PtrTy->getPointeeType();
+  if (PTy->isObjectType()) {
+llvm::Align Alignment =
+getNaturalPointeeTypeAlignment(ParamType).getAsAlign();
+Attrs.addAlignmentAttr(Alignment);
+  }
+}
+
 switch (FI.getExtParameterInfo(ArgNo).getABI()) {
 case ParameterABI::Ordinary:
   break;


Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -2445,6 +2445,15 @@
   }
 }
 
+if (const auto *PtrTy = ParamType->getAs()) {
+  QualType PTy = PtrTy->getPointeeType();
+  if (PTy->isObjectType()) {
+llvm::Align Alignment =
+getNaturalPointeeTypeAlignment(ParamType).getAsAlign();
+Attrs.addAlignmentAttr(Alignment);
+  }
+}
+
 switch (FI.getExtParameterInfo(ArgNo).getABI()) {
 case ParameterABI::Ordinary:
   break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99790: [CGCall] Annotate `this` argument with alignment

2021-04-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2314
+  llvm::Align Alignment =
+  getNaturalTypeAlignment(ThisTy, /*BaseInfo=*/nullptr,
+  /*TBAAInfo=*/nullptr,

arichardson wrote:
> Shouldn't the alignment also be valid for non-zero address spaces?
> 
> 
> This reminds me that I need to upstream our local CHERI changes to take the 
> branch for all address spaces with an all-zero null pointer representation.
> Shouldn't the alignment also be valid for non-zero address spaces?

Probably. It should also be fine when null pointer is valid.
If other reviewers agree i can do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99790

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


[PATCH] D99488: [SYCL][Doc] Add address space handling section to SYCL documentation

2021-04-02 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 334927.
bader marked 4 inline comments as done.
bader added a comment.

Address comments from @Anastasia.

- Removed controversial clarifications.
- Reshuffled text to keep language semantics clarifications closer to each 
other.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99488

Files:
  clang/docs/SYCLSupport.rst


Index: clang/docs/SYCLSupport.rst
===
--- clang/docs/SYCLSupport.rst
+++ clang/docs/SYCLSupport.rst
@@ -219,3 +219,92 @@
 
 Additional details of kernel parameter passing may be found in the document
 `SYCL Kernel Parameter Handling and Array Support 
`_.
+
+Address space handling
+^^
+
+The SYCL specification represents pointers to disjoint memory regions using C++
+wrapper classes on an accelerator to enable compilation with a standard C++
+toolchain and a SYCL compiler toolchain. Section 3.8.2 of SYCL 2020
+specification defines
+`memory model 
`_\
 ,
+section 4.7.7 - `address space classes 
`_
+and section 5.9 covers `address space deduction 
`_.
+The SYCL specification allows two modes of address space deduction: "generic as
+default address space" (see section 5.9.3) and "inferred address space" (see
+section 5.9.4). Current implementation supports only "generic as default 
address
+space" mode.
+
+SYCL borrows its memory model from OpenCL however SYCL doesn't perform
+the address space qualifier inference as detailed in
+`OpenCL C v3.0 6.7.8 
`_.
+
+The default address space is "generic-memory", which is a virtual address space
+that overlaps the global, local, and private address spaces. SYCL mode enables
+both explicit and implicit conversion to/from the default address space from/to
+the address space-attributed type. All named address spaces are disjoint and
+sub-sets of default address space.
+
+The SPIR target allocates SYCL namespace scope variables in the global address
+space.
+
+Pointers to default address space should get lowered into a pointer to a 
generic
+address space (or flat to reuse more general terminology). But depending on the
+allocation context, the default address space of a non-pointer type is assigned
+to a specific address space. This is described in
+https://www.khronos.org/registry/SYCL/specs/sycl-2020/html/sycl-2020.html#subsec:commonAddressSpace.
+
+This is also in line with the behaviour of CUDA (small example
+https://godbolt.org/z/veqTfo9PK).
+
+``multi_ptr`` class implementation example:
+
+.. code-block:: C++
+
+   // check that SYCL mode is ON and we can use non-standard decorations
+   #if defined(__SYCL_DEVICE_ONLY__)
+   // GPU/accelerator implementation
+   template  class multi_ptr {
+ // DecoratedType applies corresponding address space attribute to the 
type T
+ // DecoratedType::type == 
"__attribute__((opencl_global)) T"
+ // See sycl/include/CL/sycl/access/access.hpp for more details
+ using pointer_t = typename DecoratedType::type *;
+
+ pointer_t m_Pointer;
+ public:
+ pointer_t get() { return m_Pointer; }
+ T& operator* () { return *reinterpret_cast(m_Pointer); }
+   }
+   #else
+   // CPU/host implementation
+   template  class multi_ptr {
+ T *m_Pointer; // regular undecorated pointer
+ public:
+ T *get() { return m_Pointer; }
+ T& operator* () { return *m_Pointer; }
+   }
+   #endif
+
+Depending on the compiler mode, ``multi_ptr`` will either decorate its internal
+data with the address space attribute or not.
+
+To utilize clang's existing functionality, we reuse the following OpenCL 
address
+space attributes for pointers:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Address space attribute
+ - SYCL address_space enumeration
+   * - ``__attribute__((opencl_global))``
+ - global_space, constant_space
+   * - ``__attribute__((opencl_local))``
+ - local_space
+   * - ``__attribute__((opencl_private))``
+ - private_space
+
+
+.. code-block::
+
+   TODO: add support for `__attribute__((opencl_global_host))` and
+   `__attribute__((opencl_global_device))`.


Index: clang/docs/SYCLSupport.rst
===
--- clang/docs/SYCLSupport.rst
+++ clang/docs/SYCLSupport.rst
@@ -219,3 +219,92 @@
 
 Additional details of kernel parameter passing may be found in the document
 `SYCL Kernel Parameter Handling and Array Support 

[PATCH] D99488: [SYCL][Doc] Add address space handling section to SYCL documentation

2021-04-02 Thread Alexey Bader via Phabricator via cfe-commits
bader marked 4 inline comments as done.
bader added inline comments.



Comment at: clang/docs/SYCLSupport.rst:243
+Similar to other single-source C++-based GPU programming modes like
+OpenMP/CUDA/HIP, SYCL uses clang's "default" address space for types with no
+explicit address space attribute. This design has two important features: it

Anastasia wrote:
> This is ambiguous now because every language will use `clang's "default" 
> address space` because at least one address space is always needed by every 
> language but it has different semantics in languages. We should either 
> attempt to describe it somehow or perhaps just point out that it is inherited 
> from CUDA and currently undocumented.
Removed this paragraph as it's already covered by SYCL specification.



Comment at: clang/docs/SYCLSupport.rst:341
+that overlaps the global, local, and private address spaces. SYCL mode enables
+conversion to/from the default address space from/to the address
+space-attributed type.

Anastasia wrote:
> Do you mean both implicit and explicit conversions? Does it mean that in your 
> AS model named ASes are subset of generic AS and generic AS is a subset of 
> named ASes so they are equivalent sets? It is probably good to mention here 
> that all named address spaces are disjoint.
> Do you mean both implicit and explicit conversions? Does it mean that in your 
> AS model named ASes are subset of generic AS and generic AS is a subset of 
> named ASes so they are equivalent sets? It is probably good to mention here 
> that all named address spaces are disjoint.

Updated paragraph:

The default address space is "generic-memory", which is a virtual address space
that overlaps the global, local, and private address spaces. SYCL mode enables
both explicit and implicit conversion to/from the default address space from/to
the address space-attributed type. All named address spaces are disjoint and
sub-sets of default address space.



Comment at: clang/docs/SYCLSupport.rst:344
+
+The SPIR target allocates SYCL namespace scope variables in the global address
+space.

Anastasia wrote:
> Interesting, will this deduction always be target specific or can it be 
> generalized since it is governed by the language semantic already?
> Interesting, will this deduction always be target specific or can it be 
> generalized since it is governed by the language semantic already?

It's target specific deduction. CPU targets doesn't require such deduction.



Comment at: clang/docs/SYCLSupport.rst:347
+
+Pointers to Default address space should get lowered into a pointer to a 
generic
+address space (or flat to reuse more general terminology). But depending on the

Anastasia wrote:
> I think it is also relevant to highlight that you don't perform inference of 
> the address space qualifiers and the memory segment binding is performed as a 
> final phase of parsing. This is quite relevant since embedded C or C++ have 
> no address space inference at all and OpenCL explicitly requires inference in 
> the type qualifiers.
> I think it is also relevant to highlight that you don't perform inference of 
> the address space qualifiers and the memory segment binding is performed as a 
> final phase of parsing. This is quite relevant since embedded C or C++ have 
> no address space inference at all and OpenCL explicitly requires inference in 
> the type qualifiers.

I move this paragraph before the code example right after this section:

SYCL borrows its memory model from OpenCL however SYCL doesn't perform
the address space qualifier inference as detailed in
`OpenCL C v3.0 6.7.8 
`_.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99488

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


[PATCH] D93822: [clang-tidy] Add check for implicit widening of multiplication result

2021-04-02 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 334929.
lebedev.ri marked 5 inline comments as done.
lebedev.ri added a comment.

Addressed review comments.
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93822

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
  
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone-implicit-widening-of-multiplication-result.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-array-subscript-expression.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-char.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-int.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-pointer-offset.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-implicit-widening-of-multiplication-result-short.cpp
  clang/include/clang/AST/ASTContext.h
  clang/lib/AST/ASTContext.cpp

Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -10097,7 +10097,8 @@
 return getVectorType(getCorrespondingUnsignedType(VTy->getElementType()),
  VTy->getNumElements(), VTy->getVectorKind());
 
-  // For enums, we return the unsigned version of the base type.
+  // For enums, get the underlying integer type of the enum, and let the general
+  // integer type signchanging code handle it.
   if (const auto *ETy = T->getAs())
 T = ETy->getDecl()->getIntegerType();
 
@@ -10150,6 +10151,70 @@
   }
 }
 
+QualType ASTContext::getCorrespondingSignedType(QualType T) const {
+  assert((T->hasUnsignedIntegerRepresentation() ||
+  T->isUnsignedFixedPointType()) &&
+ "Unexpected type");
+
+  // Turn <4 x unsigned int> -> <4 x signed int>
+  if (const auto *VTy = T->getAs())
+return getVectorType(getCorrespondingSignedType(VTy->getElementType()),
+ VTy->getNumElements(), VTy->getVectorKind());
+
+  // For enums, get the underlying integer type of the enum, and let the general
+  // integer type signchanging code handle it.
+  if (const auto *ETy = T->getAs())
+T = ETy->getDecl()->getIntegerType();
+
+  switch (T->castAs()->getKind()) {
+  case BuiltinType::Char_U:
+  case BuiltinType::UChar:
+return SignedCharTy;
+  case BuiltinType::UShort:
+return ShortTy;
+  case BuiltinType::UInt:
+return IntTy;
+  case BuiltinType::ULong:
+return LongTy;
+  case BuiltinType::ULongLong:
+return LongLongTy;
+  case BuiltinType::UInt128:
+return Int128Ty;
+  // wchar_t is special. It is either unsigned or not, but when it's unsigned,
+  // there's no matching "signed wchar_t". Therefore we return the signed
+  // version of it's underlying type instead.
+  case BuiltinType::WChar_U:
+return getSignedWCharType();
+
+  case BuiltinType::UShortAccum:
+return ShortAccumTy;
+  case BuiltinType::UAccum:
+return AccumTy;
+  case BuiltinType::ULongAccum:
+return LongAccumTy;
+  case BuiltinType::SatUShortAccum:
+return SatShortAccumTy;
+  case BuiltinType::SatUAccum:
+return SatAccumTy;
+  case BuiltinType::SatULongAccum:
+return SatLongAccumTy;
+  case BuiltinType::UShortFract:
+return ShortFractTy;
+  case BuiltinType::UFract:
+return FractTy;
+  case BuiltinType::ULongFract:
+return LongFractTy;
+  case BuiltinType::SatUShortFract:
+return SatShortFractTy;
+  case BuiltinType::SatUFract:
+return SatFractTy;
+  case BuiltinType::SatULongFract:
+return SatLongFractTy;
+  default:
+llvm_unreachable("Unexpected unsigned integer or fixed point type");
+  }
+}
+
 ASTMutationListener::~ASTMutationListener() = default;
 
 void ASTMutationListener::DeducedReturnType(const FunctionDecl *FD,
Index: clang/include/clang/AST/ASTContext.h
===
--- clang/include/clang/AST/ASTContext.h
+++ clang/include/clang/AST/ASTContext.h
@@ -2748,6 +2748,14 @@
   // a given fixed point type.
   QualType getCorrespondingUnsignedType(QualType T) const;
 
+  // Per C99 6.2.5p6, for every signed integer type, there is a corresponding
+  // unsigned integer type.  This method takes an unsigned type, and returns the
+  // corresponding signed integer type.
+  // With the introduction of fixed point types in ISO N1169, this method also
+  // accepts fixed point types and returns the corresponding signed type for
+  // a given fixe

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

2021-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok updated this revision to Diff 334931.
alok added a comment.

Updated testcase to use option "-O0", earlier default option was being used 
instead.


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

https://reviews.llvm.org/D99160

Files:
  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,317 @@
+;; This test checks if DW_TAG_GNU_call_site_parameter is generated for fastIsel.
+; REQUIRES: x86_64-linux
+;RUN: llc -O0 -mtriple=x86_64-pc-linux-gnu -emit-call-site-info -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
+
+;; This should be genenerated now.
+;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 was already being generated.
+;CHECK: DW_OP_GNU_entry_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
+
+define void @foo_(i64* noalias %array, i64* noalias %"array$sd") !dbg !15 {
+L.entry:
+  %z_b_1_350 = alloca i64, align 8
+  %z_b_2_351 = alloca i64, align 8
+  %z_b_4_352 = alloca i64, align 8
+  %z_b_6_354 = alloca i64, align 8
+  %.dY0001_373 = alloca i64, align 8
+  %"i$a_368" = alloca i64, align 8
+  %.dY0002_376 = alloca i64, align 8
+  %"i$b_369" = alloca i64, align 8
+  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 = bitcast i64* %"array$sd" to i8*
+  %1 = getelementptr i8, i8* %0, i64 88
+  %2 = bitcast i8* %1 to i64*
+  %3 = load i64, i64* %2, align 8
+  call void @llvm.dbg.declare(metadata i64* %z_b_1_350, metadata !21, metadata !DIExpression()), !dbg !29
+  store i64 %3, i64* %z_b_1_350, align 8
+  %4 = bitcast i64* %"array$sd" to i8*
+  %5 = getelementptr i8, i8* %4, i64 160
+  %6 = bitcast i8* %5 to i64*
+  %7 = load i64, i64* %6, align 8
+  call void @llvm.dbg.declare(metadata i64* %z_b_2_351, metadata !35, metadata !DIExpression()), !dbg !29
+  store i64 %7, i64* %z_b_2_351, align 8
+  %8 = bitcast i64* %"array$sd" to i8*
+  %9 = getelementptr i8, i8* %8, i64 136
+  %10 = bitcast i8* %9 to i64*
+  %11 = load i64, i64* %10, align 8
+  call void @llvm.dbg.declare(metadata i64* %z_b_4_352, metadata !24, metadata !DIExpression()), !dbg !29
+  store i64 %11, i64* %z_b_4_352, align 8
+  %12 = bitcast i64* %"array$sd" to i8*
+  %13 = getelementptr i8, i8* %12, i64 56
+  %14 = bitcast i8* %13 to i64*
+  %15 = load i64, i64* %14, align 8
+  %16 = bitcast i64* %"array$sd" to i8*
+  %17 = getelementptr i8, i8* %16, i64 160
+  %18 = bitcast i8* %17 to i64*
+  %19 = load i64, i64* %18, align 8
+  %20 = bitcast i64* %"array$sd" to i8*
+  %21 = getelementptr i8, i8* %20, i64 128
+  %22 = bitcast i8* %21 to i64*
+  %23 = load i64, i64* %22, align 8
+  %24 = sub nsw i64 %23, 1
+  %25 = mul nsw i64 %19, %24
+  %26 = bitcast i64* %"array$sd" to i8*
+  %27 = getelementptr i8, i8* %26, i64 80
+  %28 = bitcast i8* %27 to i64*
+  %29 = load i64, i64* %28, align 8
+  %30 = sub nsw i64 %29, 1
+  %31 = add nsw i64 %25, %30
+  %32 = add nsw i64 %15, %31
+  call void @llvm.dbg.declare(metadata i64* %z_b_6_354, metadata !36, metadata !DIExpression()), !dbg !29
+  store i64 %32, i64* %z_b_6_354, align 8
+  %33 = load i64, i64* %z_b_4_352, align 8, !dbg !37
+  call void @llvm.dbg.declare(metadata i64* %z_b_4_352, metadata !38, metadata !DIExpression()), !dbg !29
+  store i64 %33, i64* %.dY0001_373, align 8, !dbg !37
+  call void @llvm.dbg.declare(metadata i64* %"i$a_368", metadata !39, metadata !DIExpression()), !dbg !29
+  store i64 1, i64* %"i$a_368", alig

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

2021-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D99160#2665580 , @probinson wrote:

> FastISel is normally used only at -O0, I wouldn't expect any parameters to be 
> optimized out at -O0.
> The test is running llc with default optimization, which is -O2, and forcing 
> fast-isel; this is not a usual combination and I wouldn't expect us to spend 
> any effort making sure debug info works well with that combination.
>
> If flang is forcing fast-isel even with optimization, that sounds like a 
> problem for flang to solve, not LLVM.

Thanks for your comments. I am sorry as the earlier used options in test case 
were more confusing than helpful. I have changed that now.
The updated testcase at "-O0" with FastISel does have optimized out parameter, 
this is because generation of "DW_OP_GNU_entry_value" is enabled starting from 
"-O0". This causes llvm to generate it whenever it gets opportunity (more local 
variables to preserve may be the reason). 
The concern here is only DW_OP_GNU_entry_value is not sufficient and should be 
supported with "DW_TAG_GNU_call_site_parameter", which I tried in current patch.


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


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

2021-04-02 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D99160#2666066 , @alok wrote:

> In D99160#2665580 , @probinson wrote:
>
>> FastISel is normally used only at -O0, I wouldn't expect any parameters to 
>> be optimized out at -O0.
>> The test is running llc with default optimization, which is -O2, and forcing 
>> fast-isel; this is not a usual combination and I wouldn't expect us to spend 
>> any effort making sure debug info works well with that combination.
>>
>> If flang is forcing fast-isel even with optimization, that sounds like a 
>> problem for flang to solve, not LLVM.
>
> Thanks for your comments. I am sorry as the earlier used options in test case 
> were more confusing than helpful. I have changed that now.
> The updated testcase at "-O0" with FastISel does have optimized out 
> parameter, this is because generation of "DW_OP_GNU_entry_value" is enabled 
> starting from "-O0". This causes llvm to generate it whenever it gets 
> opportunity (more local variables to preserve may be the reason). 
> The concern here is only DW_OP_GNU_entry_value is not sufficient and should 
> be supported with "DW_TAG_GNU_call_site_parameter", which I tried in current 
> patch.



> "DW_OP_GNU_entry_value" is enabled starting from "-O0".

I am wondering if this is true...


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] 0f7bbbc - Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-04-02 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2021-04-02T10:55:22+01:00
New Revision: 0f7bbbc481e20a152c74bc315f8995b62d54c8c0

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

LOG: Always emit error for wrong interfaces to scalable vectors, unless cmdline 
flag is passed.

In order to bring up scalable vector support in LLVM incrementally,
we introduced behaviour to emit a warning, instead of an error, when
asking the wrong question of a scalable vector, like asking for the
fixed number of elements.

This patch puts that behaviour under a flag. The default behaviour is
that the compiler will always error, which means that all LLVM unit
tests and regression tests will now fail when a code-path is taken that
still uses the wrong interface.

The behaviour to demote an error to a warning can be individually enabled
for tools that want to support experimental use of scalable vectors.
This patch enables that behaviour when driving compilation from Clang.
This means that for users who want to try out scalable-vector support,
fixed-width codegen support, or build user-code with scalable vector
intrinsics, Clang will not crash and burn when the compiler encounters
such a case.

This allows us to do away with the following pattern in many of the SVE tests:
  RUN:  2>%t
  RUN: cat %t | FileCheck --check-prefix=WARN
  WARN-NOT: warning: ...

The behaviour to emit warnings is only temporary and we expect this flag
to be removed in the future when scalable vector support is more stable.

This patch also has fixes the following tests:
 unittests:
   ScalableVectorMVTsTest.SizeQueries
   SelectionDAGAddressAnalysisTest.unknownSizeFrameObjects
   AArch64SelectionDAGTest.computeKnownBitsSVE_ZERO_EXTEND_VECTOR_INREG

 regression tests:
   Transforms/InstCombine/vscale_gep.ll

Reviewed By: paulwalker-arm, ctetreau

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

Added: 
llvm/lib/Support/TypeSize.cpp

Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
llvm/include/llvm/CodeGen/ValueTypes.h
llvm/include/llvm/Support/TypeSize.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/Support/CMakeLists.txt
llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 30a0b090b6922..3d5cdb3acd244 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5051,6 +5051,21 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
 
   RenderTargetOptions(Triple, Args, KernelOrKext, CmdArgs);
 
+  // FIXME: For now we want to demote any errors to warnings, when they have
+  // been raised for asking the wrong question of scalable vectors, such as
+  // asking for the fixed number of elements. This may happen because code that
+  // is not yet ported to work for scalable vectors uses the wrong interfaces,
+  // whereas the behaviour is actually correct. Emitting a warning helps bring
+  // up scalable vector support in an incremental way. When scalable vector
+  // support is stable enough, all uses of wrong interfaces should be 
considered
+  // as errors, but until then, we can live with a warning being emitted by the
+  // compiler. This way, Clang can be used to compile code with scalable 
vectors
+  // and identify possible issues.
+  if (isa(JA)) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
+  }
+
   // These two are potentially updated by AddClangCLArgs.
   codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
   bool EmitCodeView = false;

diff  --git a/llvm/include/llvm/CodeGen/ValueTypes.h 
b/llvm/include/llvm/CodeGen/ValueTypes.h
index ccdaab5ed96d2..e7346f7a75abc 100644
--- a/llvm/include/llvm/CodeGen/ValueTypes.h
+++ b/llvm/include/llvm/CodeGen/ValueTypes.h
@@ -299,19 +299,16 @@ namespace llvm {
 
 /// Given a vector type, return the number of elements it contains.
 unsigned getVectorNumElements() const {
-#ifdef STRICT_FIXED_SIZE_VECTORS
-  assert(isFixedLengthVector() && "Invalid vector type!");
-#else
   assert(isVector() && "Invalid vector type!");
+
   if (isScalableVector())
-WithColor::warning()
-<< "Possible incorrect use of EVT::getVectorNumElements() for "
-   "scalable vector. Scalable flag may be dropped, use "
-   "EVT::getVectorElementCount() instead\n";
-#endif
-  if (isSimple())
-return V.getVectorNumElements();
-  return getExtendedVectorNumElements();
+llvm::reportInvalidSizeRequest(
+"Possible incorrect use of EVT::getVectorNumElements() for "
+"scalable vector. Scalable flag may b

[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-04-02 Thread Sander de Smalen 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 rG0f7bbbc481e2: Always emit error for wrong interfaces to 
scalable vectors, unless cmdline flag… (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D98856?vs=333018&id=334933#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/TypeSize.cpp
  llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp

Index: llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
===
--- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
+++ llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
@@ -180,7 +180,8 @@
   // Check convenience size scaling methods.
   EXPECT_EQ(v2i32.getSizeInBits() * 2, v4i32.getSizeInBits());
   EXPECT_EQ(2 * nxv2i32.getSizeInBits(), nxv4i32.getSizeInBits());
-  EXPECT_EQ(nxv2f64.getSizeInBits() / 2, nxv2i32.getSizeInBits());
+  EXPECT_EQ(nxv2f64.getSizeInBits().divideCoefficientBy(2),
+nxv2i32.getSizeInBits());
 }
 
 } // end anonymous namespace
Index: llvm/lib/Support/TypeSize.cpp
===
--- /dev/null
+++ llvm/lib/Support/TypeSize.cpp
@@ -0,0 +1,41 @@
+//===- TypeSize.cpp - Wrapper around type sizes--*- 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 "llvm/Support/TypeSize.h"
+#include "llvm/Support/CommandLine.h"
+
+using namespace llvm;
+
+/// The ScalableErrorAsWarning is a temporary measure to suppress errors from
+/// using the wrong interface on a scalable vector.
+cl::opt ScalableErrorAsWarning(
+"treat-scalable-fixed-error-as-warning", cl::Hidden, cl::init(false),
+cl::desc("Treat issues where a fixed-width property is requested from a "
+ "scalable type as a warning, instead of an error."),
+cl::ZeroOrMore);
+
+void llvm::reportInvalidSizeRequest(const char *Msg) {
+#ifndef STRICT_FIXED_SIZE_VECTORS
+  if (ScalableErrorAsWarning) {
+WithColor::warning() << "Invalid size request on a scalable vector; " << Msg
+ << "\n";
+return;
+  }
+#endif
+  report_fatal_error("Invalid size request on a scalable vector.");
+}
+
+TypeSize::operator TypeSize::ScalarTy() const {
+  if (isScalable()) {
+reportInvalidSizeRequest(
+"Cannot implicitly convert a scalable size to a fixed-width size in "
+"`TypeSize::operator ScalarTy()`");
+return getKnownMinValue();
+  }
+  return getFixedValue();
+}
Index: llvm/lib/Support/CMakeLists.txt
===
--- llvm/lib/Support/CMakeLists.txt
+++ llvm/lib/Support/CMakeLists.txt
@@ -185,6 +185,7 @@
   TrigramIndex.cpp
   Triple.cpp
   Twine.cpp
+  TypeSize.cpp
   Unicode.cpp
   UnicodeCaseFold.cpp
   VersionTuple.cpp
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -4847,8 +4847,8 @@
 assert(VT.isVector() && "This DAG node is restricted to vector types.");
 assert(Operand.getValueType().bitsLE(VT) &&
"The input must be the same size or smaller than the result.");
-assert(VT.getVectorNumElements() <
- Operand.getValueType().getVectorNumElements() &&
+assert(VT.getVectorMinNumElements() <
+   Operand.getValueType().getVectorMinNumElements() &&
"The destination vector type must have fewer lanes than the input.");
 break;
   case ISD::ABS:
Index: llvm/lib/Analysis/InstructionSimplify.cpp
===
--- llvm/lib/Analysis/InstructionSimplify.cpp
+++ llvm/lib/Analysis/InstructionSimplify.cpp
@@ -4332,7 +4332,10 @@
   if (Q.isUndefValue(Ops[0]))
 return UndefValue::get(GEPTy);
 
-  bool IsScalableVec = isa(SrcTy);
+  bool IsScalableVec =
+  isa(SrcTy) || any_of(Ops, [](const Value *V) {
+return isa(V->getType());
+  });
 
   if (Ops.size() == 2) {
 // getelementptr P, 0 -> P.
Index: llvm/include/llvm/Support/TypeSize.h
===
--- llvm/include/llvm/Support/TypeSize.h
+++ llvm/include/llvm/Support/TypeSize.h
@@ -27,6 +27,10 @@
 
 names

[PATCH] D99703: [debug-info][XCOFF] set `-gno-column-info` by default for DBX

2021-04-02 Thread ChenZheng via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf026e1f52055: [debug-info][XCOFF] set `-gno-column-info` by 
default for DBX (authored by shchenz).

Changed prior to commit:
  https://reviews.llvm.org/D99703?vs=334589&id=334879#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99703

Files:
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options.c


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -110,6 +110,16 @@
 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
 
+// On the AIX, -g defaults to -gno-column-info.
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff -gcolumn-info 2>&1 \
+// RUN: | FileCheck -check-prefix=CI %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff -gcolumn-info \
+// RUN: 2>&1 | FileCheck -check-prefix=CI %s
+
 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3972,12 +3972,15 @@
   // Column info is included by default for everything except SCE and
   // CodeView. Clang doesn't track end columns, just starting columns, which,
   // in theory, is fine for CodeView (and PDB).  In practice, however, the
-  // Microsoft debuggers don't handle missing end columns well, so it's better
-  // not to include any column info.
+  // Microsoft debuggers don't handle missing end columns well, and the AIX
+  // debugger DBX also doesn't handle the columns well, so it's better not to
+  // include any column info.
   if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
 (void)checkDebugInfoOption(A, Args, D, TC);
   if (!Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
-!EmitCodeView && DebuggerTuning != 
llvm::DebuggerKind::SCE))
+!EmitCodeView &&
+(DebuggerTuning != llvm::DebuggerKind::SCE &&
+ DebuggerTuning != llvm::DebuggerKind::DBX)))
 CmdArgs.push_back("-gno-column-info");
 
   // FIXME: Move backend command line options to the module.


Index: clang/test/Driver/debug-options.c
===
--- clang/test/Driver/debug-options.c
+++ clang/test/Driver/debug-options.c
@@ -110,6 +110,16 @@
 // RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
 // RUN: | FileCheck -check-prefix=G_LIMITED -check-prefix=G_DBX %s
 
+// On the AIX, -g defaults to -gno-column-info.
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff 2>&1 \
+// RUN: | FileCheck -check-prefix=NOCI %s
+// RUN: %clang -### -c -g %s -target powerpc-ibm-aix-xcoff -gcolumn-info 2>&1 \
+// RUN: | FileCheck -check-prefix=CI %s
+// RUN: %clang -### -c -g %s -target powerpc64-ibm-aix-xcoff -gcolumn-info \
+// RUN: 2>&1 | FileCheck -check-prefix=CI %s
+
 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 \
 // RUN: | FileCheck -check-prefix=G_ONLY_DWARF2 %s
 //
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3972,12 +3972,15 @@
   // Column info is included by default for everything except SCE and
   // CodeView. Clang doesn't track end columns, just starting columns, which,
   // in theory, is fine for CodeView (and PDB).  In practice, however, the
-  // Microsoft debuggers don't handle missing end columns well, so it's better
-  // not to include any column info.
+  // Microsoft debuggers don't handle missing end columns well, and the AIX
+  // debugger DBX also doesn't handle the columns well, so it's better not to
+  // include any column info.
   if (const Arg *A = Args.getLastArg(options::OPT_gcolumn_info))
 (void)checkDebugInfoOption(A, Args, D, TC);
   if (!Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,
-!EmitCodeView && DebuggerTuning != llvm::DebuggerKind::SCE))
+!EmitCodeView &&
+(DebuggerTuning !=

[PATCH] D99703: [debug-info][XCOFF] set `-gno-column-info` by default for DBX

2021-04-02 Thread ChenZheng via Phabricator via cfe-commits
shchenz added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:3974
+  // Microsoft debuggers don't handle missing end columns well, and the AIX
+  // debugger DBX also doesn't handle the columns well, so it's bettre not to
+  // include any column info.

dblaikie wrote:
> 
oops. Will fix in the commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99703

___
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-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok added a comment.

In D99160#2666068 , @djtodoro wrote:

> In D99160#2666066 , @alok wrote:
>
>> In D99160#2665580 , @probinson 
>> wrote:
>>
>>> FastISel is normally used only at -O0, I wouldn't expect any parameters to 
>>> be optimized out at -O0.
>>> The test is running llc with default optimization, which is -O2, and 
>>> forcing fast-isel; this is not a usual combination and I wouldn't expect us 
>>> to spend any effort making sure debug info works well with that combination.
>>>
>>> If flang is forcing fast-isel even with optimization, that sounds like a 
>>> problem for flang to solve, not LLVM.
>>
>> Thanks for your comments. I am sorry as the earlier used options in test 
>> case were more confusing than helpful. I have changed that now.
>> The updated testcase at "-O0" with FastISel does have optimized out 
>> parameter, this is because generation of "DW_OP_GNU_entry_value" is enabled 
>> starting from "-O0". This causes llvm to generate it whenever it gets 
>> opportunity (more local variables to preserve may be the reason). 
>> The concern here is only DW_OP_GNU_entry_value is not sufficient and should 
>> be supported with "DW_TAG_GNU_call_site_parameter", which I tried in current 
>> patch.
>
>
>
>> "DW_OP_GNU_entry_value" is enabled starting from "-O0".
>
> I am wondering if this is true...

You can try with testcase attached with this patch.

bash$ llc -O0 -filetype=obj llvm/test/DebugInfo/X86/callsitepar-fastisel.ll -o 
callsitepar-fastisel.o
bash$ llvm-dwarfdump callsitepar-fastisel.o | grep DW_OP_GNU_entry_value

  [0x00bf, 0x0101): DW_OP_GNU_entry_value(DW_OP_reg4 
RSI))


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


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

2021-04-02 Thread Djordje Todorovic via Phabricator via cfe-commits
djtodoro added a comment.

In D99160#2666104 , @alok wrote:

> In D99160#2666068 , @djtodoro wrote:
>
>> In D99160#2666066 , @alok wrote:
>>
>>> In D99160#2665580 , @probinson 
>>> wrote:
>>>
 FastISel is normally used only at -O0, I wouldn't expect any parameters to 
 be optimized out at -O0.
 The test is running llc with default optimization, which is -O2, and 
 forcing fast-isel; this is not a usual combination and I wouldn't expect 
 us to spend any effort making sure debug info works well with that 
 combination.

 If flang is forcing fast-isel even with optimization, that sounds like a 
 problem for flang to solve, not LLVM.
>>>
>>> Thanks for your comments. I am sorry as the earlier used options in test 
>>> case were more confusing than helpful. I have changed that now.
>>> The updated testcase at "-O0" with FastISel does have optimized out 
>>> parameter, this is because generation of "DW_OP_GNU_entry_value" is enabled 
>>> starting from "-O0". This causes llvm to generate it whenever it gets 
>>> opportunity (more local variables to preserve may be the reason). 
>>> The concern here is only DW_OP_GNU_entry_value is not sufficient and should 
>>> be supported with "DW_TAG_GNU_call_site_parameter", which I tried in 
>>> current patch.
>>
>>
>>
>>> "DW_OP_GNU_entry_value" is enabled starting from "-O0".
>>
>> I am wondering if this is true...
>
> You can try with testcase attached with this patch.
>
> bash$ llc -O0 -filetype=obj llvm/test/DebugInfo/X86/callsitepar-fastisel.ll 
> -o callsitepar-fastisel.o
> bash$ llvm-dwarfdump callsitepar-fastisel.o | grep DW_OP_GNU_entry_value
>
>   [0x00bf, 0x0101): DW_OP_GNU_entry_value(DW_OP_reg4 
> RSI))

OK, thanks! We should fix that.


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


[PATCH] D99426: [Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added a comment.

In D99426#2665361 , @aganea wrote:

> I am still concerned by the fact that this patch doesn't fix the issue 
> mentionned in https://reviews.llvm.org/D96363#2650460
> Was the intention to fix that issue? Will the fix be done in a subsequent 
> patch?

I was fairly confident that if https://reviews.llvm.org/D96363 was the patch 
that was causing the issue for you, then this patch would have fixed the 
problem. I've already reverted the change in 
clang/lib/Frontend/Rewrite/FrontendActions.cpp and you mentioned that reverting 
the change in clang/lib/Driver/Driver.cpp didn't resolve the issue either. This 
patch should turn off CRLF translation in the remaining 2 files modified in 
that patch (Driver.cpp and DwarfLinkerForBinary.cpp). Since this doesn't seem 
to fix your problem, I'll need to do further investigation into which patch 
actually does cause the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 334942.
SaurabhJha added a comment.

Updating D99037 : [Matrix] Implement explicit 
type conversions for matrix types

Latest update includes code gen for c style casts along with some lit tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,74 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef short sx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+typedef double dx5x5 __attribute__((matrix_type(5, 5)));
+typedef signed int signed_int_5x5 __attribute__((matrix_type(5, 5)));
+typedef unsigned int unsigned_int_5x5 __attribute__((matrix_type(5, 5)));
+
+void cast_char_matrix_to_int(cx5x5 c, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_char_matrix_to_int(<25 x i8> %c, <25 x i32> %i)
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[C1:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C1]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)c;
+}
+
+void cast_int_matrix_to_short(ix5x5 i, sx5x5 s) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_short(<25 x i32> %i, <25 x i16> %s)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[I1:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = trunc <25 x i32> [[I1]] to <25 x i16>
+  // CHECK-NEXT:  store <25 x i16> [[CONV]], <25 x i16>* {{.*}}, align 2
+  // CH

[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-02 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 334941.
abhina.sreeskantharajan retitled this revision from "[Windows] Add new 
OF_TextWithCRLF flag and use this flag instead of OF_Text" to 
"[SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag 
instead of OF_Text".
abhina.sreeskantharajan edited the summary of this revision.
abhina.sreeskantharajan added a comment.

Updated comments and assertion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

Files:
  clang-tools-extra/clang-move/tool/ClangMove.cpp
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang-tools-extra/pp-trace/PPTrace.cpp
  clang/lib/ARCMigrate/PlistReporter.cpp
  clang/lib/Driver/Compilation.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Frontend/DependencyGraph.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Frontend/HeaderIncludeGen.cpp
  clang/lib/Frontend/ModuleDependencyCollector.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/tools/clang-refactor/ClangRefactor.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/CompilerInstance.cpp
  lld/COFF/DriverUtils.cpp
  lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp
  lldb/include/lldb/Utility/ReproducerProvider.h
  lldb/source/Utility/GDBRemote.cpp
  lldb/source/Utility/ReproducerProvider.cpp
  lldb/tools/lldb-server/LLDBServerUtilities.cpp
  llvm/include/llvm/Analysis/DOTGraphTraitsPass.h
  llvm/include/llvm/Support/FileSystem.h
  llvm/lib/CodeGen/RegAllocPBQP.cpp
  llvm/lib/IR/Core.cpp
  llvm/lib/IR/LLVMRemarkStreamer.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/MC/MCParser/DarwinAsmParser.cpp
  llvm/lib/ProfileData/GCOV.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/FileCollector.cpp
  llvm/lib/Support/MemoryBuffer.cpp
  llvm/lib/Support/TimeProfiler.cpp
  llvm/lib/Support/Timer.cpp
  llvm/lib/Support/Unix/Program.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/lib/Support/Windows/Program.inc
  llvm/lib/Transforms/IPO/Attributor.cpp
  llvm/lib/Transforms/IPO/LowerTypeTests.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/lib/Transforms/Utils/Debugify.cpp
  llvm/tools/dsymutil/dsymutil.cpp
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp
  llvm/tools/llvm-dis/llvm-dis.cpp
  llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
  llvm/tools/llvm-exegesis/lib/BenchmarkResult.cpp
  llvm/tools/llvm-link/llvm-link.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-opt-report/OptReport.cpp
  llvm/tools/llvm-profdata/llvm-profdata.cpp
  llvm/tools/llvm-xray/xray-account.cpp
  llvm/tools/llvm-xray/xray-converter.cpp
  llvm/tools/llvm-xray/xray-extract.cpp
  llvm/tools/llvm-xray/xray-graph-diff.cpp
  llvm/tools/llvm-xray/xray-graph.cpp
  llvm/tools/opt/opt.cpp
  llvm/tools/verify-uselistorder/verify-uselistorder.cpp
  llvm/unittests/Support/Path.cpp
  polly/lib/Exchange/JSONExporter.cpp

Index: polly/lib/Exchange/JSONExporter.cpp
===
--- polly/lib/Exchange/JSONExporter.cpp
+++ polly/lib/Exchange/JSONExporter.cpp
@@ -178,7 +178,7 @@
 
   // Write to file.
   std::error_code EC;
-  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_Text);
+  ToolOutputFile F(FileName, EC, llvm::sys::fs::OF_TextWithCRLF);
 
   std::string FunctionName = S.getFunction().getName().str();
   errs() << "Writing JScop '" << S.getNameStr() << "' in function '"
Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -1253,7 +1253,7 @@
   path::append(FilePathname, "test");
 
   {
-raw_fd_ostream File(FilePathname, EC, sys::fs::OF_Text);
+raw_fd_ostream File(FilePathname, EC, sys::fs::OF_TextWithCRLF);
 ASSERT_NO_ERROR(EC);
 File << '\n';
   }
Index: llvm/tools/verify-uselistorder/verify-uselistorder.cpp
===
--- llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -136,7 +136,7 @@
 bool TempFile::writeAssembly(const Module &M) const {
   LLVM_DEBUG(dbgs() << " - write assembly\n");
   std::error_code EC;
-  raw_fd_ostream OS(Filename, EC, sys::fs::OF_Text);
+  raw_fd_ostream OS(Filename, EC, sys::fs::OF_TextWithCRLF);
   if (EC) {
 errs() << "verify-uselistorder: error: " << EC.message() << "\n";
 return true;
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -700,8 +700,8 @@
   OutputFilename = "-";
 
 std::error_code EC;
-sys::fs::OpenFlags Fla

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

I pushed some unwanted changes that I used for debugging..fixing/removing them 
now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 334945.
SaurabhJha added a comment.

Updating D99037 : [Matrix] Implement explicit 
type conversions for matrix types
Removed unused variables and includes and fix codegen lit tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef short sx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+typedef double dx5x5 __attribute__((matrix_type(5, 5)));
+typedef signed int signed_int_5x5 __attribute__((matrix_type(5, 5)));
+typedef unsigned int unsigned_int_5x5 __attribute__((matrix_type(5, 5)));
+
+void cast_char_matrix_to_int(cx5x5 c, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_char_matrix_to_int(<25 x i8> %c, <25 x i32> %i)
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)c;
+}
+
+void cast_int_matrix_to_short(ix5x5 i, sx5x5 s) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_short(<25 x i32> %i, <25 x i16> %s)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
+  // CHECK-NEXT:  store <25 x i16> [[CONV]], <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  ret void
+
+  s = (sx5x5)i;
+}
+
+void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added a comment.

Added some inline comments on where I have some doubts.




Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:547
+  case CK_MatrixCast: {
+// TODO: Handle MatrixCast here.
+  }

I thought doing changes here is is outside the scope of casting so I just left 
a TODO here. Please let me know if we want to do something else here.



Comment at: clang/test/CodeGen/matrix-cast.c:39
+
+  f = (fx5x5)i;
+}

I tried adding a float -> int conversion too but it failed because of this 
assertion 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1339-L1344
 Hopefully that's intended.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:547
+  case CK_MatrixCast: {
+// TODO: Handle MatrixCast here.
+  }

SaurabhJha wrote:
> I thought doing changes here is is outside the scope of casting so I just 
> left a TODO here. Please let me know if we want to do something else here.
I think that's fair,  but you should probably add `continue;` rather than 
falling through.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

This doesn't seem right. We are casting between 2 signed types, so the sign 
should get preserved, right? Shouldn't this be `sext`? See 
https://godbolt.org/z/zWznYdnKW for the scalar case.

I think you also need tests for casts with different bitwidths with unsigned, 
unsigned -> signed & signed -> unsigned.



Comment at: clang/test/CodeGen/matrix-cast.c:39
+
+  f = (fx5x5)i;
+}

SaurabhJha wrote:
> I tried adding a float -> int conversion too but it failed because of this 
> assertion 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1339-L1344
>  Hopefully that's intended.
Clang should never run into an assertion. If that should not be allowed, then 
Clang should emit an error during Sema. I'm not sure why there is such a 
restriction for vector types, but I am not sure that this shouldn't be allowed 
for matrixes. Perhaps @rjmccall has more thoughts on this, but conversion 
between scalar ints to floats is allowed AFAIKT.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:2916
 
   // Require the operand to be a scalar or vector.
+  if (!SrcType->isScalarType() && !SrcType->isVectorType() &&

` ... or a matrix`?



Comment at: clang/test/Sema/matrix-cast.c:3
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));

I think it would be good to add additional test coverage casting between matrix 
types and other types, e.g.  vector types, pointer types and struct types.

It would also be good to have C++ tests that test casting with matrix types 
where some of the dimensions are template arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:7400
+  } else {
+return Diag(R.getBegin(),
+diag::err_invalid_conversion_between_matrix_and_scalar)

When we get here, `SrcTy` may not necessarily be a scalar I think (see my 
earlier note about adding more invalid cast tests for some additional cases 
that might reach this code)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha updated this revision to Diff 334951.
SaurabhJha added a comment.

Update commit message to more accurately reflect the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Edit/RewriteObjCFoundationAPI.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp
  clang/test/CodeGen/matrix-cast.c
  clang/test/Sema/matrix-cast.c

Index: clang/test/Sema/matrix-cast.c
===
--- /dev/null
+++ clang/test/Sema/matrix-cast.c
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -fenable-matrix -fsyntax-only %s -verify
+
+typedef char cx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix4x4 __attribute__((matrix_type(4, 4)));
+typedef short sx4x4 __attribute__((matrix_type(4, 4)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+
+void f1() {
+  cx4x4 m1;
+  ix4x4 m2;
+  sx4x4 m3;
+  ix5x5 m4;
+  fx5x5 m5;
+
+  m2 = (ix4x4)m1;
+  m3 = (sx4x4)m2;
+  m4 = (ix5x5)m3; // expected-error {{invalid conversion between matrix type \
+'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))') and 'sx4x4' \
+(aka 'short __attribute__((matrix_type(4, 4)))') of different size}}
+  m5 = (ix5x5)m4; // expected-error {{assigning to 'fx5x5' (aka \
+'float __attribute__((matrix_type(5, 5)))') from incompatible type 'ix5x5' (aka 'int __attribute__((matrix_type(5, 5)))')}}
+  m4 = (ix5x5)m5;
+}
+
+typedef float float2_8x8 __attribute__((matrix_type(8, 8)));
+typedef double double_10x10 __attribute__((matrix_type(10, 10)));
+typedef double double_8x8 __attribute__((matrix_type(8, 8)));
+typedef signed int signed_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_12x12 __attribute__((matrix_type(12, 12)));
+typedef unsigned int unsigned_int_10x10 __attribute__((matrix_type(10, 10)));
+
+void f2() {
+  float2_8x8 m1;
+  double_10x10 m2;
+  double_8x8 m3;
+  signed_int_12x12 m4;
+  unsigned_int_12x12 m5;
+  unsigned_int_10x10 m6;
+
+  m2 = (double_10x10)m1; // expected-error {{invalid conversion between matrix type \
+'double_10x10' (aka 'double __attribute__((matrix_type(10, 10)))') and 'float2_8x8' \
+(aka 'float __attribute__((matrix_type(8, 8)))') of different size}}
+  m3 = (double_8x8)m1;
+
+  m5 = (unsigned_int_12x12)m4;
+  m4 = (signed_int_12x12)m5;
+  m6 = (unsigned_int_10x10)m4; // expected-error {{invalid conversion between matrix type \
+'unsigned_int_10x10' (aka 'unsigned int __attribute__((matrix_type(10, 10)))') and 'signed_int_12x12' \
+(aka 'int __attribute__((matrix_type(12, 12)))') of different size}}
+}
\ No newline at end of file
Index: clang/test/CodeGen/matrix-cast.c
===
--- /dev/null
+++ clang/test/CodeGen/matrix-cast.c
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -fenable-matrix -triple x86_64-apple-darwin %s -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef char cx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef short sx5x5 __attribute__((matrix_type(5, 5)));
+typedef int ix5x5 __attribute__((matrix_type(5, 5)));
+typedef float fx5x5 __attribute__((matrix_type(5, 5)));
+typedef double dx5x5 __attribute__((matrix_type(5, 5)));
+typedef signed int signed_int_5x5 __attribute__((matrix_type(5, 5)));
+typedef unsigned int unsigned_int_5x5 __attribute__((matrix_type(5, 5)));
+
+void cast_char_matrix_to_int(cx5x5 c, ix5x5 i) {
+  // CHECK-LABEL: define{{.*}} void @cast_char_matrix_to_int(<25 x i8> %c, <25 x i32> %i)
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  ret void
+
+  i = (ix5x5)c;
+}
+
+void cast_int_matrix_to_short(ix5x5 i, sx5x5 s) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_short(<25 x i32> %i, <25 x i16> %s)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [[CONV:%.*]] = trunc <25 x i32> [[I]] to <25 x i16>
+  // CHECK-NEXT:  store <25 x i16> [[CONV]], <25 x i16>* {{.*}}, align 2
+  // CHECK-NEXT:  ret void
+
+  s = (sx5x5)i;
+}
+
+void cast_int_matrix_to_float(ix5x5 i, fx5x5 f) {
+  // CHECK-LABEL: define{{.*}} void @cast_int_matrix_to_float(<25 x i32> %i, <25 x float> %f)
+  // CHECK:   [[I:%.*]] = load <25 x i32>, <25 x i32>* {{.*}}, align 4
+  // CHECK-NEXT:  [

[PATCH] D99580: [CLANG] [DebugInfo] Convert File name to native format

2021-04-02 Thread kamlesh kumar via Phabricator via cfe-commits
kamleshbhalui updated this revision to Diff 334952.
kamleshbhalui added a comment.

Making changes effective only for windows


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99580

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/debug-info-preprocessed-file.i
  clang/test/CodeGen/debug-prefix-map.c
  clang/test/CodeGenCXX/debug-info-mingw.cpp
  clang/test/CodeGenCXX/linetable-fnbegin.cpp
  clang/test/Frontend/optimization-remark-line-directive.c
  clang/test/Frontend/stdin-input.c
  clang/test/Modules/module-debuginfo-prefix.m
  clang/test/PCH/debug-info-pch-container-path.c

Index: clang/test/PCH/debug-info-pch-container-path.c
===
--- clang/test/PCH/debug-info-pch-container-path.c
+++ clang/test/PCH/debug-info-pch-container-path.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Modules/module-debuginfo-prefix.m
===
--- clang/test/Modules/module-debuginfo-prefix.m
+++ clang/test/Modules/module-debuginfo-prefix.m
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // REQUIRES: asserts
 
 // Modules:
Index: clang/test/Frontend/stdin-input.c
===
--- clang/test/Frontend/stdin-input.c
+++ clang/test/Frontend/stdin-input.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: cat %s | %clang -emit-llvm -g -S \
 // RUN: -Xclang -main-file-name -Xclang test/foo.c -x c - -o - | FileCheck %s
 // CHECK: ; ModuleID = 'test/foo.c'
Index: clang/test/Frontend/optimization-remark-line-directive.c
===
--- clang/test/Frontend/optimization-remark-line-directive.c
+++ clang/test/Frontend/optimization-remark-line-directive.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // This file tests -Rpass diagnostics together with #line
 // directives. We cannot map #line directives back to
 // a SourceLocation.
Index: clang/test/CodeGenCXX/linetable-fnbegin.cpp
===
--- clang/test/CodeGenCXX/linetable-fnbegin.cpp
+++ clang/test/CodeGenCXX/linetable-fnbegin.cpp
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s
 // Test that the line table info for Foo::bar() is pointing to the
 // right header file.
@@ -11,7 +12,6 @@
 // We shouldn't need a lexical block for this function.
 // CHECK: [[DBG]] = !DILocation(line: 23, column: 3, scope: [[SP]])
 
-
 # 1 "./template.h" 1
 template 
 class Foo {
Index: clang/test/CodeGenCXX/debug-info-mingw.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-mingw.cpp
@@ -0,0 +1,9 @@
+// UNSUPPORTED: !system-windows
+// RUN: rm -rf %t/UNIQUE_DIR && mkdir -p %t/UNIQUE_DIR
+// RUN: cp %s %t/UNIQUE_DIR/debug-info-mingw.cpp
+// RUN: %clang_cc1 -triple x86_64-w64-windows-gnu -debug-info-kind=limited \
+// RUN: -main-file-name debug-info-mingw.cpp %t/UNIQUE_DIR/debug-info-mingw.cpp \
+// RUN: -emit-llvm -o - | FileCheck %s
+int main() {
+}
+// CHECK: !DIFile(filename: "{{.+}}\\UNIQUE_DIR\\debug-info-mingw.cpp",
Index: clang/test/CodeGen/debug-prefix-map.c
===
--- clang/test/CodeGen/debug-prefix-map.c
+++ clang/test/CodeGen/debug-prefix-map.c
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-NO-MAIN-FILE-NAME
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH=empty %s -emit-llvm -o - | FileCheck %s -check-prefix CHECK-EVIL
 // RUN: %clang_cc1 -debug-info-kind=standalone -fdebug-prefix-map=%p=/UNLIKELY_PATH/empty %s -emit-llvm -o - -main-file-name debug-prefix-map.c | FileCheck %s
Index: clang/test/CodeGen/debug-info-preprocessed-file.i
===
--- clang/test/CodeGen/debug-info-preprocessed-file.i
+++ clang/test/CodeGen/debug-info-preprocessed-file.i
@@ -1,3 +1,4 @@
+// UNSUPPORTED: system-windows
 # 1 "/foo/bar/preprocessed-input.c"
 # 1 "" 1
 # 1 "" 3
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -444,6 +444,12 @@
   StringRef Dir;
   StringRef File;
   std::string RemappedFile = remapDIPath(FileName);
+  // Convert RemappedFile to native style when Windows
+  if (CGM.getTarget().getTriple().isOSWindows()) {
+SmallString<128> NativeFileName = StringRef(RemappedFile);
+llvm::sys::path::native(NativeFileName);
+RemappedFile = (std::string)NativeFileName.st

[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2021-04-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 334954.
tbaeder added a comment.
Herald added a subscriber: jdoerfert.

A little earlier than expected. Happy Easter  :P


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

https://reviews.llvm.org/D75844

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -185,9 +185,12 @@
   return 1;
   [[clang::fallthrough]];  // expected-warning{{fallthrough annotation in unreachable code}}
 case 222:
+  return 2;
+  __attribute__((fallthrough)); // expected-warning{{fallthrough annotation in unreachable code}}
+case 223:
   n += 400;
-case 223:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
-  ;
+case 224: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
+;
   }
 
   long p = static_cast(n) * n;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -368,6 +368,20 @@
   return n;
 }
 
+template struct TemplateStruct {};
+class FriendClassesWithAttributes {
+  // We allow GNU-style attributes here
+  template  friend class __attribute__((__type_visibility__("default"))) vector;
+  // But not C++11 ones
+  template  friend class[[]] vector2; // expected-error {{an attribute list cannot appear here}}
+  template  friend class [[clang::__type_visibility__(("default"))]] vector3; // expected-error {{an attribute list cannot appear here}}
+
+  // Also allowed
+  friend struct __attribute__((__type_visibility__("default"))) TemplateStruct;
+  friend struct[[]] TemplateStruct;   // expected-error {{an attribute list cannot appear here}}
+  friend struct [[clang::__type_visibility__("default")]] TemplateStruct; // expected-error {{an attribute list cannot appear here}}
+};
+
 #define attr_name bitand
 #define attr_name_2(x) x
 #define attr_name_3(x, y) x##y
Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,24 @@
   }
 }
 
+// CHECK-1Z: NamespaceDecl {{.*}} attributed_case
+namespace attributed_case {
+void f(int n) {
+  switch (n) {
+  case 0:
+n--;
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: FallThroughAttr {{.*}} 
+__attribute__((fallthrough))
+// CHECK: FallThroughAttr {{.*}} 
+  __attribute__((fallthrough));
+  case 1:
+n++;
+break;
+  }
+}
+} // namespace attributed_case
+
 // CHECK: NamespaceDecl {{.*}} attributed_stmt
 namespace attributed_stmt {
   // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1852,7 +1852,8 @@
 } else if (TUK == Sema::TUK_Reference ||
(TUK == Sema::TUK_Friend &&
 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
   TypeResult = Actions.ActOnTagTemplateIdType(TUK, TagType, StartLoc,
   SS,
   TemplateId->TemplateKWLoc,
@@ -1924,7 +1925,8 @@
 TagType, StartLoc, SS, Name, NameLoc, attrs);
   } else if (TUK == Sema::TUK_Friend &&
  TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
-ProhibitAttributes(attrs);
+ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+/*DiagnoseEmptyAttrs=*/true);
 
 TagOrTempResult = Actions.ActOnTemplatedFriendTag(
 getCurScope(), DS.getFriendSpecLoc(), TagType, StartLoc, SS, Name,
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -162,15 +162,19 @@
 ///',' or ')' are ignored, otherwise they produce a pa

[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-02 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 334955.
Ericson2314 added a comment.

Remove add_subdirectory(runtime) for deleted dir


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

Files:
  clang/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  clang/runtime/compiler-rt/clang_linux_test_input.c
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/include/CMakeLists.txt
  compiler-rt/lib/dfsan/CMakeLists.txt
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -1,6 +1,6 @@
 # TODO: This file assumes the Clang toolchain so it'd be better if it lived in
-# Clang, except there already is clang/runtime directory which contains
-# similar although simpler functionality. We should figure out how to merge
+# Clang, except there already is runtimes directory which contains
+# similar functionality. We should figure out how to merge
 # the two files.
 
 # TODO: Selecting runtimes should be always performed inside the runtimes
Index: compiler-rt/lib/dfsan/CMakeLists.txt
===
--- compiler-rt/lib/dfsan/CMakeLists.txt
+++ compiler-rt/lib/dfsan/CMakeLists.txt
@@ -62,4 +62,4 @@
DEPENDS done_abilist.txt libc_ubuntu1404_abilist.txt)
 add_dependencies(dfsan dfsan_abilist)
 install(FILES ${dfsan_abilist_filename}
-DESTINATION ${COMPILER_RT_INSTALL_PATH}/share)
+DESTINATION share)
Index: compiler-rt/include/CMakeLists.txt
===
--- compiler-rt/include/CMakeLists.txt
+++ compiler-rt/include/CMakeLists.txt
@@ -69,22 +69,22 @@
 install(FILES ${SANITIZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/sanitizer)
+  DESTINATION include/sanitizer)
 # Install fuzzer headers.
 install(FILES ${FUZZER_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/fuzzer)
+  DESTINATION include/fuzzer)
 # Install xray headers.
 install(FILES ${XRAY_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/xray)
+  DESTINATION include/xray)
 # Install profile headers.
 install(FILES ${PROFILE_HEADERS}
   COMPONENT compiler-rt-headers
   PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
-  DESTINATION ${COMPILER_RT_INSTALL_PATH}/include/profile)
+  DESTINATION include/profile)
 
 if (NOT CMAKE_CONFIGURATION_TYPES) # don't add this for IDEs.
   add_custom_target(install-compiler-rt-headers
Index: compiler-rt/cmake/base-config-ix.cmake
===
--- compiler-rt/cmake/base-config-ix.cmake
+++ compiler-rt/cmake/base-config-ix.cmake
@@ -92,12 +92,12 @@
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH})
+"")
 else(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR)
   set(COMPILER_RT_LIBRARY_OUTPUT_DIR
 ${COMPILER_RT_OUTPUT_DIR}/lib/${COMPILER_RT_OS_DIR})
   set(COMPILER_RT_LIBRARY_INSTALL_DIR
-${COMPILER_RT_INSTALL_PATH}/lib/${COMPILER_RT_OS_DIR})
+lib/${COMPILER_RT_OS_DIR})
 endif()
 
 if(APPLE)
Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake
@@ -386,7 +386,7 @@
 function(get_compiler_rt_install_dir arch install_dir)
   if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
 get_compiler_rt_target(${arch} target)
-set(${install_dir} ${COMPILER_RT_INSTALL_PATH}/lib/${target} PARENT_SCOPE)
+set(${install_dir} lib/${target} PARENT_SCOPE)
   else()
 set(${install_dir} ${COMPILER_RT_LIBRARY_INSTALL_DIR} PARENT_SCOPE)
   endif()
Index: compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
===
--- compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ compiler-rt/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -508,7 +508,7 @@
 set(DARWIN_macho_embedded_LIBRARY_OUTPUT_DIR
   ${COMPILER_RT_OUTPUT_DIR}/lib/macho_embedded)
 set(DARWIN_macho_embedded_LIBRARY_INSTALL_DIR
-  ${COMPILER_RT_INSTALL_PATH}/lib/macho_embedded)
+  lib/macho_embedded)
   
 set(CFLAGS_armv7 "-target thumbv7-apple-darwin-eabi")
 set(CFLAGS_i386 "-march=pentium")
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake

[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 334956.
jyu2 added a comment.

Fix format problem as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/dispatch_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -276,6 +276,10 @@
 def OMPC_Destroy : Clause<"destroy"> {
   let clangClass = "OMPDestroyClause";
 }
+def OMPC_Novariants : Clause<"novariants"> {
+  let clangClass = "OMPNovariantsClause";
+  let flangClass = "ScalarLogicalExpr";
+}
 def OMPC_Detach : Clause<"detach"> {
   let clangClass = "OMPDetachClause";
 }
@@ -1660,7 +1664,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Unknown : Directive<"unknown"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -729,6 +729,7 @@
 CHECK_SIMPLE_CLAUSE(Write, OMPC_write)
 CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
+CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2291,6 +2291,10 @@
 Visitor->AddStmt(C->getInteropVar());
 }
 
+void OMPClauseEnqueue::VisitOMPNovariantsClause(const OMPNovariantsClause *C) {
+  Visitor->AddStmt(C->getCondition());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/dispatch_messages.cpp
===
--- clang/test/OpenMP/dispatch_messages.cpp
+++ clang/test/OpenMP/dispatch_messages.cpp
@@ -28,6 +28,24 @@
   // expected-error@+1 {{cannot contain more than one 'nowait' clause}}
   #pragma omp dispatch nowait device(dnum) nowait
   disp_call();
+
+  // expected-error@+1 {{expected '(' after 'novariants'}}
+  #pragma omp dispatch novariants
+  disp_call();
+
+  // expected-error@+3 {{expected expression}}
+  // expected-error@+2 {{expected ')'}}
+  // expected-note@+1 {{to match this '('}}
+  #pragma omp dispatch novariants (
+  disp_call();
+
+  // expected-error@+1 {{cannot contain more than one 'novariants' clause}}
+  #pragma omp dispatch novariants(dnum> 4) novariants(3)
+  disp_call();
+
+  // expected-error@+1 {{use of undeclared identifier 'x'}}
+  #pragma omp dispatch novariants(x)
+  disp_call();
 }
 
 void testit_two() {
Index: clang/test/OpenMP/dispatch_ast_print.cpp
===
--- clang/test/OpenMP/dispatch_ast_print.cpp
+++ clang/test/OpenMP/dispatch_ast_print.cpp
@@ -51,20 +51,22 @@
 void test_one()
 {
   int aaa, bbb, var;
-  //PRINT: #pragma omp dispatch depend(in : var) nowait
+  //PRINT: #pragma omp dispatch depend(in : var) nowait novariants(aaa > 5)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDependClause
   //DUMP: OMPNowaitClause
-  #pragma omp dispatch depend(in:var) nowait
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch depend(in:var) nowait novariants(aaa > 5)
   foo(aaa, &bbb);
 
   int *dp = get_device_ptr();
   int dev = get_device();
-  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDeviceClause
   //DUMP: OMPIs_device_ptrClause
-  #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   foo(aaa, dp);
 
   //PRINT: #pragma omp dispatch
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6237,6 +6237,12 @@
   Record.AddSourceLocation(C->getVarLoc());
 }
 
+void OMPClauseWriter::VisitOMPNovarian

[PATCH] D99755: Remove clang/runtime and `COMPILER_RT_INSTALL_PATH`

2021-04-02 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

So unfortunately it seems the `clang/runtime`'s use was triggered by 
`LLVM_BUILD_EXTERNAL_COMPILER_RT`, which is in use in a few places still? (And 
not just Apple ones.)

On the other hand, since this is doing an *external* CMake for compiler-rt, I 
fail to see why `COMPILER_RT_INSTALL_PATH` is needed; why not just pass a 
different `CMAKE_INSTALL_PREFIX`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99755

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:7659
+/// clause with condition 'a > 5'.
+class OMPNovariantsClause : public OMPClause, public OMPClauseWithPreInit {
+  friend class OMPClauseReader;

`final`



Comment at: clang/include/clang/AST/OpenMPClause.h:7696-7698
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+

Can you make it private?



Comment at: clang/lib/AST/OpenMPClause.cpp:1830
+  OS << "novariants(";
+  Node->getCondition()->printPretty(OS, nullptr, Policy, 0);
+  OS << ")";

I would add a check for non-nullptr `Node->getCondition()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[clang] 3ebfa36 - Remove attribute handling code for simple attributes; NFC

2021-04-02 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-04-02T11:35:10-04:00
New Revision: 3ebfa363f356eff744b73885023cc1fc62fad973

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

LOG: Remove attribute handling code for simple attributes; NFC

Attributes that set the SimpleHandler flag in Attr.td don't need to be
explicitly handled in SemaDeclAttr.cpp.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/lib/Sema/SemaDeclAttr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index c7b68856aab0..b832d1df7172 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2113,6 +2113,7 @@ def ObjCNonRuntimeProtocol : Attr {
   let Subjects = SubjectList<[ObjCProtocol], ErrorDiag>;
   let LangOpts = [ObjC];
   let Documentation = [ObjCNonRuntimeProtocolDocs];
+  let SimpleHandler = 1;
 }
 
 def ObjCRuntimeName : Attr {
@@ -2247,12 +2248,14 @@ def SwiftBridgedTypedef : InheritableAttr {
   let Spellings = [GNU<"swift_bridged_typedef">];
   let Subjects = SubjectList<[TypedefName], ErrorDiag>;
   let Documentation = [SwiftBridgedTypedefDocs];
+  let SimpleHandler = 1;
 }
 
 def SwiftObjCMembers : Attr {
   let Spellings = [GNU<"swift_objc_members">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
   let Documentation = [SwiftObjCMembersDocs];
+  let SimpleHandler = 1;
 }
 
 def SwiftError : InheritableAttr {
@@ -2284,6 +2287,7 @@ def SwiftNewType : InheritableAttr {
 def SwiftPrivate : InheritableAttr {
   let Spellings = [GNU<"swift_private">];
   let Documentation = [SwiftPrivateDocs];
+  let SimpleHandler = 1;
 }
 
 def NoDeref : TypeAttr {
@@ -3667,6 +3671,7 @@ def LoaderUninitialized : Attr {
   let Spellings = [Clang<"loader_uninitialized">];
   let Subjects = SubjectList<[GlobalVar]>;
   let Documentation = [LoaderUninitializedDocs];
+  let SimpleHandler = 1;
 }
 
 def ObjCExternallyRetained : InheritableAttr {

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index b39460d33214..23b488c527b1 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2650,11 +2650,6 @@ static void handleVisibilityAttr(Sema &S, Decl *D, const 
ParsedAttr &AL,
 D->addAttr(newAttr);
 }
 
-static void handleObjCNonRuntimeProtocolAttr(Sema &S, Decl *D,
- const ParsedAttr &AL) {
-  handleSimpleAttribute(S, D, AL);
-}
-
 static void handleObjCDirectAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   // objc_direct cannot be set on methods declared in the context of a protocol
   if (isa(D->getDeclContext())) {
@@ -7957,9 +7952,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
   case ParsedAttr::AT_AnyX86NoCfCheck:
 handleNoCfCheckAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_Leaf:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_NoThrow:
 if (!AL.isUsedAsTypeAttr())
   handleSimpleAttribute(S, D, AL);
@@ -8093,9 +8085,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
   case ParsedAttr::AT_ObjCDirect:
 handleObjCDirectAttr(S, D, AL);
 break;
-  case ParsedAttr::AT_ObjCNonRuntimeProtocol:
-handleObjCNonRuntimeProtocolAttr(S, D, AL);
-break;
   case ParsedAttr::AT_ObjCDirectMembers:
 handleObjCDirectMembersAttr(S, D, AL);
 handleSimpleAttribute(S, D, AL);
@@ -8114,9 +8103,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
 handleSimpleAttributeWithExclusions(S, D,
  AL);
 break;
-  case ParsedAttr::AT_NoMerge:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_Visibility:
 handleVisibilityAttr(S, D, AL, false);
 break;
@@ -8324,9 +8310,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
   case ParsedAttr::AT_SwiftBridge:
 handleSwiftBridge(S, D, AL);
 break;
-  case ParsedAttr::AT_SwiftBridgedTypedef:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_SwiftError:
 handleSwiftError(S, D, AL);
 break;
@@ -8336,12 +8319,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
   case ParsedAttr::AT_SwiftNewType:
 handleSwiftNewType(S, D, AL);
 break;
-  case ParsedAttr::AT_SwiftObjCMembers:
-handleSimpleAttribute(S, D, AL);
-break;
-  case ParsedAttr::AT_SwiftPrivate:
-handleSimpleAttribute(S, D, AL);
-break;
   case ParsedAttr::AT_SwiftAsync:
 handleSwiftAsyncAttr(S, D, AL);
 break;
@@ -8367,10 +8344,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, 
Decl *D,
 handleUninitializedAttr(S, D, AL);
 break;
 
-  case ParsedAttr::AT_LoaderUninitialized:
-handleSim

[PATCH] D99537: [OPENMP51]Initial support for the dispatch directive

2021-04-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a subscriber: jyu2.
jdoerfert added a comment.

Cool, are you expecting to hook this up to the variant selection logic as well? 
@jyu2 similarly do you intend to hook up `novariant`?

We should also update https://clang.llvm.org/docs/OpenMPSupport.html to claim 
parts you are working on (upstreaming).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99537

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


[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D99037#2666230 , @SaurabhJha wrote:

> Update commit message to more accurately reflect the patch

Just FYI, `arc diff ` does not update the patch description on Phabricator. I 
think you have to edit it via the web-interface.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D37624: add support for -fno-instrument-functions and -finstrument-functions-exclude-{file,function}-list= to match gcc options.

2021-04-02 Thread Oliver Browne via Phabricator via cfe-commits
oliverbrowne added a comment.

Hi Folks, don't know if this review is still active but I can provide some 
context on the GCC behavior with respect to namespaces, template params and 
function arguments, they were bugs, fixed in 2019.

Associated bug reports for namespace/class, and template parameter and argument 
mishandling: 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90816
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90809


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

https://reviews.llvm.org/D37624

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


[PATCH] D95808: [test] Use host platform specific error message substitution in lit tests - continued

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

In D95808#2657744 , @jhenderson wrote:

> @ASDenysPetrov, I think you need to mark this patch as Accepted so that 
> someone can close this review.

Done. Sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95808

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


[PATCH] D95246: [test] Use host platform specific error message substitution in lit tests

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

In D95246#2606343 , 
@abhina.sreeskantharajan wrote:

> This issue has been fixed in https://reviews.llvm.org/D97472.
> @ASDenysPetrov I'm unable to close this revision and the other one 
> https://reviews.llvm.org/D95808. Do you know what the appropriate action is 
> here? To abandon this, or accept it again and close it?

Done. Sorry for the delay.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D99426: [SystemZ][z/OS][Windows] Add new OF_TextWithCRLF flag and use this flag instead of OF_Text

2021-04-02 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

In D99426#2666141 , 
@abhina.sreeskantharajan wrote:

> In D99426#2665361 , @aganea wrote:
>
>> I am still concerned by the fact that this patch doesn't fix the issue 
>> mentionned in https://reviews.llvm.org/D96363#2650460
>> Was the intention to fix that issue? Will the fix be done in a subsequent 
>> patch?
>
> I was fairly confident that if https://reviews.llvm.org/D96363 was the patch 
> that was causing the issue for you

That is the case! I've confirmed that `git checkout 
fdb640ea30d416368b76b68b106deda580c6aced~1 && ninja clang -C build` generates a 
`clang-cl.exe` that works with my above test case. `git revert 
fdb640ea30d416368b76b68b106deda580c6aced` locally over ToT fixes the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99426

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

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

Handle **intersected** and **adjacent** ranges uniting them into a single one.
Example:
intersection `[0, 10] U [5, 20] = [0, 20]`
adjacency `[0, 10] U [11, 20] = [0, 20]`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99797

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -61,6 +61,9 @@
   static constexpr BaseType getMax() {
 return std::numeric_limits::max();
   }
+  // MID is a value in the middle of the range
+  // which unary minus does not affect on,
+  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   static constexpr BaseType getMid() {
 return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
   }
@@ -160,7 +163,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(&Self::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(&Self::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -195,9 +198,6 @@
 
   constexpr TypeParam MIN = TestFixture::getMin();
   constexpr TypeParam MAX = TestFixture::getMax();
-  // MID is a value in the middle of the range
-  // which unary minus does not affect on,
-  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   constexpr TypeParam MID = TestFixture::getMid();
   constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
   constexpr TypeParam B = MID - TestFixture::fromInt(42);
@@ -310,24 +310,124 @@
 }
 
 TYPED_TEST(RangeSetTest, RangeSetAddTest) {
-  // Check adding single points
-  this->checkAdd({}, 10, {{10, 10}});
-  this->checkAdd({{0, 5}}, 10, {{0, 5}, {10, 10}});
-  this->checkAdd({{0, 5}, {30, 40}}, 10, {{0, 5}, {10, 10}, {30, 40}});
-
-  // Check adding single ranges.
-  this->checkAdd({}, {10, 20}, {{10, 20}});
-  this->checkAdd({{0, 5}}, {10, 20}, {{0, 5}, {10, 20}});
-  this->checkAdd({{0, 5}, {30, 40}}, {10, 20}, {{0, 5}, {10, 20}, {30, 40}});
-
-  // Check adding whole sets of ranges.
-  this->checkAdd({{0, 5}}, {{10, 20}}, {{0, 5}, {10, 20}});
-  // Check that ordering of ranges is as expected.
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}}, {{0, 5}, {10, 20}, {30, 40}});
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}, {50, 60}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}});
-  this->checkAdd({{10, 20}, {50, 60}}, {{0, 5}, {30, 40}, {70, 80}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}, {70, 80}});
+
+  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+  constexpr TypeParam MIN = TestFixture::getMin();
+  constexpr TypeParam MAX = TestFixture::getMax();
+  constexpr TypeParam MID = TestFixture::getMid();
+  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
+  constexpr TypeParam B = MID - TestFixture::fromInt(42);
+  constexpr TypeParam C = -B;
+  constexpr TypeParam D = -A;
+
+  // LHS and RHS is empty.
+  // RHS =>
+  // LHS => =
+  //___   ___
+  this->checkAdd({}, {}, {});
+
+  // RHS is empty.
+  // RHS =>
+  // LHS =>_=_
+  //__/_\__   __/_\__
+  this->checkAdd({{A, B}}, {}, {{A, B}});
+  this->checkAdd({{A, B}, {C, D}}, {}, {{A, B}, {C, D}});
+
+  // LHS is empty.
+  // RHS => ___
+  // LHS =>/   \=_
+  //__/_\__   __/_\__
+  this->checkAdd({}, B, {{B, B}});
+  this->checkAdd({}, {B, C}, {{B, C}});
+  this->checkAdd({}, {{MIN, B}, {C, MAX}}, {{MIN, B}, {C, MAX}});
+
+  // RHS is detached from LHS.
+  // RHS => ___
+  // LHS =>___ /   \=___ _
+  //__/___\___/_\__   __/___\___/_\__
+  this->checkAdd({{A, C}}, D, {{A, C}, {D, D}});
+  this->checkAdd({{MID, C}, {D, MAX}}, A, {{A, A}, {MID, C}, {D, MAX}});
+  this->checkAdd({{A, B}}, {MID, D}, {{A, B}, {MID, D}});
+  this->checkAdd({{MIN, A}, {D, MAX}}, {B, C}, {{MIN, A}, {B, C}, {D, MAX}});
+  this->checkAdd({{B, MID}, {D, MAX}}, {{MIN, A}, {C, C}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkAdd({{MIN, A}, {C, C}}, {{B, MID}, {D, MAX}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+
+  // RHS is inside LHS.
+  // RHS 

[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

Thanks for working on improvements of the solver and constraints!  However, I 
have some tough questions about this patch.

What I really want to understand here is motivation.  Why do we need to have 
`add` operation semantics like this in the first place?  My guess is that "the 
user" will be in the following patch.
Additionally, I don't really like the idea of replacing something simple and 
fast (old `add` methods`) with something more complex unconditionally.  Old 
users still don't need this additional logic.  C++ has always been the language 
where we "pay for what we use".
So, with good motivation, I'd still prefer methods like `add` and 
`addUnchecked` or smith similar.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:128
 ///
-/// Complexity: O(N + M)
+/// Complexity: O(N + Mlog(N))
 /// where N = size(LHS), M = size(RHS)

This most certainly can be done in `O(N + M)` the same way the intersection is 
done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

___
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-04-02 Thread Amy Huang via Phabricator via cfe-commits
akhuang added a comment.

In Chrome we noticed that plugin flags are not being roundtripped (and build 
fails with `error: Generated arguments do not match in round-trip`):

example of the differing args:

  "-plugin-arg-blink-gc-plugin"
  "no-members-in-stack-allocated"
  "-plugin-arg-find-bad-constructs"
  "checked-ptr-as-trivial-member"
  "-plugin-arg-find-bad-constructs"
  "check-ipc"

vs

  "-plugin-arg-find-bad-constructs"
  "checked-ptr-as-trivial-member"
  "-plugin-arg-find-bad-constructs"
  "check-ipc"
  "-plugin-arg-blink-gc-plugin"
  "no-members-in-stack-allocated"


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


[PATCH] D99537: [OPENMP51]Initial support for the dispatch directive

2021-04-02 Thread Mike Rice via Phabricator via cfe-commits
mikerice added a comment.

@jyu2 is currently working on the novariants and nocontext clauses.  We are 
still working on the overall construct so I'm not sure yet what more we will 
have to contribute.

I'll look into updating the support doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99537

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 334969.
jyu2 added a comment.

Thank you, Alexey for the review!!!
This changes have been addressed as you suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/OpenMP/dispatch_ast_print.cpp
  clang/test/OpenMP/dispatch_messages.cpp
  clang/tools/libclang/CIndex.cpp
  flang/lib/Semantics/check-omp-structure.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -276,6 +276,10 @@
 def OMPC_Destroy : Clause<"destroy"> {
   let clangClass = "OMPDestroyClause";
 }
+def OMPC_Novariants : Clause<"novariants"> {
+  let clangClass = "OMPNovariantsClause";
+  let flangClass = "ScalarLogicalExpr";
+}
 def OMPC_Detach : Clause<"detach"> {
   let clangClass = "OMPDetachClause";
 }
@@ -1660,7 +1664,8 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
-VersionedClause
+VersionedClause,
+VersionedClause
   ];
 }
 def OMP_Unknown : Directive<"unknown"> {
Index: flang/lib/Semantics/check-omp-structure.cpp
===
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -729,6 +729,7 @@
 CHECK_SIMPLE_CLAUSE(Write, OMPC_write)
 CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
 CHECK_SIMPLE_CLAUSE(Use, OMPC_use)
+CHECK_SIMPLE_CLAUSE(Novariants, OMPC_novariants)
 
 CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -2291,6 +2291,10 @@
 Visitor->AddStmt(C->getInteropVar());
 }
 
+void OMPClauseEnqueue::VisitOMPNovariantsClause(const OMPNovariantsClause *C) {
+  Visitor->AddStmt(C->getCondition());
+}
+
 void OMPClauseEnqueue::VisitOMPUnifiedAddressClause(
 const OMPUnifiedAddressClause *) {}
 
Index: clang/test/OpenMP/dispatch_messages.cpp
===
--- clang/test/OpenMP/dispatch_messages.cpp
+++ clang/test/OpenMP/dispatch_messages.cpp
@@ -28,6 +28,24 @@
   // expected-error@+1 {{cannot contain more than one 'nowait' clause}}
   #pragma omp dispatch nowait device(dnum) nowait
   disp_call();
+
+  // expected-error@+1 {{expected '(' after 'novariants'}}
+  #pragma omp dispatch novariants
+  disp_call();
+
+  // expected-error@+3 {{expected expression}}
+  // expected-error@+2 {{expected ')'}}
+  // expected-note@+1 {{to match this '('}}
+  #pragma omp dispatch novariants (
+  disp_call();
+
+  // expected-error@+1 {{cannot contain more than one 'novariants' clause}}
+  #pragma omp dispatch novariants(dnum> 4) novariants(3)
+  disp_call();
+
+  // expected-error@+1 {{use of undeclared identifier 'x'}}
+  #pragma omp dispatch novariants(x)
+  disp_call();
 }
 
 void testit_two() {
Index: clang/test/OpenMP/dispatch_ast_print.cpp
===
--- clang/test/OpenMP/dispatch_ast_print.cpp
+++ clang/test/OpenMP/dispatch_ast_print.cpp
@@ -51,20 +51,22 @@
 void test_one()
 {
   int aaa, bbb, var;
-  //PRINT: #pragma omp dispatch depend(in : var) nowait
+  //PRINT: #pragma omp dispatch depend(in : var) nowait novariants(aaa > 5)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDependClause
   //DUMP: OMPNowaitClause
-  #pragma omp dispatch depend(in:var) nowait
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch depend(in:var) nowait novariants(aaa > 5)
   foo(aaa, &bbb);
 
   int *dp = get_device_ptr();
   int dev = get_device();
-  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //PRINT: #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   //DUMP: OMPDispatchDirective
   //DUMP: OMPDeviceClause
   //DUMP: OMPIs_device_ptrClause
-  #pragma omp dispatch device(dev) is_device_ptr(dp)
+  //DUMP: OMPNovariantsClause
+  #pragma omp dispatch device(dev) is_device_ptr(dp) novariants(dev > 10)
   foo(aaa, dp);
 
   //PRINT: #pragma omp dispatch
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6237,6 +6237,12 @@
   Record.AddSourceLocation(C->getV

[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D99797#2666358 , @vsavchenko wrote:

> Thanks for working on improvements of the solver and constraints!  However, I 
> have some tough questions about this patch.
>
> What I really want to understand here is motivation.  Why do we need to have 
> `add` operation semantics like this in the first place?  My guess is that 
> "the user" will be in the following patch.
> Additionally, I don't really like the idea of replacing something simple and 
> fast (old `add` methods`) with something more complex unconditionally.  Old 
> users still don't need this additional logic.  C++ has always been the 
> language where we "pay for what we use".
> So, with good motivation, I'd still prefer methods like `add` and 
> `addUnchecked` or smith similar.

My motivation is that I'm currently working on some bigger improvement 
(symbolic integral cast) and stucked here of the lack of handling 
intersections. Would you mind of accepting this revision in case if I restore 
complexity to O(N+M)?




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:128
 ///
-/// Complexity: O(N + M)
+/// Complexity: O(N + Mlog(N))
 /// where N = size(LHS), M = size(RHS)

vsavchenko wrote:
> This most certainly can be done in `O(N + M)` the same way the intersection 
> is done.
Actually yes, it can. And it was, when I played with different solutions. But 
the code was poor readable. So I decided make it easier to understand to bring 
to review. Of couse I can move further to improve it and retain readability. 
I'll do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:13567-13568
+case OMPD_dispatch:
+  CaptureRegion = OMPD_task;
+  break;
+default:

What about other directives?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

___
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-04-02 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added a comment.

In D97462#2666366 , @akhuang wrote:

> In Chrome we noticed that plugin flags are not being roundtripped (and build 
> fails with `error: Generated arguments do not match in round-trip`):
>
> example of the differing args:
>
>   "-plugin-arg-blink-gc-plugin"
>   "no-members-in-stack-allocated"
>   "-plugin-arg-find-bad-constructs"
>   "checked-ptr-as-trivial-member"
>   "-plugin-arg-find-bad-constructs"
>   "check-ipc"
>
> vs
>
>   "-plugin-arg-find-bad-constructs"
>   "checked-ptr-as-trivial-member"
>   "-plugin-arg-find-bad-constructs"
>   "check-ipc"
>   "-plugin-arg-blink-gc-plugin"
>   "no-members-in-stack-allocated"

Thanks for reporting that. D99606  fixes one 
aspect of `-plugin-arg`, but it seems the order of generation is 
non-deterministic (most likely related to the underlying storage, 
`std::unordered_map`). I can look into it early next week, but I think simple 
sort in the generation code should do the trick.


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


[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2021-04-02 Thread Frank Derry Wanye via Phabricator via cfe-commits
ffrankies updated this revision to Diff 334979.
ffrankies added a comment.

- Rebased on top of latest changes in main branch
- The diagnostic that identifies the code location where an ID-dependent 
variable/field is assigned has been changed from a warning to a note
- Changes addressing code style


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

https://reviews.llvm.org/D70094

Files:
  clang-tools-extra/clang-tidy/altera/AlteraTidyModule.cpp
  clang-tools-extra/clang-tidy/altera/CMakeLists.txt
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.cpp
  clang-tools-extra/clang-tidy/altera/IdDependentBackwardBranchCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/altera-id-dependent-backward-branch.cpp
@@ -0,0 +1,86 @@
+// RUN: %check_clang_tidy %s altera-id-dependent-backward-branch %t -- -header-filter=.* "--" -cl-std=CL1.2 -c --include opencl-c.h
+
+typedef struct ExampleStruct {
+  int IDDepField;
+} ExampleStruct;
+
+void error() {
+  //  Conditional Expressions 
+  int accumulator = 0;
+  for (int i = 0; i < get_local_id(0); i++) {
+// CHECK-NOTES: :[[@LINE-1]]:19: warning: backward branch (for loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  int j = 0;
+  while (j < get_local_id(0)) {
+// CHECK-NOTES: :[[@LINE-1]]:10: warning: backward branch (while loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < get_local_id(0));
+  // CHECK-NOTES: :[[@LINE-1]]:12: warning: backward branch (do loop) is ID-dependent due to ID function call and may cause performance degradation [altera-id-dependent-backward-branch]
+
+  //  Assignments 
+  int ThreadID = get_local_id(0);
+
+  while (j < ThreadID) {
+// CHECK-NOTES: :[[@LINE-3]]:3: note: assignment of ID-dependent variable ThreadID
+// CHECK-NOTES: :[[@LINE-2]]:10: warning: backward branch (while loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  ExampleStruct Example;
+  Example.IDDepField = get_local_id(0);
+
+  //  Inferred Assignments 
+  int ThreadID2 = ThreadID * get_local_size(0);
+
+  int ThreadID3 = Example.IDDepField; // OK: not used in any loops
+
+  ExampleStruct UnusedStruct = {
+  ThreadID * 2 // OK: not used in any loops
+  };
+
+  for (int i = 0; i < ThreadID2; i++) {
+// CHECK-NOTES: :[[@LINE-9]]:3: note: inferred assignment of ID-dependent value from ID-dependent variable ThreadID
+// CHECK-NOTES: :[[@LINE-2]]:19: warning: backward branch (for loop) is ID-dependent due to variable reference to 'ThreadID2' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < ThreadID);
+  // CHECK-NOTES: :[[@LINE-29]]:3: note: assignment of ID-dependent variable ThreadID
+  // CHECK-NOTES: :[[@LINE-2]]:12: warning: backward branch (do loop) is ID-dependent due to variable reference to 'ThreadID' and may cause performance degradation [altera-id-dependent-backward-branch]
+
+  for (int i = 0; i < Example.IDDepField; i++) {
+// CHECK-NOTES: :[[@LINE-24]]:3: note: assignment of ID-dependent field IDDepField
+// CHECK-NOTES: :[[@LINE-2]]:19: warning: backward branch (for loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  while (j < Example.IDDepField) {
+// CHECK-NOTES: :[[@LINE-30]]:3: note: assignment of ID-dependent field IDDepField
+// CHECK-NOTES: :[[@LINE-2]]:10: warning: backward branch (while loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+accumulator++;
+  }
+
+  do {
+accumulator++;
+  } while (j < Example.IDDepField);
+  // CHECK-NOTES: :[[@LINE-38]]:3: note: assignment of ID-dependent field IDDepField
+  // CHECK-NOTES: :[[@LINE-2]]:12: warning: backward branch (do loop) is ID-dependent due to member reference to 'IDDepField' and may cause performance degradation [altera-id-dependent-backward-branch]
+}
+
+void success() {
+  int accumulator = 0;
+
+  for (int i = 0; i < 1000; i++) {
+if (i < get_local_id(0)) {
+  accumulator++;
+}
+  }
+}
Index: clang-

[PATCH] D99517: Implemented [[clang::musttail]] attribute for guaranteed tail calls.

2021-04-02 Thread Josh Haberman via Phabricator via cfe-commits
haberman updated this revision to Diff 334985.
haberman added a comment.

- Fixed unit test by running `opt` in a separate invocation.
- Formatting fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99517

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprCXX.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/CodeGen/EHScopeStack.h
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/CodeGen/attr-musttail.cpp
  clang/test/Sema/attr-musttail.c
  clang/test/Sema/attr-musttail.cpp
  clang/test/Sema/attr-musttail.m

Index: clang/test/Sema/attr-musttail.m
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.m
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void TestObjcBlock(void) {
+  void (^x)(void) = ^(void) {
+__attribute__((musttail)) return TestObjcBlock(); // expected-error{{'musttail' attribute cannot be used from Objective-C blocks}}
+  };
+  __attribute__((musttail)) return x();
+}
Index: clang/test/Sema/attr-musttail.cpp
===
--- /dev/null
+++ clang/test/Sema/attr-musttail.cpp
@@ -0,0 +1,189 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fms-extensions -fexceptions %s
+
+int ReturnsInt1();
+int Func1() {
+  [[clang::musttail]] ReturnsInt1();   // expected-error {{'musttail' attribute only applies to return statements}}
+  [[clang::musttail(1, 2)]] return ReturnsInt1(); // expected-error {{'musttail' attribute takes no arguments}}
+  [[clang::musttail]] return 5;// expected-error {{'musttail' attribute requires that the return value is the result of a function call}}
+  [[clang::musttail]] return ReturnsInt1();
+}
+
+[[clang::musttail]] static int int_val = ReturnsInt1(); // expected-error {{'musttail' attribute cannot be applied to a declaration}}
+
+void NoParams(); // expected-note {{target function has different number of parameters (expected 1 but has 0)}}
+void TestParamArityMismatch(int x) {
+  [[clang::musttail]] return NoParams(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void LongParam(long x); // expected-note {{target function has type mismatch at 1st parameter (expected 'long' but has 'int')}}
+void TestParamTypeMismatch(int x) {
+  [[clang::musttail]] return LongParam(x); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+long ReturnsLong(); // expected-note {{target function has different return type ('int' expected but has 'long')}}
+int TestReturnTypeMismatch() {
+  [[clang::musttail]] return ReturnsLong(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+struct Struct1 {
+  void MemberFunction(); // expected-note {{target function is a member of different class (expected 'void' but has 'Struct1')}}
+};
+void TestNonMemberToMember() {
+  Struct1 st;
+  [[clang::musttail]] return st.MemberFunction(); // expected-error {{'musttail' attribute requires that caller and callee have compatible function signatures}}
+}
+
+void ReturnsVoid(); // expected-note {{target function is a member of different class (expected 'Struct2' but has 'void')}}
+struct Struct2 {
+  void TestMemberToNonMember() {
+[[clang::musttail]] return ReturnsVoid(); // expected-error{{'musttail' attribute requires that caller and callee have compatible function signatures}}
+  }
+};
+
+class HasNonTrivialDestructor {
+public:
+  ~HasNonTrivialDestructor() {}
+  int ReturnsInt();
+};
+
+void ReturnsVoid2();
+void TestNonTrivialDestructorInScope() {
+  HasNonTrivialDestructor foo;  // expected-note {{jump exits scope of variable with non-trivial destructor}}
+  [[clang::musttail]] return ReturnsVoid(); // expected-error {{'musttail' attribute requires that all variables in scope are trivially destructible}}
+}
+
+int NonTrivialParam(HasNonTrivialDestructor x);
+int TestNonTrivialParam(HasNonTrivialDestructor x) {
+  [[clang::musttail]] return NonTrivialParam(x); // expected-error {{'musttail' attribute requires that the return value, all parameters, and any temporaries created by the expression are trivially destructible and do not require ARC}}
+}
+
+HasNonTrivialDestructor ReturnsNonTrivialValue();
+HasNonTrivialDestructor TestReturnsNonTrivialValue() {
+  [[clang::musttail]] return (ReturnsNonTrivialValue()); // expected-error {{'musttail' attribute requires that 

[PATCH] D70094: [clang-tidy] new altera ID dependent backward branch check

2021-04-02 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/altera-id-dependent-backward-branch.rst:9
+
+Based on the `Altera SDK for OpenCL: Best Practices Guide
+`_.

Usually link to external documentation is placed at the end. See other checks 
documentation as example.


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

https://reviews.llvm.org/D70094

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


[PATCH] D98856: Always emit error for wrong interfaces to scalable vectors, unless cmdline flag is passed.

2021-04-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:5066
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
+  }

Does this introduce an option in the CC1 command line for most cases? We should 
shorten the CC1 command line for common cases...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98856

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko
OK, what do you think of ***adjacency*** feature? I mean it simplifies such 
ranges `[1,2][3,4][5,6]` to `[1,6]`. Is it worth for implementation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99797

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



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

probinson wrote:
> I think we don't want this enabled by default at -O0.  It doesn't run any 
> optimizations that should eliminate parameters, so this is going to increase 
> debug info size for no real benefit to the debugging experience.
+1 to @probinson here. That's generally been the thinking behind why this was 
only enabled when optimizations are enabled. (there's some minor tradeoff here: 
call site descriptions in unoptimized code can still be useful if they call 
into optimized code, so this is a bit heuristical - assuming that all code will 
be compiled with the same optimization level)

If flang is in a different situation and enables some optimizations at -O0 that 
make call site parameter descriptions beneficial even there, then maybe we'll 
need some different way to differentiate optimizations V no optimizations for 
the purpose of this feature.


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

https://reviews.llvm.org/D99238

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


[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/test/Parser/cxx0x-attributes.cpp:377
+  template  friend class[[]] vector2; 
// expected-error {{an attribute list cannot appear 
here}}
+  template  friend class 
[[clang::__type_visibility__(("default"))]] vector3; // expected-error {{an 
attribute list cannot appear here}}
+

Can you also add a test for `__declspec` attributes, like `template  friend class __declspec(code_seg("whatever")) vector4;`? That is 
accepted by MSVC: https://godbolt.org/z/b8Gc3Y4Tr


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

https://reviews.llvm.org/D75844

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok marked 2 inline comments as done.
alok added inline comments.



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

dblaikie wrote:
> probinson wrote:
> > I think we don't want this enabled by default at -O0.  It doesn't run any 
> > optimizations that should eliminate parameters, so this is going to 
> > increase debug info size for no real benefit to the debugging experience.
> +1 to @probinson here. That's generally been the thinking behind why this was 
> only enabled when optimizations are enabled. (there's some minor tradeoff 
> here: call site descriptions in unoptimized code can still be useful if they 
> call into optimized code, so this is a bit heuristical - assuming that all 
> code will be compiled with the same optimization level)
> 
> If flang is in a different situation and enables some optimizations at -O0 
> that make call site parameter descriptions beneficial even there, then maybe 
> we'll need some different way to differentiate optimizations V no 
> optimizations for the purpose of this feature.
Thanks Paul for the comment. I shall probably add an option to enable in such 
cases which should remain off by default, Flang driver can pass that to 
compiler to turn it on.



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

alok wrote:
> dblaikie wrote:
> > probinson wrote:
> > > I think we don't want this enabled by default at -O0.  It doesn't run any 
> > > optimizations that should eliminate parameters, so this is going to 
> > > increase debug info size for no real benefit to the debugging experience.
> > +1 to @probinson here. That's generally been the thinking behind why this 
> > was only enabled when optimizations are enabled. (there's some minor 
> > tradeoff here: call site descriptions in unoptimized code can still be 
> > useful if they call into optimized code, so this is a bit heuristical - 
> > assuming that all code will be compiled with the same optimization level)
> > 
> > If flang is in a different situation and enables some optimizations at -O0 
> > that make call site parameter descriptions beneficial even there, then 
> > maybe we'll need some different way to differentiate optimizations V no 
> > optimizations for the purpose of this feature.
> Thanks Paul for the comment. I shall probably add an option to enable in such 
> cases which should remain off by default, Flang driver can pass that to 
> compiler to turn it on.
Thanks David for your explanation and thoughts. Please also look at trigger to 
this https://reviews.llvm.org/D99160

It is needed in a Fortran case. I shall probably drop to enable it by default 
and add an option which by default is disabled and Fortran driver can pass that 
to make use of it.


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

https://reviews.llvm.org/D99238

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


[clang] b001d57 - [RISCV] Add IR intrinsic for Zbr extension

2021-04-02 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-02T10:58:45-07:00
New Revision: b001d574d7d94bcf1508fa4cdc22e02a0bf4adea

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

LOG: [RISCV] Add IR intrinsic for Zbr extension

Implementation for RISC-V Zbr extension intrinsic.

Header files are included in separate patch in case the name needs to be changed

RV32 / 64:
crc32b
crc32h
crc32w
crc32cb
crc32ch
crc32cw

RV64 Only:
crc32d
crc32cd

Reviewed By: craig.topper

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbr.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbr.c
llvm/test/CodeGen/RISCV/rv32zbr.ll
llvm/test/CodeGen/RISCV/rv64zbr.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index c91b3d1b1f5c1..7197b3df26212 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,5 +17,15 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+// Zbr extension
+TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32_w, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_b, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_h, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_w, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32_d, "LiLi", "nc", "experimental-zbr")
+TARGET_BUILTIN(__builtin_riscv_crc32c_d, "LiLi", "nc", "experimental-zbr")
+
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d51a01837fc93..91246ccba6fa0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11185,7 +11185,7 @@ def warn_tcb_enforcement_violation : Warning<
   "calling %0 is a violation of trusted computing base '%1'">,
   InGroup>;
 
-// RISC-V V-extension
-def err_riscvv_builtin_requires_v : Error<
-   "builtin requires 'V' extension support to be enabled">;
+// RISC-V builtin required extension warning
+def err_riscv_builtin_requires_extension : Error<
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 86ea4ac28ae86..fc5b7ce6bcca2 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17876,6 +17876,44 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   llvm::SmallVector IntrinsicTypes;
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
+
+  // Zbr
+  case RISCV::BI__builtin_riscv_crc32_b:
+ID = Intrinsic::riscv_crc32_b;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32_h:
+ID = Intrinsic::riscv_crc32_h;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32_w:
+ID = Intrinsic::riscv_crc32_w;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32_d:
+ID = Intrinsic::riscv_crc32_d;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_b:
+ID = Intrinsic::riscv_crc32c_b;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_h:
+ID = Intrinsic::riscv_crc32c_h;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_w:
+ID = Intrinsic::riscv_crc32c_w;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_crc32c_d:
+ID = Intrinsic::riscv_crc32c_d;
+IntrinsicTypes = {ResultType};
+break;
+  default: {
+llvm_unreachable("unexpected builtin ID");
+return nullptr;
+  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 305fcd574a373..a128fae78b9d0 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3415,13 +3415,27 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const 
TargetInfo &TI,
  CallExpr *TheCall) {
   // CodeGenFunction can al

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

2021-04-02 Thread Craig Topper 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 rGb001d574d7d9: [RISCV] Add IR intrinsic for Zbr extension 
(authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D99009?vs=334331&id=334990#toc

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(

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Saurabh Jha via Phabricator via cfe-commits
SaurabhJha added inline comments.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

fhahn wrote:
> This doesn't seem right. We are casting between 2 signed types, so the sign 
> should get preserved, right? Shouldn't this be `sext`? See 
> https://godbolt.org/z/zWznYdnKW for the scalar case.
> 
> I think you also need tests for casts with different bitwidths with unsigned, 
> unsigned -> signed & signed -> unsigned.
This is happening because we are always passing inSigned argument to 
`Builder.CreateIntCast` as false here 
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1348.
 IfI change it to `true`, it generates `sext` instructions.

I am figuring out how can I determine sign of src and dest type. Because 
`SrcTy` and `DestTy` are vectors here, they are unsigned and `SrcElementTy` and 
`DestElementTy` have no method like `isSignedIntegerOrEnumerationType`. Once 
that's solved, this should be fixed.



Comment at: clang/test/CodeGen/matrix-cast.c:39
+
+  f = (fx5x5)i;
+}

fhahn wrote:
> SaurabhJha wrote:
> > I tried adding a float -> int conversion too but it failed because of this 
> > assertion 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1339-L1344
> >  Hopefully that's intended.
> Clang should never run into an assertion. If that should not be allowed, then 
> Clang should emit an error during Sema. I'm not sure why there is such a 
> restriction for vector types, but I am not sure that this shouldn't be 
> allowed for matrixes. Perhaps @rjmccall has more thoughts on this, but 
> conversion between scalar ints to floats is allowed AFAIKT.
I can probably try removing that assert and see if some other unit or lit tests 
are failing. We can then make a decision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

___
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-04-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11190
+def err_riscv_builtin_requires_extension : Error<
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

This lost the quotes



Comment at: clang/lib/Sema/SemaChecking.cpp:3427
+  continue;
+// Make message like "experimental-zbr" to "Zbr"
+I.consume_front("experimental-");

both to improve the English and to be clear that this is for non-experimental 
feature strings too



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:19
+
+class BitMan_GPR_Intrinsics
+: Intrinsic<[llvm_any_ty],

This file, like the rest of LLVM, uses a 2-space indent, not 4.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



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

alok wrote:
> alok wrote:
> > dblaikie wrote:
> > > probinson wrote:
> > > > I think we don't want this enabled by default at -O0.  It doesn't run 
> > > > any optimizations that should eliminate parameters, so this is going to 
> > > > increase debug info size for no real benefit to the debugging 
> > > > experience.
> > > +1 to @probinson here. That's generally been the thinking behind why this 
> > > was only enabled when optimizations are enabled. (there's some minor 
> > > tradeoff here: call site descriptions in unoptimized code can still be 
> > > useful if they call into optimized code, so this is a bit heuristical - 
> > > assuming that all code will be compiled with the same optimization level)
> > > 
> > > If flang is in a different situation and enables some optimizations at 
> > > -O0 that make call site parameter descriptions beneficial even there, 
> > > then maybe we'll need some different way to differentiate optimizations V 
> > > no optimizations for the purpose of this feature.
> > Thanks Paul for the comment. I shall probably add an option to enable in 
> > such cases which should remain off by default, Flang driver can pass that 
> > to compiler to turn it on.
> Thanks David for your explanation and thoughts. Please also look at trigger 
> to this https://reviews.llvm.org/D99160
> 
> It is needed in a Fortran case. I shall probably drop to enable it by default 
> and add an option which by default is disabled and Fortran driver can pass 
> that to make use of it.
Sounds like @djtodoro is suggesting in https://reviews.llvm.org/D99160#2666106 
that the "Bug" to fix here is the presence of DW_OP_call_value at -O0, it seems 
that could be an issue for the existing/original use of 
call_site_parameter/call_value (in C++/clang) as it would be for flang - so the 
fix should probably not be flang-specific if the issue isn't flang-specific. 
Understanding why we produce DW_OP_call_values at -O0, whether we can/should 
avoid that, what it costs (how much larger the debug info gets by adding 
DW_TAG_call_sites at -O0) would be necessary to determine the right path 
forward here.


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

https://reviews.llvm.org/D99238

___
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-04-02 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11190
+def err_riscv_builtin_requires_extension : Error<
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

jrtc27 wrote:
> This lost the quotes
I will fix when I rebase Zbb on top of this



Comment at: clang/lib/Sema/SemaChecking.cpp:3427
+  continue;
+// Make message like "experimental-zbr" to "Zbr"
+I.consume_front("experimental-");

jrtc27 wrote:
> both to improve the English and to be clear that this is for non-experimental 
> feature strings too
I will fix when I rebase Zbb on top of this



Comment at: llvm/include/llvm/IR/IntrinsicsRISCV.td:19
+
+class BitMan_GPR_Intrinsics
+: Intrinsic<[llvm_any_ty],

jrtc27 wrote:
> This file, like the rest of LLVM, uses a 2-space indent, not 4.
I will fix when I rebase Zbb on top of this. I'll also move it below atomics.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

___
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-04-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Thanks, and good point re ordering


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D99238: [DebugInfo] Enable the call site parameter feature by default

2021-04-02 Thread Alok Kumar Sharma via Phabricator via cfe-commits
alok marked an inline comment as done.
alok added inline comments.



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

dblaikie wrote:
> alok wrote:
> > alok wrote:
> > > dblaikie wrote:
> > > > probinson wrote:
> > > > > I think we don't want this enabled by default at -O0.  It doesn't run 
> > > > > any optimizations that should eliminate parameters, so this is going 
> > > > > to increase debug info size for no real benefit to the debugging 
> > > > > experience.
> > > > +1 to @probinson here. That's generally been the thinking behind why 
> > > > this was only enabled when optimizations are enabled. (there's some 
> > > > minor tradeoff here: call site descriptions in unoptimized code can 
> > > > still be useful if they call into optimized code, so this is a bit 
> > > > heuristical - assuming that all code will be compiled with the same 
> > > > optimization level)
> > > > 
> > > > If flang is in a different situation and enables some optimizations at 
> > > > -O0 that make call site parameter descriptions beneficial even there, 
> > > > then maybe we'll need some different way to differentiate optimizations 
> > > > V no optimizations for the purpose of this feature.
> > > Thanks Paul for the comment. I shall probably add an option to enable in 
> > > such cases which should remain off by default, Flang driver can pass that 
> > > to compiler to turn it on.
> > Thanks David for your explanation and thoughts. Please also look at trigger 
> > to this https://reviews.llvm.org/D99160
> > 
> > It is needed in a Fortran case. I shall probably drop to enable it by 
> > default and add an option which by default is disabled and Fortran driver 
> > can pass that to make use of it.
> Sounds like @djtodoro is suggesting in 
> https://reviews.llvm.org/D99160#2666106 that the "Bug" to fix here is the 
> presence of DW_OP_call_value at -O0, it seems that could be an issue for the 
> existing/original use of call_site_parameter/call_value (in C++/clang) as it 
> would be for flang - so the fix should probably not be flang-specific if the 
> issue isn't flang-specific. Understanding why we produce DW_OP_call_values at 
> -O0, whether we can/should avoid that, what it costs (how much larger the 
> debug info gets by adding DW_TAG_call_sites at -O0) would be necessary to 
> determine the right path forward here.
Thanks David for clarification. I shall look at it and get back.


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

https://reviews.llvm.org/D99238

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:13567-13568
+case OMPD_dispatch:
+  CaptureRegion = OMPD_task;
+  break;
+default:

ABataev wrote:
> What about other directives?
Hi Alexey,

As of now "novariants" clause only allowed in disapatch directive.  And 
dispatch directive can have implicit task directive. So for other directives 
will be unreachable.  Am I missing something here?  
Thanks.
Jennifer


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[clang] 1808194 - [RISCV] Add IR intrinsic for Zbb extension

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T11:23:57-07:00
New Revision: 1808194590dd2b308bc146406425d5d52e46b7e6

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

LOG: [RISCV] Add IR intrinsic for Zbb extension

Header files are included in a separate patch in case the name needs to be 
changed.

RV32 / 64:
orc.b

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 7197b3df2621..564573ffa746 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,6 +17,10 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+// Zbb extension
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 91246ccba6fa..2d43f5d3dfa4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11187,5 +11187,5 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires %0 extension support to be enabled">;
+  "builtin requires '%0' extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fc5b7ce6bcca..899c7b944ecf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17877,6 +17877,13 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
+  // Zbb
+  case RISCV::BI__builtin_riscv_orc_b_32:
+  case RISCV::BI__builtin_riscv_orc_b_64:
+ID = Intrinsic::riscv_orc_b;
+IntrinsicTypes = {ResultType};
+break;
+
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;
@@ -17910,10 +17917,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_crc32c_d;
 IntrinsicTypes = {ResultType};
 break;
-  default: {
+  default:
 llvm_unreachable("unexpected builtin ID");
-return nullptr;
-  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a128fae78b9d..98b37f3c0265 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3424,7 +3424,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
&TI,
   for (auto &I : ReqFeatures) {
 if (TI.hasFeature(I))
   continue;
-// Make message like "experimental-zbr" to "Zbr"
+// Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
new file mode 100644
index ..4f326fea9e74
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb 
-emit-llvm %s -o - \
+// RUN: | FileCheck %s  -check-prefix=RV32ZBB
+
+// RV32ZBB-LABEL: @orcb32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int orcb32(int a) {
+  return __builtin_riscv_orc_b_32(a);
+}

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
new file mode 100644
in

[PATCH] D99808: [Sema] Move 'char-expression-as-unsigned < 0' into a separate diagnostic

2021-04-02 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev created this revision.
AntonBikineev added reviewers: aaron.ballman, thakis.
AntonBikineev requested review of this revision.
Herald added a project: clang.

This change splits '-Wtautological-unsigned-zero-compare' by reporting
char-expressions-interpreted-as-unsigned under a separate diagnostic
'-Wtautological-unsigned-char-zero-compare'. This is beneficial for
projects that want to enable '-Wtautological-unsigned-zero-compare' but at
the same time want to keep code portable for platforms with char being
signed or unsigned, such as Chromium.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99808

Files:
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/tautological-unsigned-char-zero-compare.cc

Index: clang/test/Sema/tautological-unsigned-char-zero-compare.cc
===
--- /dev/null
+++ clang/test/Sema/tautological-unsigned-char-zero-compare.cc
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN:-fno-signed-char \
+// RUN:-Wtautological-unsigned-zero-compare \
+// RUN:-Wtautological-unsigned-char-zero-compare \
+// RUN:-verify=unsigned %s
+// RUN: %clang_cc1 -fsyntax-only \
+// RUN:-Wtautological-unsigned-zero-compare \
+// RUN:-Wtautological-unsigned-char-zero-compare \
+// RUN:-verify=signed %s
+
+void f(char c, unsigned char uc, signed char cc) {
+  if (c < 0)
+return;
+  // unsigned-warning@-2 {{comparison of char expression < 0 is always false, since char is interpreted as unsigned}}
+  if (uc < 0)
+return;
+  // unsigned-warning@-2 {{comparison of unsigned expression < 0 is always false}}
+  // signed-warning@-3 {{comparison of unsigned expression < 0 is always false}}
+  if (cc < 0)
+return;
+  // Promoted to integer expressions should not warn.
+  if (c - 4 < 0)
+return;
+}
+
+void ref(char &c, unsigned char &uc, signed char &cc) {
+  if (c < 0)
+return;
+  // unsigned-warning@-2 {{comparison of char expression < 0 is always false, since char is interpreted as unsigned}}
+  if (uc < 0)
+return;
+  // unsigned-warning@-2 {{comparison of unsigned expression < 0 is always false}}
+  // signed-warning@-3 {{comparison of unsigned expression < 0 is always false}}
+  if (cc < 0)
+return;
+  // Promoted to integer expressions should not warn.
+  if (c - 4 < 0)
+return;
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -11415,11 +11415,14 @@
 << OtherIsBooleanDespiteType << *Result
 << E->getLHS()->getSourceRange() << E->getRHS()->getSourceRange());
   } else {
-unsigned Diag = (isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
-? (HasEnumType(OriginalOther)
-   ? diag::warn_unsigned_enum_always_true_comparison
-   : diag::warn_unsigned_always_true_comparison)
-: diag::warn_tautological_constant_compare;
+bool IsCharTy = OtherT.withoutLocalFastQualifiers() == S.Context.CharTy;
+unsigned Diag =
+(isKnownToHaveUnsignedValue(OriginalOther) && Value == 0)
+? (HasEnumType(OriginalOther)
+   ? diag::warn_unsigned_enum_always_true_comparison
+   : IsCharTy ? diag::warn_unsigned_char_always_true_comparison
+  : diag::warn_unsigned_always_true_comparison)
+: diag::warn_tautological_constant_compare;
 
 S.Diag(E->getOperatorLoc(), Diag)
 << RhsConstant << OtherT << E->getOpcodeStr() << OS.str() << *Result
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6784,6 +6784,10 @@
   "result of comparison of %select{%3|unsigned expression}0 %2 "
   "%select{unsigned expression|%3}0 is always %4">,
   InGroup, DefaultIgnore;
+def warn_unsigned_char_always_true_comparison : Warning<
+  "result of comparison of %select{%3|char expression}0 %2 "
+  "%select{char expression|%3}0 is always %4, since char is interpreted as "
+  "unsigned">, InGroup, DefaultIgnore;
 def warn_unsigned_enum_always_true_comparison : Warning<
   "result of comparison of %select{%3|unsigned enum expression}0 %2 "
   "%select{unsigned enum expression|%3}0 is always %4">,
Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -591,11 +591,13 @@
 def IntInBoolContext : DiagGroup<"int-in-bool-context">;
 def TautologicalTypeLimi

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added inline comments.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

SaurabhJha wrote:
> fhahn wrote:
> > This doesn't seem right. We are casting between 2 signed types, so the sign 
> > should get preserved, right? Shouldn't this be `sext`? See 
> > https://godbolt.org/z/zWznYdnKW for the scalar case.
> > 
> > I think you also need tests for casts with different bitwidths with 
> > unsigned, unsigned -> signed & signed -> unsigned.
> This is happening because we are always passing inSigned argument to 
> `Builder.CreateIntCast` as false here 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1348.
>  IfI change it to `true`, it generates `sext` instructions.
> 
> I am figuring out how can I determine sign of src and dest type. Because 
> `SrcTy` and `DestTy` are vectors here, they are unsigned and `SrcElementTy` 
> and `DestElementTy` have no method like `isSignedIntegerOrEnumerationType`. 
> Once that's solved, this should be fixed.
Oh right, I think I see what's going on. I think the code you are referring to 
is specifically for the vector types in Clang, but it is checking the LLVM type 
and we also use LLVM IR vector types for matrix values, so the code 
accidentally also covers matrix values at the moment. 

I *think* we should probably handled matrix values separately in this function. 
@rjmccall what do you think?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

___
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-04-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D97462#2666485 , @jansvoboda11 
wrote:

> Thanks for reporting that. D99606  fixes one 
> aspect of `-plugin-arg`, but it seems the order of generation is 
> non-deterministic (most likely related to the underlying storage, 
> `std::unordered_map`). I can look into it early next week, but I think simple 
> sort in the generation code should do the trick.

Can/should it just be changed to a `std::map`?


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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:13567-13568
+case OMPD_dispatch:
+  CaptureRegion = OMPD_task;
+  break;
+default:

jyu2 wrote:
> ABataev wrote:
> > What about other directives?
> Hi Alexey,
> 
> As of now "novariants" clause only allowed in disapatch directive.  And 
> dispatch directive can have implicit task directive. So for other directives 
> will be unreachable.  Am I missing something here?  
> Thanks.
> Jennifer
No, I just was not aware of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[clang] 1f0b309 - Revert "[RISCV] Add IR intrinsic for Zbb extension"

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T11:47:02-07:00
New Revision: 1f0b309f24ba7ed144ddcd20cccedc284d990074

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

LOG: Revert "[RISCV] Add IR intrinsic for Zbb extension"

This reverts commit 1808194590dd2b308bc146406425d5d52e46b7e6.

I forgot to change the author.

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll



diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 564573ffa746..7197b3df2621 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,10 +17,6 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
-// Zbb extension
-TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
-TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
-
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 2d43f5d3dfa4..91246ccba6fa 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11187,5 +11187,5 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires '%0' extension support to be enabled">;
+  "builtin requires %0 extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 899c7b944ecf..fc5b7ce6bcca 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17877,13 +17877,6 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
-  // Zbb
-  case RISCV::BI__builtin_riscv_orc_b_32:
-  case RISCV::BI__builtin_riscv_orc_b_64:
-ID = Intrinsic::riscv_orc_b;
-IntrinsicTypes = {ResultType};
-break;
-
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;
@@ -17917,8 +17910,10 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_crc32c_d;
 IntrinsicTypes = {ResultType};
 break;
-  default:
+  default: {
 llvm_unreachable("unexpected builtin ID");
+return nullptr;
+  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 98b37f3c0265..a128fae78b9d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3424,7 +3424,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
&TI,
   for (auto &I : ReqFeatures) {
 if (TI.hasFeature(I))
   continue;
-// Convert features like "zbr" and "experimental-zbr" to "Zbr".
+// Make message like "experimental-zbr" to "Zbr"
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
deleted file mode 100644
index 4f326fea9e74..
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ /dev/null
@@ -1,15 +0,0 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
-// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb 
-emit-llvm %s -o - \
-// RUN: | FileCheck %s  -check-prefix=RV32ZBB
-
-// RV32ZBB-LABEL: @orcb32(
-// RV32ZBB-NEXT:  entry:
-// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
-// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
-// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
-// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
-// RV32ZBB-NEXT:ret i32 [[TMP1]]
-//
-int orcb32(int a) {
-  return __builtin_riscv_orc_b_32(a);
-}

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
deleted file mode 1

[clang] 944adbf - Recommit "[RISCV] Add IR intrinsic for Zbb extension"

2021-04-02 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-02T11:50:19-07:00
New Revision: 944adbf285505ac481551157c4ee3cc3c0724900

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

LOG: Recommit "[RISCV] Add IR intrinsic for Zbb extension"

Forgot to amend the Author.

Original commit message:

Header files are included in a separate patch in case the name needs to be 
changed.

RV32 / 64:
orc.b

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 7197b3df2621..564573ffa746 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -17,6 +17,10 @@
 
 #include "clang/Basic/riscv_vector_builtins.inc"
 
+// Zbb extension
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 91246ccba6fa..2d43f5d3dfa4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11187,5 +11187,5 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires %0 extension support to be enabled">;
+  "builtin requires '%0' extension support to be enabled">;
 } // end of sema component.

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fc5b7ce6bcca..899c7b944ecf 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17877,6 +17877,13 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
   switch (BuiltinID) {
 #include "clang/Basic/riscv_vector_builtin_cg.inc"
 
+  // Zbb
+  case RISCV::BI__builtin_riscv_orc_b_32:
+  case RISCV::BI__builtin_riscv_orc_b_64:
+ID = Intrinsic::riscv_orc_b;
+IntrinsicTypes = {ResultType};
+break;
+
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;
@@ -17910,10 +17917,8 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 ID = Intrinsic::riscv_crc32c_d;
 IntrinsicTypes = {ResultType};
 break;
-  default: {
+  default:
 llvm_unreachable("unexpected builtin ID");
-return nullptr;
-  } // default
   }
 
   assert(ID != Intrinsic::not_intrinsic);

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index a128fae78b9d..98b37f3c0265 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3424,7 +3424,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
&TI,
   for (auto &I : ReqFeatures) {
 if (TI.hasFeature(I))
   continue;
-// Make message like "experimental-zbr" to "Zbr"
+// Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
 FeatureStr[0] = std::toupper(FeatureStr[0]);

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
new file mode 100644
index ..593b52698d35
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbb 
-emit-llvm %s -o - \
+// RUN: | FileCheck %s  -check-prefix=RV32ZBB
+
+// RV32ZBB-LABEL: @orc_b_32(
+// RV32ZBB-NEXT:  entry:
+// RV32ZBB-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBB-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
+// RV32ZBB-NEXT:ret i32 [[TMP1]]
+//
+int orc_b_32(int a) {
+  return __builtin_riscv_orc_b_32(a);
+}

diff  --git a/clang/test/C

[PATCH] D99320: [RISCV] [1/2] Add intrinsic for Zbb extension

2021-04-02 Thread Craig Topper 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 rG944adbf28550: Recommit "[RISCV] Add IR intrinsic for 
Zbb extension" (authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D99320?vs=334322&id=335001#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99320

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-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll

Index: llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbb-intrinsic.ll
@@ -0,0 +1,37 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbb -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBB
+
+declare i32 @llvm.riscv.orc.b.i32(i32)
+
+define i32 @orcb32(i32 %a) nounwind {
+; RV64IB-LABEL: orcb32:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:orc.b a0, a0
+; RV64IB-NEXT:ret
+;
+; RV64IBB-LABEL: orcb32:
+; RV64IBB:   # %bb.0:
+; RV64IBB-NEXT:orc.b a0, a0
+; RV64IBB-NEXT:ret
+  %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
+ ret i32 %tmp
+}
+
+declare i64 @llvm.riscv.orc.b.i64(i64)
+
+define i64 @orcb64(i64 %a) nounwind {
+; RV64IB-LABEL: orcb64:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:orc.b a0, a0
+; RV64IB-NEXT:ret
+;
+; RV64IBB-LABEL: orcb64:
+; RV64IBB:   # %bb.0:
+; RV64IBB-NEXT:orc.b a0, a0
+; RV64IBB-NEXT:ret
+  %tmp = call i64 @llvm.riscv.orc.b.i64(i64 %a)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbb-intrinsic.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IB
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbb -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IBB
+
+declare i32 @llvm.riscv.orc.b.i32(i32)
+
+define i32 @orcb(i32 %a) nounwind {
+; RV32IB-LABEL: orcb:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:orc.b a0, a0
+; RV32IB-NEXT:ret
+;
+; RV32IBB-LABEL: orcb:
+; RV32IBB:   # %bb.0:
+; RV32IBB-NEXT:orc.b a0, a0
+; RV32IBB-NEXT:ret
+  %tmp = call i32 @llvm.riscv.orc.b.i32(i32 %a)
+ ret i32 %tmp
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoB.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -894,6 +894,10 @@
   (PACKUW GPR:$rs1, GPR:$rs2)>;
 } // Predicates = [HasStdExtZbp, IsRV64]
 
+let Predicates = [HasStdExtZbb] in {
+def : PatGpr;
+} // Predicates = [HasStdExtZbb]
+
 let Predicates = [HasStdExtZbr] in {
 def : PatGpr;
 def : PatGpr;
Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -198,6 +198,9 @@
 setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand);
   }
 
+  if (Subtarget.hasStdExtZbb() && Subtarget.is64Bit())
+setOperationAction(ISD::INTRINSIC_WO_CHAIN, MVT::i32, Custom);
+
   if (Subtarget.is64Bit()) {
 setOperationAction(ISD::ADD, MVT::i32, Custom);
 setOperationAction(ISD::SUB, MVT::i32, Custom);
@@ -4198,6 +4201,14 @@
 default:
   llvm_unreachable(
   "Don't know how to custom type legalize this intrinsic!");
+case Intrinsic::riscv_orc_b: {
+  SDValue Newop1 =
+  DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, N->getOperand(1));
+  SDValue Res = 
+  DAG.getNode(N->getOpcode(), DL, MVT::i64, N->getOperand(0), Newop1);
+  Results.push_back(DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, Res));
+  return;
+}
 case Intrinsic::riscv_vmv_x_s: {
   EVT VT = N->getValueType(0);
   MVT XLenVT = Subtarget.getXLenVT();
Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ llvm/include/llvm/IR/IntrinsicsRISCV.td
@@ 

[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added a reviewer: rsmith.
aaron.ballman requested review of this revision.
Herald added a project: clang.

Currently, when one or more attributes are mutually exclusive, the developer 
adding the attribute has to manually emit diagnostics. In practice, this is 
highly error prone, especially for declaration attributes, because such 
checking is not trivial. Redeclarations require you to write a "merge" function 
to diagnose mutually exclusive attributes and most attributes get this wrong.

This patch introduces a table-generated way to specify that a group of two or 
more attributes are mutually exclusive: `def : MutualExclusions<[Attr1, Attr2, 
Attr3]>;`

This works for both statement and declaration attributes (but not type 
attributes) and the checking is done either from the common attribute 
diagnostic checking code or from within `mergeDeclAttribute()` when merging 
redeclarations.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99809

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/ParsedAttr.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/attr-coldhot.c
  clang/test/Sema/attr-disable-tail-calls.c
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/attr-speculative-load-hardening.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3627,6 +3627,114 @@
   }
 }
 
+// Generates the mutual exclusion checks. The checks for parsed attributes are
+// written into OS and the checks for merging declaration attributes are
+// written into MergeOS.
+static void GenerateMutualExclusionsChecks(const Record &Attr,
+   const RecordKeeper &Records,
+   raw_ostream &OS,
+   raw_ostream &MergeOS) {
+  // Find all of the definitions that inherit from MutualExclusions and include
+  // the given attribute in the list of exclusions to generate the
+  // diagMutualExclusion() check.
+  std::vector ExclusionsList =
+  Records.getAllDerivedDefinitions("MutualExclusions");
+
+  // We don't do any of this magic for type attributes yet.
+  if (Attr.isSubClassOf("TypeAttr"))
+return;
+
+  // This means the attribute is either a statement attribute or a decl
+  // attribute, find out which.
+  bool CurAttrIsStmtAttr =
+  Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr");
+
+  std::vector DeclAttrs, StmtAttrs;
+
+  for (const Record *Exclusion : ExclusionsList) {
+std::vector MutuallyExclusiveAttrs =
+Exclusion->getValueAsListOfDefs("Exclusions");
+auto IsCurAttr = [Attr](const Record *R) {
+  return R->getName() == Attr.getName();
+};
+if (llvm::any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
+  // This list of exclusions includes the attribute we're looking for, so
+  // add the exclusive attributes to the proper list for checking.
+  for (const Record *AttrToExclude : MutuallyExclusiveAttrs) {
+if (IsCurAttr(AttrToExclude))
+  continue;
+
+if (CurAttrIsStmtAttr)
+  StmtAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+else
+  DeclAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+  }
+}
+  }
+
+  // If we discovered any decl or stmt attributes to test for, generate the
+  // predicates for them now.
+  if (!DeclAttrs.empty()) {
+// Generate the ParsedAttrInfo subclass logic for declarations.
+OS << "  bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, "
+   << "const Decl *D) const {\n";
+for (const std::string &A : DeclAttrs) {
+  OS << "if (const auto *A = D->getAttr<" << A << ">()) {\n";
+  OS << "  S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)"
+ << " << AL << A;\n";
+  OS << "  S.Diag(A->getLocation(), diag::note_conflicting_attribute);";
+  OS << "  \nreturn false;\n";
+  OS << "}\n";
+}
+OS << "return true;\n";
+OS << "  }\n\n";
+
+// Also generate the declaration attribute merging logic if the current
+// attribute is one that can be inheritted on a declaration. It is assumed
+// this code will be executed in the context of a function with parameters:
+// Sema &S, Decl *D, Attr *A and that returns a bool (false on diagnostic,
+// true on success).
+if (Attr.isSubClassOf("InheritableAttr")) {
+  MergeOS << "  if (const auto *Second = dyn_cast<"
+  << (Attr.getName() + "Attr").str() << ">(A)) {\n";
+  for (const std::string &A : DeclAttrs) {
+Merg

[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

@rsmith -- I am posting the review so that I can see how the CI pipeline likes 
the functionality (because this impacts so many different attributes), but I 
intend to commit it on my own authority once CI passes. Feel free to review it 
if you'd like and I'll address any concerns you have post-commit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99809

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


[PATCH] D99811: [TextAPI] move source code files out of subdirectory, NFC

2021-04-02 Thread Cyndy Ishida via Phabricator via cfe-commits
cishida created this revision.
cishida added reviewers: steven_wu, ributzka.
Herald added subscribers: hiraditya, mgorny.
Herald added a reviewer: int3.
Herald added a project: lld-macho.
Herald added a reviewer: lld-macho.
cishida requested review of this revision.
Herald added projects: clang, LLVM.
Herald added a subscriber: cfe-commits.

TextAPI/ELF has moved out into InterfaceStubs, so theres no longer a
need to seperate out TextAPI between formats.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D99811

Files:
  clang/docs/ClangFormattedStatus.rst
  lld/MachO/Config.h
  lld/MachO/Driver.cpp
  lld/MachO/DriverUtils.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/InputFiles.h
  lld/lib/ReaderWriter/MachO/File.h
  llvm/include/llvm/Object/TapiFile.h
  llvm/include/llvm/Object/TapiUniversal.h
  llvm/include/llvm/TextAPI/Architecture.def
  llvm/include/llvm/TextAPI/Architecture.h
  llvm/include/llvm/TextAPI/ArchitectureSet.h
  llvm/include/llvm/TextAPI/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/Architecture.def
  llvm/include/llvm/TextAPI/MachO/Architecture.h
  llvm/include/llvm/TextAPI/MachO/ArchitectureSet.h
  llvm/include/llvm/TextAPI/MachO/InterfaceFile.h
  llvm/include/llvm/TextAPI/MachO/PackedVersion.h
  llvm/include/llvm/TextAPI/MachO/Platform.h
  llvm/include/llvm/TextAPI/MachO/Symbol.h
  llvm/include/llvm/TextAPI/MachO/Target.h
  llvm/include/llvm/TextAPI/MachO/TextAPIReader.h
  llvm/include/llvm/TextAPI/MachO/TextAPIWriter.h
  llvm/include/llvm/TextAPI/PackedVersion.h
  llvm/include/llvm/TextAPI/Platform.h
  llvm/include/llvm/TextAPI/Symbol.h
  llvm/include/llvm/TextAPI/Target.h
  llvm/include/llvm/TextAPI/TextAPIReader.h
  llvm/include/llvm/TextAPI/TextAPIWriter.h
  llvm/lib/Object/TapiUniversal.cpp
  llvm/lib/TextAPI/Architecture.cpp
  llvm/lib/TextAPI/ArchitectureSet.cpp
  llvm/lib/TextAPI/CMakeLists.txt
  llvm/lib/TextAPI/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/Architecture.cpp
  llvm/lib/TextAPI/MachO/ArchitectureSet.cpp
  llvm/lib/TextAPI/MachO/InterfaceFile.cpp
  llvm/lib/TextAPI/MachO/PackedVersion.cpp
  llvm/lib/TextAPI/MachO/Platform.cpp
  llvm/lib/TextAPI/MachO/Symbol.cpp
  llvm/lib/TextAPI/MachO/Target.cpp
  llvm/lib/TextAPI/MachO/TextAPIContext.h
  llvm/lib/TextAPI/MachO/TextStub.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.cpp
  llvm/lib/TextAPI/MachO/TextStubCommon.h
  llvm/lib/TextAPI/PackedVersion.cpp
  llvm/lib/TextAPI/Platform.cpp
  llvm/lib/TextAPI/Symbol.cpp
  llvm/lib/TextAPI/Target.cpp
  llvm/lib/TextAPI/TextAPIContext.h
  llvm/lib/TextAPI/TextStub.cpp
  llvm/lib/TextAPI/TextStubCommon.cpp
  llvm/lib/TextAPI/TextStubCommon.h
  llvm/tools/llvm-ifs/llvm-ifs.cpp
  llvm/tools/llvm-libtool-darwin/llvm-libtool-darwin.cpp
  llvm/tools/llvm-lipo/llvm-lipo.cpp
  llvm/unittests/TextAPI/TextStubHelpers.h
  llvm/unittests/TextAPI/TextStubV1Tests.cpp
  llvm/unittests/TextAPI/TextStubV2Tests.cpp
  llvm/unittests/TextAPI/TextStubV3Tests.cpp
  llvm/unittests/TextAPI/TextStubV4Tests.cpp

Index: llvm/unittests/TextAPI/TextStubV4Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV4Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV4Tests.cpp
@@ -7,9 +7,9 @@
 //===---===/
 
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV3Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV3Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV3Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV2Tests.cpp
===
--- llvm/unittests/TextAPI/TextStubV2Tests.cpp
+++ llvm/unittests/TextAPI/TextStubV2Tests.cpp
@@ -6,9 +6,9 @@
 //
 //===---===/
 #include "TextStubHelpers.h"
-#include "llvm/TextAPI/MachO/InterfaceFile.h"
-#include "llvm/TextAPI/MachO/TextAPIReader.h"
-#include "llvm/TextAPI/MachO/TextAPIWriter.h"
+#include "llvm/TextAPI/InterfaceFile.h"
+#include "llvm/TextAPI/TextAPIReader.h"
+#include "llvm/TextAPI/TextAPIWriter.h"
 #include "gtest/gtest.h"
 #include 
 #include 
Index: llvm/unittests/TextAPI/TextStubV1Tests.cpp
===

[clang] f78d932 - [RISCV] Add IR intrinsics for Zbc extension

2021-04-02 Thread Craig Topper via cfe-commits

Author: Levy Hsu
Date: 2021-04-02T12:09:13-07:00
New Revision: f78d932cf23a6521a1f9a08c539d1a00148ebe54

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

LOG: [RISCV] Add IR intrinsics for Zbc extension

Head files are included in a separate patch in case the name needs to be 
changed.

RV32 / 64:
clmul
clmulh
clmulr

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

Added: 
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll

Modified: 
clang/include/clang/Basic/BuiltinsRISCV.def
clang/lib/CodeGen/CGBuiltin.cpp
llvm/include/llvm/IR/IntrinsicsRISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCV.def 
b/clang/include/clang/Basic/BuiltinsRISCV.def
index 564573ffa746..e0b28011e61a 100644
--- a/clang/include/clang/Basic/BuiltinsRISCV.def
+++ b/clang/include/clang/Basic/BuiltinsRISCV.def
@@ -21,6 +21,11 @@
 TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "experimental-zbb")
 TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "experimental-zbb")
 
+// Zbc extension
+TARGET_BUILTIN(__builtin_riscv_clmul, "LiLiLi", "nc", "experimental-zbc")
+TARGET_BUILTIN(__builtin_riscv_clmulh, "LiLiLi", "nc", "experimental-zbc")
+TARGET_BUILTIN(__builtin_riscv_clmulr, "LiLiLi", "nc", "experimental-zbc")
+
 // Zbr extension
 TARGET_BUILTIN(__builtin_riscv_crc32_b, "LiLi", "nc", "experimental-zbr")
 TARGET_BUILTIN(__builtin_riscv_crc32_h, "LiLi", "nc", "experimental-zbr")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 899c7b944ecf..80e48fbceef4 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -17884,6 +17884,20 @@ Value *CodeGenFunction::EmitRISCVBuiltinExpr(unsigned 
BuiltinID,
 IntrinsicTypes = {ResultType};
 break;
 
+  // Zbc
+  case RISCV::BI__builtin_riscv_clmul:
+ID = Intrinsic::riscv_clmul;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_clmulh:
+ID = Intrinsic::riscv_clmulh;
+IntrinsicTypes = {ResultType};
+break;
+  case RISCV::BI__builtin_riscv_clmulr:
+ID = Intrinsic::riscv_clmulr;
+IntrinsicTypes = {ResultType};
+break;
+
   // Zbr
   case RISCV::BI__builtin_riscv_crc32_b:
 ID = Intrinsic::riscv_crc32_b;

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
new file mode 100644
index ..c07bd91fb40e
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
@@ -0,0 +1,48 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-zbc 
-emit-llvm %s -o - \
+// RUN: | FileCheck %s  -check-prefix=RV32ZBC
+
+// RV32ZBC-LABEL: @clmul(
+// RV32ZBC-NEXT:  entry:
+// RV32ZBC-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.clmul.i32(i32 
[[TMP0]], i32 [[TMP1]])
+// RV32ZBC-NEXT:ret i32 [[TMP2]]
+//
+long clmul(long a, long b) {
+  return __builtin_riscv_clmul(a, b);
+}
+
+// RV32ZBC-LABEL: @clmulh(
+// RV32ZBC-NEXT:  entry:
+// RV32ZBC-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.clmulh.i32(i32 
[[TMP0]], i32 [[TMP1]])
+// RV32ZBC-NEXT:ret i32 [[TMP2]]
+//
+long clmulh(long a, long b) {
+  return __builtin_riscv_clmulh(a, b);
+}
+
+// RV32ZBC-LABEL: @clmulr(
+// RV32ZBC-NEXT:  entry:
+// RV32ZBC-NEXT:[[A_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:[[B_ADDR:%.*]] = alloca i32, align 4
+// RV32ZBC-NEXT:store i32 [[A:%.*]], i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:store i32 [[B:%.*]], i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP0:%.*]] = load i32, i32* [[A_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP1:%.*]] = load i32, i32* [[B_ADDR]], align 4
+// RV32ZBC-NEXT:[[TMP2:%.*]] = call i32 @llvm.riscv.clmulr.i32(i32 
[[T

[PATCH] D99711: [RISCV] [1/2] Add intrinsic for Zbc extension

2021-04-02 Thread Craig Topper via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf78d932cf23a: [RISCV] Add IR intrinsics for Zbc extension 
(authored by LevyHsu, committed by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D99711?vs=334882&id=335008#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99711

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbc.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbc.c
  llvm/include/llvm/IR/IntrinsicsRISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoB.td
  llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
  llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll

Index: llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv64zbc-intrinsic.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IB
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zbc -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV64IBC
+
+declare i64 @llvm.riscv.clmul.i64(i64 %a, i64 %b)
+
+define i64 @clmul64(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmul a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmul a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmul.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.clmulh.i64(i64 %a, i64 %b)
+
+define i64 @clmul64h(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64h:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmulh a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64h:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmulh a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmulh.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
+
+declare i64 @llvm.riscv.clmulr.i64(i64 %a, i64 %b)
+
+define i64 @clmul64r(i64 %a, i64 %b) nounwind {
+; RV64IB-LABEL: clmul64r:
+; RV64IB:   # %bb.0:
+; RV64IB-NEXT:clmulr a0, a0, a1
+; RV64IB-NEXT:ret
+;
+; RV64IBC-LABEL: clmul64r:
+; RV64IBC:   # %bb.0:
+; RV64IBC-NEXT:clmulr a0, a0, a1
+; RV64IBC-NEXT:ret
+  %tmp = call i64 @llvm.riscv.clmulr.i64(i64 %a, i64 %b)
+ ret i64 %tmp
+}
Index: llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rv32zbc-intrinsic.ll
@@ -0,0 +1,53 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-b -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IB
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zbc -verify-machineinstrs < %s \
+; RUN:   | FileCheck %s -check-prefix=RV32IBC
+
+declare i32 @llvm.riscv.clmul.i32(i32 %a, i32 %b)
+
+define i32 @clmul32(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmul a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmul a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmul.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.clmulh.i32(i32 %a, i32 %b)
+
+define i32 @clmul32h(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32h:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmulh a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32h:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmulh a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmulh.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
+
+declare i32 @llvm.riscv.clmulr.i32(i32 %a, i32 %b)
+
+define i32 @clmul32r(i32 %a, i32 %b) nounwind {
+; RV32IB-LABEL: clmul32r:
+; RV32IB:   # %bb.0:
+; RV32IB-NEXT:clmulr a0, a0, a1
+; RV32IB-NEXT:ret
+;
+; RV32IBC-LABEL: clmul32r:
+; RV32IBC:   # %bb.0:
+; RV32IBC-NEXT:clmulr a0, a0, a1
+; RV32IBC-NEXT:ret
+  %tmp = call i32 @llvm.riscv.clmulr.i32(i32 %a, i32 %b)
+ ret i32 %tmp
+}
Index: llvm/lib/Target/RISCV/RISCVInstrInfoB.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoB.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoB.td
@@ -898,6 +898,12 @@
 def : PatGpr;
 } // Predicates = [HasStdExtZbb]
 
+let Predicates = [HasStdExtZbc] in {
+def : PatGprGpr;
+def : PatGprGpr;
+def : PatGprGpr;
+} // Predicates = [HasStdExtZbc]
+
 let Predicates = [HasStdExtZbr] in {
 def : PatGpr;
 def : PatGpr;
Index: llvm/include/llvm/IR/IntrinsicsRISCV.td
===
--- llvm/include/llvm/IR/IntrinsicsRISCV.td
+++ llvm/include/llv

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

2021-04-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this doesn't build on windows: 
http://45.33.8.238/win/36271/step_4.txt

Please take a look and revert for now if it takes a while to fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[clang] 1bd4986 - [Sema] Fix Windows build after b001d574d7d9

2021-04-02 Thread Jessica Clarke via cfe-commits

Author: Jessica Clarke
Date: 2021-04-02T20:27:58+01:00
New Revision: 1bd4986e7cdc124fecbf4b4527039a9a845e61f5

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

LOG: [Sema] Fix Windows build after b001d574d7d9

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 98b37f3c0265..5b534f871bcc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -91,6 +91,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



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


[clang] 5311abc - [RISCV] Try using toupper instead of std::toupper to make the build bots happy.

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T12:29:07-07:00
New Revision: 5311abc7a24e4170e5e6d06f1022da87f1413dd7

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

LOG: [RISCV] Try using toupper instead of std::toupper to make the build bots 
happy.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5b534f871bcc..c92c1b5aa3d1 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3428,7 +3428,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
&TI,
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
-FeatureStr[0] = std::toupper(FeatureStr[0]);
+FeatureStr[0] = toupper(FeatureStr[0]);
 
 // Error message
 FeatureMissing = true;



___
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-04-02 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

In D99009#2666793 , @thakis wrote:

> Looks like this doesn't build on windows: 
> http://45.33.8.238/win/36271/step_4.txt
>
> Please take a look and revert for now if it takes a while to fix.

Hopefully fixed in 1bd4986e7cdc 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[clang] be7358d - Revert "[RISCV] Try using toupper instead of std::toupper to make the build bots happy."

2021-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2021-04-02T12:30:23-07:00
New Revision: be7358df1e3066d09171159211b9fa578272585e

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

LOG: Revert "[RISCV] Try using toupper instead of std::toupper to make the 
build bots happy."

This reverts commit 5311abc7a24e4170e5e6d06f1022da87f1413dd7.

jrtc27 included the proper header in 1bd4986e7cdc124fecbf4b4527039a9a845e61f5
while I was trying to figure out what llvm/clang usually used.

Added: 


Modified: 
clang/lib/Sema/SemaChecking.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index c92c1b5aa3d1..5b534f871bcc 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3428,7 +3428,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
&TI,
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
 I.consume_front("experimental-");
 std::string FeatureStr = I.str();
-FeatureStr[0] = toupper(FeatureStr[0]);
+FeatureStr[0] = std::toupper(FeatureStr[0]);
 
 // Error message
 FeatureMissing = true;



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


[PATCH] D89013: [libcxx] Support per-target __config_site in per-target runtime build

2021-04-02 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

@ldionne I have update the change description to explain the new layout.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

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


[clang] 2165c0d - [OPENMP][DOCS]Update status of the supported constructs, NFC.

2021-04-02 Thread Mike Rice via cfe-commits

Author: Mike Rice
Date: 2021-04-02T12:31:36-07:00
New Revision: 2165c0d389c0b8f7dfd383ea6abd0d9b5d2ee07f

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

LOG: [OPENMP][DOCS]Update status of the supported constructs, NFC.

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 6e15716f3bb4..ab4d4d52c736 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -266,7 +266,7 @@ want to help with the implementation.
 
+==+==+==+===+
 | atomic extension | 'compare' and 'fail' clauses on atomic 
construct | :none:`unclaimed`|  
 |
 
+--+--+--+---+
-| base language| C++ attribute specifier syntax
   | :none:`unclaimed`| 
  |
+| base language| C++ attribute specifier syntax
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | device extension | 'present' map type modifier   
   | :good:`done` | D83061, D83062, D84422  
  |
 
+--+--+--+---+
@@ -294,7 +294,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | device extension | allow virtual functions calls for mapped 
object on device| :none:`unclaimed`|
   |
 
+--+--+--+---+
-| device extension | interop construct 
   | :none:`unclaimed`| 
  |
+| device extension | interop construct 
   | :part:`partial`  | parsing/sema done: D98558, D98834, 
D98815 |
 
+--+--+--+---+
 | device extension | assorted routines for querying interoperable 
properties  | :none:`unclaimed`|
   |
 
+--+--+--+---+
@@ -304,7 +304,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | loop extension   | 'reproducible'/'unconstrained' modifiers in 
'order' clause   | :none:`unclaimed`|   
|
 
+--+--+--+---+
-| memory management| alignment extensions for allocate directive 
and clause   | :none:`unclaimed`|   
|
+| memory management| alignment extensions for allocate directive 
and clause   | :part:`worked on`|   
  

[PATCH] D89013: [libcxx] Support per-target __config_site in per-target runtime build

2021-04-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> This layout matches the layout use by other compilers like GCC.

Clarification: this is similar but not match GCC's layout, where the multiarch 
path component (e.g. `/x86_64-linux-gnu`) is appended to `.../include`

  % clang++ --target=aarch64-pc-linux-gnu a.cc '-###' |& sed -E 's/ 
"?-[LiI]/\n&/g'
  clang version 13.0.0
  Target: aarch64-pc-linux-gnu
  Thread model: posix
  InstalledDir: /tmp/RelA/bin
   "/tmp/RelA/bin/clang-13" "-cc1" "-triple" "aarch64-pc-linux-gnu" "-emit-obj" 
"-mrelax-all" "--mrelax-relocations" "-disable-free" "-main-file-name" "a.cc" 
"-mrelocation-model" "static" "-mframe-pointer=non-leaf" "-fmath-errno" 
"-fno-rounding-math" "-mconstructor-aliases" "-munwind-tables" "-target-cpu" 
"generic" "-target-feature" "+neon" "-target-abi" "aapcs" 
"-fallow-half-arguments-and-returns" "-debugger-tuning=gdb" 
"-fcoverage-compilation-dir=/tmp/c" "-resource-dir" "/tmp/RelA/lib/clang/13.0.0"
   "-internal-isystem" 
"/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10"
   "-internal-isystem" 
"/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10/aarch64-linux-gnu"
   "-internal-isystem" 
"/usr/lib/gcc-cross/aarch64-linux-gnu/10/../../../../aarch64-linux-gnu/include/c++/10/backward"
  ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89013

___
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-04-02 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In D99009#2666797 , @jrtc27 wrote:

> In D99009#2666793 , @thakis wrote:
>
>> Looks like this doesn't build on windows: 
>> http://45.33.8.238/win/36271/step_4.txt
>>
>> Please take a look and revert for now if it takes a while to fix.
>
> Hopefully fixed in 1bd4986e7cdc 
> 

Yup, better now. Thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99009

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


[PATCH] D75844: [clang] Set begin loc on GNU attribute parsed attrs

2021-04-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 335016.

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

https://reviews.llvm.org/D75844

Files:
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Parser/cxx0x-attributes.cpp
  clang/test/SemaCXX/switch-implicit-fallthrough.cpp

Index: clang/test/SemaCXX/switch-implicit-fallthrough.cpp
===
--- clang/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ clang/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -185,9 +185,12 @@
   return 1;
   [[clang::fallthrough]];  // expected-warning{{fallthrough annotation in unreachable code}}
 case 222:
+  return 2;
+  __attribute__((fallthrough)); // expected-warning{{fallthrough annotation in unreachable code}}
+case 223:
   n += 400;
-case 223:  // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
-  ;
+case 224: // expected-warning{{unannotated fall-through between switch labels}} expected-note{{insert '[[clang::fallthrough]];' to silence this warning}} expected-note{{insert 'break;' to avoid fall-through}}
+;
   }
 
   long p = static_cast(n) * n;
Index: clang/test/Parser/cxx0x-attributes.cpp
===
--- clang/test/Parser/cxx0x-attributes.cpp
+++ clang/test/Parser/cxx0x-attributes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fcxx-exceptions -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions %s
+// RUN: %clang_cc1 -fcxx-exceptions -fdeclspec -fexceptions -fsyntax-only -verify -std=c++11 -Wc++14-compat -Wc++14-extensions -Wc++17-extensions %s
 
 // Need std::initializer_list
 namespace std {
@@ -368,6 +368,22 @@
   return n;
 }
 
+template struct TemplateStruct {};
+class FriendClassesWithAttributes {
+  // We allow GNU-style attributes here
+  template  friend class __attribute__((__type_visibility__("default"))) vector;
+  template  friend class __declspec(code_seg("whatever")) vector2;
+  // But not C++11 ones
+  template  friend class[[]] vector3; // expected-error {{an attribute list cannot appear here}}
+  template  friend class [[clang::__type_visibility__(("default"))]] vector4; // expected-error {{an attribute list cannot appear here}}
+
+  // Also allowed
+  friend struct __attribute__((__type_visibility__("default"))) TemplateStruct;
+  friend struct __declspec(code_seg("whatever")) TemplateStruct;
+  friend struct[[]] TemplateStruct;   // expected-error {{an attribute list cannot appear here}}
+  friend struct [[clang::__type_visibility__("default")]] TemplateStruct; // expected-error {{an attribute list cannot appear here}}
+};
+
 #define attr_name bitand
 #define attr_name_2(x) x
 #define attr_name_3(x, y) x##y
Index: clang/test/AST/sourceranges.cpp
===
--- clang/test/AST/sourceranges.cpp
+++ clang/test/AST/sourceranges.cpp
@@ -108,6 +108,24 @@
   }
 }
 
+// CHECK-1Z: NamespaceDecl {{.*}} attributed_case
+namespace attributed_case {
+void f(int n) {
+  switch (n) {
+  case 0:
+n--;
+// CHECK: AttributedStmt {{.*}} 
+// CHECK: FallThroughAttr {{.*}} 
+__attribute__((fallthrough))
+// CHECK: FallThroughAttr {{.*}} 
+  __attribute__((fallthrough));
+  case 1:
+n++;
+break;
+  }
+}
+} // namespace attributed_case
+
 // CHECK: NamespaceDecl {{.*}} attributed_stmt
 namespace attributed_stmt {
   // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from 
Index: clang/lib/Parse/ParseDeclCXX.cpp
===
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1852,7 +1852,8 @@
 } else if (TUK == Sema::TUK_Reference ||
(TUK == Sema::TUK_Friend &&
 TemplateInfo.Kind == ParsedTemplateInfo::NonTemplate)) {
-  ProhibitAttributes(attrs);
+  ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+  /*DiagnoseEmptyAttrs=*/true);
   TypeResult = Actions.ActOnTagTemplateIdType(TUK, TagType, StartLoc,
   SS,
   TemplateId->TemplateKWLoc,
@@ -1924,7 +1925,8 @@
 TagType, StartLoc, SS, Name, NameLoc, attrs);
   } else if (TUK == Sema::TUK_Friend &&
  TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate) {
-ProhibitAttributes(attrs);
+ProhibitCXX11Attributes(attrs, diag::err_attributes_not_allowed,
+/*DiagnoseEmptyAttrs=*/true);
 
 TagOrT

[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 335011.
ASDenysPetrov added a comment.

Updated. Restored complexity to O(N).


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

https://reviews.llvm.org/D99797

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -61,6 +61,9 @@
   static constexpr BaseType getMax() {
 return std::numeric_limits::max();
   }
+  // MID is a value in the middle of the range
+  // which unary minus does not affect on,
+  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   static constexpr BaseType getMid() {
 return isSigned() ? 0 : ~(fromInt(-1) / fromInt(2));
   }
@@ -160,7 +163,7 @@
 
   void checkAdd(RawRangeSet RawLHS, RawRangeSet RawRHS,
 RawRangeSet RawExpected) {
-wrap(&Self::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(&Self::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }
 
   void checkAdd(RawRangeSet RawLHS, BaseType RawRHS, RawRangeSet RawExpected) {
@@ -195,9 +198,6 @@
 
   constexpr TypeParam MIN = TestFixture::getMin();
   constexpr TypeParam MAX = TestFixture::getMax();
-  // MID is a value in the middle of the range
-  // which unary minus does not affect on,
-  // e.g. int8/int32(0), uint8(128), uint32(2147483648).
   constexpr TypeParam MID = TestFixture::getMid();
   constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
   constexpr TypeParam B = MID - TestFixture::fromInt(42);
@@ -310,24 +310,124 @@
 }
 
 TYPED_TEST(RangeSetTest, RangeSetAddTest) {
-  // Check adding single points
-  this->checkAdd({}, 10, {{10, 10}});
-  this->checkAdd({{0, 5}}, 10, {{0, 5}, {10, 10}});
-  this->checkAdd({{0, 5}, {30, 40}}, 10, {{0, 5}, {10, 10}, {30, 40}});
-
-  // Check adding single ranges.
-  this->checkAdd({}, {10, 20}, {{10, 20}});
-  this->checkAdd({{0, 5}}, {10, 20}, {{0, 5}, {10, 20}});
-  this->checkAdd({{0, 5}, {30, 40}}, {10, 20}, {{0, 5}, {10, 20}, {30, 40}});
-
-  // Check adding whole sets of ranges.
-  this->checkAdd({{0, 5}}, {{10, 20}}, {{0, 5}, {10, 20}});
-  // Check that ordering of ranges is as expected.
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}}, {{0, 5}, {10, 20}, {30, 40}});
-  this->checkAdd({{0, 5}, {30, 40}}, {{10, 20}, {50, 60}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}});
-  this->checkAdd({{10, 20}, {50, 60}}, {{0, 5}, {30, 40}, {70, 80}},
- {{0, 5}, {10, 20}, {30, 40}, {50, 60}, {70, 80}});
+
+  // Use next values of the range {MIN, A, B, MID, C, D, MAX}.
+  constexpr TypeParam MIN = TestFixture::getMin();
+  constexpr TypeParam MAX = TestFixture::getMax();
+  constexpr TypeParam MID = TestFixture::getMid();
+  constexpr TypeParam A = MID - TestFixture::fromInt(42 + 42);
+  constexpr TypeParam B = MID - TestFixture::fromInt(42);
+  constexpr TypeParam C = -B;
+  constexpr TypeParam D = -A;
+
+  // LHS and RHS is empty.
+  // RHS =>
+  // LHS => =
+  //___   ___
+  this->checkAdd({}, {}, {});
+
+  // RHS is empty.
+  // RHS =>
+  // LHS =>_=_
+  //__/_\__   __/_\__
+  this->checkAdd({{A, B}}, {}, {{A, B}});
+  this->checkAdd({{A, B}, {C, D}}, {}, {{A, B}, {C, D}});
+
+  // LHS is empty.
+  // RHS => ___
+  // LHS =>/   \=_
+  //__/_\__   __/_\__
+  this->checkAdd({}, B, {{B, B}});
+  this->checkAdd({}, {B, C}, {{B, C}});
+  this->checkAdd({}, {{MIN, B}, {C, MAX}}, {{MIN, B}, {C, MAX}});
+
+  // RHS is detached from LHS.
+  // RHS => ___
+  // LHS =>___ /   \=___ _
+  //__/___\___/_\__   __/___\___/_\__
+  this->checkAdd({{A, C}}, D, {{A, C}, {D, D}});
+  this->checkAdd({{MID, C}, {D, MAX}}, A, {{A, A}, {MID, C}, {D, MAX}});
+  this->checkAdd({{A, B}}, {MID, D}, {{A, B}, {MID, D}});
+  this->checkAdd({{MIN, A}, {D, MAX}}, {B, C}, {{MIN, A}, {B, C}, {D, MAX}});
+  this->checkAdd({{B, MID}, {D, MAX}}, {{MIN, A}, {C, C}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+  this->checkAdd({{MIN, A}, {C, C}}, {{B, MID}, {D, MAX}},
+ {{MIN, A}, {B, MID}, {C, C}, {D, MAX}});
+
+  // RHS is inside LHS.
+  // RHS => ___
+  // LHS => ___/___\___ = ___
+  //___/__/_\__\___   ___/___\___
+  this->checkAdd({{A, C}}, MID, {{A, C}});
+  this->checkAdd({{A, D}}, {B, C}, {{A, D}});
+
+  // RHS wraps LHS.
+  // RHS =>  _
+  // LHS => /  _  \ = ___
+  //___/__/_\__\___   ___/___\___
+  this->checkAdd({{MID, MID}}, {A, D}, {{A

[PATCH] D99037: [Matrix] Implement explicit type conversions for matrix types

2021-04-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/test/CodeGen/matrix-cast.c:15
+  // CHECK:   [[C:%.*]] = load <25 x i8>, <25 x i8>* {{.*}}, align 1
+  // CHECK-NEXT:  [[CONV:%.*]] = zext <25 x i8> [[C]] to <25 x i32>
+  // CHECK-NEXT:  store <25 x i32> [[CONV]], <25 x i32>* {{.*}}, align 4

fhahn wrote:
> SaurabhJha wrote:
> > fhahn wrote:
> > > This doesn't seem right. We are casting between 2 signed types, so the 
> > > sign should get preserved, right? Shouldn't this be `sext`? See 
> > > https://godbolt.org/z/zWznYdnKW for the scalar case.
> > > 
> > > I think you also need tests for casts with different bitwidths with 
> > > unsigned, unsigned -> signed & signed -> unsigned.
> > This is happening because we are always passing inSigned argument to 
> > `Builder.CreateIntCast` as false here 
> > https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGExprScalar.cpp#L1348.
> >  IfI change it to `true`, it generates `sext` instructions.
> > 
> > I am figuring out how can I determine sign of src and dest type. Because 
> > `SrcTy` and `DestTy` are vectors here, they are unsigned and `SrcElementTy` 
> > and `DestElementTy` have no method like `isSignedIntegerOrEnumerationType`. 
> > Once that's solved, this should be fixed.
> Oh right, I think I see what's going on. I think the code you are referring 
> to is specifically for the vector types in Clang, but it is checking the LLVM 
> type and we also use LLVM IR vector types for matrix values, so the code 
> accidentally also covers matrix values at the moment. 
> 
> I *think* we should probably handled matrix values separately in this 
> function. @rjmccall what do you think?
Yes, I would recommend that you recognize matrix values by their Clang type and 
then call something in the matrix IR-generation library.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99037

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


[PATCH] D99797: [analyzer] Handle intersections and adjacency in RangeSet::Factory::add function

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko FYI.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:112-113
+RangeSet RangeSet::Factory::add(RangeSet LHS, RangeSet RHS) {
+  if (LHS.isEmpty())
+return RHS;
+  for (const Range &R : RHS)

Also optimized this particular case.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:138-139
 
-  return makePersistent(std::move(Result));
-}
+  if (!Original.pin(From, To))
+return getEmptySet();
 

This allows to add a RangeSet of any type. E.g. RangeSet(uchar) + RangeSet(int) 
= valid, because of `pin`

I'm wondering whether we really need it here in practice?



Comment at: clang/unittests/StaticAnalyzer/RangeSetTest.cpp:166
 RawRangeSet RawExpected) {
-wrap(&Self::checkAddImpl, RawRHS, RawLHS, RawExpected);
+wrap(&Self::checkAddImpl, RawLHS, RawRHS, RawExpected);
   }

Fixed the misprint.


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

https://reviews.llvm.org/D99797

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


[PATCH] D96090: [analyzer] Replace StoreManager::CastRetrievedVal with SValBuilder::evalCast

2021-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@steakhal thanks for the approval.




Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:564-565
   }
-
-  llvm_unreachable("Unknown SVal kind");
 }

steakhal wrote:
> You probably don't want to remove this. The same applies to similar ones.
Yep. I'd keep it here, beacuse of compiler warnings of no-return function.


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

https://reviews.llvm.org/D96090

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


[PATCH] D99809: Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 335021.
aaron.ballman added a comment.

Correcting lint warnings, adding documentation for the new feature.


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

https://reviews.llvm.org/D99809

Files:
  clang/docs/InternalsManual.rst
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Sema/ParsedAttr.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/ParsedAttr.cpp
  clang/lib/Sema/SemaAttr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/Sema/attr-coldhot.c
  clang/test/Sema/attr-disable-tail-calls.c
  clang/test/Sema/internal_linkage.c
  clang/test/SemaCXX/attr-speculative-load-hardening.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp

Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -3627,6 +3627,114 @@
   }
 }
 
+// Generates the mutual exclusion checks. The checks for parsed attributes are
+// written into OS and the checks for merging declaration attributes are
+// written into MergeOS.
+static void GenerateMutualExclusionsChecks(const Record &Attr,
+   const RecordKeeper &Records,
+   raw_ostream &OS,
+   raw_ostream &MergeOS) {
+  // Find all of the definitions that inherit from MutualExclusions and include
+  // the given attribute in the list of exclusions to generate the
+  // diagMutualExclusion() check.
+  std::vector ExclusionsList =
+  Records.getAllDerivedDefinitions("MutualExclusions");
+
+  // We don't do any of this magic for type attributes yet.
+  if (Attr.isSubClassOf("TypeAttr"))
+return;
+
+  // This means the attribute is either a statement attribute or a decl
+  // attribute, find out which.
+  bool CurAttrIsStmtAttr =
+  Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr");
+
+  std::vector DeclAttrs, StmtAttrs;
+
+  for (const Record *Exclusion : ExclusionsList) {
+std::vector MutuallyExclusiveAttrs =
+Exclusion->getValueAsListOfDefs("Exclusions");
+auto IsCurAttr = [Attr](const Record *R) {
+  return R->getName() == Attr.getName();
+};
+if (llvm::any_of(MutuallyExclusiveAttrs, IsCurAttr)) {
+  // This list of exclusions includes the attribute we're looking for, so
+  // add the exclusive attributes to the proper list for checking.
+  for (const Record *AttrToExclude : MutuallyExclusiveAttrs) {
+if (IsCurAttr(AttrToExclude))
+  continue;
+
+if (CurAttrIsStmtAttr)
+  StmtAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+else
+  DeclAttrs.push_back((AttrToExclude->getName() + "Attr").str());
+  }
+}
+  }
+
+  // If we discovered any decl or stmt attributes to test for, generate the
+  // predicates for them now.
+  if (!DeclAttrs.empty()) {
+// Generate the ParsedAttrInfo subclass logic for declarations.
+OS << "  bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, "
+   << "const Decl *D) const {\n";
+for (const std::string &A : DeclAttrs) {
+  OS << "if (const auto *A = D->getAttr<" << A << ">()) {\n";
+  OS << "  S.Diag(AL.getLoc(), diag::err_attributes_are_not_compatible)"
+ << " << AL << A;\n";
+  OS << "  S.Diag(A->getLocation(), diag::note_conflicting_attribute);";
+  OS << "  \nreturn false;\n";
+  OS << "}\n";
+}
+OS << "return true;\n";
+OS << "  }\n\n";
+
+// Also generate the declaration attribute merging logic if the current
+// attribute is one that can be inheritted on a declaration. It is assumed
+// this code will be executed in the context of a function with parameters:
+// Sema &S, Decl *D, Attr *A and that returns a bool (false on diagnostic,
+// true on success).
+if (Attr.isSubClassOf("InheritableAttr")) {
+  MergeOS << "  if (const auto *Second = dyn_cast<"
+  << (Attr.getName() + "Attr").str() << ">(A)) {\n";
+  for (const std::string &A : DeclAttrs) {
+MergeOS << "if (const auto *First = D->getAttr<" << A << ">()) {\n";
+MergeOS << "  S.Diag(First->getLocation(), "
+<< "diag::err_attributes_are_not_compatible) << First << "
+<< "Second;\n";
+MergeOS << "  S.Diag(Second->getLocation(), "
+<< "diag::note_conflicting_attribute);\n";
+MergeOS << "  return false;\n";
+MergeOS << "}\n";
+  }
+  MergeOS << "return true;\n";
+  MergeOS << "  }\n";
+}
+  }
+  if (!StmtAttrs.empty()) {
+// Generate the ParsedAttrInfo subclass logic for statements.
+OS << "  bool diagMutualExclusion(Sema &S, const ParsedAttr &AL, "
+   << "const Stmt *St) const {\n";
+OS << " 

[clang] cb424fe - [OPENMP5.1]Initial support for novariants clause.

2021-04-02 Thread Jennifer Yu via cfe-commits

Author: Jennifer Yu
Date: 2021-04-02T13:19:01-07:00
New Revision: cb424fee3d6b27dbd38de666382b702100935286

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

LOG: [OPENMP5.1]Initial support for novariants clause.
Added basic parsing/sema/serialization support for the 'novariants' clause.

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/Basic/OpenMPKinds.cpp
clang/lib/Parse/ParseOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/test/OpenMP/dispatch_ast_print.cpp
clang/test/OpenMP/dispatch_messages.cpp
clang/tools/libclang/CIndex.cpp
flang/lib/Semantics/check-omp-structure.cpp
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index f71eb15feea2..4d5cdffba891 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7649,6 +7649,77 @@ class OMPDestroyClause final : public OMPClause {
   }
 };
 
+/// This represents 'novariants' clause in the '#pragma omp ...' directive.
+///
+/// \code
+/// #pragma omp dispatch novariants(a > 5)
+/// \endcode
+/// In this example directive '#pragma omp dispatch' has simple 'novariants'
+/// clause with condition 'a > 5'.
+class OMPNovariantsClause final : public OMPClause,
+  public OMPClauseWithPreInit {
+  friend class OMPClauseReader;
+
+  /// Location of '('.
+  SourceLocation LParenLoc;
+
+  /// Condition of the 'if' clause.
+  Stmt *Condition = nullptr;
+
+  /// Set condition.
+  void setCondition(Expr *Cond) { Condition = Cond; }
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+
+public:
+  /// Build 'novariants' clause with condition \a Cond.
+  ///
+  /// \param Cond Condition of the clause.
+  /// \param HelperCond Helper condition for the construct.
+  /// \param CaptureRegion Innermost OpenMP region where expressions in this
+  /// clause must be captured.
+  /// \param StartLoc Starting location of the clause.
+  /// \param LParenLoc Location of '('.
+  /// \param EndLoc Ending location of the clause.
+  OMPNovariantsClause(Expr *Cond, Stmt *HelperCond,
+  OpenMPDirectiveKind CaptureRegion,
+  SourceLocation StartLoc, SourceLocation LParenLoc,
+  SourceLocation EndLoc)
+  : OMPClause(llvm::omp::OMPC_novariants, StartLoc, EndLoc),
+OMPClauseWithPreInit(this), LParenLoc(LParenLoc), Condition(Cond) {
+setPreInitStmt(HelperCond, CaptureRegion);
+  }
+
+  /// Build an empty clause.
+  OMPNovariantsClause()
+  : OMPClause(llvm::omp::OMPC_novariants, SourceLocation(),
+  SourceLocation()),
+OMPClauseWithPreInit(this) {}
+
+  /// Returns the location of '('.
+  SourceLocation getLParenLoc() const { return LParenLoc; }
+
+  /// Returns condition.
+  Expr *getCondition() const { return cast_or_null(Condition); }
+
+  child_range children() { return child_range(&Condition, &Condition + 1); }
+
+  const_child_range children() const {
+return const_child_range(&Condition, &Condition + 1);
+  }
+
+  child_range used_children();
+  const_child_range used_children() const {
+auto Children = const_cast(this)->used_children();
+return const_child_range(Children.begin(), Children.end());
+  }
+
+  static bool classof(const OMPClause *T) {
+return T->getClauseKind() == llvm::omp::OMPC_novariants;
+  }
+};
+
 /// This represents 'detach' clause in the '#pragma omp task' directive.
 ///
 /// \code

diff  --git a/clang/include/clang/AST/RecursiveASTVisitor.h 
b/clang/include/clang/AST/RecursiveASTVisitor.h
index 23864819bc07..cdedbe22f9ed 100644
--- a/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -3218,6 +3218,14 @@ bool 
RecursiveASTVisitor::VisitOMPDestroyClause(OMPDestroyClause *C) {
   return true;
 }
 
+template 
+bool RecursiveASTVisitor::VisitOMPNovariantsClause(
+OMPNovariantsClause *C) {
+  TRY_TO(VisitOMPClauseWithPreInit(C));
+  TRY_TO(TraverseStmt(C->getCondition()));
+  return true;
+}
+
 template 
 template 
 bool RecursiveASTVisitor::VisitOMPClauseList(T *Node) {

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index b5c8d3d292fc..5f514d5f6a1d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -11017,7 +11017,11 @@ class Sema final {
 

[PATCH] D99679: [OPENMP51]Initial support for novariants clause

2021-04-02 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 closed this revision.
jyu2 added a comment.

cb424fee3d6b27dbd38de666382b702100935286 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99679

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


[clang] 4be8a26 - Use tablegen to diagnose mutually exclusive attributes

2021-04-02 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2021-04-02T16:34:42-04:00
New Revision: 4be8a26951da9a6e04de327b38dd158f4c8e3280

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

LOG: Use tablegen to diagnose mutually exclusive attributes

Currently, when one or more attributes are mutually exclusive, the
developer adding the attribute has to manually emit diagnostics. In
practice, this is highly error prone, especially for declaration
attributes, because such checking is not trivial. Redeclarations
require you to write a "merge" function to diagnose mutually exclusive
attributes and most attributes get this wrong.

This patch introduces a table-generated way to specify that a group of
two or more attributes are mutually exclusive:

def : MutualExclusions<[Attr1, Attr2, Attr3]>;

This works for both statement and declaration attributes (but not type
attributes) and the checking is done either from the common attribute
diagnostic checking code or from within mergeDeclAttribute() when
merging redeclarations.

Added: 


Modified: 
clang/docs/InternalsManual.rst
clang/include/clang/Basic/Attr.td
clang/include/clang/Sema/ParsedAttr.h
clang/include/clang/Sema/Sema.h
clang/lib/Sema/ParsedAttr.cpp
clang/lib/Sema/SemaAttr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/Sema/attr-coldhot.c
clang/test/Sema/attr-disable-tail-calls.c
clang/test/Sema/internal_linkage.c
clang/test/SemaCXX/attr-speculative-load-hardening.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index a547154721e9..c1e45569a816 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -3033,6 +3033,13 @@ If additional functionality is desired for the semantic 
form of the attribute,
 the ``AdditionalMembers`` field specifies code to be copied verbatim into the
 semantic attribute class object, with ``public`` access.
 
+If two or more attributes cannot be used in combination on the same declaration
+or statement, a ``MutualExclusions`` definition can be supplied to 
automatically
+generate diagnostic code. This will disallow the attribute combinations
+regardless of spellings used. Additionally, it will diagnose combinations 
within
+the same attribute list, 
diff erent attribute list, and redeclarations, as
+appropriate.
+
 Boilerplate
 ^^^
 All semantic processing of declaration attributes happens in 
`lib/Sema/SemaDeclAttr.cpp

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index b832d1df7172..d9c2422536d0 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -554,6 +554,11 @@ class Attr {
   list Documentation;
 }
 
+/// Used to define a set of mutually exclusive attributes.
+class MutualExclusions Ex> {
+  list Exclusions = Ex;
+}
+
 /// A type attribute is not processed on a declaration or a statement.
 class TypeAttr : Attr;
 
@@ -918,6 +923,7 @@ def CFAuditedTransfer : InheritableAttr {
   let Spellings = [Clang<"cf_audited_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
+  let SimpleHandler = 1;
 }
 
 // cf_unknown_transfer is an explicit opt-out of cf_audited_transfer.
@@ -927,7 +933,9 @@ def CFUnknownTransfer : InheritableAttr {
   let Spellings = [Clang<"cf_unknown_transfer">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
   let Documentation = [Undocumented];
+  let SimpleHandler = 1;
 }
+def : MutualExclusions<[CFAuditedTransfer, CFUnknownTransfer]>;
 
 def CFReturnsRetained : InheritableAttr {
   let Spellings = [Clang<"cf_returns_retained">];
@@ -1009,6 +1017,7 @@ def Cold : InheritableAttr {
   let Spellings = [GCC<"cold">];
   let Subjects = SubjectList<[Function]>;
   let Documentation = [Undocumented];
+  let SimpleHandler = 1;
 }
 
 def Common : InheritableAttr {
@@ -1094,6 +1103,7 @@ def CUDADeviceBuiltinSurfaceType : InheritableAttr {
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [CUDADeviceBuiltinSurfaceTypeDocs];
   let MeaningfulToClassTemplateDefinition = 1;
+  let SimpleHandler = 1;
 }
 
 def CUDADeviceBuiltinTextureType : InheritableAttr {
@@ -1103,7 +1113,10 @@ def CUDADeviceBuiltinTextureType : InheritableAttr {
   let Subjects = SubjectList<[CXXRecord]>;
   let Documentation = [CUDADeviceBuiltinTextureTypeDocs];
   let MeaningfulToClassTemplateDefinition = 1;
+  let SimpleHandler = 1;
 }
+def : MutualExclusions<[CUDADeviceBuiltinSurfaceType,
+CUDADeviceBuiltinTextureType]>;
 
 def CUDAGlobal : InheritableAttr {
   let Spellings = [GNU<"global">, Declspec<"__global__">];
@@ -,13 +1124,16 @@ d

  1   2   >