[PATCH] D126158: [MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

2022-05-30 Thread Christian Sigg via Phabricator via cfe-commits
csigg added inline comments.



Comment at: mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp:158
+// by the same divisor.
+struct ExpandDivF16 : public ConvertOpToLLVMPattern {
+  using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;

herhut wrote:
> This pattern is a bit misplaced here, as `LLVM::FDivOp` is not really a GPU 
> dialect operation. Instead, should this be a special lowering of the arith 
> dialect to NVVM (which we do not have yet) or a rewrite at the LLVM dialect 
> level?
> 
> When lowering to LLVM, we already typically configure a different lowering 
> for math dialect, so configuring the lowering of arith dialect differently 
> seems like an OK option. That would mean a specialized pattern for 
> `arith.divf` with higher priority. That would also give users a choice.
Yes, I agree it's a bit misplaced. I considered it the best of all questionable 
options.

Adding it to ArithToLLVM doesn't really work, because we don't want it to 
depend on the NVVM dialect.

How about adding it as a separate pass to 
`mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126158

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


[clang-tools-extra] a5ddd4a - [pseudo] Remove an unnecessary nullable check diagnostic in the bnf

2022-05-30 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-05-30T09:04:47+02:00
New Revision: a5ddd4a23858044beb3c04ebc6b965760eb7c125

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

LOG: [pseudo] Remove an unnecessary nullable check diagnostic in the bnf
grammar, NFC.

This diagnostic has been handled in eliminateOptional.

Added: 


Modified: 
clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp 
b/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
index 7ca5bc1a90221..f581adb3932ef 100644
--- a/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
+++ b/clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
@@ -270,10 +270,6 @@ class GrammarBuilder {
   if (T.Rules[RID] == T.Rules[RID + 1])
 Diagnostics.push_back(
 llvm::formatv("Duplicate rule: `{0}`", G.dumpRule(RID)));
-  // Warning for nullable nonterminals
-  if (T.Rules[RID].Size == 0)
-Diagnostics.push_back(
-llvm::formatv("Rule `{0}` has a nullable RHS", G.dumpRule(RID)));
 }
 // symbol-id -> used counts
 std::vector UseCounts(T.Nonterminals.size(), 0);



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


[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-30 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D124690#3542961 , @nridge wrote:

> I would try using getPointeeTypeAsWritten() 
> 
>  instead and see if that helps.

Indeed, this change makes two tests (VariadicPlainNewConstructor and 
VariadicForwardedNewConstructor) pass. I assume the other failures are due to 
other issues in the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

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


[PATCH] D126633: [pseudo] Use the pseudoCXX library in fuzzer.

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

Get rid of the tedious grammar command-flag handling, and simply the
code.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126633

Files:
  clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp


Index: clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
===
--- clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
+++ clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
@@ -12,6 +12,7 @@
 #include "clang-pseudo/Grammar.h"
 #include "clang-pseudo/LRTable.h"
 #include "clang-pseudo/Token.h"
+#include "clang-pseudo/cxx/CXX.h"
 #include "clang/Basic/LangOptions.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -24,28 +25,10 @@
 
 class Fuzzer {
   clang::LangOptions LangOpts = clang::pseudo::genericLangOpts();
-  std::unique_ptr G;
-  LRTable T;
   bool Print;
 
 public:
-  Fuzzer(llvm::StringRef GrammarPath, bool Print) : Print(Print) {
-llvm::ErrorOr> GrammarText =
-llvm::MemoryBuffer::getFile(GrammarPath);
-if (std::error_code EC = GrammarText.getError()) {
-  llvm::errs() << "Error: can't read grammar file '" << GrammarPath
-   << "': " << EC.message() << "\n";
-  std::exit(1);
-}
-std::vector Diags;
-G = Grammar::parseBNF(GrammarText->get()->getBuffer(), Diags);
-if (!Diags.empty()) {
-  for (const auto &Diag : Diags)
-llvm::errs() << Diag << "\n";
-  std::exit(1);
-}
-T = LRTable::buildSLR(*G);
-  }
+  Fuzzer(bool Print) : Print(Print) {}
 
   void operator()(llvm::StringRef Code) {
 std::string CodeStr = Code.str(); // Must be null-terminated.
@@ -58,11 +41,13 @@
 
 clang::pseudo::ForestArena Arena;
 clang::pseudo::GSS GSS;
+const auto &G = cxx::getGrammar();
+const LRTable &T = cxx::getLRTable();
 auto &Root =
-glrParse(ParseableStream, clang::pseudo::ParseParams{*G, T, Arena, 
GSS},
- *G->findNonterminal("translation-unit"));
+glrParse(ParseableStream, clang::pseudo::ParseParams{G, T, Arena, GSS},
+ static_cast(cxx::Symbol::translation_unit));
 if (Print)
-  llvm::outs() << Root.dumpRecursive(*G);
+  llvm::outs() << Root.dumpRecursive(G);
   }
 };
 
@@ -78,13 +63,9 @@
 //  -grammar= (required) - path to cxx.bnf
 //  -print - used for testing the fuzzer
 int LLVMFuzzerInitialize(int *Argc, char ***Argv) {
-  llvm::StringRef GrammarFile;
   bool PrintForest = false;
   auto ConsumeArg = [&](llvm::StringRef Arg) -> bool {
-if (Arg.consume_front("-grammar=")) {
-  GrammarFile = Arg;
-  return true;
-} else if (Arg == "-print") {
+if (Arg == "-print") {
   PrintForest = true;
   return true;
 }
@@ -92,11 +73,7 @@
   };
   *Argc = std::remove_if(*Argv + 1, *Argv + *Argc, ConsumeArg) - *Argv;
 
-  if (GrammarFile.empty()) {
-fprintf(stderr, "Fuzzer needs -grammar=/path/to/cxx.bnf\n");
-exit(1);
-  }
-  clang::pseudo::Fuzz = new clang::pseudo::Fuzzer(GrammarFile, PrintForest);
+  clang::pseudo::Fuzz = new clang::pseudo::Fuzzer(PrintForest);
   return 0;
 }
 
Index: clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
===
--- clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
+++ clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
@@ -11,5 +11,6 @@
 target_link_libraries(clang-pseudo-fuzzer
   PRIVATE
   clangPseudo
+  clangPseudoCXX
   clangPseudoGrammar
   )


Index: clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
===
--- clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
+++ clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
@@ -12,6 +12,7 @@
 #include "clang-pseudo/Grammar.h"
 #include "clang-pseudo/LRTable.h"
 #include "clang-pseudo/Token.h"
+#include "clang-pseudo/cxx/CXX.h"
 #include "clang/Basic/LangOptions.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -24,28 +25,10 @@
 
 class Fuzzer {
   clang::LangOptions LangOpts = clang::pseudo::genericLangOpts();
-  std::unique_ptr G;
-  LRTable T;
   bool Print;
 
 public:
-  Fuzzer(llvm::StringRef GrammarPath, bool Print) : Print(Print) {
-llvm::ErrorOr> GrammarText =
-llvm::MemoryBuffer::getFile(GrammarPath);
-if (std::error_code EC = GrammarText.getError()) {
-  llvm::errs() << "Error: can't read grammar file '" << GrammarPath
-   << "': " << EC.message() << "\n";
-  std::exit(1);
-}
-std::vector Diags;
-G = Grammar::parseBNF(GrammarText->get()->getBuffer(), Diags);
-if (!Diags.empty()) {
-  for (const auto &Diag : Diags)
-llvm::errs() << Diag << "\n";
-  std::exit(1);
-}

[PATCH] D126634: [RISCV][NFC] Rename variables in rvv intrinsics related files.

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

This patch does the same thing as D125886  
did.

- Use `Overloaded` rather than `Mangled`.
- Use `Prototype` or `Desc` rather than `Seq`, it's not just a string

sequence.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126634

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

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -155,10 +155,10 @@
   OS << ");\n";
 }
 
-void emitMangledFuncDef(const RVVIntrinsic &RVVI, raw_ostream &OS) {
+void emitOverloadedFuncDef(const RVVIntrinsic &RVVI, raw_ostream &OS) {
   OS << "__attribute__((__clang_builtin_alias__(";
   OS << "__builtin_rvv_" << RVVI.getBuiltinName() << ")))\n";
-  OS << RVVI.getOutputType()->getTypeStr() << " " << RVVI.getMangledName()
+  OS << RVVI.getOutputType()->getTypeStr() << " " << RVVI.getOverloadedName()
  << "(";
   // Emit function arguments
   const RVVTypes &InputTypes = RVVI.getInputTypes();
@@ -289,7 +289,7 @@
 if (!Inst.isMasked() && !Inst.hasUnMaskedOverloaded())
   return;
 OS << "__rvv_aio ";
-emitMangledFuncDef(Inst, OS);
+emitOverloadedFuncDef(Inst, OS);
   });
 
   OS << "#undef __rvv_aio\n";
@@ -387,8 +387,8 @@
   for (auto *R : RV) {
 StringRef Name = R->getValueAsString("Name");
 StringRef SuffixProto = R->getValueAsString("Suffix");
-StringRef OverloadedName = R->getValueAsString("MangledName");
-StringRef OverloadedSuffixProto = R->getValueAsString("MangledSuffix");
+StringRef OverloadedName = R->getValueAsString("OverloadedName");
+StringRef OverloadedSuffixProto = R->getValueAsString("OverloadedSuffix");
 StringRef Prototypes = R->getValueAsString("Prototype");
 StringRef TypeRange = R->getValueAsString("TypeRange");
 bool HasMasked = R->getValueAsBit("HasMasked");
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -791,13 +791,13 @@
 
 Optional
 RVVType::computeTypes(BasicType BT, int Log2LMUL, unsigned NF,
-  ArrayRef PrototypeSeq) {
+  ArrayRef Prototype) {
   // LMUL x NF must be less than or equal to 8.
   if ((Log2LMUL >= 1) && (1 << Log2LMUL) * NF > 8)
 return llvm::None;
 
   RVVTypes Types;
-  for (const PrototypeDescriptor &Proto : PrototypeSeq) {
+  for (const PrototypeDescriptor &Proto : Prototype) {
 auto T = computeType(BT, Log2LMUL, Proto);
 if (!T.hasValue())
   return llvm::None;
@@ -847,8 +847,8 @@
 // RVVIntrinsic implementation
 //===--===//
 RVVIntrinsic::RVVIntrinsic(
-StringRef NewName, StringRef Suffix, StringRef NewMangledName,
-StringRef MangledSuffix, StringRef IRName, bool IsMasked,
+StringRef NewName, StringRef Suffix, StringRef NewOverloadedName,
+StringRef OverloadedSuffix, StringRef IRName, bool IsMasked,
 bool HasMaskedOffOperand, bool HasVL, PolicyScheme Scheme,
 bool HasUnMaskedOverloaded, bool HasBuiltinAlias, StringRef ManualCodegen,
 const RVVTypes &OutInTypes, const std::vector &NewIntrinsicTypes,
@@ -858,17 +858,17 @@
   HasBuiltinAlias(HasBuiltinAlias), ManualCodegen(ManualCodegen.str()),
   NF(NF) {
 
-  // Init BuiltinName, Name and MangledName
+  // Init BuiltinName, Name and OverloadedName
   BuiltinName = NewName.str();
   Name = BuiltinName;
-  if (NewMangledName.empty())
-MangledName = NewName.split("_").first.str();
+  if (NewOverloadedName.empty())
+OverloadedName = NewName.split("_").first.str();
   else
-MangledName = NewMangledName.str();
+OverloadedName = NewOverloadedName.str();
   if (!Suffix.empty())
 Name += "_" + Suffix.str();
-  if (!MangledSuffix.empty())
-MangledName += "_" + MangledSuffix.str();
+  if (!OverloadedSuffix.empty())
+OverloadedName += "_" + OverloadedSuffix.str();
   if (IsMasked) {
 BuiltinName += "_m";
 Name += "_m";
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===

[PATCH] D126479: [Clang] Allow 'Complex float __attribute__((mode(HC)))'

2022-05-30 Thread mgabka via Phabricator via cfe-commits
mgabka added inline comments.



Comment at: clang/test/CodeGen/aarch64-attr-mode-complex.c:11
+// CHECK: define{{.*}} { half, half } @c16_test([2 x half] noundef 
[[C16A:%.*]])
+// CHECK-NEXT: entry:
+// CHECK-NEXT:   [[C16B:%.*]] = extractvalue [2 x half] [[C16A]], 0

Hi Jolanta,
I the tests from this file, I don't think these check lines are necessary, if 
it was me I would rather check only the type of the argument passed into the 
function and also the return type.
If you did it like that you could also remove the -Ofast from the RUN lines, as 
it does not have impact on the functionality you are testing here.




Comment at: clang/test/Sema/attr-mode.c:40
 
+typedef _Complex float c16a __attribute((mode(HC)));
+int c16a_test[sizeof(c16a) == 4 ? 1 : -1];

shouldn't we have here and in the line below : "// expected-no-diagnostics" ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126479

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


[PATCH] D126186: [clang-tidy] Extend cert-oop57-cpp to check non-zero memset values

2022-05-30 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 432866.
gamesh411 added a comment.

fix Release Notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126186

Files:
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -88,3 +88,10 @@
   mymemcmp(&Data, &Other, sizeof(Data));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison 
operators instead of calling 'mymemcmp'
 }
+
+void nonNullSetValue() {
+  NonTrivial Data;
+  // Check non-null-valued second argument.
+  std::memset(&Data, 1, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a 
non-trivially default constructible class is undefined
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -152,6 +152,9 @@
   ` when `sizeof(...)` is
   compared against a `__int128_t`.
 
+- Made :doc:`cert-oop57-cpp ` more sensitive
+  by checking for non-zero integer literal `memset` arguments as well.
+
 - Improved :doc:`cppcoreguidelines-prefer-member-initializer
   ` check.
 
Index: clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
@@ -90,7 +90,7 @@
   callExpr(callee(namedDecl(hasAnyName(
utils::options::parseListPair(BuiltinMemSet, 
MemSetNames,
ArgChecker(unless(isTriviallyDefaultConstructible()),
-  expr(integerLiteral(equals(0)
+  expr(integerLiteral(
   .bind("lazyConstruct"),
   this);
   Finder->addMatcher(


Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -88,3 +88,10 @@
   mymemcmp(&Data, &Other, sizeof(Data));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'mymemcmp'
 }
+
+void nonNullSetValue() {
+  NonTrivial Data;
+  // Check non-null-valued second argument.
+  std::memset(&Data, 1, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -152,6 +152,9 @@
   ` when `sizeof(...)` is
   compared against a `__int128_t`.
 
+- Made :doc:`cert-oop57-cpp ` more sensitive
+  by checking for non-zero integer literal `memset` arguments as well.
+
 - Improved :doc:`cppcoreguidelines-prefer-member-initializer
   ` check.
 
Index: clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
@@ -90,7 +90,7 @@
   callExpr(callee(namedDecl(hasAnyName(
utils::options::parseListPair(BuiltinMemSet, MemSetNames,
ArgChecker(unless(isTriviallyDefaultConstructible()),
-  expr(integerLiteral(equals(0)
+  expr(integerLiteral(
   .bind("lazyConstruct"),
   this);
   Finder->addMatcher(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126451: [Clang][CSKY] Add support about CSKYABIInfo

2022-05-30 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett accepted this revision.
DavidSpickett added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D126451

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


[PATCH] D126186: [clang-tidy] Extend cert-oop57-cpp to check non-zero memset values

2022-05-30 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 updated this revision to Diff 432868.
gamesh411 added a comment.

Remove literal checking from the matcher for memset as well

There is no change in the result set on open source projects even without
restricting the matches to literals.

IMO this is more in line with the rule as it's written as @aaron.ballman 
mentioned.

Updated the ReleaseNotes to reflect this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126186

Files:
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -88,3 +88,17 @@
   mymemcmp(&Data, &Other, sizeof(Data));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison 
operators instead of calling 'mymemcmp'
 }
+
+void nonNullSetValue() {
+  NonTrivial Data;
+  // Check non-null-valued second argument.
+  std::memset(&Data, 1, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a 
non-trivially default constructible class is undefined
+}
+
+void nonLiteralSetValue(char C) {
+  NonTrivial Data;
+  // Check non-literal second argument.
+  std::memset(&Data, C, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a 
non-trivially default constructible class is undefined
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -156,6 +156,9 @@
   ` when `sizeof(...)` is
   compared against a `__int128_t`.
 
+- Made :doc:`cert-oop57-cpp ` more sensitive
+  by checking for an arbitrary expression in the second argument of `memset`.
+
 - Improved :doc:`cppcoreguidelines-prefer-member-initializer
   ` check.
 
Index: clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
===
--- clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
+++ clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
@@ -80,7 +80,7 @@
   auto IsRecordSizeOf =
   expr(sizeOfExpr(hasArgumentOfType(equalsBoundNode("Record";
   auto ArgChecker = [&](Matcher RecordConstraint,
-BindableMatcher SecondArg) {
+BindableMatcher SecondArg = expr()) {
 return allOf(argumentCountIs(3),
  hasArgument(0, IsStructPointer(RecordConstraint, true)),
  hasArgument(1, SecondArg), hasArgument(2, IsRecordSizeOf));
@@ -89,8 +89,7 @@
   Finder->addMatcher(
   callExpr(callee(namedDecl(hasAnyName(
utils::options::parseListPair(BuiltinMemSet, 
MemSetNames,
-   ArgChecker(unless(isTriviallyDefaultConstructible()),
-  expr(integerLiteral(equals(0)
+   ArgChecker(unless(isTriviallyDefaultConstructible(
   .bind("lazyConstruct"),
   this);
   Finder->addMatcher(


Index: clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cert-oop57-cpp.cpp
@@ -88,3 +88,17 @@
   mymemcmp(&Data, &Other, sizeof(Data));
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: consider using comparison operators instead of calling 'mymemcmp'
 }
+
+void nonNullSetValue() {
+  NonTrivial Data;
+  // Check non-null-valued second argument.
+  std::memset(&Data, 1, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+}
+
+void nonLiteralSetValue(char C) {
+  NonTrivial Data;
+  // Check non-literal second argument.
+  std::memset(&Data, C, sizeof(Data));
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: calling 'memset' on a non-trivially default constructible class is undefined
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -156,6 +156,9 @@
   ` when `sizeof(...)` is
   compared against a `__int128_t`.
 
+- Made :doc:`cert-oop57-cpp ` more sensitive
+  by checking for an arbitrary expression in the second argument of `memset`.
+
 - Improved :doc:`cppcoreguidelines-prefer-member-initializer
   ` check.
 
Index: clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
==

[PATCH] D116638: [clang-format] Fix ignoring JavaScriptWrapImport when ColumnWidth: 0

2022-05-30 Thread Stanisław Małolepszy via Phabricator via cfe-commits
stasm added a comment.
Herald added a project: All.

I'm still interested in seeing this fixed. Would it help if I rebased this 
change and addressed the outstanding review comments?


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

https://reviews.llvm.org/D116638

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


[PATCH] D126634: [RISCV][NFC] Rename variables in rvv intrinsics related files.

2022-05-30 Thread Yeting Kuo via Phabricator via cfe-commits
fakepaper56 added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126634

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


[PATCH] D126158: [MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

2022-05-30 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 432871.
csigg added a comment.

Rebase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126158

Files:
  mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
  mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
  mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
  mlir/test/Dialect/LLVMIR/nvvm.mlir
  mlir/test/Target/LLVMIR/nvvmir.mlir

Index: mlir/test/Target/LLVMIR/nvvmir.mlir
===
--- mlir/test/Target/LLVMIR/nvvmir.mlir
+++ mlir/test/Target/LLVMIR/nvvmir.mlir
@@ -33,6 +33,13 @@
   llvm.return %1 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+llvm.func @nvvm_rcp(%0: f32) -> f32 {
+  // CHECK: call float @llvm.nvvm.rcp.approx.ftz.f
+  %1 = nvvm.rcp.approx.ftz.f %0 : f32
+  llvm.return %1 : f32
+}
+
 // CHECK-LABEL: @llvm_nvvm_barrier0
 llvm.func @llvm_nvvm_barrier0() {
   // CHECK: call void @llvm.nvvm.barrier0()
Index: mlir/test/Dialect/LLVMIR/nvvm.mlir
===
--- mlir/test/Dialect/LLVMIR/nvvm.mlir
+++ mlir/test/Dialect/LLVMIR/nvvm.mlir
@@ -29,6 +29,13 @@
   llvm.return %0 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+func.func @nvvm_rcp(%arg0: f32) -> f32 {
+  // CHECK: nvvm.rcp.approx.ftz.f %arg0 : f32
+  %0 = nvvm.rcp.approx.ftz.f %arg0 : f32
+  llvm.return %0 : f32
+}
+
 // CHECK-LABEL: @llvm_nvvm_barrier0
 func.func @llvm_nvvm_barrier0() {
   // CHECK: nvvm.barrier0
Index: mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
===
--- mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
+++ mlir/test/Conversion/GPUToNVVM/gpu-to-nvvm.mlir
@@ -488,3 +488,30 @@
   }
 }
 
+// -
+
+gpu.module @test_module {
+  // CHECK-LABEL: func @gpu_divf_fp16
+  func.func @gpu_divf_fp16(%arg0 : f16, %arg1 : f16) -> f16 {
+// CHECK: %[[lhs:.*]] = llvm.fpext %arg0 : f16 to f32
+// CHECK: %[[rhs:.*]] = llvm.fpext %arg1 : f16 to f32
+// CHECK: %[[rcp:.*]] = nvvm.rcp.approx.ftz.f %1 : f32
+// CHECK: %[[approx:.*]]  = llvm.fmul %[[lhs]], %[[rcp]] : f32
+// CHECK: %[[neg:.*]] = llvm.fneg %[[rhs]] : f32
+// CHECK: %[[err:.*]] = "llvm.intr.fma"(%[[approx]], %[[neg]], %[[lhs]]) : (f32, f32, f32) -> f32
+// CHECK: %[[refined:.*]] = "llvm.intr.fma"(%[[err]], %[[rcp]], %[[approx]]) : (f32, f32, f32) -> f32
+// CHECK: %[[mask:.*]]= llvm.mlir.constant(2139095040 : ui32) : i32
+// CHECK: %[[cast:.*]]= llvm.bitcast %[[approx]] : f32 to i32
+// CHECK: %[[exp:.*]] = llvm.and %[[cast]], %[[mask]] : i32
+// CHECK: %[[c0:.*]]  = llvm.mlir.constant(0 : ui32) : i32
+// CHECK: %[[is_zero:.*]] = llvm.icmp "eq" %[[exp]], %[[c0]] : i32
+// CHECK: %[[is_mask:.*]] = llvm.icmp "eq" %[[exp]], %[[mask]] : i32
+// CHECK: %[[pred:.*]]= llvm.or %[[is_zero]], %[[is_mask]] : i1
+// CHECK: %[[select:.*]]  = llvm.select %[[pred]], %[[approx]], %[[refined]] : i1, f32
+// CHECK: %[[result:.*]]  = llvm.fptrunc %[[select]] : f32 to f16
+%result = arith.divf %arg0, %arg1 : f16
+// CHECK: llvm.return %[[result]] : f16
+func.return %result : f16
+  }
+}
+
Index: mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
===
--- mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -148,6 +148,62 @@
   }
 };
 
+// Replaces fdiv on fp16 with fp32 multiplication with reciprocal plus one
+// (conditional) Newton iteration.
+//
+// This as accurate as promoting the division to fp32 in the NVPTX backend, but
+// faster because it performs less Newton iterations, avoids the slow path
+// for e.g. denormals, and allows reuse of the reciprocal for multiple divisions
+// by the same divisor.
+struct ExpandDivF16 : public ConvertOpToLLVMPattern {
+  using ConvertOpToLLVMPattern::ConvertOpToLLVMPattern;
+
+private:
+  LogicalResult
+  matchAndRewrite(LLVM::FDivOp op, LLVM::FDivOp::Adaptor adaptor,
+  ConversionPatternRewriter &rewriter) const override {
+if (!op.getType().isF16())
+  return rewriter.notifyMatchFailure(op, "not f16");
+Location loc = op.getLoc();
+
+Type f32Type = rewriter.getF32Type();
+Type i32Type = rewriter.getI32Type();
+
+// Extend lhs and rhs to fp32.
+Value lhs = rewriter.create(loc, f32Type, adaptor.getLhs());
+Value rhs = rewriter.create(loc, f32Type, adaptor.getRhs());
+
+// float rcp = rcp.approx.ftz.f32(rhs), approx = lhs * rcp.
+Value rcp = rewriter.create(loc, f32Type, rhs);
+Value approx = rewriter.create(loc, lhs, rcp);
+
+// Refine the approximation with one Newton iteration:
+// float refined = approx + (lhs - approx * rhs) * rcp;
+Value err = rewriter.create(
+loc, approx, rewriter.create(loc, rhs), lhs);
+Value refined = rewriter.create(loc, err, r

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

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

Thank you all for your comments and apologies for going radio silent - I was 
away for a few days.

I've identified 2 threads emerging from your comments:

**1. flang vs flang-new**
@sscalpone, if I understand correctly, you are suggesting that any tool named 
`flang` in "LLVM Flang" should satisfy the following condition:

> 2. For all tests with unsupported features, the compiler must issues an error 
> message and the message references the source-location of the unsupported 
> feature

Indeed, `flang-new` does not satisfy this yet, but neither does `flang`, the 
bash wrapper script. `flang`, the bash script, calls `flang-new` to run parsing 
and semantic analysis. Basically, it's the same Fortran frontend as far as 
these initial phases are concerned. So, if "LLVM Flang" is missing diagnostics 
for e.g. unsupported language features, both `flang` and `flang-new` will fail 
to report these. I don't see how defaulting to `flang` (the bash script) 
instead of `flang-new` (the compiler driver) helps here.

Put differently, if the above condition is to be considered a requirement for 
any tool called `flang`, then the bash wrapper script should be renamed as it 
does not satisfy it.

**2. NAG test suite**
From what I recall, we did discuss renaming `flang-new` as `flang` in the past 
and it was decided that we would wait for `flang-new` to be able to generate 
executables. I couldn't find this written down, so perhaps I'm misremembering? 
In any case, I don't follow why a test-suite conformance should determine what 
name is used for a compiler driver in "LLVM Flang". We should definitely work 
towards 100% pass rate, but to me that's orthogonal to how our tools are 
called. The level of Language support in "LLVM Flang"  should be communicated 
through the documentation (including release notes) instead of misleading tool 
names.

As for NAG test-suite specifically:

> My preference is to use the NAG test suite.   It is not freely available.

If we take this path, we will effectively be introducing yet another dependency 
on an external project in "LLVM Flang" (libpgmath 
 being 
the first one). While most (perhaps all?) salaried "LLVM Flang" developers will 
have access to the NAG test suite, community volunteers will effectively have 
their ability to contribute severely limited. I'm against this, but also don't 
have a counter-proposal (I'm not aware of any freely accessible Fortran test 
suites that we could use here).

@peixin, you raised some really good points, thank you! I agree that even if it 
is decided that the NAG test suite is used as the benchmark for "LLVM Flang", 
it's still unclear how to deal with all these tricky corner cases (there will 
be platform dependencies too). As for the following one:

> 5. Are the rules also applied to Fortran 2003, 2008 and 2018 code, or only 
> restricted to Fortran 95 code?

I think that we should limit ourselves to Fortran 95 for now - there's no 
code-gen support beyond that.

**NEXT STEPS**
Based on the above, how would you feel about the following:

1. Lets rename `flang` as `flang-to-external-fc` regardless of what's decided 
for `flang-new`. That would already be a huge step forward (and would reflect 
accurately what the bash wrapper script actually does).
2. As for the NAG test suite, I hope that we can agree not to use it as the 
condition for renaming `flang-new`. If it's decided that that's a valid 
requirement, then I agree with @kiranchandramohan that we should find a way to 
openly track the progress towards the required pass rate (and how that's 
defined).

Perhaps we could discuss more in the call today?


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


[clang] a5cf17f - [OpenCL] Expose wg collective functions for CL3 SPIR targets

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

Author: Sven van Haastregt
Date: 2022-05-30T10:48:49+01:00
New Revision: a5cf17f8ae752f1b62b40b907bfee4faa3600b21

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

LOG: [OpenCL] Expose wg collective functions for CL3 SPIR targets

Since the SPIR/SPIR-V targets enable all known features, we must
ensure the Work-group Collective Functions feature macro is set for
OpenCL 3.0.

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 20048d97bc74..c433b4f7eb1a 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -68,6 +68,7 @@
 #if (__OPENCL_CPP_VERSION__ == 202100 || __OPENCL_C_VERSION__ == 300)
 // For the SPIR and SPIR-V target all features are supported.
 #if defined(__SPIR__) || defined(__SPIRV__)
+#define __opencl_c_work_group_collective_functions 1
 #define __opencl_c_atomic_order_seq_cst 1
 #define __opencl_c_atomic_scope_device 1
 #define __opencl_c_atomic_scope_all_devices 1



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


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-05-30 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added a comment.

In D126481#3542919 , @ASDenysPetrov 
wrote:

> @martong As you said, my solution D103096  
> suppose to pass these and more other tests cases. So how it will help in 
> combination with my solution D103096 ? 
> Although, your patch is really simple but it's more like a plug then a real 
> `SymbolCast ` support, isn't it? I don't quite understand the motivation.

This part of the SValBuilder is responsible for **constant folding**. We need 
this constant folding, so the engine can work with less symbols, this way it 
can be more efficient. Whenever a symbol is constrained with a constant then we 
substitute the symbol with the corresponding integer. If a symbol is 
constrained with a range, then the symbol is kept and we fall-back to use the 
range based constraint manager, which is not that efficient. This patch is the 
natural extension of the existing constant folding machinery with the support 
of `SymbolCast` symbols.




Comment at: clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:1354
+return I->second;
+  const SymExpr *OpSym = S->getOperand();
+  SVal OpVal = getConstOrVisit(OpSym);

ASDenysPetrov wrote:
> Should this imply to use the root symbol and not the second nested one?
> E.g. from `(int)(short)(x)` do you want `(short)(x)` or `(x)`?
> `getOperand` gives you `(short)(x)` in this case.
We need the operand, with your words it is the second nested one, not the root. 
In case of `(int)(short)(x)` we need the `(short)(x)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


[PATCH] D126364: Fix interaction of pragma FENV_ACCESS with other pragmas

2022-05-30 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D126364#3542917 , @efriedma wrote:

> I mean that ActOnPragmaFEnvAccess shouldn't call 
> hasRoundingModeOverride()/setRoundingModeOverride(), and setRoundingMode 
> shouldn't call getAllowFEnvAccess().

setRoundingMode definitely should not call getAllowFEnvAccess() and it does 
not. As for ActOnPragmaFEnvAccess, it make sense to set the most general mode. 
Code like:

  {
  #pragma STDC FENV_ACCESS ON
  fesetround(x);
  ...
  }

must work as is, and it requires that operations are created with dynamic 
rounding mode.

If a user wants to have more specific mode, they can amend FENV_ACCESS with 
other pragmas, like FENV_ROUND or `clang fp exceptions`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126364

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


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

2022-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 432876.
pmatos added a comment.

Rebased the work on D126535 . Added support 
for funcrefs as return values.
Still having problems with funcrefs as function arguments though. So, further 
work is required.
Not ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/WebAssembly/wasm-funcref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -404,11 +404,17 @@
 }
 
 //===--===//
-// The following functions are called from lib/CodeGen/Passes.cpp to modify
-// the CodeGen pass sequence.
+// The following functions are called from lib/CodeGen/TargetPassConfig.cpp
+// to modify the CodeGen pass sequence.
 //===--===//
 
 void WebAssemblyPassConfig::addIRPasses() {
+  // Run mem2reg to remove alloca references - needed for reference types
+  // FIXME: this should only be added when the subtarget has reference types 
+  // enabled but the subtarget is dependent on the function being compiled to 
+  // which we don't have access atm.
+  addPass(createPromoteMemoryToRegisterPass());
+
   // Add signatures to prototype-less function declarations
   addPass(createWebAssemblyAddMissingPrototypes());
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -304,6 +304,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext &C) {
+  // pointer to opaque struct in addrspace(10)
+  static PointerType *Ty = PointerType::get(StructType::get(C), 10);
+  return Ty;
+}
+
+Type *Type::getWasm_FuncrefTy(LLVMContext &C) {
+  // pointer to i8 addrspace(20)
+  static PointerType *Ty = PointerType::get(Type::getInt8Ty(C), 20);
+  return Ty;
+}
+
 //===--===//
 //   IntegerType Implementation
 //===--===//
Index: llvm/lib/CodeGen/ValueTypes.cpp
===
--- llvm/lib/CodeGen/ValueTypes.cpp
+++ llvm/lib/CodeGen/ValueTypes.cpp
@@ -201,12 +201,8 @@
   case MVT::x86mmx:  return Type::getX86_MMXTy(Context);
   case MVT::x86amx:  return Type::getX86_AMXTy(Context);
   case MVT::i64x8:   return IntegerType::get(Context, 512);
-  case MVT::externref:
-// pointer to opaque struct in addrspace(10)
-return PointerType::get(StructType::create(Context), 10);
-  case MVT::funcref:
-// pointer to i8 addrspace(20)
-return PointerTyp

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

2022-05-30 Thread Paulo Matos via Phabricator via cfe-commits
pmatos planned changes to this revision.
pmatos added a comment.

Still need to implement funcrefs support as function arguments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

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


[PATCH] D126308: cmake: use llvm dir variables for clang/utils/hmaptool

2022-05-30 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

It looks like this change breaks the standalone build for clang. From what I 
can see, while LLVM_TOOLS_BINARY_DIR and LLVM_TOOLS_INSTALL_DIR are exported in 
llvm/cmake/modules/LLVMConfig.cmake.in, LLVM_UTILS_INSTALL_DIR is not, 
resulting in an "install PROGRAMS given no DESTINATION" error. Presumably we 
either need to export that variable, or it's not intended to be used outside 
LLVM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126308

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


[PATCH] D126158: [MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

2022-05-30 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 432880.
csigg added a comment.
Herald added a subscriber: mgorny.

Make fdiv rewrite an NVVM transform pass instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126158

Files:
  mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
  mlir/include/mlir/Dialect/LLVMIR/Transforms/OptimizeNVVM.h
  mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
  mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
  mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
  mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
  mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
  mlir/test/Dialect/LLVMIR/nvvm.mlir
  mlir/test/Target/LLVMIR/nvvmir.mlir
  utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -3373,7 +3373,9 @@
 ":IR",
 ":LLVMDialect",
 ":LLVMPassIncGen",
+":NVVMDialect",
 ":Pass",
+":Transforms",
 ],
 )
 
Index: mlir/test/Target/LLVMIR/nvvmir.mlir
===
--- mlir/test/Target/LLVMIR/nvvmir.mlir
+++ mlir/test/Target/LLVMIR/nvvmir.mlir
@@ -32,6 +32,14 @@
   llvm.return %1 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+llvm.func @nvvm_rcp(%0: f32) -> f32 {
+  // CHECK: call float @llvm.nvvm.rcp.approx.ftz.f
+  %1 = nvvm.rcp.approx.ftz.f %0 : f32
+  llvm.return %1 : f32
+}
+
+// CHECK-LABEL: @llvm_nvvm_barrier0
 llvm.func @llvm_nvvm_barrier0() {
   // CHECK: call void @llvm.nvvm.barrier0()
   nvvm.barrier0
Index: mlir/test/Dialect/LLVMIR/nvvm.mlir
===
--- mlir/test/Dialect/LLVMIR/nvvm.mlir
+++ mlir/test/Dialect/LLVMIR/nvvm.mlir
@@ -28,6 +28,14 @@
   llvm.return %0 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+func.func @nvvm_rcp(%arg0: f32) -> f32 {
+  // CHECK: nvvm.rcp.approx.ftz.f %arg0 : f32
+  %0 = nvvm.rcp.approx.ftz.f %arg0 : f32
+  llvm.return %0 : f32
+}
+
+// CHECK-LABEL: @llvm_nvvm_barrier0
 func.func @llvm.nvvm.barrier0() {
   // CHECK: nvvm.barrier0
   nvvm.barrier0
Index: mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
===
--- /dev/null
+++ mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
@@ -0,0 +1,24 @@
+// RUN: mlir-opt %s -nvvm-optimize | FileCheck %s
+
+// CHECK-LABEL: llvm.func @fdiv_fp16
+llvm.func @fdiv_fp16(%arg0 : f16, %arg1 : f16) -> f16 {
+  // CHECK-DAG: %[[c0:.*]]  = llvm.mlir.constant(0 : ui32) : i32
+  // CHECK-DAG: %[[mask:.*]]= llvm.mlir.constant(2139095040 : ui32) : i32
+  // CHECK-DAG: %[[lhs:.*]] = llvm.fpext %arg0 : f16 to f32
+  // CHECK-DAG: %[[rhs:.*]] = llvm.fpext %arg1 : f16 to f32
+  // CHECK-DAG: %[[rcp:.*]] = nvvm.rcp.approx.ftz.f %[[rhs]] : f32
+  // CHECK-DAG: %[[approx:.*]]  = llvm.fmul %[[lhs]], %[[rcp]] : f32
+  // CHECK-DAG: %[[neg:.*]] = llvm.fneg %[[rhs]] : f32
+  // CHECK-DAG: %[[err:.*]] = "llvm.intr.fma"(%[[approx]], %[[neg]], %[[lhs]]) : (f32, f32, f32) -> f32
+  // CHECK-DAG: %[[refined:.*]] = "llvm.intr.fma"(%[[err]], %[[rcp]], %[[approx]]) : (f32, f32, f32) -> f32
+  // CHECK-DAG: %[[cast:.*]]= llvm.bitcast %[[approx]] : f32 to i32
+  // CHECK-DAG: %[[exp:.*]] = llvm.and %[[cast]], %[[mask]] : i32
+  // CHECK-DAG: %[[is_zero:.*]] = llvm.icmp "eq" %[[exp]], %[[c0]] : i32
+  // CHECK-DAG: %[[is_mask:.*]] = llvm.icmp "eq" %[[exp]], %[[mask]] : i32
+  // CHECK-DAG: %[[pred:.*]]= llvm.or %[[is_zero]], %[[is_mask]] : i1
+  // CHECK-DAG: %[[select:.*]]  = llvm.select %[[pred]], %[[approx]], %[[refined]] : i1, f32
+  // CHECK-DAG: %[[result:.*]]  = llvm.fptrunc %[[select]] : f32 to f16
+  %result = llvm.fdiv %arg0, %arg1 : f16
+  // CHECK: llvm.return %[[result]] : f16
+  llvm.return %result : f16
+}
Index: mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
===
--- /dev/null
+++ mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
@@ -0,0 +1,99 @@
+//===- OptimizeNVVM.cpp - Optimize NVVM IR -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "mlir/Dialect/LLVMIR/Transforms/OptimizeNVVM.h"
+#include "PassDetail.h"
+#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
+#include "mlir/IR/Block.h"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+// Replaces fdiv on fp16 with fp32 multiplication with reciprocal plus one
+

[PATCH] D126158: [MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

2022-05-30 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 432881.
csigg added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126158

Files:
  mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
  mlir/include/mlir/Dialect/LLVMIR/Transforms/OptimizeNVVM.h
  mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
  mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
  mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
  mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
  mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
  mlir/test/Dialect/LLVMIR/nvvm.mlir
  mlir/test/Target/LLVMIR/nvvmir.mlir
  utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -3374,7 +3374,9 @@
 ":IR",
 ":LLVMDialect",
 ":LLVMPassIncGen",
+":NVVMDialect",
 ":Pass",
+":Transforms",
 ],
 )
 
Index: mlir/test/Target/LLVMIR/nvvmir.mlir
===
--- mlir/test/Target/LLVMIR/nvvmir.mlir
+++ mlir/test/Target/LLVMIR/nvvmir.mlir
@@ -33,6 +33,13 @@
   llvm.return %1 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+llvm.func @nvvm_rcp(%0: f32) -> f32 {
+  // CHECK: call float @llvm.nvvm.rcp.approx.ftz.f
+  %1 = nvvm.rcp.approx.ftz.f %0 : f32
+  llvm.return %1 : f32
+}
+
 // CHECK-LABEL: @llvm_nvvm_barrier0
 llvm.func @llvm_nvvm_barrier0() {
   // CHECK: call void @llvm.nvvm.barrier0()
Index: mlir/test/Dialect/LLVMIR/nvvm.mlir
===
--- mlir/test/Dialect/LLVMIR/nvvm.mlir
+++ mlir/test/Dialect/LLVMIR/nvvm.mlir
@@ -29,8 +29,15 @@
   llvm.return %0 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+func.func @nvvm_rcp(%arg0: f32) -> f32 {
+  // CHECK: nvvm.rcp.approx.ftz.f %arg0 : f32
+  %0 = nvvm.rcp.approx.ftz.f %arg0 : f32
+  llvm.return %0 : f32
+}
+
 // CHECK-LABEL: @llvm_nvvm_barrier0
-func.func @llvm_nvvm_barrier0() {
+func.func @llvm.nvvm.barrier0() {
   // CHECK: nvvm.barrier0
   nvvm.barrier0
   llvm.return
Index: mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
===
--- /dev/null
+++ mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
@@ -0,0 +1,24 @@
+// RUN: mlir-opt %s -nvvm-optimize | FileCheck %s
+
+// CHECK-LABEL: llvm.func @fdiv_fp16
+llvm.func @fdiv_fp16(%arg0 : f16, %arg1 : f16) -> f16 {
+  // CHECK-DAG: %[[c0:.*]]  = llvm.mlir.constant(0 : ui32) : i32
+  // CHECK-DAG: %[[mask:.*]]= llvm.mlir.constant(2139095040 : ui32) : i32
+  // CHECK-DAG: %[[lhs:.*]] = llvm.fpext %arg0 : f16 to f32
+  // CHECK-DAG: %[[rhs:.*]] = llvm.fpext %arg1 : f16 to f32
+  // CHECK-DAG: %[[rcp:.*]] = nvvm.rcp.approx.ftz.f %[[rhs]] : f32
+  // CHECK-DAG: %[[approx:.*]]  = llvm.fmul %[[lhs]], %[[rcp]] : f32
+  // CHECK-DAG: %[[neg:.*]] = llvm.fneg %[[rhs]] : f32
+  // CHECK-DAG: %[[err:.*]] = "llvm.intr.fma"(%[[approx]], %[[neg]], %[[lhs]]) : (f32, f32, f32) -> f32
+  // CHECK-DAG: %[[refined:.*]] = "llvm.intr.fma"(%[[err]], %[[rcp]], %[[approx]]) : (f32, f32, f32) -> f32
+  // CHECK-DAG: %[[cast:.*]]= llvm.bitcast %[[approx]] : f32 to i32
+  // CHECK-DAG: %[[exp:.*]] = llvm.and %[[cast]], %[[mask]] : i32
+  // CHECK-DAG: %[[is_zero:.*]] = llvm.icmp "eq" %[[exp]], %[[c0]] : i32
+  // CHECK-DAG: %[[is_mask:.*]] = llvm.icmp "eq" %[[exp]], %[[mask]] : i32
+  // CHECK-DAG: %[[pred:.*]]= llvm.or %[[is_zero]], %[[is_mask]] : i1
+  // CHECK-DAG: %[[select:.*]]  = llvm.select %[[pred]], %[[approx]], %[[refined]] : i1, f32
+  // CHECK-DAG: %[[result:.*]]  = llvm.fptrunc %[[select]] : f32 to f16
+  %result = llvm.fdiv %arg0, %arg1 : f16
+  // CHECK: llvm.return %[[result]] : f16
+  llvm.return %result : f16
+}
Index: mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
===
--- /dev/null
+++ mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
@@ -0,0 +1,99 @@
+//===- OptimizeNVVM.cpp - Optimize NVVM IR -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "mlir/Dialect/LLVMIR/Transforms/OptimizeNVVM.h"
+#include "PassDetail.h"
+#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
+#include "mlir/IR/Block.h"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+// Replaces fdiv on fp16 with fp32 multiplication with reciprocal plus one
+// (conditional) Newton iteration.
+//
+// Th

[PATCH] D126194: [Concepts] Implement overload resolution for destructors (P0848)

2022-05-30 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson planned changes to this revision.
royjacobson added inline comments.



Comment at: clang/lib/AST/DeclCXX.cpp:1901
+  for (auto* Decl : R) {
+auto* DD = dyn_cast(Decl);
+if (DD && DD->isEligibleOrSelected())

erichkeane wrote:
> What cases happen when the lookup for a destructor name ends up not being a 
> destructor on a RecordDecl type?  I guess I could see this happening with a 
> pseudo-destructor, but that isn't a class type.
> 
> 
It's a bit silly, but it's because we can have template destructors that we 
added to the AST even though they're invalid (it ends up as a 
FunctionTemplateDecl).

I noticed it because of SemaTemplate/destructor-template.cpp



Comment at: clang/lib/Sema/SemaDecl.cpp:17841
+  if (CXXRecord && !CXXRecord->isDependentType())
+ComputeSelectedDestructor(*this, CXXRecord);
+

erichkeane wrote:
> How does all of this play with the 'defaulted destructor is constexpr' stuff? 
>  We end up storing facts like that, destructor 
> triviality/irrelevance/defaulted-and-constexpr/deleted/etc as a bit in the 
> Decl, rather than calculating it.  Can this feature (Allowing overloading) 
> cause those to be inaccurate?
> 
> That is, could we do something like use a requires clause to select between a 
> trivial, irrelevant, and constexpr destructor? Do we need to make sure we 
> update those too?  I would expect that the destructor here would need to 
> store its OWN trivaility/relevance/constexpr/etc here, so we can then update 
> those flags on the type once it is selected.
> 
You're right, I also found `canPassInRegisters` that will need to be adjusted a 
bit so it seems I need to write some codegen tests to make sure this gets the 
ABI correctly.

I won't have much time in the coming month, I hope to get to it by the start of 
July (but if someone wants to pick this up in the meantime feel free to do so).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126194

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


[PATCH] D126308: cmake: use llvm dir variables for clang/utils/hmaptool

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D126308#3545410 , @nikic wrote:

> It looks like this change breaks the standalone build for clang. From what I 
> can see, while LLVM_TOOLS_BINARY_DIR and LLVM_TOOLS_INSTALL_DIR are exported 
> in llvm/cmake/modules/LLVMConfig.cmake.in, LLVM_UTILS_INSTALL_DIR is not, 
> resulting in an "install PROGRAMS given no DESTINATION" error. Presumably we 
> either need to export that variable, or it's not intended to be used outside 
> LLVM.

Interesting, had not realized we need to export them for standalone builds.

llvm/cmake/modules/AddLLVM.cmake exports a macro `add_llvm_utility` that uses 
this variable, and this file included from clang CMakeLists.

Since this macro would not be usable without this variable, then either 
add_llvm_utility is not intended to be exported, or it's intended and it was an 
oversight to not export LLVM_UTILS_INSTALL_DIR .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126308

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


[PATCH] D126642: [Clang] NFCI: Repurpose HasExtParameterInfos for HasExtraBitfields

2022-05-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: aaron.ballman, erichkeane, efriedma.
Herald added a project: All.
sdesmalen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The FunctionTypeExtraBitfields is currently only available when the
ExceptionSpecificationType == Dynamic, which means that there is no other
way to use or extend the FunctionTypeExtraBitfields independently of the
exception specification type.

Because there are no more bits available, this patch repurposes the
HasExtParameterInfos bit to specify whether the prototype has
ExtraBitfields and moves the `HasExtParamaterInfos` value to the
FunctionTypeExtraBitfields struct.

This patch intends to be NFC and is required for future extension
of the ExtraBitfields struct.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126642

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Type.cpp

Index: clang/lib/AST/Type.cpp
===
--- clang/lib/AST/Type.cpp
+++ clang/lib/AST/Type.cpp
@@ -3209,15 +3209,16 @@
   FunctionTypeBits.NumParams = params.size();
   assert(getNumParams() == params.size() && "NumParams overflow!");
   FunctionTypeBits.ExceptionSpecType = epi.ExceptionSpec.Type;
-  FunctionTypeBits.HasExtParameterInfos = !!epi.ExtParameterInfos;
   FunctionTypeBits.Variadic = epi.Variadic;
   FunctionTypeBits.HasTrailingReturn = epi.HasTrailingReturn;
 
-  // Fill in the extra trailing bitfields if present.
-  if (hasExtraBitfields(epi.ExceptionSpec.Type)) {
+  if (epi.requiresFunctionProtoTypeExtraBitfields()) {
+FunctionTypeBits.HasExtraBitfields = true;
 auto &ExtraBits = *getTrailingObjects();
-ExtraBits.NumExceptionType = epi.ExceptionSpec.Exceptions.size();
-  }
+ExtraBits = FunctionTypeExtraBitfields();
+  } else
+FunctionTypeBits.HasExtraBitfields = false;
+
 
   // Fill in the trailing argument array.
   auto *argSlot = getTrailingObjects();
@@ -3229,6 +3230,9 @@
 
   // Fill in the exception type array if present.
   if (getExceptionSpecType() == EST_Dynamic) {
+auto &ExtraBits = *getTrailingObjects();
+ExtraBits.NumExceptionType = epi.ExceptionSpec.Exceptions.size();
+
 assert(hasExtraBitfields() && "missing trailing extra bitfields!");
 auto *exnSlot =
 reinterpret_cast(getTrailingObjects());
@@ -3288,6 +3292,9 @@
 
   // Fill in the extra parameter info if present.
   if (epi.ExtParameterInfos) {
+auto &ExtraBits = *getTrailingObjects();
+ExtraBits.HasExtParameterInfos = true;
+
 auto *extParamInfos = getTrailingObjects();
 for (unsigned i = 0; i != getNumParams(); ++i)
   extParamInfos[i] = epi.ExtParameterInfos[i];
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -4451,8 +4451,7 @@
   QualType, SourceLocation, FunctionType::FunctionTypeExtraBitfields,
   FunctionType::ExceptionType, Expr *, FunctionDecl *,
   FunctionProtoType::ExtParameterInfo, Qualifiers>(
-  NumArgs, EPI.Variadic,
-  FunctionProtoType::hasExtraBitfields(EPI.ExceptionSpec.Type),
+  NumArgs, EPI.Variadic, EPI.requiresFunctionProtoTypeExtraBitfields(),
   ESH.NumExceptionType, ESH.NumExprPtr, ESH.NumFunctionDeclPtr,
   EPI.ExtParameterInfos ? NumArgs : 0,
   EPI.TypeQuals.hasNonFastQualifiers() ? 1 : 0);
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1621,8 +1621,8 @@
 /// The type of exception specification this function has.
 unsigned ExceptionSpecType : 4;
 
-/// Whether this function has extended parameter information.
-unsigned HasExtParameterInfos : 1;
+/// Whether this function has extra bitfields for the prototype.
+unsigned HasExtraBitfields : 1;
 
 /// Whether the function is variadic.
 unsigned Variadic : 1;
@@ -3805,6 +3805,12 @@
 /// A whole unsigned is not needed here and according to
 /// [implimits] 8 bits would be enough here.
 unsigned NumExceptionType;
+
+/// Whether this function has extended parameter information.
+bool HasExtParameterInfos : 1;
+
+FunctionTypeExtraBitfields()
+: NumExceptionType(0), HasExtParameterInfos(false) {}
   };
 
 protected:
@@ -3998,6 +4004,10 @@
   Result.ExceptionSpec = ESI;
   return Result;
 }
+
+bool requiresFunctionProtoTypeExtraBitfields() const {
+  return ExtParameterInfos != nullptr || ExceptionSpec.Type == EST_Dynamic;
+}
   };
 
 private:
@@ -4088,16 +4098,13 @@
 return getExceptionSpecSize(getExceptionSpecType(), getNumExceptions());
   }
 
-  /// Whether the trailing FunctionTypeExtraBitfields is present.
-  static bool hasExtraBitfields(ExceptionSpecificationType EST) {
-// I

[PATCH] D126642: [Clang] NFCI: Repurpose HasExtParameterInfos for HasExtraBitfields

2022-05-30 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

This patch follows from some discussion on D124998 
 as well as the need for more bits to 
represent future function type attributes :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126642

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


[PATCH] D126158: [MLIR][GPU] Replace fdiv on fp16 with promoted (fp32) multiplication with reciprocal plus one (conditional) Newton iteration.

2022-05-30 Thread Christian Sigg via Phabricator via cfe-commits
csigg updated this revision to Diff 432894.
csigg added a comment.

Fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126158

Files:
  mlir/include/mlir/Dialect/LLVMIR/NVVMOps.td
  mlir/include/mlir/Dialect/LLVMIR/Transforms/OptimizeNVVM.h
  mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.h
  mlir/include/mlir/Dialect/LLVMIR/Transforms/Passes.td
  mlir/lib/Dialect/LLVMIR/Transforms/CMakeLists.txt
  mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
  mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
  mlir/test/Dialect/LLVMIR/nvvm.mlir
  mlir/test/Target/LLVMIR/nvvmir.mlir
  utils/bazel/llvm-project-overlay/mlir/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/mlir/BUILD.bazel
@@ -3374,7 +3374,9 @@
 ":IR",
 ":LLVMDialect",
 ":LLVMPassIncGen",
+":NVVMDialect",
 ":Pass",
+":Transforms",
 ],
 )
 
Index: mlir/test/Target/LLVMIR/nvvmir.mlir
===
--- mlir/test/Target/LLVMIR/nvvmir.mlir
+++ mlir/test/Target/LLVMIR/nvvmir.mlir
@@ -33,6 +33,13 @@
   llvm.return %1 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+llvm.func @nvvm_rcp(%0: f32) -> f32 {
+  // CHECK: call float @llvm.nvvm.rcp.approx.ftz.f
+  %1 = nvvm.rcp.approx.ftz.f %0 : f32
+  llvm.return %1 : f32
+}
+
 // CHECK-LABEL: @llvm_nvvm_barrier0
 llvm.func @llvm_nvvm_barrier0() {
   // CHECK: call void @llvm.nvvm.barrier0()
Index: mlir/test/Dialect/LLVMIR/nvvm.mlir
===
--- mlir/test/Dialect/LLVMIR/nvvm.mlir
+++ mlir/test/Dialect/LLVMIR/nvvm.mlir
@@ -29,6 +29,13 @@
   llvm.return %0 : i32
 }
 
+// CHECK-LABEL: @nvvm_rcp
+func.func @nvvm_rcp(%arg0: f32) -> f32 {
+  // CHECK: nvvm.rcp.approx.ftz.f %arg0 : f32
+  %0 = nvvm.rcp.approx.ftz.f %arg0 : f32
+  llvm.return %0 : f32
+}
+
 // CHECK-LABEL: @llvm_nvvm_barrier0
 func.func @llvm_nvvm_barrier0() {
   // CHECK: nvvm.barrier0
Index: mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
===
--- /dev/null
+++ mlir/test/Dialect/LLVMIR/nvvm-optimize.mlir
@@ -0,0 +1,24 @@
+// RUN: mlir-opt %s -nvvm-optimize | FileCheck %s
+
+// CHECK-LABEL: llvm.func @fdiv_fp16
+llvm.func @fdiv_fp16(%arg0 : f16, %arg1 : f16) -> f16 {
+  // CHECK-DAG: %[[c0:.*]]  = llvm.mlir.constant(0 : ui32) : i32
+  // CHECK-DAG: %[[mask:.*]]= llvm.mlir.constant(2139095040 : ui32) : i32
+  // CHECK-DAG: %[[lhs:.*]] = llvm.fpext %arg0 : f16 to f32
+  // CHECK-DAG: %[[rhs:.*]] = llvm.fpext %arg1 : f16 to f32
+  // CHECK-DAG: %[[rcp:.*]] = nvvm.rcp.approx.ftz.f %[[rhs]] : f32
+  // CHECK-DAG: %[[approx:.*]]  = llvm.fmul %[[lhs]], %[[rcp]] : f32
+  // CHECK-DAG: %[[neg:.*]] = llvm.fneg %[[rhs]] : f32
+  // CHECK-DAG: %[[err:.*]] = "llvm.intr.fma"(%[[approx]], %[[neg]], %[[lhs]]) : (f32, f32, f32) -> f32
+  // CHECK-DAG: %[[refined:.*]] = "llvm.intr.fma"(%[[err]], %[[rcp]], %[[approx]]) : (f32, f32, f32) -> f32
+  // CHECK-DAG: %[[cast:.*]]= llvm.bitcast %[[approx]] : f32 to i32
+  // CHECK-DAG: %[[exp:.*]] = llvm.and %[[cast]], %[[mask]] : i32
+  // CHECK-DAG: %[[is_zero:.*]] = llvm.icmp "eq" %[[exp]], %[[c0]] : i32
+  // CHECK-DAG: %[[is_mask:.*]] = llvm.icmp "eq" %[[exp]], %[[mask]] : i32
+  // CHECK-DAG: %[[pred:.*]]= llvm.or %[[is_zero]], %[[is_mask]] : i1
+  // CHECK-DAG: %[[select:.*]]  = llvm.select %[[pred]], %[[approx]], %[[refined]] : i1, f32
+  // CHECK-DAG: %[[result:.*]]  = llvm.fptrunc %[[select]] : f32 to f16
+  %result = llvm.fdiv %arg0, %arg1 : f16
+  // CHECK: llvm.return %[[result]] : f16
+  llvm.return %result : f16
+}
Index: mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
===
--- /dev/null
+++ mlir/lib/Dialect/LLVMIR/Transforms/OptimizeNVVM.cpp
@@ -0,0 +1,99 @@
+//===- OptimizeNVVM.cpp - Optimize NVVM IR -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "mlir/Dialect/LLVMIR/Transforms/OptimizeNVVM.h"
+#include "PassDetail.h"
+#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
+#include "mlir/IR/Block.h"
+#include "mlir/IR/Builders.h"
+#include "mlir/IR/BuiltinOps.h"
+#include "mlir/IR/PatternMatch.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+// Replaces fdiv on fp16 with fp32 multiplication with reciprocal plus one
+// (conditional) Newton iteration.
+//
+// This as accurate as promoting the division to fp32 in the NVPTX backend

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-05-30 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 432900.
upsj marked an inline comment as done.
upsj added a comment.

Thanks Nathan, that was exactly it. I thought I looked at getTypePtr() 
directly, but I must have been mistaken.
After a small fix (only adding inlay hints until the first unexpanded pack 
expression, it seems to work now).

Short explanation of what is going on: I split the parameters into head, pack 
and tail where pack are all parameters matching the variadic template type 
parameter we are expanding.
This way, I need to make no allocations inside the visitor.

The only thing to be fixed is a `make_tuple`-like call, where each parameter is 
called `head`, probably simple deduplication makes most sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -174,6 +174,44 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward($fwd[[args]])...); }
+void baz() {
+  bar(42);
+}
+  )cpp",
+   ExpectedHint{"&: ", "fwd"});
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -186,6 +224,19 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, NamePartiallyInDefinition) {
+  // Parameter name picked up from definition if necessary.
+  assertParameterHints(R"cpp(
+void foo(int, int b);
+void bar() {
+  foo($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
 TEST(ParameterHints, NameMismatch) {
   // Prefer name from declaration.
   assertParameterHints(R"cpp(
@@ -258,6 +309,276 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward($fwd[[args]])...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"&: ", "fwd"},
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward($fwd[[args]])...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"&: ", "fwd"},
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter
+  // This p

[clang] be3fc66 - Revert "[clang][test] mark tests added in ee8524087c78 as unsupported on AIX"

2022-05-30 Thread Jake Egan via cfe-commits

Author: Jake Egan
Date: 2022-05-30T09:35:26-04:00
New Revision: be3fc66f83b08a03ef3bc849ca3b37ff11e09199

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

LOG: Revert "[clang][test] mark tests added in ee8524087c78 as unsupported on 
AIX"

The tests pass now on a clean build.

This reverts commit 1b34f1e996565bc5e4f2be14b89f881f8fe0f3b9.

Added: 


Modified: 
clang/test/Index/index-concept-kind.cpp
clang/test/Index/index-concepts.cpp

Removed: 




diff  --git a/clang/test/Index/index-concept-kind.cpp 
b/clang/test/Index/index-concept-kind.cpp
index f33fc6bc5cc0d..7aaf814f5f989 100644
--- a/clang/test/Index/index-concept-kind.cpp
+++ b/clang/test/Index/index-concept-kind.cpp
@@ -1,5 +1,5 @@
 // RUN: c-index-test -index-file %s -std=gnu++20 | FileCheck %s
-// UNSUPPORTED: aix
+
 template 
 concept LargeType = sizeof(T) > 8;
 // CHECK: [indexDeclaration]: kind: concept | name: LargeType | USR: 
c:@CT@LargeType | lang: C | cursor: ConceptDecl=LargeType:[[@LINE-1]]:9 
(Definition) | loc: [[@LINE-1]]:9 | semantic-container: [TU] | 
lexical-container: [TU] | isRedecl: 0 | isDef: 1 | isContainer: 0 | isImplicit: 0

diff  --git a/clang/test/Index/index-concepts.cpp 
b/clang/test/Index/index-concepts.cpp
index b8d41e841e619..d29b9dcf79522 100644
--- a/clang/test/Index/index-concepts.cpp
+++ b/clang/test/Index/index-concepts.cpp
@@ -1,5 +1,5 @@
 // RUN: c-index-test -test-load-source all %s -std=gnu++20 
-fno-delayed-template-parsing | FileCheck %s
-// UNSUPPORTED: aix
+
 template
 struct type_trait {
 const static bool value = false;



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


[PATCH] D126651: [clang-diff] Fix getStmtValue when dealing with wide chars

2022-05-30 Thread Kaining Zhong via Phabricator via cfe-commits
PRESIDENT810 created this revision.
PRESIDENT810 added reviewers: klimek, arphaman, johannes.
Herald added a project: All.
PRESIDENT810 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This fixes https://github.com/llvm/llvm-project/issues/55771.
Directly using StringLiteral::getString for wide string is not currently 
supported; therefore in ASTDiff, getStmtValue will fail when asserting that the 
StringLiteral has a width of 1. This patch will convert wide string to utf-8 
string.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126651

Files:
  clang/lib/Tooling/ASTDiff/ASTDiff.cpp
  clang/test/Tooling/clang-diff-ast.cpp


Index: clang/test/Tooling/clang-diff-ast.cpp
===
--- clang/test/Tooling/clang-diff-ast.cpp
+++ clang/test/Tooling/clang-diff-ast.cpp
@@ -51,6 +51,12 @@
 return 0;
   }
 
+  // CHECK: CXXMethodDecl: :bar(const wchar_t *()
+  const wchar_t *bar() {
+// CHECK: StringLiteral: bar(
+return L"bar";
+  }
+
   // CHECK: AccessSpecDecl: public(
 public:
   int not_initialized;
Index: clang/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/PriorityQueue.h"
+#include "llvm/Support/ConvertUTF.h"
 
 #include 
 #include 
@@ -463,8 +464,19 @@
   }
   if (auto *D = dyn_cast(S))
 return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
-  if (auto *String = dyn_cast(S))
+  if (auto *String = dyn_cast(S)) {
+if (String->isWide()) {
+  unsigned int wsize = String->getByteLength() / 
String->getCharByteWidth();
+  const wchar_t *temp =
+  reinterpret_cast(String->getBytes().data());
+  std::wstring wstr(temp);
+  std::string str;
+  if (!convertWideToUTF8(wstr.substr(0, wsize), str))
+return "";
+  return str;
+}
 return std::string(String->getString());
+  }
   if (auto *B = dyn_cast(S))
 return B->getValue() ? "true" : "false";
   return "";


Index: clang/test/Tooling/clang-diff-ast.cpp
===
--- clang/test/Tooling/clang-diff-ast.cpp
+++ clang/test/Tooling/clang-diff-ast.cpp
@@ -51,6 +51,12 @@
 return 0;
   }
 
+  // CHECK: CXXMethodDecl: :bar(const wchar_t *()
+  const wchar_t *bar() {
+// CHECK: StringLiteral: bar(
+return L"bar";
+  }
+
   // CHECK: AccessSpecDecl: public(
 public:
   int not_initialized;
Index: clang/lib/Tooling/ASTDiff/ASTDiff.cpp
===
--- clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -16,6 +16,7 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/PriorityQueue.h"
+#include "llvm/Support/ConvertUTF.h"
 
 #include 
 #include 
@@ -463,8 +464,19 @@
   }
   if (auto *D = dyn_cast(S))
 return getRelativeName(D->getDecl(), getEnclosingDeclContext(AST, S));
-  if (auto *String = dyn_cast(S))
+  if (auto *String = dyn_cast(S)) {
+if (String->isWide()) {
+  unsigned int wsize = String->getByteLength() / String->getCharByteWidth();
+  const wchar_t *temp =
+  reinterpret_cast(String->getBytes().data());
+  std::wstring wstr(temp);
+  std::string str;
+  if (!convertWideToUTF8(wstr.substr(0, wsize), str))
+return "";
+  return str;
+}
 return std::string(String->getString());
+  }
   if (auto *B = dyn_cast(S))
 return B->getValue() ? "true" : "false";
   return "";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126397: [pseudo] Fix pseudo-gen usage when cross-compiling

2022-05-30 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

This didn't fix the mac/arm64 llvm builds for Chromium. I think it's because we 
don't set CMAKE_CROSSCOMPILING, so I'll try doing that as a work-around. 
(crbug.com/1330304).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126397

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


[PATCH] D124752: [HLSL] clang codeGen for HLSLShaderAttr.

2022-05-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:2606
+  if (getLangOpts().HLSL && TargetDecl) {
+if (const FunctionDecl *FD = dyn_cast_or_null(TargetDecl))
+  getHLSLRuntime().addHLSLFunctionAttributes(FuncAttrs, RetAttrs, FD);

I think `TargetDecl` can't be nullptr at this point due to the above check? So 
perhaps using `dyn_cast` is better here?



Comment at: clang/lib/CodeGen/CGHLSLRuntime.cpp:55
+void CGHLSLRuntime::addHLSLFunctionAttributes(llvm::AttrBuilder &FuncAttrs,
+  llvm::AttrBuilder &RetAttrs,
+  const FunctionDecl *FD) {

This parameter seems to be unused?



Comment at: clang/test/CodeGenHLSL/shader_type_attr.hlsl:3
+
+// Make sure not mangle entry.
+// CHECK:define void @foo()

python3kgae wrote:
> Anastasia wrote:
> > I struggle understand the difference in this test? Can it be merged with 
> > the above?
> The difference between these 2 tests is entry.hlsl test for entry which does 
> not have shader attribute on foo while shader_type_attr.hlsl test for entry 
> in a library which has shader attribute (the [shader("compute")]).
Ok, I see although in this patch you only add support for generating the 
attribute in IR so the logic for handling `-E` or input attribute is I assume 
elsewhere and it is tested separately?

But the tests are small so no big concerns to keep both either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124752

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


[PATCH] D124753: [HLSL] Set main as default entry.

2022-05-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

From the current change it seems to me that what you need to be testing is a 
just that the frontend options are being passed correctly? This should then be 
a driver test with `-###` checking for the options to be set for the frontend 
invocation...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124753

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


[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-30 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks

Please make sure to reflect in your commit message that you are adding the 
clang internal headers too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125052

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


[clang] d2e3cb7 - [OpenMP][Clang] Fix atomic compare for signed vs. unsigned

2022-05-30 Thread Joel E. Denny via cfe-commits

Author: Joel E. Denny
Date: 2022-05-30T11:02:20-04:00
New Revision: d2e3cb737417a2e5ffad34f666fa8510e88e8bc2

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

LOG: [OpenMP][Clang] Fix atomic compare for signed vs. unsigned

Without this patch, arguments to the
`llvm::OpenMPIRBuilder::AtomicOpValue` initializer are reversed.

Reviewed By: ABataev, tianshilei1992

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

Added: 
openmp/libomptarget/test/offloading/atomic-compare-signedness.c
openmp/runtime/test/atomic/omp-atomic-compare-signedness.c

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/test/OpenMP/atomic_compare_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 61e3661e59be..f78443fd20bc 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -6188,8 +6188,8 @@ static void emitOMPAtomicCompareExpr(CodeGenFunction &CGF,
 
   llvm::OpenMPIRBuilder::AtomicOpValue XOpVal{
   XAddr.getPointer(), XAddr.getElementType(),
-  X->getType().isVolatileQualified(),
-  X->getType()->hasSignedIntegerRepresentation()};
+  X->getType()->hasSignedIntegerRepresentation(),
+  X->getType().isVolatileQualified()};
 
   CGF.Builder.restoreIP(OMPBuilder.createAtomicCompare(
   CGF.Builder, XOpVal, EVal, DVal, AO, Op, IsXBinopExpr));

diff  --git a/clang/test/OpenMP/atomic_compare_codegen.cpp 
b/clang/test/OpenMP/atomic_compare_codegen.cpp
index cc36eae2cd50..825832399e3c 100644
--- a/clang/test/OpenMP/atomic_compare_codegen.cpp
+++ b/clang/test/OpenMP/atomic_compare_codegen.cpp
@@ -1979,21 +1979,21 @@ void foo(void) {
 // CHECK-NEXT:[[ULLE:%.*]] = alloca i64, align 8
 // CHECK-NEXT:[[ULLD:%.*]] = alloca i64, align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP0]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP0]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP2:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP3:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP2]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP3:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP2]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP4:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP5:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP4]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP5:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP4]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP6:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP7:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP6]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP7:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP6]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP8:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP9:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP8]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP9:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP8]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP10:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP11:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP10]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP11:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP10]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP12:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP13:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP12]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP13:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP12]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP14:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP15:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP14]] 
monotonic, align 1
+// CHECK-NEXT:[[TMP15:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP14]] 
monotonic, align 1
 // CHECK-NEXT:[[TMP16:%.*]] = load i8, i8* [[CE]], align 1
 // CHECK-NEXT:[[TMP17:%.*]] = load i8, i8* [[CD]], align 1
 // CHECK-NEXT:[[TMP18:%.*]] = cmpxchg i8* [[CX]], i8 [[TMP16]], i8 
[[TMP17]] monotonic monotonic, align 1
@@ -2035,28 +2035,28 @@ void foo(void) {
 // CHECK-NEXT:[[TMP54:%.*]] = load i8, i8* [[UCD]], align 1
 // CHECK-NEXT:[[TMP55:%.*]] = cmpxchg i8* [[UCX]], i8 [[TMP53]], i8 
[[TMP54]] monotonic monotonic, align 1
 // CHECK-NEXT:[[TMP56:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP57:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP56]] 
acq_rel, align 1
+// CHECK-NEXT:[[TMP57:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP56]] 
acq_rel, align 1
 // CHECK-NEXT:call void @__kmpc_flush(%struct.ident_t* @[[GLOB1:[0-9]+]])
 // CHECK-NEXT:[[TMP58:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP59:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP58]] 
acq_rel, align 1
+// CHECK-NEXT:[[TMP59:%.*]] = atomicrmw

[PATCH] D126619: [OpenMP][Clang] Fix atomic compare for signed vs. unsigned

2022-05-30 Thread Joel E. Denny 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 rGd2e3cb737417: [OpenMP][Clang] Fix atomic compare for signed 
vs. unsigned (authored by jdenny).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126619

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  openmp/libomptarget/test/offloading/atomic-compare-signedness.c
  openmp/runtime/test/atomic/omp-atomic-compare-signedness.c

Index: openmp/runtime/test/atomic/omp-atomic-compare-signedness.c
===
--- /dev/null
+++ openmp/runtime/test/atomic/omp-atomic-compare-signedness.c
@@ -0,0 +1,40 @@
+// Check that omp atomic compare handles signedness of integer comparisons
+// correctly.
+//
+// At one time, a bug sometimes reversed the signedness.
+
+// RUN: %libomp-compile -fopenmp-version=51
+// RUN: %libomp-run | FileCheck %s
+
+// High parallelism increases our chances of detecting a lack of atomicity.
+#define NUM_THREADS_TRY 256
+
+#include 
+#include 
+#include 
+
+int main() {
+  //  CHECK: signed: num_threads=[[#NUM_THREADS:]]{{$}}
+  // CHECK-NEXT: signed: xs=[[#NUM_THREADS-1]]{{$}}
+  int xs = -1;
+  int numThreads;
+  #pragma omp parallel for num_threads(NUM_THREADS_TRY)
+  for (int i = 0; i < omp_get_num_threads(); ++i) {
+#pragma omp atomic compare
+if (xs < i) { xs = i; }
+if (i == 0)
+  numThreads = omp_get_num_threads();
+  }
+  printf("signed: num_threads=%d\n", numThreads);
+  printf("signed: xs=%d\n", xs);
+
+  // CHECK-NEXT: unsigned: xu=0x0{{$}}
+  unsigned xu = UINT_MAX;
+  #pragma omp parallel for num_threads(NUM_THREADS_TRY)
+  for (int i = 0; i < omp_get_num_threads(); ++i) {
+#pragma omp atomic compare
+if (xu > i) { xu = i; }
+  }
+  printf("unsigned: xu=0x%x\n", xu);
+  return 0;
+}
Index: openmp/libomptarget/test/offloading/atomic-compare-signedness.c
===
--- /dev/null
+++ openmp/libomptarget/test/offloading/atomic-compare-signedness.c
@@ -0,0 +1,42 @@
+// Check that omp atomic compare handles signedness of integer comparisons
+// correctly.
+//
+// At one time, a bug sometimes reversed the signedness.
+
+// RUN: %libomptarget-compile-generic -fopenmp-version=51
+// RUN: %libomptarget-run-generic | %fcheck-generic
+
+// High parallelism increases our chances of detecting a lack of atomicity.
+#define NUM_THREADS_TRY 256
+
+#include 
+#include 
+#include 
+
+int main() {
+  //  CHECK: signed: num_threads=[[#NUM_THREADS:]]{{$}}
+  // CHECK-NEXT: signed: xs=[[#NUM_THREADS-1]]{{$}}
+  int xs = -1;
+  int numThreads;
+  #pragma omp target parallel for num_threads(NUM_THREADS_TRY) \
+  map(tofrom:xs, numThreads)
+  for (int i = 0; i < omp_get_num_threads(); ++i) {
+#pragma omp atomic compare
+if (xs < i) { xs = i; }
+if (i == 0)
+  numThreads = omp_get_num_threads();
+  }
+  printf("signed: num_threads=%d\n", numThreads);
+  printf("signed: xs=%d\n", xs);
+
+  // CHECK-NEXT: unsigned: xu=0x0{{$}}
+  unsigned xu = UINT_MAX;
+  #pragma omp target parallel for num_threads(NUM_THREADS_TRY) \
+  map(tofrom:xu)
+  for (int i = 0; i < omp_get_num_threads(); ++i) {
+#pragma omp atomic compare
+if (xu > i) { xu = i; }
+  }
+  printf("unsigned: xu=0x%x\n", xu);
+  return 0;
+}
Index: clang/test/OpenMP/atomic_compare_codegen.cpp
===
--- clang/test/OpenMP/atomic_compare_codegen.cpp
+++ clang/test/OpenMP/atomic_compare_codegen.cpp
@@ -1979,21 +1979,21 @@
 // CHECK-NEXT:[[ULLE:%.*]] = alloca i64, align 8
 // CHECK-NEXT:[[ULLD:%.*]] = alloca i64, align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP0]] monotonic, align 1
+// CHECK-NEXT:[[TMP1:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP0]] monotonic, align 1
 // CHECK-NEXT:[[TMP2:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP3:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP2]] monotonic, align 1
+// CHECK-NEXT:[[TMP3:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP2]] monotonic, align 1
 // CHECK-NEXT:[[TMP4:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP5:%.*]] = atomicrmw umax i8* [[CX]], i8 [[TMP4]] monotonic, align 1
+// CHECK-NEXT:[[TMP5:%.*]] = atomicrmw max i8* [[CX]], i8 [[TMP4]] monotonic, align 1
 // CHECK-NEXT:[[TMP6:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP7:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP6]] monotonic, align 1
+// CHECK-NEXT:[[TMP7:%.*]] = atomicrmw min i8* [[CX]], i8 [[TMP6]] monotonic, align 1
 // CHECK-NEXT:[[TMP8:%.*]] = load i8, i8* [[CE]], align 1
-// CHECK-NEXT:[[TMP9:%.*]] = atomicrmw umin i8* [[CX]], i8 [[TMP8]] monotonic, align 1
+// CH

[PATCH] D126619: [OpenMP][Clang] Fix atomic compare for signed vs. unsigned

2022-05-30 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

Thanks for the quick review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126619

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


[PATCH] D122150: [clang][analyzer] Add checker for bad use of 'errno'.

2022-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 432929.
balazske added a comment.

added option to allow read-only of `errno`
other small change in the test checker


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122150

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
  clang/lib/StaticAnalyzer/Checkers/ErrnoTesterChecker.cpp
  clang/test/Analysis/errno-notes.c
  clang/test/Analysis/errno-options.c
  clang/test/Analysis/errno.c

Index: clang/test/Analysis/errno.c
===
--- clang/test/Analysis/errno.c
+++ clang/test/Analysis/errno.c
@@ -3,6 +3,7 @@
 // RUN:   -analyzer-checker=apiModeling.Errno \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-checker=debug.ErrnoTest \
+// RUN:   -analyzer-checker=alpha.unix.Errno \
 // RUN:   -DERRNO_VAR
 
 // RUN: %clang_analyze_cc1 -verify %s \
@@ -10,8 +11,10 @@
 // RUN:   -analyzer-checker=apiModeling.Errno \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -analyzer-checker=debug.ErrnoTest \
+// RUN:   -analyzer-checker=alpha.unix.Errno \
 // RUN:   -DERRNO_FUNC
 
+#include "Inputs/system-header-simulator.h"
 #ifdef ERRNO_VAR
 #include "Inputs/errno_var.h"
 #endif
@@ -24,6 +27,7 @@
 int ErrnoTesterChecker_getErrno();
 int ErrnoTesterChecker_setErrnoIfError();
 int ErrnoTesterChecker_setErrnoIfErrorRange();
+int ErrnoTesterChecker_setErrnoCheckState();
 
 void something();
 
@@ -61,3 +65,154 @@
 clang_analyzer_eval(errno == 1); // expected-warning{{FALSE}} expected-warning{{TRUE}}
   }
 }
+
+void testErrnoCheck0() {
+  // If the function returns a success result code, value of 'errno'
+  // is unspecified and it is unsafe to make any decision with it.
+  // The function did not promise to not change 'errno' if no failure happens.
+  int X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 0) {
+if (errno) { // expected-warning{{An undefined value may be read from 'errno' [alpha.unix.Errno]}}
+}
+if (errno) { // no warning for second time (analysis stops at the first warning)
+}
+  }
+  X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 0) {
+if (errno) { // expected-warning{{An undefined value may be read from 'errno' [alpha.unix.Errno]}}
+}
+errno = 0;
+  }
+  X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 0) {
+errno = 0;
+if (errno) { // no warning after overwritten 'errno'
+}
+  }
+}
+
+void testErrnoCheck1() {
+  // If the function returns error result code that is out-of-band (not a valid
+  // non-error return value) the value of 'errno' can be checked but it is not
+  // required to do so.
+  int X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 1) {
+if (errno) { // no warning
+}
+  }
+  X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 1) {
+errno = 0; // no warning
+  }
+}
+
+void testErrnoCheck2() {
+  // If the function returns an in-band error result the value of 'errno' is
+  // required to be checked to verify if error happened.
+  // The same applies to other functions that can indicate failure only by
+  // change of 'errno'.
+  int X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 2) {
+if (errno) {
+}
+errno = 0; // no warning after 'errno' was read
+  }
+  X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 2) {
+errno = 0; // expected-warning{{Value of 'errno' was not checked and is overwritten here [alpha.unix.Errno]}}
+errno = 0;
+  }
+  X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 2) {
+errno = 0; // expected-warning{{Value of 'errno' was not checked and is overwritten here [alpha.unix.Errno]}}
+if (errno) {
+}
+  }
+}
+
+void testErrnoCheckUndefinedLoad() {
+  int X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 0) {
+if (errno) {
+}; // expected-warning{{An undefined value may be read from 'errno' [alpha.unix.Errno]}}
+  }
+}
+
+void testErrnoNotCheckedAtSystemCall() {
+  int X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 2) {
+printf("%i", 1); // expected-warning{{Value of 'errno' was not checked and may be overwritten by function 'printf' [alpha.unix.Errno]}}
+printf("%i", 1); // no warning ('printf' does not change errno state)
+  }
+}
+
+void testErrnoCheckStateInvalidate() {
+  int X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 0) {
+something();
+if (errno) { // no warning after an invalidating function call
+}
+  }
+  X = ErrnoTesterChecker_setErrnoCheckState();
+  if (X == 0) {
+printf("%i", 1);
+if (errno) { // no warning after an invalidating standard function call
+}
+  }
+}
+
+void testErrnoCheckStateInvalidate1() {
+  int 

[PATCH] D125400: [clang][Analyzer] Add errno state to standard functions modeling.

2022-05-30 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 432930.
balazske added a comment.

applied the review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125400

Files:
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/Inputs/system-header-simulator-for-errno.h
  clang/test/Analysis/errno-stdlibraryfunctions.c

Index: clang/test/Analysis/errno-stdlibraryfunctions.c
===
--- /dev/null
+++ clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -0,0 +1,46 @@
+// RUN: %clang_analyze_cc1 -verify -analyzer-output text %s \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-checker=debug.ExprInspection \
+// RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
+// RUN:   -analyzer-checker=apiModeling.Errno \
+// RUN:   -analyzer-checker=alpha.unix.Errno \
+// RUN:   -analyzer-config apiModeling.StdCLibraryFunctions:ModelPOSIX=true
+
+#include "Inputs/errno_var.h"
+#include "Inputs/system-header-simulator-for-errno.h"
+
+void clang_analyzer_warnIfReached();
+
+void test1() {
+  access("path", 0); // no note here
+  access("path", 0);
+  // expected-note@-1{{Assuming that function 'access' is successful, in this case the value 'errno' may be undefined after the call and should not be used}}
+  if (errno != 0) { }
+  // expected-warning@-1{{An undefined value may be read from 'errno'}}
+  // expected-note@-2{{An undefined value may be read from 'errno'}}
+}
+
+void test2() {
+  if (access("path", 0) == -1) {
+// expected-note@-1{{Taking true branch}}
+// Failure path.
+if (errno != 0) {
+  // expected-note@-1{{'errno' is not equal to 0}}
+  // expected-note@-2{{Taking true branch}}
+  clang_analyzer_warnIfReached(); // expected-note {{REACHABLE}} expected-warning {{REACHABLE}}
+} else {
+  clang_analyzer_warnIfReached(); // no-warning: We are on the failure path.
+}
+  }
+}
+
+void test3() {
+  if (access("path", 0) != -1) {
+// Success path.
+// expected-note@-2{{Assuming that function 'access' is successful, in this case the value 'errno' may be undefined after the call and should not be used}}
+// expected-note@-3{{Taking true branch}}
+if (errno != 0) { }
+// expected-warning@-1{{An undefined value may be read from 'errno'}}
+// expected-note@-2{{An undefined value may be read from 'errno'}}
+  }
+}
Index: clang/test/Analysis/Inputs/system-header-simulator-for-errno.h
===
--- /dev/null
+++ clang/test/Analysis/Inputs/system-header-simulator-for-errno.h
@@ -0,0 +1,6 @@
+#pragma clang system_header
+
+typedef __typeof(sizeof(int)) off_t;
+
+int access(const char *path, int amode);
+off_t lseek(int fildes, off_t offset, int whence);
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -40,6 +40,7 @@
 //
 //===--===//
 
+#include "ErrnoModeling.h"
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
@@ -56,6 +57,19 @@
 using namespace clang;
 using namespace clang::ento;
 
+static const char *describeErrnoCheckState(errno_modeling::ErrnoCheckState CS) {
+  switch (CS) {
+  case errno_modeling::Errno_Irrelevant:
+return "is not significant";
+  case errno_modeling::Errno_MustBeChecked:
+return "should be checked to verify if the call was successful";
+  case errno_modeling::Errno_MustNotBeChecked:
+return "may be undefined after the call and should not be used";
+  default:
+llvm_unreachable("unknown enum value");
+  };
+}
+
 namespace {
 class StdLibraryFunctionsChecker
 : public Checker {
@@ -377,6 +391,113 @@
   /// The complete list of constraints that defines a single branch.
   using ConstraintSet = std::vector;
 
+  /// Define how a function affects the system variable 'errno'.
+  /// This works together with the ErrnoModeling and ErrnoChecker classes.
+  class ErrnoConstraintBase {
+  public:
+/// Apply specific state changes related to the errno variable.
+virtual ProgramStateRef apply(ProgramStateRef State, const CallEvent &Call,
+  const Summary &Summary,
+  CheckerContext &C) const = 0;
+/// Get a description about what is applied to 'errno' and how is it allowed
+/// to be used. If ErrnoChecker generates a bug then this message is
+/// displayed as a note at the function call.
+/// It may return empty string if no note tag is to be added.
+virtual std::string describe(St

[PATCH] D126660: [OpenCL] Reword unknown extension pragma diagnostic

2022-05-30 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, stuart.
svenvh added a project: clang.
Herald added subscribers: Naghasan, ldrumm, yaxunl.
Herald added a project: All.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

For newer OpenCL extensions that do not require a pragma, such as
`cl_khr_subgroup_shuffle`, a user could still accidentally attempt to
use a pragma.  This would result in a warning

  "unknown OpenCL extension 'cl_khr_subgroup_shuffle' - ignoring"

which could be mistakenly interpreted as "Clang does not support this
extension at all" instead of "Clang does not require any pragma for
this extension".


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126660

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/test/Headers/opencl-c-header.cl
  clang/test/Parser/opencl-pragma.cl
  clang/test/SemaOpenCL/extension-begin.cl
  clang/test/SemaOpenCL/extension-version.cl

Index: clang/test/SemaOpenCL/extension-version.cl
===
--- clang/test/SemaOpenCL/extension-version.cl
+++ clang/test/SemaOpenCL/extension-version.cl
@@ -217,51 +217,51 @@
 // Check that pragmas for the OpenCL 3.0 features are rejected.
 
 #pragma OPENCL EXTENSION __opencl_c_int64 : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_int64' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_3d_image_writes : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_3d_image_writes' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_atomic_order_acq_rel : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_acq_rel' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_atomic_order_acq_rel' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_atomic_order_seq_cst : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_atomic_order_seq_cst' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_atomic_order_seq_cst' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_device_enqueue : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_device_enqueue' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_device_enqueue' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_fp64 : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_fp64' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_fp64' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_generic_address_space : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_generic_address_space' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_generic_address_space' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_images : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_images' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_images' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_pipes : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_pipes' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_pipes' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_program_scope_global_variables : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_program_scope_global_variables' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_program_scope_global_variables' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_read_write_images : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_read_write_images' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_read_write_images' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_subgroups : disable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_subgroups' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_subgroups' unknown or does not require pragma - ignoring}}
 
 #pragma OPENCL EXTENSION __opencl_c_int64 : enable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_int64' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_int64' unknown or does not require pragma - ignoring}}
 #pragma OPENCL EXTENSION __opencl_c_3d_image_writes : enable
-//expected-warning@-1{{unknown OpenCL extension '__opencl_c_3d_image_writes' - ignoring}}
+//expected-warning@-1{{OpenCL extension '__opencl_c_3d_image_writes' unknown or does not require pragma - 

[PATCH] D126308: cmake: use llvm dir variables for clang/utils/hmaptool

2022-05-30 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

There is a lot of cruft behind the signs. I would just use 
`LLVM_TOOLS_INSTALL_DIR` then which is exported to get this unblocked, and I'll 
rebase D117977  to try to clean these things 
up later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126308

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


[PATCH] D124918: [clang-tidy] Add a new check for non-trivial unused variables.

2022-05-30 Thread Luca Versari via Phabricator via cfe-commits
veluca93 marked 2 inline comments as done.
veluca93 added a comment.

@LegalizeAdulthood friendly ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124918

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


[clang] e576280 - [HLSL] Enable vector types for hlsl.

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

Author: Xiang Li
Date: 2022-05-30T09:05:29-07:00
New Revision: e576280380d3f5221cfcc14e9fabeacc8506a43c

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

LOG: [HLSL] Enable vector types for hlsl.

Vector types in hlsl is using clang ext_vector_type.
Declaration of vector types is in builtin header hlsl.h.
hlsl.h will be included by default for hlsl shader.

Reviewed By: Anastasia

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

Added: 
clang/lib/Headers/hlsl.h
clang/lib/Headers/hlsl/hlsl_basic_types.h
clang/test/CodeGenHLSL/basic_types.hlsl
clang/test/Driver/hlsl_no_stdinc.hlsl

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/LangOptions.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 0343e48c1a9d1..44fd4d50ca051 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6051,7 +6051,7 @@ def fdefault_calling_conv_EQ : Joined<["-"], 
"fdefault-calling-conv=">,
 
 // These options cannot be marshalled, because they are used to set up the 
LangOptions defaults.
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
-  HelpText<"Include default header file for OpenCL">;
+  HelpText<"Include default header file for OpenCL and HLSL">;
 def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
   HelpText<"Add OpenCL builtin function declarations (experimental)">;
 
@@ -6780,6 +6780,8 @@ class DXCJoinedOrSeparate : Option<["/", 
"-"], name,
 def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
   Group, Flags<[DXCOption, NoXarchOption]>, Alias,
   HelpText<"Display available options">;
+def dxc_no_stdinc : DXCFlag<"hlsl-no-stdinc">,
+  HelpText<"HLSL only. Disables all standard includes containing non-native 
compiler types and functions.">;
 def Fo : DXCJoinedOrSeparate<"Fo">, Alias,
   HelpText<"Output object file">;
 def dxil_validator_version : Option<["/", "-"], "validator-version", 
KIND_SEPARATE>,

diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 7791bff388be7..7549f3f2e23b4 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -117,6 +117,8 @@ void LangOptions::setLangDefaults(LangOptions &Opts, 
Language Lang,
   Opts.Digraphs = Std.hasDigraphs();
 
   Opts.HLSL = Lang == Language::HLSL;
+  if (Opts.HLSL && Opts.IncludeDefaultHeader)
+Includes.push_back("hlsl.h");
 
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 5106c0e327b87..a8706215bf605 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3484,6 +3484,9 @@ static void RenderHLSLOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
   for (const auto &Arg : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
   A->renderAsInput(Args, CmdArgs);
+  // Add the default headers if dxc_no_stdinc is not set.
+  if (!Args.hasArg(options::OPT_dxc_no_stdinc))
+CmdArgs.push_back("-finclude-default-header");
 }
 
 static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 32b084dfedecc..a51d4621ba682 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4202,6 +4202,10 @@ static void GeneratePreprocessorArgs(PreprocessorOptions 
&Opts,
 ((LangOpts.DeclareOpenCLBuiltins && I == "opencl-c-base.h") ||
  I == "opencl-c.h"))
   continue;
+// Don't generate HLSL includes. They are implied by other flags that are
+// generated elsewhere.
+if (LangOpts.HLSL && I == "hlsl.h")
+  continue;
 
 GenerateArg(Args, OPT_include, I, SA);
   }

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 3921f7949a0a9..4c5e7325d7960 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -377,6 +377,10 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
 Builder.defineMacro("__HLSL_VERSION",
 Twine((unsigned)LangOpts.getHLSLVersion()));
 
+if (LangOpts.NativeHalfType)
+  Builder.defineMacro("__HLSL_ENABLE_16_BIT",
+  Twine((unsigned)LangOpts.getHLSLVersion()));
+
 // Shader target information
 // "enums" for shader stages
 Builder.defineMacro("__SHADER_STA

[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-30 Thread Xiang Li 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 rGe576280380d3: [HLSL] Enable vector types for hlsl. (authored 
by python3kgae).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125052

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/LangOptions.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/hlsl.h
  clang/lib/Headers/hlsl/hlsl_basic_types.h
  clang/test/CodeGenHLSL/basic_types.hlsl
  clang/test/Driver/hlsl_no_stdinc.hlsl

Index: clang/test/Driver/hlsl_no_stdinc.hlsl
===
--- /dev/null
+++ clang/test/Driver/hlsl_no_stdinc.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_dxc  -Tlib_6_7 -fcgl -Fo - %s -### 2>&1 | FileCheck %s --check-prefix=STDINC
+// RUN: %clang_dxc  -Tlib_6_7 -hlsl-no-stdinc -fcgl -Fo - %s -### 2>&1 | FileCheck %s --check-prefix=NOSTDINC
+
+// RUN: %clang -cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -ast-dump -o - %s -verify
+
+// Make sure hlsl-no-stdinc is translated into finclude-default-header.
+// STDINC:"-finclude-default-header"
+// NOSTDINC-NOT:"-finclude-default-header"
+
+// Make sure uint not work when finclude-default-header is off.
+// expected-error@+1 {{unknown type name 'uint'}}
+uint a;
Index: clang/test/CodeGenHLSL/basic_types.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/basic_types.hlsl
@@ -0,0 +1,76 @@
+// RUN: %clang_dxc  -Tlib_6_7 -fcgl -Fo - %s | FileCheck %s
+
+// FIXME: check 16bit types once enable-16bit-types is ready.
+
+// CHECK:@uint_Val = global i32 0, align 4
+// CHECK:@uint64_t_Val = global i64 0, align 8
+// CHECK:@int64_t_Val = global i64 0, align 8
+// CHECK:@int2_Val = global <2 x i32> zeroinitializer, align 8
+// CHECK:@int3_Val = global <3 x i32> zeroinitializer, align 16
+// CHECK:@int4_Val = global <4 x i32> zeroinitializer, align 16
+// CHECK:@uint2_Val = global <2 x i32> zeroinitializer, align 8
+// CHECK:@uint3_Val = global <3 x i32> zeroinitializer, align 16
+// CHECK:@uint4_Val = global <4 x i32> zeroinitializer, align 16
+// CHECK:@int64_t2_Val = global <2 x i64> zeroinitializer, align 16
+// CHECK:@int64_t3_Val = global <3 x i64> zeroinitializer, align 32
+// CHECK:@int64_t4_Val = global <4 x i64> zeroinitializer, align 32
+// CHECK:@uint64_t2_Val = global <2 x i64> zeroinitializer, align 16
+// CHECK:@uint64_t3_Val = global <3 x i64> zeroinitializer, align 32
+// CHECK:@uint64_t4_Val = global <4 x i64> zeroinitializer, align 32
+// CHECK:@float2_Val = global <2 x float> zeroinitializer, align 8
+// CHECK:@float3_Val = global <3 x float> zeroinitializer, align 16
+// CHECK:@float4_Val = global <4 x float> zeroinitializer, align 16
+// CHECK:@double2_Val = global <2 x double> zeroinitializer, align 16
+// CHECK:@double3_Val = global <3 x double> zeroinitializer, align 32
+// CHECK:@double4_Val = global <4 x double> zeroinitializer, align 32
+
+#define TYPE_DECL(T)  T T##_Val
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(uint16_t);
+TYPE_DECL(int16_t);
+#endif
+
+// unsigned 32-bit integer.
+TYPE_DECL(uint);
+
+// 64-bit integer.
+TYPE_DECL(uint64_t);
+TYPE_DECL(int64_t);
+
+// built-in vector data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(int16_t2   );
+TYPE_DECL(int16_t3   );
+TYPE_DECL(int16_t4   );
+TYPE_DECL( uint16_t2 );
+TYPE_DECL( uint16_t3 );
+TYPE_DECL( uint16_t4 );
+#endif
+
+TYPE_DECL( int2  );
+TYPE_DECL( int3  );
+TYPE_DECL( int4  );
+TYPE_DECL( uint2 );
+TYPE_DECL( uint3 );
+TYPE_DECL( uint4 );
+TYPE_DECL( int64_t2  );
+TYPE_DECL( int64_t3  );
+TYPE_DECL( int64_t4  );
+TYPE_DECL( uint64_t2 );
+TYPE_DECL( uint64_t3 );
+TYPE_DECL( uint64_t4 );
+
+#ifdef __HLSL_ENABLE_16_BIT
+TYPE_DECL(half2 );
+TYPE_DECL(half3 );
+TYPE_DECL(half4 );
+#endif
+
+TYPE_DECL( float2  );
+TYPE_DECL( float3  );
+TYPE_DECL( float4  );
+TYPE_DECL( double2 );
+TYPE_DECL( double3 );
+TYPE_DECL( double4 );
Index: clang/lib/Headers/hlsl/hlsl_basic_types.h
===
--- /dev/null
+++ clang/lib/Headers/hlsl/hlsl_basic_types.h
@@ -0,0 +1,64 @@
+//===- hlsl_basic_types.h - HLSL definitions for basic types --===//
+//
+// 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_BASIC_TYPES_H_
+#define _HLSL_HLSL_BASIC_TYPES_H_
+
+// built-in scalar data types:
+
+#ifdef __HLSL_ENABLE_16_BIT
+// 16-bit integer.
+typedef unsigned short uint16_t;
+typedef short int16_t;
+#endif
+
+// unsign

[PATCH] D124752: [HLSL] clang codeGen for HLSLShaderAttr.

2022-05-30 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 432947.
python3kgae marked an inline comment as done.
python3kgae added a comment.

Code cleanup to match comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124752

Files:
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/lib/CodeGen/CGHLSLRuntime.h
  clang/test/CodeGenHLSL/shader_type_attr.hlsl


Index: clang/test/CodeGenHLSL/shader_type_attr.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/shader_type_attr.hlsl
@@ -0,0 +1,11 @@
+// RUN: %clang --driver-mode=dxc -Tlib_6_x -fcgl -Fo - %s | FileCheck %s
+
+// Make sure not mangle entry.
+// CHECK:define void @foo()
+// Make sure add function attribute.
+// CHECK:"dx.shader"="compute"
+[shader("compute")]
+[numthreads(1,1,1)]
+void foo() {
+
+}
Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -15,8 +15,13 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 #define LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 
+namespace llvm {
+class AttrBuilder;
+}
 namespace clang {
 
+class FunctionDecl;
+
 namespace CodeGen {
 
 class CodeGenModule;
@@ -30,6 +35,9 @@
   virtual ~CGHLSLRuntime() {}
 
   void finishCodeGen();
+
+  void addHLSLFunctionAttributes(llvm::AttrBuilder &FuncAttrs,
+ const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -50,3 +50,13 @@
   llvm::Module &M = CGM.getModule();
   addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
 }
+
+void CGHLSLRuntime::addHLSLFunctionAttributes(llvm::AttrBuilder &FuncAttrs,
+  const FunctionDecl *FD) {
+  if (HLSLShaderAttr *ShaderAttr = FD->getAttr()) {
+const StringRef ShaderAttrKindStr = "dx.shader";
+FuncAttrs.addAttribute(
+ShaderAttrKindStr,
+ShaderAttr->ConvertShaderTypeToStr(ShaderAttr->getType()));
+  }
+}
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -16,6 +16,7 @@
 #include "CGBlocks.h"
 #include "CGCXXABI.h"
 #include "CGCleanup.h"
+#include "CGHLSLRuntime.h"
 #include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
@@ -2601,6 +2602,11 @@
   }
   assert(ArgNo == FI.arg_size());
 
+  if (getLangOpts().HLSL && TargetDecl) {
+if (const FunctionDecl *FD = dyn_cast(TargetDecl))
+  getHLSLRuntime().addHLSLFunctionAttributes(FuncAttrs, FD);
+  }
+
   AttrList = llvm::AttributeList::get(
   getLLVMContext(), llvm::AttributeSet::get(getLLVMContext(), FuncAttrs),
   llvm::AttributeSet::get(getLLVMContext(), RetAttrs), ArgAttrs);
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -3281,7 +3281,7 @@
 }
 
 bool FunctionDecl::isInExternCContext() const {
-  if (hasAttr())
+  if (hasAttr() || hasAttr())
 return true;
   return getLexicalDeclContext()->isExternCContext();
 }


Index: clang/test/CodeGenHLSL/shader_type_attr.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/shader_type_attr.hlsl
@@ -0,0 +1,11 @@
+// RUN: %clang --driver-mode=dxc -Tlib_6_x -fcgl -Fo - %s | FileCheck %s
+
+// Make sure not mangle entry.
+// CHECK:define void @foo()
+// Make sure add function attribute.
+// CHECK:"dx.shader"="compute"
+[shader("compute")]
+[numthreads(1,1,1)]
+void foo() {
+
+}
Index: clang/lib/CodeGen/CGHLSLRuntime.h
===
--- clang/lib/CodeGen/CGHLSLRuntime.h
+++ clang/lib/CodeGen/CGHLSLRuntime.h
@@ -15,8 +15,13 @@
 #ifndef LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 #define LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
 
+namespace llvm {
+class AttrBuilder;
+}
 namespace clang {
 
+class FunctionDecl;
+
 namespace CodeGen {
 
 class CodeGenModule;
@@ -30,6 +35,9 @@
   virtual ~CGHLSLRuntime() {}
 
   void finishCodeGen();
+
+  void addHLSLFunctionAttributes(llvm::AttrBuilder &FuncAttrs,
+ const FunctionDecl *);
 };
 
 } // namespace CodeGen
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -50,3 +50,13 @@
   llvm::Module &M = CGM.getModule();
   addDxilValVersion(TargetOpts.DxilValidatorVersion, M);
 }
+
+void CGHLSLRuntime::addHLSLFunctionAttributes(llvm::AttrBuilder &FuncAttrs,
+ 

[PATCH] D126664: Expand definition deprecation warning to include constexpr statements.

2022-05-30 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google created this revision.
Herald added a project: All.
luken-google requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Clang currently warns on definitions downgraded to declarations
with a const modifier, but not for a constexpr modifier. This patch
updates the warning logic to warn on both inputs, and adds a test to
check the additional case as well.

See also: https://bugs.chromium.org/p/chromium/issues/detail?id=1284718


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126664

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/basic/basic.def/p2.cpp


Index: clang/test/CXX/basic/basic.def/p2.cpp
===
--- clang/test/CXX/basic/basic.def/p2.cpp
+++ clang/test/CXX/basic/basic.def/p2.cpp
@@ -5,4 +5,9 @@
 static constexpr int n = 0;
   };
   const int A::n; // expected-warning {{deprecated}}
+
+  struct B {
+static constexpr int m = 0;
+  };
+  constexpr int B::m; // expected-warning {{deprecated}}
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4508,15 +4508,15 @@
   }
 
   // C++ doesn't have tentative definitions, so go right ahead and check here.
-  if (getLangOpts().CPlusPlus &&
-  New->isThisDeclarationADefinition() == VarDecl::Definition) {
+  if (getLangOpts().CPlusPlus) {
 if (Old->isStaticDataMember() && Old->getCanonicalDecl()->isInline() &&
 Old->getCanonicalDecl()->isConstexpr()) {
   // This definition won't be a definition any more once it's been merged.
   Diag(New->getLocation(),
diag::warn_deprecated_redundant_constexpr_static_def);
-} else if (VarDecl *Def = Old->getDefinition()) {
-  if (checkVarDeclRedefinition(Def, New))
+} else if (New->isThisDeclarationADefinition() == VarDecl::Definition) {
+  VarDecl *Def = Old->getDefinition();
+  if (Def && checkVarDeclRedefinition(Def, New))
 return;
 }
   }


Index: clang/test/CXX/basic/basic.def/p2.cpp
===
--- clang/test/CXX/basic/basic.def/p2.cpp
+++ clang/test/CXX/basic/basic.def/p2.cpp
@@ -5,4 +5,9 @@
 static constexpr int n = 0;
   };
   const int A::n; // expected-warning {{deprecated}}
+
+  struct B {
+static constexpr int m = 0;
+  };
+  constexpr int B::m; // expected-warning {{deprecated}}
 }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -4508,15 +4508,15 @@
   }
 
   // C++ doesn't have tentative definitions, so go right ahead and check here.
-  if (getLangOpts().CPlusPlus &&
-  New->isThisDeclarationADefinition() == VarDecl::Definition) {
+  if (getLangOpts().CPlusPlus) {
 if (Old->isStaticDataMember() && Old->getCanonicalDecl()->isInline() &&
 Old->getCanonicalDecl()->isConstexpr()) {
   // This definition won't be a definition any more once it's been merged.
   Diag(New->getLocation(),
diag::warn_deprecated_redundant_constexpr_static_def);
-} else if (VarDecl *Def = Old->getDefinition()) {
-  if (checkVarDeclRedefinition(Def, New))
+} else if (New->isThisDeclarationADefinition() == VarDecl::Definition) {
+  VarDecl *Def = Old->getDefinition();
+  if (Def && checkVarDeclRedefinition(Def, New))
 return;
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126481: [analyzer] Handle SymbolCast in SValBuilder

2022-05-30 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov accepted this revision.
ASDenysPetrov added a comment.
This revision is now accepted and ready to land.

In D126481#3545350 , @martong wrote:

> This part of the SValBuilder is responsible for **constant folding**. We need 
> this constant folding, so the engine can work with less symbols, this way it 
> can be more efficient. Whenever a symbol is constrained with a constant then 
> we substitute the symbol with the corresponding integer. If a symbol is 
> constrained with a range, then the symbol is kept and we fall-back to use the 
> range based constraint manager, which is not that efficient. This patch is 
> the natural extension of the existing constant folding machinery with the 
> support of `SymbolCast` symbols.

Now I see. Thanks. I also wouldn't mind if you add this explanation to the 
summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126481

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


[PATCH] D120540: [Driver] Enable to use C++20 modules standalone by -fcxx-modules

2022-05-30 Thread Daniel McIntosh via Phabricator via cfe-commits
DanielMcIntosh-IBM added inline comments.



Comment at: clang/test/Driver/modules.cpp:79-86
+// RUN: %clang++ -fcxx-modules -std=c++17 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX17-MODULES
+// CHECK-CXX17-MODULES: "-fcxx-modules"
+// RUN: %clang++ -fcxx-modules -std=c++14 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX14-MODULES
+// CHECK-CXX14-MODULES: "-fcxx-modules"
+// RUN: %clang++ -fcxx-modules -std=c++11 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX11-MODULES
+// CHECK-CXX11-MODULES: "-fcxx-modules"
+// RUN: %clang++ -fcxx-modules -std=c++03 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX03-MODULES

1. Do we really need separate check prefixes for each of these? The general 
practice seems to be to re-use the check prefix if we are expecting the same 
output (e.g. in this very file we use CHECK-COMPILE twice and CHECK-PRECOMPILE 
three times)
2. Is there some reason not to pass either `--precompile` or `-S` for any of 
these tests like we do with the rest of the existing tests? Without that, this 
test fails when a toolchain doesn't support linking. Based on the rest of this 
test, I would have guessed that linking is outside the scope of this test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120540

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


[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Mac/arm: 
http://45.33.8.238/macm1/36297/step_7.txt

Please take a look and revert for now if it takes a while to fix. (Maybe the 
test just needs an explicit triple?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125052

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


[clang] f3defc2 - [ODRHash][NFC] Add missing 'select' case for `ODRMismatchDecl`.

2022-05-30 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-05-30T10:07:03-07:00
New Revision: f3defc23488eb29c69d2a33c0c5b652c874fb0f3

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

LOG: [ODRHash][NFC] Add missing 'select' case for `ODRMismatchDecl`.

No test changes because `err_module_odr_violation_mismatch_decl_unknown`
is a catch-all when custom diagnostic is missing. And missing custom
diagnostic we should fix by implementing it, not by improving the
general case. But if we pass enum value not covered by 'select', clang
can crash, so protect against that.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSerializationKinds.td

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td 
b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index 3fcdb616bd21a..33eba6cf0c3f2 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -375,12 +375,14 @@ def err_module_odr_violation_mismatch_decl_unknown : 
Error<
   "%q0 %select{with definition in module '%2'|defined here}1 has 
diff erent "
   "definitions in 
diff erent modules; first 
diff erence is this "
   "%select{static assert|field|method|type alias|typedef|data member|"
-  "friend declaration|unexpected decl}3">;
+  "friend declaration|function template|"
+  "unexpected decl}3">;
 def note_module_odr_violation_mismatch_decl_unknown : Note<
   "but in '%0' found "
   "%select{
diff erent static assert|
diff erent field|
diff erent method|"
   "
diff erent type alias|
diff erent typedef|
diff erent data member|"
-  "
diff erent friend declaration|another unexpected decl}1">;
+  "
diff erent friend declaration|
diff erent function template|"
+  "another unexpected decl}1">;
 
 def warn_duplicate_module_file_extension : Warning<
   "duplicate module file extension block name '%0'">,



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


[PATCH] D126566: [ODRHash][NFC] Add missing 'select' case for `ODRMismatchDecl`.

2022-05-30 Thread Volodymyr Sapsai 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 rGf3defc23488e: [ODRHash][NFC] Add missing 'select' 
case for `ODRMismatchDecl`. (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126566

Files:
  clang/include/clang/Basic/DiagnosticSerializationKinds.td


Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -375,12 +375,14 @@
   "%q0 %select{with definition in module '%2'|defined here}1 has different "
   "definitions in different modules; first difference is this "
   "%select{static assert|field|method|type alias|typedef|data member|"
-  "friend declaration|unexpected decl}3">;
+  "friend declaration|function template|"
+  "unexpected decl}3">;
 def note_module_odr_violation_mismatch_decl_unknown : Note<
   "but in '%0' found "
   "%select{different static assert|different field|different method|"
   "different type alias|different typedef|different data member|"
-  "different friend declaration|another unexpected decl}1">;
+  "different friend declaration|different function template|"
+  "another unexpected decl}1">;
 
 def warn_duplicate_module_file_extension : Warning<
   "duplicate module file extension block name '%0'">,


Index: clang/include/clang/Basic/DiagnosticSerializationKinds.td
===
--- clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -375,12 +375,14 @@
   "%q0 %select{with definition in module '%2'|defined here}1 has different "
   "definitions in different modules; first difference is this "
   "%select{static assert|field|method|type alias|typedef|data member|"
-  "friend declaration|unexpected decl}3">;
+  "friend declaration|function template|"
+  "unexpected decl}3">;
 def note_module_odr_violation_mismatch_decl_unknown : Note<
   "but in '%0' found "
   "%select{different static assert|different field|different method|"
   "different type alias|different typedef|different data member|"
-  "different friend declaration|another unexpected decl}1">;
+  "different friend declaration|different function template|"
+  "another unexpected decl}1">;
 
 def warn_duplicate_module_file_extension : Warning<
   "duplicate module file extension block name '%0'">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120244: [clang][sema] Enable first-class bool support for C2x

2022-05-30 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D120244#3540780 , @aaron.ballman 
wrote:

> In D120244#3540746 , @aaron.ballman 
> wrote:
>
>> I'll roll back the `#warning` use and report back when that's done.
>
> I've rolled it back in 6273b5cbcdd346a833120c55061ab56f61827068 
> .

Thank you! I've filed a bug report about Foundation to let them know about 
their usage of `` which is deprecated in C2x.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120244

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


[PATCH] D126669: Remove dependence on linking support from clang/test/Driver/modules.cpp

2022-05-30 Thread Daniel McIntosh via Phabricator via cfe-commits
DanielMcIntosh-IBM created this revision.
DanielMcIntosh-IBM added reviewers: MaskRay, ChuanqiXu, iains, jansvoboda11, 
Bigcheese, rsmith.
Herald added a subscriber: StephenFan.
Herald added a project: All.
DanielMcIntosh-IBM requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The new tests in clang/test/Driver/modules.cpp added by D120540 
 will fail if the
toolchain getting tested doesn't support linking. This reduces the utility of
the test since we would like a failure of this test to reflect a problem with
modules. We should already have other tests that validate linking support.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126669

Files:
  clang/test/Driver/modules.cpp


Index: clang/test/Driver/modules.cpp
===
--- clang/test/Driver/modules.cpp
+++ clang/test/Driver/modules.cpp
@@ -76,11 +76,8 @@
 
 // Check the independent use of -fcxx-modules
 //
-// RUN: %clang -fcxx-modules -std=c++17 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX17-MODULES
-// CHECK-CXX17-MODULES: "-fcxx-modules"
-// RUN: %clang -fcxx-modules -std=c++14 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX14-MODULES
-// CHECK-CXX14-MODULES: "-fcxx-modules"
-// RUN: %clang -fcxx-modules -std=c++11 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX11-MODULES
-// CHECK-CXX11-MODULES: "-fcxx-modules"
-// RUN: %clang -fcxx-modules -std=c++03 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX03-MODULES
-// CHECK-CXX03-MODULES: "-fcxx-modules"
+// RUN: %clang -fcxx-modules -std=c++17 -### -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX-MODULES
+// RUN: %clang -fcxx-modules -std=c++14 -### -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX-MODULES
+// RUN: %clang -fcxx-modules -std=c++11 -### -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX-MODULES
+// RUN: %clang -fcxx-modules -std=c++03 -### -c %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX-MODULES
+// CHECK-CXX-MODULES: "-fcxx-modules"


Index: clang/test/Driver/modules.cpp
===
--- clang/test/Driver/modules.cpp
+++ clang/test/Driver/modules.cpp
@@ -76,11 +76,8 @@
 
 // Check the independent use of -fcxx-modules
 //
-// RUN: %clang -fcxx-modules -std=c++17 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX17-MODULES
-// CHECK-CXX17-MODULES: "-fcxx-modules"
-// RUN: %clang -fcxx-modules -std=c++14 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX14-MODULES
-// CHECK-CXX14-MODULES: "-fcxx-modules"
-// RUN: %clang -fcxx-modules -std=c++11 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX11-MODULES
-// CHECK-CXX11-MODULES: "-fcxx-modules"
-// RUN: %clang -fcxx-modules -std=c++03 -### %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX03-MODULES
-// CHECK-CXX03-MODULES: "-fcxx-modules"
+// RUN: %clang -fcxx-modules -std=c++17 -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX-MODULES
+// RUN: %clang -fcxx-modules -std=c++14 -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX-MODULES
+// RUN: %clang -fcxx-modules -std=c++11 -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX-MODULES
+// RUN: %clang -fcxx-modules -std=c++03 -### -c %s 2>&1 | FileCheck %s --check-prefix=CHECK-CXX-MODULES
+// CHECK-CXX-MODULES: "-fcxx-modules"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D120540: [Driver] Enable to use C++20 modules standalone by -fcxx-modules

2022-05-30 Thread Daniel McIntosh via Phabricator via cfe-commits
DanielMcIntosh-IBM added inline comments.



Comment at: clang/test/Driver/modules.cpp:79-86
+// RUN: %clang++ -fcxx-modules -std=c++17 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX17-MODULES
+// CHECK-CXX17-MODULES: "-fcxx-modules"
+// RUN: %clang++ -fcxx-modules -std=c++14 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX14-MODULES
+// CHECK-CXX14-MODULES: "-fcxx-modules"
+// RUN: %clang++ -fcxx-modules -std=c++11 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX11-MODULES
+// CHECK-CXX11-MODULES: "-fcxx-modules"
+// RUN: %clang++ -fcxx-modules -std=c++03 -### %s 2>&1 | FileCheck %s 
--check-prefix=CHECK-CXX03-MODULES

DanielMcIntosh-IBM wrote:
> 1. Do we really need separate check prefixes for each of these? The general 
> practice seems to be to re-use the check prefix if we are expecting the same 
> output (e.g. in this very file we use CHECK-COMPILE twice and 
> CHECK-PRECOMPILE three times)
> 2. Is there some reason not to pass either `--precompile` or `-S` for any of 
> these tests like we do with the rest of the existing tests? Without that, 
> this test fails when a toolchain doesn't support linking. Based on the rest 
> of this test, I would have guessed that linking is outside the scope of this 
> test?
Or, instead of `--precompile` or `-S`, `-c` would also prevent this test from 
requiring linking support. I've created a patch to address these issues: D126669


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120540

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


[PATCH] D126669: [Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp

2022-05-30 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This change is fine (if I were adding the tests in the first place, I'd add -c 
or -S), but I'd like to understand why you have such a toolchain not supporting 
linking.
Such special requirements make me feel odd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126669

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


[PATCH] D126364: Fix interaction of pragma FENV_ACCESS with other pragmas

2022-05-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> setRoundingMode definitely should not call getAllowFEnvAccess() and it does 
> not

Yes, it does?

  // C2x: 7.6.2p3  If the FE_DYNAMIC mode is specified and FENV_ACCESS is "off",
  // the translator may assume that the default rounding mode is in effect.
  if (FPR == llvm::RoundingMode::Dynamic &&
  !CurFPFeatures.getAllowFEnvAccess() &&
  CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Ignore)
FPR = llvm::RoundingMode::NearestTiesToEven;



> As for ActOnPragmaFEnvAccess, it make sense to set the most general mode.

Shouldn't the default mode just be "dynamic"?  The fact that we emit non-strict 
floating-point ops if FENV_ACCESS is disabled is an implementation detail.  I 
don't see the point of switching the rounding mode between "Dynamic" and 
"NearestTiesToEven" depending on whether FENV_ACCESS is enabled.  Making the 
required state transitions complicated like this just makes the code harder to 
understand.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126364

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


[PATCH] D126566: [ODRHash][NFC] Add missing 'select' case for `ODRMismatchDecl`.

2022-05-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126566

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


[PATCH] D126669: [Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp

2022-05-30 Thread Daniel McIntosh via Phabricator via cfe-commits
DanielMcIntosh-IBM added a comment.

In D126669#3546172 , @MaskRay wrote:

> This change is fine (if I were adding the tests in the first place, I'd add 
> -c or -S), but I'd like to understand why you have such a toolchain not 
> supporting linking.
> Such special requirements make me feel odd.

Downstream we have a branch that only contains some of the required changes for 
z/OS support, but which we still run tests on (why this is the case is a long 
story, but it's something we're working on fixing, it's just going to take a 
very long time to do so). This test is failing on that branch. Rather than 
loose the test, I figured I'd improve the test and in the process get it 
working again on that branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126669

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


[clang] c4eb803 - Revert "[HLSL] Enable vector types for hlsl."

2022-05-30 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2022-05-30T14:11:07-04:00
New Revision: c4eb8035ed6647e58d4c5161f393e9220f7402cf

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

LOG: Revert "[HLSL] Enable vector types for hlsl."

This reverts commit e576280380d3f5221cfcc14e9fabeacc8506a43c.
Breaks tests on mac/arm, see comment on https://reviews.llvm.org/D125052

Also revert follow-up "[gn build] Port e576280380d3"
This reverts commit 1e01b1ec72031fcaceb4e77e1c5c8e34f1e862e8.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Basic/LangOptions.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/lib/Headers/CMakeLists.txt
llvm/utils/gn/secondary/clang/lib/Headers/BUILD.gn

Removed: 
clang/lib/Headers/hlsl.h
clang/lib/Headers/hlsl/hlsl_basic_types.h
clang/test/CodeGenHLSL/basic_types.hlsl
clang/test/Driver/hlsl_no_stdinc.hlsl



diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 44fd4d50ca051..0343e48c1a9d1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6051,7 +6051,7 @@ def fdefault_calling_conv_EQ : Joined<["-"], 
"fdefault-calling-conv=">,
 
 // These options cannot be marshalled, because they are used to set up the 
LangOptions defaults.
 def finclude_default_header : Flag<["-"], "finclude-default-header">,
-  HelpText<"Include default header file for OpenCL and HLSL">;
+  HelpText<"Include default header file for OpenCL">;
 def fdeclare_opencl_builtins : Flag<["-"], "fdeclare-opencl-builtins">,
   HelpText<"Add OpenCL builtin function declarations (experimental)">;
 
@@ -6780,8 +6780,6 @@ class DXCJoinedOrSeparate : Option<["/", 
"-"], name,
 def dxc_help : Option<["/", "-", "--"], "help", KIND_JOINED>,
   Group, Flags<[DXCOption, NoXarchOption]>, Alias,
   HelpText<"Display available options">;
-def dxc_no_stdinc : DXCFlag<"hlsl-no-stdinc">,
-  HelpText<"HLSL only. Disables all standard includes containing non-native 
compiler types and functions.">;
 def Fo : DXCJoinedOrSeparate<"Fo">, Alias,
   HelpText<"Output object file">;
 def dxil_validator_version : Option<["/", "-"], "validator-version", 
KIND_SEPARATE>,

diff  --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 7549f3f2e23b4..7791bff388be7 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -117,8 +117,6 @@ void LangOptions::setLangDefaults(LangOptions &Opts, 
Language Lang,
   Opts.Digraphs = Std.hasDigraphs();
 
   Opts.HLSL = Lang == Language::HLSL;
-  if (Opts.HLSL && Opts.IncludeDefaultHeader)
-Includes.push_back("hlsl.h");
 
   // Set OpenCL Version.
   Opts.OpenCL = Std.isOpenCL();

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index a8706215bf605..5106c0e327b87 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3484,9 +3484,6 @@ static void RenderHLSLOptions(const ArgList &Args, 
ArgStringList &CmdArgs,
   for (const auto &Arg : ForwardedArguments)
 if (const auto *A = Args.getLastArg(Arg))
   A->renderAsInput(Args, CmdArgs);
-  // Add the default headers if dxc_no_stdinc is not set.
-  if (!Args.hasArg(options::OPT_dxc_no_stdinc))
-CmdArgs.push_back("-finclude-default-header");
 }
 
 static void RenderARCMigrateToolOptions(const Driver &D, const ArgList &Args,

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index a51d4621ba682..32b084dfedecc 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -4202,10 +4202,6 @@ static void GeneratePreprocessorArgs(PreprocessorOptions 
&Opts,
 ((LangOpts.DeclareOpenCLBuiltins && I == "opencl-c-base.h") ||
  I == "opencl-c.h"))
   continue;
-// Don't generate HLSL includes. They are implied by other flags that are
-// generated elsewhere.
-if (LangOpts.HLSL && I == "hlsl.h")
-  continue;
 
 GenerateArg(Args, OPT_include, I, SA);
   }

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 4c5e7325d7960..3921f7949a0a9 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -377,10 +377,6 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
 Builder.defineMacro("__HLSL_VERSION",
 Twine((unsigned)LangOpts.getHLSLVersion()));
 
-if (LangOpts.NativeHalfType)
-  Builder.defineMacro("__HLSL_ENABLE_16_BIT",
-  Twine((unsigned)LangOpts.getHLSLVersion()));
-
 // Shader target informatio

[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted in c4eb8035ed6647e58d4c5161f393e9220f7402cf 
 for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125052

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


[PATCH] D126671: cmake: fix clang standalone build

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a subscriber: mgorny.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

D126308  broke building clang standalone, as 
LLVM_UTILS_INSTALL_DIR is
not exported.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126671

Files:
  clang/utils/hmaptool/CMakeLists.txt


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@
COMMAND "${CMAKE_COMMAND}" -E copy 
"${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT 
hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126308: cmake: use llvm dir variables for clang/utils/hmaptool

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D126308#3545937 , @Ericson2314 
wrote:

> There is a lot of cruft behind the signs. I would just use 
> `LLVM_TOOLS_INSTALL_DIR` then which is exported to get this unblocked, and 
> I'll rebase D117977  to try to clean these 
> things up later.

Done in https://reviews.llvm.org/D126671


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126308

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


[PATCH] D126337: [pseudo] WIP: GSS node refcounting (dumb pointers)

2022-05-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/pseudo/lib/GLR.cpp:118
+CheckRefcounts();
+for (const auto *Head : NewHeads) {
   AddSteps(Head, Terminal.symbol());

> The freelist works well (on AST.cpp, 35K nodes created but only 74 allocated),

The number of saving is quite promising! But as discussed, it didn't speed up 
the parser (mostly we're paying extra cost of updating nodes in dead branches, 
causing ~10% slowdown).

Wanted to explore an alternative (which we discussed briefly)  -- for 
errory-recovery, the key point is that  when there is no active head, we'd like 
to find a recovery state (retrieved from the most-recent live heads) and 
continue the parsing from there.

This main parsing for-loop can provide a global view of active heads:
- we can assume here the `NewHeads` is not empty (for-loop body always starts 
with active heads);
- if all heads die, we can detect it after the `glrReduce` (on Line130, by 
checking `PendingShift` is empty);

So the code is roughly like

```
for ( ... : Terminals) {
  auto PreviousNewHeads = NewHeads;

  
  glrReduce(...);

  if (PendingShift.empty()) {
// run error-recovery from the PreviousNewHeads
  } else {
glrShift(...);
  }
}
``` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126337

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


[PATCH] D126672: [Driver] Add multiarch path for RISC-V

2022-05-30 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld created this revision.
Hahnfeld added a reviewer: sylvestre.ledru.
Herald added subscribers: sunshaoce, VincentWu, luke957, vkmr, luismarques, 
sameer.abuasal, s.egerton, Jim, PkmX, rogfer01, shiva0217, kito-cheng, 
simoncook, arichardson.
Herald added a project: All.
Hahnfeld requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

This is required to find headers on the Debian port for RISC-V.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126672

Files:
  clang/lib/Driver/ToolChains/Linux.cpp


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -124,6 +124,8 @@
 return "powerpc64-linux-gnu";
   case llvm::Triple::ppc64le:
 return "powerpc64le-linux-gnu";
+  case llvm::Triple::riscv64:
+return "riscv64-linux-gnu";
   case llvm::Triple::sparc:
 return "sparc-linux-gnu";
   case llvm::Triple::sparcv9:


Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -124,6 +124,8 @@
 return "powerpc64-linux-gnu";
   case llvm::Triple::ppc64le:
 return "powerpc64le-linux-gnu";
+  case llvm::Triple::riscv64:
+return "riscv64-linux-gnu";
   case llvm::Triple::sparc:
 return "sparc-linux-gnu";
   case llvm::Triple::sparcv9:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D125052: [HLSL] Enable vector types for hlsl.

2022-05-30 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added a comment.

In D125052#3546205 , @thakis wrote:

> Reverted in c4eb8035ed6647e58d4c5161f393e9220f7402cf 
>  for now.

Hi thakis,
The issue could be fixed by https://reviews.llvm.org/D125585
Could you take a look?
Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125052

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


[PATCH] D126674: [clang] NFC: introduce test for D126620

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126674

Files:
  clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp


Index: clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -74,3 +74,16 @@
   int array0[Outer::Inner::value? 1 : -1];
   int array1[Outer::Inner::value? -1 : 1];
 }
+
+namespace print_dependent_TemplateSpecializationType {
+
+template  struct Foo {
+  template  struct Bar;
+  template  struct Bar<0, T, Y> {};
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, 
type-parameter-0-0>' is here}}
+  template  struct Bar<0, U, Y> {};
+  // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be 
redeclared}}
+};
+template struct Foo; // expected-note {{requested here}}
+
+} // namespace print_dependent_TemplateSpecializationType


Index: clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -74,3 +74,16 @@
   int array0[Outer::Inner::value? 1 : -1];
   int array1[Outer::Inner::value? -1 : 1];
 }
+
+namespace print_dependent_TemplateSpecializationType {
+
+template  struct Foo {
+  template  struct Bar;
+  template  struct Bar<0, T, Y> {};
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, type-parameter-0-0>' is here}}
+  template  struct Bar<0, U, Y> {};
+  // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be redeclared}}
+};
+template struct Foo; // expected-note {{requested here}}
+
+} // namespace print_dependent_TemplateSpecializationType
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 9331912 - cmake: fix clang standalone build

2022-05-30 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2022-05-30T21:56:38+02:00
New Revision: 93319128d0d4eda22ce8d531ba668cb8c7c8c8e8

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

LOG: cmake: fix clang standalone build

D126308 broke building clang standalone, as LLVM_UTILS_INSTALL_DIR is
not exported.

Signed-off-by: Matheus Izvekov 

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

Added: 


Modified: 
clang/utils/hmaptool/CMakeLists.txt

Removed: 




diff  --git a/clang/utils/hmaptool/CMakeLists.txt 
b/clang/utils/hmaptool/CMakeLists.txt
index 375d7b044882..01b6a920fb94 100644
--- a/clang/utils/hmaptool/CMakeLists.txt
+++ b/clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@ add_custom_command(OUTPUT "${LLVM_TOOLS_BINARY_DIR}/hmaptool"
COMMAND "${CMAKE_COMMAND}" -E copy 
"${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT 
hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 



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


[PATCH] D126671: cmake: fix clang standalone build

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG93319128d0d4: cmake: fix clang standalone build (authored by 
mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126671

Files:
  clang/utils/hmaptool/CMakeLists.txt


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@
COMMAND "${CMAKE_COMMAND}" -E copy 
"${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT 
hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT 
hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 


Index: clang/utils/hmaptool/CMakeLists.txt
===
--- clang/utils/hmaptool/CMakeLists.txt
+++ clang/utils/hmaptool/CMakeLists.txt
@@ -2,7 +2,7 @@
COMMAND "${CMAKE_COMMAND}" -E copy "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool" "${LLVM_TOOLS_BINARY_DIR}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/hmaptool")
 
-install(PROGRAMS hmaptool DESTINATION "${LLVM_UTILS_INSTALL_DIR}" COMPONENT hmaptool)
+install(PROGRAMS hmaptool DESTINATION "${LLVM_TOOLS_INSTALL_DIR}" COMPONENT hmaptool)
 add_custom_target(hmaptool ALL DEPENDS "${LLVM_TOOLS_BINARY_DIR}/hmaptool")
 set_target_properties(hmaptool PROPERTIES FOLDER "Utils")
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126620: [clang] AST/Print: honor AlwaysIncludeTypeForTemplateArgument policy

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov updated this revision to Diff 432974.
mizvekov retitled this revision from "WIP" to "[clang] AST/Print: honor 
AlwaysIncludeTypeForTemplateArgument policy".
mizvekov edited the summary of this revision.
mizvekov added a comment.
mizvekov published this revision for review.
mizvekov added reviewers: rsmith, v.g.vassilev, reikdas.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

.


This redoes D103040  in a way that 
`AlwaysIncludeTypeForTemplateArgument = false`
policy is honored for printing template specialization types.
This can be seen for example when printing a canonicalized
dependent TemplateSpecializationType which has integral arguments.

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126620

Files:
  clang/lib/AST/TypePrinter.cpp
  clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp


Index: clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -80,7 +80,7 @@
 template  struct Foo {
   template  struct Bar;
   template  struct Bar<0, T, Y> {};
-  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, 
type-parameter-0-0>' is here}}
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0, int, 
type-parameter-0-0>' is here}}
   template  struct Bar<0, U, Y> {};
   // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be 
redeclared}}
 };
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -80,6 +80,21 @@
 }
   };
 
+  class DefaultTemplateArgsPolicyRAII {
+PrintingPolicy &Policy;
+bool Old;
+
+  public:
+explicit DefaultTemplateArgsPolicyRAII(PrintingPolicy &Policy)
+: Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) {
+  Policy.SuppressDefaultTemplateArgs = false;
+}
+
+~DefaultTemplateArgsPolicyRAII() {
+  Policy.SuppressDefaultTemplateArgs = Old;
+}
+  };
+
   class ElaboratedTypePolicyRAII {
 PrintingPolicy &Policy;
 bool SuppressTagKeyword;
@@ -1470,6 +1485,7 @@
   IncludeStrongLifetimeRAII Strong(Policy);
 
   TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl();
+  // FIXME: Null TD never excercised in test suite.
   if (FullyQualify && TD) {
 if (!Policy.SuppressScope)
   AppendScope(TD->getDeclContext(), OS, TD->getDeclName());
@@ -1479,7 +1495,9 @@
 T->getTemplateName().print(OS, Policy);
   }
 
-  printTemplateArgumentList(OS, T->template_arguments(), Policy);
+  DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
+  const TemplateParameterList *TPL = TD ? TD->getTemplateParameters() : 
nullptr;
+  printTemplateArgumentList(OS, T->template_arguments(), Policy, TPL);
   spaceBeforePlaceHolder(OS);
 }
 


Index: clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -80,7 +80,7 @@
 template  struct Foo {
   template  struct Bar;
   template  struct Bar<0, T, Y> {};
-  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, type-parameter-0-0>' is here}}
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0, int, type-parameter-0-0>' is here}}
   template  struct Bar<0, U, Y> {};
   // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be redeclared}}
 };
Index: clang/lib/AST/TypePrinter.cpp
===
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -80,6 +80,21 @@
 }
   };
 
+  class DefaultTemplateArgsPolicyRAII {
+PrintingPolicy &Policy;
+bool Old;
+
+  public:
+explicit DefaultTemplateArgsPolicyRAII(PrintingPolicy &Policy)
+: Policy(Policy), Old(Policy.SuppressDefaultTemplateArgs) {
+  Policy.SuppressDefaultTemplateArgs = false;
+}
+
+~DefaultTemplateArgsPolicyRAII() {
+  Policy.SuppressDefaultTemplateArgs = Old;
+}
+  };
+
   class ElaboratedTypePolicyRAII {
 PrintingPolicy &Policy;
 bool SuppressTagKeyword;
@@ -1470,6 +1485,7 @@
   IncludeStrongLifetimeRAII Strong(Policy);
 
   TemplateDecl *TD = T->getTemplateName().getAsTemplateDecl();
+  // FIXME: Null TD never excercised in test suite.
   if (FullyQualify && TD) {
 if (!Policy.SuppressScope)
   AppendScope(TD->getDeclContext(), OS, TD->getDeclName());
@@ -1479,7 +1495,9 @@
 T->getTemplateName().print(OS, Policy);
   }
 
-  printTemplateArgumentList(OS, T->template_arguments(), Policy);
+  DefaultTemplateArgsPolicyRAII TemplateArgs(Policy);
+  const TemplateParameterList *TPL 

[PATCH] D126676: [clang] Disallow differences in defines used for creating and using PCH

2022-05-30 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: aaron.ballman, rnk.
Herald added a project: All.
mstorsjo requested review of this revision.
Herald added a project: clang.

Some amount of differences between defines when creating and using
a PCH were intentionally allowed in
c379c072405f39bca1d3552408fc0427328e8b6d (and later extended in
b63687519610a73dd565be1fec28332211b4df5b).

When using a PCH (or when picking a PCH out of a directory containing
multiple candidates) Clang used to accept the header if there were
defines on the command line when creating the PCH that are missing
when using the PCH, or vice versa, defines only set when using the
PCH.

The only cases where Clang explicitly rejected the use of a PCH
is if there was an explicit conflict between the options, e.g.
-DFOO=1 vs -DFOO=2, or -DFOO vs -UFOO.

The latter commit added a FIXME that we really should check whether
mismatched defines actually were used somewhere in the PCH, so that
the define would affect the outcome. This FIXME has stood unaddressed
since 2012.

This differs from GCC, which rejects PCH files if the defines differ
at all.

This is also problematic when using a directory containing multiple
candidate PCH files, one built with -DFOO and one without. When
attempting to include a PCH and iterating over the candidates in the
directory, Clang will essentially pick the first one out of the two,
even if there existed a better, exact match in the directory.

This fixes https://github.com/lhmouse/mcfgthread/issues/63.

This is likely to be controversial. In tree, 84 tests break by
making this change. This patch only fixes up the core tests for
this feature (to bring it up for discussion); out of the rest, some
probably are easy to fix, while others seem to be designed to specifically
test cases with such discrepancies.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126676

Files:
  clang/lib/Serialization/ASTReader.cpp
  clang/test/PCH/fuzzy-pch.c
  clang/test/PCH/pch-dir.c

Index: clang/test/PCH/pch-dir.c
===
--- clang/test/PCH/pch-dir.c
+++ clang/test/PCH/pch-dir.c
@@ -6,7 +6,7 @@
 // RUN: %clang -x c++-header -std=c++98 %S/pch-dir.h -o %t.h.gch/cpp.gch 
 // RUN: %clang -include %t.h -DFOO=foo -fsyntax-only %s -Xclang -print-stats 2> %t.clog
 // RUN: FileCheck -check-prefix=CHECK-C %s < %t.clog
-// RUN: %clang -include %t.h -DFOO=bar -DBAR=bar -fsyntax-only %s -Xclang -ast-print > %t.cbarlog
+// RUN: %clang -include %t.h -DFOO=bar -fsyntax-only %s -Xclang -ast-print > %t.cbarlog
 // RUN: FileCheck -check-prefix=CHECK-CBAR %s < %t.cbarlog
 // RUN: %clang -x c++ -include %t.h -std=c++98 -fsyntax-only %s -Xclang -print-stats 2> %t.cpplog
 // RUN: FileCheck -check-prefix=CHECK-CPP %s < %t.cpplog
@@ -14,6 +14,11 @@
 // RUN: not %clang -x c++ -std=c++11 -include %t.h -fsyntax-only %s 2> %t.cpp11log
 // RUN: FileCheck -check-prefix=CHECK-NO-SUITABLE %s < %t.cpp11log
 
+// RUN: not %clang -include %t.h -fsyntax-only %s 2> %t.missinglog2
+// RUN: FileCheck -check-prefix=CHECK-NO-SUITABLE %s < %t.missinglog2
+// RUN: not %clang -include %t.h -DFOO=foo -DBAR=bar -fsyntax-only %s 2> %t.missinglog2
+// RUN: FileCheck -check-prefix=CHECK-NO-SUITABLE %s < %t.missinglog2
+
 // Don't crash if the precompiled header file is missing.
 // RUN: not %clang_cc1 -include-pch %t.h.gch -DFOO=baz -fsyntax-only %s -print-stats 2> %t.missinglog
 // RUN: FileCheck -check-prefix=CHECK-NO-SUITABLE %s < %t.missinglog
Index: clang/test/PCH/fuzzy-pch.c
===
--- clang/test/PCH/fuzzy-pch.c
+++ clang/test/PCH/fuzzy-pch.c
@@ -1,7 +1,9 @@
 // Test with pch.
 // RUN: %clang_cc1 -emit-pch -DFOO -o %t %S/variables.h
-// RUN: %clang_cc1 -DBAR=int -include-pch %t -fsyntax-only -pedantic %s
-// RUN: %clang_cc1 -DFOO -DBAR=int -include-pch %t %s
+// RUN: not %clang_cc1 -DBAR=int -include-pch %t -fsyntax-only -pedantic %s 2> %t.err
+// RUN: FileCheck -check-prefix=CHECK-BAR %s < %t.err
+// RUN: not %clang_cc1 -DFOO -DBAR=int -include-pch %t %s 2> %t.err
+// RUN: FileCheck -check-prefix=CHECK-BAR %s < %t.err
 // RUN: not %clang_cc1 -DFOO=blah -DBAR=int -include-pch %t %s 2> %t.err
 // RUN: FileCheck -check-prefix=CHECK-FOO %s < %t.err
 // RUN: not %clang_cc1 -UFOO -include-pch %t %s 2> %t.err
@@ -26,6 +28,7 @@
 
 // CHECK-FOO: definition of macro 'FOO' differs between the precompiled header ('1') and the command line ('blah')
 // CHECK-NOFOO: macro 'FOO' was defined in the precompiled header but undef'd on the command line
+// CHECK-BAR: macro 'BAR' was undef'd in the precompiled header but defined on the command line
 
 // CHECK-UNDEF: command line contains '-undef' but precompiled header was not built with it
 
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -653,11 +653,7

[PATCH] D126674: [clang] NFC: introduce test for D126620

2022-05-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev accepted this revision.
v.g.vassilev added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126674

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


[clang] c825abd - [clang] NFC: introduce test for D126620

2022-05-30 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2022-05-30T22:45:57+02:00
New Revision: c825abd6b0198fb088d9752f556a70705bc99dfd

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

LOG: [clang] NFC: introduce test for D126620

Signed-off-by: Matheus Izvekov 

Reviewed By: v.g.vassilev

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

Added: 


Modified: 
clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp

Removed: 




diff  --git a/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp 
b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
index 38dde7367fea..7eddef1cb71f 100644
--- a/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ b/clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -74,3 +74,16 @@ namespace rdar8651930 {
   int array0[Outer::Inner::value? 1 : -1];
   int array1[Outer::Inner::value? -1 : 1];
 }
+
+namespace print_dependent_TemplateSpecializationType {
+
+template  struct Foo {
+  template  struct Bar;
+  template  struct Bar<0, T, Y> {};
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, 
type-parameter-0-0>' is here}}
+  template  struct Bar<0, U, Y> {};
+  // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be 
redeclared}}
+};
+template struct Foo; // expected-note {{requested here}}
+
+} // namespace print_dependent_TemplateSpecializationType



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


[PATCH] D126674: [clang] NFC: introduce test for D126620

2022-05-30 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc825abd6b019: [clang] NFC: introduce test for D126620 
(authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126674

Files:
  clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp


Index: clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -74,3 +74,16 @@
   int array0[Outer::Inner::value? 1 : -1];
   int array1[Outer::Inner::value? -1 : 1];
 }
+
+namespace print_dependent_TemplateSpecializationType {
+
+template  struct Foo {
+  template  struct Bar;
+  template  struct Bar<0, T, Y> {};
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, 
type-parameter-0-0>' is here}}
+  template  struct Bar<0, U, Y> {};
+  // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be 
redeclared}}
+};
+template struct Foo; // expected-note {{requested here}}
+
+} // namespace print_dependent_TemplateSpecializationType


Index: clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
@@ -74,3 +74,16 @@
   int array0[Outer::Inner::value? 1 : -1];
   int array1[Outer::Inner::value? -1 : 1];
 }
+
+namespace print_dependent_TemplateSpecializationType {
+
+template  struct Foo {
+  template  struct Bar;
+  template  struct Bar<0, T, Y> {};
+  // expected-note-re@-1 {{previous declaration {{.*}} 'Bar<0UL, int, type-parameter-0-0>' is here}}
+  template  struct Bar<0, U, Y> {};
+  // expected-error@-1 {{partial specialization 'Bar<0, int, Y>' cannot be redeclared}}
+};
+template struct Foo; // expected-note {{requested here}}
+
+} // namespace print_dependent_TemplateSpecializationType
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D124525: [OpenMP][ClangLinkerWrapper] Extending linker wrapper to embed metadata for multi-arch fat binaries

2022-05-30 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Also I probably should've discussed this earlier, but another potential 
solution is to use the binary format 

 that we use to embed the object files for the images as well. This is more 
similar to how CUDA does it. Making it backwards compatible would probably 
require just assuming it's an image with no information if it doesn't include 
the magic bytes. This might be better if we want a unified tool to give 
information on embedded device formats.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124525

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


[PATCH] D123319: Change how we handle auto return types for lambda operator() to be consistent with gcc

2022-05-30 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D123319#3532811 , @dblaikie wrote:

> Ping

@aprantl thoughts on this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123319

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


[PATCH] D126681: [HIP] Fix static lib name on windows

2022-05-30 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added a reviewer: tra.
Herald added a project: All.
yaxunl requested review of this revision.
Herald added a subscriber: MaskRay.

clang by default assumes static library name to be xxx.lib
when -lxxx is specified on Windows with MSVC environment,
instead of libxxx.a.

This patch fixes static device library unbundling for that.
It falls back to libxxx.a if xxx.lib is not found.


https://reviews.llvm.org/D126681

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/hip-link-bundle-archive.hip


Index: clang/test/Driver/hip-link-bundle-archive.hip
===
--- clang/test/Driver/hip-link-bundle-archive.hip
+++ clang/test/Driver/hip-link-bundle-archive.hip
@@ -1,14 +1,28 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
 
-// RUN: touch %T/libhipBundled.a
 
 // Check clang unbundle the archive and link them by lld.
 
+// RUN: touch %T/libhipBundled.a
 // RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-unknown-linux-gnu \
 // RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled \
-// RUN:   2>&1 | FileCheck -check-prefix=CHECK %s
+// RUN:   2>&1 | FileCheck -check-prefix=GNU %s
+
+// RUN: touch %T/hipBundled2.lib
+// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-pc-windows-msvc \
+// RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled2 \
+// RUN:   2>&1 | FileCheck -check-prefix=MSVC %s
+
+// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
+// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
+// GNU: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
+// GNU: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// GNU: "{{.*}}ld{{.*}}" {{.*}}"-o" "a.out" {{.*}}"-lhipBundled"
 
-// CHECK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
-// CHECK: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
-// CHECK: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}libhipBundled.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
-// CHECK: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx1030" 
"-output=[[A1030:.*\.a]]" "-allow-missing-bundles"
+// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx1030" {{.*}} "[[A1030]]"
+// MSVC: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" 
"-input={{.*}}hipBundled2.lib" "-targets=hip-amdgcn-amd-amdhsa-gfx906" 
"-output=[[A906:.*\.a]]" "-allow-missing-bundles"
+// MSVC: "{{.*}}lld{{.*}}" {{.*}}"-plugin-opt=mcpu=gfx906" {{.*}} "[[A906]]"
+// MSVC: "{{.*}}link{{.*}}" {{.*}}"-out:a.exe" {{.*}}"hipBundled2.lib"
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1782,8 +1782,14 @@
   for (auto LPath : LibraryPaths) {
 ArchiveOfBundles.clear();
 
-AOBFileNames.push_back(Twine(LPath + "/libdevice/lib" + Lib + ".a").str());
-AOBFileNames.push_back(Twine(LPath + "/lib" + Lib + ".a").str());
+llvm::Triple Triple(D.getTargetTriple());
+bool IsMSVC = Triple.isWindowsMSVCEnvironment();
+for (auto Prefix : {"/libdevice/", "/"}) {
+  if (IsMSVC) {
+AOBFileNames.push_back(Twine(LPath + Prefix + Lib + ".lib").str());
+  }
+  AOBFileNames.push_back(Twine(LPath + Prefix + "lib" + Lib + ".a").str());
+}
 
 for (auto AOB : AOBFileNames) {
   if (llvm::sys::fs::exists(AOB)) {


Index: clang/test/Driver/hip-link-bundle-archive.hip
===
--- clang/test/Driver/hip-link-bundle-archive.hip
+++ clang/test/Driver/hip-link-bundle-archive.hip
@@ -1,14 +1,28 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
 
-// RUN: touch %T/libhipBundled.a
 
 // Check clang unbundle the archive and link them by lld.
 
+// RUN: touch %T/libhipBundled.a
 // RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-unknown-linux-gnu \
 // RUN:   -nogpulib %s -fgpu-rdc -L%T -lhipBundled \
-// RUN:   2>&1 | FileCheck -check-prefix=CHECK %s
+// RUN:   2>&1 | FileCheck -check-prefix=GNU %s
+
+// RUN: touch %T/hipBundled2.lib
+// RUN: %clang -### --offload-arch=gfx906 --offload-arch=gfx1030 \
+// RUN:   -target x86_64-pc-windows-msvc \
+// RUN:   -nogpulib %s

Re: Call for an assistance pushing patch review forward

2022-05-30 Thread David Blaikie via cfe-commits
Beyond that it may be useful to look at who's been contributing to the
code you're trying to change and consider cc'ing them on the review.
(if they can't help, maybe they can point you to someone who can)

On Fri, May 27, 2022 at 2:23 PM stryku_t via cfe-commits
 wrote:
>
> Hi Paul,
>
> Thank you for the tips.
> Pinging is indeed mentioned in the docs, but I didn't want to piss everyone 
> off, so after two pings I thought that I'm doing something wrong. From now on 
> I'll ping once a week in such situations.
>
> Got review comments now, so we're back on track. Gonna implement changes over 
> the weekend.
>
> Thanks,
> Mateusz Janek
>
> czw., 26 maj 2022 o 22:51 Robinson, Paul  napisał(a):
>>
>> Hi Mateusz,
>>
>>
>>
>> I wouldn’t worry too much about the failed build.  I took a peek and it 
>> looks like the failures are mostly in places very unrelated to your patch.  
>> If your own testing shows no problems, it’s very likely you’re fine.
>>
>>
>>
>> Regarding lack of response, this is unfortunately more common than it should 
>> be.  Our recommended practice—and I’m surprised we don’t say anything on the 
>> website—is to add a “ping” comment to your review, maybe once a week.  This 
>> can “bump” it up in someone’s to-be-reviewed list; if nothing else, there’s 
>> another email to the list that will hopefully catch someone’s attention.
>>
>>
>>
>> Good luck,
>>
>> --paulr
>>
>>
>>
>> From: cfe-commits  On Behalf Of stryku_t 
>> via cfe-commits
>> Sent: Thursday, May 26, 2022 4:20 PM
>> To: cfe-commits@lists.llvm.org
>> Subject: Call for an assistance pushing patch review forward
>>
>>
>>
>> Hi,
>>
>> Some time ago I submitted a Clang patch for review: 
>> https://reviews.llvm.org/D123532
>>
>> It's been some time and I can't make progress with it.
>> I'm aware that there is failed build. But, as I mentioned in one of the 
>> comments, I can't reproduce it locally.
>> Tried to reach out to the people mentioned in the review, but I struggle 
>> getting answers.
>> At this point I'm not sure if I'm doing something wrong or people are just 
>> busy. Should tag different people? Different project? Am I expected to 
>> figure out failed builds on my own before someone will review the changes?
>>
>> Could someone from the community please assist me how for move forward with 
>> this patch? Also, I'd be grateful if there's someone who can hint me how to 
>> reproduce failed builds locally or using some CI server.
>>
>> Thanks in advance!
>>
>> Best regards,
>> Mateusz Janek
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D126669: [Driver][Modules] Remove dependence on linking support from clang/test/Driver/modules.cpp

2022-05-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126669

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


[PATCH] D124753: [HLSL] Set main as default entry.

2022-05-30 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added a comment.

In D124753#3545779 , @Anastasia wrote:

> From the current change it seems to me that what you need to be testing is a 
> just that the frontend options are being passed correctly? This should then 
> be a driver test with `-###` checking for the options to be set for the 
> frontend invocation...

There's already a driver test with '-###' in 
https://reviews.llvm.org/D124751#change-af6Z62NjlfGb


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124753

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


[PATCH] D124753: [HLSL] Set main as default entry.

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

Add new line at end of file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124753

Files:
  clang/include/clang/Driver/Options.td
  clang/test/CodeGenHLSL/entry_default.hlsl


Index: clang/test/CodeGenHLSL/entry_default.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/entry_default.hlsl
@@ -0,0 +1,28 @@
+// RUN: %clang --driver-mode=dxc -Tcs_6_1 -fcgl -Fo - %s | FileCheck %s
+// RUN: %clang --driver-mode=dxc -Efoo -Tcs_6_1 -fcgl -Fo - %s | FileCheck %s 
--check-prefix=NOTMAIN
+
+// Make sure main is default entry.
+// Make sure not mangle entry.
+// CHECK:define void @main() [[MAIN_ATTR:#[0-9]]]
+// CHECK:define void @_Z3foov() [[FOO_ATTR:#[0-9]]]
+// Make sure only main has dx.shader attribute.
+// CHECK:[[MAIN_ATTR]]
+// CHECK:"dx.shader"="compute"
+// CHECK-SAME:}
+// CHECK:[[FOO_ATTR]]
+// CHECK-NOT:"dx.shader"="compute"
+[numthreads(1, 1, 1)] void main() {
+
+}
+
+// NOTMAIN:define void @main() [[MAIN_ATTR:#[0-9]]]
+// NOTMAIN:define void @foo() [[FOO_ATTR:#[0-9]]]
+// Make sure only foo has dx.shader attribute.
+// NOTMAIN:[[MAIN_ATTR]]
+// NOTMAIN-NOT:"dx.shader"="compute"
+// NOTMAIN-SAME:}
+// NOTMAIN:[[FOO_ATTR]]
+// NOTMAIN-SAME:"dx.shader"="compute"
+[numthreads(1, 1, 1)] void foo() {
+
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6810,5 +6810,5 @@
 def hlsl_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>,
   Group,
   Flags<[DXCOption, CC1Option, NoXarchOption]>,
-  MarshallingInfoString>,
+  MarshallingInfoString, 
"\"main\"">,
   HelpText<"Entry point name">;


Index: clang/test/CodeGenHLSL/entry_default.hlsl
===
--- /dev/null
+++ clang/test/CodeGenHLSL/entry_default.hlsl
@@ -0,0 +1,28 @@
+// RUN: %clang --driver-mode=dxc -Tcs_6_1 -fcgl -Fo - %s | FileCheck %s
+// RUN: %clang --driver-mode=dxc -Efoo -Tcs_6_1 -fcgl -Fo - %s | FileCheck %s --check-prefix=NOTMAIN
+
+// Make sure main is default entry.
+// Make sure not mangle entry.
+// CHECK:define void @main() [[MAIN_ATTR:#[0-9]]]
+// CHECK:define void @_Z3foov() [[FOO_ATTR:#[0-9]]]
+// Make sure only main has dx.shader attribute.
+// CHECK:[[MAIN_ATTR]]
+// CHECK:"dx.shader"="compute"
+// CHECK-SAME:}
+// CHECK:[[FOO_ATTR]]
+// CHECK-NOT:"dx.shader"="compute"
+[numthreads(1, 1, 1)] void main() {
+
+}
+
+// NOTMAIN:define void @main() [[MAIN_ATTR:#[0-9]]]
+// NOTMAIN:define void @foo() [[FOO_ATTR:#[0-9]]]
+// Make sure only foo has dx.shader attribute.
+// NOTMAIN:[[MAIN_ATTR]]
+// NOTMAIN-NOT:"dx.shader"="compute"
+// NOTMAIN-SAME:}
+// NOTMAIN:[[FOO_ATTR]]
+// NOTMAIN-SAME:"dx.shader"="compute"
+[numthreads(1, 1, 1)] void foo() {
+
+}
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -6810,5 +6810,5 @@
 def hlsl_entrypoint : Option<["--", "/", "-"], "E", KIND_JOINED_OR_SEPARATE>,
   Group,
   Flags<[DXCOption, CC1Option, NoXarchOption]>,
-  MarshallingInfoString>,
+  MarshallingInfoString, "\"main\"">,
   HelpText<"Entry point name">;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119646: [clang] Allow consteval functions in default arguments

2022-05-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu accepted this revision as: ChuanqiXu.
ChuanqiXu added a comment.
This revision is now accepted and ready to land.

This change LGTM and I prefer the change than D74130 
 since this one is much more comprehensible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119646

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


[PATCH] D126682: [WIP][Interpreter] Implement undo command

2022-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added a reviewer: v.g.vassilev.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -248,4 +248,23 @@
   EXPECT_EQ(42, fn(NewA));
 }
 
+TEST(InterpreterTest, UndoBasic) {
+  Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"};
+
+  // Create the diagnostic engine with unowned consumer.
+  std::string DiagnosticOutput;
+  llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
+  auto DiagPrinter = std::make_unique(
+  DiagnosticsOS, new DiagnosticOptions());
+
+  auto Interp = createInterpreter(ExtraArgs, DiagPrinter.get());
+  auto R1 = Interp->Parse("int x = 42;");
+  EXPECT_TRUE(!!R1);
+
+  llvm::cantFail(Interp->Undo());
+
+  auto R2 = Interp->Parse("int x = 24;");
+  EXPECT_TRUE(!!R2);
+}
+
 } // end anonymous namespace
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -95,6 +95,11 @@
 while (llvm::Optional Line = LE.readLine()) {
   if (*Line == "quit")
 break;
+  if (*Line == "undo") {
+Interp->Undo();
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(&T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -228,6 +227,16 @@
   return llvm::Error::success();
 }
 
+llvm::Error Interpreter::ParseAndExecute(llvm::StringRef Code) {
+  auto PTU = Parse(Code);
+  if (!PTU)
+return PTU.takeError();
+  if (PTU->TheModule) {
+return Execute(*PTU);
+  }
+  return llvm::Error::success();
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
@@ -257,3 +266,12 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+clang::PartialTranslationUnit &Interpreter::getLastPTU() {
+  return IncrParser->getPTUs().back();
+}
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  clang::PartialTranslationUnit &PTU = IncrParser->getPTUs().back();
+  return IncrExecutor->removeModule(&PTU);
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  std::list &getPTUs() { return PTUs; }
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 #define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -29,11 +30,17 @@
 } // namespace llvm
 
 namespace clang {
+
+struct PartialTranslationUnit;
+
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
   std::unique_ptr Jit;
   llvm::orc::ThreadSafeContext &TSCtx;
 
+  llvm::DenseMap
+  ResourceTrackers;
+
 public:
   enum SymbolNameKind { IRName, LinkerName };
 
@@ -41,7 +48,8 @@
   const llvm::Triple &Triple);
   ~IncrementalExecutor();
 
-  llvm::Error addModule(std::unique_ptr M);
+  llvm::Error addModule(PartialTranslationUnit *PTU);
+  llvm::Error removeModule(clang::PartialTranslationUnit *PTU);
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind

[PATCH] D126682: [WIP][Interpreter] Implement undo command

2022-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 433008.
junaire added a comment.

Also remove PTU in PTU list


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -248,4 +248,23 @@
   EXPECT_EQ(42, fn(NewA));
 }
 
+TEST(InterpreterTest, UndoBasic) {
+  Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"};
+
+  // Create the diagnostic engine with unowned consumer.
+  std::string DiagnosticOutput;
+  llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
+  auto DiagPrinter = std::make_unique(
+  DiagnosticsOS, new DiagnosticOptions());
+
+  auto Interp = createInterpreter(ExtraArgs, DiagPrinter.get());
+  auto R1 = Interp->Parse("int x = 42;");
+  EXPECT_TRUE(!!R1);
+
+  llvm::cantFail(Interp->Undo());
+
+  auto R2 = Interp->Parse("int x = 24;");
+  EXPECT_TRUE(!!R2);
+}
+
 } // end anonymous namespace
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -95,6 +95,11 @@
 while (llvm::Optional Line = LE.readLine()) {
   if (*Line == "quit")
 break;
+  if (*Line == "undo") {
+Interp->Undo();
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(&T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -228,6 +227,16 @@
   return llvm::Error::success();
 }
 
+llvm::Error Interpreter::ParseAndExecute(llvm::StringRef Code) {
+  auto PTU = Parse(Code);
+  if (!PTU)
+return PTU.takeError();
+  if (PTU->TheModule) {
+return Execute(*PTU);
+  }
+  return llvm::Error::success();
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
@@ -257,3 +266,13 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+clang::PartialTranslationUnit &Interpreter::getLastPTU() {
+  return IncrParser->getPTUs().back();
+}
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  llvm::Error Err = IncrExecutor->removeModule(&IncrParser->getPTUs().back());
+  IncrParser->getPTUs().pop_back();
+  return Err;
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  std::list &getPTUs() { return PTUs; }
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 #define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -29,11 +30,17 @@
 } // namespace llvm
 
 namespace clang {
+
+struct PartialTranslationUnit;
+
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
   std::unique_ptr Jit;
   llvm::orc::ThreadSafeContext &TSCtx;
 
+  llvm::DenseMap
+  ResourceTrackers;
+
 public:
   enum SymbolNameKind { IRName, LinkerName };
 
@@ -41,7 +48,8 @@
   const llvm::Triple &Triple);
   ~IncrementalExecutor();
 
-  llvm::Error addModule(std::unique_ptr M);
+  llvm::Error addModule(PartialTranslationUnit *PTU);
+  llvm::Error removeModule(clang::PartialTranslationUnit *PTU);
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
Index: clang/lib/Interpreter/Increment

[clang] 563cc3f - [Clang][CSKY] Add support about CSKYABIInfo

2022-05-30 Thread Zi Xuan Wu via cfe-commits

Author: Zi Xuan Wu (Zeson)
Date: 2022-05-31T10:53:30+08:00
New Revision: 563cc3fda9a2a35582d274e1d2d66687ecf2fc77

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

LOG: [Clang][CSKY] Add support about CSKYABIInfo

According to the CSKY ABIv2 document, 
https://github.com/c-sky/csky-doc/blob/master/C-SKY_V2_CPU_Applications_Binary_Interface_Standards_Manual.pdf
construct the ABIInfo to handle argument passing and return of clang data type. 
It also includes how to emit and expand VAArg intrinsic.

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

Added: 
clang/test/CodeGen/CSKY/csky-abi.c
clang/test/CodeGen/CSKY/csky-hard-abi.c
clang/test/CodeGen/CSKY/csky-soft-abi.c

Modified: 
clang/lib/CodeGen/TargetInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index ecbb3505bb91c..4b7b301594d77 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -11325,6 +11325,165 @@ class VETargetCodeGenInfo : public TargetCodeGenInfo {
 };
 } // end anonymous namespace
 
+//===--===//
+// CSKY ABI Implementation
+//===--===//
+namespace {
+class CSKYABIInfo : public DefaultABIInfo {
+  static const int NumArgGPRs = 4;
+  static const int NumArgFPRs = 4;
+
+  static const unsigned XLen = 32;
+  unsigned FLen;
+
+public:
+  CSKYABIInfo(CodeGen::CodeGenTypes &CGT, unsigned FLen)
+  : DefaultABIInfo(CGT), FLen(FLen) {}
+
+  void computeInfo(CGFunctionInfo &FI) const override;
+  ABIArgInfo classifyArgumentType(QualType Ty, int &ArgGPRsLeft,
+  int &ArgFPRsLeft,
+  bool isReturnType = false) const;
+  ABIArgInfo classifyReturnType(QualType RetTy) const;
+
+  Address EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+QualType Ty) const override;
+};
+
+} // end anonymous namespace
+
+void CSKYABIInfo::computeInfo(CGFunctionInfo &FI) const {
+  QualType RetTy = FI.getReturnType();
+  if (!getCXXABI().classifyReturnType(FI))
+FI.getReturnInfo() = classifyReturnType(RetTy);
+
+  bool IsRetIndirect = FI.getReturnInfo().getKind() == ABIArgInfo::Indirect;
+
+  // We must track the number of GPRs used in order to conform to the CSKY
+  // ABI, as integer scalars passed in registers should have signext/zeroext
+  // when promoted.
+  int ArgGPRsLeft = IsRetIndirect ? NumArgGPRs - 1 : NumArgGPRs;
+  int ArgFPRsLeft = FLen ? NumArgFPRs : 0;
+
+  for (auto &ArgInfo : FI.arguments()) {
+ArgInfo.info = classifyArgumentType(ArgInfo.type, ArgGPRsLeft, 
ArgFPRsLeft);
+  }
+}
+
+Address CSKYABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
+   QualType Ty) const {
+  CharUnits SlotSize = CharUnits::fromQuantity(XLen / 8);
+
+  // Empty records are ignored for parameter passing purposes.
+  if (isEmptyRecord(getContext(), Ty, true)) {
+Address Addr = Address(CGF.Builder.CreateLoad(VAListAddr),
+   getVAListElementType(CGF), SlotSize);
+Addr = CGF.Builder.CreateElementBitCast(Addr, CGF.ConvertTypeForMem(Ty));
+return Addr;
+  }
+
+  auto TInfo = getContext().getTypeInfoInChars(Ty);
+
+  return emitVoidPtrVAArg(CGF, VAListAddr, Ty, false, TInfo, SlotSize,
+  /*AllowHigherAlign=*/true);
+}
+
+ABIArgInfo CSKYABIInfo::classifyArgumentType(QualType Ty, int &ArgGPRsLeft,
+ int &ArgFPRsLeft,
+ bool isReturnType) const {
+  assert(ArgGPRsLeft <= NumArgGPRs && "Arg GPR tracking underflow");
+  Ty = useFirstFieldIfTransparentUnion(Ty);
+
+  // Structures with either a non-trivial destructor or a non-trivial
+  // copy constructor are always passed indirectly.
+  if (CGCXXABI::RecordArgABI RAA = getRecordArgABI(Ty, getCXXABI())) {
+if (ArgGPRsLeft)
+  ArgGPRsLeft -= 1;
+return getNaturalAlignIndirect(Ty, /*ByVal=*/RAA ==
+   CGCXXABI::RAA_DirectInMemory);
+  }
+
+  // Ignore empty structs/unions.
+  if (isEmptyRecord(getContext(), Ty, true))
+return ABIArgInfo::getIgnore();
+
+  if (!Ty->getAsUnionType())
+if (const Type *SeltTy = isSingleElementStruct(Ty, getContext()))
+  return ABIArgInfo::getDirect(CGT.ConvertType(QualType(SeltTy, 0)));
+
+  uint64_t Size = getContext().getTypeSize(Ty);
+  // Pass floating point values via FPRs if possible.
+  if (Ty->isFloatingType() && !Ty->isComplexType() && FLen >= Size &&
+  ArgFPRsLeft) {
+ArgFPRsLeft--;
+return ABIArgInfo::getDirect();
+  }
+
+  // Complex types for the hard float ABI must be passed

[PATCH] D126451: [Clang][CSKY] Add support about CSKYABIInfo

2022-05-30 Thread Zixuan Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG563cc3fda9a2: [Clang][CSKY] Add support about CSKYABIInfo 
(authored by zixuan-wu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126451

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/CSKY/csky-abi.c
  clang/test/CodeGen/CSKY/csky-hard-abi.c
  clang/test/CodeGen/CSKY/csky-soft-abi.c

Index: clang/test/CodeGen/CSKY/csky-soft-abi.c
===
--- /dev/null
+++ clang/test/CodeGen/CSKY/csky-soft-abi.c
@@ -0,0 +1,395 @@
+// RUN: %clang_cc1 -no-opaque-pointers -triple csky -target-feature +fpuv2_sf -target-feature +fpuv2_df -target-feature +hard-float -emit-llvm %s -o - | FileCheck %s
+
+#include 
+
+// Verify that the tracking of used GPRs and FPRs works correctly by checking
+// that small integers are sign/zero extended when passed in registers.
+
+// Doubles are passed in FPRs, so argument 'i' will be passed zero-extended
+// because it will be passed in a GPR.
+
+// CHECK: define{{.*}} void @f_fpr_tracking(double noundef %a, double noundef %b, double noundef %c, double noundef %d, i8 noundef zeroext %i)
+void f_fpr_tracking(double a, double b, double c, double d, uint8_t i) {}
+
+// A struct containing just one floating-point real is passed as though it
+// were a standalone floating-point real.
+struct double_s {
+  double f;
+};
+
+// CHECK: define{{.*}} void @f_double_s_arg(double %a.coerce)
+void f_double_s_arg(struct double_s a) {}
+
+// CHECK: define{{.*}} double @f_ret_double_s()
+struct double_s f_ret_double_s(void) {
+  return (struct double_s){1.0};
+}
+
+// A struct containing a double and any number of zero-width bitfields is
+// passed as though it were a standalone floating-point real.
+
+struct zbf_double_s {
+  int : 0;
+  double f;
+};
+struct zbf_double_zbf_s {
+  int : 0;
+  double f;
+  int : 0;
+};
+
+// CHECK: define{{.*}} void @f_zbf_double_s_arg(double %a.coerce)
+void f_zbf_double_s_arg(struct zbf_double_s a) {}
+
+// CHECK: define{{.*}} double @f_ret_zbf_double_s()
+struct zbf_double_s f_ret_zbf_double_s(void) {
+  return (struct zbf_double_s){1.0};
+}
+
+// CHECK: define{{.*}} void @f_zbf_double_zbf_s_arg(double %a.coerce)
+void f_zbf_double_zbf_s_arg(struct zbf_double_zbf_s a) {}
+
+// CHECK: define{{.*}} double @f_ret_zbf_double_zbf_s()
+struct zbf_double_zbf_s f_ret_zbf_double_zbf_s(void) {
+  return (struct zbf_double_zbf_s){1.0};
+}
+
+// For argument type, the first 4*XLen parts of aggregate will be passed
+// in registers, and the rest will be passed in stack.
+// So we can coerce to integers directly and let backend handle it correctly.
+// For return type, aggregate which <= 2*XLen will be returned in registers.
+// Otherwise, aggregate will be returned indirectly.
+
+struct double_double_s {
+  double f;
+  double g;
+};
+struct double_float_s {
+  double f;
+  float g;
+};
+
+// CHECK: define{{.*}} void @f_double_double_s_arg([4 x i32] %a.coerce)
+void f_double_double_s_arg(struct double_double_s a) {}
+
+// CHECK: define{{.*}} void @f_ret_double_double_s(%struct.double_double_s* noalias sret(%struct.double_double_s) align 4 %agg.result)
+struct double_double_s f_ret_double_double_s(void) {
+  return (struct double_double_s){1.0, 2.0};
+}
+
+// CHECK: define{{.*}} void @f_double_float_s_arg([3 x i32] %a.coerce)
+void f_double_float_s_arg(struct double_float_s a) {}
+
+// CHECK: define{{.*}} void @f_ret_double_float_s(%struct.double_float_s* noalias sret(%struct.double_float_s) align 4 %agg.result)
+struct double_float_s f_ret_double_float_s(void) {
+  return (struct double_float_s){1.0, 2.0};
+}
+
+// CHECK: define{{.*}} void @f_double_double_s_arg_insufficient_fprs(float noundef %a, double noundef %b, double noundef %c, double noundef %d, double noundef %e, double noundef %f, double noundef %g, double noundef %i, [4 x i32] %h.coerce)
+void f_double_double_s_arg_insufficient_fprs(float a, double b, double c, double d,
+ double e, double f, double g, double i, struct double_double_s h) {}
+
+struct double_int8_s {
+  double f;
+  int8_t i;
+};
+struct double_uint8_s {
+  double f;
+  uint8_t i;
+};
+struct double_int32_s {
+  double f;
+  int32_t i;
+};
+struct double_int64_s {
+  double f;
+  int64_t i;
+};
+struct double_int64bf_s {
+  double f;
+  int64_t i : 32;
+};
+struct double_int8_zbf_s {
+  double f;
+  int8_t i;
+  int : 0;
+};
+
+// CHECK: define{{.*}}  @f_double_int8_s_arg([3 x i32] %a.coerce)
+void f_double_int8_s_arg(struct double_int8_s a) {}
+
+// CHECK: define{{.*}} void @f_ret_double_int8_s(%struct.double_int8_s* noalias sret(%struct.double_int8_s) align 4 %agg.result)
+struct double_int8_s f_ret_double_int8_s(void) {
+  return (struct double_int8_s){1.0, 2};
+}
+
+// CHECK: define{{.*}} void @f_double_uint8_s_arg([3 x i32] %a.coerce)
+void f_double_uint8_s_ar

[PATCH] D126682: [WIP][Interpreter] Implement undo command

2022-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 433009.
junaire added a comment.

Improve code a little bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -248,4 +248,23 @@
   EXPECT_EQ(42, fn(NewA));
 }
 
+TEST(InterpreterTest, UndoBasic) {
+  Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"};
+
+  // Create the diagnostic engine with unowned consumer.
+  std::string DiagnosticOutput;
+  llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
+  auto DiagPrinter = std::make_unique(
+  DiagnosticsOS, new DiagnosticOptions());
+
+  auto Interp = createInterpreter(ExtraArgs, DiagPrinter.get());
+  auto R1 = Interp->Parse("int x = 42;");
+  EXPECT_TRUE(!!R1);
+
+  llvm::cantFail(Interp->Undo());
+
+  auto R2 = Interp->Parse("int x = 24;");
+  EXPECT_TRUE(!!R2);
+}
+
 } // end anonymous namespace
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -95,6 +95,11 @@
 while (llvm::Optional Line = LE.readLine()) {
   if (*Line == "quit")
 break;
+  if (*Line == "undo") {
+Interp->Undo();
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(&T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -228,6 +227,16 @@
   return llvm::Error::success();
 }
 
+llvm::Error Interpreter::ParseAndExecute(llvm::StringRef Code) {
+  auto PTU = Parse(Code);
+  if (!PTU)
+return PTU.takeError();
+  if (PTU->TheModule) {
+return Execute(*PTU);
+  }
+  return llvm::Error::success();
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
@@ -257,3 +266,9 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  llvm::Error Err = IncrExecutor->removeModule(&IncrParser->getPTUs().back());
+  IncrParser->getPTUs().pop_back();
+  return Err;
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  std::list &getPTUs() { return PTUs; }
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 #define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -29,11 +30,17 @@
 } // namespace llvm
 
 namespace clang {
+
+struct PartialTranslationUnit;
+
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
   std::unique_ptr Jit;
   llvm::orc::ThreadSafeContext &TSCtx;
 
+  llvm::DenseMap
+  ResourceTrackers;
+
 public:
   enum SymbolNameKind { IRName, LinkerName };
 
@@ -41,7 +48,8 @@
   const llvm::Triple &Triple);
   ~IncrementalExecutor();
 
-  llvm::Error addModule(std::unique_ptr M);
+  llvm::Error addModule(PartialTranslationUnit *PTU);
+  llvm::Error removeModule(PartialTranslationUnit *PTU);
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
Index: clang/lib/Interpreter/IncrementalExecutor.cpp
===
--- clang/lib/Interpreter/Increm

[PATCH] D126682: [WIP][Interpreter] Implement undo command

2022-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 433011.
junaire added a comment.

Remove a NFC change to make review easier


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126682

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp
  clang/tools/clang-repl/ClangRepl.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -248,4 +248,23 @@
   EXPECT_EQ(42, fn(NewA));
 }
 
+TEST(InterpreterTest, UndoBasic) {
+  Args ExtraArgs = {"-Xclang", "-diagnostic-log-file", "-Xclang", "-"};
+
+  // Create the diagnostic engine with unowned consumer.
+  std::string DiagnosticOutput;
+  llvm::raw_string_ostream DiagnosticsOS(DiagnosticOutput);
+  auto DiagPrinter = std::make_unique(
+  DiagnosticsOS, new DiagnosticOptions());
+
+  auto Interp = createInterpreter(ExtraArgs, DiagPrinter.get());
+  auto R1 = Interp->Parse("int x = 42;");
+  EXPECT_TRUE(!!R1);
+
+  llvm::cantFail(Interp->Undo());
+
+  auto R2 = Interp->Parse("int x = 24;");
+  EXPECT_TRUE(!!R2);
+}
+
 } // end anonymous namespace
Index: clang/tools/clang-repl/ClangRepl.cpp
===
--- clang/tools/clang-repl/ClangRepl.cpp
+++ clang/tools/clang-repl/ClangRepl.cpp
@@ -95,6 +95,11 @@
 while (llvm::Optional Line = LE.readLine()) {
   if (*Line == "quit")
 break;
+  if (*Line == "undo") {
+Interp->Undo();
+continue;
+  }
+
   if (auto Err = Interp->ParseAndExecute(*Line))
 llvm::logAllUnhandledErrors(std::move(Err), llvm::errs(), "error: ");
 }
Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -218,8 +218,7 @@
 if (Err)
   return Err;
   }
-  // FIXME: Add a callback to retain the llvm::Module once the JIT is done.
-  if (auto Err = IncrExecutor->addModule(std::move(T.TheModule)))
+  if (auto Err = IncrExecutor->addModule(&T))
 return Err;
 
   if (auto Err = IncrExecutor->runCtors())
@@ -257,3 +256,9 @@
 
   return IncrExecutor->getSymbolAddress(Name, IncrementalExecutor::LinkerName);
 }
+
+llvm::Error Interpreter::Undo(unsigned N) {
+  llvm::Error Err = IncrExecutor->removeModule(&IncrParser->getPTUs().back());
+  IncrParser->getPTUs().pop_back();
+  return Err;
+}
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  std::list &getPTUs() { return PTUs; }
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 #define LLVM_CLANG_LIB_INTERPRETER_INCREMENTALEXECUTOR_H
 
+#include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -29,11 +30,17 @@
 } // namespace llvm
 
 namespace clang {
+
+struct PartialTranslationUnit;
+
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
   std::unique_ptr Jit;
   llvm::orc::ThreadSafeContext &TSCtx;
 
+  llvm::DenseMap
+  ResourceTrackers;
+
 public:
   enum SymbolNameKind { IRName, LinkerName };
 
@@ -41,7 +48,8 @@
   const llvm::Triple &Triple);
   ~IncrementalExecutor();
 
-  llvm::Error addModule(std::unique_ptr M);
+  llvm::Error addModule(PartialTranslationUnit *PTU);
+  llvm::Error removeModule(PartialTranslationUnit *PTU);
   llvm::Error runCtors() const;
   llvm::Expected
   getSymbolAddress(llvm::StringRef Name, SymbolNameKind NameKind) const;
Index: clang/lib/Interpreter/IncrementalExecutor.cpp
===
--- clang/lib/Interpreter/IncrementalExecutor.cpp
+++ clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -12,6 +12,7 @@
 
 #include "IncrementalExecutor.h"
 
+#include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
@@ -52,8 +53,24 @@
 
 Increment

[PATCH] D126540: PowerPC] Emit warning for incompatible vector types that are currently diagnosed with -fno-lax-vector-conversions

2022-05-30 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7572
+  "Current bitcast for incompatible vector types (%0 and %1) are deprecated. "
+  "The default behaviour will change to what implied by the "
+  "-fno-lax-vector-conversions option">,





Comment at: clang/lib/Sema/SemaOverload.cpp:1664
  !ToType->hasAttr(attr::ArmMveStrictPolymorphism))) {
+  if (!InOverloadResolution &&
+  FromType->castAs()->getVectorKind() ==

Just wanted to check, but is this case covered in the comment above? If it is 
not, can we add a comment for it?



Comment at: clang/lib/Sema/SemaOverload.cpp:13027
   // end up here.
+  //
   return SemaRef.BuildCallExpr(/*Scope*/ nullptr, NewFn.get(), LParenLoc,

Unnecessary change?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126540

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


[PATCH] D126620: [clang] AST/Print: honor AlwaysIncludeTypeForTemplateArgument policy

2022-05-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

This patch fixes our test case which we intended to fix with:

  From 17e94a6a2adc3eb8d5fcc532eb1f3e57cc59b0fd Mon Sep 17 00:00:00 2001
  From: Vassil Vassilev 
  Date: Mon, 23 May 2022 21:36:43 +
  Subject: [PATCH] Fix type printing to not include the suffix when not needed.
  
  before:
  root.exe -l -b -q -e 'TClass::GetClass("std::array")->Print()'
  OBJ: TClassarray
  
  after: root.exe -l -b -q -e 'TClass::GetClass("std::array")->Print()'
  OBJ: TClassarray
  
  To be upstreamed.
  ---
   interpreter/llvm/src/tools/clang/lib/AST/TypePrinter.cpp | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
  
  diff --git a/interpreter/llvm/src/tools/clang/lib/AST/TypePrinter.cpp 
b/interpreter/llvm/src/tools/clang/lib/AST/TypePrinter.cpp
  index 5de22f76f458..844a5be12836 100644
  --- a/interpreter/llvm/src/tools/clang/lib/AST/TypePrinter.cpp
  +++ b/interpreter/llvm/src/tools/clang/lib/AST/TypePrinter.cpp
  @@ -1452,7 +1452,8 @@ void TypePrinter::printTemplateId(const 
TemplateSpecializationType *T,
   T->getTemplateName().print(OS, Policy);
 }
   
  -  printTemplateArgumentList(OS, T->template_arguments(), Policy);
  +  printTemplateArgumentList(OS, T->template_arguments(), Policy,
  +TD->getTemplateParameters());
 spaceBeforePlaceHolder(OS);
   }
   

The proposed patch is better because it is more precise whereas my approach 
above has multiple test failures and may be impossible to upstream.

This LGTM, but I'd like to see what @rsmith thinks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126620

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


[PATCH] D126364: Fix interaction of pragma FENV_ACCESS with other pragmas

2022-05-30 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

In D126364#3546173 , @efriedma wrote:

>> setRoundingMode definitely should not call getAllowFEnvAccess() and it does 
>> not
>
> Yes, it does?
>
>   // C2x: 7.6.2p3  If the FE_DYNAMIC mode is specified and FENV_ACCESS is 
> "off",
>   // the translator may assume that the default rounding mode is in effect.
>   if (FPR == llvm::RoundingMode::Dynamic &&
>   !CurFPFeatures.getAllowFEnvAccess() &&
>   CurFPFeatures.getFPExceptionMode() == LangOptions::FPE_Ignore)
> FPR = llvm::RoundingMode::NearestTiesToEven;

Sorry for my confusion, I meant setAllowFEnvAccess().

>> As for ActOnPragmaFEnvAccess, it make sense to set the most general mode.
>
> Shouldn't the default mode just be "dynamic"?  The fact that we emit 
> non-strict floating-point ops if FENV_ACCESS is disabled is an implementation 
> detail.  I don't see the point of switching the rounding mode between 
> "Dynamic" and "NearestTiesToEven" depending on whether FENV_ACCESS is 
> enabled.  Making the required state transitions complicated like this just 
> makes the code harder to understand.

The standard says that

  the translator may assume that the default rounding mode is in effect

so it does not require to make such assumption, and we can use the most 
profitable way.

The advantages of using default rounding mode are:

1. In this case the mode has concrete value. Constant evaluator can evaluate 
expressions like `1.0/3.0`, which is not allowed if rounding is dynamic, and 
the expression is not constexpr anymore.

2. On targets that support static rounding mode (like RISCV) dynamic and 
constant rounding modes may be different and the behavior changes if default 
mode is replaced by dynamic.

In these cases choosing dynamic mode is not an implementation details, it has 
user-visible effect and the behavior should be chosen most close to the 
standard.

It seems that `#pragma STDC FENV_ROUND FE_DYNAMIC` without `#pragma STDC 
FENV_ACCESS ON` is more like an error, because there is no legitimate way to 
set rounding mode in this case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126364

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


[PATCH] D123674: Clang-Repl Error Recovery Bug Fix

2022-05-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

Hi,

I noticed that the testcase Interpreter/execute.cpp starts failing with this 
patch when run/compiled with asan:

  Failed Tests (1):
Clang :: Interpreter/execute.cpp

Seen in the buildbot run
 https://lab.llvm.org/buildbot/#/builders/5/builds/24221

The run on the commit before passed:
 https://lab.llvm.org/buildbot/#/builders/5/builds/24220


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123674

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


[PATCH] D126672: [Driver] Add multiarch path for RISC-V

2022-05-30 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru accepted this revision.
sylvestre.ledru added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126672

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


[PATCH] D126684: [Interpreter] Implment Interpreter::Restore to clean up lookup table

2022-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added a reviewer: v.g.vassilev.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds a new method to the clang::Interpreter, enables us to
explictly clean up the lookup table when doing recovery.
Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D126684

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -228,6 +228,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit& PTU) {
+IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  void Restore(PartialTranslationUnit &PTU);
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -293,6 +293,24 @@
   return PTU;
 }
 
+void IncrementalParser::Restore(PartialTranslationUnit& PTU) {
+  TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+   TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+   if (StoredDeclsMap *Map = FirstTU->getLookupPtr()) {
+  for (auto I = Map->begin(); I != Map->end(); ++I) {
+StoredDeclsList &List = I->second;
+DeclContextLookupResult R = List.getLookupResult();
+for (NamedDecl *D : R){
+  if (D->getTranslationUnitDecl() == MostRecentTU){
+List.remove(D);
+  }
+}
+if (List.isNull())
+  Map->erase(I);
+  }
+}
+}
+
 llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {
   CodeGenerator *CG = getCodeGen(Act.get());
   assert(CG);
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -69,6 +69,8 @@
 return llvm::Error::success();
   }
 
+  void Restore(PartialTranslationUnit &PTU);
+
   /// \returns the \c JITTargetAddress of a \c GlobalDecl. This interface uses
   /// the CodeGenModule's internal mangling cache to avoid recomputing the
   /// mangled name.


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -228,6 +228,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit& PTU) {
+IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  void Restore(PartialTranslationUnit &PTU);
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -293,6 +293,24 @@
   return PTU;
 }
 
+void IncrementalParser::Restore(PartialTranslationUnit& PTU) {
+  TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+   TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+   if (StoredDeclsMap *Map = FirstTU->getLookupPtr()) {
+  for (auto I = Map->begin(); I != Map->end(); ++I) {
+StoredDeclsList &List = I->second;
+DeclContextLookupResult R = List.getLookupResult();
+for (NamedDecl *D : R){
+  if (D->getTranslationUnitDecl() == MostRecentTU){
+List.remove(D);
+  }
+}
+if (List.isNull())
+  Map->erase(I);
+  }
+}
+}
+
 llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {
   CodeGenerator *CG = getCodeGen(Act.get());
   assert(CG);
Index: clang/include/clang/Interpreter/Interpreter.h
=

[PATCH] D126684: [Interpreter] Implment Interpreter::Restore to clean up lookup table

2022-05-30 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 433022.
junaire added a comment.

Format the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126684

Files:
  clang/include/clang/Interpreter/Interpreter.h
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Interpreter/IncrementalParser.h
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -228,6 +228,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit &PTU) {
+  IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  void Restore(PartialTranslationUnit &PTU);
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -293,6 +293,24 @@
   return PTU;
 }
 
+void IncrementalParser::Restore(PartialTranslationUnit &PTU) {
+  TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+  TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+  if (StoredDeclsMap *Map = FirstTU->getLookupPtr()) {
+for (auto I = Map->begin(); I != Map->end(); ++I) {
+  StoredDeclsList &List = I->second;
+  DeclContextLookupResult R = List.getLookupResult();
+  for (NamedDecl *D : R) {
+if (D->getTranslationUnitDecl() == MostRecentTU) {
+  List.remove(D);
+}
+  }
+  if (List.isNull())
+Map->erase(I);
+}
+  }
+}
+
 llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {
   CodeGenerator *CG = getCodeGen(Act.get());
   assert(CG);
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -69,6 +69,8 @@
 return llvm::Error::success();
   }
 
+  void Restore(PartialTranslationUnit &PTU);
+
   /// \returns the \c JITTargetAddress of a \c GlobalDecl. This interface uses
   /// the CodeGenModule's internal mangling cache to avoid recomputing the
   /// mangled name.


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -228,6 +228,10 @@
   return llvm::Error::success();
 }
 
+void Interpreter::Restore(PartialTranslationUnit &PTU) {
+  IncrParser->Restore(PTU);
+}
+
 llvm::Expected
 Interpreter::getSymbolAddress(GlobalDecl GD) const {
   if (!IncrExecutor)
Index: clang/lib/Interpreter/IncrementalParser.h
===
--- clang/lib/Interpreter/IncrementalParser.h
+++ clang/lib/Interpreter/IncrementalParser.h
@@ -72,6 +72,8 @@
   ///\returns the mangled name of a \c GD.
   llvm::StringRef GetMangledName(GlobalDecl GD) const;
 
+  void Restore(PartialTranslationUnit &PTU);
+
 private:
   llvm::Expected ParseOrWrapTopLevelDecl();
 };
Index: clang/lib/Interpreter/IncrementalParser.cpp
===
--- clang/lib/Interpreter/IncrementalParser.cpp
+++ clang/lib/Interpreter/IncrementalParser.cpp
@@ -293,6 +293,24 @@
   return PTU;
 }
 
+void IncrementalParser::Restore(PartialTranslationUnit &PTU) {
+  TranslationUnitDecl *MostRecentTU = PTU.TUPart;
+  TranslationUnitDecl *FirstTU = MostRecentTU->getFirstDecl();
+  if (StoredDeclsMap *Map = FirstTU->getLookupPtr()) {
+for (auto I = Map->begin(); I != Map->end(); ++I) {
+  StoredDeclsList &List = I->second;
+  DeclContextLookupResult R = List.getLookupResult();
+  for (NamedDecl *D : R) {
+if (D->getTranslationUnitDecl() == MostRecentTU) {
+  List.remove(D);
+}
+  }
+  if (List.isNull())
+Map->erase(I);
+}
+  }
+}
+
 llvm::StringRef IncrementalParser::GetMangledName(GlobalDecl GD) const {
   CodeGenerator *CG = getCodeGen(Act.get());
   assert(CG);
Index: clang/include/clang/Interpreter/Interpreter.h
===
--- clang/include/clang/Interpreter/Interpreter.h
+++ clang/include/clang/Interpreter/Interpreter.h
@@ -69,6 +69,8 @@
 return llvm::Error::success();
   }
 
+  void Restore(PartialTranslationUnit &PTU);
+
   /// \

[clang] 575e297 - Revert "[clang-repl] Recover the lookup tables of the primary context."

2022-05-30 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2022-05-31T06:25:37Z
New Revision: 575e297fcb289f0a9b0ac4b01d1d0fa051f5cc29

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

LOG: Revert "[clang-repl] Recover the lookup tables of the primary context."

This reverts commit 5ff27fe1ff03d5aeaf8567c97618170f0cef8f58.

This patch caused failures in asan: 
https://lab.llvm.org/buildbot/#/builders/5/builds/24221

Added: 


Modified: 
clang/lib/Interpreter/IncrementalParser.cpp
clang/test/Interpreter/execute.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/IncrementalParser.cpp 
b/clang/lib/Interpreter/IncrementalParser.cpp
index 87687ea6906d..0f1ef3233a2a 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -188,7 +188,7 @@ IncrementalParser::ParseOrWrapTopLevelDecl() {
 S.TUScope->setEntity(PreviousTU);
 
 // Clean up the lookup table
-if (StoredDeclsMap *Map = PreviousTU->getPrimaryContext()->getLookupPtr()) 
{
+if (StoredDeclsMap *Map = PreviousTU->getLookupPtr()) {
   for (auto I = Map->begin(); I != Map->end(); ++I) {
 StoredDeclsList &List = I->second;
 DeclContextLookupResult R = List.getLookupResult();

diff  --git a/clang/test/Interpreter/execute.cpp 
b/clang/test/Interpreter/execute.cpp
index 5f3fe3e837d9..298046c068c3 100644
--- a/clang/test/Interpreter/execute.cpp
+++ b/clang/test/Interpreter/execute.cpp
@@ -1,4 +1,3 @@
-// RUN: clang-repl "int x = 10;" "int y=7; err;" "int y = 10;"
 // RUN: clang-repl "int i = 10;" 'extern "C" int printf(const char*,...);' \
 // RUN:'auto r1 = printf("i = %d\n", i);' | FileCheck 
--check-prefix=CHECK-DRIVER %s
 // REQUIRES: host-supports-jit



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


[PATCH] D123674: Clang-Repl Error Recovery Bug Fix

2022-05-30 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D123674#3546722 , @uabelho wrote:

> Hi,
>
> I noticed that the testcase Interpreter/execute.cpp starts failing with this 
> patch when run/compiled with asan:
>
>   Failed Tests (1):
> Clang :: Interpreter/execute.cpp
>
> Seen in the buildbot run
>  https://lab.llvm.org/buildbot/#/builders/5/builds/24221
>
> The run on the commit before passed:
>  https://lab.llvm.org/buildbot/#/builders/5/builds/24220

Thanks a lot for the notice @uabelho! I have reverted the patch while we are 
investigating.

@Purva-Chaudhari, can you take look and reproduce the asan failure locally?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123674

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