[PATCH] D96838: CodeGen: Set !retain metadata on UsedAttr definitions for Linux/FreeBSD

2021-02-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2071
+  const llvm::Triple &T = getTarget().getTriple();
+  if (T.isOSFreeBSD() || T.isOSLinux())
+GO->setMetadata(llvm::LLVMContext::MD_retain,

Would it be possible to also include Fuchsia?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96838

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


[PATCH] D64146: [Clang Interpreter] Initial patch for the constexpr interpreter

2021-02-17 Thread Nandor Licker via Phabricator via cfe-commits
nand added a comment.

CodePtr points into the bytecode emitted by the byte code compiler. In some 
instances, pointers to auxiliary data structures are embedded into the byte 
code, such as functions or AST nodes which contain information relevant to the 
execution of the instruction.

Would it help if instead of encoding pointers, the byte code encoded some 
integers mapped to the original objects?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64146

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


[PATCH] D96755: [clangd] Shutdown sequence for modules, and doc threading requirements

2021-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

thanks, lgtm!




Comment at: clang-tools-extra/clangd/ClangdServer.cpp:180
+for (auto &Mod : *Modules)
+  Mod.blockUntilIdle(Deadline::infinity());
+  }

sammccall wrote:
> kadircet wrote:
> > why is our contract saying that just calling `stop` is not enough?
> > i think clangdserver should just signal shutdown to modules, and our 
> > contract should say that server facilities will be undefined from this 
> > point forward.
> > that way modules accessing the facilities, could block stop until they are 
> > done, and never make use of it afterwards? it'll make modules a little more 
> > complicated, at the very least they would need some stricter control 
> > whenever they are accessing facilities, but I think it is worth for keeping 
> > clangdserver shutdown cleaner. wdyt?
> We need Module::blockUntilIdle anyway for tests and stuff. And in practice 
> requesting shutdown of background work doesn't naturally block until that 
> work is complete IME.
> 
> So we could ask every module to call blockUntilIdle() in stop(), or make 
> stop() non-virtual and have it wrap requestStop()+blockUntilIdle().
> 
> Neither really seems simpler/cleaner to me overall, and it means modules shut 
> down in serial instead of parallel.
> 
> We need Module::blockUntilIdle anyway for tests and stuff

i was trying to ensure it is *only* used for tests, but i suppose you are 
right, in practice making `stop` block until in-flight tasks finishes vs 
stop+blockuntilidle is likely to have same effect, with the latter having the 
benefit of triggering shut down in parallel. so SGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96755

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


[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-17 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.

still LG!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

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


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

2021-02-17 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

@ASDenysPetrov, could you provide your link command-line for one of the tools 
that produces the failing message, please, e.g. llvm-ar? That may give us a 
hint about whether different libraries are being used. It's possible we need 
some additional cmake-time configuration steps to detect this difference. Also 
are you using cygwin at all?

Not that I'm saying we shouldn't try to fix your use-case, but if you aren't 
using Cygwin, it's worth noting that 
https://llvm.org/docs/GettingStarted.html#hardware states that only Visual 
Studio builds (whether via the IDE or some other tool like ninja) are known to 
work for Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D96033: [clang-repl] Land initial infrastructure for incremental parsing

2021-02-17 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added inline comments.



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:184
+  SourceLocation NewLoc = SM.getLocForStartOfFile(SM.getMainFileID())
+  .getLocWithOffset(InputCount + 2);
+

The `+ 2` here is probably not what you want. This will just give you a pointer 
into Clang's source buffers and will eventually point to random source buffers 
(or worse) once InputCount is large enough.

I feel like the proper solution is to just use the StartOfFile Loc and don't 
add any offset to it. I think Clang should still be able to figure out a 
reasonable ordering for overload candidates etc. 

(I thought I already commented on this line before, but I can't see my comment 
or any replies on Phab so I'm just commenting again).



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:63
+if (CI.hasCodeCompletionConsumer())
+  CompletionConsumer = &CI.getCodeCompletionConsumer();
+

v.g.vassilev wrote:
> teemperor wrote:
> > Can this completion code even be used? It doesn't look like it can (and I'm 
> > not sure if using the `CodeCompletionAt` flag is really useful in a REPL as 
> > you can only specify it once during startup). IMHO this can be left out 
> > until we actually can hook up this into the LineEditor (and we have a way 
> > to test this).
> Cling, on which this patch is based on, has a CodeCompleteConsumer and it 
> seems to work.
> 
> I can leave it out but then we will have to remember where to put it. I have 
> a slight preference to leave it as it is.
Alright, given that this is just passing along the CompletionConsumer from Ci 
to Sema, I think this can stay then.



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:189
+  // NewLoc only used for diags.
+  PP.EnterSourceFile(FID, /*DirLookup*/ 0, NewLoc);
+

v.g.vassilev wrote:
> teemperor wrote:
> > I think we could assert that this succeeds.
> assert on the FID you mean?
I meant the `EnterSourceFile` call has a `bool` error it returns (along with a 
diagnostic). I think the only way it should fail is if the previous code got 
somehow messed up, hence the assert suggestion.



Comment at: clang/lib/Interpreter/Interpreter.cpp:82
+  PCHOps->registerWriter(std::make_unique());
+  PCHOps->registerReader(std::make_unique());
+

v.g.vassilev wrote:
> teemperor wrote:
> > Can you add a FIXME that this should be removed (as I think we keep adding 
> > these two lines to all kind of Clang tools)? I assume this is only needed 
> > because of Clang errors when you encounter -gmodules produced pcms ?
> I do not understand the problem entirely, could you propose wording for the 
> FIXME?
The PCM files generated with `-gmodules` are object-files that contain the 
Clang AST inside them. To deal with the object-file wrapping and get to the AST 
inside, we need the `ObjectFilePCHContainerReader`. But that class is part of 
CodeGen which isn't a dependency of the normal parsing logic, so these classes 
can't be hooked up automatically by Clang like the other 'ContainerReaders' 
classes (well, there is only one other classes which just opens the file 
normally).

So to work around the fact that to **parse** code we now need a **CodeGen** 
dependency, every clang tool (which usually depend on CodeGen + parsing code) 
has to manually register the `ObjectFilePCHContainer*` classes.

My point is just that it's not sustainable to have everyone copy around these 
three lines as otherwise Clang won't handle any PCM file that was generated 
with -gmodules.

I think the FIXME for this could be:
`FIXME: Clang should register these container operations automatically.`.



Comment at: clang/tools/clang-repl/CMakeLists.txt:3
+#  ${LLVM_TARGETS_TO_BUILD}
+#  Option
+  Support

v.g.vassilev wrote:
> teemperor wrote:
> > v.g.vassilev wrote:
> > > teemperor wrote:
> > > > Commented out by mistake?
> > > Does not seem to be required. I will remove it for now...
> > I meant that shouldn't have been commented out (as I think we don't get the 
> > targets symbols from any other library so this fails to link)
> It compiles just fine for me. Should we add it back once we find the setup 
> that requires it?
On my Linux setup the dependencies were required (and it seems logical that 
they are required), so I would just add them.


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

https://reviews.llvm.org/D96033

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


[PATCH] D96847: [clang][cli] Store additional optimization remarks info

2021-02-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

After a revision of D96274  changed 
`DiagnosticOptions` to not store all remark arguments **as-written**, it is no 
longer possible to reconstruct the arguments accurately from the class.

This is caused by the fact that for `-Rpass=regexp` and friends, 
`DiagnosticOptions` store only the group name `pass` and not `regexp`. This is 
the same representation used for the plain `-Rpass` argument.

Each argument must be generated exactly once in 
`CompilerInvocation::generateCC1CommandLine`, otherwise each subsequent call 
would produce more arguments than the previous one. This currently works out 
because of the way `RoundTrip` splits the responsibilities for certain 
arguments based on what arguments were queried during parsing. This breaks when 
we move to single round-trip for the whole `CompilerInvocation`.

This patch ensures that for one `-Rpass=regexp`, we don't generate two 
arguments (`-Rpass` from `DiagnosticOptions` and `-Rpass=regexp` from 
`CodeGenOptions`) by shifting the responsibility for handling both cases to 
`CodeGenOptions`. To distinguish between the cases correctly, additional 
information is stored in `CodeGenOptions`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96847

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1162,20 +1162,70 @@
<< "a filename";
 }
 
-/// Create a new Regex instance out of the string value in \p RpassArg.
-/// It returns the string and a pointer to the newly generated Regex instance.
-static CodeGenOptions::RemarkPattern
-GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
-Arg *RpassArg) {
-  StringRef Val = RpassArg->getValue();
-  std::string RegexError;
-  std::shared_ptr Pattern = std::make_shared(Val);
-  if (!Pattern->isValid(RegexError)) {
-Diags.Report(diag::err_drv_optimization_remark_pattern)
-<< RegexError << RpassArg->getAsString(Args);
-Pattern.reset();
-  }
-  return {std::string(Val), Pattern};
+/// Generate a remark argument. This is an inverse of `ParseOptimizationRemark`.
+static void GenerateOptimizationRemark(
+SmallVectorImpl &Args, CompilerInvocation::StringAllocator SA,
+OptSpecifier OptEQ, StringRef Name, const CodeGenOptions::RemarkKind &Kind,
+const CodeGenOptions::RemarkPattern &Pattern) {
+  if (Pattern) {
+GenerateArg(Args, OptEQ, Pattern.Pattern, SA);
+  } else if (Kind == CodeGenOptions::RK_Enabled) {
+GenerateArg(Args, OPT_R_Joined, Name, SA);
+  } else if (Kind == CodeGenOptions::RK_Disabled) {
+GenerateArg(Args, OPT_R_Joined, StringRef("no-") + Name, SA);
+  }
+};
+
+/// Parse a remark command line argument. It may be missing, disabled via
+/// '-Rno-group', enabled via '-Rgroup' or specified with a regular expression
+/// via '-Rgroup=regexp'. On top of that, it can be disabled/enabled globally by
+/// '-R[no-]everything'. The \p Kind and \p Pattern are initialized accordingly.
+static void ParseOptimizationRemark(DiagnosticsEngine &Diags, ArgList &Args,
+OptSpecifier OptEQ, StringRef Name,
+CodeGenOptions::RemarkKind &Kind,
+CodeGenOptions::RemarkPattern &Pattern) {
+  auto InitializePattern =
+  [&Diags, &Args](const Arg *A, CodeGenOptions::RemarkPattern &Pattern) {
+StringRef Value = A->getValue();
+std::string RegexError;
+auto Regex = std::make_shared(Value);
+
+if (!Regex->isValid(RegexError)) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << RegexError << A->getAsString(Args);
+  return false;
+}
+
+Pattern = CodeGenOptions::RemarkPattern{std::string(Value), Regex};
+return true;
+  };
+
+  CodeGenOptions::RemarkPattern ParsedPattern;
+
+  Kind = CodeGenOptions::RK_Missing;
+
+  for (Arg *A : Args) {
+if (A->getOption().matches(OPT_R_Joined)) {
+  StringRef Value = A->getValue();
+
+  if (Value == Name)
+Kind = CodeGenOptions::RK_Enabled;
+  else if (Value == "everything")
+Kind = CodeGenOptions::RK_EnabledEverything;
+  else if (Value.split('-') == std::make_pair(StringRef("no"), Name))
+Kind = CodeGenOptions::RK_Disabled;
+  else if (Value == "no-everything")
+Kind = CodeGenOptions::RK_DisabledEverything;
+} else if (A->getOption().matches(OptEQ)) {
+  Kind = CodeGenOptions

[PATCH] D95753: [Coverage] Store compilation dir separately in coverage mapping

2021-02-17 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 324224.
phosek marked an inline comment as done.
phosek retitled this revision from "Store compilation dir separately in 
coverage mapping" to "[Coverage] Store compilation dir separately in coverage 
mapping".

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95753

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CoverageMappingGen.cpp
  clang/lib/CodeGen/CoverageMappingGen.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CoverageMapping/abspath.cpp
  clang/test/Profile/profile-prefix-map.c
  compiler-rt/include/profile/InstrProfData.inc
  llvm/docs/CoverageMappingFormat.rst
  llvm/include/llvm/ProfileData/Coverage/CoverageMapping.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingReader.h
  llvm/include/llvm/ProfileData/Coverage/CoverageMappingWriter.h
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/test/tools/llvm-cov/Inputs/binary-formats.v6.linux64l
  llvm/test/tools/llvm-cov/binary-formats.c
  llvm/unittests/ProfileData/CoverageMappingTest.cpp

Index: llvm/unittests/ProfileData/CoverageMappingTest.cpp
===
--- llvm/unittests/ProfileData/CoverageMappingTest.cpp
+++ llvm/unittests/ProfileData/CoverageMappingTest.cpp
@@ -129,6 +129,7 @@
 struct CoverageMappingTest : ::testing::TestWithParam> {
   bool UseMultipleReaders;
   StringMap Files;
+  std::vector Filenames;
   std::vector InputFunctions;
   std::vector OutputFunctions;
 
@@ -146,7 +147,7 @@
 auto R = Files.find(Name);
 if (R != Files.end())
   return R->second;
-unsigned Index = Files.size();
+unsigned Index = Files.size() + 1;
 Files.try_emplace(Name, Index);
 return Index;
   }
@@ -200,11 +201,12 @@
 
   void readCoverageRegions(const std::string &Coverage,
OutputFunctionCoverageData &Data) {
-SmallVector Filenames(Files.size());
+Filenames.resize(Files.size() + 1);
 for (const auto &E : Files)
-  Filenames[E.getValue()] = E.getKey();
+  Filenames[E.getValue()] = E.getKey().str();
 std::vector Expressions;
-RawCoverageMappingReader Reader(Coverage, Filenames, Data.Filenames,
+ArrayRef FilenameRefs = llvm::makeArrayRef(Filenames);
+RawCoverageMappingReader Reader(Coverage, FilenameRefs, Data.Filenames,
 Expressions, Data.Regions);
 EXPECT_THAT_ERROR(Reader.read(), Succeeded());
   }
@@ -895,7 +897,7 @@
   std::pair({true, true})),);
 
 TEST(CoverageMappingTest, filename_roundtrip) {
-  std::vector Paths({"a", "b", "c", "d", "e"});
+  std::vector Paths({"", "a", "b", "c", "d", "e"});
 
   for (bool Compress : {false, true}) {
 std::string EncodedFilenames;
@@ -905,16 +907,12 @@
   Writer.write(OS, Compress);
 }
 
-std::vector ReadFilenames;
+std::vector ReadFilenames;
 RawCoverageFilenamesReader Reader(EncodedFilenames, ReadFilenames);
-BinaryCoverageReader::DecompressedData Decompressed;
-EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion, Decompressed),
-  Succeeded());
-if (!Compress)
-  ASSERT_EQ(Decompressed.size(), 0U);
+EXPECT_THAT_ERROR(Reader.read(CovMapVersion::CurrentVersion), Succeeded());
 
 ASSERT_EQ(ReadFilenames.size(), Paths.size());
-for (unsigned I = 0; I < Paths.size(); ++I)
+for (unsigned I = 1; I < Paths.size(); ++I)
   ASSERT_TRUE(ReadFilenames[I] == Paths[I]);
   }
 }
Index: llvm/test/tools/llvm-cov/binary-formats.c
===
--- llvm/test/tools/llvm-cov/binary-formats.c
+++ llvm/test/tools/llvm-cov/binary-formats.c
@@ -8,5 +8,6 @@
 // RUN: llvm-cov show %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/binary-formats.macho32b -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 // RUN: llvm-cov show %S/Inputs/binary-formats.v3.macho64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
+// RUN: llvm-cov show %S/Inputs/binary-formats.v6.linux64l -instr-profile %t.profdata -path-equivalence=/tmp,%S %s | FileCheck %s
 
 // RUN: llvm-cov export %S/Inputs/binary-formats.macho64l -instr-profile %t.profdata | FileCheck %S/Inputs/binary-formats.canonical.json
Index: llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
===
--- llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
+++ llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
@@ -27,7 +27,7 @@
 using namespace coverage;
 
 CoverageFilenamesSectionWriter::CoverageFilenamesSectionWriter

[PATCH] D93446: [RISCV] Add vadd with mask and without mask builtin.

2021-02-17 Thread Jim Lin via Phabricator via cfe-commits
Jim added inline comments.



Comment at: clang/lib/Basic/Targets/RISCV.cpp:89
+#define BUILTIN(ID, TYPE, ATTRS)   
\
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#include "clang/Basic/BuiltinsRISCV.def"

Should it put together with `getTargetBuiltins` function?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93446

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


[PATCH] D96847: [clang][cli] Store additional optimization remarks info

2021-02-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 324225.
jansvoboda11 added a comment.

Rename variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96847

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -1162,20 +1162,70 @@
<< "a filename";
 }
 
