[PATCH] D128833: [clang][dataflow] Handle `for` statements without conditions

2022-06-30 Thread Stanislav Gatev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8207c2a66030: [clang][dataflow] Handle `for` statements 
without conditions (authored by sgatev).
Herald added a reviewer: NoQ.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128833

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


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3827,4 +3827,30 @@
   });
 }
 
+TEST_F(TransferTest, ForStmtBranchWithoutConditionDoesNotExtendFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  for (;;) {
+(void)0;
+// [[loop_body]]
+  }
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("loop_body", _)));
+const Environment &LoopBodyEnv = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+BoolValue &LoopBodyFooVal =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_FALSE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -97,8 +97,8 @@
 
   void VisitForStmt(const ForStmt *S) {
 auto *Cond = S->getCond();
-assert(Cond != nullptr);
-extendFlowCondition(*Cond);
+if (Cond != nullptr)
+  extendFlowCondition(*Cond);
   }
 
   void VisitBinaryOperator(const BinaryOperator *S) {


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3827,4 +3827,30 @@
   });
 }
 
+TEST_F(TransferTest, ForStmtBranchWithoutConditionDoesNotExtendFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  for (;;) {
+(void)0;
+// [[loop_body]]
+  }
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("loop_body", _)));
+const Environment &LoopBodyEnv = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+BoolValue &LoopBodyFooVal =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_FALSE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+  });
+}
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -97,8 +97,8 @@
 
   void VisitForStmt(const ForStmt *S) {
 auto *Cond = S->getCond();
-assert(Cond != nullptr);
-extendFlowCondition(*Cond);
+if (Cond != nullptr)
+  extendFlowCondition(*Cond);
   }
 
   void VisitBinaryOperator(const BinaryOperator *S) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8207c2a - [clang][dataflow] Handle `for` statements without conditions

2022-06-30 Thread Stanislav Gatev via cfe-commits

Author: Stanislav Gatev
Date: 2022-06-30T07:00:35Z
New Revision: 8207c2a660303272ad8ecb1807407f029466ff49

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

LOG: [clang][dataflow] Handle `for` statements without conditions

Handle `for` statements without conditions.

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

Reviewed-by: xazax.hun, gribozavr2, li.zhe.hua

Added: 


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

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp 
b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
index 4a35c39cf2fd5..6443fc1b64226 100644
--- a/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ b/clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -97,8 +97,8 @@ class TerminatorVisitor : public 
ConstStmtVisitor {
 
   void VisitForStmt(const ForStmt *S) {
 auto *Cond = S->getCond();
-assert(Cond != nullptr);
-extendFlowCondition(*Cond);
+if (Cond != nullptr)
+  extendFlowCondition(*Cond);
   }
 
   void VisitBinaryOperator(const BinaryOperator *S) {

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index a0b753ff9e317..021f8a238c634 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -3827,4 +3827,30 @@ TEST_F(TransferTest, ForStmtBranchExtendsFlowCondition) {
   });
 }
 
+TEST_F(TransferTest, ForStmtBranchWithoutConditionDoesNotExtendFlowCondition) {
+  std::string Code = R"(
+void target(bool Foo) {
+  for (;;) {
+(void)0;
+// [[loop_body]]
+  }
+}
+  )";
+  runDataflow(
+  Code, [](llvm::ArrayRef<
+   std::pair>>
+   Results,
+   ASTContext &ASTCtx) {
+ASSERT_THAT(Results, ElementsAre(Pair("loop_body", _)));
+const Environment &LoopBodyEnv = Results[0].second.Env;
+
+const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
+ASSERT_THAT(FooDecl, NotNull());
+
+BoolValue &LoopBodyFooVal =
+*cast(LoopBodyEnv.getValue(*FooDecl, SkipPast::None));
+EXPECT_FALSE(LoopBodyEnv.flowConditionImplies(LoopBodyFooVal));
+  });
+}
+
 } // namespace



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


[PATCH] D128704: [clang-extdef-mapping] Directly process .ast files

2022-06-30 Thread Tobias Hieta via Phabricator via cfe-commits
thieta updated this revision to Diff 441279.
thieta added a comment.

Clean-ups and error handling.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128704

Files:
  clang/test/Analysis/func-mapping-test.cpp
  clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp

Index: clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
===
--- clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -1,4 +1,4 @@
-//===- ClangExtDefMapGen.cpp ---===//
+//===- ClangExtDefMapGen.cpp -===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -13,10 +13,12 @@
 
 #include "clang/AST/ASTConsumer.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/CrossTU/CrossTranslationUnit.h"
 #include "clang/Frontend/CompilerInstance.h"
 #include "clang/Frontend/FrontendActions.h"
+#include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/Support/CommandLine.h"
@@ -29,12 +31,16 @@
 using namespace clang::cross_tu;
 using namespace clang::tooling;
 
-static cl::OptionCategory ClangExtDefMapGenCategory("clang-extdefmapgen options");
+static cl::OptionCategory
+ClangExtDefMapGenCategory("clang-extdefmapgen options");
 
 class MapExtDefNamesConsumer : public ASTConsumer {
 public:
-  MapExtDefNamesConsumer(ASTContext &Context)
-  : Ctx(Context), SM(Context.getSourceManager()) {}
+  MapExtDefNamesConsumer(ASTContext &Context,
+ StringRef astFilePath = StringRef())
+  : Ctx(Context), SM(Context.getSourceManager()) {
+CurrentFileName = astFilePath.str();
+  }
 
   ~MapExtDefNamesConsumer() {
 // Flush results to standard output.
@@ -111,6 +117,56 @@
 
 static cl::extrahelp CommonHelp(CommonOptionsParser::HelpMessage);
 
+static bool HandleAST(StringRef astPath) {
+
+  CompilerInstance CI;
+
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  TextDiagnosticPrinter *DiagClient =
+  new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);
+  IntrusiveRefCntPtr DiagID(new DiagnosticIDs());
+  IntrusiveRefCntPtr Diags(
+  new DiagnosticsEngine(DiagID, &*DiagOpts, DiagClient));
+
+  std::unique_ptr unit = ASTUnit::LoadFromASTFile(
+  astPath.str(), CI.getPCHContainerOperations()->getRawReader(),
+  ASTUnit::LoadASTOnly, Diags, CI.getFileSystemOpts());
+
+  if (!unit)
+return false;
+
+  FileManager fm(CI.getFileSystemOpts());
+  SmallString<128> absPath(astPath);
+  fm.makeAbsolutePath(absPath);
+
+  std::unique_ptr consumer =
+  std::make_unique(unit->getASTContext(), absPath);
+  consumer->HandleTranslationUnit(unit->getASTContext());
+
+  return true;
+}
+
+static int HandleFiles(ArrayRef sourceFiles,
+   CompilationDatabase &compilations) {
+  std::vector sourceToBeParsed;
+  for (StringRef src : sourceFiles) {
+if (src.endswith(".ast")) {
+  if (!HandleAST(src)) {
+return 1;
+  }
+} else {
+  sourceToBeParsed.push_back(src.str());
+}
+  }
+
+  if (!sourceToBeParsed.empty()) {
+ClangTool Tool(compilations, sourceToBeParsed);
+return Tool.run(newFrontendActionFactory().get());
+  }
+
+  return 0;
+}
+
 int main(int argc, const char **argv) {
   // Print a stack trace if we signal out.
   sys::PrintStackTraceOnErrorSignal(argv[0], false);
@@ -127,8 +183,6 @@
   }
   CommonOptionsParser &OptionsParser = ExpectedParser.get();
 
-  ClangTool Tool(OptionsParser.getCompilations(),
- OptionsParser.getSourcePathList());
-
-  return Tool.run(newFrontendActionFactory().get());
+  return HandleFiles(OptionsParser.getSourcePathList(),
+ OptionsParser.getCompilations());
 }
