r358745 - [LibTooling] Fix -Wsign-compare after r358697

2019-04-19 Thread Bjorn Pettersson via cfe-commits
Author: bjope
Date: Fri Apr 19 02:10:42 2019
New Revision: 358745

URL: http://llvm.org/viewvc/llvm-project?rev=358745&view=rev
Log:
[LibTooling] Fix -Wsign-compare after r358697

Modified:
cfe/trunk/unittests/Tooling/TransformerTest.cpp

Modified: cfe/trunk/unittests/Tooling/TransformerTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/TransformerTest.cpp?rev=358745&r1=358744&r2=358745&view=diff
==
--- cfe/trunk/unittests/Tooling/TransformerTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/TransformerTest.cpp Fri Apr 19 02:10:42 2019
@@ -369,7 +369,7 @@ TEST_F(TransformerTest, OverlappingEdits
   // The rewrite process fails...
   EXPECT_TRUE(rewrite(Input));
   // ... but one AtomicChange was consumed:
-  ASSERT_EQ(Changes.size(), 1);
+  ASSERT_EQ(Changes.size(), 1u);
   EXPECT_TRUE(Changes[0].hasError());
 }
 
@@ -384,7 +384,7 @@ TEST_F(TransformerTest, OverlappingEdits
   // The rewrite process fails because the changes conflict with each other...
   EXPECT_FALSE(rewrite(Input));
   // ... but all changes are (individually) fine:
-  ASSERT_EQ(Changes.size(), 2);
+  ASSERT_EQ(Changes.size(), 2u);
   EXPECT_FALSE(Changes[0].hasError());
   EXPECT_FALSE(Changes[1].hasError());
 }


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


r358750 - [analyzer] Fix an assertion failure if plugins added dependencies

2019-04-19 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Apr 19 04:01:35 2019
New Revision: 358750

URL: http://llvm.org/viewvc/llvm-project?rev=358750&view=rev
Log:
[analyzer] Fix an assertion failure if plugins added dependencies

Ideally, there is no reason behind not being able to depend on checkers that
come from a different plugin (or on builtin checkers) -- however, this is only
possible if all checkers are added to the registry before resolving checker
dependencies. Since I used a binary search in my addDependency method, this also
resulted in an assertion failure (due to CheckerRegistry::Checkers not being
sorted), since the function used by plugins to register their checkers
(clang_registerCheckers) calls addDependency.

This patch resolves this issue by only noting which dependencies have to
established when addDependency is called, and resolves them at a later stage
when no more checkers are added to the registry, by which point
CheckerRegistry::Checkers is already sorted.

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

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/test/Analysis/checker-dependencies.c

Modified: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h?rev=358750&r1=358749&r2=358750&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h Fri Apr 
19 04:01:35 2019
@@ -195,6 +195,12 @@ private:
   CheckerInfoList Checkers;
   llvm::StringMap PackageSizes;
 
+  /// Contains all (Dependendent checker, Dependency) pairs. We need this, as
+  /// we'll resolve dependencies after all checkers were added first.
+  llvm::SmallVector, 0> Dependencies;
+
+  void resolveDependencies();
+
   DiagnosticsEngine &Diags;
   AnalyzerOptions &AnOpts;
   const LangOptions &LangOpts;

Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp?rev=358750&r1=358749&r2=358750&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp Fri Apr 19 
04:01:35 2019
@@ -177,6 +177,8 @@ CheckerRegistry::CheckerRegistry(
 #undef CHECKER_DEPENDENCY
 #undef GET_CHECKER_DEPENDENCIES
 
+  resolveDependencies();
+
   // Parse '-analyzer-checker' and '-analyzer-disable-checker' options from the
   // command line.
   for (const std::pair &Opt : AnOpts.CheckersControlList) {
@@ -278,18 +280,26 @@ void CheckerRegistry::addChecker(Initial
   }
 }
 
-void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
-  auto CheckerIt = binaryFind(Checkers, FullName);
-  assert(CheckerIt != Checkers.end() && CheckerIt->FullName == FullName &&
- "Failed to find the checker while attempting to set up its "
- "dependencies!");
-
-  auto DependencyIt = binaryFind(Checkers, Dependency);
-  assert(DependencyIt != Checkers.end() &&
- DependencyIt->FullName == Dependency &&
- "Failed to find the dependency of a checker!");
+void CheckerRegistry::resolveDependencies() {
+  for (const std::pair &Entry : Dependencies) {
+auto CheckerIt = binaryFind(Checkers, Entry.first);
+assert(CheckerIt != Checkers.end() && CheckerIt->FullName == Entry.first &&
+   "Failed to find the checker while attempting to set up its "
+   "dependencies!");
+
+auto DependencyIt = binaryFind(Checkers, Entry.second);
+assert(DependencyIt != Checkers.end() &&
+   DependencyIt->FullName == Entry.second &&
+   "Failed to find the dependency of a checker!");
+
+CheckerIt->Dependencies.emplace_back(&*DependencyIt);
+  }
 
-  CheckerIt->Dependencies.emplace_back(&*DependencyIt);
+  Dependencies.clear();
+}
+
+void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
+  Dependencies.emplace_back(FullName, Dependency);
 }
 
 void CheckerRegistry::initializeManager(CheckerManager &CheckerMgr) const {

Modified: cfe/trunk/test/Analysis/checker-dependencies.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/checker-dependencies.c?rev=358750&r1=358749&r2=358750&view=diff
==
--- cfe/trunk/test/Analysis/checker-dependencies.c (original)
+++ cfe/trunk/test/Analysis/checker-dependencies.c Fri Apr 19 04:01:35 2019
@@ -1,3 +1,20 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability.NullReturnedFromNonnull
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer

[PATCH] D59461: [analyzer] Fix an assertion failure if plugins added dependencies

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358750: [analyzer] Fix an assertion failure if plugins added 
dependencies (authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D59461?vs=190976&id=195869#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D59461

Files:
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/checker-dependencies.c


Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -195,6 +195,12 @@
   CheckerInfoList Checkers;
   llvm::StringMap PackageSizes;
 
+  /// Contains all (Dependendent checker, Dependency) pairs. We need this, as
+  /// we'll resolve dependencies after all checkers were added first.
+  llvm::SmallVector, 0> Dependencies;
+
+  void resolveDependencies();
+
   DiagnosticsEngine &Diags;
   AnalyzerOptions &AnOpts;
   const LangOptions &LangOpts;
Index: test/Analysis/checker-dependencies.c
===
--- test/Analysis/checker-dependencies.c
+++ test/Analysis/checker-dependencies.c
@@ -1,3 +1,20 @@
 // RUN: %clang_analyze_cc1 %s \
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=nullability.NullReturnedFromNonnull
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=osx.cocoa.RetainCount \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-ENABLED
+
+// CHECK-IMPLICITLY-ENABLED: osx.cocoa.RetainCountBase
+// CHECK-IMPLICITLY-ENABLED: osx.cocoa.RetainCount
+
+// RUN: %clang_analyze_cc1 %s \
+// RUN:   -analyzer-checker=osx.cocoa.RetainCount \
+// RUN:   -analyzer-disable-checker=osx.cocoa.RetainCountBase \
+// RUN:   -analyzer-list-enabled-checkers \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-IMPLICITLY-DISABLED
+
+// CHECK-IMPLICITLY-DISABLED-NOT: osx.cocoa.RetainCountBase
+// CHECK-IMPLICITLY-DISABLED-NOT: osx.cocoa.RetainCount
Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -177,6 +177,8 @@
 #undef CHECKER_DEPENDENCY
 #undef GET_CHECKER_DEPENDENCIES
 
+  resolveDependencies();
+
   // Parse '-analyzer-checker' and '-analyzer-disable-checker' options from the
   // command line.
   for (const std::pair &Opt : AnOpts.CheckersControlList) {
@@ -278,18 +280,26 @@
   }
 }
 
-void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
-  auto CheckerIt = binaryFind(Checkers, FullName);
-  assert(CheckerIt != Checkers.end() && CheckerIt->FullName == FullName &&
- "Failed to find the checker while attempting to set up its "
- "dependencies!");
-
-  auto DependencyIt = binaryFind(Checkers, Dependency);
-  assert(DependencyIt != Checkers.end() &&
- DependencyIt->FullName == Dependency &&
- "Failed to find the dependency of a checker!");
+void CheckerRegistry::resolveDependencies() {
+  for (const std::pair &Entry : Dependencies) {
+auto CheckerIt = binaryFind(Checkers, Entry.first);
+assert(CheckerIt != Checkers.end() && CheckerIt->FullName == Entry.first &&
+   "Failed to find the checker while attempting to set up its "
+   "dependencies!");
+
+auto DependencyIt = binaryFind(Checkers, Entry.second);
+assert(DependencyIt != Checkers.end() &&
+   DependencyIt->FullName == Entry.second &&
+   "Failed to find the dependency of a checker!");
+
+CheckerIt->Dependencies.emplace_back(&*DependencyIt);
+  }
 
-  CheckerIt->Dependencies.emplace_back(&*DependencyIt);
+  Dependencies.clear();
+}
+
+void CheckerRegistry::addDependency(StringRef FullName, StringRef Dependency) {
+  Dependencies.emplace_back(FullName, Dependency);
 }
 
 void CheckerRegistry::initializeManager(CheckerManager &CheckerMgr) const {


Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -195,6 +195,12 @@
   CheckerInfoList Checkers;
   llvm::StringMap PackageSizes;
 
+  /// Contains all (Dependendent checker, Dependency) pairs. We need this, as
+  /// we'll resolve dependencies after all checkers were added first.
+  llvm::SmallVector, 0> Dependencies;
+
+  void resolveDependencies();
+
   DiagnosticsEngine &Diags;
   AnalyzerOptions &AnOpts;
   const LangOptions &LangOpts;
Index: test/Analysis/checker-dependencies.c

[PATCH] D60516: [LTO] Add plumbing to save stats during LTO on Darwin.

2019-04-19 Thread Florian Hahn via Phabricator via cfe-commits
fhahn marked 2 inline comments as done.
fhahn added a comment.

In D60516#1470518 , @tejohnson wrote:

> LGTM with a minor fix needed below.
>
> Darwin still uses the old LTO API, which is why the lto Config based handling 
> in the new LTO API (LTO.h/LTO.cpp) are not being used on this path.


Yep, that is unfortunate. I'll create a PR to move it to the new API.




Comment at: llvm/lib/LTO/LTOCodeGenerator.cpp:101
+"lto-stats-file",
+cl::desc("With PGO, include profile count in optimization remarks"),
+cl::Hidden);

tejohnson wrote:
> Wrong description for this option
Thanks, I'll fix it before I commit the change.



Comment at: llvm/lib/LTO/LTOCodeGenerator.cpp:601
   // If statistics were requested, print them out after codegen.
-  if (llvm::AreStatisticsEnabled())
+  if (llvm::AreStatisticsEnabled() && !StatsFile)
 llvm::PrintStatistics();

steven_wu wrote:
> You can simplify the logic a bit here.
> ```
> if (StatsFile)
> ...
> else if (llvm::AreStatisticsEnabled())
> ...
> ```
Thanks, I'll fix it before I commit the change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60516



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


r358752 - [analyzer][NFC] Reimplement checker options

2019-04-19 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Apr 19 05:32:10 2019
New Revision: 358752

URL: http://llvm.org/viewvc/llvm-project?rev=358752&view=rev
Log:
[analyzer][NFC] Reimplement checker options

TL;DR:

* Add checker and package options to the TableGen files
* Added a new class called CmdLineOption, and both Package and Checker recieved
   a list field.
* Added every existing checker and package option to Checkers.td.
* The CheckerRegistry class
  * Received some comments to most of it's inline classes
  * Received the CmdLineOption and PackageInfo inline classes, a list of
 CmdLineOption was added to CheckerInfo and PackageInfo
  * Added addCheckerOption and addPackageOption
  * Added a new field called Packages, used in addPackageOptions, filled up in
 addPackage

Detailed description:

In the last couple months, a lot of effort was put into tightening the
analyzer's command line interface. The main issue is that it's spectacularly
easy to mess up a lenghty enough invocation of the analyzer, and the user was
given no warnings or errors at all in that case.

We can divide the effort of resolving this into several chapters:

* Non-checker analyzer configurations:
Gather every analyzer configuration into a dedicated file. Emit errors for
non-existent configurations or incorrect values. Be able to list these
configurations. Tighten AnalyzerOptions interface to disallow making such
a mistake in the future.

* Fix the "Checker Naming Bug" by reimplementing checker dependencies:
When cplusplus.InnerPointer was enabled, it implicitly registered
unix.Malloc, which implicitly registered some sort of a modeling checker
from the CStringChecker family. This resulted in all of these checker
objects recieving the name "cplusplus.InnerPointer", making AnalyzerOptions
asking for the wrong checker options from the command line:
  cplusplus.InnerPointer:Optimisic
istead of
  unix.Malloc:Optimistic.
This was resolved by making CheckerRegistry responsible for checker
dependency handling, instead of checkers themselves.

* Checker options: (this patch included!)
Same as the first item, but for checkers.

(+ minor fixes here and there, and everything else that is yet to come)

There were several issues regarding checker options, that non-checker
configurations didn't suffer from: checker plugins are loaded runtime, and they
could add new checkers and new options, meaning that unlike for non-checker
configurations, we can't collect every checker option purely by generating code.
Also, as seen from the "Checker Naming Bug" issue raised above, they are very
rarely used in practice, and all sorts of skeletons fell out of the closet while
working on this project.

They were extremely problematic for users as well, purely because of how long
they were. Consider the following monster of a checker option:

  alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=false

While we were able to verify whether the checker itself (the part before the
colon) existed, any errors past that point were unreported, easily resulting
in 7+ hours of analyses going to waste.

This patch, similarly to how dependencies were reimplemented, uses TableGen to
register checker options into Checkers.td, so that Checkers.inc now contains
entries for both checker and package options. Using the preprocessor,
Checkers.inc is converted into code in CheckerRegistry, adding every builtin
(checkers and packages that have an entry in the Checkers.td file) checker and
package option to the registry. The new addPackageOption and addCheckerOption
functions expose the same functionality to statically-linked non-builtin and
plugin checkers and packages as well.

Emitting errors for incorrect user input, being able to list these options, and
some other functionalies will land in later patches.

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


Added:
cfe/trunk/test/Analysis/invalid-checker-option.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/test/Analysis/disable-all-checks.c
cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=358752&r1=358751&r2=358752&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri Apr 19 05:32:10 
2019
@@ -292,7 +292,7 @@ def err_omp_more_one_clause : Error<
 
 // Static Analyzer Core
 def err_unk

[PATCH] D57855: [analyzer][NFC] Reimplement checker options

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358752: [analyzer][NFC] Reimplement checker options 
(authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D57855?vs=190977&id=195872#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D57855

Files:
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/Frontend/CompilerInvocation.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/disable-all-checks.c
  test/Analysis/invalid-checker-option.c
  utils/TableGen/ClangSACheckersEmitter.cpp

Index: include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -91,6 +91,27 @@
   using InitializationFunction = void (*)(CheckerManager &);
   using ShouldRegisterFunction = bool (*)(const LangOptions &);
 
+  /// Specifies a command line option. It may either belong to a checker or a
+  /// package.
+  struct CmdLineOption {
+StringRef OptionType;
+StringRef OptionName;
+StringRef DefaultValStr;
+StringRef Description;
+
+CmdLineOption(StringRef OptionType, StringRef OptionName,
+  StringRef DefaultValStr, StringRef Description)
+: OptionType(OptionType), OptionName(OptionName),
+  DefaultValStr(DefaultValStr), Description(Description) {
+
+  assert((OptionType == "bool" || OptionType == "string" ||
+  OptionType == "int") &&
+ "Unknown command line option type!");
+}
+  };
+
+  using CmdLineOptionList = llvm::SmallVector;
+
   struct CheckerInfo;
 
   using CheckerInfoList = std::vector;
@@ -98,6 +119,8 @@
   using ConstCheckerInfoList = llvm::SmallVector;
   using CheckerInfoSet = llvm::SetVector;
 
+  /// Specifies a checker. Note that this isn't what we call a checker object,
+  /// it merely contains everything required to create one.
   struct CheckerInfo {
 enum class StateFromCmdLine {
   // This checker wasn't explicitly enabled or disabled.
@@ -113,6 +136,7 @@
 StringRef FullName;
 StringRef Desc;
 StringRef DocumentationUri;
+CmdLineOptionList CmdLineOptions;
 StateFromCmdLine State = StateFromCmdLine::State_Unspecified;
 
 ConstCheckerInfoList Dependencies;
@@ -136,6 +160,23 @@
 
   using StateFromCmdLine = CheckerInfo::StateFromCmdLine;
 
+  /// Specifies a package. Each package option is implicitly an option for all
+  /// checkers within the package.
+  struct PackageInfo {
+StringRef FullName;
+CmdLineOptionList CmdLineOptions;
+
+// Since each package must have a different full name, we can identify
+// CheckerInfo objects by them.
+bool operator==(const PackageInfo &Rhs) const {
+  return FullName == Rhs.FullName;
+}
+
+explicit PackageInfo(StringRef FullName) : FullName(FullName) {}
+  };
+
+  using PackageInfoList = llvm::SmallVector;
+
 private:
   template  static void initializeManager(CheckerManager &mgr) {
 mgr.registerChecker();
@@ -165,6 +206,35 @@
   /// called \p dependency.
   void addDependency(StringRef FullName, StringRef Dependency);
 
+  /// Registers an option to a given checker. A checker option will always have
+  /// the following format:
+  ///   CheckerFullName:OptionName=Value
+  /// And can be specified from the command line like this:
+  ///   -analyzer-config CheckerFullName:OptionName=Value
+  ///
+  /// Options for unknown checkers, or unknown options for a given checker, or
+  /// invalid value types for that given option are reported as an error in
+  /// non-compatibility mode.
+  void addCheckerOption(StringRef OptionType, StringRef CheckerFullName,
+StringRef OptionName, StringRef DefaultValStr,
+StringRef Description);
+
+  /// Adds a package to the registry.
+  void addPackage(StringRef FullName);
+
+  /// Registers an option to a given package. A package option will always have
+  /// the following format:
+  ///   PackageFullName:OptionName=Value
+  /// And can be specified from the command line like this:
+  ///   -analyzer-config PackageFullName:OptionName=Value
+  ///
+  /// Options for unknown packages, or unknown options for a given package, or
+  /// invalid value types for that given option are reported as an error in
+  /// non-compatibility mode.
+  void addPackageOption(StringRef OptionType, StringRef PackageFullName,
+StringRef OptionName, StringRef DefaultValStr,
+StringRef Description);
+
   // FIXME: This *really* should be added to the frontend flag descriptions.
   /// Initializes a CheckerManag

r358753 - [LTO] Add plumbing to save stats during LTO on Darwin.

2019-04-19 Thread Florian Hahn via cfe-commits
Author: fhahn
Date: Fri Apr 19 05:36:41 2019
New Revision: 358753

URL: http://llvm.org/viewvc/llvm-project?rev=358753&view=rev
Log:
[LTO] Add plumbing to save stats during LTO on Darwin.

Gold and ld on Linux already support saving stats, but the
infrastructure is missing on Darwin. Unfortunately it seems like the
configuration from lib/LTO/LTO.cpp is not used.

This patch adds a new LTOStatsFile option and adds plumbing in Clang to
use it on Darwin, similar to the way remarks are handled.

Currnetly the handling of LTO flags seems quite spread out, with a bunch
of duplication. But I am not sure if there is an easy way to improve
that?

Reviewers: anemet, tejohnson, thegameg, steven_wu

Reviewed By: steven_wu

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=358753&r1=358752&r2=358753&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Apr 19 05:36:41 2019
@@ -514,6 +514,14 @@ void darwin::Linker::ConstructJob(Compil
 }
   }
 
+  // Setup statistics file output.
+  SmallString<128> StatsFile =
+  getStatsFileName(Args, Output, Inputs[0], getToolChain().getDriver());
+  if (!StatsFile.empty()) {
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back(Args.MakeArgString("-lto-stats-file=" + 
StatsFile.str()));
+  }
+
   // It seems that the 'e' option is completely ignored for dynamic executables
   // (the default), and with static executables, the last one wins, as 
expected.
   Args.AddAllArgs(CmdArgs, {options::OPT_d_Flag, options::OPT_s, 
options::OPT_t,


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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

> SYCL is similar to OpenMP 5 for C++, where you use only C++ classes instead 
> of #pragma. So it is quite C++-friendlier than OpenMP.

I am not sure what you mean by friendlier? OpenMP concept is very clear to be - 
a program written in C/C++ or Fortran can be complimented with simple compiler 
directives to instruct the compiler about the parallelization.  Hence exactly 
the same program can be  used on sequential or parallel architectures. I can't 
imagine however anyone would use SYCL program on a non-parallel architecture? 
And this is where it is fundamentally different concept to me than C++ that has 
very different execution model (using very explicit language constructs for 
parallelism btw!).

To me SYCL dictates how program is to be written with explicit parallelism 
constructs using a special language. The fact that the language doesn't use 
different syntax from standard C++ at the moment doesn't mean that it's not 
there at least implicitly. If you would be able to just reuse C++ it would be 
perfectly a library style language but since you need language extensions to 
the compiler it isn't just a pure C++ library to me.

> But that means also there is not the same concept of explicit kernel like in 
> OpenCL or CUDA. In OpenCL or CUDA, when there is a function with a specific 
> attribute, you know it is a kernel and you can compile as such.

I am very confused, because if you don't need an explicit kernel construct why 
are you adding it here at all? The fact that you don't provide the 
documentation for it in the spec but yet add it as an explicit attribute in the 
language to allow implementing the feature does show that it is actually 
explicitly required. It is just well hidden behind the C++ library syntax that 
however requires activating features that aren't part of ISO C++. Perhaps I am 
still missing something but I am just worried that we are going to end up with 
a language that pretends to be a C++ library. I certainly see that CUDA or 
OpenCL could just add a layer of C++ libraries on top of their language 
extensions to provide the same functionality. So I still feel SYCL is closer to 
CUDA than to pure C++.

> In SYCL or OpenMP you need an outliner that will estimate what should be 
> executed as an heterogeneous kernel, split the code between the host side and 
> the device side, add some glue/stub to implement an RPC between the host and 
> the device, manage potentially some allocation/memory transfers, etc.

But in SYCL this is requested explicitly in the source code using language 
constructs, isn't it?

> This is quite more complex than compiling OpenCL, CUDA or other graphics 
> shader languages.

I think CUDA still does fair bit of similar logic what you describe above 
though.

> This is also why, while SYCL is technically pure standard C++, you need some 
> specific compiler magic to do the code massaging to have everything working 
> well between a host and some devices.

This patch is actually extending pure standard C++ to make it less pure. There 
is nothing magic about it.

> The attribute we discuss here is just an implementation detail to help the 
> coordination between the compiler and the SYCL frontend classes to mark some 
> area to outline, without relying to do some precise pattern matching, 
> allowing more flexibility in the runtime without changing the compiler every 
> time. So while it defines a zone to be outlined as a kernel, it is not really 
> a kernel in the sense of OpenCL.

Can you give some concrete examples of why device outlined functions can't be 
an OpenCL kernel or functions? What functionality (apart from kernel templates) 
wouldn't be applicable?

> In triSYCL I made some completely different choices, using late outlining in 
> LLVM and detecting some specific functions such as 
> `cl::sycl::detail::instantiate_kernel()` that defines some stuff 
> I want to outline 
> https://github.com/triSYCL/triSYCL/blob/master/doc/architecture.rst#low-level-view-of-the-device-compiler-workflow
>  For me an attribute was not an option because I wanted to change Clang as 
> little as possible.

Why not to continue this approach? What limitation does it have? Is it 
something that demonstrates that the language extension is the real solution to 
this?

> But at the end, I think it is quite more brittle than doing early outlining 
> in Clang as discussed here, which also requires quite more knowledge of Clang 
> than I have. :-)
> 
> So at the end, I think we should use a different keyword from OpenCL or CUDA 
> because the semantics is different.

Overall, I see that this work is now going into a very different direction from 
what was written in the original RFC.
https://lists.llvm.org/pipermail/cfe-dev/2019-January/060811.html

It was suggested that SYCL builds on top of OpenCL and therefore most of 
functionality can be reused. May be the best approach is to restart the RFC 
making the new intent and the overall conce

[PATCH] D60516: [LTO] Add plumbing to save stats during LTO on Darwin.

2019-04-19 Thread Florian Hahn via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358753: [LTO] Add plumbing to save stats during LTO on 
Darwin. (authored by fhahn, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60516?vs=194524&id=195873#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60516

Files:
  cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
  llvm/trunk/include/llvm/LTO/LTO.h
  llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h
  llvm/trunk/lib/LTO/LTO.cpp
  llvm/trunk/lib/LTO/LTOCodeGenerator.cpp

Index: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
===
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
@@ -95,6 +95,11 @@
 "lto-pass-remarks-with-hotness",
 cl::desc("With PGO, include profile count in optimization remarks"),
 cl::Hidden);
+
+cl::opt LTOStatsFile(
+"lto-stats-file",
+cl::desc("Save statistics to the specified file"),
+cl::Hidden);
 }
 
 LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context)
@@ -518,6 +523,14 @@
   }
   DiagnosticOutputFile = std::move(*DiagFileOrErr);
 
+  // Setup output file to emit statistics.
+  auto StatsFileOrErr = lto::setupStatsFile(LTOStatsFile);
+  if (!StatsFileOrErr) {
+errs() << "Error: " << toString(StatsFileOrErr.takeError()) << "\n";
+report_fatal_error("Can't get an output file for the statistics");
+  }
+  StatsFile = std::move(StatsFileOrErr.get());
+
   // We always run the verifier once on the merged module, the `DisableVerify`
   // parameter only applies to subsequent verify.
   verifyMergedModuleOnce();
@@ -584,9 +597,13 @@
   [&]() { return createTargetMachine(); }, FileType,
   ShouldRestoreGlobalsLinkage);
 
-  // If statistics were requested, print them out after codegen.
-  if (llvm::AreStatisticsEnabled())
-llvm::PrintStatistics();
+  // If statistics were requested, save them to the specified file or
+  // print them out after codegen.
+  if (StatsFile)
+PrintStatisticsJSON(StatsFile->os());
+  else if (AreStatisticsEnabled())
+PrintStatistics();
+
   reportAndResetTimings();
 
   finishOptimizationRemarks();
Index: llvm/trunk/lib/LTO/LTO.cpp
===
--- llvm/trunk/lib/LTO/LTO.cpp
+++ llvm/trunk/lib/LTO/LTO.cpp
@@ -885,16 +885,10 @@
   isPrevailing, Conf.OptLevel > 0);
 
   // Setup output file to emit statistics.
