r365873 - [test] Delete trailing spaces from YAML tests

2019-07-11 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Jul 11 22:59:28 2019
New Revision: 365873

URL: http://llvm.org/viewvc/llvm-project?rev=365873=rev
Log:
[test] Delete trailing spaces from YAML tests

Modified:
cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp
cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp
cfe/trunk/unittests/Tooling/RefactoringTest.cpp
cfe/trunk/unittests/Tooling/ReplacementsYamlTest.cpp

Modified: cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp?rev=365873=365872=365873=diff
==
--- cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/DiagnosticsYamlTest.cpp Thu Jul 11 22:59:28 2019
@@ -42,34 +42,34 @@ static Diagnostic makeDiagnostic(StringR
 static const char *YAMLContent =
 "---\n"
 "MainSourceFile:  'path/to/source.cpp'\n"
-"Diagnostics: \n"
+"Diagnostics:\n"
 "  - DiagnosticName:  'diagnostic#1\'\n"
-"DiagnosticMessage: \n"
+"DiagnosticMessage:\n"
 "  Message: 'message #1'\n"
 "  FilePath:'path/to/source.cpp'\n"
 "  FileOffset:  55\n"
-"  Replacements:\n"
+"  Replacements:\n"
 "- FilePath:'path/to/source.cpp'\n"
 "  Offset:  100\n"
 "  Length:  12\n"
 "  ReplacementText: 'replacement #1'\n"
 "  - DiagnosticName:  'diagnostic#2'\n"
-"DiagnosticMessage: \n"
+"DiagnosticMessage:\n"
 "  Message: 'message #2'\n"
 "  FilePath:'path/to/header.h'\n"
 "  FileOffset:  60\n"
-"  Replacements:\n"
+"  Replacements:\n"
 "- FilePath:'path/to/header.h'\n"
 "  Offset:  62\n"
 "  Length:  2\n"
 "  ReplacementText: 'replacement #2'\n"
 "  - DiagnosticName:  'diagnostic#3'\n"
-"DiagnosticMessage: \n"
+"DiagnosticMessage:\n"
 "  Message: 'message #3'\n"
 "  FilePath:'path/to/source2.cpp'\n"
 "  FileOffset:  72\n"
 "  Replacements:[]\n"
-"Notes:   \n"
+"Notes:\n"
 "  - Message: Note1\n"
 "FilePath:'path/to/note1.cpp'\n"
 "FileOffset:  88\n"

Modified: cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp?rev=365873=365872=365873=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringActionRulesTest.cpp Thu Jul 11 
22:59:28 2019
@@ -118,7 +118,7 @@ TEST_F(RefactoringActionRulesTest, MyFir
  "Error:   ''\n"
  "InsertedHeaders: []\n"
  "RemovedHeaders:  []\n"
- "Replacements:\n" // Extra whitespace here!
+ "Replacements:\n"
  "  - FilePath:input.cpp\n"
  "Offset:  30\n"
  "Length:  1\n"

Modified: cfe/trunk/unittests/Tooling/RefactoringTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Tooling/RefactoringTest.cpp?rev=365873=365872=365873=diff
==
--- cfe/trunk/unittests/Tooling/RefactoringTest.cpp (original)
+++ cfe/trunk/unittests/Tooling/RefactoringTest.cpp Thu Jul 11 22:59:28 2019
@@ -1122,11 +1122,11 @@ TEST_F(AtomicChangeTest, AtomicChangeToY
"Key: 'input.cpp:20'\n"
"FilePath:input.cpp\n"
"Error:   ''\n"
-   "InsertedHeaders: \n" // Extra whitespace here!
+   "InsertedHeaders:\n"
"  - a.h\n"
-   "RemovedHeaders:  \n" // Extra whitespace here!
+   "RemovedHeaders:\n"
"  - b.h\n"
-   "Replacements:\n" // Extra whitespace here!
+   "Replacements:\n"
"  - FilePath:input.cpp\n"
"Offset:  20\n"
"Length:  0\n"
@@ -1144,11 +1144,11 @@ TEST_F(AtomicChangeTest, YAMLToAtomicCha
 "Key: 'input.cpp:20'\n"
 "FilePath:input.cpp\n"
 "Error:   'ok'\n"
-"InsertedHeaders: \n" // Extra whitespace here!
+"InsertedHeaders:\n"
 "  - a.h\n"
-"RemovedHeaders:  \n" // Extra whitespace here!
+"RemovedHeaders:\n"

r365872 - test/Driver/fsanitize.c: delete -target x86_64-linux-gnu from tests that should always be available

2019-07-11 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Jul 11 22:51:36 2019
New Revision: 365872

URL: http://llvm.org/viewvc/llvm-project?rev=365872=rev
Log:
test/Driver/fsanitize.c: delete -target x86_64-linux-gnu from tests that should 
always be available

Follow-up of D64317/r365587.

Modified:
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=365872=365871=365872=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Thu Jul 11 22:51:36 2019
@@ -30,13 +30,13 @@
 // RUN: %clang -target x86_64-pc-win32 -fsanitize-coverage=bb %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-COVERAGE-WIN64
 // CHECK-COVERAGE-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib"
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=integer %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-INTEGER 
-implicit-check-not="-fsanitize-address-use-after-scope"
+// RUN: %clang -target %itanium_abi_triple -fsanitize=integer %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-INTEGER 
-implicit-check-not="-fsanitize-address-use-after-scope"
 // CHECK-INTEGER: 
"-fsanitize={{((signed-integer-overflow|unsigned-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){8}"}}
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion %s -### 
2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion 
-fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion 
-fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=implicit-conversion 
-fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP
+// RUN: %clang -fsanitize=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
+// RUN: %clang -fsanitize=implicit-conversion 
-fsanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-RECOVER
+// RUN: %clang -fsanitize=implicit-conversion 
-fno-sanitize-recover=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-NORECOVER
+// RUN: %clang -fsanitize=implicit-conversion 
-fsanitize-trap=implicit-conversion %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-conversion,CHECK-implicit-conversion-TRAP
 // CHECK-implicit-conversion: 
"-fsanitize={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
 // CHECK-implicit-conversion-RECOVER: 
"-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
 // CHECK-implicit-conversion-RECOVER-NOT: 
"-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
@@ -48,10 +48,10 @@
 // CHECK-implicit-conversion-TRAP-NOT: 
"-fsanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
 // CHECK-implicit-conversion-TRAP-NOT: 
"-fno-sanitize-recover={{((implicit-unsigned-integer-truncation|implicit-signed-integer-truncation|implicit-integer-sign-change),?){3}"}}
 
-// RUN: %clang -target x86_64-linux-gnu 
-fsanitize=implicit-integer-arithmetic-value-change %s -### 2>&1 | FileCheck %s 
--check-prefixes=CHECK-implicit-integer-arithmetic-value-change,CHECK-implicit-integer-arithmetic-value-change-RECOVER
-// RUN: %clang -target x86_64-linux-gnu 
-fsanitize=implicit-integer-arithmetic-value-change 
-fsanitize-recover=implicit-integer-arithmetic-value-change %s -### 2>&1 | 
FileCheck %s 
--check-prefixes=CHECK-implicit-integer-arithmetic-value-change,CHECK-implicit-integer-arithmetic-value-change-RECOVER
-// RUN: %clang -target x86_64-linux-gnu 
-fsanitize=implicit-integer-arithmetic-value-change 
-fno-sanitize-recover=implicit-integer-arithmetic-value-change %s -### 2>&1 | 
FileCheck %s 
--check-prefixes=CHECK-implicit-integer-arithmetic-value-change,CHECK-implicit-integer-arithmetic-value-change-NORECOVER
-// RUN: %clang -target x86_64-linux-gnu 
-fsanitize=implicit-integer-arithmetic-value-change 
-fsanitize-trap=implicit-integer-arithmetic-value-change %s -### 2>&1 | 
FileCheck %s 

[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

2019-07-11 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.

The `impure-warning` sounds like some alpha, not-well-defined warning, other 
than that I like the movement to rethink existing checkers.


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

https://reviews.llvm.org/D64274



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


[PATCH] D64614: [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/docs/clangd/Features.rst:264
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+

Should I perhaps change type hierarchy's entry in the LSP column from "No" to 
"Proposed"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64614



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


[PATCH] D64614: [clangd] Mark type hierarchy as a supported feature in the docs

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64614

Files:
  clang-tools-extra/docs/clangd/Features.rst


Index: clang-tools-extra/docs/clangd/Features.rst
===
--- clang-tools-extra/docs/clangd/Features.rst
+++ clang-tools-extra/docs/clangd/Features.rst
@@ -261,7 +261,7 @@
 +-++--+
 | Call hierarchy  | No |   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+
 | Organize Includes   | No |   No |
 +-++--+


Index: clang-tools-extra/docs/clangd/Features.rst
===
--- clang-tools-extra/docs/clangd/Features.rst
+++ clang-tools-extra/docs/clangd/Features.rst
@@ -261,7 +261,7 @@
 +-++--+
 | Call hierarchy  | No |   No |
 +-++--+
-| Type hierarchy  | No |   No |
+| Type hierarchy  | No |   Yes|
 +-++--+
 | Organize Includes   | No |   No |
 +-++--+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64613: [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

This is an issue I noticed while writing the unit test for D64308 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64613



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


[PATCH] D64308: [clangd] Implement typeHierarchy/resolve for subtypes

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge marked an inline comment as done.
nridge added inline comments.



Comment at: clang-tools-extra/clangd/test/type-hierarchy.test:1
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}

sammccall wrote:
> Please add a unit test to TypeHierarchyTests.
> 
> I'm on the fence about having a lit test: it's a new LSP method, though the 
> binding is pretty simple.
> But features that are **only** covered by lit tests are too painful to 
> maintain.
As I've already written the lit test, I think there's little harm in keeping it.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64308



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


[PATCH] D64613: [clangd] Type hierarchy: don't resolve parents if the client only asked for children

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
nridge created this revision.
nridge added a reviewer: sammccall.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64613

Files:
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp


Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -630,7 +630,8 @@
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
 Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
ParentsNotResolved(), ChildrenNotResolved();
 
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1134,9 +1134,9 @@
 
 static Optional
 getTypeAncestors(const CXXRecordDecl , ASTContext ,
- RecursionProtectionSet ) {
+ RecursionProtectionSet , bool ResolveParents = true) {
   Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
+  if (!Result || !ResolveParents)
 return Result;
 
   Result->parents.emplace();
@@ -1232,8 +1232,10 @@
 return llvm::None;
 
   RecursionProtectionSet RPSet;
+  bool ResolveParents = (Direction == TypeHierarchyDirection::Parents ||
+ Direction == TypeHierarchyDirection::Both);
   Optional Result =
-  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet, ResolveParents);
   if (!Result)
 return Result;
 


Index: clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
===
--- clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -630,7 +630,8 @@
   ASSERT_TRUE(bool(Result));
   EXPECT_THAT(
   *Result,
-  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct), Parents(),
+  AllOf(WithName("Parent"), WithKind(SymbolKind::Struct),
+ParentsNotResolved(),
 Children(AllOf(WithName("Child1"), WithKind(SymbolKind::Struct),
ParentsNotResolved(), ChildrenNotResolved();
 
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -1134,9 +1134,9 @@
 
 static Optional
 getTypeAncestors(const CXXRecordDecl , ASTContext ,
- RecursionProtectionSet ) {
+ RecursionProtectionSet , bool ResolveParents = true) {
   Optional Result = declToTypeHierarchyItem(ASTCtx, CXXRD);
-  if (!Result)
+  if (!Result || !ResolveParents)
 return Result;
 
   Result->parents.emplace();
@@ -1232,8 +1232,10 @@
 return llvm::None;
 
   RecursionProtectionSet RPSet;
+  bool ResolveParents = (Direction == TypeHierarchyDirection::Parents ||
+ Direction == TypeHierarchyDirection::Both);
   Optional Result =
-  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet, ResolveParents);
   if (!Result)
 return Result;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64308: [clangd] Implement typeHierarchy/resolve for subtypes

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
nridge marked 3 inline comments as done.
Closed by commit rL365867: [clangd] Implement typeHierarchy/resolve for 
subtypes (authored by nridge, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64308?vs=208318=209406#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64308

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdLSPServer.h
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/Protocol.cpp
  clang-tools-extra/trunk/clangd/Protocol.h
  clang-tools-extra/trunk/clangd/XRefs.cpp
  clang-tools-extra/trunk/clangd/XRefs.h
  clang-tools-extra/trunk/clangd/test/type-hierarchy.test
  clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Index: clang-tools-extra/trunk/clangd/XRefs.h
===
--- clang-tools-extra/trunk/clangd/XRefs.h
+++ clang-tools-extra/trunk/clangd/XRefs.h
@@ -141,6 +141,10 @@
 ParsedAST , Position Pos, int Resolve, TypeHierarchyDirection Direction,
 const SymbolIndex *Index = nullptr, PathRef TUPath = PathRef{});
 
+void resolveTypeHierarchy(TypeHierarchyItem , int ResolveLevels,
+  TypeHierarchyDirection Direction,
+  const SymbolIndex *Index);
+
 /// Retrieves the deduced type at a given location (auto, decltype).
 /// Retuns None unless SourceLocationBeg starts an auto/decltype token.
 /// It will return the underlying type.
Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h
@@ -100,6 +100,8 @@
Callback>);
   void onTypeHierarchy(const TypeHierarchyParams &,
Callback>);
+  void onResolveTypeHierarchy(const ResolveTypeHierarchyItemParams &,
+  Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
   void onSymbolInfo(const TextDocumentPositionParams &,
 Callback>);
Index: clang-tools-extra/trunk/clangd/Protocol.cpp
===
--- clang-tools-extra/trunk/clangd/Protocol.cpp
+++ clang-tools-extra/trunk/clangd/Protocol.cpp
@@ -422,8 +422,7 @@
 bool fromJSON(const llvm::json::Value ,
   DocumentRangeFormattingParams ) {
   llvm::json::ObjectMapper O(Params);
-  return O && O.map("textDocument", R.textDocument) &&
- O.map("range", R.range);
+  return O && O.map("textDocument", R.textDocument) && O.map("range", R.range);
 }
 
 bool fromJSON(const llvm::json::Value ,
@@ -445,8 +444,8 @@
 
 llvm::json::Value toJSON(const DiagnosticRelatedInformation ) {
   return llvm::json::Object{
-{"location", DRI.location},
-{"message", DRI.message},
+  {"location", DRI.location},
+  {"message", DRI.message},
   };
 }
 
@@ -978,6 +977,8 @@
 Result["parents"] = I.parents;
   if (I.children)
 Result["children"] = I.children;
+  if (I.data)
+Result["data"] = I.data;
   return std::move(Result);
 }
 
@@ -996,10 +997,18 @@
   O.map("deprecated", I.deprecated);
   O.map("parents", I.parents);
   O.map("children", I.children);
+  O.map("data", I.data);
 
   return true;
 }
 
+bool fromJSON(const llvm::json::Value ,
+  ResolveTypeHierarchyItemParams ) {
+  llvm::json::ObjectMapper O(Params);
+  return O && O.map("item", P.item) && O.map("resolve", P.resolve) &&
+ O.map("direction", P.direction);
+}
+
 bool fromJSON(const llvm::json::Value , ReferenceParams ) {
   TextDocumentPositionParams  = R;
   return fromJSON(Params, Base);
Index: clang-tools-extra/trunk/clangd/test/type-hierarchy.test
===
--- clang-tools-extra/trunk/clangd/test/type-hierarchy.test
+++ clang-tools-extra/trunk/clangd/test/type-hierarchy.test
@@ -1,7 +1,7 @@
 # RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct Parent {};\nstruct Child1 : Parent {};\nstruct Child2 : Child1 {};\nstruct Child3 : Child2 {};"}}}
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1,"text":"struct Parent {};\nstruct Child1 : Parent {};\nstruct Child2 : Child1 {};\nstruct Child3 : Child2 {};\nstruct Child4 : Child3 {};"}}}
 ---
 

[clang-tools-extra] r365867 - [clangd] Implement typeHierarchy/resolve for subtypes

2019-07-11 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Thu Jul 11 20:26:32 2019
New Revision: 365867

URL: http://llvm.org/viewvc/llvm-project?rev=365867=rev
Log:
[clangd] Implement typeHierarchy/resolve for subtypes

Summary:
This allows the client to resolve subtypes one level at a time.

For supertypes, this is not necessary, because we eagerly compute
supertypes and return all levels.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
clang-tools-extra/trunk/clangd/ClangdLSPServer.h
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/Protocol.cpp
clang-tools-extra/trunk/clangd/Protocol.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/XRefs.h
clang-tools-extra/trunk/clangd/test/type-hierarchy.test
clang-tools-extra/trunk/clangd/unittests/TypeHierarchyTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=365867=365866=365867=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Thu Jul 11 20:26:32 2019
@@ -926,6 +926,13 @@ void ClangdLSPServer::onTypeHierarchy(
 Params.resolve, Params.direction, std::move(Reply));
 }
 
+void ClangdLSPServer::onResolveTypeHierarchy(
+const ResolveTypeHierarchyItemParams ,
+Callback> Reply) {
+  Server->resolveTypeHierarchy(Params.item, Params.resolve, Params.direction,
+   std::move(Reply));
+}
+
 void ClangdLSPServer::applyConfiguration(
 const ConfigurationSettings ) {
   // Per-file update to the compilation database.
@@ -1021,6 +1028,7 @@ ClangdLSPServer::ClangdLSPServer(
   MsgHandler->bind("workspace/didChangeConfiguration", 
::onChangeConfiguration);
   MsgHandler->bind("textDocument/symbolInfo", ::onSymbolInfo);
   MsgHandler->bind("textDocument/typeHierarchy", 
::onTypeHierarchy);
+  MsgHandler->bind("typeHierarchy/resolve", 
::onResolveTypeHierarchy);
   // clang-format on
 }
 

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.h?rev=365867=365866=365867=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.h Thu Jul 11 20:26:32 2019
@@ -100,6 +100,8 @@ private:
Callback>);
   void onTypeHierarchy(const TypeHierarchyParams &,
Callback>);
+  void onResolveTypeHierarchy(const ResolveTypeHierarchyItemParams &,
+  Callback>);
   void onChangeConfiguration(const DidChangeConfigurationParams &);
   void onSymbolInfo(const TextDocumentPositionParams &,
 Callback>);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=365867=365866=365867=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Thu Jul 11 20:26:32 2019
@@ -101,8 +101,7 @@ ClangdServer::ClangdServer(const GlobalC
  : nullptr),
   GetClangTidyOptions(Opts.GetClangTidyOptions),
   SuggestMissingIncludes(Opts.SuggestMissingIncludes),
-  EnableHiddenFeatures(Opts.HiddenFeatures),
-  TweakFilter(Opts.TweakFilter),
+  EnableHiddenFeatures(Opts.HiddenFeatures), TweakFilter(Opts.TweakFilter),
   WorkspaceRoot(Opts.WorkspaceRoot),
   // Pass a callback into `WorkScheduler` to extract symbols from a newly
   // parsed file and rebuild the file index synchronously each time an AST
@@ -528,6 +527,13 @@ void ClangdServer::typeHierarchy(PathRef
   WorkScheduler.runWithAST("Type Hierarchy", File, Bind(Action, 
std::move(CB)));
 }
 
+void ClangdServer::resolveTypeHierarchy(
+TypeHierarchyItem Item, int Resolve, TypeHierarchyDirection Direction,
+Callback> CB) {
+  clangd::resolveTypeHierarchy(Item, Resolve, Direction, Index);
+  CB(Item);
+}
+
 void ClangdServer::onFileEvent(const DidChangeWatchedFilesParams ) {
   // FIXME: Do nothing for now. This will be used for indexing and potentially
   // invalidating other caches.

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=365867=365866=365867=diff
==
--- 

[PATCH] D63975: Warn when ScopeDepthOrObjCQuals overflows

2019-07-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:6587
+return;
+  }
+

Mordante wrote:
> rjmccall wrote:
> > Comment indentation.
> > 
> > Should we do this when starting to parse a function prototype instead of 
> > when parsing a parameter?
> Thanks I noticed I forgot to change the tabs to spaces.
> 
> I looked at your suggestion to move the code, but I think this is the proper 
> place. Now it also validates whether lambdas exceed the limit, else we need 
> to check at two places.
> I'll also add a unit test to test for the lambda.
I don't understand.  I'm just saying to put the check at the top of the 
function instead of inside the loop.


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

https://reviews.llvm.org/D63975



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


[PATCH] D61809: [BPF] Preserve debuginfo array/union/struct type/access index

2019-07-11 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

The followup patch for this change is at https://reviews.llvm.org/D64598.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61809



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


[PATCH] D64400: [OpenCL][PR42390] Deduce addr space for templ specialization

2019-07-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

There are some code paths that I think are common between the parser and 
template instantiation, like `BuildPointerType` and `BuildReferenceType`, but 
if you want to do context-sensitive inference that might not be good enough.


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

https://reviews.llvm.org/D64400



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


[PATCH] D62584: [OpenCL][PR42033] Deducing addr space with template parameter types

2019-07-11 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/TreeTransform.h:5363
+if (ResultType.getAddressSpace() != LangAS::Default &&
+(ResultType.getAddressSpace() != LangAS::opencl_private)) {
   SemaRef.Diag(TL.getReturnLoc().getBeginLoc(),

Anastasia wrote:
> rjmccall wrote:
> > Anastasia wrote:
> > > Anastasia wrote:
> > > > rjmccall wrote:
> > > > > Anastasia wrote:
> > > > > > I am trying to be a bit more helpful here although I am not sure if 
> > > > > > we should instead require explicit template parameter and fail the 
> > > > > > template deduction instead.
> > > > > > 
> > > > > > Basically, do we want the following code to always require 
> > > > > > specifying template argument explicitly:
> > > > > > 
> > > > > > 
> > > > > > ```
> > > > > > template 
> > > > > > T xxx(T *in) {
> > > > > >   T *i = in;
> > > > > >   return *i;
> > > > > > }
> > > > > > 
> > > > > > __kernel void test() {
> > > > > >   int foo[10];
> > > > > >   xxx([0]); // if we deduce type from foo, it ends up 
> > > > > > being qualified by __private that we currently diagnose. However 
> > > > > > private is default (implicit) address space for return type so 
> > > > > > technically there is no danger in just allowing xxx([0])
> > > > > > }
> > > > > > ```
> > > > > Implicitly ignoring all address-space qualifiers on the return type 
> > > > > seems like the right thing to do; I don't think it needs to be 
> > > > > limited to `__private`.  That's probably also the right thing to do 
> > > > > for locals, but I'm less certain about it.
> > > > Just to clarify by "Implicitly ignoring" you mean ignoring if the templ 
> > > > parameters were deduced?
> > > > 
> > > > Although I am a bit concerned about allowing other than `__private` 
> > > > address spaces in return types as we reject them in return types of 
> > > > functions generally. Would it not be somehow inconsistent?
> > > Ok, I have removed the diagnostic completely. At least we don't seem to 
> > > generate any incorrect IR.
> > They should be diagnosed somehow when written explicitly on a return type, 
> > but if you just do that on the parser path you don't have to worry about it 
> > during template instantiation.  They should probably otherwise be ignored 
> > no matter where they came from — if someone typedefs `private_int_t` to 
> > `__private int`, you should just treat that as `int` in a return type.  
> > Stripping the qualifier from the type is probably the right thing to do so 
> > that it doesn't further impact semantic analysis.
> > 
> > I definitely don't think you want a model where the qualifier actually 
> > means that the return is somehow done via an object in that address space.
> > They should be diagnosed somehow when written explicitly on a return type, 
> > but if you just do that on the parser path you don't have to worry about it 
> > during template instantiation.
> 
> Ok, this seems to be working currently. The following won't compile:
> 
> ```
> template 
> struct S {
>   __global T f1(); // error: return value cannot be qualified with 
> address space
> };
> 
> ```
> 
> > They should probably otherwise be ignored no matter where they came from — 
> > if someone typedefs private_int_t to __private int, you should just treat 
> > that as int in a return type.
> 
> We produce diagnostic for this case currently. I can update this in a 
> separate patch if you think it's more helpful behavior. Although I feel a bit 
> worried about it. However it would align with what we are doing with 
> templates here... so perhaps it's logical change... 
> 
> > Stripping the qualifier from the type is probably the right thing to do so 
> > that it doesn't further impact semantic analysis.
> 
> I guess you mean stripping quals for the case of typedef or others where we 
> will accept the code and ignore quals on the return type? I have tried to do 
> this just for the template case but there are some assertions firing because 
> we are expecting the original return type to be the same before and after 
> template instantiation. So it feels like I would have to do it for everything 
> together. Maybe it should rather go into separate review?
> We produce diagnostic for this case currently. I can update this in a 
> separate patch if you think it's more helpful behavior. Although I feel a bit 
> worried about it. However it would align with what we are doing with 
> templates here... so perhaps it's logical change...

Well, it's debatable.  C doesn't say that qualifiers are erased in function 
return types in general.  On the other hand, qualifiers are semantically 
meaningless there, and C has few rules that rely on exact type identity.  On 
reflection, we should probably keep diagnosing that at parse-time, even for 
typedefs, and just ignore it in templates.

Can you point out which assertion is firing?


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


[PATCH] D56353: Replace cc1 options '-mdisable-fp-elim' and '-momit-leaf-frame-pointer' with'-mframe-pointer='

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This should be rebased after D64294 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D56353



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


[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365866: [X86][PowerPC] Support -mlong-double-128 (authored 
by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64277

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/lib/Basic/Targets/PPC.cpp
  cfe/trunk/lib/Basic/Targets/X86.h
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/CodeGen/ppc64-long-double.cpp
  cfe/trunk/test/CodeGen/x86-long-double.cpp
  cfe/trunk/test/Driver/mlong-double-128.c

Index: cfe/trunk/lib/Basic/Targets/X86.h
===
--- cfe/trunk/lib/Basic/Targets/X86.h
+++ cfe/trunk/lib/Basic/Targets/X86.h
@@ -133,6 +133,10 @@
 LongDoubleFormat = ::APFloat::x87DoubleExtended();
   }
 
+  const char *getLongDoubleMangling() const override {
+return LongDoubleFormat == ::APFloat::IEEEquad() ? "g" : "e";
+  }
+
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
 return SSELevel == NoSSE ? 2 : 0;
@@ -845,8 +849,6 @@
   : LinuxTargetInfo(Triple, Opts) {
 LongDoubleFormat = ::APFloat::IEEEquad();
   }
-
-  const char *getLongDoubleMangling() const override { return "g"; }
 };
 } // namespace targets
 } // namespace clang
Index: cfe/trunk/lib/Basic/Targets/PPC.cpp
===
--- cfe/trunk/lib/Basic/Targets/PPC.cpp
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp
@@ -465,6 +465,8 @@
   if (HasAltivec)
 Opts.AltiVec = 1;
   TargetInfo::adjust(Opts);
+  if (LongDoubleFormat != ::APFloat::IEEEdouble())
+LongDoubleFormat = ::APFloat::PPCDoubleDouble();
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {
Index: cfe/trunk/lib/Basic/TargetInfo.cpp
===
--- cfe/trunk/lib/Basic/TargetInfo.cpp
+++ cfe/trunk/lib/Basic/TargetInfo.cpp
@@ -373,10 +373,15 @@
 LongDoubleFormat = ::APFloat::IEEEquad();
   }
 
-  if (Opts.LongDoubleSize && Opts.LongDoubleSize == DoubleWidth) {
-LongDoubleWidth = DoubleWidth;
-LongDoubleAlign = DoubleAlign;
-LongDoubleFormat = DoubleFormat;
+  if (Opts.LongDoubleSize) {
+if (Opts.LongDoubleSize == DoubleWidth) {
+  LongDoubleWidth = DoubleWidth;
+  LongDoubleAlign = DoubleAlign;
+  LongDoubleFormat = DoubleFormat;
+} else if (Opts.LongDoubleSize == 128) {
+  LongDoubleWidth = LongDoubleAlign = 128;
+  LongDoubleFormat = ::APFloat::IEEEquad();
+}
   }
 
   if (Opts.NewAlignOverride)
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -4012,15 +4012,15 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
-TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
-} else {
+TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64())
+  A->render(Args, CmdArgs);
+else
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
-}
   }
 
   // Decide whether to use verbose asm. Verbose assembly is the default on
Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -2025,6 +2025,8 @@
   HelpText<"Generate branches with extended addressability, usually via 