-/// Create a new Regex instance out of the string value in \p RpassArg.
-/// It returns the string and a pointer to the newly generated Regex instance.
-static CodeGenOptions::RemarkPattern
-GenerateOptimizationRemarkRegex(DiagnosticsEngine &Diags, ArgList &Args,
-Arg *RpassArg) {
-  StringRef Val = RpassArg->getValue();
-  std::string RegexError;
-  std::shared_ptr Pattern = std::make_shared(Val);
-  if (!Pattern->isValid(RegexError)) {
-Diags.Report(diag::err_drv_optimization_remark_pattern)
-<< RegexError << RpassArg->getAsString(Args);
-Pattern.reset();
-  }
-  return {std::string(Val), Pattern};
+/// Generate a remark argument. This is an inverse of `ParseOptimizationRemark`.
+static void GenerateOptimizationRemark(
+SmallVectorImpl &Args, CompilerInvocation::StringAllocator SA,
+OptSpecifier OptEQ, StringRef Name, const CodeGenOptions::RemarkKind &Kind,
+const CodeGenOptions::RemarkPattern &Pattern) {
+  if (Pattern) {
+GenerateArg(Args, OptEQ, Pattern.Pattern, SA);
+  } else if (Kind == CodeGenOptions::RK_Enabled) {
+GenerateArg(Args, OPT_R_Joined, Name, SA);
+  } else if (Kind == CodeGenOptions::RK_Disabled) {
+GenerateArg(Args, OPT_R_Joined, StringRef("no-") + Name, SA);
+  }
+};
+
+/// Parse a remark command line argument. It may be missing, disabled via
+/// '-Rno-group', enabled via '-Rgroup' or specified with a regular expression
+/// via '-Rgroup=regexp'. On top of that, it can be disabled/enabled globally by
+/// '-R[no-]everything'. The \p Kind and \p Pattern are initialized accordingly.
+static void ParseOptimizationRemark(DiagnosticsEngine &Diags, ArgList &Args,
+OptSpecifier OptEQ, StringRef Name,
+CodeGenOptions::RemarkKind &Kind,
+CodeGenOptions::RemarkPattern &Pattern) {
+  auto InitializePattern =
+  [&Diags, &Args](const Arg *A, CodeGenOptions::RemarkPattern &Pattern) {
+StringRef Value = A->getValue();
+std::string RegexError;
+auto Regex = std::make_shared(Value);
+
+if (!Regex->isValid(RegexError)) {
+  Diags.Report(diag::err_drv_optimization_remark_pattern)
+  << RegexError << A->getAsString(Args);
+  return false;
+}
+
+Pattern = CodeGenOptions::RemarkPattern{std::string(Value), Regex};
+return true;
+  };
+
+  CodeGenOptions::RemarkPattern ParsedPattern;
+
+  Kind = CodeGenOptions::RK_Missing;
+
+  for (Arg *A : Args) {
+if (A->getOption().matches(OPT_R_Joined)) {
+  StringRef Value = A->getValue();
+
+  if (Value == Name)
+Kind = CodeGenOptions::RK_Enabled;
+  else if (Value == "everything")
+Kind = CodeGenOptions::RK_EnabledEverything;
+  else if (Value.split('-') == std::make_pair(StringRef("no"), Name))
+Kind = CodeGenOptions::RK_Disabled;
+  else if (Value == "no-everything")
+Kind = CodeGenOptions::RK_DisabledEverything;
+} else if (A->getOption().matches(OptEQ)) {
+  Kind = CodeGenOptions::RK_Pattern;
+  if (!InitializePattern(A, ParsedPattern))
+return;
+}
+  }
+
+  if (ParsedPattern && Kind != CodeGenOptions::RK_Disabled &&
+  Kind != CodeGenOptions::RK_DisabledEverything)
+Pattern = ParsedPattern;
 }
 
 static bool parseDiagnosticLevelMask(StringRef FlagName,
@@ -1484,16 +1534,17 @@
   if (!Opts.OptRecordFormat.empty())
 GenerateArg(Args, OPT_opt_record_format, Opts.OptRecordFormat, SA);
 
-  if (Opts.OptimizationRemarkPattern)
-GenerateArg(Args, OPT_Rpass_EQ, Opts.OptimizationRemarkPattern.Pattern, SA);
+  GenerateOptimizationRemark(Args, SA, OPT_Rpass_EQ, "pass",
+ Opts.OptimizationRemarkKind,
+ Opts.OptimizationRemarkPattern);
 
-  if (Opts.OptimizationRemarkMissedPattern)
-GenerateArg(Args, OPT_Rpass_missed_EQ,
-Opts.OptimizationRemarkMissedPattern.Pattern, SA);
+  GenerateOptimizationRemark(Args, SA, OPT_Rpass_missed_EQ, "pass-missed",
+ Opts.OptimizationRemarkMissedKind,
+ Opts.OptimizationRemarkMissedPattern);
 
-  if (Opts.OptimizationRemarkAnalysisPattern)
-GenerateArg(Args, OPT_Rpass_analysis_EQ,
-Opts.Optimi

[clang] e1a64aa - [OpenCL] Create VoidPtrTy with generic AS in C++ for OpenCL mode

2021-02-17 Thread Anton Zabaznov via cfe-commits

Author: Anton Zabaznov
Date: 2021-02-17T12:18:46+03:00
New Revision: e1a64aa66c332d16b3f0dae0426ee29eeb6bbba6

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

LOG: [OpenCL] Create VoidPtrTy with generic AS in C++ for OpenCL mode

This change affects 'SemaOpenCLCXX/newdelete.cl' test,
thus the patch contains adjustments in types validation of
operators new and delete

Reviewed By: Anastasia

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

Added: 
clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl

Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 80ec858ca0f0..02f9b214fe94 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1445,7 +1445,7 @@ void ASTContext::InitBuiltinTypes(const TargetInfo 
&Target,
   ObjCSuperType = QualType();
 
   // void * type
-  if (LangOpts.OpenCLVersion >= 200) {
+  if (LangOpts.OpenCLGenericAddressSpace) {
 auto Q = VoidTy.getQualifiers();
 Q.setAddressSpace(LangAS::opencl_generic);
 VoidPtrTy = getPointerType(getCanonicalType(

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 8bfaa46162bc..bef7cb39fdff 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -15261,11 +15261,13 @@ CheckOperatorNewDeleteDeclarationScope(Sema &SemaRef,
   return false;
 }
 
-static QualType
-RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
-  QualType QTy = PtrTy->getPointeeType();
-  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
-  return SemaRef.Context.getPointerType(QTy);
+static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef,
+ const PointerType *PtrTy) {
+  auto &Ctx = SemaRef.Context;
+  Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
+  PtrQuals.removeAddressSpace();
+  return Ctx.getPointerType(Ctx.getCanonicalType(Ctx.getQualifiedType(
+  PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
 }
 
 static inline bool
@@ -15277,11 +15279,14 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const 
FunctionDecl *FnDecl,
   QualType ResultType =
   FnDecl->getType()->castAs()->getReturnType();
 
-  // The operator is valid on any address space for OpenCL.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
-if (auto *PtrTy = ResultType->getAs()) {
+// The operator is valid on any address space for OpenCL.
+// Drop address space from actual and expected result types.
+if (const auto *PtrTy = ResultType->getAs())
   ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
-}
+
+if (auto ExpectedPtrTy = ExpectedResultType->getAs())
+  ExpectedResultType = RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
   }
 
   // Check that the result type is what we expect.
@@ -15311,10 +15316,14 @@ CheckOperatorNewDeleteTypes(Sema &SemaRef, const 
FunctionDecl *FnDecl,
   QualType FirstParamType = FnDecl->getParamDecl(0)->getType();
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
 // The operator is valid on any address space for OpenCL.
-if (auto *PtrTy =
-FnDecl->getParamDecl(0)->getType()->getAs()) {
+// Drop address space from actual and expected first parameter types.
+if (const auto *PtrTy =
+FnDecl->getParamDecl(0)->getType()->getAs())
   FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
-}
+
+if (auto ExpectedPtrTy = ExpectedFirstParamType->getAs())
+  ExpectedFirstParamType =
+  RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
   }
 
   // Check that the first parameter type is what we expect.

diff  --git a/clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl 
b/clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
new file mode 100644
index ..f3a397419def
--- /dev/null
+++ b/clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=clc++ -emit-llvm -O0 -o - | 
FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+class A {
+public:
+  void* operator new(size_t);
+  void operator delete(void *ptr);
+};
+
+void test_new_delete(A **a) {
+// CHECK: %{{.*}} = call spir_func i8 addrspace(4)* @_ZNU3AS41AnwEj(i32 {{.*}})
+*a = new A;
+// CHECK: call spir_func void @_ZNU3AS41AdlEPU3AS4v(i8 addrspace(4)* {{.*}})
+delete *a;
+}



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


[PATCH] D96178: [OpenCL] Create VoidPtrTy with generic AS in C++ for OpenCL mode

2021-02-17 Thread Anton Zabaznov 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 rGe1a64aa66c33: [OpenCL] Create VoidPtrTy with generic AS in 
C++ for OpenCL mode (authored by azabaznov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96178

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=clc++ -emit-llvm -O0 -o - | 
FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+class A {
+public:
+  void* operator new(size_t);
+  void operator delete(void *ptr);
+};
+
+void test_new_delete(A **a) {
+// CHECK: %{{.*}} = call spir_func i8 addrspace(4)* @_ZNU3AS41AnwEj(i32 {{.*}})
+*a = new A;
+// CHECK: call spir_func void @_ZNU3AS41AdlEPU3AS4v(i8 addrspace(4)* {{.*}})
+delete *a;
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15261,11 +15261,13 @@
   return false;
 }
 
-static QualType
-RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
-  QualType QTy = PtrTy->getPointeeType();
-  QTy = SemaRef.Context.removeAddrSpaceQualType(QTy);
-  return SemaRef.Context.getPointerType(QTy);
+static CanQualType RemoveAddressSpaceFromPtr(Sema &SemaRef,
+ const PointerType *PtrTy) {
+  auto &Ctx = SemaRef.Context;
+  Qualifiers PtrQuals = PtrTy->getPointeeType().getQualifiers();
+  PtrQuals.removeAddressSpace();
+  return Ctx.getPointerType(Ctx.getCanonicalType(Ctx.getQualifiedType(
+  PtrTy->getPointeeType().getUnqualifiedType(), PtrQuals)));
 }
 
 static inline bool
@@ -15277,11 +15279,14 @@
   QualType ResultType =
   FnDecl->getType()->castAs()->getReturnType();
 
-  // The operator is valid on any address space for OpenCL.
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
-if (auto *PtrTy = ResultType->getAs()) {
+// The operator is valid on any address space for OpenCL.
+// Drop address space from actual and expected result types.
+if (const auto *PtrTy = ResultType->getAs())
   ResultType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
-}
+
+if (auto ExpectedPtrTy = ExpectedResultType->getAs())
+  ExpectedResultType = RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
   }
 
   // Check that the result type is what we expect.
@@ -15311,10 +15316,14 @@
   QualType FirstParamType = FnDecl->getParamDecl(0)->getType();
   if (SemaRef.getLangOpts().OpenCLCPlusPlus) {
 // The operator is valid on any address space for OpenCL.
-if (auto *PtrTy =
-FnDecl->getParamDecl(0)->getType()->getAs()) {
+// Drop address space from actual and expected first parameter types.
+if (const auto *PtrTy =
+FnDecl->getParamDecl(0)->getType()->getAs())
   FirstParamType = RemoveAddressSpaceFromPtr(SemaRef, PtrTy);
-}
+
+if (auto ExpectedPtrTy = ExpectedFirstParamType->getAs())
+  ExpectedFirstParamType =
+  RemoveAddressSpaceFromPtr(SemaRef, ExpectedPtrTy);
   }
 
   // Check that the first parameter type is what we expect.
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -1445,7 +1445,7 @@
   ObjCSuperType = QualType();
 
   // void * type
-  if (LangOpts.OpenCLVersion >= 200) {
+  if (LangOpts.OpenCLGenericAddressSpace) {
 auto Q = VoidTy.getQualifiers();
 Q.setAddressSpace(LangAS::opencl_generic);
 VoidPtrTy = getPointerType(getCanonicalType(


Index: clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCLCXX/addrspace-new-delete.cl
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 %s -triple spir -cl-std=clc++ -emit-llvm -O0 -o - | FileCheck %s
+
+typedef __SIZE_TYPE__ size_t;
+
+class A {
+public:
+  void* operator new(size_t);
+  void operator delete(void *ptr);
+};
+
+void test_new_delete(A **a) {
+// CHECK: %{{.*}} = call spir_func i8 addrspace(4)* @_ZNU3AS41AnwEj(i32 {{.*}})
+*a = new A;
+// CHECK: call spir_func void @_ZNU3AS41AdlEPU3AS4v(i8 addrspace(4)* {{.*}})
+delete *a;
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -15261,11 +15261,13 @@
   return false;
 }
 
-static QualType
-RemoveAddressSpaceFromPtr(Sema &SemaRef, const PointerType *PtrTy) {
-  QualType QTy = PtrTy->getPointeeType();
-  QTy = 

[PATCH] D96816: [ObjC] Encode pointers to C++ classes as "^v" if the encoded string would otherwise include template specialization types

2021-02-17 Thread David Chisnall via Phabricator via cfe-commits
theraven requested changes to this revision.
theraven added a comment.
This revision now requires changes to proceed.

I'm broadly in favour of this change, but with the GNUstep ABIs this is an 
ABI-breaking change and so should not be on by default.  The type encoding 
leaks into the ABI in two ways:

- Dispatch is dependent on type, which avoids some stack corruption bugs on 
NeXT-style runtimes.  This means that the types of the selector in the caller 
and the selector in the method definition must match.  I don't see a problem 
with turning this change off for this specific case, because it's incredibly 
rare to pass complex C++ template types as arguments to Objective-C methods.
- The variable that contains the offset of ivars includes the type encoding, so 
that changing the type of a public ivar breaks linkage, rather than just subtly 
corrupting data later.  We could leave this change on for any `@private` or 
`@package` ivars, but changing the type encoding for public ivars will break 
code linking with existing frameworks.

I'm quite happy with this to be opt-in for non-Apple runtimes and opt-out for 
Apple runtimes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96816

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


[PATCH] D96848: [clang][cli] Don't emit manufactured warnings

2021-02-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, dexonsmith.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The switch from per-member round-trip to whole-`CompilerInvocation` round-trip 
in D96280  means we'll be running the extra 
code present in `CompilerInvocation::CreateFromArgs`. This code conditionally 
manufactures extra warnings based on the target and input. This patch ensures 
we don't generate arguments for such manufactured warnings. Without this patch, 
each call to `CompilerInvocation::generateCC1CommandLine` during 
whole-`CompilerInvocation` round-trip could generate more arguments than the 
previous one.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96848

Files:
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2295,7 +2295,8 @@
 
 void CompilerInvocation::GenerateDiagnosticArgs(
 const DiagnosticOptions &Opts, SmallVectorImpl &Args,
-StringAllocator SA, bool DefaultDiagColor) {
+StringAllocator SA, bool DefaultDiagColor, const llvm::Triple &T,
+InputKind DashX) {
   const DiagnosticOptions *DiagnosticOpts = &Opts;
 #define DIAG_OPTION_WITH_MARSHALLING(  
\
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,
\
@@ -2343,6 +2344,13 @@
 // This option is automatically generated from UndefPrefixes.
 if (Warning == "undef-prefix")
   continue;
+// This warning was manufactured, don't put it on the command line.
+if (Warning == "no-stdlibcxx-not-found" && T.isOSDarwin() &&
+DashX.isPreprocessed())
+  continue;
+// This warning was manufactured, don't put it on the command line.
+if (Warning == "spir-compat" && T.isSPIR())
+  continue;
 Args.push_back(SA(StringRef("-W") + Warning));
   }
 
@@ -4831,11 +4839,12 @@
 void CompilerInvocation::generateCC1CommandLine(
 SmallVectorImpl &Args, StringAllocator SA) const {
   llvm::Triple T(TargetOpts->Triple);
+  InputKind DashX = FrontendOpts.DashX;
 
   GenerateFileSystemArgs(FileSystemOpts, Args, SA);
   GenerateMigratorArgs(MigratorOpts, Args, SA);
   GenerateAnalyzerArgs(*AnalyzerOpts, Args, SA);
-  GenerateDiagnosticArgs(*DiagnosticOpts, Args, SA, false);
+  GenerateDiagnosticArgs(*DiagnosticOpts, Args, SA, false, T, DashX);
   GenerateFrontendArgs(FrontendOpts, Args, SA, LangOpts->IsHeaderFile);
   GenerateTargetArgs(*TargetOpts, Args, SA);
   GenerateHeaderSearchArgs(*HeaderSearchOpts, Args, SA);
Index: clang/include/clang/Frontend/CompilerInvocation.h
===
--- clang/include/clang/Frontend/CompilerInvocation.h
+++ clang/include/clang/Frontend/CompilerInvocation.h
@@ -249,7 +249,8 @@
   /// Generate command line options from DiagnosticOptions.
   static void GenerateDiagnosticArgs(const DiagnosticOptions &Opts,
  SmallVectorImpl &Args,
- StringAllocator SA, bool 
DefaultDiagColor);
+ StringAllocator SA, bool DefaultDiagColor,
+ const llvm::Triple &T, InputKind DashX);
 
   /// Parse command line options that map to LangOptions.
   static bool ParseLangArgsImpl(LangOptions &Opts, llvm::opt::ArgList &Args,


Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2295,7 +2295,8 @@
 
 void CompilerInvocation::GenerateDiagnosticArgs(
 const DiagnosticOptions &Opts, SmallVectorImpl &Args,
-StringAllocator SA, bool DefaultDiagColor) {
+StringAllocator SA, bool DefaultDiagColor, const llvm::Triple &T,
+InputKind DashX) {
   const DiagnosticOptions *DiagnosticOpts = &Opts;
 #define DIAG_OPTION_WITH_MARSHALLING(  \
 PREFIX_TYPE, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,\
@@ -2343,6 +2344,13 @@
 // This option is automatically generated from UndefPrefixes.
 if (Warning == "undef-prefix")
   continue;
+// This warning was manufactured, don't put it on the command line.
+if (Warning == "no-stdlibcxx-not-found" && T.isOSDarwin() &&
+DashX.isPreprocessed())
+  continue;
+// This warning was manufactured, don't put it on the command line.
+if (Warning == "spir-compat" && T.isSPIR())
+  continue;
 Args.push_back(SA(StringRef("-W") + Warning));
   }
 
@@ -4831,11 +4839,12 @@
 void CompilerInvocation::generateCC1CommandLine(
 SmallVec

[PATCH] D96280: [clang][cli] Round-trip the whole CompilerInvocation

2021-02-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 324229.
jansvoboda11 added a comment.

Add fixme as suggested in code review. Rebase on top of the final version of 
D94472 , which added `-[no-]round-trip-args`. 
The arguments are now handled in `RoundTrip`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96280

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Frontend/round-trip-cc1-args.c

Index: clang/test/Frontend/round-trip-cc1-args.c
===
--- clang/test/Frontend/round-trip-cc1-args.c
+++ clang/test/Frontend/round-trip-cc1-args.c
@@ -4,4 +4,4 @@
 
 // CHECK-WITHOUT-ROUND-TRIP-NOT: remark:
 // CHECK-ROUND-TRIP-WITHOUT-REMARKS-NOT: remark:
-// CHECK-ROUND-TRIP-WITH-REMARKS: remark: Generated arguments {{.*}} in {{.*}} round-trip: {{.*}}
+// CHECK-ROUND-TRIP-WITH-REMARKS: remark: Generated arguments #{{.*}} in round-trip: {{.*}}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -423,9 +423,11 @@
 
 static const StringRef GetInputKindName(InputKind IK);
 
-static void FixupInvocation(CompilerInvocation &Invocation,
-DiagnosticsEngine &Diags, const InputArgList &Args,
+static bool FixupInvocation(CompilerInvocation &Invocation,
+DiagnosticsEngine &Diags, const ArgList &Args,
 InputKind IK) {
+  unsigned NumErrorsBefore = Diags.getNumErrors();
+
   LangOptions &LangOpts = *Invocation.getLangOpts();
   CodeGenOptions &CodeGenOpts = Invocation.getCodeGenOpts();
   TargetOptions &TargetOpts = Invocation.getTargetOpts();
@@ -502,6 +504,8 @@
 Diags.Report(diag::err_drv_argument_only_allowed_with)
 << Args.getLastArg(OPT_fprofile_remapping_file_EQ)->getAsString(Args)
 << "-fno-legacy-pass-manager";
+
+  return Diags.getNumErrors() == NumErrorsBefore;
 }
 
 //===--===//
@@ -569,27 +573,29 @@
 Opt.getKind(), 0, Value);
 }
 
-// Parse subset of command line arguments into a member of CompilerInvocation.
-using ParseFn = llvm::function_ref;
+// Parse command line arguments into CompilerInvocation.
+using ParseFn =
+llvm::function_ref,
+DiagnosticsEngine &, const char *)>;
 
-// Generate part of command line arguments from a member of CompilerInvocation.
+// Generate command line arguments from CompilerInvocation.
 using GenerateFn = llvm::function_ref &,
 CompilerInvocation::StringAllocator)>;
 
-// Swap between dummy/real instance of a CompilerInvocation member.
-using SwapOptsFn = llvm::function_ref;
-
-// Performs round-trip of command line arguments if OriginalArgs contain
-// "-round-trip-args". Effectively runs the Parse function for a part of
-// CompilerInvocation on command line arguments that were already once parsed
-// and generated. This is used to check the Generate function produces arguments
-// that are semantically equivalent to those that were used to create
-// CompilerInvocation.
-static bool RoundTrip(ParseFn Parse, GenerateFn Generate, SwapOptsFn SwapOpts,
-  CompilerInvocation &Res, ArgList &OriginalArgs,
-  DiagnosticsEngine &Diags, StringRef OptsName) {
+// May perform round-trip of command line arguments. By default, the round-trip
+// is enabled if CLANG_ROUND_TRIP_CC1_ARGS was defined during build. This can be
+// overwritten at run-time via the "-round-trip-args" and "-no-round-trip-args"
+// command line flags.
+// During round-trip, the command line arguments are parsed into a dummy
+// instance of CompilerInvocation which is used to generate the command line
+// arguments again. The real CompilerInvocation instance is then created by
+// parsing the generated arguments, not the original ones.
+static bool RoundTrip(ParseFn Parse, GenerateFn Generate,
+  CompilerInvocation &RealInvocation,
+  CompilerInvocation &DummyInvocation,
+  ArrayRef CommandLineArgs,
+  DiagnosticsEngine &Diags, const char *Argv0) {
   // FIXME: Switch to '#ifndef NDEBUG' when possible.
 #ifdef CLANG_ROUND_TRIP_CC1_ARGS
   bool DoRoundTripDefault = true;
@@ -597,16 +603,21 @@
   bool DoRoundTripDefault = false;
 #endif
 
-  bool DoRoundTrip = OriginalArgs.hasFlag(
-  OPT_round_trip_args, OPT_no_round_trip_args, DoRoundTripDefault);
+  bool DoRoundTrip = DoRoundTripDefault;
+  for (const auto *Arg : CommandLineArgs) {
+if (Arg == StringRef("-round-trip-args"))
+  DoRoundTrip = true;
+if (Arg == StringRef("-n

[PATCH] D96751: [clangd] Populate detail field in document symbols

2021-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

This looks really good. Only thing i'd really think about changing in behavior 
is dropping the template params.
Please go ahead and upload the unittests!

(And thanks for including the diff context)




Comment at: clang-tools-extra/clangd/FindSymbols.cpp:184
+  llvm::raw_string_ostream OS(Detail);
+  if (const auto *TP = ND.getDescribedTemplateParams()) {
+TP->print(OS, Ctx, P);

As a tradeoff between brevity and information, we might consider printing 
`template` but not the param list.

Particularly for functions this is useful, as template params are mostly types 
repeated in the signature:
```
- DenseMap | template  void (const InputIt&, const InputIt&)
+ DenseMap | template void (const InputIt&, const InputIt&)
```

But I think this may be fine for classes as well:
```
- DenseMap | template  
class
+ DenseMap | template class
```



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:188
+  if (const auto *VD = dyn_cast(&ND)) {
+VD->getType().print(OS, P);
+  } else if (const auto *TD = dyn_cast(&ND)) {

It might not makes sense to print the placeholder DependentType, types that 
contain undeduced `auto`, and maybe some other cases.

(This can definitely be a fixme comment for later - it'll be hard to find 
exactly the right cases in one pass)




Comment at: clang-tools-extra/clangd/FindSymbols.cpp:192
+  } else if (const auto *TD = dyn_cast(&ND)) {
+OS << "type alias";
+  } else if (const auto *CD = dyn_cast(&ND)) {

What you have here is probably best, just thinking out loud...

we could also consider including the underlying type like `= int` but I suspect 
the difference between ValueDecl is too subtle and sometimes the types are 
really long anyway.



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:194
+  } else if (const auto *CD = dyn_cast(&ND)) {
+CD->getTemplateParameters()->print(OS, Ctx, P);
+OS << "concept";

(if we drop the template params then I don't think we need to even print 
"template" in this case because concepts are always templates)



Comment at: clang-tools-extra/clangd/FindSymbols.cpp:197
+  }
+  return Detail;
+}

nit: either `OS.flush(); return Detail;` or equivalently `return 
std::move(OS.str());`

(Otherwise whether OS's buffer gets flushed into the right string or not is 
fragile, I believe relying on move elision)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96751

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


[PATCH] D96850: [clang] Add -ffinite-loops & -fno-finite-loops options.

2021-02-17 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added subscribers: jansvoboda11, dexonsmith, dang.
fhahn requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This cherry-picks the following patches on the release branch:

6280bb4cd80e 
 [clang] 
Remove redundant condition (NFC).
51bf4c0e6d4c 
 [clang] 
Add -ffinite-loops & -fno-finite-loops options.
fb4d8fe80701 
 [clang] 
Update mustprogress tests

This patch adds 2 new options to control when Clang adds `mustprogress`:

1. -ffinite-loops: assume all loops are finite; mustprogress is added to all 
loops, regardless of the selected language standard.
2. -fno-finite-loops: assume no loop is finite; mustprogress is not added to 
any loop or function. We could add mustprogress to functions without loops, but 
we would have to detect that in Clang, which is probably not worth it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96850

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/attr-mustprogress-0.c
  clang/test/CodeGen/attr-mustprogress-0.cpp
  clang/test/CodeGen/attr-mustprogress-1.c
  clang/test/CodeGen/attr-mustprogress-1.cpp
  clang/test/CodeGen/attr-mustprogress.c
  clang/test/CodeGenCXX/attr-mustprogress.cpp

Index: clang/test/CodeGenCXX/attr-mustprogress.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/attr-mustprogress.cpp
@@ -0,0 +1,330 @@
+// RUN: %clang_cc1 -std=c++98 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
+// RUN: %clang_cc1 -std=c++11 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
+// RUN: %clang_cc1 -std=c++14 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
+// RUN: %clang_cc1 -std=c++17 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
+// RUN: %clang_cc1 -std=c++20 -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX11 %s
+
+// Make sure -ffinite-loops overrides -std=c++98 for loops.
+// RUN: %clang_cc1 -std=c++98 -ffinite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=FINITE %s
+
+// Make sure -fno-finite-loops overrides -std=c++11
+// RUN: %clang_cc1 -std=c++11 -fno-finite-loops -triple=x86_64-unknown-linux-gnu -S -emit-llvm %s -o - | FileCheck --check-prefix=CHECK --check-prefix=CXX98 %s
+
+int a = 0;
+int b = 0;
+
+// CHECK: datalayout
+
+// CXX98-NOT: mustprogress
+// CXX11-NOT: mustprogress
+// FINITE-NOT: mustprogress
+// CHECK-LABEL: @_Z2f0v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:br label %for.cond
+// CHECK:   for.cond:
+// CHECK-NOT:br {{.*}} llvm.loop
+void f0() {
+  for (; ;) ;
+}
+
+// CXX98-NOT: mustprogress
+// CXX11-NOT: mustprogress
+// FINITE-NOT: mustprogress
+// CHECK-LABEL: @_Z2f1v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:br label %for.cond
+// CHECK:   for.cond:
+// CHECK-NEXT:br i1 true, label %for.body, label %for.end
+// CHECK:   for.body:
+// CHECK-NOT:br {{.*}}, !llvm.loop
+// CHECK:   for.end:
+// CHECK-NEXT:ret void
+//
+void f1() {
+  for (; 1;)
+;
+}
+
+// CXX98-NOT: mustprogress
+// CXX11: mustprogress
+// FINITE-NOT: mustprogress
+// CHECK-LABEL: @_Z2f2v(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:br label %for.cond
+// CHECK:   for.cond:
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, i32* @a, align 4
+// CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* @b, align 4
+// CHECK-NEXT:[[CMP:%.*]] = icmp eq i32 [[TMP0]], [[TMP1]]
+// CHECK-NEXT:br i1 [[CMP]], label %for.body, label %for.end
+// CHECK:   for.body:
+// CXX98-NOT:br {{.*}}, !llvm.loop
+// CXX11:br label %for.cond, !llvm.loop [[LOOP1:!.*]]
+// FINITE-NEXT:   br label %for.cond, !llvm.loop [[LOOP1:!.*]]
+// CHECK:   for.end:
+// CHECK-NEXT:ret void
+//
+void f2() {
+  for (; a == b;)
+;
+}
+
+// CXX98-NOT: mustprogress
+// CXX11-NOT: mustprogress
+// FINITE-NOT: mustprogress
+// CHECK-LABEL: @_Z1Fv(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:br label %for.cond
+// CHECK:   for.cond:
+// CHECK-NEXT:br i1 true, label %for.body, label %for.end
+// CHECK:   for.body:
+// CHECK-NOT: br {{.*}}, !llvm.loop
+// CHECK:   for.end:
+// CHECK-NEXT:br label %for.cond1
+// CHECK:   for.cond1:
+// CHECK-NEXT:[[TMP0:%.*]] = lo

[clang-tools-extra] 7b83837 - [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-17 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2021-02-17T10:56:06+01:00
New Revision: 7b83837af6f472e9c0ed0b96b78717d4a3c4dbfe

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

LOG: [clangd] Bind outgoing calls through LSPBinder too. NFC

The redundancy around work-done-progress is annoying but ok for now.

There's a weirdness with context lifetimes around outgoing method calls, which
I've preserved to keep this NFC. We should probably fix it though.

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/LSPBinder.h
clang-tools-extra/clangd/Module.h
clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
clang-tools-extra/clangd/unittests/LSPBinderTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 8bc49b5a5817..d29014f3e7ca 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -410,8 +410,8 @@ class ClangdLSPServer::MessageHandler : public 
Transport::MessageHandler {
 constexpr int ClangdLSPServer::MessageHandler::MaxReplayCallbacks;
 
 // call(), notify(), and reply() wrap the Transport, adding logging and 
locking.
-void ClangdLSPServer::callRaw(StringRef Method, llvm::json::Value Params,
-  Callback CB) {
+void ClangdLSPServer::callMethod(StringRef Method, llvm::json::Value Params,
+ Callback CB) {
   auto ID = MsgHandler->bindReply(std::move(CB));
   log("--> {0}({1})", Method, ID);
   std::lock_guard Lock(TranspWriter);
@@ -578,7 +578,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
&Params,
   };
 
   {
-LSPBinder Binder(Handlers);
+LSPBinder Binder(Handlers, *this);
 bindMethods(Binder);
 if (Opts.Modules)
   for (auto &Mod : *Opts.Modules)
@@ -736,7 +736,7 @@ void ClangdLSPServer::onCommandApplyTweak(const TweakArgs 
&Args,
   ShowMessageParams Msg;
   Msg.message = *R->ShowMessage;
   Msg.type = MessageType::Info;
-  notify("window/showMessage", Msg);
+  ShowMessage(Msg);
 }
 // When no edit is specified, make sure we Reply().
 if (R->ApplyEdits.empty())
@@ -762,10 +762,9 @@ void ClangdLSPServer::applyEdit(WorkspaceEdit WE, 
llvm::json::Value Success,
 Callback Reply) {
   ApplyWorkspaceEditParams Edit;
   Edit.edit = std::move(WE);
-  call(
-  "workspace/applyEdit", std::move(Edit),
-  [Reply = std::move(Reply), SuccessMessage = std::move(Success)](
-  llvm::Expected Response) mutable {
+  ApplyWorkspaceEdit(
+  Edit, [Reply = std::move(Reply), SuccessMessage = std::move(Success)](
+llvm::Expected Response) mutable {
 if (!Response)
   return Reply(Response.takeError());
 if (!Response->applied) {
@@ -851,7 +850,7 @@ void ClangdLSPServer::onDocumentDidClose(
   // executed after it returns.
   PublishDiagnosticsParams Notification;
   Notification.uri = URIForFile::canonicalize(File, /*TUPath=*/File);
-  publishDiagnostics(Notification);
+  PublishDiagnostics(Notification);
 }
 
 void ClangdLSPServer::onDocumentOnTypeFormatting(
@@ -1251,11 +1250,6 @@ void ClangdLSPServer::applyConfiguration(
   [&](llvm::StringRef File) { return ModifiedFiles.count(File) != 0; });
 }
 
-void ClangdLSPServer::publishDiagnostics(
-const PublishDiagnosticsParams &Params) {
-  notify("textDocument/publishDiagnostics", Params);
-}
-
 void ClangdLSPServer::maybeExportMemoryProfile() {
   if (!trace::enabled() || !ShouldProfile())
 return;
@@ -1454,7 +1448,7 @@ ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
 this->Opts.ContextProvider = ClangdServer::createConfiguredContextProvider(
 Opts.ConfigProvider, this);
   }
-  LSPBinder Bind(this->Handlers);
+  LSPBinder Bind(this->Handlers, *this);
   Bind.method("initialize", this, &ClangdLSPServer::onInitialize);
 }
 
@@ -1503,6 +1497,15 @@ void ClangdLSPServer::bindMethods(LSPBinder &Bind) {
 Bind.method("textDocument/foldingRange", this, 
&ClangdLSPServer::onFoldingRange);
   Bind.command(APPLY_FIX_COMMAND, this, &ClangdLSPServer::onCommandApplyEdit);
   Bind.command(APPLY_TWEAK_COMMAND, this, 
&ClangdLSPServer::onCommandApplyTweak);
+
+  ApplyWorkspaceEdit = Bind.outgoingMethod("workspace/applyEdit");
+  PublishDiagnostics = 
Bind.outgoingNotification("textDocument/publishDiagnostics");
+  ShowMessage = Bind.outgoingNotification("window/showMessage");
+  NotifyFileStatus = 
Bind.outgoingNotification("textDocument/clangd.fileStatus");
+  CreateWorkDoneProgress = 
Bind.outgoingMethod("window/workDoneProgress/cre

[PATCH] D96717: [clangd] Bind outgoing calls through LSPBinder too. NFC

2021-02-17 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7b83837af6f4: [clangd] Bind outgoing calls through LSPBinder 
too. NFC (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96717

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/LSPBinder.h
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
  clang-tools-extra/clangd/unittests/LSPBinderTests.cpp

Index: clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
===
--- clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
+++ clang-tools-extra/clangd/unittests/LSPBinderTests.cpp
@@ -15,12 +15,15 @@
 namespace clangd {
 namespace {
 
+using testing::ElementsAre;
 using testing::HasSubstr;
+using testing::IsEmpty;
 using testing::UnorderedElementsAre;
 
 // JSON-serializable type for testing.
 struct Foo {
   int X;
+  friend bool operator==(Foo A, Foo B) { return A.X == B.X; }
 };
 bool fromJSON(const llvm::json::Value &V, Foo &F, llvm::json::Path P) {
   return fromJSON(V, F.X, P.field("X"));
@@ -35,9 +38,31 @@
   return [&Out](llvm::Expected V) { Out.emplace(std::move(V)); };
 }
 
+struct OutgoingRecorder : public LSPBinder::RawOutgoing {
+  llvm::StringMap> Received;
+
+  void callMethod(llvm::StringRef Method, llvm::json::Value Params,
+  Callback Reply) override {
+Received[Method].push_back(Params);
+if (Method == "fail")
+  return Reply(error("Params={0}", Params));
+Reply(Params); // echo back the request
+  }
+  void notify(llvm::StringRef Method, llvm::json::Value Params) override {
+Received[Method].push_back(std::move(Params));
+  }
+
+  std::vector take(llvm::StringRef Method) {
+std::vector Result = Received.lookup(Method);
+Received.erase(Method);
+return Result;
+  }
+};
+
 TEST(LSPBinderTest, IncomingCalls) {
   LSPBinder::RawHandlers RawHandlers;
-  LSPBinder Binder{RawHandlers};
+  OutgoingRecorder RawOutgoing;
+  LSPBinder Binder{RawHandlers, RawOutgoing};
   struct Handler {
 void plusOne(const Foo &Params, Callback Reply) {
   Reply(Foo{Params.X + 1});
@@ -94,7 +119,45 @@
   RawCmdPlusOne(1, capture(Reply));
   ASSERT_TRUE(Reply.hasValue());
   EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(2));
+
+  // None of this generated any outgoing traffic.
+  EXPECT_THAT(RawOutgoing.Received, IsEmpty());
+}
+
+TEST(LSPBinderTest, OutgoingCalls) {
+  LSPBinder::RawHandlers RawHandlers;
+  OutgoingRecorder RawOutgoing;
+  LSPBinder Binder{RawHandlers, RawOutgoing};
+
+  LSPBinder::OutgoingMethod Echo;
+  Echo = Binder.outgoingMethod("echo");
+  LSPBinder::OutgoingMethod WrongSignature;
+  WrongSignature = Binder.outgoingMethod("wrongSignature");
+  LSPBinder::OutgoingMethod Fail;
+  Fail = Binder.outgoingMethod("fail");
+
+  llvm::Optional> Reply;
+  Echo(Foo{2}, capture(Reply));
+  EXPECT_THAT(RawOutgoing.take("echo"), ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::HasValue(Foo{2}));
+
+  // JSON response is integer, can't be parsed as string.
+  llvm::Optional> WrongTypeReply;
+  WrongSignature(Foo{2}, capture(WrongTypeReply));
+  EXPECT_THAT(RawOutgoing.take("wrongSignature"),
+  ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(WrongTypeReply.getValue(),
+   llvm::FailedWithMessage(
+   HasSubstr("failed to decode wrongSignature reply")));
+
+  Fail(Foo{2}, capture(Reply));
+  EXPECT_THAT(RawOutgoing.take("fail"), ElementsAre(llvm::json::Value(2)));
+  ASSERT_TRUE(Reply.hasValue());
+  EXPECT_THAT_EXPECTED(Reply.getValue(), llvm::FailedWithMessage("Params=2"));
 }
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -23,6 +23,7 @@
 namespace clang {
 namespace clangd {
 namespace {
+using testing::ElementsAre;
 
 MATCHER_P(DiagMessage, M, "") {
   if (const auto *O = arg.getAsObject()) {
@@ -223,16 +224,20 @@
 
 TEST_F(LSPTest, ModulesTest) {
   class MathModule final : public Module {
+OutgoingNotification Changed;
 void initializeLSP(LSPBinder &Bind, const llvm::json::Object &ClientCaps,
llvm::json::Object &ServerCaps) override {
   Bind.notification("add", this, &MathModule::add);
   Bind.method("get", this, &MathModule::get);
+  Changed = Bind.outgoingNotification("changed");
 }
 
 int Value = 0;
 
-  public:
-void add(const int &X) { Value += X; }
+void 

[PATCH] D96419: [clang] Add -ffinite-loops & -fno-finite-loops options.

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

In D96419#2556411 , @xbolva00 wrote:

> In D96419#2556349 , @fhahn wrote:
>
>> In D96419#213 , @xbolva00 wrote:
>>
>>> Maybe we want these options in llvm 12 as well?
>>>
>>> (+ Release note)
>>
>> That's a good idea. The patch currently depends on D96418 
>> . Not sure if we should pull that one on 
>> the 12.x release branch though
>
> I think we should to keep consistency with gcc and llvm 13+.

Filed https://bugs.llvm.org/show_bug.cgi?id=49219 to pick this to 12.x


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96419

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


[PATCH] D96825: [AArch64] Adding Polynomial vadd Intrinsics support

2021-02-17 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover accepted this revision.
t.p.northover added a comment.
This revision is now accepted and ready to land.

Looks sensible to me.


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

https://reviews.llvm.org/D96825

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


[clang] aa84289 - [DebugInfo] Keep the DWARF64 flag in the module metadata

2021-02-17 Thread Igor Kudrin via cfe-commits

Author: Igor Kudrin
Date: 2021-02-17T17:03:34+07:00
New Revision: aa842896299b014dc1837f1a01dfccbd94242c84

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

LOG: [DebugInfo] Keep the DWARF64 flag in the module metadata

This allows the option to affect the LTO output. Module::Max helps to
generate debug info for all modules in the same format.

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

Added: 
clang/test/CodeGen/dwarf-format.c
llvm/test/DebugInfo/X86/dwarf64-module-flag.ll

Modified: 
clang/lib/CodeGen/CodeGenModule.cpp
llvm/include/llvm/IR/Module.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/IR/Module.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 4688f13dae21..ff36d5529d4c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -533,6 +533,9 @@ void CodeGenModule::Release() {
   CodeGenOpts.DwarfVersion);
   }
 
+  if (CodeGenOpts.Dwarf64)
+getModule().addModuleFlag(llvm::Module::Max, "DWARF64", 1);
+
   if (Context.getLangOpts().SemanticInterposition)
 // Require various optimization to respect semantic interposition.
 getModule().setSemanticInterposition(1);

diff  --git a/clang/test/CodeGen/dwarf-format.c 
b/clang/test/CodeGen/dwarf-format.c
new file mode 100644
index ..aff941993371
--- /dev/null
+++ b/clang/test/CodeGen/dwarf-format.c
@@ -0,0 +1,13 @@
+// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefix=NODWARF64
+// RUN: %clang -target x86_64-linux-gnu -g -gdwarf64 -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefix=DWARF64
+// RUN: %clang -target x86_64-linux-gnu -g -gdwarf64 -gdwarf32 -S -emit-llvm 
-o - %s | \
+// RUN:   FileCheck %s --check-prefix=NODWARF64
+
+// DWARF64: !{i32 7, !"DWARF64", i32 1}
+// NODWARF64-NOT: !"DWARF64"
+
+int main (void) {
+  return 0;
+}

diff  --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 3664b275114d..3ac57b7e5750 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -805,6 +805,9 @@ class Module {
   /// Returns the Dwarf Version by checking module flags.
   unsigned getDwarfVersion() const;
 
+  /// Returns the DWARF format by checking module flags.
+  bool isDwarf64() const;
+
   /// Returns the CodeView Version by checking module flags.
   /// Returns zero if not present in module.
   unsigned getCodeViewFlag() const;

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 9eaef84c9130..3c2c1f5ded0a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -392,10 +392,11 @@ DwarfDebug::DwarfDebug(AsmPrinter *A)
   DwarfVersion =
   TT.isNVPTX() ? 2 : (DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION);
 
-  bool Dwarf64 = Asm->TM.Options.MCOptions.Dwarf64 &&
- DwarfVersion >= 3 &&   // DWARF64 was introduced in DWARFv3.
- TT.isArch64Bit() &&// DWARF64 requires 64-bit relocations.
- TT.isOSBinFormatELF(); // Support only ELF for now.
+  bool Dwarf64 =
+  (Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64()) &&
+  DwarfVersion >= 3 &&   // DWARF64 was introduced in DWARFv3.
+  TT.isArch64Bit() &&// DWARF64 requires 64-bit relocations.
+  TT.isOSBinFormatELF(); // Support only ELF for now.
 
   UseRangesSection = !NoDwarfRangesSection && !TT.isNVPTX();
 

diff  --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index b4f10e2e2d23..9395b2bb849c 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -509,6 +509,11 @@ unsigned Module::getDwarfVersion() const {
   return cast(Val->getValue())->getZExtValue();
 }
 
+bool Module::isDwarf64() const {
+  auto *Val = cast_or_null(getModuleFlag("DWARF64"));
+  return Val && cast(Val->getValue())->isOne();
+}
+
 unsigned Module::getCodeViewFlag() const {
   auto *Val = cast_or_null(getModuleFlag("CodeView"));
   if (!Val)

diff  --git a/llvm/test/DebugInfo/X86/dwarf64-module-flag.ll 
b/llvm/test/DebugInfo/X86/dwarf64-module-flag.ll
new file mode 100644
index ..7bdacae6d892
--- /dev/null
+++ b/llvm/test/DebugInfo/X86/dwarf64-module-flag.ll
@@ -0,0 +1,37 @@
+; This checks that the debug info is generated in the 64-bit format if the
+; module has the corresponding flag.
+
+; RUN: llc -mtriple=x86_64 -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-info -debug-line %t | FileCheck %s
+
+; CHECK:  Compile Unit: {{.*}} format = DWARF64
+; CHECK:  debug_line[
+; CHECK-NEXT: Line table prologue:
+; CHECK-NEXT:   total_length:
+; CHECK-NEXT: format: DWA

[PATCH] D96597: [DebugInfo] Keep the DWARF64 flag in the module metadata

2021-02-17 Thread Igor Kudrin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGaa842896299b: [DebugInfo] Keep the DWARF64 flag in the 
module metadata (authored by ikudrin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96597

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/dwarf-format.c
  llvm/include/llvm/IR/Module.h
  llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
  llvm/lib/IR/Module.cpp
  llvm/test/DebugInfo/X86/dwarf64-module-flag.ll

Index: llvm/test/DebugInfo/X86/dwarf64-module-flag.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/dwarf64-module-flag.ll
@@ -0,0 +1,37 @@
+; This checks that the debug info is generated in the 64-bit format if the
+; module has the corresponding flag.
+
+; RUN: llc -mtriple=x86_64 -filetype=obj %s -o %t
+; RUN: llvm-dwarfdump -debug-info -debug-line %t | FileCheck %s
+
+; CHECK:  Compile Unit: {{.*}} format = DWARF64
+; CHECK:  debug_line[
+; CHECK-NEXT: Line table prologue:
+; CHECK-NEXT:   total_length:
+; CHECK-NEXT: format: DWARF64
+
+; IR generated and reduced from:
+; $ cat foo.c
+; int foo;
+; $ clang -g -gdwarf64 -S -emit-llvm foo.c -o foo.ll
+
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = dso_local global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!7, !8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "foo", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 12.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "foo.c", directory: "/tmp")
+!4 = !{}
+!5 = !{!0}
+!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!7 = !{i32 7, !"Dwarf Version", i32 4}
+!8 = !{i32 7, !"DWARF64", i32 1}
+!9 = !{i32 2, !"Debug Info Version", i32 3}
+!10 = !{i32 1, !"wchar_size", i32 4}
+!11 = !{!"clang version 13.0.0"}
Index: llvm/lib/IR/Module.cpp
===
--- llvm/lib/IR/Module.cpp
+++ llvm/lib/IR/Module.cpp
@@ -509,6 +509,11 @@
   return cast(Val->getValue())->getZExtValue();
 }
 
+bool Module::isDwarf64() const {
+  auto *Val = cast_or_null(getModuleFlag("DWARF64"));
+  return Val && cast(Val->getValue())->isOne();
+}
+
 unsigned Module::getCodeViewFlag() const {
   auto *Val = cast_or_null(getModuleFlag("CodeView"));
   if (!Val)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -392,10 +392,11 @@
   DwarfVersion =
   TT.isNVPTX() ? 2 : (DwarfVersion ? DwarfVersion : dwarf::DWARF_VERSION);
 
-  bool Dwarf64 = Asm->TM.Options.MCOptions.Dwarf64 &&
- DwarfVersion >= 3 &&   // DWARF64 was introduced in DWARFv3.
- TT.isArch64Bit() &&// DWARF64 requires 64-bit relocations.
- TT.isOSBinFormatELF(); // Support only ELF for now.
+  bool Dwarf64 =
+  (Asm->TM.Options.MCOptions.Dwarf64 || MMI->getModule()->isDwarf64()) &&
+  DwarfVersion >= 3 &&   // DWARF64 was introduced in DWARFv3.
+  TT.isArch64Bit() &&// DWARF64 requires 64-bit relocations.
+  TT.isOSBinFormatELF(); // Support only ELF for now.
 
   UseRangesSection = !NoDwarfRangesSection && !TT.isNVPTX();
 
Index: llvm/include/llvm/IR/Module.h
===
--- llvm/include/llvm/IR/Module.h
+++ llvm/include/llvm/IR/Module.h
@@ -805,6 +805,9 @@
   /// Returns the Dwarf Version by checking module flags.
   unsigned getDwarfVersion() const;
 
+  /// Returns the DWARF format by checking module flags.
+  bool isDwarf64() const;
+
   /// Returns the CodeView Version by checking module flags.
   /// Returns zero if not present in module.
   unsigned getCodeViewFlag() const;
Index: clang/test/CodeGen/dwarf-format.c
===
--- /dev/null
+++ clang/test/CodeGen/dwarf-format.c
@@ -0,0 +1,13 @@
+// RUN: %clang -target x86_64-linux-gnu -g -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefix=NODWARF64
+// RUN: %clang -target x86_64-linux-gnu -g -gdwarf64 -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefix=DWARF64
+// RUN: %clang -target x86_64-linux-gnu -g -gdwarf64 -gdwarf32 -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefix=NODWARF64
+
+// DWARF64: !{i32 7, !"DWARF64", i32 1}
+// NODWARF64-NOT: !"DWARF64"
+
+int main (void) {
+  return 0;
+}
Index: clang/lib/CodeGen/CodeGenModule.cpp
==

[clang] 72eee60 - [Driver] Support -gdwarf64 for assembly files

2021-02-17 Thread Igor Kudrin via cfe-commits

Author: Igor Kudrin
Date: 2021-02-17T17:03:34+07:00
New Revision: 72eee60b2451e8627e492d42bf1d43247685bef9

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

LOG: [Driver] Support -gdwarf64 for assembly files

The option was added in D90507 for C/C++ source files. This patch adds
support for assembly files.

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

Added: 
clang/test/Misc/cc1as-debug-format.s

Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/debug-options-as.c
clang/tools/driver/cc1as_main.cpp

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index b3e17e1bfe27..0451fa829c00 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2666,10 +2666,12 @@ def gdwarf_4 : Flag<["-"], "gdwarf-4">, Group,
   HelpText<"Generate source-level debug information with dwarf version 4">;
 def gdwarf_5 : Flag<["-"], "gdwarf-5">, Group,
   HelpText<"Generate source-level debug information with dwarf version 5">;
-def gdwarf64 : Flag<["-"], "gdwarf64">, Group, Flags<[CC1Option]>,
+def gdwarf64 : Flag<["-"], "gdwarf64">, Group,
+  Flags<[CC1Option, CC1AsOption]>,
   HelpText<"Enables DWARF64 format for ELF binaries, if debug information 
emission is enabled.">,
   MarshallingInfoFlag>;
-def gdwarf32 : Flag<["-"], "gdwarf32">, Group, Flags<[CC1Option]>,
+def gdwarf32 : Flag<["-"], "gdwarf32">, Group,
+  Flags<[CC1Option, CC1AsOption]>,
   HelpText<"Enables DWARF32 format for ELF binaries, if debug information 
emission is enabled.">;
 
 def gcodeview : Flag<["-"], "gcodeview">,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 819f10eb2524..03166232cf42 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3749,6 +3749,29 @@ static DwarfFissionKind getDebugFissionKind(const Driver 
&D,
   return DwarfFissionKind::None;
 }
 
+static void renderDwarfFormat(const Driver &D, const llvm::Triple &T,
+  const ArgList &Args, ArgStringList &CmdArgs,
+  unsigned DwarfVersion) {
+  auto *DwarfFormatArg =
+  Args.getLastArg(options::OPT_gdwarf64, options::OPT_gdwarf32);
+  if (!DwarfFormatArg)
+return;
+
+  if (DwarfFormatArg->getOption().matches(options::OPT_gdwarf64)) {
+if (DwarfVersion < 3)
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << DwarfFormatArg->getAsString(Args) << "DWARFv3 or greater";
+else if (!T.isArch64Bit())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << DwarfFormatArg->getAsString(Args) << "64 bit architecture";
+else if (!T.isOSBinFormatELF())
+  D.Diag(diag::err_drv_argument_only_allowed_with)
+  << DwarfFormatArg->getAsString(Args) << "ELF platforms";
+  }
+
+  DwarfFormatArg->render(Args, CmdArgs);
+}
+
 static void renderDebugOptions(const ToolChain &TC, const Driver &D,
const llvm::Triple &T, const ArgList &Args,
bool EmitCodeView, bool IRInput,
@@ -4049,25 +4072,7 @@ static void renderDebugOptions(const ToolChain &TC, 
const Driver &D,
   if (DebuggerTuning == llvm::DebuggerKind::SCE)
 CmdArgs.push_back("-dwarf-explicit-import");
 
-  auto *DwarfFormatArg =
-  Args.getLastArg(options::OPT_gdwarf64, options::OPT_gdwarf32);
-  if (DwarfFormatArg &&
-  DwarfFormatArg->getOption().matches(options::OPT_gdwarf64)) {
-const llvm::Triple &RawTriple = TC.getTriple();
-if (EffectiveDWARFVersion < 3)
-  D.Diag(diag::err_drv_argument_only_allowed_with)
-  << DwarfFormatArg->getAsString(Args) << "DWARFv3 or greater";
-else if (!RawTriple.isArch64Bit())
-  D.Diag(diag::err_drv_argument_only_allowed_with)
-  << DwarfFormatArg->getAsString(Args) << "64 bit architecture";
-else if (!RawTriple.isOSBinFormatELF())
-  D.Diag(diag::err_drv_argument_only_allowed_with)
-  << DwarfFormatArg->getAsString(Args) << "ELF platforms";
-  }
-
-  if (DwarfFormatArg)
-DwarfFormatArg->render(Args, CmdArgs);
-
+  renderDwarfFormat(D, T, Args, CmdArgs, EffectiveDWARFVersion);
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
@@ -7211,6 +7216,7 @@ void ClangAs::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
   RenderDebugEnablingArgs(Args, CmdArgs, DebugInfoKind, DwarfVersion,
   llvm::DebuggerKind::Default);
+  renderDwarfFormat(D, Triple, Args, CmdArgs, DwarfVersion);
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, getToolChain());
 
 

diff  --git a/clang/test/Driver/debug-options-as.c 
b/clang/test/Driver/debug-options-as.c
index 514756

[PATCH] D96783: [Driver] Support -gdwarf64 for assembly files

2021-02-17 Thread Igor Kudrin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
ikudrin marked 2 inline comments as done.
Closed by commit rG72eee60b2451: [Driver] Support -gdwarf64 for assembly files 
(authored by ikudrin).

Changed prior to commit:
  https://reviews.llvm.org/D96783?vs=323989&id=324239#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96783

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/debug-options-as.c
  clang/test/Misc/cc1as-debug-format.s
  clang/tools/driver/cc1as_main.cpp

Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -91,6 +91,7 @@
   unsigned SaveTemporaryLabels : 1;
   unsigned GenDwarfForAssembly : 1;
   unsigned RelaxELFRelocations : 1;
+  unsigned Dwarf64 : 1;
   unsigned DwarfVersion;
   std::string DwarfDebugFlags;
   std::string DwarfDebugProducer;
@@ -160,6 +161,7 @@
 FatalWarnings = 0;
 NoWarn = 0;
 IncrementalLinkerCompatible = 0;
+Dwarf64 = 0;
 DwarfVersion = 0;
 EmbedBitcode = 0;
   }
@@ -231,6 +233,8 @@
   }
 
   Opts.RelaxELFRelocations = Args.hasArg(OPT_mrelax_relocations);
+  if (auto *DwarfFormatArg = Args.getLastArg(OPT_gdwarf64, OPT_gdwarf32))
+Opts.Dwarf64 = DwarfFormatArg->getOption().matches(OPT_gdwarf64);
   Opts.DwarfVersion = getLastArgIntValue(Args, OPT_dwarf_version_EQ, 2, Diags);
   Opts.DwarfDebugFlags =
   std::string(Args.getLastArgValue(OPT_dwarf_debug_flags));
@@ -417,6 +421,7 @@
   Ctx.addDebugPrefixMapEntry(KV.first, KV.second);
   if (!Opts.MainFileName.empty())
 Ctx.setMainFileName(StringRef(Opts.MainFileName));
+  Ctx.setDwarfFormat(Opts.Dwarf64 ? dwarf::DWARF64 : dwarf::DWARF32);
   Ctx.setDwarfVersion(Opts.DwarfVersion);
   if (Opts.GenDwarfForAssembly)
 Ctx.setGenDwarfRootFile(Opts.InputFile,
Index: clang/test/Misc/cc1as-debug-format.s
===
--- /dev/null
+++ clang/test/Misc/cc1as-debug-format.s
@@ -0,0 +1,24 @@
+// REQUIRES: x86-registered-target
+/// DWARF32 debug info is produced by default, when neither -gdwarf32 nor -gdwarf64 is given.
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu -filetype obj -debug-info-kind=limited -dwarf-version=4 %s -o %t
+// RUN: llvm-dwarfdump -all %t | FileCheck %s --check-prefixes=CHECK,DWARF32
+/// -gdwarf64 causes generating DWARF64 debug info.
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu -filetype obj -gdwarf64 -debug-info-kind=limited -dwarf-version=4 %s -o %t
+// RUN: llvm-dwarfdump -all %t | FileCheck %s --check-prefixes=CHECK,DWARF64
+/// -gdwarf32 is also handled and produces DWARF32 debug info.
+// RUN: %clang -cc1as -triple x86_64-pc-linux-gnu -filetype obj -gdwarf32 -debug-info-kind=limited -dwarf-version=4 %s -o %t
+// RUN: llvm-dwarfdump -all %t | FileCheck %s --check-prefixes=CHECK,DWARF32
+
+// CHECK:.debug_info contents:
+// DWARF32-NEXT: format = DWARF32
+// DWARF64-NEXT: format = DWARF64
+
+// CHECK:.debug_line contents:
+// CHECK-NEXT:   debug_line[
+// CHECK-NEXT:   Line table prologue:
+// CHECK-NEXT: total_length:
+// DWARF32-NEXT: format: DWARF32
+// DWARF64-NEXT: format: DWARF64
+
+.text
+  nop
Index: clang/test/Driver/debug-options-as.c
===
--- clang/test/Driver/debug-options-as.c
+++ clang/test/Driver/debug-options-as.c
@@ -32,3 +32,31 @@
 //
 // P: "-cc1as"
 // P: "-dwarf-debug-producer"
+
+// Check that -gdwarf64 is passed to cc1as.
+// RUN: %clang -### -c -gdwarf64 -gdwarf-5 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-3 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ON %s
+// GDWARF64_ON: "-cc1as"
+// GDWARF64_ON: "-gdwarf64"
+
+// Check that -gdwarf64 can be reverted with -gdwarf32.
+// RUN: %clang -### -c -gdwarf64 -gdwarf32 -gdwarf-4 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_OFF %s
+// GDWARF64_OFF: "-cc1as"
+// GDWARF64_OFF-NOT: "-gdwarf64"
+
+// Check that an error is reported if -gdwarf64 cannot be used.
+// RUN: %clang -### -c -gdwarf64 -gdwarf-2 -target x86_64 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_VER %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target i386-linux-gnu %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_32ARCH %s
+// RUN: %clang -### -c -gdwarf64 -gdwarf-4 -target x86_64-apple-darwin %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=GDWARF64_ELF %s
+//
+// GDWARF64_VER:  

[PATCH] D96825: [AArch64] Adding Polynomial vadd Intrinsics support

2021-02-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

This LGTM unless @labrinea has any final comments.

Could you add "Neon" in the commit title? "[AArch64] Adding Neon Polynomial 
vadd Intrinsics support", just to help when reading git history.




Comment at: clang/test/CodeGen/aarch64-poly-add.c:4
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN: -disable-O0-optnone -ffp-contract=fast -emit-llvm -o - %s | opt -S 
-mem2reg \
+// RUN:  | FileCheck %s

Do we need this option? (-ffp-contract)


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

https://reviews.llvm.org/D96825

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


[clang-tools-extra] d20961c - [clang-tidy] Simplify delete null ptr check

2021-02-17 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-02-17T10:18:36Z
New Revision: d20961c6575c00fc998d901ded78c1a41edd61b1

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

LOG: [clang-tidy] Simplify delete null ptr check

Because it no longer relies on finding implicit casts, this check now
works on templates which are not instantiated in the translation unit.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h

clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp 
b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
index 16e86c201ff1..9f3350409d06 100644
--- a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
@@ -20,34 +20,30 @@ namespace readability {
 
 void DeleteNullPointerCheck::registerMatchers(MatchFinder *Finder) {
   const auto DeleteExpr =
-  cxxDeleteExpr(has(castExpr(has(declRefExpr(
-to(decl(equalsBoundNode("deletedPointer"
+  cxxDeleteExpr(
+  has(declRefExpr(to(decl(equalsBoundNode("deletedPointer"))
   .bind("deleteExpr");
 
   const auto DeleteMemberExpr =
-  cxxDeleteExpr(has(castExpr(has(memberExpr(hasDeclaration(
-
fieldDecl(equalsBoundNode("deletedMemberPointer"
+  cxxDeleteExpr(has(memberExpr(hasDeclaration(
+fieldDecl(equalsBoundNode("deletedMemberPointer"))
   .bind("deleteMemberExpr");
 
-  const auto PointerExpr = ignoringImpCasts(anyOf(
+  const auto PointerExpr = anyOf(
   declRefExpr(to(decl().bind("deletedPointer"))),
-  memberExpr(hasDeclaration(fieldDecl().bind("deletedMemberPointer");
+  memberExpr(hasDeclaration(fieldDecl().bind("deletedMemberPointer";
 
-  const auto PointerCondition = castExpr(hasCastKind(CK_PointerToBoolean),
- hasSourceExpression(PointerExpr));
-  const auto BinaryPointerCheckCondition = binaryOperator(
-  hasOperands(castExpr(hasCastKind(CK_NullToPointer)), PointerExpr));
+  const auto BinaryPointerCheckCondition = binaryOperator(hasOperands(
+  anyOf(cxxNullPtrLiteralExpr(), integerLiteral(equals(0))), PointerExpr));
 
   Finder->addMatcher(
-  traverse(TK_AsIs,
-   ifStmt(hasCondition(
-  anyOf(PointerCondition, 
BinaryPointerCheckCondition)),
-  hasThen(anyOf(DeleteExpr, DeleteMemberExpr,
-compoundStmt(anyOf(has(DeleteExpr),
-   has(DeleteMemberExpr)),
- statementCountIs(1))
-.bind("compound"
-   .bind("ifWithDelete")),
+  ifStmt(hasCondition(anyOf(PointerExpr, BinaryPointerCheckCondition)),
+ hasThen(anyOf(
+ DeleteExpr, DeleteMemberExpr,
+ compoundStmt(anyOf(has(DeleteExpr), has(DeleteMemberExpr)),
+  statementCountIs(1))
+ .bind("compound"
+  .bind("ifWithDelete"),
   this);
 }
 

diff  --git a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h 
b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
index 0e310f797a4c..c0d07d5d71b6 100644
--- a/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
+++ b/clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
@@ -26,6 +26,9 @@ class DeleteNullPointerCheck : public ClangTidyCheck {
   : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
index 1c044e9d25f0..36e8f059c22b 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-delete-null-pointer %t
+// RUN: %check_clang_tidy %s readability-delete-null-pointer %t -- -- 
-fno-delayed-template-parsing
 
 #define N

[PATCH] D96138: [clang-tidy] Simplify delete null ptr check

2021-02-17 Thread Stephen Kelly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd20961c6575c: [clang-tidy] Simplify delete null ptr check 
(authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96138

Files:
  clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
  clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
  clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-delete-null-pointer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-delete-null-pointer %t
+// RUN: %check_clang_tidy %s readability-delete-null-pointer %t -- -- -fno-delayed-template-parsing
 
 #define NULL 0
 
@@ -37,6 +37,34 @@
   ti3.foo();
 }
 
+template 
+struct NeverInstantiated {
+  void foo() {
+// t1
+if (mem) // t2
+  delete mem;
+// CHECK-MESSAGES: :[[@LINE-2]]:5: warning: 'if' statement is unnecessary;
+// CHECK-FIXES: // t1
+// CHECK-FIXES-NEXT: {{^}}// t2
+// CHECK-FIXES-NEXT: delete mem;
+  }
+  T mem;
+};
+
+template 
+struct NeverInstantiatedPtr {
+  void foo() {
+// t3
+if (mem) // t4
+  delete mem;
+// CHECK-MESSAGES: :[[@LINE-2]]:5: warning: 'if' statement is unnecessary;
+// CHECK-FIXES: // t3
+// CHECK-FIXES-NEXT: {{^}}// t4
+// CHECK-FIXES-NEXT: delete mem;
+  }
+  T *mem;
+};
+
 void f() {
   int *ps = 0;
   if (ps /**/) // #0
Index: clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
===
--- clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
+++ clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.h
@@ -26,6 +26,9 @@
   : ClangTidyCheck(Name, Context) {}
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/DeleteNullPointerCheck.cpp
@@ -20,34 +20,30 @@
 
 void DeleteNullPointerCheck::registerMatchers(MatchFinder *Finder) {
   const auto DeleteExpr =
-  cxxDeleteExpr(has(castExpr(has(declRefExpr(
-to(decl(equalsBoundNode("deletedPointer"
+  cxxDeleteExpr(
+  has(declRefExpr(to(decl(equalsBoundNode("deletedPointer"))
   .bind("deleteExpr");
 
   const auto DeleteMemberExpr =
-  cxxDeleteExpr(has(castExpr(has(memberExpr(hasDeclaration(
-fieldDecl(equalsBoundNode("deletedMemberPointer"
+  cxxDeleteExpr(has(memberExpr(hasDeclaration(
+fieldDecl(equalsBoundNode("deletedMemberPointer"))
   .bind("deleteMemberExpr");
 
-  const auto PointerExpr = ignoringImpCasts(anyOf(
+  const auto PointerExpr = anyOf(
   declRefExpr(to(decl().bind("deletedPointer"))),
-  memberExpr(hasDeclaration(fieldDecl().bind("deletedMemberPointer");
+  memberExpr(hasDeclaration(fieldDecl().bind("deletedMemberPointer";
 
-  const auto PointerCondition = castExpr(hasCastKind(CK_PointerToBoolean),
- hasSourceExpression(PointerExpr));
-  const auto BinaryPointerCheckCondition = binaryOperator(
-  hasOperands(castExpr(hasCastKind(CK_NullToPointer)), PointerExpr));
+  const auto BinaryPointerCheckCondition = binaryOperator(hasOperands(
+  anyOf(cxxNullPtrLiteralExpr(), integerLiteral(equals(0))), PointerExpr));
 
   Finder->addMatcher(
-  traverse(TK_AsIs,
-   ifStmt(hasCondition(
-  anyOf(PointerCondition, BinaryPointerCheckCondition)),
-  hasThen(anyOf(DeleteExpr, DeleteMemberExpr,
-compoundStmt(anyOf(has(DeleteExpr),
-   has(DeleteMemberExpr)),
- statementCountIs(1))
-.bind("compound"
-   .bind("ifWithDelete")),
+  ifStmt(hasCondition(anyOf(PointerExpr, BinaryPointerCheckCondition)),
+ hasThen(anyOf(
+ DeleteExpr, DeleteMemberExpr,
+ compoundStmt(anyOf(has(DeleteExpr), has(DeleteMemberExpr)),
+  

[clang-tools-extra] 6c2eca9 - [clang-tidy] Simplify inefficient algorithm check

2021-02-17 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-02-17T10:19:44Z
New Revision: 6c2eca96a2a59f69889a9d4133a819ab2e4fa1ef

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

LOG: [clang-tidy] Simplify inefficient algorithm check

The normalization of matchers means that this now works in all language
modes.

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h

clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
index 8381ed0b1553..05ef855de7e7 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -35,27 +35,24 @@ void 
InefficientAlgorithmCheck::registerMatchers(MatchFinder *Finder) {
   "::std::unordered_set", "::std::unordered_map",
   "::std::unordered_multiset", "::std::unordered_multimap"));
 
-  const auto Matcher = traverse(
-  TK_AsIs,
+  const auto Matcher =
   callExpr(
   callee(functionDecl(Algorithms)),
   hasArgument(
-  0, cxxConstructExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
+  0, cxxMemberCallExpr(
  callee(cxxMethodDecl(hasName("begin"))),
  on(declRefExpr(
 hasDeclaration(decl().bind("IneffContObj")),
 anyOf(hasType(ContainerMatcher.bind("IneffCont")),
   hasType(pointsTo(
   ContainerMatcher.bind("IneffContPtr")
-.bind("IneffContExpr"))),
+.bind("IneffContExpr",
   hasArgument(
-  1, cxxConstructExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
- callee(cxxMethodDecl(hasName("end"))),
- on(declRefExpr(
- 
hasDeclaration(equalsBoundNode("IneffContObj"),
-  hasArgument(2, expr().bind("AlgParam")),
-  unless(isInTemplateInstantiation()))
-  .bind("IneffAlg"));
+  1, cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))),
+   on(declRefExpr(hasDeclaration(
+   equalsBoundNode("IneffContObj")),
+  hasArgument(2, expr().bind("AlgParam")))
+  .bind("IneffAlg");
 
   Finder->addMatcher(Matcher, this);
 }

diff  --git 
a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h 
b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
index 14f8fbbab2ae..5a7536ad76aa 100644
--- a/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
@@ -29,6 +29,9 @@ class InefficientAlgorithmCheck : public ClangTidyCheck {
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace performance

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
index aa4e30d6f3fe..19a6701c5b6a 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s 
performance-inefficient-algorithm %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s performance-inefficient-algorithm %t
 
 namespace std {
 template  struct less {



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


[PATCH] D96140: [clang-tidy] Simplify inefficient algorithm check

2021-02-17 Thread Stephen Kelly 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 rG6c2eca96a2a5: [clang-tidy] Simplify inefficient algorithm 
check (authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96140

Files:
  clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
  clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
  
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s 
performance-inefficient-algorithm %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s performance-inefficient-algorithm %t
 
 namespace std {
 template  struct less {
Index: clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
===
--- clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
+++ clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
@@ -29,6 +29,9 @@
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace performance
Index: clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
===
--- clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
+++ clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.cpp
@@ -35,27 +35,24 @@
   "::std::unordered_set", "::std::unordered_map",
   "::std::unordered_multiset", "::std::unordered_multimap"));
 
-  const auto Matcher = traverse(
-  TK_AsIs,
+  const auto Matcher =
   callExpr(
   callee(functionDecl(Algorithms)),
   hasArgument(
-  0, cxxConstructExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
+  0, cxxMemberCallExpr(
  callee(cxxMethodDecl(hasName("begin"))),
  on(declRefExpr(
 hasDeclaration(decl().bind("IneffContObj")),
 anyOf(hasType(ContainerMatcher.bind("IneffCont")),
   hasType(pointsTo(
   ContainerMatcher.bind("IneffContPtr")
-.bind("IneffContExpr"))),
+.bind("IneffContExpr",
   hasArgument(
-  1, cxxConstructExpr(has(ignoringParenImpCasts(cxxMemberCallExpr(
- callee(cxxMethodDecl(hasName("end"))),
- on(declRefExpr(
- 
hasDeclaration(equalsBoundNode("IneffContObj"),
-  hasArgument(2, expr().bind("AlgParam")),
-  unless(isInTemplateInstantiation()))
-  .bind("IneffAlg"));
+  1, cxxMemberCallExpr(callee(cxxMethodDecl(hasName("end"))),
+   on(declRefExpr(hasDeclaration(
+   equalsBoundNode("IneffContObj")),
+  hasArgument(2, expr().bind("AlgParam")))
+  .bind("IneffAlg");
 
   Finder->addMatcher(Matcher, this);
 }


Index: clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/performance-inefficient-algorithm.cpp
@@ -1,5 +1,4 @@
-// RUN: %check_clang_tidy -std=c++11,c++14 %s performance-inefficient-algorithm %t
-// FIXME: Fix the checker to work in C++17 mode.
+// RUN: %check_clang_tidy %s performance-inefficient-algorithm %t
 
 namespace std {
 template  struct less {
Index: clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
===
--- clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
+++ clang-tools-extra/clang-tidy/performance/InefficientAlgorithmCheck.h
@@ -29,6 +29,9 @@
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace performance
Index: clang

[clang-tools-extra] ca4485d - [clang-tidy] Simplify const params check

2021-02-17 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-02-17T10:20:12Z
New Revision: ca4485d9fc3449f7bb9522ee16ccf63f2219732c

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

LOG: [clang-tidy] Simplify const params check

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp 
b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
index aed01ab7ae7c..d35cc079d78a 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -33,14 +33,6 @@ void AvoidConstParamsInDecls::registerMatchers(MatchFinder 
*Finder) {
   parmVarDecl(hasType(qualType(isConstQualified(.bind("param");
   Finder->addMatcher(
   functionDecl(unless(isDefinition()),
-   // Lambdas are always their own definition, but they
-   // generate a non-definition FunctionDecl too. Ignore those.
-   // Class template instantiations have a non-definition
-   // CXXMethodDecl for methods that aren't used in this
-   // translation unit. Ignore those, as the template will have
-   // already been checked.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
-   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);

diff  --git 
a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h 
b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
index 08aac949f98e..d366949e4a16 100644
--- a/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
+++ b/clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
@@ -24,6 +24,9 @@ class AvoidConstParamsInDecls : public ClangTidyCheck {
 
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability



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


[PATCH] D96141: [clang-tidy] Simplify const params check

2021-02-17 Thread Stephen Kelly 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 rGca4485d9fc34: [clang-tidy] Simplify const params check 
(authored by stephenkelly).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96141

Files:
  clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
  clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h


Index: clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
===
--- clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
+++ clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
@@ -24,6 +24,9 @@
 
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -33,14 +33,6 @@
   parmVarDecl(hasType(qualType(isConstQualified(.bind("param");
   Finder->addMatcher(
   functionDecl(unless(isDefinition()),
-   // Lambdas are always their own definition, but they
-   // generate a non-definition FunctionDecl too. Ignore those.
-   // Class template instantiations have a non-definition
-   // CXXMethodDecl for methods that aren't used in this
-   // translation unit. Ignore those, as the template will have
-   // already been checked.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
-   isLambda(), 
ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);


Index: clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
===
--- clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
+++ clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.h
@@ -24,6 +24,9 @@
 
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  llvm::Optional getCheckTraversalKind() const override {
+return TK_IgnoreUnlessSpelledInSource;
+  }
 };
 
 } // namespace readability
Index: clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
===
--- clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
+++ clang-tools-extra/clang-tidy/readability/AvoidConstParamsInDecls.cpp
@@ -33,14 +33,6 @@
   parmVarDecl(hasType(qualType(isConstQualified(.bind("param");
   Finder->addMatcher(
   functionDecl(unless(isDefinition()),
-   // Lambdas are always their own definition, but they
-   // generate a non-definition FunctionDecl too. Ignore those.
-   // Class template instantiations have a non-definition
-   // CXXMethodDecl for methods that aren't used in this
-   // translation unit. Ignore those, as the template will have
-   // already been checked.
-   unless(cxxMethodDecl(ofClass(cxxRecordDecl(anyOf(
-   isLambda(), ast_matchers::isTemplateInstantiation()),
has(typeLoc(forEach(ConstParamDecl
   .bind("func"),
   this);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96568: [CFE, SystemZ] Emit s390.tdc instrincic for __builtin_isnan in Constrained FP mode.

2021-02-17 Thread Thomas Preud'homme via Phabricator via cfe-commits
thopre added a comment.

In D96568#2567145 , @jonpa wrote:

> In D96568#2559476 , @thopre wrote:
>
>> In D96568#2559475 , @uweigand wrote:
>>
>>> In D96568#2559336 , @thopre wrote:
>>>
 That's interesting. I presume that can be used to implement isinf as well? 
 Perhaps better call the hook fpclassify or similar?
>>>
>>> Hmm, the instruction doesn't really implement fpclassify in itself, it is 
>>> more like a combined check for fpclassify() == .   
>>> Specifically, the TEST DATA CLASS instruction takes an immediate operand 
>>> that represents a bit mask, which each bit standing for one type of 
>>> floating-point value (zero, normal, subnormal, infinity, QNaN, SNaN -- each 
>>> in positive and negative versions).  The instruction sets the condition 
>>> code depending on whether the input FP number is in one of the classes 
>>> selected by the bit mask, or not.
>>>
>>> This is why Jonas' patch uses a bit mask of 0x0F -- this has the bits for 
>>> the four types of NaN set (pos/neg QNaN/SNan).   The instruction could 
>>> indeed also be used to implement an isinf check (bit mask 0x30) or many 
>>> other checks.   We actually have a SystemZ back-end pass that tries to 
>>> multiple combine FP checks into a single TEST DATA CLASS instruction.
>>>
>>> However, the instruction does not directly implement the fpclassify 
>>> semantics.  To implement fpclassify, you'd still have to use multiple 
>>> invocations of the instruction with different flags to determine the 
>>> fpclassify output value.
>>
>> I see. I'm not sure whether it's better to have several target hooks or a 
>> single one like testFPKind that would take a flag saying what do we want to 
>> test (NaN, Inf, etc.).
>
> Personally I think testFPKind should work well - it gives a single target 
> hook for related purposes which should be more readable, and it is also 
> natural for SystemZ since we will be using the same (Test Data Class) 
> instruction for differnet checks only with different flag bits... Any one 
> else has an opinion? Should I go ahead and change the patch to this end?

Sounds good to me. Hopefully I'll get round to __builtin_isinf soon and a 
single hook will make the patch slightly smaller.


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

https://reviews.llvm.org/D96568

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


[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis created this revision.
joechrisellis added reviewers: DavidTruby, peterwaller-arm, paulwalker-arm, 
bsmith.
Herald added subscribers: psnobl, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
joechrisellis requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The inline keyword is not defined in the C89 standard, so source files
that include arm_sve.h will fail compilation if -std=c89 is specified.
We already use the __always_inline__ function attribute so the inline
keyword here is redundant anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96852

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1201,7 +1201,7 @@
   OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
-  OS << "#define __aio static inline __attribute__((__always_inline__, "
+  OS << "#define __aio static __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
 
   // Add reinterpret functions.


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1201,7 +1201,7 @@
   OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
-  OS << "#define __aio static inline __attribute__((__always_inline__, "
+  OS << "#define __aio static __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
 
   // Add reinterpret functions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

@jhenderson

> @ASDenysPetrov, could you provide your link command-line for one of the tools 
> that produces the failing message, please, e.g. llvm-ar?

Here is output of running tests in llvm-ar folder: F15562458: 
fail_output_llvm_ar.txt 

> Not that I'm saying we shouldn't try to fix your use-case, but if you aren't 
> using Cygwin, it's worth noting that 
> https://llvm.org/docs/GettingStarted.html#hardware states that only Visual 
> Studio builds (whether via the IDE or some other tool like ninja) are known 
> to work for Windows.

I'm using MSYS2 instead of Cygwin. I found it as a better alternative. I'm 
using GCC+MSYS2+Ninja.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D96853: [clang][AVR] Support variable decorator '__flash'

2021-02-17 Thread Ben Shi via Phabricator via cfe-commits
benshi001 created this revision.
benshi001 added reviewers: dylanmckay, aykevl.
Herald added a subscriber: Jim.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96853

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Targets/AVR.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/address-space-avr.c
  clang/test/CodeGen/avr-flash.c


Index: clang/test/CodeGen/avr-flash.c
===
--- /dev/null
+++ clang/test/CodeGen/avr-flash.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+
+static __flash int arr[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 
'const' needed for variables in address space '__flash'}}
+
+int foo(int i, int j) {
+  static __flash int b[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 
'const' needed for variables in address space '__flash'}}
+  return arr[i] + b[j];
+}
Index: clang/test/CodeGen/address-space-avr.c
===
--- clang/test/CodeGen/address-space-avr.c
+++ clang/test/CodeGen/address-space-avr.c
@@ -3,10 +3,16 @@
 // Test that function declarations in nonzero address spaces without prototype
 // are called correctly.
 
+// CHECK: @var0 {{.*}} addrspace(1) constant i16 333
+// CHECK: @bar.var1 {{.*}} addrspace(1) constant i16 555
 // CHECK: define{{.*}} void @bar() addrspace(1)
 // CHECK: call addrspace(1) void bitcast (void (...) addrspace(1)* @foo to 
void (i16) addrspace(1)*)(i16 3)
 // CHECK: declare void @foo(...) addrspace(1)
+
+__flash const int var0 = 333;
+
 void foo();
 void bar(void) {
+   static __flash const int var1 = 555;
foo(3);
 }
Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/RecordLayout.h"
 #include "clang/Basic/CodeGenOptions.h"
 #include "clang/Basic/DiagnosticFrontend.h"
+#include "clang/Basic/DiagnosticSema.h"
 #include "clang/CodeGen/CGFunctionInfo.h"
 #include "clang/CodeGen/SwiftCallingConv.h"
 #include "llvm/ADT/SmallBitVector.h"
@@ -8032,6 +8033,17 @@
   AVRTargetCodeGenInfo(CodeGenTypes &CGT)
   : TargetCodeGenInfo(std::make_unique(CGT)) {}
 
+  LangAS getGlobalVarAddressSpace(CodeGenModule &CGM, const VarDecl *D) const {
+// Check if a global/static variable is defined within address space 1
+// but not constant.
+if (toTargetAddressSpace(D->getType().getAddressSpace()) == 1 &&
+!D->getType().isConstQualified())
+  CGM.getDiags().Report(D->getLocation(),
+diag::err_qualifier_with_address_space)
+  << 0 << 0 << "__flash";
+return TargetCodeGenInfo::getGlobalVarAddressSpace(CGM, D);
+  }
+
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule &CGM) const override {
 if (GV->isDeclaration())
Index: clang/lib/Basic/Targets/AVR.cpp
===
--- clang/lib/Basic/Targets/AVR.cpp
+++ clang/lib/Basic/Targets/AVR.cpp
@@ -308,6 +308,7 @@
   Builder.defineMacro("__AVR");
   Builder.defineMacro("__AVR__");
   Builder.defineMacro("__ELF__");
+  Builder.defineMacro("__flash", "__attribute__((address_space(1)))");
 
   if (!this->CPU.empty()) {
 auto It = llvm::find_if(
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2991,6 +2991,9 @@
   "parameter may not be qualified with an address space">;
 def err_field_with_address_space : Error<
   "field may not be qualified with an address space">;
+def err_qualifier_with_address_space : Error<
+  "qualifier '%select{const|volatile}0' %select{needed|invalid}1 "
+  "for variables in address space '%2'">;
 def err_compound_literal_with_address_space : Error<
   "compound literal in function scope may not be qualified with an address 
space">;
 def err_address_space_mismatch_templ_inst : Error<


Index: clang/test/CodeGen/avr-flash.c
===
--- /dev/null
+++ clang/test/CodeGen/avr-flash.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -triple avr -emit-llvm-only -verify %s
+
+static __flash int arr[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 'const' needed for variables in address space '__flash'}}
+
+int foo(int i, int j) {
+  static __flash int b[] = {4, 6, 1, 2, 5}; // expected-error {{qualifier 'const' needed for variables in address space '__flash'}}
+  return arr[i] + b[j];
+}
Index: clang/test/CodeGen/address-space-avr.c
===
-

[PATCH] D96853: [clang][AVR] Support variable decorator '__flash'

2021-02-17 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

This patch immitates avr-gcc behavior on `__flash`

1. `__flash` variables are put into `.section .progmem.data`
2. `__flash` non-const variables are rejected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96853

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


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

2021-02-17 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D95246#2568084 , @ASDenysPetrov 
wrote:

> @jhenderson
>
>> @ASDenysPetrov, could you provide your link command-line for one of the 
>> tools that produces the failing message, please, e.g. llvm-ar?
>
> Here is output of running tests in llvm-ar folder: F15562458: 
> fail_output_llvm_ar.txt 

Sorry, what I meant was, what is the command used to build the llvm-ar 
executable, not what does it print when used. The command used to build llvm-ar 
should tell us what libraries are being used, which could impact this behaviour.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

2021-02-17 Thread Balázs Kéri via Phabricator via cfe-commits
balazske accepted this revision.
balazske added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:835
+  CTU.getMacroExpansionContextForSourceLocation(MacroExpansionLoc)) {
+return CTUMacroExpCtx->getExpandedText(MacroExpansionLoc);
   }

I am not sure if `getExpandedText` will handle a source location that is not in 
the same TU. Probably the previous source location mapping mechanism (that is 
now removed) is needed additionally, so that here the original source location 
and the original `MacroExpansionContext` is available. Probably this can be 
done in other way, the `MacroExpansionContext` could handle this mapping. (A 
single `MacroExpansionContext` could handle every imported source location at 
least for on-demand parsing.)


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

https://reviews.llvm.org/D94673

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


[PATCH] D96755: [clangd] Shutdown sequence for modules, and doc threading requirements

2021-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 324262.
sammccall added a comment.

Fix racy test - forgot to blockUntilIdle in sync!

Found a bug in blockUntilIdle, i'll send it separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96755

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Module.h
  clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp

Index: clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
===
--- clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
+++ clang-tools-extra/clangd/unittests/ClangdLSPServerTests.cpp
@@ -16,6 +16,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/JSON.h"
+#include "llvm/Testing/Support/Error.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -23,6 +24,7 @@
 namespace clang {
 namespace clangd {
 namespace {
+using llvm::Succeeded;
 using testing::ElementsAre;
 
 MATCHER_P(DiagMessage, M, "") {
@@ -40,6 +42,7 @@
 Base = ClangdServer::optsForTest();
 // This is needed to we can test index-based operations like call hierarchy.
 Base.BuildDynamicSymbolIndex = true;
+Base.Modules = &Modules;
   }
 
   LSPClient &start() {
@@ -67,6 +70,7 @@
 
   MockFS FS;
   ClangdLSPServer::Options Opts;
+  ModuleSet Modules;
 
 private:
   // Color logs so we can distinguish them from test output.
@@ -244,9 +248,7 @@
   [Reply(std::move(Reply)), Value(Value)]() mutable { Reply(Value); });
 }
   };
-  ModuleSet Mods;
-  Mods.add(std::make_unique());
-  Opts.Modules = &Mods;
+  Modules.add(std::make_unique());
 
   auto &Client = start();
   Client.notify("add", 2);
@@ -256,6 +258,104 @@
   ElementsAre(llvm::json::Value(2), llvm::json::Value(10)));
 }
 
+// Creates a Callback that writes its received value into an Optional.
+template 
+llvm::unique_function)>
+capture(llvm::Optional> &Out) {
+  Out.reset();
+  return [&Out](llvm::Expected V) { Out.emplace(std::move(V)); };
+}
+
+TEST_F(LSPTest, ModulesThreadingTest) {
+  // A module that does its work on a background thread, and so exercises the
+  // block/shutdown protocol.
+  class AsyncCounter final : public Module {
+bool ShouldStop = false;
+int State = 0;
+std::deque> Queue; // null = increment, non-null = read.
+std::condition_variable CV;
+std::mutex Mu;
+std::thread Thread;
+
+void run() {
+  std::unique_lock Lock(Mu);
+  while (true) {
+CV.wait(Lock, [&] { return ShouldStop || !Queue.empty(); });
+if (ShouldStop) {
+  Queue.clear();
+  CV.notify_all();
+  return;
+}
+Callback &Task = Queue.front();
+if (Task)
+  Task(State);
+else
+  ++State;
+Queue.pop_front();
+CV.notify_all();
+  }
+}
+
+bool blockUntilIdle(Deadline D) override {
+  std::unique_lock Lock(Mu);
+  return clangd::wait(Lock, CV, D, [this] { return Queue.empty(); });
+}
+
+void stop() override {
+  {
+std::lock_guard Lock(Mu);
+ShouldStop = true;
+  }
+  CV.notify_all();
+}
+
+  public:
+AsyncCounter() : Thread([this] { run(); }) {}
+~AsyncCounter() {
+  // Verify shutdown sequence was performed.
+  // Real modules would not do this, to be robust to no ClangdServer.
+  EXPECT_TRUE(ShouldStop) << "ClangdServer should request shutdown";
+  EXPECT_EQ(Queue.size(), 0u) << "ClangdServer should block until idle";
+  Thread.join();
+}
+
+void initializeLSP(LSPBinder &Bind, const llvm::json::Object &ClientCaps,
+   llvm::json::Object &ServerCaps) override {
+  Bind.notification("increment", this, &AsyncCounter::increment);
+}
+
+// Get the current value, bypassing the queue.
+// Used to verify that sync->blockUntilIdle avoids races in tests.
+int getSync() {
+  std::lock_guard Lock(Mu);
+  return State;
+}
+
+// Increment the current value asynchronously.
+void increment(const std::nullptr_t &) {
+  {
+std::lock_guard Lock(Mu);
+Queue.push_back(nullptr);
+  }
+  CV.notify_all();
+}
+  };
+
+  Modules.add(std::make_unique());
+  auto &Client = start();
+
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  EXPECT_THAT_EXPECTED(Client.call("sync", nullptr).take(), Succeeded());
+  EXPECT_EQ(3, Modules.get()->getSync());
+  // Throw some work on the queue to make sure shutdown blocks on it.
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  Client.notify("increment", nullptr);
+  // And immediately shut down. Module destructor verifies that we blocked.
+}
+
 } // namesp

[PATCH] D96856: [clangd] Narrow and document a loophole in blockUntilIdle

2021-02-17 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: usaxena95, arphaman.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

blockUntilIdle of a parent can't always be correctly implemented as

  return ChildA.blockUntilIdle() && ChildB.blockUntilIdle()

The problem is that B can schedule work on A while we're waiting on it.

I believe this is theoretically possible today between CDB and background index.
Modules open more possibilities and it's hard to reason about all of them.

I don't have a perfect fix, and the abstraction is too good to lose. this patch:

- calls out why we block on workscheduler first, and asserts correctness
- documents the issue
- reduces the practical possibility of spuriously returning true significantly

This function is ultimately only for testing, so we're driving down flake rate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96856

Files:
  clang-tools-extra/clangd/ClangdServer.cpp

Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -130,15 +130,13 @@
 : Modules(Opts.Modules), CDB(CDB), TFS(TFS),
   DynamicIdx(Opts.BuildDynamicSymbolIndex ? new FileIndex() : nullptr),
   ClangTidyProvider(Opts.ClangTidyProvider),
-  WorkspaceRoot(Opts.WorkspaceRoot),
-  // Pass a callback into `WorkScheduler` to extract symbols from a newly
-  // parsed file and rebuild the file index synchronously each time an AST
-  // is parsed.
-  // FIXME(ioeric): this can be slow and we may be able to index on less
-  // critical paths.
-  WorkScheduler(
-  CDB, TUScheduler::Options(Opts),
-  std::make_unique(DynamicIdx.get(), Callbacks)) {
+  WorkspaceRoot(Opts.WorkspaceRoot) {
+  // Pass a callback into `WorkScheduler` to extract symbols from a newly
+  // parsed file and rebuild the file index synchronously each time an AST
+  // is parsed.
+  WorkScheduler.emplace(
+  CDB, TUScheduler::Options(Opts),
+  std::make_unique(DynamicIdx.get(), Callbacks));
   // Adds an index to the stack, at higher priority than existing indexes.
   auto AddIndex = [&](SymbolIndex *Idx) {
 if (this->Index != nullptr) {
@@ -170,7 +168,7 @@
 
   if (Opts.Modules) {
 Module::Facilities F{
-this->WorkScheduler,
+*this->WorkScheduler,
 this->Index,
 this->TFS,
 };
@@ -179,6 +177,20 @@
   }
 }
 
+ClangdServer::~ClangdServer() {
+  // Destroying TUScheduler first shuts down request threads that might
+  // otherwise access members concurrently.
+  // (Nobody can be using TUScheduler because we're on the main thread).
+  WorkScheduler.reset();
+  // Now requests have stopped, we can shut down modules.
+  if (Modules) {
+for (auto &Mod : *Modules)
+  Mod.stop();
+for (auto &Mod : *Modules)
+  Mod.blockUntilIdle(Deadline::infinity());
+  }
+}
+
 void ClangdServer::addDocument(PathRef File, llvm::StringRef Contents,
llvm::StringRef Version,
WantDiagnostics WantDiags, bool ForceRebuild) {
@@ -193,7 +205,7 @@
   Inputs.Opts = std::move(Opts);
   Inputs.Index = Index;
   Inputs.ClangTidyProvider = ClangTidyProvider;
-  bool NewFile = WorkScheduler.update(File, Inputs, WantDiags);
+  bool NewFile = WorkScheduler->update(File, Inputs, WantDiags);
   // If we loaded Foo.h, we want to make sure Foo.cpp is indexed.
   if (NewFile && BackgroundIdx)
 BackgroundIdx->boostRelated(File);
@@ -276,7 +288,7 @@
   };
 }
 
-void ClangdServer::removeDocument(PathRef File) { WorkScheduler.remove(File); }
+void ClangdServer::removeDocument(PathRef File) { WorkScheduler->remove(File); }
 
 void ClangdServer::codeComplete(PathRef File, Position Pos,
 const clangd::CodeCompleteOptions &Opts,
@@ -330,7 +342,7 @@
   };
 
   // We use a potentially-stale preamble because latency is critical here.
-  WorkScheduler.runWithPreamble(
+  WorkScheduler->runWithPreamble(
   "CodeComplete", File,
   (Opts.RunParser == CodeCompleteOptions::AlwaysParse)
   ? TUScheduler::Stale
@@ -356,8 +368,8 @@
   };
 
   // Unlike code completion, we wait for a preamble here.
-  WorkScheduler.runWithPreamble("SignatureHelp", File, TUScheduler::Stale,
-std::move(Action));
+  WorkScheduler->runWithPreamble("SignatureHelp", File, TUScheduler::Stale,
+ std::move(Action));
 }
 
 void ClangdServer::formatRange(PathRef File, llvm::StringRef Code, Range Rng,
@@ -399,7 +411,7 @@
   Result.push_back(replacementToEdit(Code, R));
 return CB(Result);
   };
-  WorkScheduler.runQuick("FormatOnType", File, std::move(Action));
+  WorkScheduler->runQuick("FormatOnType", File, std:

[PATCH] D96803: EntryExitInstrumenter: Move to a module pass and enable at all optimization levels (PR49143)

2021-02-17 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz added a comment.

In D96803#2566322 , @aeubanks wrote:

> why is this now a module pass?

Mainly to avoid the default rule from new pass manager to *not* apply any 
FunctionPass for optnone (which is the main issue for PR49143). Is there a 
better way to accomplish it? I noted also that 
createModuleToFunctionPassAdaptor basically creates a adaptor that applies the 
pass to all function on the module.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96803

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


[PATCH] D95016: [Clang][RISCV] Add custom TableGen backend for riscv-vector intrinsics.

2021-02-17 Thread Zakk Chen via Phabricator via cfe-commits
khchen updated this revision to Diff 324197.
khchen added a comment.

remove float32_t and float64_t to avoid collisions with other project.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95016

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-generic/vfadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vadd.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfadd.c
  clang/test/CodeGen/RISCV/vadd.c
  clang/test/Headers/riscv-vector-header.c
  clang/utils/TableGen/CMakeLists.txt
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

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


[PATCH] D96082: [clang-tidy] Add 'readability-useless-return-value' check

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

In D96082#2566984 , @steveire wrote:

> In D96082#2565339 , @aaron.ballman 
> wrote:
>
>> A somewhat similar check that would be interesting is a function that 
>> returns the same value on all control paths
>
> I think we shouldn't try to design a new, different check in the comments of 
> this MR.

I wasn't. I was giving an example of what is similar and I would find 
acceptable so that the code author has more data from which to make decisions 
about their patch.

> I think it would be better to finalize what to do with this one.
>
> Request further work to also change expressions in all affected TUs? Or close?

I don't think requesting further work would solve any of my concerns short of 
making a rather different check, so my preference is to close.

In D96082#2567143 , @LukasHanel wrote:

> As a follow-up to this checker, clang -Wdocumentation does not understand the 
> `@retval` command.
> I was thinking of adding a new clang-tidy checker for this to verify/complete 
> the list of documented return values.
> In this case where the documentation does not say `@retval 0 always`, than I 
> will come back to the checker here, suggest make the function void or add the 
> "always" to the text :).
> The work with the useless-return-value was a study towards this new @retval 
> checker.

That's an interesting idea -- we don't have any clang-tidy checks related to 
documentation comments currently, but the doxygen-style comments are the only 
form of comment to be retained in the AST. So it seems plausible to write 
clang-tidy checkers for documentation comments. However, you should know that 
there are limitations to this given that clang-tidy works most effectively with 
ASTs and not the user's original source -- it's trivially easy to lose some or 
all of the AST nodes for the comments if the formatting gets mucked up: 
https://godbolt.org/z/nWcMsM So it is possible that it's easier to do this work 
in the frontend instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96082

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


[PATCH] D96860: [OpenCL] Add declarations with enum/typedef args

2021-02-17 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added a reviewer: Anastasia.
svenvh added a project: clang.
Herald added subscribers: jfb, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Add the remaining missing builtin function declarations that have enum
or typedef argument or return types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96860

Files:
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -45,6 +45,9 @@
 typedef uint uint4 __attribute__((ext_vector_type(4)));
 typedef long long2 __attribute__((ext_vector_type(2)));
 
+typedef int clk_profiling_info;
+#define CLK_PROFILING_COMMAND_EXEC_TIME 0x1
+
 typedef uint cl_mem_fence_flags;
 #define CLK_GLOBAL_MEM_FENCE 0x02
 
@@ -79,6 +82,15 @@
 }
 #endif
 
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200
+void test_typedef_args(clk_event_t evt, volatile atomic_flag *flg, global unsigned long long *values) {
+  capture_event_profiling_info(evt, CLK_PROFILING_COMMAND_EXEC_TIME, values);
+
+  atomic_flag_clear(flg);
+  bool result = atomic_flag_test_and_set(flg);
+}
+#endif
+
 kernel void basic_conversion() {
   double d;
   float f;
@@ -167,6 +179,11 @@
   // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is invalid in OpenCL}}
   // expected-error@-3{{implicit conversion changes signedness}}
 #endif
+
+// Only test when the base header is included, because we need the enum declarations.
+#if !defined(NO_HEADER) && (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+  sub_group_barrier(CLK_GLOBAL_MEM_FENCE, memory_scope_device);
+#endif
 }
 
 kernel void extended_subgroup(global uint4 *out, global int *scalar, global char2 *c2) {
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -310,6 +310,7 @@
 def Queue : Type<"queue_t", QualType<"Context.OCLQueueTy">>;
 def ReserveId : Type<"reserve_id_t", QualType<"Context.OCLReserveIDTy">>;
 def MemFenceFlags : TypedefType<"cl_mem_fence_flags">;
+def ClkProfilingInfo  : TypedefType<"clk_profiling_info">;
 
 // OpenCL v2.0 s6.13.11: Atomic integer and floating-point types.
 def AtomicInt : Type<"atomic_int", QualType<"Context.getAtomicType(Context.IntTy)">>;
@@ -323,6 +324,7 @@
 def AtomicSize: Type<"atomic_size_t", QualType<"Context.getAtomicType(Context.getSizeType())">>;
 def AtomicPtrDiff : Type<"atomic_ptrdiff_t", QualType<"Context.getAtomicType(Context.getPointerDiffType())">>;
 
+def AtomicFlag: TypedefType<"atomic_flag">;
 def MemoryOrder   : EnumType<"memory_order">;
 def MemoryScope   : EnumType<"memory_scope">;
 
@@ -913,6 +915,23 @@
 
 // OpenCL v3.0 s6.15.8 - Synchronization Functions.
 def : Builtin<"barrier", [Void, MemFenceFlags], Attr.Convergent>;
+let MinVersion = CL20 in {
+  def : Builtin<"work_group_barrier", [Void, MemFenceFlags], Attr.Convergent>;
+  def : Builtin<"work_group_barrier", [Void, MemFenceFlags, MemoryScope], Attr.Convergent>;
+}
+
+// OpenCL v3.0 s6.15.9 - Legacy Explicit Memory Fence Functions.
+def : Builtin<"mem_fence", [Void, MemFenceFlags]>;
+def : Builtin<"read_mem_fence", [Void, MemFenceFlags]>;
+def : Builtin<"write_mem_fence", [Void, MemFenceFlags]>;
+
+// OpenCL v3.0 s6.15.10 - Address Space Qualifier Functions.
+// to_global, to_local, to_private are declared in Builtins.def.
+
+let MinVersion = CL20 in {
+  def : Builtin<"get_fence", [MemFenceFlags, PointerType]>;
+  def : Builtin<"get_fence", [MemFenceFlags, PointerType, GenericAS>]>;
+}
 
 //
 // OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10: Async Copies from Global to Local Memory, Local to Global Memory, and Prefetch
@@ -1030,6 +1049,8 @@
 }
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 let MinVersion = CL20 in {
+  def : Builtin<"atomic_work_item_fence", [Void, MemFenceFlags, MemoryOrder, MemoryScope]>;
+
   foreach TypePair = [[AtomicInt, Int], [AtomicUInt, UInt],
   [AtomicLong, Long], [AtomicULong, ULong],
   [AtomicFloat, Float], [AtomicDouble, Double]] in {
@@ -1037,10 +1058,22 @@
 [Void, PointerType, GenericAS>, TypePair[1]]>;
 def : Builtin<"atomic_store",
 [Void, PointerType, GenericAS>, TypePair[1]]>;
+def : Builtin<"atomic_store_explicit",
+[Void, PointerType, GenericAS>, TypePair[1], MemoryOrder]>;
+def : Builtin<"atomic_store_explicit",
+[Void, PointerType, GenericAS>, TypePair[1], MemoryOrder, MemoryScope]>;
 def : Builtin<"atomic_loa

[PATCH] D95536: [clang][sema] Note decl location on missing member

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

In D95536#2557197 , @aaron.ballman 
wrote:

> Hmm... I feel like the diagnostic should already be sufficient to locate the 
> originating location of the class or namespace and the note is adding a bit 
> more (almost, but not quite) noise,

I guess this makes sense when you're talking about 
https://godbolt.org/z/1Yo3Pj, but I don't understand how I would know where 
`OsType` is defined in https://godbolt.org/ in a larger code base (e.g. when 
using `OsType` in clang, with it being defined in llvm).

> Anonymous namespaces:
>
>   namespace foo {
>   namespace {
> void func();
>   }
>   }
>   
>   void bar() {
> foo::blarg(); // Should point to 'foo'?
>   }

Seems to work:

  ./enum.cpp:56:8: error: no member named 'blarg' in namespace 'foo'
foo::blarg(); // Should point to 'foo'?
~^
  ./enum.cpp:49:11: note: namespace 'foo' declared here
  namespace foo {
^~~

You list a few more interesting corner cases however. I'm not sure if I want to 
pursue this patch further as it is already quite ugly because it's touching all 
those tests. Or if it would be better to implement a note that lists all enum 
members (up to a certain threshold?), but just for enums.


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

https://reviews.llvm.org/D95536

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


[PATCH] D96832: [Clang][Attributes] Allow not_tail_called attribute to be applied to virtual function.

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

It was explicitly disallowed in the initial patch: 
https://reviews.llvm.org/D12922 and the original author said "I'm still trying 
to figure out the best way to handle c++ virtual functions: this attribute is 
not very useful for someone who is looking for a way to reliably prevent 
tail-call to a virtual function." and "I made this change because this 
attribute isn't useful when the compiler cannot resolve the function call 
statically at compile time and it isn't important for the use case I have." Has 
this situation changed in the backend?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96832

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


[PATCH] D95790: [clang][cli] Documentation of CompilerInvocation parsing/generation

2021-02-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 324280.
jansvoboda11 added a comment.

Add example to "Adding new Command Line Option", polish the rest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95790

Files:
  clang/docs/InternalsManual.rst

Index: clang/docs/InternalsManual.rst
===
--- clang/docs/InternalsManual.rst
+++ clang/docs/InternalsManual.rst
@@ -572,6 +572,422 @@
 The Frontend library contains functionality useful for building tools on top of
 the Clang libraries, for example several methods for outputting diagnostics.
 
+Compiler Invocation
+---
+
+One of the classes provided by the Frontend library is ``CompilerInvocation``,
+which holds information that describe current invocation of the Clang frontend.
+The information typically comes from the command line constructed by the Clang
+driver or from clients performing custom initialization. The data structure is
+split into logical units used by different parts of the compiler, for example
+``PreprocessorOptions``, ``LanguageOptions`` or ``CodeGenOptions``.
+
+Command Line Interface
+--
+
+The command line interface of the Clang ``-cc1`` frontend is defined alongside
+the driver options in ``clang/Driver/Options.td``. The information making up an
+option definition includes its prefix and name (for example ``-std=``), form and
+position of the option value, help text, aliases and more. Each option may
+belong to a certain group and can be marked with zero or more flags. Options
+accepted by the ``-cc1`` frontend are marked with the ``CC1Option`` flag.
+
+Command Line Parsing
+
+
+Option definitions are processed by the ``-gen-opt-parser-defs`` tablegen
+backend during early stages of the build. Options are then used for querying an
+instance ``llvm::opt::ArgList``, a wrapper around the command line arguments.
+This is done in the Clang driver to construct individual jobs based on the
+driver arguments and also in the ``CompilerInvocation::CreateFromArgs`` function
+that parses the ``-cc1`` frontend arguments.
+
+Command Line Generation
+---
+
+Any valid ``CompilerInvocation`` created from a ``-cc1`` command line  can be
+also serialized back into semantically equivalent command line in a
+deterministic manner. This enables features such as implicitly discovered,
+explicitly built modules.
+
+..
+  TODO: Create and link corresponding section in Modules.rst.
+
+Adding new Command Line Option
+--
+
+When adding a new command line option, the first place of interest is the header
+file declaring the corresponding options class (e.g. ``CodeGenOptions.h`` for
+command line option that affects the code generation). Create new member
+variable for the option value:
+
+.. code-block:: diff
+
+class CodeGenOptions : public CodeGenOptionsBase {
+
+  +   /// List of dynamic shared object files to be loaded as pass plugins.
+  +   std::vector PassPlugins;
+
+}
+
+Next, declare the command line interface of the option in the tablegen file
+``clang/include/clang/Driver/Options.td``. This is done by instantiating the
+``Option`` class (defined in ``llvm/include/llvm/Option/OptParser.td``). The
+instance is typically created through one of the helper classes that encode the
+acceptable ways to specify the option value on the command line:
+
+* ``Flag`` - the option does not accept any value,
+* ``Joined`` - the value must immediately follow the option name within the same
+  argument,
+* ``Separate`` - the value must follow the option name in the next command line
+  argument,
+* ``JoinedOrSeparate`` - the value can be specified either as ``Joined`` or
+  ``Separate``,
+* ``CommaJoined`` - the values are comma-separated and must immediately follow
+  the option name within the same argument (see ``Wl,`` for an example).
+
+The helper classes take a list of acceptable prefixes of the option (e.g.
+``"-"``, ``"--"`` or ``"/"``) and the option name:
+
+.. code-block:: diff
+
+// Options.td
+
+  + def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">;
+
+Then, specify additional attributes via mix-ins:
+
+* ``HelpText`` holds the text that will be printed besides the option name when
+  the user requests help (e.g. via ``clang --help``).
+* ``Group`` specifies the "category" of options this option belongs to. This is
+  used by various tools to filter certain options of interest.
+* ``Flags`` may contain a number of "tags" associated with the option. This
+  enables more granular filtering than the ``Group`` attribute.
+* ``Alias`` denotes that the option is an alias of another option. This may be
+  combined with ``AliasArgs`` that holds the implied value.
+
+.. code-block:: diff
+
+// Options.td
+
+def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
+  +   Group, Flags<[CC1Option]>,
+  +   Hel

[clang] 8ddfcec - [clang][cli] Documentation of CompilerInvocation parsing/generation

2021-02-17 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-02-17T14:29:49+01:00
New Revision: 8ddfcec91b7801af058f43906073822d7f146bf5

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

LOG: [clang][cli] Documentation of CompilerInvocation parsing/generation

This patch documents command line parsing in `-cc1`, `CompilerInvocation` and 
the marshalling infrastructure for command line options.

Reviewed By: Bigcheese

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

Added: 


Modified: 
clang/docs/InternalsManual.rst

Removed: 




diff  --git a/clang/docs/InternalsManual.rst b/clang/docs/InternalsManual.rst
index 5732e9b9af03..906b6d153f2b 100644
--- a/clang/docs/InternalsManual.rst
+++ b/clang/docs/InternalsManual.rst
@@ -572,6 +572,422 @@ The Frontend Library
 The Frontend library contains functionality useful for building tools on top of
 the Clang libraries, for example several methods for outputting diagnostics.
 
+Compiler Invocation
+---
+
+One of the classes provided by the Frontend library is ``CompilerInvocation``,
+which holds information that describe current invocation of the Clang frontend.
+The information typically comes from the command line constructed by the Clang
+driver or from clients performing custom initialization. The data structure is
+split into logical units used by 
diff erent parts of the compiler, for example
+``PreprocessorOptions``, ``LanguageOptions`` or ``CodeGenOptions``.
+
+Command Line Interface
+--
+
+The command line interface of the Clang ``-cc1`` frontend is defined alongside
+the driver options in ``clang/Driver/Options.td``. The information making up an
+option definition includes its prefix and name (for example ``-std=``), form 
and
+position of the option value, help text, aliases and more. Each option may
+belong to a certain group and can be marked with zero or more flags. Options
+accepted by the ``-cc1`` frontend are marked with the ``CC1Option`` flag.
+
+Command Line Parsing
+
+
+Option definitions are processed by the ``-gen-opt-parser-defs`` tablegen
+backend during early stages of the build. Options are then used for querying an
+instance ``llvm::opt::ArgList``, a wrapper around the command line arguments.
+This is done in the Clang driver to construct individual jobs based on the
+driver arguments and also in the ``CompilerInvocation::CreateFromArgs`` 
function
+that parses the ``-cc1`` frontend arguments.
+
+Command Line Generation
+---
+
+Any valid ``CompilerInvocation`` created from a ``-cc1`` command line  can be
+also serialized back into semantically equivalent command line in a
+deterministic manner. This enables features such as implicitly discovered,
+explicitly built modules.
+
+..
+  TODO: Create and link corresponding section in Modules.rst.
+
+Adding new Command Line Option
+--
+
+When adding a new command line option, the first place of interest is the 
header
+file declaring the corresponding options class (e.g. ``CodeGenOptions.h`` for
+command line option that affects the code generation). Create new member
+variable for the option value:
+
+.. code-block:: 
diff 
+
+class CodeGenOptions : public CodeGenOptionsBase {
+
+  +   /// List of dynamic shared object files to be loaded as pass plugins.
+  +   std::vector PassPlugins;
+
+}
+
+Next, declare the command line interface of the option in the tablegen file
+``clang/include/clang/Driver/Options.td``. This is done by instantiating the
+``Option`` class (defined in ``llvm/include/llvm/Option/OptParser.td``). The
+instance is typically created through one of the helper classes that encode the
+acceptable ways to specify the option value on the command line:
+
+* ``Flag`` - the option does not accept any value,
+* ``Joined`` - the value must immediately follow the option name within the 
same
+  argument,
+* ``Separate`` - the value must follow the option name in the next command line
+  argument,
+* ``JoinedOrSeparate`` - the value can be specified either as ``Joined`` or
+  ``Separate``,
+* ``CommaJoined`` - the values are comma-separated and must immediately follow
+  the option name within the same argument (see ``Wl,`` for an example).
+
+The helper classes take a list of acceptable prefixes of the option (e.g.
+``"-"``, ``"--"`` or ``"/"``) and the option name:
+
+.. code-block:: 
diff 
+
+// Options.td
+
+  + def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">;
+
+Then, specify additional attributes via mix-ins:
+
+* ``HelpText`` holds the text that will be printed besides the option name when
+  the user requests help (e.g. via ``clang --help``).
+* ``Group`` specifies the "category" of options this option belongs to. This is
+  used by various tools to fil

[PATCH] D95790: [clang][cli] Documentation of CompilerInvocation parsing/generation

2021-02-17 Thread Jan Svoboda 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 rG8ddfcec91b78: [clang][cli] Documentation of 
CompilerInvocation parsing/generation (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95790

Files:
  clang/docs/InternalsManual.rst

Index: clang/docs/InternalsManual.rst
===
--- clang/docs/InternalsManual.rst
+++ clang/docs/InternalsManual.rst
@@ -572,6 +572,422 @@
 The Frontend library contains functionality useful for building tools on top of
 the Clang libraries, for example several methods for outputting diagnostics.
 
+Compiler Invocation
+---
+
+One of the classes provided by the Frontend library is ``CompilerInvocation``,
+which holds information that describe current invocation of the Clang frontend.
+The information typically comes from the command line constructed by the Clang
+driver or from clients performing custom initialization. The data structure is
+split into logical units used by different parts of the compiler, for example
+``PreprocessorOptions``, ``LanguageOptions`` or ``CodeGenOptions``.
+
+Command Line Interface
+--
+
+The command line interface of the Clang ``-cc1`` frontend is defined alongside
+the driver options in ``clang/Driver/Options.td``. The information making up an
+option definition includes its prefix and name (for example ``-std=``), form and
+position of the option value, help text, aliases and more. Each option may
+belong to a certain group and can be marked with zero or more flags. Options
+accepted by the ``-cc1`` frontend are marked with the ``CC1Option`` flag.
+
+Command Line Parsing
+
+
+Option definitions are processed by the ``-gen-opt-parser-defs`` tablegen
+backend during early stages of the build. Options are then used for querying an
+instance ``llvm::opt::ArgList``, a wrapper around the command line arguments.
+This is done in the Clang driver to construct individual jobs based on the
+driver arguments and also in the ``CompilerInvocation::CreateFromArgs`` function
+that parses the ``-cc1`` frontend arguments.
+
+Command Line Generation
+---
+
+Any valid ``CompilerInvocation`` created from a ``-cc1`` command line  can be
+also serialized back into semantically equivalent command line in a
+deterministic manner. This enables features such as implicitly discovered,
+explicitly built modules.
+
+..
+  TODO: Create and link corresponding section in Modules.rst.
+
+Adding new Command Line Option
+--
+
+When adding a new command line option, the first place of interest is the header
+file declaring the corresponding options class (e.g. ``CodeGenOptions.h`` for
+command line option that affects the code generation). Create new member
+variable for the option value:
+
+.. code-block:: diff
+
+class CodeGenOptions : public CodeGenOptionsBase {
+
+  +   /// List of dynamic shared object files to be loaded as pass plugins.
+  +   std::vector PassPlugins;
+
+}
+
+Next, declare the command line interface of the option in the tablegen file
+``clang/include/clang/Driver/Options.td``. This is done by instantiating the
+``Option`` class (defined in ``llvm/include/llvm/Option/OptParser.td``). The
+instance is typically created through one of the helper classes that encode the
+acceptable ways to specify the option value on the command line:
+
+* ``Flag`` - the option does not accept any value,
+* ``Joined`` - the value must immediately follow the option name within the same
+  argument,
+* ``Separate`` - the value must follow the option name in the next command line
+  argument,
+* ``JoinedOrSeparate`` - the value can be specified either as ``Joined`` or
+  ``Separate``,
+* ``CommaJoined`` - the values are comma-separated and must immediately follow
+  the option name within the same argument (see ``Wl,`` for an example).
+
+The helper classes take a list of acceptable prefixes of the option (e.g.
+``"-"``, ``"--"`` or ``"/"``) and the option name:
+
+.. code-block:: diff
+
+// Options.td
+
+  + def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">;
+
+Then, specify additional attributes via mix-ins:
+
+* ``HelpText`` holds the text that will be printed besides the option name when
+  the user requests help (e.g. via ``clang --help``).
+* ``Group`` specifies the "category" of options this option belongs to. This is
+  used by various tools to filter certain options of interest.
+* ``Flags`` may contain a number of "tags" associated with the option. This
+  enables more granular filtering than the ``Group`` attribute.
+* ``Alias`` denotes that the option is an alias of another option. This may be
+  combined with ``AliasArgs`` that holds the implied value.
+
+.. code-block:: diff
+
+// Optio

[PATCH] D96113: [ASTMatchers] Fix hasParent while ignoring unwritten nodes

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

Can you add a bit more description to the review summary about what's being 
fixed? It helps the reviewers with context but it also helps when doing code 
archeology on changes.




Comment at: clang/lib/AST/ParentMapContext.cpp:138
+  // different intermediate nodes.
+  // Look up 4 levels for a cxxRewrittenBinaryOperator
+  auto RewrittenBinOpParentsList = ParentList;

Why four levels? (May be worth adding that to the comment so it seems like less 
of a magic number.)



Comment at: clang/lib/AST/ParentMapContext.cpp:140
+  auto RewrittenBinOpParentsList = ParentList;
+  auto I = 0;
+  while (RewrittenBinOpParentsList.size() == 1 && I++ < 4) {





Comment at: clang/lib/AST/ParentMapContext.cpp:143-145
+if (!S) {
+  break;
+}





Comment at: clang/lib/AST/ParentMapContext.cpp:152
+}
+if (RWBO->getLHS()->IgnoreUnlessSpelledInSource() != ChildExpr &&
+RWBO->getRHS()->IgnoreUnlessSpelledInSource() != ChildExpr)

If `ChildExpr` is null, we do a fair amount of work just to get to this point 
and break out of the `while` loop -- would it be more clear to add `ChildExpr 
&&` to the loop predicate?



Comment at: clang/lib/AST/ParentMapContext.cpp:160-162
+if (ParentExpr && ChildExpr) {
+  return AscendIgnoreUnlessSpelledInSource(ParentExpr, ChildExpr);
+}





Comment at: clang/lib/AST/ParentMapContext.cpp:174
+{
+  auto AncestorNodes = matchParents(
+  ParentList, this);

Not needing to be solved in this patch, but do we eventually need to do 
something for `ObjCForCollectionStmt` the same as we do for `CXXForRangeStmt`?



Comment at: clang/lib/AST/ParentMapContext.cpp:179-181
+  std::get(AncestorNodes)) {
+return std::get(AncestorNodes);
+  }





Comment at: clang/lib/AST/ParentMapContext.cpp:185
+  auto AncestorNodes =
+  matchParents(ParentList,
+ this);

Not needing to be solved in this patch, but do we need to eventually do 
something about `BlockExpr` the same as we do for `LambdaExpr`?



Comment at: clang/lib/AST/ParentMapContext.cpp:187-189
+  if (std::get(AncestorNodes)) {
+return std::get(AncestorNodes);
+  }





Comment at: clang/lib/AST/ParentMapContext.cpp:195-197
+  if (std::get(AncestorNodes)) {
+return std::get(AncestorNodes);
+  }





Comment at: clang/lib/AST/ParentMapContext.cpp:310-312
+  if (NextParentList.size() == 1) {
+return std::make_tuple(true, NodeList, TypedNode);
+  }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96113

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


[PATCH] D90299: [windows-itanium] handle dllimport/export code paths separately and share with PS4

2021-02-17 Thread ben via Phabricator via cfe-commits
bd1976llvm marked 2 inline comments as done.
bd1976llvm added a comment.

ping :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D90299

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


[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis planned changes to this revision.
joechrisellis added a comment.

Speaking to @DavidTruby about this, it appears that this fix is insufficient -- 
`inline` has important semantic meaning in C++ that means that we can't simply 
omit the keyword here.

The `inline` keyword bypasses the one-definition rule. If we have a function 
defined in a header that isn't marked `inline`, and you include that header in 
two different source files, then your program is ill formed because it contains 
2 definitions of that function. So we have to keep it for C++.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96852

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


[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

In D96852#2568383 , @joechrisellis 
wrote:

> Speaking to @DavidTruby about this, it appears that this fix is insufficient 
> -- `inline` has important semantic meaning in C++ that means that we can't 
> simply omit the keyword here.
>
> The `inline` keyword bypasses the one-definition rule. If we have a function 
> defined in a header that isn't marked `inline`, and you include that header 
> in two different source files, then your program is ill formed because it 
> contains 2 definitions of that function. So we have to keep it for C++.

That makes sense and suggests we're missing some additional C++ testing?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96852

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


[PATCH] D96051: [OpenCL] Support enum and typedef args in TableGen BIFs

2021-02-17 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG23d65aa44631: [OpenCL] Support enum and typedef args in 
TableGen BIFs (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96051

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/OpenCLBuiltins.td
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -48,7 +48,7 @@
 //Find out whether a string matches an existing OpenCL builtin function
 //name and return an index into BuiltinTable and the number of overloads.
 //
-//  * void OCL2Qual(ASTContext&, OpenCLTypeStruct, std::vector&)
+//  * void OCL2Qual(Sema&, OpenCLTypeStruct, std::vector&)
 //Convert an OpenCLTypeStruct type to a list of QualType instances.
 //One OpenCLTypeStruct can represent multiple types, primarily when using
 //GenTypes.
@@ -628,6 +628,9 @@
 void BuiltinNameEmitter::EmitQualTypeFinder() {
   OS << R"(
 
+static QualType getOpenCLEnumType(Sema &S, llvm::StringRef Name);
+static QualType getOpenCLTypedefType(Sema &S, llvm::StringRef Name);
+
 // Convert an OpenCLTypeStruct type to a list of QualTypes.
 // Generic types represent multiple types and vector sizes, thus a vector
 // is returned. The conversion is done in two steps:
@@ -636,8 +639,9 @@
 // or a single scalar type for non generic types.
 // Step 2: Qualifiers and other type properties such as vector size are
 // applied.
-static void OCL2Qual(ASTContext &Context, const OpenCLTypeStruct &Ty,
+static void OCL2Qual(Sema &S, const OpenCLTypeStruct &Ty,
  llvm::SmallVectorImpl &QT) {
+  ASTContext &Context = S.Context;
   // Number of scalar types in the GenType.
   unsigned GenTypeNumTypes;
   // Pointer to the list of vector sizes for the GenType.
Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -17,6 +17,17 @@
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 #endif
 
+// First, test that Clang gracefully handles missing types.
+#ifdef NO_HEADER
+void test_without_header() {
+  barrier(0);
+  // expected-note@-1 0+{{candidate function not viable}}
+  // expected-error@-2 0+{{argument type 'void' is incomplete}}
+  // expected-error@-3 0+{{no matching function for call to 'barrier'}}
+  // expected-error@* {{typedef type cl_mem_fence_flags not found; include the base header with -finclude-default-header}}
+}
+#endif
+
 // Provide typedefs when invoking clang without -finclude-default-header.
 #ifdef NO_HEADER
 typedef unsigned char uchar;
@@ -34,6 +45,9 @@
 typedef uint uint4 __attribute__((ext_vector_type(4)));
 typedef long long2 __attribute__((ext_vector_type(2)));
 
+typedef uint cl_mem_fence_flags;
+#define CLK_GLOBAL_MEM_FENCE 0x02
+
 // Enable extensions that are enabled in opencl-c-base.h.
 #if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 #define cl_khr_subgroup_extended_types 1
@@ -53,6 +67,18 @@
   atom_cmpxchg((volatile __global unsigned int *)global_p, ui, ui);
 }
 
+// Only test enum arguments when the base header is included, because we need
+// the enum declarations.
+#if !defined(NO_HEADER) && (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+kernel void test_enum_args(volatile global atomic_int *global_p, global int *expected) {
+  int desired;
+  atomic_compare_exchange_strong_explicit(global_p, expected, desired,
+  memory_order_acq_rel,
+  memory_order_relaxed,
+  memory_scope_work_group);
+}
+#endif
+
 kernel void basic_conversion() {
   double d;
   float f;
@@ -184,6 +210,8 @@
 kernel void basic_work_item() {
   uint ui;
 
+  barrier(CLK_GLOBAL_MEM_FENCE);
+
   get_enqueued_local_size(ui);
 #if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_enqueued_local_size' is invalid in OpenCL}}
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -677,9 +677,43 @@
 D->dump();
 }
 
+/// Diagnose a missing builtin type.
+static QualType diagOpenCLBuiltinTypeError(Sema &S, llvm::StringRef TypeClass,
+   llvm::StringRef Name) {
+  S.Diag(SourceLocation(), diag::err_opencl_type_not_found)
+  << 

[clang] 23d65aa - [OpenCL] Support enum and typedef args in TableGen BIFs

2021-02-17 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-02-17T14:17:43Z
New Revision: 23d65aa446312402a0b4615122f0a18d4467ed60

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

LOG: [OpenCL] Support enum and typedef args in TableGen BIFs

Add enum and typedef argument support to `-fdeclare-opencl-builtins`,
which was the last major missing feature.

Adding the remaining missing builtins is left as future work.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/OpenCLBuiltins.td
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index f69ef3286975..a7a6b250b5a8 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9893,6 +9893,8 @@ def err_opencl_pointer_to_type : Error<
   "pointer to type %0 is invalid in OpenCL">;
 def err_opencl_type_can_only_be_used_as_function_parameter : Error <
   "type %0 can only be used as a function parameter in OpenCL">;
+def err_opencl_type_not_found : Error<
+  "%0 type %1 not found; include the base header with 
-finclude-default-header">;
 def warn_opencl_attr_deprecated_ignored : Warning <
   "%0 attribute is deprecated and ignored in OpenCL version %1">,
   InGroup;

diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 7f32be6cc8e8..7f0e0c1e8297 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -178,6 +178,16 @@ class ImageType :
   let AddrSpace = _Ty.AddrSpace;
 }
 
+// OpenCL enum type (e.g. memory_scope).
+class EnumType :
+Type<_Name, QualType<"getOpenCLEnumType(S, \"" # _Name # "\")", 0>> {
+}
+
+// OpenCL typedef type (e.g. cl_mem_fence_flags).
+class TypedefType :
+Type<_Name, QualType<"getOpenCLTypedefType(S, \"" # _Name # "\")", 0>> {
+}
+
 // List of Types.
 class TypeList _Type> {
   list List = _Type;
@@ -299,6 +309,7 @@ def ClkEvent  : Type<"clk_event_t", 
QualType<"Context.OCLClkEventTy"
 def Event : Type<"event_t", QualType<"Context.OCLEventTy">>;
 def Queue : Type<"queue_t", QualType<"Context.OCLQueueTy">>;
 def ReserveId : Type<"reserve_id_t", 
QualType<"Context.OCLReserveIDTy">>;
+def MemFenceFlags : TypedefType<"cl_mem_fence_flags">;
 
 // OpenCL v2.0 s6.13.11: Atomic integer and floating-point types.
 def AtomicInt : Type<"atomic_int", 
QualType<"Context.getAtomicType(Context.IntTy)">>;
@@ -312,6 +323,9 @@ def AtomicUIntPtr : Type<"atomic_uintptr_t", 
QualType<"Context.getAtomic
 def AtomicSize: Type<"atomic_size_t", 
QualType<"Context.getAtomicType(Context.getSizeType())">>;
 def AtomicPtrDiff : Type<"atomic_ptr
diff _t", QualType<"Context.getAtomicType(Context.getPointerDiffType())">>;
 
+def MemoryOrder   : EnumType<"memory_order">;
+def MemoryScope   : EnumType<"memory_scope">;
+
 
//===--===//
 // Definitions of OpenCL gentype variants
 
//===--===//
@@ -897,6 +911,9 @@ foreach AS = [ConstantAS] in {
   }
 }
 
+// OpenCL v3.0 s6.15.8 - Synchronization Functions.
+def : Builtin<"barrier", [Void, MemFenceFlags], Attr.Convergent>;
+
 //
 // OpenCL v1.1 s6.11.10, v1.2 s6.12.10, v2.0 s6.13.10: Async Copies from 
Global to Local Memory, Local to Global Memory, and Prefetch
 // OpenCL Extension v2.0 s5.1.7 and s6.1.7: Async Copies from Global to Local 
Memory, Local to Global Memory, and Prefetch
@@ -1028,6 +1045,12 @@ let MinVersion = CL20 in {
   def : Builtin<"atomic_compare_exchange_" # Variant,
   [Bool, PointerType, GenericAS>,
PointerType, TypePair[1]]>;
+  def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
+  [Bool, PointerType, GenericAS>,
+   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder]>;
+  def : Builtin<"atomic_compare_exchange_" # Variant # "_explicit",
+  [Bool, PointerType, GenericAS>,
+   PointerType, TypePair[1], MemoryOrder, 
MemoryOrder, MemoryScope]>;
 }
   }
 

diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index 3556f07b1fe5..404f24d8ce0a 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -677,9 +677,43 @@ LLVM_DUMP_METHOD void LookupResult::dump() {
 D->dump();
 }
 
+/// Diagno

[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

See

  __STDC_VERSION__ 

in  https://gcc.gnu.org/onlinedocs/cpp/Standard-Predefined-Macros.html.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96852

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


[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis added a comment.

> That makes sense and suggests we're missing some additional C++ testing?

Agreed -- this passes all tests at the moment, so we can do better test-wise. 
The error to do with the one definition rule would crop up at link time, 
though, so we'd need at least two compilation units to validate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96852

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


[PATCH] D96864: [flang][driver] Add -Xflang and make -test-io a frontend-only flang

2021-02-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added subscribers: jansvoboda11, dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds support for `-Xflang` in `flang-new`. The semantics are
identical to `-Xclang`.

With the addition of `-Xflang`, we can modify `-test-io` to be a
compiler-frontend only flag. This makes more sense, this flag is:

- very frontend specific
- to be used for development and testing only
- not to be exposed to the end user

Originally we added it to the compiler driver, `flang-new`, in order to
facilitate testing. With `-Xflang` this is no longer needed. Tests are
updated accordingly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96864

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/Types.cpp
  flang/test/Flang-Driver/driver-help-hidden.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Frontend/input-output-file.f90
  flang/test/Frontend/multiple-input-files.f90

Index: flang/test/Frontend/multiple-input-files.f90
===
--- flang/test/Frontend/multiple-input-files.f90
+++ flang/test/Frontend/multiple-input-files.f90
@@ -1,16 +1,15 @@
-! RUN: rm -rf %S/multiple-input-files.txt  %S/Inputs/hello-world.txt
-
 ! REQUIRES: new-flang-driver
 
 !--
 ! FLANG DRIVER (flang-new)
 !--
+! NOTE: We need `-E` below in order to instruct the compiler driver to create a job representing a fronted compiler invocation
 ! TEST 1: Both input files are processed (output is printed to stdout)
-! RUN: %flang-new -test-io %s %S/Inputs/hello-world.f90 | FileCheck %s --match-full-lines -check-prefix=FLANG
+! RUN: %flang-new -E -Xflang -test-io %s %S/Inputs/hello-world.f90 | FileCheck %s --match-full-lines -check-prefix=FLANG
 
 ! TEST 2: None of the files is processed (not possible to specify the output file when multiple input files are present)
-! RUN: not %flang-new -test-io -o - %S/Inputs/hello-world.f90 %s  2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR
-! RUN: not %flang-new -test-io -o %t %S/Inputs/hello-world.f90 %s 2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR
+! RUN: not %flang-new -E -Xflang -test-io -o - %S/Inputs/hello-world.f90 %s  2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR
+! RUN: not %flang-new -E -Xflang -test-io -o %t %S/Inputs/hello-world.f90 %s 2>&1 | FileCheck %s --match-full-lines -check-prefix=ERROR
 
 !
 ! FLANG FRONTEND DRIVER (flang-new -fc1)
Index: flang/test/Frontend/input-output-file.f90
===
--- flang/test/Frontend/input-output-file.f90
+++ flang/test/Frontend/input-output-file.f90
@@ -1,16 +1,15 @@
-! RUN: rm -rf %S/input-output-file.txt
-
 ! REQUIRES: new-flang-driver
 
 !--
 ! FLANG DRIVER (flang-new)
 !--
+! NOTE: We need `-E` below in order to instruct the compiler driver to create a job representing a fronted compiler invocation
 ! TEST 1: Print to stdout (implicit)
-! RUN: %flang-new -test-io %s  2>&1 | FileCheck %s --match-full-lines
+! RUN: %flang-new -E -Xflang -test-io %s  2>&1 | FileCheck %s --match-full-lines
 ! TEST 2: Print to stdout (explicit)
-! RUN: %flang-new -test-io -o - %s  2>&1 | FileCheck %s --match-full-lines
+! RUN: %flang-new -E -Xflang -test-io -o - %s  2>&1 | FileCheck %s --match-full-lines
 ! TEST 3: Print to a file
-! RUN: %flang-new -test-io -o %t %s 2>&1 && FileCheck %s --match-full-lines --input-file=%t
+! RUN: %flang-new -E -Xflang -test-io -o %t %s 2>&1 && FileCheck %s --match-full-lines --input-file=%t
 
 !
 ! FLANG FRONTEND DRIVER (flang-new -fc1)
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -43,6 +43,7 @@
 ! HELP-NEXT: -o   Write output to 
 ! HELP-NEXT: -U  Undefine macro 
 ! HELP-NEXT: --version  Print version information
+! HELP-NEXT: -Xflang   Pass  to the flang compiler
 
 !-
 ! EXPECTED OUTPUT FOR FLANG FRONTEND DRIVER (flang-new -fc1)
@@ -73,6 +74,7 @@
 ! HELP-FC1-NEXT: -IAdd directory to the end of the list of include search paths
 ! HELP-FC1-NEXT: -module-dir   Put MODULE files in 
 ! HELP-FC1-NEXT: -o   Write output to 
+! HELP-FC1-NEXT: -test-io   Run the InputOuputTest action. Use for development and testing only.
 ! HELP-FC1-NEXT: -U  Undefine macro 
 ! HELP-FC1-NEXT: --version  Print version information
 
Index: flang/test/Flang-Driver/driver-help-hidden.f90

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

2021-02-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

This patch preserves all previous reports as expected.
You can check it by yourself at 
https://codechecker-demo.eastus.cloudapp.azure.com/Default/runs?run=D96090&items-per-page=50.

However, I still have some minor concerns inline.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h:101-103
   // FIXME: Make these protected again once RegionStoreManager correctly
   // handles loads from different bound value types.
   virtual SVal dispatchCast(SVal val, QualType castTy) = 0;

I'm not sure if this FIXME is still applicable.

I'm also confused about having two functions doing effectively the same thing.
`SimpleSValBuilder::dispatchCast` is a virtual function, which just invokes a 
non-virtual function `SValBuilder::evalCast`.

Why should it be virtual in the first place?



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:727-728
+  // pointers as well.
+  // FIXME: We really need a single good function to perform casts for us
+  // correctly every time we need it.
+  if (CastTy->isPointerType() && !CastTy->isVoidPointerType()) {

You are resolving exactly this FIXME in this patch if I'm correct.
Shouldn't you update this comment?



Comment at: clang/lib/StaticAnalyzer/Core/SValBuilder.cpp:868-870
+  if (OriginalTy.isNull())
+// Pass to MemRegion function.
+return evalCastSubKind(loc::MemRegionVal(R), CastTy, OriginalTy);

Eh, I don't like comments preceding a single-statement block.
It might be a personal preference though.


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

https://reviews.llvm.org/D96090

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


[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

One observation is that for arm_neon.h `__inline__` is used.  So perhaps we can 
just do likewise and we'll also be consistent across the two ACLE headers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96852

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


[PATCH] D95536: [clang][sema] Note decl location on missing member

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

In D95536#2568252 , @tbaeder wrote:

> In D95536#2557197 , @aaron.ballman 
> wrote:
>
>> Hmm... I feel like the diagnostic should already be sufficient to locate the 
>> originating location of the class or namespace and the note is adding a bit 
>> more (almost, but not quite) noise,
>
> I guess this makes sense when you're talking about 
> https://godbolt.org/z/1Yo3Pj, but I don't understand how I would know where 
> `OsType` is defined in https://godbolt.org/ in a larger code base (e.g. when 
> using `OsType` in clang, with it being defined in llvm).

I think that the name in the diagnostic should be sufficient for you to track 
that down using the editor of your choice (including super simple editors like 
notepad), such as by using a simple search. With that example, when I search 
for "enum OsType" in my editor, there's only one hit in the code base. Even in 
slightly more complex cases where you try to make things look ambiguous, the 
diagnostic text does a pretty good job of making it clear roughly where to 
look: https://godbolt.org/z/41nPnd

>> Anonymous namespaces:
>>
>>   namespace foo {
>>   namespace {
>> void func();
>>   }
>>   }
>>   
>>   void bar() {
>> foo::blarg(); // Should point to 'foo'?
>>   }
>
> Seems to work:
>
>   ./enum.cpp:56:8: error: no member named 'blarg' in namespace 'foo'
> foo::blarg(); // Should point to 'foo'?
> ~^
>   ./enum.cpp:49:11: note: namespace 'foo' declared here
>   namespace foo {
> ^~~
>
> You list a few more interesting corner cases however. I'm not sure if I want 
> to pursue this patch further as it is already quite ugly because it's 
> touching all those tests. Or if it would be better to implement a note that 
> lists all enum members (up to a certain threshold?), but just for enums.

I'd be worried that would add even more output that would largely be noise in 
the common case. My personal preference in this case would be to try to improve 
the existing diagnostics to be more clear as to what's referenced rather than 
adding an extra note. However, I won't block the patch based solely on my 
personal preference if you'd like to continue to pursue this -- I leave the 
final decision to @rsmith in that case.


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

https://reviews.llvm.org/D95536

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


[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

2021-02-17 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:835
+  CTU.getMacroExpansionContextForSourceLocation(MacroExpansionLoc)) {
+return CTUMacroExpCtx->getExpandedText(MacroExpansionLoc);
   }

balazske wrote:
> I am not sure if `getExpandedText` will handle a source location that is not 
> in the same TU. Probably the previous source location mapping mechanism (that 
> is now removed) is needed additionally, so that here the original source 
> location and the original `MacroExpansionContext` is available. Probably this 
> can be done in other way, the `MacroExpansionContext` could handle this 
> mapping. (A single `MacroExpansionContext` could handle every imported source 
> location at least for on-demand parsing.)
Yes. For a complete CTU implementation, it seems inevitable to be able to 
acquire the proper MacroExpansionContext for an imported source-location. So 
the previous mapping will be likely back once we implement this functionality 
completely.

I think we can not implement it via having a single MacroExpansionContext due 
to layering violations.
I wanted this to be part of the Analysis library, but if it was concerned about 
CTU importing and stuff it would reside inside the cross_tu library.
I might be wrong about this though.


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

https://reviews.llvm.org/D94673

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


[clang-tools-extra] e030de7 - [clangd] Pass file when possible to resolve URI.

2021-02-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-02-17T15:33:50+01:00
New Revision: e030de7e5a28de1bcc337ede445600f8d282d252

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

LOG: [clangd] Pass file when possible to resolve URI.

Some URI scheme needs the hint path to do a correct resolution, we pass
one of the open files as hint path.

This is not perfect, and it might not work for opening files across
project, but it would fix a bug with our internal scheme.

in the long run, removing URIs from all the index internals is a more proper 
fix.

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

Added: 


Modified: 
clang-tools-extra/clangd/index/MemIndex.cpp
clang-tools-extra/clangd/index/dex/Dex.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/MemIndex.cpp 
b/clang-tools-extra/clangd/index/MemIndex.cpp
index a578ed2da140..e2a8eb7f8e3f 100644
--- a/clang-tools-extra/clangd/index/MemIndex.cpp
+++ b/clang-tools-extra/clangd/index/MemIndex.cpp
@@ -112,9 +112,11 @@ void MemIndex::relations(
 llvm::unique_function
 MemIndex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-auto Path = URI::resolve(FileURI);
+if (Files.empty())
+  return IndexContents::None;
+auto Path = URI::resolve(FileURI, Files.begin()->first());
 if (!Path) {
-  llvm::consumeError(Path.takeError());
+  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
   return IndexContents::None;
 }
 return Files.contains(*Path) ? IdxContents : IndexContents::None;

diff  --git a/clang-tools-extra/clangd/index/dex/Dex.cpp 
b/clang-tools-extra/clangd/index/dex/Dex.cpp
index 8552fa3b5174..a6a8f23cab4c 100644
--- a/clang-tools-extra/clangd/index/dex/Dex.cpp
+++ b/clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -316,9 +316,11 @@ void Dex::relations(
 llvm::unique_function
 Dex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-auto Path = URI::resolve(FileURI);
+if (Files.empty())
+  return IndexContents::None;
+auto Path = URI::resolve(FileURI, Files.begin()->first());
 if (!Path) {
-  llvm::consumeError(Path.takeError());
+  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
   return IndexContents::None;
 }
 return Files.contains(*Path) ? IdxContents : IndexContents::None;



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


[PATCH] D96844: [clangd] Pass file when possible to resolve URI.

2021-02-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe030de7e5a28: [clangd] Pass file when possible to resolve 
URI. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96844

Files:
  clang-tools-extra/clangd/index/MemIndex.cpp
  clang-tools-extra/clangd/index/dex/Dex.cpp


Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -316,9 +316,11 @@
 llvm::unique_function
 Dex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-auto Path = URI::resolve(FileURI);
+if (Files.empty())
+  return IndexContents::None;
+auto Path = URI::resolve(FileURI, Files.begin()->first());
 if (!Path) {
-  llvm::consumeError(Path.takeError());
+  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
   return IndexContents::None;
 }
 return Files.contains(*Path) ? IdxContents : IndexContents::None;
Index: clang-tools-extra/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/clangd/index/MemIndex.cpp
+++ clang-tools-extra/clangd/index/MemIndex.cpp
@@ -112,9 +112,11 @@
 llvm::unique_function
 MemIndex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-auto Path = URI::resolve(FileURI);
+if (Files.empty())
+  return IndexContents::None;
+auto Path = URI::resolve(FileURI, Files.begin()->first());
 if (!Path) {
-  llvm::consumeError(Path.takeError());
+  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
   return IndexContents::None;
 }
 return Files.contains(*Path) ? IdxContents : IndexContents::None;


Index: clang-tools-extra/clangd/index/dex/Dex.cpp
===
--- clang-tools-extra/clangd/index/dex/Dex.cpp
+++ clang-tools-extra/clangd/index/dex/Dex.cpp
@@ -316,9 +316,11 @@
 llvm::unique_function
 Dex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-auto Path = URI::resolve(FileURI);
+if (Files.empty())
+  return IndexContents::None;
+auto Path = URI::resolve(FileURI, Files.begin()->first());
 if (!Path) {
-  llvm::consumeError(Path.takeError());
+  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
   return IndexContents::None;
 }
 return Files.contains(*Path) ? IdxContents : IndexContents::None;
Index: clang-tools-extra/clangd/index/MemIndex.cpp
===
--- clang-tools-extra/clangd/index/MemIndex.cpp
+++ clang-tools-extra/clangd/index/MemIndex.cpp
@@ -112,9 +112,11 @@
 llvm::unique_function
 MemIndex::indexedFiles() const {
   return [this](llvm::StringRef FileURI) {
-auto Path = URI::resolve(FileURI);
+if (Files.empty())
+  return IndexContents::None;
+auto Path = URI::resolve(FileURI, Files.begin()->first());
 if (!Path) {
-  llvm::consumeError(Path.takeError());
+  vlog("Failed to resolve the URI {0} : {1}", FileURI, Path.takeError());
   return IndexContents::None;
 }
 return Files.contains(*Path) ? IdxContents : IndexContents::None;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87029: [AIX] Implement AIX special bitfield related alignment rules

2021-02-17 Thread Xiangling Liao via Phabricator via cfe-commits
Xiangling_L added a comment.

ping.


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

https://reviews.llvm.org/D87029

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


[clang-tools-extra] 7048cb5 - [clangd] IndexedFiles should include Fils from RefSlab and RelationSlab.

2021-02-17 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2021-02-17T15:41:09+01:00
New Revision: 7048cb5371f93788ee650c521995a85211f3ae46

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

LOG: [clangd] IndexedFiles should include Fils from RefSlab and RelationSlab.

This looks like an oversight.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/FileIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index f497f845b42d..528630f9232a 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -280,11 +280,14 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling 
DuplicateHandle,
 }
 for (const auto &FileAndRefs : RefsSnapshot) {
   RefSlabs.push_back(FileAndRefs.second.Slab);
+  Files.insert(FileAndRefs.first());
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelationsSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot) {
+  Files.insert(FileAndRelations.first());
   RelationSlabs.push_back(FileAndRelations.second);
+}
 
 if (Version)
   *Version = this->Version;



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


[PATCH] D96845: [clangd] IndexedFiles should include Fils from RefSlab and RelationSlab.

2021-02-17 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7048cb5371f9: [clangd] IndexedFiles should include Fils from 
RefSlab and RelationSlab. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96845

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -280,11 +280,14 @@
 }
 for (const auto &FileAndRefs : RefsSnapshot) {
   RefSlabs.push_back(FileAndRefs.second.Slab);
+  Files.insert(FileAndRefs.first());
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelationsSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot) {
+  Files.insert(FileAndRelations.first());
   RelationSlabs.push_back(FileAndRelations.second);
+}
 
 if (Version)
   *Version = this->Version;


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -280,11 +280,14 @@
 }
 for (const auto &FileAndRefs : RefsSnapshot) {
   RefSlabs.push_back(FileAndRefs.second.Slab);
+  Files.insert(FileAndRefs.first());
   if (FileAndRefs.second.CountReferences)
 MainFileRefs.push_back(RefSlabs.back().get());
 }
-for (const auto &FileAndRelations : RelationsSnapshot)
+for (const auto &FileAndRelations : RelationsSnapshot) {
+  Files.insert(FileAndRelations.first());
   RelationSlabs.push_back(FileAndRelations.second);
+}
 
 if (Version)
   *Version = this->Version;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96865: [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Igor Kudrin via Phabricator via cfe-commits
ikudrin created this revision.
ikudrin added reviewers: dblaikie, probinson, aprantl, MaskRay, mehdi_amini.
ikudrin added projects: LLVM, clang, debug-info.
ikudrin requested review of this revision.

This fixes an issue when `-gdwarf-N` switch was ignored if it was given before 
another debug option.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96865

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


Index: clang/test/Driver/debug-options-as.c
===
--- clang/test/Driver/debug-options-as.c
+++ clang/test/Driver/debug-options-as.c
@@ -60,3 +60,18 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 
'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 
bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF 
platforms'
+
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -gdwarf-3 -g -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -g -gdwarf-5 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+// RUN: %clang -### -c -gdwarf-5 -g -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+
+// DWARF3: "-cc1as"
+// DWARF3: "-dwarf-version=3"
+// DWARF5: "-cc1as"
+// DWARF5: "-dwarf-version=5"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -983,6 +983,14 @@
   .Default(0);
 }
 
+// Find a DWARF format version option.
+// This function is a complementary for DwarfVersionNum().
+static const Arg *getDwarfNArg(const ArgList &Args) {
+  return Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
+ options::OPT_gdwarf_4, options::OPT_gdwarf_5,
+ options::OPT_gdwarf);
+}
+
 static void RenderDebugEnablingArgs(const ArgList &Args, ArgStringList 
&CmdArgs,
 codegenoptions::DebugInfoKind 
DebugInfoKind,
 unsigned DwarfVersion,
@@ -3850,9 +3858,7 @@
   }
 
   // If a -gdwarf argument appeared, remember it.
-  const Arg *GDwarfN = Args.getLastArg(
-  options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
-  options::OPT_gdwarf_5, options::OPT_gdwarf);
+  const Arg *GDwarfN = getDwarfNArg(Args);
   bool EmitDwarf = false;
   if (GDwarfN) {
 if (checkDebugInfoOption(GDwarfN, Args, D, TC))
@@ -7175,18 +7181,14 @@
   // Forward -g and handle debug info related flags, assuming we are dealing
   // with an actual assembly file.
   bool WantDebug = false;
-  unsigned DwarfVersion = 0;
   Args.ClaimAllArgs(options::OPT_g_Group);
-  if (Arg *A = Args.getLastArg(options::OPT_g_Group)) {
+  if (Arg *A = Args.getLastArg(options::OPT_g_Group))
 WantDebug = !A->getOption().matches(options::OPT_g0) &&
 !A->getOption().matches(options::OPT_ggdb0);
-if (WantDebug)
-  DwarfVersion = DwarfVersionNum(A->getSpelling());
-  }
 
-  unsigned DefaultDwarfVersion = ParseDebugDefaultVersion(getToolChain(), 
Args);
-  if (DwarfVersion == 0)
-DwarfVersion = DefaultDwarfVersion;
+  unsigned DwarfVersion = ParseDebugDefaultVersion(getToolChain(), Args);
+  if (const Arg *GDwarfN = getDwarfNArg(Args))
+DwarfVersion = DwarfVersionNum(GDwarfN->getSpelling());
 
   if (DwarfVersion == 0)
 DwarfVersion = getToolChain().GetDefaultDwarfVersion();


Index: clang/test/Driver/debug-options-as.c
===
--- clang/test/Driver/debug-options-as.c
+++ clang/test/Driver/debug-options-as.c
@@ -60,3 +60,18 @@
 // GDWARF64_VER:  error: invalid argument '-gdwarf64' only allowed with 'DWARFv3 or greater'
 // GDWARF64_32ARCH: error: invalid argument '-gdwarf64' only allowed with '64 bit architecture'
 // GDWARF64_ELF: error: invalid argument '-gdwarf64' only allowed with 'ELF platforms'
+
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -gdwarf-3 -g -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s
+// RUN: %clang -### -c -g -gdwarf-5 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+// RUN: %clang -### -c -gdwarf-5 -g -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF5 %s
+
+// DWARF3: "-cc1as"
+// DWARF3: "-dwarf-version=3"
+// DWARF5: "-cc1as"
+// DWARF5: "-dwarf-version=5"
In

[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-17 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 324296.
arnamoy10 added a comment.

Addresses proper handling of sizes


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

https://reviews.llvm.org/D96344

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

Index: flang/test/Flang-Driver/pipeline.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/pipeline.f90
@@ -0,0 +1,17 @@
+! This file tests that flang-new forwards 
+! all Flang frontend options to flang-new -fc1
+! as expected.
+!
+! RUN: %flang-new -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: -fdefault-double-8 \
+! RUN: -fdefault-integer-8 \
+! RUN: -fdefault-real-8 \
+! RUN: -flarge-sizes \
+! RUN:   | FileCheck %s
+!
+!
+! CHECK: "-fdefault-double-8"
+! CHECK: "-fdefault-integer-8"
+! CHECK: "-fdefault-real-8"
+! CHECK: "-flarge-sizes"
+
Index: flang/test/Flang-Driver/fdefault.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fdefault.f90
@@ -0,0 +1,26 @@
+! Ensure argument -fdefault* works as expected.
+! TODO: Add checks when actual codegen is possible for this family
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -fdefault-double-8 %s  2>&1 | FileCheck %s --check-prefix=DOUBLE
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang-new -fc1 -fsyntax-only -fdefault-double-8 %s  2>&1 | FileCheck %s --check-prefix=DOUBLE
+
+!-
+! EXPECTED OUTPUT FOR PROVIDING ONLY -fdefault-double-8 
+!-
+! DOUBLE:error: Use of `-fdefault-double-8` requires `-fdefault-real-8`
+
+PROGRAM test
+  implicit none
+  real :: x! note kind is not specified
+  x = 3.4
+  print *, "x = ", x
+END PROGRAM
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -23,10 +23,14 @@
 ! HELP-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
+! HELP-NEXT: -fdefault-double-8 Set the DOUBLE PRECISION type and double real constants like 1.d0 to an 8 byte wide type.
+! HELP-NEXT: -fdefault-integer-8Set the default integer and logical types to an 8 byte wide type.
+! HELP-NEXT: -fdefault-real-8   Set the default real type to an 8 byte wide type.
 ! HELP-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-NEXT: -ffixed-line-length=
 ! HELP-NEXT: Use  as character line width in fixed mode
 ! HELP-NEXT: -ffree-formProcess source files in free form
+! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics.
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
@@ -46,10 +50,14 @@
 ! HELP-FC1-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-FC1-NEXT: -emit-obj Emit native object files
 ! HELP-FC1-NEXT: -E Only run the preprocessor
+! HELP-FC1-NEXT: -fdefault-double-8  Set the DOUBLE PRECISION type and double real constants like 1.d0 to an 8 byte wide type.
+! HELP-FC1-NEXT: -fdefault-integer-8 Set the default integer and logical types to an 8 byte wide type.
+! HELP-FC1-NEXT: -fdefault-real-8Set the default real type to an 8 byte wide type.
 ! HELP-FC1-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-FC1-NEXT: -ffixed-line-length=
 ! HELP-FC1-NEXT: Use  as character line width in fixed mode
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
+! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics.
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-FC1-NEXT: -help  Display available options
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -23,10 +23,14 @@
 ! CHECK-NEXT: -D = Define  to  (or 1 if  omitted)
 ! CHECK-NEXT: -EOnly run the prepr

[PATCH] D96852: [clang][SVE] Remove inline keyword from arm_sve.h

2021-02-17 Thread Joe Ellis via Phabricator via cfe-commits
joechrisellis updated this revision to Diff 324311.
joechrisellis added a comment.
This revision is now accepted and ready to land.

Use __inline__ instead of inline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96852

Files:
  clang/utils/TableGen/SveEmitter.cpp


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1201,7 +1201,7 @@
   OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
-  OS << "#define __aio static inline __attribute__((__always_inline__, "
+  OS << "#define __aio static __inline__ __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
 
   // Add reinterpret functions.


Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -1201,7 +1201,7 @@
   OS << "};\n\n";
 
   OS << "/* Function attributes */\n";
-  OS << "#define __aio static inline __attribute__((__always_inline__, "
+  OS << "#define __aio static __inline__ __attribute__((__always_inline__, "
 "__nodebug__, __overloadable__))\n\n";
 
   // Add reinterpret functions.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D96864: [flang][driver] Add -Xflang and make -test-io a frontend-only flag

2021-02-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX added a comment.

Thanks! for the patch @awarzynski . I support this enhancement. LGTM(Not 
accepting formally :) ), Let's wait and hear from others also, what's their 
take on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96864

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


[PATCH] D96864: [flang][driver] Add -Xflang and make -test-io a frontend-only flag

2021-02-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX added inline comments.



Comment at: flang/test/Frontend/input-output-file.f90:6
 !--
+! NOTE: We need `-E` below in order to instruct the compiler driver to create 
a job representing a fronted compiler invocation
 ! TEST 1: Print to stdout (implicit)

I didn't follow this completely, Could you please elaborate a bit.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96864

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski requested changes to this revision.
awarzynski added a comment.
This revision now requires changes to proceed.

Thank you for updating this!

I've left a couple of small suggestions inline. Once those are addressed I 
believe that this is ready to land. @tskeith, any thoughts ?




Comment at: flang/lib/Frontend/CompilerInvocation.cpp:254
+  if (args.hasArg(clang::driver::options::OPT_fdefault_real_8))
+res.defaultKinds().set_defaultRealKind(8);
+  if (args.hasArg(clang::driver::options::OPT_fdefault_integer_8)) {

From `gfortran` [[ 
https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html | 
documentation ]]:

```
This option promotes the default width of DOUBLE PRECISION and double real 
constants like 1.d0 to 16 bytes if possible.
```

So I believe that you are missing:
```
res.defaultKinds().set_doublePrecisionKind(16);
```



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:269-271
+// For -fdefault-double-8 + -fdefault-real-8, only the size of
+// DOUBLE PRECISION type changes, the size of default real type stays
+// the same

I think that it's more like:
```
// -fdefault-real-8 alone promotes the width for DOUBLE PRECISION to 16 bytes. 
-fdefault-double-8 overwrites that and sets the width back to 8 bytes.
```
Since this patch adds `gfortran` style semantics, it would be worth adding a 
link to the docs somewhere at the top.


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

https://reviews.llvm.org/D96344

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-17 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:254
+  if (args.hasArg(clang::driver::options::OPT_fdefault_real_8))
+res.defaultKinds().set_defaultRealKind(8);
+  if (args.hasArg(clang::driver::options::OPT_fdefault_integer_8)) {

awarzynski wrote:
> From `gfortran` [[ 
> https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html | 
> documentation ]]:
> 
> ```
> This option promotes the default width of DOUBLE PRECISION and double real 
> constants like 1.d0 to 16 bytes if possible.
> ```
> 
> So I believe that you are missing:
> ```
> res.defaultKinds().set_doublePrecisionKind(16);
> ```
I thought it is not necessary because `doublePrecisionKind` is automatically 
initialized to double the size of `defaultRealKind_` in [[ 
https://github.com/llvm/llvm-project/blob/adfd3c7083f9808d145239153c10f72eece485d8/flang/include/flang/Common/default-kinds.h#L51-L58
 | here ]]--> `int doublePrecisionKind_{2 * defaultRealKind_};`. 





Comment at: flang/lib/Frontend/CompilerInvocation.cpp:269-271
+// For -fdefault-double-8 + -fdefault-real-8, only the size of
+// DOUBLE PRECISION type changes, the size of default real type stays
+// the same

awarzynski wrote:
> I think that it's more like:
> ```
> // -fdefault-real-8 alone promotes the width for DOUBLE PRECISION to 16 
> bytes. -fdefault-double-8 overwrites that and sets the width back to 8 bytes.
> ```
> Since this patch adds `gfortran` style semantics, it would be worth adding a 
> link to the docs somewhere at the top.
Sure, will do!


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

https://reviews.llvm.org/D96344

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


[PATCH] D80833: [CodeView] Add full repro to LF_BUILDINFO record

2021-02-17 Thread Leonardo Santagada via Phabricator via cfe-commits
santagada added a comment.

In D80833#2069411 , @aganea wrote:

> In D80833#2069246 , @amccarth wrote:
>
>> Does the full path to the tool end up only in the object file, or does this 
>> make it all the way to the final executable or library?
>
> The `LF_BUILDINFO` records for each .OBJ are emitted as they are in the final 
> .PDB.
>
>> Does embedding full paths affect distributed builds or build reproducibility?
>
> It does affect reproducibility for distributed builds, the contents of 
> `LF_BUILDINFO` for a remotely-compiled .OBJ will be different in the final 
> .PDB.
> In our case, compilation jobs can be executed locally or remotely, depending 
> on how they are queued.
> For example,
>
> - If a local compilation, `C:\.nuget\llvm.10.0.0.2\bin\clang-cl.exe` would be 
> stamped in the `LF_BUILDINFO` record.
> - If a remote compilation, 
> `C:\Users\SomeUser\AppData\Local\Temp\.fbuild.tmp\worker\toolchain.130589cdf35aed3b\clang-cl.exe`
>  would be stamped (the compiler executable is sent to the remote worker).
>
> But you've got a good point. We would need an way to force the remote 
> compiler to stamp the local path (which is unique for all users). We've got a 
> manual override if the compiler path referred by `LF_BUILDINFO` can't be 
> found locally, but this is a bit annoying, see: 
> https://liveplusplus.tech/docs/documentation.html#FASTBuild.
> It is better if the right information was there in the first place in the 
> .OBJ. Could we do a remapping instead through VFS maybe? I'd like to avoid 
> adding yet-a-new-flag to handle that.

I'm quite late into this ticket, but just to tell our solution, our distributed 
compilation system maps its own work directory to an I:\ drive and all our 
compiler/dependencies live inside the same folder, so locally something is in 
D:\dev\game\toolset\compiler\clang-cl.exe becomes 
I:\dev\game\toolset\compiler\clang-cl.exe then when copying the objects back 
the distribution system maps I:\ to D:\, which doesn't break the obj sizes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80833

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:254
+  if (args.hasArg(clang::driver::options::OPT_fdefault_real_8))
+res.defaultKinds().set_defaultRealKind(8);
+  if (args.hasArg(clang::driver::options::OPT_fdefault_integer_8)) {

arnamoy10 wrote:
> awarzynski wrote:
> > From `gfortran` [[ 
> > https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html | 
> > documentation ]]:
> > 
> > ```
> > This option promotes the default width of DOUBLE PRECISION and double real 
> > constants like 1.d0 to 16 bytes if possible.
> > ```
> > 
> > So I believe that you are missing:
> > ```
> > res.defaultKinds().set_doublePrecisionKind(16);
> > ```
> I thought it is not necessary because `doublePrecisionKind` is automatically 
> initialized to double the size of `defaultRealKind_` in [[ 
> https://github.com/llvm/llvm-project/blob/adfd3c7083f9808d145239153c10f72eece485d8/flang/include/flang/Common/default-kinds.h#L51-L58
>  | here ]]--> `int doublePrecisionKind_{2 * defaultRealKind_};`. 
> 
> 
Yes, but the default value for `defaultRealKind_` is 4 and here you are setting 
it to 8. So, correct me if I'm wrong, but when the driver is here, the 
following has happened:
```
int defaultIntegerKind_{4};
int defaultRealKind_{defaultIntegerKind_};
int doublePrecisionKind_{2 * defaultRealKind_};
```
So `dublePrecisionKind_` is 8 rather than 16.


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

https://reviews.llvm.org/D96344

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


[PATCH] D96816: [ObjC] Encode pointers to C++ classes as "^v" if the encoded string would otherwise include template specialization types

2021-02-17 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Since this is just in pointee types, I suspect this is fine for dispatch 
outside of targets (like that one old Cray) where `sizeof(void*) != 
sizeof(some_struct*)`, which I don't believe we generally support.  But yeah, 
if this affects GNU-runtime ivar mangling, we need a way to not disturb this 
for that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96816

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-17 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 updated this revision to Diff 324334.
arnamoy10 added a comment.

- Added option for setting DOUBLE PRECISION when `fdefault-real-8` is given
- Also added link to relevant gfortran doc


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

https://reviews.llvm.org/D96344

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

Index: flang/test/Flang-Driver/pipeline.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/pipeline.f90
@@ -0,0 +1,17 @@
+! This file tests that flang-new forwards 
+! all Flang frontend options to flang-new -fc1
+! as expected.
+!
+! RUN: %flang-new -fsyntax-only -### %s -o %t 2>&1 \
+! RUN: -fdefault-double-8 \
+! RUN: -fdefault-integer-8 \
+! RUN: -fdefault-real-8 \
+! RUN: -flarge-sizes \
+! RUN:   | FileCheck %s
+!
+!
+! CHECK: "-fdefault-double-8"
+! CHECK: "-fdefault-integer-8"
+! CHECK: "-fdefault-real-8"
+! CHECK: "-flarge-sizes"
+
Index: flang/test/Flang-Driver/fdefault.f90
===
--- /dev/null
+++ flang/test/Flang-Driver/fdefault.f90
@@ -0,0 +1,26 @@
+! Ensure argument -fdefault* works as expected.
+! TODO: Add checks when actual codegen is possible for this family
+
+! REQUIRES: new-flang-driver
+
+!--
+! FLANG DRIVER (flang-new)
+!--
+! RUN: not %flang-new -fsyntax-only -fdefault-double-8 %s  2>&1 | FileCheck %s --check-prefix=DOUBLE
+
+!-
+! FRONTEND FLANG DRIVER (flang-new -fc1)
+!-
+! RUN: not %flang-new -fc1 -fsyntax-only -fdefault-double-8 %s  2>&1 | FileCheck %s --check-prefix=DOUBLE
+
+!-
+! EXPECTED OUTPUT FOR PROVIDING ONLY -fdefault-double-8 
+!-
+! DOUBLE:error: Use of `-fdefault-double-8` requires `-fdefault-real-8`
+
+PROGRAM test
+  implicit none
+  real :: x! note kind is not specified
+  x = 3.4
+  print *, "x = ", x
+END PROGRAM
Index: flang/test/Flang-Driver/driver-help.f90
===
--- flang/test/Flang-Driver/driver-help.f90
+++ flang/test/Flang-Driver/driver-help.f90
@@ -23,10 +23,14 @@
 ! HELP-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-NEXT: -E Only run the preprocessor
 ! HELP-NEXT: -fcolor-diagnosticsEnable colors in diagnostics
+! HELP-NEXT: -fdefault-double-8 Set the DOUBLE PRECISION type and double real constants like 1.d0 to an 8 byte wide type.
+! HELP-NEXT: -fdefault-integer-8Set the default integer and logical types to an 8 byte wide type.
+! HELP-NEXT: -fdefault-real-8   Set the default real type to an 8 byte wide type.
 ! HELP-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-NEXT: -ffixed-line-length=
 ! HELP-NEXT: Use  as character line width in fixed mode
 ! HELP-NEXT: -ffree-formProcess source files in free form
+! HELP-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics.
 ! HELP-NEXT: -fno-color-diagnostics Disable colors in diagnostics
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
@@ -46,10 +50,14 @@
 ! HELP-FC1-NEXT: -D = Define  to  (or 1 if  omitted)
 ! HELP-FC1-NEXT: -emit-obj Emit native object files
 ! HELP-FC1-NEXT: -E Only run the preprocessor
+! HELP-FC1-NEXT: -fdefault-double-8  Set the DOUBLE PRECISION type and double real constants like 1.d0 to an 8 byte wide type.
+! HELP-FC1-NEXT: -fdefault-integer-8 Set the default integer and logical types to an 8 byte wide type.
+! HELP-FC1-NEXT: -fdefault-real-8Set the default real type to an 8 byte wide type.
 ! HELP-FC1-NEXT: -ffixed-form   Process source files in fixed form
 ! HELP-FC1-NEXT: -ffixed-line-length=
 ! HELP-FC1-NEXT: Use  as character line width in fixed mode
 ! HELP-FC1-NEXT: -ffree-formProcess source files in free form
+! HELP-FC1-NEXT: -flarge-sizes  Use INTEGER(KIND=8) for the result type in size-related intrinsics.
 ! HELP-FC1-NEXT: -fopenacc  Enable OpenACC
 ! HELP-FC1-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-FC1-NEXT: -help  Display available options
Index: flang/test/Flang-Driver/driver-help-hidden.f90
===
--- flang/test/Flang-Driver/driver-help-hidden.f90
+++ flang/test/Flang-Driver/driver-help-hidden.f90
@@ -23,10 +23,14 @@
 ! CHECK-NEXT:

[PATCH] D96864: [flang][driver] Add -Xflang and make -test-io a frontend-only flag

2021-02-17 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski added inline comments.



Comment at: flang/test/Frontend/input-output-file.f90:6
 !--
+! NOTE: We need `-E` below in order to instruct the compiler driver to create 
a job representing a fronted compiler invocation
 ! TEST 1: Print to stdout (implicit)

SouraVX wrote:
> I didn't follow this completely, Could you please elaborate a bit.
Sorry, I'm doing a poor job documenting this here.

Basically, we want to instruct `flang-new` to stop after the preprocessing 
phase. `-E` is a phase control flag. `-c` is another phase control flag. You 
can also skip phase flags all together:
```
$ bin/flang-new -ccc-print-phases file.f90
+- 0: input, "file.f90", f95-cpp-input
 +- 1: preprocessor, {0}, f95
  +- 2: compiler, {1}, ir
   +- 3: backend, {2}, assembler
+- 4: assembler, {3}, object
5: linker, {4}, image
```
As you can see, without `-E` the driver, `flang-new`, would attempt to run 
multiple phases which would result in multiple compiler _jobs_. But we only 
want the compiler job, i.e. we are only interested the the first phase. (IIRC, 
compiler jobs map 1-1 to compiler phases).

So, `-E` is added here to make sure that `flang-new` doesn't try to do too much 
here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96864

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


[PATCH] D96825: [AArch64] Adding Polynomial vadd Intrinsics support

2021-02-17 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic marked an inline comment as done.
rsanthir.quic added inline comments.



Comment at: clang/test/CodeGen/aarch64-poly-add.c:4
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN: -disable-O0-optnone -ffp-contract=fast -emit-llvm -o - %s | opt -S 
-mem2reg \
+// RUN:  | FileCheck %s

DavidSpickett wrote:
> Do we need this option? (-ffp-contract)
You are correct this is not necessary, I'll remove it


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

https://reviews.llvm.org/D96825

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


[PATCH] D96825: [AArch64] Adding Neon Polynomial vadd Intrinsics

2021-02-17 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 324336.
rsanthir.quic marked an inline comment as done.
rsanthir.quic retitled this revision from "[AArch64] Adding Polynomial vadd 
Intrinsics support" to "[AArch64] Adding Neon Polynomial vadd Intrinsics".
rsanthir.quic added a comment.

removed unnecessary flag in test and changed commit message.


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

https://reviews.llvm.org/D96825

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-poly-add.c

Index: clang/test/CodeGen/aarch64-poly-add.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-poly-add.c
@@ -0,0 +1,85 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple arm64-none-linux-gnu -target-feature +neon \
+// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \
+// RUN:  | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vadd_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <8 x i8> [[TMP0]]
+//
+poly8x8_t test_vadd_p8(poly8x8_t a, poly8x8_t b) {
+  return vadd_p8 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i16> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <4 x i16>
+// CHECK-NEXT:ret <4 x i16> [[TMP3]]
+//
+poly16x4_t test_vadd_p16(poly16x4_t a, poly16x4_t b) {
+  return vadd_p16 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <1 x i64> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <1 x i64>
+// CHECK-NEXT:ret <1 x i64> [[TMP3]]
+//
+poly64x1_t test_vadd_p64(poly64x1_t a, poly64x1_t b) {
+  return vadd_p64(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+poly8x16_t test_vaddq_p8(poly8x16_t a, poly8x16_t b){
+  return vaddq_p8(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i16> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP3]]
+//
+poly16x8_t test_vaddq_p16(poly16x8_t a, poly16x8_t b){
+  return vaddq_p16(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <2 x i64> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x i64> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
+// CHECK-NEXT:ret <2 x i64> [[TMP3]]
+//
+poly64x2_t test_vaddq_p64(poly64x2_t a, poly64x2_t b){
+  return vaddq_p64(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p128(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast i128 [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast i128 [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to i128
+// CHECK-NEXT:ret i128 [[TMP3]]
+//
+poly128_t test_vaddq_p128 (poly128_t a, poly128_t b){
+  return vaddq_p128(a, b);
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5368,7 +5368,10 @@
   NEONMAP2(vabdq_v, arm_neon_vabdu, arm_neon_vabds, Add1ArgType | UnsignedAlts),
   NEONMAP1(vabs_v, arm_neon_vabs, 0),
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
+  NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
+  NEONMAP0(vaddq_p128),
+  NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
   NEONMAP1(vaesimcq_v, arm_neon_aesimc, 0),
@@ -6299,6 +6302,14 @@
 if (VTy->getElementType()->isFloatingPointTy())
   return EmitNeonCall(CGM.getIntrinsic(Intrinsic::fabs, Ty), Ops, "vabs");
 return EmitNeonCall(CGM.getIntrinsic(LLVMIntrinsic, Ty), Ops, "vabs");
+  case NEON::BI__builtin_neon_vadd_v:
+  case NEON::BI__builtin_neon_vaddq_v: {
+llvm::Type *VTy = llvm::FixedVectorType::get(Int8Ty, Quad ? 16 : 8);
+Ops[0] = Builder.CreateBitCast(Ops[0], VTy);
+Ops[1] = Builder.CreateBitCas

[PATCH] D96381: [AArch64] Adding SHA3 Intrinsics support

2021-02-17 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

One nit for now, I'll take a proper look tomorrow. Thanks for your work on 
these!




Comment at: clang/test/CodeGen/aarch64-neon-sha3.c:26
+void test_vsha512su0(uint64x2_t w0_1, uint64x2_t w2_) {
+
+  uint64x2_t result = vsha512su0q_u64(w0_1, w2_);

Nit: remove empty lines in this and the following


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

https://reviews.llvm.org/D96381

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-02-17 Thread Arnamoy B via Phabricator via cfe-commits
arnamoy10 created this revision.
arnamoy10 added reviewers: awarzynski, tskeith, sscalpone, clementval, 
AMDChirag, SouraVX.
Herald added subscribers: jansvoboda11, dang.
arnamoy10 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add support for the following f18 options:

- -fdebug-module-writer

Depends on: D96344 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96875

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CompilerInvocation.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Semantics/mod-file-rewriter.f90

Index: flang/test/Semantics/mod-file-rewriter.f90
===
--- flang/test/Semantics/mod-file-rewriter.f90
+++ flang/test/Semantics/mod-file-rewriter.f90
@@ -3,6 +3,10 @@
 ! RUN: %f18 -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
 ! RUN: %f18 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
 ! RUN: %f18 -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
+! RUN: %flang-new -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
+! RUN: %flang-new -fsyntax-only -fdebug-module-writer %s 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
+! RUN: %flang-new -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix CHECK_UNCHANGED
+! RUN: %flang-new -fsyntax-only -fdebug-module-writer %p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
 
 module m
   real :: x(10)
Index: flang/lib/Frontend/FrontendActions.cpp
===
--- flang/lib/Frontend/FrontendActions.cpp
+++ flang/lib/Frontend/FrontendActions.cpp
@@ -134,7 +134,7 @@
 
   // Prepare semantics
   Fortran::semantics::Semantics semantics{ci.invocation().semanticsContext(),
-  parseTree, ci.parsing().cooked().AsCharBlock()};
+  parseTree, ci.parsing().cooked().AsCharBlock(),ci.invocation().debugModuleDir()};
 
   // Run semantic checks
   semantics.Perform();
Index: flang/lib/Frontend/CompilerInvocation.cpp
===
--- flang/lib/Frontend/CompilerInvocation.cpp
+++ flang/lib/Frontend/CompilerInvocation.cpp
@@ -227,9 +227,11 @@
 
 /// Parses all semantic related arguments and populates the variables
 /// options accordingly.
-static void parseSemaArgs(std::string &moduleDir, llvm::opt::ArgList &args,
+static void parseSemaArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
 clang::DiagnosticsEngine &diags) {
 
+  // -J/module-dir option
+  auto &moduleDir = res.moduleDir();
   auto moduleDirList =
   args.getAllArgValues(clang::driver::options::OPT_module_dir);
   // User can only specify -J/-module-dir once
@@ -242,6 +244,12 @@
   }
   if (moduleDirList.size() == 1)
 moduleDir = moduleDirList[0];
+
+  // -fdebug-module-writer option
+  auto &debugModuleDir = res.debugModuleDir();
+  if (args.hasArg(clang::driver::options::OPT_fdebug_module_writer)) {
+debugModuleDir = true;
+  }
 }
 
 /// Parses all Dialect related arguments and populates the variables
@@ -316,7 +324,7 @@
   // Parse the preprocessor args
   parsePreprocessorArgs(res.preprocessorOpts(), args);
   // Parse semantic args
-  parseSemaArgs(res.moduleDir(), args, diags);
+  parseSemaArgs(res, args, diags);
   // Parse dialect arguments
   parseDialectArgs(res, args, diags);
 
Index: flang/include/flang/Frontend/CompilerInvocation.h
===
--- flang/include/flang/Frontend/CompilerInvocation.h
+++ flang/include/flang/Frontend/CompilerInvocation.h
@@ -69,6 +69,8 @@
   // of options.
   std::string moduleDir_ = ".";
 
+  bool debugModuleDir_ = false;
+
   // Fortran Dialect options
   Fortran::common::IntrinsicTypeDefaultKinds defaultKinds_;
 
@@ -91,6 +93,9 @@
   std::string &moduleDir() { return moduleDir_; }
   const std::string &moduleDir() const { return moduleDir_; }
 
+  bool &debugModuleDir() { return debugModuleDir_; }
+  const bool &debugModuleDir() const { return debugModuleDir_; }
+
   Fortran::common::IntrinsicTypeDefaultKinds &defaultKinds() {
 return defaultKinds_;
   }
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -35,7 +35,7 @@
 }
 
 void Flang::AddOtherOptions(const ArgList &Args, ArgStringList &CmdArgs) const {
-  Args.AddAllArgs(CmdArgs, options::OPT_module_dir);
+  Args.AddAllArgs(CmdArgs, {options::OPT_module_dir,options::OPT_fdebug_module_writer}

[PATCH] D96515: [OpenCL] Add builtin declarations by default.

2021-02-17 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D96515

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


[PATCH] D96875: [flang][driver] Add -fdebug-module-writer option

2021-02-17 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:234
+  // -J/module-dir option
+  auto &moduleDir = res.moduleDir();
   auto moduleDirList =

In my opinion, using mutable references like this make the code hard to 
understand. Setters on CompilerInvocation would be clearer.



Comment at: flang/test/Semantics/mod-file-rewriter.f90:9
+! RUN: %flang-new -fsyntax-only -fdebug-module-writer 
%p/Inputs/mod-file-unchanged.f90 2>&1 | FileCheck %s --check-prefix 
CHECK_UNCHANGED
+! RUN: %flang-new -fsyntax-only -fdebug-module-writer 
%p/Inputs/mod-file-changed.f90 2>&1 | FileCheck %s --check-prefix CHECK_CHANGED
 

Why do you need to duplicate these lines? Doesn't it work to use `%flang`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96875

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, ye-luo, tianshilei1992, ABataev, 
grokos.
JonChesterfield requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

[libomptarget] Try a fallback devicertl if the preferred one is missing

Clang may be used with a cuda version that is newer than the clang release.
This may fail in various ways, but there is also a credible chance it will
work OK, for sufficiently small version slip.

As discussed in the weekly call, this change adds a fallback path to clang
which looks for a devicertl library that doesn't have a specific cuda version
encoded in the name, specifically 'libomptarget-nvptx-unknown.bc'. It also
warns about this, and recommends the user specify a devicertl they expect to
work manually.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D96877

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp

Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args, StringRef lib) {
+  if (llvm::sys::fs::exists(lib)) {
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(lib));
+return true;
+  } else {
+return false;
+  }
+}
+
+bool tryAppendBuiltinBitcodeGivenPaths(
+const SmallVector &LibraryPaths,
+const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
+llvm::Twine lib) {
+  for (StringRef LibraryPath : LibraryPaths) {
+SmallString<128> TargetFile(LibraryPath);
+llvm::sys::path::append(TargetFile, lib);
+if (tryAppendBuiltinBitcode(DriverArgs, CC1Args, TargetFile)) {
+  return true;
+}
+  }
+  return false;
+}
+} // namespace
+
 void tools::addOpenMPDeviceRTL(const Driver &D,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
@@ -1658,32 +1685,31 @@
   // First check whether user specifies bc library
   if (const Arg *A = DriverArgs.getLastArg(LibomptargetBCPathOpt)) {
 std::string LibOmpTargetName(A->getValue());
-if (llvm::sys::fs::exists(LibOmpTargetName)) {
-  CC1Args.push_back("-mlink-builtin-bitcode");
-  CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetName));
-} else {
+if (!tryAppendBuiltinBitcode(DriverArgs, CC1Args, LibOmpTargetName)) {
   D.Diag(diag::err_drv_omp_offload_target_bcruntime_not_found)
   << LibOmpTargetName;
 }
   } else {
 bool FoundBCLibrary = false;
 
-std::string LibOmpTargetName =
-"libomptarget-" + BitcodeSuffix.str() + ".bc";
-
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
+llvm::Twine LibOmpTargetName = "libomptarget-" + BitcodeSuffix + ".bc";
+llvm::Twine FallbackTargetName =
+"libomptarget-" + ArchPrefix + "-unknown.bc";
+
+FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+LibraryPaths, DriverArgs, CC1Args, LibOmpTargetName);
+
+if (!FoundBCLibrary) {
+  FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+  LibraryPaths, DriverArgs, CC1Args, FallbackTargetName);
+  if (FoundBCLibrary) {
+D.Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+<< LibOmpTargetName.str() << FallbackTargetName.str() << ArchPrefix;
   }
 }
 
 if (!FoundBCLibrary)
   D.Diag(diag::err_drv_omp_offload_target_missingbcruntime)
-  << LibOmpTargetName << ArchPrefix;
+  << LibOmpTargetName.str() << ArchPrefix;
   }
 }
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -262,6 +262,10 @@
   "The option -fopenmp-targets must be used in conjunction with a -fopenmp option compatible with offloading, please use -fopenmp=libomp or -fopenmp=libiomp5.">;
 def err_drv_omp_offload_target_missingbcruntime : Error<
   "No library '%0' found in the default clang lib directory or in LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode library.">;
+
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' found in the default clang lib directory or in LIBRAR

[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield updated this revision to Diff 324342.
JonChesterfield added a comment.

- drop whitespace from .td


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/CommonArgs.cpp


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args, StringRef lib) 
{
+  if (llvm::sys::fs::exists(lib)) {
+CC1Args.push_back("-mlink-builtin-bitcode");
+CC1Args.push_back(DriverArgs.MakeArgString(lib));
+return true;
+  } else {
+return false;
+  }
+}
+
+bool tryAppendBuiltinBitcodeGivenPaths(
+const SmallVector &LibraryPaths,
+const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
+llvm::Twine lib) {
+  for (StringRef LibraryPath : LibraryPaths) {
+SmallString<128> TargetFile(LibraryPath);
+llvm::sys::path::append(TargetFile, lib);
+if (tryAppendBuiltinBitcode(DriverArgs, CC1Args, TargetFile)) {
+  return true;
+}
+  }
+  return false;
+}
+} // namespace
+
 void tools::addOpenMPDeviceRTL(const Driver &D,
const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
@@ -1658,32 +1685,31 @@
   // First check whether user specifies bc library
   if (const Arg *A = DriverArgs.getLastArg(LibomptargetBCPathOpt)) {
 std::string LibOmpTargetName(A->getValue());
-if (llvm::sys::fs::exists(LibOmpTargetName)) {
-  CC1Args.push_back("-mlink-builtin-bitcode");
-  CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetName));
-} else {
+if (!tryAppendBuiltinBitcode(DriverArgs, CC1Args, LibOmpTargetName)) {
   D.Diag(diag::err_drv_omp_offload_target_bcruntime_not_found)
   << LibOmpTargetName;
 }
   } else {
 bool FoundBCLibrary = false;
 
-std::string LibOmpTargetName =
-"libomptarget-" + BitcodeSuffix.str() + ".bc";
-
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
+llvm::Twine LibOmpTargetName = "libomptarget-" + BitcodeSuffix + ".bc";
+llvm::Twine FallbackTargetName =
+"libomptarget-" + ArchPrefix + "-unknown.bc";
+
+FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+LibraryPaths, DriverArgs, CC1Args, LibOmpTargetName);
+
+if (!FoundBCLibrary) {
+  FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+  LibraryPaths, DriverArgs, CC1Args, FallbackTargetName);
+  if (FoundBCLibrary) {
+D.Diag(diag::warn_drv_omp_offload_target_missingbcruntime)
+<< LibOmpTargetName.str() << FallbackTargetName.str() << 
ArchPrefix;
   }
 }
 
 if (!FoundBCLibrary)
   D.Diag(diag::err_drv_omp_offload_target_missingbcruntime)
-  << LibOmpTargetName << ArchPrefix;
+  << LibOmpTargetName.str() << ArchPrefix;
   }
 }
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -262,6 +262,7 @@
   "The option -fopenmp-targets must be used in conjunction with a -fopenmp 
option compatible with offloading, please use -fopenmp=libomp or 
-fopenmp=libiomp5.">;
 def err_drv_omp_offload_target_missingbcruntime : Error<
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH, using '%1' 
instead. Please use --libomptarget-%2-bc-path to specify %2 bitcode library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;
 def warn_drv_omp_offload_target_duplicate : Warning<
   "The OpenMP offloading target '%0' is similar to target '%1' already 
specified - will be ignored.">,


Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1628,6 +1628,33 @@
   }
 }
 
+namespace {
+bool tryAppendBuiltinBitcode(const llvm:

[PATCH] D96789: [OpenCL] Move printf declaration to opencl-c-base.h

2021-02-17 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!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96789

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


[PATCH] D96344: [flang][driver] Add options for -fdefault* and -flarge-sizes

2021-02-17 Thread Tim Keith via Phabricator via cfe-commits
tskeith added inline comments.



Comment at: flang/lib/Frontend/CompilerInvocation.cpp:254
+  if (args.hasArg(clang::driver::options::OPT_fdefault_real_8))
+res.defaultKinds().set_defaultRealKind(8);
+  if (args.hasArg(clang::driver::options::OPT_fdefault_integer_8)) {

awarzynski wrote:
> arnamoy10 wrote:
> > awarzynski wrote:
> > > From `gfortran` [[ 
> > > https://gcc.gnu.org/onlinedocs/gfortran/Fortran-Dialect-Options.html | 
> > > documentation ]]:
> > > 
> > > ```
> > > This option promotes the default width of DOUBLE PRECISION and double 
> > > real constants like 1.d0 to 16 bytes if possible.
> > > ```
> > > 
> > > So I believe that you are missing:
> > > ```
> > > res.defaultKinds().set_doublePrecisionKind(16);
> > > ```
> > I thought it is not necessary because `doublePrecisionKind` is 
> > automatically initialized to double the size of `defaultRealKind_` in [[ 
> > https://github.com/llvm/llvm-project/blob/adfd3c7083f9808d145239153c10f72eece485d8/flang/include/flang/Common/default-kinds.h#L51-L58
> >  | here ]]--> `int doublePrecisionKind_{2 * defaultRealKind_};`. 
> > 
> > 
> Yes, but the default value for `defaultRealKind_` is 4 and here you are 
> setting it to 8. So, correct me if I'm wrong, but when the driver is here, 
> the following has happened:
> ```
> int defaultIntegerKind_{4};
> int defaultRealKind_{defaultIntegerKind_};
> int doublePrecisionKind_{2 * defaultRealKind_};
> ```
> So `dublePrecisionKind_` is 8 rather than 16.
You can test these are working correctly by compiling a module like this:
```
module m
  implicit none
  real :: x
  double precision :: y
  integer, parameter :: real_kind = kind(x)
  integer, parameter :: double_kind = kind(y)
end
```
Then check for `double_kind=8_4` (or whatever) in the generated `.mod` file.

For `-flarge-sizes`:
```
  real :: z(10)
  integer, parameter :: size_kind = kind(ubound(z, 1))
```


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

https://reviews.llvm.org/D96344

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1695
 
-std::string LibOmpTargetName =
-"libomptarget-" + BitcodeSuffix.str() + ".bc";
-
-for (StringRef LibraryPath : LibraryPaths) {
-  SmallString<128> LibOmpTargetFile(LibraryPath);
-  llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-  if (llvm::sys::fs::exists(LibOmpTargetFile)) {
-CC1Args.push_back("-mlink-builtin-bitcode");
-CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
-FoundBCLibrary = true;
-break;
+llvm::Twine LibOmpTargetName = "libomptarget-" + BitcodeSuffix + ".bc";
+llvm::Twine FallbackTargetName =

If you're using `Twine`, `+` is not needed.
```
llvm::Twine LibOmpTargetName("libomptarget-", BitcodeSuffix ,".bc");
```



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1697
+llvm::Twine FallbackTargetName =
+"libomptarget-" + ArchPrefix + "-unknown.bc";
+

The `BitcodeSuffix` for NVPTX consists of three parts: `nvptx`, `cuda_xxx`, and 
`sm_yy`. We might want to have an unknown for every `sm`?



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1699-1700
+
+FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
+LibraryPaths, DriverArgs, CC1Args, LibOmpTargetName);
+

```
bool FoundBCLibrary = tryAppendBuiltinBitcodeGivenPaths(
LibraryPaths, DriverArgs, CC1Args, LibOmpTargetName);
```
Remove the definition above?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


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

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

@jhenderson
I'm using 
`cmake -GNinja ../llvm -DLLVM_LIT_ARGS=-sv -DLLVM_ENABLE_PROJECTS=clang 
-DLLVM_TARGETS_TO_BUILD=X86 -DCMAKE_BUILD_TYPE=Release 
-DLLVM_ENABLE_ASSERTIONS=ON`
for setup and `ninja` for build. Here is my CMakeCache.txt config file. 
F15567363: CMakeCache.txt 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95246

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


[PATCH] D96864: [flang][driver] Add -Xflang and make -test-io a frontend-only flag

2021-02-17 Thread Sourabh Singh Tomar via Phabricator via cfe-commits
SouraVX added inline comments.



Comment at: flang/test/Frontend/input-output-file.f90:6
 !--
+! NOTE: We need `-E` below in order to instruct the compiler driver to create 
a job representing a fronted compiler invocation
 ! TEST 1: Print to stdout (implicit)

awarzynski wrote:
> SouraVX wrote:
> > I didn't follow this completely, Could you please elaborate a bit.
> Sorry, I'm doing a poor job documenting this here.
> 
> Basically, we want to instruct `flang-new` to stop after the preprocessing 
> phase. `-E` is a phase control flag. `-c` is another phase control flag. You 
> can also skip phase flags all together:
> ```
> $ bin/flang-new -ccc-print-phases file.f90
> +- 0: input, "file.f90", f95-cpp-input
>  +- 1: preprocessor, {0}, f95
>   +- 2: compiler, {1}, ir
>+- 3: backend, {2}, assembler
> +- 4: assembler, {3}, object
> 5: linker, {4}, image
> ```
> As you can see, without `-E` the driver, `flang-new`, would attempt to run 
> multiple phases which would result in multiple compiler _jobs_. But we only 
> want the compiler job, i.e. we are only interested the the first phase. 
> (IIRC, compiler jobs map 1-1 to compiler phases).
> 
> So, `-E` is added here to make sure that `flang-new` doesn't try to do too 
> much here.
Great - thanks for explaining the intent!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96864

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


[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-17 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman updated this revision to Diff 324352.
FarisRehman marked an inline comment as done.
FarisRehman added a comment.

Make semantics_ private

Make semantics_ in PrescanAndSemaAction private, adding semantics() and 
setSemantics().

Summary of changes:

- Add semantics() and setSemantics() to PrescanAndSemaAction
- Update tests to use `-fsyntax-only` but specify it first so that the new 
driver ignores it as only the last action option is executed. f18 will still 
run as if `-fsyntax-only` is present.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

Files:
  clang/include/clang/Driver/Options.td
  flang/include/flang/Frontend/FrontendActions.h
  flang/include/flang/Frontend/FrontendOptions.h
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  flang/test/Flang-Driver/debug-provenance.f90
  flang/test/Flang-Driver/driver-help.f90
  flang/test/Semantics/data05.f90
  flang/test/Semantics/data08.f90
  flang/test/Semantics/data09.f90
  flang/test/Semantics/offsets01.f90
  flang/test/Semantics/offsets02.f90
  flang/test/Semantics/offsets03.f90
  flang/test/Semantics/resolve100.f90
  flang/test/Semantics/rewrite01.f90

Index: flang/test/Semantics/rewrite01.f90
===
--- flang/test/Semantics/rewrite01.f90
+++ flang/test/Semantics/rewrite01.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-parse-tree %s 2>&1 | FileCheck %s
 ! Ensure that READ(CVAR) [, item-list] is corrected when CVAR is a
 ! character variable so as to be a formatted read from the default
 ! unit, not an unformatted read from an internal unit (which is not
Index: flang/test/Semantics/resolve100.f90
===
--- flang/test/Semantics/resolve100.f90
+++ flang/test/Semantics/resolve100.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s | FileCheck %s
 
 program p
   ! CHECK: a size=4 offset=0: ObjectEntity type: LOGICAL(4)
Index: flang/test/Semantics/offsets03.f90
===
--- flang/test/Semantics/offsets03.f90
+++ flang/test/Semantics/offsets03.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment with EQUIVALENCE and COMMON
 
Index: flang/test/Semantics/offsets02.f90
===
--- flang/test/Semantics/offsets02.f90
+++ flang/test/Semantics/offsets02.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment of derived types
 
Index: flang/test/Semantics/offsets01.f90
===
--- flang/test/Semantics/offsets01.f90
+++ flang/test/Semantics/offsets01.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s | FileCheck %s
 
 ! Size and alignment of intrinsic types
 subroutine s1
Index: flang/test/Semantics/data09.f90
===
--- flang/test/Semantics/data09.f90
+++ flang/test/Semantics/data09.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fsyntax-only -fdebug-dump-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 ! CHECK: init:[INTEGER(4)::1065353216_4,1073741824_4,1077936128_4,1082130432_4]
 ! Verify that the closure of EQUIVALENCE'd symbols with any DATA
 ! initialization produces a combined initializer.
Index: flang/test/Semantics/data08.f90
===
--- flang/test/Semantics/data08.f90
+++ flang/test/Semantics/data08.f90
@@ -1,4 +1,4 @@
-! RUN: %f18 -fdebug-dump-symbols %s 2>&1 | FileCheck %s
+! RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s 2>&1 | FileCheck %s
 ! CHECK: DATA statement value initializes 'jx' of type 'INTEGER(4)' with CHARACTER
 ! CHECK: DATA statement value initializes 'jy' of type 'INTEGER(4)' with CHARACTER
 ! CHECK: DATA statement value initializes 'jz' of type 'INTEGER(4)' with CHARACTER
Index: flang/test/Semantics/data05.f90
===
--- flang/test/Semantics/data05.f90
+++ flang/test/Semantics/data05.f90
@@ -1,4 +1,4 @@
-!RUN: %f18 -fdebug-dump-symbols %s | FileCheck %s
+!RUN: %flang_fc1 -fsyntax-only -fdebug-dump-symbols %s | FileCheck %s
 module m
   interface
 integer function ifunc(n)
Index: flang/test/Flang-Driver/driver-help.f90

[PATCH] D96716: [flang][driver] Add debug dump options

2021-02-17 Thread Faris Rehman via Phabricator via cfe-commits
FarisRehman added inline comments.



Comment at: flang/include/flang/Frontend/FrontendActions.h:54
+public:
+  std::unique_ptr semantics_;
 };

FarisRehman wrote:
> awarzynski wrote:
> > Do we need to expose it? Shouldn't this be private?
> It will not compile if the variable is private as it needs to be referenced 
> in the implementation of ExecuteAction, e.g. 
> `DebugDumpParseTreeAction::ExecuteAction()`
> It will compile if set to `protected` or `public`
Updated to use a public getter and setter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96716

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


[PATCH] D92715: [Clang][RISCV] Define RISC-V V builtin types

2021-02-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D92715/new/

https://reviews.llvm.org/D92715

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


[PATCH] D96877: [libomptarget] Try a fallback devicertl if the preferred one is missing

2021-02-17 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:265
   "No library '%0' found in the default clang lib directory or in 
LIBRARY_PATH. Please use --libomptarget-%1-bc-path to specify %1 bitcode 
library.">;
+def warn_drv_omp_offload_target_missingbcruntime : Warning<"No library '%0' 
found in the default clang lib directory or in LIBRARY_PATH, using '%1' 
instead. Please use --libomptarget-%2-bc-path to specify %2 bitcode library.">;
 def err_drv_omp_offload_target_bcruntime_not_found : Error<"Bitcode library 
'%0' does not exist.">;

Besides, we might also need to tell users this bitcode library might not work 
as expected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96877

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


[PATCH] D96381: [AArch64] Adding SHA3 Intrinsics support

2021-02-17 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 324347.
rsanthir.quic added a comment.

Removed extra whitespace


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

https://reviews.llvm.org/D96381

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-neon-range-checks.c
  clang/test/CodeGen/aarch64-neon-sha3.c
  clang/utils/TableGen/NeonEmitter.cpp
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/neon-sha3.ll

Index: llvm/test/CodeGen/AArch64/neon-sha3.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/neon-sha3.ll
@@ -0,0 +1,106 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc %s -mtriple=aarch64 -mattr=+v8.3a,+sha3 -o - | FileCheck %s
+
+define <2 x i64> @test_vsha512h(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
+; CHECK-LABEL: test_vsha512h:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512h q0, q1, v2.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512h.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512h(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
+  ret <2 x i64> %vsha512h.i
+}
+
+define <2 x i64> @test_vsha512h2(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
+; CHECK-LABEL: test_vsha512h2:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512h2 q0, q1, v2.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512h2.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512h2(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
+  ret <2 x i64> %vsha512h2.i
+}
+
+define <2 x i64> @test_vsha512su0(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vsha512su0:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512su0 v0.2d, v1.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512su0.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512su0(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %vsha512su0.i
+}
+
+define <2 x i64> @test_vsha512su1(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c) {
+; CHECK-LABEL: test_vsha512su1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:sha512su1 v0.2d, v1.2d, v2.2d
+; CHECK-NEXT:ret
+entry:
+  %vsha512su1.i = tail call <2 x i64> @llvm.aarch64.crypto.sha512su1(<2 x i64> %a, <2 x i64> %b, <2 x i64> %c)
+  ret <2 x i64> %vsha512su1.i
+}
+
+define <2 x i64> @test_vrax1(<2 x i64> %a, <2 x i64> %b) {
+; CHECK-LABEL: test_vrax1:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:rax1 v0.2d, v0.2d, v1.2d
+; CHECK-NEXT:ret
+entry:
+  %vrax1.i = tail call <2 x i64> @llvm.aarch64.crypto.rax1(<2 x i64> %a, <2 x i64> %b)
+  ret <2 x i64> %vrax1.i
+}
+
+define <2 x i64> @test_vxar(<2 x i64> %a,  <2 x i64> %b) {
+; CHECK-LABEL: test_vxar:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:xar v0.2d, v0.2d, v1.2d, #1
+; CHECK-NEXT:ret
+entry:
+  %vxar.i = tail call  <2 x i64> @llvm.aarch64.crypto.xar(<2 x i64> %a, <2 x i64> %b, i64 1)
+  ret <2 x i64> %vxar.i
+}
+
+define <16 x i8> @test_bcax_8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) {
+; CHECK-LABEL: test_bcax_8:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:bcax v0.16b, v0.16b, v1.16b, v2.16b
+; CHECK-NEXT:ret
+entry:
+  %vbcax_8.i = tail call <16 x i8> @llvm.aarch64.crypto.bcaxu.v16i8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c)
+  ret <16 x i8> %vbcax_8.i
+}
+
+define <16 x i8> @test_eor3_8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c) {
+; CHECK-LABEL: test_eor3_8:
+; CHECK:   // %bb.0: // %entry
+; CHECK-NEXT:eor3 v0.16b, v0.16b, v1.16b, v2.16b
+; CHECK-NEXT:ret
+entry:
+  %veor3_8.i = tail call <16 x i8> @llvm.aarch64.crypto.eor3u.v16i8(<16 x i8> %a, <16 x i8> %b, <16 x i8> %c)
+  ret <16 x i8> %veor3_8.i
+}
+
+declare <2 x i64> @llvm.aarch64.crypto.sha512h(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.sha512h2(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.sha512su0(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.sha512su1(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.rax1(<2 x i64>, <2 x i64>)
+declare <2 x i64> @llvm.aarch64.crypto.xar(<2 x i64>, <2 x i64>, i64 immarg)
+declare <16 x i8> @llvm.aarch64.crypto.bcaxu.v16i8(<16 x i8>, <16 x i8>, <16 x i8>)
+declare <8 x i16> @llvm.aarch64.crypto.bcaxu.v8i16(<8 x i16>, <8 x i16>, <8 x i16>)
+declare <4 x i32> @llvm.aarch64.crypto.bcaxu.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.aarch64.crypto.bcaxu.v2i64(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <16 x i8> @llvm.aarch64.crypto.bcaxs.v16i8(<16 x i8>, <16 x i8>, <16 x i8>)
+declare <8 x i16> @llvm.aarch64.crypto.bcaxs.v8i16(<8 x i16>, <8 x i16>, <8 x i16>)
+declare <4 x i32> @llvm.aarch64.crypto.bcaxs.v4i32(<4 x i32>, <4 x i32>, <4 x i32>)
+declare <2 x i64> @llvm.aarch64.crypto.bcaxs.v2i64(<2 x i64>, <2 x i64>, <2 x i64>)
+declare <16 x i8> @llvm.aarch64.crypto.eor3u.v16i8(<16 x i8>,

[PATCH] D96835: [HIP] Support device sanitizer

2021-02-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/include/clang/Driver/Options.td:939
   "__cyg_profile_func_enter and __cyg_profile_func_exit">;
+def fgpu_sanitize : Flag<["-"], "fgpu-sanitize">,
+  HelpText<"Enable sanitizer for AMDGPU target.">;

We do have `BoolFOption` for `-fsomething`/`-fno-something` options. 



Comment at: clang/lib/Driver/ToolChains/HIP.cpp:117
+   false))
+TC.addHIPDeviceLibArgs(Args, LldArgs, /*UseMLinkOpt=*/false);
+

I'd pass the library prefix argument as a string, instead of a boolean flag. 
Makes it easier to tell what's going on without having to annotate it as a 
comment. 

Also, maybe consider separating "get the list of bitcode files" from "construct 
aguments for tool X for the given list of bitcode files". Right now 
`addHIPDeviceLibArgs` does both and has to plumb the `UseMLinkOpt`through 
multiple function calls. Adding the prefix argument can be done at the 
`constructLldCommand`/`addClangTargetOptions`. 


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

https://reviews.llvm.org/D96835

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


[PATCH] D96865: [Driver] Honor "-gdwarf-N" at any position for assembler sources

2021-02-17 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/debug-options-as.c:65
+// Check that -gdwarf-N can be placed before other options of the "-g" group.
+// RUN: %clang -### -c -g -gdwarf-3 -integrated-as -x assembler %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=DWARF3 %s

Nit: use the more common spelling `-fintegrated-as`

`-triple %itanium_abi_triple`

msvc windows triples ideally don't need `-dwarf-version=`, but that can be a 
separate clean-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D96865

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


  1   2   >