-  std::unique_ptr StatsFile = nullptr;
-  if (!Conf.StatsFile.empty()) {
-EnableStatistics(false);
-std::error_code EC;
-StatsFile =
-llvm::make_unique(Conf.StatsFile, EC, sys::fs::F_None);
-if (EC)
-  return errorCodeToError(EC);
-StatsFile->keep();
-  }
+  auto StatsFileOrErr = setupStatsFile(Conf.StatsFile);
+  if (!StatsFileOrErr)
+return StatsFileOrErr.takeError();
+  std::unique_ptr StatsFile = std::move(StatsFileOrErr.get());
 
   // Finalize linking of regular LTO modules containing summaries now that
   // we have computed liveness information.
@@ -1343,3 +1337,20 @@
   DiagnosticFile->keep();
   return std::move(DiagnosticFile);
 }
+
+Expected>
+lto::setupStatsFile(StringRef StatsFilename) {
+  // Setup output file to emit statistics.
+  if (StatsFilename.empty())
+return nullptr;
+
+  llvm::EnableStatistics(false);
+  std::error_code EC;
+  auto StatsFile =
+  llvm::make_unique(StatsFilename, EC, sys::fs::F_None);
+  if (EC)
+return errorCodeToError(EC);
+
+  StatsFile->keep();
+  return std::move(StatsFile);
+}
Index: llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h
===
--- llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h
+++ llvm/trunk/include/llvm/LTO/legacy/LTOCodeGenerator.h
@@ -241,6 +241,7 @@
   TargetMachine::CodeGenFileType FileType = TargetMachine::CGFT_ObjectFile;
   std::unique_ptr DiagnosticOutputFile;
   bool Freestanding = false;
+  std::unique_ptr StatsFile = nullptr;
 };
 }
 #endif
Index: llvm/trunk/include/llvm/LTO/LTO.h
===
--- llvm/trunk/include/llvm/LTO/LTO.h
+++ llvm/trunk/include/llvm/LTO/LTO.h
@@ -87,6 +87,10 @@
  StringRef LTORemarksPasses,
  bool LTOPassRemarksWithHotness, int Count = -1);
 
+/// Setups the output file for saving statistics.
+Expected>
+setupStatsFile(StringRef StatsFilename);
+
 class LTO;
 struct SymbolResolution;
 class ThinBackendProc;
Index: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
@@ -514,6 +514,14 @@
 }
   }
 
+  // Setup statistics file output.
+  SmallString<128> StatsFile =
+  g

[PATCH] D58573: [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Gentle ping.


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

https://reviews.llvm.org/D58573



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


r358756 - Add support of the next Ubuntu (Ubuntu 19.10 - Eoan EANIMAL)

2019-04-19 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Apr 19 06:43:28 2019
New Revision: 358756

URL: http://llvm.org/viewvc/llvm-project?rev=358756&view=rev
Log:
Add support of the next Ubuntu (Ubuntu 19.10 - Eoan EANIMAL)


Modified:
cfe/trunk/include/clang/Driver/Distro.h
cfe/trunk/lib/Driver/Distro.cpp

Modified: cfe/trunk/include/clang/Driver/Distro.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Distro.h?rev=358756&r1=358755&r2=358756&view=diff
==
--- cfe/trunk/include/clang/Driver/Distro.h (original)
+++ cfe/trunk/include/clang/Driver/Distro.h Fri Apr 19 06:43:28 2019
@@ -63,6 +63,7 @@ public:
 UbuntuBionic,
 UbuntuCosmic,
 UbuntuDisco,
+UbuntuEoan,
 UnknownDistro
   };
 
@@ -116,7 +117,7 @@ public:
   }
 
   bool IsUbuntu() const {
-return DistroVal >= UbuntuHardy && DistroVal <= UbuntuDisco;
+return DistroVal >= UbuntuHardy && DistroVal <= UbuntuEoan;
   }
 
   bool IsAlpineLinux() const {

Modified: cfe/trunk/lib/Driver/Distro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Distro.cpp?rev=358756&r1=358755&r2=358756&view=diff
==
--- cfe/trunk/lib/Driver/Distro.cpp (original)
+++ cfe/trunk/lib/Driver/Distro.cpp Fri Apr 19 06:43:28 2019
@@ -51,6 +51,7 @@ static Distro::DistroType DetectDistro(l
   .Case("bionic", Distro::UbuntuBionic)
   .Case("cosmic", Distro::UbuntuCosmic)
   .Case("disco", Distro::UbuntuDisco)
+  .Case("eoan", Distro::UbuntuEoan)
   .Default(Distro::UnknownDistro);
 if (Version != Distro::UnknownDistro)
   return Version;


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


r358757 - Add support of the future Debian (Debian 11 - Bullseye)

2019-04-19 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Apr 19 06:46:58 2019
New Revision: 358757

URL: http://llvm.org/viewvc/llvm-project?rev=358757&view=rev
Log:
Add support of the future Debian (Debian 11 - Bullseye)
https://wiki.debian.org/DebianBullseye


Modified:
cfe/trunk/include/clang/Driver/Distro.h
cfe/trunk/lib/Driver/Distro.cpp

Modified: cfe/trunk/include/clang/Driver/Distro.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Distro.h?rev=358757&r1=358756&r2=358757&view=diff
==
--- cfe/trunk/include/clang/Driver/Distro.h (original)
+++ cfe/trunk/include/clang/Driver/Distro.h Fri Apr 19 06:46:58 2019
@@ -33,6 +33,7 @@ public:
 DebianJessie,
 DebianStretch,
 DebianBuster,
+DebianBullseye,
 Exherbo,
 RHEL5,
 RHEL6,
@@ -113,7 +114,7 @@ public:
   }
 
   bool IsDebian() const {
-return DistroVal >= DebianLenny && DistroVal <= DebianBuster;
+return DistroVal >= DebianLenny && DistroVal <= DebianBullseye;
   }
 
   bool IsUbuntu() const {

Modified: cfe/trunk/lib/Driver/Distro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Distro.cpp?rev=358757&r1=358756&r2=358757&view=diff
==
--- cfe/trunk/lib/Driver/Distro.cpp (original)
+++ cfe/trunk/lib/Driver/Distro.cpp Fri Apr 19 06:46:58 2019
@@ -94,6 +94,8 @@ static Distro::DistroType DetectDistro(l
 return Distro::DebianStretch;
   case 10:
 return Distro::DebianBuster;
+  case 11:
+return Distro::DebianBullseye;
   default:
 return Distro::UnknownDistro;
   }


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


r358758 - Debian: Add two missing version code in sid

2019-04-19 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Fri Apr 19 06:48:52 2019
New Revision: 358758

URL: http://llvm.org/viewvc/llvm-project?rev=358758&view=rev
Log:
Debian: Add two missing version code in sid

Modified:
cfe/trunk/lib/Driver/Distro.cpp

Modified: cfe/trunk/lib/Driver/Distro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Distro.cpp?rev=358758&r1=358757&r2=358758&view=diff
==
--- cfe/trunk/lib/Driver/Distro.cpp (original)
+++ cfe/trunk/lib/Driver/Distro.cpp Fri Apr 19 06:48:52 2019
@@ -105,6 +105,8 @@ static Distro::DistroType DetectDistro(l
 .Case("wheezy/sid", Distro::DebianWheezy)
 .Case("jessie/sid", Distro::DebianJessie)
 .Case("stretch/sid", Distro::DebianStretch)
+.Case("buster/sid", Distro::DebianBuster)
+.Case("bullseye/sid", Distro::DebianBullseye)
 .Default(Distro::UnknownDistro);
   }
 


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


[PATCH] D60455: [SYCL] Add support for SYCL device attributes

2019-04-19 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

I tried to reuse OpenCL kernel attribute with "__kernel" keyword in our current 
SYCL implementation. PR with this try is here  - 
https://github.com/intel/llvm/pull/97
Now It looks feasible but with a couple notes:
From SYCL specification "SYCL is designed to be as close to standard C++ as 
possible. Standard C++ compiler can compile the SYCL programs and they will run 
correctly on host CPU." So SYCL doesn't provide non-standard `kernel` keyword 
which is provided by OpenCL. Due this fact it's not possible to add `kernel` 
keyword as in OpenCL, it will prevent compilation of following valid SYCL code:

  int foo(int kernel) { return ++kernel; } // If "kernel" will be a keyword 
like in OpenCL, here will be a error
  …
  using namespace cl::sycl;
  queue Q;
  buffer a(range<1>{1024});
  Q.submit([&](handler& cgh) {
auto A = a.get_access(cgh);
cgh.parallel_for(range<1>{1024}, [=](id<1> index) {
  A[index] = index[0] * 2 + index[1] + foo(42);
});
  }
  ...

So I added only `__kernel` keyword for SYCL because in C++ identifiers which 
start with `__` are reserved for compiler internals.
Next note:
In our current implementation actually not quite that function which is marked 
with `sycl_kernel` (or `__kernel`, whatever) will be real OpenCL kernel in 
produced module. In SYCL all shared between host and device memory objects 
(buffers/images, these objects map to OpenCL buffers and images) can be 
accessed through special `accessor` classes. SYCL also has special mechanism 
for passing kernel arguments from host to device, if in OpenCL you need to do 
`clSetKernelArg`, in SYCL all kernel arguments are captures/fields of 
lambda/functor which is passed to `parallel_for` (See code snippet above, here 
one kernel argument - accessor `A` ). To map to OpenCL setting kernel arguments 
mechanism we added generation of some "kernel wrapper" function inside the 
compiler. "Kernel wrapper" function contains body of SYCL kernel function, 
receives OpenCL like parameters and additionally does some manipulation to 
initialize captured lambda fields with this parameters. In some pseudo code 
"kernel wrapper" looks like this:

  // SYCL kernel is defined in SYCL headers
  __kernel someSYCLKernel(lambda) {
lambda();
  }
  // Kernel wrapper
  __kernel wrapper(global int* a) {
lambda; // Actually lambda declaration doesn't have a name in AST
// Let lambda has one captured field - accessor A. We need to init it with 
global pointer from arguments:
lambda.A.__init(a);
// Body of SYCL kernel from SYCL headers:
{
  lambda();
}
  }

And actually kernel wrapper is presented in result module and passed to OpenCL 
backend.
As I said, kernel wrapper is generated by the compiler inside the Sema and 
OpenCLKernel attribute manually added to it, no matter which attribute was 
added to "SYCL kernel" from SYCL headers.
So, while we are generating this wrapper I see only one profit to use OpenCL 
kernel attribute in SYCL kernels - don't add new attribute to clang (but we 
need to add `__kernel` keyword to SYCL).
I thought about idea - don't generate kernel wrapper but looks like it will not 
work with OpenCL since we can't pass OpenCL `cl_mem` arguments inside any 
structures (including accessors and lambdas) to the kernel.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D58573: [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Ouch, forgot to accept it. Here you go!


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

https://reviews.llvm.org/D58573



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


[PATCH] D60800: [MS] Emit S_HEAPALLOCSITE debug info

2019-04-19 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 195877.
akhuang added a comment.

whitespace fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60800

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  llvm/include/llvm/CodeGen/MachineFunction.h
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/test/CodeGen/X86/label-heapallocsite.ll

Index: llvm/test/CodeGen/X86/label-heapallocsite.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/label-heapallocsite.ll
@@ -0,0 +1,68 @@
+; RUN: llc -O0 < %s | FileCheck %s
+; FIXME: Add test for llc with optimizations once it is implemented.
+
+; Source to regenerate:
+; $ clang --target=x86_64-windows-msvc -S heapallocsite.c  -g -gcodeview -o t.ll \
+;  -emit-llvm -O0 -Xclang -disable-llvm-passes -fms-extensions
+; __declspec(allocator) char *myalloc();
+; void g();
+; void foo() {
+;   g();
+;   myalloc()
+;   g();
+; }
+
+target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-windows-msvc"
+
+; Function Attrs: noinline nounwind optnone
+define dso_local void @f() #0 !dbg !7 {
+entry:
+  call void @g(), !dbg !11
+  %call = call i8* @myalloc(), !dbg !12, !heapallocsite !13
+  call void @g(), !dbg !14
+  ret void, !dbg !15
+}
+
+; CHECK-LABEL: f: # @f
+; CHECK: callq g
+; CHECK: .Lheapallocsite0:
+; CHECK: callq myalloc
+; CHECK: .Lheapallocsite1:
+; CHECK: retq
+
+; CHECK-LABEL: .short  4423# Record kind: S_GPROC32_ID
+; CHECK:   .short  4446# Record kind: S_HEAPALLOCSITE
+; CHECK-NEXT:  .secrel32   .Lheapallocsite0
+; CHECK-NEXT:  .secidx .Lheapallocsite0
+; CHECK-NEXT:  .short  .Lheapallocsite1-.Lheapallocsite0
+; CHECK-NEXT:  .long 112
+; CHECK-NEXT:  .p2align 2
+
+; CHECK-LABEL: .short  4431# Record kind: S_PROC_ID_END
+
+declare dso_local void @g() #1
+
+declare dso_local i8* @myalloc() #1
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4eff3de99423a62fd6e833e29c71c1e62ba6140b)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "6d758cfa3834154a04ce8a55102772a9")
+!2 = !{}
+!3 = !{i32 2, !"CodeView", i32 1}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 2}
+!6 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git 4eff3de99423a62fd6e833e29c71c1e62ba6140b)"}
+!7 = distinct !DISubprogram(name: "f", scope: !8, file: !8, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!8 = !DIFile(filename: "heapallocsite.c", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "6d758cfa3834154a04ce8a55102772a9")
+!9 = !DISubroutineType(types: !10)
+!10 = !{null}
+!11 = !DILocation(line: 5, scope: !7)
+!12 = !DILocation(line: 6, scope: !7)
+!13 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
+!14 = !DILocation(line: 7, scope: !7)
+!15 = !DILocation(line: 8, scope: !7)
+
Index: llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
===
--- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1234,6 +1234,12 @@
   if (CLI.NumResultRegs && CLI.CS)
 updateValueMap(CLI.CS->getInstruction(), CLI.ResultReg, CLI.NumResultRegs);
 
+  // Set labels for heapallocsite call.
+  if (CLI.CS && CLI.CS->getInstruction()->getMetadata("heapallocsite")) {
+MDNode *MD = CLI.CS->getInstruction()->getMetadata("heapallocsite");
+MF->addCodeViewHeapAllocSite(CLI.Call, MD);
+  }
+
   return true;
 }
 