r365866 - [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Jul 11 19:32:15 2019
New Revision: 365866

URL: http://llvm.org/viewvc/llvm-project?rev=365866=rev
Log:
[X86][PowerPC] Support -mlong-double-128

This patch makes the driver option -mlong-double-128 available for X86
and PowerPC. The CC1 option -mlong-double-128 is available on all targets
for users to test on unsupported targets.

On PowerPC, -mlong-double-128 uses the IBM extended double format
because we don't support -mabi=ieeelongdouble yet (D64283).

Reviewed By: rnk

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

Added:
cfe/trunk/test/Driver/mlong-double-128.c
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/PPC.cpp
cfe/trunk/lib/Basic/Targets/X86.h
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/CodeGen/ppc64-long-double.cpp
cfe/trunk/test/CodeGen/x86-long-double.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=365866=365865=365866=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Jul 11 19:32:15 2019
@@ -2025,6 +2025,8 @@ def mlong_calls : Flag<["-"], "mlong-cal
   HelpText<"Generate branches with extended addressability, usually via 
indirect jumps.">;
 def mlong_double_64 : Flag<["-"], "mlong-double-64">, Group, 
Flags<[CC1Option]>,
   HelpText<"Force long double to be 64 bits">;
+def mlong_double_128 : Flag<["-"], "mlong-double-128">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Force long double to be 128 bits">;
 def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,
   HelpText<"Restore the default behaviour of not generating long calls">;
 def mexecute_only : Flag<["-"], "mexecute-only">, Group,

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=365866=365865=365866=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Thu Jul 11 19:32:15 2019
@@ -373,10 +373,15 @@ void TargetInfo::adjust(LangOptions 
 LongDoubleFormat = ::APFloat::IEEEquad();
   }
 
-  if (Opts.LongDoubleSize && Opts.LongDoubleSize == DoubleWidth) {
-LongDoubleWidth = DoubleWidth;
-LongDoubleAlign = DoubleAlign;
-LongDoubleFormat = DoubleFormat;
+  if (Opts.LongDoubleSize) {
+if (Opts.LongDoubleSize == DoubleWidth) {
+  LongDoubleWidth = DoubleWidth;
+  LongDoubleAlign = DoubleAlign;
+  LongDoubleFormat = DoubleFormat;
+} else if (Opts.LongDoubleSize == 128) {
+  LongDoubleWidth = LongDoubleAlign = 128;
+  LongDoubleFormat = ::APFloat::IEEEquad();
+}
   }
 
   if (Opts.NewAlignOverride)

Modified: cfe/trunk/lib/Basic/Targets/PPC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/PPC.cpp?rev=365866=365865=365866=diff
==
--- cfe/trunk/lib/Basic/Targets/PPC.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/PPC.cpp Thu Jul 11 19:32:15 2019
@@ -465,6 +465,8 @@ void PPCTargetInfo::adjust(LangOptions &
   if (HasAltivec)
 Opts.AltiVec = 1;
   TargetInfo::adjust(Opts);
+  if (LongDoubleFormat != ::APFloat::IEEEdouble())
+LongDoubleFormat = ::APFloat::PPCDoubleDouble();
 }
 
 ArrayRef PPCTargetInfo::getTargetBuiltins() const {

Modified: cfe/trunk/lib/Basic/Targets/X86.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.h?rev=365866=365865=365866=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.h (original)
+++ cfe/trunk/lib/Basic/Targets/X86.h Thu Jul 11 19:32:15 2019
@@ -133,6 +133,10 @@ public:
 LongDoubleFormat = ::APFloat::x87DoubleExtended();
   }
 
+  const char *getLongDoubleMangling() const override {
+return LongDoubleFormat == ::APFloat::IEEEquad() ? "g" : "e";
+  }
+
   unsigned getFloatEvalMethod() const override {
 // X87 evaluates with 80 bits "long double" precision.
 return SSELevel == NoSSE ? 2 : 0;
@@ -845,8 +849,6 @@ public:
   : LinuxTargetInfo(Triple, Opts) {
 LongDoubleFormat = ::APFloat::IEEEquad();
   }
-
-  const char *getLongDoubleMangling() const override { return "g"; }
 };
 } // namespace targets
 } // namespace clang

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=365866=365865=365866=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 11 19:32:15 2019
@@ -4012,15 +4012,15 @@ void 

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 209404.
MaskRay added a comment.

Use   A->render(Args, CmdArgs);


Repository:
  rC Clang

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

https://reviews.llvm.org/D64277

Files:
  include/clang/Driver/Options.td
  lib/Basic/TargetInfo.cpp
  lib/Basic/Targets/PPC.cpp
  lib/Basic/Targets/X86.h
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/ppc64-long-double.cpp
  test/CodeGen/x86-long-double.cpp
  test/Driver/mlong-double-128.c

Index: test/Driver/mlong-double-128.c
===
--- /dev/null
+++ test/Driver/mlong-double-128.c
@@ -0,0 +1,11 @@
+// RUN: %clang -target powerpc-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64-pc-freebsd12 -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target powerpc64le-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target i686-linux-gnu -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+// RUN: %clang -target x86_64-linux-musl -c -### %s -mlong-double-128 2>&1 | FileCheck %s
+
+// CHECK: "-mlong-double-128"
+
+// RUN: %clang -target aarch64 -c -### %s -mlong-double-128 2>&1 | FileCheck --check-prefix=ERR %s
+
+// ERR: error: unsupported option '-mlong-double-128' for target 'aarch64'
Index: test/CodeGen/x86-long-double.cpp
===
--- test/CodeGen/x86-long-double.cpp
+++ test/CodeGen/x86-long-double.cpp
@@ -16,6 +16,15 @@
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-64 | \
 // RUN:   FileCheck --check-prefixes=FP64,FP64-X64 %s
 
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64 -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+// RUN: %clang_cc1 %s -emit-llvm -o - -triple=x86_64-apple-darwin -mlong-double-128 | \
+// RUN:   FileCheck --check-prefix=FP128 %s
+
 // Check -malign-double increases the alignment from 4 to 8 on x86-32.
 // RUN: %clang_cc1 %s -emit-llvm -o - -triple=i686 -mlong-double-64 \
 // RUN:   -malign-double | FileCheck --check-prefixes=FP64,FP64-X64 %s
@@ -37,7 +46,11 @@
 // FP64-X64: @x = global double {{.*}}, align 8
 // FP64-X64: @size = global i32 8
 
+// FP128: @x = global fp128 {{.*}}, align 16
+// FP128: @size = global i32 16
+
 long double foo(long double d) { return d; }
 
 // FP64: double @_Z3fooe(double %d)
 // FP80: x86_fp80 @_Z3fooe(x86_fp80 %d)
+// FP128: fp128 @_Z3foog(fp128 %d)
Index: test/CodeGen/ppc64-long-double.cpp
===
--- test/CodeGen/ppc64-long-double.cpp
+++ test/CodeGen/ppc64-long-double.cpp
@@ -2,8 +2,11 @@
 // RUN:   FileCheck --check-prefix=FP64 %s
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s -mlong-double-64 | \
 // RUN:   FileCheck --check-prefix=FP64 %s
+
 // RUN: %clang_cc1 -triple powerpc64-linux-gnu -emit-llvm -o - %s | \
 // RUN:   FileCheck --check-prefix=IBM128 %s
+// RUN: %clang_cc1 -triple powerpc64-linux-musl -emit-llvm -o - -mlong-double-128 %s | \
+// RUN:   FileCheck --check-prefix=IBM128 %s
 
 long double x = 0;
 int size = sizeof(x);
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2742,7 +2742,9 @@
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, Diags);
   Opts.AlignDouble = Args.hasArg(OPT_malign_double);
-  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
+  Opts.LongDoubleSize = Args.hasArg(OPT_mlong_double_128)
+? 128
+: Args.hasArg(OPT_mlong_double_64) ? 64 : 0;
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.ROPI = Args.hasArg(OPT_fropi);
   Opts.RWPI = Args.hasArg(OPT_frwpi);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4012,15 +4012,15 @@
 
   RenderFloatingPointOptions(TC, D, OFastEnabled, Args, CmdArgs);
 
-  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64)) {
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_double_64,
+   options::OPT_mlong_double_128)) {
 if (TC.getArch() == llvm::Triple::x86 ||
 TC.getArch() == llvm::Triple::x86_64 ||
-TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
-} else {
+

[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-11 Thread Phabricator via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365863: NFC: Unforget a colon in a few CHECK: directives. 
(authored by dergachev, committed by ).
Herald added a subscriber: delcypher.

Changed prior to commit:
  https://reviews.llvm.org/D64526?vs=209060=209402#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64526

Files:
  cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
  cfe/trunk/test/CodeGenCXX/noescape.cpp
  cfe/trunk/test/CodeGenObjC/externally-retained.m
  compiler-rt/trunk/test/profile/instrprof-merge.c
  llvm/trunk/test/tools/dsymutil/X86/modules.m
  llvm/trunk/test/tools/dsymutil/X86/odr-fwd-declaration.cpp


Index: cfe/trunk/test/CodeGenCXX/noescape.cpp
===
--- cfe/trunk/test/CodeGenCXX/noescape.cpp
+++ cfe/trunk/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -459,7 +459,7 @@
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void simpleTemporary() {
   C();
 }
Index: cfe/trunk/test/CodeGenObjC/externally-retained.m
===
--- cfe/trunk/test/CodeGenObjC/externally-retained.m
+++ cfe/trunk/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {
Index: llvm/trunk/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
===
--- llvm/trunk/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
+++ llvm/trunk/test/tools/dsymutil/X86/odr-fwd-declaration.cpp
@@ -49,7 +49,7 @@
 // CHECK: AT_name{{.*}} "S"
 // CHECK-NOT: {{DW_TAG|NULL}}
 // CHECK: AT_declaration
-// CHECK-NOT AT_byte_size
+// CHECK-NOT: AT_byte_size
 
 #elif defined(FILE2)
 # 1 "Header.h" 1
Index: llvm/trunk/test/tools/dsymutil/X86/modules.m
===
--- llvm/trunk/test/tools/dsymutil/X86/modules.m
+++ llvm/trunk/test/tools/dsymutil/X86/modules.m
@@ -116,6 +116,7 @@
 // CHECK:   DW_AT_type {{.*}}{0x{{0*}}[[PTR:.*]]}
 //
 // CHECK: 0x{{0*}}[[PTR]]: DW_TAG_pointer_type
+// FIXME: The next line doesn't work.
 // CHECK-NEXT   DW_AT_type [DW_FORM_ref_addr] {0x{{0*}}[[INTERFACE]]
 extern int odr_violation;
 
Index: compiler-rt/trunk/test/profile/instrprof-merge.c
===
--- compiler-rt/trunk/test/profile/instrprof-merge.c
+++ compiler-rt/trunk/test/profile/instrprof-merge.c
@@ -90,8 +90,8 @@
 // Not profiled
 // CHECK-LABEL:  bar:
 // CHECK: Counters: 1
-// CHECK-NEXT Function count: 0
-// CHECK-NEXT Block counts: []
+// CHECK-NEXT:Function count: 0
+// CHECK-NEXT:Block counts: []
 
 // Not profiled
 // CHECK-LABEL:  main:


Index: cfe/trunk/test/CodeGenCXX/noescape.cpp
===
--- cfe/trunk/test/CodeGenCXX/noescape.cpp
+++ cfe/trunk/test/CodeGenCXX/noescape.cpp
@@ -45,7 +45,7 @@
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }
Index: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
===
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
@@ -459,7 +459,7 @@
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void simpleTemporary() {
   C();
 }
Index: cfe/trunk/test/CodeGenObjC/externally-retained.m
===
--- cfe/trunk/test/CodeGenObjC/externally-retained.m
+++ cfe/trunk/test/CodeGenObjC/externally-retained.m
@@ -22,7 +22,7 @@
 void 

[PATCH] D64526: [NFC] Unforget a colon in a few CHECK: directives.

2019-07-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Thanks all! I guess i'll commit.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64526



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


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xFFFFFFFF

2019-07-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 209401.
vitalybuka added a comment.

undo unrelated line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64597

Files:
  clang/lib/CodeGen/PatternInit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp


Index: clang/test/CodeGenCXX/auto-var-init.cpp
===
--- clang/test/CodeGenCXX/auto-var-init.cpp
+++ clang/test/CodeGenCXX/auto-var-init.cpp
@@ -12,7 +12,7 @@
 #ifdef __x86_64__
 char inits[] = 
{"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
 #else
-char inits[] = 
{"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
+char inits[] = {"-1/-1/-1/i32/-1/-1/i32/-1/i32/-1/FF/"};
 #define __int128 int;
 #endif
 // PATTERN: @inits = {{.*}} 
c"[[I8:[^/]+]]/[[I16:[^/]+]]/[[I32:[^/]+]]/[[ILONGT:[^/]+]]/[[ILONG:[^/]+]]/[[I64:[^/]+]]/[[I128T:[^/]+]]/[[I128:[^/]+]]/[[IPTRT:[^/]+]]/[[IPTR:[^/]+]]/[[IC:[^/]+]]/\00",
 align 1
Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -17,12 +17,13 @@
   // repeated byte-pattern which makes it easier to synthesize. We use it for
   // pointers as well as integers so that aggregates are likely to be
   // initialized with this repeated value.
-  constexpr uint64_t LargeValue = 0xull;
   // For 32-bit platforms it's a bit trickier because, across systems, only the
-  // zero page can reasonably be expected to be unmapped, and even then we need
-  // a very low address. We use a smaller value, and that value sadly doesn't
-  // have a repeated byte-pattern. We don't use it for integers.
-  constexpr uint32_t SmallValue = 0x00AA;
+  // zero page can reasonably be expected to be unmapped. We use max 0x
+  // assuming that memory access will overlap into zero page.
+  const uint64_t IntValue =
+  CGM.getContext().getTargetInfo().getMaxPointerWidth() < 64
+  ? 0xull
+  : 0xull;
   // Floating-point values are initialized as NaNs because they propagate. 
Using
   // a repeated byte pattern means that it will be easier to initialize
   // all-floating-point aggregates and arrays with memset. Further, aggregates
@@ -36,27 +37,18 @@
 Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
 ->getBitWidth();
 if (BitWidth <= 64)
-  return llvm::ConstantInt::get(Ty, LargeValue);
+  return llvm::ConstantInt::get(Ty, IntValue);
 return llvm::ConstantInt::get(
-Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, LargeValue)));
+Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, IntValue)));
   }
   if (Ty->isPtrOrPtrVectorTy()) {
 auto *PtrTy = cast(
 Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
 unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
 PtrTy->getAddressSpace());
-llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
-uint64_t IntValue;
-switch (PtrWidth) {
-default:
+if (PtrWidth > 64)
   llvm_unreachable("pattern initialization of unsupported pointer width");
-case 64:
-  IntValue = LargeValue;
-  break;
-case 32:
-  IntValue = SmallValue;
-  break;
-}
+llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
 auto *Int = llvm::ConstantInt::get(IntTy, IntValue);
 return llvm::ConstantExpr::getIntToPtr(Int, PtrTy);
   }


Index: clang/test/CodeGenCXX/auto-var-init.cpp
===
--- clang/test/CodeGenCXX/auto-var-init.cpp
+++ clang/test/CodeGenCXX/auto-var-init.cpp
@@ -12,7 +12,7 @@
 #ifdef __x86_64__
 char inits[] = {"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
 #else
-char inits[] = {"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
+char inits[] = {"-1/-1/-1/i32/-1/-1/i32/-1/i32/-1/FF/"};
 #define __int128 int;
 #endif
 // PATTERN: @inits = {{.*}} c"[[I8:[^/]+]]/[[I16:[^/]+]]/[[I32:[^/]+]]/[[ILONGT:[^/]+]]/[[ILONG:[^/]+]]/[[I64:[^/]+]]/[[I128T:[^/]+]]/[[I128:[^/]+]]/[[IPTRT:[^/]+]]/[[IPTR:[^/]+]]/[[IC:[^/]+]]/\00", align 1
Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -17,12 +17,13 @@
   // repeated byte-pattern which makes it easier to synthesize. We use it for
   // pointers as well as integers so that aggregates are likely to be
   // initialized with this repeated value.
- 

r365863 - NFC: Unforget a colon in a few CHECK: directives.

2019-07-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jul 11 19:16:56 2019
New Revision: 365863

URL: http://llvm.org/viewvc/llvm-project?rev=365863=rev
Log:
NFC: Unforget a colon in a few CHECK: directives.

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

Modified:
cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
cfe/trunk/test/CodeGenCXX/noescape.cpp
cfe/trunk/test/CodeGenObjC/externally-retained.m

Modified: cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/cfg-rich-constructors.cpp?rev=365863=365862=365863=diff
==
--- cfe/trunk/test/Analysis/cfg-rich-constructors.cpp (original)
+++ cfe/trunk/test/Analysis/cfg-rich-constructors.cpp Thu Jul 11 19:16:56 2019
@@ -459,7 +459,7 @@ namespace temporary_object_expr_without_
 // TODO: Should provide construction context for the constructor,
 // even if there is no specific trigger statement here.
 // CHECK: void simpleTemporary()
-// CHECK   1: C() (CXXConstructExpr, class C)
+// CHECK:  1: C() (CXXConstructExpr, class C)
 void simpleTemporary() {
   C();
 }

Modified: cfe/trunk/test/CodeGenCXX/noescape.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/noescape.cpp?rev=365863=365862=365863=diff
==
--- cfe/trunk/test/CodeGenCXX/noescape.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/noescape.cpp Thu Jul 11 19:16:56 2019
@@ -45,7 +45,7 @@ void *operator new(std::size_t, void * _
 }
 
 // CHECK-LABEL: define i8* @_Z5test1Pv(
-// CHECK : %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
+// CHECK: %call = call {{.*}} @_ZnwmPv({{.*}}, {{.*}} nocapture {{.*}})
 void *test1(void *p0) {
   return ::operator new(16, p0);
 }

Modified: cfe/trunk/test/CodeGenObjC/externally-retained.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/externally-retained.m?rev=365863=365862=365863=diff
==
--- cfe/trunk/test/CodeGenObjC/externally-retained.m (original)
+++ cfe/trunk/test/CodeGenObjC/externally-retained.m Thu Jul 11 19:16:56 2019
@@ -22,7 +22,7 @@ extern "C" void block_param();
 void param(ObjTy *p) EXT_RET {
   // CHECK-LABEL: define void @param
   // CHECK-NOT: llvm.objc.
-  // CHECK ret
+  // CHECK: ret
 }
 
 void local() {


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


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xFFFFFFFF

2019-07-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 209400.
vitalybuka added a comment.

0x


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64597

Files:
  clang/lib/CodeGen/PatternInit.cpp
  clang/test/CodeGenCXX/auto-var-init.cpp


Index: clang/test/CodeGenCXX/auto-var-init.cpp
===
--- clang/test/CodeGenCXX/auto-var-init.cpp
+++ clang/test/CodeGenCXX/auto-var-init.cpp
@@ -12,7 +12,7 @@
 #ifdef __x86_64__
 char inits[] = 
{"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
 #else
-char inits[] = 
{"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
+char inits[] = {"-1/-1/-1/i32/-1/-1/i32/-1/i32/-1/FF/"};
 #define __int128 int;
 #endif
 // PATTERN: @inits = {{.*}} 
c"[[I8:[^/]+]]/[[I16:[^/]+]]/[[I32:[^/]+]]/[[ILONGT:[^/]+]]/[[ILONG:[^/]+]]/[[I64:[^/]+]]/[[I128T:[^/]+]]/[[I128:[^/]+]]/[[IPTRT:[^/]+]]/[[IPTR:[^/]+]]/[[IC:[^/]+]]/\00",
 align 1
@@ -1043,7 +1043,7 @@
 // CHECK-NEXT:   call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-O1-LABEL: @test_intptr4_uninit()
 // PATTERN-O1:   %1 = bitcast [4 x i32*]* %uninit to i8*
-// PATTERN-O1-NEXT:  call void @llvm.memset.p0i8.i64(i8* nonnull align 16 %1, 
i8 -86, i64 32, i1 false)
+// PATTERN-O1-NEXT:  call void @llvm.memset.p0i8.i64(i8* nonnull align 16 %1, 
i8 [[I8]], i64 32, i1 false)
 // ZERO-LABEL:   @test_intptr4_uninit()
 // ZERO: call void @llvm.memset{{.*}}, i8 0,
 
Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -17,12 +17,13 @@
   // repeated byte-pattern which makes it easier to synthesize. We use it for
   // pointers as well as integers so that aggregates are likely to be
   // initialized with this repeated value.
-  constexpr uint64_t LargeValue = 0xull;
   // For 32-bit platforms it's a bit trickier because, across systems, only the
-  // zero page can reasonably be expected to be unmapped, and even then we need
-  // a very low address. We use a smaller value, and that value sadly doesn't
-  // have a repeated byte-pattern. We don't use it for integers.
-  constexpr uint32_t SmallValue = 0x00AA;
+  // zero page can reasonably be expected to be unmapped. We use max 0x
+  // assuming that memory access will overlap into zero page.
+  const uint64_t IntValue =
+  CGM.getContext().getTargetInfo().getMaxPointerWidth() < 64
+  ? 0xull
+  : 0xull;
   // Floating-point values are initialized as NaNs because they propagate. 
Using
   // a repeated byte pattern means that it will be easier to initialize
   // all-floating-point aggregates and arrays with memset. Further, aggregates
@@ -36,27 +37,18 @@
 Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
 ->getBitWidth();
 if (BitWidth <= 64)
-  return llvm::ConstantInt::get(Ty, LargeValue);
+  return llvm::ConstantInt::get(Ty, IntValue);
 return llvm::ConstantInt::get(
-Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, LargeValue)));
+Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, IntValue)));
   }
   if (Ty->isPtrOrPtrVectorTy()) {
 auto *PtrTy = cast(
 Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
 unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
 PtrTy->getAddressSpace());
-llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
-uint64_t IntValue;
-switch (PtrWidth) {
-default:
+if (PtrWidth > 64)
   llvm_unreachable("pattern initialization of unsupported pointer width");
-case 64:
-  IntValue = LargeValue;
-  break;
-case 32:
-  IntValue = SmallValue;
-  break;
-}
+llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
 auto *Int = llvm::ConstantInt::get(IntTy, IntValue);
 return llvm::ConstantExpr::getIntToPtr(Int, PtrTy);
   }