Index: clang/test/Analysis/func-mapping-test.cpp
===
--- clang/test/Analysis/func-mapping-test.cpp
+++ clang/test/Analysis/func-mapping-test.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_extdef_map %s -- | FileCheck --implicit-check-not "c:@y" --implicit-check-not "c:@z" %s
+// RUN: %clang -emit-ast %s -o %t.ast
+// RUN: %clang_extdef_map %t.ast -- | FileCheck --implicit-check-not "c:@y" --implicit-check-not "c:@z" %s
 
 int f(int) {
   return 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added a comment.

I'm glad the `DenseSet`s are gone, but my three-ish biggest gripes are:

- The algorithm is conceptually simple, but there is way more code than is 
necessary to achieve it.
- More comments (excluding "doc" comments) than code is generally not a good 
sign
- The implementation is still inefficient in a lot of obvious ways.




Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:10-11
+// This file implements a commutativity utility pattern and a function to
+// populate this pattern. The function is intended to be used inside passes to
+// simplify the matching of commutative operations.
+//





Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:21-38
+/// Stores the "ancestor" of an operand of some op. The operand of any op is
+/// produced by a set of ops and block arguments. Each of these ops and block
+/// arguments is called an "ancestor" of this operand.
+struct Ancestor {
+  /// Stores true when the "ancestor" is an op and false when the "ancestor" is
+  /// a block argument.
+  bool isOp;

This class isn't necessary. `Ancestor` can just be `Operation *`. If it's null, 
then we know it's a block argument (the bool flag is redundant).



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:40
+
+/// Declares various "types" of ancestors.
+enum AncestorType {





Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:65-66
+if (!ancestor.isOp) {
+  // When `ancestor` is a block argument, we assign `type` as
+  // `BLOCK_ARGUMENT` and `opName` remains "".
+  type = BLOCK_ARGUMENT;

My biggest complaint with respect to readability is that there are more 
comments than code. This is fine if the comment has a big explanation about the 
algorithm and how keys are represented, especially with a nice ASCII diagram as 
you have below. But if this constructor had 0 comments except maybe "Only 
non-constant ops are sorted by name", it would be perfectly fine.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:76
+  // `CONSTANT_OP` and `opName` remains "".
+  type = CONSTANT_OP;
+}

Constant ops could be sorted by name as well.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:88-96
+  bool operator<(const AncestorKey &key) const {
+if ((type == BLOCK_ARGUMENT && key.type != BLOCK_ARGUMENT) ||
+(type == NON_CONSTANT_OP && key.type == CONSTANT_OP))
+  return true;
+if ((key.type == BLOCK_ARGUMENT && type != BLOCK_ARGUMENT) ||
+(key.type == NON_CONSTANT_OP && type == CONSTANT_OP))
+  return false;

This should behave the same as the manually written comparator. `operator<` of 
`std::tuple` compares the first element and then the next if the first is equal.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:110
+  /// operand at a particular point in time.
+  DenseSet visitedAncestors;
+

Since this is a set of pointers expected to be small, you can use `SmallPtrSet` 
for a big efficiency boost (linear scan instead of hashing when small).



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:148-149
+
+  /// Stores true iff the operand has been assigned a sorted position yet.
+  bool isSorted = false;
+

Since you are moving sorted operands into their sorted position and tracking 
the unsorted range, you shouldn't even need this flag because you will always 
know the sorted and unsorted subranges.

There are multiple loops in which you iterate over the entire operand list but 
skip those where this flag is set/unset. In those cases, you can always just 
iterate the subrange of interest.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:155-159
+Ancestor ancestor(op);
+ancestorQueue.push(ancestor);
+if (ancestor.isOp)
+  visitedAncestors.insert(ancestor.op);
+return;





Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:162-177
+  /// Pop the ancestor from the front of the queue.
+  void popAncestor() {
+assert(!ancestorQueue.empty() &&
+   "to pop the ancestor from the front of the queue, the ancestor "
+   "queue should be non-empty");
+ancestorQueue.pop();
+return;

I would drop these helpers. `std::queue` will already assert if `pop` or 
`front` are called on an empty queue.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:200-217
+  unsigned keyASize = keyA.size();
+  unsigned keyBSize = keyB.size();
+  unsigned smallestSize = keyASize;
+  if (keyBSize < smallestSize)
+smallestSize = keyBSize;
+
+  for (unsigned i = 0; i < smallestSize; i++) {





Comment at: mlir/lib/Transforms/Utils/Comm

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:523
+  shiftTheSmallestUnsortedOperandsToTheSmallestUnsortedPositions(
+  bfsOfOperands, smallestUnsortedPosition);
+

And then you'll never need to check `isSorted` again.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm marked 4 inline comments as done.
srishti-pm added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:76
+  // `CONSTANT_OP` and `opName` remains "".
+  type = CONSTANT_OP;
+}

Mogball wrote:
> Constant ops could be sorted by name as well.
The only reason we separated constant ops from the non-constant ops was because 
the former are canonicalized to the right (as a stable sort) by existing 
canonicalizations. And, we didn't want our algorithm to conflict with these 
existing canonicalizations. That is the reason I am not sorting them by name 
and just keeping them to the right (as a stable sort).



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:269
+ArrayRef> bfsOfOperands,
+bool &hasOneOperandWithKey) {
+  bool keyFound = false;

Mogball wrote:
> This flag is not necessary because you can just check 
> `bfsOfOperandsWithKey.size() == 1`
`.size()` is an O(N) operation and that is why I usually try to avoid it. Do 
you still agree we should use it here? I understand that N is an expectedly 
small value.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:278-279
+if (compareKeys(key, currentKey) == 0) {
+  bfsOfOperandsWithKey.push_back(
+  std::make_unique(*bfsOfOperand));
+  if (keyFound)

Mogball wrote:
> You don't need to make a copy. In fact, I think you should just track the 
> indices.
I agree. But, we had discussed to store operands instead of indices and that's 
why I did this. I will change this to use indices again (keeping other things 
unchanged).



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:329-353
+  assert(frontPosition >= 0 && frontPosition < bfsOfOperands.size() &&
+ "`frontPosition` should be valid");
+  unsigned positionOfOperandToShift;
+  bool foundOperandToShift = false;
+  for (auto &indexedBfsOfOperand : llvm::enumerate(bfsOfOperands)) {
+std::unique_ptr &bfsOfOperand = indexedBfsOfOperand.value();
+if (bfsOfOperand->isSorted)

Mogball wrote:
> There is no way you need this much code. A `std::swap` between the current 
> operand and the first unsorted position should be enough.
If I do a swap, the sorting will no longer be stable and I believe that there 
was a discussion that concluded with the fact that "we want stable sorting".



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:360
+/// the smallest position containing an unsorted operand).
+static void shiftTheSmallestUnsortedOperandsToTheSmallestUnsortedPositions(
+SmallVectorImpl> &bfsOfOperands,

Mogball wrote:
> This is possibly the longest function name I've ever seen. Please make it 
> more concise.
Could you please give a suggestion for the name? After a long thought, I came 
up with this name. It was better than all my other ideas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D128887: [clang][transformer] Fix crash on replacement-less ASTEdit.

2022-06-30 Thread Clement Courbet via Phabricator via cfe-commits
courbet created this revision.
courbet added a reviewer: ymandel.
Herald added a project: All.
courbet requested review of this revision.
Herald added projects: clang, clang-tools-extra.

Given that we provide an EditGenerator edit(ASTEdit), we can't ever be
sure that the user won't give us an empty replacement.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128887

Files:
  clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
  clang/lib/Tooling/Transformer/RewriteRule.cpp


Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -50,17 +50,21 @@
 // produces a bad range, whereas the latter will simply ignore A.
 if (!EditRange)
   return SmallVector();
-auto Replacement = E.Replacement->eval(Result);
-if (!Replacement)
-  return Replacement.takeError();
-auto Metadata = E.Metadata(Result);
-if (!Metadata)
-  return Metadata.takeError();
 transformer::Edit T;
 T.Kind = E.Kind;
 T.Range = *EditRange;
-T.Replacement = std::move(*Replacement);
-T.Metadata = std::move(*Metadata);
+if (E.Replacement) {
+  auto Replacement = E.Replacement->eval(Result);
+  if (!Replacement)
+return Replacement.takeError();
+  T.Replacement = std::move(*Replacement);
+}
+if (E.Metadata) {
+  auto Metadata = E.Metadata(Result);
+  if (!Metadata)
+return Metadata.takeError();
+  T.Metadata = std::move(*Metadata);
+}
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -90,6 +90,32 @@
   EXPECT_EQ(Errors[0].Message.FileOffset, 10U);
 }
 
+transformer::ASTEdit noReplacementEdit(transformer::RangeSelector Target) {
+  transformer::ASTEdit E;
+  E.TargetRange = std::move(Target);
+  return E;
+}
+
+TEST(TransformerClangTidyCheckTest, EmptyReplacement) {
+  class DiagOnlyCheck : public TransformerClangTidyCheck {
+  public:
+DiagOnlyCheck(StringRef Name, ClangTidyContext *Context)
+: TransformerClangTidyCheck(
+  makeRule(returnStmt(), edit(noReplacementEdit(node(RootID))),
+   cat("message")),
+  Name, Context) {}
+  };
+  std::string Input = "int h() { return 5; }";
+  std::vector Errors;
+  EXPECT_EQ("int h() { }", test::runCheckOnCode(Input, 
&Errors));
+  EXPECT_EQ(Errors.size(), 1U);
+  EXPECT_EQ(Errors[0].Message.Message, "message");
+  EXPECT_THAT(Errors[0].Message.Ranges, testing::IsEmpty());
+
+  // The diagnostic is anchored to the match, "return 5".
+  EXPECT_EQ(Errors[0].Message.FileOffset, 10U);
+}
+
 TEST(TransformerClangTidyCheckTest, DiagnosticMessageEscaped) {
   class GiveDiagWithPercentSymbol : public TransformerClangTidyCheck {
   public:


Index: clang/lib/Tooling/Transformer/RewriteRule.cpp
===
--- clang/lib/Tooling/Transformer/RewriteRule.cpp
+++ clang/lib/Tooling/Transformer/RewriteRule.cpp
@@ -50,17 +50,21 @@
 // produces a bad range, whereas the latter will simply ignore A.
 if (!EditRange)
   return SmallVector();
-auto Replacement = E.Replacement->eval(Result);
-if (!Replacement)
-  return Replacement.takeError();
-auto Metadata = E.Metadata(Result);
-if (!Metadata)
-  return Metadata.takeError();
 transformer::Edit T;
 T.Kind = E.Kind;
 T.Range = *EditRange;
-T.Replacement = std::move(*Replacement);
-T.Metadata = std::move(*Metadata);
+if (E.Replacement) {
+  auto Replacement = E.Replacement->eval(Result);
+  if (!Replacement)
+return Replacement.takeError();
+  T.Replacement = std::move(*Replacement);
+}
+if (E.Metadata) {
+  auto Metadata = E.Metadata(Result);
+  if (!Metadata)
+return Metadata.takeError();
+  T.Metadata = std::move(*Metadata);
+}
 Edits.push_back(std::move(T));
   }
   return Edits;
Index: clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/TransformerClangTidyCheckTest.cpp
@@ -90,6 +90,32 @@
   EXPECT_EQ(Errors[0].Message.FileOffset, 10U);
 }
 
+transformer::ASTEdit noReplacementEdit(transformer::RangeSelector Target) {
+  transformer::ASTEdit E;
+  E.TargetRange = std::move(Target);
+  return E;
+}
+
+TEST(TransformerClangTidyCheckTest, EmptyReplacement) {
+  class DiagOnlyCheck : public TransformerClangTidyCheck {
+  public:
+   

[PATCH] D128807: [clang][transformer] Finish plumbing `Note` all the way to the output.

2022-06-30 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: clang/lib/Tooling/Transformer/RewriteRule.cpp:56
 T.Range = *EditRange;
-T.Replacement = std::move(*Replacement);
-T.Metadata = std::move(*Metadata);
+if (E.Replacement) {
+  auto Replacement = E.Replacement->eval(Result);

ymandel wrote:
> Can this ever be null? I assume the intent was "no" (in which case I'd 
> recommend an assert instead), but I'm open to the idea that it's valid, just 
> want to understand better.
Given that we provide an `EditGenerator edit(ASTEdit)`, we can't ever be sure 
that the user won't give us an empty replacement.

I've split this off to a separate patch here with a test to show the issue: 
https://reviews.llvm.org/D128887


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128807

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


[clang] f595003 - [NFC] [Modules] Add test for inherit default arguments

2022-06-30 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-06-30T15:48:22+08:00
New Revision: f595003e8e86bcb9531c2439f6a3771e669a3f3e

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

LOG: [NFC] [Modules] Add test for inherit default arguments

Added: 
clang/test/Modules/InheritDefaultArguments.cppm

Modified: 


Removed: 




diff  --git a/clang/test/Modules/InheritDefaultArguments.cppm 
b/clang/test/Modules/InheritDefaultArguments.cppm
new file mode 100644
index 0..bbd5ad4c96a56
--- /dev/null
+++ b/clang/test/Modules/InheritDefaultArguments.cppm
@@ -0,0 +1,28 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/A.cppm -emit-module-interface -o %t/A.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t -I%t %t/Use.cppm 
-verify -fsyntax-only
+
+//--- foo.h
+template 
+class Templ;
+
+template 
+class Templ {};
+
+template 
+Templ(T t) -> Templ;
+
+//--- A.cppm
+module;
+#include "foo.h"
+export module A;
+
+//--- Use.cppm
+// expected-no-diagnostics
+module;
+#include "foo.h"
+export module X;
+import A;



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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-06-30 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 441293.
lkail added a comment.

Option name changed to `-mabi=quadword-atomics` as nemanja suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/PowerPC/quadword-atomics.c
  clang/test/Driver/aix-quadword-atomics-abi.c
  clang/test/Driver/ppc-unsupported.c
  clang/test/Sema/atomic-ops.c

Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -10,6 +10,12 @@
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11 \
 // RUN:   -target-cpu pwr8 -DPPC64_PWR8
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64-unknown-aix -std=c11 \
+// RUN:   -target-cpu pwr8
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64-unknown-aix -std=c11 \
+// RUN:   -mabi=quadword-atomics -target-cpu pwr8 -DPPC64_PWR8
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/Driver/ppc-unsupported.c
===
--- clang/test/Driver/ppc-unsupported.c
+++ clang/test/Driver/ppc-unsupported.c
@@ -7,4 +7,14 @@
 // RUN:   -c %s 2>&1 | FileCheck %s
 // RUN: not %clang -target powerpc64le-unknown-linux -msvr4-struct-return \
 // RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64-unknown-freebsd -mabi=quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64-unknown-linux -mabi=quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-unknown-linux -mabi=quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc-unknown-unknown -mabi=quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc-unknown-aix -mabi=quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
 // CHECK: unsupported option
Index: clang/test/Driver/aix-quadword-atomics-abi.c
===
--- /dev/null
+++ clang/test/Driver/aix-quadword-atomics-abi.c
@@ -0,0 +1,11 @@
+// RUN:  %clang -### -target powerpc-unknown-aix -S %s 2>&1 | FileCheck %s
+// RUN:  %clang -### -target powerpc64-unknown-aix -S %s 2>&1 | FileCheck %s
+// RUN:  %clang -### -target powerpc-unknown-aix -mabi=quadword-atomics -S \
+// RUN:%s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
+// RUN:  %clang -### -target powerpc64-unknown-aix -mabi=quadword-atomics -S \
+// RUN:%s 2>&1 | FileCheck %s --check-prefix=CHECK-QUADWORD-ATOMICS
+//
+// CHECK-UNSUPPORTED-TARGET: unsupported option '-mabi=quadword-atomics' for target 'powerpc-unknown-aix'
+// CHECK-NOT: "-mabi=quadword-atomics"
+// CHECK-QUADWORD-ATOMICS: "-cc1"
+// CHECK-QUADWORD-ATOMICS-SAME: "-mabi=quadword-atomics"
Index: clang/test/CodeGen/PowerPC/quadword-atomics.c
===
--- clang/test/CodeGen/PowerPC/quadword-atomics.c
+++ clang/test/CodeGen/PowerPC/quadword-atomics.c
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
-// RUN:   -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64-PWR8
+// RUN:   -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64-QUADWORD-ATOMICS
 // RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
 // RUN:   -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
 // RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
 // RUN:   -target-cpu pwr7 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
+// RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
+// RUN:   -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
+// RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
+// RUN:   -mabi=quadword-atomics -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s \
+// RUN:   --check-prefix=PPC64-QUADWORD-ATOMICS
+
 
 typedef struct {
   char x[16];
@@ -13,8 +19,8 @@
 
 typedef __int128_t int128_t;
 
-// PPC64-PWR8-LABEL: @test_load(
-// PPC64-PWR8:[[TMP3:%.*]] = load atomic i128, i128* [[TMP1:%.*]] acquire, align 16
+// PPC64-QUADWORD-ATOMICS-LABEL: @test_load(
+// PPC64-QUADWORD-ATOMICS:[[TMP3:%.*]] = load atomic i128, i128* [[TMP1:%.*]] acquire, align 16
 //
 // PPC64-LABEL: @test_load(
 // PPC

[PATCH] D126956: [tbaa] Handle base classes in struct tbaa

2022-06-30 Thread Bruno De Fraine via Phabricator via cfe-commits
brunodf updated this revision to Diff 441294.
brunodf added a comment.

Adding comment regarding empty subobjects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126956

Files:
  clang/lib/CodeGen/CodeGenTBAA.cpp
  clang/test/CodeGen/tbaa-class.cpp
  clang/unittests/CodeGen/TBAAMetadataTest.cpp

Index: clang/unittests/CodeGen/TBAAMetadataTest.cpp
===
--- clang/unittests/CodeGen/TBAAMetadataTest.cpp
+++ clang/unittests/CodeGen/TBAAMetadataTest.cpp
@@ -968,13 +968,10 @@
   MConstInt(0)),
 MConstInt(0));
 
-  auto ClassDerived = MMTuple(
-MMString("_ZTS7Derived"),
-MMTuple(
-  MMString("short"),
-  OmnipotentCharCXX,
-  MConstInt(0)),
-MConstInt(4));
+  auto ClassDerived =
+  MMTuple(MMString("_ZTS7Derived"), ClassBase, MConstInt(0),
+  MMTuple(MMString("short"), OmnipotentCharCXX, MConstInt(0)),
+  MConstInt(4));
 
   const Instruction *I = match(BB,
   MInstruction(Instruction::Store,
@@ -1047,13 +1044,10 @@
   MConstInt(0)),
 MConstInt(Compiler.PtrSize));
 
-  auto ClassDerived = MMTuple(
-MMString("_ZTS7Derived"),
-MMTuple(
-  MMString("short"),
-  OmnipotentCharCXX,
-  MConstInt(0)),
-MConstInt(Compiler.PtrSize + 4));
+  auto ClassDerived =
+  MMTuple(MMString("_ZTS7Derived"), ClassBase, MConstInt(0),
+  MMTuple(MMString("short"), OmnipotentCharCXX, MConstInt(0)),
+  MConstInt(Compiler.PtrSize + 4));
 
   const Instruction *I = match(BB,
   MInstruction(Instruction::Store,
Index: clang/test/CodeGen/tbaa-class.cpp
===
--- clang/test/CodeGen/tbaa-class.cpp
+++ clang/test/CodeGen/tbaa-class.cpp
@@ -51,6 +51,25 @@
uint32_t f32_2;
 };
 
+class StructT {
+public:
+  uint32_t f32_2;
+  void foo();
+};
+class StructM1 : public StructS, public StructT {
+public:
+  uint16_t f16_2;
+};
+class StructDyn {
+public:
+  uint32_t f32_2;
+  virtual void foo();
+};
+class StructM2 : public StructS, public StructDyn {
+public:
+  uint16_t f16_2;
+};
+
 uint32_t g(uint32_t *s, StructA *A, uint64_t count) {
 // CHECK-LABEL: define{{.*}} i32 @_Z1g
 // CHECK: store i32 1, i32* %{{.*}}, align 4, !tbaa [[TAG_i32:!.*]]
@@ -199,6 +218,30 @@
   return b1->a.f32;
 }
 
+uint32_t g13(StructM1 *M, StructS *S) {
+  // CHECK-LABEL: define{{.*}} i32 @_Z3g13
+  // CHECK: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // CHECK: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // PATH-LABEL: define{{.*}} i32 @_Z3g13
+  // PATH: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_S_f16]]
+  // PATH: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_M1_f16_2:!.*]]
+  S->f16 = 1;
+  M->f16_2 = 4;
+  return S->f16;
+}
+
+uint32_t g14(StructM2 *M, StructS *S) {
+  // CHECK-LABEL: define{{.*}} i32 @_Z3g14
+  // CHECK: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // CHECK: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_i16]]
+  // PATH-LABEL: define{{.*}} i32 @_Z3g14
+  // PATH: store i16 1, i16* %{{.*}}, align 4, !tbaa [[TAG_S_f16]]
+  // PATH: store i16 4, i16* %{{.*}}, align 4, !tbaa [[TAG_M2_f16_2:!.*]]
+  S->f16 = 1;
+  M->f16_2 = 4;
+  return S->f16;
+}
+
 // CHECK: [[TYPE_char:!.*]] = !{!"omnipotent char", [[TAG_cxx_tbaa:!.*]],
 // CHECK: [[TAG_cxx_tbaa]] = !{!"Simple C++ TBAA"}
 // CHECK: [[TAG_i32]] = !{[[TYPE_i32:!.*]], [[TYPE_i32]], i64 0}
@@ -222,11 +265,17 @@
 // OLD-PATH: [[TYPE_S]] = !{!"_ZTS7StructS", [[TYPE_SHORT]], i64 0, [[TYPE_INT]], i64 4}
 // OLD-PATH: [[TAG_S_f16]] = !{[[TYPE_S]], [[TYPE_SHORT]], i64 0}
 // OLD-PATH: [[TAG_S2_f32_2]] = !{[[TYPE_S2:!.*]], [[TYPE_INT]], i64 12}
-// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
+// OLD-PATH: [[TYPE_S2]] = !{!"_ZTS8StructS2", [[TYPE_S]], i64 0, [[TYPE_SHORT]], i64 8, [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TAG_C_b_a_f32]] = !{[[TYPE_C:!.*]], [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TYPE_C]] = !{!"_ZTS7StructC", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28}
 // OLD-PATH: [[TAG_D_b_a_f32]] = !{[[TYPE_D:!.*]], [[TYPE_INT]], i64 12}
 // OLD-PATH: [[TYPE_D]] = !{!"_ZTS7StructD", [[TYPE_SHORT]], i64 0, [[TYPE_B]], i64 4, [[TYPE_INT]], i64 28, [[TYPE_CHAR]], i64 32}
+// OLD-PATH: [[TAG_M1_f16_2]] = !{[[TYPE_M1:!.*]], [[TYPE_SHORT]], i64 12}
+// OLD-PATH: [[TYPE_M1]] = !{!"_ZTS8StructM1", [[TYPE_S]], i64 0, [[TYPE_T:!.*]], i64 8, [[TYPE_SHORT]], i64 12}
+// OLD_PATH: [[TYPE_T]] = !{!"_ZTS7StructT", [[TYPE_INT]], i64 0}
+// OLD-PATH: [[TAG_M2_f16_2]] = !{[[TYPE_M2:!.*]], [[TYPE_SHORT]], i64 20}
+// OLD-PATH: [[TYPE_M2]] = !{!"_ZTS8StructM2", [[TYPE_DYN:!.*]], i64 0, [[TYPE_S]], i64 12, [[TYPE_SHORT]], i64 20}
+// OLD_PATH: [[TYPE_DYN]] = !{!"_ZTS9StructDyn", [[TYPE_INT]], i64 8}
 
 // NEW-PATH: [[TYPE_CHAR:!.*]] = !{!{{.*}}, i64 1, !"omnipotent char"}
 // NEW-PATH: [[

[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D128402#3621002 , @ishaangandhi 
wrote:

> Once you see it, can you either confirm `-fix-errors` was correct originally, 
> or instruct me on how to fix this test failure?

`-expect-clang-tidy-error` is the technically correct flag to use, but I'm easy 
either way.


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

https://reviews.llvm.org/D128402

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

Overall the patch looks ok from a technical point. Shouldn't we just wait until 
we can make the permanent renaming so we do not add unnecessary cmake option?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D128892: [clangd] Also mark output arguments of array subscript expressions

2022-06-30 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler created this revision.
Herald added subscribers: usaxena95, kadircet, arphaman.
Herald added a project: All.
ckandeler requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

... with the "usedAsMutableReference" semantic token modifier.
It's quite unusual to declare the index parameter of a subscript
operator as a non-const reference type, but arguably that makes it even
more helpful to be aware of it when working with such code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128892

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -742,6 +742,8 @@
 void operator()(int);
 void operator()(int, int &);
 void operator()(int, int, const int &);
+int &operator[](int &);
+int operator[](int) const;
 };
 void $Function_decl[[fun]](int, const int,
int*, const int*,
@@ -768,9 +770,12 @@
   [](int&){}($LocalVariable_usedAsMutableReference[[val]]);
   [](const int&){}($LocalVariable[[val]]);
   $Class[[ClassWithOp]] $LocalVariable_decl[[c]];
+  const $Class[[ClassWithOp]] $LocalVariable_decl_readonly[[c2]];
   $LocalVariable[[c]]($LocalVariable[[val]]);
   $LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]);
   $LocalVariable[[c]](0, 0, $LocalVariable[[val]]);
+  $LocalVariable[[c]][$LocalVariable_usedAsMutableReference[[val]]];
+  $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_decl[[S]] {
   $Class_decl[[S]](int&) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -543,9 +543,14 @@
 // operators as well
 llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()};
 if (const auto callOp = dyn_cast(E)) {
-  if (callOp->getOperator() != OO_Call)
+  switch (callOp->getOperator()) {
+  case OO_Call:
+  case OO_Subscript:
+Args = Args.drop_front(); // Drop object parameter
+break;
+  default:
 return true;
-  Args = Args.drop_front(); // Drop object parameter
+  }
 }
 
 highlightMutableReferenceArguments(


Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -742,6 +742,8 @@
 void operator()(int);
 void operator()(int, int &);
 void operator()(int, int, const int &);
+int &operator[](int &);
+int operator[](int) const;
 };
 void $Function_decl[[fun]](int, const int,
int*, const int*,
@@ -768,9 +770,12 @@
   [](int&){}($LocalVariable_usedAsMutableReference[[val]]);
   [](const int&){}($LocalVariable[[val]]);
   $Class[[ClassWithOp]] $LocalVariable_decl[[c]];
+  const $Class[[ClassWithOp]] $LocalVariable_decl_readonly[[c2]];
   $LocalVariable[[c]]($LocalVariable[[val]]);
   $LocalVariable[[c]](0, $LocalVariable_usedAsMutableReference[[val]]);
   $LocalVariable[[c]](0, 0, $LocalVariable[[val]]);
+  $LocalVariable[[c]][$LocalVariable_usedAsMutableReference[[val]]];
+  $LocalVariable_readonly[[c2]][$LocalVariable[[val]]];
 }
 struct $Class_decl[[S]] {
   $Class_decl[[S]](int&) {
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -543,9 +543,14 @@
 // operators as well
 llvm::ArrayRef Args = {E->getArgs(), E->getNumArgs()};
 if (const auto callOp = dyn_cast(E)) {
-  if (callOp->getOperator() != OO_Call)
+  switch (callOp->getOperator()) {
+  case OO_Call:
+  case OO_Subscript:
+Args = Args.drop_front(); // Drop object parameter
+break;
+  default:
 return true;
-  Args = Args.drop_front(); // Drop object parameter
+  }
 }
 
 highlightMutableReferenceArguments(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-

[PATCH] D128783: [test] Check for more -fsanitize=array-bounds regressions

2022-06-30 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg updated this revision to Diff 441313.
sberg added a comment.

Updated the prospective git commit message as follow:

  [test] Check for more -fsanitize=array-bounds behavior
  
  ...that had temporarily regressed with (since reverted)
  

  "[clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible
  arrays", and had then been seen to cause issues in the wild:
  
  For one, the HarfBuzz project has various "fake" flexible array members of the
  form
  
  > TypearrayZ[HB_VAR_ARRAY];
  
  in , where
  HB_VAR_ARRAY is a macro defined as
  
  > #ifndef HB_VAR_ARRAY
  > #define HB_VAR_ARRAY 1
  > #endif
  
  in .
  
  For another, the Firebird project in
   
uses
  a trailing member
  
  > srq lhb_hash[1];// Hash table
  
  as a "fake" flexible array, but declared in a
  
  > struct lhb : public Firebird::MemoryHeader
  
  that is not a standard-layout class (because the Firebird::MemoryHeader base
  class also declares non-static data members).
  
  (The second case is specific to C++.  Extend the test setup so that all the
  other tests are now run for both C and C++, just in case the behavior could 
ever
  start to diverge for those two languages.)
  
  Differential Revision: https://reviews.llvm.org/D128783


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

https://reviews.llvm.org/D128783

Files:
  clang/test/CodeGen/bounds-checking-fam.c


Index: clang/test/CodeGen/bounds-checking-fam.c
===
--- clang/test/CodeGen/bounds-checking-fam.c
+++ clang/test/CodeGen/bounds-checking-fam.c
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds %s -o - | 
FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds -x c++ %s 
-o - | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0,CXX,CXX-STRICT-0
 
 /// Before flexible array member was added to C99, many projects use a
 /// one-element array as the last emember of a structure as an alternative.
@@ -14,21 +15,48 @@
 struct Three {
   int a[3];
 };
+#define FLEXIBLE 1
+struct Macro {
+  int a[FLEXIBLE];
+};
 
-// CHECK-LABEL: define {{.*}} @test_one(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_one{{.*}}(
 int test_one(struct One *p, int i) {
   // CHECK-STRICT-0-NOT: @__ubsan
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_two(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_two{{.*}}(
 int test_two(struct Two *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_three(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_three{{.*}}(
 int test_three(struct Three *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
+
+// CHECK-LABEL: define {{.*}} @{{.*}}test_macro{{.*}}(
+int test_macro(struct Macro *p, int i) {
+  // CHECK-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+#if defined __cplusplus
+
+struct Base {
+  int b;
+};
+struct NoStandardLayout : Base {
+  int a[1];
+};
+
+// CXX-LABEL: define {{.*}} @{{.*}}test_nostandardlayout{{.*}}(
+int test_nostandardlayout(NoStandardLayout *p, int i) {
+  // CXX-STRICT-0-NOT: @__ubsan
+  return p->a[i] + (p->a)[i];
+}
+
+#endif


Index: clang/test/CodeGen/bounds-checking-fam.c
===
--- clang/test/CodeGen/bounds-checking-fam.c
+++ clang/test/CodeGen/bounds-checking-fam.c
@@ -1,5 +1,6 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0
+// RUN: %clang_cc1 -emit-llvm -triple x86_64 -fsanitize=array-bounds -x c++ %s -o - | FileCheck %s --check-prefixes=CHECK,CHECK-STRICT-0,CXX,CXX-STRICT-0
 
 /// Before flexible array member was added to C99, many projects use a
 /// one-element array as the last emember of a structure as an alternative.
@@ -14,21 +15,48 @@
 struct Three {
   int a[3];
 };
+#define FLEXIBLE 1
+struct Macro {
+  int a[FLEXIBLE];
+};
 
-// CHECK-LABEL: define {{.*}} @test_one(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_one{{.*}}(
 int test_one(struct One *p, int i) {
   // CHECK-STRICT-0-NOT: @__ubsan
   return p->a[i] + (p->a)[i];
 }
 
-// CHECK-LABEL: define {{.*}} @test_two(
+// CHECK-LABEL: define {{.*}} @{{.*}}test_two{{.*}}(
 int test_two(struct Two *p, int i) {
   // CHECK-STRICT-0: call void @__ubsan_handle_out_of_bounds_abort(
   return p->a[i] + (p->a)[i];
 }
 
-//

[PATCH] D128625: [RISCV][Driver] Fix baremetal `GCCInstallation` paths

2022-06-30 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev added a comment.

In D128625#3621030 , @MaskRay wrote:

> The description seems unclear to me. Is a `riscv64-unknown-linux-gnu` GCC 
> installation selected while the requested target triple is 
> `riscv64-unknown-elf`?

Yes, exactly (see precommitted tests 4ee6b7806bc0 
: adding 
one more target directory confuses driver, mixing triples in paths). Adjusting 
description to be more clear.

> This could be an instance of 
> https://discourse.llvm.org/t/rfc-fix-loose-behaviors-of-clang-target/60272 
> (`[RFC] Fix loose behaviors of Clang –target=`) and the right fix may be 
> somewhere upper level.

This looks related but not the same one: this patch fixes the incorrect use of 
completely different targets. I believe this issue could be addressed on top of 
your RFC implemented, need to refactor triple, setting equivalence of triples 
explicitly. Anyway, I'd like to have this patch committed meanwhile: it is more 
related to how `RISCVToolchain` uses baremetal `GCCInstallation` for the 
current state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128625

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


[clang] abeeae5 - [X86] Support `_Float16` on SSE2 and up

2022-06-30 Thread Phoebe Wang via cfe-commits

Author: Phoebe Wang
Date: 2022-06-30T17:21:37+08:00
New Revision: abeeae570efff38dceccf68f5352809c58ffdda2

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

LOG: [X86] Support `_Float16` on SSE2 and up

This is split from D113107 to address #56204 and 
https://discourse.llvm.org/t/how-to-build-compiler-rt-for-new-x86-half-float-abi/63366

Reviewed By: zahiraam, rjmccall, bkramer, MaskRay

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

Added: 
clang/test/CodeGen/X86/Float16-arithmetic.c
clang/test/CodeGen/X86/Float16-complex.c

Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/X86.cpp
clang/test/Sema/Float16.c
clang/test/Sema/conversion-target-dep.c
clang/test/SemaCXX/Float16.cpp
compiler-rt/test/builtins/CMakeLists.txt

Removed: 
clang/test/CodeGen/X86/avx512fp16-complex.c



diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index af697fafd8c41..1bac2aee84bd9 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -743,7 +743,13 @@ targets pending ABI standardization:
 * 64-bit ARM (AArch64)
 * AMDGPU
 * SPIR
-* X86 (Only available under feature AVX512-FP16)
+* X86 (see below)
+
+On X86 targets, ``_Float16`` is supported as long as SSE2 is available, which
+includes all 64-bit and all recent 32-bit processors. When the target supports
+AVX512-FP16, ``_Float16`` arithmetic is performed using that native support.
+Otherwise, ``_Float16`` arithmetic is performed by promoting to ``float``,
+performing the operation, and then truncating to ``_Float16``.
 
 ``_Float16`` will be supported on more targets as they define ABIs for it.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 99288d0ffac4e..b80e401e02f6c 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -516,6 +516,9 @@ X86 Support in Clang
 
 - Support ``-mharden-sls=[none|all|return|indirect-jmp]`` for straight-line
   speculation hardening.
+- Support for the ``_Float16`` type has been added for all targets with SSE2.
+  When AVX512-FP16 is not available, arithmetic on ``_Float16`` is emulated
+  using ``float``.
 
 DWARF Support in Clang
 --

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index b83b3517ddf90..06988830eaed6 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -239,7 +239,6 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
   HasAVX512ER = true;
 } else if (Feature == "+avx512fp16") {
   HasAVX512FP16 = true;
-  HasFloat16 = true;
 } else if (Feature == "+avx512pf") {
   HasAVX512PF = true;
 } else if (Feature == "+avx512dq") {
@@ -355,6 +354,8 @@ bool 
X86TargetInfo::handleTargetFeatures(std::vector &Features,
.Default(NoSSE);
 SSELevel = std::max(SSELevel, Level);
 
+HasFloat16 = SSELevel >= SSE2;
+
 MMX3DNowEnum ThreeDNowLevel = llvm::StringSwitch(Feature)
   .Case("+3dnowa", AMD3DNowAthlon)
   .Case("+3dnow", AMD3DNow)

diff  --git a/clang/test/CodeGen/X86/Float16-arithmetic.c 
b/clang/test/CodeGen/X86/Float16-arithmetic.c
new file mode 100644
index 0..aa61f7cb3c65f
--- /dev/null
+++ b/clang/test/CodeGen/X86/Float16-arithmetic.c
@@ -0,0 +1,112 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | 
FileCheck %s
+
+
+// CHECK-LABEL: @add1(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:store half [[A:%.*]], ptr [[A_ADDR]], align 2
+// CHECK-NEXT:store half [[B:%.*]], ptr [[B_ADDR]], align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr [[A_ADDR]], align 2
+// CHECK-NEXT:[[TMP1:%.*]] = load half, ptr [[B_ADDR]], align 2
+// CHECK-NEXT:[[ADD:%.*]] = fadd half [[TMP0]], [[TMP1]]
+// CHECK-NEXT:ret half [[ADD]]
+//
+_Float16 add1(_Float16 a, _Float16 b) {
+  return a + b;
+}
+
+// CHECK-LABEL: @add2(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:[[B_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:[[C_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:store half [[A:%.*]], ptr [[A_ADDR]], align 2
+// CHECK-NEXT:store half [[B:%.*]], ptr [[B_ADDR]], align 2
+// CHECK-NEXT:store half [[C:%.*]], ptr [[C_ADDR]], align 2
+// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr [[A_ADDR]], align 2
+// CHECK-NEXT:[[TMP1:%.*]] = load half, ptr [[B_ADDR]], align 2
+// CHECK-

[PATCH] D128571: [X86] Support `_Float16` on SSE2 and up

2022-06-30 Thread Phoebe Wang 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 rGabeeae570eff: [X86] Support `_Float16` on SSE2 and up 
(authored by pengfei).

Changed prior to commit:
  https://reviews.llvm.org/D128571?vs=441272&id=441315#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128571

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/X86/Float16-arithmetic.c
  clang/test/CodeGen/X86/Float16-complex.c
  clang/test/CodeGen/X86/avx512fp16-complex.c
  clang/test/Sema/Float16.c
  clang/test/Sema/conversion-target-dep.c
  clang/test/SemaCXX/Float16.cpp
  compiler-rt/test/builtins/CMakeLists.txt

Index: compiler-rt/test/builtins/CMakeLists.txt
===
--- compiler-rt/test/builtins/CMakeLists.txt
+++ compiler-rt/test/builtins/CMakeLists.txt
@@ -44,9 +44,17 @@
 string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
   endif()
 
-  if (${arch} MATCHES "arm|aarch64|arm64" AND COMPILER_RT_HAS_FLOAT16)
-list(APPEND BUILTINS_TEST_TARGET_CFLAGS -DCOMPILER_RT_HAS_FLOAT16)
-string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
+  if(APPLE)
+# TODO: Support the new ABI on Apple platforms.
+if (${arch} MATCHES "arm|aarch64|arm64" AND COMPILER_RT_HAS_FLOAT16)
+  list(APPEND BUILTINS_TEST_TARGET_CFLAGS -DCOMPILER_RT_HAS_FLOAT16)
+  string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
+endif()
+  else()
+if (${arch} MATCHES "arm|aarch64|arm64|i?86|x86_64|AMD64" AND COMPILER_RT_HAS_FLOAT16)
+  list(APPEND BUILTINS_TEST_TARGET_CFLAGS -DCOMPILER_RT_HAS_FLOAT16)
+  string(REPLACE ";" " " BUILTINS_TEST_TARGET_CFLAGS "${BUILTINS_TEST_TARGET_CFLAGS}")
+endif()
   endif()
 
   if(COMPILER_RT_ENABLE_CET)
Index: clang/test/SemaCXX/Float16.cpp
===
--- clang/test/SemaCXX/Float16.cpp
+++ clang/test/SemaCXX/Float16.cpp
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc -target-feature +sse2 %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
Index: clang/test/Sema/conversion-target-dep.c
===
--- clang/test/Sema/conversion-target-dep.c
+++ clang/test/Sema/conversion-target-dep.c
@@ -6,7 +6,7 @@
 
 long double ld;
 double d;
-_Float16 f16; // x86-error {{_Float16 is not supported on this target}}
+_Float16 f16;
 
 int main(void) {
   ld = d; // x86-warning {{implicit conversion increases floating-point precision: 'double' to 'long double'}}
Index: clang/test/Sema/Float16.c
===
--- clang/test/Sema/Float16.c
+++ clang/test/Sema/Float16.c
@@ -1,5 +1,6 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s
-// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc -target-feature +avx512fp16 %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc %s
+// RUN: %clang_cc1 -fsyntax-only -verify -triple i686-linux-pc -target-feature +sse2 %s -DHAVE
+// RUN: %clang_cc1 -fsyntax-only -verify -triple x86_64-linux-pc %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple spir-unknown-unknown %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple armv7a-linux-gnu %s -DHAVE
 // RUN: %clang_cc1 -fsyntax-only -verify -triple aarch64-linux-gnu %s -DHAVE
Index: clang/test/CodeGen/X86/Float16-complex.c
===
--- clang/test/CodeGen/X86/Float16-complex.c
+++ clang/test/CodeGen/X86/Float16-complex.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -target-feature +avx512fp16 -o - | FileCheck %s --check-prefix=X86
+// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown -o - | FileCheck %s --check-prefix=X86
 
 _Float16 _Complex add_half_rr(_Float16 a, _Float16 b) {
   // X86-LABEL: @add_half_rr(
Index: clang/test/CodeGen/X86/Float16-arithmetic.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/Float16-arithmetic.c
@@ -0,0 +1,112 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+
+

[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added a comment.

Thank your for reviewing @clementval !

In D125788#3621585 , @clementval 
wrote:

> Shouldn't we just wait until we can make the permanent renaming so we do not 
> add unnecessary cmake option?

This was discussed in one of our calls. As we weren't able to agree on any 
specific time-frames, the CMake route was proposed instead. This was suggested 
by @sscalpone as an acceptable compromise. From what I recall, there were no 
objections to this.

`flang-new` has always been intended as a //temporary name// for the compiler 
driver. That's because `flang` was reserved for the bash script. The bash 
script has recently been renamed as `flang-to-external-fc` ( D125832 
) so we are free to repurpose that name.  As 
I tried to explain earlier, these names (`flang-new` vs `flang`) have always 
been very confusing to people and we are trying to improve and to clarify that, 
step by step. While this approach is not ideal, it gives us the flexibility to 
choose our preferred name sooner rather than later. If you feel that we should 
keep `flang-new`, you can continue using/building LLVM Flang as you have been 
so far. If you are ready to update the driver name, the CMake option enables 
that for you.

We discussed this in our call on Monday and agreed to go ahead provided that 
this change is technically sound. IIUC, this has now been confirmed:

> Overall the patch looks ok from a technical point.

As always, please correct me if I missed or misinterpreted something!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-06-30 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng updated this revision to Diff 441320.
kito-cheng added a comment.

Changes:

- Rebase
- Address @khchen's comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/CMakeLists.txt
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -110,6 +110,7 @@
 void EmitRVVHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitRVVBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitRVVBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -88,6 +88,7 @@
   GenRISCVVectorHeader,
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
+  GenRISCVVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -243,6 +244,8 @@
"Generate riscv_vector_builtins.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinCG, "gen-riscv-vector-builtin-codegen",
"Generate riscv_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
+   "Generate riscv_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -458,6 +461,9 @@
   case GenRISCVVectorBuiltinCG:
 EmitRVVBuiltinCG(Records, OS);
 break;
+  case GenRISCVVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
@@ -29,6 +30,59 @@
 using namespace clang::RISCV;
 
 namespace {
+struct SemaRecord {
+  // Intrinsic name, e.g. vadd_vv
+  std::string Name;
+
+  // Overloaded intrinsic name, could be empty if can be computed from Name
+  // e.g. vadd
+  std::string OverloadedName;
+
+  // Supported type, mask of BasicType
+  unsigned TypeRangeMask;
+
+  // Supported LMUL.
+  unsigned Log2LMULMask;
+
+  // Required extensions for this intrinsic.
+  unsigned RequiredExtension;
+
+  // Prototype for this intrinsic.
+  SmallVector Prototype;
+
+  // Prototype for masked intrinsic.
+  SmallVector MaskedPrototype;
+
+  // Suffix of intrinsic name.
+  SmallVector Suffix;
+
+  // Suffix of overloaded intrinsic name.
+  SmallVector OverloadedSuffix;
+
+  // Number of field, large than 1 if it's segment load/store.
+  unsigned NF;
+};
+
+// Compressed function signature table.
+class SemaSignatureTable {
+private:
+  std::vector SignatureTable;
+
+  void insert(ArrayRef Signature);
+
+public:
+  static constexpr unsigned INVALID_INDEX = (unsigned)-1;
+
+  // Create compressed hsignature table from SemaRecords.
+  void init(const std::vector &SemaRecords);
+
+  // Query the Signature, return INVALID_INDEX if not found.
+  unsigned getIndex(ArrayRef Signature);
+
+  /// Print signature table in RVVHeader Record to \p OS
+  void print(raw_ostream &OS);
+};
+
 class RVVEmitter {
 private:
   RecordKeeper &Records;
@@ -45,22 +99,22 @@
   /// Emit all the information needed to map builtin -> LLVM IR intrinsic.
   void createCodeGen(raw_ostream &o);
 
+  /// Emit all the information needed by SemaRISCVVectorLookup.cpp.
+  /// We've large number of intrinsic function for RVV, creating a customized
+  /// could speed up the compilation time.
+  void createSema(raw_ostream &o);
+
 private:
-  /// Create all intrinsics and add them to \p Out
-  void createRVVIntrinsics(std::vector> &Out);
+  /// Create all intrin

[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Valentin Clement via Phabricator via cfe-commits
clementval requested changes to this revision.
clementval added inline comments.
This revision now requires changes to proceed.



Comment at: clang/lib/Driver/ToolChain.cpp:185
   {"flang", "--driver-mode=flang"},
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},

This is counter intuitive. We rename flang-new but we add flang-new here. It 
should be configurable. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D113107: Support of expression granularity for _Float16.

2022-06-30 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

> Am I understanding correctly? @pengfei you are interested in the 
> -fexcess-precision=16 part of this right? @rjmccall what do yo think?

I agree with @rjmccall , we just need to disable what we do here for 
`-fexcess-precision=16`.


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

https://reviews.llvm.org/D113107

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


[clang] 1d421e6 - [OpenCL] Remove half scalar vload/vstore builtins

2022-06-30 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-06-30T11:01:19+01:00
New Revision: 1d421e6e3b789ede2f61756a72e2b27456f868e3

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

LOG: [OpenCL] Remove half scalar vload/vstore builtins

These are not mentioned in the OpenCL C Specification nor in the
OpenCL Extension Specification.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Headers/opencl-c.h b/clang/lib/Headers/opencl-c.h
index 1942da77f5e50..ed647d9e9c064 100644
--- a/clang/lib/Headers/opencl-c.h
+++ b/clang/lib/Headers/opencl-c.h
@@ -11255,7 +11255,6 @@ double16 __ovld __purefn vload16(size_t, const 
__constant double *);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __constant half *);
 half2 __ovld __purefn vload2(size_t, const __constant half *);
 half3 __ovld __purefn vload3(size_t, const __constant half *);
 half4 __ovld __purefn vload4(size_t, const __constant half *);
@@ -11319,7 +11318,6 @@ double16 __ovld __purefn vload16(size_t, const double 
*);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const half *);
 half2 __ovld __purefn vload2(size_t, const half *);
 half3 __ovld __purefn vload3(size_t, const half *);
 half4 __ovld __purefn vload4(size_t, const half *);
@@ -11484,19 +11482,16 @@ double16 __ovld __purefn vload16(size_t, const 
__private double *);
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __global half *);
 half2 __ovld __purefn vload2(size_t, const __global half *);
 half3 __ovld __purefn vload3(size_t, const __global half *);
 half4 __ovld __purefn vload4(size_t, const __global half *);
 half8 __ovld __purefn vload8(size_t, const __global half *);
 half16 __ovld __purefn vload16(size_t, const __global half *);
-half __ovld __purefn vload(size_t, const __local half *);
 half2 __ovld __purefn vload2(size_t, const __local half *);
 half3 __ovld __purefn vload3(size_t, const __local half *);
 half4 __ovld __purefn vload4(size_t, const __local half *);
 half8 __ovld __purefn vload8(size_t, const __local half *);
 half16 __ovld __purefn vload16(size_t, const __local half *);
-half __ovld __purefn vload(size_t, const __private half *);
 half2 __ovld __purefn vload2(size_t, const __private half *);
 half3 __ovld __purefn vload3(size_t, const __private half *);
 half4 __ovld __purefn vload4(size_t, const __private half *);
@@ -11559,7 +11554,6 @@ void __ovld vstore8(double8, size_t, double *);
 void __ovld vstore16(double16, size_t, double *);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-void __ovld vstore(half, size_t, half *);
 void __ovld vstore2(half2, size_t, half *);
 void __ovld vstore3(half3, size_t, half *);
 void __ovld vstore4(half4, size_t, half *);
@@ -11722,19 +11716,16 @@ void __ovld vstore8(double8, size_t, __private double 
*);
 void __ovld vstore16(double16, size_t, __private double *);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-void __ovld vstore(half, size_t, __global half *);
 void __ovld vstore2(half2, size_t, __global half *);
 void __ovld vstore3(half3, size_t, __global half *);
 void __ovld vstore4(half4, size_t, __global half *);
 void __ovld vstore8(half8, size_t, __global half *);
 void __ovld vstore16(half16, size_t, __global half *);
-void __ovld vstore(half, size_t, __local half *);
 void __ovld vstore2(half2, size_t, __local half *);
 void __ovld vstore3(half3, size_t, __local half *);
 void __ovld vstore4(half4, size_t, __local half *);
 void __ovld vstore8(half8, size_t, __local half *);
 void __ovld vstore16(half16, size_t, __local half *);
-void __ovld vstore(half, size_t, __private half *);
 void __ovld vstore2(half2, size_t, __private half *);
 void __ovld vstore3(half3, size_t, __private half *);
 void __ovld vstore4(half4, size_t, __private half *);



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


[PATCH] D128434: [OpenCL] Remove half scalar vload/vstore builtins

2022-06-30 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1d421e6e3b78: [OpenCL] Remove half scalar vload/vstore 
builtins (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128434

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


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11255,7 +11255,6 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __constant half *);
 half2 __ovld __purefn vload2(size_t, const __constant half *);
 half3 __ovld __purefn vload3(size_t, const __constant half *);
 half4 __ovld __purefn vload4(size_t, const __constant half *);
@@ -11319,7 +11318,6 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const half *);
 half2 __ovld __purefn vload2(size_t, const half *);
 half3 __ovld __purefn vload3(size_t, const half *);
 half4 __ovld __purefn vload4(size_t, const half *);
@@ -11484,19 +11482,16 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __global half *);
 half2 __ovld __purefn vload2(size_t, const __global half *);
 half3 __ovld __purefn vload3(size_t, const __global half *);
 half4 __ovld __purefn vload4(size_t, const __global half *);
 half8 __ovld __purefn vload8(size_t, const __global half *);
 half16 __ovld __purefn vload16(size_t, const __global half *);
-half __ovld __purefn vload(size_t, const __local half *);
 half2 __ovld __purefn vload2(size_t, const __local half *);
 half3 __ovld __purefn vload3(size_t, const __local half *);
 half4 __ovld __purefn vload4(size_t, const __local half *);
 half8 __ovld __purefn vload8(size_t, const __local half *);
 half16 __ovld __purefn vload16(size_t, const __local half *);
-half __ovld __purefn vload(size_t, const __private half *);
 half2 __ovld __purefn vload2(size_t, const __private half *);
 half3 __ovld __purefn vload3(size_t, const __private half *);
 half4 __ovld __purefn vload4(size_t, const __private half *);
@@ -11559,7 +11554,6 @@
 void __ovld vstore16(double16, size_t, double *);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-void __ovld vstore(half, size_t, half *);
 void __ovld vstore2(half2, size_t, half *);
 void __ovld vstore3(half3, size_t, half *);
 void __ovld vstore4(half4, size_t, half *);
@@ -11722,19 +11716,16 @@
 void __ovld vstore16(double16, size_t, __private double *);
 #endif //cl_khr_fp64
 #ifdef cl_khr_fp16
-void __ovld vstore(half, size_t, __global half *);
 void __ovld vstore2(half2, size_t, __global half *);
 void __ovld vstore3(half3, size_t, __global half *);
 void __ovld vstore4(half4, size_t, __global half *);
 void __ovld vstore8(half8, size_t, __global half *);
 void __ovld vstore16(half16, size_t, __global half *);
-void __ovld vstore(half, size_t, __local half *);
 void __ovld vstore2(half2, size_t, __local half *);
 void __ovld vstore3(half3, size_t, __local half *);
 void __ovld vstore4(half4, size_t, __local half *);
 void __ovld vstore8(half8, size_t, __local half *);
 void __ovld vstore16(half16, size_t, __local half *);
-void __ovld vstore(half, size_t, __private half *);
 void __ovld vstore2(half2, size_t, __private half *);
 void __ovld vstore3(half3, size_t, __private half *);
 void __ovld vstore4(half4, size_t, __private half *);


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -11255,7 +11255,6 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __constant half *);
 half2 __ovld __purefn vload2(size_t, const __constant half *);
 half3 __ovld __purefn vload3(size_t, const __constant half *);
 half4 __ovld __purefn vload4(size_t, const __constant half *);
@@ -11319,7 +11318,6 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const half *);
 half2 __ovld __purefn vload2(size_t, const half *);
 half3 __ovld __purefn vload3(size_t, const half *);
 half4 __ovld __purefn vload4(size_t, const half *);
@@ -11484,19 +11482,16 @@
 #endif //cl_khr_fp64
 
 #ifdef cl_khr_fp16
-half __ovld __purefn vload(size_t, const __global half *);
 half2 __ovld __purefn vload2(size_t, const __global half *);
 half3 __ovld __purefn vload3(size_t, const __global half *);
 half4 __ovld __purefn vload4(size_t, const __global half *);
 half8 __ovld __purefn vload8(size_t, const __global half *);
 half16 __ovld __purefn vload16(size_t, const __global half *);
-half __ovld __purefn vload(size_t, const __local half *);
 half2 __ovld __purefn vload2(size_t, const __local half *);
 half3 __ovld __purefn vload3(size_t, const __local half *);
 half4 __ovld __purefn vload4(size_t, const __local half *);
 half8 __ovld __purefn vload8(size_t, const __local half *);
 half16 _

[PATCH] D128625: [RISCV][Driver] Fix baremetal `GCCInstallation` paths

2022-06-30 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/Driver/ToolChains/RISCVToolchain.cpp:54
+
+  // Set alias for "riscv{64|32}-unknown-unknown-elf"
+  SmallVector TripleAliases;

This seems like the wrong place to add this workaround, shouldn't the change be 
in `GCCInstallation::init`? That way targets other than RISC-V also benefit 
from this fix.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128625

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Richard Barton via Phabricator via cfe-commits
richard.barton.arm added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:185
   {"flang", "--driver-mode=flang"},
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},

clementval wrote:
> This is counter intuitive. We rename flang-new but we add flang-new here. It 
> should be configurable. 
This is a list of all the valid prefixes of binaries that the driver supports. 
With this change, an additional one will be supported so I don't think it's an 
issue to have both flang and flang-new here.

The thing that confuses me is how flang-new works today without this change, 
given that "flang" is not a suffix of "flang-new"? @awarzynski , do you know 
why that is? Perhaps the line here is not needed at all? Or is this a bug fix 
for flang-new that is actually unrelated to this change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:185
   {"flang", "--driver-mode=flang"},
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},

richard.barton.arm wrote:
> clementval wrote:
> > This is counter intuitive. We rename flang-new but we add flang-new here. 
> > It should be configurable. 
> This is a list of all the valid prefixes of binaries that the driver 
> supports. With this change, an additional one will be supported so I don't 
> think it's an issue to have both flang and flang-new here.
> 
> The thing that confuses me is how flang-new works today without this change, 
> given that "flang" is not a suffix of "flang-new"? @awarzynski , do you know 
> why that is? Perhaps the line here is not needed at all? Or is this a bug fix 
> for flang-new that is actually unrelated to this change?
> This is counter intuitive. 

I can add a comment to clarify this.

> It should be configurable.

It is, in Flang's [[ 
https://github.com/llvm/llvm-project/blob/main/flang/tools/flang-driver/driver.cpp
 | driver.cpp ]]. Originally, the suffix was hard-coded as:
```
clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
```
(i.e. the `clangDriver` library used `flang` internally despite the actual name 
being `flang-new`). This is now being replaced with (see in "driver.cpp"):
```
 clang::driver::ParsedClangName targetandMode =
  clang::driver::ToolChain::getTargetAndModeFromProgramName(argv[0]);
```

But the change in "driver.cpp" means that we can no longer make assumptions 
about the suffix and hence the update here. 

Like I mentioned earlier, we should not make this file build-time configurable. 
One possible option would be to try to update Clang's [[ 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Config/config.h.cmake
 | config.h.cmake ]], but that's would lead to more Flang-specific changes in 
Clang's core set-up. Also, I'm not convinced it would work here. 

> @awarzynski , do you know why that is? 

Yeah, check Flang's "driver.cpp". We should've captured this earlier. The 
original set-up from ToolChain.cpp predates `flang-new`. And then in 
"driver.cpp" we just matched what was here. There was a lot of confusion around 
naming  back then and this has slipped in. 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D128550: [OpenMP] Change OpenMP code generation for target region entries

2022-06-30 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/D128550/new/

https://reviews.llvm.org/D128550

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


[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

2022-06-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 441344.

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

https://reviews.llvm.org/D128248

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-array-init.cpp


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 
'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' 
is not initialized}}
+{{}},
+};
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10754,17 +10754,18 @@
   for (unsigned Index = 0; Index != NumEltsToInit; ++Index) {
 const Expr *Init =
 Index < E->getNumInits() ? E->getInit(Index) : FillerExpr;
-if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
- Info, Subobject, Init) ||
-!HandleLValueArrayAdjustment(Info, Init, Subobject,
- CAT->getElementType(), 1)) {
+if (Result.isArray() &&
+(!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, 
Subobject,
+  Init) ||
+ !HandleLValueArrayAdjustment(Info, Init, Subobject,
+  CAT->getElementType(), 1))) {
   if (!Info.noteFailure())
 return false;
   Success = false;
 }
   }
 
-  if (!Result.hasArrayFiller())
+  if (!Result.isArray() || !Result.hasArrayFiller())
 return Success;
 
   // If we get here, we have a trivial filler, which we can just evaluate


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' is not initialized}}
+{{}},
+};
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10754,17 +10754,18 @@
   for (unsigned Index = 0; Index != NumEltsToInit; ++Index) {
 const Expr *Init =
 Index < E->getNumInits() ? E->getInit(Index) : FillerExpr;
-if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
- Info, Subobject, Init) ||
-!HandleLValueArrayAdjustment(Info, Init, Subobject,
- CAT->getElementType(), 1)) {
+if (Result.isArray() &&
+(!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, Subobject,
+  Init) ||
+ !HandleLValueArrayAdjustment(Info, Init, Subobject,
+  CAT->getElementType(), 1))) {
   if (!Info.noteFailure())
 return false;
   Success = false;
 }
   }
 
-  if (!Result.hasArrayFiller())
+  if (!Result.isArray() || !Result.hasArrayFiller())
 return Success;
 
   // If we get here, we have a trivial filler, which we can just evaluate
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

2022-06-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

I added the `isArray()` check in both places now, but the first one is not 
necessary for the test case (at least).


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

https://reviews.llvm.org/D128248

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-06-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:199
 UsesAllocatorsDecls;
+/// Data is needed on creating capture fields for implicit
+/// defualt first|private clause.

Data required?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:200
+/// Data is needed on creating capture fields for implicit
+/// defualt first|private clause.
+struct ImplicitDefaultFDInfoTy {

default



Comment at: clang/lib/Sema/SemaOpenMP.cpp:212
+};
+/// List of captuer fields
+llvm::SmallVector

Captured?



Comment at: clang/lib/Sema/TreeTransform.h:122
+  /// the RebuildME uses to set if member expression needs to be rebuilt.
+  bool RebuildME = false;
+

I think we don't need to add a new field here. Can instead we have a check for 
regions with default clauses, if possible?


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

https://reviews.llvm.org/D127803

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


[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 441351.
njames93 added a comment.
Herald added subscribers: ormris, mgorny.

Emit documentation links for the version of clangd built.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/test/diagnostics-tidy.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in

Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
 config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
+config.clangd_pre_release = @CLANGD_PRE_RELEASE@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -34,5 +34,8 @@
 if config.clangd_tidy_checks:
   config.available_features.add('clangd-tidy-checks')
 
+if config.clangd_pre_release:
+  config.available_features.add('clangd-tidy-checks')
+
 if config.have_zlib:
   config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -1,4 +1,5 @@
 # REQUIRES: clangd-tidy-checks
+# REQUIRES: clangd-pre-release
 # RUN: clangd -lit-test -clang-tidy-checks=bugprone-sizeof-expression < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
@@ -9,7 +10,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html";
+# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html";
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -4,3 +4,4 @@
 #define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
 #define CLANGD_TIDY_CHECKS @CLANGD_TIDY_CHECKS@
+#define CLANGD_PRE_RELEASE @CLANGD_PRE_RELEASE@
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -9,6 +9,7 @@
 #include "Diagnostics.h"
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "Compiler.h"
+#include "Feature.h"
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
@@ -17,6 +18,7 @@
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Version.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -918,9 +920,28 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/"; + Name + ".html")
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+#if CLANGD_PRE_RELEASE
+return {("https://clang.llvm.org/extra/clang-tidy/checks/"; + Module + "/" +
+ Check + ".html")
 .str()};
+#else
+return {
+  ("https://releases.llvm.org"; CLANG_VERSION_STRING
+   "/tools/clang/tools/extra/docs/clang-tidy/checks" +
+   Module + "/" + Check + ".html")
+  .str()
+}
+#endif
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};
Index: clang-tools-extra/clangd/CMakeLists.txt
==

[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 441352.
njames93 added a comment.

Fix lit cfg typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/test/diagnostics-tidy.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in

Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
 config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
+config.clangd_pre_release = @CLANGD_PRE_RELEASE@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -34,5 +34,8 @@
 if config.clangd_tidy_checks:
   config.available_features.add('clangd-tidy-checks')
 
+if config.clangd_pre_release:
+  config.available_features.add('clangd-pre-release')
+
 if config.have_zlib:
   config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -1,4 +1,5 @@
 # REQUIRES: clangd-tidy-checks
+# REQUIRES: clangd-pre-release
 # RUN: clangd -lit-test -clang-tidy-checks=bugprone-sizeof-expression < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
@@ -9,7 +10,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html";
+# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html";
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -4,3 +4,4 @@
 #define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
 #define CLANGD_TIDY_CHECKS @CLANGD_TIDY_CHECKS@
+#define CLANGD_PRE_RELEASE @CLANGD_PRE_RELEASE@
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -9,6 +9,7 @@
 #include "Diagnostics.h"
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "Compiler.h"
+#include "Feature.h"
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
@@ -17,6 +18,7 @@
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Version.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -918,9 +920,28 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/"; + Name + ".html")
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+#if CLANGD_PRE_RELEASE
+return {("https://clang.llvm.org/extra/clang-tidy/checks/"; + Module + "/" +
+ Check + ".html")
 .str()};
+#else
+return {
+  ("https://releases.llvm.org"; CLANG_VERSION_STRING
+   "/tools/clang/tools/extra/docs/clang-tidy/checks" +
+   Module + "/" + Check + ".html")
+  .str()
+}
+#endif
+  }
   case Diag::Clangd:
 if (Name == "unused-includes")
   return {"https://clangd.llvm.org/guides/include-cleaner"};
Index: clang-tools-extra/clangd/CMakeLists.txt
===
--- clang-tools-e

[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 requested review of this revision.
njames93 added a comment.

Any issues with this now for getting correct version?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

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


[PATCH] D127313: [libc++] Implement P0618R0 (Deprecating )

2022-06-30 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 441353.
philnik added a comment.

- Try to fix CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127313

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx17Papers.csv
  libcxx/include/codecvt
  libcxx/include/locale
  libcxx/src/locale.cpp
  
libcxx/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
  libcxx/test/support/platform_support.h

Index: libcxx/test/support/platform_support.h
===
--- libcxx/test/support/platform_support.h
+++ libcxx/test/support/platform_support.h
@@ -14,6 +14,8 @@
 #ifndef PLATFORM_SUPPORT_H
 #define PLATFORM_SUPPORT_H
 
+#include "test_macros.h"
+
 // locale names
 #define LOCALE_en_US   "en_US"
 #define LOCALE_en_US_UTF_8 "en_US.UTF-8"
@@ -88,6 +90,7 @@
 #endif
 }
 
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
 inline
 std::

[PATCH] D128855: [HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits

2022-06-30 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 441358.
python3kgae added a comment.

Rebase to fix test fail.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128855

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/hlsl.h
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaHLSL/Wave.hlsl


Index: clang/test/SemaHLSL/Wave.hlsl
===
--- clang/test/SemaHLSL/Wave.hlsl
+++ clang/test/SemaHLSL/Wave.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -x hlsl -triple dxil--shadermodel6.7-library  %s  -verify
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple 
dxil--shadermodel6.7-library  %s  -verify
 
 // Make sure WaveActiveCountBits is accepted.
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5629,11 +5629,12 @@
   bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
   bool IsARM = S.Context.getTargetInfo().getTriple().isARM();
   bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV();
+  bool IsHLSL = S.Context.getLangOpts().HLSL;
   if ((IsAArch64 && !ArmSveAliasValid(S.Context, BuiltinID, AliasName)) ||
   (IsARM && !ArmMveAliasValid(BuiltinID, AliasName) &&
!ArmCdeAliasValid(BuiltinID, AliasName)) ||
   (IsRISCV && !RISCVAliasValid(BuiltinID, AliasName)) ||
-  (!IsAArch64 && !IsARM && !IsRISCV)) {
+  (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
 S.Diag(AL.getLoc(), diag::err_attribute_builtin_alias) << AL;
 return;
   }
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- /dev/null
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -0,0 +1,15 @@
+//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _HLSL_HLSL_INTRINSICS_H_
+#define _HLSL_HLSL_INTRINSICS_H_
+
+__attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) 
uint
+WaveActiveCountBits(bool bBit);
+
+#endif //_HLSL_HLSL_INTRINSICS_H_
Index: clang/lib/Headers/hlsl.h
===
--- clang/lib/Headers/hlsl.h
+++ clang/lib/Headers/hlsl.h
@@ -10,5 +10,6 @@
 #define _HLSL_H_
 
 #include "hlsl/hlsl_basic_types.h"
+#include "hlsl/hlsl_intrinsics.h"
 
 #endif //_HLSL_H_
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -65,6 +65,7 @@
 set(hlsl_files
   hlsl.h
   hlsl/hlsl_basic_types.h
+  hlsl/hlsl_intrinsics.h
   )
 
 set(mips_msa_files
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4183,7 +4183,7 @@
   "argument %0 to 'preferred_name' attribute is not a typedef for "
   "a specialization of %1">;
 def err_attribute_builtin_alias : Error<
-  "%0 attribute can only be applied to a ARM or RISC-V builtin">;
+  "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">;
 
 // called-once attribute diagnostics.
 def err_called_once_attribute_wrong_type : Error<
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -1699,7 +1699,7 @@
 LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG)
 
 // HLSL
-LANGBUILTIN(WaveActiveCountBits, "Uib", "nc", HLSL_LANG)
+LANGBUILTIN(__builtin_hlsl_wave_active_count_bits, "Uib", "nc", HLSL_LANG)
 
 // Builtins for XRay
 BUILTIN(__xray_customevent, "vcC*z", "")


Index: clang/test/SemaHLSL/Wave.hlsl
===
--- clang/test/SemaHLSL/Wave.hlsl
+++ clang/test/SemaHLSL/Wave.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -x hlsl -triple dxil--shadermodel6.7-library  %s  -verify
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil--shadermodel6.7-library  %s  -verify
 
 // Make sure WaveActiveCountBits is accepted.
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5629,11 +5629,12 @@
   bool IsAArch64 = 

[PATCH] D95588: [RISCV] Implement the MC layer support of P extension

2022-06-30 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce added a comment.

Hello @Jim! We are developing the P extension, are you still maintaining this 
patch? Or would you mind co-development together?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95588

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


[PATCH] D128774: [libTooling] Add a comment about comment parsing to getAssociatedRange.

2022-06-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

sure


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128774

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


[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

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

Basically LGTM -- can you also add a release note about the assertion fix?




Comment at: clang/test/SemaCXX/constexpr-array-init.cpp:1
+
+// RUN: %clang_cc1 -std=c++20 -verify %s

Can remove spurious newline



Comment at: clang/test/SemaCXX/constexpr-array-init.cpp:15
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 
'bar' must be initialized by a constant expression}} \

Same here.

Also, I'd appreciate a FIXME comment about what this is testing (it's not 
obvious from the context) and that this code is expected to compile without a 
diagnostic in the future (so it's a bit more obviously correct when we do fix 
that).


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

https://reviews.llvm.org/D128248

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


[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-06-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

FWIW, I'm also a tentative LG on these changes. I'm not certain if there's a 
reason why we did things this way in the first place, but I think the new 
output is more readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Hmm, this version looks complicated to me.
And also fragile: downstream we have CLANG_VERSION_STRINGs that don't match 
upstream, Apple has their own versioning scheme, linux distros tend to do 
things like `6.0.1~ubuntu3`...
Let me sync with @kadircet


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

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


[clang] 0079343 - [libTooling][NFC] Add a comment about comment parsing to getAssociatedRange.

2022-06-30 Thread Yitzhak Mandelbaum via cfe-commits

Author: Aaron Jacobs
Date: 2022-06-30T12:46:57Z
New Revision: 007934343c4c18102b2b3e4195d356dbcdf9a3fc

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

LOG: [libTooling][NFC] Add a comment about comment parsing to 
getAssociatedRange.

It took me multiple hours of debugging plus asking an expert for help to
figure out why this function didn't do what it promised to do. It turns
out there is a flag that needs to be set. Document this, in an attempt
to save the next person the surprise.

Reviewed By: ymandel

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/SourceCode.h

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/SourceCode.h 
b/clang/include/clang/Tooling/Transformer/SourceCode.h
index 16411b9c398d0..f3d119c86074a 100644
--- a/clang/include/clang/Tooling/Transformer/SourceCode.h
+++ b/clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -41,6 +41,10 @@ CharSourceRange getExtendedRange(const T &Node, 
tok::TokenKind Next,
 /// terminators. The returned range consists of file locations, if valid file
 /// locations can be found for the associated content; otherwise, an invalid
 /// range is returned.
+///
+/// Note that parsing comments is disabled by default. In order to select a
+/// range containing associated comments, you may need to invoke the tool with
+/// `-fparse-all-comments`.
 CharSourceRange getAssociatedRange(const Decl &D, ASTContext &Context);
 
 /// Returns the source-code text in the specified range.



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


[PATCH] D128774: [libTooling] Add a comment about comment parsing to getAssociatedRange.

2022-06-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG007934343c4c: [libTooling][NFC] Add a comment about comment 
parsing to getAssociatedRange. (authored by jacobsa, committed by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128774

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h


Index: clang/include/clang/Tooling/Transformer/SourceCode.h
===
--- clang/include/clang/Tooling/Transformer/SourceCode.h
+++ clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -41,6 +41,10 @@
 /// terminators. The returned range consists of file locations, if valid file
 /// locations can be found for the associated content; otherwise, an invalid
 /// range is returned.
+///
+/// Note that parsing comments is disabled by default. In order to select a
+/// range containing associated comments, you may need to invoke the tool with
+/// `-fparse-all-comments`.
 CharSourceRange getAssociatedRange(const Decl &D, ASTContext &Context);
 
 /// Returns the source-code text in the specified range.


Index: clang/include/clang/Tooling/Transformer/SourceCode.h
===
--- clang/include/clang/Tooling/Transformer/SourceCode.h
+++ clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -41,6 +41,10 @@
 /// terminators. The returned range consists of file locations, if valid file
 /// locations can be found for the associated content; otherwise, an invalid
 /// range is returned.
+///
+/// Note that parsing comments is disabled by default. In order to select a
+/// range containing associated comments, you may need to invoke the tool with
+/// `-fparse-all-comments`.
 CharSourceRange getAssociatedRange(const Decl &D, ASTContext &Context);
 
 /// Returns the source-code text in the specified range.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-30 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo updated this revision to Diff 441368.
dongjunduo added a comment.

[Clang] change "-ftime-trace-path" to "-ftime-trace"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp


Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -212,7 +212,9 @@
   bool Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
 Argv, Diags, Argv0);
 
-  if (Clang->getFrontendOpts().TimeTrace) {
+  if (Clang->getFrontendOpts().TimeTrace ||
+  !Clang->getFrontendOpts().TimeTracePath.empty()) {
+Clang->getFrontendOpts().TimeTrace = 1;
 llvm::timeTraceProfilerInitialize(
 Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
@@ -256,6 +258,15 @@
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
 llvm::sys::path::replace_extension(Path, "json");
+if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  SmallString<128> FileName(llvm::sys::path::filename(Path));
+  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+  if (llvm::sys::fs::is_directory(TracePath)) {
+llvm::sys::path::append(TracePath, FileName);
+  }
+  Path.assign(TracePath);
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -2,6 +2,18 @@
 // RUN: cat %T/check-time-trace.json \
 // RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T/new-name.json -ftime-trace-granularity=0 
-o %T/check-time-trace %s
+// RUN: cat %T/new-name.json \
+// RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T -ftime-trace-granularity=0 -o 
%T/check-time-trace %s
+// RUN: cat %T/check-time-trace.json \
+// RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T/ -ftime-trace-granularity=0 -o 
%T/check-time-trace %s
+// RUN: cat %T/check-time-trace.json \
+// RUN:   | %python -c 'import json, sys; 
json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
 
 // CHECK:  "beginningOfTime": {{[0-9]{16},}}
 // CHECK-NEXT: "traceEvents": [
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -499,6 +499,9 @@
   /// Minimum time granularity (in microseconds) traced by time profiler.
   unsigned TimeTraceGranularity;
 
+  /// Path which stores the output files for -ftime-trace
+  std::string TimeTracePath;
+
 public:
   FrontendOptions()
   : DisableFree(false), RelocatablePCH(false), ShowHelp(false),
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2828,6 +2828,15 @@
   HelpText<"Minimum time granularity (in microseconds) traced by time 
profiler">,
   Flags<[CC1Option, CoreOption]>,
   MarshallingInfoInt, "500u">;
+def ftime_trace_path : Joined<["-"], "ftime-trace=">, Group,
+  HelpText<"Turn on time profiler. Generates JSON file based on output 
filename. "
+   "Specify the path which stores the tracing output fi

[PATCH] D128907: [Clang] Disable noundef attribute for languages which allow uninitialized function arguments

2022-06-30 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 created this revision.
skc7 added reviewers: arsenm, sameerds, cdevadas, ronlieb, yaxunl, b-sumner, 
bcahoon.
Herald added subscribers: kosarev, mattd, asavonic, ThomasRaoux, jdoerfert, 
kerbowa, kbarton, jvesely, nemanjai.
Herald added a project: All.
skc7 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1, wdng.
Herald added a reviewer: jdoerfert.
Herald added projects: clang, LLVM.

Languages like CUDA, HIP etc. have APIs which accept uninitialized function 
arguments.
With D105169 , noundef-analysis has been 
enabled by default and
we are forced to assume very strict constraints for the mentioned languages.
So, the proposed change is to skip adding noundef attribute to function
arguments and return values for such languages.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128907

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGenCUDA/address-spaces.cu
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCUDA/cuda-builtin-vars.cu
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/CodeGenCUDA/redux-builtins.cu
  clang/test/CodeGenCUDA/surface.cu
  clang/test/CodeGenCUDA/unnamed-types.cu
  clang/test/CodeGenCUDA/usual-deallocators.cu
  clang/test/CodeGenCUDA/vtbl.cu
  clang/test/CodeGenCUDASPIRV/kernel-argument.cu
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
  clang/test/CodeGenHIP/noundef-attribute-hip-device-verify.hip
  clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  clang/test/CodeGenOpenCL/amdgpu-call-kernel.cl
  clang/test/CodeGenOpenCL/amdgpu-printf.cl
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/CodeGenOpenCL/byval.cl
  clang/test/CodeGenOpenCL/const-str-array-decay.cl
  clang/test/CodeGenOpenCL/constant-addr-space-globals.cl
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/CodeGenOpenCL/half.cl
  clang/test/CodeGenOpenCL/kernel-param-alignment.cl
  clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
  clang/test/CodeGenOpenCL/no-half.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/CodeGenOpenCL/size_t.cl
  clang/test/CodeGenOpenCL/spir-calling-conv.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-mangling.cpp
  clang/test/CodeGenSYCL/functionptr-addrspace.cpp
  clang/test/CodeGenSYCL/unique_stable_name.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_re

[PATCH] D128700: [AMDGPU][Clang] Skip adding noundef attribute to AMDGPU HIP device functions

2022-06-30 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2309
+  bool EnableNoundefAttrs = CodeGenOpts.EnableNoundefAttrs &&
+!(getLangOpts().HIP && getLangOpts().CUDAIsDevice);
+

arsenm wrote:
> Shouldn't be limited to HIP. All languages with convergent operations
With this above suggested change to include all languages with convergent 
operations, lot of tests had to be updated. Created this new patch D128907 for 
same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128700

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


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-30 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

Hi @jamieschmeiser @Whitney @MaskRay, I have changed "-ftime-trace-path" to 
"-ftime-trace". It is a well-spelling option name.

The user can turn on the time-trace by:

- specifying "**-ftime-trace**" only and output it to the default directory 
(the same as the "-o" option's value)
- specifying "**-ftime-trace=the-directory-you-want**"
- specifying "**-ftime-trace=the-directory-you-want/**"
- specifying "**-ftime-trace=the-full-file-path-you-want**"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D128652: [PowerPC] Finished kill_canary implementation and debugging

2022-06-30 Thread Paul Scoropan via Phabricator via cfe-commits
pscoro updated this revision to Diff 441374.
pscoro added a comment.

fixed XOR usage, added linux tests and other small fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128652

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Basic/Targets/PPC.cpp
  clang/test/CodeGen/PowerPC/builtins-ppc-stackprotect.c
  llvm/include/llvm/IR/IntrinsicsPowerPC.td
  llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
  llvm/lib/Target/PowerPC/PPCISelLowering.cpp
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll
  llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-linux.ll

Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-linux.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-linux.ll
@@ -0,0 +1,43 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-linux \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; CHECK-LABEL: test_kill_canary:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; CHECK-LABEL: test_kill_canary_ssp:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mflr r0
+; CHECK-NEXT:std r0, 16(r1)
+; CHECK-NEXT:stdu r1, -128(r1)
+; CHECK-NEXT:.cfi_def_cfa_offset 128
+; CHECK-NEXT:.cfi_offset lr, 16
+; CHECK-NEXT:ld r3, -28688(r13)
+; CHECK-NEXT:std r3, 120(r1)
+; CHECK-NEXT:ld r3, 120(r1)
+; CHECK-NEXT:ld r4, -28688(r13)
+; CHECK-NEXT:cmpld r4, r3
+; CHECK-NEXT:bne cr0, .LBB1_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:addi r1, r1, 128
+; CHECK-NEXT:ld r0, 16(r1)
+; CHECK-NEXT:mtlr r0
+; CHECK-NEXT:blr
+; CHECK-NEXT:  .LBB1_2: # %entry
+; CHECK-NEXT:bl __stack_chk_fail
+; CHECK-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
Index: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll
===
--- /dev/null
+++ llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll
@@ -0,0 +1,46 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -verify-machineinstrs -mtriple=powerpc64-unknown-aix \
+; RUN:   --ppc-asm-full-reg-names < %s | FileCheck %s
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {
+; CHECK-LABEL: test_kill_canary:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:blr
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
+attributes #0 = { sspreq }
+; Function Attrs: sspreq
+define dso_local void @test_kill_canary_ssp() #0 {
+; CHECK-LABEL: test_kill_canary_ssp:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:mflr r0
+; CHECK-NEXT:std r0, 16(r1)
+; CHECK-NEXT:stdu r1, -128(r1)
+; CHECK-NEXT:ld r3, L..C0(r2) # @__ssp_canary_word
+; CHECK-NEXT:ld r4, 0(r3)
+; CHECK-NEXT:std r4, 120(r1)
+; CHECK-NEXT:ld r4, 0(r3)
+; CHECK-NEXT:xori r4, r4, 65535
+; CHECK-NEXT:xoris r4, r4, 65535
+; CHECK-NEXT:std r4, 0(r3)
+; CHECK-NEXT:ld r3, 0(r3)
+; CHECK-NEXT:ld r4, 120(r1)
+; CHECK-NEXT:cmpld r3, r4
+; CHECK-NEXT:bne cr0, L..BB1_2
+; CHECK-NEXT:  # %bb.1: # %entry
+; CHECK-NEXT:addi r1, r1, 128
+; CHECK-NEXT:ld r0, 16(r1)
+; CHECK-NEXT:mtlr r0
+; CHECK-NEXT:blr
+; CHECK-NEXT:  L..BB1_2: # %entry
+; CHECK-NEXT:bl .__stack_chk_fail[PR]
+; CHECK-NEXT:nop
+entry:
+  call void @llvm.ppc.kill.canary()
+  ret void
+}
+
Index: llvm/lib/Target/PowerPC/PPCISelLowering.cpp
===
--- llvm/lib/Target/PowerPC/PPCISelLowering.cpp
+++ llvm/lib/Target/PowerPC/PPCISelLowering.cpp
@@ -58,6 +58,7 @@
 #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
 #include "llvm/CodeGen/TargetRegisterInfo.h"
 #include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
 #include "llvm/IR/CallingConv.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/Constants.h"
@@ -11127,6 +11128,51 @@
 }
 break;
   }
+  case Intrinsic::ppc_kill_canary: { 
+MachineFunction &MF = DAG.getMachineFunction();
+if (MF.getFunction().hasFnAttribute(Attribute::SafeStack) ||
+		!MF.getFunction().hasStackProtectorFnAttr()) {
+  DAG.ReplaceAllUsesOfValueWith(SDValue(Op.getNode(), 0), Op->getOperand(0));
+  break;
+}
+
+const Module *M = MF.getMMI().getModule();
+GlobalValue *GV = (Subtarget.isAIXABI()) ?
+  M->getGlobalVariable(AIXSSPCanaryWordName) : M->getNamedValue("__stack_chk_guard");
+
+if(GV == nullptr) {
+  DAG.ReplaceAllUsesOfValueWith(SDValue(Op.getNode(), 0), Op->getOpe

[clang] cde1df4 - Correct -Winfinite-recursion warning on potentially-unevaluated operand

2022-06-30 Thread Aaron Ballman via cfe-commits

Author: Prathit Aswar
Date: 2022-06-30T09:09:28-04:00
New Revision: cde1df4ca4f233f1069041ed1646779e9ff1ad7d

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

LOG: Correct -Winfinite-recursion warning on potentially-unevaluated operand

Fixing issue "incorrect -Winfinite-recursion warning on potentially-
unevaluated operand".

We add a dedicated visit function (VisitCXXTypeidExpr) for typeid,
instead of using the default (VisitStmt). In this new function we skip
over building the CFG for unevaluated operands of typeid.

Fixes #21668

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Analysis/CFG.cpp
clang/test/SemaCXX/warn-infinite-recursion.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b80e401e02f6c..e6353de934153 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -275,6 +275,10 @@ Improvements to Clang's diagnostics
   This fixes `Issue 55962 
`_.
 - Printable Unicode characters within `static_assert` messages are no longer
   escaped.
+- The ``-Winfinite-recursion`` diagnostic no longer warns about
+  unevaluated operands of a ``typeid`` expression, as they are now
+  modeled correctly in the CFG. This fixes
+  `Issue 21668 `_.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index b16898d3ffa0b..614d94ae31a6d 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@ class CFGBuilder {
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@ CFGBlock *CFGBuilder::Visit(Stmt * S, AddStmtChoice asc,
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,25 @@ CFGBlock *CFGBuilder::VisitCXXThrowExpr(CXXThrowExpr *T) 
{
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to the block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent() && S->isPotentiallyEvaluated())
+return VisitChildren(S);
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 

diff  --git a/clang/test/SemaCXX/warn-infinite-recursion.cpp 
b/clang/test/SemaCXX/warn-infinite-recursion.cpp
index e5a5a18b65717..8e07d5c876612 100644
--- a/clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ b/clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -171,3 +171,35 @@ int test_wrapper() {
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+namespace std {
+class type_info {
+public:
+  virtual ~type_info();
+  const char *name() const { return __name; }
+  bool operator==(const type_info &__arg) const {
+return __name == __arg.__name;
+  }
+
+  bool operator!=(const type_info &__arg) const {
+return !operator==(__arg);
+  }
+
+protected:
+  const char *__name;
+};
+} // namespace std
+struct Q {
+  virtual ~Q() = default;
+};
+
+Q q;
+Q &evaluated_recursive_function(int x) { // expected-warning{{call 
itself}}
+  (void)typeid(evaluated_recursive_function(x)); // expected-warning 
{{expression with side effects will be evaluated despite being used as an 
operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}



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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-30 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGcde1df4ca4f2: Correct -Winfinite-recursion warning on 
potentially-unevaluated operand (authored by appmonster007, committed by 
aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Analysis/CFG.cpp
  clang/test/SemaCXX/warn-infinite-recursion.cpp

Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -171,3 +171,35 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+namespace std {
+class type_info {
+public:
+  virtual ~type_info();
+  const char *name() const { return __name; }
+  bool operator==(const type_info &__arg) const {
+return __name == __arg.__name;
+  }
+
+  bool operator!=(const type_info &__arg) const {
+return !operator==(__arg);
+  }
+
+protected:
+  const char *__name;
+};
+} // namespace std
+struct Q {
+  virtual ~Q() = default;
+};
+
+Q q;
+Q &evaluated_recursive_function(int x) { // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,25 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to the block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent() && S->isPotentiallyEvaluated())
+return VisitChildren(S);
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -275,6 +275,10 @@
   This fixes `Issue 55962 `_.
 - Printable Unicode characters within `static_assert` messages are no longer
   escaped.
+- The ``-Winfinite-recursion`` diagnostic no longer warns about
+  unevaluated operands of a ``typeid`` expression, as they are now
+  modeled correctly in the CFG. This fixes
+  `Issue 21668 `_.
 
 Non-comprehensive list of changes in this release
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128064: [Static Analyzer] Small array binding policy

2022-06-30 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.
Herald added a subscriber: steakhal.

No need for post commit fixes, just general observations since I noticed them.




Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2427
+  uint64_t ArrSize = CAT->getSize().getLimitedValue();
+  if (ArrSize > SmallArrayLimit)
+return None;

Unless we use this a lot, it'd be better to just use `AnalyzerOptions` 
natively, it'd be more visible that this is directly configurable by the user.

There is no need to change this once its here, just a general design 
observation.



Comment at: clang/lib/StaticAnalyzer/Core/RegionStore.cpp:2466
   // Handle lazy compound values.
-  if (isa(Init))
+  if (Optional LCV =
+  Init.getAs()) {

For `SVal::getAs`, we usually use `auto` for the return value type (which has 
its history: D54877#inline-484319!).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128064

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/AST/Decl.h:1944-1948
+  /// For non-templates this value will be NULL, unless this non-template
+  /// function declaration was declared directly inside of a function template,
+  /// in which case this will have a pointer to a FunctionDecl, stored in the
+  /// NamedDecl. For function declarations that describe a function template,
+  /// this will be a pointer to a FunctionTemplateDecl, stored in the 
NamedDecl.

ChuanqiXu wrote:
> erichkeane wrote:
> > ChuanqiXu wrote:
> > > Could we give a new abstract like `XXXInfo` to replace `NamedDecl*` here? 
> > > The NamedDecl* covers a lot of things. It looks more consistent.
> > All of those 'Info' types contain significantly more information, which we 
> > really don't have a need for here.  Basically all this patch is doing is 
> > using the FunctionTemplateDecl* that was already in the list and 
> > generalizing it a bit.  AND unfortunately, the only commonality between 
> > FunctionTemplateDecl and FunctionDecl is NamedDecl.  
> > 
> > So any type we would use would end up causing an additional allocation 
> > here, and make its use require us to unpack it :/
> > 
> > I guess what I'm saying, is I'm not sure what that would look like in a way 
> > that wouldn't make this worse.  Do you have an idea you could share that 
> > would improve that?  
> > 
> > 
> My idea would be something like:
> 
> ```C++
> llvm::PointerUnion MemberSpecializationInfo *,
>  FunctionTemplateSpecializationInfo *,
> ```
> 
> > So any type we would use would end up causing an additional allocation 
> > here, and make its use require us to unpack it :/
> 
> This is a union so it wouldn't cause additional allocations?
> 
I tried doing FunctionDecl and FunctionTemplateDecl at one point, but we endd 
up running out of bits for the pointer-union to work on 32 bit builds.  
Otherwise I would have done that.

I misunderstood the 'Info' thing and thought you wanted a new wrapper type (an 
'Info' type), which would need to be allocated and contain just a pointer, 
which is why I was thinking about needing allocations.


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

https://reviews.llvm.org/D126907

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


[clang] a591c7c - [HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits

2022-06-30 Thread Xiang Li via cfe-commits

Author: Xiang Li
Date: 2022-06-30T06:16:51-07:00
New Revision: a591c7ca0d9fe47223127ee13df60689f36ba112

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

LOG: [HLSL] Change WaveActiveCountBits to wrapper of 
__builtin_hlsl_wave_active_count_bits

Change WaveActiveCountBits from builtin into wrapper of 
__builtin_hlsl_wave_active_count_bits.
For comment at
https://reviews.llvm.org/D126857#inline-1235949

Reviewed By: beanz

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

Added: 
clang/lib/Headers/hlsl/hlsl_intrinsics.h

Modified: 
clang/include/clang/Basic/Builtins.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Headers/CMakeLists.txt
clang/lib/Headers/hlsl.h
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/SemaHLSL/Wave.hlsl

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index c084cc2c4cbdf..f19807dbbb0bb 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1699,7 +1699,7 @@ BUILTIN(__builtin_os_log_format, "v*v*cC*.", "p:0:nt")
 LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG)
 
 // HLSL
-LANGBUILTIN(WaveActiveCountBits, "Uib", "nc", HLSL_LANG)
+LANGBUILTIN(__builtin_hlsl_wave_active_count_bits, "Uib", "nc", HLSL_LANG)
 
 // Builtins for XRay
 BUILTIN(__xray_customevent, "vcC*z", "")

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index dc9ca4bd18e2e..880fe0d18a02e 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4183,7 +4183,7 @@ def err_attribute_preferred_name_arg_invalid : Error<
   "argument %0 to 'preferred_name' attribute is not a typedef for "
   "a specialization of %1">;
 def err_attribute_builtin_alias : Error<
-  "%0 attribute can only be applied to a ARM or RISC-V builtin">;
+  "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">;
 
 // called-once attribute diagnostics.
 def err_called_once_attribute_wrong_type : Error<

diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index dfa3602b557b1..5a0268da14a5f 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -65,6 +65,7 @@ set(hip_files
 set(hlsl_files
   hlsl.h
   hlsl/hlsl_basic_types.h
+  hlsl/hlsl_intrinsics.h
   )
 
 set(mips_msa_files

diff  --git a/clang/lib/Headers/hlsl.h b/clang/lib/Headers/hlsl.h
index 0db8a4ed1fe40..a9dce4503ddd9 100644
--- a/clang/lib/Headers/hlsl.h
+++ b/clang/lib/Headers/hlsl.h
@@ -10,5 +10,6 @@
 #define _HLSL_H_
 
 #include "hlsl/hlsl_basic_types.h"
+#include "hlsl/hlsl_intrinsics.h"
 
 #endif //_HLSL_H_

diff  --git a/clang/lib/Headers/hlsl/hlsl_intrinsics.h 
b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
new file mode 100644
index 0..b5cdb8b449709
--- /dev/null
+++ b/clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -0,0 +1,15 @@
+//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _HLSL_HLSL_INTRINSICS_H_
+#define _HLSL_HLSL_INTRINSICS_H_
+
+__attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) 
uint
+WaveActiveCountBits(bool bBit);
+
+#endif //_HLSL_HLSL_INTRINSICS_H_

diff  --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 52fd5fc637d36..f79523983ed89 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -5629,11 +5629,12 @@ static void handleBuiltinAliasAttr(Sema &S, Decl *D,
   bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
   bool IsARM = S.Context.getTargetInfo().getTriple().isARM();
   bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV();
+  bool IsHLSL = S.Context.getLangOpts().HLSL;
   if ((IsAArch64 && !ArmSveAliasValid(S.Context, BuiltinID, AliasName)) ||
   (IsARM && !ArmMveAliasValid(BuiltinID, AliasName) &&
!ArmCdeAliasValid(BuiltinID, AliasName)) ||
   (IsRISCV && !RISCVAliasValid(BuiltinID, AliasName)) ||
-  (!IsAArch64 && !IsARM && !IsRISCV)) {
+  (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
 S.Diag(AL.getLoc(), diag::err_attribute_builtin_alias) << AL;
 return;
   }

diff  --git a/clang/test/SemaHLSL/Wave.hlsl b/clang/test/SemaHLSL/Wave.hlsl
index ed64d1a5a55ba..3222a7e9366ad 100644
--- a/clang/test/SemaHLSL/Wave.hlsl
+++ b/clang/test/SemaHLSL/Wave.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -x

[PATCH] D128855: [HLSL] Change WaveActiveCountBits to wrapper of __builtin_hlsl_wave_active_count_bits

2022-06-30 Thread Xiang Li via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa591c7ca0d9f: [HLSL] Change WaveActiveCountBits to wrapper 
of… (authored by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128855

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/hlsl.h
  clang/lib/Headers/hlsl/hlsl_intrinsics.h
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/SemaHLSL/Wave.hlsl


Index: clang/test/SemaHLSL/Wave.hlsl
===
--- clang/test/SemaHLSL/Wave.hlsl
+++ clang/test/SemaHLSL/Wave.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -x hlsl -triple dxil--shadermodel6.7-library  %s  -verify
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple 
dxil--shadermodel6.7-library  %s  -verify
 
 // Make sure WaveActiveCountBits is accepted.
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -5629,11 +5629,12 @@
   bool IsAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
   bool IsARM = S.Context.getTargetInfo().getTriple().isARM();
   bool IsRISCV = S.Context.getTargetInfo().getTriple().isRISCV();
+  bool IsHLSL = S.Context.getLangOpts().HLSL;
   if ((IsAArch64 && !ArmSveAliasValid(S.Context, BuiltinID, AliasName)) ||
   (IsARM && !ArmMveAliasValid(BuiltinID, AliasName) &&
!ArmCdeAliasValid(BuiltinID, AliasName)) ||
   (IsRISCV && !RISCVAliasValid(BuiltinID, AliasName)) ||
-  (!IsAArch64 && !IsARM && !IsRISCV)) {
+  (!IsAArch64 && !IsARM && !IsRISCV && !IsHLSL)) {
 S.Diag(AL.getLoc(), diag::err_attribute_builtin_alias) << AL;
 return;
   }
Index: clang/lib/Headers/hlsl/hlsl_intrinsics.h
===
--- /dev/null
+++ clang/lib/Headers/hlsl/hlsl_intrinsics.h
@@ -0,0 +1,15 @@
+//===- hlsl_intrinsics.h - HLSL definitions for intrinsics --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef _HLSL_HLSL_INTRINSICS_H_
+#define _HLSL_HLSL_INTRINSICS_H_
+
+__attribute__((clang_builtin_alias(__builtin_hlsl_wave_active_count_bits))) 
uint
+WaveActiveCountBits(bool bBit);
+
+#endif //_HLSL_HLSL_INTRINSICS_H_
Index: clang/lib/Headers/hlsl.h
===
--- clang/lib/Headers/hlsl.h
+++ clang/lib/Headers/hlsl.h
@@ -10,5 +10,6 @@
 #define _HLSL_H_
 
 #include "hlsl/hlsl_basic_types.h"
+#include "hlsl/hlsl_intrinsics.h"
 
 #endif //_HLSL_H_
Index: clang/lib/Headers/CMakeLists.txt
===
--- clang/lib/Headers/CMakeLists.txt
+++ clang/lib/Headers/CMakeLists.txt
@@ -65,6 +65,7 @@
 set(hlsl_files
   hlsl.h
   hlsl/hlsl_basic_types.h
+  hlsl/hlsl_intrinsics.h
   )
 
 set(mips_msa_files
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4183,7 +4183,7 @@
   "argument %0 to 'preferred_name' attribute is not a typedef for "
   "a specialization of %1">;
 def err_attribute_builtin_alias : Error<
-  "%0 attribute can only be applied to a ARM or RISC-V builtin">;
+  "%0 attribute can only be applied to a ARM, HLSL or RISC-V builtin">;
 
 // called-once attribute diagnostics.
 def err_called_once_attribute_wrong_type : Error<
Index: clang/include/clang/Basic/Builtins.def
===
--- clang/include/clang/Basic/Builtins.def
+++ clang/include/clang/Basic/Builtins.def
@@ -1699,7 +1699,7 @@
 LANGBUILTIN(__builtin_get_device_side_mangled_name, "cC*.", "ncT", CUDA_LANG)
 
 // HLSL
-LANGBUILTIN(WaveActiveCountBits, "Uib", "nc", HLSL_LANG)
+LANGBUILTIN(__builtin_hlsl_wave_active_count_bits, "Uib", "nc", HLSL_LANG)
 
 // Builtins for XRay
 BUILTIN(__xray_customevent, "vcC*z", "")


Index: clang/test/SemaHLSL/Wave.hlsl
===
--- clang/test/SemaHLSL/Wave.hlsl
+++ clang/test/SemaHLSL/Wave.hlsl
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -x hlsl -triple dxil--shadermodel6.7-library  %s  -verify
+// RUN: %clang_cc1 -finclude-default-header -x hlsl -triple dxil--shadermodel6.7-library  %s  -verify
 
 // Make sure WaveActiveCountBits is accepted.
 
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
++

[PATCH] D128844: Improve the formatting of static_assert messages

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

I agree with the changes in principle, but it looks like the libc++ precommit 
CI builder is failing with a bunch of failures... but those failures look like 
the precommit CI isn't testing the Clang built by the patch?

  error: 'error' diagnostics expected but not seen:
File * Line * (directive at 
/home/libcxx-builder/.buildkite-agent/builds/5d14e636cf69-1/llvm-project/libcxx-ci/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp:22):
 static_assert failed due to requirement '1ULL == 0 || 1ULL < 1ULL': 
linear_congruential_engine invalid parameters
File * Line * (directive at 
/home/libcxx-builder/.buildkite-agent/builds/5d14e636cf69-1/llvm-project/libcxx-ci/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp:24):
 static_assert failed due to requirement '1ULL == 0 || 1ULL < 1ULL': 
linear_congruential_engine invalid parameters
File * Line * (directive at 
/home/libcxx-builder/.buildkite-agent/builds/5d14e636cf69-1/llvm-project/libcxx-ci/libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp:27):
 static_assert failed due to requirement 'is_unsigned::value': _UIntType 
must be unsigned type
  error: 'error' diagnostics seen but not expected:
Line 218: static_assert failed due to requirement '1ULL == 0 || 1ULL < 
1ULL' "linear_congruential_engine invalid parameters"
Line 217: static_assert failed due to requirement '1ULL == 0 || 1ULL < 
1ULL' "linear_congruential_engine invalid parameters"
Line 219: static_assert failed due to requirement 'is_unsigned::value' 
"_UIntType must be unsigned type"
  6 errors generated.

So I *think* this LG, but am not certain what will happen when you land it. I 
think the precommit CI failures are not failures that will happen when testing 
against the just-built clang.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

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


[PATCH] D128103: Adds AST Matcher for ObjCStringLiteral

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

LGTM! Do you need me to commit on your behalf? If so, what name and email 
address would you like me to use for patch attribution?


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

https://reviews.llvm.org/D128103

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


[PATCH] D128625: [RISCV][Driver] Fix baremetal `GCCInstallation` paths

2022-06-30 Thread Anton Afanasyev via Phabricator via cfe-commits
anton-afanasyev marked an inline comment as done.
anton-afanasyev added inline comments.



Comment at: clang/lib/Driver/ToolChains/RISCVToolchain.cpp:54
+
+  // Set alias for "riscv{64|32}-unknown-unknown-elf"
+  SmallVector TripleAliases;

arichardson wrote:
> This seems like the wrong place to add this workaround, shouldn't the change 
> be in `GCCInstallation::init`? That way targets other than RISC-V also 
> benefit from this fix.
> 
`GCCInstallation` knows nothing about triple equivalence of the specific 
targets, but provides `TripleAliases` init variable for installation target 
callers. Other targets are to do the same initialization as we do here in case 
of different normalized and layout-used triple names.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128625

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


[PATCH] D128652: [PowerPC] Finished kill_canary implementation and debugging

2022-06-30 Thread Kai Luo via Phabricator via cfe-commits
lkail added a comment.

Summary should be updated as @nemanjai has said.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128652

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


[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik requested changes to this revision.
philnik added a comment.
This revision now requires changes to proceed.

Sorry I missed that. You have to changes the libc++ tests to regex checks to 
allow both error-styles. This can then be removed once we drop support for LLVM 
14 (so after the release of LLVM 16).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

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


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-30 Thread Whitney Tsang via Phabricator via cfe-commits
Whitney added inline comments.



Comment at: clang/test/Driver/check-time-trace.cpp:9
+// RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T -ftime-trace-granularity=0 -o 
%T/check-time-trace %s
+// RUN: cat %T/check-time-trace.json \

By default, the JSON file is stored in %T, as it is the directory for the 
output object file. Can you make a different directory, to ensure it is not 
just the default behavior?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

2022-06-30 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 441379.

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

https://reviews.llvm.org/D128248

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-array-init.cpp


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+// FIXME: This code should compile without errors but as of right now doesn't.
+//   We're only testing that clang doesn't crash or run into an assertion.
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 
'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' 
is not initialized}}
+{{}},
+};
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10754,17 +10754,18 @@
   for (unsigned Index = 0; Index != NumEltsToInit; ++Index) {
 const Expr *Init =
 Index < E->getNumInits() ? E->getInit(Index) : FillerExpr;
-if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
- Info, Subobject, Init) ||
-!HandleLValueArrayAdjustment(Info, Init, Subobject,
- CAT->getElementType(), 1)) {
+if (Result.isArray() &&
+(!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, 
Subobject,
+  Init) ||
+ !HandleLValueArrayAdjustment(Info, Init, Subobject,
+  CAT->getElementType(), 1))) {
   if (!Info.noteFailure())
 return false;
   Success = false;
 }
   }
 
-  if (!Result.hasArrayFiller())
+  if (!Result.isArray() || !Result.hasArrayFiller())
 return Success;
 
   // If we get here, we have a trivial filler, which we can just evaluate
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -175,6 +175,8 @@
   emitted as a dynamic initializer. Previously the variable would
   incorrectly be zero-initialized. In contexts where a dynamic
   initializer is not allowed this is now diagnosed as an error.
+- Fixed an assertion failure when evaluating a constexpr constructor
+  in an array initializer.
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+// FIXME: This code should compile without errors but as of right now doesn't.
+//   We're only testing that clang doesn't crash or run into an assertion.
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' is not initialized}}
+{{}},
+};
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10754,17 +10754,18 @@
   for (unsigned Index = 0; Index != NumEltsToInit; ++Index) {
 const Expr *Init =
 Index < E->getNumInits() ? E->getInit(Index) : FillerExpr;
-if (!EvaluateInPlace(Result.getArrayInitializedElt(Index),
- Info, Subobject, Init) ||
-!HandleLValueArrayAdjustment(Info, Init, Subobject,
- CAT->getElementType(), 1)) {
+if (Result.isArray() &&
+(!EvaluateInPlace(Result.getArrayInitializedElt(Index), Info, Subobject,
+  Init) ||
+ !HandleLValueArrayAdjustment(Info, Init, Subobject,
+  CAT->getElementType(), 1))) {
   if (!Info.noteFailure())
 return false;
   Success = false;
 }
   }
 
-  if (!Result.hasArrayFiller())
+  if (!Result.isArray() || !Result.hasArrayFiller())
 return Success;
 
   // If we get here, we have a trivial filler, which we can just evaluate
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -175,6 +175,8 @@
   emitted as a dynamic initializer.

[clang] 2f20743 - Deferred Concept Instantiation Implementation

2022-06-30 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2022-06-30T06:47:11-07:00
New Revision: 2f207439521d62d9551b2884158368e8b34084e5

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

LOG: Deferred Concept Instantiation Implementation

This is a continuation of D119544.  Based on @rsmith 's feed back
showing me https://eel.is/c++draft/temp#friend-9, We should properly
handle friend functions now.

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

Added: 
clang/test/SemaTemplate/concepts-friends.cpp
clang/test/SemaTemplate/deferred-concept-inst.cpp
clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Decl.h
clang/include/clang/AST/DeclBase.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/Template.h
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp

clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
clang/test/SemaTemplate/concepts.cpp
clang/test/SemaTemplate/instantiate-requires-clause.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e6353de934153..5585467769b03 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -451,10 +451,11 @@ C++20 Feature Support
 - No longer attempt to evaluate a consteval UDL function call at runtime when
   it is called through a template instantiation. This fixes
   `Issue 54578 `_.
-
-- Implemented ``__builtin_source_location()``, which enables library support
-  for ``std::source_location``.
-
+- Implemented `__builtin_source_location()` which enables library support for 
std::source_location.
+- Clang now correctly delays the instantiation of function constraints until
+  the time of checking, which should now allow the libstdc++ ranges 
implementation
+  to work for at least trivial examples.  This fixes
+  `Issue 44178 `_.
 - The mangling scheme for C++20 modules has incompatibly changed. The
   initial mangling was discovered not to be reversible, and the weak
   ownership design decision did not give the backwards compatibility

diff  --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 66fab94b45b8a..0a7dc63d1c25d 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -1890,7 +1890,9 @@ class FunctionDecl : public DeclaratorDecl,
 TK_FunctionTemplateSpecialization,
 // A function template specialization that hasn't yet been resolved to a
 // particular specialized function template.
-TK_DependentFunctionTemplateSpecialization
+TK_DependentFunctionTemplateSpecialization,
+// A non templated function which is in a dependent scope.
+TK_DependentNonTemplate
   };
 
   /// Stashed information about a defaulted function definition whose body has
@@ -1939,20 +1941,21 @@ class FunctionDecl : public DeclaratorDecl,
   /// The template or declaration that this declaration
   /// describes or was instantiated from, respectively.
   ///
-  /// For non-templates, this value will be NULL. For function
-  /// declarations that describe a function template, this will be a
-  /// pointer to a FunctionTemplateDecl. For member functions
-  /// of class template specializations, this will be a 
MemberSpecializationInfo
-  /// pointer containing information about the specialization.
-  /// For function template specializations, this will be a
-  /// FunctionTemplateSpecializationInfo, which contains information about
-  /// the template being specialized and the template arguments involved in
-  /// that specialization.
-  llvm::PointerUnion
-TemplateOrSpecialization;
+  TemplateOrSpecialization;
 
   /// Provides source/type location info for the declaration name embedded in
   /// the DeclaratorDecl base class.
@@ -2695,6 +2698,11 @@ class FunctionDecl : public DeclaratorDecl,
 setInstantiationOfMemberFunction(getASTContext(), FD, TSK);
   }
 
+  /// Specify that this function declaration was instantiated from FunctionDecl
+  ///

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-30 Thread Erich Keane 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 rG2f207439521d: Deferred Concept Instantiation Implementation 
(authored by erichkeane).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  
clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  
clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
  clang/test/SemaTemplate/concepts-friends.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/test/SemaTemplate/deferred-concept-inst.cpp
  clang/test/SemaTemplate/instantiate-requires-clause.cpp
  clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Index: clang/test/SemaTemplate/trailing-return-short-circuit.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/trailing-return-short-circuit.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template 
+  requires(sizeof(T) > 2) || T::value // #FOO_REQ
+void Foo(T){};// #FOO
+
+template 
+void TrailingReturn(T)   // #TRAILING
+  requires(sizeof(T) > 2) || // #TRAILING_REQ
+  T::value   // #TRAILING_REQ_VAL
+{};
+template 
+struct HasValue {
+  static constexpr bool value = B;
+};
+static_assert(sizeof(HasValue) <= 2);
+
+template 
+struct HasValueLarge {
+  static constexpr bool value = B;
+  int I;
+};
+static_assert(sizeof(HasValueLarge) > 2);
+
+void usage() {
+  // Passes the 1st check, short-circuit so the 2nd ::value is not evaluated.
+  Foo(1.0);
+  TrailingReturn(1.0);
+
+  // Fails the 1st check, but has a ::value, so the check happens correctly.
+  Foo(HasValue{});
+  TrailingReturn(HasValue{});
+
+  // Passes the 1st check, but would have passed the 2nd one.
+  Foo(HasValueLarge{});
+  TrailingReturn(HasValueLarge{});
+
+  // Fails the 1st check, fails 2nd because there is no ::value.
+  Foo(true);
+  // expected-error@-1{{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  TrailingReturn(true);
+  // expected-error@-1{{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  // Fails the 1st check, fails 2nd because ::value is false.
+  Foo(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{and 'HasValue::value' evaluated to false}}
+  TrailingReturn(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{and 'HasValue::value' evaluated to false}}
+}
Index: clang/test/SemaTemplate/instantiate-requires-clause.cpp
===
--- clang/test/SemaTemplate/instantiate-requires-clause.cpp
+++ clang/test/SemaTemplate/instantiate-requires-clause.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
+// RUN: %clang_cc1 -std=c++2a -x c++ %s -Wno-unused-value -verify
 
 template  requires ((sizeof(Args) == 1), ...)
 // expected-note@-1 {{becau

[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Valentin Clement via Phabricator via cfe-commits
clementval added inline comments.



Comment at: clang/lib/Driver/ToolChain.cpp:185
   {"flang", "--driver-mode=flang"},
+  {"flang-new", "--driver-mode=flang"},
   {"clang-dxc", "--driver-mode=dxc"},

awarzynski wrote:
> richard.barton.arm wrote:
> > clementval wrote:
> > > This is counter intuitive. We rename flang-new but we add flang-new here. 
> > > It should be configurable. 
> > This is a list of all the valid prefixes of binaries that the driver 
> > supports. With this change, an additional one will be supported so I don't 
> > think it's an issue to have both flang and flang-new here.
> > 
> > The thing that confuses me is how flang-new works today without this 
> > change, given that "flang" is not a suffix of "flang-new"? @awarzynski , do 
> > you know why that is? Perhaps the line here is not needed at all? Or is 
> > this a bug fix for flang-new that is actually unrelated to this change?
> > This is counter intuitive. 
> 
> I can add a comment to clarify this.
> 
> > It should be configurable.
> 
> It is, in Flang's [[ 
> https://github.com/llvm/llvm-project/blob/main/flang/tools/flang-driver/driver.cpp
>  | driver.cpp ]]. Originally, the suffix was hard-coded as:
> ```
> clang::driver::ParsedClangName targetandMode("flang", "--driver-mode=flang");
> ```
> (i.e. the `clangDriver` library used `flang` internally despite the actual 
> name being `flang-new`). This is now being replaced with (see in 
> "driver.cpp"):
> ```
>  clang::driver::ParsedClangName targetandMode =
>   clang::driver::ToolChain::getTargetAndModeFromProgramName(argv[0]);
> ```
> 
> But the change in "driver.cpp" means that we can no longer make assumptions 
> about the suffix and hence the update here. 
> 
> Like I mentioned earlier, we should not make this file build-time 
> configurable. One possible option would be to try to update Clang's [[ 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Config/config.h.cmake
>  | config.h.cmake ]], but that's would lead to more Flang-specific changes in 
> Clang's core set-up. Also, I'm not convinced it would work here. 
> 
> > @awarzynski , do you know why that is? 
> 
> Yeah, check Flang's "driver.cpp". We should've captured this earlier. The 
> original set-up from ToolChain.cpp predates `flang-new`. And then in 
> "driver.cpp" we just matched what was here. There was a lot of confusion 
> around naming  back then and this has slipped in. 
> 
> > This is counter intuitive. 
> 
> I can add a comment to clarify this.
> 
There should be at least a comment here. 


> Like I mentioned earlier, we should not make this file build-time 
> configurable. One possible option would be to try to update Clang's [[ 
> https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Config/config.h.cmake
>  | config.h.cmake ]], but that's would lead to more Flang-specific changes in 
> Clang's core set-up. Also, I'm not convinced it would work here. 
> 

If it cannot be configurable I think this is a good reason to wait a bit and 
make a direct renaming without all the options and duplicate. 




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D125788: [flang][driver] Rename `flang-new` as `flang`

2022-06-30 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D125788#3621744 , @awarzynski 
wrote:

> We discussed this in our call on Monday and agreed to go ahead provided that 
> this change is technically sound. IIUC, this has now been confirmed:
>
>> Overall the patch looks ok from a technical point.
>
> As always, please correct me if I missed or misinterpreted something!

I still have reserved on this patch so please do not take my "Overall the patch 
looks ok from a technical point." as an approval. There are open discussion so 
wait for other to confirm or not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125788

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


[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D128379#3622128 , @sammccall wrote:

> Hmm, this version looks complicated to me.
> And also fragile: downstream we have CLANG_VERSION_STRINGs that don't match 
> upstream, Apple has their own versioning scheme, linux distros tend to do 
> things like `6.0.1~ubuntu3`...
> Let me sync with @kadircet

The good news is that the ~ubuntu3 isn't part of CLANG_VERSION_STRING I think.
Bad news #1 is that it still may not match llvm.org versions: e.g. our internal 
distribution is "trunk", Apple's CLANG_VERSION_STRING is 10.0.1 on my machine, 
but it's approximately LLVM version 7.
Bad news #2 is that the documentation isn't actually available for all these 
versions: none of 14.0.1->14.0.5 exist, the point releases for 9-13 all have 
documentation but not 8.0.1. Looking at other projects, the set of docs 
available is inconsistent.

I don't think this substantially more reliable than just pointing at the HEAD 
docs, and it certainly doesn't seem "better enough" to be worth any build 
complexity. Can we revert to the simple version?

(I do think changing the URLs of the clang-tidy check documentation was 
unfortunate, and setting up server-side redirects for those would be nice to 
have if it's easy)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

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


[PATCH] D128907: [Clang] Disable noundef attribute for languages which allow uninitialized function arguments

2022-06-30 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:534
+  bool allowUninitializedFunctionsArgs() const {
+return ConvergentFunctions;
+  }

Should add a comment explaining it here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128907

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


[PATCH] D121141: [Clang] Add `-funstable` flag to enable unstable and experimental features: follow-up fixes

2022-06-30 Thread Louis Dionne via Phabricator via cfe-commits
ldionne commandeered this revision.
ldionne edited reviewers, added: egorzhdan; removed: ldionne.
ldionne added a comment.
Herald added a subscriber: MaskRay.

Thanks a lot for the fixes @egorzhdan! I think this looks pretty good. Since 
LLVM 15 is coming up and we'd like to have this in its final state for libc++ 
purposes, I'll commandeer this to make a couple adjustments and I'll merge this 
after seeking more feedback on the overall design. Thanks for doing all the 
work!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121141

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


[PATCH] D128652: [PowerPC] Finished kill_canary implementation and debugging

2022-06-30 Thread ChenZheng via Phabricator via cfe-commits
shchenz added a comment.

Please make sure the patch is able to compile first. I fixed two build 
failures, it still fails : (




Comment at: llvm/include/llvm/IR/IntrinsicsPowerPC.td:221
+  def int_ppc_kill_canary
+  : GCCBuiltin<"__builtin_ppc_kill_canary">, 
+Intrinsic<[],

Need rebase your code. `GCCBuiltin` is not a valid class anymore. See 
https://reviews.llvm.org/D127460



Comment at: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp:5013
 auto IntrinsicID = N->getConstantOperandVal(1);
+
 if (IntrinsicID == Intrinsic::ppc_tdw || IntrinsicID == Intrinsic::ppc_tw) 
{

Nit: avoid this unnecessary change



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:61
 #include "llvm/CodeGen/ValueTypes.h"
+#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
 #include "llvm/IR/CallingConv.h"

Do we need this header? A little strange...



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11148
+EVT VT = DAG.getTargetLoweringInfo().getValueType(DAG.getDataLayout(), 
GV->getType(), true); 
+SDValue canaryLoc = DAG.getGlobalAddress(GV, DL, VT);
+

Please make sure when you post the patch, it is ok to compile. `DL` seems 
undefined, we use `dl` here.

Also please read the coding style of llvm first. 
https://llvm.org/docs/CodingStandards.html#name-types-functions-variables-and-enumerators-properly

`canaryLoc` does not follow the style, should be `CanaryLoc`.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:11158
+   canaryLoc,
+   MachinePointerInfo()
+);

All these new added codes need clang-format



Comment at: llvm/test/CodeGen/PowerPC/kill-canary-intrinsic-aix.ll:5
+
+declare void @llvm.ppc.kill.canary()
+define dso_local void @test_kill_canary() {

We can merge these two files `kill-canary-intrinsic-aix.ll` and 
`kill-canary-intrinsic-linux.ll` into one file with different runlines but with 
different check prefix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128652

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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-06-30 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, yaxunl, tra.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds the necessary changes required to bundle and wrap HIP
files. The bundling is done using `clang-offload-bundler` currently to
mimic `fatbinary` and the wrapping is done using very similar runtime
calls to CUDA. This still does not support managed / surface / texture
variables, that would require some additional information in the entry.

One difference in the codegeneration with AMD is that I don't check if
the handle is null before destructing it, I'm not sure if that's
required.

With this we should be able to support HIP with the new driver.

Depends on D128850 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128914

Files:
  clang/test/Driver/linker-wrapper-image.c
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
  clang/tools/clang-linker-wrapper/OffloadWrapper.h

Index: clang/tools/clang-linker-wrapper/OffloadWrapper.h
===
--- clang/tools/clang-linker-wrapper/OffloadWrapper.h
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.h
@@ -21,4 +21,8 @@
 /// registers the images with the CUDA runtime.
 llvm::Error wrapCudaBinary(llvm::Module &M, llvm::ArrayRef Images);
 
+/// Wraps the input bundled image into the module \p M as global symbols and
+/// registers the images with the HIP runtime.
+llvm::Error wrapHIPBinary(llvm::Module &M, llvm::ArrayRef Images);
+
 #endif
Index: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
+++ clang/tools/clang-linker-wrapper/OffloadWrapper.cpp
@@ -22,6 +22,7 @@
 namespace {
 /// Magic number that begins the section containing the CUDA fatbinary.
 constexpr unsigned CudaFatMagic = 0x466243b1;
+constexpr unsigned HIPFatMagic = 0x48495046;
 
 /// Copied from clang/CGCudaRuntime.h.
 enum OffloadEntryKindFlag : uint32_t {
@@ -288,14 +289,15 @@
 
 /// Embed the image \p Image into the module \p M so it can be found by the
 /// runtime.
-GlobalVariable *createFatbinDesc(Module &M, ArrayRef Image) {
+GlobalVariable *createFatbinDesc(Module &M, ArrayRef Image, bool IsHIP) {
   LLVMContext &C = M.getContext();
   llvm::Type *Int8PtrTy = Type::getInt8PtrTy(C);
   llvm::Triple Triple = llvm::Triple(M.getTargetTriple());
 
   // Create the global string containing the fatbinary.
   StringRef FatbinConstantSection =
-  Triple.isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin";
+  IsHIP ? ".hip_fatbin"
+: (Triple.isMacOSX() ? "__NV_CUDA,__nv_fatbin" : ".nv_fatbin");
   auto *Data = ConstantDataArray::get(C, Image);
   auto *Fatbin = new GlobalVariable(M, Data->getType(), /*isConstant*/ true,
 GlobalVariable::InternalLinkage, Data,
@@ -303,10 +305,11 @@
   Fatbin->setSection(FatbinConstantSection);
 
   // Create the fatbinary wrapper
-  StringRef FatbinWrapperSection =
-  Triple.isMacOSX() ? "__NV_CUDA,__fatbin" : ".nvFatBinSegment";
+  StringRef FatbinWrapperSection = IsHIP   ? ".hipFatBinSegment"
+   : Triple.isMacOSX() ? "__NV_CUDA,__fatbin"
+   : ".nvFatBinSegment";
   Constant *FatbinWrapper[] = {
-  ConstantInt::get(Type::getInt32Ty(C), CudaFatMagic),
+  ConstantInt::get(Type::getInt32Ty(C), IsHIP ? HIPFatMagic : CudaFatMagic),
   ConstantInt::get(Type::getInt32Ty(C), 1),
   ConstantExpr::getPointerBitCastOrAddrSpaceCast(Fatbin, Int8PtrTy),
   ConstantPointerNull::get(Type::getInt8PtrTy(C))};
@@ -328,9 +331,10 @@
   ConstantAggregateZero::get(ArrayType::get(getEntryTy(M), 0u));
   auto *DummyEntry = new GlobalVariable(
   M, DummyInit->getType(), true, GlobalVariable::ExternalLinkage, DummyInit,
-  "__dummy.cuda_offloading.entry");
-  DummyEntry->setSection("cuda_offloading_entries");
+  IsHIP ? "__dummy.hip_offloading.entry" : "__dummy.cuda_offloading.entry");
   DummyEntry->setVisibility(GlobalValue::HiddenVisibility);
+  DummyEntry->setSection(IsHIP ? "hip_offloading_entries"
+   : "cuda_offloading_entries");
 
   return FatbinDesc;
 }
@@ -358,7 +362,7 @@
 /// 0, entry->size, 0, 0);
 ///   }
 /// }
-Function *createRegisterGlobalsFunction(Module &M) {
+Function *createRegisterGlobalsFunction(Module &M, bool IsHIP) {
   LLVMContext &C = M.getContext();
   // Get the __cudaRegisterFunction function declaration.
   auto *RegFuncTy = FunctionType::get(
@@ -368,8 +372,8 @@
Type::getInt8PtrTy(C), Type::getInt8PtrTy(C), Type::getInt8PtrT

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:76
+  // `CONSTANT_OP` and `opName` remains "".
+  type = CONSTANT_OP;
+}

srishti-pm wrote:
> Mogball wrote:
> > Constant ops could be sorted by name as well.
> The only reason we separated constant ops from the non-constant ops was 
> because the former are canonicalized to the right (as a stable sort) by 
> existing canonicalizations. And, we didn't want our algorithm to conflict 
> with these existing canonicalizations. That is the reason I am not sorting 
> them by name and just keeping them to the right (as a stable sort).
I know. You can sort them separately from regular ops and also by name and the 
overall behaviour would be the same.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:269
+ArrayRef> bfsOfOperands,
+bool &hasOneOperandWithKey) {
+  bool keyFound = false;

srishti-pm wrote:
> Mogball wrote:
> > This flag is not necessary because you can just check 
> > `bfsOfOperandsWithKey.size() == 1`
> `.size()` is an O(N) operation and that is why I usually try to avoid it. Do 
> you still agree we should use it here? I understand that N is an expectedly 
> small value.
Size is constant time 



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:278-279
+if (compareKeys(key, currentKey) == 0) {
+  bfsOfOperandsWithKey.push_back(
+  std::make_unique(*bfsOfOperand));
+  if (keyFound)

srishti-pm wrote:
> Mogball wrote:
> > You don't need to make a copy. In fact, I think you should just track the 
> > indices.
> I agree. But, we had discussed to store operands instead of indices and 
> that's why I did this. I will change this to use indices again (keeping other 
> things unchanged).
I mean you can have list (not a set) of indices to shift



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:329-353
+  assert(frontPosition >= 0 && frontPosition < bfsOfOperands.size() &&
+ "`frontPosition` should be valid");
+  unsigned positionOfOperandToShift;
+  bool foundOperandToShift = false;
+  for (auto &indexedBfsOfOperand : llvm::enumerate(bfsOfOperands)) {
+std::unique_ptr &bfsOfOperand = indexedBfsOfOperand.value();
+if (bfsOfOperand->isSorted)

srishti-pm wrote:
> Mogball wrote:
> > There is no way you need this much code. A `std::swap` between the current 
> > operand and the first unsorted position should be enough.
> If I do a swap, the sorting will no longer be stable and I believe that there 
> was a discussion that concluded with the fact that "we want stable sorting".
That's true, but shifting like this is very slow as well. At this point, you 
might want to give `std::stable_sort` with a custom comparator that does extra 
BFS iterations on demand a try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D127313: [libc++] Implement P0618R0 (Deprecating )

2022-06-30 Thread Nikolas Klauser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ee9a50a146c: [libc++] Implement P0618R0 (Deprecating 
) (authored by philnik).

Changed prior to commit:
  https://reviews.llvm.org/D127313?vs=441353&id=441398#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127313

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx17Papers.csv
  libcxx/include/codecvt
  libcxx/include/locale
  libcxx/src/locale.cpp
  
libcxx/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
  libcxx/test/support/platform_support.h

Index: libcxx/test/support/platform_support.h
===
--- libcxx/test/support/platform_support.h
+++ libcxx/test/support/platform_support.h
@@ -14,6 +14,8 @@
 #ifndef PLATFORM_SUPPORT_H
 #define PLATFORM_SUPPORT_H
 
+#include "test_macros.h"
+
 // locale names
 #define LOCALE_en_US  

[clang-tools-extra] 8b04c33 - [pseudo] Forest dump ascii art isn't broken by large indices

2022-06-30 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-06-30T16:53:51+02:00
New Revision: 8b04c331b51811fc6ddcfc8207b1ccdcea02108e

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

LOG: [pseudo] Forest dump ascii art isn't broken by large indices

Added: 


Modified: 
clang-tools-extra/pseudo/lib/Forest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/Forest.cpp 
b/clang-tools-extra/pseudo/lib/Forest.cpp
index d9086c8dea5cd..02818547761c8 100644
--- a/clang-tools-extra/pseudo/lib/Forest.cpp
+++ b/clang-tools-extra/pseudo/lib/Forest.cpp
@@ -33,10 +33,13 @@ std::string ForestNode::dump(const Grammar &G) const {
 
 std::string ForestNode::dumpRecursive(const Grammar &G,
   bool Abbreviated) const {
+  using llvm::formatv;
+  Token::Index MaxToken = 0;
   // Count visits of nodes so we can mark those seen multiple times.
   llvm::DenseMap VisitCounts;
   std::function CountVisits =
   [&](const ForestNode *P) {
+MaxToken = std::max(MaxToken, P->startTokenIndex());
 if (VisitCounts[P]++ > 0)
   return; // Don't count children as multiply visited.
 if (P->kind() == Ambiguous)
@@ -46,6 +49,10 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
   };
   CountVisits(this);
 
+  unsigned IndexWidth = std::max(3, (int)std::to_string(MaxToken).size());
+  // e.g. "[{0,4}, {1,4})" if MaxToken is 5742.
+  std::string RangeFormat = formatv("[{{0,{0}}, {{1,{0}}) ", IndexWidth);
+
   // The box-drawing characters that should be added as a child is rendered.
   struct LineDecoration {
 std::string Prefix; // Prepended to every line.
@@ -93,9 +100,9 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
 }
 
 if (End == KEnd)
-  Result += llvm::formatv("[{0,3}, end) ", P->startTokenIndex());
+  Result += formatv(RangeFormat.c_str(), P->startTokenIndex(), "end");
 else
-  Result += llvm::formatv("[{0,3}, {1,3}) ", P->startTokenIndex(), 
End);
+  Result += formatv(RangeFormat.c_str(), P->startTokenIndex(), End);
 Result += LineDec.Prefix;
 Result += LineDec.First;
 if (ElidedParent) {
@@ -110,9 +117,9 @@ std::string ForestNode::dumpRecursive(const Grammar &G,
 
   // The first time, print as #1. Later, =#1.
   if (First) {
-Result += llvm::formatv("{0} #{1}", P->dump(G), ID);
+Result += formatv("{0} #{1}", P->dump(G), ID);
   } else {
-Result += llvm::formatv("{0} =#{1}", G.symbolName(P->symbol()), 
ID);
+Result += formatv("{0} =#{1}", G.symbolName(P->symbol()), ID);
 Children = {}; // Don't walk the children again.
   }
 } else {



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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm marked 4 inline comments as done.
srishti-pm added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:329-353
+  assert(frontPosition >= 0 && frontPosition < bfsOfOperands.size() &&
+ "`frontPosition` should be valid");
+  unsigned positionOfOperandToShift;
+  bool foundOperandToShift = false;
+  for (auto &indexedBfsOfOperand : llvm::enumerate(bfsOfOperands)) {
+std::unique_ptr &bfsOfOperand = indexedBfsOfOperand.value();
+if (bfsOfOperand->isSorted)

Mogball wrote:
> srishti-pm wrote:
> > Mogball wrote:
> > > There is no way you need this much code. A `std::swap` between the 
> > > current operand and the first unsorted position should be enough.
> > If I do a swap, the sorting will no longer be stable and I believe that 
> > there was a discussion that concluded with the fact that "we want stable 
> > sorting".
> That's true, but shifting like this is very slow as well. At this point, you 
> might want to give `std::stable_sort` with a custom comparator that does 
> extra BFS iterations on demand a try.
So, this is what I think:

The number of commutative operands is not expected to be huge. So, we can 
afford to do shifting. In most cases, we wouldn't have to shift more than 1 or 
2 positions. But, the custom comparator might cost us a lot, considering that 
each BFS could potentially be very large, especially for deep learning models. 
So, doing the BFS traversals again and again for the same operand, even though 
caching will be involved, doesn't sound like a good idea to me.

What are your views?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: erichkeane.
Herald added a project: All.
ilya-biryukov requested review of this revision.
Herald added a project: clang.

Currently the C++20 concepts are only merged in `ASTReader`, i.e. when
coming from different TU. This can causes ambiguious reference errors when
trying to access the same concept that should otherwise be merged.

Please see the added test for an example.

Note that we currently use `ASTContext::isSameEntity` to check for ODR
violations. However, it will not check that concept requirements match.
The same issue holds for mering concepts from different TUs, I added a
FIXME and filed a GH issue to track this:
https://github.com/llvm/llvm-project/issues/56310


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128921

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/Inputs/merge-concepts/concepts.h
  clang/test/Modules/Inputs/merge-concepts/format.h
  clang/test/Modules/Inputs/merge-concepts/modules.map
  clang/test/Modules/Inputs/merge-concepts/same_as.h
  clang/test/Modules/merge-concepts.m

Index: clang/test/Modules/merge-concepts.m
===
--- /dev/null
+++ clang/test/Modules/merge-concepts.m
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
+// RUN: -emit-module %S/Inputs/merge-concepts/modules.map \
+// RUN: -o %t.dir/module.pcm
+//
+// Note that this file merely checks the module compiles. The contents of this
+// file are never read by the compiler.
Index: clang/test/Modules/Inputs/merge-concepts/same_as.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/same_as.h
@@ -0,0 +1,7 @@
+#ifndef SAME_AS_H
+#define SAME_AS_H
+
+template 
+concept same_as = __is_same(T, U);
+
+#endif // SAME_AS_H
Index: clang/test/Modules/Inputs/merge-concepts/modules.map
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/modules.map
@@ -0,0 +1,11 @@
+module "library" {
+	export *
+	module "concepts" {
+		export *
+		header "concepts.h"
+	}
+	module "format" {
+		export *
+		header "format.h"
+	}
+}
Index: clang/test/Modules/Inputs/merge-concepts/format.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/format.h
@@ -0,0 +1,11 @@
+#ifndef FORMAT_H
+#define FORMAT_H
+
+#include "concepts.h"
+#include "same_as.h"
+
+template  void foo()
+  requires same_as
+{}
+
+#endif // FORMAT_H
Index: clang/test/Modules/Inputs/merge-concepts/concepts.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/concepts.h
@@ -0,0 +1,6 @@
+#ifndef SAMEAS_CONCEPTS_H_
+#define SAMEAS_CONCEPTS_H_
+
+#include "same_as.h"
+
+#endif // SAMEAS_CONCEPTS_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8655,12 +8655,21 @@
   // Check for conflicting previous declaration.
   DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NameLoc);
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
-ForVisibleRedeclaration);
+forRedeclarationInCurContext());
   LookupName(Previous, S);
 
   FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage=*/false,
/*AllowInlineNamespace*/false);
-  if (!Previous.empty()) {
+
+  auto *Old =
+  Previous.isSingleResult() ? Previous.getAsSingle() : nullptr;
+  bool AddToScope = true;
+  // Check for redefinition and merge with decl from other module if needed.
+  if (Old && !hasVisibleDefinition(Old) && Context.isSameEntity(NewDecl, Old)) {
+Context.setPrimaryMergedDecl(NewDecl, Old);
+makeMergedDefinitionVisible(Old);
+AddToScope = false;
+  } else if (!Previous.empty()) {
 auto *Old = Previous.getRepresentativeDecl();
 Diag(NameLoc, isa(Old) ? diag::err_redefinition :
  diag::err_redefinition_different_kind) << NewDecl->getDeclName();
@@ -8668,7 +8677,8 @@
   }
 
   ActOnDocumentableDecl(NewDecl);
-  PushOnScopeChains(NewDecl, S);
+  if (AddToScope)
+PushOnScopeChains(NewDecl, S);
   return NewDecl;
 }
 
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -6512,6 +6512,7 @@
   // and patterns match.
   if (const auto *TemplateX = dyn_cast(X)) {
 const auto *TemplateY = cast(Y);
+// FIXME: for C++20 concepts, check their requirements are the same.
 return isSameEntity(TemplateX->getTemplatedDecl(),
 TemplateY->getTemplatedDecl()) &&
 

[PATCH] D128612: RISC-V big-endian support implementation

2022-06-30 Thread Guy Benyei via Phabricator via cfe-commits
gbenyei marked 3 inline comments as done.
gbenyei added inline comments.



Comment at: llvm/lib/ExecutionEngine/JITLink/ELF_riscv.cpp:554
 .buildGraph();
-  } else {
-assert((*ELFObj)->getArch() == Triple::riscv32 &&
-   "Invalid triple for RISCV ELF object file");
+  } else if ((*ELFObj)->getArch() == Triple::riscv64be) {
+auto &ELFObjFile = cast>(**ELFObj);

gbenyei wrote:
> jrtc27 wrote:
> > Why switch to this order when before you've used 32, 64, 32be, 64be as the 
> > order
> The order in the code before my changes is 64, 32. I guess for no good 
> reason, but I prefer not to re-order code while implementing a feature - it 
> trashes git history.
Removed this part anyway - JIT is out of scope for this commit. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

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


[PATCH] D128907: [Clang] Disable noundef attribute for languages which allow uninitialized function arguments

2022-06-30 Thread krishna chaitanya sankisa via Phabricator via cfe-commits
skc7 updated this revision to Diff 441409.
skc7 added a comment.

Add description for allowUninitializedFunctionsArgs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128907

Files:
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/PowerPC/ppc64le-varargs-f128.c
  clang/test/CodeGenCUDA/address-spaces.cu
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenCUDA/cuda-builtin-vars.cu
  clang/test/CodeGenCUDA/kernel-args-alignment.cu
  clang/test/CodeGenCUDA/kernel-args.cu
  clang/test/CodeGenCUDA/lambda.cu
  clang/test/CodeGenCUDA/redux-builtins.cu
  clang/test/CodeGenCUDA/surface.cu
  clang/test/CodeGenCUDA/unnamed-types.cu
  clang/test/CodeGenCUDA/usual-deallocators.cu
  clang/test/CodeGenCUDA/vtbl.cu
  clang/test/CodeGenCUDASPIRV/kernel-argument.cu
  clang/test/CodeGenHIP/hipspv-addr-spaces.cpp
  clang/test/CodeGenHIP/noundef-attribute-hip-device-verify.hip
  clang/test/CodeGenOpenCL/addr-space-struct-arg.cl
  clang/test/CodeGenOpenCL/address-spaces.cl
  clang/test/CodeGenOpenCL/amdgcn-automatic-variable.cl
  clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
  clang/test/CodeGenOpenCL/amdgpu-call-kernel.cl
  clang/test/CodeGenOpenCL/amdgpu-printf.cl
  clang/test/CodeGenOpenCL/as_type.cl
  clang/test/CodeGenOpenCL/atomic-ops-libcall.cl
  clang/test/CodeGenOpenCL/blocks.cl
  clang/test/CodeGenOpenCL/byval.cl
  clang/test/CodeGenOpenCL/const-str-array-decay.cl
  clang/test/CodeGenOpenCL/constant-addr-space-globals.cl
  clang/test/CodeGenOpenCL/convergent.cl
  clang/test/CodeGenOpenCL/fpmath.cl
  clang/test/CodeGenOpenCL/half.cl
  clang/test/CodeGenOpenCL/kernel-param-alignment.cl
  clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
  clang/test/CodeGenOpenCL/no-half.cl
  clang/test/CodeGenOpenCL/overload.cl
  clang/test/CodeGenOpenCL/size_t.cl
  clang/test/CodeGenOpenCL/spir-calling-conv.cl
  clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
  clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
  clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-mangling.cpp
  clang/test/CodeGenSYCL/functionptr-addrspace.cpp
  clang/test/CodeGenSYCL/unique_stable_name.cpp
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/amdgcn_target_global_constructor.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/declare_target_codegen.cpp
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_declare_target_var_ctor_dtor_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_target_printf_codegen.c
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_unsupported_type_codegen.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_debug_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_private_cod

[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: ChuanqiXu, iains.
erichkeane added a comment.

I don't see anything to be concerned about here, but I'd like a modules person 
to take a look.  @ChuanqiXu any chance you can confirm here? (or @iains ?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:329-353
+  assert(frontPosition >= 0 && frontPosition < bfsOfOperands.size() &&
+ "`frontPosition` should be valid");
+  unsigned positionOfOperandToShift;
+  bool foundOperandToShift = false;
+  for (auto &indexedBfsOfOperand : llvm::enumerate(bfsOfOperands)) {
+std::unique_ptr &bfsOfOperand = indexedBfsOfOperand.value();
+if (bfsOfOperand->isSorted)

srishti-pm wrote:
> Mogball wrote:
> > srishti-pm wrote:
> > > Mogball wrote:
> > > > There is no way you need this much code. A `std::swap` between the 
> > > > current operand and the first unsorted position should be enough.
> > > If I do a swap, the sorting will no longer be stable and I believe that 
> > > there was a discussion that concluded with the fact that "we want stable 
> > > sorting".
> > That's true, but shifting like this is very slow as well. At this point, 
> > you might want to give `std::stable_sort` with a custom comparator that 
> > does extra BFS iterations on demand a try.
> So, this is what I think:
> 
> The number of commutative operands is not expected to be huge. So, we can 
> afford to do shifting. In most cases, we wouldn't have to shift more than 1 
> or 2 positions. But, the custom comparator might cost us a lot, considering 
> that each BFS could potentially be very large, especially for deep learning 
> models. So, doing the BFS traversals again and again for the same operand, 
> even though caching will be involved, doesn't sound like a good idea to me.
> 
> What are your views?
Very rough estimate: on its own, this function is N. Finding the smallest key 
is N, and then finding all matching elements is N. This function is called for 
each operand that needs to be moved, but the number of such operands decreases. 
So the sort itself averages out to be 3N^2 iterations over the operand list.

Now for traversals, doing BFS on demand inside the comparator doesn't mean it 
has to restart every time. It would do extra iterations on top of existing 
iteration results only when needed to break ties. In your case, you do an extra 
iteration of BFS for all operands if the current smallest key is identical, not 
just for the ones needed. It's hard to estimate the number of iterations of 
BFS, but certainly it's more in your case. Using `std::stable_sort` would also 
bring the complexity down to N logN


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I don't see anything to be concerned about here, but I'd like a modules person 
to take a look.  @ChuanqiXu any chance you can confirm here? (or @iains ?)

Also, would like to see a release note on this too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D128612: RISC-V big-endian support implementation

2022-06-30 Thread Guy Benyei via Phabricator via cfe-commits
gbenyei updated this revision to Diff 441410.
gbenyei added a comment.

Removed LLD and JIT related parts - JIT is out of my scope, and LLD will be in 
an additional patch.
Fixed additional remarks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128612

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/OSTargets.h
  clang/lib/Basic/Targets/RISCV.cpp
  clang/lib/Basic/Targets/RISCV.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/BareMetal.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/FreeBSD.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/RISCVToolchain.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  llvm/cmake/config.guess
  llvm/include/llvm/ADT/Triple.h
  llvm/include/llvm/Object/ELFObjectFile.h
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/lib/Object/RelocationResolver.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp
  llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp
  llvm/lib/Target/RISCV/RISCVTargetMachine.cpp
  llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp
  llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.h
  llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/Object/ELFObjectFileTest.cpp

Index: llvm/unittests/Object/ELFObjectFileTest.cpp
===
--- llvm/unittests/Object/ELFObjectFileTest.cpp
+++ llvm/unittests/Object/ELFObjectFileTest.cpp
@@ -186,10 +186,10 @@
 }
 
 TEST(ELFObjectFileTest, MachineTestForRISCV) {
-  std::array Formats = {"elf32-littleriscv", "elf32-littleriscv",
-  "elf64-littleriscv", "elf64-littleriscv"};
-  std::array Archs = {Triple::riscv32, Triple::riscv32,
-   Triple::riscv64, Triple::riscv64};
+  std::array Formats = {"elf32-littleriscv", "elf32-bigriscv",
+  "elf64-littleriscv", "elf64-bigriscv"};
+  std::array Archs = {Triple::riscv32, Triple::riscv32be,
+   Triple::riscv64, Triple::riscv64be};
   size_t I = 0;
   for (const DataForTest &D : generateData(ELF::EM_RISCV)) {
 checkFormatAndArch(D, Formats[I], Archs[I]);
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -301,6 +301,8 @@
 // RISC-V
 {"elf32-littleriscv", {ELF::EM_RISCV, false, true}},
 {"elf64-littleriscv", {ELF::EM_RISCV, true, true}},
+{"elf32-bigriscv", {ELF::EM_RISCV, false, false}},
+{"elf64-bigriscv", {ELF::EM_RISCV, true, false}},
 // PowerPC
 {"elf32-powerpc", {ELF::EM_PPC, false, false}},
 {"elf32-powerpcle", {ELF::EM_PPC, false, true}},
Index: llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
===
--- llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
+++ llvm/test/tools/llvm-objcopy/ELF/binary-output-target.test
@@ -33,6 +33,12 @@
 # RUN: llvm-objcopy -I binary -O elf64-littleriscv %t.txt %t.rv64.o
 # RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,LE,RISCV64,64
 
+# RUN: llvm-objcopy -I binary -O elf32-bigriscv %t.txt %t.rv32.o
+# RUN: llvm-readobj --file-headers %t.rv32.o | FileCheck %s --check-prefixes=CHECK,BE,RISCV32,32
+
+# RUN: llvm-objcopy -I binary -O elf64-bigriscv %t.txt %t.rv64.o
+# RUN: llvm-readobj --file-headers %t.rv64.o | FileCheck %s --check-prefixes=CHECK,BE,RISCV64,64
+
 # RUN: llvm-objcopy -I binary -O elf32-sparc %t.txt %t.sparc.o
 # RUN: llvm-readobj --file-headers %t.sparc.o | FileCheck %s --check-prefixes=CHECK,BE,SPARC,32
 
Index: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
@@ -480,7 +480,8 @@
   bool IsMIPS64 = TargetTriple.isMIPS64();
   bool IsArmOrThumb = TargetTriple.isARM() || TargetTriple.isThumb();
   bool IsAArch64 = TargetTriple.getArc

[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

@erichkeane please let me know if you're the right person to review this.




Comment at: clang/lib/Sema/SemaTemplate.cpp:8674
 auto *Old = Previous.getRepresentativeDecl();
 Diag(NameLoc, isa(Old) ? diag::err_redefinition :
  diag::err_redefinition_different_kind) << NewDecl->getDeclName();

Not sure if reporting the redefinition if `isSameEntity` returns false is the 
right approach here.
This leads to errors on definitions of something like:
```
// foo.h
template  concept A = false;

// bar.h
template  concept A = true;

#include "foo.h"
#include "bar.h" // <-- redefinition error shown here
```

The alternative is the "ambiguous reference" error on the use of the concept. I 
will check what happens for variables and typedefs in that case and follow the 
same pattern.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D128379#3622286 , @sammccall wrote:

> In D128379#3622128 , @sammccall 
> wrote:
>
>> Hmm, this version looks complicated to me.
>> And also fragile: downstream we have CLANG_VERSION_STRINGs that don't match 
>> upstream, Apple has their own versioning scheme, linux distros tend to do 
>> things like `6.0.1~ubuntu3`...
>> Let me sync with @kadircet
>
> The good news is that the ~ubuntu3 isn't part of CLANG_VERSION_STRING I think.
> Bad news #1 is that it still may not match llvm.org versions: e.g. our 
> internal distribution is "trunk", Apple's CLANG_VERSION_STRING is 10.0.1 on 
> my machine, but it's approximately LLVM version 7.
> Bad news #2 is that the documentation isn't actually available for all these 
> versions: none of 14.0.1->14.0.5 exist, the point releases for 9-13 all have 
> documentation but not 8.0.1. Looking at other projects, the set of docs 
> available is inconsistent.
>
> I don't think this substantially more reliable than just pointing at the HEAD 
> docs, and it certainly doesn't seem "better enough" to be worth any build 
> complexity. Can we revert to the simple version?
>
> (I do think changing the URLs of the clang-tidy check documentation was 
> unfortunate, and setting up server-side redirects for those would be nice to 
> have if it's easy)

That's a good point about the point releases. The best acceptable compromise 
would be to just point the docs to the `.0.0`. This should 
always be a valid
The only issue here is that if there was any issue relating to the 
documentation URL it would surface after we have already published the release.

I did raise the issue about redirects for the check documentation when the 
structure was changed but it wasn't implemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

For this to be a usable canonicalization, it is really the case where the 
operands are already sorted (no-op) that needs to be heavily optimized (that is 
no complex data structure to populate, etc.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D128923: [LinkerWrapper] Add AMDGPU specific options to the LLD invocation

2022-06-30 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: arsenm, JonChesterfield, saiislam, yaxunl.
Herald added subscribers: kosarev, t-tye, tpr, dstuttard, kzhuravl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

We use LLD to perform AMDGPU linking. This linker accepts some arguments
through the `-plugin-opt` facilities. These options match what `Clang`
will output when given the same input.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128923

Files:
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -8,9 +8,9 @@
 //
 // This tool works as a wrapper over a linking job. This tool is used to create
 // linked device images for offloading. It scans the linker's input for 
embedded
-// device offloading data stored in sections `.llvm.offloading..`
-// and extracts it as a temporary file. The extracted device files will then be
-// passed to a device linking job to create a final device image.
+// device offloading data stored in sections `.llvm.offloading` and extracts it
+// as a temporary file. The extracted device files will then be passed to a
+// device linking job to create a final device image.
 //
 //===-===//
 
@@ -573,6 +573,7 @@
"out");
   if (!TempFileOrErr)
 return TempFileOrErr.takeError();
+  std::string ArchArg = ("-plugin-opt=mcpu=" + Arch).str();
 
   SmallVector CmdArgs;
   CmdArgs.push_back(*LLDPath);
@@ -580,6 +581,8 @@
   CmdArgs.push_back("gnu");
   CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
+  CmdArgs.push_back("-plugin-opt=-amdgpu-internalize-symbols");
+  CmdArgs.push_back(ArchArg);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(*TempFileOrErr);
 
Index: clang/test/Driver/linker-wrapper.c
===
--- clang/test/Driver/linker-wrapper.c
+++ clang/test/Driver/linker-wrapper.c
@@ -18,7 +18,7 @@
 // RUN: clang-linker-wrapper --host-triple x86_64-unknown-linux-gnu --dry-run 
-linker-path \
 // RUN:   /usr/bin/ld -- %t.o -o a.out 2>&1 | FileCheck %s 
--check-prefix=AMDGPU_LINK
 
-// AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out 
{{.*}}.o {{.*}}.o
+// AMDGPU_LINK: lld{{.*}}-flavor gnu --no-undefined -shared 
-plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out 
{{.*}}.o {{.*}}.o
 
 // RUN: clang-offload-packager -o %t.out \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=x86_64-unknown-linux-gnu \
@@ -90,7 +90,7 @@
 // RUN:   /usr/bin/ld --device-linker=a --device-linker=nvptx64-nvidia-cuda=b 
-- \
 // RUN:   %t.o -o a.out 2>&1 | FileCheck %s --check-prefix=LINKER_ARGS
 
-// LINKER_ARGS: lld{{.*}}-flavor gnu --no-undefined -shared -o {{.*}}.out 
{{.*}}.o a
+// LINKER_ARGS: lld{{.*}}-flavor gnu --no-undefined -shared 
-plugin-opt=-amdgpu-internalize-symbols -plugin-opt=mcpu=gfx908 -o {{.*}}.out 
{{.*}}.o a
 // LINKER_ARGS: nvlink{{.*}}-m64 -o {{.*}}.out -arch sm_70 {{.*}}.o a b
 
 // RUN: clang-offload-packager -o %t-lib.out \


Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -8,9 +8,9 @@
 //
 // This tool works as a wrapper over a linking job. This tool is used to create
 // linked device images for offloading. It scans the linker's input for embedded
-// device offloading data stored in sections `.llvm.offloading..`
-// and extracts it as a temporary file. The extracted device files will then be
-// passed to a device linking job to create a final device image.
+// device offloading data stored in sections `.llvm.offloading` and extracts it
+// as a temporary file. The extracted device files will then be passed to a
+// device linking job to create a final device image.
 //
 //===-===//
 
@@ -573,6 +573,7 @@
"out");
   if (!TempFileOrErr)
 return TempFileOrErr.takeError();
+  std::string ArchArg = ("-plugin-opt=mcpu=" + Arch).str();
 
   SmallVector CmdArgs;
   CmdArgs.push_back(*LLDPath);
@@ -580,6 +581,8 @@
   CmdArgs.push_back("gnu");
   CmdArgs.push_back("--no-undefined");
   CmdArgs.push_back("-shared");
+  CmdArgs.push_back("-plugin-opt=-amdgpu-internalize-symbols");
+  CmdArgs.push_back(ArchArg);
   CmdArgs.push_back("-o");
   CmdArgs.push_back(*TempFileOrErr);
 
Index: clang/test/Driver/linker-wrapper.c
==

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-06-30 Thread Zakk Chen via Phabricator via cfe-commits
khchen accepted this revision.
khchen added a comment.
This revision is now accepted and ready to land.

LGTM. Other than that last comments.




Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:77
+  // Create compressed hsignature table from SemaRecords.
+  void init(const std::vector &SemaRecords);
+

please use ArrayRef



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:110
+  void createRVVIntrinsics(std::vector> &Out,
+   std::vector *SemaRecords);
+  /// Create all intrinsics record and SemaSignatureTable from SemaRecords.

maybe SemaRecords could have default argument as nullptr.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:114
+SemaSignatureTable &SST,
+const std::vector &SemaRecords);
+

please use ArrayRef



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:254
+  if (Signature.empty())
+return 0;
+

Does it mean empty Signature always at 0?
If yes,  maybe we could check the table from Index = 1 in below loop?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D128924: [clang][dataflow] Replace TEST_F with TEST where possible

2022-06-30 Thread Sam Estep via Phabricator via cfe-commits
samestep created this revision.
Herald added subscribers: martong, tschuett, xazax.hun.
Herald added a project: All.
samestep requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128924

Files:
  clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -37,33 +37,30 @@
 using ::testing::Pair;
 using ::testing::SizeIs;
 
-class TransferTest : public ::testing::Test {
-protected:
-  template 
-  void runDataflow(llvm::StringRef Code, Matcher Match,
-   LangStandard::Kind Std = LangStandard::lang_cxx17,
-   bool ApplyBuiltinTransfer = true,
-   llvm::StringRef TargetFun = "target") {
-ASSERT_THAT_ERROR(
-test::checkDataflow(
-Code, TargetFun,
-[ApplyBuiltinTransfer](ASTContext &C, Environment &) {
-  return NoopAnalysis(C, ApplyBuiltinTransfer);
-},
-[&Match](
-llvm::ArrayRef<
-std::pair>>
-Results,
-ASTContext &ASTCtx) { Match(Results, ASTCtx); },
-{"-fsyntax-only", "-fno-delayed-template-parsing",
- "-std=" +
- std::string(
- LangStandard::getLangStandardForKind(Std).getName())}),
-llvm::Succeeded());
-  }
-};
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+  LangStandard::Kind Std = LangStandard::lang_cxx17,
+  bool ApplyBuiltinTransfer = true,
+  llvm::StringRef TargetFun = "target") {
+  ASSERT_THAT_ERROR(
+  test::checkDataflow(
+  Code, TargetFun,
+  [ApplyBuiltinTransfer](ASTContext &C, Environment &) {
+return NoopAnalysis(C, ApplyBuiltinTransfer);
+  },
+  [&Match](
+  llvm::ArrayRef<
+  std::pair>>
+  Results,
+  ASTContext &ASTCtx) { Match(Results, ASTCtx); },
+  {"-fsyntax-only", "-fno-delayed-template-parsing",
+"-std=" +
+std::string(
+LangStandard::getLangStandardForKind(Std).getName())}),
+  llvm::Succeeded());
+}
 
-TEST_F(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
+TEST(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
   std::string Code = R"(
 void target() {
   int Foo;
@@ -88,7 +85,7 @@
   /*ApplyBuiltinTransfer=*/false);
 }
 
-TEST_F(TransferTest, BoolVarDecl) {
+TEST(TransferTest, BoolVarDecl) {
   std::string Code = R"(
 void target() {
   bool Foo;
@@ -115,7 +112,7 @@
   });
 }
 
-TEST_F(TransferTest, IntVarDecl) {
+TEST(TransferTest, IntVarDecl) {
   std::string Code = R"(
 void target() {
   int Foo;
@@ -142,7 +139,7 @@
   });
 }
 
-TEST_F(TransferTest, StructVarDecl) {
+TEST(TransferTest, StructVarDecl) {
   std::string Code = R"(
 struct A {
   int Bar;
@@ -188,7 +185,7 @@
   });
 }
 
-TEST_F(TransferTest, StructVarDeclWithInit) {
+TEST(TransferTest, StructVarDeclWithInit) {
   std::string Code = R"(
 struct A {
   int Bar;
@@ -236,7 +233,7 @@
   });
 }
 
-TEST_F(TransferTest, ClassVarDecl) {
+TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {
   int Bar;
@@ -282,7 +279,7 @@
   });
 }
 
-TEST_F(TransferTest, ReferenceVarDecl) {
+TEST(TransferTest, ReferenceVarDecl) {
   std::string Code = R"(
 struct A {};
 
@@ -318,7 +315,7 @@
   });
 }
 
-TEST_F(TransferTest, SelfReferentialReferenceVarDecl) {
+TEST(TransferTest, SelfReferentialReferenceVarDecl) {
   std::string Code = R"(
 struct A;
 
@@ -427,7 +424,7 @@
   });
 }
 
-TEST_F(TransferTest, PointerVarDecl) {
+TEST(TransferTest, PointerVarDecl) {
   std::string Code = R"(
 struct A {};
 
@@ -462,7 +459,7 @@
   });
 }
 
-TEST_F(TransferTest, SelfReferentialPointerVarDecl) {
+TEST(TransferTest, SelfReferentialPointerVarDecl) {
   std::string Code = R"(
 struct A;
 
@@ -584,7 +581,7 @@
   });
 }
 
-TEST_F(TransferTest, MultipleVarsDecl) {
+TEST(TransferTest, MultipleVarsDecl) {
   std::string Code = R"(
 void target() {
   int Foo, Bar;
@@ -622,7 +619,7 @@
   });
 }
 
-TEST_F(TransferTest, JoinVarDecl) {
+TEST(TransferTest, JoinVarDecl) {
   std::string Code = R"(
   

[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-06-30 Thread Zakk Chen via Phabricator via cfe-commits
khchen added a comment.

@craig.topper @rogfer01 - do you have other comments?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

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


[PATCH] D128924: [clang][dataflow] Replace TEST_F with TEST where possible

2022-06-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.
This revision is now accepted and ready to land.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128924

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


[PATCH] D128807: [clang][transformer] Finish plumbing `Note` all the way to the output.

2022-06-30 Thread Eric Li via Phabricator via cfe-commits
li.zhe.hua added a comment.

In D128807#3620573 , @ymandel wrote:

> Eric -- what do you think? You've thought a lot more about metadata recently.

(Apologies for the delay. Still struggling to figure out a good workflow for 
reviewing patches...)

Can you say more about what your intended use of the note is? Perhaps that can 
motivate some of the discussion.

From what I can see, here's my thoughts:

- A note being a part of an edit seems weird at best. An `ASTEdit` and `Edit` 
are fragments of a greater, logical change. That a note should semantically be 
associated with the insertion of an open paren "`(`" but not the close paren 
"`)`" seems odd to me.
- The note takes the location of the edit it is attached to. Perhaps that could 
be of some convenience when those coincide, but I don't believe that should 
necessarily be the case. I'm imagining notes could be used to point out 
//other// parts of the source that are interesting.

I don't have a lot of experience with how notes appear when surfaced, but I 
suspect that this interface might encourage callers to tack notes on without 
putting a lot of thought to //where// the note shows up. As is, I'm inclined to 
think that extending the metadata from `std::string` to something richer would 
be a better design.

Let me know if I'm misunderstanding the code or the intent of the patch.




Comment at: clang/include/clang/Tooling/Transformer/RewriteRule.h:250-251
 
+// Adds a note to the given edit or edits. If there are several edits, the note
+// is added to each one of them.
+// \code

Are we sure that this is what someone would want? Perhaps I am not creative 
enough, but this seems like it could explode a large number of notes that 
coincide to edits, which seems like an odd thing to want.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128807

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


[PATCH] D128924: [clang][dataflow] Replace TEST_F with TEST where possible

2022-06-30 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev accepted this revision.
sgatev added a comment.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128924

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


[clang] 1d83a16 - [clang][dataflow] Replace TEST_F with TEST where possible

2022-06-30 Thread Sam Estep via cfe-commits

Author: Sam Estep
Date: 2022-06-30T16:03:33Z
New Revision: 1d83a16bd3faa1dfb6e8ed40c53d018dc03e2c81

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

LOG: [clang][dataflow] Replace TEST_F with TEST where possible

Many of our tests are currently written using `TEST_F` where the test fixture 
class doesn't have any `SetUp` or `TearDown` methods, and just one helper 
method. In those cases, this patch deletes the class and pulls its method out 
into a standalone function, using `TEST` instead of `TEST_F`.

There are still a few test files leftover in 
`clang/unittests/Analysis/FlowSensitive/` that use `TEST_F`:

- `DataflowAnalysisContextTest.cpp` because the class contains a `Context` 
field which is used
- `DataflowEnvironmentTest.cpp` because the class contains an `Environment` 
field which is used
- `SolverTest.cpp` because the class contains a `Vals` field which is used
- `TypeErasedDataflowAnalysisTest.cpp` because there are several different 
classes which all share the same method name

Reviewed By: ymandel, sgatev

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

Added: 


Modified: 
clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
index a61d6dc682d87..2be1405465838 100644
--- a/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
@@ -128,31 +128,28 @@ class ModelAdaptorAnalysis
   Model M;
 };
 
-class ChromiumCheckModelTest : public ::testing::TestWithParam {
-protected:
-  template 
-  void runDataflow(llvm::StringRef Code, Matcher Match) {
-const tooling::FileContentMappings FileContents = {
-{"check.h", ChromiumCheckHeader}, {"othercheck.h", OtherCheckHeader}};
-
-ASSERT_THAT_ERROR(
-test::checkDataflow>(
-Code, "target",
-[](ASTContext &C, Environment &) {
-  return ModelAdaptorAnalysis(C);
-},
-[&Match](
-llvm::ArrayRef<
-std::pair>>
-Results,
-ASTContext &ASTCtx) { Match(Results, ASTCtx); },
-{"-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"},
-FileContents),
-llvm::Succeeded());
-  }
-};
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match) {
+  const tooling::FileContentMappings FileContents = {
+  {"check.h", ChromiumCheckHeader}, {"othercheck.h", OtherCheckHeader}};
+
+  ASSERT_THAT_ERROR(
+  test::checkDataflow>(
+  Code, "target",
+  [](ASTContext &C, Environment &) {
+return ModelAdaptorAnalysis(C);
+  },
+  [&Match](
+  llvm::ArrayRef<
+  std::pair>>
+  Results,
+  ASTContext &ASTCtx) { Match(Results, ASTCtx); },
+  {"-fsyntax-only", "-fno-delayed-template-parsing", "-std=c++17"},
+  FileContents),
+  llvm::Succeeded());
+}
 
-TEST_F(ChromiumCheckModelTest, CheckSuccessImpliesConditionHolds) {
+TEST(ChromiumCheckModelTest, CheckSuccessImpliesConditionHolds) {
   auto Expectations =
   [](llvm::ArrayRef<
  std::pair>>
@@ -185,7 +182,7 @@ TEST_F(ChromiumCheckModelTest, 
CheckSuccessImpliesConditionHolds) {
   runDataflow(ReplacePattern(Code, "$check", "DPCHECK"), Expectations);
 }
 
-TEST_F(ChromiumCheckModelTest, UnrelatedCheckIgnored) {
+TEST(ChromiumCheckModelTest, UnrelatedCheckIgnored) {
   auto Expectations =
   [](llvm::ArrayRef<
  std::pair>>

diff  --git a/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
index 98319760fd206..bf8c2f5eedc95 100644
--- a/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
@@ -123,25 +123,22 @@ class TestAnalysis : public 
DataflowAnalysis {
   }
 };
 
-class MatchSwitchTest : public ::testing::Test {
-protected:
-  template 
-  void RunDataflow(llvm::StringRef Code, Matcher Expectations) {
-ASSERT_THAT_ERROR(
-test::checkDataflow(
-Code, "fun",
-[](ASTContext &C, Environment &) { return TestAnalysis(C); },
-[&Expectations](
-llvm::ArrayR

[PATCH] D128924: [clang][dataflow] Replace TEST_F with TEST where possible

2022-06-30 Thread Sam Estep 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 rG1d83a16bd3fa: [clang][dataflow] Replace TEST_F with TEST 
where possible (authored by samestep).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128924

Files:
  clang/unittests/Analysis/FlowSensitive/ChromiumCheckModelTest.cpp
  clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
  clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -37,33 +37,30 @@
 using ::testing::Pair;
 using ::testing::SizeIs;
 
-class TransferTest : public ::testing::Test {
-protected:
-  template 
-  void runDataflow(llvm::StringRef Code, Matcher Match,
-   LangStandard::Kind Std = LangStandard::lang_cxx17,
-   bool ApplyBuiltinTransfer = true,
-   llvm::StringRef TargetFun = "target") {
-ASSERT_THAT_ERROR(
-test::checkDataflow(
-Code, TargetFun,
-[ApplyBuiltinTransfer](ASTContext &C, Environment &) {
-  return NoopAnalysis(C, ApplyBuiltinTransfer);
-},
-[&Match](
-llvm::ArrayRef<
-std::pair>>
-Results,
-ASTContext &ASTCtx) { Match(Results, ASTCtx); },
-{"-fsyntax-only", "-fno-delayed-template-parsing",
- "-std=" +
- std::string(
- LangStandard::getLangStandardForKind(Std).getName())}),
-llvm::Succeeded());
-  }
-};
+template 
+void runDataflow(llvm::StringRef Code, Matcher Match,
+  LangStandard::Kind Std = LangStandard::lang_cxx17,
+  bool ApplyBuiltinTransfer = true,
+  llvm::StringRef TargetFun = "target") {
+  ASSERT_THAT_ERROR(
+  test::checkDataflow(
+  Code, TargetFun,
+  [ApplyBuiltinTransfer](ASTContext &C, Environment &) {
+return NoopAnalysis(C, ApplyBuiltinTransfer);
+  },
+  [&Match](
+  llvm::ArrayRef<
+  std::pair>>
+  Results,
+  ASTContext &ASTCtx) { Match(Results, ASTCtx); },
+  {"-fsyntax-only", "-fno-delayed-template-parsing",
+"-std=" +
+std::string(
+LangStandard::getLangStandardForKind(Std).getName())}),
+  llvm::Succeeded());
+}
 
-TEST_F(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
+TEST(TransferTest, IntVarDeclNotTrackedWhenTransferDisabled) {
   std::string Code = R"(
 void target() {
   int Foo;
@@ -88,7 +85,7 @@
   /*ApplyBuiltinTransfer=*/false);
 }
 
-TEST_F(TransferTest, BoolVarDecl) {
+TEST(TransferTest, BoolVarDecl) {
   std::string Code = R"(
 void target() {
   bool Foo;
@@ -115,7 +112,7 @@
   });
 }
 
-TEST_F(TransferTest, IntVarDecl) {
+TEST(TransferTest, IntVarDecl) {
   std::string Code = R"(
 void target() {
   int Foo;
@@ -142,7 +139,7 @@
   });
 }
 
-TEST_F(TransferTest, StructVarDecl) {
+TEST(TransferTest, StructVarDecl) {
   std::string Code = R"(
 struct A {
   int Bar;
@@ -188,7 +185,7 @@
   });
 }
 
-TEST_F(TransferTest, StructVarDeclWithInit) {
+TEST(TransferTest, StructVarDeclWithInit) {
   std::string Code = R"(
 struct A {
   int Bar;
@@ -236,7 +233,7 @@
   });
 }
 
-TEST_F(TransferTest, ClassVarDecl) {
+TEST(TransferTest, ClassVarDecl) {
   std::string Code = R"(
 class A {
   int Bar;
@@ -282,7 +279,7 @@
   });
 }
 
-TEST_F(TransferTest, ReferenceVarDecl) {
+TEST(TransferTest, ReferenceVarDecl) {
   std::string Code = R"(
 struct A {};
 
@@ -318,7 +315,7 @@
   });
 }
 
-TEST_F(TransferTest, SelfReferentialReferenceVarDecl) {
+TEST(TransferTest, SelfReferentialReferenceVarDecl) {
   std::string Code = R"(
 struct A;
 
@@ -427,7 +424,7 @@
   });
 }
 
-TEST_F(TransferTest, PointerVarDecl) {
+TEST(TransferTest, PointerVarDecl) {
   std::string Code = R"(
 struct A {};
 
@@ -462,7 +459,7 @@
   });
 }
 
-TEST_F(TransferTest, SelfReferentialPointerVarDecl) {
+TEST(TransferTest, SelfReferentialPointerVarDecl) {
   std::string Code = R"(
 struct A;
 
@@ -584,7 +581,7 @@
   });
 }
 
-TEST_F(TransferTest, MultipleVarsDecl) {
+TEST(TransferTest, MultipleVarsDecl) {
   std::string Code = R"(
 void target() {
   int Foo, Bar;
@@ -622,7 +619,7 @@
   });
 }
 
-TEST_F(TransferTest

[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-06-30 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:17480
 DeclRefExpr *Ref = nullptr;
-if (!VD && !CurContext->isDependentContext())
-  Ref = buildCapture(*this, D, SimpleRefExpr, /*WithInit=*/false);
-DSAStack->addDSA(D, RefExpr->IgnoreParens(), OMPC_private, Ref);
+if (!VD && !CurContext->isDependentContext()) {
+  auto *FD = dyn_cast(D);

jyu2 wrote:
> ABataev wrote:
> > A check here not for curcontext dependent but for FD being dependent?
> I can not this to work.  Since the private copy only build under only build 
> non-dependent context. 
> 
> 
fix typo:
I can not get this to work, since the private copy only build under 
non-dependent context.



Comment at: clang/lib/Sema/TreeTransform.h:122
+  /// the RebuildME uses to set if member expression needs to be rebuilt.
+  bool RebuildME = false;
+

ABataev wrote:
> I think we don't need to add a new field here. Can instead we have a check 
> for regions with default clauses, if possible?
It seems during the TransformMemberExpr, I can not get Directives info for omp 
regions to check.  Could you give me hand? 
Thanks.  



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

https://reviews.llvm.org/D127803

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


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-06-30 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added a reviewer: Mordante.
Herald added subscribers: Enna1, abrachet, arichardson, mgorny.
Herald added a project: All.
ldionne requested review of this revision.
Herald added projects: clang, Sanitizers, libc++.
Herald added subscribers: libcxx-commits, Sanitizers, cfe-commits.
Herald added a reviewer: libc++.

This is the first part of a plan to ship experimental features
by default while guarding them behind a compiler flag to avoid
users accidentally depending on them. Subsequent patches will
also encompass incomplete features (such as  and )
in that categorization.

Note that this patch intentionally does not start guarding
existing  content behind the flag, because
that would merely break users that might be relying on such
content being in the headers unconditionally. Instead, we
should start guarding new TSes behind the flag, and get rid
of the existing TSes we have by shipping their Standard
counterpart.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128927

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/caches/Fuchsia.cmake
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libcxx/CMakeLists.txt
  libcxx/appveyor.yml
  libcxx/cmake/caches/AIX.cmake
  libcxx/cmake/caches/Apple.cmake
  libcxx/cmake/caches/Generic-no-experimental.cmake
  libcxx/cmake/caches/MinGW.cmake
  libcxx/docs/BuildingLibcxx.rst
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/UsingLibcxx.rst
  libcxx/src/CMakeLists.txt
  libcxx/test/CMakeLists.txt
  libcxx/utils/ci/run-buildbot
  libcxx/utils/libcxx/test/params.py

Index: libcxx/utils/libcxx/test/params.py
===
--- libcxx/utils/libcxx/test/params.py
+++ libcxx/utils/libcxx/test/params.py
@@ -62,6 +62,13 @@
 return '-std='+fallbacks[std]
   return None
 
+# TODO: Remove this once all the compilers we support understand `-funstable`
+def getUnstableFlag(cfg):
+  if hasCompileFlag(cfg, '-funstable'):
+return '-funstable'
+  else:
+return '-D_LIBCPP_ENABLE_EXPERIMENTAL -lc++experimental'
+
 DEFAULT_PARAMETERS = [
   Parameter(name='target_triple', type=str,
 help="The target triple to compile the test suite for. This must be "
@@ -156,15 +163,10 @@
 ])),
 
   Parameter(name='enable_experimental', choices=[True, False], type=bool, default=True,
-help="Whether to enable tests for experimental C++ libraries (typically Library Fundamentals TSes).",
+help="Whether to enable tests for experimental C++ Library features.",
 actions=lambda experimental: [] if not experimental else [
+  AddCompileFlag(getUnstableFlag),
   AddFeature('c++experimental'),
-  # When linking in MSVC mode via the Clang driver, a -l
-  # maps to .lib, so we need to use -llibc++experimental here
-  # to make it link against the static libc++experimental.lib.
-  # We can't check for the feature 'msvc' in available_features
-  # as those features are added after processing parameters.
-  PrependLinkFlag(lambda config: '-llibc++experimental' if _isMSVC(config) else '-lc++experimental')
 ]),
 
   Parameter(name='long_tests', choices=[True, False], type=bool, default=True,
Index: libcxx/utils/ci/run-buildbot
===
--- libcxx/utils/ci/run-buildbot
+++ libcxx/utils/ci/run-buildbot
@@ -517,13 +517,7 @@
 ;;
 clang-cl-dll)
 clean
-# TODO: Currently, building with the experimental library breaks running
-# tests (the test linking look for the c++experimental library with the
-# wrong name, and the statically linked c++experimental can't be linked
-# correctly when libc++ visibility attributes indicate dllimport linkage
-# anyway), thus just disable the experimental library. Remove this
-# setting when cmake and the test driver does the right thing automatically.
-generate-cmake-libcxx-win -DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF
+generate-cmake-libcxx-win
 echo "+++ Running the libc++ tests"
 ${NINJA} -vC "${BUILD_DIR}" check-cxx
 ;;
Index: libcxx/test/CMakeLists.txt
===
--- libcxx/test/CMakeLists.txt
+++ libcxx/test/CMakeLists.txt
@@ -93,10 +93,6 @@
   serialize_lit_param(enable_exceptions False)
 endif()
 
-if (NOT LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-  serialize_lit_param(enable_experimental False)
-endif()
-
 if (NOT LIBCXX_ENABLE_RTTI)
   serialize_lit_param(enable_rtti False)
 endif()
Index: libcxx/src/CMakeLists.txt
===
--- libcxx/src/CMakeLists.txt
+++ libcxx/src/CMakeLists.txt
@@ -315,25 +315,23 @@
 # Add a meta-target for both libraries.
 add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS})
 
-if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
-  set(LIBCXX_EXPERIMENTAL_SOURCES
-exp

[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

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

LGTM after addressing all of Aaron's comments.


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

https://reviews.llvm.org/D128248

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


[PATCH] D128807: [clang][transformer] Finish plumbing `Note` all the way to the output.

2022-06-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D128807#3622727 , @li.zhe.hua 
wrote:

> - A note being a part of an edit seems weird at best. An `ASTEdit` and `Edit` 
> are fragments of a greater, logical change. That a note should semantically 
> be associated with the insertion of an open paren "`(`" but not the close 
> paren "`)`" seems odd to me.
> - The note takes the location of the edit it is attached to. Perhaps that 
> could be of some convenience when those coincide, but I don't believe that 
> should necessarily be the case. I'm imagining notes could be used to point 
> out //other// parts of the source that are interesting.

Eric, these are great points. Originally, the idea for note (IIRC) came from 
the observation that sometimes a single match will generate edits in multiple 
locations, each which deserve a different diagnostic note (perhaps the same 
text, but appearing at the respective location). The intent was *not* to allow 
noting the insertion of paren, for example.  So, I think it was a mistake. Yes, 
sometimes an ASTEdit is a coherent change, but sometimes (as the paren example 
demonstrates) its just a fragment.

So, from my original intent, I think that we'd just want to support multiple 
notes per rule, with each keyed on a source range.  That said, we could decide 
to use `ASTEdit` for that purpose, assuming we're ok with `ASTEdit` with a null 
`Replacement` field. But, we'd have to think about th implications before we go 
down that route.

Clement -- what was your intended application? That may help clarify.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128807

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


[PATCH] D128927: [libc++] Always build c++experimental.a

2022-06-30 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: mstorsjo.
ldionne added a comment.

@mstorsjo I might need some assistance figuring out what to do with the Windows 
parts of this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-06-30 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/TokenKinds.def:911
 
+// Annotation for the riscv pragma directives - #pragma clang riscv intrinsic 
..
+PRAGMA_ANNOTATION(pragma_riscv)

Why only 2 periods at the end. Should be 3 like on like 908 or in the middle of 
line 903



Comment at: clang/include/clang/Sema/Sema.h:1590
 
+  /// Indicate RVV builtin funtions enabled or not.
+  bool DeclareRVVBuiltins = false;

funtion -> functions



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:110
   }
+  bool operator==(const PrototypeDescriptor &PD) const {
+return !(*this != PD);

I think it's more conventional to define operator== as `PD.PT == PT && PD.VTM 
== VTM && PD.TM == TM` and operator!= as `!(*this == PD)`



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:114
   bool operator>(const PrototypeDescriptor &PD) const {
-return !(PD.PT <= PT && PD.VTM <= VTM && PD.TM <= TM);
+if (PD.PT != PT)
+  return PD.PT > PT;

This can be written as

`return std::tie(PD.PT, PD.VTM, PD.TM) > std::tie(PT, VTM, TM);`

Though it's still surprising that PD is on the left. This is operator> but the 
implementation looks more like operator<.



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:364
+
+  // Overloaded intrinsic name, could be empty if can be computed from Name
+  // e.g. vadd

"if can" -> "if it can"



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:395
+
+  // Supported type, mask of BasicType
+  uint8_t TypeRangeMask;

Missing period at end of comment.



Comment at: clang/lib/Parse/ParsePragma.cpp:3960
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  if (!II || (!II->isStr("intrinsic"))) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)

Drop parenthese arounds `(!II->isStr("intrinsic"))`



Comment at: clang/lib/Parse/ParsePragma.cpp:3968
+  II = Tok.getIdentifierInfo();
+  if (!II || (!II->isStr("vector"))) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)

Drop parentheses around `(!II->isStr("vector"))`



Comment at: clang/lib/Sema/CMakeLists.txt:49
   SemaLookup.cpp
+  SemaRISCVVectorLookup.cpp
   SemaModule.cpp

These are supposed to be in alphabetical order



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:68
+   uint8_t Length) {
+  return ArrayRef(&RVVSignatureTable[Index], Length);
+}

Can this use makeArrayRef?



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:117
+
+  if (Type->isConstant()) {
+QT = Context.getConstType(QT);

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:122
+  // Transform the type to a pointer as the last step, if necessary.
+  if (Type->isPointer()) {
+QT = Context.getPointerType(QT);

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:262
+
+  if (IsMask) {
+Name += "_m";

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:277
+  std::string BuiltinName = "__builtin_rvv_" + std::string(Record.Name);
+  if (IsMask) {
+BuiltinName += "_m";

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:311
+  // Skip return type, and convert RVVType to QualType for arguments.
+  for (size_t i = 1; i < SigLength; ++i) {
+ArgTypes.push_back(RVVType2Qual(Context, Sigs[i]));

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:364
+auto OvIntrinsicDef = OvIItr->second;
+for (auto Index : OvIntrinsicDef.Indexs) {
+  CreateRVVIntrinsicDecl(S, LR, II, PP, Index,

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:382
+
+  // It's not RVV intrinsics.
+  return false;

"It's not an RVV intrinsic."



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:389
+   Preprocessor &PP) {
+  static std::unique_ptr IntrinsicManager =
+  std::make_unique(S.Context);

Should this be a member of Sema instead of a function static? 
RVVIntrinsicManager holds a reference to ASTContext but will outlive it.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:76
+
+  // Create compressed hsignature table from SemaRecords.
+  void init(const std::vector &SemaRecords);

Is `hsignature` a typo?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:582
+  BasicType TypeRangeMask = BasicType::Unknown

[PATCH] D128927: [libc++] Always build c++experimental.a

2022-06-30 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision.
Mordante added a comment.
This revision is now accepted and ready to land.

Thanks for working on this! LGTM with some suggestions.




Comment at: libcxx/docs/ReleaseNotes.rst:226
+  experimental features provided by it. Note that vendors are encouraged to 
ship the
+  experimental library now that the compiler provides an ergonomic way to use 
it.

I agree this is a build system change, but I wonder how many users read this 
part and find the hidden gem.
Should we add a note at new features too? Maybe there we can mention format and 
ranges are available with this new switch.
(technically that actually belongs in the next patch, but I wouldn't mind to do 
it in this patch.)



Comment at: libcxx/docs/UsingLibcxx.rst:42
+default because they are neither API nor ABI stable. However, the Clang flag 
``-funstable``
+can be used to turn those features on.
 

I think it would be good to explain what experimental features are. The current 
wording makes it sound the features may not be part of an IS, WP, or TS.

How about something like
```
Libc++ provides implementations of some experimental features. Experimental 
features
are either a TS or a feature in the Standard whose implementation is 
incomplete. Those
features are disabled by default because they are neither API nor ABI stable. 
However,
the Clang flag ``-funstable`` can be used to turn those features on.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


  1   2   >