Index: llvm/lib/CodeGen/MachineFunction.cpp
===
--- llvm/lib/CodeGen/MachineFunction.cpp
+++ llvm/lib/CodeGen/MachineFunction.cpp
@@ -43,6 +43,7 @@
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalValue.h"
@@ -806,6 +807,16 @@
   return FilterID;
 }
 
+void MachineFunction::addCodeViewHeapAllocSite(MachineInstr *I, MDNode *MD) {
+  MCSymbol *BeginLabel = Ctx.createTempSymbol("heapallocsite", true);
+  MCSymbol *EndLabel = Ctx.createTempSymbol("heapallocsite", true);
+  I->setPreInstrSymbol(*this, BeginLabel);
+  I->setPostInstrSymbol(*this, EndLabel);
+
+  DIType *DI = dyn_cast(MD);
+  CodeViewHeapAllocSites.push_back({BeginLabel, EndLabel, DI});
+}
+
 /// \}
 

r358765 - Update to use PipelineTuningOptions. Corresponds to llvm change: D59723.

2019-04-19 Thread Alina Sbirlea via cfe-commits
Author: asbirlea
Date: Fri Apr 19 09:32:08 2019
New Revision: 358765

URL: http://llvm.org/viewvc/llvm-project?rev=358765&view=rev
Log:
Update to use PipelineTuningOptions. Corresponds to llvm change: D59723.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=358765&r1=358764&r2=358765&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Apr 19 09:32:08 2019
@@ -1011,7 +1011,7 @@ void EmitAssemblyHelper::EmitAssemblyWit
   CodeGenOpts.DebugInfoForProfiling);
   }
 
-  PassBuilder PB(TM.get(), PGOOpt);
+  PassBuilder PB(TM.get(), PipelineTuningOptions(), PGOOpt);
 
   // Attempt to load pass plugins and register their callbacks with PB.
   for (auto &PluginFN : CodeGenOpts.PassPlugins) {


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


r358766 - [OPENMP][NVPTX] target [teams distribute] simd maybe run without

2019-04-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Apr 19 09:48:38 2019
New Revision: 358766

URL: http://llvm.org/viewvc/llvm-project?rev=358766&view=rev
Log:
[OPENMP][NVPTX] target [teams distribute] simd maybe run without
runtime.

target [teams distribute] simd costructs do not require full runtime for
the correct execution, we can run them without full runtime.

Modified:
cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_simd_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=358766&r1=358765&r2=358766&view=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Fri Apr 19 09:48:38 2019
@@ -907,6 +907,8 @@ static bool hasNestedLightweightDirectiv
   isOpenMPWorksharingDirective(DKind) && isOpenMPLoopDirective(DKind) 
&&
   hasStaticScheduling(*NestedDir))
 return true;
+  if (DKind == OMPD_teams_distribute_simd || DKind == OMPD_simd)
+return true;
   if (DKind == OMPD_parallel) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers(
 /*IgnoreCaptured=*/true);
@@ -955,6 +957,8 @@ static bool hasNestedLightweightDirectiv
   isOpenMPWorksharingDirective(DKind) && isOpenMPLoopDirective(DKind) 
&&
   hasStaticScheduling(*NestedDir))
 return true;
+  if (DKind == OMPD_distribute_simd || DKind == OMPD_simd)
+return true;
   if (DKind == OMPD_parallel) {
 Body = NestedDir->getInnermostCapturedStmt()->IgnoreContainers(
 /*IgnoreCaptured=*/true);
@@ -971,6 +975,8 @@ static bool hasNestedLightweightDirectiv
   }
   return false;
 case OMPD_target_parallel:
+  if (DKind == OMPD_simd)
+return true;
   return isOpenMPWorksharingDirective(DKind) &&
  isOpenMPLoopDirective(DKind) && hasStaticScheduling(*NestedDir);
 case OMPD_target_teams_distribute:
@@ -1052,8 +1058,9 @@ static bool supportsLightweightRuntime(A
 // (Last|First)-privates must be shared in parallel region.
 return hasStaticScheduling(D);
   case OMPD_target_simd:
-  case OMPD_target_teams_distribute:
   case OMPD_target_teams_distribute_simd:
+return true;
+  case OMPD_target_teams_distribute:
 return false;
   case OMPD_parallel:
   case OMPD_for:

Modified: cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp?rev=358766&r1=358765&r2=358766&view=diff
==
--- cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_simd_codegen.cpp Fri Apr 19 09:48:38 2019
@@ -54,33 +54,33 @@ int bar(int n){
 }
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l25}}(
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 1, i16 0)
+// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0, i16 0)
 // CHECK-NOT: call void @__kmpc_for_static_init
 // CHECK-NOT: call void @__kmpc_for_static_fini
-// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l30}}(
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 1, i16 0)
+// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0, i16 0)
 // CHECK-NOT: call void @__kmpc_for_static_init
 // CHECK-NOT: call void @__kmpc_for_static_fini
-// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l35}}(
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 1, i16 0)
+// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0, i16 0)
 // CHECK-NOT: call void @__kmpc_for_static_init
 // CHECK-NOT: call void @__kmpc_for_static_fini
-// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}void {{@__omp_offloading_.+l40}}(
-// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 1, i16 0)
+// CHECK: call void @__kmpc_spmd_kernel_init(i32 %{{.+}}, i16 0, i16 0)
 // CHECK-NOT: call void @__kmpc_for_static_init
 // CHECK-NOT: call void @__kmpc_for_static_fini
 // CHECK-NOT: call i32 @__kmpc_nvptx_simd_reduce_nowait(
 // CHECK-NOT: call void @__kmpc_nvptx_end_reduce_nowait(
-// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 1)
+// CHECK: call void @__kmpc_spmd_kernel_deinit_v2(i16 0)
 // CHECK: ret void
 
 

Modified: cfe/trunk/test/OpenMP/nvptx_target_teams_distribu

[PATCH] D60848: [Parser] Avoid correcting delayed typos in array subscript multiple times.

2019-04-19 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Wait, why is NumTypos incorrect here? I think its because we don't handle the 
typo on the line: `[self undeclaredMethod:undeclaredArg];`, even the following 
asserts now. Seems like the right fix would be to track down why we aren't 
handling the typo in the message expr.

  // RUN: clang -cc1 %s -fobjc-arc
  @implementation X
  -x { [self undeclaredMethod:undeclaredArg]; }
  @end


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

https://reviews.llvm.org/D60848



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