Index: clang/test/CodeGenCXX/auto-var-init.cpp
===
--- clang/test/CodeGenCXX/auto-var-init.cpp
+++ clang/test/CodeGenCXX/auto-var-init.cpp
@@ -12,7 +12,7 @@
 #ifdef __x86_64__
 char inits[] = {"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
 #else
-char inits[] = {"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
+char inits[] = {"-1/-1/-1/i32/-1/-1/i32/-1/i32/-1/FF/"};
 #define __int128 int;
 #endif
 // PATTERN: @inits = {{.*}} 

[PATCH] D64597: CodeGet: Init 32bit pointers with 0xFFFFFFFF

2019-07-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D64597#1581654 , @jfb wrote:

> In D64597#1581605 , @pcc wrote:
>
> > The problem with `0x` on 32-bit is that it is likely to be a valid 
> > address.
> >
> > When I discussed this with JF I proposed a pointer initialization of 
> > `0x` which he agreed to. This value is very likely to trap when 
> > accessed (due to accesses likely wrapping to zero) and also has the benefit 
> > of being the same pattern as for floats.
>
>
> Indeed.


Done. This is even more effective.
Maybe we should consider 0xAA for floats on 64bit?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64597



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


[PATCH] D60335: Use -fomit-frame-pointer when optimizing PowerPC code

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I did this in rC365862  with a test after my 
refactoring of the interface rC365860 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D60335



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


r365862 - [PowerPC] Default to -fomit-frame-pointer when optimization is enabled

2019-07-11 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Jul 11 19:14:08 2019
New Revision: 365862

URL: http://llvm.org/viewvc/llvm-project?rev=365862=rev
Log:
[PowerPC] Default to -fomit-frame-pointer when optimization is enabled

NetBSD, Linux, CloudABI and Hurd already omit frame pointer for PowerPC.
Make it do so for other platforms.

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=365862=365861=365862=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 11 19:14:08 2019
@@ -528,6 +528,9 @@ static bool useFramePointerForTargetByDe
 // XCore never wants frame pointers, regardless of OS.
 // WebAssembly never wants frame pointers.
 return false;
+  case llvm::Triple::ppc:
+  case llvm::Triple::ppc64:
+  case llvm::Triple::ppc64le:
   case llvm::Triple::riscv32:
   case llvm::Triple::riscv64:
 return !areOptimizationsEnabled(Args);
@@ -547,9 +550,6 @@ static bool useFramePointerForTargetByDe
 case llvm::Triple::mips64el:
 case llvm::Triple::mips:
 case llvm::Triple::mipsel:
-case llvm::Triple::ppc:
-case llvm::Triple::ppc64:
-case llvm::Triple::ppc64le:
 case llvm::Triple::systemz:
 case llvm::Triple::x86:
 case llvm::Triple::x86_64:

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=365862=365861=365862=diff
==
--- cfe/trunk/test/Driver/frame-pointer-elim.c (original)
+++ cfe/trunk/test/Driver/frame-pointer-elim.c Thu Jul 11 19:14:08 2019
@@ -94,5 +94,10 @@
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
+// RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target powerpc64 -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
 void f0() {}
 void f1() { f0(); }


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


[PATCH] D64611: [analyzer] exploded-graph-rewriter: Improve source location dumps.

2019-07-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision.
NoQ added a comment.

Whoops, forgot the phabricator link.
Committed as rC365861 .


Repository:
  rC Clang

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

https://reviews.llvm.org/D64611



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


r365861 - [analyzer] exploded-graph-rewriter: Improve source location dumps.

2019-07-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jul 11 19:10:33 2019
New Revision: 365861

URL: http://llvm.org/viewvc/llvm-project?rev=365861=rev
Log:
[analyzer] exploded-graph-rewriter: Improve source location dumps.

- Correctly display macro expansion and spelling locations.
- Use the same procedure to display location context call site locations.
- Display statement IDs for program points.

Added:
cfe/trunk/test/Analysis/exploded-graph-rewriter/macros.c
Modified:
cfe/trunk/include/clang/Basic/JsonSupport.h
cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
cfe/trunk/lib/Analysis/ProgramPoint.cpp
cfe/trunk/test/Analysis/dump_egraph.cpp
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment_diff.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/test/Analysis/expr-inspection.c
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/include/clang/Basic/JsonSupport.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/JsonSupport.h?rev=365861=365860=365861=diff
==
--- cfe/trunk/include/clang/Basic/JsonSupport.h (original)
+++ cfe/trunk/include/clang/Basic/JsonSupport.h Thu Jul 11 19:10:33 2019
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_BASIC_JSONSUPPORT_H
 
 #include "clang/Basic/LLVM.h"
+#include "clang/Basic/SourceManager.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 
@@ -77,6 +78,42 @@ inline std::string JsonFormat(StringRef
   return '\"' + Str + '\"';
 }
 
+inline void printSourceLocationAsJson(raw_ostream , SourceLocation Loc,
+  const SourceManager ,
+  bool AddBraces = true) {
+  // Mostly copy-pasted from SourceLocation::print.
+  if (!Loc.isValid()) {
+Out << "null";
+return;
+  }
+
+  if (Loc.isFileID()) {
+PresumedLoc PLoc = SM.getPresumedLoc(Loc);
+
+if (PLoc.isInvalid()) {
+  Out << "null";
+  return;
+}
+// The macro expansion and spelling pos is identical for file locs.
+if (AddBraces)
+  Out << "{ ";
+Out << "\"line\": " << PLoc.getLine()
+<< ", \"column\": " << PLoc.getColumn()
+<< ", \"file\": \"" << PLoc.getFilename() << "\"";
+if (AddBraces)
+  Out << " }";
+return;
+  }
+
+  // We want 'location: { ..., spelling: { ... }}' but not
+  // 'location: { ... }, spelling: { ... }', hence the dance
+  // with braces.
+  Out << "{ ";
+  printSourceLocationAsJson(Out, SM.getExpansionLoc(Loc), SM, false);
+  Out << ", \"spelling\": ";
+  printSourceLocationAsJson(Out, SM.getSpellingLoc(Loc), SM, true);
+  Out << " }";
+}
 } // namespace clang
 
 #endif // LLVM_CLANG_BASIC_JSONSUPPORT_H

Modified: cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp?rev=365861=365860=365861=diff
==
--- cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp (original)
+++ cfe/trunk/lib/Analysis/AnalysisDeclContext.cpp Thu Jul 11 19:10:33 2019
@@ -538,11 +538,9 @@ void LocationContext::printJson(raw_ostr
   else
 Out << "anonymous code";
 
-  Out << "\", \"call_line\": ";
+  Out << "\", \"location\": ";
   if (const Stmt *S = cast(LCtx)->getCallSite()) {
-Out << '\"';
-printLocation(Out, SM, S->getBeginLoc());
-Out << '\"';
+printSourceLocationAsJson(Out, S->getBeginLoc(), SM);
   } else {
 Out << "null";
   }
@@ -555,8 +553,8 @@ void LocationContext::printJson(raw_ostr
 case Block:
   Out << "Invoking block\" ";
   if (const Decl *D = cast(LCtx)->getDecl()) {
-Out << ", \"decl_line\": ";
-printLocation(Out, SM, D->getBeginLoc());
+Out << ", \"location\": ";
+printSourceLocationAsJson(Out, D->getBeginLoc(), SM);
 Out << ' ';
   }
   break;

Modified: cfe/trunk/lib/Analysis/ProgramPoint.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/ProgramPoint.cpp?rev=365861=365860=365861=diff
==
--- cfe/trunk/lib/Analysis/ProgramPoint.cpp (original)
+++ cfe/trunk/lib/Analysis/ProgramPoint.cpp Thu Jul 11 19:10:33 2019
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include "clang/Analysis/ProgramPoint.h"
+#include "clang/Basic/JsonSupport.h"
 
 using namespace clang;
 
@@ -46,19 +47,6 @@ LLVM_DUMP_METHOD void ProgramPoint::dump
   return printJson(llvm::errs());
 }
 
-static void printLocJson(raw_ostream , SourceLocation Loc,
- const SourceManager ) {
-  Out << "\"location\": ";
-  if (!Loc.isFileID()) {
-Out << "null";
-return;
-  }
-
-  Out << "{ \"line\": " << 

[PATCH] D64294: [Driver] Refactor interaction between -f(no-)?omit-frame-pointer and -m(no-)?omit-leaf-frame-pointer

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365860: [Driver] Refactor interaction between 
-f(no-)?omit-frame-pointer and -m(no-)? (authored by MaskRay, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64294

Files:
  cfe/trunk/lib/Driver/ToolChains/Clang.cpp
  cfe/trunk/test/Driver/cl-options.c
  cfe/trunk/test/Driver/clang_f_opts.c
  cfe/trunk/test/Driver/frame-pointer-elim.c
  cfe/trunk/test/Driver/xcore-opts.c

Index: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
===
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp
@@ -501,6 +501,8 @@
   return codegenoptions::LimitedDebugInfo;
 }
 
+enum class FramePointerKind { None, NonLeaf, All };
+
 static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple ) {
   switch (Triple.getArch()){
   default:
@@ -515,6 +517,9 @@
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
+  if (Args.hasArg(options::OPT_pg))
+return true;
+
   switch (Triple.getArch()) {
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
@@ -574,32 +579,22 @@
   return true;
 }
 
-static bool shouldUseFramePointer(const ArgList ,
-  const llvm::Triple ) {
-  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
-   options::OPT_fomit_frame_pointer))
-return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseNonLeafFramePointerForTarget(Triple);
-
-  if (Args.hasArg(options::OPT_pg))
-return true;
-
-  return useFramePointerForTargetByDefault(Args, Triple);
-}
-
-static bool shouldUseLeafFramePointer(const ArgList ,
-  const llvm::Triple ) {
-  if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
-   options::OPT_momit_leaf_frame_pointer))
-return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
-
-  if (Args.hasArg(options::OPT_pg))
-return true;
-
-  if (Triple.isPS4CPU())
-return false;
-
-  return useFramePointerForTargetByDefault(Args, Triple);
+static FramePointerKind getFramePointerKind(const ArgList ,
+const llvm::Triple ) {
+  Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
+   options::OPT_fno_omit_frame_pointer);
+  bool OmitFP = A && A->getOption().matches(options::OPT_fomit_frame_pointer);
+  bool NoOmitFP =
+  A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+  if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
+  (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
+if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
+ options::OPT_mno_omit_leaf_frame_pointer,
+ Triple.isPS4CPU()))
+  return FramePointerKind::NonLeaf;
+return FramePointerKind::All;
+  }
+  return FramePointerKind::None;
 }
 
 /// Add a CC1 option to specify the debug compilation directory.
@@ -3960,8 +3955,12 @@
   if (Args.hasFlag(options::OPT_mrtd, options::OPT_mno_rtd, false))
 CmdArgs.push_back("-fdefault-calling-conv=stdcall");
 
-  if (shouldUseFramePointer(Args, RawTriple))
+  FramePointerKind FPKeepKind = getFramePointerKind(Args, RawTriple);
+  if (FPKeepKind != FramePointerKind::None) {
 CmdArgs.push_back("-mdisable-fp-elim");
+if (FPKeepKind == FramePointerKind::NonLeaf)
+  CmdArgs.push_back("-momit-leaf-frame-pointer");
+  }
   if (!Args.hasFlag(options::OPT_fzero_initialized_in_bss,
 options::OPT_fno_zero_initialized_in_bss))
 CmdArgs.push_back("-mno-zero-initialized-in-bss");
@@ -4146,9 +4145,6 @@
 CmdArgs.push_back(A->getValue());
   }
 
-  if (!shouldUseLeafFramePointer(Args, RawTriple))
-CmdArgs.push_back("-momit-leaf-frame-pointer");
-
   // Explicitly error on some things we know we don't support and can't just
   // ignore.
   if (!Args.hasArg(options::OPT_fallow_unsupported)) {
@@ -5503,7 +5499,7 @@
   }
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
-if (!shouldUseFramePointer(Args, Triple))
+if (FPKeepKind == FramePointerKind::None)
   D.Diag(diag::err_drv_argument_not_allowed_with) << "-fomit-frame-pointer"
   << A->getAsString(Args);
 
Index: cfe/trunk/test/Driver/cl-options.c
===
--- cfe/trunk/test/Driver/cl-options.c
+++ cfe/trunk/test/Driver/cl-options.c
@@ -161,28 +161,28 @@
 // RUN: %clang_cl /Os --target=i686-pc-windows-msvc -### -- %s 2>&1 | FileCheck -check-prefix=Os %s
 // RUN: %clang_cl /Os 

r365860 - [Driver] Refactor interaction between -f(no-)?omit-frame-pointer and -m(no-)?omit-leaf-frame-pointer

2019-07-11 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Thu Jul 11 19:01:51 2019
New Revision: 365860

URL: http://llvm.org/viewvc/llvm-project?rev=365860=rev
Log:
[Driver] Refactor interaction between -f(no-)?omit-frame-pointer and 
-m(no-)?omit-leaf-frame-pointer

Use a tri-state enum to represent shouldUseFramePointer() and
shouldUseLeafFramePointer().

This simplifies the logic and fixes PR9825:
  -fno-omit-frame-pointer doesn't imply -mno-omit-leaf-frame-pointer.

and PR24003:
  /Oy- /O2 should not omit leaf frame pointer: this matches MSVC x86-32.
  (/Oy- is a no-op on MSVC x86-64.)

and:
  when CC1 option -mdisable-fp-elim if absent, -momit-leaf-frame-pointer
  can also be omitted.

The new behavior matches GCC:
  -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer
  -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer

The behavior makes lots of sense. We have 4 states:

- 00) leaf retained, non-leaf retained
- 01) leaf retained, non-leaf omitted  (this is invalid)
- 10) leaf omitted, non-leaf retained  (what -momit-leaf-frame-pointer was 
designed for)
- 11) leaf omitted, non-leaf omitted

"omit" options taking precedence over "no-omit" options is the only way
to make 3 valid states representable with -f(no-)?omit-frame-pointer and
-m(no-)?omit-leaf-pointer.

Reviewed By: ychen

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/cl-options.c
cfe/trunk/test/Driver/clang_f_opts.c
cfe/trunk/test/Driver/frame-pointer-elim.c
cfe/trunk/test/Driver/xcore-opts.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=365860=365859=365860=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Thu Jul 11 19:01:51 2019
@@ -501,6 +501,8 @@ static codegenoptions::DebugInfoKind Deb
   return codegenoptions::LimitedDebugInfo;
 }
 
