[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

In D81407#2080273 , @Szelethus wrote:

> > If there are multiple resource leak paths for the same stream, only one wil 
> > be reported.
>
> What is the rationale behind this? Do all leaks from the same opening 
> describe the same kind of error? Is this based on observations on a codebase?


The code was taken from `FuchsiaHandleChecker`. I do not know which approach to 
use, it may be that reporting all leak paths is better, these are really 
different problems. But I did not like getting many similar looking bug reports 
at a function that opens a file and then in various error cases stops the 
program by a "noreturn" function. At every such case a false positive resource 
leak is reported (I think it is OK to not close the file at stopping the 
program specially if there is some kind of error). Or the checker can be 
improved to find at a `checkDeadSymbols` if the program execution is stopping 
and do not report resource leak in that case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[clang] e87e55e - Make ASTFileSignature an array of 20 uint8_t instead of 5 uint32_t

2020-06-11 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2020-06-11T09:12:29+01:00
New Revision: e87e55edbc798c1c73963151f114df775b1ec460

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

LOG: Make ASTFileSignature an array of 20 uint8_t instead of 5 uint32_t

Reviewers: aprantl, dexonsmith, Bigcheese

Subscribers: arphaman, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/Module.h
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/GlobalModuleIndex.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index b14f6b59dd8c..6b932a9a84d0 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -20,9 +20,9 @@
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SetVector.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -52,12 +53,33 @@ class TargetInfo;
 using ModuleId = SmallVector, 2>;
 
 /// The signature of a module, which is a hash of the AST content.
-struct ASTFileSignature : std::array {
-  ASTFileSignature(std::array S = {{0}})
-  : std::array(std::move(S)) {}
+struct ASTFileSignature : std::array {
+  using BaseT = std::array;
+
+  static constexpr size_t size = std::tuple_size::value;
+
+  ASTFileSignature(BaseT S = {{0}}) : BaseT(std::move(S)) {}
+
+  explicit operator bool() const { return *this != BaseT({{0}}); }
+
+  static ASTFileSignature create(StringRef Bytes) {
+return create(Bytes.bytes_begin(), Bytes.bytes_end());
+  }
+
+  static ASTFileSignature createDISentinel() {
+ASTFileSignature Sentinel;
+Sentinel.fill(0xFF);
+return Sentinel;
+  }
+
+  template 
+  static ASTFileSignature create(InputIt First, InputIt Last) {
+assert(std::distance(First, Last) == size &&
+   "Wrong amount of bytes to create an ASTFileSignature");
 
-  explicit operator bool() const {
-return *this != std::array({{0}});
+ASTFileSignature Signature;
+std::copy(First, Last, Signature.begin());
+return Signature;
   }
 };
 

diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 65d513c8cf05..6965c4a1209c 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -2535,10 +2535,14 @@ llvm::DIModule 
*CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
 // PCH files don't have a signature field in the control block,
 // but LLVM detects skeleton CUs by looking for a non-zero DWO id.
 // We use the lower 64 bits for debug info.
-uint64_t Signature =
-Mod.getSignature()
-? (uint64_t)Mod.getSignature()[1] << 32 | Mod.getSignature()[0]
-: ~1ULL;
+
+uint64_t Signature = 0;
+if (const auto &ModSig = Mod.getSignature()) {
+  for (unsigned I = 0; I != sizeof(Signature); ++I)
+Signature |= (uint64_t)ModSig[I] << (I * 8);
+} else {
+  Signature = ~1ULL;
+}
 llvm::DIBuilder DIB(CGM.getModule());
 SmallString<0> PCM;
 if (!llvm::sys::path::is_absolute(Mod.getASTFile()))

diff  --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp 
b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 284e8022a3c4..0c7e5f4598f8 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -173,8 +173,8 @@ class PCHContainerGenerator : public ASTConsumer {
 // Prepare CGDebugInfo to emit debug info for a clang module.
 auto *DI = Builder->getModuleDebugInfo();
 StringRef ModuleName = llvm::sys::path::filename(MainFileName);
-DI->setPCHDescriptor({ModuleName, "", OutputFileName,
-  ASTFileSignature{{{~0U, ~0U, ~0U, ~0U, ~1U);
+DI->setPCHDescriptor(
+{ModuleName, "", OutputFileName, 
ASTFileSignature::createDISentinel()});
 DI->setModuleMap(MMap);
   }
 

diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 87987064b747..673b65d543fc 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -2791,10 +2791,10 @@ ASTReader::ReadControlBlock(ModuleFile &F,
 ReadUntranslatedSourceLocation(Record[Idx++]);
 off_t StoredSize = (off_t)Record[Idx++];

[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-06-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

After running the checker I could observe the following problems:

  time_t now = time(NULL);
  if (now > 0) { ... }

Here only `now == EOF` would be correct for the checker, so this case is 
reported (false positive). It may be better if the checker finds any "now > 
//x//" where //x// is non-negative. This can be used for any function that 
returns an integer value (not pointer) and EOF is the error return code.

  c = fgetc(fd);
  if (c == '+' || c == '*' || c == '|' || c == '>' || c == '@' || c == EOF || c 
== '\n') { ... }

The first `c == '+'` is found by the checker and reported as false positive 
(the later `c == EOF` is not found). Such a case can be found if the checker 
can collect expressions that are separated by `||` or `&&` and the symbol to 
check occurs in these and there is only a simple comparison.

The checker can find places where the return value is tested for error (mostly 
early-return cases), not where the return value is tested for a valid value 
(that may be a subset of all non-error values). And the test for error or valid 
value should be in a single statement, not in nested `if`s for example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D81347: Make ASTFileSignature an array of 20 uint8_t instead of 5 uint32_t

2020-06-11 Thread Daniel Grumberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe87e55edbc79: Make ASTFileSignature an array of 20 uint8_t 
instead of 5 uint32_t (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81347

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/GlobalModuleIndex.cpp

Index: clang/lib/Serialization/GlobalModuleIndex.cpp
===
--- clang/lib/Serialization/GlobalModuleIndex.cpp
+++ clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -643,10 +643,10 @@
 
 // Skip the stored signature.
 // FIXME: we could read the signature out of the import and validate it.
-ASTFileSignature StoredSignature = {
-{{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
-  (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
-  (uint32_t)Record[Idx++]}}};
+auto FirstSignatureByte = Record.begin() + Idx;
+ASTFileSignature StoredSignature = ASTFileSignature::create(
+FirstSignatureByte, FirstSignatureByte + ASTFileSignature::size);
+Idx += ASTFileSignature::size;
 
 // Skip the module name (currently this is only used for prebuilt
 // modules while here we are only dealing with cached).
@@ -704,9 +704,8 @@
 
 // Get Signature.
 if (State == DiagnosticOptionsBlock && Code == SIGNATURE)
-  getModuleFileInfo(File).Signature = {
-  {{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
-(uint32_t)Record[3], (uint32_t)Record[4]}}};
+  getModuleFileInfo(File).Signature = ASTFileSignature::create(
+  Record.begin(), Record.begin() + ASTFileSignature::size);
 
 // We don't care about this record.
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -1032,16 +1032,7 @@
   Hasher.update(ArrayRef(Bytes.bytes_begin(), Bytes.size()));
   auto Hash = Hasher.result();
 
-  // Convert to an array [5*i32].
-  ASTFileSignature Signature;
-  auto LShift = [&](unsigned char Val, unsigned Shift) {
-return (uint32_t)Val << Shift;
-  };
-  for (int I = 0; I != 5; ++I)
-Signature[I] = LShift(Hash[I * 4 + 0], 24) | LShift(Hash[I * 4 + 1], 16) |
-   LShift(Hash[I * 4 + 2], 8) | LShift(Hash[I * 4 + 3], 0);
-
-  return Signature;
+  return ASTFileSignature::create(Hash);
 }
 
 ASTFileSignature ASTWriter::writeUnhashedControlBlock(Preprocessor &PP,
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -2791,10 +2791,10 @@
 ReadUntranslatedSourceLocation(Record[Idx++]);
 off_t StoredSize = (off_t)Record[Idx++];
 time_t StoredModTime = (time_t)Record[Idx++];
-ASTFileSignature StoredSignature = {
-{{(uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
-  (uint32_t)Record[Idx++], (uint32_t)Record[Idx++],
-  (uint32_t)Record[Idx++]}}};
+auto FirstSignatureByte = Record.begin() + Idx;
+ASTFileSignature StoredSignature = ASTFileSignature::create(
+FirstSignatureByte, FirstSignatureByte + ASTFileSignature::size);
+Idx += ASTFileSignature::size;
 
 std::string ImportedName = ReadString(Record, Idx);
 std::string ImportedFile;
@@ -4734,7 +4734,7 @@
 switch ((UnhashedControlBlockRecordTypes)MaybeRecordType.get()) {
 case SIGNATURE:
   if (F)
-std::copy(Record.begin(), Record.end(), F->Signature.data());
+F->Signature = ASTFileSignature::create(Record.begin(), Record.end());
   break;
 case DIAGNOSTIC_OPTIONS: {
   bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
@@ -5023,8 +5023,8 @@
   return ASTFileSignature();
 }
 if (SIGNATURE == MaybeRecord.get())
-  return {{{(uint32_t)Record[0], (uint32_t)Record[1], (uint32_t)Record[2],
-(uint32_t)Record[3], (uint32_t)Record[4]}}};
+  return ASTFileSignature::create(Record.begin(),
+  Record.begin() + ASTFileSignature::size);
   }
 }
 
@@ -5322,7 +5322,9 @@
   unsigned Idx = 0, N = Record.size();
   while (Idx < N) {
 // Read information about the AST file.
-Idx += 1+1+1+1+5; // Kind, ImportLoc, Size, ModTime, Signature
+Idx +=
+1 + 1 + 1 + 1 +
+ASTFileSignature::size; // Kind, ImportLoc, Size, ModTime, Signature
 std::string ModuleName = ReadString(Record, Idx);

[PATCH] D81567: [analyzer] SATest: Introduce a single entrypoint for regression scripts

2020-06-11 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 270059.
vsavchenko added a comment.

Change script modes as the shouldn't be used as executables now


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81567

Files:
  clang/utils/analyzer/CmpRuns.py
  clang/utils/analyzer/SATest.py
  clang/utils/analyzer/SATestAdd.py
  clang/utils/analyzer/SATestBuild.py
  clang/utils/analyzer/SATestUpdateDiffs.py

Index: clang/utils/analyzer/SATestBuild.py
===
--- clang/utils/analyzer/SATestBuild.py
+++ clang/utils/analyzer/SATestBuild.py
@@ -46,7 +46,6 @@
 import SATestUtils
 from ProjectMap import DownloadType, ProjectInfo, ProjectMap
 
-import argparse
 import glob
 import logging
 import math
@@ -635,7 +634,6 @@
the canonical ones.
 :param failure_flag: Used to signify a failure during the run.
 """
-self.args = args
 self.tasks_queue = tasks_queue
 self.results_differ = results_differ
 self.failure_flag = failure_flag
@@ -883,37 +881,6 @@
 
 
 if __name__ == "__main__":
-# Parse command line arguments.
-parser = argparse.ArgumentParser(
-description="Test the Clang Static Analyzer.")
-
-parser.add_argument("--strictness", dest="strictness", type=int, default=0,
-help="0 to fail on runtime errors, 1 to fail when the "
-"number of found bugs are different from the "
-"reference, 2 to fail on any difference from the "
-"reference. Default is 0.")
-parser.add_argument("-r", dest="regenerate", action="store_true",
-default=False, help="Regenerate reference output.")
-parser.add_argument("--override-compiler", action="store_true",
-default=False, help="Call scan-build with "
-"--override-compiler option.")
-parser.add_argument("-j", "--jobs", dest="jobs", type=int,
-default=0,
-help="Number of projects to test concurrently")
-parser.add_argument("--extra-analyzer-config",
-dest="extra_analyzer_config", type=str,
-default="",
-help="Arguments passed to to -analyzer-config")
-parser.add_argument("-v", "--verbose", action="count", default=0)
-
-args = parser.parse_args()
-
-VERBOSE = args.verbose
-tester = RegressionTester(args.jobs, args.override_compiler,
-  args.extra_analyzer_config, args.regenerate,
-  args.strictness)
-tests_passed = tester.test_all()
-
-if not tests_passed:
-stderr("ERROR: Tests failed.")
-sys.exit(42)
+print("SATestBuild.py should not be used on its own.")
+print("Please use 'SATest.py build' instead")
+sys.exit(1)
Index: clang/utils/analyzer/SATestAdd.py
===
--- clang/utils/analyzer/SATestAdd.py
+++ clang/utils/analyzer/SATestAdd.py
@@ -45,7 +45,6 @@
 import SATestBuild
 from ProjectMap import ProjectMap, ProjectInfo
 
-import argparse
 import os
 import sys
 
@@ -85,41 +84,7 @@
for existing_project in project_map.projects)
 
 
-# TODO: Add an option not to build.
-# TODO: Set the path to the Repository directory.
 if __name__ == "__main__":
-parser = argparse.ArgumentParser()
-
-parser.add_argument("name", nargs=1, help="Name of the new project")
-parser.add_argument("--mode", action="store", default=1, type=int,
-choices=[0, 1, 2],
-help="Build mode: 0 for single file project, "
-"1 for scan_build, "
-"2 for single file c++11 project")
-parser.add_argument("--source", action="store", default="script",
-choices=["script", "git", "zip"],
-help=f"Source type of the new project: "
-f"'git' for getting from git "
-f"(please provide --origin and --commit), "
-f"'zip' for unpacking source from a zip file, "
-f"'script' for downloading source by running "
-f"a custom script {SATestBuild.DOWNLOAD_SCRIPT}")
-parser.add_argument("--origin", action="store", default="",
-help="Origin link for a git repository")
-parser.add_argument("--commit", action="store", default="",
-help="Git hash for a commit to checkout")
-
-args = parser.parse_args()
-
-if args.source == "git" and (args.origin == "" or args.commit == ""):
-parser.error(
-"Please provide both --origin and --commit if source is 'git'")
-
-if args.source != "git" and (args.origin != "" or args.c

[clang] 5cc1851 - [analyzer] On-demand parsing capability for CTU

2020-06-11 Thread Endre Fülöp via cfe-commits

Author: Endre Fülöp
Date: 2020-06-11T10:56:59+02:00
New Revision: 5cc18516c4839fccc64b54eaa5aa447a8e1ed8fa

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

LOG: [analyzer] On-demand parsing capability for CTU

Summary:
Introduce on-demand parsing of needed ASTs during CTU analysis.
The index-file format is extended, and analyzer-option CTUInvocationList
is added to specify the exact invocations needed to parse the needed
source-files.

Reviewers: martong, balazske, Szelethus, xazax.hun, whisperity

Reviewed By: martong, xazax.hun

Subscribers: gribozavr2, thakis, ASDenysPetrov, ormris, mgorny, whisperity, 
xazax.hun, baloghadamsoftware, szepet, rnkovacs, a.sidorin, mikhail.ramalho, 
Szelethus, donat.nagy, dkrupp, Charusso, steakhal, cfe-commits

Tags: #clang

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

Added: 
clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
clang/test/Analysis/ctu-on-demand-parsing.c
clang/test/Analysis/ctu-on-demand-parsing.cpp

Modified: 
clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.def
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/test/Analysis/Inputs/ctu-other.c
clang/test/Analysis/analyzer-config.c
clang/test/Analysis/ctu-different-triples.cpp
clang/test/Analysis/ctu-main.c
clang/test/Analysis/ctu-main.cpp
clang/test/Analysis/ctu-unknown-parts-in-triples.cpp
clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Removed: 
clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.txt
clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.txt



diff  --git a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst 
b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
index 86f972b63e31..36be82f209ef 100644
--- a/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
+++ b/clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
@@ -3,14 +3,35 @@ Cross Translation Unit (CTU) Analysis
 =
 
 Normally, static analysis works in the boundary of one translation unit (TU).
-However, with additional steps and configuration we can enable the analysis to 
inline the definition of a function from another TU.
+However, with additional steps and configuration we can enable the analysis to 
inline the definition of a function from
+another TU.
 
 .. contents::
:local:
 
-Manual CTU Analysis

+Overview
+
+CTU analysis can be used in a variety of ways. The importing of external TU 
definitions can work with pre-dumped PCH
+files or generating the necessary AST structure on-demand, during the analysis 
of the main TU. Driving the static
+analysis can also be implemented in multiple ways. The most direct way is to 
specify the necessary commandline options
+of the Clang frontend manually (and generate the prerequisite dependencies of 
the specific import method by hand). This
+process can be automated by other tools, like `CodeChecker 
`_ and scan-build-py
+(preference for the former).
+
+PCH-based analysis
+__
+The analysis needs the PCH dumps of all the translations units used in the 
project.
+These can be generated by the Clang Frontend itself, and must be arranged in a 
specific way in the filesystem.
+The index, which maps symbols' USR names to PCH dumps containing them must 
also be generated by the
+`clang-extdef-mapping`. Entries in the index *must* have an `.ast` suffix if 
the goal
+is to use PCH-based analysis, as the lack of that extension signals that the 
entry is to be used as a source-file, and parsed on-demand.
+This tool uses a :doc:`compilation database <../../JSONCompilationDatabase>` to
+determine the compilation flags used.
+The analysis invocation must be provided with the directory which contains the 
dumps and the mapping files.
+
 
+Manual CTU Analysis
+###
 Let's consider these source files in our minimal example:
 
 .. code-block:: cpp
@@ -47,7 +68,8 @@ And a compilation database:
   ]
 
 We'd like to analyze `main.cpp` and discover the division by zero bug.
-In order to be able to inline the definition of `foo` from `foo.cpp` first we 
have to generate the `AST` (or `PCH`) file of `foo.cpp`:
+In order to be able to inline the definition of `foo` from `foo.cpp` first we 
have to generate the `AST` (or `PCH`) file
+of `foo.cpp`:
 
 .. code-block:: bash
 
@@ -58,7 +80,8 @@ In order to be able to inline the definition of `foo` from 
`foo.cpp` first we ha
   compile_commands.json  foo.cpp.ast  foo.cpp  main.cpp
   $
 
-The next step is to create

[clang] afa42e4 - [NFC] Make formatting changes to ASTBitCodes.h ahead of a functional change

2020-06-11 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2020-06-11T10:25:04+01:00
New Revision: afa42e4c9253ca111fdcb6238a0da34129475911

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

LOG: [NFC] Make formatting changes to ASTBitCodes.h ahead of a functional change

Added: 


Modified: 
clang/include/clang/Serialization/ASTBitCodes.h

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index a98d12645985..54d3e6ab8917 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -30,84 +30,84 @@
 namespace clang {
 namespace serialization {
 
-/// AST file major version number supported by this version of
-/// Clang.
-///
-/// Whenever the AST file format changes in a way that makes it
-/// incompatible with previous versions (such that a reader
-/// designed for the previous version could not support reading
-/// the new version), this number should be increased.
-///
-/// Version 4 of AST files also requires that the version control branch 
and
-/// revision match exactly, since there is no backward compatibility of
-/// AST files at this time.
-const unsigned VERSION_MAJOR = 10;
-
-/// AST file minor version number supported by this version of
-/// Clang.
-///
-/// Whenever the AST format changes in a way that is still
-/// compatible with previous versions (such that a reader designed
-/// for the previous version could still support reading the new
-/// version by ignoring new kinds of subblocks), this number
-/// should be increased.
-const unsigned VERSION_MINOR = 0;
-
-/// An ID number that refers to an identifier in an AST file.
-///
-/// The ID numbers of identifiers are consecutive (in order of discovery)
-/// and start at 1. 0 is reserved for NULL.
-using IdentifierID = uint32_t;
-
-/// An ID number that refers to a declaration in an AST file.
-///
-/// The ID numbers of declarations are consecutive (in order of
-/// discovery), with values below NUM_PREDEF_DECL_IDS being reserved.
-/// At the start of a chain of precompiled headers, declaration ID 1 is
-/// used for the translation unit declaration.
-using DeclID = uint32_t;
-
-// FIXME: Turn these into classes so we can have some type safety when
-// we go from local ID to global and vice-versa.
-using LocalDeclID = DeclID;
-using GlobalDeclID = DeclID;
-
-/// An ID number that refers to a type in an AST file.
-///
-/// The ID of a type is partitioned into two parts: the lower
-/// three bits are used to store the const/volatile/restrict
-/// qualifiers (as with QualType) and the upper bits provide a
-/// type index. The type index values are partitioned into two
-/// sets. The values below NUM_PREDEF_TYPE_IDs are predefined type
-/// IDs (based on the PREDEF_TYPE_*_ID constants), with 0 as a
-/// placeholder for "no type". Values from NUM_PREDEF_TYPE_IDs are
-/// other types that have serialized representations.
-using TypeID = uint32_t;
-
-/// A type index; the type ID with the qualifier bits removed.
-class TypeIdx {
-  uint32_t Idx = 0;
-
-public:
-  TypeIdx() = default;
-  explicit TypeIdx(uint32_t index) : Idx(index) {}
-
-  uint32_t getIndex() const { return Idx; }
-
-  TypeID asTypeID(unsigned FastQuals) const {
-if (Idx == uint32_t(-1))
-  return TypeID(-1);
-
-return (Idx << Qualifiers::FastWidth) | FastQuals;
-  }
-
-  static TypeIdx fromTypeID(TypeID ID) {
-if (ID == TypeID(-1))
-  return TypeIdx(-1);
-
-return TypeIdx(ID >> Qualifiers::FastWidth);
-  }
-};
+/// AST file major version number supported by this version of
+/// Clang.
+///
+/// Whenever the AST file format changes in a way that makes it
+/// incompatible with previous versions (such that a reader
+/// designed for the previous version could not support reading
+/// the new version), this number should be increased.
+///
+/// Version 4 of AST files also requires that the version control branch and
+/// revision match exactly, since there is no backward compatibility of
+/// AST files at this time.
+const unsigned VERSION_MAJOR = 10;
+
+/// AST file minor version number supported by this version of
+/// Clang.
+///
+/// Whenever the AST format changes in a way that is still
+/// compatible with previous versions (such that a reader designed
+/// for the previous version could still support reading the new
+/// version by ignoring new kinds of subblocks), this number
+/// should be increased.
+const unsigned VERSION_MINOR = 0;
+
+/// An ID number that re

[PATCH] D75665: [analyzer] On-demand parsing capability for CTU

2020-06-11 Thread Endre Fülöp via Phabricator via cfe-commits
gamesh411 added a comment.

In D75665#2084889 , @thakis wrote:

> This breaks check-clang on mac: http://45.33.8.238/mac/15258/step_7.txt
>
> Please take a look, and revert for now if it takes a while to fix.


Thanks for reporting this, i think the output is valuable for debugging. I have 
restricted the test case to linux for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75665



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


[PATCH] D78477: [profile] Don't crash when forking in several threads

2020-06-11 Thread Diana Picus via Phabricator via cfe-commits
rovka added a comment.

Ping!
https://bugs.llvm.org/show_bug.cgi?id=46092


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78477



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


[PATCH] D81474: Handle delayed-template-parsing functions imported into a non-dtp TU

2020-06-11 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.

Looking at this some more, it looks like whenever clang is building a TU 
prefix(preamble), the assumption is that any delayed templates will be parsed 
at the end of the TU. That is unfortunately not true, if the rest of the TU is 
built with no-delayed-template-parsing. (as you've already said in the 
description)

This suggests that DelayedTemplateParsing shouldn't be a benign langopt. But 
since it is, we should be setting late template parser at the end of TU if 
there are any delayed templates coming from either the preamble or in the rest 
of the TU.
The latter is already done by checking for langopt, we can check for the former 
using `Actions.ExternalSemaSource`. But in the absence of delayed templates, 
setting the parser is (currently) a no-op. So setting it all the time should 
hopefully be OK.
Hence LGTM.

Another option would be to change preamble building logic to parse all the late 
parsed templates at the end, instead of just serializing the tokens. That 
sounds like a more intrusive change though, so I am more comfortable with 
current one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81474



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


[PATCH] D80383: Add AST_SIGNATURE record to unhashed control block of PCM files

2020-06-11 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 270077.
dang marked 3 inline comments as done.
dang added a comment.

Rebase on top of latest master that has needed NFC changes to calm down 
clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80383

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/ASTSignature.c
  clang/test/Modules/Inputs/ASTHash/module.modulemap
  clang/test/Modules/Inputs/ASTHash/my_header_1.h
  clang/test/Modules/Inputs/ASTHash/my_header_2.h

Index: clang/test/Modules/Inputs/ASTHash/my_header_2.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/my_header_2.h
@@ -0,0 +1,3 @@
+#include "my_header_1.h"
+
+extern my_int var;
Index: clang/test/Modules/Inputs/ASTHash/my_header_1.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/my_header_1.h
@@ -0,0 +1 @@
+typedef int my_int;
Index: clang/test/Modules/Inputs/ASTHash/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/module.modulemap
@@ -0,0 +1,8 @@
+module MyHeader1 {
+  header "my_header_1.h"
+}
+
+module MyHeader2 {
+  header "my_header_2.h"
+  export *
+}
Index: clang/test/Modules/ASTSignature.c
===
--- /dev/null
+++ clang/test/Modules/ASTSignature.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -iquote %S/Inputs/ASTHash/ -fsyntax-only -fmodules \
+// RUN:   -fimplicit-module-maps -fmodules-strict-context-hash \
+// RUN:   -fmodules-cache-path=%t -fdisable-module-hash %s
+// RUN: cp %t/MyHeader2.pcm %t1.pcm
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -iquote "/dev/null" -iquote %S/Inputs/ASTHash/ -fsyntax-only \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-strict-context-hash \
+// RUN:   -fmodules-cache-path=%t -fdisable-module-hash %s
+// RUN: cp %t/MyHeader2.pcm %t2.pcm
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t1.pcm > %t1.dump
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t2.pcm > %t2.dump
+// RUN: cat %t1.dump %t2.dump | FileCheck %s
+
+#include "my_header_2.h"
+
+my_int var = 42;
+
+// CHECK: [[AST_BLOCK_HASH:]]
+// CHECK: [[SIGNATURE:]]
+// CHECK: [[AST_BLOCK_HASH]]
+// CHECK-NOT: [[SIGNATURE]]
+// The modules built by this test are designed to yield the same AST. If this
+// test fails, it means that the AST block is has become non-relocatable.
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2432,12 +2432,12 @@
   SourceLocation Loc = D->getLocation();
   unsigned Index = ID - FirstDeclID;
   if (DeclOffsets.size() == Index)
-DeclOffsets.emplace_back(Loc, Offset);
+DeclOffsets.emplace_back(Loc, Offset, DeclTypesBlockStartOffset);
   else if (DeclOffsets.size() < Index) {
 // FIXME: Can/should this happen?
 DeclOffsets.resize(Index+1);
 DeclOffsets[Index].setLocation(Loc);
-DeclOffsets[Index].setBitOffset(Offset);
+DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
   } else {
 llvm_unreachable("declarations should be emitted in ID order");
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -10,14 +10,12 @@
 //
 //===--===//
 
-#include "clang/AST/OpenMPClause.h"
-#include "clang/Serialization/ASTRecordWriter.h"
 #include "ASTCommon.h"
 #include "ASTReaderInternals.h"
 #include "MultiOnDiskHashTable.h"
-#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
+#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -31,6 +29,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -65,7 +64,9 @@
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
+#include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTReader.h"
+#include "clang/Serialization/ASTRecordWriter

[PATCH] D81642: [analyzer] CmpRuns.py: Fix error due to statistics differences

2020-06-11 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko created this revision.
vsavchenko added reviewers: NoQ, dcoughlin.
Herald added subscribers: cfe-commits, ASDenysPetrov, Charusso, dkrupp, 
donat.nagy, Szelethus, mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, 
xazax.hun.
Herald added a project: clang.
vsavchenko added a parent revision: D80517: [analyzer] CmpRuns.py: Refactor and 
add type annotations.
vsavchenko added a child revision: D81563: [analyzer] SATest: Move from csv to 
json project maps.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81642

Files:
  clang/utils/analyzer/CmpRuns.py


Index: clang/utils/analyzer/CmpRuns.py
===
--- clang/utils/analyzer/CmpRuns.py
+++ clang/utils/analyzer/CmpRuns.py
@@ -398,16 +398,18 @@
 stats_old = derive_stats(results_old)
 stats_new = derive_stats(results_new)
 
-keys = sorted(stats_old.keys())
+old_keys = set(stats_old.keys())
+new_keys = set(stats_new.keys())
+keys = sorted(old_keys & new_keys)
 
-# FIXME: stats_old and stats_new are not necessarily sharing all of their
-#stats and can crash when stats_new doesn't have/removed some
 for key in keys:
 print(key)
 
-for kkey in stats_old[key]:
-val_old = float(stats_old[key][kkey])
-val_new = float(stats_new[key][kkey])
+nested_keys = sorted(set(stats_old[key]) & set(stats_new[key]))
+
+for nested_key in nested_keys:
+val_old = float(stats_old[key][nested_key])
+val_new = float(stats_new[key][nested_key])
 
 report = f"{val_old:.3f} -> {val_new:.3f}"
 
@@ -420,7 +422,17 @@
 elif ratio > 0.2:
 report = Colors.RED + report + Colors.CLEAR
 
-print(f"\t {kkey} {report}")
+print(f"\t {nested_key} {report}")
+
+removed_keys = old_keys - new_keys
+if removed_keys:
+print(f"REMOVED statistics: {removed_keys}")
+
+added_keys = new_keys - old_keys
+if added_keys:
+print(f"ADDED statistics: {added_keys}")
+
+print()
 
 
 def dump_scan_build_results_diff(dir_old: str, dir_new: str,


Index: clang/utils/analyzer/CmpRuns.py
===
--- clang/utils/analyzer/CmpRuns.py
+++ clang/utils/analyzer/CmpRuns.py
@@ -398,16 +398,18 @@
 stats_old = derive_stats(results_old)
 stats_new = derive_stats(results_new)
 
-keys = sorted(stats_old.keys())
+old_keys = set(stats_old.keys())
+new_keys = set(stats_new.keys())
+keys = sorted(old_keys & new_keys)
 
-# FIXME: stats_old and stats_new are not necessarily sharing all of their
-#stats and can crash when stats_new doesn't have/removed some
 for key in keys:
 print(key)
 
-for kkey in stats_old[key]:
-val_old = float(stats_old[key][kkey])
-val_new = float(stats_new[key][kkey])
+nested_keys = sorted(set(stats_old[key]) & set(stats_new[key]))
+
+for nested_key in nested_keys:
+val_old = float(stats_old[key][nested_key])
+val_new = float(stats_new[key][nested_key])
 
 report = f"{val_old:.3f} -> {val_new:.3f}"
 
@@ -420,7 +422,17 @@
 elif ratio > 0.2:
 report = Colors.RED + report + Colors.CLEAR
 
-print(f"\t {kkey} {report}")
+print(f"\t {nested_key} {report}")
+
+removed_keys = old_keys - new_keys
+if removed_keys:
+print(f"REMOVED statistics: {removed_keys}")
+
+added_keys = new_keys - old_keys
+if added_keys:
+print(f"ADDED statistics: {added_keys}")
+
+print()
 
 
 def dump_scan_build_results_diff(dir_old: str, dir_new: str,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81169: [clangd] Improve hover on arguments to function call

2020-06-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet marked an inline comment as done.
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:695
+   const PrintingPolicy &Policy) {
+  if (!N)
+return;

nit: this is already checked before entering the function.



Comment at: clang-tools-extra/clangd/Hover.cpp:871
+  if (CalleeArgInfo) {
+Output.addRuler();
+std::string Buffer;

I know you are planning to make more changes on how we render this, but let's 
not forget to drop the ruler in here.



Comment at: clang-tools-extra/clangd/Hover.cpp:717
+  if (const FunctionDecl *FD = CE->getDirectCallee()) {
+if (FD->isOverloadedOperator() || FD->isVariadic() ||
+FD->getNumParams() <= I)

adamcz wrote:
> kadircet wrote:
> > i can see the reason for variadics, but why bail out on overloaded 
> > operators? also can we have some tests for these two?
> I could totally see us supporting variadic, I'm just not sure how useful that 
> will be, so I didn't do it right away.
> 
> As for the operators, I don't think we should trigger on those. There are two 
> cases:
> - things that do not look like a function call: operator+, operator<<, etc. 
> When you hover over a variable it's not immediately obvious what the "passed 
> to" would be referring to. Something like:
> foo(a+b);
> if I see "a passed as const int&" I might think this is about passing it to 
> foo() (at least of first glance).
> At the same time, the value of this is very low for operators. You know what 
> their signature is already.
> 
> -operator() - this is much more like a function call. Maybe it would make 
> sense to support it. It gets tricky with matching CallExpr args to FD params 
> though. I'll leave a todo for now and worry about this in a separate change, 
> if don't mind.jj
ok makes sense, you are definitely right about nested case, I wasn't thinking 
about it.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:728
+C c;
+c.fun([[^a]], b);
+  }

adamcz wrote:
> kadircet wrote:
> > can you also add a test for a literal ?
> Currently there is no hover at all for literals. The reason was that it 
> wouldn't be useful. This information, however, might be, especially in cases 
> like:
> printThis(that, true, false, true);
> knowing what these refer to could be useful.
> 
> Do you think this is good enough reason to enable hover on literals, with 
> just this information? I'm thinking yes, but I'm not sure.
you are right, i remember carving the codepath for handling literals but forgot 
that we've disabled them at the time because there wasn't much info we could 
surface. I believe this one is a pretty good candidate (assuming LSP doesn't 
get "inline parameter annotations").

But definitely doesn't need to be handled in this patch, feel free to update 
the fixme on `getHoverContents(Expr ...)` though, saying we might want to 
surface callee information.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81169



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a subscriber: ABataev.
Fznamznon added a comment.

@jdoerfert , @ABataev , if OpenMP needs same diagnostic as well, I can 
generalize it between SYCL and OpenMP.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added subscribers: cfe-commits, sstefan1, Anastasia, ebevhan, yaxunl.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.
Fznamznon added reviewers: erichkeane, bader.
Fznamznon added a subscriber: ABataev.
Fznamznon added a comment.

@jdoerfert , @ABataev , if OpenMP needs same diagnostic as well, I can 
generalize it between SYCL and OpenMP.


The SYCL spec prohibits thread local storage in device code,
so this commit ensures an error is emitted for device code and not
emitted for host code when host target supports it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81641

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp

Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+template 
+__attribute__((sycl_kernel))
+// expected-note@+2 2{{called by}}
+void
+kernel_single_task(Func kernelFunc) { kernelFunc(); }
+
+int main() {
+  // expected-note@+1 2{{called by}}
+  kernel_single_task([]() { usage(); });
+  return 0;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -212,6 +212,11 @@
  bool ObjCPropertyAccess,
  bool AvoidPartialAvailabilityChecks,
  ObjCInterfaceDecl *ClassReceiver) {
+  if (getLangOpts().SYCLIsDevice)
+if (auto VD = dyn_cast(D))
+  if (VD->getTLSKind() != VarDecl::TLS_None)
+SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_thread_unsupported);
+
   SourceLocation Loc = Locs.front();
   if (getLangOpts().CPlusPlus && isa(D)) {
 // If there were any diagnostics suppressed by template argument deduction,
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7077,7 +7077,8 @@
diag::err_thread_non_global)
 << DeclSpec::getSpecifierName(TSCS);
 else if (!Context.getTargetInfo().isTLSSupported()) {
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 // Postpone error emission until we've collected attributes required to
 // figure out whether it's a host or device variable and whether the
 // error should be ignored.
@@ -7179,13 +7180,17 @@
   // Handle attributes prior to checking for duplicates in MergeVarDecl
   ProcessDeclAttributes(S, NewVD, D);
 
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 if (EmitTLSUnsupportedError &&
 ((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) ||
  (getLangOpts().OpenMPIsDevice &&
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD
   Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
+
+if (EmitTLSUnsupportedError && getLangOpts().SYCLIsDevice)
+  SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_thread_unsupported);
 // CUDA B.2.5: "__shared__ and __constant__ variables have implied static
 // storage [duration]."
 if (SC == SC_None && S->getFnParent() != nullptr &&
___
cfe-commits mailing list
cfe-commits@lists.

[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a reviewer: xazax.hun.
Szelethus added a comment.
Herald added a subscriber: rnkovacs.

Alright, I'm sold. How about we add a checker option for it? I don't actually 
insist, just an idea. @xazax.hun, how has this feature played out?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:394
 
+const ExplodedNode *StreamChecker::getAcquireSite(const ExplodedNode *N,
+  SymbolRef Sym,

How about `getAcquisitionSite`, and a line of comment:
> Searches for the `ExplodedNode` where the file descriptor was acquired for 
> `Sym`.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:398-399
+  ProgramStateRef State = N->getState();
+  // When bug type is resource leak, exploded node N may not have state info
+  // for leaked file descriptor, but predecessor should have it.
+  if (!State->get(Sym))

I see what you mean, but I'd phrase this differently, and place it...

>Resource leaks can result in multiple warning that describe the same kind of 
>programming error:
>```
>void f() {
>  FILE *F = fopen("a.txt");
>  if (rand()) // state split
>return; // warning
>} // warning
>```
>While this isn't necessarily true (leaking the same stream could result from a 
>different kinds of errors), the reduction in redundant reports makes this a 
>worthwhile heuristic.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:961
 
-C.emitReport(std::make_unique(
-BT_ResourceLeak, BT_ResourceLeak.getDescription(), N));
+;
+const ExplodedNode *AcquireNode = getAcquireSite(N, Sym, C);

...here!



Comment at: clang/test/Analysis/stream-note.c:1
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store 
region -analyzer-output text -verify %s
+

`core` package! Also, we don't specify `-analyzer-store region` explicitly, we 
even wondered whether we should just remove the option altogether. Fun fact, 
`clang_analyze_cc1` actually expands to an invocation that contains it anyways.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[clang] 0418005 - [clang][NFC] Various NFCs in CheckDefaultArgumentVisitor

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T12:19:45+01:00
New Revision: 0418005c0e2f280f0cdab9ad7b5a1a7bd03d9c10

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

LOG: [clang][NFC] Various NFCs in CheckDefaultArgumentVisitor

Before the next patches do the following NFCs:
  - Make it a const visitor; CheckDefaultArgumentVisitor should
really not modify the visited nodes.

  - clang-format

  - Take a reference to Sema instead of a pointer and pass it
as the first argument to the constructor. This is for
consistency with the other similar visitors.

  - Use range for loops when appropriate as per the style guide.

  - Use `const auto *" when appropriate as per the style guide.

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 26a5e129efdf..e33df2527d2c 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -52,102 +52,100 @@ using namespace clang;
 
//===--===//
 
 namespace {
-  /// CheckDefaultArgumentVisitor - C++ [dcl.fct.default] Traverses
-  /// the default argument of a parameter to determine whether it
-  /// contains any ill-formed subexpressions. For example, this will
-  /// diagnose the use of local variables or parameters within the
-  /// default argument expression.
-  class CheckDefaultArgumentVisitor
-: public StmtVisitor {
-Expr *DefaultArg;
-Sema *S;
-
-  public:
-CheckDefaultArgumentVisitor(Expr *defarg, Sema *s)
-: DefaultArg(defarg), S(s) {}
-
-bool VisitExpr(Expr *Node);
-bool VisitDeclRefExpr(DeclRefExpr *DRE);
-bool VisitCXXThisExpr(CXXThisExpr *ThisE);
-bool VisitLambdaExpr(LambdaExpr *Lambda);
-bool VisitPseudoObjectExpr(PseudoObjectExpr *POE);
-  };
-
-  /// VisitExpr - Visit all of the children of this expression.
-  bool CheckDefaultArgumentVisitor::VisitExpr(Expr *Node) {
-bool IsInvalid = false;
-for (Stmt *SubStmt : Node->children())
-  IsInvalid |= Visit(SubStmt);
-return IsInvalid;
-  }
-
-  /// VisitDeclRefExpr - Visit a reference to a declaration, to
-  /// determine whether this declaration can be used in the default
-  /// argument expression.
-  bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(DeclRefExpr *DRE) {
-NamedDecl *Decl = DRE->getDecl();
-if (ParmVarDecl *Param = dyn_cast(Decl)) {
-  // C++ [dcl.fct.default]p9
-  //   Default arguments are evaluated each time the function is
-  //   called. The order of evaluation of function arguments is
-  //   unspecified. Consequently, parameters of a function shall not
-  //   be used in default argument expressions, even if they are not
-  //   evaluated. Parameters of a function declared before a default
-  //   argument expression are in scope and can hide namespace and
-  //   class member names.
-  return S->Diag(DRE->getBeginLoc(),
- diag::err_param_default_argument_references_param)
- << Param->getDeclName() << DefaultArg->getSourceRange();
-} else if (VarDecl *VDecl = dyn_cast(Decl)) {
-  // C++ [dcl.fct.default]p7
-  //   Local variables shall not be used in default argument
-  //   expressions.
-  if (VDecl->isLocalVarDecl())
-return S->Diag(DRE->getBeginLoc(),
-   diag::err_param_default_argument_references_local)
-   << VDecl->getDeclName() << DefaultArg->getSourceRange();
-}
+/// CheckDefaultArgumentVisitor - C++ [dcl.fct.default] Traverses
+/// the default argument of a parameter to determine whether it
+/// contains any ill-formed subexpressions. For example, this will
+/// diagnose the use of local variables or parameters within the
+/// default argument expression.
+class CheckDefaultArgumentVisitor
+: public ConstStmtVisitor {
+  Sema &S;
+  const Expr *DefaultArg;
 
-return false;
-  }
+public:
+  CheckDefaultArgumentVisitor(Sema &S, const Expr *DefaultArg)
+  : S(S), DefaultArg(DefaultArg) {}
+
+  bool VisitExpr(const Expr *Node);
+  bool VisitDeclRefExpr(const DeclRefExpr *DRE);
+  bool VisitCXXThisExpr(const CXXThisExpr *ThisE);
+  bool VisitLambdaExpr(const LambdaExpr *Lambda);
+  bool VisitPseudoObjectExpr(const PseudoObjectExpr *POE);
+};
 
-  /// VisitCXXThisExpr - Visit a C++ "this" expression.
-  bool CheckDefaultArgumentVisitor::VisitCXXThisExpr(CXXThisExpr *ThisE) {
-// C++ [dcl.fct.default]p8:
-//   The keyword this shall not be used in a default argument of a
-//   member function.
-return S->Diag(ThisE->getBeginLoc(),
-   diag::err_param_default_argument_references_this)
-   << ThisE->getSourceRange();
+/// V

[clang] 5951ff4 - [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T12:41:08+01:00
New Revision: 5951ff4512332fff9d191da8661143a883d3b8aa

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

LOG: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local 
variables in default arguments.

This patch implements the resolution of CWG 2082 and CWG 2346.

The resolution of CWG 2082 changed [dcl.fct.default]p7 and p9 to allow
a parameter or local variable to appear in a default argument if not
in a potentially-evaluated expression.

The resolution of CWG 2346 changed [dcl.fct.default]p7 to allow a local
variable to appear in a default argument if not odr-used.

An issue remains after this patch
(see the FIXME in test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp).
This is addressed by the next patch.

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

Reviewed By: rsmith, erichkeane

Added: 
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp

Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
clang/test/CXX/drs/dr20xx.cpp
clang/test/CXX/drs/dr23xx.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index e33df2527d2c..28a84d27c038 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -87,22 +87,31 @@ bool CheckDefaultArgumentVisitor::VisitExpr(const Expr 
*Node) {
 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(const DeclRefExpr *DRE) {
   const NamedDecl *Decl = DRE->getDecl();
   if (const auto *Param = dyn_cast(Decl)) {
-// C++ [dcl.fct.default]p9
-//   Default arguments are evaluated each time the function is
-//   called. The order of evaluation of function arguments is
-//   unspecified. Consequently, parameters of a function shall not
-//   be used in default argument expressions, even if they are not
-//   evaluated. Parameters of a function declared before a default
-//   argument expression are in scope and can hide namespace and
-//   class member names.
-return S.Diag(DRE->getBeginLoc(),
-  diag::err_param_default_argument_references_param)
-   << Param->getDeclName() << DefaultArg->getSourceRange();
+// C++ [dcl.fct.default]p9:
+//   [...] parameters of a function shall not be used in default
+//   argument expressions, even if they are not evaluated. [...]
+//
+// C++17 [dcl.fct.default]p9 (by CWG 2082):
+//   [...] A parameter shall not appear as a potentially-evaluated
+//   expression in a default argument. [...]
+//
+if (DRE->isNonOdrUse() != NOUR_Unevaluated)
+  return S.Diag(DRE->getBeginLoc(),
+diag::err_param_default_argument_references_param)
+ << Param->getDeclName() << DefaultArg->getSourceRange();
   } else if (const auto *VDecl = dyn_cast(Decl)) {
-// C++ [dcl.fct.default]p7
+// C++ [dcl.fct.default]p7:
 //   Local variables shall not be used in default argument
 //   expressions.
-if (VDecl->isLocalVarDecl())
+//
+// C++17 [dcl.fct.default]p7 (by CWG 2082):
+//   A local variable shall not appear as a potentially-evaluated
+//   expression in a default argument.
+//
+// C++20 [dcl.fct.default]p7 (DR as part of P0588R1, see also CWG 2346):
+//   Note: A local variable cannot be odr-used (6.3) in a default argument.
+//
+if (VDecl->isLocalVarDecl() && !DRE->isNonOdrUse())
   return S.Diag(DRE->getBeginLoc(),
 diag::err_param_default_argument_references_local)
  << VDecl->getDeclName() << DefaultArg->getSourceRange();

diff  --git a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp 
b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
index 164eb3682f31..07b527bbdc20 100644
--- a/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ b/clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,7 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-void h()
-{
-  int i;
-  extern void h2(int x = sizeof(i)); // expected-error {{default argument 
references local variable 'i' of enclosing function}}
+void h() {
+  int i1 = 0;
+  extern void h1(int x = i1);
+  // expected-error@-1 {{default argument references local variable 'i1' of 
enclosing function}}
+
+  const int i2 = 0;
+  extern void h2a(int x = i2); // FIXME: ok, not odr-use
+  // expected-error@-1 {{default argument references local variable 'i2' of 
enclosing function}}
+  extern void h2b(int x = i2 + 0); // ok, not odr-use
+
+  const int i3 = 0;
+  extern void h3(const int *x = &i3);
+  // expected-error@-1 {{default argument references local variabl

cfe-commits@lists.llvm.org

2020-06-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij added inline comments.



Comment at: llvm/test/CodeGen/AArch64/aarch64-bf16-ldst-intrinsics.ll:264
+; Function Attrs: argmemonly nounwind readonly
+declare { <8 x bfloat>, <8 x bfloat> } 
@llvm.aarch64.neon.ld2lane.v8bf16.p0i8(<8 x bfloat>, <8 x bfloat>, i64, i8*) #3
+

chill wrote:
> SjoerdMeijer wrote:
> > chill wrote:
> > > SjoerdMeijer wrote:
> > > > chill wrote:
> > > > > LukeGeeson wrote:
> > > > > > SjoerdMeijer wrote:
> > > > > > > LukeGeeson wrote:
> > > > > > > > arsenm wrote:
> > > > > > > > > Why is the IR type name bfloat and not bfloat16?
> > > > > > > > The naming for the IR type was agreed upon here after quite a 
> > > > > > > > big discussion. 
> > > > > > > > https://reviews.llvm.org/D78190
> > > > > > > I regret very much that I didn't notice this earlier... I.e., I 
> > > > > > > noticed this in D76077 and wrote that I am relatively unhappy 
> > > > > > > about this (I think I mentioned this on another ticket too).
> > > > > > > Because like @arsenm , I would expect the IR type name to be 
> > > > > > > bfloat16.
> > > > > > > 
> > > > > > > Correct me if I am wrong, but I don't see a big discussion about 
> > > > > > > this in D78190. I only see 1 or 2 comments about `BFloat` vs 
> > > > > > > `Bfloat`.
> > > > > > I cannot see a discussion about the IR type name per-se but I can 
> > > > > > see you were both involved in the discussion more generally.
> > > > > > 
> > > > > > I am concerned that this patch is the wrong place to discuss such 
> > > > > > issues, and that we should bring this up in a more appropriate 
> > > > > > place as you mention so that this patch isn't held back.
> > > > > I don't see a compelling reason for the name to be `bfloat16` or 
> > > > > `bfloat3`, etc. Like other floating-point types (`float`, `double`, 
> > > > > and `half`), the name denotes a specific externally defined format, 
> > > > > unlike `iN`.
> > > > > Like other floating-point types (float, double, and half), the name 
> > > > > denotes a specific externally defined format, 
> > > > 
> > > > Is the defined format not called bfloat16?
> > > Indeed, people use the name "bfloat16". But then the `half`, `float`, and 
> > > `double` also differ from the official `binary16`, `binarty32`, and 
> > > `binary64`.
> > > IMHO `bfloat` fits better in the LLVM IR naming convention.
> > yeah, so that's exactly why I don't follow your logic. If there's any logic 
> > in the names here, the mapping from source-language type to IR type seems 
> > the most plausible one. And I just don't see the benefit of dropping the 
> > 16, and how that would fit better in some naming scheme or how that makes 
> > things clearer here.
> What source language?
> 
> That said, I'm resigning from the bikeshedding here.
Just as a house-keeping note: If we would change the naming, I think we can all 
agree that this ticket itself shouldn't be the place where we want to do this. 
I'm happy for the conversation to carry on here, but I think we can move the 
ticket forward at the same time.



Comment at: llvm/test/CodeGen/AArch64/aarch64-bf16-ldst-intrinsics.ll:916
+
+attributes #0 = { norecurse nounwind readonly 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="none" "less-precise-fpmad"="false" 
"min-legal-vector-width"="64" "no-infs-fp-math"="false" 
"no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+neon" 
"unsafe-fp-math"="false" "use-soft-float"="false" }
+attributes #1 = { norecurse nounwind readonly 
"correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" 
"frame-pointer"="none" "less-precise-fpmad"="false" 
"min-legal-vector-width"="128" "no-infs-fp-math"="false" 
"no-jump-tables"="false" "no-nans-fp-math"="false" 
"no-signed-zeros-fp-math"="false" "no-trapping-math"="false" 
"stack-protector-buffer-size"="8" "target-features"="+bf16,+neon" 
"unsafe-fp-math"="false" "use-soft-float"="false" }

You should be able to do without all these big blocks of attributes which I 
guess were generated from C -> IR conversion. Just remove it and the `#x`s 
after the function declarations (maybe replace them with `nounwind`).


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

https://reviews.llvm.org/D80716



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


[PATCH] D81615: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno updated this revision to Diff 270100.
riccibruno marked an inline comment as done.
riccibruno added a comment.

Add the example in `clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp` 
as requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81615

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
  clang/test/CXX/drs/dr20xx.cpp
  clang/test/CXX/drs/dr23xx.cpp

Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -4,6 +4,13 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 
+namespace dr2346 { // dr2346: 11
+  void test() {
+const int i2 = 0;
+extern void h2b(int x = i2 + 0); // ok, not odr-use
+  }
+}
+
 namespace dr2352 { // dr2352: 10
   int **p;
   const int *const *const &f1() { return p; }
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -49,6 +49,13 @@
   }
 }
 
+namespace dr2082 { // dr2082: 11
+  void test1(int x, int = sizeof(x)); // ok
+#if __cplusplus >= 201103L
+  void test2(int x, int = decltype(x){}); // ok
+#endif
+}
+
 namespace dr2083 { // dr2083: partial
 #if __cplusplus >= 201103L
   void non_const_mem_ptr() {
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void h() {
+  void f1(int x, int y = sizeof(x));  // ok
+  void f2(int x, int y = decltype(x)());  // ok
+  void f3(int x, int y = x);
+  // expected-error@-1 {{default argument references parameter 'x'}}
+  void f4(int x, int y = x + 0);
+  // expected-error@-1 {{default argument references parameter 'x'}}
+  void f5(int x, int y = ((void)x, 0));
+  // expected-error@-1 {{default argument references parameter 'x'}}
+}
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 class A { 
   void f(A* p = this) { }	// expected-error{{invalid use of 'this'}}
+
+  void test();
 };
+
+void A::test() {
+  void g(int = this); // expected-error {{default argument references 'this'}}
+}
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,7 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-void h()
-{
-  int i;
-  extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
+void h() {
+  int i1 = 0;
+  extern void h1(int x = i1);
+  // expected-error@-1 {{default argument references local variable 'i1' of enclosing function}}
+
+  const int i2 = 0;
+  extern void h2a(int x = i2); // FIXME: ok, not odr-use
+  // expected-error@-1 {{default argument references local variable 'i2' of enclosing function}}
+  extern void h2b(int x = i2 + 0); // ok, not odr-use
+
+  const int i3 = 0;
+  extern void h3(const int *x = &i3);
+  // expected-error@-1 {{default argument references local variable 'i3' of enclosing function}}
+
+  const int i4 = 0;
+  extern void h4(int x = sizeof(i4)); // ok, not odr-use
+  extern void h5(int x = decltype(i4 + 4)()); // ok, not odr-use
 }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -87,22 +87,31 @@
 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(const DeclRefExpr *DRE) {
   const NamedDecl *Decl = DRE->getDecl();
   if (const auto *Param = dyn_cast(Decl)) {
-// C++ [dcl.fct.default]p9
-//   Default arguments are evaluated each time the function is
-//   called. The order of evaluation of function arguments is
-//   unspecified. Consequently, parameters of a function shall not
-//   be used in default argument expressions, even if they are not
-//   evaluated. Parameters of a function declared before a default
-//   argument expression are in scope and can hide namespace and
-//   

[PATCH] D81455: [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits enumerations from TokenKinds.def...

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

LGTM, your choice on hiding in TokenKinds.def.




Comment at: clang/lib/Basic/ExpressionTraits.cpp:29-34
+  assert(T <= ET_Last && "invalid enum value!");
+  return ExpressionTraitNames[T];
+}
+
+const char *clang::getTraitSpelling(ExpressionTrait T) {
+  assert(T <= ET_Last && "invalid enum value!");

riccibruno wrote:
> aaron.ballman wrote:
> > Isn't `ET_Last` -1?
> Nope :) It's `-1` plus 1 per element in the enumeration. I have added the 
> enumerators `ET_Last`, `ATT_Last` and `UETT_Last` for consistency with 
> `UTT_Last`, `BTT_Last` and `TT_Last` which are needed.
> 
> In this patch `ET_Last`, `ATT_Last` and `UETT_Last` are only used here in 
> this assertion and could be replaced by the equivalent `T < XX_Last` where 
> `XX_Last` is just added as the last element in the enumeration. However 
> mixing `XX_Last = XX_LastElement` and `XX_Last = LastElement + 1` would be 
> very error-prone.
Oh! I see now what's going on and that's clever; I was misunderstanding the 
second macro usage (which makes me wonder if it would make more sense to hide 
the `Last` fields at the bottom of TokenKinds.def rather than use the current 
approach, but I don't insist). Thank you for the clarification.



Comment at: clang/lib/Sema/SemaExpr.cpp:3974
 S.Diag(Loc, diag::ext_sizeof_alignof_function_type)
-  << TraitKind << ArgRange;
+<< getTraitSpelling(TraitKind) << ArgRange;
 return false;

riccibruno wrote:
> aaron.ballman wrote:
> > I think the original code was a bit more clear; would it make sense to make 
> > the diagnostic engine aware of trait kinds so that it does this dance for 
> > you? (It may be overkill given that we don't pass `UnaryExprOrTypeTrait` 
> > objects to the diagnostic engine THAT often, but I'm curious what you 
> > think.)
> I don't think it is worthwhile since as you say `UnaryExprOrTypeTrait` 
> objects are not frequently passed to the diagnostic engine.
> 
> Moreover I personally finds the explicit `getTraitSpelling(TraitKind)` 
> clearer for two reasons:
> 1. Frequently a non-class enumerator is used as an index to a `select` in a 
> diagnostic, relying on the implicit integer conversion.  Special casing 
> `UnaryExprOrTypeTrait` would be surprising.
> 
> 2. (weaker) `<< TraitKind` could mean something else than the trait's 
> spelling; for example this could print the trait's name or some user-visible 
> version thereof.
Sold! Thank you. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81455



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


[PATCH] D81615: [clang] CWG 2082 and 2346: loosen the restrictions on parameters and local variables in default arguments.

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5951ff451233: [clang] CWG 2082 and 2346: loosen the 
restrictions on parameters and local… (authored by riccibruno).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81615

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
  clang/test/CXX/drs/dr20xx.cpp
  clang/test/CXX/drs/dr23xx.cpp

Index: clang/test/CXX/drs/dr23xx.cpp
===
--- clang/test/CXX/drs/dr23xx.cpp
+++ clang/test/CXX/drs/dr23xx.cpp
@@ -4,6 +4,13 @@
 // RUN: %clang_cc1 -std=c++17 %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 // RUN: %clang_cc1 -std=c++2a %s -verify -fexceptions -fcxx-exceptions -pedantic-errors 2>&1 | FileCheck %s
 
+namespace dr2346 { // dr2346: 11
+  void test() {
+const int i2 = 0;
+extern void h2b(int x = i2 + 0); // ok, not odr-use
+  }
+}
+
 namespace dr2352 { // dr2352: 10
   int **p;
   const int *const *const &f1() { return p; }
Index: clang/test/CXX/drs/dr20xx.cpp
===
--- clang/test/CXX/drs/dr20xx.cpp
+++ clang/test/CXX/drs/dr20xx.cpp
@@ -49,6 +49,13 @@
   }
 }
 
+namespace dr2082 { // dr2082: 11
+  void test1(int x, int = sizeof(x)); // ok
+#if __cplusplus >= 201103L
+  void test2(int x, int = decltype(x){}); // ok
+#endif
+}
+
 namespace dr2083 { // dr2083: partial
 #if __cplusplus >= 201103L
   void non_const_mem_ptr() {
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p9.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void h() {
+  void f1(int x, int y = sizeof(x));  // ok
+  void f2(int x, int y = decltype(x)());  // ok
+  void f3(int x, int y = x);
+  // expected-error@-1 {{default argument references parameter 'x'}}
+  void f4(int x, int y = x + 0);
+  // expected-error@-1 {{default argument references parameter 'x'}}
+  void f5(int x, int y = ((void)x, 0));
+  // expected-error@-1 {{default argument references parameter 'x'}}
+}
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -1,4 +1,10 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 class A { 
   void f(A* p = this) { }	// expected-error{{invalid use of 'this'}}
+
+  void test();
 };
+
+void A::test() {
+  void g(int = this); // expected-error {{default argument references 'this'}}
+}
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -1,7 +1,20 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
 
-void h()
-{
-  int i;
-  extern void h2(int x = sizeof(i)); // expected-error {{default argument references local variable 'i' of enclosing function}}
+void h() {
+  int i1 = 0;
+  extern void h1(int x = i1);
+  // expected-error@-1 {{default argument references local variable 'i1' of enclosing function}}
+
+  const int i2 = 0;
+  extern void h2a(int x = i2); // FIXME: ok, not odr-use
+  // expected-error@-1 {{default argument references local variable 'i2' of enclosing function}}
+  extern void h2b(int x = i2 + 0); // ok, not odr-use
+
+  const int i3 = 0;
+  extern void h3(const int *x = &i3);
+  // expected-error@-1 {{default argument references local variable 'i3' of enclosing function}}
+
+  const int i4 = 0;
+  extern void h4(int x = sizeof(i4)); // ok, not odr-use
+  extern void h5(int x = decltype(i4 + 4)()); // ok, not odr-use
 }
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -87,22 +87,31 @@
 bool CheckDefaultArgumentVisitor::VisitDeclRefExpr(const DeclRefExpr *DRE) {
   const NamedDecl *Decl = DRE->getDecl();
   if (const auto *Param = dyn_cast(Decl)) {
-// C++ [dcl.fct.default]p9
-//   Default arguments are evaluated each time the function is
-//   called. The order of evaluation of function arguments is
-//   unspecified. Consequently, parameters of a function shall not
-//   be used in default argument expressions, even if they are not
-//   evaluated. Parameters of a function declared before a default
-//   argument expression are in scope and can hide namespace and
-//   class mem

[clang] 40ea01f - [clang] Convert a default argument expression to the parameter type...

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T13:18:45+01:00
New Revision: 40ea01f6543d0d4aa2701d1b27a6c5413340e7d5

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

LOG: [clang] Convert a default argument expression to the parameter type...

...before checking that the default argument is valid with
CheckDefaultArgumentVisitor.

Currently the restrictions on a default argument are checked with the visitor
CheckDefaultArgumentVisitor in ActOnParamDefaultArgument before
performing the conversion to the parameter type in SetParamDefaultArgument.

This was fine before the previous patch but now some valid code post-CWG 2346
is rejected:

void test() {
  const int i2 = 0;
  extern void h2a(int x = i2); // FIXME: ok, not odr-use
  extern void h2b(int x = i2 + 0); // ok, not odr-use
}

This is because the reference to i2 in h2a has not been marked yet with
NOUR_Constant. i2 is marked NOUR_Constant when the conversion to the parameter
type is done, which is done just after.

The solution is to do the conversion to the parameter type before checking
the restrictions on default arguments with CheckDefaultArgumentVisitor.
This has the side-benefit of improving some diagnostics.

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

Reviewed By: rsmith

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
clang/test/SemaCXX/vartemplate-lambda.cpp
clang/test/SemaTemplate/instantiate-local-class.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 6f074fb941af..3416f339768f 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2381,11 +2381,13 @@ class Sema final {
   void ActOnParamDefaultArgument(Decl *param,
  SourceLocation EqualLoc,
  Expr *defarg);
-  void ActOnParamUnparsedDefaultArgument(Decl *param,
- SourceLocation EqualLoc,
+  void ActOnParamUnparsedDefaultArgument(Decl *param, SourceLocation EqualLoc,
  SourceLocation ArgLoc);
   void ActOnParamDefaultArgumentError(Decl *param, SourceLocation EqualLoc);
-  bool SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
+  ExprResult ConvertParamDefaultArgument(const ParmVarDecl *Param,
+ Expr *DefaultArg,
+ SourceLocation EqualLoc);
+  void SetParamDefaultArgument(ParmVarDecl *Param, Expr *DefaultArg,
SourceLocation EqualLoc);
 
   // Contexts where using non-trivial C union types can be disallowed. This is

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 28a84d27c038..a77f7a460242 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -254,14 +254,12 @@ void 
Sema::ImplicitExceptionSpecification::CalledStmt(Stmt *S) {
 ComputedEST = EST_None;
 }
 
-bool
-Sema::SetParamDefaultArgument(ParmVarDecl *Param, Expr *Arg,
-  SourceLocation EqualLoc) {
+ExprResult Sema::ConvertParamDefaultArgument(const ParmVarDecl *Param,
+ Expr *Arg,
+ SourceLocation EqualLoc) {
   if (RequireCompleteType(Param->getLocation(), Param->getType(),
-  diag::err_typecheck_decl_incomplete_type)) {
-Param->setInvalidDecl();
+  diag::err_typecheck_decl_incomplete_type))
 return true;
-  }
 
   // C++ [dcl.fct.default]p5
   //   A default argument expression is implicitly converted (clause
@@ -282,7 +280,12 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, Expr 
*Arg,
   CheckCompletedExpr(Arg, EqualLoc);
   Arg = MaybeCreateExprWithCleanups(Arg);
 
-  // Okay: add the default argument to the parameter
+  return Arg;
+}
+
+void Sema::SetParamDefaultArgument(ParmVarDecl *Param, Expr *Arg,
+   SourceLocation EqualLoc) {
+  // Add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
   // We have already instantiated this parameter; provide each of the
@@ -296,8 +299,6 @@ Sema::SetParamDefaultArgument(ParmVarDecl *Param, Expr *Arg,
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-
-  return false;
 }
 
 /// ActOnParamDefaultArgument - Check whether the default argument
@@ -341,13 +342,18 @@ Sema::ActOnParamDefaultArgument(Decl *param, 
SourceLocation EqualLoc

[PATCH] D81455: [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits enumerations from TokenKinds.def...

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno marked 6 inline comments as done.
riccibruno added a comment.

In D81455#2087286 , @aaron.ballman 
wrote:

> LGTM, your choice on hiding in TokenKinds.def.




> Oh! I see now what's going on and that's clever; I was misunderstanding the 
> second macro usage (which makes me wonder if it would make more sense to hide 
> the Last fields at the bottom of TokenKinds.def rather than use the current 
> approach, but I don't insist). Thank you for the clarification.

Ah, I admit I was grinning for a few minutes when I came up with this :) Yay 
for macros... I think I will leave the `XX_Last`s in the enumeration since they 
are not really a trait but a structural feature of the enumerations. I will 
however add a comment next to each `XX_Last` explaining this trick.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81455



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-06-11 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko I've compiled some performance stats using //csa-testbench//. The 
result are within the margin of error.

| Project| Before  | After   | Delta  |
| libWebM| 0:00:32 | 0:00:34 | 6,25%  |
| Memcached  | 0:00:25 | 0:00:26 | 4,00%  |
| OpenSSL| 0:05:03 | 0:04:56 | -2,31% |
| PostgreSQL | 0:09:55 | 0:09:24 | -5,21% |
| protobuf   | 0:07:07 | 0:06:53 | -3,28% |
| Redis  | 0:02:50 | 0:02:59 | 5,29%  |
| SQLite | 0:08:24 | 0:08:48 | 4,76%  |
| TinyXML2   | 0:00:15 | 0:00:18 | 20,00% |
| TMUX   | 0:01:20 | 0:01:30 | 12,50% |
| twin   | 0:00:54 | 0:00:57 | 5,56%  |
| Vim| 0:03:36 | 0:03:46 | 4,63%  |
| Xerces | 0:04:41 | 0:05:01 | 7,12%  |
| TOTAL  | 0:45:02 | 0:45:32 | 1,11%  |


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

https://reviews.llvm.org/D78933



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


[PATCH] D81616: [clang] Convert a default argument expression to the parameter type before checking that the default argument is valid with CheckDefaultArgumentVisitor.

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG40ea01f6543d: [clang] Convert a default argument expression 
to the parameter type... (authored by riccibruno).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81616

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
  clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
  clang/test/SemaCXX/vartemplate-lambda.cpp
  clang/test/SemaTemplate/instantiate-local-class.cpp

Index: clang/test/SemaTemplate/instantiate-local-class.cpp
===
--- clang/test/SemaTemplate/instantiate-local-class.cpp
+++ clang/test/SemaTemplate/instantiate-local-class.cpp
@@ -462,18 +462,15 @@
 struct Inner { // expected-note {{in instantiation}}
   void operator()(T a = "") {} // expected-error {{conversion function from 'const char [1]' to 'rdar23721638::A' invokes a deleted function}}
   // expected-note@-1 {{passing argument to parameter 'a' here}}
-  // expected-note@-2 {{candidate function not viable}}
 };
-Inner()(); // expected-error {{no matching function}}
+Inner()(); // expected-error {{type 'Inner' does not provide a call operator}}
   }
   template void foo(); // expected-note 2 {{in instantiation}}
 
   template  void bar() {
 auto lambda = [](T a = "") {}; // expected-error {{conversion function from 'const char [1]' to 'rdar23721638::A' invokes a deleted function}}
   // expected-note@-1 {{passing argument to parameter 'a' here}}
-  // expected-note@-2 {{candidate function not viable}}
-  // expected-note@-3 {{conversion candidate of type}}
-lambda(); // expected-error {{no matching function}}
+lambda();
   }
   template void bar(); // expected-note {{in instantiation}}
 }
@@ -494,9 +491,6 @@
   void f(int x = [](T x = nullptr) -> int { return x; }());
   // expected-error@-1 {{cannot initialize a parameter of type 'int' with an rvalue of type 'nullptr_t'}}
   // expected-note@-2 {{passing argument to parameter 'x' here}}
-  // expected-error@-3 {{no matching function for call}}
-  // expected-note@-4 {{candidate function not viable: requires single argument 'x', but no arguments were provided}}
-  // expected-note@-5 {{conversion candidate of type 'auto (*)(int) -> int'}}
 
   void g() { f(); }
   // expected-note@-1 {{in instantiation of default function argument expression for 'f' required here}}
Index: clang/test/SemaCXX/vartemplate-lambda.cpp
===
--- clang/test/SemaCXX/vartemplate-lambda.cpp
+++ clang/test/SemaCXX/vartemplate-lambda.cpp
@@ -6,10 +6,7 @@
 template auto fn1 = [](auto a) { return a + T(1); };
 template auto v1 = [](int a = T()) { return a; }();
 // expected-error@-1{{cannot initialize a parameter of type 'int' with an rvalue of type 'int *'}}
-// expected-error@-2{{no matching function for call}}
-// expected-note@-3{{passing argument to parameter 'a' here}}
-// expected-note@-4{{candidate function not viable}}
-// expected-note@-5{{conversion candidate of type 'int (*)(int)'}}
+// expected-note@-2{{passing argument to parameter 'a' here}}
 
 struct S {
   template
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p8.cpp
@@ -6,5 +6,10 @@
 };
 
 void A::test() {
-  void g(int = this); // expected-error {{default argument references 'this'}}
+  void g(int = this);
+  // expected-error@-1 {{cannot initialize a parameter of type 'int' with an rvalue of type 'A *'}}
+  // expected-note@-2 {{passing argument to parameter here}}
+
+  void h(int = ((void)this,42));
+  // expected-error@-1 {{default argument references 'this'}}
 }
Index: clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
===
--- clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
+++ clang/test/CXX/dcl.decl/dcl.meaning/dcl.fct.default/p7.cpp
@@ -6,8 +6,7 @@
   // expected-error@-1 {{default argument references local variable 'i1' of enclosing function}}
 
   const int i2 = 0;
-  extern void h2a(int x = i2); // FIXME: ok, not odr-use
-  // expected-error@-1 {{default argument references local variable 'i2' of enclosing function}}
+  extern void h2a(int x = i2); // ok, not odr-use
   extern void h2b(int x = i2 + 0); // ok, not odr-use
 
   const int i3 = 0;
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2405,7 +2405,12

[clang] acb8922 - [clang][NFC] Fix a Wdocumentation warning in Basic/TargetInfo.h

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T13:30:26+01:00
New Revision: acb892233d4c51579c350ad632a1f391ba13bac2

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

LOG: [clang][NFC] Fix a Wdocumentation warning in Basic/TargetInfo.h

Added: 


Modified: 
clang/include/clang/Basic/TargetInfo.h

Removed: 




diff  --git a/clang/include/clang/Basic/TargetInfo.h 
b/clang/include/clang/Basic/TargetInfo.h
index b1a4017b4c76..140f55ff66b1 100644
--- a/clang/include/clang/Basic/TargetInfo.h
+++ b/clang/include/clang/Basic/TargetInfo.h
@@ -1326,7 +1326,7 @@ class TargetInfo : public virtual TransferrableTargetInfo,
 return LangAS::Default;
   }
 
-  /// Return a target-specific GPU grid value based on the GVIDX enum \param gv
+  /// Return a target-specific GPU grid value based on the GVIDX enum \p gv
   unsigned getGridValue(llvm::omp::GVIDX gv) const {
 assert(GridValues != nullptr && "GridValues not initialized");
 return GridValues[gv];



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


[clang] f529c0a - Fix unused variable warning. NFCI.

2020-06-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-06-11T13:48:42+01:00
New Revision: f529c0a8a149ce6d027400a12a1637eda19e03b5

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

LOG: Fix unused variable warning. NFCI.

We're only using the D2 iteration value inside the assert (the only component 
of the loop) - move the entire loop inside the assert by using llvm::all_of.

Added: 


Modified: 
clang/unittests/StaticAnalyzer/ParamRegionTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp 
b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
index 4edbeb30df1c..52789fdf5b9d 100644
--- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
@@ -19,10 +19,10 @@ class ParamRegionTestConsumer : public ExprEngineConsumer {
   void checkForSameParamRegions(MemRegionManager &MRMgr,
 const StackFrameContext *SFC,
 const ParmVarDecl *PVD) {
-for (const auto *D2: PVD->redecls()) {
-  assert(MRMgr.getVarRegion(PVD, SFC) ==
- MRMgr.getVarRegion(cast(D2), SFC));
-}
+assert(llvm::all_of(PVD->redecls(), [](const clang::VarDecl *D2) {
+  return MRMgr.getVarRegion(PVD, SFC) ==
+ MRMgr.getVarRegion(cast(D2), SFC)
+}));
   }
 
   void performTest(const Decl *D) {



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


[clang] 948b206 - Add missing lambda capture from rGf529c0a8a149.

2020-06-11 Thread Simon Pilgrim via cfe-commits

Author: Simon Pilgrim
Date: 2020-06-11T13:57:39+01:00
New Revision: 948b206fc236502caa20e51cf39b9d4d0fda00b6

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

LOG: Add missing lambda capture from rGf529c0a8a149.

Added: 


Modified: 
clang/unittests/StaticAnalyzer/ParamRegionTest.cpp

Removed: 




diff  --git a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp 
b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
index 52789fdf5b9d..7ec032a7beae 100644
--- a/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
+++ b/clang/unittests/StaticAnalyzer/ParamRegionTest.cpp
@@ -19,9 +19,9 @@ class ParamRegionTestConsumer : public ExprEngineConsumer {
   void checkForSameParamRegions(MemRegionManager &MRMgr,
 const StackFrameContext *SFC,
 const ParmVarDecl *PVD) {
-assert(llvm::all_of(PVD->redecls(), [](const clang::VarDecl *D2) {
+assert(llvm::all_of(PVD->redecls(), [&](const clang::VarDecl *D2) {
   return MRMgr.getVarRegion(PVD, SFC) ==
- MRMgr.getVarRegion(cast(D2), SFC)
+ MRMgr.getVarRegion(cast(D2), SFC);
 }));
   }
 



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


[PATCH] D78933: [analyzer] RangeConstraintManager optimizations in comparison expressions

2020-06-11 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.
This revision is now accepted and ready to land.

In D78933#2087386 , @ASDenysPetrov 
wrote:

> @vsavchenko I've compiled some performance stats using //csa-testbench//. The 
> result are within the margin of error.


Awesome! Thank you for your work!


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

https://reviews.llvm.org/D78933



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Give @ABataev and @jdoerfert a day or two to review before committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[clang] fb80e67 - [OPENMP50]Codegen for scan directive in simd loops.

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T09:01:23-04:00
New Revision: fb80e67f10eea7177b0ff9c618c8231363b6f2fc

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

LOG: [OPENMP50]Codegen for scan directive in simd loops.

Added codegen for scandirectives in simd loop. The codegen transforms
original code:

```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  
  #pragma omp scan inclusive(x)
  
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  
  x = x_priv + x;
  x_priv = x;
  
}
```
and
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  
  #pragma omp scan exclusive(x)
  
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  
  int temp = x;
  x = x_priv + x;
  x_priv = temp;
  
}
```

Differential revision: https://reviews.llvm.org/D78232

Added: 
clang/test/OpenMP/scan_codegen.cpp

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 664aeccfe7b9..a94cca758b22 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2075,6 +2075,15 @@ void CodeGenFunction::EmitOMPSimdInit(const 
OMPLoopDirective &D,
   if (const auto *C = D.getSingleClause())
 if (C->getKind() == OMPC_ORDER_concurrent)
   LoopStack.setParallel(/*Enable=*/true);
+  if ((D.getDirectiveKind() == OMPD_simd ||
+   (getLangOpts().OpenMPSimd &&
+isOpenMPSimdDirective(D.getDirectiveKind( &&
+  llvm::any_of(D.getClausesOfKind(),
+   [](const OMPReductionClause *C) {
+ return C->getModifier() == OMPC_REDUCTION_inscan;
+   }))
+// Disable parallel access in case of prefix sum.
+LoopStack.setParallel(/*Enable=*/false);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(
@@ -2270,6 +2279,8 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const 
OMPLoopDirective &S,
 }
 
 void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) {
+  ParentLoopDirectiveForScanRegion ScanRegion(*this, S);
+  OMPFirstScanLoop = true;
   auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
 emitOMPSimdRegion(CGF, S, Action);
   };
@@ -4191,14 +4202,15 @@ void CodeGenFunction::EmitOMPDepobjDirective(const 
OMPDepobjDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective &S) {
-  // Do not emit code for non-simd directives in simd-only mode.
-  if (getLangOpts().OpenMPSimd && !OMPParentLoopDirectiveForScan)
+  if (!OMPParentLoopDirectiveForScan)
 return;
   const OMPExecutableDirective &ParentDir = *OMPParentLoopDirectiveForScan;
+  bool IsInclusive = S.hasClausesOfKind();
   SmallVector Shareds;
   SmallVector Privates;
   SmallVector LHSs;
   SmallVector RHSs;
+  SmallVector ReductionOps;
   SmallVector CopyOps;
   SmallVector CopyArrayTemps;
   SmallVector CopyArrayElems;
@@ -4209,13 +4221,109 @@ void CodeGenFunction::EmitOMPScanDirective(const 
OMPScanDirective &S) {
 Privates.append(C->privates().begin(), C->privates().end());
 LHSs.append(C->lhs_exprs().begin(), C->lhs_exprs().end());
 RHSs.append(C->rhs_exprs().begin(), C->rhs_exprs().end());
+ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
 CopyOps.append(C->copy_ops().begin(), C->copy_ops().end());
 CopyArrayTemps.append(C->copy_array_temps().begin(),
   C->copy_array_temps().end());
 CopyArrayElems.append(C->copy_array_elems().begin(),
   C->copy_array_elems().end());
   }
-  bool IsInclusive = S.hasClausesOfKind();
+  if (ParentDir.getDirectiveKind() == OMPD_simd ||
+  (getLangOpts().OpenMPSimd &&
+   isOpenMPSimdDirective(ParentDir.getDirectiveKind( {
+// For simd directive and simd-based directives in simd only mode, use the
+// following codegen:
+// int x = 0;
+// #pragma omp simd reduction(inscan, +: x)
+// for (..) {
+//   
+//   #pragma omp scan inclusive(x)
+//   
+//  }
+// is transformed to:
+// int x = 0;
+// for (..) {
+//   int x_priv = 0;
+//   
+//   x = x_priv + x;
+//   x_priv = x;
+//   
+// }
+// and
+// int x = 0;
+// #pragma omp simd reduction(inscan, +: x)
+// for (..) {
+//   
+//   #pragma omp scan exclusive(x)
+//   
+// }
+// to
+// int x = 0;
+// for (..) {
+//   int x_priv = 0;
+//   
+//   int temp = x;
+//   x = x_priv + x;
+//   x_priv = temp;
+//   
+// }
+llvm::BasicBlock *OMPScanReduce = createBasicBlock("omp.inscan.reduce");
+EmitBranch(IsInclusive
+   ? OMPScanReduce
+   : BreakContinueStack

[clang] bb8c7e7 - Add AST_SIGNATURE record to unhashed control block of PCM files

2020-06-11 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2020-06-11T14:09:07+01:00
New Revision: bb8c7e756c51bb3dc05b30671fa4c64f48e41c39

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

LOG: Add AST_SIGNATURE record to unhashed control block of PCM files

Summary:
This record is constructed by hashing the bytes of the AST block in a similiar
fashion to the SIGNATURE record. This new signature only means anything if the
AST block is fully relocatable, i.e. it does not embed absolute offsets within
the PCM file. This change ensure this does not happen by replacing these offsets
with offsets relative to the nearest relevant subblock of the AST block.

Reviewers: Bigcheese, dexonsmith

Subscribers: dexonsmith, cfe-commits

Tags: #clang

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

Added: 
clang/test/Modules/ASTSignature.c
clang/test/Modules/Inputs/ASTHash/module.modulemap
clang/test/Modules/Inputs/ASTHash/my_header_1.h
clang/test/Modules/Inputs/ASTHash/my_header_2.h

Modified: 
clang/include/clang/Serialization/ASTBitCodes.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/Serialization/ASTWriter.h
clang/include/clang/Serialization/ModuleFile.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/Serialization/ASTWriterDecl.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 54d3e6ab8917..4008f11daa15 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -41,7 +41,7 @@ namespace serialization {
 /// Version 4 of AST files also requires that the version control branch and
 /// revision match exactly, since there is no backward compatibility of
 /// AST files at this time.
-const unsigned VERSION_MAJOR = 10;
+const unsigned VERSION_MAJOR = 11;
 
 /// AST file minor version number supported by this version of
 /// Clang.
@@ -242,14 +242,16 @@ class TypeIdx {
   /// Raw source location.
   unsigned Loc = 0;
 
-  /// Offset in the AST file. Keep structure alignment 32-bit and avoid
-  /// padding gap because undefined value in the padding affects AST hash.
+  /// Offset relative to the start of the DECLTYPES_BLOCK block. Keep
+  /// structure alignment 32-bit and avoid padding gap because undefined
+  /// value in the padding affects AST hash.
   UnderalignedInt64 BitOffset;
 
   DeclOffset() = default;
-  DeclOffset(SourceLocation Loc, uint64_t BitOffset) {
+  DeclOffset(SourceLocation Loc, uint64_t BitOffset,
+ uint64_t DeclTypesBlockStartOffset) {
 setLocation(Loc);
-setBitOffset(BitOffset);
+setBitOffset(BitOffset, DeclTypesBlockStartOffset);
   }
 
   void setLocation(SourceLocation L) {
@@ -260,12 +262,13 @@ class TypeIdx {
 return SourceLocation::getFromRawEncoding(Loc);
   }
 
-  void setBitOffset(uint64_t Offset) {
-BitOffset.setBitOffset(Offset);
+  void setBitOffset(uint64_t Offset,
+const uint64_t DeclTypesBlockStartOffset) {
+BitOffset.setBitOffset(Offset - DeclTypesBlockStartOffset);
   }
 
-  uint64_t getBitOffset() const {
-return BitOffset.getBitOffset();
+  uint64_t getBitOffset(const uint64_t DeclTypesBlockStartOffset) const {
+return BitOffset.getBitOffset() + DeclTypesBlockStartOffset;
   }
 };
 
@@ -394,6 +397,9 @@ class TypeIdx {
   /// Record code for the signature that identifiers this AST file.
   SIGNATURE = 1,
 
+  /// Record code for the content hash of the AST block.
+  AST_BLOCK_HASH,
+
   /// Record code for the diagnostic options table.
   DIAGNOSTIC_OPTIONS,
 

diff  --git a/clang/include/clang/Serialization/ASTReader.h 
b/clang/include/clang/Serialization/ASTReader.h
index aa93c702bed1..a80366f0ee04 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -1890,7 +1890,8 @@ class ASTReader
   /// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
   /// specified cursor.  Read the abbreviations that are at the top of the 
block
   /// and then leave the cursor pointing into the block.
-  static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned 
BlockID);
+  static bool ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor, unsigned BlockID,
+   uint64_t *StartOfBlockOffset = nullptr);
 
   /// Finds all the visible declarations with a given name.
   /// The current implementation of this method just loads the entire

diff  --git a/clang/include/clang/Serialization/ASTWriter.

[PATCH] D81420: Fix size for _ExtInt types with builtins

2020-06-11 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

Feel free to simplify the error message on commit.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:7940
+def err_overflow_builtin_ext_int_max_size : Error<
+  "__builtin_mul_overflow does not support %select{signed|unsigned}0 _ExtInt "
+  "operands of more than %1 bits">;

I don't think it is worth doing a 'select' on signed/unsigned.  When we need 
it, we can add it.

I more expect the builtin name to be modified first though (but don't bother 
making it a modifyable either).


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

https://reviews.llvm.org/D81420



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


[PATCH] D80383: Add AST_SIGNATURE record to unhashed control block of PCM files

2020-06-11 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:3706
   unsigned LocalBaseMacroID = Record[1];
-  F.MacroOffsetsBase = Record[2];
+  F.MacroOffsetsBase = Record[2] + F.ASTBlockStartOffset;
   F.BaseMacroID = getTotalNumMacros();

@dexonsmith the field you asked about is used here and the MacroOffsetsBase is 
used in other places to compute offsets



Comment at: clang/lib/Serialization/ASTWriter.cpp:2345
FirstMacroID - NUM_PREDEF_MACRO_IDS,
-   MacroOffsetsBase};
+   MacroOffsetsBase - ASTBlockStartOffset};
 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, bytes(MacroOffsets));

dexonsmith wrote:
> It looks to me like this field is ignored in the reader. If so we should just 
> strip it. Can you confirm?
No, look at line 3706 of the Reader in the updated version. I added a comment 
on the relevant line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80383



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


cfe-commits@lists.llvm.org

2020-06-11 Thread Ties Stuij via Phabricator via cfe-commits
stuij accepted this revision.
stuij added a comment.

LGTM. Thanks!


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

https://reviews.llvm.org/D80752



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:216
+  if (getLangOpts().SYCLIsDevice)
+if (auto VD = dyn_cast(D))
+  if (VD->getTLSKind() != VarDecl::TLS_None)

Nit: The convention is `auto *VD`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[PATCH] D78232: [OPENMP50]Codegen for scan directive in simd loops.

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb80e67f10ee: [OPENMP50]Codegen for scan directive in simd 
loops. (authored by ABataev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78232

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/scan_codegen.cpp

Index: clang/test/OpenMP/scan_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/scan_codegen.cpp
@@ -0,0 +1,277 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+//
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+void foo();
+void bar();
+
+// CHECK-LABEL: baz
+void baz() {
+  int a = 0;
+
+  // CHECK: store i32 0, i32* [[A_ADDR:%.+]],
+  // CHECK: store i32 0, i32* [[OMP_CNT:%.+]],
+  // CHECK: br label %[[OMP_HEADER:.+]]
+
+  // CHECK: [[OMP_HEADER]]:
+  // CHECK: [[CNT_VAL:%.+]] = load i32, i32* [[OMP_CNT]],
+  // CHECK: [[CMP:%.+]] = icmp slt i32 [[CNT_VAL]], 10
+  // CHECK: br i1 [[CMP]], label %[[OMP_BODY:.+]], label %[[OMP_END:.+]]
+#pragma omp simd reduction(inscan, + : a)
+  for (int i = 0; i < 10; ++i) {
+// CHECK: [[OMP_BODY]]:
+
+// i = OMP_CNT*1 + 0;
+// CHECK: [[CNT_VAL:%.+]] = load i32, i32* [[OMP_CNT]],
+// CHECK: [[MUL:%.+]] = mul nsw i32 [[CNT_VAL]], 1
+// CHECK: [[ADD:%.+]] = add nsw i32 0, [[MUL]]
+// CHECK: store i32 [[ADD]], i32* [[I_ADDR:%.+]],
+
+// A_PRIV = 0;
+// CHECK: store i32 0, i32* [[A_PRIV_ADDR:%.+]],
+
+// goto DISPATCH;
+// CHECK: br label %[[DISPATCH:[^,]+]]
+
+// INPUT_PHASE:
+// foo();
+// goto REDUCE;
+// CHECK: [[INPUT_PHASE:.+]]:
+// CHECK: call void @{{.*}}foo{{.*}}()
+// CHECK: br label %[[REDUCE:[^,]+]]
+foo();
+
+// DISPATCH:
+// goto INPUT_PHASE;
+// CHECK: [[DISPATCH]]:
+// CHECK: br label %[[INPUT_PHASE]]
+
+// REDUCE:
+// A = A_PRIV + A;
+// A_PRIV = A;
+// goto SCAN_PHASE;
+// CHECK: [[REDUCE]]:
+// CHECK: [[A:%.+]] = load i32, i32* [[A_ADDR]],
+// CHECK: [[A_PRIV:%.+]] = load i32, i32* [[A_PRIV_ADDR]],
+// CHECK: [[SUM:%.+]] = add nsw i32 [[A]], [[A_PRIV]]
+// CHECK: store i32 [[SUM]], i32* [[A_ADDR]],
+// CHECK: [[A:%.+]] = load i32, i32* [[A_ADDR]],
+// CHECK: store i32 [[A]], i32* [[A_PRIV_ADDR]],
+// CHECK: br label %[[SCAN_PHASE:[^,]+]]
+#pragma omp scan inclusive(a)
+
+// SCAN_PHASE:
+// bar();
+// goto CONTINUE;
+// CHECK: [[SCAN_PHASE]]:
+// CHECK: call void @{{.*}}bar{{.*}}()
+// CHECK: br label %[[CONTINUE:[^,]+]]
+bar();
+
+// CHECK: [[CONTINUE]]:
+// CHECK: br label %[[INC_BLOCK:[^,]+]]
+
+// ++OMP_CNT;
+// CHECK: [[INC_BLOCK]]:
+// CHECK: [[CNT:%.+]] = load i32, i32* [[OMP_CNT]],
+// CHECK: [[INC:%.+]] = add nsw i32 [[CNT]], 1
+// CHECK: store i32 [[INC]], i32* [[OMP_CNT]],
+// CHECK: br label %[[OMP_HEADER]]
+  }
+  // CHECK: [[OMP_END]]:
+}
+
+struct S {
+  int a;
+  S() {}
+  ~S() {}
+  S& operator+(const S&);
+  S& operator=(const S&);
+};
+
+// CHECK-LABEL: xyz
+void xyz() {
+  S s[2];
+
+  // CHECK: [[S_BEGIN:%.+]] = getelementptr inbounds [2 x %struct.S], [2 x %struct.S]* [[S_ADDR:%.+]], i{{.+}} 0, i{{.+}} 0
+  // CHECK: [[S_END:%.+]] = getelementptr {{.*}}%struct.S, %struct.S* [[S_BEGIN]], i{{.+}} 2
+  // CHECK: br label %[[ARRAY_INIT:.+]]
+  // CHECK: [[ARRAY_INIT]]:
+  // CHECK: [[S_CUR:%.+]] = phi %struct.S* [ [[S_BEGIN]], %{{.+}} ], [ [[S_NEXT:%.+]], %[[ARRAY_INIT]] ]
+  // CHECK: call void [[CONSTR:@.+]](%struct.S* [[S_CUR]])
+  // CHECK: [[S_NEXT]] = getelementptr inbounds %struct.S, %struct.S* [[S_CUR]], i{{.+}} 1
+  // CHECK: [[IS_DONE:%.+]] = icmp eq %struct.S* [[S_NEXT]], [[S_END]]
+  // CHECK: br i1 [[IS_DONE]], label %[[DONE:.+]], label %[[ARRAY_INIT]]
+  // CHECK: [[DONE]]:
+  // CHECK: store i32 0, i32* [[OMP_CNT:%.+]],
+  // CHECK: br label %[[OMP_HEADER:.+]]
+
+  // CHECK: [[OMP_HEADER]]:
+  // CHECK: [[CNT_VAL:%.+]] = load i32, i32* [[OMP_CNT]],
+  // CHECK: [[CMP:%.+]] = icmp slt i32 [[CNT_VAL]], 10
+  // CHECK: br i1 [[

[PATCH] D79796: Sketch support for generating CC1 command line from CompilerInvocation

2020-06-11 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 270117.
dang added a comment.

This addresses the usability concern with having to specify fully scoped 
definitions for normalized values in the TableGen files.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79796

Files:
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Frontend/CompilerInvocation.h
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/unittests/Frontend/CMakeLists.txt
  clang/unittests/Frontend/CompilerInvocationTest.cpp
  llvm/include/llvm/Option/OptParser.td
  llvm/utils/TableGen/OptParserEmitter.cpp

Index: llvm/utils/TableGen/OptParserEmitter.cpp
===
--- llvm/utils/TableGen/OptParserEmitter.cpp
+++ llvm/utils/TableGen/OptParserEmitter.cpp
@@ -9,7 +9,9 @@
 #include "OptEmitter.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringSwitch.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/raw_ostream.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/TableGenBackend.h"
 #include 
@@ -33,6 +35,50 @@
   return OS;
 }
 
+static void emitMarshallingInfoFlag(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsBit("IsPositive");
+}
+
+static void emitMarshallingInfoString(raw_ostream &OS, const Record &R) {
+  OS << R.getValueAsString("Normalizer");
+  OS << ", ";
+  OS << R.getValueAsString("Denormalizer");
+}
+
+static void emitScopedNormalizedValue(raw_ostream &OS,
+  StringRef NormalizedValuesScope,
+  StringRef NormalizedValue) {
+  if (!NormalizedValuesScope.empty())
+OS << NormalizedValuesScope << "::";
+  OS << NormalizedValue;
+}
+
+static void emitValueTable(raw_ostream &OS, StringRef OptionID,
+   StringRef Values, StringRef NormalizedValuesScope,
+   std::vector NormalizedValues) {
+  SmallVector SplitValues;
+  Values.split(SplitValues, ',');
+  assert(SplitValues.size() == NormalizedValues.size() &&
+ "The number of associated definitions doesn't match the number of "
+ "values");
+
+  SmallString<64> MacroName("HANDLE_");
+  MacroName += OptionID.upper();
+  MacroName += "_VALUES";
+  OS << "#ifdef " << MacroName << "\n";
+  for (unsigned I = 0, E = SplitValues.size(); I != E; ++I) {
+OS << MacroName << "(\"" << SplitValues[I] << "\",";
+emitScopedNormalizedValue(OS, NormalizedValuesScope, NormalizedValues[I]);
+OS << ")\n";
+  }
+  OS << "#endif\n";
+}
+
+struct MarshallingKindInfo {
+  const char *MacroName;
+  void (*Emit)(raw_ostream &OS, const Record &R);
+};
+
 /// OptParserEmitter - This tablegen backend takes an input .td file
 /// describing a list of options and emits a data structure for parsing and
 /// working with those options when given an input command line.
@@ -135,12 +181,8 @@
 
   OS << "//\n";
   OS << "// Options\n\n";
-  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
-const Record &R = *Opts[i];
-
-// Start a single option entry.
-OS << "OPTION(";
 
+  auto WriteOptRecordFields = [&](raw_ostream &OS, const Record &R) {
 // The option prefix;
 std::vector prf = R.getValueAsListOfStrings("Prefixes");
 OS << Prefixes[PrefixKeyT(prf.begin(), prf.end())] << ", ";
@@ -223,11 +265,62 @@
   write_cstring(OS, R.getValueAsString("Values"));
 else
   OS << "nullptr";
+  };
 
+  std::vector OptsWithMarshalling;
+  for (unsigned i = 0, e = Opts.size(); i != e; ++i) {
+const Record &R = *Opts[i];
+
+// Start a single option entry.
+OS << "OPTION(";
+WriteOptRecordFields(OS, R);
 OS << ")\n";
+if (!isa(R.getValueInit("MarshallingKind")))
+  OptsWithMarshalling.push_back(&R);
   }
   OS << "#endif // OPTION\n";
 
+  for (unsigned I = 0, E = OptsWithMarshalling.size(); I != E; ++I) {
+const Record &R = *OptsWithMarshalling[I];
+assert(!isa(R.getValueInit("KeyPath")) &&
+   !isa(R.getValueInit("DefaultValue")) &&
+   "Must provide at least a key-path and a default value for emitting "
+   "marshalling information");
+StringRef KindStr = R.getValueAsString("MarshallingKind");
+auto KindInfo = StringSwitch(KindStr)
+.Case("flag", {"OPTION_WITH_MARSHALLING_FLAG",
+   &emitMarshallingInfoFlag})
+.Case("string", {"OPTION_WITH_MARSHALLING_STRING",
+ &emitMarshallingInfoString})
+.Default({"", nullptr});
+StringRef NormalizedValuesScope;
+if (!isa(R.getValueInit("NormalizedValuesScope")))
+  NormalizedValuesScope = R.getValueAsString("NormalizedValuesScope");
+
+OS << "#ifdef " << KindInfo.MacroName << "\n";
+OS << KindInfo.MacroName << "(";
+WriteOptRecordFields(OS, R);
+OS << ", ";

[PATCH] D80383: Add AST_SIGNATURE record to unhashed control block of PCM files

2020-06-11 Thread Daniel Grumberg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbb8c7e756c51: Add AST_SIGNATURE record to unhashed control 
block of PCM files (authored by dang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80383

Files:
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/include/clang/Serialization/ModuleFile.h
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/Modules/ASTSignature.c
  clang/test/Modules/Inputs/ASTHash/module.modulemap
  clang/test/Modules/Inputs/ASTHash/my_header_1.h
  clang/test/Modules/Inputs/ASTHash/my_header_2.h

Index: clang/test/Modules/Inputs/ASTHash/my_header_2.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/my_header_2.h
@@ -0,0 +1,3 @@
+#include "my_header_1.h"
+
+extern my_int var;
Index: clang/test/Modules/Inputs/ASTHash/my_header_1.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/my_header_1.h
@@ -0,0 +1 @@
+typedef int my_int;
Index: clang/test/Modules/Inputs/ASTHash/module.modulemap
===
--- /dev/null
+++ clang/test/Modules/Inputs/ASTHash/module.modulemap
@@ -0,0 +1,8 @@
+module MyHeader1 {
+  header "my_header_1.h"
+}
+
+module MyHeader2 {
+  header "my_header_2.h"
+  export *
+}
Index: clang/test/Modules/ASTSignature.c
===
--- /dev/null
+++ clang/test/Modules/ASTSignature.c
@@ -0,0 +1,24 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -iquote %S/Inputs/ASTHash/ -fsyntax-only -fmodules \
+// RUN:   -fimplicit-module-maps -fmodules-strict-context-hash \
+// RUN:   -fmodules-cache-path=%t -fdisable-module-hash %s
+// RUN: cp %t/MyHeader2.pcm %t1.pcm
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -iquote "/dev/null" -iquote %S/Inputs/ASTHash/ -fsyntax-only \
+// RUN:   -fmodules -fimplicit-module-maps -fmodules-strict-context-hash \
+// RUN:   -fmodules-cache-path=%t -fdisable-module-hash %s
+// RUN: cp %t/MyHeader2.pcm %t2.pcm
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t1.pcm > %t1.dump
+// RUN: llvm-bcanalyzer --dump --disable-histogram %t2.pcm > %t2.dump
+// RUN: cat %t1.dump %t2.dump | FileCheck %s
+
+#include "my_header_2.h"
+
+my_int var = 42;
+
+// CHECK: [[AST_BLOCK_HASH:]]
+// CHECK: [[SIGNATURE:]]
+// CHECK: [[AST_BLOCK_HASH]]
+// CHECK-NOT: [[SIGNATURE]]
+// The modules built by this test are designed to yield the same AST. If this
+// test fails, it means that the AST block is has become non-relocatable.
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -2432,12 +2432,12 @@
   SourceLocation Loc = D->getLocation();
   unsigned Index = ID - FirstDeclID;
   if (DeclOffsets.size() == Index)
-DeclOffsets.emplace_back(Loc, Offset);
+DeclOffsets.emplace_back(Loc, Offset, DeclTypesBlockStartOffset);
   else if (DeclOffsets.size() < Index) {
 // FIXME: Can/should this happen?
 DeclOffsets.resize(Index+1);
 DeclOffsets[Index].setLocation(Loc);
-DeclOffsets[Index].setBitOffset(Offset);
+DeclOffsets[Index].setBitOffset(Offset, DeclTypesBlockStartOffset);
   } else {
 llvm_unreachable("declarations should be emitted in ID order");
   }
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -10,14 +10,12 @@
 //
 //===--===//
 
-#include "clang/AST/OpenMPClause.h"
-#include "clang/Serialization/ASTRecordWriter.h"
 #include "ASTCommon.h"
 #include "ASTReaderInternals.h"
 #include "MultiOnDiskHashTable.h"
-#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTUnresolvedSet.h"
+#include "clang/AST/AbstractTypeWriter.h"
 #include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
@@ -31,6 +29,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/LambdaCapture.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/OpenMPClause.h"
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -65,7 +64,9 @@
 #include "clang/Sema/ObjCMethodList.h"
 #include "clang/Sema/Sema.h"
 #include "clang/Sema/Weak.h"
+#include "clang/Serialization/ASTBitCodes.h"
 #include "clang/Serialization/ASTReader.h"
+#include "clang/Serialization/ASTRecordWriter.

[clang] 78e636b - [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits...

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T14:35:52+01:00
New Revision: 78e636b3f2f0b0487130b31fade4f95ab179a18c

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

LOG: [clang][NFC] Generate the 
{Type,ArrayType,UnaryExprOrType,Expression}Traits...

...enumerations from TokenKinds.def and use the new macros from TokenKinds.def
to remove the hard-coded lists of traits.

All the information needed to generate these enumerations is already present
in TokenKinds.def. The motivation here is to be able to dump the trait spelling
without hard-coding the list in yet another place.

Note that this change the order of the enumerators in the enumerations (except
that in the TypeTrait enumeration all unary type traits are before all binary
type traits, and all binary type traits are before all n-ary type traits).

Apart from the aforementioned ordering which is relied upon, after this patch
no code in clang or in the various clang tools depend on the specific ordering
of the enumerators.

No functional changes intended.

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

Reviewed By: aaron.ballman

Added: 
clang/lib/Basic/ExpressionTraits.cpp
clang/lib/Basic/TypeTraits.cpp

Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/ExpressionTraits.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Basic/TypeTraits.h
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Basic/CMakeLists.txt
clang/lib/Sema/SemaExpr.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 1f68ef0d8dae..a295b3778cf0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6009,24 +6009,16 @@ def err_atomic_specifier_bad_type
 "1 byte of precision|with a non power of 2 precision}0">;
 
 // Expressions.
-def select_unary_expr_or_type_trait_kind : TextSubstitution<
-  "%select{sizeof|alignof|vec_step|__builtin_omp_required_simd_align|"
-  "__alignof}0">;
 def ext_sizeof_alignof_function_type : Extension<
-  "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
-  "to a function type">, InGroup;
+  "invalid application of '%0' to a function type">, InGroup;
 def ext_sizeof_alignof_void_type : Extension<
-  "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
-  "to a void type">, InGroup;
+  "invalid application of '%0' to a void type">, InGroup;
 def err_opencl_sizeof_alignof_type : Error<
-  "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
-  "to a void type">;
+  "invalid application of '%0' to a void type">;
 def err_sizeof_alignof_incomplete_or_sizeless_type : Error<
-  "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
-  "to %select{an incomplete|sizeless}1 type %2">;
+  "invalid application of '%0' to %select{an incomplete|sizeless}1 type %2">;
 def err_sizeof_alignof_function_type : Error<
-  "invalid application of '%sub{select_unary_expr_or_type_trait_kind}0' "
-  "to a function type">;
+  "invalid application of '%0' to a function type">;
 def err_openmp_default_simd_align_expr : Error<
   "invalid application of '__builtin_omp_required_simd_align' to an 
expression, only type is allowed">;
 def err_sizeof_alignof_typeof_bitfield : Error<

diff  --git a/clang/include/clang/Basic/ExpressionTraits.h 
b/clang/include/clang/Basic/ExpressionTraits.h
index 85005330a0af..b38ebd9ac60b 100644
--- a/clang/include/clang/Basic/ExpressionTraits.h
+++ b/clang/include/clang/Basic/ExpressionTraits.h
@@ -14,12 +14,24 @@
 #ifndef LLVM_CLANG_BASIC_EXPRESSIONTRAITS_H
 #define LLVM_CLANG_BASIC_EXPRESSIONTRAITS_H
 
+#include "llvm/Support/Compiler.h"
+
 namespace clang {
 
-  enum ExpressionTrait {
-ET_IsLValueExpr,
-ET_IsRValueExpr
-  };
-}
+enum ExpressionTrait {
+#define EXPRESSION_TRAIT(Spelling, Name, Key) ET_##Name,
+#include "clang/Basic/TokenKinds.def"
+  ET_Last = -1 // ET_Last == last ET_XX in the enum.
+#define EXPRESSION_TRAIT(Spelling, Name, Key) +1
+#include "clang/Basic/TokenKinds.def"
+};
+
+/// Return the internal name of type trait \p T. Never null.
+const char *getTraitName(ExpressionTrait T) LLVM_READONLY;
+
+/// Return the spelling of the type trait \p TT. Never null.
+const char *getTraitSpelling(ExpressionTrait T) LLVM_READONLY;
+
+} // namespace clang
 
 #endif

diff  --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 141470abecf4..2b353269ed52 100644
--- a/clang/include/clang/Basic/TokenKi

[PATCH] D81455: [clang][NFC] Generate the {Type,ArrayType,UnaryExprOrType,Expression}Traits enumerations from TokenKinds.def...

2020-06-11 Thread Bruno Ricci via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG78e636b3f2f0: [clang][NFC] Generate the 
{Type,ArrayType,UnaryExprOrType,Expression}Traits... (authored by riccibruno).

Changed prior to commit:
  https://reviews.llvm.org/D81455?vs=269467&id=270121#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81455

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/ExpressionTraits.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TypeTraits.h
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
  clang/lib/ASTMatchers/Dynamic/Marshallers.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/ExpressionTraits.cpp
  clang/lib/Basic/TypeTraits.cpp
  clang/lib/Sema/SemaExpr.cpp

Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -3971,7 +3971,7 @@
TraitKind == UETT_PreferredAlignOf)) {
 // sizeof(function)/alignof(function) is allowed as an extension.
 S.Diag(Loc, diag::ext_sizeof_alignof_function_type)
-  << TraitKind << ArgRange;
+<< getTraitSpelling(TraitKind) << ArgRange;
 return false;
   }
 
@@ -3980,7 +3980,7 @@
   if (T->isVoidType()) {
 unsigned DiagID = S.LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
 : diag::ext_sizeof_alignof_void_type;
-S.Diag(Loc, DiagID) << TraitKind << ArgRange;
+S.Diag(Loc, DiagID) << getTraitSpelling(TraitKind) << ArgRange;
 return false;
   }
 
@@ -4059,13 +4059,13 @@
   if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf) {
 if (RequireCompleteSizedType(
 E->getExprLoc(), Context.getBaseElementType(E->getType()),
-diag::err_sizeof_alignof_incomplete_or_sizeless_type, ExprKind,
-E->getSourceRange()))
+diag::err_sizeof_alignof_incomplete_or_sizeless_type,
+getTraitSpelling(ExprKind), E->getSourceRange()))
   return true;
   } else {
 if (RequireCompleteSizedExprType(
-E, diag::err_sizeof_alignof_incomplete_or_sizeless_type, ExprKind,
-E->getSourceRange()))
+E, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
+getTraitSpelling(ExprKind), E->getSourceRange()))
   return true;
   }
 
@@ -4075,7 +4075,7 @@
 
   if (ExprTy->isFunctionType()) {
 Diag(E->getExprLoc(), diag::err_sizeof_alignof_function_type)
-  << ExprKind << E->getSourceRange();
+<< getTraitSpelling(ExprKind) << E->getSourceRange();
 return true;
   }
 
@@ -4164,12 +4164,12 @@
 
   if (RequireCompleteSizedType(
   OpLoc, ExprType, diag::err_sizeof_alignof_incomplete_or_sizeless_type,
-  ExprKind, ExprRange))
+  getTraitSpelling(ExprKind), ExprRange))
 return true;
 
   if (ExprType->isFunctionType()) {
 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
-  << ExprKind << ExprRange;
+<< getTraitSpelling(ExprKind) << ExprRange;
 return true;
   }
 
Index: clang/lib/Basic/TypeTraits.cpp
===
--- /dev/null
+++ clang/lib/Basic/TypeTraits.cpp
@@ -0,0 +1,86 @@
+//===--- TypeTraits.cpp - Type Traits Support -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+//  This file implements the type traits support functions.
+//
+//===--===//
+
+#include "clang/Basic/TypeTraits.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+using namespace clang;
+
+static constexpr const char *TypeTraitNames[] = {
+#define TYPE_TRAIT_1(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_2(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_N(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+};
+
+static constexpr const char *TypeTraitSpellings[] = {
+#define TYPE_TRAIT_1(Spelling, Name, Key) #Spelling,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_2(Spelling, Name, Key) #Spelling,
+#include "clang/Basic/TokenKinds.def"
+#define TYPE_TRAIT_N(Spelling, Name, Key) #Spelling,
+#include "clang/Basic/TokenKinds.def"
+};
+
+static constexpr const char *ArrayTypeTraitNames[] = {
+#define ARRAY_TYPE_TRAIT(Spelling, Name, Key) #Name,
+#include "clang/Basic/TokenKinds.def"
+};
+
+static constexpr const char *ArrayTypeTraitSpellings[] = {
+#define ARRAY_TYPE_

[clang] 90b54fa - [OPENMP50]Codegen for use_device_addr clauses.

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T09:54:51-04:00
New Revision: 90b54fa045e3f8711e0bfb2d22626b28fd3b131f

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

LOG: [OPENMP50]Codegen for use_device_addr clauses.

Summary:
Added codegen for use_device_addr clause. The components of the list
items are mapped as a kind of RETURN components and then the returned
base address is used instead of the real address of the base declaration
used in the use_device_addr expressions.

Reviewers: jdoerfert

Subscribers: yaxunl, guansong, sstefan1, cfe-commits, caomhin

Tags: #clang

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

Added: 
clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Modified: 
clang/lib/AST/OpenMPClause.cpp
clang/lib/CodeGen/CGOpenMPRuntime.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/AST/OpenMPClause.cpp b/clang/lib/AST/OpenMPClause.cpp
index 3cb71d3d77bc..6a8b3ce231f2 100644
--- a/clang/lib/AST/OpenMPClause.cpp
+++ b/clang/lib/AST/OpenMPClause.cpp
@@ -1207,8 +1207,8 @@ OMPUseDevicePtrClause *OMPUseDevicePtrClause::Create(
   Sizes.NumComponents = getComponentsTotalNumber(ComponentLists);
 
   // We need to allocate:
-  // 3 x NumVars x Expr* - we have an original list expression for each clause
-  // list entry and an equal number of private copies and inits.
+  // NumVars x Expr* - we have an original list expression for each clause
+  // list entry.
   // NumUniqueDeclarations x ValueDecl* - unique base declarations associated
   // with each component list.
   // (NumUniqueDeclarations + NumComponentLists) x unsigned - we specify the

diff  --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp 
b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index 95b4c81baf9d..d1b1d5c0d911 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -7031,7 +7031,7 @@ class MappableExprsHandler {
 OMP_MAP_TARGET_PARAM = 0x20,
 /// Signal that the runtime library has to return the device pointer
 /// in the current position for the data being mapped. Used when we have 
the
-/// use_device_ptr clause.
+/// use_device_ptr or use_device_addr clause.
 OMP_MAP_RETURN_PARAM = 0x40,
 /// This flag signals that the reference being passed is a pointer to
 /// private data.
@@ -7099,26 +7099,30 @@ class MappableExprsHandler {
 ArrayRef MapModifiers;
 bool ReturnDevicePointer = false;
 bool IsImplicit = false;
+bool ForDeviceAddr = false;
 
 MapInfo() = default;
 MapInfo(
 OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
 OpenMPMapClauseKind MapType,
-ArrayRef MapModifiers,
-bool ReturnDevicePointer, bool IsImplicit)
+ArrayRef MapModifiers, bool ReturnDevicePointer,
+bool IsImplicit, bool ForDeviceAddr = false)
 : Components(Components), MapType(MapType), MapModifiers(MapModifiers),
-  ReturnDevicePointer(ReturnDevicePointer), IsImplicit(IsImplicit) {}
+  ReturnDevicePointer(ReturnDevicePointer), IsImplicit(IsImplicit),
+  ForDeviceAddr(ForDeviceAddr) {}
   };
 
-  /// If use_device_ptr is used on a pointer which is a struct member and there
-  /// is no map information about it, then emission of that entry is deferred
-  /// until the whole struct has been processed.
+  /// If use_device_ptr or use_device_addr is used on a decl which is a struct
+  /// member and there is no map information about it, then emission of that
+  /// entry is deferred until the whole struct has been processed.
   struct DeferredDevicePtrEntryTy {
 const Expr *IE = nullptr;
 const ValueDecl *VD = nullptr;
+bool ForDeviceAddr = false;
 
-DeferredDevicePtrEntryTy(const Expr *IE, const ValueDecl *VD)
-: IE(IE), VD(VD) {}
+DeferredDevicePtrEntryTy(const Expr *IE, const ValueDecl *VD,
+ bool ForDeviceAddr)
+: IE(IE), VD(VD), ForDeviceAddr(ForDeviceAddr) {}
   };
 
   /// The target directive from where the mappable clauses were extracted. It
@@ -7306,13 +7310,12 @@ class MappableExprsHandler {
   /// \a IsFirstComponent should be set to true if the provided set of
   /// components is the first associated with a capture.
   void generateInfoForComponentList(
-  OpenMPMapClauseKind MapType,
-  ArrayRef MapModifiers,
+  OpenMPMapClauseKind MapType, ArrayRef 
MapModifiers,
   OMPClauseMappableExprCommon::MappableExprComponentListRef Components,
   MapBaseValuesArrayTy &BasePointers, MapValuesArrayTy &Pointers,
   MapValuesArrayTy &Sizes, MapFlagsArrayTy &Types,
   StructRangeInfoTy &PartialStruct, bool IsFirstComponentList,
- 

[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG90b54fa045e3: [OPENMP50]Codegen for use_device_addr clauses. 
(authored by ABataev).

Changed prior to commit:
  https://reviews.llvm.org/D80730?vs=269618&id=270131#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730

Files:
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_addr_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_addr_codegen.cpp
@@ -0,0 +1,224 @@
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -DCK1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -DCK1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+// CHECK-DAG: [[SIZES1:@.+]] = private unnamed_addr constant [5 x i64] zeroinitializer
+// 96 = 0x60 = OMP_MAP_TARGET_PARAM | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES1:@.+]] = private unnamed_addr constant [5 x i64] [i64 96, i64 96, i64 96, i64 96, i64 96]
+// 32 = 0x20 = OMP_MAP_TARGET_PARAM
+// 281474976710720 = 0x10040 = OMP_MAP_MEMBER_OF | OMP_MAP_RETURN_PARAM
+// CHECK-DAG: [[MAPTYPES2:@.+]] = private unnamed_addr constant [5 x i64] [i64 32, i64 281474976710720, i64 281474976710720, i64 281474976710720, i64 281474976710720]
+struct S {
+  int a = 0;
+  int *ptr = &a;
+  int &ref = a;
+  int arr[4];
+  S() {}
+  void foo() {
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:a])
+++a, ++*ptr, ++ref, ++arr[0];
+  }
+};
+
+int main() {
+  float a = 0;
+  float *ptr = &a;
+  float &ref = a;
+  float arr[4];
+  float vla[(int)a];
+  S s;
+  s.foo();
+#pragma omp target data use_device_addr(a, ptr [3:4], ref, ptr[0], arr[:(int)a], vla[0])
+  ++a, ++*ptr, ++ref, ++arr[0], ++vla[0];
+  return a;
+}
+
+// CHECK-LABEL: @main()
+// CHECK: [[A_ADDR:%.+]] = alloca float,
+// CHECK: [[PTR_ADDR:%.+]] = alloca float*,
+// CHECK: [[REF_ADDR:%.+]] = alloca float*,
+// CHECK: [[ARR_ADDR:%.+]] = alloca [4 x float],
+// CHECK: [[BPTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[PTRS:%.+]] = alloca [5 x i8*],
+// CHECK: [[VLA_ADDR:%.+]] = alloca float, i64 %{{.+}},
+// CHECK: [[PTR:%.+]] = load float*, float** [[PTR_ADDR]],
+// CHECK: [[REF:%.+]] = load float*, float** [[REF_ADDR]],
+// CHECK: [[ARR:%.+]] = getelementptr inbounds [4 x float], [4 x float]* [[ARR_ADDR]], i64 0, i64 0
+// CHECK: [[BPTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 0
+// CHECK: [[BPTR0_A_ADDR:%.+]] = bitcast i8** [[BPTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[BPTR0_A_ADDR]],
+// CHECK: [[PTR0:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 0
+// CHECK: [[PTR0_A_ADDR:%.+]] = bitcast i8** [[PTR0]] to float**
+// CHECK: store float* [[A_ADDR]], float** [[PTR0_A_ADDR]],
+// CHECK: [[BPTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 1
+// CHECK: [[BPTR1_PTR_ADDR:%.+]] = bitcast i8** [[BPTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[BPTR1_PTR_ADDR]],
+// CHECK: [[PTR1:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0, i32 1
+// CHECK: [[PTR1_PTR_ADDR:%.+]] = bitcast i8** [[PTR1]] to float**
+// CHECK: store float* [[PTR]], float** [[PTR1_PTR_ADDR]],
+// CHECK: [[BPTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[BPTRS]], i32 0, i32 2
+// CHECK: [[BPTR2_REF_ADDR:%.+]] = bitcast i8** [[BPTR2]] to float**
+// CHECK: store float* [[REF]], float** [[BPTR2_REF_ADDR]],
+// CHECK: [[PTR2:%.+]] = getelementptr inbounds [5 x i8*], [5 x i8*]* [[PTRS]], i32 0

[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 270135.
Fznamznon added a comment.

Fixed code style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaSYCL/prohibit-thread-local.cpp

Index: clang/test/SemaSYCL/prohibit-thread-local.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/prohibit-thread-local.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -fsycl -fsycl-is-device -triple spir64 -verify -fsyntax-only %s
+
+thread_local const int prohobit_ns_scope = 0;
+thread_local int prohobit_ns_scope2 = 0;
+thread_local const int allow_ns_scope = 0;
+
+struct S {
+  static const thread_local int prohibit_static_member;
+  static thread_local int prohibit_static_member2;
+};
+
+struct T {
+  static const thread_local int allow_static_member;
+};
+
+void foo() {
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local const int prohibit_local = 0;
+  // expected-error@+1{{thread-local storage is not supported for the current target}}
+  thread_local int prohibit_local2;
+}
+
+void bar() { thread_local int allow_local; }
+
+void usage() {
+  // expected-note@+1 {{called by}}
+  foo();
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)prohobit_ns_scope2;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member;
+  // expected-error@+1 {{thread-local storage is not supported for the current target}}
+  (void)S::prohibit_static_member2;
+}
+
+template 
+__attribute__((sycl_kernel))
+// expected-note@+2 2{{called by}}
+void
+kernel_single_task(Func kernelFunc) { kernelFunc(); }
+
+int main() {
+  // expected-note@+1 2{{called by}}
+  kernel_single_task([]() { usage(); });
+  return 0;
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -212,6 +212,11 @@
  bool ObjCPropertyAccess,
  bool AvoidPartialAvailabilityChecks,
  ObjCInterfaceDecl *ClassReceiver) {
+  if (getLangOpts().SYCLIsDevice)
+if (auto *VD = dyn_cast(D))
+  if (VD->getTLSKind() != VarDecl::TLS_None)
+SYCLDiagIfDeviceCode(*Locs.begin(), diag::err_thread_unsupported);
+
   SourceLocation Loc = Locs.front();
   if (getLangOpts().CPlusPlus && isa(D)) {
 // If there were any diagnostics suppressed by template argument deduction,
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -7077,7 +7077,8 @@
diag::err_thread_non_global)
 << DeclSpec::getSpecifierName(TSCS);
 else if (!Context.getTargetInfo().isTLSSupported()) {
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 // Postpone error emission until we've collected attributes required to
 // figure out whether it's a host or device variable and whether the
 // error should be ignored.
@@ -7179,13 +7180,17 @@
   // Handle attributes prior to checking for duplicates in MergeVarDecl
   ProcessDeclAttributes(S, NewVD, D);
 
-  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice) {
+  if (getLangOpts().CUDA || getLangOpts().OpenMPIsDevice ||
+  getLangOpts().SYCLIsDevice) {
 if (EmitTLSUnsupportedError &&
 ((getLangOpts().CUDA && DeclAttrsMatchCUDAMode(getLangOpts(), NewVD)) ||
  (getLangOpts().OpenMPIsDevice &&
   OMPDeclareTargetDeclAttr::isDeclareTargetDeclaration(NewVD
   Diag(D.getDeclSpec().getThreadStorageClassSpecLoc(),
diag::err_thread_unsupported);
+
+if (EmitTLSUnsupportedError && getLangOpts().SYCLIsDevice)
+  SYCLDiagIfDeviceCode(D.getIdentifierLoc(), diag::err_thread_unsupported);
 // CUDA B.2.5: "__shared__ and __constant__ variables have implied static
 // storage [duration]."
 if (SC == SC_None && S->getFnParent() != nullptr &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D81311#2086326 , @rjmccall wrote:

> In D81311#2086227 , @jdoerfert wrote:
>
> > Do we allow `inmem` to be used for other purposes? I would assume the 
> > answer is yes, as we do not forbid it.
>
>
> I don't know what else we might use it for off-hand, but yes, I think the 
> frontend could put this down on all value arguments that are actually passed 
> indirectly.


Where does it say it is limited to indirectly passed arguments?


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

https://reviews.llvm.org/D81311



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


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon marked 2 inline comments as done.
Fznamznon added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:216
+  if (getLangOpts().SYCLIsDevice)
+if (auto VD = dyn_cast(D))
+  if (VD->getTLSKind() != VarDecl::TLS_None)

riccibruno wrote:
> Nit: The convention is `auto *VD`.
Fixed, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 270140.
balazske added a comment.

- Report every path of resource leak.
- Do not report if non-returning function was encountered.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -139,7 +139,7 @@
   if (!p)
 return;
   if(c)
-return; // expected-warning {{Opened File never closed. Potential Resource leak}}
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
   fclose(p);
 }
 
Index: clang/test/Analysis/stream-note.c
===
--- /dev/null
+++ clang/test/Analysis/stream-note.c
@@ -0,0 +1,48 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -analyzer-output text -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void check_note_at_correct_open() {
+  FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  if (!F1)
+// expected-note@-1 {{'F1' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  FILE *F2 = tmpfile();
+  if (!F2) {
+// expected-note@-1 {{'F2' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+fclose(F1);
+return;
+  }
+  rewind(F2);
+  fclose(F2);
+  rewind(F1);
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_fopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_freopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -216,8 +216,8 @@
   "Read function called when stream is in EOF state. "
   "Function has no effect."};
   BuiltinBug BT_ResourceLeak{
-  this, "Resource Leak",
-  "Opened File never closed. Potential Resource leak."};
+  this, "Resource leak",
+  "Opened stream never closed. Potential resource leak."};
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -365,6 +365,20 @@
 
 return FnDescriptions.lookup(Call);
   }
+
+  /// Generate a message for BugReporterVisitor if the stored symbol is
+  /// marked as interesting by the actual bug report.
+  struct NoteFn {
+SymbolRef StreamSym;
+std::string Message;
+
+std::string operator()(PathSensitiveBugReport &BR) const {
+  if (BR.isInteresting(StreamSym))
+return Message;
+
+  return "";
+}
+  };
 };
 
 } // end anonymous namespace
@@ -421,7 +435,8 @@
   StateNull =
   StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{RetSym, "Stream opened here"});
+  C.addTransition(StateNotNull, T);
   C.addTransition(StateNull);
 }
 
@@ -476,7 +491,8 @@
   StateRetNull =
   StateRetNull->set(StreamSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateRetNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{StreamSym, "Stream reopened here"});
+  C.addTransition(StateRetNotNull, T);
   C.addTransition(StateRetNull);
 }
 
@@ -921,8 +937,17 @@
 if (!N)
   continue;
 
-C.emitReport(std::make_unique(
-BT_ResourceLeak, BT_ResourceLeak.getDescription(), N));
+// Do not warn for non-closed stream at program exit.
+ExplodedNode *Pred = C.getPredecessor();
+if (Pred && Pred->getCFGBlock() &&
+Pred->getCFGBlock()->hasNoReturnElement())
+  continue;
+
+std::unique_ptr R =
+std::make_unique(
+BT_ResourceLeak, BT_ResourceLeak.getDescription(), N);
+R->

[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-11 Thread Benson Chu via Phabricator via cfe-commits
pestctrl marked an inline comment as done.
pestctrl added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6451
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<

rsmith wrote:
> pestctrl wrote:
> > efriedma wrote:
> > > `InGroup`
> > Sorry, I'm not sure I understand. Isn't this a C99 warning? Why is it being 
> > put in the C11 group?
> Because `C11` really means `C11Extensions`, and this is a C11 extension (ie, 
> it's code that's valid in C11 but not valid in C99):
> ```
> // A warning group for warnings about using C11 features as extensions.
> def C11 : DiagGroup<"c11-extensions">;
> ```
Got it, thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945



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


[PATCH] D79945: [Sema] Comparison of pointers to complete and incomplete types

2020-06-11 Thread Benson Chu via Phabricator via cfe-commits
pestctrl updated this revision to Diff 270139.
pestctrl added a comment.

Moved the extension to C11 group


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79945

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/complete-incomplete-pointer-relational-c99.c


Index: clang/test/Sema/complete-incomplete-pointer-relational-c99.c
===
--- /dev/null
+++ clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to 
have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return (&incomplete < &complete) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplete <= &complete) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplete > &complete) &&  // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplete >= &complete) && // expected-warning {{pointer 
comparisons before C11 need to be between two complete or two incomplete types; 
'int (*)[]' is incomplete and 'int (*)[6]' is complete}}
+ (&incomplete == &complete) &&
+ (&incomplete != &complete);
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -11563,11 +11563,22 @@
 // C99 6.5.9p2 and C99 6.5.8p2
 if (Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
RCanPointeeTy.getUnqualifiedType())) {
-  // Valid unless a relational comparison of function pointers
-  if (IsRelational && LCanPointeeTy->isFunctionType()) {
-Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
-  << LHSType << RHSType << LHS.get()->getSourceRange()
-  << RHS.get()->getSourceRange();
+  if (IsRelational) {
+// Pointers both need to point to complete or incomplete types
+if ((LCanPointeeTy->isIncompleteType() !=
+ RCanPointeeTy->isIncompleteType()) &&
+!getLangOpts().C11) {
+  Diag(Loc, diag::ext_typecheck_compare_complete_incomplete_pointers)
+  << LHS.get()->getSourceRange() << RHS.get()->getSourceRange()
+  << LHSType << RHSType << LCanPointeeTy->isIncompleteType()
+  << RCanPointeeTy->isIncompleteType();
+}
+if (LCanPointeeTy->isFunctionType()) {
+  // Valid unless a relational comparison of function pointers
+  Diag(Loc, 
diag::ext_typecheck_ordered_comparison_of_function_pointers)
+  << LHSType << RHSType << LHS.get()->getSourceRange()
+  << RHS.get()->getSourceRange();
+}
   }
 } else if (!IsRelational &&
(LCanPointeeTy->isVoidType() || RCanPointeeTy->isVoidType())) {
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6443,6 +6443,12 @@
   "ordered comparison between pointer and zero (%0 and %1)">;
 def err_typecheck_three_way_comparison_of_pointer_and_zero : Error<
   "three-way comparison between pointer and zero">;
+def ext_typecheck_compare_complete_incomplete_pointers : Extension<
+  "pointer comparisons before C11 "
+  "need to be between two complete or two incomplete types; "
+  "%0 is %select{|in}2complete and "
+  "%1 is %select{|in}3complete">,
+  InGroup;
 def ext_typecheck_ordered_comparison_of_function_pointers : ExtWarn<
   "ordered comparison of function pointers (%0 and %1)">,
   InGroup>;


Index: clang/test/Sema/complete-incomplete-pointer-relational-c99.c
===
--- /dev/null
+++ clang/test/Sema/complete-incomplete-pointer-relational-c99.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c99 -Wc11-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c89 -Wc11-extensions %s
+
+int incomplete[]; // expected-warning {{tentative array definition assumed to have one element}}
+int complete[6];
+
+int test_comparison_between_incomplete_and_complete_pointer() {
+  return (&incomplete < &complete) &&  // expected-

[PATCH] D81658: [OPENMP50]Codegen for scan directive in for simd regions.

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev created this revision.
ABataev added a reviewer: jdoerfert.
Herald added subscribers: sstefan1, guansong, yaxunl.
Herald added a project: clang.

Added codegen for scan directives in parallel for regions.

Emits the code for the directive with inscan reductions.
Original code:

   #pragma omp for simd reduction(inscan, op : ...)
  for(...) {
;
#pragma omp scan (in)exclusive(...)

  }

is transformed to something:

  size num_iters = ;
   buffer[num_iters];
   #pragma omp for simd
  for (i: 0..) {
;
buffer[i] = red;
  }
   #pragma omp barrier
  for (int k = 0; k != ceil(log2(num_iters)); ++k)
  for (size cnt = last_iter; cnt >= pow(2, k); --k)
buffer[i] op= buffer[i-pow(2,k)];
   #pragma omp for simd
  for (0..) {
red = InclusiveScan ? buffer[i] : buffer[i-1];
;
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81658

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/for_simd_scan_codegen.cpp

Index: clang/test/OpenMP/for_simd_scan_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/for_simd_scan_codegen.cpp
@@ -0,0 +1,312 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -std=c++11 -triple x86_64-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50 -x c++ -triple x86_64-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
+// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+void foo();
+void bar();
+
+// CHECK: define void @{{.*}}baz{{.*}}(i32 %n)
+void baz(int n) {
+  static float a[10];
+  static double b;
+  // CHECK: call i8* @llvm.stacksave()
+  // CHECK: [[A_BUF_SIZE:%.+]] = mul nuw i64 10, [[NUM_ELEMS:%[^,]+]]
+
+  // float a_buffer[10][n];
+  // CHECK: [[A_BUF:%.+]] = alloca float, i64 [[A_BUF_SIZE]],
+
+  // double b_buffer[10];
+  // CHECK: [[B_BUF:%.+]] = alloca double, i64 10,
+#pragma omp for simd reduction(inscan, +:a[:n], b)
+  for (int i = 0; i < 10; ++i) {
+// CHECK: call void @__kmpc_for_static_init_4(
+// CHECK: call i8* @llvm.stacksave()
+// CHECK: store float 0.00e+00, float* %
+// CHECK: store double 0.00e+00, double* [[B_PRIV_ADDR:%.+]],
+// CHECK: br label %[[DISPATCH:[^,]+]]
+// CHECK: [[INPUT_PHASE:.+]]:
+// CHECK: call void @{{.+}}foo{{.+}}()
+
+// a_buffer[i][0..n] = a_priv[[0..n];
+// CHECK: [[BASE_IDX_I:%.+]] = load i32, i32* [[IV_ADDR:%.+]],
+// CHECK: [[BASE_IDX:%.+]] = zext i32 [[BASE_IDX_I]] to i64
+// CHECK: [[IDX:%.+]] = mul nsw i64 [[BASE_IDX]], [[NUM_ELEMS]]
+// CHECK: [[A_BUF_IDX:%.+]] = getelementptr inbounds float, float* [[A_BUF]], i64 [[IDX]]
+// CHECK: [[A_PRIV:%.+]] = getelementptr inbounds [10 x float], [10 x float]* [[A_PRIV_ADDR:%.+]], i64 0, i64 0
+// CHECK: [[BYTES:%.+]] = mul nuw i64 [[NUM_ELEMS:%.+]], 4
+// CHECK: [[DEST:%.+]] = bitcast float* [[A_BUF_IDX]] to i8*
+// CHECK: [[SRC:%.+]] = bitcast float* [[A_PRIV]] to i8*
+// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}[[DEST]], i8* {{.*}}[[SRC]], i64 [[BYTES]], i1 false)
+
+// b_buffer[i] = b_priv;
+// CHECK: [[B_BUF_IDX:%.+]] = getelementptr inbounds double, double* [[B_BUF]], i64 [[BASE_IDX]]
+// CHECK: [[B_PRIV:%.+]] = load double, double* [[B_PRIV_ADDR]],
+// CHECK: store double [[B_PRIV]], double* [[B_BUF_IDX]],
+// CHECK: br label %[[LOOP_CONTINUE:.+]]
+
+// CHECK: [[DISPATCH]]:
+// CHECK: br label %[[INPUT_PHASE]]
+// CHECK: [[LOOP_CONTINUE]]:
+// CHECK: call void @llvm.stackrestore(i8* %
+// CHECK: call void @__kmpc_for_static_fini(
+// CHECK: call void @__kmpc_barrier(
+foo();
+#pragma omp scan inclusive(a[:n], b)
+// CHECK: [[LOG2_10:%.+]] = call double @llvm.log2.f64(double 1.00e+01)
+// CHECK: [[CEIL_LOG2_10:%.+]] = call double @llvm.ceil.f64(double [[LOG2_10]])
+// CHECK: [[CEIL_LOG2_10_INT:%.+]] = fptoui double [[CEIL_LOG2_10]] to i32
+// CHECK: br label %[[OUTER_BODY:[^,]+]]
+// CHECK: [[OUTER_BODY]]:
+// CHECK: [[K:%.+]] = phi i32 [ 0, %{{.+}} ], [ [[K_NEXT:%.+]], %{{.+}} ]
+// CHECK: [[K2POW:%.+]] = phi i64 [ 1, %{{.+}} ], [ [[K2POW_NEXT:%.+]], %{{.+}} ]
+// CHECK: [[CMP:%.+]] = icmp uge i64 9, [[K2POW]]
+// CHECK: br i1 [[CMP]], label %[[INNER_BODY:[^,]+]], label %[[INNER_EXI

[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 270143.
pratlucas added a comment.

Fixing failure on CodeGen/ARM/GlobalISel/arm-unsupported.ll and making 
clang-format happy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169

Files:
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/CodeGen/GlobalISel/CallLowering.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/Target/ARM/ARMCallLowering.cpp
  llvm/lib/Target/ARM/ARMCallingConv.cpp
  llvm/lib/Target/ARM/ARMCallingConv.td
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMISelLowering.h
  llvm/test/CodeGen/ARM/GlobalISel/arm-unsupported.ll
  llvm/test/CodeGen/ARM/fp16-args.ll
  llvm/test/CodeGen/ARM/fp16-bitcast.ll
  llvm/test/CodeGen/ARM/fp16-promote.ll
  llvm/test/CodeGen/ARM/fp16-vminmaxnm-safe.ll
  llvm/test/CodeGen/ARM/vecreduce-fadd-legalization-strict.ll
  llvm/test/CodeGen/ARM/vecreduce-fmul-legalization-strict.ll
  llvm/test/CodeGen/Thumb2/mve-shuffle.ll
  llvm/test/CodeGen/Thumb2/mve-vdup.ll
  llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll

Index: llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
===
--- llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
+++ llvm/test/CodeGen/Thumb2/mve-vecreduce-fminmax.ll
@@ -78,7 +78,6 @@
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
 ; CHECK-NEXT:vminnm.f16 s0, s0, s2
-; CHECK-NEXT:vstr.16 s0, [r0]
 ; CHECK-NEXT:bx lr
 ; CHECK-NEXT:.p2align 1
 ; CHECK-NEXT:  @ %bb.1:
@@ -103,7 +102,6 @@
 ; CHECK-NEXT:vminnm.f16 s4, s4, s6
 ; CHECK-NEXT:vminnm.f16 s4, s4, s3
 ; CHECK-NEXT:vminnm.f16 s0, s4, s0
-; CHECK-NEXT:vstr.16 s0, [r0]
 ; CHECK-NEXT:bx lr
 entry:
   %z = call fast half @llvm.experimental.vector.reduce.fmin.v8f16(<8 x half> %x)
@@ -125,7 +123,6 @@
 ; CHECK-FP-NEXT:vminnm.f16 s4, s4, s6
 ; CHECK-FP-NEXT:vminnm.f16 s4, s4, s3
 ; CHECK-FP-NEXT:vminnm.f16 s0, s4, s0
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v16f16:
@@ -169,7 +166,6 @@
 ; CHECK-NOFP-NEXT:vminnm.f16 s8, s8, s10
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s4
 ; CHECK-NOFP-NEXT:vminnm.f16 s0, s8, s0
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call fast half @llvm.experimental.vector.reduce.fmin.v16f16(<16 x half> %x)
@@ -309,20 +305,20 @@
 define arm_aapcs_vfpcc half @fmin_v4f16_nofast(<4 x half> %x) {
 ; CHECK-FP-LABEL: fmin_v4f16_nofast:
 ; CHECK-FP:   @ %bb.0: @ %entry
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov.u16 r1, q0[1]
-; CHECK-FP-NEXT:vdup.16 q1, r1
+; CHECK-FP-NEXT:vmov.u16 r0, q0[1]
+; CHECK-FP-NEXT:vdup.16 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
+; CHECK-FP-NEXT:@ kill: def $s0 killed $s0 killed $q0
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v4f16_nofast:
 ; CHECK-NOFP:   @ %bb.0: @ %entry
-; CHECK-NOFP-NEXT:vmov r1, s1
+; CHECK-NOFP-NEXT:vmov r0, s1
 ; CHECK-NOFP-NEXT:vmovx.f16 s10, s0
-; CHECK-NOFP-NEXT:vdup.32 q1, r1
+; CHECK-NOFP-NEXT:vdup.32 q1, r0
 ; CHECK-NOFP-NEXT:vmovx.f16 s8, s4
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s10
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
@@ -333,7 +329,6 @@
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s0
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s8
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call half @llvm.experimental.vector.reduce.fmin.v4f16(<4 x half> %x)
@@ -346,13 +341,13 @@
 ; CHECK-FP-NEXT:vmov.f64 d2, d1
 ; CHECK-FP-NEXT:vmov.f32 s5, s3
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov r1, s1
-; CHECK-FP-NEXT:vdup.32 q1, r1
+; CHECK-FP-NEXT:vmov r0, s1
+; CHECK-FP-NEXT:vdup.32 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov.u16 r1, q0[1]
-; CHECK-FP-NEXT:vdup.16 q1, r1
+; CHECK-FP-NEXT:vmov.u16 r0, q0[1]
+; CHECK-FP-NEXT:vdup.16 q1, r0
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vstr.16 s0, [r0]
+; CHECK-FP-NEXT:@ kill: def $s0 killed $s0 killed $q0
 ; CHECK-FP-NEXT:bx lr
 ;
 ; CHECK-NOFP-LABEL: fmin_v8f16_nofast:
@@ -384,7 +379,6 @@
 ; CHECK-NOFP-NEXT:vcmp.f16 s8, s0
 ; CHECK-NOFP-NEXT:vmrs APSR_nzcv, fpscr
 ; CHECK-NOFP-NEXT:vselgt.f16 s0, s0, s8
-; CHECK-NOFP-NEXT:vstr.16 s0, [r0]
 ; CHECK-NOFP-NEXT:bx lr
 entry:
   %z = call half @llvm.experimental.vector.reduce.fmin.v8f16(<8 x half> %x)
@@ -398,13 +392,13 @@
 ; CHECK-FP-NEXT:vmov.f64 d2, d1
 ; CHECK-FP-NEXT:vmov.f32 s5, s3
 ; CHECK-FP-NEXT:vminnm.f16 q0, q0, q1
-; CHECK-FP-NEXT:vmov r1, s

[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Rodrigo Caetano Rocha via Phabricator via cfe-commits
rcorcs added a comment.

The way I see it, with size level for LTO, we could have a different LTO 
optimization pipeline for size or runtime performance. For example, we could 
have a different tuning for inlining,  vectorization, etc. We could also use 
the size level to automatically enable optimizations such as HotColdSplitting, 
MergeFunctions, etc., instead of relying on specific enabling flags. We could 
also have other size-specific optimizations in the future, such as 
MergeSimilarFunctions (https://reviews.llvm.org/D52896).

I believe that function attributes for size are useful for optimizing cold 
functions that have been outlined by HotColdSplitting, for example. However, an 
ideal size level LTO would involve a different optimization pipeline and also a 
different tuning of those optimizations.

For example, when optimizing for size, we could disable loop vectorization and 
have SLP optimizing based on the code-size cost model. We could also have 
MergeFunctions enabled with Os and both MergeFunctions and 
MergeSimilarFunctions enabled with Oz. A similar logic could be applied to 
other optimizations, such as Inlining, HotColdSplitting, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[clang] fac7259 - Revert "[OPENMP50]Codegen for scan directive in simd loops."

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T11:22:51-04:00
New Revision: fac7259c81671c37140374f3e6ec1fc7472c677c

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

LOG: Revert "[OPENMP50]Codegen for scan directive in simd loops."

This reverts commit fb80e67f10eea7177b0ff9c618c8231363b6f2fc to resolve
the issue with asan buildbots.

Added: 


Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 
clang/test/OpenMP/scan_codegen.cpp



diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 1bdb1672b2f4..e9569d4e5658 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -2083,15 +2083,6 @@ void CodeGenFunction::EmitOMPSimdInit(const 
OMPLoopDirective &D,
   if (const auto *C = D.getSingleClause())
 if (C->getKind() == OMPC_ORDER_concurrent)
   LoopStack.setParallel(/*Enable=*/true);
-  if ((D.getDirectiveKind() == OMPD_simd ||
-   (getLangOpts().OpenMPSimd &&
-isOpenMPSimdDirective(D.getDirectiveKind( &&
-  llvm::any_of(D.getClausesOfKind(),
-   [](const OMPReductionClause *C) {
- return C->getModifier() == OMPC_REDUCTION_inscan;
-   }))
-// Disable parallel access in case of prefix sum.
-LoopStack.setParallel(/*Enable=*/false);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(
@@ -2287,8 +2278,6 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const 
OMPLoopDirective &S,
 }
 
 void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) {
-  ParentLoopDirectiveForScanRegion ScanRegion(*this, S);
-  OMPFirstScanLoop = true;
   auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
 emitOMPSimdRegion(CGF, S, Action);
   };
@@ -4210,15 +4199,14 @@ void CodeGenFunction::EmitOMPDepobjDirective(const 
OMPDepobjDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective &S) {
-  if (!OMPParentLoopDirectiveForScan)
+  // Do not emit code for non-simd directives in simd-only mode.
+  if (getLangOpts().OpenMPSimd && !OMPParentLoopDirectiveForScan)
 return;
   const OMPExecutableDirective &ParentDir = *OMPParentLoopDirectiveForScan;
-  bool IsInclusive = S.hasClausesOfKind();
   SmallVector Shareds;
   SmallVector Privates;
   SmallVector LHSs;
   SmallVector RHSs;
-  SmallVector ReductionOps;
   SmallVector CopyOps;
   SmallVector CopyArrayTemps;
   SmallVector CopyArrayElems;
@@ -4229,109 +4217,13 @@ void CodeGenFunction::EmitOMPScanDirective(const 
OMPScanDirective &S) {
 Privates.append(C->privates().begin(), C->privates().end());
 LHSs.append(C->lhs_exprs().begin(), C->lhs_exprs().end());
 RHSs.append(C->rhs_exprs().begin(), C->rhs_exprs().end());
-ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
 CopyOps.append(C->copy_ops().begin(), C->copy_ops().end());
 CopyArrayTemps.append(C->copy_array_temps().begin(),
   C->copy_array_temps().end());
 CopyArrayElems.append(C->copy_array_elems().begin(),
   C->copy_array_elems().end());
   }
-  if (ParentDir.getDirectiveKind() == OMPD_simd ||
-  (getLangOpts().OpenMPSimd &&
-   isOpenMPSimdDirective(ParentDir.getDirectiveKind( {
-// For simd directive and simd-based directives in simd only mode, use the
-// following codegen:
-// int x = 0;
-// #pragma omp simd reduction(inscan, +: x)
-// for (..) {
-//   
-//   #pragma omp scan inclusive(x)
-//   
-//  }
-// is transformed to:
-// int x = 0;
-// for (..) {
-//   int x_priv = 0;
-//   
-//   x = x_priv + x;
-//   x_priv = x;
-//   
-// }
-// and
-// int x = 0;
-// #pragma omp simd reduction(inscan, +: x)
-// for (..) {
-//   
-//   #pragma omp scan exclusive(x)
-//   
-// }
-// to
-// int x = 0;
-// for (..) {
-//   int x_priv = 0;
-//   
-//   int temp = x;
-//   x = x_priv + x;
-//   x_priv = temp;
-//   
-// }
-llvm::BasicBlock *OMPScanReduce = createBasicBlock("omp.inscan.reduce");
-EmitBranch(IsInclusive
-   ? OMPScanReduce
-   : BreakContinueStack.back().ContinueBlock.getBlock());
-EmitBlock(OMPScanDispatch);
-{
-  // New scope for correct construction/destruction of temp variables for
-  // exclusive scan.
-  LexicalScope Scope(*this, S.getSourceRange());
-  EmitBranch(IsInclusive ? OMPBeforeScanBlock : OMPAfterScanBlock);
-  EmitBlock(OMPScanReduce);
-  if (!IsInclusive) {
-// Create temp var and copy LHS value to this temp value.
-// TMP = LHS;
-for (unsigned I = 0, E = CopyArrayElems.s

[PATCH] D81428: [ARM] Moving CMSE handling of half arguments and return to the backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 270149.
pratlucas added a comment.

Rebasing and simplifying function attributes on test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81428

Files:
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll

Index: llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
===
--- llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
+++ llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
@@ -4,13 +4,13 @@
 ; RUN: llc %s -o - -mtriple=thumbebv8m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
 ; RUN:   FileCheck %s --check-prefix=CHECK-8M --check-prefix=CHECK-8M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-BE
 
 define float @f1(float (float)* nocapture %fptr) #0 {
 ; CHECK-8M-LABEL: f1:
@@ -809,3 +809,443 @@
   ret void
 }
 
+define half @h1(half (half)* nocapture %hptr) "cmse_nonsecure_entry" nounwind {
+; CHECK-8M-LABEL: h1:
+; CHECK-8M:   @ %bb.0:
+; CHECK-8M-NEXT:push {r7, lr}
+; CHECK-8M-NEXT:vldr s0, .LCPI11_0
+; CHECK-8M-NEXT:blx r0
+; CHECK-8M-NEXT:vmov r0, s0
+; CHECK-8M-NEXT:uxth r0, r0
+; CHECK-8M-NEXT:vmov s0, r0
+; CHECK-8M-NEXT:pop.w {r7, lr}
+; CHECK-8M-NEXT:mrs r12, control
+; CHECK-8M-NEXT:tst.w r12, #8
+; CHECK-8M-NEXT:beq .LBB11_2
+; CHECK-8M-NEXT:  @ %bb.1:
+; CHECK-8M-NEXT:vmrs r12, fpscr
+; CHECK-8M-NEXT:vmov s1, lr
+; CHECK-8M-NEXT:vmov d1, lr, lr
+; CHECK-8M-NEXT:vmov d2, lr, lr
+; CHECK-8M-NEXT:vmov d3, lr, lr
+; CHECK-8M-NEXT:vmov d4, lr, lr
+; CHECK-8M-NEXT:vmov d5, lr, lr
+; CHECK-8M-NEXT:vmov d6, lr, lr
+; CHECK-8M-NEXT:vmov d7, lr, lr
+; CHECK-8M-NEXT:bic r12, r12, #159
+; CHECK-8M-NEXT:bic r12, r12, #4026531840
+; CHECK-8M-NEXT:vmsr fpscr, r12
+; CHECK-8M-NEXT:  .LBB11_2:
+; CHECK-8M-NEXT:mov r0, lr
+; CHECK-8M-NEXT:mov r1, lr
+; CHECK-8M-NEXT:mov r2, lr
+; CHECK-8M-NEXT:mov r3, lr
+; CHECK-8M-NEXT:mov r12, lr
+; CHECK-8M-NEXT:msr apsr_nzcvqg, lr
+; CHECK-8M-NEXT:bxns lr
+; CHECK-8M-NEXT:.p2align 2
+; CHECK-8M-NEXT:  @ %bb.3:
+; CHECK-8M-NEXT:  .LCPI11_0:
+; CHECK-8M-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-NO-MVE-LABEL: h1:
+; CHECK-NO-MVE:   @ %bb.0:
+; CHECK-NO-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-NO-MVE-NEXT:push {r7, lr}
+; CHECK-NO-MVE-NEXT:sub sp, #4
+; CHECK-NO-MVE-NEXT:vldr s0, .LCPI11_0
+; CHECK-NO-MVE-NEXT:blx r0
+; CHECK-NO-MVE-NEXT:vmov r0, s0
+; CHECK-NO-MVE-NEXT:uxth r0, r0
+; CHECK-NO-MVE-NEXT:vmov s0, r0
+; CHECK-NO-MVE-NEXT:add sp, #4
+; CHECK-NO-MVE-NEXT:pop.w {r7, lr}
+; CHECK-NO-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-NO-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-NO-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-NO-MVE-NEXT:bxns lr
+; CHECK-NO-MVE-NEXT:.p2align 2
+; CHECK-NO-MVE-NEXT:  @ %bb.1:
+; CHECK-NO-MVE-NEXT:  .LCPI11_0:
+; CHECK-NO-MVE-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-MVE-LABEL: h1:
+; CHECK-MVE:   @ %bb.0:
+; CHECK-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-MVE-NEXT:push {r7, lr}
+; CHECK-MVE-NEXT:sub sp, #4
+; CHECK-MVE-NEXT:vmov.f16 s0, #1.00e+01
+; CHECK-MVE-NEXT:vmov.f16 r1, s0
+; CHECK-MVE-NEXT:vmov s0, r1
+; CHECK-MVE-NEXT:blx r0
+; CHECK-MVE-NEXT:vmov.f16 r0, s0
+; CHECK-MVE-NEXT:vmov s0, r0
+; CHECK-MVE-NEXT:add sp, #4
+; CHECK-MVE-NEXT:pop.w {r7, lr}
+; CHECK-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-MVE-NEXT:bxns lr
+  %call = call half %hptr(half 10.0) nounwind
+  ret half %call
+}
+
+define half @h2(half (half)* nocapture %hptr

[PATCH] D81428: [ARM] Moving CMSE handling of half arguments and return to the backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 270160.
pratlucas added a comment.

Addressing review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81428

Files:
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll

Index: llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
===
--- llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
+++ llvm/test/CodeGen/ARM/cmse-clear-float-hard.ll
@@ -4,13 +4,13 @@
 ; RUN: llc %s -o - -mtriple=thumbebv8m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
 ; RUN:   FileCheck %s --check-prefix=CHECK-8M --check-prefix=CHECK-8M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+fp-armv8d16sp,+dsp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-NO-MVE --check-prefix=CHECK-81M-BE
 ; RUN: llc %s -o - -mtriple=thumbv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-LE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-LE
 ; RUN: llc %s -o - -mtriple=thumbebv8.1m.main -mattr=+mve.fp -float-abi=hard | \
-; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-81M-BE
+; RUN:   FileCheck %s --check-prefix=CHECK-81M --check-prefix=CHECK-MVE --check-prefix=CHECK-81M-BE
 
 define float @f1(float (float)* nocapture %fptr) #0 {
 ; CHECK-8M-LABEL: f1:
@@ -809,3 +809,443 @@
   ret void
 }
 
+define half @h1(half (half)* nocapture %hptr) "cmse_nonsecure_entry" nounwind {
+; CHECK-8M-LABEL: h1:
+; CHECK-8M:   @ %bb.0:
+; CHECK-8M-NEXT:push {r7, lr}
+; CHECK-8M-NEXT:vldr s0, .LCPI11_0
+; CHECK-8M-NEXT:blx r0
+; CHECK-8M-NEXT:vmov r0, s0
+; CHECK-8M-NEXT:uxth r0, r0
+; CHECK-8M-NEXT:vmov s0, r0
+; CHECK-8M-NEXT:pop.w {r7, lr}
+; CHECK-8M-NEXT:mrs r12, control
+; CHECK-8M-NEXT:tst.w r12, #8
+; CHECK-8M-NEXT:beq .LBB11_2
+; CHECK-8M-NEXT:  @ %bb.1:
+; CHECK-8M-NEXT:vmrs r12, fpscr
+; CHECK-8M-NEXT:vmov s1, lr
+; CHECK-8M-NEXT:vmov d1, lr, lr
+; CHECK-8M-NEXT:vmov d2, lr, lr
+; CHECK-8M-NEXT:vmov d3, lr, lr
+; CHECK-8M-NEXT:vmov d4, lr, lr
+; CHECK-8M-NEXT:vmov d5, lr, lr
+; CHECK-8M-NEXT:vmov d6, lr, lr
+; CHECK-8M-NEXT:vmov d7, lr, lr
+; CHECK-8M-NEXT:bic r12, r12, #159
+; CHECK-8M-NEXT:bic r12, r12, #4026531840
+; CHECK-8M-NEXT:vmsr fpscr, r12
+; CHECK-8M-NEXT:  .LBB11_2:
+; CHECK-8M-NEXT:mov r0, lr
+; CHECK-8M-NEXT:mov r1, lr
+; CHECK-8M-NEXT:mov r2, lr
+; CHECK-8M-NEXT:mov r3, lr
+; CHECK-8M-NEXT:mov r12, lr
+; CHECK-8M-NEXT:msr apsr_nzcvqg, lr
+; CHECK-8M-NEXT:bxns lr
+; CHECK-8M-NEXT:.p2align 2
+; CHECK-8M-NEXT:  @ %bb.3:
+; CHECK-8M-NEXT:  .LCPI11_0:
+; CHECK-8M-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-NO-MVE-LABEL: h1:
+; CHECK-NO-MVE:   @ %bb.0:
+; CHECK-NO-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-NO-MVE-NEXT:push {r7, lr}
+; CHECK-NO-MVE-NEXT:sub sp, #4
+; CHECK-NO-MVE-NEXT:vldr s0, .LCPI11_0
+; CHECK-NO-MVE-NEXT:blx r0
+; CHECK-NO-MVE-NEXT:vmov r0, s0
+; CHECK-NO-MVE-NEXT:uxth r0, r0
+; CHECK-NO-MVE-NEXT:vmov s0, r0
+; CHECK-NO-MVE-NEXT:add sp, #4
+; CHECK-NO-MVE-NEXT:pop.w {r7, lr}
+; CHECK-NO-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-NO-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-NO-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-NO-MVE-NEXT:bxns lr
+; CHECK-NO-MVE-NEXT:.p2align 2
+; CHECK-NO-MVE-NEXT:  @ %bb.1:
+; CHECK-NO-MVE-NEXT:  .LCPI11_0:
+; CHECK-NO-MVE-NEXT:.long 0x4900 @ float 2.61874657E-41
+;
+; CHECK-MVE-LABEL: h1:
+; CHECK-MVE:   @ %bb.0:
+; CHECK-MVE-NEXT:vstr fpcxtns, [sp, #-4]!
+; CHECK-MVE-NEXT:push {r7, lr}
+; CHECK-MVE-NEXT:sub sp, #4
+; CHECK-MVE-NEXT:vmov.f16 s0, #1.00e+01
+; CHECK-MVE-NEXT:vmov.f16 r1, s0
+; CHECK-MVE-NEXT:vmov s0, r1
+; CHECK-MVE-NEXT:blx r0
+; CHECK-MVE-NEXT:vmov.f16 r0, s0
+; CHECK-MVE-NEXT:vmov s0, r0
+; CHECK-MVE-NEXT:add sp, #4
+; CHECK-MVE-NEXT:pop.w {r7, lr}
+; CHECK-MVE-NEXT:vscclrm {s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, vpr}
+; CHECK-MVE-NEXT:vldr fpcxtns, [sp], #4
+; CHECK-MVE-NEXT:clrm {r0, r1, r2, r3, r12, apsr}
+; CHECK-MVE-NEXT:bxns lr
+  %call = call half %hptr(half 10.0) nounwind
+  ret half %call
+}
+
+define half @h2(half (half)* nocapture %hptr) nounwind {
+; CHECK-8M-LA

[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

Sorry I haven't had a chance to review this yet. Added @mtrofin who recently 
added the OptimizationLevel class that this is leveraging, and @yamauchi who 
has also been looking at size optimizations in llvm.

At a first glance it isn't clear to me how much of this is NFC related 
refactoring/cleanup vs behavior change. If it has both, it would be helpful to 
split into an NFC patch first and then a follow on with actual behavior 
changes. Can you clarify?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D81428: [ARM] Moving CMSE handling of half arguments and return to the backend

2020-06-11 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas marked 4 inline comments as done.
pratlucas added inline comments.



Comment at: llvm/lib/Target/ARM/ARMISelLowering.cpp:2267
 
+// Mask f16 arguments if this is a CMSE nonsecure call
+auto ArgVT = Outs[realArgIdx].ArgVT;

ostannard wrote:
> Could this be done more efficiently by changing the ANY_EXTEND above to a 
> ZERO_EXTEND when this is a CMSE call?
Now that the `fp16` type convertion on D75169 was updated to use 
`VMOVhr`/`VMOVrh`, I've updated this patch to only use and `AND` masking when 
the argument are extended by `getCopyToParts`/`getCopyFromParts` prior to the 
calling convention lowering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81428



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


[PATCH] D78122: [analyzer][Nullability] Don't emit under the checker name NullabilityBase

2020-06-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

@NoQ Have you unearthed anything on this matter? Do I need to step in/revert?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78122



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 270161.
balazske added a comment.

- Added tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407

Files:
  clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
  clang/test/Analysis/stream-note.c
  clang/test/Analysis/stream.c

Index: clang/test/Analysis/stream.c
===
--- clang/test/Analysis/stream.c
+++ clang/test/Analysis/stream.c
@@ -139,7 +139,7 @@
   if (!p)
 return;
   if(c)
-return; // expected-warning {{Opened File never closed. Potential Resource leak}}
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
   fclose(p);
 }
 
@@ -240,3 +240,26 @@
   fwrite("1", 1, 1, F); // expected-warning {{might be 'indeterminate'}}
   fclose(F);
 }
+
+int Test;
+_Noreturn void handle_error();
+
+void check_leak_noreturn_1() {
+  FILE *F1 = tmpfile();
+  if (!F1)
+return;
+  if (Test == 1) {
+handle_error(); // no warning
+  }
+  rewind(F1);
+} // expected-warning {{Opened stream never closed. Potential resource leak}}
+
+void check_leak_noreturn_2() {
+  FILE *F1 = tmpfile();
+  if (!F1)
+return;
+  if (Test == 1) {
+return; // expected-warning {{Opened stream never closed. Potential resource leak}}
+  }
+  rewind(F1);
+} // expected-warning {{Opened stream never closed. Potential resource leak}}
Index: clang/test/Analysis/stream-note.c
===
--- /dev/null
+++ clang/test/Analysis/stream-note.c
@@ -0,0 +1,48 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.unix.Stream -analyzer-store region -analyzer-output text -verify %s
+
+#include "Inputs/system-header-simulator.h"
+
+void check_note_at_correct_open() {
+  FILE *F1 = tmpfile(); // expected-note {{Stream opened here}}
+  if (!F1)
+// expected-note@-1 {{'F1' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  FILE *F2 = tmpfile();
+  if (!F2) {
+// expected-note@-1 {{'F2' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+fclose(F1);
+return;
+  }
+  rewind(F2);
+  fclose(F2);
+  rewind(F1);
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_fopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
+
+void check_note_freopen() {
+  FILE *F = fopen("file", "r"); // expected-note {{Stream opened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+  F = freopen(0, "w", F); // expected-note {{Stream reopened here}}
+  if (!F)
+// expected-note@-1 {{'F' is non-null}}
+// expected-note@-2 {{Taking false branch}}
+return;
+}
+// expected-warning@-1 {{Opened stream never closed. Potential resource leak}}
+// expected-note@-2 {{Opened stream never closed. Potential resource leak}}
Index: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -216,8 +216,8 @@
   "Read function called when stream is in EOF state. "
   "Function has no effect."};
   BuiltinBug BT_ResourceLeak{
-  this, "Resource Leak",
-  "Opened File never closed. Potential Resource leak."};
+  this, "Resource leak",
+  "Opened stream never closed. Potential resource leak."};
 
 public:
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
@@ -365,6 +365,20 @@
 
 return FnDescriptions.lookup(Call);
   }
+
+  /// Generate a message for BugReporterVisitor if the stored symbol is
+  /// marked as interesting by the actual bug report.
+  struct NoteFn {
+SymbolRef StreamSym;
+std::string Message;
+
+std::string operator()(PathSensitiveBugReport &BR) const {
+  if (BR.isInteresting(StreamSym))
+return Message;
+
+  return "";
+}
+  };
 };
 
 } // end anonymous namespace
@@ -421,7 +435,8 @@
   StateNull =
   StateNull->set(RetSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{RetSym, "Stream opened here"});
+  C.addTransition(StateNotNull, T);
   C.addTransition(StateNull);
 }
 
@@ -476,7 +491,8 @@
   StateRetNull =
   StateRetNull->set(StreamSym, StreamState::getOpenFailed(Desc));
 
-  C.addTransition(StateRetNotNull);
+  const NoteTag *T = C.getNoteTag(NoteFn{StreamSym

[PATCH] D78024: [FileCheck] - Fix the false positive when -implicit-check-not is used with an unknown -check-prefix.

2020-06-11 Thread Xing GUO via Phabricator via cfe-commits
Higuoxing added a comment.
Herald added a project: LLVM.

> btw, do you know why FileCheck seems intentionally allows the case when 
> --check-prefixes=KNOWN,UNKNOWN?
>  I've mentioned in the description of D78110 
>  that there are about 1000 tests that have 
> this. but is it a feature or a something that we might want to fix?>

I noticed this strange behavior of `FileCheck` as well. When I try to fix it, 
there are lots of test failures. /subscribe


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78024



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


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Mircea Trofin via Phabricator via cfe-commits
mtrofin added inline comments.



Comment at: llvm/include/llvm/IR/PassManager.h:413
 
+/// LLVM-provided high-level optimization levels.
+///

I think this change - moving OptimizationLevel out - should be in its own 
patch, to avoid noise.



Comment at: llvm/include/llvm/LTO/legacy/ThinLTOCodeGenerator.h:22
 #include "llvm/IR/ModuleSummaryIndex.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/LTO/LTO.h"

It's unfortunate we now need to pull pass management into places that didn't 
have that dependency. IIUC, the goal of this overall effort includes piping 
though the full user-requested optimization parameters (i.e. both speed and 
size). Given the likely diversity of the consumers, it may make sense to move 
OptimizationLevel in its own header?



Comment at: llvm/tools/opt/CMakeLists.txt:20
   ObjCARCOpts
+  Passes
   Remarks

Nit: make this change separately, and since it's just a style change, it can 
probably be just submitted with no review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D80730: [OPENMP50]Codegen for use_device_addr clauses.

2020-06-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Hi, you can drop `Reviewers:` `Subscribers:` `Tags:` and the text `Summary:` 
with the following script

  arcfilter () {
  arc amend
  git log -1 --pretty=%B | awk '/Reviewers:|Subscribers:/{p=1} 
/Reviewed By:|Differential Revision:/{p=0} !p && !/^Summary:$/ {sub(/^Summary: 
/,"");print}' | git commit --amend --date=now -F -
  }

`Reviewed By: ` is considered important by some people. You should keep the 
tag. (I have updated my script to use `--date=now` (setting author date to 
committer date))

`https://reviews.llvm.org/D80978` contains a git pre-push hook to automate this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80730



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


[PATCH] D81223: Size LTO (1/3): Standardizing the use of OptimizationLevel

2020-06-11 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In D81223#2087660 , @rcorcs wrote:

> The way I see it, with size level for LTO, we could have a different LTO 
> optimization pipeline for size or runtime performance.


So this is the important point to settle before going on with any patch: this 
isn't how LTO is setup today.

>   For example, we could have a different tuning for inlining,  vectorization, 
> etc. 

All these are covered by the function attributes already.

> We could also use the size level to automatically enable optimizations such 
> as HotColdSplitting, MergeFunctions, etc., instead of relying on specific 
> enabling flags. We could also have other size-specific optimizations in the 
> future, such as MergeSimilarFunctions (https://reviews.llvm.org/D52896).

All these could be in the LTO pipeline and driven by the attribute as well.

> I believe that function attributes for size are useful for optimizing cold 
> functions that have been outlined by HotColdSplitting, for example.

The attribute is added by the frontend and can change per translation-unit / 
per function though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81223



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


[PATCH] D75169: [ARM] Supporting lowering of half-precision FP arguments and returns in AArch32's backend

2020-06-11 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:524
+  CallConv))
+return;
   EVT ValueVT = Val.getValueType();

efriedma wrote:
> pratlucas wrote:
> > efriedma wrote:
> > > I'm not sure I understand why the standard 
> > > getCopyFromParts/getCopyToParts codepath doesn't work. Is the issue that 
> > > it uses FP_ROUND/FP_EXTEND to promote from f16 to f32?
> > Yes, the issue is the usage of FP_ROUND/FP_EXTEND indeed. Those cause the 
> > argument to be converted from f16 into f32 - with a `vcvtb.f16.f32` for 
> > instance - instead of simply being placed the value in the LSBs as required 
> > by the AAPCS.
> That makes sense.
> 
> It feels a little weird to have a TLI method to do the splitting, as opposed 
> to adding an extra check to the shared codepath, but I guess this way is more 
> flexible if someone else needs a similar change in the future.
> 
> One other thing to consider is that we could make f16 a "legal" type for all 
> ARM subtargets with floating-point registers, regardless of whether the 
> target actually has native f16 arithmetic instructions. We do this on 
> AArch64.  That would reduce the number of different ways to handle f16 
> values, and I think this change would be unnecessary.
> One other thing to consider is that we could make f16 a "legal" type for all 
> ARM subtargets with floating-point registers, regardless of whether the 
> target actually has native f16 arithmetic instructions. We do this on AArch64.

I am partly guilty here and there when I added _Float16 and v8.2 FP16 support. 
When I did this, life was easy for AArch64, because it doesn't have a soft 
float ABI support and it has or hasn't got FP16 support, and so everything is 
straightforward. Life became an awful lot less pleasant for AArch32, because of 
the hard/soft float and different FP16 support, i.e. there are early FPU 
versions with limited fp16 support for the storage only type (some conversion), 
and from v8.2 and up the native fp16 instruction. It's been a few years now so 
can't remember exactly, which is a bit unhelpful,  but somewhere here for these 
corner cases I got into trouble by treating f16 as a legal type.

But in case you're interested / this might be useful, I think this is the mail 
that I wrote to the llvm dev list when I got into trouble here (which I 
actually need to reread too for details):

http://lists.llvm.org/pipermail/llvm-dev/2018-January/120537.html

and as referred in that mail, earlier revisions of this:

https://reviews.llvm.org/D38315

might have taken exactly that approach. Long story short, I am not saying we 
shouldn't do it, just pointing out some background info. And since we're all a 
few years wiser now since that happened, perhaps we should try again ;-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75169



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D81407#2087624 , @balazske wrote:

> - Report every path of resource leak.


I thought we agreed on the uniqueing being great?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: arsenm, chandlerc.
Herald added subscribers: llvm-commits, cfe-commits, kerbowa, dexonsmith, 
steven_wu, hiraditya, nhaehnle, wdng, jvesely.
Herald added projects: clang, LLVM.

So far, SROA could only handle convertible pointer pairs if they are in the
same address space. Just like no-op cast, a no-op `addrspacecast` also changes
no bits, it could also be used to convert pointer pairs from different address
spaces. That benefits `infer-address-spaces` pass to propagate address spaces.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81670

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/SROA/noop-addrspacecast.ll

Index: llvm/test/Transforms/SROA/noop-addrspacecast.ll
===
--- /dev/null
+++ llvm/test/Transforms/SROA/noop-addrspacecast.ll
@@ -0,0 +1,19 @@
+; RUN: opt -S -o - -sroa %s | FileCheck %s
+; RUN: opt -S -o - -passes=sroa %s | FileCheck %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+target triple = "amdgcn-amd-amdhsa"
+
+; CHECK-LABEL: @noop_addrspacecast(
+; CHECK-NEXT: = addrspacecast i32 addrspace(1)* %{{.*}} to i32*
+; CHECK-NEXT: store i32 0, i32* %{{.*}}
+; CHECK-NEXT: ret void
+define void @noop_addrspacecast(i32 addrspace(1)* %x.coerce) {
+  %x = alloca i32*, align 8, addrspace(5)
+  %x1 = addrspacecast i32* addrspace(5)* %x to i32**
+  %x2 = bitcast i32** %x1 to i32 addrspace(1)**
+  store i32 addrspace(1)* %x.coerce, i32 addrspace(1)** %x2
+  %x3 = load i32*, i32** %x1
+  store i32 0, i32* %x3
+  ret void
+}
Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -123,15 +123,15 @@
 ; CHECK-O-NEXT: Running pass: CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run.
 ; CHECK-O-NEXT: Running pass: SROA
-; These next two can appear in any order since they are accessed as parameters
+; These next three can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
+; CHECK-O1-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-O2-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Os-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Oz-DAG: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on foo
 ; CHECK-O-DAG: Running analysis: AssumptionAnalysis on foo
 ; CHECK-O-NEXT: Running pass: EarlyCSEPass
-; CHECK-O1-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-O2-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Os-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Oz-NEXT: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-NEXT: Running analysis: MemorySSAAnalysis
 ; CHECK-O23SZ-NEXT: Running pass: SpeculativeExecutionPass
 ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/PtrUseVisitor.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
@@ -1677,7 +1678,9 @@
 /// ensure that we only try to convert viable values. The strategy is that we
 /// will peel off single element struct and array wrappings to get to an
 /// underlying value, and convert that value.
-static bool canConvertValue(const DataLayout &DL, Type *OldTy, Type *NewTy) {
+static bool canConvertValue(const DataLayout &DL,
+const TargetTransformInfo &TTI, Type *OldTy,
+Type *NewTy) {
   if (OldTy == NewTy)
 return true;
 
@@ -1703,8 +1706,11 @@
   NewTy = NewTy->getScalarType();
   if (NewTy->isPointerTy() || OldTy->isPointerTy()) {
 if (NewTy->isPointerTy() && OldTy->isPointerTy()) {
-  return cast(NewTy)->getPointerAddressSpace() ==
-cast(OldTy)->getPointerAddressSpace();
+  // Pointers are convertible if they have the same address space or that
+  // address space casting is a

[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Reproducer for the regression. 
https://gist.github.com/Artem-B/183e9cfc28c6b04c1c862c853b5d9575
It's not particularly small, but that's as far as I could get it reduced.

With the patch, an attempt to instantiate `ag` on line 36 (in the reproducer 
sources I linked to above) results in ambiguity between two templates on lines 
33 and 24 that are in different namespaces.
Previously it picked the template on line 28.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80450



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

We should instead allow bitcast to perform no-op addrspacecasts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670



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


[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 270177.
hliao added a comment.

Revise the formatting.

Updating D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.
===

[SROA] Teach SROA to recognize no-op addrspacecast.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/Transforms/Scalar/SROA.h
  llvm/lib/Analysis/TargetTransformInfo.cpp
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Transforms/SROA/noop-addrspacecast.ll

Index: llvm/test/Transforms/SROA/noop-addrspacecast.ll
===
--- /dev/null
+++ llvm/test/Transforms/SROA/noop-addrspacecast.ll
@@ -0,0 +1,19 @@
+; RUN: opt -S -o - -sroa %s | FileCheck %s
+; RUN: opt -S -o - -passes=sroa %s | FileCheck %s
+
+target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
+target triple = "amdgcn-amd-amdhsa"
+
+; CHECK-LABEL: @noop_addrspacecast(
+; CHECK-NEXT: = addrspacecast i32 addrspace(1)* %{{.*}} to i32*
+; CHECK-NEXT: store i32 0, i32* %{{.*}}
+; CHECK-NEXT: ret void
+define void @noop_addrspacecast(i32 addrspace(1)* %x.coerce) {
+  %x = alloca i32*, align 8, addrspace(5)
+  %x1 = addrspacecast i32* addrspace(5)* %x to i32**
+  %x2 = bitcast i32** %x1 to i32 addrspace(1)**
+  store i32 addrspace(1)* %x.coerce, i32 addrspace(1)** %x2
+  %x3 = load i32*, i32** %x1
+  store i32 0, i32* %x3
+  ret void
+}
Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -123,15 +123,15 @@
 ; CHECK-O-NEXT: Running pass: CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O-NEXT: Starting {{.*}}Function pass manager run.
 ; CHECK-O-NEXT: Running pass: SROA
-; These next two can appear in any order since they are accessed as parameters
+; These next three can appear in any order since they are accessed as parameters
 ; on the same call to SROA::runImpl
+; CHECK-O1-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-O2-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Os-DAG: Running analysis: TargetIRAnalysis on foo
+; CHECK-Oz-DAG: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-DAG: Running analysis: DominatorTreeAnalysis on foo
 ; CHECK-O-DAG: Running analysis: AssumptionAnalysis on foo
 ; CHECK-O-NEXT: Running pass: EarlyCSEPass
-; CHECK-O1-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-O2-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Os-NEXT: Running analysis: TargetIRAnalysis on foo
-; CHECK-Oz-NEXT: Running analysis: TargetIRAnalysis on foo
 ; CHECK-O-NEXT: Running analysis: MemorySSAAnalysis
 ; CHECK-O23SZ-NEXT: Running pass: SpeculativeExecutionPass
 ; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass
Index: llvm/lib/Transforms/Scalar/SROA.cpp
===
--- llvm/lib/Transforms/Scalar/SROA.cpp
+++ llvm/lib/Transforms/Scalar/SROA.cpp
@@ -41,6 +41,7 @@
 #include "llvm/Analysis/GlobalsModRef.h"
 #include "llvm/Analysis/Loads.h"
 #include "llvm/Analysis/PtrUseVisitor.h"
+#include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
@@ -1677,7 +1678,9 @@
 /// ensure that we only try to convert viable values. The strategy is that we
 /// will peel off single element struct and array wrappings to get to an
 /// underlying value, and convert that value.
-static bool canConvertValue(const DataLayout &DL, Type *OldTy, Type *NewTy) {
+static bool canConvertValue(const DataLayout &DL,
+const TargetTransformInfo &TTI, Type *OldTy,
+Type *NewTy) {
   if (OldTy == NewTy)
 return true;
 
@@ -1703,8 +1706,11 @@
   NewTy = NewTy->getScalarType();
   if (NewTy->isPointerTy() || OldTy->isPointerTy()) {
 if (NewTy->isPointerTy() && OldTy->isPointerTy()) {
-  return cast(NewTy)->getPointerAddressSpace() ==
-cast(OldTy)->getPointerAddressSpace();
+  // Pointers are convertible if they have the same address space or that
+  // address space casting is a no-op.
+  unsigned OldAS = cast(OldTy)->getPointerAddressSpace();
+  unsigned NewAS = cast(NewTy)->getPointerAddressSpace();
+  return OldAS == NewAS || TTI.isNoopAddrSpaceCast(OldAS, NewAS);
 }

[PATCH] D81672: [Driver] When forcing a crash call abort to get the correct diagnostic

2020-06-11 Thread John Brawn via Phabricator via cfe-commits
john.brawn created this revision.
john.brawn added reviewers: gbreynoo, jhenderson, probinson.
Herald added a project: clang.

Commit a945037e8fd0c30e250a62211469eea6765a36ae 
 moved the 
printing of the "PLEASE submit a bug report" message to the crash handler, but 
that means we don't print it when forcing a crash using -gen-reproducer. Fix 
this by calling abort inside of a CrashRecoveryContext so we go through the 
crash handler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81672

Files:
  clang/test/Driver/crash-report-crashfile.m
  clang/test/Driver/crash-report-modules.m
  clang/test/Driver/crash-report-null.test
  clang/tools/driver/driver.cpp


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -511,6 +511,11 @@
   for (const auto &J : C->getJobs())
 if (const Command *C = dyn_cast(&J))
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Crash using abort.
+  llvm::CrashRecoveryContext CRC;
+  CRC.DumpStackAndCleanupOnFailure = true;
+  CRC.RunSafely([&]() { abort(); });
 }
 
 for (const auto &P : FailingCommands) {
Index: clang/test/Driver/crash-report-null.test
===
--- clang/test/Driver/crash-report-null.test
+++ clang/test/Driver/crash-report-null.test
@@ -3,5 +3,6 @@
 // FIXME: Investigating. "fatal error: file 'nul' modified since it was first 
processed"
 // XFAIL: windows-gnu
 
+// CHECK: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c
Index: clang/test/Driver/crash-report-modules.m
===
--- clang/test/Driver/crash-report-modules.m
+++ clang/test/Driver/crash-report-modules.m
@@ -19,6 +19,7 @@
 @import simple;
 const int x = MODULE_MACRO;
 
+// CHECK: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.m
 // CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
Index: clang/test/Driver/crash-report-crashfile.m
===
--- clang/test/Driver/crash-report-crashfile.m
+++ clang/test/Driver/crash-report-crashfile.m
@@ -18,6 +18,7 @@
 const int x = MODULE_MACRO;
 
 // CRASH_ENV: failing because environment variable 
'FORCE_CLANG_DIAGNOSTICS_CRASH' is set
+// CRASH_ENV: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CRASH_ENV: Preprocessed source(s) and associated run script(s) are located 
at:
 // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.m
 // CRASH_ENV-NEXT: note: diagnostic msg: {{.*}}.cache
@@ -26,6 +27,7 @@
 // CRASH_ENV-NEXT: note: diagnostic msg: 
{{.*}}Library/Logs/DiagnosticReports{{.*}}
 
 // CRASH_FLAG: failing because '-gen-reproducer' is used
+// CRASH_FLAG: PLEASE submit a bug report to {{.*}} and include the crash 
backtrace, preprocessed source, and associated run script.
 // CRASH_FLAG: Preprocessed source(s) and associated run script(s) are located 
at:
 // CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.m
 // CRASH_FLAG-NEXT: note: diagnostic msg: {{.*}}.cache


Index: clang/tools/driver/driver.cpp
===
--- clang/tools/driver/driver.cpp
+++ clang/tools/driver/driver.cpp
@@ -511,6 +511,11 @@
   for (const auto &J : C->getJobs())
 if (const Command *C = dyn_cast(&J))
   FailingCommands.push_back(std::make_pair(-1, C));
+
+  // Crash using abort.
+  llvm::CrashRecoveryContext CRC;
+  CRC.DumpStackAndCleanupOnFailure = true;
+  CRC.RunSafely([&]() { abort(); });
 }
 
 for (const auto &P : FailingCommands) {
Index: clang/test/Driver/crash-report-null.test
===
--- clang/test/Driver/crash-report-null.test
+++ clang/test/Driver/crash-report-null.test
@@ -3,5 +3,6 @@
 // FIXME: Investigating. "fatal error: file 'nul' modified since it was first processed"
 // XFAIL: windows-gnu
 
+// CHECK: PLEASE submit a bug report to {{.*}} and include the crash backtrace, preprocessed source, and associated run script.
 // CHECK: Preprocessed source(s) and associated run script(s) are located at:
 // CHECK-NEXT: note: diagnostic msg: {{.*}}null-{{.*}}.c
Index: clang/test/Driver/crash-report-modules.m
===
--- clang/test/Driver/crash-report-modules.m
+++ clang/tes

[clang] 95d7ccb - [PCH] Support writing BuiltinBitCastExprs to PCHs

2020-06-11 Thread Erik Pilkington via cfe-commits

Author: hyd-dev
Date: 2020-06-11T13:37:01-04:00
New Revision: 95d7ccb70b9cbd53f1f137c0b2411852c42c122b

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

LOG: [PCH] Support writing BuiltinBitCastExprs to PCHs

eee944e7f adds the new BuiltinBitCastExpr, but does not set the Code member of
ASTStmtWriter. This is not correct and causes an assertion failue in
ASTStmtWriter::emit() when building PCHs that contain __builtin_bit_cast.  This
commit adds serialization::EXPR_BUILTIN_BIT_CAST and handles
ASTStmtWriter::Code properly.

Differential revision: https://reviews.llvm.org/D80360

Added: 
clang/test/PCH/builtin-bit-cast.cpp

Modified: 
clang/include/clang/AST/ExprCXX.h
clang/include/clang/Serialization/ASTBitCodes.h
clang/lib/Serialization/ASTReaderStmt.cpp
clang/lib/Serialization/ASTWriterStmt.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 56b27d57bd5c..379f762275c6 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -4821,6 +4821,8 @@ class BuiltinBitCastExpr final
   : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0,
  DstType),
 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
+  BuiltinBitCastExpr(EmptyShell Empty)
+  : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0) {}
 
   SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
   SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }

diff  --git a/clang/include/clang/Serialization/ASTBitCodes.h 
b/clang/include/clang/Serialization/ASTBitCodes.h
index 4008f11daa15..c6f9f1d1a08f 100644
--- a/clang/include/clang/Serialization/ASTBitCodes.h
+++ b/clang/include/clang/Serialization/ASTBitCodes.h
@@ -1812,6 +1812,9 @@ class TypeIdx {
   /// A CXXFunctionalCastExpr record.
   EXPR_CXX_FUNCTIONAL_CAST,
 
+  /// A BuiltinBitCastExpr record.
+  EXPR_BUILTIN_BIT_CAST,
+
   /// A UserDefinedLiteral record.
   EXPR_USER_DEFINED_LITERAL,
 

diff  --git a/clang/lib/Serialization/ASTReaderStmt.cpp 
b/clang/lib/Serialization/ASTReaderStmt.cpp
index 5c7bc7a57a9f..86895c319ee8 100644
--- a/clang/lib/Serialization/ASTReaderStmt.cpp
+++ b/clang/lib/Serialization/ASTReaderStmt.cpp
@@ -3618,6 +3618,11 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
+case EXPR_BUILTIN_BIT_CAST:
+  assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
+  S = new (Context) BuiltinBitCastExpr(Empty);
+  break;
+
 case EXPR_USER_DEFINED_LITERAL:
   S = UserDefinedLiteral::CreateEmpty(
   Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);

diff  --git a/clang/lib/Serialization/ASTWriterStmt.cpp 
b/clang/lib/Serialization/ASTWriterStmt.cpp
index 5e445b6f4627..45cd54f8dc9e 100644
--- a/clang/lib/Serialization/ASTWriterStmt.cpp
+++ b/clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1655,6 +1655,7 @@ void 
ASTStmtWriter::VisitBuiltinBitCastExpr(BuiltinBitCastExpr *E) {
   VisitExplicitCastExpr(E);
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
+  Code = serialization::EXPR_BUILTIN_BIT_CAST;
 }
 
 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {

diff  --git a/clang/test/PCH/builtin-bit-cast.cpp 
b/clang/test/PCH/builtin-bit-cast.cpp
new file mode 100644
index ..5755ce965e33
--- /dev/null
+++ b/clang/test/PCH/builtin-bit-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+constexpr T BuiltinBitCastWrapper(const U &Arg) {
+  return __builtin_bit_cast(T, Arg);
+}
+
+#else
+
+int main() {
+  return BuiltinBitCastWrapper(0);
+}
+
+#endif



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


[PATCH] D72781: [Matrix] Add __builtin_matrix_column_load to Clang.

2020-06-11 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

In D72781#2084077 , @rjmccall wrote:

> LGTM.


Thank you very much again John! This patch is pending on a few smallish 
improvements to the load/store intrinsics (D81472 
) and I'll land once that one is wrapped up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72781



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


[PATCH] D80360: [PCH] Support writing BuiltinBitCastExprs to PCHs

2020-06-11 Thread Erik Pilkington via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95d7ccb70b9c: [PCH] Support writing BuiltinBitCastExprs to 
PCHs (authored by hyd-dev, committed by erik.pilkington).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80360

Files:
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/PCH/builtin-bit-cast.cpp


Index: clang/test/PCH/builtin-bit-cast.cpp
===
--- /dev/null
+++ clang/test/PCH/builtin-bit-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+constexpr T BuiltinBitCastWrapper(const U &Arg) {
+  return __builtin_bit_cast(T, Arg);
+}
+
+#else
+
+int main() {
+  return BuiltinBitCastWrapper(0);
+}
+
+#endif
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1655,6 +1655,7 @@
   VisitExplicitCastExpr(E);
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
+  Code = serialization::EXPR_BUILTIN_BIT_CAST;
 }
 
 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -3618,6 +3618,11 @@
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
+case EXPR_BUILTIN_BIT_CAST:
+  assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
+  S = new (Context) BuiltinBitCastExpr(Empty);
+  break;
+
 case EXPR_USER_DEFINED_LITERAL:
   S = UserDefinedLiteral::CreateEmpty(
   Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Index: clang/include/clang/Serialization/ASTBitCodes.h
===
--- clang/include/clang/Serialization/ASTBitCodes.h
+++ clang/include/clang/Serialization/ASTBitCodes.h
@@ -1812,6 +1812,9 @@
   /// A CXXFunctionalCastExpr record.
   EXPR_CXX_FUNCTIONAL_CAST,
 
+  /// A BuiltinBitCastExpr record.
+  EXPR_BUILTIN_BIT_CAST,
+
   /// A UserDefinedLiteral record.
   EXPR_USER_DEFINED_LITERAL,
 
Index: clang/include/clang/AST/ExprCXX.h
===
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -4821,6 +4821,8 @@
   : ExplicitCastExpr(BuiltinBitCastExprClass, T, VK, CK, SrcExpr, 0,
  DstType),
 KWLoc(KWLoc), RParenLoc(RParenLoc) {}
+  BuiltinBitCastExpr(EmptyShell Empty)
+  : ExplicitCastExpr(BuiltinBitCastExprClass, Empty, 0) {}
 
   SourceLocation getBeginLoc() const LLVM_READONLY { return KWLoc; }
   SourceLocation getEndLoc() const LLVM_READONLY { return RParenLoc; }


Index: clang/test/PCH/builtin-bit-cast.cpp
===
--- /dev/null
+++ clang/test/PCH/builtin-bit-cast.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+#ifndef HEADER
+#define HEADER
+
+template 
+constexpr T BuiltinBitCastWrapper(const U &Arg) {
+  return __builtin_bit_cast(T, Arg);
+}
+
+#else
+
+int main() {
+  return BuiltinBitCastWrapper(0);
+}
+
+#endif
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1655,6 +1655,7 @@
   VisitExplicitCastExpr(E);
   Record.AddSourceLocation(E->getBeginLoc());
   Record.AddSourceLocation(E->getEndLoc());
+  Code = serialization::EXPR_BUILTIN_BIT_CAST;
 }
 
 void ASTStmtWriter::VisitUserDefinedLiteral(UserDefinedLiteral *E) {
Index: clang/lib/Serialization/ASTReaderStmt.cpp
===
--- clang/lib/Serialization/ASTReaderStmt.cpp
+++ clang/lib/Serialization/ASTReaderStmt.cpp
@@ -3618,6 +3618,11 @@
/*PathSize*/ Record[ASTStmtReader::NumExprFields]);
   break;
 
+case EXPR_BUILTIN_BIT_CAST:
+  assert(Record[ASTStmtReader::NumExprFields] == 0 && "Wrong PathSize!");
+  S = new (Context) BuiltinBitCastExpr(Empty);
+  break;
+
 case EXPR_USER_DEFINED_LITERAL:
   S = UserDefinedLiteral::CreateEmpty(
   Context, /*NumArgs=*/Record[ASTStmtReader::NumExprFields], Empty);
Index: clang/incl

[PATCH] D81676: [MSP430] Align the toolchain definition with the TI's msp430-gcc v8.3.1

2020-06-11 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko created this revision.
atrosinenko added reviewers: broadwaylamb, sepavloff.
Herald added subscribers: s.egerton, dexonsmith, simoncook, emaste.
Herald added a reviewer: espindola.
Herald added a project: clang.
atrosinenko edited the summary of this revision.

This patch updates the toolchain description for MSP430 target, aligning it 
with the TI-provided sysroot based on msp430-gcc v8.3.1.

It leaves some features (such as sanitizer runtimes, LTO, etc.) unsupported, 
trying to translate the remaining parts of the `link_command` spec description 
from current GCC version as closely as possible.

It introduces support for GCC `-msim` option to Clang that simplifies building 
msp430 binaries to be run on a simulator (such as for unit testing purposes).

This patch contains updated unit tests to prevent silent changing of the 
behavior. Its current behavior can be manually tested as follows:

- Compile and run on the simulator: compiles successfully, runs as expected, 
terminates cleanly

  $ /path/to/bin/clang -target msp430 --sysroot=$sysroot test.c -o test -I 
$sysroot/msp430-elf/include -msim
  $ $sysroot/bin/msp430-elf-run ./test
  N = 1

- Compile for a real MCU: links successfully

  $ /path/to/bin/clang -target msp430 --sysroot=$sysroot test.c -o test -I 
$sysroot/msp430-elf/include -mmcu=msp430g2553

Current state:

- can run simple programs on a simulator built into msp430-elf-gdb
- can **link** a program by passing just a 
`--sysroot=/path/to/msp430-gcc/binary/distrib` (still requires specifying `-I 
path`)
- **not** yet tested on a real hardware
- may require further adjustment of `--gcc-toolchain` option handling

name=test.c
  #include 
  
  int main()
  {
printf("N = %d\n", 1);
return 0;
  }

References:

- https://clang.llvm.org/docs/CrossCompilation.html
- https://www.ti.com/tool/MSP430-GCC-OPENSOURCE
- cfe-users: --sysroot and --gcc-toolchain: any docs etc.? 



Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81676

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/MSP430.cpp
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/lib/Driver/ToolChains/MSP430.cpp
  clang/lib/Driver/ToolChains/MSP430.h
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/7.3.1/430/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/430/exceptions/crtend_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtbegin_no_eh.o
  clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/exceptions/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/exceptions/crtend_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtbegin_no_eh.o
  
clang/test/Driver/Inputs/basic_msp430_tree/lib/gcc/msp430-elf/8.3.1/large/full-memory-range/crtend.o
  
clang/t

[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3537
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType,
-AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl,
-CXXBaseSpecifier),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, FriendDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 1) {

njames93 wrote:
> jkorous wrote:
> > aaron.ballman wrote:
> > > njames93 wrote:
> > > > aaron.ballman wrote:
> > > > > This is undoing a change that was just added less than two weeks ago, 
> > > > > so I think the potential for breaking code is small. That said, can 
> > > > > you explain why you think `hasClass` is a better approach than 
> > > > > `hasType`?
> > > > Yeah, as that change hasn't reached landed onto a release branch 
> > > > breaking code shouldn't be an issue, If it was I'd leave it in.
> > > > 
> > > > - `hasType` is very generic, whereas `hasClass` is specific to what a 
> > > > `CXXBaseSpecifier` supports.
> > > > - It makes the matchers marginally simpler.
> > > >   `hasDirectBase(hasType(cxxRecordDecl(hasName("Base"` vs 
> > > > `hasDirectBase(hasClass(hasName("Base")))`
> > > > - In the documentation it also specifies that `hasClass` takes a 
> > > > `Matcher, making it more user friendly.
> > > FWIW, I prefer `hasType` to `hasClass`. You can inherit from things which 
> > > are not a class, such as a struct (so the name is a bit of a misnomer, 
> > > but not too awful), a class template (which you can't match with this 
> > > interface), or a template type (which you also can't match with this 
> > > interface).
> > I don't feel super strongly about this but I also slightly prefer `hasType`.
> > 
> > To be fair - I didn't really have things like inheritance from template 
> > parameters on my mind when working on `hasAnyBase` (it's definitely not 
> > tested) so I'd rather not assume it works.
> I have decided to put `hasType` back in there as it does have some general 
> uses. However I have added more class and class template specific matchers as 
> I feel these are slightly more user friendly. 
> 
> LMK what you think of this approach.
> 
> Side note what is the correct collective term for classes and structs. I'd be 
> tempted to refer to them how clang does, records, but `hasRecord` seems wrong.
> Side note what is the correct collective term for classes and structs. I'd be 
> tempted to refer to them how clang does, records, but hasRecord seems wrong.

We use the term "record", but I'm not certain how widely used that is.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

jkorous wrote:
> Nit: while "[base specifier] `hasType`" sounds natural to me for some reason 
> `hasClass` doesn't. English is not my first language though.
I agree that `hasClass` seems unnatural here. Out of curiosity, could we modify 
the `hasName` matcher to work on base specifiers so you can write: 
`cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more wordy 
version `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81311: [RFC] LangRef: Define inmem parameter attribute

2020-06-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In D81311#2087592 , @jdoerfert wrote:

> In D81311#2086326 , @rjmccall wrote:
>
> > In D81311#2086227 , @jdoerfert 
> > wrote:
> >
> > > Do we allow `inmem` to be used for other purposes? I would assume the 
> > > answer is yes, as we do not forbid it.
> >
> >
> > I don't know what else we might use it for off-hand, but yes, I think the 
> > frontend could put this down on all value arguments that are actually 
> > passed indirectly.
>
>
> Where does it say it is limited to indirectly passed arguments?


The argument does have to be a pointer.  And passes aren't allowed to infer 
this or it becomes useless for the original purpose.


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

https://reviews.llvm.org/D81311



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


[clang] 43101d1 - [OPENMP50]Codegen for scan directive in simd loops.

2020-06-11 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-06-11T14:48:43-04:00
New Revision: 43101d10dbd58d48df732f974e078fd82376039e

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

LOG: [OPENMP50]Codegen for scan directive in simd loops.

Added codegen for scan directives in simd loop. The codegen transforms
original code:
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  
  #pragma omp scan inclusive(x)
  
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  
  x = x_priv + x;
  x_priv = x;
  
}
```
and
```
int x = 0;
 #pragma omp simd reduction(inscan, +: x)
for (..) {
  
  #pragma omp scan exclusive(x)
  
}
```
into
```
int x = 0;
for (..) {
  int x_priv = 0;
  
  int temp = x;
  x = x_priv + x;
  x_priv = temp;
  
}
```

Differential revision: https://reviews.llvm.org/D78232

Added: 
clang/test/OpenMP/scan_codegen.cpp

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/Sema/SemaOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index e9569d4e5658..d51693a4551a 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1730,7 +1730,13 @@ void CodeGenFunction::EmitOMPLoopBody(const 
OMPLoopDirective &D,
 // executed in reverse order.
 OMPBeforeScanBlock = createBasicBlock("omp.before.scan.bb");
 OMPAfterScanBlock = createBasicBlock("omp.after.scan.bb");
-OMPScanExitBlock = createBasicBlock("omp.exit.inscan.bb");
+// No need to allocate inscan exit block, in simd mode it is selected in 
the
+// codegen for the scan directive.
+if (D.getDirectiveKind() != OMPD_simd &&
+(!getLangOpts().OpenMPSimd ||
+ isOpenMPSimdDirective(D.getDirectiveKind( {
+  OMPScanExitBlock = createBasicBlock("omp.exit.inscan.bb");
+}
 OMPScanDispatch = createBasicBlock("omp.inscan.dispatch");
 EmitBranch(OMPScanDispatch);
 EmitBlock(OMPBeforeScanBlock);
@@ -2083,6 +2089,15 @@ void CodeGenFunction::EmitOMPSimdInit(const 
OMPLoopDirective &D,
   if (const auto *C = D.getSingleClause())
 if (C->getKind() == OMPC_ORDER_concurrent)
   LoopStack.setParallel(/*Enable=*/true);
+  if ((D.getDirectiveKind() == OMPD_simd ||
+   (getLangOpts().OpenMPSimd &&
+isOpenMPSimdDirective(D.getDirectiveKind( &&
+  llvm::any_of(D.getClausesOfKind(),
+   [](const OMPReductionClause *C) {
+ return C->getModifier() == OMPC_REDUCTION_inscan;
+   }))
+// Disable parallel access in case of prefix sum.
+LoopStack.setParallel(/*Enable=*/false);
 }
 
 void CodeGenFunction::EmitOMPSimdFinal(
@@ -2278,6 +2293,8 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const 
OMPLoopDirective &S,
 }
 
 void CodeGenFunction::EmitOMPSimdDirective(const OMPSimdDirective &S) {
+  ParentLoopDirectiveForScanRegion ScanRegion(*this, S);
+  OMPFirstScanLoop = true;
   auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
 emitOMPSimdRegion(CGF, S, Action);
   };
@@ -4199,14 +4216,15 @@ void CodeGenFunction::EmitOMPDepobjDirective(const 
OMPDepobjDirective &S) {
 }
 
 void CodeGenFunction::EmitOMPScanDirective(const OMPScanDirective &S) {
-  // Do not emit code for non-simd directives in simd-only mode.
-  if (getLangOpts().OpenMPSimd && !OMPParentLoopDirectiveForScan)
+  if (!OMPParentLoopDirectiveForScan)
 return;
   const OMPExecutableDirective &ParentDir = *OMPParentLoopDirectiveForScan;
+  bool IsInclusive = S.hasClausesOfKind();
   SmallVector Shareds;
   SmallVector Privates;
   SmallVector LHSs;
   SmallVector RHSs;
+  SmallVector ReductionOps;
   SmallVector CopyOps;
   SmallVector CopyArrayTemps;
   SmallVector CopyArrayElems;
@@ -4217,13 +4235,109 @@ void CodeGenFunction::EmitOMPScanDirective(const 
OMPScanDirective &S) {
 Privates.append(C->privates().begin(), C->privates().end());
 LHSs.append(C->lhs_exprs().begin(), C->lhs_exprs().end());
 RHSs.append(C->rhs_exprs().begin(), C->rhs_exprs().end());
+ReductionOps.append(C->reduction_ops().begin(), C->reduction_ops().end());
 CopyOps.append(C->copy_ops().begin(), C->copy_ops().end());
 CopyArrayTemps.append(C->copy_array_temps().begin(),
   C->copy_array_temps().end());
 CopyArrayElems.append(C->copy_array_elems().begin(),
   C->copy_array_elems().end());
   }
-  bool IsInclusive = S.hasClausesOfKind();
+  if (ParentDir.getDirectiveKind() == OMPD_simd ||
+  (getLangOpts().OpenMPSimd &&
+   isOpenMPSimdDirective(ParentDir.getDirectiveKind( {
+// For simd directive and simd-based directives in simd only mode, use the
+// following codegen:
+// int x = 0;
+// #pragma omp simd reduction(inscan, +: x)
+//

[PATCH] D80450: [CUDA][HIP] Fix implicit HD function resolution

2020-06-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D80450#2087938 , @tra wrote:

> Reproducer for the regression. 
> https://gist.github.com/Artem-B/183e9cfc28c6b04c1c862c853b5d9575
>  It's not particularly small, but that's as far as I could get it reduced.
>
> With the patch, an attempt to instantiate `ag` on line 36 (in the reproducer 
> sources I linked to above) results in ambiguity between two templates on 
> lines 33 and 24 that are in different namespaces.
>  Previously it picked the template on line 28.


Managed to simplify the reproducer down to this which now reports that a host 
candidate has been ignored. This may explain why we ended up with the ambiguity 
when other overloads were present.

  template  struct a {};
  namespace b {
  struct c : a {};
  template  void ag(d);
  } // namespace b
  template 
  __attribute__((host)) __attribute__((device)) int ag(a) {
ae e;
ag(e);
  }
  void f() { ag; }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80450



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


[PATCH] D81392: [clang] Rename Decl::isHidden() to isUnconditionallyVisible()

2020-06-11 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

I think renaming the flag in the AST dump output would be a good idea, though 
it'll be a lot of churn in the tests. I would prefer that we continue to dump a 
marker only if the declaration is not unconditionally visible rather than 
reversing the sense of the flag in the dump output. Maybe we should dump the 
ModuleOwnershipKind in general, not only an indicator of whether it's Visible 
or something else?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81392



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3621
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClassOrClassTemplate,
+  internal::Matcher, InnerMatcher) {

I think we should just use `eachOf` matcher for this kind of composition.

https://clang.llvm.org/docs/LibASTMatchersReference.html#traversal-matchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81552: [ASTMatchers] Added hasDirectBase and hasClass Matchers

2020-06-11 Thread Jan Korous via Phabricator via cfe-commits
jkorous added inline comments.



Comment at: clang/include/clang/ASTMatchers/ASTMatchers.h:3553
+/// \endcode
+AST_MATCHER_P(CXXBaseSpecifier, hasClass, internal::Matcher,
+  InnerMatcher) {

aaron.ballman wrote:
> jkorous wrote:
> > Nit: while "[base specifier] `hasType`" sounds natural to me for some 
> > reason `hasClass` doesn't. English is not my first language though.
> I agree that `hasClass` seems unnatural here. Out of curiosity, could we 
> modify the `hasName` matcher to work on base specifiers so you can write: 
> `cxxRecordDecl(hasAnyBase(hasName("Base")))` as shorthand for the more wordy 
> version `cxxRecordDecl(hasAnyBase(hasType(cxxRecordDecl(hasName("Base")`?
Wouldn't it be strange to treat `hasName` differently than all the other 
narrowing matchers? Honest question - I feel that `hasName` might be the most 
commonly used, just don't know if that's enough to justify this.
https://clang.llvm.org/docs/LibASTMatchersReference.html#narrowing-matchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81552



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


[PATCH] D81627: [HIP] Do not call opt/llc for -fno-gpu-rdc

2020-06-11 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Looks OK in general. I'm happy to see reduced opt/llc use.

You may want to get someone more familiar with the AMD GPU compilation process 
to double-check that the compilation pipeline still does the right thing.




Comment at: clang/lib/Driver/Driver.cpp:2725-2726
 for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
   // Create a link action to link device IR with device library
   // and generate ISA.
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(

The comment about "create link action" should probably be moved down below to 
where the link action is constructed now.




Comment at: clang/lib/Driver/Driver.cpp:2727-2732
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
+  C, Args, phases::Backend, CudaDeviceActions[I],
+  AssociatedOffloadKind);
+  CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
+  C, Args, phases::Assemble, CudaDeviceActions[I],
+  AssociatedOffloadKind);

Looks like we're chaining backend/assembly actions here. but it's not easy to 
spot that we use `CudaDeviceActions[I]`  as an intermediate value. At the first 
glance it looked like a copy/paste error writing to `CudaDeviceActions[I]` 
multiple times.

It would be easier to see what's going on if the code was structured like this:
```
BackendAction = Construct(... CudaDeviceActions[I]);
AssembleAction  = Construct(... BackendAction);
AL.push_back(AssembleAction)
CudaDeviceActions[I] = C.MakeAction(AL);
```



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

https://reviews.llvm.org/D81627



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


[PATCH] D79155: [CodeGen] Increase applicability of ffine-grained-bitfield-accesses for targets with limited native integer widths

2020-06-11 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Please add a comment explaining what OffsetInRecord means; then LGTM.


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

https://reviews.llvm.org/D79155



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


[clang] a06f000 - [clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and ExpressionTrait

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T20:27:40+01:00
New Revision: a06f000326e3362ffb5634957447dd434abab0f9

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

LOG: [clang][NFC] Remove two hard-coded lists of ArrayTypeTrait and 
ExpressionTrait

These two were missed in 78e636b3f2f0b0487130b31fade4f95ab179a18c.

Added: 


Modified: 
clang/lib/Parse/ParseExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Parse/ParseExprCXX.cpp 
b/clang/lib/Parse/ParseExprCXX.cpp
index d794977a..48277dc85466 100644
--- a/clang/lib/Parse/ParseExprCXX.cpp
+++ b/clang/lib/Parse/ParseExprCXX.cpp
@@ -3649,18 +3649,24 @@ case tok::kw_ ## Spelling: return BTT_ ## Name;
 }
 
 static ArrayTypeTrait ArrayTypeTraitFromTokKind(tok::TokenKind kind) {
-  switch(kind) {
-  default: llvm_unreachable("Not a known binary type trait");
-  case tok::kw___array_rank: return ATT_ArrayRank;
-  case tok::kw___array_extent:   return ATT_ArrayExtent;
+  switch (kind) {
+  default:
+llvm_unreachable("Not a known array type trait");
+#define ARRAY_TYPE_TRAIT(Spelling, Name, Key)  
\
+  case tok::kw_##Spelling: 
\
+return ATT_##Name;
+#include "clang/Basic/TokenKinds.def"
   }
 }
 
 static ExpressionTrait ExpressionTraitFromTokKind(tok::TokenKind kind) {
-  switch(kind) {
-  default: llvm_unreachable("Not a known unary expression trait.");
-  case tok::kw___is_lvalue_expr: return ET_IsLValueExpr;
-  case tok::kw___is_rvalue_expr: return ET_IsRValueExpr;
+  switch (kind) {
+  default:
+llvm_unreachable("Not a known unary expression trait.");
+#define EXPRESSION_TRAIT(Spelling, Name, Key)  
\
+  case tok::kw_##Spelling: 
\
+return ET_##Name;
+#include "clang/Basic/TokenKinds.def"
   }
 }
 



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


[clang] a9250c2 - [clang] TextNodeDumper: Dump the trait spelling of {Type,ArrayType,Expression}TraitExpr

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T20:27:40+01:00
New Revision: a9250c281a875d91fb5dd1c8f4ad8ee4ff61b75d

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

LOG: [clang] TextNodeDumper: Dump the trait spelling of 
{Type,ArrayType,Expression}TraitExpr

nodes using the new helper functions introduced
in 78e636b3f2f0b0487130b31fade4f95ab179a18c.

Added: 
clang/test/AST/ast-dump-traits.cpp

Modified: 
clang/include/clang/AST/TextNodeDumper.h
clang/lib/AST/TextNodeDumper.cpp

Removed: 




diff  --git a/clang/include/clang/AST/TextNodeDumper.h 
b/clang/include/clang/AST/TextNodeDumper.h
index 4636c8ef65d3..b069bd09287a 100644
--- a/clang/include/clang/AST/TextNodeDumper.h
+++ b/clang/include/clang/AST/TextNodeDumper.h
@@ -259,6 +259,9 @@ class TextNodeDumper
   void VisitCXXBindTemporaryExpr(const CXXBindTemporaryExpr *Node);
   void VisitCXXNewExpr(const CXXNewExpr *Node);
   void VisitCXXDeleteExpr(const CXXDeleteExpr *Node);
+  void VisitTypeTraitExpr(const TypeTraitExpr *Node);
+  void VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *Node);
+  void VisitExpressionTraitExpr(const ExpressionTraitExpr *Node);
   void VisitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *Node);
   void VisitExprWithCleanups(const ExprWithCleanups *Node);
   void VisitUnresolvedLookupExpr(const UnresolvedLookupExpr *Node);

diff  --git a/clang/lib/AST/TextNodeDumper.cpp 
b/clang/lib/AST/TextNodeDumper.cpp
index 609a9d7ac2df..7007aa833f3f 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -949,6 +949,18 @@ void TextNodeDumper::VisitCXXDeleteExpr(const 
CXXDeleteExpr *Node) {
   }
 }
 
+void TextNodeDumper::VisitTypeTraitExpr(const TypeTraitExpr *Node) {
+  OS << " " << getTraitSpelling(Node->getTrait());
+}
+
+void TextNodeDumper::VisitArrayTypeTraitExpr(const ArrayTypeTraitExpr *Node) {
+  OS << " " << getTraitSpelling(Node->getTrait());
+}
+
+void TextNodeDumper::VisitExpressionTraitExpr(const ExpressionTraitExpr *Node) 
{
+  OS << " " << getTraitSpelling(Node->getTrait());
+}
+
 void TextNodeDumper::VisitMaterializeTemporaryExpr(
 const MaterializeTemporaryExpr *Node) {
   if (const ValueDecl *VD = Node->getExtendingDecl()) {

diff  --git a/clang/test/AST/ast-dump-traits.cpp 
b/clang/test/AST/ast-dump-traits.cpp
new file mode 100644
index ..92931e2ac67a
--- /dev/null
+++ b/clang/test/AST/ast-dump-traits.cpp
@@ -0,0 +1,55 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck 
-strict-whitespace %s
+
+void test_type_trait() {
+  // An unary type trait.
+  enum E {};
+  (void) __is_enum(E);
+  // A binary type trait.
+  (void) __is_same(int ,float);
+  // An n-ary type trait.
+  (void) __is_constructible(int, int, int, int);
+}
+
+void test_array_type_trait() {
+  // An array type trait.
+  (void) __array_rank(int[10][20]);
+}
+
+void test_expression_trait() {
+  // An expression trait.
+  (void) __is_lvalue_expr(1);
+}
+
+void test_unary_expr_or_type_trait() {
+  // Some UETTs.
+  (void) sizeof(int);
+  (void) alignof(int);
+  (void) __alignof(int);
+}
+// CHECK: TranslationUnitDecl {{.*}} <> 
+// CHECK: |-FunctionDecl {{.*}} <{{.*}}ast-dump-traits.cpp:3:1, line:11:1> 
line:3:6 test_type_trait 'void ()'
+// CHECK-NEXT: | `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |   |-DeclStmt {{.*}} 
+// CHECK-NEXT: |   | `-EnumDecl {{.*}}  col:8 referenced E
+// CHECK-NEXT: |   |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: |   | `-TypeTraitExpr {{.*}}  'bool' __is_enum
+// CHECK-NEXT: |   |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: |   | `-TypeTraitExpr {{.*}}  'bool' __is_same
+// CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-TypeTraitExpr {{.*}}  'bool' 
__is_constructible
+// CHECK-NEXT: |-FunctionDecl {{.*}}  line:13:6 
test_array_type_trait 'void ()'
+// CHECK-NEXT: | `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-ArrayTypeTraitExpr {{.*}}  'unsigned 
long' __array_rank
+// CHECK-NEXT: |-FunctionDecl {{.*}}  line:18:6 
test_expression_trait 'void ()'
+// CHECK-NEXT: | `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |   `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-ExpressionTraitExpr {{.*}}  'bool' 
__is_lvalue_expr
+// CHECK-NEXT: `-FunctionDecl {{.*}}  line:23:6 
test_unary_expr_or_type_trait 'void ()'
+// CHECK-NEXT:   `-CompoundStmt {{.*}} 
+// CHECK-NEXT: |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}}  
'unsigned long' sizeof 'int'
+// CHECK-NEXT: |-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT: | `-UnaryExprOrTypeTraitExpr {{.*}}  
'unsigned long' alignof 'int'
+// CHECK-NEXT: `-CStyleCastExpr {{.*}}  'void' 
+// CHECK-NEXT:   `-UnaryExprOrTypeTraitExpr {{.*}}  
'unsig

[clang] efb0413 - [clang][NFC] Assert that the enumerator value of {Type,ArrayType,UnaryExprOrType,Expression}Traits

2020-06-11 Thread Bruno Ricci via cfe-commits

Author: Bruno Ricci
Date: 2020-06-11T20:27:40+01:00
New Revision: efb0413a5cf9b1481c9b6169c8685f8d71f6de84

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

LOG: [clang][NFC] Assert that the enumerator value of 
{Type,ArrayType,UnaryExprOrType,Expression}Traits

is valid and does not overflow in the bit-field for its storage in more places.
This is a follow-up to 78e636b3f2f0b0487130b31fade4f95ab179a18c. NFC.

Added: 


Modified: 
clang/include/clang/AST/Expr.h
clang/include/clang/AST/ExprCXX.h
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index 670c0fe80b4e..d31f582264b5 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -2509,7 +2509,11 @@ class UnaryExprOrTypeTraitExpr : public Expr {
SourceLocation rp)
   : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, 
OK_Ordinary),
 OpLoc(op), RParenLoc(rp) {
+assert(ExprKind <= UETT_Last && "invalid enum value!");
 UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
+assert(static_cast(ExprKind) ==
+   UnaryExprOrTypeTraitExprBits.Kind &&
+   "UnaryExprOrTypeTraitExprBits.Kind overflow!");
 UnaryExprOrTypeTraitExprBits.IsType = true;
 Argument.Ty = TInfo;
 setDependence(computeDependence(this));
@@ -2526,7 +2530,12 @@ class UnaryExprOrTypeTraitExpr : public Expr {
   UnaryExprOrTypeTrait getKind() const {
 return 
static_cast(UnaryExprOrTypeTraitExprBits.Kind);
   }
-  void setKind(UnaryExprOrTypeTrait K) { UnaryExprOrTypeTraitExprBits.Kind = 
K;}
+  void setKind(UnaryExprOrTypeTrait K) {
+assert(K <= UETT_Last && "invalid enum value!");
+UnaryExprOrTypeTraitExprBits.Kind = K;
+assert(static_cast(K) == UnaryExprOrTypeTraitExprBits.Kind &&
+   "UnaryExprOrTypeTraitExprBits.Kind overflow!");
+  }
 
   bool isArgumentType() const { return UnaryExprOrTypeTraitExprBits.IsType; }
   QualType getArgumentType() const {

diff  --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 379f762275c6..82036a295002 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -2749,6 +2749,8 @@ class ArrayTypeTraitExpr : public Expr {
   : Expr(ArrayTypeTraitExprClass, ty, VK_RValue, OK_Ordinary), ATT(att),
 Value(value), Dimension(dimension), Loc(loc), RParen(rparen),
 QueriedType(queried) {
+assert(att <= ATT_Last && "invalid enum value!");
+assert(static_cast(att) == ATT && "ATT overflow!");
 setDependence(computeDependence(this));
   }
 
@@ -2813,6 +2815,8 @@ class ExpressionTraitExpr : public Expr {
   : Expr(ExpressionTraitExprClass, resultType, VK_RValue, OK_Ordinary),
 ET(et), Value(value), Loc(loc), RParen(rparen),
 QueriedExpression(queried) {
+assert(et <= ET_Last && "invalid enum value!");
+assert(static_cast(et) == ET && "ET overflow!");
 setDependence(computeDependence(this));
   }
 

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 71cc159d06fb..89eb8e9c0220 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1535,7 +1535,10 @@ UnaryExprOrTypeTraitExpr::UnaryExprOrTypeTraitExpr(
 SourceLocation op, SourceLocation rp)
 : Expr(UnaryExprOrTypeTraitExprClass, resultType, VK_RValue, OK_Ordinary),
   OpLoc(op), RParenLoc(rp) {
+  assert(ExprKind <= UETT_Last && "invalid enum value!");
   UnaryExprOrTypeTraitExprBits.Kind = ExprKind;
+  assert(static_cast(ExprKind) == UnaryExprOrTypeTraitExprBits.Kind 
&&
+ "UnaryExprOrTypeTraitExprBits.Kind overflow!");
   UnaryExprOrTypeTraitExprBits.IsType = false;
   Argument.Ex = E;
   setDependence(computeDependence(this));

diff  --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 9d285550ef90..9d4df28c7473 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -1579,6 +1579,7 @@ TypeTraitExpr::TypeTraitExpr(QualType T, SourceLocation 
Loc, TypeTrait Kind,
  SourceLocation RParenLoc, bool Value)
 : Expr(TypeTraitExprClass, T, VK_RValue, OK_Ordinary), Loc(Loc),
   RParenLoc(RParenLoc) {
+  assert(Kind <= TT_Last && "invalid enum value!");
   TypeTraitExprBits.Kind = Kind;
   assert(static_cast(Kind) == TypeTraitExprBits.Kind &&
  "TypeTraitExprBits.Kind overflow!");



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


[PATCH] D79972: [OpenMP5.0] map item can be non-contiguous for target update

2020-06-11 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7327-7330
+  bool IsNonContiguous = false,
+  MapNonContiguousArrayTy *const Offsets = nullptr,
+  MapNonContiguousArrayTy *const Counts = nullptr,
+  MapNonContiguousArrayTy *const Strides = nullptr) const {

I would prefer to pack these 4 params into a single parameter (a struct). Also, 
can we put `Dims` parameter into the list of the optional parameters?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7805
+  // should be [10, 10] and the first stride is 4 btyes.
+  for (const auto &Component : Components) {
+const Expr *AssocExpr = Component.getAssociatedExpression();

Expand `auto` here to a real type



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7807
+const Expr *AssocExpr = Component.getAssociatedExpression();
+const auto *OASE = dyn_cast(AssocExpr);
+if (OASE) {

Can we have anything else except for array section here? If not, use just 
`cast`. If yes, use `continue` to simplify complexity:
```
if (!OASE)
  continue;
...
```



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7821
+  Context.getTypeSizeInChars(ElementType).getQuantity();
+} else if (VAT) {
+  ElementType = VAT->getElementType().getTypePtr();

What if the base is a pointer, not an array?



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7831-7838
+  llvm::Value *SizeV = nullptr;
+  if (CAT) {
+llvm::APInt Size = CAT->getSize();
+SizeV = llvm::ConstantInt::get(CGF.SizeTy, Size);
+  } else if (VAT) {
+const Expr *Size = VAT->getSizeExpr();
+SizeV = CGF.EmitScalarExpr(Size);

The code for `SizeV` must be under the control of the next `if`:
```
if (DimSizes.size() < Components.size() - 1) {
 
}
```



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7834
+llvm::APInt Size = CAT->getSize();
+SizeV = llvm::ConstantInt::get(CGF.SizeTy, Size);
+  } else if (VAT) {

Create directly as of `CGF.Int64Ty` type.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7859
+  // declaration in target update to/from clause.
+  for (const auto &Component : Components) {
+const Expr *AssocExpr = Component.getAssociatedExpression();

Expand `auto` here to a real type



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7861-7864
+const auto *OASE = dyn_cast(AssocExpr);
+
+if (OASE) {
+  // Offset

Can we have anything else except for array section here? If not, use just 
`cast`. If yes, use `continue` to simplify complexity:
```
if (!OASE)
  continue;
...
```



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7872-7873
+  } else {
+Offset = CGF.Builder.CreateIntCast(CGF.EmitScalarExpr(OffsetExpr),
+   CGF.Int64Ty,
+   /*isSigned=*/false);

Do you really to pass real offsets here? Can we use pointers instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79972



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


[PATCH] D80301: [yaml][clang-tidy] Fix new line YAML serialization

2020-06-11 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 270206.
DmitryPolukhin added a comment.

Fix single new line handling, it should be replace with space


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80301

Files:
  clang/include/clang/Tooling/ReplacementsYaml.h
  llvm/lib/Support/YAMLTraits.cpp
  llvm/unittests/Support/YAMLIOTest.cpp

Index: llvm/unittests/Support/YAMLIOTest.cpp
===
--- llvm/unittests/Support/YAMLIOTest.cpp
+++ llvm/unittests/Support/YAMLIOTest.cpp
@@ -274,8 +274,8 @@
 
 TEST(YAMLIO, MultilineStrings) {
   WithStringField Original;
-  Original.str1 = "a multiline string\nfoobarbaz";
-  Original.str2 = "another one\rfoobarbaz";
+  Original.str1 = "a\n\nmultiline\nstring\nfoobarbaz ";
+  Original.str2 = "another one\rfoobarbaz\n";
   Original.str3 = "a one-line string";
 
   std::string Serialized;
@@ -285,10 +285,10 @@
 YOut << Original;
   }
   auto Expected = "---\n"
-  "str1:'a multiline string\n"
-  "foobarbaz'\n"
+  "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
+  "foobarbaz '\n"
   "str2:'another one\r"
-  "foobarbaz'\n"
+  "foobarbaz\n\n'\n"
   "str3:a one-line string\n"
   "...\n";
   ASSERT_EQ(Serialized, Expected);
@@ -305,6 +305,25 @@
   EXPECT_EQ(Original.str1, Deserialized.str1);
   EXPECT_EQ(Original.str2, Deserialized.str2);
   EXPECT_EQ(Original.str3, Deserialized.str3);
+
+  // Check deserialization of single '\n' that should be converted to space.
+  Serialized = "---\n"
+   "str1:'a\n\n\n\nmultiline\n\nstring\n\n"
+   "foobarbaz\n'\n"
+   "str2:'another\none\r"
+   "foobarbaz\n\n'\n"
+   "str3:a one-line string\n"
+   "...\n";
+  {
+Input YIn(Serialized);
+YIn >> Deserialized;
+ASSERT_FALSE(YIn.error())
+<< "Parsing error occurred during deserialization. Serialized string:\n"
+<< Serialized;
+  }
+  EXPECT_EQ(Original.str1, Deserialized.str1);
+  EXPECT_EQ(Original.str2, Deserialized.str2);
+  EXPECT_EQ(Original.str3, Deserialized.str3);
 }
 
 TEST(YAMLIO, NoQuotesForTab) {
Index: llvm/lib/Support/YAMLTraits.cpp
===
--- llvm/lib/Support/YAMLTraits.cpp
+++ llvm/lib/Support/YAMLTraits.cpp
@@ -876,13 +876,38 @@
 }
 
 void ScalarTraits::output(const std::string &Val, void *,
- raw_ostream &Out) {
-  Out << Val;
+   raw_ostream &Out) {
+  SmallVector Lines;
+  StringRef(Val).split(Lines, '\n');
+  bool First = true;
+  for (StringRef Line : Lines) {
+if (First)
+  First = false;
+else
+  Out << "\n\n";
+Out << Line;
+  }
 }
 
 StringRef ScalarTraits::input(StringRef Scalar, void *,
- std::string &Val) {
-  Val = Scalar.str();
+   std::string &Val) {
+  Val.clear();
+  SmallVector Lines;
+  Scalar.split(Lines, '\n');
+  size_t C = Lines.size();
+  for (size_t I = 0; I < C; ++I) {
+Val += Lines[I];
+// Next empty line means that it was '\n\n' that should convert to '\n'.
+// +2 here because we need separator only if more elements will be added.
+if (I + 2 < C && Lines[I + 1].empty()) {
+  Val += '\n';
+  ++I;
+} else if ((I + 1 < C && !Lines[I + 1].empty()) ||
+   (I + 2 == C && Lines[I + 1].empty())) {
+  // Single '\n' should be converted to space ' '.
+  Val += ' ';
+}
+  }
   return StringRef();
 }
 
Index: clang/include/clang/Tooling/ReplacementsYaml.h
===
--- clang/include/clang/Tooling/ReplacementsYaml.h
+++ clang/include/clang/Tooling/ReplacementsYaml.h
@@ -35,13 +35,7 @@
 
 NormalizedReplacement(const IO &, const clang::tooling::Replacement &R)
 : FilePath(R.getFilePath()), Offset(R.getOffset()),
-  Length(R.getLength()), ReplacementText(R.getReplacementText()) {
-  size_t lineBreakPos = ReplacementText.find('\n');
-  while (lineBreakPos != std::string::npos) {
-ReplacementText.replace(lineBreakPos, 1, "\n\n");
-lineBreakPos = ReplacementText.find('\n', lineBreakPos + 2);
-  }
-}
+  Length(R.getLength()), ReplacementText(R.getReplacementText()) {}
 
 clang::tooling::Replacement denormalize(const IO &) {
   return clang::tooling::Replacement(FilePath, Offset, Length,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D78122: [analyzer][Nullability] Don't emit under the checker name NullabilityBase

2020-06-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Nope, false alarm! Our buildbot configuration change was at fault. Sorry for 
forgetting to follow up >.<


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78122



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


[PATCH] D80947: Add to the Coding Standard our that single-line bodies omit braces

2020-06-11 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc08ea0771682: Add to the Coding Standard our that 
single-line bodies omit braces (authored by erichkeane).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80947

Files:
  llvm/docs/CodingStandards.rst

Index: llvm/docs/CodingStandards.rst
===
--- llvm/docs/CodingStandards.rst
+++ llvm/docs/CodingStandards.rst
@@ -669,15 +669,15 @@
 .. code-block:: c++
 
   // Typically there's no reason to copy.
-  for (const auto &Val : Container) { observe(Val); }
-  for (auto &Val : Container) { Val.change(); }
+  for (const auto &Val : Container) observe(Val);
+  for (auto &Val : Container) Val.change();
 
   // Remove the reference if you really want a new copy.
   for (auto Val : Container) { Val.change(); saveSomewhere(Val); }
 
   // Copy pointers, but make it clear that they're pointers.
-  for (const auto *Ptr : Container) { observe(*Ptr); }
-  for (auto *Ptr : Container) { Ptr->change(); }
+  for (const auto *Ptr : Container) observe(*Ptr);
+  for (auto *Ptr : Container) Ptr->change();
 
 Beware of non-determinism due to ordering of pointers
 ^
@@ -884,7 +884,7 @@
 .. code-block:: c++
 
   Value *doSomething(Instruction *I) {
-// Terminators never need 'something' done to them because ... 
+// Terminators never need 'something' done to them because ...
 if (I->isTerminator())
   return 0;
 
@@ -896,7 +896,7 @@
 // This is really just here for example.
 if (!doOtherThing(I))
   return 0;
-
+
 ... some long code 
   }
 
@@ -1000,7 +1000,7 @@
   Type = Context.getsigjmp_bufType();
 else
   Type = Context.getjmp_bufType();
-
+
 if (Type.isNull()) {
   Error = Signed ? ASTContext::GE_Missing_sigjmp_buf :
ASTContext::GE_Missing_jmp_buf;
@@ -1010,7 +1010,7 @@
 
 The idea is to reduce indentation and the amount of code you have to keep track
 of when reading the code.
-  
+
 Turn Predicate Loops into Predicate Functions
 ^
 
@@ -1081,7 +1081,7 @@
 * **Variable names** should be nouns (as they represent state).  The name should
   be camel case, and start with an upper case letter (e.g. ``Leader`` or
   ``Boats``).
-  
+
 * **Function names** should be verb phrases (as they represent actions), and
   command-like function should be imperative.  The name should be camel case,
   and start with a lower case letter (e.g. ``openFile()`` or ``isFoo()``).
@@ -1091,7 +1091,7 @@
   discriminator for a union, or an indicator of a subclass.  When an enum is
   used for something like this, it should have a ``Kind`` suffix
   (e.g. ``ValueKind``).
-  
+
 * **Enumerators** (e.g. ``enum { Foo, Bar }``) and **public member variables**
   should start with an upper-case letter, just like types.  Unless the
   enumerators are defined in their own small namespace or inside a class,
@@ -1107,7 +1107,7 @@
 MaxSize = 42,
 Density = 12
   };
-  
+
 As an exception, classes that mimic STL classes can have member names in STL's
 style of lower-case words separated by underscores (e.g. ``begin()``,
 ``push_back()``, and ``empty()``). Classes that provide multiple
@@ -1359,7 +1359,7 @@
 The use of ``#include `` in library files is hereby **forbidden**,
 because many common implementations transparently inject a `static constructor`_
 into every translation unit that includes it.
-  
+
 Note that using the other stream headers ( for example) is not
 problematic in this regard --- just . However, ``raw_ostream``
 provides various APIs that are better performing for almost every use than
@@ -1491,7 +1491,7 @@
   public:
 explicit Grokable() { ... }
 virtual ~Grokable() = 0;
-  
+
 ...
 
   };
@@ -1540,8 +1540,8 @@
   };
   } // end anonymous namespace
 
-  static void runHelper() { 
-... 
+  static void runHelper() {
+...
   }
 
   bool StringSort::operator<(const char *RHS) const {
@@ -1569,6 +1569,53 @@
 contrast, when the function is marked static, you don't need to cross-reference
 faraway places in the file to tell that the function is local.
 
+Don't Use Braces on Simple Single-Statement Bodies of if/else/loop Statements
+^
+
+When writing the body of an ``if``, ``else``, or loop statement, omit the braces to
+avoid unnecessary line noise. However, braces should be used in cases where the
+omission of braces harm the readability and maintainability of the code.
+
+Readability is harmed when a single statement is accompanied by a comment that loses
+its meaning if hoisted above the ``if`` or loop statement. Similarly, braces should
+be used when single-statement body is complex enough that it

[PATCH] D81670: [TTI] Expose isNoopAddrSpaceCast from TLI.[SROA] Teach SROA to recognize no-op addrspacecast.

2020-06-11 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D81670#2087974 , @arsenm wrote:

> We should instead allow bitcast to perform no-op addrspacecasts


That may be a little bit challenging as so far no-op `addrspacecast` is 
target-specific. There may be no TTI available when `bitcast` is constructed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81670



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


[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-06-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D72705#1871996 , @Szelethus wrote:

> @NoQ, @xazax.hun, @baloghadamsoftware, how do you like this patch? I think 
> the high level idea is correct.


I still don't understand how do we enable this checker, i.e. for whom and how 
often. Is there anything we'll be able to turn on by default, like maybe warn 
on all functions that wear `__attribute__((warn_unused_result))`?




Comment at: clang/lib/StaticAnalyzer/Checkers/ErrorReturnChecker.cpp:309-311
+void ErrorReturnChecker::checkAccess(CheckerContext &C, ProgramStateRef State,
+ const Stmt *LoadS, SymbolRef CallSym,
+ const CalledFunctionData *CFD) const {

Why scan parent statements proactively given that we will reach them later 
anyway? Looks like you're using a wrong checker callback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705



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


[PATCH] D81407: [Analyzer][StreamChecker] Add note tags for file opening.

2020-06-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:376-377
+std::string operator()(PathSensitiveBugReport &BR) const {
+  if (BR.isInteresting(StreamSym))
+return Message;
+

Another thing you might want to check is that the warning is coming from your 
checker. The symbol may be marked as interesting by another checker for a 
completely unrelated reason. The easiest way to check that is usually to 
compare the report's bug type to your checker's bug type.

(we should absolutely automate this)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81407



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


[libunwind] 96e6cbb - [libc++] Allow specifying arbitrary custom executors with the new format

2020-06-11 Thread Louis Dionne via cfe-commits

Author: Louis Dionne
Date: 2020-06-11T16:24:29-04:00
New Revision: 96e6cbbf941d0f937b7e823433d4c222967a1817

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

LOG: [libc++] Allow specifying arbitrary custom executors with the new format

The integration between CMake and executor selection in the new format
wasn't very flexible -- only the default executor and SSH executors were
supported.

This patch makes it possible to specify arbitrary executors with the new
format. With the new testing format, a custom executor is just a script
that gets called with a command-line to execute, and some arguments like
--env, --codesign_identity and --execdir. As such, the default executor
is just run.py.

Remote execution with the SSH executor can be achived by specifying
LIBCXX_EXECUTOR=" --host ". Similarly, arbitrary
scripts can be provided.

Added: 


Modified: 
libcxx/test/CMakeLists.txt
libcxx/utils/libcxx/test/config.py
libcxxabi/test/CMakeLists.txt
libunwind/test/CMakeLists.txt

Removed: 




diff  --git a/libcxx/test/CMakeLists.txt b/libcxx/test/CMakeLists.txt
index 5068cbd1b1b0..b68f59f38e76 100644
--- a/libcxx/test/CMakeLists.txt
+++ b/libcxx/test/CMakeLists.txt
@@ -81,7 +81,7 @@ endif()
 
 set(LIBCXX_TARGET_INFO "libcxx.test.target_info.LocalTI" CACHE STRING
 "TargetInfo to use when setting up test environment.")
-set(LIBCXX_EXECUTOR "None" CACHE STRING
+set(LIBCXX_EXECUTOR "${Python3_EXECUTABLE} 
${CMAKE_CURRENT_LIST_DIR}/../utils/run.py" CACHE STRING
 "Executor to use when running tests.")
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")

diff  --git a/libcxx/utils/libcxx/test/config.py 
b/libcxx/utils/libcxx/test/config.py
index 5eccc2783a74..44cb95943877 100644
--- a/libcxx/utils/libcxx/test/config.py
+++ b/libcxx/utils/libcxx/test/config.py
@@ -189,18 +189,22 @@ def get_test_format(self):
 exec_env=self.exec_env)
 
 def configure_executor(self):
-exec_str = self.get_lit_conf('executor', "None")
-te = eval(exec_str)
-if te:
-self.lit_config.note("Using executor: %r" % exec_str)
-if self.lit_config.useValgrind:
-self.lit_config.fatal("The libc++ test suite can't run under 
Valgrind with a custom executor")
-else:
-te = LocalExecutor()
+if self.get_lit_conf('use_old_format'):
+exec_str = self.get_lit_conf('executor', "None")
+te = eval(exec_str)
+if te:
+self.lit_config.note("Using executor: %r" % exec_str)
+if self.lit_config.useValgrind:
+self.lit_config.fatal("The libc++ test suite can't run 
under Valgrind with a custom executor")
+else:
+te = LocalExecutor()
 
-te.target_info = self.target_info
-self.target_info.executor = te
-self.executor = te
+te.target_info = self.target_info
+self.target_info.executor = te
+self.executor = te
+else:
+self.executor = self.get_lit_conf('executor')
+self.lit_config.note("Using executor: {}".format(self.executor))
 
 def configure_target_info(self):
 self.target_info = make_target_info(self)
@@ -751,14 +755,8 @@ def configure_substitutions(self):
 '--codesign_identity "{}"'.format(codesign_ident),
 '--env {}'.format(env_vars)
 ]
-if isinstance(self.executor, SSHExecutor):
-exec_args.append('--host {}'.format(self.executor.user_prefix + 
self.executor.host))
-executor = os.path.join(self.libcxx_src_root, 'utils', 'ssh.py')
-else:
-executor = os.path.join(self.libcxx_src_root, 'utils', 'run.py')
-sub.append(('%{exec}', '{} {} {} -- 
'.format(pipes.quote(sys.executable),
- pipes.quote(executor),
- ' '.join(exec_args
+if not self.get_lit_conf('use_old_format'):
+sub.append(('%{exec}', '{} {} -- '.format(self.executor, ' 
'.join(exec_args
 if self.get_lit_conf('libcxx_gdb'):
 sub.append(('%{libcxx_gdb}', self.get_lit_conf('libcxx_gdb')))
 

diff  --git a/libcxxabi/test/CMakeLists.txt b/libcxxabi/test/CMakeLists.txt
index bedfce8bc397..2160f52c3350 100644
--- a/libcxxabi/test/CMakeLists.txt
+++ b/libcxxabi/test/CMakeLists.txt
@@ -32,7 +32,7 @@ if(LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX AND NOT 
LIBCXX_ENABLE_SHARED)
 endif()
 
 if(DEFINED LIBCXX_ENABLE_STATIC
-   AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX 
+   AND NOT LIBCXXABI_LINK_TESTS_WITH_SHARED_LIBCXX
AND NOT LIBCXX_ENABLE_STATIC)
   message(FATAL_ERROR "LIBCXXABI

[PATCH] D80952: [FPEnv][Clang][Driver] Disable constrained floating point on targets lacking support.

2020-06-11 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn updated this revision to Diff 270219.
kpn retitled this revision from "[FPEnv][Clang][Driver][WIP] Disable 
constrained floating point on targets lacking support." to 
"[FPEnv][Clang][Driver] Disable constrained floating point on targets lacking 
support.".
kpn added a comment.
Herald added a subscriber: kbarton.

Added new warnings to a new group "unsupported-floating-point-opt". The warning 
can be disabled. The disabling of constrained floating point is unaffected by 
the status of the warning.

I added PowerPC to the list of targets that are _not_ disabled by this patch 
since that target is close to parity with X86 and SystemZ.

Is there anything left?


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

https://reviews.llvm.org/D80952

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SystemZ.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/Frontend/CompilerInstance.cpp
  clang/test/CodeGen/aarch64-neon-misc-constrained.c
  clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
  clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
  clang/test/CodeGen/arm64-vrnd-constrained.c
  clang/test/CodeGen/fp-strictfp.cpp

Index: clang/test/CodeGen/fp-strictfp.cpp
===
--- /dev/null
+++ clang/test/CodeGen/fp-strictfp.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -ffp-exception-behavior=strict -O2 -verify=rounding,exception -emit-llvm -o - %s | tee /tmp/1 | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -ffp-exception-behavior=strict -O2 -verify=exception -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -frounding-math -O2 -verify=rounding -emit-llvm -o - %s | FileCheck %s
+//
+// Verify that constrained intrinsics are not used.
+// As more targets gain support for constrained intrinsics the triple
+// in this test will need to change.
+
+// rounding-warning@* {{overriding currently unsupported rounding mode on this target}}
+// exception-warning@* {{overriding currently unsupported use of floating point exceptions on this target}}
+float fp_precise_1(float a, float b, float c) {
+// CHECK: _Z12fp_precise_1fff
+// CHECK: %[[M:.+]] = fmul float{{.*}}
+// CHECK: fadd float %[[M]], %c
+  return a * b + c;
+}
+
+
Index: clang/test/CodeGen/arm64-vrnd-constrained.c
===
--- clang/test/CodeGen/arm64-vrnd-constrained.c
+++ clang/test/CodeGen/arm64-vrnd-constrained.c
@@ -9,6 +9,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 float64x2_t rnd5(float64x2_t a) { return vrndq_f64(a); }
Index: clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
===
--- clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
+++ clang/test/CodeGen/arm-neon-directed-rounding-constrained.c
@@ -32,6 +32,9 @@
 
 // REQUIRES: arm-registered-target,aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vrndi_f32
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics-constrained.c
@@ -19,6 +19,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 #include 
 
 // COMMON-LABEL: test_vsqrt_f16
Index: clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
+++ clang/test/CodeGen/aarch64-neon-scalar-x-indexed-elem-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/test/CodeGen/aarch64-neon-misc-constrained.c
===
--- clang/test/CodeGen/aarch64-neon-misc-constrained.c
+++ clang/test/CodeGen/aarch64-neon-misc-constrained.c
@@ -15,6 +15,9 @@
 
 // REQUIRES: aarch64-registered-target
 
+// Disabled until constrained floating point is implemented for arm64.
+// XFAIL: *
+
 // Test new aarch64 intrinsics and types but constrained
 
 #include 
Index: clang/lib/Frontend/CompilerInstance.cpp
=

[PATCH] D81688: [WebAssembly] WebAssembly doesn't support "protected" visibility

2020-06-11 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
Herald added subscribers: llvm-commits, aheejin, jgravelle-google, sbc100, 
dschuff.
Herald added projects: clang, LLVM.

mplement the `hasProtectedVisibility()` hook to indicate that, like
Darwin, WebAssembly doesn't support "protected" visibility.

On ELF, "protected" visibility is intended to be an optimization, however
in practice it often [isn't], and ELF documentation generally ranges from
[not mentioning it at all] to [strongly discouraging its use].

[isn't]: https://www.airs.com/blog/archives/307
[not mentioning it at all]: https://gcc.gnu.org/wiki/Visibility
[strongly discouraging its use]: https://www.akkadia.org/drepper/dsohowto.pdf

While here, also mention the new Reactor support in the release notes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81688

Files:
  clang/lib/Basic/Targets/WebAssembly.h
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -144,8 +144,14 @@
 Changes to the WebAssembly Target
 -
 
-During this release ...
-
+* Programs which don't have a "main" function, called "reactors" are now
+  properly supported, with a new `-mexec-model=reactor` flag. Programs which
+  previously used `-Wl,--no-entry` to avoid having a main function should
+  switch to this new flag, so that static initialization is properly
+  performed.
+
+* `__attribute__((visibility("protected")))` now evokes a warning, as
+  WebAssembly does not support "protected" visibility.
 
 Changes to the OCaml bindings
 -
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -132,7 +132,14 @@
   }
 
   bool hasExtIntType() const override { return true; }
+
+  bool hasProtectedVisibility() const override {
+// For compatibility, continue to advertise "protected" support for
+// Emscripten targets.
+return getTriple().isOSEmscripten();
+  }
 };
+
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
 : public WebAssemblyTargetInfo {
 public:


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -144,8 +144,14 @@
 Changes to the WebAssembly Target
 -
 
-During this release ...
-
+* Programs which don't have a "main" function, called "reactors" are now
+  properly supported, with a new `-mexec-model=reactor` flag. Programs which
+  previously used `-Wl,--no-entry` to avoid having a main function should
+  switch to this new flag, so that static initialization is properly
+  performed.
+
+* `__attribute__((visibility("protected")))` now evokes a warning, as
+  WebAssembly does not support "protected" visibility.
 
 Changes to the OCaml bindings
 -
Index: clang/lib/Basic/Targets/WebAssembly.h
===
--- clang/lib/Basic/Targets/WebAssembly.h
+++ clang/lib/Basic/Targets/WebAssembly.h
@@ -132,7 +132,14 @@
   }
 
   bool hasExtIntType() const override { return true; }
+
+  bool hasProtectedVisibility() const override {
+// For compatibility, continue to advertise "protected" support for
+// Emscripten targets.
+return getTriple().isOSEmscripten();
+  }
 };
+
 class LLVM_LIBRARY_VISIBILITY WebAssembly32TargetInfo
 : public WebAssemblyTargetInfo {
 public:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81608: Fix incorrect call to ExprResult::get()

2020-06-11 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks! Great spot!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81608



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


[PATCH] D81691: [clangd] Set CWD in semaCodeComplete

2020-06-11 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81691

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


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ? &Input.Preamble.Preamble : 
nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);


Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -1116,6 +1116,9 @@
   Input.ParseInput.FSProvider->getFileSystem();
   if (Input.Preamble.StatCache)
 VFS = Input.Preamble.StatCache->getConsumingFS(std::move(VFS));
+  if (VFS->setCurrentWorkingDirectory(
+  Input.ParseInput.CompileCommand.Directory))
+elog("Couldn't set working directory during code completion");
   auto Clang = prepareCompilerInstance(
   std::move(CI), !CompletingInPreamble ? &Input.Preamble.Preamble : nullptr,
   std::move(ContentsBuffer), std::move(VFS), IgnoreDiags);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D81641: [SYCL] Implement thread-local storage restriction

2020-06-11 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

OpenMP has the same restriction (no surprise I guess). Thanks for the ping!

I think we do not emit diagnosis right now: https://godbolt.org/z/srDkXZ
I think we also should diagnose this the same way, though it might be beyond 
the scope of this patch: https://godbolt.org/z/rRZFi4


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D81641



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


  1   2   >