[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This is, obviously, an ABI break. I think Sony would probably want you to 
preserve the existing behavior of intentionally underaligning such byval 
parameters for PS4 targets. +@rjmccall in case he has other ABI thoughts.




Comment at: lib/CodeGen/TargetInfo.cpp:1496
+  if (IsDarwinVectorABI) {
+// On Darwin, if the type contains an SSE vector type, the alignment is 16.
+if (Align >= 16 && (isSSEVectorType(getContext(), Ty) ||

@rjmccall, does this comment need updating in an AVX world?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60748



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


[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-04-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a subscriber: dexonsmith.
rjmccall added a comment.

I suspect Darwin also doesn't want to take this.  We care very little about 
32-bit Intel, and part of caring very little is not wanting to spend any effort 
dealing with the ramifications of ABI breaks.  That would apply both to the 
rule in general and to the vector rule specifically.  @dexonsmith, agreed?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60748



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


[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

2019-04-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: ABataev, hfinkel, caomhin.
Herald added subscribers: cfe-commits, jdoerfert, guansong, mgorny.
Herald added a project: clang.
gtbercea added a reviewer: tra.
gtbercea added parent revisions: D60906: [OpenMP][libomptarget][WIP] Add math 
functions support in OpenMP offloading, D60905: [OpenMP][LLVM][WIP] Add math 
functions support to OpenMP.
gtbercea edited the summary of this revision.

This patch adds an OpenMP specific math functions header to the lib/Headers 
folder and ensures it is passed to Clang.

Note:
This is an example of how support for math functions could be implemented. 
Before expanding this to include other math functions please let me know if you 
have any comments, concerns or proposed changes.


Repository:
  rC Clang

https://reviews.llvm.org/D60907

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_openmp_math.h

Index: lib/Headers/__clang_openmp_math.h
===
--- /dev/null
+++ lib/Headers/__clang_openmp_math.h
@@ -0,0 +1,33 @@
+
+#ifndef __CLANG_OMP_CMATH_H__
+#define __CLANG_OMP_CMATH_H__
+
+#ifdef __NVPTX__
+#pragma omp declare target
+
+// Declarations of function in libomptarget
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+double __kmpc_pow(double, double);
+double __kmpc_sin(double);
+
+#if defined(__cplusplus)
+}
+#endif
+
+// Define existing function to call kmpc functions.
+__attribute__((always_inline, used)) static double pow(double a, double b) {
+  return __kmpc_pow(a, b);
+}
+
+__attribute__((always_inline, used)) static double sin(double a) {
+  return __kmpc_sin(a);
+}
+
+#pragma omp end declare target
+#endif
+
+#endif
+
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -31,6 +31,7 @@
   avxintrin.h
   bmi2intrin.h
   bmiintrin.h
+  __clang_openmp_math.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_cmath.h
   __clang_cuda_complex_builtins.h
Index: lib/Driver/ToolChains/Cuda.h
===
--- lib/Driver/ToolChains/Cuda.h
+++ lib/Driver/ToolChains/Cuda.h
@@ -48,6 +48,9 @@
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const;
 
+  void AddMathDeviceFunctions(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const;
+
   /// Emit an error if Version does not support the given Arch.
   ///
   /// If either Version or Arch is unknown, does not emit an error.  Emits at
@@ -165,6 +168,9 @@
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
+  void AddMathDeviceFunctions(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
   void
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -255,6 +255,16 @@
   CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
 }
 
+void CudaInstallationDetector::AddMathDeviceFunctions(
+const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+  CC1Args.push_back("-internal-isystem");
+  CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath()));
+  CC1Args.push_back("-include");
+  CC1Args.push_back("__clang_openmp_math.h");
+  CC1Args.push_back("-I");
+  CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath()));
+}
+
 void CudaInstallationDetector::CheckCudaVersionSupportsArch(
 CudaArch Arch) const {
   if (Arch == CudaArch::UNKNOWN || Version == CudaVersion::UNKNOWN ||
@@ -898,6 +908,11 @@
   CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
 }
 
+void CudaToolChain::AddMathDeviceFunctions(
+const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+  CudaInstallation.AddMathDeviceFunctions(DriverArgs, CC1Args);
+}
+
 llvm::opt::DerivedArgList *
 CudaToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
  StringRef BoundArch,
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -1150,6 +1150,14 @@
   if (JA.isOffloading(Action::OFK_Cuda))
 getToolChain().AddCudaIncludeArgs(Args, CmdArgs);
 
+  // If we are offloading to a target via OpenMP and this target happens
+  // to be an NVIDIA GPU then we need to include the CUDA runtime wrapper
+ 

[PATCH] D60748: Fix i386 struct and union parameter alignment

2019-04-19 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D60748#1472829 , @rjmccall wrote:

> I suspect Darwin also doesn't want to take this.  We care very little about 
> 32-bit Intel, and part of caring very little is not wanting to spend any 
> effort dealing with the ramifications of ABI breaks.  That would apply both 
> to the rule in general and to the vector rule specifically.  @dexonsmith, 
> agreed?


Agreed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60748



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


[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

2019-04-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Headers/__clang_openmp_math.h:14
+double __kmpc_pow(double, double);
+double __kmpc_sin(double);
+

Also, versions for float and long double



Comment at: lib/Headers/__clang_openmp_math.h:21
+// Define existing function to call kmpc functions.
+__attribute__((always_inline, used)) static double pow(double a, double b) {
+  return __kmpc_pow(a, b);

Add `powf(float)`, `powl(long double)`, `sinf(float)`, `sinl(long double)`


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907



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


[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

2019-04-19 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/Headers/__clang_openmp_math.h:2
+
+#ifndef __CLANG_OMP_CMATH_H__
+#define __CLANG_OMP_CMATH_H__

Why `__CLANG_OMP_CMATH_H__`? Your file is `..._math.h`, not `..._cmath.h`. 
Plus, seems to me, you're missing standard header for the file.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907



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


[PATCH] D60094: [MSVC] If unable to find link.exe from a MSVC installation, look for link.exe next to cl.exe

2019-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D60094



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


r358775 - Enable frame pointer elimination for OpenBSD on powerpc.

2019-04-19 Thread Brad Smith via cfe-commits
Author: brad
Date: Fri Apr 19 11:41:40 2019
New Revision: 358775

URL: http://llvm.org/viewvc/llvm-project?rev=358775&view=rev
Log:
Enable frame pointer elimination for OpenBSD on powerpc.

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/frame-pointer-elim.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=358775&r1=358774&r2=358775&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Apr 19 11:41:40 2019
@@ -538,6 +538,7 @@ static bool useFramePointerForTargetByDe
 switch (Triple.getArch()) {
 case llvm::Triple::mips64:
 case llvm::Triple::mips64el:
+case llvm::Triple::ppc:
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:
   return !areOptimizationsEnabled(Args);

Modified: cfe/trunk/test/Driver/frame-pointer-elim.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/frame-pointer-elim.c?rev=358775&r1=358774&r2=358775&view=diff
==
--- cfe/trunk/test/Driver/frame-pointer-elim.c (original)
+++ cfe/trunk/test/Driver/frame-pointer-elim.c Fri Apr 19 11:41:40 2019
@@ -29,10 +29,14 @@
 // OpenBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-openbsd -S -O1 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OPENBSD-OPT %s
+// RUN: %clang -### -target powerpc-unknown-openbsd -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OPENBSD-OPT %s
 // OPENBSD-OPT: "-momit-leaf-frame-pointer"
 
 // RUN: %clang -### -target x86_64-unknown-openbsd -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=OPENBSD %s
+// RUN: %clang -### -target powerpc-unknown-openbsd -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=OPENBSD %s
 // OPENBSD-NOT: "-momit-leaf-frame-pointer"
 
 // Darwin disables omitting the leaf frame pointer even under optimization


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


[PATCH] D60910: [WIP] Dumping the AST to JSON

2019-04-19 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, riccibruno, steveire, dblaikie.
Herald added a subscriber: mgorny.

This is a work in progress patch that adds the ability to specify an AST dump 
format on the command line. By default, we continue to dump the AST with its 
usual tree view, but users can now optionally pass `-ast-dump=json` to dump to 
a machine-readable JSON format that makes it easier for third parties to 
consume the Clang AST in some fashion.

The patch can currently handle dumping a fair amount of declaration 
information, some statements, and very few expressions. I got it to the point 
where it was showing useful output in roughly the correct format, but I wanted 
to get community feedback for continuing the implementation. Once the current 
approach gains consensus, my plan is to commit the WIP and then do subsequent 
commits with post-commit review to finish the implementation (unless the 
changes are somehow interesting enough to warrant pre-commit review, of course).

The hybrid approach of using some LLVM JSON functionality and some streaming 
functionality is purposeful for performance reasons (collecting the entire AST 
into memory in a second form means ~2x the memory usage for the AST, which can 
be prohibitive for large compilation units). Testing this functionality with 
FileCheck is quite verbose, so if someone has suggestions for a better way to 
test the JSON output, I'd be happy to consider it.


https://reviews.llvm.org/D60910

Files:
  include/clang/AST/ASTDumperUtils.h
  include/clang/AST/DeclBase.h
  include/clang/AST/JSONNodeDumper.h
  include/clang/Driver/CC1Options.td
  include/clang/Frontend/ASTConsumers.h
  include/clang/Frontend/FrontendOptions.h
  lib/AST/ASTDumper.cpp
  lib/AST/CMakeLists.txt
  lib/AST/JSONNodeDumper.cpp
  lib/Frontend/ASTConsumers.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  test/AST/ast-dump-enum-json.cpp
  test/AST/ast-dump-if-json.cpp
  tools/clang-check/ClangCheck.cpp
  tools/clang-import-test/clang-import-test.cpp

Index: tools/clang-import-test/clang-import-test.cpp
===
--- tools/clang-import-test/clang-import-test.cpp
+++ tools/clang-import-test/clang-import-test.cpp
@@ -316,8 +316,9 @@
   auto &CG = *static_cast(ASTConsumers.back().get());
 
   if (ShouldDumpAST)
-ASTConsumers.push_back(CreateASTDumper(nullptr /*Dump to stdout.*/,
-   "", true, false, false));
+ASTConsumers.push_back(
+CreateASTDumper(nullptr /*Dump to stdout.*/, "", true, false, false,
+clang::FrontendOptions::AOF_Default));
 
   CI.getDiagnosticClient().BeginSourceFile(
   CI.getCompilerInstance().getLangOpts(),
Index: tools/clang-check/ClangCheck.cpp
===
--- tools/clang-check/ClangCheck.cpp
+++ tools/clang-check/ClangCheck.cpp
@@ -134,11 +134,11 @@
 if (ASTList)
   return clang::CreateASTDeclNodeLister();
 if (ASTDump)
-  return clang::CreateASTDumper(nullptr /*Dump to stdout.*/,
-ASTDumpFilter,
+  return clang::CreateASTDumper(nullptr /*Dump to stdout.*/, ASTDumpFilter,
 /*DumpDecls=*/true,
 /*Deserialize=*/false,
-/*DumpLookups=*/false);
+/*DumpLookups=*/false,
+clang::FrontendOptions::AOF_Default);
 if (ASTPrint)
   return clang::CreateASTPrinter(nullptr, ASTDumpFilter);
 return llvm::make_unique();
Index: test/AST/ast-dump-if-json.cpp
===
--- test/AST/ast-dump-if-json.cpp
+++ test/AST/ast-dump-if-json.cpp
@@ -0,0 +1,360 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux -std=c++17 -ast-dump=json %s | FileCheck %s
+
+void func(int val) {
+  if (val)
+;
+
+// CHECK: "kind": "IfStmt",
+// CHECK-NEXT: "range": {"begin":{"col":3,"file":"{{.*}}","line":4},"end":{"col":5,"file":"{{.*}}","line":5}},
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "ImplicitCastExpr",
+// CHECK-NEXT: "range": {"begin":{"col":7,"file":"{{.*}}","line":4},"end":{"col":7,"file":"{{.*}}","line":4}},
+// CHECK-NEXT: "type": {"qualType":"bool"},
+// CHECK-NEXT: "valueCategory": "rvalue",
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "ImplicitCastExpr",
+// CHECK-NEXT: "range": {"begin":{"col":7,"file":"{{.*}}","line":4},"end":{"col":7,"file":"{{.*}}","line":4}},
+// CHECK-NEXT: "type": {"qualType":"int"},
+// CHECK-NEXT: "valueCategory": "rvalue",
+// CHECK-NEXT: "inner": [
+// CHECK-NEXT: {
+// CHECK-NEXT: "id": "0x{{.*}}",
+// CHECK-NEXT: "kind": "DeclRefExpr",
+// CHECK-NEXT: "range": {"begin":{"col":7,"f

[PATCH] D60912: MS ABI: handle inline static data member as template static data member

2019-04-19 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 created this revision.
jyu2 added reviewers: rnk, majnemer, erichkeane, cfe-commits.
Herald added a project: clang.

MS only run time problem with inline static data member.
A inline static data member’s init function gets called multiple time.

To fix this, using template static data members initialization method instead.  
So that inline static data member initialize function can be put into COMDAT 
group with global being initialized.  And also put static data member in the 
linker directive.  So that the function can be called before main, even the 
that variable is not been referenced.

The bug is report in:
https://bugs.llvm.org/show_bug.cgi?id=37903


Repository:
  rC Clang

https://reviews.llvm.org/D60912

Files:
  lib/CodeGen/CGDeclCXX.cpp
  test/CodeGenCXX/microsoft-abi-template-static-init.cpp

Index: test/CodeGenCXX/microsoft-abi-template-static-init.cpp
===
--- /dev/null
+++ test/CodeGenCXX/microsoft-abi-template-static-init.cpp
@@ -0,0 +1,86 @@
+// RUN: %clang_cc1 %s -triple=i686-pc-win32 -fms-extensions -std=c++17 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-win32 -fms-extensions -std=c++17 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=i686-pc-windows-msvc -fms-extensions -std=c++17 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=x86_64-pc-windows-msvc -std=c++17 -fms-extensions -emit-llvm -o - | FileCheck %s
+
+struct S {
+  S();
+  ~S();
+};
+
+template  struct __declspec(dllexport) ExportedTemplate {
+  static S s;
+};
+template  S ExportedTemplate::s;
+void useExportedTemplate(ExportedTemplate x) {
+  (void)x.s;
+}
+int f();
+namespace selectany_init {
+// MS don't put selectany static var in the linker directive, init routine
+// f() is not getting called if x is not referenced.
+int __declspec(selectany) x = f();
+}
+
+namespace explicit_template_instantiation {
+template  struct A { static  int x; };
+template  int A::x = f();
+template struct A;
+}
+
+namespace implicit_template_instantiation {
+template  struct A { static  int x; };
+template   int A::x = f();
+int g() { return A::x; }
+}
+
+
+template 
+struct X_ {
+  static T ioo;
+  static T init();
+};
+template  T X_::ioo = X_::init();
+template struct X_;
+
+template 
+struct X {
+  static T ioo;
+  static T init();
+};
+// template specialized static data don't need in llvm.used,
+// the static init routine get call from _GLOBAL__sub_I_ routines.
+template <> int X::ioo = X::init();
+template struct X;
+class a {
+public:
+  a();
+};
+// For the static var inside unnamed namespace, the object is local to TU.
+// No need to put static var in the linker directive.
+// The static init routine is called before main.
+namespace {
+template  class aj {
+public:
+  static a al;
+};
+template  a aj::al;
+class b : aj<3> {
+  void c();
+};
+void b::c() { al; }
+}
+
+// C++17, inline static data member also need to use
+struct A
+{
+  A();
+  ~A();
+};
+
+struct S1
+{
+  inline static A aoo; // C++17 inline variable, thus also a definition
+};
+
+// CHECK: @llvm.used = appending global [5 x i8*] [i8* bitcast (i32* @"?x@?$A@H@explicit_template_instantiation@@2HA" to i8*), i8* bitcast (i32* @"?ioo@?$X_@H@@2HA" to i8*), i8* getelementptr inbounds (%struct.A, %struct.A* @"?aoo@S1@@2UA@@A", i32 0, i32 0), i8* getelementptr inbounds (%struct.S, %struct.S* @"?s@?$ExportedTemplate@H@@2US@@A", i32 0, i32 0), i8* bitcast (i32* @"?x@?$A@H@implicit_template_instantiation@@2HA" to i8*)], section "llvm.metadata"
Index: lib/CodeGen/CGDeclCXX.cpp
===
--- lib/CodeGen/CGDeclCXX.cpp
+++ lib/CodeGen/CGDeclCXX.cpp
@@ -467,7 +467,10 @@
   } else if (auto *IPA = D->getAttr()) {
 OrderGlobalInits Key(IPA->getPriority(), PrioritizedCXXGlobalInits.size());
 PrioritizedCXXGlobalInits.push_back(std::make_pair(Key, Fn));
-  } else if (isTemplateInstantiation(D->getTemplateSpecializationKind())) {
+  } else if (isTemplateInstantiation(D->getTemplateSpecializationKind()) ||
+ (getTarget().getCXXABI().isMicrosoft() &&
+  D->isInlineSpecified() && D->isStaticDataMember() &&
+  getLangOpts().CPlusPlus17)) {
 // C++ [basic.start.init]p2:
 //   Definitions of explicitly specialized class template static data
 //   members have ordered initialization. Other class template static data
@@ -481,6 +484,11 @@
 // minor startup time optimization.  In the MS C++ ABI, there are no guard
 // variables, so this COMDAT key is required for correctness.
 AddGlobalCtor(Fn, 65535, COMDATKey);
+if (getTarget().getCXXABI().isMicrosoft() && COMDATKey) {
+  // In The MS C++, MS add template static data member in the linker
+  // drective.
+  addUsedGlobal(COMDATKey);
+}
   } else if (D->hasAttr()) {
 // SelectAny globals will be comdat-folded. Put the initializer into a
 // COMDAT group associated with the glo

r358778 - [MSVC] If unable to find link.exe from a MSVC installation, look for link.exe next to cl.exe

2019-04-19 Thread Martin Storsjo via cfe-commits
Author: mstorsjo
Date: Fri Apr 19 12:04:22 2019
New Revision: 358778

URL: http://llvm.org/viewvc/llvm-project?rev=358778&view=rev
Log:
[MSVC] If unable to find link.exe from a MSVC installation, look for link.exe 
next to cl.exe

Previously, if the MSVC installation isn't detected properly, clang
will later just fail to execute link.exe.

This improves using clang in msvc mode on linux, where one intentionally
might not want to point clang to the MSVC installation itself (which
isn't executable as such), but where a link.exe named wine wrapper is
available in the path next to a cl.exe named wine wrapper.

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

Modified:
cfe/trunk/lib/Driver/ToolChains/MSVC.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/MSVC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MSVC.cpp?rev=358778&r1=358777&r2=358778&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/MSVC.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/MSVC.cpp Fri Apr 19 12:04:22 2019
@@ -488,8 +488,18 @@ void visualstudio::Linker::ConstructJob(
 // their own link.exe which may come first.
 linkPath = FindVisualStudioExecutable(TC, "link.exe");
 
-if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath))
-  C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) {
+  llvm::SmallString<128> ClPath;
+  ClPath = TC.GetProgramPath("cl.exe");
+  if (llvm::sys::fs::can_execute(ClPath)) {
+linkPath = llvm::sys::path::parent_path(ClPath);
+llvm::sys::path::append(linkPath, "link.exe");
+if (!llvm::sys::fs::can_execute(linkPath))
+  C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  } else {
+C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  }
+}
 
 #ifdef _WIN32
 // When cross-compiling with VS2017 or newer, link.exe expects to have


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


[PATCH] D60094: [MSVC] If unable to find link.exe from a MSVC installation, look for link.exe next to cl.exe

2019-04-19 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358778: [MSVC] If unable to find link.exe from a MSVC 
installation, look for link.exe… (authored by mstorsjo, committed by ).

Repository:
  rC Clang

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

https://reviews.llvm.org/D60094

Files:
  lib/Driver/ToolChains/MSVC.cpp


Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -488,8 +488,18 @@
 // their own link.exe which may come first.
 linkPath = FindVisualStudioExecutable(TC, "link.exe");
 
-if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath))
-  C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) {
+  llvm::SmallString<128> ClPath;
+  ClPath = TC.GetProgramPath("cl.exe");
+  if (llvm::sys::fs::can_execute(ClPath)) {
+linkPath = llvm::sys::path::parent_path(ClPath);
+llvm::sys::path::append(linkPath, "link.exe");
+if (!llvm::sys::fs::can_execute(linkPath))
+  C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  } else {
+C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  }
+}
 
 #ifdef _WIN32
 // When cross-compiling with VS2017 or newer, link.exe expects to have


Index: lib/Driver/ToolChains/MSVC.cpp
===
--- lib/Driver/ToolChains/MSVC.cpp
+++ lib/Driver/ToolChains/MSVC.cpp
@@ -488,8 +488,18 @@
 // their own link.exe which may come first.
 linkPath = FindVisualStudioExecutable(TC, "link.exe");
 
-if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath))
-  C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+if (!TC.FoundMSVCInstall() && !llvm::sys::fs::can_execute(linkPath)) {
+  llvm::SmallString<128> ClPath;
+  ClPath = TC.GetProgramPath("cl.exe");
+  if (llvm::sys::fs::can_execute(ClPath)) {
+linkPath = llvm::sys::path::parent_path(ClPath);
+llvm::sys::path::append(linkPath, "link.exe");
+if (!llvm::sys::fs::can_execute(linkPath))
+  C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  } else {
+C.getDriver().Diag(clang::diag::warn_drv_msvc_not_found);
+  }
+}
 
 #ifdef _WIN32
 // When cross-compiling with VS2017 or newer, link.exe expects to have
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60912: MS ABI: handle inline static data member as template static data member

2019-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks, I think there's another case to handle, though.




Comment at: lib/CodeGen/CGDeclCXX.cpp:471-473
+ (getTarget().getCXXABI().isMicrosoft() &&
+  D->isInlineSpecified() && D->isStaticDataMember() &&
+  getLangOpts().CPlusPlus17)) {

I think the whole second condition can be simplified to just 
`D->isIinlineSpecified()`. We have to consider plain inline global variables, 
not just static data members, as in:
```
int f();
inline int gvinit_inline = f();
int useit() { return gvinit_inline ; }
```


Repository:
  rC Clang

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

https://reviews.llvm.org/D60912



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


[PATCH] D60912: MS ABI: handle inline static data member as template static data member

2019-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D60912#1472986 , @jyu2 wrote:

> inline static int aoo = foo(); // C++17 inline variable, thus also a 
> definition


This is a `static inline` global variable, so it technically creates two 
different globals, so calling foo twice is intended behavior. I think we really 
want to look at the GVA linkage instead of trying to list all the reasons why 
something might have weak linkage. Take a look at `shouldBeInCOMDAT` in 
CodeGenModule.cpp, I think it has the logic we want.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60912



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


[PATCH] D60912: MS ABI: handle inline static data member as template static data member

2019-04-19 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D60912#1472983 , @rnk wrote:

> Thanks, I think there's another case to handle, though.


Hi Reid,
Thank you so much for the review.

Yes, I check the following test case, both gnu and cl call foo twice.  Do we 
want to do differently with that?  Thanks.  Jennifer
I add MS only, since we are generate same with gnu.  Sure remove that should 
work at run time.  But I am not sure if we have abi issues when mix-match 
object.  I will look more about that.Thanks.

bug-37903>g++ x.cpp x1.cpp -std=c++17
bug-37903>./a.out
foo
foo

bug-37903>cat x.h
extern "C" int printf(const char*,...);
int foo();
inline static int aoo = foo(); // C++17 inline variable, thus also a definition
bug-37903>cat x.cpp
#include "x.h"
int foo()
{

  printf("foo\n");
  return 1;

}
int main()
{
}
bug-37903>cat x1.cpp
#include "x.h"


Repository:
  rC Clang

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

https://reviews.llvm.org/D60912



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


r358781 - Reapply "[analyzer] Introduce a simplified API for adding custom path notes."

2019-04-19 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Apr 19 13:23:29 2019
New Revision: 358781

URL: http://llvm.org/viewvc/llvm-project?rev=358781&view=rev
Log:
Reapply "[analyzer] Introduce a simplified API for adding custom path notes."

This reapplies commit r357323, fixing memory leak found by LSan.

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

Modified:
cfe/trunk/include/clang/Analysis/ProgramPoint.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/mig.mm

Modified: cfe/trunk/include/clang/Analysis/ProgramPoint.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ProgramPoint.h?rev=358781&r1=358780&r2=358781&view=diff
==
--- cfe/trunk/include/clang/Analysis/ProgramPoint.h (original)
+++ cfe/trunk/include/clang/Analysis/ProgramPoint.h Fri Apr 19 13:23:29 2019
@@ -42,12 +42,11 @@ public:
   virtual ~ProgramPointTag();
   virtual StringRef getTagDescription() const = 0;
 
-protected:
   /// Used to implement 'isKind' in subclasses.
-  const void *getTagKind() { return TagKind; }
+  const void *getTagKind() const { return TagKind; }
 
 private:
-  const void *TagKind;
+  const void *const TagKind;
 };
 
 class SimpleProgramPointTag : public ProgramPointTag {

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=358781&r1=358780&r2=358781&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Fri 
Apr 19 13:23:29 2019
@@ -592,6 +592,59 @@ public:
   NodeMapClosure& getNodeResolver() { return NMC; }
 };
 
+
+/// The tag upon which the TagVisitor reacts. Add these in order to display
+/// additional PathDiagnosticEventPieces along the path.
+class NoteTag : public ProgramPointTag {
+public:
+  using Callback =
+  std::function;
+
+private:
+  static int Kind;
+
+  const Callback Cb;
+
+  NoteTag(Callback &&Cb) : ProgramPointTag(&Kind), Cb(std::move(Cb)) {}
+
+public:
+  static bool classof(const ProgramPointTag *T) {
+return T->getTagKind() == &Kind;
+  }
+
+  Optional generateMessage(BugReporterContext &BRC,
+BugReport &R) const {
+std::string Msg = Cb(BRC, R);
+if (Msg.empty())
+  return None;
+
+return std::move(Msg);
+  }
+
+  StringRef getTagDescription() const override {
+// TODO: Remember a few examples of generated messages
+// and display them in the ExplodedGraph dump by
+// returning them from this function.
+return "Note Tag";
+  }
+
+  // Manage memory for NoteTag objects.
+  class Factory {
+std::vector> Tags;
+
+  public:
+const NoteTag *makeNoteTag(Callback &&Cb) {
+  // We cannot use make_unique because we cannot access the private
+  // constructor from inside it.
+  std::unique_ptr T(new NoteTag(std::move(Cb)));
+  Tags.push_back(std::move(T));
+  return Tags.back().get();
+}
+  };
+
+  friend class TagVisitor;
+};
+
 } // namespace ento
 
 } // namespace clang

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h?rev=358781&r1=358780&r2=358781&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h 
Fri Apr 19 13:23:29 2019
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H
 #define LLVM_CLANG_STATICANALYZER_CORE_BUGREPORTER_BUGREPORTERVISITORS_H
 
+#include "clang/Analysis/ProgramPoint.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
@@ -328,6 +329,17 @@ public:
BugReport &BR) override;
 };
 