+enum class FramePointerKind { None, NonLeaf, All };
+
 static bool mustUseNonLeafFramePointerForTarget(const llvm::Triple ) {
   switch (Triple.getArch()){
   default:
@@ -515,6 +517,9 @@ static bool mustUseNonLeafFramePointerFo
 
 static bool useFramePointerForTargetByDefault(const ArgList ,
   const llvm::Triple ) {
+  if (Args.hasArg(options::OPT_pg))
+return true;
+
   switch (Triple.getArch()) {
   case llvm::Triple::xcore:
   case llvm::Triple::wasm32:
@@ -574,32 +579,22 @@ static bool useFramePointerForTargetByDe
   return true;
 }
 
-static bool shouldUseFramePointer(const ArgList ,
-  const llvm::Triple ) {
-  if (Arg *A = Args.getLastArg(options::OPT_fno_omit_frame_pointer,
-   options::OPT_fomit_frame_pointer))
-return A->getOption().matches(options::OPT_fno_omit_frame_pointer) ||
-   mustUseNonLeafFramePointerForTarget(Triple);
-
-  if (Args.hasArg(options::OPT_pg))
-return true;
-
-  return useFramePointerForTargetByDefault(Args, Triple);
-}
-
-static bool shouldUseLeafFramePointer(const ArgList ,
-  const llvm::Triple ) {
-  if (Arg *A = Args.getLastArg(options::OPT_mno_omit_leaf_frame_pointer,
-   options::OPT_momit_leaf_frame_pointer))
-return A->getOption().matches(options::OPT_mno_omit_leaf_frame_pointer);
-
-  if (Args.hasArg(options::OPT_pg))
-return true;
-
-  if (Triple.isPS4CPU())
-return false;
-
-  return useFramePointerForTargetByDefault(Args, Triple);
+static FramePointerKind getFramePointerKind(const ArgList ,
+const llvm::Triple ) {
+  Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
+   options::OPT_fno_omit_frame_pointer);
+  bool OmitFP = A && A->getOption().matches(options::OPT_fomit_frame_pointer);
+  bool NoOmitFP =
+  A && A->getOption().matches(options::OPT_fno_omit_frame_pointer);
+  if (NoOmitFP || mustUseNonLeafFramePointerForTarget(Triple) ||
+  (!OmitFP && useFramePointerForTargetByDefault(Args, Triple))) {
+if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
+ options::OPT_mno_omit_leaf_frame_pointer,
+ Triple.isPS4CPU()))
+  return FramePointerKind::NonLeaf;
+return FramePointerKind::All;
+  }
+  return FramePointerKind::None;
 }
 
 /// Add a CC1 option to specify the debug compilation directory.
@@ -3960,8 +3955,12 @@ void Clang::ConstructJob(Compilation ,
   if (Args.hasFlag(options::OPT_mrtd, options::OPT_mno_rtd, false))
 CmdArgs.push_back("-fdefault-calling-conv=stdcall");
 
-  if (shouldUseFramePointer(Args, RawTriple))
+  FramePointerKind FPKeepKind = getFramePointerKind(Args, RawTriple);
+  if (FPKeepKind != FramePointerKind::None) {
 CmdArgs.push_back("-mdisable-fp-elim");
+if (FPKeepKind 

[PATCH] D64294: [Driver] Refactor interaction between -f(no-)?omit-frame-pointer and -m(no-)?omit-leaf-frame-pointer

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 209398.
MaskRay retitled this revision from "[Driver] Refactor interaction between 
-f(no-)omit-frame-pointer and -mno-omit-leaf-frame-pointer" to "[Driver] 
Refactor interaction between -f(no-)?omit-frame-pointer and 
-m(no-)?omit-leaf-frame-pointer".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Fix title


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c
  test/Driver/frame-pointer-elim.c
  test/Driver/xcore-opts.c

Index: test/Driver/xcore-opts.c
===
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -4,8 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
 // CHECK: "-nostdsysteminc"
-// CHECK: "-momit-leaf-frame-pointer"
 // CHECK-NOT: "-mdisable-fp-elim"
+// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -1,48 +1,74 @@
-// For these next two tests when optimized we should omit the leaf frame
-// pointer, for unoptimized we should have a leaf frame pointer.
-// RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX-OPT %s
-// LINUX-OPT: "-momit-leaf-frame-pointer"
-
-// RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX %s
-// LINUX-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL: "-mdisable-fp-elim"
+// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// KEEP-NON-LEAF: "-mdisable-fp-elim"
+// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
+
+// KEEP-NONE-NOT: "-mdisable-fp-elim"
+// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+
+// On Linux x86, omit frame pointer when optimization is enabled.
+// RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -fno-omit-frame-pointer or -pg disables frame pointer omission.
+// RUN: %clang -### -target i386-linux -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -pg %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+
+// -momit-leaf-frame-pointer omits leaf frame pointer.
+// -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S %s -O1 -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -pg -fomit-frame-pointer => error.
+// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
+// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
+// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
+// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
 
 // CloudABI follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI-OPT %s
-// CLOUDABI-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI %s
-// CLOUDABI-NOT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
 
 // NetBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=NETBSD-OPT %s
-// NETBSD-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
-// RUN:   FileCheck 

[PATCH] D64294: [Driver] Refactor interaction between -f(no-)omit-frame-pointer and -mno-omit-leaf-frame-pointer

2019-07-11 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay updated this revision to Diff 209396.
MaskRay marked 2 inline comments as done.
MaskRay retitled this revision from "[Driver] Consolidate 
shouldUseFramePointer() and shouldUseLeafFramePointer()" to "[Driver] Refactor 
interaction between -f(no-)omit-frame-pointer and -mno-omit-leaf-frame-pointer".
MaskRay edited the summary of this revision.
MaskRay added a comment.

Update title and description


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cl-options.c
  test/Driver/clang_f_opts.c
  test/Driver/frame-pointer-elim.c
  test/Driver/xcore-opts.c

Index: test/Driver/xcore-opts.c
===
--- test/Driver/xcore-opts.c
+++ test/Driver/xcore-opts.c
@@ -4,8 +4,8 @@
 // RUN: %clang -target xcore %s -g0 -### -o %t.o 2>&1 | FileCheck -check-prefix CHECK-G0 %s
 
 // CHECK: "-nostdsysteminc"
-// CHECK: "-momit-leaf-frame-pointer"
 // CHECK-NOT: "-mdisable-fp-elim"
+// CHECK-NOT: "-momit-leaf-frame-pointer"
 // CHECK: "-fno-signed-char"
 // CHECK: "-fno-use-cxa-atexit"
 // CHECK-NOT: "-fcxx-exceptions"
Index: test/Driver/frame-pointer-elim.c
===
--- test/Driver/frame-pointer-elim.c
+++ test/Driver/frame-pointer-elim.c
@@ -1,48 +1,74 @@
-// For these next two tests when optimized we should omit the leaf frame
-// pointer, for unoptimized we should have a leaf frame pointer.
-// RUN: %clang -### -target i386-pc-linux-gnu -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX-OPT %s
-// LINUX-OPT: "-momit-leaf-frame-pointer"
-
-// RUN: %clang -### -target i386-pc-linux-gnu -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=LINUX %s
-// LINUX-NOT: "-momit-leaf-frame-pointer"
+// KEEP-ALL: "-mdisable-fp-elim"
+// KEEP-ALL-NOT: "-momit-leaf-frame-pointer"
+
+// KEEP-NON-LEAF: "-mdisable-fp-elim"
+// KEEP-NON-LEAF: "-momit-leaf-frame-pointer"
+
+// KEEP-NONE-NOT: "-mdisable-fp-elim"
+// KEEP-NONE-NOT: "-momit-leaf-frame-pointer"
+
+// On Linux x86, omit frame pointer when optimization is enabled.
+// RUN: %clang -### -target i386-linux -S -fomit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S -O1 %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -fno-omit-frame-pointer or -pg disables frame pointer omission.
+// RUN: %clang -### -target i386-linux -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+// RUN: %clang -### -target i386-linux -S -O1 -pg %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
+
+// -momit-leaf-frame-pointer omits leaf frame pointer.
+// -fno-omit-frame-pointer loses out to -momit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -fno-omit-frame-pointer -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target i386-linux -S -O1 -momit-leaf-frame-pointer %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// Explicit or default -fomit-frame-pointer wins over -mno-omit-leaf-frame-pointer.
+// RUN: %clang -### -target i386 -S %s -fomit-frame-pointer -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+// RUN: %clang -### -target i386-linux -S %s -O1 -mno-omit-leaf-frame-pointer 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
+
+// -pg -fomit-frame-pointer => error.
+// RUN: %clang -### -S -fomit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-NO-MIX-OMIT-FP-PG %s
+// RUN: %clang -### -S -fomit-frame-pointer -fno-omit-frame-pointer -pg %s 2>&1 | FileCheck -check-prefix=CHECK-MIX-NO-OMIT-FP-PG %s
+// CHECK-NO-MIX-OMIT-FP-PG: '-fomit-frame-pointer' not allowed with '-pg'
+// CHECK-MIX-NO-OMIT-FP-PG-NOT: '-fomit-frame-pointer' not allowed with '-pg'
 
 // CloudABI follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI-OPT %s
-// CLOUDABI-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-cloudabi -S %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=CLOUDABI %s
-// CLOUDABI-NOT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-ALL %s
 
 // NetBSD follows the same rules as Linux.
 // RUN: %clang -### -target x86_64-unknown-netbsd -S -O1 %s 2>&1 | \
-// RUN:   FileCheck --check-prefix=NETBSD-OPT %s
-// NETBSD-OPT: "-momit-leaf-frame-pointer"
+// RUN:   FileCheck --check-prefix=KEEP-NONE %s
 
 // RUN: %clang -### -target x86_64-unknown-netbsd -S %s 2>&1 | \
-// 

[PATCH] D63967: Handle IntToPtr in isBytewiseValue

2019-07-11 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365858: Handle IntToPtr in isBytewiseValue (authored by 
vitalybuka, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D63967?vs=207180=209394#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63967

Files:
  cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
  llvm/trunk/lib/Analysis/ValueTracking.cpp
  llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp


Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -3218,6 +3218,17 @@
 }
   }
 
+  if (auto *CE = dyn_cast(C)) {
+if (CE->getOpcode() == Instruction::IntToPtr) {
+  auto PS = DL.getPointerSizeInBits(
+  cast(CE->getType())->getAddressSpace());
+  return isBytewiseValue(
+  ConstantExpr::getIntegerCast(CE->getOperand(0),
+   Type::getIntNTy(Ctx, PS), false),
+  DL);
+}
+  }
+
   auto Merge = [&](Value *LHS, Value *RHS) -> Value * {
 if (LHS == RHS)
   return LHS;
Index: llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
===
--- llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
+++ llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
@@ -794,11 +794,11 @@
 "i16* inttoptr (i64 0 to i16*)",
 },
 {
-"",
+"i8 -1",
 "i16* inttoptr (i64 -1 to i16*)",
 },
 {
-"",
+"i8 -86",
 "i16* inttoptr (i64 -6148914691236517206 to i16*)",
 },
 {
@@ -806,7 +806,7 @@
 "i16* inttoptr (i48 -1 to i16*)",
 },
 {
-"",
+"i8 -1",
 "i16* inttoptr (i96 -1 to i16*)",
 },
 {
Index: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
@@ -1042,14 +1042,8 @@
 // CHECK:%uninit = alloca [4 x i32*], align
 // CHECK-NEXT:   call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-O1-LABEL: @test_intptr4_uninit()
-// PATTERN-O1:   %1 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 0
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %1, align 16
-// PATTERN-O1-NEXT:  %2 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 1
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %2, align 8
-// PATTERN-O1-NEXT:  %3 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 2
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %3, align 16
-// PATTERN-O1-NEXT:  %4 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 3
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %4, align 8
+// PATTERN-O1:   %1 = bitcast [4 x i32*]* %uninit to i8*
+// PATTERN-O1-NEXT:  call void @llvm.memset.p0i8.i64(i8* nonnull align 16 %1, 
i8 -86, i64 32, i1 false)
 // ZERO-LABEL:   @test_intptr4_uninit()
 // ZERO: call void @llvm.memset{{.*}}, i8 0,
 


Index: llvm/trunk/lib/Analysis/ValueTracking.cpp
===
--- llvm/trunk/lib/Analysis/ValueTracking.cpp
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp
@@ -3218,6 +3218,17 @@
 }
   }
 
+  if (auto *CE = dyn_cast(C)) {
+if (CE->getOpcode() == Instruction::IntToPtr) {
+  auto PS = DL.getPointerSizeInBits(
+  cast(CE->getType())->getAddressSpace());
+  return isBytewiseValue(
+  ConstantExpr::getIntegerCast(CE->getOperand(0),
+   Type::getIntNTy(Ctx, PS), false),
+  DL);
+}
+  }
+
   auto Merge = [&](Value *LHS, Value *RHS) -> Value * {
 if (LHS == RHS)
   return LHS;
Index: llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
===
--- llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
+++ llvm/trunk/unittests/Analysis/ValueTrackingTest.cpp
@@ -794,11 +794,11 @@
 "i16* inttoptr (i64 0 to i16*)",
 },
 {
-"",
+"i8 -1",
 "i16* inttoptr (i64 -1 to i16*)",
 },
 {
-"",
+"i8 -86",
 "i16* inttoptr (i64 -6148914691236517206 to i16*)",
 },
 {
@@ -806,7 +806,7 @@
 "i16* inttoptr (i48 -1 to i16*)",
 },
 {
-"",
+"i8 -1",
 "i16* inttoptr (i96 -1 to i16*)",
 },
 {
Index: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
===
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

r365858 - Handle IntToPtr in isBytewiseValue

2019-07-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jul 11 18:42:03 2019
New Revision: 365858

URL: http://llvm.org/viewvc/llvm-project?rev=365858=rev
Log:
Handle IntToPtr in isBytewiseValue

Summary:
This helps with more efficient use of memset for pattern initialization

From @pcc prototype for -ftrivial-auto-var-init=pattern optimizations

Binary size change on CTMark, (with -fuse-ld=lld -Wl,--icf=all, similar results 
with default linker options)
```
   master   patch  diff
Os   8.238864e+058.238864e+05   0.0
O3   1.054797e+061.054797e+06   0.0
Os zero  8.292384e+058.292384e+05   0.0
O3 zero  1.062626e+061.062626e+06   0.0
Os pattern   8.579712e+058.338048e+05 -0.030299
O3 pattern   1.090502e+061.067574e+06 -0.020481
```

Zero vs Pattern on master
```
   zero   pattern  diff
Os 8.292384e+05  8.579712e+05  0.036578
O3 1.062626e+06  1.090502e+06  0.025124
```

Zero vs Pattern with the patch
```
   zero   pattern  diff
Os 8.292384e+05  8.338048e+05  0.00
O3 1.062626e+06  1.067574e+06  0.003193
```

Reviewers: pcc, eugenis

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365858=365857=365858=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Thu Jul 11 18:42:03 2019
@@ -1042,14 +1042,8 @@ TEST_UNINIT(intptr4, int*[4]);
 // CHECK:%uninit = alloca [4 x i32*], align
 // CHECK-NEXT:   call void @{{.*}}used{{.*}}%uninit)
 // PATTERN-O1-LABEL: @test_intptr4_uninit()
-// PATTERN-O1:   %1 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 0
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %1, align 16
-// PATTERN-O1-NEXT:  %2 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 1
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %2, align 8
-// PATTERN-O1-NEXT:  %3 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 2
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %3, align 16
-// PATTERN-O1-NEXT:  %4 = getelementptr inbounds [4 x i32*], [4 x i32*]* 
%uninit, i64 0, i64 3
-// PATTERN-O1-NEXT:  store i32* inttoptr (i64 -6148914691236517206 to i32*), 
i32** %4, align 8
+// PATTERN-O1:   %1 = bitcast [4 x i32*]* %uninit to i8*
+// PATTERN-O1-NEXT:  call void @llvm.memset.p0i8.i64(i8* nonnull align 16 %1, 
i8 -86, i64 32, i1 false)
 // ZERO-LABEL:   @test_intptr4_uninit()
 // ZERO: call void @llvm.memset{{.*}}, i8 0,
 


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


r365857 - Codegen, NFC: 32bit test in auto-var-init.cpp

2019-07-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jul 11 18:36:11 2019
New Revision: 365857

URL: http://llvm.org/viewvc/llvm-project?rev=365857=rev
Log:
Codegen, NFC: 32bit test in auto-var-init.cpp

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365857=365856=365857=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Thu Jul 11 18:36:11 2019
@@ -5,10 +5,18 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O0,ZERO,ZERO-O0
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fno-experimental-new-pass-manager 
-emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-LEGACY
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fexperimental-new-pass-manager -emit-llvm 
-o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-NEWPM
-// RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=PATTERN-I386
+// RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O0,PATTERN,PATTERN-O0
 
 #pragma clang diagnostic ignored "-Winaccessible-base"
 
+#ifdef __x86_64__
+char inits[] = 
{"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
+#else
+char inits[] = 
{"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
+#define __int128 int;
+#endif
+// PATTERN: @inits = {{.*}} 
c"[[I8:[^/]+]]/[[I16:[^/]+]]/[[I32:[^/]+]]/[[ILONGT:[^/]+]]/[[ILONG:[^/]+]]/[[I64:[^/]+]]/[[I128T:[^/]+]]/[[I128:[^/]+]]/[[IPTRT:[^/]+]]/[[IPTR:[^/]+]]/[[IC:[^/]+]]/\00",
 align 1
+
 template void used(T &) noexcept;
 
 #define TEST_UNINIT(NAME, TYPE) \
@@ -37,122 +45,118 @@ template void used(T &) noex
 // PATTERN-NOT: undef
 // ZERO-NOT: undef
 
-// PATTERN-O0: @__const.test_empty_uninit.uninit = private unnamed_addr 
constant %struct.empty { i8 -86 }, align 1
+// PATTERN-O0: @__const.test_empty_uninit.uninit = private unnamed_addr 
constant %struct.empty { i8 [[I8]] }, align 1
 // PATTERN-O1-NOT: @__const.test_empty_uninit.uninit
 struct empty {};
-// PATTERN-O0: @__const.test_small_uninit.uninit = private unnamed_addr 
constant %struct.small { i8 -86 }, align 1
+// PATTERN-O0: @__const.test_small_uninit.uninit = private unnamed_addr 
constant %struct.small { i8 [[I8]] }, align 1
 // PATTERN-O0: @__const.test_small_custom.custom = private unnamed_addr 
constant %struct.small { i8 42 }, align 1
 // ZERO-O0: @__const.test_small_custom.custom = private unnamed_addr constant 
%struct.small { i8 42 }, align 1
 // PATTERN-O1-NOT: @__const.test_small_uninit.uninit
 // PATTERN-O1-NOT: @__const.test_small_custom.custom
 // ZERO-O1-NOT: @__const.test_small_custom.custom
 struct small { char c; };
-// PATTERN-O0: @__const.test_smallinit_uninit.uninit = private unnamed_addr 
constant %struct.smallinit { i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallinit_braces.braces = private unnamed_addr 
constant %struct.smallinit { i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallinit_custom.custom = private unnamed_addr 
constant %struct.smallinit { i8 -86 }, align 1
+// PATTERN-O0: @__const.test_smallinit_uninit.uninit = private unnamed_addr 
constant %struct.smallinit { i8 [[I8]] }, align 1
+// PATTERN-O0: @__const.test_smallinit_braces.braces = private unnamed_addr 
constant %struct.smallinit { i8 [[I8]] }, align 1
+// PATTERN-O0: @__const.test_smallinit_custom.custom = private unnamed_addr 
constant %struct.smallinit { i8 [[I8]] }, align 1
 // PATTERN-O1-NOT: @__const.test_smallinit_uninit.uninit
 // PATTERN-O1-NOT: @__const.test_smallinit_braces.braces
 // PATTERN-O1-NOT: @__const.test_smallinit_custom.custom
 struct smallinit { char c = 42; };
-// PATTERN-O0: @__const.test_smallpartinit_uninit.uninit = private 
unnamed_addr constant %struct.smallpartinit { i8 -86, i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallpartinit_braces.braces = private 
unnamed_addr constant %struct.smallpartinit { i8 -86, i8 -86 }, align 1
-// PATTERN-O0: @__const.test_smallpartinit_custom.custom = private 
unnamed_addr constant %struct.smallpartinit { i8 -86, i8 -86 }, align 1
+// PATTERN-O0: @__const.test_smallpartinit_uninit.uninit = private 
unnamed_addr constant %struct.smallpartinit { i8 [[I8]], i8 [[I8]] }, align 1
+// PATTERN-O0: @__const.test_smallpartinit_braces.braces = private 
unnamed_addr constant 

Re: [PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-11 Thread Nick Desaulniers via cfe-commits
Yes, the current behavior is erroring for assembler flags clang does not
recognize, which is irrelevant when compiling with `-no-integrated-as`,
which is breaking our assembler flag feature detection in building the
Linux kernel.

On Thu, Jul 11, 2019, 6:09 PM Reid Kleckner via Phabricator <
revi...@reviews.llvm.org> wrote:

> rnk added a comment.
>
> I think the intention of this change was to ignore assembler flags in
> pre-processing actions without warning about them. It implements that
> behavior by running the code that gathers and validates assembler flags.
> The validation is whats emitting the problematic errors. I don't think
> that's desirable, so I'd recommend reverting for now.
>
>
>
> 
> Comment at: cfe/trunk/lib/Driver/ToolChains/Clang.cpp:3555
> +  // in -E mode either for example, even though it's not really used
> either.
> +  if (!isa(JA)) {
> +ArgStringList DummyArgs;
> 
> nickdesaulniers wrote:
> > Should you be checking `!TC.IsIntegratedAssemblerDefault()` additionally?
> I don't think so. We want to ignore assembler flags in a preprocessor
> action even if we're not going to use the integrated assembler.
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D64527/new/
>
> https://reviews.llvm.org/D64527
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64611: [analyzer] exploded-graph-rewriter: Improve source location dumps.

2019-07-11 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso added a comment.
This revision is now accepted and ready to land.

Much better! Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D64611



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum marked 28 inline comments as done.
quantum added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:33
+// Thread-local storage
+TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+

tlively wrote:
> quantum wrote:
> > quantum wrote:
> > > aheejin wrote:
> > > > Why is it `c`(const)? According to [[ 
> > > > https://github.com/llvm/llvm-project/blob/e6695821e592f95bffe1340b28be7bcfcce04284/clang/include/clang/Basic/Builtins.h#L104-L108
> > > >  | this comment ]], this is true if this function has no side effects 
> > > > and doesn't read memory, i.e., the result should be only dependent on 
> > > > its arguments. Can't wasm globals be memory locations in machines?
> > > I was thinking that since the global is immutable, so the value is always 
> > > a constant.
> > According to @tlively, there is no solid definition on whether a global 
> > (especially a constant one), counts as memory access. For now, I am going 
> > to change this to not constant. We can always change it back later.
> I think this requires more conversation.
We decided that this is really a constant, since this global is immutable.



Comment at: lld/test/wasm/data-layout.ll:43
+; CHECK-NEXT:   - Index:   3
+; CHECK-NEXT: Type:I32
 ; CHECK-NEXT: Mutable: false

tlively wrote:
> These globals don't have enough information to tell the reader what they even 
> are, and they don't have anything to do with the data layout, so how about 
> skipping these in the test with a comment saying what is being skipped?
Going to skip over `__tls_base` and `__tls_size`.



Comment at: lld/test/wasm/tls.ll:57
+;   memory.init 0, 0
+;   end
+

tlively wrote:
> quantum wrote:
> > aheejin wrote:
> > > Hmm, I think there might be a way to actually print disassembly results. 
> > > There are '*.test' files in test directory, in which we have some 
> > > examples. For example, [[ 
> > > https://github.com/llvm/llvm-project/blob/master/lld/test/wasm/export-table.test
> > >  | this test ]] has a sequence of commands you want to run, and you can 
> > > put input files in a separate directory. That test uses `obj2yaml`, but 
> > > can we possibly use `llvm-objdump` or something to disassemble?
> > We already know that we can do something like
> > 
> > Run: obj2yaml %t.wasm | sed -n '/Body:/{s/^\s*Body:\s*//;s/../0x& /gp}' 
> >  | llvm-mc -disassemble -triple=wasm32
> > 
> > to compare the actual assembly. As for `llvm-objdump`, it seems to be 
> > unable to disassemble the WASM properly:
> > 
> > 
> > ```
> > .../tools/lld/test/wasm/Output/tls.ll.tmp.wasm: file format WASM
> > 
> > 
> > Disassembly of section CODE:
> > 
> >  CODE:
> > # 4 functions in section.
> >1: 02 00 block   invalid_type
> >3: 0bend
> >4: 10 00 call0
> >6: 20 00 local.get   0
> >8: 24 01 global.set  1
> >a: 20 00 local.get   0
> >c: 41 00 i32.const   0
> >e: 41 08 i32.const   8
> >   10: fc 08 00 00   memory.init 0, 0
> >   14: 0bend
> >   15: 0freturn
> >   16: 00llvm-objdump: 
> > lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc:2032: void 
> > llvm::WebAssemblyInstPrinter::printInstruction(const llvm::MCInst *, 
> > llvm::raw_ostream &): Assertion `Bits != 0 && "Cannot print this 
> > instruction."' failed.
> > 
> > ```
> It might be worth filing an LLVM bug for this (or possibly fixing in a 
> separate CL).
Going to fix this at some point in the future.



Comment at: lld/wasm/Symbols.cpp:208
+if (Segment->OutputSeg->Name == ".tdata")
+  return Segment->OutputSegmentOffset + Offset;
 return Segment->OutputSeg->StartVA + Segment->OutputSegmentOffset + Offset;

tlively wrote:
> It would be great to have an explanatory comment here.
Adding a comment.



Comment at: lld/wasm/Writer.cpp:431
+error("'bulk-memory' feature must be used in order to use thread-local "
+  "storage");
+

quantum wrote:
> aheejin wrote:
> > Should we check for "mutable-global" feature too?
> Do we need to? I thought it's always available since we use it for the stack 
> pointer.
On second thought, the `mutable-global` feature is for import/export of mutable 
globals. TLS does not need to do this.



Comment at: lld/wasm/Writer.cpp:777
+  break;
+}
+

tlively wrote:
> quantum wrote:
> > aheejin wrote:
> > > Is it 

[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209391.
quantum marked 10 inline comments as done.
quantum added a comment.

Apply review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-layout.ll
  lld/test/wasm/data-segment-merging.ll
  lld/test/wasm/data-segments.ll
  lld/test/wasm/gc-imports.ll
  lld/test/wasm/gc-sections.ll
  lld/test/wasm/load-undefined.test
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,61 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory | FileCheck %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -mattr=+bulk-memory -fast-isel | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls
+define i32* @ptr_to_tls() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load
+define i32 @tls_load() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.load 0
+  ; CHECK-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store
+define void @tls_store(i32 %x) {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.store 0
+  ; CHECK-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+declare i32 @llvm.wasm.tls.size.i32()
+define i32 @tls_size() {
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; CHECK-NEXT: .section .tbss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
Index: llvm/test/CodeGen/WebAssembly/target-features-tls.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features-tls.ll
+++ llvm/test/CodeGen/WebAssembly/target-features-tls.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes CHECK,NO-ATOMICS
-; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes CHECK,ATOMICS
+; RUN: llc < %s -mattr=-bulk-memory | FileCheck %s --check-prefixes NO-BULK-MEM
+; RUN: llc < %s -mattr=+bulk-memory | FileCheck %s --check-prefixes BULK-MEM
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,18 +9,19 @@
 
 @foo = internal thread_local global i32 0
 
-; CHECK-LABEL: .custom_section.target_features,"",@
 
-; -atomics
-; NO-ATOMICS-NEXT: .int8 1
-; NO-ATOMICS-NEXT: .int8 45
-; NO-ATOMICS-NEXT: .int8 7
-; NO-ATOMICS-NEXT: .ascii "atomics"
-; NO-ATOMICS-NEXT: .bss.foo,"",@
+; -bulk-memory
+; NO-BULK-MEM-LABEL: .custom_section.target_features,"",@
+; NO-BULK-MEM-NEXT: .int8 1
+; NO-BULK-MEM-NEXT: .int8 45
+; NO-BULK-MEM-NEXT: .int8 7
+; NO-BULK-MEM-NEXT: .ascii "atomics"
+; NO-BULK-MEM-NEXT: .bss.foo,"",@
 
-; 

[PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I think the intention of this change was to ignore assembler flags in 
pre-processing actions without warning about them. It implements that behavior 
by running the code that gathers and validates assembler flags. The validation 
is whats emitting the problematic errors. I don't think that's desirable, so 
I'd recommend reverting for now.




Comment at: cfe/trunk/lib/Driver/ToolChains/Clang.cpp:3555
+  // in -E mode either for example, even though it's not really used either.
+  if (!isa(JA)) {
+ArgStringList DummyArgs;

nickdesaulniers wrote:
> Should you be checking `!TC.IsIntegratedAssemblerDefault()` additionally?
I don't think so. We want to ignore assembler flags in a preprocessor action 
even if we're not going to use the integrated assembler.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64527



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


[PATCH] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-11 Thread Bob Haarman via Phabricator via cfe-commits
inglorion added a comment.

This was suggested on D64458 .

If we take this change, D64458  can be 
simplified to just accepting -fthinlto-index= as a CoreOption without needing 
any further changes to Driver.cpp.

I also changed the error message in this change to reflect the fact that we no 
longer require -x ir; we just require the input to be a bitcode file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64610



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


[PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: cfe/trunk/lib/Driver/ToolChains/Clang.cpp:3555
+  // in -E mode either for example, even though it's not really used either.
+  if (!isa(JA)) {
+ArgStringList DummyArgs;

Should you be checking `!TC.IsIntegratedAssemblerDefault()` additionally?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64527



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


[PATCH] D64611: [analyzer] exploded-graph-rewriter: Improve source location dumps.

2019-07-11 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added a reviewer: Charusso.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Herald added a project: clang.

- Correctly display macro expansion and spelling locations.
- Use the same procedure to display location context call site locations.
- Display statement IDs for program points.

F9535526: Screen Shot 2019-07-11 at 5.07.05 PM.png 



Repository:
  rC Clang

https://reviews.llvm.org/D64611

Files:
  clang/include/clang/Basic/JsonSupport.h
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/Analysis/ProgramPoint.cpp
  clang/test/Analysis/dump_egraph.cpp
  clang/test/Analysis/exploded-graph-rewriter/environment.dot
  clang/test/Analysis/exploded-graph-rewriter/environment_diff.dot
  clang/test/Analysis/exploded-graph-rewriter/macros.c
  clang/test/Analysis/exploded-graph-rewriter/program_points.dot
  clang/test/Analysis/expr-inspection.c
  clang/utils/analyzer/exploded-graph-rewriter.py

Index: clang/utils/analyzer/exploded-graph-rewriter.py
===
--- clang/utils/analyzer/exploded-graph-rewriter.py
+++ clang/utils/analyzer/exploded-graph-rewriter.py
@@ -49,10 +49,16 @@
 class SourceLocation(object):
 def __init__(self, json_loc):
 super(SourceLocation, self).__init__()
+logging.debug('json: %s' % json_loc)
 self.line = json_loc['line']
 self.col = json_loc['column']
 self.filename = os.path.basename(json_loc['file']) \
 if 'file' in json_loc else '(main file)'
+self.spelling = SourceLocation(json_loc['spelling']) \
+if 'spelling' in json_loc else None
+
+def is_macro(self):
+return self.spelling is not None
 
 
 # A deserialized program point.
@@ -65,8 +71,10 @@
 self.src_id = json_pp['src_id']
 self.dst_id = json_pp['dst_id']
 elif self.kind == 'Statement':
+logging.debug(json_pp)
 self.stmt_kind = json_pp['stmt_kind']
 self.stmt_point_kind = json_pp['stmt_point_kind']
+self.stmt_id = json_pp['stmt_id']
 self.pointer = json_pp['pointer']
 self.pretty = json_pp['pretty']
 self.loc = SourceLocation(json_pp['location']) \
@@ -102,7 +110,8 @@
 self.lctx_id = json_frame['lctx_id']
 self.caption = json_frame['location_context']
 self.decl = json_frame['calling']
-self.line = json_frame['call_line']
+self.loc = SourceLocation(json_frame['location']) \
+if json_frame['location'] is not None else None
 
 def _key(self):
 return self.lctx_id
@@ -432,6 +441,22 @@
 return s
 return candidate
 
+@staticmethod
+def _make_sloc(loc):
+if loc is None:
+return 'Invalid Source Location'
+
+def make_plain_loc(loc):
+return '%s:%s:%s' \
+% (loc.filename, loc.line, loc.col)
+
+if loc.is_macro():
+return '%s ' \
+   '(spelling at  %s)' \
+% (make_plain_loc(loc), make_plain_loc(loc.spelling))
+
+return make_plain_loc(loc)
+
 def visit_begin_graph(self, graph):
 self._graph = graph
 self._dump_raw('digraph "ExplodedGraph" {\n')
@@ -457,29 +482,16 @@
 # Such statements show up only at [Pre|Post]StmtPurgeDeadSymbols
 skip_pretty = 'PurgeDeadSymbols' in p.stmt_point_kind
 stmt_color = 'cyan3'
-if p.loc is not None:
-self._dump(''
-   '%s:%s:%s:'
-   ''
-   '%s'
-   '%s'
-   '%s'
-   % (p.loc.filename, p.loc.line,
-  p.loc.col, color, p.stmt_kind,
-  stmt_color, p.stmt_point_kind,
-  self._short_pretty(p.pretty)
-  if not skip_pretty else ''))
-else:
-self._dump(''
-   'Invalid Source Location:'
-   ''
-   '%s'
-   '%s'
-   '%s'
-   % (color, p.stmt_kind,
-  stmt_color, p.stmt_point_kind,
-  self._short_pretty(p.pretty)
-  if not skip_pretty else ''))
+self._dump('%s:'
+   ''
+   '%s '
+   'S%s'
+   '%s'
+   '%s'
+   % (self._make_sloc(p.loc), color, p.stmt_kind,
+  p.stmt_id, stmt_color, p.stmt_point_kind,
+  self._short_pretty(p.pretty)
+   

[PATCH] D64610: [clang] allow -fthinlto-index= without -x ir

2019-07-11 Thread Bob Haarman via Phabricator via cfe-commits
inglorion created this revision.
inglorion added reviewers: tejohnson, rnk, pcc.
Herald added subscribers: arphaman, dexonsmith, steven_wu, mehdi_amini.
Herald added a project: clang.

Previously, passing -fthinlto-index= to clang required that bitcode
files be explicitly marked by -x ir. This change makes us detect files
with object file extensions as bitcode files when -fthinlto-index= is
present, so that explicitly marking them is no longer necessary.
Explicitly specifying -x ir is still accepted and continues to be part
of the test case to ensure we continue to support it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64610

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/thinlto_backend.c


Index: clang/test/Driver/thinlto_backend.c
===
--- clang/test/Driver/thinlto_backend.c
+++ clang/test/Driver/thinlto_backend.c
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 
2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 // CHECK-THINLTOBE-ACTION: -fthinlto-index=
+// CHECK-THINLTOBE-ACTION-SAME: {{"?-x"? "?ir"?}}
+
+// Check that this also works without -x ir.
+// RUN: %clang -O2 -o %t1.o %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
 
 // -save-temps should be passed to cc1
 // RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc 
-save-temps -### 2>&1 | FileCheck %s -check-prefix=CHECK-SAVE-TEMPS 
-check-prefix=CHECK-SAVE-TEMPS-CWD
@@ -15,5 +21,6 @@
 // CHECK-SAVE-TEMPS-NOT: -emit-llvm-bc
 
 // Ensure clang driver gives the expected error for incorrect input type
-// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 | 
FileCheck %s -check-prefix=CHECK-WARNING
-// CHECK-WARNING: error: invalid argument '-fthinlto-index={{.*}}' only 
allowed with '-x ir'
+// RUN: not %clang -O2 -o %t1.o %s -c -fthinlto-index=%t.thinlto.bc 2>&1 \
+// RUN: | FileCheck %s -check-prefix=CHECK-WARNING
+// CHECK-WARNING: error: option '-fthinlto-index={{.*}}' requires input to be 
LLVM bitcode
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3660,8 +3660,7 @@
 
   if (const Arg *A = Args.getLastArg(options::OPT_fthinlto_index_EQ)) {
 if (!types::isLLVMIR(Input.getType()))
-  D.Diag(diag::err_drv_argument_only_allowed_with) << A->getAsString(Args)
-   << "-x ir";
+  D.Diag(diag::err_drv_arg_requires_bitcode_input) << A->getAsString(Args);
 Args.AddLastArg(CmdArgs, options::OPT_fthinlto_index_EQ);
   }
 
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -2119,6 +2119,12 @@
   Diag(clang::diag::warn_drv_treating_input_as_cxx)
   << getTypeName(OldTy) << getTypeName(Ty);
   }
+
+  // If running with -thinlto-index=, extensions that normally identify
+  // native object files actually identify LLVM bitcode files.
+  if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ) &&
+  Ty == types::TY_Object)
+Ty = types::TY_LLVM_BC;
 }
 
 // -ObjC and -ObjC++ override the default language, but only for 
"source
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -159,6 +159,8 @@
   "cannot read configuration file '%0'">;
 def err_drv_nested_config_file: Error<
   "option '--config' is not allowed inside configuration file">;
+def err_drv_arg_requires_bitcode_input: Error<
+  "option '%0' requires input to be LLVM bitcode">;
 
 def err_target_unsupported_arch
   : Error<"the target architecture '%0' is not supported by the target '%1'">;


Index: clang/test/Driver/thinlto_backend.c
===
--- clang/test/Driver/thinlto_backend.c
+++ clang/test/Driver/thinlto_backend.c
@@ -2,8 +2,14 @@
 // RUN: llvm-lto -thinlto -o %t %t.o
 
 // -fthinlto_index should be passed to cc1
-// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### 2>&1 | FileCheck %s -check-prefix=CHECK-THINLTOBE-ACTION
+// RUN: %clang -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.thinlto.bc -### \
+// RUN: 2>&1 | 

[PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

ah, maybe the addition of `-no-integrated-as` shouldn't produce this error?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64527



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


[PATCH] D64527: driver: Don't warn about assembler flags being unused when not assembling

2019-07-11 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

> This change breaks building the Linux kernel for arm32 (at least):

Follow up discussion in https://github.com/ClangBuiltLinux/linux/issues/598.  I 
think the kernel is wrong here.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64527



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


[PATCH] D64608: [OpenCL] Make TableGen'd builtin tables and helper functions static

2019-07-11 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
tstellar added reviewers: Pierre, Anastasia.
Herald added a subscriber: yaxunl.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64608

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -207,7 +207,7 @@
 }
 
 void BuiltinNameEmitter::EmitSignatureTable() {
-  OS << "OpenCLType OpenCLSignature[] = {\n";
+  OS << "static const OpenCLType OpenCLSignature[] = {\n";
   for (auto  : SignatureSet) {
 OS << "// " << P.second << "\n";
 for (Record *R : P.first) {
@@ -222,7 +222,7 @@
 }
 
 void BuiltinNameEmitter::EmitBuiltinTable() {
-  OS << "OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
+  OS << "static const OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
   for (auto  : OverloadInfo) {
 StringRef Name = i.first;
 OS << "// " << Name << "\n";
@@ -255,7 +255,7 @@
   OS << R"(
 // Return 0 if name is not a recognized OpenCL builtin, or an index
 // into a table of declarations if it is an OpenCL builtin.
-std::pair isOpenCLBuiltin(llvm::StringRef name) {
+static std::pair isOpenCLBuiltin(llvm::StringRef name) {
 
 )";
 
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -688,7 +688,7 @@
  unsigned Len) {
 
   for (unsigned i = 0; i < Len; ++i) {
-OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
+const OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
 ASTContext  = S.Context;
 
 // Ignore this BIF if the version is incorrect.


Index: clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
===
--- clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
+++ clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
@@ -207,7 +207,7 @@
 }
 
 void BuiltinNameEmitter::EmitSignatureTable() {
-  OS << "OpenCLType OpenCLSignature[] = {\n";
+  OS << "static const OpenCLType OpenCLSignature[] = {\n";
   for (auto  : SignatureSet) {
 OS << "// " << P.second << "\n";
 for (Record *R : P.first) {
@@ -222,7 +222,7 @@
 }
 
 void BuiltinNameEmitter::EmitBuiltinTable() {
-  OS << "OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
+  OS << "static const OpenCLBuiltinDecl OpenCLBuiltins[] = {\n";
   for (auto  : OverloadInfo) {
 StringRef Name = i.first;
 OS << "// " << Name << "\n";
@@ -255,7 +255,7 @@
   OS << R"(
 // Return 0 if name is not a recognized OpenCL builtin, or an index
 // into a table of declarations if it is an OpenCL builtin.
-std::pair isOpenCLBuiltin(llvm::StringRef name) {
+static std::pair isOpenCLBuiltin(llvm::StringRef name) {
 
 )";
 
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -688,7 +688,7 @@
  unsigned Len) {
 
   for (unsigned i = 0; i < Len; ++i) {
-OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
+const OpenCLBuiltinDecl  = OpenCLBuiltins[Index - 1 + i];
 ASTContext  = S.Context;
 
 // Ignore this BIF if the version is incorrect.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D63638: [clang][NewPM] Add new pass manager RUN lines to avx512f-builtins.c

2019-07-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added a comment.

Just to make sure we're on the same page (and sorry I didn't jump in sooner)...

With the old PM, *anything* that is `always_inline` *gets* `instsimplify` run 
on it, even at -O0, even if you didn't want that. So using `-instsimplify` 
explicitly is, IMO, not any more scary of a reliance on LLVM's behavior than 
the old PM already subjected us to...

That said, if the x86 maintainers are comfortable with *only* using the new PM 
(because it has an always inliner that literally does nothing else and thus has 
an absolute minimum amount of LLVM transformations applied), I certainly don't 
have any objections. =D


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

https://reviews.llvm.org/D63638



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


r365850 - Re-Revert Devirtualize destructor of final class.

2019-07-11 Thread Jordan Rupprecht via cfe-commits
Author: rupprecht
Date: Thu Jul 11 17:32:08 2019
New Revision: 365850

URL: http://llvm.org/viewvc/llvm-project?rev=365850=rev
Log:
Re-Revert Devirtualize destructor of final class.

This reverts r365509 (git commit d088720edad9c29ee0d622b5d69092e18a9ac0bd)

This is a second revert[1] due to failures in internal test cases (shared 
offline) found during more thorough testing.

[1] Original patch commited as r364100, reverted as r364359, recommitted as 
r365509

Removed:
cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=365850=365849=365850=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Thu Jul 11 17:32:08 2019
@@ -1865,33 +1865,9 @@ static void EmitObjectDelete(CodeGenFunc
   Dtor = RD->getDestructor();
 
   if (Dtor->isVirtual()) {
-bool UseVirtualCall = true;
-const Expr *Base = DE->getArgument();
-if (auto *DevirtualizedDtor =
-dyn_cast_or_null(
-Dtor->getDevirtualizedMethod(
-Base, CGF.CGM.getLangOpts().AppleKext))) {
-  UseVirtualCall = false;
-  const CXXRecordDecl *DevirtualizedClass =
-  DevirtualizedDtor->getParent();
-  if (declaresSameEntity(getCXXRecord(Base), DevirtualizedClass)) {
-// Devirtualized to the class of the base type (the type of the
-// whole expression).
-Dtor = DevirtualizedDtor;
-  } else {
-// Devirtualized to some other type. Would need to cast the this
-// pointer to that type but we don't have support for that yet, so
-// do a virtual call. FIXME: handle the case where it is
-// devirtualized to the derived type (the type of the inner
-// expression) as in EmitCXXMemberOrOperatorMemberCallExpr.
-UseVirtualCall = true;
-  }
-}
-if (UseVirtualCall) {
-  CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, 
ElementType,
-  Dtor);
-  return;
-}
+CGF.CGM.getCXXABI().emitVirtualObjectDelete(CGF, DE, Ptr, ElementType,
+Dtor);
+return;
   }
 }
   }

Removed: cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp?rev=365849=auto
==
--- cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/devirtualize-dtor-final.cpp (removed)
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -std=c++11 %s -emit-llvm -o - 
| FileCheck %s
-
-namespace Test1 {
-  struct A { virtual ~A() {} };
-  struct B final : A {};
-  struct C : A { virtual ~C() final {} };
-  struct D { virtual ~D() final = 0; };
-  // CHECK-LABEL: define void @_ZN5Test13fooEPNS_1BE
-  void foo(B *b) {
-// CHECK: call void @_ZN5Test11BD1Ev
-delete b;
-  }
-  // CHECK-LABEL: define void @_ZN5Test14foo2EPNS_1CE
-  void foo2(C *c) {
-// CHECK: call void @_ZN5Test11CD1Ev
-delete c;
-  }
-  // CHECK-LABEL: define void @_ZN5Test14evilEPNS_1DE
-  void evil(D *p) {
-// CHECK-NOT: call void @_ZN5Test11DD1Ev
-delete p;
-  }
-}


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


[PATCH] D64607: [clang-tidy] Fix crash on end location inside macro

2019-07-11 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry updated this revision to Diff 209381.
Nathan-Huckleberry added a comment.

- Ran git-clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64607

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -132,9 +132,12 @@
   // We report the first occurence only when we find the second one.
   diag(Branches[i]->getBeginLoc(),
"repeated branch in conditional chain");
-  diag(Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0,
-  *Result.SourceManager, 
getLangOpts()),
-   "end of the original", DiagnosticIDs::Note);
+  SourceLocation End =
+  Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0,
+ *Result.SourceManager, getLangOpts());
+  if (End.isValid()) {
+diag(End, "end of the original", DiagnosticIDs::Note);
+  }
 }
 
 diag(Branches[j]->getBeginLoc(), "clone %0 starts here",
@@ -208,10 +211,12 @@
 
 if (EndLoc.isMacroID())
   EndLoc = Context.getSourceManager().getExpansionLoc(EndLoc);
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,
+getLangOpts());
 
-diag(Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,
-getLangOpts()),
- "last of these clones ends here", DiagnosticIDs::Note);
+if (EndLoc.isValid()) {
+  diag(EndLoc, "last of these clones ends here", DiagnosticIDs::Note);
+}
   }
   BeginCurrent = EndCurrent;
 }


Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -132,9 +132,12 @@
   // We report the first occurence only when we find the second one.
   diag(Branches[i]->getBeginLoc(),
"repeated branch in conditional chain");
-  diag(Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0,
-  *Result.SourceManager, getLangOpts()),
-   "end of the original", DiagnosticIDs::Note);
+  SourceLocation End =
+  Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0,
+ *Result.SourceManager, getLangOpts());
+  if (End.isValid()) {
+diag(End, "end of the original", DiagnosticIDs::Note);
+  }
 }
 
 diag(Branches[j]->getBeginLoc(), "clone %0 starts here",
@@ -208,10 +211,12 @@
 
 if (EndLoc.isMacroID())
   EndLoc = Context.getSourceManager().getExpansionLoc(EndLoc);
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,
+getLangOpts());
 
-diag(Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,
-getLangOpts()),
- "last of these clones ends here", DiagnosticIDs::Note);
+if (EndLoc.isValid()) {
+  diag(EndLoc, "last of these clones ends here", DiagnosticIDs::Note);
+}
   }
   BeginCurrent = EndCurrent;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64598: fix unnamed fiefield issue and add tests for __builtin_preserve_access_index intrinsic

2019-07-11 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 209379.
yonghong-song added a subscriber: anakryiko.
yonghong-song added a comment.

change test case so we can test metadata is generated correctly.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64598

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/builtin-preserve-access-index.c
  test/Sema/builtin-preserve-access-index.c

Index: test/Sema/builtin-preserve-access-index.c
===
--- /dev/null
+++ test/Sema/builtin-preserve-access-index.c
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -x c -triple x86_64-pc-linux-gnu -dwarf-version=4 -fsyntax-only -verify %s
+
+const void *invalid1(const int *arg) {
+  return __builtin_preserve_access_index([1], 1); // expected-error {{too many arguments to function call, expected 1, have 2}}
+}
+
+void *invalid2(const int *arg) {
+  return __builtin_preserve_access_index([1]); // expected-warning {{returning 'const void *' from a function with result type 'void *' discards qualifiers}}
+}
+
+const void *invalid3(const int *arg) {
+  return __builtin_preserve_access_index(1); // expected-warning {{incompatible integer to pointer conversion passing 'int' to parameter of type 'const void *'}}
+}
Index: test/CodeGen/builtin-preserve-access-index.c
===
--- /dev/null
+++ test/CodeGen/builtin-preserve-access-index.c
@@ -0,0 +1,177 @@
+// RUN: %clang -target x86_64 -emit-llvm -S -g %s -o - | FileCheck %s
+
+#define _(x) (__builtin_preserve_access_index(x))
+
+const void *unit1(const void *arg) {
+  return _(arg);
+}
+// CHECK: define dso_local i8* @unit1(i8* %arg)
+// CHECK-NOT: llvm.preserve.array.access.index
+// CHECK-NOT: llvm.preserve.struct.access.index
+// CHECK-NOT: llvm.preserve.union.access.index
+
+const void *unit2(void) {
+  return _((const void *)0xULL);
+}
+// CHECK: define dso_local i8* @unit2()
+// CHECK-NOT: llvm.preserve.array.access.index
+// CHECK-NOT: llvm.preserve.struct.access.index
+// CHECK-NOT: llvm.preserve.union.access.index
+
+const void *unit3(const int *arg) {
+  return _(arg + 1);
+}
+// CHECK: define dso_local i8* @unit3(i32* %arg)
+// CHECK-NOT: llvm.preserve.array.access.index
+// CHECK-NOT: llvm.preserve.struct.access.index
+// CHECK-NOT: llvm.preserve.union.access.index
+
+const void *unit4(const int *arg) {
+  return _([1]);
+}
+// CHECK: define dso_local i8* @unit4(i32* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %0, i32 0, i32 1)
+
+const void *unit5(const int *arg[5]) {
+  return _([1][2]);
+}
+// CHECK: define dso_local i8* @unit5(i32** %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32** @llvm.preserve.array.access.index.p0p0i32.p0p0i32(i32** %0, i32 0, i32 1)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.array.access.index.p0i32.p0i32(i32* %2, i32 0, i32 2)
+
+struct s1 {
+  char a;
+  int b;
+};
+
+struct s2 {
+  char a1:1;
+  char a2:1;
+  int b;
+};
+
+struct s3 {
+  char a1:1;
+  char a2:1;
+  char :6;
+  int b;
+};
+
+const void *unit6(struct s1 *arg) {
+  return _(>a);
+}
+// CHECK: define dso_local i8* @unit6(%struct.s1* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.s1s(%struct.s1* %0, i32 0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S1:[0-9]+]]
+
+const void *unit7(struct s1 *arg) {
+  return _(>b);
+}
+// CHECK: define dso_local i8* @unit7(%struct.s1* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s1s(%struct.s1* %0, i32 1, i32 1), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S1]]
+
+const void *unit8(struct s2 *arg) {
+  return _(>b);
+}
+// CHECK: define dso_local i8* @unit8(%struct.s2* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s2s(%struct.s2* %0, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S2:[0-9]+]]
+
+const void *unit9(struct s3 *arg) {
+  return _(>b);
+}
+// CHECK: define dso_local i8* @unit9(%struct.s3* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call i32* @llvm.preserve.struct.access.index.p0i32.p0s_struct.s3s(%struct.s3* %0, i32 1, i32 2), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[STRUCT_S3:[0-9]+]]
+
+union u1 {
+  char a;
+  int b;
+};
+
+union u2 {
+  char a;
+  int :32;
+  int b;
+};
+
+const void *unit10(union u1 *arg) {
+  return _(>a);
+}
+// CHECK: define dso_local i8* @unit10(%union.u1* %arg)
+// CHECK-NOT: getelementptr
+// CHECK: call %union.u1* @llvm.preserve.union.access.index.p0s_union.u1s.p0s_union.u1s(%union.u1* %0, i32 0), !dbg !{{[0-9]+}}, !llvm.preserve.access.index ![[UNION_U1:[0-9]+]]
+
+const void *unit11(union u1 *arg) {
+  return _(>b);
+}
+// CHECK: define dso_local i8* 

[PATCH] D64029: [PGO] Add PGO support at -O0 in the experimental new pass manager

2019-07-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc requested changes to this revision.
chandlerc added a comment.
This revision now requires changes to proceed.

Sorry for the delay here.

It'd be nice to land the LLVM patch first and with its own testing -- we should 
have testing for the pass builder independent of Clang (IE, in the LLVM tests).

One option would be to test it with a unittest, not sure we have pass builder 
unittests at the moment.

Probably a better option would be to define a pseudo pass name like our 
`default`, maybe `pgo`. Then you can parse the `O0` the same way we do 
for the `default` thing. when it is O0 you can call the new routine I've 
suggested below. When it is higher, you can call the existing routine much like 
the default pipeline code does. This would all be implemented inside the pass 
builder so no issues w/ using the utility code there.

This would let us much more nicely write tests for the pipeline fragment 
generated for PGO both at O0 and above -- we have tests that specifically print 
out the pipeline sequence. This makes it very easy to visualize changes to the 
pipeline. And it would let you test the O0 code path here.

The clang part of the patch (once adapted to the narrower API) seems likely to 
be good then.

I'm happy for this to be two patches (first llvm, then Clang), or one patch. 
Whatever is easier for you.




Comment at: llvm/lib/Passes/PassBuilder.cpp:576
+// dramatically increase code size.
+MPM.addPass(GlobalDCEPass());
+  }

xur wrote:
> I moved this pass under the condition when Early inline is enabled. I'm under 
> the impression that the intention is to clean up the code for the inline.
> Chandler: you added this pass. If you don't like this move, I can pull it out 
> and put it under another (Level > 0) condition.
This makes sense to me. It was probably just transcription error on my part.



Comment at: llvm/lib/Passes/PassBuilder.cpp:579-602
   if (RunProfileGen) {
 MPM.addPass(PGOInstrumentationGen(IsCS));
 
-FunctionPassManager FPM;
-FPM.addPass(
-createFunctionToLoopPassAdaptor(LoopRotatePass(), DebugLogging));
-MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
+if (Level > 0) {
+  FunctionPassManager FPM;
+  FPM.addPass(
+  createFunctionToLoopPassAdaptor(LoopRotatePass(), DebugLogging));

Rather than moving the entire routine that is really only intended for the 
innards of the pass manager to be public, I'd do something a bit more narrow...

Maybe just add pipeline method to the pass builder to generate a minimal 
pipeline suitable for O0 usage?

I think this code will be simpler to read w/o having to have the O0 conditions 
plumbed all the way through it, and the duplication is tiny.

If you want, could pull out the use bits which are common and use early exit to 
make the code more clear:

```
if (!RunProfileGen) {
  addPGOUsePasses(...);
  return;
}

...
```

(Not sure what name to use for this, but you see the idea.) Then there would be 
almost no duplication between the O0 and this code, w/o having to have the 
conditions threaded throughout.


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

https://reviews.llvm.org/D64029



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


[PATCH] D64607: [clang-tidy] Fix crash on end location inside macro

2019-07-11 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry created this revision.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.

Lexer::getLocForEndOfToken is defined to return an
invalid location if the given location is inside a macro.
Other checks conditionally warn based off location
validity. Updating this check to do the same.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64607

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp


Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -132,9 +132,10 @@
   // We report the first occurence only when we find the second one.
   diag(Branches[i]->getBeginLoc(),
"repeated branch in conditional chain");
-  diag(Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0,
-  *Result.SourceManager, 
getLangOpts()),
-   "end of the original", DiagnosticIDs::Note);
+  SourceLocation End = 
Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0, *Result.SourceManager, 
getLangOpts());
+  if(End.isValid()) {
+diag(End,"end of the original", DiagnosticIDs::Note);
+  }
 }
 
 diag(Branches[j]->getBeginLoc(), "clone %0 starts here",
@@ -208,10 +209,11 @@
 
 if (EndLoc.isMacroID())
   EndLoc = Context.getSourceManager().getExpansionLoc(EndLoc);
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, 
*Result.SourceManager,getLangOpts());
 
-diag(Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,
-getLangOpts()),
- "last of these clones ends here", DiagnosticIDs::Note);
+if(EndLoc.isValid()) {
+  diag(EndLoc,"last of these clones ends here", DiagnosticIDs::Note);
+}
   }
   BeginCurrent = EndCurrent;
 }


Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -132,9 +132,10 @@
   // We report the first occurence only when we find the second one.
   diag(Branches[i]->getBeginLoc(),
"repeated branch in conditional chain");
-  diag(Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0,
-  *Result.SourceManager, getLangOpts()),
-   "end of the original", DiagnosticIDs::Note);
+  SourceLocation End = Lexer::getLocForEndOfToken(Branches[i]->getEndLoc(), 0, *Result.SourceManager, getLangOpts());
+  if(End.isValid()) {
+diag(End,"end of the original", DiagnosticIDs::Note);
+  }
 }
 
 diag(Branches[j]->getBeginLoc(), "clone %0 starts here",
@@ -208,10 +209,11 @@
 
 if (EndLoc.isMacroID())
   EndLoc = Context.getSourceManager().getExpansionLoc(EndLoc);
+EndLoc = Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,getLangOpts());
 
-diag(Lexer::getLocForEndOfToken(EndLoc, 0, *Result.SourceManager,
-getLangOpts()),
- "last of these clones ends here", DiagnosticIDs::Note);
+if(EndLoc.isValid()) {
+  diag(EndLoc,"last of these clones ends here", DiagnosticIDs::Note);
+}
   }
   BeginCurrent = EndCurrent;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64307: [clangd] Add a missing early return in getTypeHierarchy()

2019-07-11 Thread Nathan Ridge via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365849: [clangd] Add a missing early return in 
getTypeHierarchy() (authored by nridge, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64307?vs=208317=209378#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64307

Files:
  clang-tools-extra/trunk/clangd/XRefs.cpp


Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -1230,6 +1230,8 @@
   RecursionProtectionSet RPSet;
   Optional Result =
   getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  if (!Result)
+return Result;
 
   if ((Direction == TypeHierarchyDirection::Children ||
Direction == TypeHierarchyDirection::Both) &&


Index: clang-tools-extra/trunk/clangd/XRefs.cpp
===
--- clang-tools-extra/trunk/clangd/XRefs.cpp
+++ clang-tools-extra/trunk/clangd/XRefs.cpp
@@ -1230,6 +1230,8 @@
   RecursionProtectionSet RPSet;
   Optional Result =
   getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  if (!Result)
+return Result;
 
   if ((Direction == TypeHierarchyDirection::Children ||
Direction == TypeHierarchyDirection::Both) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r365849 - [clangd] Add a missing early return in getTypeHierarchy()

2019-07-11 Thread Nathan Ridge via cfe-commits
Author: nridge
Date: Thu Jul 11 17:24:45 2019
New Revision: 365849

URL: http://llvm.org/viewvc/llvm-project?rev=365849=rev
Log:
[clangd] Add a missing early return in getTypeHierarchy()

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/XRefs.cpp

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=365849=365848=365849=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Thu Jul 11 17:24:45 2019
@@ -1230,6 +1230,8 @@ getTypeHierarchy(ParsedAST , Positio
   RecursionProtectionSet RPSet;
   Optional Result =
   getTypeAncestors(*CXXRD, AST.getASTContext(), RPSet);
+  if (!Result)
+return Result;
 
   if ((Direction == TypeHierarchyDirection::Children ||
Direction == TypeHierarchyDirection::Both) &&


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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-11 Thread Guanzhong Chen via Phabricator via cfe-commits
quantum updated this revision to Diff 209376.
quantum added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64537

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  lld/test/wasm/data-layout.ll
  lld/test/wasm/data-segment-merging.ll
  lld/test/wasm/data-segments.ll
  lld/test/wasm/gc-imports.ll
  lld/test/wasm/gc-sections.ll
  lld/test/wasm/load-undefined.test
  lld/test/wasm/tls.ll
  lld/wasm/Driver.cpp
  lld/wasm/Symbols.cpp
  lld/wasm/Symbols.h
  lld/wasm/Writer.cpp
  llvm/include/llvm/BinaryFormat/Wasm.h
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/include/llvm/MC/MCSectionWasm.h
  llvm/lib/Target/WebAssembly/WebAssemblyFastISel.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISD.def
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
  llvm/lib/Target/WebAssembly/WebAssemblyInstrInfo.td
  llvm/lib/Target/WebAssembly/WebAssemblyMCInstLower.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/test/CodeGen/WebAssembly/target-features-tls.ll
  llvm/test/CodeGen/WebAssembly/tls.ll

Index: llvm/test/CodeGen/WebAssembly/tls.ll
===
--- llvm/test/CodeGen/WebAssembly/tls.ll
+++ llvm/test/CodeGen/WebAssembly/tls.ll
@@ -1,17 +1,61 @@
-; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals -wasm-keep-registers | FileCheck --check-prefix=SINGLE %s
+; RUN: llc < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
+; RUN: llc -O0 < %s -asm-verbose=false -disable-wasm-fallthrough-return-opt -wasm-disable-explicit-locals | FileCheck %s
 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
 target triple = "wasm32-unknown-unknown"
 
-; SINGLE-LABEL: address_of_tls:
+; CHECK-LABEL: address_of_tls:
 define i32 @address_of_tls() {
-  ; SINGLE: i32.const $push0=, tls
-  ; SINGLE-NEXT: return $pop0
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
   ret i32 ptrtoint(i32* @tls to i32)
 }
 
-; SINGLE: .type	tls,@object
-; SINGLE-NEXT: .section	.bss.tls,"",@
-; SINGLE-NEXT: .p2align 2
-; SINGLE-NEXT: tls:
-; SINGLE-NEXT: .int32 0
-@tls = internal thread_local global i32 0
+; CHECK-LABEL: ptr_to_tls
+define i32* @ptr_to_tls() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: return
+  ret i32* @tls
+}
+
+; CHECK-LABEL: tls_load
+define i32 @tls_load() {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.load 0
+  ; CHECK-NEXT: return
+  %tmp = load i32, i32* @tls, align 4
+  ret i32 %tmp
+}
+
+; CHECK-LABEL: tls_store
+define void @tls_store(i32 %x) {
+  ; CHECK-DAG: global.get __tls_base
+  ; CHECK-DAG: i32.const tls
+  ; CHECK-NEXT: i32.add
+  ; CHECK-NEXT: i32.store 0
+  ; CHECK-NEXT: return
+  store i32 %x, i32* @tls, align 4
+  ret void
+}
+
+; CHECK-LABEL: tls_size:
+; CHECK-NEXT: .functype tls_size () -> (i32)
+; CHECK-NEXT: global.get __tls_size
+; CHECK-NEXT: return
+declare i32 @llvm.wasm.tls.size.i32()
+define i32 @tls_size() {
+  %1 = call i32 @llvm.wasm.tls.size.i32()
+  ret i32 %1
+}
+
+; CHECK: .type tls,@object
+; CHECK-NEXT: .section .tbss.tls,"",@
+; CHECK-NEXT: .p2align 2
+; CHECK-NEXT: tls:
+; CHECK-NEXT: .int32 0
+@tls = internal thread_local(localexec) global i32 0
Index: llvm/test/CodeGen/WebAssembly/target-features-tls.ll
===
--- llvm/test/CodeGen/WebAssembly/target-features-tls.ll
+++ llvm/test/CodeGen/WebAssembly/target-features-tls.ll
@@ -1,5 +1,5 @@
-; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes CHECK,NO-ATOMICS
-; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes CHECK,ATOMICS
+; RUN: llc < %s -mattr=-atomics | FileCheck %s --check-prefixes NO-ATOMICS
+; RUN: llc < %s -mattr=+atomics | FileCheck %s --check-prefixes ATOMICS
 
 ; Test that the target features section contains -atomics or +atomics
 ; for modules that have thread local storage in their source.
@@ -9,16 +9,13 @@
 
 @foo = internal thread_local global i32 0
 
-; CHECK-LABEL: .custom_section.target_features,"",@
 
 ; -atomics
-; NO-ATOMICS-NEXT: .int8 1
-; NO-ATOMICS-NEXT: .int8 45
-; NO-ATOMICS-NEXT: .int8 7
-; NO-ATOMICS-NEXT: .ascii "atomics"
-; NO-ATOMICS-NEXT: .bss.foo,"",@
+; NO-ATOMICS-NOT: .custom_section.target_features,"",@
+; NO-ATOMICS: .tbss.foo,"",@
 
 ; +atomics
+; ATOMICS-LABEL: .custom_section.target_features,"",@
 ; ATOMICS-NEXT: .int8 1
 ; ATOMICS-NEXT: .int8 43
 ; ATOMICS-NEXT: .int8 7
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

r365845 - [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Thu Jul 11 16:49:39 2019
New Revision: 365845

URL: http://llvm.org/viewvc/llvm-project?rev=365845=rev
Log:
[CMake][Fuchsia] Use RelWithDebInfo to build runtimes

We want to preserve debug info in our runtimes to aid symbolization and
debugging; for shared libraries this will be stripped away during
install-stripped step and distributed via .build-id, for static archives
it's part of the archive and it's a responsibility of the consumer to
strip it away in the final binary if not needed.

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

Modified:
cfe/trunk/cmake/caches/Fuchsia-stage2.cmake

Modified: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/caches/Fuchsia-stage2.cmake?rev=365845=365844=365845=diff
==
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake (original)
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake Thu Jul 11 16:49:39 2019
@@ -58,7 +58,7 @@ foreach(target aarch64-unknown-linux-gnu
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -67,7 +67,7 @@ foreach(target aarch64-unknown-linux-gnu
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -107,7 +107,7 @@ if(FUCHSIA_SDK)
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
@@ -119,7 +119,7 @@ if(FUCHSIA_SDK)
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-unknown-fuchsia")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")


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


[PATCH] D64605: [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365845: [CMake][Fuchsia] Use RelWithDebInfo to build 
runtimes (authored by phosek, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64605?vs=209372=209373#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64605

Files:
  cfe/trunk/cmake/caches/Fuchsia-stage2.cmake


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
@@ -119,7 +119,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-unknown-fuchsia")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")


Index: cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
===
--- cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
+++ cfe/trunk/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
-

[clang-tools-extra] r365844 - [clangd] Fix MSVC build failure.

2019-07-11 Thread Paul Robinson via cfe-commits
Author: probinson
Date: Thu Jul 11 16:48:06 2019
New Revision: 365844

URL: http://llvm.org/viewvc/llvm-project?rev=365844=rev
Log:
[clangd] Fix MSVC build failure.

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/26898

Modified:
clang-tools-extra/trunk/clangd/AST.cpp

Modified: clang-tools-extra/trunk/clangd/AST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=365844=365843=365844=diff
==
--- clang-tools-extra/trunk/clangd/AST.cpp (original)
+++ clang-tools-extra/trunk/clangd/AST.cpp Thu Jul 11 16:48:06 2019
@@ -184,7 +184,7 @@ std::string shortenNamespace(const llvm:
 DifferentAt++;
   }
 
-  for (u_int i = DifferentAt; i < OriginalParts.size(); ++i) {
+  for (unsigned i = DifferentAt; i < OriginalParts.size(); ++i) {
 Result.push_back(OriginalParts[i]);
   }
   return join(Result, "::");


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


[PATCH] D64605: [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr accepted this revision.
mcgrathr added a comment.
This revision is now accepted and ready to land.

Lgtm


Repository:
  rC Clang

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

https://reviews.llvm.org/D64605



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


[PATCH] D64605: [CMake][Fuchsia] Use RelWithDebInfo to build runtimes

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: mcgrathr.
Herald added subscribers: cfe-commits, aprantl, mgorny.
Herald added a project: clang.

We want to preserve debug info in our runtimes to aid symbolization and
debugging; for shared libraries this will be stripped away during
install-stripped step and distributed via .build-id, for static archives
it's part of the archive and it's a responsibility of the consumer to
strip it away in the final binary if not needed.


Repository:
  rC Clang

https://reviews.llvm.org/D64605

Files:
  clang/cmake/caches/Fuchsia-stage2.cmake


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(BUILTINS_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_CXX_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
@@ -119,7 +119,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}-unknown-fuchsia")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE 
STRING "")
-set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE Release CACHE 
STRING "")
+set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_TYPE RelWithDebInfo 
CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON 
CACHE BOOL "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_ASM_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")
 set(RUNTIMES_${target}-unknown-fuchsia_CMAKE_C_FLAGS 
${FUCHSIA_${target}_COMPILER_FLAGS} CACHE STRING "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -58,7 +58,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}")
 set(BUILTINS_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(BUILTINS_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(BUILTINS_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(BUILTINS_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -67,7 +67,7 @@
 # Set the per-target runtimes options.
 list(APPEND RUNTIME_TARGETS "${target}")
 set(RUNTIMES_${target}_CMAKE_SYSTEM_NAME Linux CACHE STRING "")
-set(RUNTIMES_${target}_CMAKE_BUILD_TYPE Release CACHE STRING "")
+set(RUNTIMES_${target}_CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SYSROOT ${LINUX_${target}_SYSROOT} CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_SHARED_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
 set(RUNTIMES_${target}_CMAKE_MODULE_LINKER_FLAGS "-fuse-ld=lld" CACHE STRING "")
@@ -107,7 +107,7 @@
 # Set the per-target builtins options.
 list(APPEND BUILTIN_TARGETS "${target}-unknown-fuchsia")
 set(BUILTINS_${target}-unknown-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")

[PATCH] D64277: [X86][PowerPC] Support -mlong-double-128

2019-07-11 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 with suggestion




Comment at: lib/Driver/ToolChains/Clang.cpp:4009
 TC.getArch() == llvm::Triple::ppc || TC.getTriple().isPPC64()) {
-  CmdArgs.push_back("-mlong-double-64");
+  CmdArgs.push_back(A->getOption().matches(options::OPT_mlong_double_64)
+? "-mlong-double-64"

There should be a shorthand for passing through the argument, `A->render()` or 
something.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64277



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


[PATCH] D64062: Remove both -dumpversion and __VERSION__

2019-07-11 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D64062#1581662 , @sylvestre.ledru 
wrote:

> In D64062#1581290 , @rnk wrote:
>
> > Perhaps we should just remove `__VERSION__` and keep `-dumpversion`.
>
>
> As you wish. clang --version seems an alternative and dumpversion never 
> //worked// for clang. so, I don't expect software to use it for clang.


That's true, but users seem to want some programmatic way to extract the 
compiler version number without having to resort to sed & co, and we don't 
provide that right now. `-dumpversion` can easily be the name for that feature.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64062



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


[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-11 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:1448
 
+def RequireDesignatedInitDocs : Documentation {
+  let Category = DocCatType;

aaron.ballman wrote:
> The behavior should be documented as to what happens when you apply these 
> attributes to unions.
For now, adding a `requires_init` attribute to a field of a union will result 
in a warning that the attribute is ignored. In the future, I might submit 
another patch in the future adding behavior for this attribute for fields of a 
union.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64380



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


[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

In D64448#1581771 , @gribozavr wrote:

> In D64448#1581719 , @mgehre wrote:
>
> > In D64448#159 , @gribozavr 
> > wrote:
> >
> > > I don't know how various versions of libstdc++ differ.
> >
> >
> > The current implementation passed the (partial) test case
> >  
> > https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
> >  for different standard libraries, namely libc++ 7.1.0, libc++ 8.0.1rc2, 
> > libstdc++ 4.6.4, libstdc++ 4.8.5,
> >  libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
> >  libstdc++ 8.3.0 and libstdc++ 9.1.0.
>
>
> Yes, I saw the testcase -- but how do different libstdc++ versions differ?


I didn't know whether they would differ, but the test tells me that they don't 
differ significantly (i.e. in introducing new techniques). 
Would you like me to test with other standard libraries (besides MSVC, which I 
already planned)?




Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

gribozavr wrote:
> mgehre wrote:
> > gribozavr wrote:
> > > I'd suggest to split type trait implementations into a separate patch.
> > > 
> > > Are these type traits being exposed only for testing? I'm not sure it is 
> > > a good idea to do that -- people will end up using them in production 
> > > code -- is that a concern? If so, maybe it would be better to test 
> > > through warnings.
> > I copied that approach from https://reviews.llvm.org/D50119.
> > If people do it in production code, then at least the two leading 
> > underscores should tell them "I'm not supposed to use this".
> > 
> > I considered a test through warnings, but how would I trigger them? Add 
> > `-Wlifetime-categories-debug` which emits notes whenever a 
> > [[gsl::Owner/Pointer]] is implicitly/explicitly attached to class?
> > If people do it in production code, then at least the two leading 
> > underscores should tell them "I'm not supposed to use this".
> 
> That's not what two underscores mean. These custom type traits, being 
> language extensions, must have a name that won't collide with any 
> user-defined name, hence two underscores. Two underscores mean nothing about 
> whether the user is allowed to use it or not. Sure the code might become 
> non-portable to other compilers, but that's not what the concern is. My 
> concern is that code that people write might become unportable to future 
> versions of Clang, where we would have to change behavior of these type 
> traits (or it would just subtly change in some corner case and we won't 
> notice since we don't consider it a public API).
> 
> > I considered a test through warnings, but how would I trigger them?
> 
> I meant regular warnings, that are the objective of this analysis -- warnings 
> about dereferencing dangling pointers. If we get those warnings for the 
> types-under-test, then obviously they have the correct annotations from the 
> compiler's point of view.
I spent a lot of time debugging on the full lifetime analysis, and knowing 
exactly which type has which Attribute (especially if inference is involved) 
was quite important.
I would say that adding additional code to trigger a real lifetime warning 
- requires that we first add some lifetime warnings to clang (currently in a 
different PR)
- obscures the purpose of the check, i.e. checking the attributes and not the 
warnings themselves
- and makes debugging hard when the test fails (warnings involve at least one 
Owner and one Pointer, so either of those could have made the test fail)
I'd prefer if we can test the attributes directly.



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

gribozavr wrote:
> mgehre wrote:
> > gribozavr wrote:
> > > This test and related code changes could be split off into a separate 
> > > patch.
> > I was thinking whether it made sense to separate
> > - fixing the AST dump of attributes with optional type parameter when there 
> > is not such attribute
> > - introduce and attribute with optional type parameter while AST dumping it 
> > is broken
> > so I decided that both are closely related. Otherwise the fix and its test 
> > are in separate PRs?
> Totally makes sense to have the fix and the test is the same PR, but they 
> seem to be separable from attribute inference for std types, right?
Yes, you are right. And Aaron would like to have the type parameter already 
optional in D63954, so I will move this part over there.



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace 

[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 209370.
mgehre marked 9 inline comments as done.
mgehre added a comment.

- Implement comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64448

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/test/SemaCXX/attr-gsl-owner-pointer.cpp

Index: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
===
--- clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
+++ clang/test/SemaCXX/attr-gsl-owner-pointer.cpp
@@ -83,14 +83,14 @@
 static_assert(__is_gsl_pointer(int &), "");
 static_assert(__is_gsl_pointer(int *), "");
 
-// Test builtin annotation for std types.
+// Test builtin attributes for std types.
 namespace std {
-// Complete class
+// Attributes are added to a (complete) class.
 class any {
 };
 static_assert(__is_gsl_owner(any), "");
 
-// Complete template
+// Attributes are added to a instantiatons of a complete template.
 template 
 class vector {
 public:
@@ -99,45 +99,60 @@
 static_assert(__is_gsl_owner(vector), "");
 static_assert(__is_gsl_pointer(vector::iterator), "");
 
+// If std::container::iterator is a using declaration, Attributes are added to
+// the underlying class
 template 
-class set_iterator {};
+class __set_iterator {};
 
 template 
 class set {
 public:
-  using iterator = set_iterator;
+  using iterator = __set_iterator;
 };
 static_assert(__is_gsl_pointer(set::iterator), "");
 
+// If std::container::iterator is a typedef, Attributes are added to the
+// underlying class. Inline namespaces are ignored when checking if
+// the class lives in the std namespace.
+inline namespace inlinens {
 template 
-class map_iterator {};
+class __map_iterator {};
 
 template 
 class map {
 public:
-  typedef map_iterator iterator;
+  typedef __map_iterator iterator;
 };
+} // namespace inlinens
 static_assert(__is_gsl_pointer(map::iterator), "");
 
-// list has an implicit gsl::Owner attribute,
+// std::list has an implicit gsl::Owner attribute,
 // but explicit attributes take precedence.
 template 
 class [[gsl::Pointer]] list{};
 static_assert(!__is_gsl_owner(list), "");
 static_assert(__is_gsl_pointer(list), "");
 
-// Forward declared template
+// Forward declared template (Owner)
 template <
 class CharT,
 class Traits>
 class basic_regex;
 static_assert(__is_gsl_owner(basic_regex), "");
 
+// Forward declared template (Pointer)
 template 
 class reference_wrapper;
 static_assert(__is_gsl_pointer(reference_wrapper), "");
 
-class thread;
-static_assert(!__is_gsl_pointer(thread), "");
-static_assert(!__is_gsl_owner(thread), "");
+class some_unknown_type;
+static_assert(!__is_gsl_pointer(some_unknown_type), "");
+static_assert(!__is_gsl_owner(some_unknown_type), "");
 } // namespace std
+
+namespace user {
+// If a class is not in the std namespace, we don't add implicit attributes.
+class any {
+};
+static_assert(!__is_gsl_owner(any), "");
+} // namespace user
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4164,7 +4164,7 @@
 When annotating a class ``O`` with ``[[gsl::Owner(T)]]``, then each function
 that returns cv-qualified ``T&`` or ``T*`` is assumed to return a
 pointer/reference to the data owned by ``O``. The owned data is assumed to end
-its lifetime once the owning object's lifetime ends. The argument is ``T`` is
+its lifetime once the owning object's lifetime ends. The argument ``T`` is
 optional.
 
 This attribute may be used by analysis tools but will not have effect on code
@@ -4177,7 +4177,7 @@
   let Content = [{
 When annotating a class with ``[[gsl::Pointer(T)]]``, it assumed to be a
 non-owning type whose objects can point to ``T`` type objects or dangle.
-The argument is ``T`` is optional.
+The argument ``T`` is optional.
 
 This attribute may be used by analysis tools but will not have effect on code
 generation.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64586: [WebAssembly] Make pthread imply bulk-memory, mutable-globals

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 209369.
tlively added a comment.

- and other comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64586

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, +mutable-globals, and 
--shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
+// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
+// '-pthread' not allowed with '-mno-mutable-globals'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
+// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with 
'-mno-mutable-globals'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies atomics, bulk-memory, and mutable-globals
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,22 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
+if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+   options::OPT_mmutable_globals, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-mutable-globals";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+mutable-globals");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, +mutable-globals, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not 

[PATCH] D64586: [WebAssembly] Make pthread imply bulk-memory, mutable-globals

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 209367.
tlively added a comment.

- Update comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64586

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
+// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
+// '-pthread' not allowed with '-mno-mutable-globals'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
+// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with 
'-mno-mutable-globals'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies atomics, bulk-memory, and mutable-globals
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,22 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
+if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+   options::OPT_mmutable_globals, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-mutable-globals";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+mutable-globals");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: 

[PATCH] D64586: [WebAssembly] Make pthread imply bulk-memory, mutable-globals

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 209365.
tlively added a comment.

- Add mutable-globals


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64586

Files:
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" 
"-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with 
'-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-bulk-memory 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_BULK_MEM %s
+// PTHREAD_NO_BULK_MEM: invalid argument '-pthread' not allowed with 
'-mno-bulk-memory'
+
+// '-pthread' not allowed with '-mno-mutable-globals'
+// RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
+// RUN: --sysroot=/foo %s -pthread -mno-mutable-globals 2>&1 \
+// RUN:   | FileCheck -check-prefix=PTHREAD_NO_MUT_GLOBALS %s
+// PTHREAD_NO_MUT_GLOBALS: invalid argument '-pthread' not allowed with 
'-mno-mutable-globals'
+
 // RUN: %clang %s -### -fsanitize=address -target wasm32-unknown-emscripten 
2>&1 | FileCheck -check-prefix=CHECK-ASAN-EMSCRIPTEN %s
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize=address"
 // CHECK-ASAN-EMSCRIPTEN: "-fsanitize-address-globals-dead-stripping"
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -141,7 +141,7 @@
  options::OPT_fno_use_init_array, true))
 CC1Args.push_back("-fuse-init-array");
 
-  // '-pthread' implies '-target-feature +atomics'
+  // '-pthread' implies target features atomics and bulk-memory
   if (DriverArgs.hasFlag(options::OPT_pthread, options::OPT_no_pthread,
  false)) {
 if (DriverArgs.hasFlag(options::OPT_mno_atomics, options::OPT_matomics,
@@ -149,8 +149,22 @@
   getDriver().Diag(diag::err_drv_argument_not_allowed_with)
   << "-pthread"
   << "-mno-atomics";
+if (DriverArgs.hasFlag(options::OPT_mno_bulk_memory,
+   options::OPT_mbulk_memory, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-bulk-memory";
+if (DriverArgs.hasFlag(options::OPT_mno_mutable_globals,
+   options::OPT_mmutable_globals, false))
+  getDriver().Diag(diag::err_drv_argument_not_allowed_with)
+  << "-pthread"
+  << "-mno-mutable-globals";
 CC1Args.push_back("-target-feature");
 CC1Args.push_back("+atomics");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+bulk-memory");
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+mutable-globals");
   }
 }
 


Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -48,11 +48,11 @@
 
 // Thread-related command line tests.
 
-// '-pthread' sets '-target-feature +atomics' and '--shared-memory'
+// '-pthread' sets +atomics, +bulk-memory, and --shared-memory
 // RUN: %clang -### -no-canonical-prefixes -target wasm32-unknown-unknown \
 // RUN:--sysroot=/foo %s -fuse-ld=wasm-ld -pthread 2>&1 \
 // RUN:  | FileCheck -check-prefix=PTHREAD %s
-// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics"
+// PTHREAD: clang{{.*}}" "-cc1" {{.*}} "-target-feature" "+atomics" "-target-feature" "+bulk-memory" "-target-feature" "+mutable-globals"
 // PTHREAD: wasm-ld{{.*}}" "-lpthread" "--shared-memory"
 
 // '-pthread' not allowed with '-mno-atomics'
@@ -61,6 +61,18 @@
 // RUN:   | FileCheck -check-prefix=PTHREAD_NO_ATOMICS %s
 // PTHREAD_NO_ATOMICS: invalid argument '-pthread' not allowed with '-mno-atomics'
 
+// '-pthread' not allowed with '-mno-bulk-memory'
+// 

[PATCH] D64562: [clangd] Fixed toHalfOpenFileRange

2019-07-11 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah added inline comments.



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:410
+// Test for functions toHalfOpenFileRange and getHalfOpenFileRange
+// FIXME: Need better testing support to be able to check more than just Decls.
+TEST(SourceCodeTests, HalfOpenFileRange) {

sammccall wrote:
> this is a function on ranges, so only using decls isn't a limitation per se.
> 
> Is there a type of range you're unable to test because you can't construct it 
> as the source range of a decl? If so, please say which. If not I think we 
> should just drop this comment.
e.g. Nested template instantiation (TemplateSpecializationTypeLoc)



Comment at: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp:421
+  $c[[FOO(b, c)]]; 
+  $d[[FOO(BAR(BAR(b)), d)]];
+}

sammccall wrote:
> some tests where the expansion range is a macro arg? e.g.
> ```
> #define ECHO(X) X
> ECHO($e[[ECHO(int) ECHO(e)]])
> ```
> 
> (if I'm understanding right)
In this case, the FileRange would be

```
ECHO(ECHO($e[[int) ECHO(e]]));
```

So the code works correctly. But it's not how we want it to behave right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64562



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


[PATCH] D64562: [clangd] Fixed toHalfOpenFileRange

2019-07-11 Thread Shaurya Gupta via Phabricator via cfe-commits
SureYeaah updated this revision to Diff 209363.
SureYeaah marked 12 inline comments as done.
SureYeaah added a comment.

Added comments and minor changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64562

Files:
  clang-tools-extra/clangd/SourceCode.cpp
  clang-tools-extra/clangd/SourceCode.h
  clang-tools-extra/clangd/unittests/SourceCodeTests.cpp

Index: clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
===
--- clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -10,6 +10,7 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "TestTU.h"
+#include "clang/Basic/LangOptions.h"
 #include "clang/Format/Format.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/raw_os_ostream.h"
@@ -421,6 +422,53 @@
   EXPECT_THAT(*Result, MacroName("MACRO"));
 }
 
+// Test for functions toHalfOpenFileRange and getHalfOpenFileRange
+// FIXME: Need better testing support to be able to check more than just Decls.
+// e.g. TemplateSpecializationTypeLoc SourceRange in nested templates.
+TEST(SourceCodeTests, HalfOpenFileRange) {
+  // Each marked range should be the file range of the decl with the same name
+  // and each name should be unique.
+  Annotations Test(R"cpp(
+#define FOO(X, Y) int Y = ++X
+#define BAR(X) X + 1
+#define ECHO(X) X
+template
+class P {};
+void f() {
+  $a[[P a]];
+  $b[[int b = 1]];
+  $c[[FOO(b, c)]]; 
+  $d[[FOO(BAR(BAR(b)), d)]];
+  // FIXME: We might want to select everything inside the outer ECHO.
+  ECHO(ECHO($e[[int) ECHO(e]]));
+}
+  )cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();
+  const SourceManager  = AST.getSourceManager();
+  const LangOptions  = AST.getASTContext().getLangOpts();
+  // Turn a SourceLocation into a pair of positions
+  auto SourceRangeToRange = [](SourceRange SrcRange) {
+return Range{sourceLocToPosition(SM, SrcRange.getBegin()),
+ sourceLocToPosition(SM, SrcRange.getEnd())};
+  };
+  auto CheckRange = [&](llvm::StringRef Name) {
+const NamedDecl  = findUnqualifiedDecl(AST, Name);
+auto FileRange = toHalfOpenFileRange(SM, LangOpts, Decl.getSourceRange());
+SCOPED_TRACE("Checking range: " + Name);
+ASSERT_NE(FileRange, llvm::None);
+Range HalfOpenRange = SourceRangeToRange(*FileRange);
+EXPECT_EQ(HalfOpenRange, Test.ranges(Name)[0]);
+  };
+
+  CheckRange("a");
+  CheckRange("b");
+  CheckRange("c");
+  CheckRange("d");
+  CheckRange("e");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SourceCode.h
===
--- clang-tools-extra/clangd/SourceCode.h
+++ clang-tools-extra/clangd/SourceCode.h
@@ -20,8 +20,9 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/Format/Format.h"
 #include "clang/Tooling/Core/Replacement.h"
-#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/StringSet.h"
+#include "llvm/Support/SHA1.h"
 
 namespace clang {
 class SourceManager;
Index: clang-tools-extra/clangd/SourceCode.cpp
===
--- clang-tools-extra/clangd/SourceCode.cpp
+++ clang-tools-extra/clangd/SourceCode.cpp
@@ -12,6 +12,8 @@
 #include "Logger.h"
 #include "Protocol.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/TokenKinds.h"
 #include "clang/Format/Format.h"
@@ -244,20 +246,106 @@
   return L == R.getEnd() || halfOpenRangeContains(Mgr, R, L);
 }
 
-llvm::Optional toHalfOpenFileRange(const SourceManager ,
+static unsigned getTokenLengthAtLoc(SourceLocation Loc, const SourceManager ,
+const LangOptions ) {
+  Token TheTok;
+  if (Lexer::getRawToken(Loc, TheTok, SM, LangOpts))
+return 0;
+  // FIXME: Here we check whether the token at the location is a greatergreater
+  // (>>) token and consider it as a single greater (>). This is to get it
+  // working for templates but it isn't correct for the right shift operator. We
+  // can avoid this by using half open char ranges in getFileRange() but getting
+  // token ending is not well supported in macroIDs.
+  if (TheTok.is(tok::greatergreater))
+return 1;
+  return TheTok.getLength();
+}
+
+// Returns location of the last character of the token at a given loc
+static SourceLocation getLocForTokenEnd(SourceLocation BeginLoc,
+const SourceManager ,
+const LangOptions ) {
+  unsigned Len = getTokenLengthAtLoc(BeginLoc, SM, LangOpts);
+  return BeginLoc.getLocWithOffset(Len ? Len - 1 : 0);
+}
+
+// 

[PATCH] D64603: [Target] Use IEEE quad format for long double on Fuchsia x86_64

2019-07-11 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, jakehehrlich.
Herald added subscribers: cfe-commits, kristof.beyls, javed.absar.
Herald added a project: clang.

This change unifies the long double format between x86_64 and aarch64
targets making it easier to write code that's independent of the target.


Repository:
  rC Clang

https://reviews.llvm.org/D64603

Files:
  clang/lib/Basic/Targets.cpp
  clang/lib/Basic/Targets/X86.h


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -848,6 +848,18 @@
 
   const char *getLongDoubleMangling() const override { return "g"; }
 };
+
+// x86_64 Fuchsia target
+class LLVM_LIBRARY_VISIBILITY FuchsiaX86_64TargetInfo
+: public FuchsiaTargetInfo {
+public:
+  FuchsiaX86_64TargetInfo(const llvm::Triple , const TargetOptions 
)
+  : FuchsiaTargetInfo(Triple, Opts) {
+LongDoubleFormat = ::APFloat::IEEEquad();
+  }
+};
+
 } // namespace targets
 } // namespace clang
+
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -517,7 +517,7 @@
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
+  return new FuchsiaX86_64TargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Solaris:


Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -848,6 +848,18 @@
 
   const char *getLongDoubleMangling() const override { return "g"; }
 };
+
+// x86_64 Fuchsia target
+class LLVM_LIBRARY_VISIBILITY FuchsiaX86_64TargetInfo
+: public FuchsiaTargetInfo {
+public:
+  FuchsiaX86_64TargetInfo(const llvm::Triple , const TargetOptions )
+  : FuchsiaTargetInfo(Triple, Opts) {
+LongDoubleFormat = ::APFloat::IEEEquad();
+  }
+};
+
 } // namespace targets
 } // namespace clang
+
 #endif // LLVM_CLANG_LIB_BASIC_TARGETS_X86_H
Index: clang/lib/Basic/Targets.cpp
===
--- clang/lib/Basic/Targets.cpp
+++ clang/lib/Basic/Targets.cpp
@@ -517,7 +517,7 @@
 case llvm::Triple::FreeBSD:
   return new FreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Fuchsia:
-  return new FuchsiaTargetInfo(Triple, Opts);
+  return new FuchsiaX86_64TargetInfo(Triple, Opts);
 case llvm::Triple::KFreeBSD:
   return new KFreeBSDTargetInfo(Triple, Opts);
 case llvm::Triple::Solaris:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-11 Thread Emmett Neyman via Phabricator via cfe-commits
emmettneyman updated this revision to Diff 209362.
emmettneyman marked 2 inline comments as done.
emmettneyman added a comment.

Added documentation about using the attributes with unions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64380

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaCXX/attr-requires-designator.cpp
  clang/test/SemaCXX/attr-requires-init.cpp

Index: clang/test/SemaCXX/attr-requires-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-requires-init.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+[[clang::requires_init]] int x;// expected-warning{{'requires_init' attribute only applies to non-static data members}}
+[[clang::requires_init]] void fun(int x) { // expected-warning{{'requires_init' attribute only applies to non-static data members}}
+  return;
+}
+struct [[clang::requires_init]] Foo { // expected-warning{{'requires_init' attribute only applies to non-static data members}}
+  int x;
+};
+
+// Struct with one required field
+struct Bar {
+  [[clang::requires_init]] int y; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+};
+
+// The following are invalid ways of initializing instances of this struct.
+Bar b1;// expected-warning{{initializer for variable b1 must explicitly initialize field y}}
+Bar b2{};  // expected-warning{{initializer for variable b2 must explicitly initialize field y}}
+Bar b3{1}; // expected-warning{{initializer for variable b3 must explicitly initialize field y}}
+
+// The following are valid ways of initializing instances of this struct.
+Bar b6{.y = 1};
+
+// Struct with multiple required fields
+struct Baz {
+  [[clang::requires_init]] int x; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+  int y;
+  [[clang::requires_init]] int z; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+};
+
+// The following are invalid ways of initializing instances of this struct.
+Baz z1; // expected-warning{{initializer for variable z1 must explicitly initialize field x}} expected-warning{{initializer for variable z1 must explicitly initialize field z}}
+Baz z2{};   // expected-warning{{initializer for variable z2 must explicitly initialize field x}} expected-warning{{initializer for variable z2 must explicitly initialize field z}}
+Baz z3{1, 2};   // expected-warning{{initializer for variable z3 must explicitly initialize field x}} expected-warning{{initializer for variable z3 must explicitly initialize field z}}
+Baz z4{1, 2, 3};// expected-warning{{initializer for variable z4 must explicitly initialize field x}} expected-warning{{initializer for variable z4 must explicitly initialize field z}}
+Baz z5{.x = 1, 2};  // expected-warning{{initializer for variable z5 must explicitly initialize field z}}
+Baz z6{.x = 1, .y = 2}; // expected-warning{{initializer for variable z6 must explicitly initialize field z}}
+
+// The following are valid ways of initializing instances of this struct.
+Baz z7{.x = 1, .y = 2, .z = 3};
+Baz z8{.x = 1, .z = 3};
+Baz z9{.x = 1, 2, .z = 3};
+
+// The required attribute can also be applied to public fields of classes.
+class Cla {
+public:
+  [[clang::requires_init]] int x; // expected-note 0+ {{enforced by 'requires_init' attribute here}}
+  int y;
+};
+
+// The following are invalid ways of initializing instances of this class.
+Cla c1;// expected-warning{{initializer for variable c1 must explicitly initialize field x}}
+Cla c2{};  // expected-warning{{initializer for variable c2 must explicitly initialize field x}}
+Cla c3{1}; // expected-warning{{initializer for variable c3 must explicitly initialize field x}}
+Cla c4{1, 2};  // expected-warning{{initializer for variable c4 must explicitly initialize field x}}
+Cla c5{1, .y = 2}; // expected-warning{{initializer for variable c5 must explicitly initialize field x}}
+
+// The following are valid ways of initializing instances of this class.
+Cla c6{.x = 1};
+Cla c7{.x = 1, .y = 2};
+Cla c8{.x = 1, 2};
+
+// This attribute cannot be applied to fields of a union.
+union Uni {
+  [[clang::requires_init]] int x; // expected-warning{{'requires_init' attribute ignored}}
+  int y;
+};
Index: clang/test/SemaCXX/attr-requires-designator.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-requires-designator.cpp
@@ -0,0 +1,102 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// The requires_designator attribute only applies to types. It will
+// generate a warning when attached to 

[PATCH] D61749: [clang-tidy] initial version of readability-convert-member-functions-to-static

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre updated this revision to Diff 209360.
mgehre added a comment.

Implement comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.cpp
  clang-tools-extra/clang-tidy/readability/ConvertMemberFunctionsToStatic.h
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/readability-convert-member-functions-to-static.rst
  
clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp

Index: clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/readability-convert-member-functions-to-static.cpp
@@ -0,0 +1,218 @@
+// RUN: %check_clang_tidy %s readability-convert-member-functions-to-static %t
+
+class DoNotMakeEmptyStatic {
+  void emptyMethod() {}
+  void empty_method_out_of_line();
+};
+
+void DoNotMakeEmptyStatic::empty_method_out_of_line() {}
+
+class A {
+  int field;
+  const int const_field;
+  static int static_field;
+
+  void no_use() {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'no_use' can be made static
+// CHECK-FIXES: {{^}}  static void no_use() {
+int i = 1;
+  }
+
+  int read_field() {
+return field;
+  }
+
+  void write_field() {
+field = 1;
+  }
+
+  int call_non_const_member() { return read_field(); }
+
+  int call_static_member() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'call_static_member' can be made static
+// CHECK-FIXES: {{^}}  static int call_static_member() {
+already_static();
+  }
+
+  int read_static() {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'read_static' can be made static
+// CHECK-FIXES: {{^}}  static int read_static() {
+return static_field;
+  }
+  void write_static() {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'write_static' can be made static
+// CHECK-FIXES: {{^}}  static void write_static() {
+static_field = 1;
+  }
+
+  static int already_static() { return static_field; }
+
+  int already_const() const { return field; }
+
+  int already_const_convert_to_static() const {
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: method 'already_const_convert_to_static' can be made static
+// CHECK-FIXES: {{^}}  static int already_const_convert_to_static() {
+return static_field;
+  }
+
+  static int out_of_line_already_static();
+
+  void out_of_line_call_static();
+  // CHECK-FIXES: {{^}}  static void out_of_line_call_static();
+  int out_of_line_const_to_static() const;
+  // CHECK-FIXES: {{^}}  static int out_of_line_const_to_static() ;
+};
+
+int A::out_of_line_already_static() { return 0; }
+
+void A::out_of_line_call_static() {
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: method 'out_of_line_call_static' can be made static
+  // CHECK-FIXES: {{^}}void A::out_of_line_call_static() {
+  already_static();
+}
+
+int A::out_of_line_const_to_static() const {
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'out_of_line_const_to_static' can be made static
+  // CHECK-FIXES: {{^}}int A::out_of_line_const_to_static() {
+  return 0;
+}
+
+struct KeepVirtual {
+  virtual int f() { return 0; }
+  virtual int h() const { return 0; }
+};
+
+struct KeepVirtualDerived : public KeepVirtual {
+  int f() { return 0; }
+  int h() const override { return 0; }
+};
+
+// Don't add 'static' to special member functions and operators.
+struct KeepSpecial {
+  KeepSpecial() { int L = 0; }
+  ~KeepSpecial() { int L = 0; }
+  int operator+() { return 0; }
+  operator int() { return 0; }
+};
+
+void KeepLambdas() {
+  using FT = int (*)();
+  auto F = static_cast([]() { return 0; });
+  auto F2 = []() { return 0; };
+}
+
+template 
+struct KeepWithTemplateBase : public Base {
+  int i;
+  // We cannot make these methods static because they might need to override
+  // a function from Base.
+  int static_f() { return 0; }
+};
+
+template 
+struct KeepTemplateClass {
+  int i;
+  // We cannot make these methods static because a specialization
+  // might use *this differently.
+  int static_f() { return 0; }
+};
+
+struct KeepTemplateMethod {
+  int i;
+  // We cannot make these methods static because a specialization
+  // might use *this differently.
+  template 
+  static int static_f() { return 0; }
+};
+
+void instantiate() {
+  struct S {};
+  KeepWithTemplateBase I1;
+  I1.static_f();
+
+  KeepTemplateClass I2;
+  I2.static_f();
+
+  KeepTemplateMethod I3;
+  I3.static_f();
+}
+
+struct Trailing {
+  auto g() const -> int {
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: method 'g' can be made static
+// CHECK-FIXES: {{^}}  

[PATCH] D61749: [clang-tidy] initial version of readability-convert-member-functions-to-static

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre added a comment.

This should address all remaining comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749



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


[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

mgehre wrote:
> gribozavr wrote:
> > I'd suggest to split type trait implementations into a separate patch.
> > 
> > Are these type traits being exposed only for testing? I'm not sure it is a 
> > good idea to do that -- people will end up using them in production code -- 
> > is that a concern? If so, maybe it would be better to test through warnings.
> I copied that approach from https://reviews.llvm.org/D50119.
> If people do it in production code, then at least the two leading underscores 
> should tell them "I'm not supposed to use this".
> 
> I considered a test through warnings, but how would I trigger them? Add 
> `-Wlifetime-categories-debug` which emits notes whenever a 
> [[gsl::Owner/Pointer]] is implicitly/explicitly attached to class?
> If people do it in production code, then at least the two leading underscores 
> should tell them "I'm not supposed to use this".

That's not what two underscores mean. These custom type traits, being language 
extensions, must have a name that won't collide with any user-defined name, 
hence two underscores. Two underscores mean nothing about whether the user is 
allowed to use it or not. Sure the code might become non-portable to other 
compilers, but that's not what the concern is. My concern is that code that 
people write might become unportable to future versions of Clang, where we 
would have to change behavior of these type traits (or it would just subtly 
change in some corner case and we won't notice since we don't consider it a 
public API).

> I considered a test through warnings, but how would I trigger them?

I meant regular warnings, that are the objective of this analysis -- warnings 
about dereferencing dangling pointers. If we get those warnings for the 
types-under-test, then obviously they have the correct annotations from the 
compiler's point of view.



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

mgehre wrote:
> gribozavr wrote:
> > This test and related code changes could be split off into a separate patch.
> I was thinking whether it made sense to separate
> - fixing the AST dump of attributes with optional type parameter when there 
> is not such attribute
> - introduce and attribute with optional type parameter while AST dumping it 
> is broken
> so I decided that both are closely related. Otherwise the fix and its test 
> are in separate PRs?
Totally makes sense to have the fix and the test is the same PR, but they seem 
to be separable from attribute inference for std types, right?



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace std {

mgehre wrote:
> gribozavr wrote:
> > I feel like these tests would be better off in a separate file.
> > 
> > It would be also good to explain which exact library we are trying to 
> > imitate in this test. Different libraries use different coding patterns.
> This is imitating techniques from different libraries - all techniques that 
> this implementation supports.
> 
> To check if all techniques that this implementation supports are enough for 
> real standard library implementations,
> I use 
> https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
>  against them. Various versions of libstdc++
> and libc++ passed. I will test MSVC standard library next. If they would use 
> a technique that this implementation does not support yet,
> I will add support for that and the corresponding test here.
> I might fix MSVC support (if needed) only in the following PR:
> This is imitating techniques from different libraries - all techniques that 
> this implementation supports.

Okay -- please add comments about each technique then (and ideally, which 
libraries use them). Right now (for me, who didn't write the patch), the test 
looks like it is testing inference for a bunch of types, not for a bunch of 
techniques -- the differences are subtle and non-obvious.



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:103
+template 
+class set_iterator {};
+

mgehre wrote:
> gribozavr wrote:
> > Is it actually defined like that?
> There might be a standard library implementation that does it like this. This 
> tests that we will use the `using iterator = set_iterator;` in `class set 
> {` to attach the [[gsl::Pointer]] to the `set_iterator`. 
Then std::set_iterator must have an implementation-reserved name, like 
std::__set_iterator.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  

[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

In D64448#1581719 , @mgehre wrote:

> In D64448#159 , @gribozavr wrote:
>
> > I don't know how various versions of libstdc++ differ.
>
>
> The current implementation passed the (partial) test case
>  
> https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
>  for different standard libraries, namely libc++ 7.1.0, libc++ 8.0.1rc2, 
> libstdc++ 4.6.4, libstdc++ 4.8.5,
>  libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
>  libstdc++ 8.3.0 and libstdc++ 9.1.0.


Yes, I saw the testcase -- but how do different libstdc++ versions differ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64448



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


[PATCH] D62888: [NewPM] Port Sancov

2019-07-11 Thread Leonard Chan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365838: [NewPM] Port Sancov (authored by leonardchan, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62888?vs=207698=209358#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62888

Files:
  cfe/trunk/lib/CodeGen/BackendUtil.cpp
  cfe/trunk/test/CodeGen/sancov-new-pm.c
  llvm/trunk/include/llvm/InitializePasses.h
  llvm/trunk/include/llvm/Transforms/Instrumentation.h
  llvm/trunk/include/llvm/Transforms/Instrumentation/SanitizerCoverage.h
  llvm/trunk/lib/Passes/PassBuilder.cpp
  llvm/trunk/lib/Passes/PassRegistry.def
  llvm/trunk/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/trunk/test/Instrumentation/SanitizerCoverage/abort-in-entry-block.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/backedge-pruning.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/chains.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_32.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/cmp-tracing-api-x86_64.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/cmp-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coff-comdat.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/coff-pc-table-inline-8bit-counters.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coff-used-ctor.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/const-cmp-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage-dbg.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/coverage2-dbg.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/div-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/gep-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/inline-8bit-counters.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/interposable-symbol-nocomdat.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/no-func.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/pc-table.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/postdominator_check.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/seh.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth-variable-declared-by-user.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/stack-depth.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/switch-tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/trace-pc-guard-comdat.ll
  
llvm/trunk/test/Instrumentation/SanitizerCoverage/trace-pc-guard-inline-8bit-counters.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/trace-pc-guard-nocomdat.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing-comdat.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/tracing.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/unreachable-critedge.ll
  llvm/trunk/test/Instrumentation/SanitizerCoverage/wineh.ll

Index: llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -10,6 +10,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/Analysis/EHPersonalities.h"
@@ -176,24 +177,168 @@
   return Options;
 }
 
-class SanitizerCoverageModule : public ModulePass {
+bool canInstrumentWithSancov(const Function ) {
+  if (F.empty())
+return false;
+  if (F.getName().find(".module_ctor") != std::string::npos)
+return false; // Should not instrument sanitizer init functions.
+  if (F.getName().startswith("__sanitizer_"))
+return false; // Don't instrument __sanitizer_* callbacks.
+  // Don't touch available_externally functions, their actual body is elewhere.
+  if (F.getLinkage() == GlobalValue::AvailableExternallyLinkage)
+return false;
+  // Don't instrument MSVC CRT configuration helpers. They may run before normal
+  // initialization.
+  if (F.getName() == "__local_stdio_printf_options" ||
+  F.getName() == "__local_stdio_scanf_options")
+return false;
+  if (isa(F.getEntryBlock().getTerminator()))
+return false;
+  // Don't instrument functions using SEH for now. Splitting basic blocks like
+  // we do for coverage breaks WinEHPrepare.
+  // FIXME: Remove this when SEH no longer uses landingpad pattern matching.
+  if (F.hasPersonalityFn() &&
+  isAsynchronousEHPersonality(classifyEHPersonality(F.getPersonalityFn(
+return false;
+  return true;
+}
+
+std::string getSectionStartImpl(const Triple ,
+const std::string ) {
+  if 

r365838 - [NewPM] Port Sancov

2019-07-11 Thread Leonard Chan via cfe-commits
Author: leonardchan
Date: Thu Jul 11 15:35:40 2019
New Revision: 365838

URL: http://llvm.org/viewvc/llvm-project?rev=365838=rev
Log:
[NewPM] Port Sancov

This patch contains a port of SanitizerCoverage to the new pass manager. This 
one's a bit hefty.

Changes:

- Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over
  functions and ModuleSanitizerCoverage for passing over modules.
- ModuleSanitizerCoverage exists for adding 2 module level calls to 
initialization
  functions but only if there's a function that was instrumented by sancov.
- Added legacy and new PM wrapper classes that own instances of the 2 new 
classes.
- Update llvm tests and add clang tests.

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

Added:
cfe/trunk/test/CodeGen/sancov-new-pm.c
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=365838=365837=365838=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Jul 11 15:35:40 2019
@@ -60,6 +60,7 @@
 #include "llvm/Transforms/Instrumentation/HWAddressSanitizer.h"
 #include "llvm/Transforms/Instrumentation/InstrProfiling.h"
 #include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
+#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
 #include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
 #include "llvm/Transforms/ObjCARC.h"
 #include "llvm/Transforms/Scalar.h"
@@ -195,11 +196,8 @@ static void addBoundsCheckingPass(const
   PM.add(createBoundsCheckingLegacyPass());
 }
 
-static void addSanitizerCoveragePass(const PassManagerBuilder ,
- legacy::PassManagerBase ) {
-  const PassManagerBuilderWrapper  =
-  static_cast(Builder);
-  const CodeGenOptions  = BuilderWrapper.getCGOpts();
+static SanitizerCoverageOptions
+getSancovOptsFromCGOpts(const CodeGenOptions ) {
   SanitizerCoverageOptions Opts;
   Opts.CoverageType =
   static_cast(CGOpts.SanitizeCoverageType);
@@ -215,7 +213,17 @@ static void addSanitizerCoveragePass(con
   Opts.Inline8bitCounters = CGOpts.SanitizeCoverageInline8bitCounters;
   Opts.PCTable = CGOpts.SanitizeCoveragePCTable;
   Opts.StackDepth = CGOpts.SanitizeCoverageStackDepth;
-  PM.add(createSanitizerCoverageModulePass(Opts));
+  return Opts;
+}
+
+static void addSanitizerCoveragePass(const PassManagerBuilder ,
+ legacy::PassManagerBase ) {
+  const PassManagerBuilderWrapper  =
+  static_cast(Builder);
+  const CodeGenOptions  = BuilderWrapper.getCGOpts();
+  auto Opts = getSancovOptsFromCGOpts(CGOpts);
+  PM.add(createModuleSanitizerCoverageLegacyPassPass(Opts));
+  PM.add(createSanitizerCoverageLegacyPassPass(Opts));
 }
 
 // Check if ASan should use GC-friendly instrumentation for globals.
@@ -1135,6 +1143,21 @@ void EmitAssemblyHelper::EmitAssemblyWit
 EntryExitInstrumenterPass(/*PostInlining=*/false)));
   });
 
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+PB.registerPipelineStartEPCallback(
+[SancovOpts](ModulePassManager ) {
+  MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+});
+PB.registerOptimizerLastEPCallback(
+[SancovOpts](FunctionPassManager ,
+ PassBuilder::OptimizationLevel Level) {
+  FPM.addPass(SanitizerCoveragePass(SancovOpts));
+});
+  }
+
   // Register callbacks to schedule sanitizer passes at the appropriate 
part of
   // the pipeline.
   // FIXME: either handle asan/the remaining sanitizers or error out
@@ -1219,8 +1242,18 @@ void EmitAssemblyHelper::EmitAssemblyWit
   }
 }
 
-if (CodeGenOpts.OptimizationLevel == 0)
+if (CodeGenOpts.OptimizationLevel == 0) {
+  if (CodeGenOpts.SanitizeCoverageType ||
+  CodeGenOpts.SanitizeCoverageIndirectCalls ||
+  CodeGenOpts.SanitizeCoverageTraceCmp) {
+auto SancovOpts = getSancovOptsFromCGOpts(CodeGenOpts);
+MPM.addPass(ModuleSanitizerCoveragePass(SancovOpts));
+MPM.addPass(createModuleToFunctionPassAdaptor(
+SanitizerCoveragePass(SancovOpts)));
+  }
+
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);
+}
   }
 
   // FIXME: We still use the legacy pass manager to do code generation. We

Added: cfe/trunk/test/CodeGen/sancov-new-pm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sancov-new-pm.c?rev=365838=auto
==
--- cfe/trunk/test/CodeGen/sancov-new-pm.c (added)
+++ cfe/trunk/test/CodeGen/sancov-new-pm.c 

[PATCH] D64458: add -fthinlto-index= option to clang-cl

2019-07-11 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

LGTM, but please wait for @pcc to make sure he is satisfied.
I think it would be good to port the file type deduction to clang (possibly as 
a follow on), to make these consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64458



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


[PATCH] D64537: [WebAssembly] Implement thread-local storage (local-exec model)

2019-07-11 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: clang/include/clang/Basic/BuiltinsWebAssembly.def:33
+// Thread-local storage
+TARGET_BUILTIN(__builtin_wasm_tls_size, "z", "nc", "bulk-memory")
+

quantum wrote:
> quantum wrote:
> > aheejin wrote:
> > > Why is it `c`(const)? According to [[ 
> > > https://github.com/llvm/llvm-project/blob/e6695821e592f95bffe1340b28be7bcfcce04284/clang/include/clang/Basic/Builtins.h#L104-L108
> > >  | this comment ]], this is true if this function has no side effects and 
> > > doesn't read memory, i.e., the result should be only dependent on its 
> > > arguments. Can't wasm globals be memory locations in machines?
> > I was thinking that since the global is immutable, so the value is always a 
> > constant.
> According to @tlively, there is no solid definition on whether a global 
> (especially a constant one), counts as memory access. For now, I am going to 
> change this to not constant. We can always change it back later.
I think this requires more conversation.



Comment at: lld/test/wasm/data-layout.ll:43
+; CHECK-NEXT:   - Index:   3
+; CHECK-NEXT: Type:I32
 ; CHECK-NEXT: Mutable: false

These globals don't have enough information to tell the reader what they even 
are, and they don't have anything to do with the data layout, so how about 
skipping these in the test with a comment saying what is being skipped?



Comment at: lld/test/wasm/tls.ll:57
+;   memory.init 0, 0
+;   end
+

quantum wrote:
> aheejin wrote:
> > Hmm, I think there might be a way to actually print disassembly results. 
> > There are '*.test' files in test directory, in which we have some examples. 
> > For example, [[ 
> > https://github.com/llvm/llvm-project/blob/master/lld/test/wasm/export-table.test
> >  | this test ]] has a sequence of commands you want to run, and you can put 
> > input files in a separate directory. That test uses `obj2yaml`, but can we 
> > possibly use `llvm-objdump` or something to disassemble?
> We already know that we can do something like
> 
> Run: obj2yaml %t.wasm | sed -n '/Body:/{s/^\s*Body:\s*//;s/../0x& /gp}'  
> | llvm-mc -disassemble -triple=wasm32
> 
> to compare the actual assembly. As for `llvm-objdump`, it seems to be unable 
> to disassemble the WASM properly:
> 
> 
> ```
> .../tools/lld/test/wasm/Output/tls.ll.tmp.wasm:   file format WASM
> 
> 
> Disassembly of section CODE:
> 
>  CODE:
> # 4 functions in section.
>1: 02 00   block   invalid_type
>3: 0b  end
>4: 10 00   call0
>6: 20 00   local.get   0
>8: 24 01   global.set  1
>a: 20 00   local.get   0
>c: 41 00   i32.const   0
>e: 41 08   i32.const   8
>   10: fc 08 00 00 memory.init 0, 0
>   14: 0b  end
>   15: 0f  return
>   16: 00  llvm-objdump: 
> lib/Target/WebAssembly/WebAssemblyGenAsmWriter.inc:2032: void 
> llvm::WebAssemblyInstPrinter::printInstruction(const llvm::MCInst *, 
> llvm::raw_ostream &): Assertion `Bits != 0 && "Cannot print this 
> instruction."' failed.
> 
> ```
It might be worth filing an LLVM bug for this (or possibly fixing in a separate 
CL).



Comment at: lld/wasm/Symbols.cpp:208
+if (Segment->OutputSeg->Name == ".tdata")
+  return Segment->OutputSegmentOffset + Offset;
 return Segment->OutputSeg->StartVA + Segment->OutputSegmentOffset + Offset;

It would be great to have an explanatory comment here.



Comment at: lld/wasm/Writer.cpp:777
+  break;
+}
+

quantum wrote:
> aheejin wrote:
> > Is it guaranteed that there's only one TLS segment?
> Yes, all the TLS input segments will be merged into `.tdata`.
--no-merge-data-segments!



Comment at: lld/wasm/Writer.cpp:250
+  TLSSize->Global->Global.InitExpr.Value.Int32 = Seg->Size;
+}
   }

What happens when there are multiple TLS sections and 
`--no-merge-data-segments` is used? I assume their sizes should be added 
together?



Comment at: lld/wasm/Writer.cpp:638
+  if (Name.startswith(".tbss."))
+return ".tdata";
   return Name;

Does this mean we can't control whether .tdata or .tbss comes first? Is that 
important for anything?



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1095
+WebAssemblyTargetLowering::LowerGlobalTLSAddress(SDValue Op,
+ SelectionDAG ) const {

[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-11 Thread Matthias Gehre via Phabricator via cfe-commits
mgehre marked 5 inline comments as done.
mgehre added a comment.

In D64448#159 , @gribozavr wrote:

> For example, libc++ wraps everything in std in an inline namespace.


I believed that I had written a test for inline namespaces, but seems that I 
shouldn't be working in the middle of the night.
I will add one.

In D64448#159 , @gribozavr wrote:

> I don't know how various versions of libstdc++ differ.


The current implementation passed the (partial) test case
https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp
for different standard libraries, namely libc++ 7.1.0, libc++ 8.0.1rc2, 
libstdc++ 4.6.4, libstdc++ 4.8.5,
libstdc++ 4.9.4, libstdc++ 5.4.0, libstdc++ 6.5.0, libstdc++ 7.3.0,
libstdc++ 8.3.0 and libstdc++ 9.1.0.




Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

gribozavr wrote:
> I'd suggest to split type trait implementations into a separate patch.
> 
> Are these type traits being exposed only for testing? I'm not sure it is a 
> good idea to do that -- people will end up using them in production code -- 
> is that a concern? If so, maybe it would be better to test through warnings.
I copied that approach from https://reviews.llvm.org/D50119.
If people do it in production code, then at least the two leading underscores 
should tell them "I'm not supposed to use this".

I considered a test through warnings, but how would I trigger them? Add 
`-Wlifetime-categories-debug` which emits notes whenever a 
[[gsl::Owner/Pointer]] is implicitly/explicitly attached to class?



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

gribozavr wrote:
> This test and related code changes could be split off into a separate patch.
I was thinking whether it made sense to separate
- fixing the AST dump of attributes with optional type parameter when there is 
not such attribute
- introduce and attribute with optional type parameter while AST dumping it is 
broken
so I decided that both are closely related. Otherwise the fix and its test are 
in separate PRs?



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace std {

gribozavr wrote:
> I feel like these tests would be better off in a separate file.
> 
> It would be also good to explain which exact library we are trying to imitate 
> in this test. Different libraries use different coding patterns.
This is imitating techniques from different libraries - all techniques that 
this implementation supports.

To check if all techniques that this implementation supports are enough for 
real standard library implementations,
I use 
https://github.com/mgehre/llvm-project/blob/lifetime-ci/lifetime-attr-test.cpp 
against them. Various versions of libstdc++
and libc++ passed. I will test MSVC standard library next. If they would use a 
technique that this implementation does not support yet,
I will add support for that and the corresponding test here.
I might fix MSVC support (if needed) only in the following PR:



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:103
+template 
+class set_iterator {};
+

gribozavr wrote:
> Is it actually defined like that?
There might be a standard library implementation that does it like this. This 
tests that we will use the `using iterator = set_iterator;` in `class set {` 
to attach the [[gsl::Pointer]] to the `set_iterator`. 



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:140
+
+class thread;
+static_assert(!__is_gsl_pointer(thread), "");

gribozavr wrote:
> Unclear what this test is testing.
> 
> If there's something special about thread (e.g., it looks very much like an 
> owner or a pointer, and a buggy implementation can easily declare thread to 
> be an owner or a pointer), please explain that in a comment.
> 
> If you're testing that some random name is not being picked up by inference 
> rules, I'd suggest to use an obviously-fictional name ("class 
> type_unknown_to_compiler;")
Agreed, I will rename this to an obviously-fictional name.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64448



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


[PATCH] D64146: [ConstExprPreter][WIP] Initial patch for the constexpr interpreter

2019-07-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added inline comments.



Comment at: clang/lib/AST/ExprVM/Compiler.cpp:85
+/* isArray */ false,
+/* isGlobal */ false);
+  ParamDescriptors.insert({ParamOffset, std::move(Desc)});

Usually the style used is `/*isMutable=*/true`



Comment at: clang/lib/AST/ExprVM/Compiler.h:69
+public:
+  /// Creates a compiler for a funciton.
+  Compiler(Context , Program , const FunctionDecl *F);

"function"



Comment at: clang/lib/AST/ExprVM/Compiler.h:125
+/// Size of the local, in bytes.
+unsigned Size;
+  };

`ByteSize` since it's the size in bytes :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64146



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


[PATCH] D64600: [ObjC] Add an attribute that "clamps" signed char BOOLs to {0,1}

2019-07-11 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added reviewers: rjmccall, aaron.ballman, steven_wu.
Herald added subscribers: dexonsmith, jkorous.
Herald added a project: clang.

This attribute can be applied to typedefs of BOOL in Objective-C. It causes 
loads, stores, and casts to BOOL to clamp into {0,1}. This is useful for us 
because a lot of code is going to be moving from a platform where BOOL is a 
typedef for a native bool type (iOS) to a platform where its a typedef for 
signed char (macOS) because of macCatalyst. We can't change the type of the 
BOOL, since its ABI.

rdar://6510042

Thanks for taking a look!
Erik


Repository:
  rC Clang

https://reviews.llvm.org/D64600

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenObjC/objc-clamping-bool.m
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/SemaObjC/objc-clamping-bool.m

Index: clang/test/SemaObjC/objc-clamping-bool.m
===
--- /dev/null
+++ clang/test/SemaObjC/objc-clamping-bool.m
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+typedef __attribute__((objc_clamping_bool)) signed char BOOL;
+
+// expected-error@+1 {{'objc_clamping_bool' attribute takes no arguments}}
+typedef __attribute__((objc_clamping_bool(1))) signed char BOOL2;
+
+// expected-warning@+1 {{'objc_clamping_bool' attribute only applies to typedefs}}
+__attribute__((objc_clamping_bool)) signed char x;
+
+// expected-error@+1 {{objc_clamping_bool must appertain to a signed char type}}
+typedef __attribute__((objc_clamping_bool)) unsigned char UNSIGNED_BOOL;
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -98,6 +98,7 @@
 // CHECK-NEXT: ObjCBridge (SubjectMatchRule_record, SubjectMatchRule_type_alias)
 // CHECK-NEXT: ObjCBridgeMutable (SubjectMatchRule_record)
 // CHECK-NEXT: ObjCBridgeRelated (SubjectMatchRule_record)
+// CHECK-NEXT: ObjCClampingBool (SubjectMatchRule_type_alias)
 // CHECK-NEXT: ObjCClassStub (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCDesignatedInitializer (SubjectMatchRule_objc_method)
 // CHECK-NEXT: ObjCException (SubjectMatchRule_objc_interface)
Index: clang/test/CodeGenObjC/objc-clamping-bool.m
===
--- /dev/null
+++ clang/test/CodeGenObjC/objc-clamping-bool.m
@@ -0,0 +1,132 @@
+// RUN: %clang_cc1 %s -triple x86_64-apple-macosx10.14 -emit-llvm -disable-llvm-passes -o - | FileCheck %s
+
+typedef __attribute__((objc_clamping_bool)) signed char BOOL;
+
+BOOL b;
+
+void store() {
+  // CHECK-LABEL: define void @store
+
+  b = 2;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  b = 1;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  b = -1;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  b = 0;
+  // CHECK: store i8 0, i8* @b, align 1
+
+  b = 256;
+  // CHECK: store i8 1, i8* @b, align 1
+
+  int unknown_value;
+  b = unknown_value;
+
+  // CHECK: [[CMPNE:%.*]] = icmp ne i32 %{{.*}}, 0
+  // CHECK-NEXT: [[ZEXT:%.*]] = zext i1 [[CMPNE]] to i8
+}
+
+void load() {
+  // CHECK-LABEL: define void @load
+  int load = b;
+
+  // CHECK: [[LOAD:%.*]] = load i8, i8* @b, align 1
+  // CHECK-NEXT: [[CMP:%.*]] = icmp ne i8 %0, 0
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+}
+
+void cast() {
+  // CHECK-LABEL: define void @cast
+  int i;
+  float f;
+  long double ld;
+  int* p;
+  _Bool real_bool;
+
+  (BOOL)i;
+  // CHECK: [[CMP:%.*]] = icmp ne i32 %{{.*}}, 0
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)f;
+  // CHECK: [[CMP:%.*]] = fcmp une float %{{.*}}, 0.00e+00
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)ld;
+  // CHECK: [[CMP:%.*]] = fcmp une x86_fp80 %{{.*}}, 0xK
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)p;
+  // CHECK: [[CMP:%.*]] = icmp ne i32* %{{.*}}, null
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+
+  (BOOL)real_bool;
+  // CHECK: [[CMP:%.*]] = icmp ne i1 %{{.*}}, false
+  // CHECK-NEXT: zext i1 [[CMP]] to i8
+}
+
+void bits() {
+  // CHECK-LABEL: define void @bits
+  struct bit_field {
+BOOL b : 1;
+  };
+
+  struct bit_field bf;
+
+  bf.b = 1;
+  // CHECK: [[SET_BIT:%.*]] = or i8 %{{.*}}, 1
+  // CHECK-NEXT: store i8 [[SET_BIT]]
+
+  bf.b = 2;
+  // CHECK: [[SET_BIT:%.*]] = or i8 %{{.*}}, 1
+  // CHECK-NEXT: store i8 [[SET_BIT]]
+
+  bf.b = 0;
+  // CHECK: [[ZERO_BIT:%.*]] = and i8 %{{.*}}, -2
+  // CHECK-NEXT: store i8 [[ZERO_BIT]]
+
+  bf.b = -1;
+  // CHECK: [[SET_BIT:%.*]] = or i8 %{{.*}}, 1
+  // CHECK-NEXT: store i8 [[SET_BIT]]
+
+  

r365835 - CodeGen: Suppress c++ warnings in test

2019-07-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jul 11 14:59:09 2019
New Revision: 365835

URL: http://llvm.org/viewvc/llvm-project?rev=365835=rev
Log:
CodeGen: Suppress c++ warnings in test

Modified:
cfe/trunk/test/CodeGenCXX/auto-var-init.cpp

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365835=365834=365835=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Thu Jul 11 14:59:09 2019
@@ -7,6 +7,8 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fexperimental-new-pass-manager -emit-llvm 
-o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-NEWPM
 // RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=PATTERN-I386
 
+#pragma clang diagnostic ignored "-Winaccessible-base"
+
 template void used(T &) noexcept;
 
 #define TEST_UNINIT(NAME, TYPE) \


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


[PATCH] D63975: Warn when ScopeDepthOrObjCQuals overflows

2019-07-11 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 209348.
Mordante added a comment.

tab -> space
adds an extra unit test for lambdas
fixes an off by one error found while testing the lambdas


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

https://reviews.llvm.org/D63975

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Parser/nested_function_prototype_overflow.cpp
  clang/test/Parser/nested_lambda_overflow.cpp


Index: clang/test/Parser/nested_lambda_overflow.cpp
===
--- /dev/null
+++ clang/test/Parser/nested_lambda_overflow.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: not %clang_cc1 %s -fsyntax-only -DFAIL 2>&1 | FileCheck %s
+
+auto foo = [](void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(
+#ifdef FAIL
+void (*f)()
+#endif
+)
 {};
+// CHECK: fatal error: function scope depth exceeded maximum of 127
Index: clang/test/Parser/nested_function_prototype_overflow.cpp
===
--- /dev/null
+++ clang/test/Parser/nested_function_prototype_overflow.cpp
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -fsyntax-only
+// RUN: not %clang_cc1 %s -fsyntax-only -DFAIL 2>&1 | FileCheck %s
+
+void foo(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void (*f)(void 
(*f)(void (*f)(
+#ifdef FAIL
+void (*f)()
+#endif
+);
+// CHECK: fatal error: function scope depth exceeded maximum of 127
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -6576,6 +6576,18 @@
   Actions.containsUnexpandedParameterPacks(ParmDeclarator))
 DiagnoseMisplacedEllipsisInDeclarator(ConsumeToken(), ParmDeclarator);
 
+  // Avoid exceeding the maximum function scope depth.
+  // See https://bugs.llvm.org/show_bug.cgi?id=19607
+  // Note Sema::ActOnParamDeclarator calls ParmVarDecl::setScopeInfo with
+  // getFunctionPrototypeDepth() - 1.
+  if (getCurScope()->getFunctionPrototypeDepth() - 1 >
+  ParmVarDecl::getMaxFunctionScopeDepth()) {
+Diag(DSStart, 

[PATCH] D64062: Remove both -dumpversion and __VERSION__

2019-07-11 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

In D64062#1581290 , @rnk wrote:

> Perhaps we should just remove `__VERSION__` and keep `-dumpversion`.


As you wish. clang --version seems an alternative and dumpversion never 
//worked// for clang. so, I don't expect software to use it for clang.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64062



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


[PATCH] D63975: Warn when ScopeDepthOrObjCQuals overflows

2019-07-11 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:6587
+return;
+  }
+

rjmccall wrote:
> Comment indentation.
> 
> Should we do this when starting to parse a function prototype instead of when 
> parsing a parameter?
Thanks I noticed I forgot to change the tabs to spaces.

I looked at your suggestion to move the code, but I think this is the proper 
place. Now it also validates whether lambdas exceed the limit, else we need to 
check at two places.
I'll also add a unit test to test for the lambda.


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

https://reviews.llvm.org/D63975



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


r365832 - Fix a Python3 compatibility error

2019-07-11 Thread Azharuddin Mohammed via cfe-commits
Author: azhar
Date: Thu Jul 11 14:45:48 2019
New Revision: 365832

URL: http://llvm.org/viewvc/llvm-project?rev=365832=rev
Log:
Fix a Python3 compatibility error

  File "clang/test/lit.cfg.py", line 186, in 
config.available_features.add('macos-sdk-' + macOSSDKVersion)
TypeError: must be str, not bytes

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=365832=365831=365832=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Thu Jul 11 14:45:48 2019
@@ -183,7 +183,7 @@ if run_console_tests != 0:
 lit.util.usePlatformSdkOnDarwin(config, lit_config)
 macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
 if macOSSDKVersion is not None:
-config.available_features.add('macos-sdk-' + macOSSDKVersion)
+config.available_features.add('macos-sdk-' + str(macOSSDKVersion))
 
 if os.path.exists('/etc/gentoo-release'):
 config.available_features.add('gentoo')


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


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xAAAAAAAA

2019-07-11 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In D64597#1581605 , @pcc wrote:

> The problem with `0x` on 32-bit is that it is likely to be a valid 
> address.
>
> When I discussed this with JF I proposed a pointer initialization of 
> `0x` which he agreed to. This value is very likely to trap when 
> accessed (due to accesses likely wrapping to zero) and also has the benefit 
> of being the same pattern as for floats.


Indeed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64597



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


[PATCH] D64278: Rename libclang_shared to libclang-cpp

2019-07-11 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365831: Rename libclang_shared to libclang-cpp (authored by 
sylvestre, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64278?vs=208258=209346#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64278

Files:
  cfe/trunk/CMakeLists.txt
  cfe/trunk/cmake/modules/AddClang.cmake
  cfe/trunk/tools/clang-shlib/CMakeLists.txt


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -324,7 +324,7 @@
 "Python versions to install libclang python bindings for")
 
 set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
-"Link tools against libclang_shared.so")
+"Link tools against libclang-cpp.so")
 
 if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
   message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "
Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Building libclang_shared.so fails if LLVM_ENABLE_PIC=Off
+# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()
 endif()
@@ -38,7 +38,7 @@
   list(APPEND _DEPS ${lib})
 endforeach ()
 
-add_clang_library(clang_shared
+add_clang_library(clang-cpp
   SHARED
   clang-shlib.cpp
   ${_OBJECTS}
Index: cfe/trunk/cmake/modules/AddClang.cmake
===
--- cfe/trunk/cmake/modules/AddClang.cmake
+++ cfe/trunk/cmake/modules/AddClang.cmake
@@ -175,7 +175,7 @@
 
 function(clang_target_link_libraries target type)
   if (CLANG_LINK_CLANG_DYLIB)
-target_link_libraries(${target} ${type} clang_shared)
+target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()


Index: cfe/trunk/CMakeLists.txt
===
--- cfe/trunk/CMakeLists.txt
+++ cfe/trunk/CMakeLists.txt
@@ -324,7 +324,7 @@
 "Python versions to install libclang python bindings for")
 
 set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
-"Link tools against libclang_shared.so")
+"Link tools against libclang-cpp.so")
 
 if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
   message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "
Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Building libclang_shared.so fails if LLVM_ENABLE_PIC=Off
+# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()
 endif()
@@ -38,7 +38,7 @@
   list(APPEND _DEPS ${lib})
 endforeach ()
 
-add_clang_library(clang_shared
+add_clang_library(clang-cpp
   SHARED
   clang-shlib.cpp
   ${_OBJECTS}
Index: cfe/trunk/cmake/modules/AddClang.cmake
===
--- cfe/trunk/cmake/modules/AddClang.cmake
+++ cfe/trunk/cmake/modules/AddClang.cmake
@@ -175,7 +175,7 @@
 
 function(clang_target_link_libraries target type)
   if (CLANG_LINK_CLANG_DYLIB)
-target_link_libraries(${target} ${type} clang_shared)
+target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365831 - Rename libclang_shared to libclang-cpp

2019-07-11 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Thu Jul 11 14:42:55 2019
New Revision: 365831

URL: http://llvm.org/viewvc/llvm-project?rev=365831=rev
Log:
Rename libclang_shared to libclang-cpp

Summary: Fix bug 42475

Reviewers: beanz, tstellar

Reviewed By: beanz

Subscribers: kimgr, mgorny, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/cmake/modules/AddClang.cmake
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=365831=365830=365831=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Thu Jul 11 14:42:55 2019
@@ -324,7 +324,7 @@ set(CLANG_PYTHON_BINDINGS_VERSIONS "" CA
 "Python versions to install libclang python bindings for")
 
 set(CLANG_LINK_CLANG_DYLIB ${LLVM_LINK_LLVM_DYLIB} CACHE BOOL
-"Link tools against libclang_shared.so")
+"Link tools against libclang-cpp.so")
 
 if (NOT LLVM_LINK_LLVM_DYLIB AND CLANG_LINK_CLANG_DYLIB)
   message(FATAL_ERROR "Cannot set CLANG_LINK_CLANG_DYLIB=ON when "

Modified: cfe/trunk/cmake/modules/AddClang.cmake
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/cmake/modules/AddClang.cmake?rev=365831=365830=365831=diff
==
--- cfe/trunk/cmake/modules/AddClang.cmake (original)
+++ cfe/trunk/cmake/modules/AddClang.cmake Thu Jul 11 14:42:55 2019
@@ -175,7 +175,7 @@ endmacro()
 
 function(clang_target_link_libraries target type)
   if (CLANG_LINK_CLANG_DYLIB)
-target_link_libraries(${target} ${type} clang_shared)
+target_link_libraries(${target} ${type} clang-cpp)
   else()
 target_link_libraries(${target} ${type} ${ARGN})
   endif()

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=365831=365830=365831=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Thu Jul 11 14:42:55 2019
@@ -1,4 +1,4 @@
-# Building libclang_shared.so fails if LLVM_ENABLE_PIC=Off
+# Building libclang-cpp.so fails if LLVM_ENABLE_PIC=Off
 if (NOT LLVM_ENABLE_PIC)
   return()
 endif()
@@ -38,7 +38,7 @@ foreach (lib ${clang_libs})
   list(APPEND _DEPS ${lib})
 endforeach ()
 
-add_clang_library(clang_shared
+add_clang_library(clang-cpp
   SHARED
   clang-shlib.cpp
   ${_OBJECTS}


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


[PATCH] D62888: [NewPM] Port Sancov

2019-07-11 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

LGTM, thanks so much for sticking through this, I know it was ... nontrivial!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62888



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


[PATCH] D64278: Rename libclang_shared to libclang-cpp

2019-07-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

This is fine with me. I have no real attachment to the name.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64278



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


[PATCH] D64582: cmake: Fix install of libclang_shared.so when LLVM_INSTALL_TOOLCHAIN_ONLY=ON

2019-07-11 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.

LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64582



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


[PATCH] D64597: CodeGet: Init 32bit pointers with 0xAAAAAAAA

2019-07-11 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

The problem with `0x` on 32-bit is that it is likely to be a valid 
address.

When I discussed this with JF I proposed a pointer initialization of 
`0x` which he agreed to. This value is very likely to trap when 
accessed (due to accesses likely wrapping to zero) and also has the benefit of 
being the same pattern as for floats.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64597



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


r365827 - [analyzer] exploded-graph-rewriter: Fix filenames in program point.

2019-07-11 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Jul 11 14:27:42 2019
New Revision: 365827

URL: http://llvm.org/viewvc/llvm-project?rev=365827=rev
Log:
[analyzer] exploded-graph-rewriter: Fix filenames in program point.

Fix a typo in JSON field name.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot?rev=365827=365826=365827=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot 
(original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot Thu Jul 
11 14:27:42 2019
@@ -52,7 +52,7 @@ Node0x1 [shape=record,label=
 // CHECK-SAME: 
 // CHECK-SAME:   
 // CHECK-SAME: 
-// CHECK-SAME:   (main file):4:5:
+// CHECK-SAME:   main.cpp:4:5:
 // CHECK-SAME: 
 // CHECK-SAME: 
 // CHECK-SAME:   DeclRefExpr
@@ -83,6 +83,7 @@ Node0x2 [shape=record,label=
 "pointer": "0x3",
 "pretty": "x",
 "location": {
+  "file": "main.cpp",
   "line": 4,
   "column": 5
 },

Modified: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/exploded-graph-rewriter.py?rev=365827=365826=365827=diff
==
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py (original)
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Thu Jul 11 14:27:42 2019
@@ -16,6 +16,7 @@ import collections
 import difflib
 import json
 import logging
+import os
 import re
 
 
@@ -50,8 +51,8 @@ class SourceLocation(object):
 super(SourceLocation, self).__init__()
 self.line = json_loc['line']
 self.col = json_loc['column']
-self.filename = json_loc['filename'] \
-if 'filename' in json_loc else '(main file)'
+self.filename = os.path.basename(json_loc['file']) \
+if 'file' in json_loc else '(main file)'
 
 
 # A deserialized program point.


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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

In D64579#1581557 , @beanz wrote:

> Yea, this makes sense even if it is a bit sad. We do use the 
> `--whole-archive` approach for `libLLVM`, and it works. I was hoping to avoid 
> it here in part to free up the ability to link `libclang_shared` before or in 
> parallel to archiving the `libclang*.a` archives.


Yeah, makes sense. I've had issues with static libraries getting reordered out 
of the `--whole-archive` with other projects in the past, which makes me wary 
of it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64579



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


[PATCH] D64579: [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365825: [clang-shlib] Fix clang-shlib for PRIVATE 
dependencies (authored by smeenai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64579?vs=209283=209336#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64579

Files:
  cfe/trunk/tools/clang-shlib/CMakeLists.txt


Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -7,8 +7,35 @@
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute 
the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead 
of
+  # using the object library at all. However, CMake reorders static libraries 
on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, 
linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared


Index: cfe/trunk/tools/clang-shlib/CMakeLists.txt
===
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt
@@ -7,8 +7,35 @@
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead of
+  # using the object library at all. However, CMake reorders static libraries on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared
___
cfe-commits mailing list

r365825 - [clang-shlib] Fix clang-shlib for PRIVATE dependencies

2019-07-11 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Thu Jul 11 14:20:38 2019
New Revision: 365825

URL: http://llvm.org/viewvc/llvm-project?rev=365825=rev
Log:
[clang-shlib] Fix clang-shlib for PRIVATE dependencies

Any static library with a PRIVATE dependency ends up with a
$ generator expression in its INTERFACE_LINK_LIBRARIES,
which won't be evaluated by the $, so we end up
with an unevaluated generator expression in the generated build file and
Ninja chokes on the dollar sign. Just use the static library directly
for its dependencies instead of trying to propagate dependencies
manually.

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

Modified:
cfe/trunk/tools/clang-shlib/CMakeLists.txt

Modified: cfe/trunk/tools/clang-shlib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-shlib/CMakeLists.txt?rev=365825=365824=365825=diff
==
--- cfe/trunk/tools/clang-shlib/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-shlib/CMakeLists.txt Thu Jul 11 14:20:38 2019
@@ -7,8 +7,35 @@ get_property(clang_libs GLOBAL PROPERTY
 
 foreach (lib ${clang_libs})
   list(APPEND _OBJECTS $)
-  list(APPEND _DEPS $)
-  list(APPEND _DEPS $)
+  # Use the static library for its dependencies. The objects that constitute 
the
+  # static library will appear on the link line before the library, so it'll
+  # just be ignored, but the dependencies of the library will still be linked
+  # correctly.
+  #
+  # We could propagate the dependencies manually using the library's
+  # INTERFACE_LINK_LIBRARIES property, but that will contain $
+  # generator expressions if a static library has a private dependency, so we
+  # can't use a $ generator expression to get the property
+  # (since it wouldn't evaluate any generator expressions inside the property).
+  # We could use get_property and do string manipulation to manually evaluate
+  # the $, but that would miss any dependencies added after we
+  # evaluate the get_property. We could also use the LINK_LIBRARIES property
+  # instead, which should be free of any generator expressions, but that's
+  # technically incorrect (it'd most likely work fine in practice, but still).
+  #
+  # Another alternative would be to use --whole-archive or equivalent instead 
of
+  # using the object library at all. However, CMake reorders static libraries 
on
+  # the link line so that a library appears after all its dependents, which can
+  # reorder static libraries out of their --whole-archive --no-whole-archive
+  # sandwich. It's really hard to avoid that reordering while still propagating
+  # dependencies, which defeats the whole point.
+  #
+  # The ideal solution here is to bump our minimum CMake requirement to 3.12,
+  # which adds support for dependencies on object libraries. Until then, 
linking
+  # both the object and the static libraries seems like the least bad solution.
+  #
+  # TODO: Rework this when we bump our minimum CMake version to 3.12 or newer.
+  list(APPEND _DEPS ${lib})
 endforeach ()
 
 add_clang_library(clang_shared


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


  1   2   3   >