+
+/// The visitor detects NoteTags and displays the event notes they contain.
+class TagVisitor : public BugReporterVisitor {
+public:
+  void Profile(llvm::FoldingSetNodeID &ID) const override;
+
+  std::shared_ptr Vi

[PATCH] D58367: [analyzer] NFC: Improve upon the concept of BugReporterVisitor.

2019-04-19 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358781: Reapply "[analyzer] Introduce a simplified API 
for adding custom path notes." (authored by dergachev, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D58367?vs=195835&id=195901#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D58367

Files:
  cfe/trunk/include/clang/Analysis/ProgramPoint.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
  cfe/trunk/test/Analysis/mig.mm

Index: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -201,7 +201,9 @@
   svalBuilder(StateMgr.getSValBuilder()),
   ObjCNoRet(mgr.getASTContext()),
   BR(mgr, *this),
-  VisitedCallees(VisitedCalleesIn), HowToInline(HowToInlineIn) {
+  VisitedCallees(VisitedCalleesIn),
+  HowToInline(HowToInlineIn)
+  {
   unsigned TrimInterval = mgr.options.GraphTrimInterval;
   if (TrimInterval != 0) {
 // Enable eager node reclamation when constructing the ExplodedGraph.
Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -2499,6 +2499,30 @@
   return nullptr;
 }
 
+int NoteTag::Kind = 0;
+
+void TagVisitor::Profile(llvm::FoldingSetNodeID &ID) const {
+  static int Tag = 0;
+  ID.AddPointer(&Tag);
+}
+
+std::shared_ptr
+TagVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
+  BugReport &R) {
+  ProgramPoint PP = N->getLocation();
+  const NoteTag *T = dyn_cast_or_null(PP.getTag());
+  if (!T)
+return nullptr;
+
+  if (Optional Msg = T->generateMessage(BRC, R)) {
+PathDiagnosticLocation Loc =
+PathDiagnosticLocation::create(PP, BRC.getSourceManager());
+return std::make_shared(Loc, *Msg);
+  }
+
+  return nullptr;
+}
+
 void FalsePositiveRefutationBRVisitor::Profile(
 llvm::FoldingSetNodeID &ID) const {
   static int Tag = 0;
Index: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2611,6 +2611,7 @@
 R->addVisitor(llvm::make_unique());
 R->addVisitor(llvm::make_unique());
 R->addVisitor(llvm::make_unique());
+R->addVisitor(llvm::make_unique());
 
 BugReporterContext BRC(Reporter, ErrorGraph.BackMap);
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -102,43 +102,10 @@
 checkReturnAux(RS, C);
   }
 
-  class Visitor : public BugReporterVisitor {
-  public:
-void Profile(llvm::FoldingSetNodeID &ID) const {
-  static int X = 0;
-  ID.AddPointer(&X);
-}
-
-std::shared_ptr VisitNode(const ExplodedNode *N,
-BugReporterContext &BRC, BugReport &R);
-  };
 };
 } // end anonymous namespace
 
-// FIXME: It's a 'const ParmVarDecl *' but there's no ready-made GDM traits
-// specialization for this sort of types.
-REGISTER_TRAIT_WITH_PROGRAMSTATE(ReleasedParameter, const void *)
-
-std::shared_ptr
-MIGChecker::Visitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
-   BugReport &R) {
-  const auto *NewPVD = static_cast(
-  N->getState()->get());
-  const auto *OldPVD = static_cast(
-  N->getFirstPred()->getState()->get());
-  if (OldPVD == NewPVD)
-return nullptr;
-
-  assert(NewPVD && "What is deallocated cannot be un-deallocated!");
-  SmallString<64> Str;
-  llvm::raw_svector_ostream OS(Str);
-  OS << "Value passed through parameter '" << NewPVD->getName()
- << "' is deallocated";
-
-  PathDiagnosticLocation Loc =
-  PathDiagnosticLocation::create(N->getLocation(), BRC.getSourceManager());
-  return std::make_shared(Loc, OS.str());
-}
+REGISTER_TRAIT_WITH_PROGRAMSTATE(ReleasedParameter, bool)
 
 static const ParmVarDecl *getOriginParam(SVal V, CheckerContext &C) {
   SymbolRef Sym = V.getAsSymbol()

[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

2019-04-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: include/clang/Driver/ToolChain.h:575
 
+  /// Add arguments to use system-specific CUDA includes.
+  virtual void AddMathDeviceFunctions(const llvm::opt::ArgList &DriverArgs,

Copy & Past comment



Comment at: lib/Headers/__clang_openmp_math.h:5
+
+#ifdef __NVPTX__
+#pragma omp declare target

Why is this NVPTX specific?


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907



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


[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

2019-04-19 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

To follow up on my comment why this is NVPTX specific:

Is there a reason why this has to happen in the Cuda ToolChain part?
I would have assumed us to add the declarations similar to the ones provided in 
`__clang_openmp_math.h` whenever we may compile for a target.
So, if we have any OpenMP target related code in the TU, we add the header 
`__clang_openmp_target_math.h` which defines "common" math functions as you did 
in `__clang_openmp_math.h` (without the NVPTX guard). The runtime will then 
implement `__kmpc_` as it sees fit.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907



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


[PATCH] D60912: MS ABI: handle inline static data member as template static data member

2019-04-19 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added a comment.

In D60912#1472987 , @rnk wrote:

> In D60912#1472986 , @jyu2 wrote:
>
> > inline static int aoo = foo(); // C++17 inline variable, thus also a 
> > definition
>
>
> This is a `static inline` global variable, so it technically creates two 
> different globals, so calling foo twice is intended behavior. I think we 
> really want to look at the GVA linkage instead of trying to list all the 
> reasons why something might have weak linkage. Take a look at 
> `shouldBeInCOMDAT` in CodeGenModule.cpp, I think it has the logic we want.


Yes, that is good.  I will do that way.  Thanks.  
Jennifer


Repository:
  rC Clang

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

https://reviews.llvm.org/D60912



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


[PATCH] D60920: [ASTMatchers] Introduce Objective-C matchers `isClassMessage`, `isClassMethod`, and `isInstanceMethod`

2019-04-19 Thread Michael Wyman via Phabricator via cfe-commits
mwyman created this revision.
mwyman added reviewers: benhamilton, klimek.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

isClassMessage is an equivalent to isInstanceMessage for ObjCMessageExpr, but 
matches message expressions to classes.

isClassMethod and isInstanceMethod check whether a method declaration (or 
definition) is for a class method or instance method (respectively).


Repository:
  rC Clang

https://reviews.llvm.org/D60920

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -454,6 +454,20 @@
   objcMessageExpr(hasReceiver(declRefExpr(to(varDecl(hasName("x";
 }
 
+TEST(Matcher, isClassMessage) {
+  EXPECT_TRUE(matchesObjC(
+  "@interface NSString +(NSString *) stringWithFormat; @end "
+  "void f() { [NSString stringWithFormat]; }",
+  objcMessageExpr(isClassMessage(;
+
+  EXPECT_FALSE(matchesObjC(
+  "@interface NSString @end "
+  "void f(NSString *x) {"
+  "[x containsString];"
+  "}",
+  objcMessageExpr(isClassMessage(;
+}
+
 TEST(Matcher, isInstanceMessage) {
   EXPECT_TRUE(matchesObjC(
   "@interface NSString @end "
@@ -469,6 +483,46 @@
 
 }
 
+TEST(Matcher, isClassMethod) {
+  EXPECT_TRUE(matchesObjC(
+"@interface Bar + (void)bar; @end",
+objcMethodDecl(isClassMethod(;
+
+  EXPECT_TRUE(matchesObjC(
+"@interface Bar @end"
+"@implementation Bar + (void)bar {} @end",
+objcMethodDecl(isClassMethod(;
+
+  EXPECT_FALSE(matchesObjC(
+"@interface Foo - (void)foo; @end",
+objcMethodDecl(isClassMethod(;
+
+  EXPECT_FALSE(matchesObjC(
+"@interface Foo @end "
+"@implementation Foo - (void)foo {} @end",
+objcMethodDecl(isClassMethod(;
+}
+
+TEST(Matcher, isInstanceMethod) {
+  EXPECT_TRUE(matchesObjC(
+"@interface Foo - (void)foo; @end",
+objcMethodDecl(isInstanceMethod(;
+
+  EXPECT_TRUE(matchesObjC(
+"@interface Foo @end "
+"@implementation Foo - (void)foo {} @end",
+objcMethodDecl(isInstanceMethod(;
+
+  EXPECT_FALSE(matchesObjC(
+"@interface Bar + (void)bar; @end",
+objcMethodDecl(isInstanceMethod(;
+
+  EXPECT_FALSE(matchesObjC(
+"@interface Bar @end"
+"@implementation Bar + (void)bar {} @end",
+objcMethodDecl(isInstanceMethod(;
+}
+
 TEST(MatcherCXXMemberCallExpr, On) {
   auto Snippet1 = R"cc(
 struct Y {
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -344,6 +344,8 @@
   REGISTER_MATCHER(isBitField);
   REGISTER_MATCHER(isCatchAll);
   REGISTER_MATCHER(isClass);
+  REGISTER_MATCHER(isClassMessage);
+  REGISTER_MATCHER(isClassMethod);
   REGISTER_MATCHER(isConst);
   REGISTER_MATCHER(isConstQualified);
   REGISTER_MATCHER(isConstexpr);
@@ -367,6 +369,7 @@
   REGISTER_MATCHER(isInTemplateInstantiation);
   REGISTER_MATCHER(isInline);
   REGISTER_MATCHER(isInstanceMessage);
+  REGISTER_MATCHER(isInstanceMethod);
   REGISTER_MATCHER(isInstantiated);
   REGISTER_MATCHER(isInstantiationDependent);
   REGISTER_MATCHER(isInteger);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2938,10 +2938,59 @@
   return InnerMatcher.matches(TypeDecl, Finder, Builder);
 }
 
+/// Returns true when the Objective-C method declaration is a class method.
+///
+/// Example
+/// matcher = objcMethodDecl(isClassMethod())
+/// matches
+/// \code
+/// @interface I + (void)foo; @end
+/// \endcode
+/// but not
+/// \code
+/// @interface I - (void)bar; @end
+/// \endcode
+AST_MATCHER(ObjCMethodDecl, isClassMethod) {
+  return Node.isClassMethod();
+}
+
+/// Returns true when the Objective-C method declaration is an instance method.
+///
+/// Example
+/// matcher = objcMethodDecl(isInstanceMethod())
+/// matches
+/// \code
+/// @interface I - (void)bar; @end
+/// \endcode
+/// but not
+/// \code
+/// @interface I + (void)foo; @end
+/// \endcode
+AST_MATCHER(ObjCMethodDecl, isInstanceMethod) {
+  return Node.isInstanceMethod();
+}
+
+/// Returns true when the Objective-C message is sent to a class.
+///
+/// Example
+/// matcher = objcMessageExpr(isClassMessage())
+/// matches
+/// \code
+///   [NSString stringWithFormat:@"format"];
+/// \endcode
+/// but not
+/// \code
+///   NSString *x = @"hello";
+///   [x containsString:@"h"];
+/// \endcode
+AST_MATCHER(ObjCMessageExpr, isClassMessage) {

r358783 - [MS] Emit S_HEAPALLOCSITE debug info

2019-04-19 Thread Amy Huang via cfe-commits
Author: akhuang
Date: Fri Apr 19 14:09:11 2019
New Revision: 358783

URL: http://llvm.org/viewvc/llvm-project?rev=358783&view=rev
Log:
[MS] Emit S_HEAPALLOCSITE debug info

Summary:
This emits labels around heapallocsite calls and S_HEAPALLOCSITE debug
info in codeview. Currently only changes FastISel, so emitting labels still
needs to be implemented in SelectionDAG.

Reviewers: hans, rnk

Subscribers: aprantl, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=358783&r1=358782&r2=358783&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Fri Apr 19 14:09:11 2019
@@ -1969,7 +1969,6 @@ void CGDebugInfo::addHeapAllocSiteMetada
 QualType PointeeTy = D.getTypePtr()->getPointeeType();
 node = getOrCreateType(PointeeTy, getOrCreateFile(Loc));
   }
-
   CI->setMetadata("heapallocsite", node);
 }
 


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


[PATCH] D60800: [MS] Emit S_HEAPALLOCSITE debug info

2019-04-19 Thread Amy Huang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358783: [MS] Emit S_HEAPALLOCSITE debug info (authored by 
akhuang, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D60800?vs=195877&id=195909#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60800

Files:
  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
  llvm/trunk/include/llvm/CodeGen/MachineFunction.h
  llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
  llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
  llvm/trunk/lib/CodeGen/MachineFunction.cpp
  llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
  llvm/trunk/test/CodeGen/X86/label-heapallocsite.ll

Index: llvm/trunk/lib/CodeGen/MachineFunction.cpp
===
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp
@@ -43,6 +43,7 @@
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Constant.h"
 #include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/GlobalValue.h"
@@ -806,6 +807,16 @@
   return FilterID;
 }
 
+void MachineFunction::addCodeViewHeapAllocSite(MachineInstr *I, MDNode *MD) {
+  MCSymbol *BeginLabel = Ctx.createTempSymbol("heapallocsite", true);
+  MCSymbol *EndLabel = Ctx.createTempSymbol("heapallocsite", true);
+  I->setPreInstrSymbol(*this, BeginLabel);
+  I->setPostInstrSymbol(*this, EndLabel);
+
+  DIType *DI = dyn_cast(MD);
+  CodeViewHeapAllocSites.push_back({BeginLabel, EndLabel, DI});
+}
+
 /// \}
 
 //===--===//
Index: llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
===
--- llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ llvm/trunk/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1234,6 +1234,12 @@
   if (CLI.NumResultRegs && CLI.CS)
 updateValueMap(CLI.CS->getInstruction(), CLI.ResultReg, CLI.NumResultRegs);
 
+  // Set labels for heapallocsite call.
+  if (CLI.CS && CLI.CS->getInstruction()->getMetadata("heapallocsite")) {
+MDNode *MD = CLI.CS->getInstruction()->getMetadata("heapallocsite");
+MF->addCodeViewHeapAllocSite(CLI.Call, MD);
+  }
+
   return true;
 }
 
Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
===
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.h
@@ -147,6 +147,7 @@
 SmallVector ChildBlocks;
 
 std::vector> Annotations;
+std::vector> HeapAllocSites;
 
 const MCSymbol *Begin = nullptr;
 const MCSymbol *End = nullptr;
Index: llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
===
--- llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -1072,6 +1072,23 @@
   endSymbolRecord(AnnotEnd);
 }
 
+for (auto HeapAllocSite : FI.HeapAllocSites) {
+  MCSymbol *BeginLabel = std::get<0>(HeapAllocSite);
+  MCSymbol *EndLabel = std::get<1>(HeapAllocSite);
+  DIType *DITy = std::get<2>(HeapAllocSite);
+
+  MCSymbol *HeapAllocEnd = beginSymbolRecord(SymbolKind::S_HEAPALLOCSITE);
+  OS.AddComment("Call site offset");
+  OS.EmitCOFFSecRel32(BeginLabel, /*Offset=*/0);
+  OS.AddComment("Call site section index");
+  OS.EmitCOFFSectionIndex(BeginLabel);
+  OS.AddComment("Call instruction length");
+  OS.emitAbsoluteSymbolDiff(EndLabel, BeginLabel, 2);
+  OS.AddComment("Type index");
+  OS.EmitIntValue(getCompleteTypeIndex(DITy).getIndex(), 4);
+  endSymbolRecord(HeapAllocEnd);
+}
+
 if (SP != nullptr)
   emitDebugInfoForUDTs(LocalUDTs);
 
@@ -2807,6 +2824,7 @@
   }
 
   CurFn->Annotations = MF->getCodeViewAnnotations();
+  CurFn->HeapAllocSites = MF->getCodeViewHeapAllocSites();
 
   CurFn->End = Asm->getFunctionEnd();
 
Index: llvm/trunk/include/llvm/CodeGen/MachineFunction.h
===
--- llvm/trunk/include/llvm/CodeGen/MachineFunction.h
+++ llvm/trunk/include/llvm/CodeGen/MachineFunction.h
@@ -321,6 +321,10 @@
   /// CodeView label annotations.
   std::vector> CodeViewAnnotations;
 
+  /// CodeView heapallocsites.
+  std::vector>
+  CodeViewHeapAllocSites;
+
   bool CallsEHReturn = false;
   bool CallsUnwindInit = false;
   bool HasEHScopes = false;
@@ -906,6 +910,14 @@
 return CodeViewAnnotations;
   }
 
+  /// Record heapallocsites
+  void addCodeViewHeapAllocSite(MachineInstr *I, MDNode *MD);
+
+  ArrayRef>
+  getCodeViewHeapAllocSites() const {
+return CodeViewHeapAllocSites;
+  }
+
   /// Return a reference to the C++ typeinfo for the current function.
   const std::vector &getTypeInfos() const {
 ret

[PATCH] D60920: [ASTMatchers] Introduce Objective-C matchers `isClassMessage`, `isClassMethod`, and `isInstanceMethod`

2019-04-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton accepted this revision.
benhamilton added a comment.
This revision is now accepted and ready to land.

LGTM!


Repository:
  rC Clang

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

https://reviews.llvm.org/D60920



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


[PATCH] D57858: [analyzer] Add a new frontend flag to display all checker options

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping^2


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

https://reviews.llvm.org/D57858



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


[PATCH] D57860: [analyzer] Validate checker option names and values

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ping^2


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

https://reviews.llvm.org/D57860



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


[PATCH] D60907: [OpenMP][WIP] Add math functions support in OpenMP offloading

2019-04-19 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 195915.
gtbercea edited the summary of this revision.
gtbercea added a comment.

- Address comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60907

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_openmp_math.h

Index: lib/Headers/__clang_openmp_math.h
===
--- /dev/null
+++ lib/Headers/__clang_openmp_math.h
@@ -0,0 +1,65 @@
+/*=== __clang_openmp_math.h - Target OpenMP math 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
+ *
+ *===---===
+ */
+
+#ifndef __CLANG_OPENMP_MATH_H__
+#define __CLANG_OPENMP_MATH_H__
+
+#pragma omp declare target
+
+// Declarations of function in libomptarget
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+// POW
+float __kmpc_powf(float, float);
+double __kmpc_pow(double, double);
+long double __kmpc_powl(long double, long double);
+
+// SIN
+float __kmpc_sinf(float);
+double __kmpc_sin(double);
+long double __kmpc_sinl(long double);
+
+#if defined(__cplusplus)
+}
+#endif
+
+// POW
+__attribute__((always_inline, used)) static float powf(float a, float b) {
+  return __kmpc_powf(a, b);
+}
+
+__attribute__((always_inline, used)) static double pow(double a, double b) {
+  return __kmpc_pow(a, b);
+}
+
+__attribute__((always_inline, used)) static long double powl(
+	long double a, long double b) {
+  return __kmpc_powl(a, b);
+}
+
+// SIN
+__attribute__((always_inline, used)) static float sinf(float a) {
+  return __kmpc_sinf(a);
+}
+
+__attribute__((always_inline, used)) static double sin(double a) {
+  return __kmpc_sin(a);
+}
+
+__attribute__((always_inline, used)) static long double sinl(
+	long double a) {
+  return __kmpc_sinl(a);
+}
+
+#pragma omp end declare target
+
+#endif
+
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -31,6 +31,7 @@
   avxintrin.h
   bmi2intrin.h
   bmiintrin.h
+  __clang_openmp_math.h
   __clang_cuda_builtin_vars.h
   __clang_cuda_cmath.h
   __clang_cuda_complex_builtins.h
Index: lib/Driver/ToolChains/Cuda.h
===
--- lib/Driver/ToolChains/Cuda.h
+++ lib/Driver/ToolChains/Cuda.h
@@ -48,6 +48,9 @@
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const;
 
+  void AddMathDeviceFunctions(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const;
+
   /// Emit an error if Version does not support the given Arch.
   ///
   /// If either Version or Arch is unknown, does not emit an error.  Emits at
@@ -165,6 +168,9 @@
   void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
 
+  void AddMathDeviceFunctions(const llvm::opt::ArgList &DriverArgs,
+  llvm::opt::ArgStringList &CC1Args) const override;
+
   void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const override;
   CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const override;
   void
Index: lib/Driver/ToolChains/Cuda.cpp
===
--- lib/Driver/ToolChains/Cuda.cpp
+++ lib/Driver/ToolChains/Cuda.cpp
@@ -255,6 +255,16 @@
   CC1Args.push_back("__clang_cuda_runtime_wrapper.h");
 }
 
+void CudaInstallationDetector::AddMathDeviceFunctions(
+const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+  CC1Args.push_back("-internal-isystem");
+  CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath()));
+  CC1Args.push_back("-include");
+  CC1Args.push_back("__clang_openmp_math.h");
+  CC1Args.push_back("-I");
+  CC1Args.push_back(DriverArgs.MakeArgString(getIncludePath()));
+}
+
 void CudaInstallationDetector::CheckCudaVersionSupportsArch(
 CudaArch Arch) const {
   if (Arch == CudaArch::UNKNOWN || Version == CudaVersion::UNKNOWN ||
@@ -898,6 +908,11 @@
   CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
 }
 
+void CudaToolChain::AddMathDeviceFunctions(
+const ArgList &DriverArgs, ArgStringList &CC1Args) const {
+  CudaInstallation.AddMathDeviceFunctions(DriverArgs, CC1Args);
+}
+
 llvm::opt::DerivedArgList *
 CudaToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
  StringRef BoundArch,
Index: lib/Driver/ToolChains/Clang.cpp
==

[PATCH] D59168: [runtimes] Move libunwind, libc++abi and libc++ to lib/clang/ and include/

2019-04-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In D59168#1472152 , @jdenny wrote:

> In D59168#1470578 , @phosek wrote:
>
> > In D59168#1469186 , @jdenny wrote:
> >
> > >
> >
> >
> > I was also thinking about alternative names for the library path, 
> > specifically for headers we use `include/c++` but for libraries we'll now 
> > use `lib/clang/` which is not very consistent.
>
>
> Does that inconsistency cause a practical problem?


Not at the moment as far as I'm aware, but I'd like to make sure we consider 
all aspects to avoid more transitions in the future.

>> I was considering `lib/c++/` instead
> 
> A practical benefit might be the ability to use `-L` to expose clang's c++ 
> libs without exposing other clang libs as well, but I'm not sure whether 
> that's a real use case.

This may be also beneficial for other compilers that would like to support 
Clang's C++ library.

>> but that wouldn't work for libomp
> 
> If we decide libomp shouldn't be version-locked, then I guess 
> `lib/openmp/` would work.

SGTM

> Is it safe to assume that `lib/c++` and `lib/openmp` would manage to be as 
> clang-dedicated as `lib/clang`?  If other packages don't install to 
> `include/c++`, then I suppose they don't install to `lib/c++`.

AFAIK no other libraries currently use `lib/c++`.


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

https://reviews.llvm.org/D59168



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


[PATCH] D59711: PR41183: Don't emit Wstrict-prototypes warning for an implicit function declaration.

2019-04-19 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59711



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


[PATCH] D60892: Modules: Search for a visible definition of the decl context when computing visibility of a default template parameter

2019-04-19 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.

LGTM, with a possible optimization. Thank you! I know this bug was incredibly 
hard to track down. =)




Comment at: lib/Sema/SemaLookup.cpp:1551
+  TemplateParameterList *TPL = TD->getTemplateParameters();
+  SearchDefinitions = llvm::find(*TPL, D) == TPL->end();
+}

You can avoid the linear search with:

```
SearchDefinitions = D->getIndex() >= TPL->size() || 
TPL->getParam(D->getIndex()) != D;
```


Repository:
  rC Clang

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

https://reviews.llvm.org/D60892



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


[PATCH] D60925: [analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus created this revision.
Szelethus added reviewers: NoQ, dcoughlin, baloghadamsoftware, Charusso, 
xazax.hun, rnkovacs.
Szelethus added a project: clang.
Herald added subscribers: cfe-commits, gamesh411, dkrupp, donat.nagy, jfb, 
mikhail.ramalho, a.sidorin, JDevlieghere, szepet, whisperity.

During my work on analyzer dependencies, I created a great amount of new 
checkers that emitted no diagnostics at all, and were purely modeling some 
function or another.

However, the user shouldn't really disable/enable these by hand, so I think it 
would be great to hide them by default, along with other, older modeling-only 
checkers and debug checkers. I intentionally chose not to hide alpha checkers, 
because they have a scary enough name, in my opinion, to cause no surprise when 
they emit false positives or cause crashes.

CodeChecker also works by individually enabling and disabling each and every 
checker, and the dependency patches would create a great amount of unnecessary 
work on that side. But this is yet another reason, not the main motivation 
behind this patch :)

The patch introduces the `Hidden` bit into the TableGen files (you may remember 
it before I removed it in D53995 ), and 
checkers that are either marked as hidden, or are in a package that is marked 
hidden won't be displayed under `-analyzer-checker-help`. 
`-analyzer-checker-help-hidden`, a new flag meant for developers only, displays 
the full list.

Some dumps I made while coding (not a part of this patch):

  CHECKER HIDDEN: debug.AnalysisOrder
  CHECKER HIDDEN: debug.Stats
  CHECKER NOT HIDDEN: alpha.security.ArrayBound
  CHECKER NOT HIDDEN: alpha.security.ArrayBoundV2
  CHECKER NOT HIDDEN: osx.cocoa.AutoreleaseWrite
  CHECKER NOT HIDDEN: alpha.unix.BlockInCriticalSection
  CHECKER NOT HIDDEN: alpha.core.BoolAssignment
  CHECKER HIDDEN: core.builtin.BuiltinFunctions
  CHECKER NOT HIDDEN: osx.coreFoundation.CFError
  CHECKER HIDDEN: debug.DumpCFG
  CHECKER HIDDEN: debug.ViewCFG
  CHECKER NOT HIDDEN: osx.coreFoundation.CFNumber
  CHECKER NOT HIDDEN: osx.coreFoundation.CFRetainRelease
  CHECKER NOT HIDDEN: alpha.unix.cstring.BufferOverlap
  CHECKER HIDDEN: unix.cstring.CStringModeling
  CHECKER NOT HIDDEN: alpha.unix.cstring.NotNullTerminated
  CHECKER NOT HIDDEN: unix.cstring.NullArg
  CHECKER NOT HIDDEN: alpha.unix.cstring.OutOfBounds
  CHECKER NOT HIDDEN: unix.cstring.BadSizeArg
  CHECKER HIDDEN: cplusplus.SelfAssignment
  CHECKER NOT HIDDEN: core.CallAndMessage
  CHECKER NOT HIDDEN: alpha.core.CallAndMessageUnInitRefArg
  CHECKER HIDDEN: debug.DumpCalls
  CHECKER HIDDEN: debug.DumpCallGraph
  CHECKER HIDDEN: debug.ViewCallGraph
  CHECKER NOT HIDDEN: alpha.core.CastSize
  CHECKER NOT HIDDEN: alpha.core.CastToStruct
  CHECKER NOT HIDDEN: alpha.unix.Chroot
  CHECKER NOT HIDDEN: osx.cocoa.ClassRelease
  CHECKER NOT HIDDEN: alpha.clone.CloneChecker
  CHECKER HIDDEN: debug.ConfigDumper
  CHECKER NOT HIDDEN: alpha.core.Conversion
  CHECKER NOT HIDDEN: valist.CopyToSelf
  CHECKER NOT HIDDEN: deadcode.DeadStores
  CHECKER NOT HIDDEN: alpha.cplusplus.DeleteWithNonVirtualDtor
  CHECKER NOT HIDDEN: security.insecureAPI.DeprecatedOrUnsafeBufferHandling
  CHECKER NOT HIDDEN: core.NullDereference
  CHECKER NOT HIDDEN: alpha.osx.cocoa.DirectIvarAssignment
  CHECKER NOT HIDDEN: alpha.osx.cocoa.DirectIvarAssignmentForAnnotatedFunctions
  CHECKER NOT HIDDEN: core.DivideZero
  CHECKER HIDDEN: debug.DumpDominators
  CHECKER HIDDEN: unix.DynamicMemoryModeling
  CHECKER NOT HIDDEN: alpha.core.DynamicTypeChecker
  CHECKER NOT HIDDEN: core.DynamicTypePropagation
  CHECKER NOT HIDDEN: 
optin.osx.cocoa.localizability.EmptyLocalizationContextChecker
  CHECKER NOT HIDDEN: alpha.cplusplus.EnumCastOutOfRange
  CHECKER HIDDEN: debug.ViewExplodedGraph
  CHECKER HIDDEN: debug.ExprInspection
  CHECKER NOT HIDDEN: alpha.core.FixedAddr
  CHECKER NOT HIDDEN: security.FloatLoopCounter
  CHECKER NOT HIDDEN: optin.performance.GCDAntipattern
  CHECKER HIDDEN: apiModeling.google.GTest
  CHECKER NOT HIDDEN: alpha.security.taint.TaintPropagation
  CHECKER NOT HIDDEN: alpha.core.IdenticalExpr
  CHECKER NOT HIDDEN: cplusplus.InnerPointer
  CHECKER NOT HIDDEN: alpha.osx.cocoa.InstanceVariableInvalidation
  CHECKER NOT HIDDEN: alpha.cplusplus.InvalidatedIterator
  CHECKER HIDDEN: alpha.cplusplus.IteratorModeling
  CHECKER NOT HIDDEN: alpha.cplusplus.IteratorRange
  CHECKER HIDDEN: alpha.osx.cocoa.IvarInvalidationModeling
  CHECKER NOT HIDDEN: alpha.llvm.Conventions
  CHECKER HIDDEN: debug.DumpLiveStmts
  CHECKER HIDDEN: debug.DumpLiveVars
  CHECKER NOT HIDDEN: osx.MIG
  CHECKER NOT HIDDEN: optin.mpi.MPI-Checker
  CHECKER NOT HIDDEN: osx.SecKeychainAPI
  CHECKER NOT HIDDEN: osx.API
  CHECKER NOT HIDDEN: unix.Malloc
  CHECKER NOT HIDDEN: alpha.security.MallocOverflow
  CHECKER NOT HIDDEN: unix.MallocSizeof
  CHECKER NOT HIDDEN: unix.MismatchedDeallocator
  CHECKER NOT HIDDEN: alpha.cplusplus.MismatchedIterator
  CHECKER NOT HIDDEN: alpha.osx.c

[PATCH] D60872: Add new warning knob for unknown attribute namespaces

2019-04-19 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Hmm. So there are a few different situations where we might meet an unknown 
attribute (I'm sure I missed some):

1. The attribute had a typo in it (eg: [[clagn::fallthrough]]).
2. The attribute has semantic effects (ignoring it is incorrect and will -- at 
best -- not compile or -- at worst -- generate a subtly broken program, eg: 
[[gnu::aligned]] or [[gnu::target]]).
3. The attribute has important effects (ignoring it is probably correct but 
suboptimal in some way, eg: [[no_unique_address]], [[gnu::packed]], ...).
4. The attribute has unimportant effects (is entirely safely ignorable) or is 
only intended to affect the behavior of a different tool (eg: gsl, static 
analyzer, clang-tidy, etc).

I think the ideal would be to warn on unknown attributes in cases 1 and 2, 
optionally warn on unknown attributes in case 3, and to not warn in case 4. 
Without user hints, we can't tell which is which in general.

"Do not warn on unknown namespaces" gives us some part of not warning on case 
4. However, it also turns off warnings in cases 1-3 (eg, we won't warn on 
`[[gcc::noinline]]` as a typo for `[[gnu::noinline]]`), and doesn't turn off 
warnings for case-4 attributes in, say, namespace `gnu`, so it's somewhat 
imperfect. I think it's also going to be surprising that the clang release that 
starts parsing a [[gsl::*]] attribute also starts warning on other ("unknown") 
[[gsl::*]] attributes for people in this new mode.

It seems to me that we can achieve the ideal (don't warn on safely-ignorable 
unknown attributes, but warn on all other unknown attributes) if we ask the 
user to give us a list of safely-ignorable attributes and attribute namespaces 
that they intend to use. (That even lets us do typo-correction for attributes 
we don't support.) In the cfe-dev thread, there was mention that there are 
hundreds of attributes supported by clang, and so hundreds of attributes would 
need to be listed, but that doesn't follow: you only need to list the 
attributes that you actually intend to use. That should be a much smaller list 
(especially once modules adoption picks up, and you don't need to list those 
attributes used by your dependencies).


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

https://reviews.llvm.org/D60872



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


r358795 - Modules: Search for a visible definition of the decl context when computing visibility of a default template parameter

2019-04-19 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Apr 19 16:02:30 2019
New Revision: 358795

URL: http://llvm.org/viewvc/llvm-project?rev=358795&view=rev
Log:
Modules: Search for a visible definition of the decl context when computing 
visibility of a default template parameter

The code is/was already correct for the case where a parameter is a
parameter of its enclosing lexical DeclContext (functions and classes).
But for other templates (alias and variable templates) they don't create
their own scope to be members of - in those cases, they parameter should
be considered visible if any definition of the lexical decl context is
visible.

[this should cleanup the failure on the libstdc++ modules buildbot]
[this doesn't actually fix the variable template case for a
secondary/compounding reason (its lexical decl context is incorrectly
considered to be the translation unit)]

Test covers all 4 kinds of templates with default args, including a
regression test for the still broken variable template case.

Reviewers: rsmith

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

Added:
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias1.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias2.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/func.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/func1.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/func2.h

cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/module.modulemap
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct1.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct2.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/var.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/var1.h
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/var2.h
cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp
Modified:
cfe/trunk/lib/Sema/SemaLookup.cpp

Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=358795&r1=358794&r2=358795&view=diff
==
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Fri Apr 19 16:02:30 2019
@@ -1543,8 +1543,21 @@ bool LookupResult::isVisibleSlow(Sema &S
 // and in C we must not because each declaration of a function gets its own
 // set of declarations for tags in prototype scope.
 bool VisibleWithinParent;
-if (D->isTemplateParameter() || isa(D) ||
-(isa(DC) && !SemaRef.getLangOpts().CPlusPlus))
+if (D->isTemplateParameter()) {
+  bool SearchDefinitions = true;
+  if (const auto *DCD = dyn_cast(DC)) {
+if (const auto *TD = DCD->getDescribedTemplate()) {
+  TemplateParameterList *TPL = TD->getTemplateParameters();
+  auto Index = getDepthAndIndex(D).second;
+  SearchDefinitions = Index >= TPL->size() || TPL->getParam(Index) != 
D;
+}
+  }
+  if (SearchDefinitions)
+VisibleWithinParent = 
SemaRef.hasVisibleDefinition(cast(DC));
+  else
+VisibleWithinParent = isVisible(SemaRef, cast(DC));
+} else if (isa(D) ||
+   (isa(DC) && !SemaRef.getLangOpts().CPlusPlus))
   VisibleWithinParent = isVisible(SemaRef, cast(DC));
 else if (D->isModulePrivate()) {
   // A module-private declaration is only visible if an enclosing lexical

Added: cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias.h?rev=358795&view=auto
==
--- cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias.h 
Fri Apr 19 16:02:30 2019
@@ -0,0 +1,7 @@
+#ifndef ALIAS_H
+#define ALIAS_H
+struct alias_outer {
+  template 
+  using alias = int;
+};
+#endif

Added: cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias1.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias1.h?rev=358795&view=auto
==
--- cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias1.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias1.h 
Fri Apr 19 16:02:30 2019
@@ -0,0 +1 @@
+#include "alias.h"

Added: cfe/trunk/test/Modules/Inputs/nested-template-default-arg-red

[PATCH] D60892: Modules: Search for a visible definition of the decl context when computing visibility of a default template parameter

2019-04-19 Thread David Blaikie via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL358795: Modules: Search for a visible definition of the decl 
context when computing… (authored by dblaikie, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60892?vs=195825&id=195931#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60892

Files:
  cfe/trunk/lib/Sema/SemaLookup.cpp
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias1.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/alias2.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/func.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/func1.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/func2.h
  
cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/module.modulemap
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct1.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct2.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/var.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/var1.h
  cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/var2.h
  cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp

Index: cfe/trunk/lib/Sema/SemaLookup.cpp
===
--- cfe/trunk/lib/Sema/SemaLookup.cpp
+++ cfe/trunk/lib/Sema/SemaLookup.cpp
@@ -1543,8 +1543,21 @@
 // and in C we must not because each declaration of a function gets its own
 // set of declarations for tags in prototype scope.
 bool VisibleWithinParent;
-if (D->isTemplateParameter() || isa(D) ||
-(isa(DC) && !SemaRef.getLangOpts().CPlusPlus))
+if (D->isTemplateParameter()) {
+  bool SearchDefinitions = true;
+  if (const auto *DCD = dyn_cast(DC)) {
+if (const auto *TD = DCD->getDescribedTemplate()) {
+  TemplateParameterList *TPL = TD->getTemplateParameters();
+  auto Index = getDepthAndIndex(D).second;
+  SearchDefinitions = Index >= TPL->size() || TPL->getParam(Index) != D;
+}
+  }
+  if (SearchDefinitions)
+VisibleWithinParent = SemaRef.hasVisibleDefinition(cast(DC));
+  else
+VisibleWithinParent = isVisible(SemaRef, cast(DC));
+} else if (isa(D) ||
+   (isa(DC) && !SemaRef.getLangOpts().CPlusPlus))
   VisibleWithinParent = isVisible(SemaRef, cast(DC));
 else if (D->isModulePrivate()) {
   // A module-private declaration is only visible if an enclosing lexical
Index: cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp
===
--- cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp
+++ cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -x c++ -fmodules -fimplicit-module-maps -fmodules-cache-path=%t \
+// RUN: -I %S/Inputs/nested-template-default-arg-redecl -std=c++14 \
+// RUN: -fmodules-local-submodule-visibility -verify %s
+#include "alias2.h"
+#include "var2.h"
+#include "strct2.h"
+#include "func2.h"
+
+// FIXME: Variable templates lexical decl context appears to be the translation
+// unit, which is incorrect. Fixing this will hopefully address the following
+// error/bug:
+
+// expected-note@Inputs/nested-template-default-arg-redecl/var.h:4 {{default argument declared here}}
+auto var = &var_outer::var<>; // expected-error {{default argument of 'var' must be imported from module 'VAR1' before it is required}}
+auto func = &func_outer::func<>;
+strct_outer::strct<> *strct;
+alias_outer::alias<> *alias;
Index: cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct2.h
===
--- cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct2.h
+++ cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/strct2.h
@@ -0,0 +1 @@
+#include "strct.h"
Index: cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/module.modulemap
===
--- cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/module.modulemap
+++ cfe/trunk/test/Modules/Inputs/nested-template-default-arg-redecl/module.modulemap
@@ -0,0 +1,24 @@
+module ALIAS1 {
+  header "alias1.h"
+  module ALIAS2 {
+header "alias2.h"
+  }
+}
+module VAR1 {
+  header "var1.h"
+  module VAR2 {
+header "var2.h"
+  }
+}
+module FUNC1 {
+  header "func1.h"
+  module FUNC2 {
+header "func2.h"
+  }
+}
+module STRCT1 {
+  header "str

r358796 - Modules: Adopt template parameters for variable templates to set their decl context correctly

2019-04-19 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Apr 19 16:04:05 2019
New Revision: 358796

URL: http://llvm.org/viewvc/llvm-project?rev=358796&view=rev
Log:
Modules: Adopt template parameters for variable templates to set their decl 
context correctly

Exposed by a related bug about visibility of default arguments of nested
templates - without the correct decl context, default template
parameters of variable templates nested in classes would have incorrect
visibility computed.

Modified:
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp

Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=358796&r1=358795&r2=358796&view=diff
==
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Fri Apr 19 16:04:05 2019
@@ -956,6 +956,7 @@ VarTemplateDecl *VarTemplateDecl::Create
  SourceLocation L, DeclarationName 
Name,
  TemplateParameterList *Params,
  VarDecl *Decl) {
+  AdoptTemplateParameterList(Params, DC);
   return new (C, DC) VarTemplateDecl(C, DC, L, Name, Params, Decl);
 }
 

Modified: cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp?rev=358796&r1=358795&r2=358796&view=diff
==
--- cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp (original)
+++ cfe/trunk/test/Modules/nested-template-default-arg-redecl.cpp Fri Apr 19 
16:04:05 2019
@@ -1,18 +1,16 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -x c++ -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t \
 // RUN: -I %S/Inputs/nested-template-default-arg-redecl -std=c++14 \
-// RUN: -fmodules-local-submodule-visibility -verify %s
+// RUN: -fmodules-local-submodule-visibility -w -verify %s
+
+// expected-no-diagnostics
+
 #include "alias2.h"
 #include "var2.h"
 #include "strct2.h"
 #include "func2.h"
 
-// FIXME: Variable templates lexical decl context appears to be the translation
-// unit, which is incorrect. Fixing this will hopefully address the following
-// error/bug:
-
-// expected-note@Inputs/nested-template-default-arg-redecl/var.h:4 {{default 
argument declared here}}
-auto var = &var_outer::var<>; // expected-error {{default argument of 'var' 
must be imported from module 'VAR1' before it is required}}
+auto var = &var_outer::var<>;
 auto func = &func_outer::func<>;
 strct_outer::strct<> *strct;
 alias_outer::alias<> *alias;


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


[PATCH] D59712: [APSInt][OpenMP] Fix isNegative, etc. for unsigned types

2019-04-19 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny added a comment.

In D59712#1469392 , @lebedev.ri wrote:

> Does this pass `check-all`? `check-all` of stage-2? test-suite?


For me, all these tests behave with the current patch.  As before, the only 
subproject I did not build was llgo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59712



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


[PATCH] D60349: [COFF, ARM64] Fix ABI implementation of struct returns

2019-04-19 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang updated this revision to Diff 195932.

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

https://reviews.llvm.org/D60349

Files:
  include/clang/CodeGen/CGFunctionInfo.h
  lib/CodeGen/CGCall.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaDeclCXX.cpp
  test/CodeGen/arm64-microsoft-arguments.cpp

Index: test/CodeGen/arm64-microsoft-arguments.cpp
===
--- test/CodeGen/arm64-microsoft-arguments.cpp
+++ test/CodeGen/arm64-microsoft-arguments.cpp
@@ -1,25 +1,31 @@
 // RUN: %clang_cc1 -triple aarch64-windows -ffreestanding -emit-llvm -O0 \
 // RUN: -x c++ -o - %s | FileCheck %s
 
-struct pod { int a, b, c, d, e; };
+// Return type size <= 8 bytes.
+// CHECK: define {{.*}} i64 @{{.*}}f1{{.*}}()
+struct S1 { int a, b; };
+S1 f1() { return S1{}; }
 
-struct non_pod {
-  int a;
-  non_pod() {}
-};
+// Return type size <= 16 bytes.
+// CHECK: define {{.*}} [2 x i64] @{{.*}}f2{{.*}}()
+struct S2 { int a, b, c, d; };
+S2 f2() { return S2{}; }
 
-struct pod s;
-struct non_pod t;
+// Return type size > 16 bytes.
+// CHECK: define {{.*}} void @{{.*}}f3{{.*}}(%struct.S3* noalias sret %agg.result)
+struct S3 { int a, b, c, d, e; };
+S3 f3() { return S3{}; }
 
-struct pod bar() { return s; }
-struct non_pod foo() { return t; }
-// CHECK: define {{.*}} void @{{.*}}bar{{.*}}(%struct.pod* noalias sret %agg.result)
-// CHECK: define {{.*}} void @{{.*}}foo{{.*}}(%struct.non_pod* noalias %agg.result)
+// Instance methods.
+// CHECK: define {{.*}} void @{{.*}}inst@C{{.*}}(%class.C* %this, %class.A* inreg noalias sret %agg.result)
 
+class A {};
 
-// Check instance methods.
-struct pod2 { int x; };
-struct Baz { pod2 baz(); };
+class C {
+public:
+  A inst();
+};
 
-int qux() { return Baz().baz().x; }
-// CHECK: declare {{.*}} void @{{.*}}baz@Baz{{.*}}(%struct.Baz*, %struct.pod2*)
+A C::inst() {
+  return A();
+}
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -5902,8 +5902,13 @@
!D->hasNonTrivialCopyConstructorForCall();
 
   if (CCK == TargetInfo::CCK_MicrosoftWin64) {
+bool isAArch64 = S.Context.getTargetInfo().getTriple().isAArch64();
+if (isAArch64 && !D->isAggregate())
+  return false;
+
 bool CopyCtorIsTrivial = false, CopyCtorIsTrivialForCall = false;
 bool DtorIsTrivialForCall = false;
+bool CopyAssignmentIsTrivial = !isAArch64;
 
 // If a class has at least one non-deleted, trivial copy constructor, it
 // is passed according to the C ABI. Otherwise, it is passed indirectly.
@@ -5929,6 +5934,9 @@
   }
 }
 
+if (isAArch64 && D->needsImplicitCopyAssignment())
+  CopyAssignmentIsTrivial = D->hasTrivialCopyAssignment();
+
 if (D->needsImplicitDestructor()) {
   if (!D->defaultedDestructorIsDeleted() &&
   D->hasTrivialDestructorForCall())
@@ -5939,7 +5947,8 @@
 }
 
 // If the copy ctor and dtor are both trivial-for-calls, pass direct.
-if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall)
+if (CopyCtorIsTrivialForCall && DtorIsTrivialForCall &&
+CopyAssignmentIsTrivial)
   return true;
 
 // If a class has a destructor, we'd really like to pass it indirectly
@@ -5952,7 +5961,7 @@
 
 // Note: This permits small classes with nontrivial destructors to be
 // passed in registers, which is non-conforming.
-if (CopyCtorIsTrivial &&
+if (!isAArch64 && CopyCtorIsTrivial &&
 S.getASTContext().getTypeSize(D->getTypeForDecl()) <= 64)
   return true;
 return false;
Index: lib/CodeGen/MicrosoftCXXABI.cpp
===
--- lib/CodeGen/MicrosoftCXXABI.cpp
+++ lib/CodeGen/MicrosoftCXXABI.cpp
@@ -52,6 +52,10 @@
 
   bool classifyReturnType(CGFunctionInfo &FI) const override;
 
+  bool passClassIndirect(const CXXRecordDecl *RD) const {
+return !canCopyArgument(RD);
+  }
+
   RecordArgABI getRecordArgABI(const CXXRecordDecl *RD) const override;
 
   bool isSRetParameterAfterThis() const override { return true; }
@@ -1056,28 +1060,17 @@
   if (!RD)
 return false;
 
-  CharUnits Align = CGM.getContext().getTypeAlignInChars(FI.getReturnType());
-  if (FI.isInstanceMethod()) {
-// If it's an instance method, aggregates are always returned indirectly via
-// the second parameter.
-FI.getReturnInfo() = ABIArgInfo::getIndirect(Align, /*ByVal=*/false);
-FI.getReturnInfo().setSRetAfterThis(FI.isInstanceMethod());
+  bool isIndirectReturn = passClassIndirect(RD);
+  bool isInstanceMethod = FI.isInstanceMethod();
 
-// aarch64-windows requires that instance methods use X1 for the return
-// address. So for aarch64-windows we do not mark the
-// return as SRet.
-FI.getReturnInfo().setSuppressSRet(CGM.getTarget().getTriple().getArch() ==
-   llvm::Triple::aarch64);
-return true;
-  } else

[PATCH] D60926: [CMake] Replace the sanitizer support in runtimes build with multilib

2019-04-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 195934.

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

https://reviews.llvm.org/D60926

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -70,7 +70,7 @@
   get_compiler_rt_path(compiler_rt_path)
   if(compiler_rt_path)
 list(REMOVE_ITEM runtimes ${compiler_rt_path})
-if(NOT LLVM_BUILD_COMPILER_RT)
+if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
   list(INSERT runtimes 0 ${compiler_rt_path})
 endif()
   endif()
@@ -242,7 +242,8 @@
 
 get_cmake_property(variableNames VARIABLES)
 foreach(variableName ${variableNames})
-  if(variableName MATCHES "^BUILTINS_${target}")
+  string(FIND "${variableName}" "BUILTINS_${target}" out)
+  if("${out}" EQUAL 0)
 string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
 list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}")
   endif()
@@ -425,10 +426,13 @@
 
 get_cmake_property(variableNames VARIABLES)
 foreach(variableName ${variableNames})
-  if(variableName MATCHES "^RUNTIMES_${name}")
+  string(FIND "${variableName}" "RUNTIMES_${name}" out)
+  if("${out}" EQUAL 0)
 string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
 list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
-  elseif(variableName MATCHES "^RUNTIMES_${target}")
+  endif()
+  string(FIND "${variableName}" "RUNTIMES_${target}" out)
+  if("${out}" EQUAL 0)
 string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
 list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
   endif()
@@ -510,28 +514,16 @@
 endif()
   endforeach()
 
-  foreach(sanitizer ${LLVM_RUNTIME_SANITIZERS})
-if (sanitizer STREQUAL "Address")
-  set(sanitizer_name "asan")
-elseif (sanitizer STREQUAL "Memory")
-  set(sanitizer_name "msan")
-elseif (sanitizer STREQUAL "Thread")
-  set(sanitizer_name "tsan")
-elseif (sanitizer STREQUAL "Undefined")
-  set(sanitizer_name "ubsan")
-else()
-  message(FATAL_ERROR "Unsupported value of LLVM_RUNTIME_TARGET_SANITIZERS: ${sanitizers}")
-endif()
-foreach(name ${LLVM_RUNTIME_SANITIZER_${sanitizer}_TARGETS})
-  runtime_register_target(${name}-${sanitizer_name} ${name}
+  foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
+foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
+  runtime_register_target(${name}+${multilib} ${name}
 DEPENDS runtimes-${name}
-CMAKE_ARGS -DLLVM_USE_SANITIZER=${sanitizer}
-   -DLLVM_RUNTIMES_PREFIX=${name}/
-   -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${sanitizer_name})
-  add_dependencies(runtimes runtimes-${name}-${sanitizer_name})
-  add_dependencies(runtimes-configure runtimes-${name}-${sanitizer_name}-configure)
-  add_dependencies(install-runtimes install-runtimes-${name}-${sanitizer_name})
-  add_dependencies(install-runtimes-stripped install-runtimes-${name}-${sanitizer_name}-stripped)
+CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
+   -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${multilib})
+  add_dependencies(runtimes runtimes-${name}+${multilib})
+  add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
+  add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
+  add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
 endforeach()
   endforeach()
 endif()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -142,12 +142,22 @@
 set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
 
+set(RUNTIMES_${target}-fuchsia+asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia+asan_LLVM_USE_SANITIZER "Address" CACHE STRING "")
+set(RUNTIMES_${target}-fuchsia+asan_LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia+asan_LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+
+set(RUNTIMES_${target}-fuchsia+noexcept_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia+noexcept_LIBCXXABI_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia+noexcept_LIBCXX_ENABLE_EXCEPTIONS OFF CACHE BOOL "")
+
 # Use .build-id link.
 list(APPEND RUNTIME_BUILD_ID_LINK "${t

[PATCH] D60926: [CMake] Replace the sanitizer support in runtimes build with multilib

2019-04-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: beanz, smeenai.
Herald added subscribers: llvm-commits, cfe-commits, mgorny.
Herald added projects: clang, LLVM.
phosek updated this revision to Diff 195934.

This is a more generic solution; while the sanitizer support can be used
only for sanitizer instrumented builds, the multilib support can be used
to build other variants such as noexcept which is what we would like to use
in Fuchsia.

The name CMake target name uses the target name, same as for the regular
runtimes build and the name of the multilib, concatenated with '+'. The
libraries are installed in a subdirectory named after the multilib.


https://reviews.llvm.org/D60926

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake
  llvm/runtimes/CMakeLists.txt

Index: llvm/runtimes/CMakeLists.txt
===
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -70,7 +70,7 @@
   get_compiler_rt_path(compiler_rt_path)
   if(compiler_rt_path)
 list(REMOVE_ITEM runtimes ${compiler_rt_path})
-if(NOT LLVM_BUILD_COMPILER_RT)
+if(NOT DEFINED LLVM_BUILD_COMPILER_RT OR LLVM_BUILD_COMPILER_RT)
   list(INSERT runtimes 0 ${compiler_rt_path})
 endif()
   endif()
@@ -242,7 +242,8 @@
 
 get_cmake_property(variableNames VARIABLES)
 foreach(variableName ${variableNames})
-  if(variableName MATCHES "^BUILTINS_${target}")
+  string(FIND "${variableName}" "BUILTINS_${target}" out)
+  if("${out}" EQUAL 0)
 string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
 list(APPEND ${target}_extra_args "-D${new_name}=${${variableName}}")
   endif()
@@ -425,10 +426,13 @@
 
 get_cmake_property(variableNames VARIABLES)
 foreach(variableName ${variableNames})
-  if(variableName MATCHES "^RUNTIMES_${name}")
+  string(FIND "${variableName}" "RUNTIMES_${name}" out)
+  if("${out}" EQUAL 0)
 string(REPLACE "RUNTIMES_${name}_" "" new_name ${variableName})
 list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
-  elseif(variableName MATCHES "^RUNTIMES_${target}")
+  endif()
+  string(FIND "${variableName}" "RUNTIMES_${target}" out)
+  if("${out}" EQUAL 0)
 string(REPLACE "RUNTIMES_${target}_" "" new_name ${variableName})
 list(APPEND ${name}_extra_args "-D${new_name}=${${variableName}}")
   endif()
@@ -510,28 +514,16 @@
 endif()
   endforeach()
 
-  foreach(sanitizer ${LLVM_RUNTIME_SANITIZERS})
-if (sanitizer STREQUAL "Address")
-  set(sanitizer_name "asan")
-elseif (sanitizer STREQUAL "Memory")
-  set(sanitizer_name "msan")
-elseif (sanitizer STREQUAL "Thread")
-  set(sanitizer_name "tsan")
-elseif (sanitizer STREQUAL "Undefined")
-  set(sanitizer_name "ubsan")
-else()
-  message(FATAL_ERROR "Unsupported value of LLVM_RUNTIME_TARGET_SANITIZERS: ${sanitizers}")
-endif()
-foreach(name ${LLVM_RUNTIME_SANITIZER_${sanitizer}_TARGETS})
-  runtime_register_target(${name}-${sanitizer_name} ${name}
+  foreach(multilib ${LLVM_RUNTIME_MULTILIBS})
+foreach(name ${LLVM_RUNTIME_MULTILIB_${multilib}_TARGETS})
+  runtime_register_target(${name}+${multilib} ${name}
 DEPENDS runtimes-${name}
-CMAKE_ARGS -DLLVM_USE_SANITIZER=${sanitizer}
-   -DLLVM_RUNTIMES_PREFIX=${name}/
-   -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${sanitizer_name})
-  add_dependencies(runtimes runtimes-${name}-${sanitizer_name})
-  add_dependencies(runtimes-configure runtimes-${name}-${sanitizer_name}-configure)
-  add_dependencies(install-runtimes install-runtimes-${name}-${sanitizer_name})
-  add_dependencies(install-runtimes-stripped install-runtimes-${name}-${sanitizer_name}-stripped)
+CMAKE_ARGS -DLLVM_RUNTIMES_PREFIX=${name}/
+   -DLLVM_RUNTIMES_LIBDIR_SUFFIX=/${multilib})
+  add_dependencies(runtimes runtimes-${name}+${multilib})
+  add_dependencies(runtimes-configure runtimes-${name}+${multilib}-configure)
+  add_dependencies(install-runtimes install-runtimes-${name}+${multilib})
+  add_dependencies(install-runtimes-stripped install-runtimes-${name}+${multilib}-stripped)
 endforeach()
   endforeach()
 endif()
Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -142,12 +142,22 @@
 set(RUNTIMES_${target}-fuchsia_LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY OFF CACHE BOOL "")
 set(RUNTIMES_${target}-fuchsia_LIBCXX_ABI_VERSION 2 CACHE STRING "")
 
+set(RUNTIMES_${target}-fuchsia+asan_LLVM_BUILD_COMPILER_RT OFF CACHE BOOL "")
+set(RUNTIMES_${target}-fuchsia+asan_LLVM_USE_SANITIZER "Address" CACHE

r358797 - [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-19 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Fri Apr 19 16:33:50 2019
New Revision: 358797

URL: http://llvm.org/viewvc/llvm-project?rev=358797&view=rev
Log:
[analyzer] Move UninitializedObjectChecker out of alpha

Moved UninitializedObjectChecker from the 'alpha.cplusplus' to the
'optin.cplusplus' package.

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

Modified:
cfe/trunk/docs/analyzer/checkers.rst
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td

cfe/trunk/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
cfe/trunk/test/Analysis/cxx-uninitialized-object-inheritance.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-no-dereference.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp
cfe/trunk/test/Analysis/cxx-uninitialized-object.cpp
cfe/trunk/test/Analysis/objcpp-uninitialized-object.mm
cfe/trunk/www/analyzer/alpha_checks.html
cfe/trunk/www/analyzer/available_checks.html

Modified: cfe/trunk/docs/analyzer/checkers.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/checkers.rst?rev=358797&r1=358796&r2=358797&view=diff
==
--- cfe/trunk/docs/analyzer/checkers.rst (original)
+++ cfe/trunk/docs/analyzer/checkers.rst Fri Apr 19 16:33:50 2019
@@ -339,6 +339,110 @@ optin
 
 Checkers for portability, performance or coding style specific rules.
 
+optin.cplusplus.UninitializedObject (C++)
+"""
+
+This checker reports uninitialized fields in objects created after a 
constructor
+call. It doesn't only find direct uninitialized fields, but rather makes a deep
+inspection of the object, analyzing all of it's fields subfields.
+The checker regards inherited fields as direct fields, so one will recieve
+warnings for uninitialized inherited data members as well.
+
+.. code-block:: cpp
+
+ // With Pedantic and CheckPointeeInitialization set to true
+
+ struct A {
+   struct B {
+ int x; // note: uninitialized field 'this->b.x'
+ // note: uninitialized field 'this->bptr->x'
+ int y; // note: uninitialized field 'this->b.y'
+ // note: uninitialized field 'this->bptr->y'
+   };
+   int *iptr; // note: uninitialized pointer 'this->iptr'
+   B b;
+   B *bptr;
+   char *cptr; // note: uninitialized pointee 'this->cptr'
+
+   A (B *bptr, char *cptr) : bptr(bptr), cptr(cptr) {}
+ };
+
+ void f() {
+   A::B b;
+   char c;
+   A a(&b, &c); // warning: 6 uninitialized fields
+  //  after the constructor call
+ }
+
+ // With Pedantic set to false and
+ // CheckPointeeInitialization set to true
+ // (every field is uninitialized)
+
+ struct A {
+   struct B {
+ int x;
+ int y;
+   };
+   int *iptr;
+   B b;
+   B *bptr;
+   char *cptr;
+
+   A (B *bptr, char *cptr) : bptr(bptr), cptr(cptr) {}
+ };
+
+ void f() {
+   A::B b;
+   char c;
+   A a(&b, &c); // no warning
+ }
+
+ // With Pedantic set to true and
+ // CheckPointeeInitialization set to false
+ // (pointees are regarded as initialized)
+
+ struct A {
+   struct B {
+ int x; // note: uninitialized field 'this->b.x'
+ int y; // note: uninitialized field 'this->b.y'
+   };
+   int *iptr; // note: uninitialized pointer 'this->iptr'
+   B b;
+   B *bptr;
+   char *cptr;
+
+   A (B *bptr, char *cptr) : bptr(bptr), cptr(cptr) {}
+ };
+
+ void f() {
+   A::B b;
+   char c;
+   A a(&b, &c); // warning: 3 uninitialized fields
+  //  after the constructor call
+ }
+
+
+**Options**
+
+This checker has several options which can be set from command line (e.g.
+``-analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true``):
+
+* ``Pedantic`` (boolean). If to false, the checker won't emit warnings for
+  objects that don't have at least one initialized field. Defaults to false.
+
+* ``NotesAsWarnings``  (boolean). If set to true, the checker will emit a
+  warning for each uninitalized field, as opposed to emitting one warning per
+  constructor call, and listing the uninitialized fields that belongs to it in
+  notes. *Defaults to false*.
+
+* ``CheckPointeeInitialization`` (boolean). If set to false, the checker will
+  not analyze the pointee of pointer/reference fields, and will only check
+  whether the object itself is initialized. *Defaults to false*.
+
+* ``IgnoreRecordsWithField`` (string). If supplied, the checker will not 
analyze
+  structures that have a field with a name or type name that matches  the given
+  pattern. *Defaults to ""*.
+
 optin.cplusplus.VirtualCall (C++)
 "
 Check virtual function calls during construction or destruction.
@@ -1383,102 +1487,6 @@ Method calls on a moved-from object and
a.foo();// warn: method call on a 'moved-from' objec

[PATCH] D58573: [analyzer] Move UninitializedObjectChecker out of alpha

2019-04-19 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC358797: [analyzer] Move UninitializedObjectChecker out of 
alpha (authored by Szelethus, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58573?vs=194667&id=195937#toc

Repository:
  rC Clang

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

https://reviews.llvm.org/D58573

Files:
  docs/analyzer/checkers.rst
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h
  test/Analysis/cxx-uninitialized-object-inheritance.cpp
  test/Analysis/cxx-uninitialized-object-no-dereference.cpp
  test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
  test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
  test/Analysis/cxx-uninitialized-object-unguarded-access.cpp
  test/Analysis/cxx-uninitialized-object-unionlike-constructs.cpp
  test/Analysis/cxx-uninitialized-object.cpp
  test/Analysis/objcpp-uninitialized-object.mm
  www/analyzer/alpha_checks.html
  www/analyzer/available_checks.html

Index: include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -493,6 +493,43 @@
 
 let ParentPackage = CplusplusOptIn in {
 
+def UninitializedObjectChecker: Checker<"UninitializedObject">,
+  HelpText<"Reports uninitialized fields after object construction">,
+  CheckerOptions<[
+CmdLineOption,
+CmdLineOption,
+CmdLineOption,
+CmdLineOption,
+CmdLineOption
+  ]>,
+  Documentation;
+
 def VirtualCallChecker : Checker<"VirtualCall">,
   HelpText<"Check virtual function calls during construction or destruction">,
   CheckerOptions<[
@@ -536,43 +573,6 @@
   Dependencies<[IteratorModeling]>,
   Documentation;
 
-def UninitializedObjectChecker: Checker<"UninitializedObject">,
-  HelpText<"Reports uninitialized fields after object construction">,
-  CheckerOptions<[
-CmdLineOption,
-CmdLineOption,
-CmdLineOption,
-CmdLineOption,
-CmdLineOption
-  ]>,
-  Documentation;
-
 } // end: "alpha.cplusplus"
 
 
Index: test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
===
--- test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
+++ test/Analysis/cxx-uninitialized-object-ptr-ref.cpp
@@ -1,10 +1,10 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
-// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:Pedantic=true -DPEDANTIC \
+// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
 // RUN:   -std=c++11 -verify  %s
 
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
 // RUN:   -std=c++11 -verify  %s
 
 //===--===//
Index: test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
===
--- test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
+++ test/Analysis/cxx-uninitialized-object-notes-as-warnings.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject \
-// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:NotesAsWarnings=true \
-// RUN:   -analyzer-config alpha.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject \
+// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:NotesAsWarnings=true \
+// RUN:   -analyzer-config optin.cplusplus.UninitializedObject:CheckPointeeInitialization=true \
 // RUN:   -std=c++11 -verify %s
 
 class NotesAsWarningsTest {
Index: test/Analysis/objcpp-uninitialized-object.mm
===
--- test/Analysis/objcpp-uninitialized-object.mm
+++ test/Analysis/objcpp-uninitialized-object.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,optin.cplusplus.UninitializedObject -std=c++11 -fblocks -verify %s
 
 typedef void (^myBlock) ();
 
Index: test/Analysis/cxx-uninitialized-object.cpp

Re: r358724 - Add header guard to Reusables.h [NFC]

2019-04-19 Thread Artem Dergachev via cfe-commits

Whoops, thanks!

On 4/18/19 5:42 PM, Ali Tamur via cfe-commits wrote:

Author: tamur
Date: Thu Apr 18 17:42:54 2019
New Revision: 358724

URL: http://llvm.org/viewvc/llvm-project?rev=358724&view=rev
Log:
Add header guard to Reusables.h [NFC]

Modified:
 cfe/trunk/unittests/StaticAnalyzer/Reusables.h

Modified: cfe/trunk/unittests/StaticAnalyzer/Reusables.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/StaticAnalyzer/Reusables.h?rev=358724&r1=358723&r2=358724&view=diff
==
--- cfe/trunk/unittests/StaticAnalyzer/Reusables.h (original)
+++ cfe/trunk/unittests/StaticAnalyzer/Reusables.h Thu Apr 18 17:42:54 2019
@@ -6,6 +6,9 @@
  //
  
//===--===//
  
+#ifndef LLVM_CLANG_UNITTESTS_STATICANALYZER_REUSABLES_H

+#define LLVM_CLANG_UNITTESTS_STATICANALYZER_REUSABLES_H
+
  #include "clang/ASTMatchers/ASTMatchFinder.h"
  #include "clang/Frontend/CompilerInstance.h"
  #include "clang/CrossTU/CrossTranslationUnit.h"
@@ -56,3 +59,5 @@ public:
  
  } // namespace ento

  } // namespace clang
+
+#endif


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


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


[PATCH] D60930: [codeview] Fix symbol names for dynamic initializers and atexit stubs

2019-04-19 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.
rnk added reviewers: rsmith, rjmccall, jyu2.
Herald added a subscriber: aprantl.
Herald added a project: clang.

Add a new variant to GlobalDecl for these so that we can detect them
more easily during debug info emission and handle them appropriately.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D60930

Files:
  clang/include/clang/AST/GlobalDecl.h
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp

Index: clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
===
--- clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
+++ clang/test/CodeGenCXX/debug-info-global-ctor-dtor.cpp
@@ -2,11 +2,14 @@
 // RUN: | FileCheck %s --check-prefix=CHECK-NOKEXT
 // RUN: %clang_cc1 %s -debug-info-kind=limited -triple %itanium_abi_triple -fno-use-cxa-atexit -fapple-kext -S -disable-O0-optnone -emit-llvm -o - \
 // RUN: | FileCheck %s --check-prefix=CHECK-KEXT
+// RUN: %clang_cc1 %s -gcodeview -debug-info-kind=limited -triple x86_64-windows-msvc -fno-use-cxa-atexit -S -disable-O0-optnone  -emit-llvm -o - \
+// RUN: | FileCheck %s --check-prefix=CHECK-MSVC
 
 class A {
- public:
-  A() {}
-  virtual ~A() {}
+public:
+  A();
+  A(int x);
+  virtual ~A();
 };
 
 A glob;
@@ -16,12 +19,35 @@
   static A stat;
 }
 
-// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 12,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 12,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 13,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 13,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 13,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
-// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+template 
+struct FooTpl {
+  template 
+  static A sdm_tpl;
+};
+template 
+template 
+A FooTpl::sdm_tpl(sizeof(U) + sizeof(T));
+template A FooTpl::sdm_tpl;
+
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init",{{.*}} line: 15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_glob",{{.*}} line: 15,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_var_init.1",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor_array",{{.*}} line: 16,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-NOKEXT: !DISubprogram(name: "__dtor__ZZ3foovE4stat",{{.*}} line: 19,{{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 // CHECK-NOKEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
 
 // CHECK-KEXT: !DISubprogram({{.*}} DISPFlagLocalToUnit | DISPFlagDefinition
+
+// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'glob'",{{.*}} line: 15,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic initializer for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "__cxx_global_array_dtor",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'array'",{{.*}} line: 16,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "`dynamic atexit destructor for 'stat'",{{.*}} line: 19,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+
+// MSVC does weird stuff when templates are involved, so we don't match exactly,
+// but these names are reasonable.
+// FIXME: These should not be marked DISPFlagLocalToUnit.
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic initializer for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
+// CHECK-MSVC: !DISubprogram(name: "FooTpl::`dynamic atexit destructor for 'sdm_tpl'",{{.*}} line: 29,{{.*}}: DISPFlagLocalToUnit | DISPFlagDefinition
Index: clang/lib/CodeGen/CGDeclCXX.cpp
===
--- clang/lib/CodeGen/CGDeclCXX.cpp
+++ clang/lib/CodeGen/CGDeclCXX.cpp
@@ -226,13 +226,13 @@
   }
 
   const CGFunctionInfo &FI = CGM.getTypes().arrangeNullaryFunction();
-  llvm::Function *fn = CGM.CreateGlobalInitOrDestructFunction(ty, FnName.str(),
-  FI,
-   

[PATCH] D59712: [APSInt][OpenMP] Fix isNegative, etc. for unsigned types

2019-04-19 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel accepted this revision.
hfinkel added a comment.
This revision is now accepted and ready to land.

In D59712#1473223 , @jdenny wrote:

> In D59712#1469392 , @lebedev.ri 
> wrote:
>
> > Does this pass `check-all`? `check-all` of stage-2? test-suite?
>
>
> For me, all these tests behave with the current patch.  As before, the only 
> subproject I did not build was llgo.


Great. LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59712



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


[PATCH] D60900: [ObjC][ARC] Check the basic block size before calling DominatorTree::dominate

2019-04-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 195951.
ahatanak added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix the comment on why we have to check the size of the basic block before 
calling DominatorTree::dominate to compute the dominance relation between two 
instructions in the same basic block.


Repository:
  rC Clang

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

https://reviews.llvm.org/D60900

Files:
  lib/Transforms/ObjCARC/ObjCARCContract.cpp
  test/Transforms/ObjCARC/contract-max-bb-size.ll


Index: test/Transforms/ObjCARC/contract-max-bb-size.ll
===
--- /dev/null
+++ test/Transforms/ObjCARC/contract-max-bb-size.ll
@@ -0,0 +1,17 @@
+; RUN: opt -objc-arc-contract -S < %s | FileCheck -check-prefix=ENABLE %s
+; RUN: opt -objc-arc-contract -arc-contract-max-bb-size=3 -S < %s | FileCheck 
-check-prefix=DISABLE %s
+
+@g0 = common global i8* null, align 8
+
+; ENABLE: store i8* %2, i8** @g0
+; DISABLE: store i8* %1, i8** @g0
+
+define void @foo0() {
+  %1 = tail call i8* @foo1()
+  %2 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
+  store i8* %1, i8** @g0, align 8
+  ret void
+}
+
+declare i8* @foo1()
+declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
Index: lib/Transforms/ObjCARC/ObjCARCContract.cpp
===
--- lib/Transforms/ObjCARC/ObjCARCContract.cpp
+++ lib/Transforms/ObjCARC/ObjCARCContract.cpp
@@ -45,6 +45,10 @@
 STATISTIC(NumPeeps,   "Number of calls peephole-optimized");
 STATISTIC(NumStoreStrongs, "Number objc_storeStrong calls formed");
 
+static cl::opt MaxBBSize("arc-contract-max-bb-size", cl::Hidden,
+cl::desc("Maximum basic block size to discover the dominance relation of "
+ "two instructions in the same basic block"), cl::init(65535));
+
 
//===--===//
 //Declarations
 
//===--===//
@@ -573,6 +577,24 @@
   // reduces register pressure.
   SmallPtrSet DependingInstructions;
   SmallPtrSet Visited;
+
+  // Cache the basic block size.
+  DenseMap BBSizeMap;
+
+  // A lambda that lazily computes the size of a basic block and determines
+  // whether the size exceeds MaxBBSize.
+  auto IsLargeBB = [&](const BasicBlock *BB) {
+unsigned BBSize;
+auto I = BBSizeMap.find(BB);
+
+if (I != BBSizeMap.end())
+  BBSize = I->second;
+else
+  BBSize = BBSizeMap[BB] = BB->size();
+
+return BBSize > MaxBBSize;
+  };
+
   for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E;) {
 Instruction *Inst = &*I++;
 
@@ -590,7 +612,7 @@
 // and such; to do the replacement, the argument must have type i8*.
 
 // Function for replacing uses of Arg dominated by Inst.
-auto ReplaceArgUses = [Inst, this](Value *Arg) {
+auto ReplaceArgUses = [Inst, IsLargeBB, this](Value *Arg) {
   // If we're compiling bugpointed code, don't get in trouble.
   if (!isa(Arg) && !isa(Arg))
 return;
@@ -602,6 +624,17 @@
 Use &U = *UI++;
 unsigned OperandNo = U.getOperandNo();
 
+// Don't replace the uses if Inst and the user belong to the same basic
+// block and the size of the basic block is large. We don't want to 
call
+// DominatorTree::dominate in that case. We can remove this check if we
+// can use OrderedBasicBlock to compute the dominance relation between
+// two instructions, but that's not currently possible since it doesn't
+// recompute the instruction ordering when new instructions are 
inserted
+// to the basic block.
+if (Inst->getParent() == cast(U.getUser())->getParent() &&
+IsLargeBB(Inst->getParent()))
+  continue;
+
 // If the call's return value dominates a use of the call's argument
 // value, rewrite the use to use the return value. We check for
 // reachability here because an unreachable call is considered to


Index: test/Transforms/ObjCARC/contract-max-bb-size.ll
===
--- /dev/null
+++ test/Transforms/ObjCARC/contract-max-bb-size.ll
@@ -0,0 +1,17 @@
+; RUN: opt -objc-arc-contract -S < %s | FileCheck -check-prefix=ENABLE %s
+; RUN: opt -objc-arc-contract -arc-contract-max-bb-size=3 -S < %s | FileCheck -check-prefix=DISABLE %s
+
+@g0 = common global i8* null, align 8
+
+; ENABLE: store i8* %2, i8** @g0
+; DISABLE: store i8* %1, i8** @g0
+
+define void @foo0() {
+  %1 = tail call i8* @foo1()
+  %2 = tail call i8* @llvm.objc.retainAutoreleasedReturnValue(i8* %1)
+  store i8* %1, i8** @g0, align 8
+  ret void
+}
+
+declare i8* @foo1()
+declare i8* @llvm.objc.retainAutoreleasedReturnValue(i8*)
Index: lib/Transforms/ObjCARC/ObjCARCContract.cpp
===

[PATCH] D56571: [RFC prototype] Implementation of asm-goto support in clang

2019-04-19 Thread James Y Knight via Phabricator via cfe-commits
jyknight added a comment.

There shouldn't be an empty string ("") in the asm output -- that should be a 
reference to the "l_yes" label, not the empty string. That seems very weird...

Even odder: running clang -S on the above without -fno-integrated-as emits a 
".quad .Ltmp00" (note the extra "0"!), while with -fno-integrated-as, it 
properly refers to ".Ltmp0".


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

https://reviews.llvm.org/D56571



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


[PATCH] D60408: [LibTooling] Extend Transformer to support multiple simultaneous changes.

2019-04-19 Thread Tianle Liu via Phabricator via cfe-commits
liutianle added a comment.

hi ymandel,

When I run "check-all", there are some warning/error in TransformerTest.cpp as 
follow. My version is llvm:0ee120077 and clang:d87ee8e678. Could you please 
have a fix or guild me how to fix it?


In file included from 
myLLVM/llvm/utils/unittest/googlemock/include/gmock/internal/gmock-internal-utils.h:47:0,

  from myLLVM/llvm/utils/unittest/googlemock/include/gmock/gmock-actions.h:46,
  from myLLVM/llvm/utils/unittest/googlemock/include/gmock/gmock.h:58,
  from myLLVM/llvm/tools/clang/unittests/Tooling/TransformerTest.cpp:13:

myLLVM/llvm/utils/unittest/googletest/include/gtest/gtest.h: In instantiation 
of 'testing::AssertionResult testing::internal::CmpHelperEQ(const char*, const 
char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = int]':
myLLVM/llvm/utils/unittest/googletest/include/gtest/gtest.h:1421:23:   required 
from 'static testing::AssertionResult 
testing::internal::EqHelper::Compare(const char*, const 
char*, const T1&, const T2&) [with T1 = long unsigned int; T2 = int; bool 
lhs_is_null_literal = false]'
myLLVM/llvm/tools/clang/unittests/Tooling/TransformerTest.cpp:372:3:   required 
from here
myLLVM/llvm/utils/unittest/googletest/include/gtest/gtest.h:1392:11: warning: 
comparison between signed and unsigned integer expressions [-Wsign-compare]

  if (lhs == rhs) {
  ^

--


Repository:
  rL LLVM

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

https://reviews.llvm.org/D60408



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


[PATCH] D59712: [APSInt][OpenMP] Fix isNegative, etc. for unsigned types

2019-04-19 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

The `APSInt.h` itself looks good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59712



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