[PATCH] D70424: clang/AMDGPU: Fix default for frame-pointer attribute

2019-11-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D70424#1761298 , @arsenm wrote:

> In D70424#1758902 , @yaxunl wrote:
>
> > LGTM. But I am wondering how it affects -g. Do we need to keep frame 
> > pointer when -g is specified? Should we add a test for -O3 -g?
>
>
> It’s independent for every other target. This matches the standard behavior


Also -g should not change codegen, but FP elimination would obviously be a 
change


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

https://reviews.llvm.org/D70424



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


[PATCH] D70424: clang/AMDGPU: Fix default for frame-pointer attribute

2019-11-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D70424#1758902 , @yaxunl wrote:

> LGTM. But I am wondering how it affects -g. Do we need to keep frame pointer 
> when -g is specified? Should we add a test for -O3 -g?


It’s independent for every other target. This matches the standard behavior


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

https://reviews.llvm.org/D70424



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 created this revision.
lh123 added a reviewer: kadircet.
Herald added subscribers: llvm-commits, cfe-commits, seiya, rupprecht, MaskRay, 
jakehehrlich, aheejin, hiraditya, arichardson, sbc100, emaste.
Herald added a reviewer: espindola.
Herald added a reviewer: alexshap.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added projects: clang, LLVM.

add vfs support for `ExpandResponseFiles`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70769

Files:
  clang/tools/driver/driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/tools/lld/lld.cpp
  lld/wasm/Driver.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -830,7 +830,8 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
   bool Res = llvm::cl::ExpandResponseFiles(
-Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true);
+  Saver, llvm::cl::TokenizeGNUCommandLine, *llvm::vfs::getRealFileSystem(),
+  Argv, false, true);
   EXPECT_TRUE(Res);
   EXPECT_EQ(Argv.size(), 13U);
   EXPECT_STREQ(Argv[0], "test/test");
@@ -905,7 +906,8 @@
 #else
   cl::TokenizerCallback Tokenizer = cl::TokenizeGNUCommandLine;
 #endif
-  bool Res = cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false);
+  bool Res = cl::ExpandResponseFiles(
+  Saver, Tokenizer, *llvm::vfs::getRealFileSystem(), Argv, false, false);
   EXPECT_FALSE(Res);
 
   EXPECT_EQ(Argv.size(), 9U);
@@ -943,7 +945,8 @@
 
   BumpPtrAllocator A;
   StringSaver Saver(A);
-  bool Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
+  bool Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine,
+ *llvm::vfs::getRealFileSystem(), Argv,
  false, false);
   EXPECT_FALSE(Res);
 
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -338,7 +338,7 @@
   Triple(sys::getProcessTriple()).isOSWindows()
   ? cl::TokenizeWindowsCommandLine
   : cl::TokenizeGNUCommandLine,
-  NewArgv);
+  *llvm::vfs::getRealFileSystem(), NewArgv);
 
   auto Args = makeArrayRef(NewArgv).drop_front();
   Expected DriverConfig =
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -1096,7 +1096,8 @@
 static int ar_main(int argc, char **argv) {
   SmallVector Argv(argv, argv + argc);
   StringSaver Saver(Alloc);
-  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine,
+  *llvm::vfs::getRealFileSystem(), Argv);
   for (size_t i = 1; i < Argv.size(); ++i) {
 StringRef Arg = Argv[i];
 const char *match = nullptr;
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -267,7 +267,8 @@
 
   // Parse command line arguments.
   SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end());
-  cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine,
+  *llvm::vfs::getRealFileSystem(), NewArgs);
   ArgsArr = NewArgs;
 
   LibOptTable Table;
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -1045,10 +1045,11 @@
 
 static bool ExpandResponseFile(StringRef FName, StringSaver &Saver,
TokenizerCallback Tokenizer,
+   llvm::vfs::FileSystem &FS,
SmallVectorImpl &NewArgv,
bool MarkEOLs, bool RelativeNames) {
   ErrorOr> MemBufOrErr =
-  MemoryBuffer::getFile(FName);
+  FS.getBufferForFile(FName);
   if (!MemBufOrErr)
 return false;
   MemoryBuffer &MemBuf = *MemBufOrErr.get();
@@ -1068,6 +1069,9 @@
   else if (hasUTF8ByteOrderMark(BufRef))
 Str = StringRef(BufRef.data() + 3, BufRef.size() - 3);
 
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return fa

[clang] e20a1e4 - clang-format-vs : Fix Unicode formatting

2019-11-27 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2019-11-27T09:58:59+01:00
New Revision: e20a1e486e144c88188bc7b420885d5326b39088

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

LOG: clang-format-vs : Fix Unicode formatting

Use UTF-8 for communication with clang-format and convert the
replacements offset/length to characters position/count.

Internally VisualStudio.Text.Editor.IWpfTextView use sequence of Unicode
characters encoded using UTF-16 and use characters position/count for
manipulating text.

Resolved "Error while running clang-format: Specified argument was out
of the range of valid values. Parameter name: replaceSpan".

Patch by empty2fill!

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

Added: 


Modified: 
clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Removed: 




diff  --git a/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs 
b/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
index 7443405efad2..26a0af3b55b5 100644
--- a/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ b/clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -24,6 +24,7 @@
 using System.Runtime.InteropServices;
 using System.Xml.Linq;
 using System.Linq;
+using System.Text;
 
 namespace LLVM.ClangFormat
 {
@@ -292,8 +293,7 @@ private void FormatSelection(OptionPageGrid options)
 string text = view.TextBuffer.CurrentSnapshot.GetText();
 int start = 
view.Selection.Start.Position.GetContainingLine().Start.Position;
 int end = 
view.Selection.End.Position.GetContainingLine().End.Position;
-int length = end - start;
-
+
 // clang-format doesn't support formatting a range that starts at 
the end
 // of the file.
 if (start >= text.Length && text.Length > 0)
@@ -301,7 +301,7 @@ private void FormatSelection(OptionPageGrid options)
 string path = Vsix.GetDocumentParent(view);
 string filePath = Vsix.GetDocumentPath(view);
 
-RunClangFormatAndApplyReplacements(text, start, length, path, 
filePath, options, view);
+RunClangFormatAndApplyReplacements(text, start, end, path, 
filePath, options, view);
 }
 
 /// 
@@ -336,11 +336,11 @@ private void FormatView(IWpfTextView view, OptionPageGrid 
options)
 RunClangFormatAndApplyReplacements(text, 0, text.Length, path, 
filePath, options, view);
 }
 
-private void RunClangFormatAndApplyReplacements(string text, int 
offset, int length, string path, string filePath, OptionPageGrid options, 
IWpfTextView view)
+private void RunClangFormatAndApplyReplacements(string text, int 
start, int end, string path, string filePath, OptionPageGrid options, 
IWpfTextView view)
 {
 try
 {
-string replacements = RunClangFormat(text, offset, length, 
path, filePath, options);
+string replacements = RunClangFormat(text, start, end, path, 
filePath, options);
 ApplyClangFormatReplacements(replacements, view);
 }
 catch (Exception e)
@@ -363,9 +363,9 @@ private void RunClangFormatAndApplyReplacements(string 
text, int offset, int len
 /// 
 /// Runs the given text through clang-format and returns the 
replacements as XML.
 /// 
-/// Formats the text range starting at offset of the given length.
+/// Formats the text in range start and end.
 /// 
-private static string RunClangFormat(string text, int offset, int 
length, string path, string filePath, OptionPageGrid options)
+private static string RunClangFormat(string text, int start, int end, 
string path, string filePath, OptionPageGrid options)
 {
 string vsixPath = Path.GetDirectoryName(
 typeof(ClangFormatPackage).Assembly.Location);
@@ -373,6 +373,9 @@ private static string RunClangFormat(string text, int 
offset, int length, string
 System.Diagnostics.Process process = new 
System.Diagnostics.Process();
 process.StartInfo.UseShellExecute = false;
 process.StartInfo.FileName = vsixPath + "\\clang-format.exe";
+char[] chars = text.ToCharArray();
+int offset = Encoding.UTF8.GetByteCount(chars, 0, start);
+int length = Encoding.UTF8.GetByteCount(chars, 0, end) - offset;
 // Poor man's escaping - this will not work when quotes are 
already escaped
 // in the input (but we don't need more).
 string style = options.Style.Replace("\"", "\\\"");
@@ -413,10 +416,11 @@ private static string RunClangFormat(string text, int 
offset, int length, string
 // 2. We write ever

[PATCH] D70633: clang-format-vs : Fix Unicode formatting

2019-11-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

>> empty2fill: Do you have an example input that I could use to hit the 
>> "Specified argument was out of the range of valid values." error?
> 
> F10867463: Main.cpp 
> 
> Encoded UTF-8(with BOM) for the Korean language.

I applied your patch locally and it seems to work :-) I'll commit it for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70633



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60330 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70633: clang-format-vs : Fix Unicode formatting

2019-11-27 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe20a1e486e14: clang-format-vs : Fix Unicode formatting 
(authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70633

Files:
  clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs

Index: clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
===
--- clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
+++ clang/tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
@@ -24,6 +24,7 @@
 using System.Runtime.InteropServices;
 using System.Xml.Linq;
 using System.Linq;
+using System.Text;
 
 namespace LLVM.ClangFormat
 {
@@ -292,8 +293,7 @@
 string text = view.TextBuffer.CurrentSnapshot.GetText();
 int start = view.Selection.Start.Position.GetContainingLine().Start.Position;
 int end = view.Selection.End.Position.GetContainingLine().End.Position;
-int length = end - start;
-
+
 // clang-format doesn't support formatting a range that starts at the end
 // of the file.
 if (start >= text.Length && text.Length > 0)
@@ -301,7 +301,7 @@
 string path = Vsix.GetDocumentParent(view);
 string filePath = Vsix.GetDocumentPath(view);
 
-RunClangFormatAndApplyReplacements(text, start, length, path, filePath, options, view);
+RunClangFormatAndApplyReplacements(text, start, end, path, filePath, options, view);
 }
 
 /// 
@@ -336,11 +336,11 @@
 RunClangFormatAndApplyReplacements(text, 0, text.Length, path, filePath, options, view);
 }
 
-private void RunClangFormatAndApplyReplacements(string text, int offset, int length, string path, string filePath, OptionPageGrid options, IWpfTextView view)
+private void RunClangFormatAndApplyReplacements(string text, int start, int end, string path, string filePath, OptionPageGrid options, IWpfTextView view)
 {
 try
 {
-string replacements = RunClangFormat(text, offset, length, path, filePath, options);
+string replacements = RunClangFormat(text, start, end, path, filePath, options);
 ApplyClangFormatReplacements(replacements, view);
 }
 catch (Exception e)
@@ -363,9 +363,9 @@
 /// 
 /// Runs the given text through clang-format and returns the replacements as XML.
 /// 
-/// Formats the text range starting at offset of the given length.
+/// Formats the text in range start and end.
 /// 
-private static string RunClangFormat(string text, int offset, int length, string path, string filePath, OptionPageGrid options)
+private static string RunClangFormat(string text, int start, int end, string path, string filePath, OptionPageGrid options)
 {
 string vsixPath = Path.GetDirectoryName(
 typeof(ClangFormatPackage).Assembly.Location);
@@ -373,6 +373,9 @@
 System.Diagnostics.Process process = new System.Diagnostics.Process();
 process.StartInfo.UseShellExecute = false;
 process.StartInfo.FileName = vsixPath + "\\clang-format.exe";
+char[] chars = text.ToCharArray();
+int offset = Encoding.UTF8.GetByteCount(chars, 0, start);
+int length = Encoding.UTF8.GetByteCount(chars, 0, end) - offset;
 // Poor man's escaping - this will not work when quotes are already escaped
 // in the input (but we don't need more).
 string style = options.Style.Replace("\"", "\\\"");
@@ -413,10 +416,11 @@
 // 2. We write everything to the standard output - this cannot block, as clang-format
 //reads the full standard input before analyzing it without writing anything to the
 //standard output.
-process.StandardInput.Write(text);
+StreamWriter utf8Writer = new StreamWriter(process.StandardInput.BaseStream, new UTF8Encoding(false));
+utf8Writer.Write(text);
 // 3. We notify clang-format that the input is done - after this point clang-format
 //will start analyzing the input and eventually write the output.
-process.StandardInput.Close();
+utf8Writer.Close();
 // 4. We must read clang-format's output before waiting for it to exit; clang-format
 //will close the channel by exiting.
 string output = process.StandardOutput.ReadToEnd();
@@ -440,13 +444,18 @@
 if (replacements.Length == 0)
 return;
 
+string text = view.TextBuffer.CurrentSnapshot.GetText();
+byte[] bytes = Encoding.UTF8.GetBytes(text);
+
 var root = XElement.P

[PATCH] D70773: [clangd] Handle the missing call expr in targetDecl.

2019-11-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added subscribers: usaxena95, kadircet, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70773

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@
   RelSet Flags;
   Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) 
{}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@
   RelSet Flags;
   Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) {}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

Are there any instances where we DON'T want to get the real file system? If 
not, could the `*llvm::vfs::getRealFileSystem()` call be put inside 
`cl::ExpandResponseFiles`?




Comment at: llvm/include/llvm/Support/CommandLine.h:32
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"

Can llvm::vfs::FileSystem be forward declared and this moved into the .cpp?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70746: [clangd] Highlighting dependent types in more contexts

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:259
 H.addToken(L.getNameLoc(), HighlightingKind::DependentType);
+visitDependentTypesInQualifier(L.getQualifierLoc());
+return true;

Instead of calling `visitDependentTypesInQualifier`, implement 
`TraverseNestedNameSpecifierLoc` to catch all their occurrences.

No need to redo the traversal, it should be handled by `RecursiveASTVisitor`.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:263
+
+  // This is similar to DependentNameTypeLoc, but used for
+  // template-ids where the template-name itself is dependent.

NIT: remove the comment, it is redundant. One can always navigate to the 
definition of `DependentTemplateSpecializationTypeLoc` if they need to 
understand what it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70746



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


[PATCH] D70773: [clangd] Handle the missing call expr in targetDecl.

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60325 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70773



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


[PATCH] D70740: [clangd] Find reference to template parameter in 'sizeof...' expression

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks! Could you also handle this in `targetDecl` and add the corresponding 
test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70740



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 added a comment.

In D70769#1761394 , @jhenderson wrote:

> Are there any instances where we DON'T want to get the real file system? If 
> not, could the `*llvm::vfs::getRealFileSystem()` call be put inside 
> `cl::ExpandResponseFiles`?


This patch is part of D70222 .
 This is for using InMemoryFileSystem in unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bader via Phabricator via cfe-commits
bader added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D69825: [Clang][Driver] Re-use the calling process instead of creating a new process for the cc1 invocation

2019-11-27 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D69825#1760400 , @aganea wrote:

> In D69825#1760373 , @russell.gallop 
> wrote:
>
> > It looks like the git apply didn't work, but the script continued so this 
> > was a duff experiment, please ignore. I'll try to fix this and run it again.
>


Note for other reviewers, the abba_test.ps1 script uses a git format patch, not 
the format you can download from Phabricator.

> Thanks Russell! Can you try running the script overnight? It'll give a better 
> result and we'll see the error bar.

Okay. With the patch sorted, I ran for 10 hours overnight.

  Total iterations:  21
  
   | Min   |Mean   |   Median  | 
Max   |
 A |  00:14:11.0340636 |  00:14:33.2494597 |  00:14:25.3644475 |  
00:15:25.4082274 |
 B |  00:13:57.9445995 |  00:14:20.3073502 |  00:14:09.0937819 |  
00:16:06.2885457 |
  Diff | -00:00:13.0894641 | -00:00:12.9421096 | -00:00:16.2706656 |  
00:00:40.8803183 |

From looking at the individual times this was stable for a couple of hours then 
there were some particularly long runs (on A and B), possibly some scheduled 
maintenance tasks, so I'd recommend using the median value to ignore these 
outliers. Based on the median this saves about 1.9% for me.


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

https://reviews.llvm.org/D69825



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D70769#1761428 , @lh123 wrote:

> In D70769#1761394 , @jhenderson 
> wrote:
>
> > Are there any instances where we DON'T want to get the real file system? If 
> > not, could the `*llvm::vfs::getRealFileSystem()` call be put inside 
> > `cl::ExpandResponseFiles`?
>
>
> This patch is part of D70222 .
>
>   This is for using InMemoryFileSystem in unit tests.


Okay, that makes sense. Perhaps we should introduce a new overload of 
`ExpandResponseFiles` that allows specifying a different file system then, and 
having the current version call into that one, specifying the getRealFileSystem 
call? I'm not overly keen on having yet another apparently boiler-plate piece 
of functionality required in every single call of `ExpandResponseFiles`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 231206.
sammccall added a comment.

Rewrote patch with a better approach (claiming expanded tokens rather than 
spelled).
Added more tests, including one showing a problem with multiple arg expansion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512

Files:
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/unittests/SelectionTests.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang/include/clang/Tooling/Syntax/Tokens.h
  clang/lib/Tooling/Syntax/Tokens.cpp
  clang/unittests/Tooling/Syntax/TokensTest.cpp

Index: clang/unittests/Tooling/Syntax/TokensTest.cpp
===
--- clang/unittests/Tooling/Syntax/TokensTest.cpp
+++ clang/unittests/Tooling/Syntax/TokensTest.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Support/Annotations.h"
 #include "llvm/Testing/Support/SupportHelpers.h"
+#include "gmock/gmock.h"
 #include 
 #include 
 #include 
@@ -663,6 +664,20 @@
   ValueIs(SameRange(findSpelled("not_mapped";
 }
 
+TEST_F(TokenBufferTest, ExpandedTokensForRange) {
+  recordTokens(R"cpp(
+#define SIGN(X) X##_washere
+A SIGN(B) C SIGN(D) E SIGN(F) G
+  )cpp");
+
+  SourceRange R(findExpanded("C").front().location(),
+findExpanded("F_washere").front().location());
+  // Sanity check: expanded and spelled tokens are stored separately.
+  EXPECT_THAT(Buffer.expandedTokens(R),
+  SameRange(findExpanded("C D_washere E F_washere")));
+  EXPECT_THAT(Buffer.expandedTokens(SourceRange()), testing::IsEmpty());
+}
+
 TEST_F(TokenBufferTest, ExpansionStartingAt) {
   // Object-like macro expansions.
   recordTokens(R"cpp(
Index: clang/lib/Tooling/Syntax/Tokens.cpp
===
--- clang/lib/Tooling/Syntax/Tokens.cpp
+++ clang/lib/Tooling/Syntax/Tokens.cpp
@@ -119,6 +119,22 @@
   return Text.substr(Begin, length());
 }
 
+llvm::ArrayRef TokenBuffer::expandedTokens(SourceRange R) const {
+  if (R.isInvalid())
+return {};
+  const Token *Begin =
+  llvm::partition_point(expandedTokens(), [&](const syntax::Token &T) {
+return SourceMgr->isBeforeInTranslationUnit(T.location(), R.getBegin());
+  });
+  const Token *End =
+  llvm::partition_point(expandedTokens(), [&](const syntax::Token &T) {
+return !SourceMgr->isBeforeInTranslationUnit(R.getEnd(), T.location());
+  });
+  if (Begin > End)
+return {};
+  return {Begin, End};
+}
+
 std::pair
 TokenBuffer::spelledForExpandedToken(const syntax::Token *Expanded) const {
   assert(Expanded);
Index: clang/include/clang/Tooling/Syntax/Tokens.h
===
--- clang/include/clang/Tooling/Syntax/Tokens.h
+++ clang/include/clang/Tooling/Syntax/Tokens.h
@@ -175,6 +175,7 @@
   /// All tokens produced by the preprocessor after all macro replacements,
   /// directives, etc. Source locations found in the clang AST will always
   /// point to one of these tokens.
+  /// Tokens are in TU order (per SourceManager::isBeforeInTranslationUnit()).
   /// FIXME: figure out how to handle token splitting, e.g. '>>' can be split
   ///into two '>' tokens by the parser. However, TokenBuffer currently
   ///keeps it as a single '>>' token.
@@ -182,6 +183,10 @@
 return ExpandedTokens;
   }
 
+  /// Returns the subrange of expandedTokens() corresponding to the closed
+  /// token range R.
+  llvm::ArrayRef expandedTokens(SourceRange R) const;
+
   /// Find the subrange of spelled tokens that produced the corresponding \p
   /// Expanded tokens.
   ///
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -269,7 +269,7 @@
   EXPECT_UNAVAILABLE(UnavailableCases);
 
   // vector of pairs of input and output strings
-  const std::vector>
+  const std::vector>
   InputOutputs = {
   // extraction from variable declaration/assignment
   {R"cpp(void varDecl() {
@@ -321,17 +321,10 @@
if(1)
 LOOP(5 + [[3]])
  })cpp",
-   /*FIXME: It should be extracted like this. SelectionTree needs to be
- * fixed for macros.
 R"cpp(#define LOOP(x) while (1) {a = x;}
-void f(int a) {
-  auto dummy = 3; if(1)
-   LOOP(5 + dummy)
-})cpp"},*/
-   R"cpp(#define LOOP(x) while (1) {a = x;}
  void f(int a) {
-   auto dummy = LOOP(5 + 3); if(1)
-dummy
+   auto dummy = 3; if(1)
+LOOP(5 + dummy)

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D70769#1761494 , @jhenderson wrote:

> In D70769#1761428 , @lh123 wrote:
>
> > In D70769#1761394 , @jhenderson 
> > wrote:
> >
> > > Are there any instances where we DON'T want to get the real file system? 
> > > If not, could the `*llvm::vfs::getRealFileSystem()` call be put inside 
> > > `cl::ExpandResponseFiles`?
> >
> >
> > This patch is part of D70222 .
> >
> >   This is for using InMemoryFileSystem in unit tests.
>
>
> Okay, that makes sense. Perhaps we should introduce a new overload of 
> `ExpandResponseFiles` that allows specifying a different file system then, 
> and having the current version call into that one, specifying the 
> getRealFileSystem call? I'm not overly keen on having yet another apparently 
> boiler-plate piece of functionality required in every single call of 
> `ExpandResponseFiles`.


It's not just unit-tests, in D70222  we will 
ultimately use FSes other than getRealFilesystem() in clangd.
Having non-VFS-clean versions of functions around that silently use the real FS 
is a bit of a scourge for users that need to be VFS-clean, honestly. Parsing 
argv is exactly the sort of place where FS access isn't obvious and exposing a 
function that doesn't accept a VFS encourages callers to miss this aspect. At 
the same time this is mostly called from a bunch of drivers that (presumably) 
don't need VFS support. Maybe allowing nullptr = real FS, or a default 
argument, would be an OK compromise?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70524: Support DebugInfo generation for auto return type for C++ functions.

2019-11-27 Thread Awanish Pandey via Phabricator via cfe-commits
awpandey updated this revision to Diff 231208.
awpandey marked 5 inline comments as done.
awpandey added a comment.

Hi @aprantl  and @dblaikie. Currently, there is no test case for the 
unspecified type, so I have added that in the regression test suite. Also, I 
have incorporated all of your suggestions.


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

https://reviews.llvm.org/D70524

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/test/CodeGenCXX/debug-info-auto-return.cpp
  llvm/test/DebugInfo/X86/debug-info-auto-return.ll

Index: llvm/test/DebugInfo/X86/debug-info-auto-return.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/X86/debug-info-auto-return.ll
@@ -0,0 +1,171 @@
+;RUN: %llc_dwarf %s -filetype=obj -o - | llvm-dwarfdump -v - | FileCheck %s
+
+; C++ source to regenerate:
+
+;class myClass {
+;int low, high;
+;
+;  public:
+;  myClass(int a, int b) {
+;low = a;
+;high = b;
+;  }
+;auto findMax();
+;};
+;
+;auto myClass::findMax() {
+;if (low > high)
+;return 1;
+;  else
+;return 1;
+;}
+;int main() {
+;myClass f(3, 5);
+;  return 0;
+;}
+
+; CHECK: .debug_info contents:
+
+; CHECK:  DW_TAG_subprogram [7] *
+; CHECK-NEXT: DW_AT_linkage_name {{.*}} string = "_ZN7myClass7findMaxEv")
+; CHECK: DW_AT_type [DW_FORM_ref4] {{.*}} "auto"
+; CHECK-NEXT: DW_AT_declaration {{.*}} (true)
+
+; CHECK: DW_TAG_unspecified_type
+; CHECK-NEXT:  DW_AT_name [DW_FORM_strx1] {{.*}} "auto"
+
+; ModuleID = 'debug-info-auto-return.cpp'
+source_filename = "debug-info-auto-return.cpp"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%class.myClass = type { i32, i32 }
+
+$_ZN7myClassC2Eii = comdat any
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @_ZN7myClass7findMaxEv(%class.myClass* %this) #0 align 2 !dbg !7 {
+entry:
+  %retval = alloca i32, align 4
+  %this.addr = alloca %class.myClass*, align 8
+  store %class.myClass* %this, %class.myClass** %this.addr, align 8
+  call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !22, metadata !DIExpression()), !dbg !24
+  %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8
+  %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !25
+  %0 = load i32, i32* %low, align 4, !dbg !25
+  %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !27
+  %1 = load i32, i32* %high, align 4, !dbg !27
+  %cmp = icmp sgt i32 %0, %1, !dbg !28
+  br i1 %cmp, label %if.then, label %if.else, !dbg !29
+
+if.then:  ; preds = %entry
+  store i32 1, i32* %retval, align 4, !dbg !30
+  br label %return, !dbg !30
+
+if.else:  ; preds = %entry
+  store i32 1, i32* %retval, align 4, !dbg !31
+  br label %return, !dbg !31
+
+return:   ; preds = %if.else, %if.then
+  %2 = load i32, i32* %retval, align 4, !dbg !32
+  ret i32 %2, !dbg !32
+}
+
+; Function Attrs: nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+; Function Attrs: noinline norecurse optnone uwtable
+define dso_local i32 @main() #2 !dbg !33 {
+entry:
+  %retval = alloca i32, align 4
+  %f = alloca %class.myClass, align 4
+  store i32 0, i32* %retval, align 4
+  call void @llvm.dbg.declare(metadata %class.myClass* %f, metadata !36, metadata !DIExpression()), !dbg !37
+  call void @_ZN7myClassC2Eii(%class.myClass* %f, i32 3, i32 5), !dbg !37
+  ret i32 0, !dbg !38
+}
+
+; Function Attrs: noinline nounwind optnone uwtable
+define linkonce_odr dso_local void @_ZN7myClassC2Eii(%class.myClass* %this, i32 %a, i32 %b) unnamed_addr #0 comdat align 2 !dbg !39 {
+entry:
+  %this.addr = alloca %class.myClass*, align 8
+  %a.addr = alloca i32, align 4
+  %b.addr = alloca i32, align 4
+  store %class.myClass* %this, %class.myClass** %this.addr, align 8
+  call void @llvm.dbg.declare(metadata %class.myClass** %this.addr, metadata !40, metadata !DIExpression()), !dbg !41
+  store i32 %a, i32* %a.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !42, metadata !DIExpression()), !dbg !43
+  store i32 %b, i32* %b.addr, align 4
+  call void @llvm.dbg.declare(metadata i32* %b.addr, metadata !44, metadata !DIExpression()), !dbg !45
+  %this1 = load %class.myClass*, %class.myClass** %this.addr, align 8
+  %0 = load i32, i32* %a.addr, align 4, !dbg !46
+  %low = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 0, !dbg !48
+  store i32 %0, i32* %low, align 4, !dbg !49
+  %1 = load i32, i32* %b.addr, align 4, !dbg !50
+  %high = getelementptr inbounds %class.myClass, %class.myClass* %this1, i32 0, i32 1, !dbg !51
+

[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60302 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512



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


[PATCH] D70684: [clangd] Shutdown cleanly on signals.

2019-11-27 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG19ac0eaf07e6: [clangd] Shutdown cleanly on signals. 
(authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70684

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/JSONTransport.cpp
  clang-tools-extra/clangd/Shutdown.cpp
  clang-tools-extra/clangd/Shutdown.h
  clang-tools-extra/clangd/test/exit-eof.test
  clang-tools-extra/clangd/test/exit-signal.test
  clang-tools-extra/clangd/tool/ClangdMain.cpp

Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -11,6 +11,7 @@
 #include "Features.inc"
 #include "Path.h"
 #include "Protocol.h"
+#include "Shutdown.h"
 #include "Trace.h"
 #include "Transport.h"
 #include "index/Background.h"
@@ -35,6 +36,10 @@
 #include 
 #include 
 
+#ifndef _WIN32
+#include 
+#endif
+
 namespace clang {
 namespace clangd {
 namespace {
@@ -445,6 +450,7 @@
 
   llvm::InitializeAllTargetInfos();
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  llvm::sys::SetInterruptFunction(&requestShutdown);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream &OS) {
 OS << clang::getClangToolFullVersion("clangd") << "\n";
   });
@@ -541,6 +547,10 @@
   LoggingSession LoggingSession(Logger);
   // Write some initial logs before we start doing any real work.
   log("{0}", clang::getClangToolFullVersion("clangd"));
+// FIXME: abstract this better, and print PID on windows too.
+#ifndef _WIN32
+  log("PID: {0}", getpid());
+#endif
   {
 SmallString<128> CWD;
 if (auto Err = llvm::sys::fs::current_path(CWD))
@@ -694,12 +704,7 @@
   // However if a bug causes them to run forever, we want to ensure the process
   // eventually exits. As clangd isn't directly user-facing, an editor can
   // "leak" clangd processes. Crashing in this case contains the damage.
-  //
-  // This is more portable than sys::WatchDog, and yields a stack trace.
-  std::thread([] {
-std::this_thread::sleep_for(std::chrono::minutes(5));
-std::abort();
-  }).detach();
+  abortAfterTimeout(std::chrono::minutes(5));
 
   return ExitCode;
 }
Index: clang-tools-extra/clangd/test/exit-signal.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-signal.test
@@ -0,0 +1,32 @@
+# This is a fiddly signal test, we need POSIX and a real shell.
+UNSUPPORTED: win32
+REQUIRES: shell
+
+# Our goal is:
+#  1) spawn clangd
+#  2) wait for it to start up (install signal handlers)
+#  3) send SIGTERM
+#  4) wait for clangd to shut down (nonzero exit for a signal)
+#  4) verify the shutdown was clean
+
+RUN: rm -f %t.err
+ # To keep clangd running, we need to hold its input stream open.
+ # We redirect its input to a subshell that waits for it to start up.
+RUN: not clangd 2> %t.err < <( \
+   # Loop waiting for clangd to start up, so signal handlers are installed.
+   # Reading the PID line ensures this, and lets us send a signal.
+RUN:   while true; do \
+ # Relevant log line is I[timestamp] PID: 
+RUN: CLANGD_PID=$(grep -a -m 1 "PID:" %t.err | cut -d' ' -f 3); \
+RUN: [ ! -z "$CLANGD_PID" ] && break; \
+RUN:   done; \
+RUN:   kill $CLANGD_PID; \
+   # Now wait for clangd to stop reading (before closing its input!)
+RUN:   while not grep "LSP finished" %t.err; do :; done; \
+RUN: )
+
+# Check that clangd caught the signal and shut down cleanly.
+RUN: FileCheck %s < %t.err
+CHECK: Transport error: Got signal
+CHECK: LSP finished
+
Index: clang-tools-extra/clangd/test/exit-eof.test
===
--- /dev/null
+++ clang-tools-extra/clangd/test/exit-eof.test
@@ -0,0 +1,7 @@
+# RUN: not clangd -sync < %s 2> %t.err
+# RUN: FileCheck %s < %t.err
+#
+# No LSP messages here, just let clangd see the end-of-file
+# CHECK: Transport error:
+# (Typically "Transport error: Input/output error" but platform-dependent).
+
Index: clang-tools-extra/clangd/Shutdown.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Shutdown.h
@@ -0,0 +1,84 @@
+//===--- Shutdown.h - Unclean exit scenarios *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// LSP specifies a protocol for shutting down: a `shutdown` request followed
+// by an `exit` notification. If this protocol is followed, clangd should
+// finish outstanding work and exit with code 0.
+//
+// The way this works in th

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

In D70769#1761517 , @sammccall wrote:

> It's not just unit-tests, in D70222  we will 
> ultimately use FSes other than getRealFilesystem() in clangd.


I see, thank you.

> Having non-VFS-clean versions of functions around that silently use the real 
> FS is a bit of a scourge for users that need to be VFS-clean, honestly. 
> Parsing argv is exactly the sort of place where FS access isn't obvious and 
> exposing a function that doesn't accept a VFS encourages callers to miss this 
> aspect. At the same time this is mostly called from a bunch of drivers that 
> (presumably) don't need VFS support. Maybe allowing nullptr = real FS, or a 
> default argument, would be an OK compromise?

A default argument would be my preference there. It looks like we have some 
already.




Comment at: llvm/include/llvm/Support/CommandLine.h:1963
 /// \param [in] Tokenizer Tokenization strategy. Typically Unix or Windows.
+/// \param [in] FS VFS used for all file accesses when running the tool.
 /// \param [in,out] Argv Command line into which to expand response files.

Does `VFS` make sense here, given that it could be a real filesystem?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231213.
lh123 added a comment.

Address comments


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

https://reviews.llvm.org/D70769

Files:
  clang/tools/driver/driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/tools/lld/lld.cpp
  lld/wasm/Driver.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "gtest/gtest.h"
 #include 
 #include 
@@ -830,7 +831,8 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
   bool Res = llvm::cl::ExpandResponseFiles(
-Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true);
+  Saver, llvm::cl::TokenizeGNUCommandLine, *llvm::vfs::getRealFileSystem(),
+  Argv, false, true);
   EXPECT_TRUE(Res);
   EXPECT_EQ(Argv.size(), 13U);
   EXPECT_STREQ(Argv[0], "test/test");
@@ -905,7 +907,8 @@
 #else
   cl::TokenizerCallback Tokenizer = cl::TokenizeGNUCommandLine;
 #endif
-  bool Res = cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false);
+  bool Res = cl::ExpandResponseFiles(
+  Saver, Tokenizer, *llvm::vfs::getRealFileSystem(), Argv, false, false);
   EXPECT_FALSE(Res);
 
   EXPECT_EQ(Argv.size(), 9U);
@@ -943,7 +946,8 @@
 
   BumpPtrAllocator A;
   StringSaver Saver(A);
-  bool Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
+  bool Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine,
+ *llvm::vfs::getRealFileSystem(), Argv,
  false, false);
   EXPECT_FALSE(Res);
 
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -338,7 +339,7 @@
   Triple(sys::getProcessTriple()).isOSWindows()
   ? cl::TokenizeWindowsCommandLine
   : cl::TokenizeGNUCommandLine,
-  NewArgv);
+  *llvm::vfs::getRealFileSystem(), NewArgv);
 
   auto Args = makeArrayRef(NewArgv).drop_front();
   Expected DriverConfig =
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -32,6 +32,7 @@
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h"
@@ -1096,7 +1097,8 @@
 static int ar_main(int argc, char **argv) {
   SmallVector Argv(argv, argv + argc);
   StringSaver Saver(Alloc);
-  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine,
+  *llvm::vfs::getRealFileSystem(), Argv);
   for (size_t i = 1; i < Argv.size(); ++i) {
 StringRef Arg = Argv[i];
 const char *match = nullptr;
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -267,7 +268,8 @@
 
   // Parse command line arguments.
   SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end());
-  cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine,
+  *llvm::vfs::getRealFileSystem(), NewArgs);
   ArgsArr = NewArgs;
 
   LibOptTable Table;
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Supp

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231215.
lh123 added a comment.

address comments and delete unused code.


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

https://reviews.llvm.org/D70769

Files:
  clang/tools/driver/driver.cpp
  lld/COFF/DriverUtils.cpp
  lld/ELF/DriverUtils.cpp
  lld/MinGW/Driver.cpp
  lld/tools/lld/lld.cpp
  lld/wasm/Driver.cpp
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp
  llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
  llvm/tools/llvm-ar/llvm-ar.cpp
  llvm/tools/llvm-objcopy/llvm-objcopy.cpp
  llvm/unittests/Support/CommandLineTest.cpp

Index: llvm/unittests/Support/CommandLineTest.cpp
===
--- llvm/unittests/Support/CommandLineTest.cpp
+++ llvm/unittests/Support/CommandLineTest.cpp
@@ -17,6 +17,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Program.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "gtest/gtest.h"
 #include 
 #include 
@@ -830,7 +831,8 @@
   llvm::BumpPtrAllocator A;
   llvm::StringSaver Saver(A);
   bool Res = llvm::cl::ExpandResponseFiles(
-Saver, llvm::cl::TokenizeGNUCommandLine, Argv, false, true);
+  Saver, llvm::cl::TokenizeGNUCommandLine, *llvm::vfs::getRealFileSystem(),
+  Argv, false, true);
   EXPECT_TRUE(Res);
   EXPECT_EQ(Argv.size(), 13U);
   EXPECT_STREQ(Argv[0], "test/test");
@@ -905,7 +907,8 @@
 #else
   cl::TokenizerCallback Tokenizer = cl::TokenizeGNUCommandLine;
 #endif
-  bool Res = cl::ExpandResponseFiles(Saver, Tokenizer, Argv, false, false);
+  bool Res = cl::ExpandResponseFiles(
+  Saver, Tokenizer, *llvm::vfs::getRealFileSystem(), Argv, false, false);
   EXPECT_FALSE(Res);
 
   EXPECT_EQ(Argv.size(), 9U);
@@ -943,7 +946,8 @@
 
   BumpPtrAllocator A;
   StringSaver Saver(A);
-  bool Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv,
+  bool Res = cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine,
+ *llvm::vfs::getRealFileSystem(), Argv,
  false, false);
   EXPECT_FALSE(Res);
 
Index: llvm/tools/llvm-objcopy/llvm-objcopy.cpp
===
--- llvm/tools/llvm-objcopy/llvm-objcopy.cpp
+++ llvm/tools/llvm-objcopy/llvm-objcopy.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
@@ -338,7 +339,7 @@
   Triple(sys::getProcessTriple()).isOSWindows()
   ? cl::TokenizeWindowsCommandLine
   : cl::TokenizeGNUCommandLine,
-  NewArgv);
+  *llvm::vfs::getRealFileSystem(), NewArgv);
 
   auto Args = makeArrayRef(NewArgv).drop_front();
   Expected DriverConfig =
Index: llvm/tools/llvm-ar/llvm-ar.cpp
===
--- llvm/tools/llvm-ar/llvm-ar.cpp
+++ llvm/tools/llvm-ar/llvm-ar.cpp
@@ -32,6 +32,7 @@
 #include "llvm/Support/StringSaver.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/ToolOutputFile.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/WithColor.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h"
@@ -1096,7 +1097,8 @@
 static int ar_main(int argc, char **argv) {
   SmallVector Argv(argv, argv + argc);
   StringSaver Saver(Alloc);
-  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine, Argv);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeGNUCommandLine,
+  *llvm::vfs::getRealFileSystem(), Argv);
   for (size_t i = 1; i < Argv.size(); ++i) {
 StringRef Arg = Argv[i];
 const char *match = nullptr;
Index: llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
===
--- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
+++ llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
@@ -27,6 +27,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 
 using namespace llvm;
@@ -267,7 +268,8 @@
 
   // Parse command line arguments.
   SmallVector NewArgs(ArgsArr.begin(), ArgsArr.end());
-  cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine, NewArgs);
+  cl::ExpandResponseFiles(Saver, cl::TokenizeWindowsCommandLine,
+  *llvm::vfs::getRealFileSystem(), NewArgs);
   ArgsArr = NewArgs;
 
   LibOptTable Table;
Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7

[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9872ea4ed1de: [clang][CodeGen] Implicit Conversion 
Sanitizer: handle increment/decrement… (authored by lebedev.ri).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/catch-implicit-conversions-incdec-basics.c
  
clang/test/CodeGen/catch-implicit-integer-arithmetic-value-change-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-conversions-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
  clang/test/CodeGen/catch-implicit-integer-truncations-incdec-basics.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec-basics.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  clang/test/CodeGen/catch-implicit-unsigned-integer-truncations-incdec-basics.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-conversion-incdec.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-sign-change-incdec.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c

Index: compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c
@@ -0,0 +1,122 @@
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+
+void test_unsigned() {
+  unsigned char x;
+
+  x = 0;
+  x++;
+  x = 0;
+  ++x;
+
+  x = 0;
+  x--;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned char' changed the value to 255 (8-bit, unsigned)
+  x = 0;
+  --x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned char' changed the value to 255 (8-bit, unsigned)
+
+  x = 1;
+  x++;
+  x = 1;
+  ++x;
+
+  x = 1;
+  x--;
+  x = 1;
+  --x;
+
+  x = 254;
+  x++;
+  x = 254;
+  ++x;
+
+  x = 254;
+  x--;
+  x = 254;
+  --x;
+
+  x = 255;
+  x++;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned)
+  x = 255;
+  ++x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned)
+
+  x = 255;
+  x--;
+  x = 255;
+  --x;
+}
+
+void test_signed() {
+  signed char x;
+
+  x = -128;
+  x++;
+  x = -128;
+  ++x;
+
+  x = -128;
+  x--;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value -129 (32-bit, signed) to type 'signed char' changed the value to 127 (8-bit, signed)
+  x = -128;
+  --x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value -129 (32-bit, signed) to type 'signed char' changed the value to 127 (8-bit, signed)
+
+  x = -1;
+  x++;
+  x = -1;
+  ++x;
+
+  x = -1;
+  x--;
+  x = -1;
+  --x;
+
+  x = 0;
+  x++;
+  x = 0;
+  ++x;
+
+  x = 0;

[clang] 3edf2eb - [Frontend] Clean up some dead code in PrecompiledPreamble. NFC

2019-11-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2019-11-27T13:44:14+01:00
New Revision: 3edf2eb897e4fe0795253e8e8c1e62b93bac60c9

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

LOG: [Frontend] Clean up some dead code in PrecompiledPreamble. NFC

Added: 


Modified: 
clang/include/clang/Frontend/PrecompiledPreamble.h
clang/lib/Frontend/PrecompiledPreamble.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/PrecompiledPreamble.h 
b/clang/include/clang/Frontend/PrecompiledPreamble.h
index 1a8a64951ec4..5ae77735576c 100644
--- a/clang/include/clang/Frontend/PrecompiledPreamble.h
+++ b/clang/include/clang/Frontend/PrecompiledPreamble.h
@@ -134,14 +134,6 @@ class PrecompiledPreamble {
 // A main method used to construct TempPCHFile.
 static llvm::ErrorOr CreateNewPreamblePCHFile();
 
-/// Call llvm::sys::fs::createTemporaryFile to create a new temporary file.
-static llvm::ErrorOr createInSystemTempDir(const Twine 
&Prefix,
-StringRef Suffix);
-/// Create a new instance of TemporaryFile for file at \p Path. Use with
-/// extreme caution, there's an assertion checking that there's only a
-/// single instance of TempPCHFile alive for each path.
-static llvm::ErrorOr createFromCustomPath(const Twine &Path);
-
   private:
 TempPCHFile(std::string FilePath);
 

diff  --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index ced32c670288..0e5a8e504dc5 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -535,21 +535,15 @@ 
PrecompiledPreamble::TempPCHFile::CreateNewPreamblePCHFile() {
   // FIXME: This is a hack so that we can override the preamble file during
   // crash-recovery testing, which is the only case where the preamble files
   // are not necessarily cleaned up.
-  const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE");
-  if (TmpFile)
-return TempPCHFile::createFromCustomPath(TmpFile);
-  return TempPCHFile::createInSystemTempDir("preamble", "pch");
-}
+  if (const char *TmpFile = ::getenv("CINDEXTEST_PREAMBLE_FILE"))
+return TempPCHFile(TmpFile);
 
-llvm::ErrorOr
-PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix,
-StringRef Suffix) {
   llvm::SmallString<64> File;
   // Using a version of createTemporaryFile with a file descriptor guarantees
   // that we would never get a race condition in a multi-threaded setting
   // (i.e., multiple threads getting the same temporary path).
   int FD;
-  auto EC = llvm::sys::fs::createTemporaryFile(Prefix, Suffix, FD, File);
+  auto EC = llvm::sys::fs::createTemporaryFile("preamble", "pch", FD, File);
   if (EC)
 return EC;
   // We only needed to make sure the file exists, close the file right away.
@@ -557,11 +551,6 @@ 
PrecompiledPreamble::TempPCHFile::createInSystemTempDir(const Twine &Prefix,
   return TempPCHFile(std::move(File).str());
 }
 
-llvm::ErrorOr
-PrecompiledPreamble::TempPCHFile::createFromCustomPath(const Twine &Path) {
-  return TempPCHFile(Path.str());
-}
-
 PrecompiledPreamble::TempPCHFile::TempPCHFile(std::string FilePath)
 : FilePath(std::move(FilePath)) {
   TemporaryFiles::getInstance().addFile(*this->FilePath);



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


[clang] a29aa47 - [OpenCL] Move addr space deduction to Sema.

2019-11-27 Thread Anastasia Stulova via cfe-commits

Author: Anastasia Stulova
Date: 2019-11-27T12:44:42Z
New Revision: a29aa47106205ec95c12e0ebac4260c5de878a6a

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

LOG: [OpenCL] Move addr space deduction to Sema.

In order to simplify implementation we are moving add space
deduction into Sema while constructing variable declaration
and on template instantiation. Pointee are deduced to generic
addr space during creation of types.

This commit also
- fixed addr space dedution for auto type;
- factors out in a separate helper function OpenCL specific
  logic from type diagnostics in var decl.

Tags: #clang

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

Added: 
clang/test/SemaOpenCLCXX/addrspace-auto.cl

Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Expr.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Sema/TreeTransform.h
clang/test/SemaOpenCL/event_t.cl
clang/test/SemaOpenCL/invalid-block.cl
clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
clang/test/SemaOpenCL/sampler_t.cl
clang/test/SemaOpenCLCXX/address-space-deduction.cl
clang/test/SemaOpenCLCXX/restricted.cl

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index ecbbd73e19fb..05e78aa78236 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -2069,6 +2069,8 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
   bool isAlignValT() const; // C++17 std::align_val_t
   bool isStdByteType() const;   // C++17 std::byte
   bool isAtomicType() const;// C11 _Atomic()
+  bool isUndeducedAutoType() const; // C++11 auto or
+// C++14 decltype(auto)
 
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   bool is##Id##Type() const;
@@ -6509,6 +6511,10 @@ inline bool Type::isAtomicType() const {
   return isa(CanonicalType);
 }
 
+inline bool Type::isUndeducedAutoType() const {
+  return isa(CanonicalType);
+}
+
 inline bool Type::isObjCQualifiedIdType() const {
   if (const auto *OPT = getAs())
 return OPT->isObjCQualifiedIdType();

diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 0a6f58a484ae..ac5a4953e00d 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -8760,6 +8760,8 @@ class Sema final {
   bool CheckARCMethodDecl(ObjCMethodDecl *method);
   bool inferObjCARCLifetime(ValueDecl *decl);
 
+  void deduceOpenCLAddressSpace(ValueDecl *decl);
+
   ExprResult
   HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
 Expr *BaseExpr,

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 3f722f8fd541..322b3a7fa740 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1814,7 +1814,7 @@ bool CastExpr::CastConsistency() const {
 auto Ty = getType();
 auto SETy = getSubExpr()->getType();
 assert(getValueKindForType(Ty) == Expr::getValueKindForType(SETy));
-if (/*isRValue()*/ !Ty->getPointeeType().isNull()) {
+if (isRValue()) {
   Ty = Ty->getPointeeType();
   SETy = SETy->getPointeeType();
 }

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6ea4923dc2ba..dffb460cedc9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -6117,6 +6117,22 @@ bool Sema::inferObjCARCLifetime(ValueDecl *decl) {
   return false;
 }
 
+void Sema::deduceOpenCLAddressSpace(ValueDecl *Decl) {
+  if (Decl->getType().getQualifiers().hasAddressSpace())
+return;
+  if (VarDecl *Var = dyn_cast(Decl)) {
+QualType Type = Var->getType();
+if (Type->isSamplerT() || Type->isVoidType())
+  return;
+LangAS ImplAS = LangAS::opencl_private;
+if ((getLangOpts().OpenCLCPlusPlus || getLangOpts().OpenCLVersion >= 200) 
&&
+Var->hasGlobalStorage())
+  ImplAS = LangAS::opencl_global;
+Type = Context.getAddrSpaceQualType(Type, ImplAS);
+Decl->setType(Type);
+  }
+}
+
 static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND) {
   // Ensure that an auto decl is deduced otherwise the checks below might cache
   // the wrong linkage.
@@ -6474,6 +6490,105 @@ static bool isDeclExternC(const Decl *D) {
 
   llvm_unreachable("Unknown type of decl!");
 }
+/// Returns true if there hasn't been any invalid type diagnosed.
+static bool diagnoseOpenCLTypes(Scope *S, Sema &Se, Declarator &D,
+DeclContext *DC, QualType R) {
+  // OpenCL v2.0 s6.9.b - Image type can only be used as a function argume

[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231217.
lh123 set the repository for this revision to rG LLVM Github Monorepo.
lh123 added a comment.

rebase to D70769 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70222

Files:
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -859,5 +859,64 @@
 "clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
 }
 
+class ExpandResponseFilesTest : public MemDBTest {
+protected:
+  void SetUp() override {
+FS = new llvm::vfs::InMemoryFileSystem;
+
+InnerDir = path(StringRef("inner"));
+
+llvm::sys::path::append(RspFileName1, InnerDir, "rsp1.rsp");
+addFile(RspFileName1, "-Dflag1");
+
+RspFileName2 = path(StringRef("rsp2.rsp"));
+addFile(RspFileName2, "-Dflag2 @rsp3.rsp");
+
+RspFileName3 = path(StringRef("rsp3.rsp"));
+addFile(RspFileName3, "-Dflag3");
+
+RspFileName4 = path(StringRef("rsp4.rsp"));
+addFile(RspFileName4, "-Dflag4 @rsp4.rsp");
+
+llvm::sys::path::append(RspFileName5, InnerDir, "rsp5.rsp");
+addFile(RspFileName5, "-Dflag5 @inner/rsp1.rsp");
+  }
+
+  void addFile(StringRef File, StringRef Context) {
+ASSERT_TRUE(FS->addFile(File, 0, llvm::MemoryBuffer::getMemBufferCopy(Context)));
+  }
+
+  std::string getCommand(llvm::StringRef F) {
+auto Results = expandResponseFiles(std::make_unique(Entries),
+   FS)
+   ->getCompileCommands(path(F));
+if (Results.empty()) {
+  return "none";
+}
+return llvm::join(Results[0].CommandLine, " ");
+  }
+
+  SmallString<128> InnerDir;
+  SmallString<128> RspFileName1;
+  SmallString<128> RspFileName2;
+  SmallString<128> RspFileName3;
+  SmallString<128> RspFileName4;
+  SmallString<128> RspFileName5;
+  llvm::IntrusiveRefCntPtr FS;
+
+};
+
+TEST_F(ExpandResponseFilesTest, ExpandResponseFiles) {
+  // clang-format off
+  add("foo.cpp", "clang",
+  ("@inner/rsp1.rsp @rsp2.rsp @rsp4.rsp "
+"@" + RspFileName1 + " @inner/rsp5.rsp @rsp6.rsp")
+  .str());
+  // clang-format on
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag1 -Dflag2 "
+   "-Dflag3 -Dflag4 @rsp4.rsp -Dflag1 "
+   "-Dflag5 -Dflag1 @rsp6.rsp");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -168,7 +168,8 @@
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
 return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(std::move(Base)))
+  inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem(
 : nullptr;
   }
 };
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -0,0 +1,92 @@
+//===- ExpandResponseFileCompilationDataBase.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+
+class ExpandResponseFilesDatabase : public CompilationDatabase {
+public:
+  ExpandResponseFilesDatabase(
+  std::unique_ptr Base,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::IntrusiveRefCntPtr FS)
+  : Base(std::move(Base)), Tokenizer(Tokenizer), FS(FS) {
+assert(this->Base != nullptr);
+assert(this->Tokenizer != nullptr);
+assert(this->FS != nullptr);
+  }
+
+  std::vector getAllFiles() const override {
+return Base->getAllFiles();

[PATCH] D65744: [PR42707][OpenCL] Fix addr space deduction for auto

2019-11-27 Thread Anastasia Stulova via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa29aa4710620: [OpenCL] Move addr space deduction to Sema. 
(authored by Anastasia).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D65744?vs=227841&id=231218#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D65744

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Expr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/SemaOpenCL/event_t.cl
  clang/test/SemaOpenCL/invalid-block.cl
  clang/test/SemaOpenCL/invalid-pipes-cl2.0.cl
  clang/test/SemaOpenCL/sampler_t.cl
  clang/test/SemaOpenCLCXX/address-space-deduction.cl
  clang/test/SemaOpenCLCXX/addrspace-auto.cl
  clang/test/SemaOpenCLCXX/restricted.cl

Index: clang/test/SemaOpenCLCXX/restricted.cl
===
--- clang/test/SemaOpenCLCXX/restricted.cl
+++ clang/test/SemaOpenCLCXX/restricted.cl
@@ -32,12 +32,14 @@
 __constant _Thread_local int a = 1;
 // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '_Thread_local' storage class specifier}}
 // expected-warning@-2 {{'_Thread_local' is a C11 extension}}
-
+// expected-error@-3 {{thread-local storage is not supported for the current target}}
 __constant __thread int b = 2;
 // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the '__thread' storage class specifier}}
+// expected-error@-2 {{thread-local storage is not supported for the current target}}
 kernel void test_storage_classes() {
   register int x;
   // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'register' storage class specifier}}
   thread_local int y;
   // expected-error@-1 {{C++ for OpenCL version 1.0 does not support the 'thread_local' storage class specifier}}
+  // expected-error@-2 {{thread-local storage is not supported for the current target}}
 }
Index: clang/test/SemaOpenCLCXX/addrspace-auto.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/addrspace-auto.cl
@@ -0,0 +1,35 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+__constant int i = 1;
+//CHECK: |-VarDecl {{.*}} ai '__global int':'__global int'
+auto ai = i;
+
+kernel void test() {
+  int i;
+  //CHECK: VarDecl {{.*}} ai 'int':'int'
+  auto ai = i;
+
+  constexpr int c = 1;
+  //CHECK: VarDecl {{.*}} used cai '__constant int':'__constant int'
+  __constant auto cai = c;
+  //CHECK: VarDecl {{.*}} aii 'int':'int'
+  auto aii = cai;
+
+  //CHECK: VarDecl {{.*}} ref 'int &'
+  auto &ref = i;
+  //CHECK: VarDecl {{.*}} ptr 'int *'
+  auto *ptr = &i;
+  //CHECK: VarDecl {{.*}} ref_c '__constant int &'
+  auto &ref_c = cai;
+
+  //CHECK: VarDecl {{.*}} ptrptr 'int *__generic *'
+  auto **ptrptr = &ptr;
+  //CHECK: VarDecl {{.*}} refptr 'int *__generic &'
+  auto *&refptr = ptr;
+
+  //CHECK: VarDecl {{.*}} invalid gref '__global auto &'
+  __global auto &gref = i; //expected-error{{variable 'gref' with type '__global auto &' has incompatible initializer of type 'int'}}
+  __local int *ptr_l;
+  //CHECK: VarDecl {{.*}} invalid gptr '__global auto *'
+  __global auto *gptr = ptr_l; //expected-error{{variable 'gptr' with type '__global auto *' has incompatible initializer of type '__local int *'}}
+}
Index: clang/test/SemaOpenCLCXX/address-space-deduction.cl
===
--- clang/test/SemaOpenCLCXX/address-space-deduction.cl
+++ clang/test/SemaOpenCLCXX/address-space-deduction.cl
@@ -65,30 +65,42 @@
 x3::x3(const x3 &t) {}
 
 template 
-T xxx(T *in) {
+T xxx(T *in1, T in2) {
   // This pointer can't be deduced to generic because addr space
   // will be taken from the template argument.
   //CHECK: `-VarDecl {{.*}} i 'T *' cinit
-  T *i = in;
+  T *i = in1;
   T ii;
+  __private T *ptr = ⅈ
+  ptr = &in2;
   return *i;
 }
 
 __kernel void test() {
   int foo[10];
-  xxx(&foo[0]);
+  xxx<__private int>(&foo[0], foo[0]);
+  // FIXME: Template param deduction fails here because
+  // temporaries are not in the __private address space.
+  // It is probably reasonable to put them in __private
+  // considering that stack and function params are
+  // implicitly in __private.
+  // However, if temporaries are left in default addr
+  // space we should at least pretty print the __private
+  // addr space. Otherwise diagnostic apprears to be
+  // confusing.
+  //xxx(&foo[0], foo[0]);
 }
 
 // Addr space for pointer/reference to an array
-//CHECK: FunctionDecl {{.*}} t1 'void (const __generic float (&)[2])'
+//CHECK: FunctionDecl {{.*}} t1 'void (const float (__generic &)[2])'
 void t1(const float (&fYZ)[2]);
-//CHECK: FunctionDecl

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: fail - 60341 tests passed, 3 failed and 732 were skipped.

  failed: Clang.CodeGen/catch-implicit-integer-sign-changes-incdec.c
  failed: Clang.CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  failed: libc++.std/thread/futures/futures_async/async.pass.cpp

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[clang] 870f354 - [CodeGen][UBSan] Relax newly-added verbose sanitization tests for inc/dec

2019-11-27 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2019-11-27T16:05:34+03:00
New Revision: 870f3542d3e0d06d208442bdca6482866b59171b

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

LOG: [CodeGen][UBSan] Relax newly-added verbose sanitization tests for inc/dec

In particular, don't hardcode the signature of the handler:
it takes src filepath so the length of buffers will not match,

Added: 


Modified: 
clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c

Removed: 




diff  --git a/clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c 
b/clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
index 3fe23ecbd8d9..41e08ee32a52 100644
--- a/clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
+++ b/clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
@@ -41,8 +41,8 @@ unsigned short t0(unsigned short x) {
 // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
 // CHECK-SANITIZE-ANYRECOVER-NEXT:[[TMP1:%.*]] = zext i32 [[INC]] to i64, 
!nosanitize
 // CHECK-SANITIZE-ANYRECOVER-NEXT:[[TMP2:%.*]] = zext i16 
[[X_PROMOTED_DEMOTED]] to i64, !nosanitize
-// CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ { [91 x i8]*, i32, i32 
}, { i16, i16, [6 x i8] }*, { i16, i16, [17 x i8] }*, i8 }* @[[LINE_100]] to 
i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
-// CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_implicit_conversion(i8* bitcast ({ { [91 x i8]*, i32, i32 }, { 
i16, i16, [6 x i8] }*, { i16, i16, [17 x i8] }*, i8 }* @[[LINE_100]] to i8*), 
i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
+// CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, 
{{{.*}}}*, i8 }* @[[LINE_100]] to i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, 
!nosanitize
+// CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, 
{{{.*}}}*, i8 }* @[[LINE_100]] to i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, 
!nosanitize
 // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
 // CHECK-SANITIZE-RECOVER-NEXT:   br label %[[CONT]], !nosanitize
 // CHECK-SANITIZE:  [[CONT]]:
@@ -76,8 +76,8 @@ unsigned short t1(unsigned short x) {
 // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
 // CHECK-SANITIZE-ANYRECOVER-NEXT:[[TMP1:%.*]] = zext i32 [[INC]] to i64, 
!nosanitize
 // CHECK-SANITIZE-ANYRECOVER-NEXT:[[TMP2:%.*]] = zext i16 
[[X_PROMOTED_DEMOTED]] to i64, !nosanitize
-// CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ { [91 x i8]*, i32, i32 
}, { i16, i16, [6 x i8] }*, { i16, i16, [17 x i8] }*, i8 }* @[[LINE_200]] to 
i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
-// CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_implicit_conversion(i8* bitcast ({ { [91 x i8]*, i32, i32 }, { 
i16, i16, [6 x i8] }*, { i16, i16, [17 x i8] }*, i8 }* @[[LINE_200]] to i8*), 
i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
+// CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, 
{{{.*}}}*, i8 }* @[[LINE_200]] to i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, 
!nosanitize
+// CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_implicit_conversion(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, 
{{{.*}}}*, i8 }* @[[LINE_200]] to i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, 
!nosanitize
 // CHECK-SANITIZE-UNREACHABLE-NEXT:   unreachable, !nosanitize
 // CHECK-SANITIZE-RECOVER-NEXT:   br label %[[CONT]], !nosanitize
 // CHECK-SANITIZE:  [[CONT]]:
@@ -112,8 +112,8 @@ unsigned short t2(unsigned short x) {
 // CHECK-SANITIZE-TRAP-NEXT:  call void @llvm.trap(){{.*}}, !nosanitize
 // CHECK-SANITIZE-ANYRECOVER-NEXT:[[TMP1:%.*]] = zext i32 [[INC]] to i64, 
!nosanitize
 // CHECK-SANITIZE-ANYRECOVER-NEXT:[[TMP2:%.*]] = zext i16 
[[X_PROMOTED_DEMOTED]] to i64, !nosanitize
-// CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ { [91 x i8]*, i32, i32 
}, { i16, i16, [6 x i8] }*, { i16, i16, [17 x i8] }*, i8 }* @[[LINE_300]] to 
i8*), i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
-// CHECK-SANITIZE-RECOVER-NEXT:   call void 
@__ubsan_handle_implicit_conversion(i8* bitcast ({ { [91 x i8]*, i32, i32 }, { 
i16, i16, [6 x i8] }*, { i16, i16, [17 x i8] }*, i8 }* @[[LINE_300]] to i8*), 
i64 [[TMP1]], i64 [[TMP2]]) #2, !nosanitize
+// CHECK-SANITIZE-NORECOVER-NEXT: call void 
@__ubsan_handle_implicit_conversion_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}*, 
{{{.*}}}*, i8 }* @[[L

[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-11-27 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: ab.
Herald added subscribers: hiraditya, kristof.beyls, mcrosier.
Herald added a project: LLVM.
t.p.northover updated this revision to Diff 231220.
t.p.northover added a comment.

Test updates after switching arm64_32 default CPU to apple-s4.


The CPUs used in Apple devices have been gradually getting more features, but 
upstream LLVM only knew about the original "Cyclone" variant. Xcode could also 
target "vortex" (for arm64_32 and arm64e), but using internal names isn't 
really ideal for anyone.

In official documentation the 64-bit CPUs are known as A7-A13 (iPhone, iPad) 
and S4-S5 (Watch), with some marketing suffixes that we probably don't need to 
care about. Since those bare names would be quite a land grab (and easily 
confused with Cortex-A*), this adds the currently released CPUs as "apple-aN" 
and "apple-sN".

I've left Cyclone in as a legacy option (build systems and existing bitcode 
probably relies on it), but switched the default over to the new scheme: 
apple-a7 for arm64 and apple-s4 for arm64_32.


https://reviews.llvm.org/D70779

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64-as.s
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -820,6 +820,51 @@
   EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a7", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a8", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a9", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU("apple-a10", "armv8-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_RDM |
+ AArch64::AEK_SIMD,
+ "8-A"));
+  EXPECT_TRUE(testAArch64CPU("apple-a11", "armv8.2-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_LSE |
+ AArch64::AEK_RAS | AArch64::AEK_RDM |
+ AArch64::AEK_SIMD,
+ "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a12", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a13", "armv8.4-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_FP16 | AArch64::AEK_FP16FML,
+  "8.4-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-s4", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-s5", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
   EXPECT_TRUE(testAArch64CPU(
   "exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
@@ -891,7 +936,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 26;
+static constexpr unsigned NumAArch64CPUArchs = 35;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/AArch64/AArch64SystemOperands.td
===
--- llvm/lib/Target/AArch64/AArch64SystemOperan

[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-11-27 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover updated this revision to Diff 231220.
t.p.northover added a comment.

Test updates after switching arm64_32 default CPU to apple-s4.


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

https://reviews.llvm.org/D70779

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64-as.s
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/include/llvm/Support/AArch64TargetParser.def
  llvm/lib/Target/AArch64/AArch64.td
  llvm/lib/Target/AArch64/AArch64Subtarget.cpp
  llvm/lib/Target/AArch64/AArch64Subtarget.h
  llvm/lib/Target/AArch64/AArch64SystemOperands.td
  llvm/unittests/Support/TargetParserTest.cpp

Index: llvm/unittests/Support/TargetParserTest.cpp
===
--- llvm/unittests/Support/TargetParserTest.cpp
+++ llvm/unittests/Support/TargetParserTest.cpp
@@ -820,6 +820,51 @@
   EXPECT_TRUE(testAArch64CPU(
   "cyclone", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a7", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a8", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a9", "armv8-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD, "8-A"));
+  EXPECT_TRUE(testAArch64CPU("apple-a10", "armv8-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_RDM |
+ AArch64::AEK_SIMD,
+ "8-A"));
+  EXPECT_TRUE(testAArch64CPU("apple-a11", "armv8.2-a", "crypto-neon-fp-armv8",
+ AArch64::AEK_CRC | AArch64::AEK_CRYPTO |
+ AArch64::AEK_FP | AArch64::AEK_LSE |
+ AArch64::AEK_RAS | AArch64::AEK_RDM |
+ AArch64::AEK_SIMD,
+ "8.2-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a12", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-a13", "armv8.4-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
+  AArch64::AEK_FP16 | AArch64::AEK_FP16FML,
+  "8.4-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-s4", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
+  EXPECT_TRUE(testAArch64CPU(
+  "apple-s5", "armv8.3-a", "crypto-neon-fp-armv8",
+  AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
+  AArch64::AEK_SIMD | AArch64::AEK_LSE | AArch64::AEK_RAS |
+  AArch64::AEK_RDM | AArch64::AEK_RCPC | AArch64::AEK_FP16,
+  "8.3-A"));
   EXPECT_TRUE(testAArch64CPU(
   "exynos-m3", "armv8-a", "crypto-neon-fp-armv8",
   AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
@@ -891,7 +936,7 @@
   "8.2-A"));
 }
 
-static constexpr unsigned NumAArch64CPUArchs = 26;
+static constexpr unsigned NumAArch64CPUArchs = 35;
 
 TEST(TargetParserTest, testAArch64CPUArchList) {
   SmallVector List;
Index: llvm/lib/Target/AArch64/AArch64SystemOperands.td
===
--- llvm/lib/Target/AArch64/AArch64SystemOperands.td
+++ llvm/lib/Target/AArch64/AArch64SystemOperands.td
@@ -1492,5 +1492,5 @@
 
 // Cyclone specific system registers
 // Op0Op1 CRn CRmOp2
-let Requires = [{ {AArch64::ProcCyclone} }] in
+let Requires = [{ {AArch64::ProcAppleA7} }] in
 def : RWSysReg<"CPM_IOACC_CTL_EL3", 0b11, 0b111, 0b, 0b0010, 0b000>;
Index: llvm/lib/Target/AArch64/AArch64Subtarget.h
===
--- llvm/lib/Target/AArch64/AArch64Subtarget.h
+++ llvm/lib/Target/AArch64/AArch64Subtarget.h
@@ -38,6 +38,11 @@
 public:
   enum ARMProcFamilyEnum : uint8_t {
 Others,
+AppleA7,
+AppleA10,
+AppleA11,
+AppleA12,
+AppleA13,
 CortexA35,
 CortexA53,
 CortexA55,
@@ -47,7 +52,6 @@
 CortexA73,
 CortexA75,
 CortexA76,
-Cyclone,
 ExynosM3,
 Falkor,
 

[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: fail - 60344 tests passed, 2 failed and 732 were skipped.

  failed: Clang.CodeGen/catch-implicit-integer-sign-changes-incdec.c
  failed: Clang.CodeGen/catch-implicit-signed-integer-truncations-incdec.c

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70222



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


[PATCH] D70779: AArch64: add support for newer Apple CPUs

2019-11-27 Thread Kristof Beyls via Phabricator via cfe-commits
kristof.beyls added a comment.

I agree the bare names could cause a lot of confusion, and that the naming 
scheme proposed in this patch resolves that potential confusion.


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

https://reviews.llvm.org/D70779



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


[clang] 9f15fcc - [ARM] Replace arm_neon_vqadds with sadd_sat

2019-11-27 Thread David Green via cfe-commits

Author: David Green
Date: 2019-11-27T13:32:29Z
New Revision: 9f15fcc2718f95f1dac9e6e57aa93d84e9709930

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

LOG: [ARM] Replace arm_neon_vqadds with sadd_sat

This replaces the A32 NEON vqadds, vqaddu, vqsubs and vqsubu intrinsics
with the target independent sadd_sat, uadd_sat, ssub_sat and usub_sat.
This helps generate vqadds from standard IR nodes, which might be
produced from the vectoriser. The old variants are removed in the
process.

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

Added: 
llvm/test/CodeGen/ARM/neon-vqaddsub-upgrade.ll

Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/arm-v8.1a-neon-intrinsics.c
clang/test/CodeGen/arm_neon_intrinsics.c
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMInstrNEON.td
llvm/test/CodeGen/ARM/addsubo-legalization.ll
llvm/test/CodeGen/ARM/neon-v8.1a.ll
llvm/test/CodeGen/ARM/vmul.ll
llvm/test/CodeGen/ARM/vqadd.ll
llvm/test/CodeGen/ARM/vqdmul.ll
llvm/test/CodeGen/ARM/vqsub.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index ecac9aee5c7c..26044f53e496 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4621,10 +4621,10 @@ static const NeonIntrinsicInfo ARMSIMDIntrinsicMap [] = 
{
   NEONMAP2(vpmin_v, arm_neon_vpminu, arm_neon_vpmins, Add1ArgType | 
UnsignedAlts),
   NEONMAP1(vqabs_v, arm_neon_vqabs, Add1ArgType),
   NEONMAP1(vqabsq_v, arm_neon_vqabs, Add1ArgType),
-  NEONMAP2(vqadd_v, arm_neon_vqaddu, arm_neon_vqadds, Add1ArgType | 
UnsignedAlts),
-  NEONMAP2(vqaddq_v, arm_neon_vqaddu, arm_neon_vqadds, Add1ArgType | 
UnsignedAlts),
-  NEONMAP2(vqdmlal_v, arm_neon_vqdmull, arm_neon_vqadds, 0),
-  NEONMAP2(vqdmlsl_v, arm_neon_vqdmull, arm_neon_vqsubs, 0),
+  NEONMAP2(vqadd_v, uadd_sat, sadd_sat, Add1ArgType | UnsignedAlts),
+  NEONMAP2(vqaddq_v, uadd_sat, sadd_sat, Add1ArgType | UnsignedAlts),
+  NEONMAP2(vqdmlal_v, arm_neon_vqdmull, sadd_sat, 0),
+  NEONMAP2(vqdmlsl_v, arm_neon_vqdmull, ssub_sat, 0),
   NEONMAP1(vqdmulh_v, arm_neon_vqdmulh, Add1ArgType),
   NEONMAP1(vqdmulhq_v, arm_neon_vqdmulh, Add1ArgType),
   NEONMAP1(vqdmull_v, arm_neon_vqdmull, Add1ArgType),
@@ -4642,8 +4642,8 @@ static const NeonIntrinsicInfo ARMSIMDIntrinsicMap [] = {
   NEONMAP2(vqshlq_v, arm_neon_vqshiftu, arm_neon_vqshifts, Add1ArgType | 
UnsignedAlts),
   NEONMAP1(vqshlu_n_v, arm_neon_vqshiftsu, 0),
   NEONMAP1(vqshluq_n_v, arm_neon_vqshiftsu, 0),
-  NEONMAP2(vqsub_v, arm_neon_vqsubu, arm_neon_vqsubs, Add1ArgType | 
UnsignedAlts),
-  NEONMAP2(vqsubq_v, arm_neon_vqsubu, arm_neon_vqsubs, Add1ArgType | 
UnsignedAlts),
+  NEONMAP2(vqsub_v, usub_sat, ssub_sat, Add1ArgType | UnsignedAlts),
+  NEONMAP2(vqsubq_v, usub_sat, ssub_sat, Add1ArgType | UnsignedAlts),
   NEONMAP1(vraddhn_v, arm_neon_vraddhn, Add1ArgType),
   NEONMAP2(vrecpe_v, arm_neon_vrecpe, arm_neon_vrecpe, 0),
   NEONMAP2(vrecpeq_v, arm_neon_vrecpe, arm_neon_vrecpe, 0),

diff  --git a/clang/test/CodeGen/arm-v8.1a-neon-intrinsics.c 
b/clang/test/CodeGen/arm-v8.1a-neon-intrinsics.c
index 6f5867b6c11f..5462c17a1cc5 100644
--- a/clang/test/CodeGen/arm-v8.1a-neon-intrinsics.c
+++ b/clang/test/CodeGen/arm-v8.1a-neon-intrinsics.c
@@ -13,7 +13,7 @@
 // CHECK-LABEL: test_vqrdmlah_s16
 int16x4_t test_vqrdmlah_s16(int16x4_t a, int16x4_t b, int16x4_t c) {
 // CHECK-ARM: call <4 x i16> @llvm.arm.neon.vqrdmulh.v4i16(<4 x i16> {{%.*}}, 
<4 x i16> {{%.*}})
-// CHECK-ARM: call <4 x i16> @llvm.arm.neon.vqadds.v4i16(<4 x i16> {{%.*}}, <4 
x i16> {{%.*}})
+// CHECK-ARM: call <4 x i16> @llvm.sadd.sat.v4i16(<4 x i16> {{%.*}}, <4 x i16> 
{{%.*}})
 
 // CHECK-AARCH64: call <4 x i16> @llvm.aarch64.neon.sqrdmulh.v4i16(<4 x i16> 
{{%.*}}, <4 x i16> {{%.*}})
 // CHECK-AARCH64: call <4 x i16> @llvm.aarch64.neon.sqadd.v4i16(<4 x i16> 
{{%.*}}, <4 x i16> {{%.*}})
@@ -23,7 +23,7 @@ int16x4_t test_vqrdmlah_s16(int16x4_t a, int16x4_t b, 
int16x4_t c) {
 // CHECK-LABEL: test_vqrdmlah_s32
 int32x2_t test_vqrdmlah_s32(int32x2_t a, int32x2_t b, int32x2_t c) {
 // CHECK-ARM: call <2 x i32> @llvm.arm.neon.vqrdmulh.v2i32(<2 x i32> {{%.*}}, 
<2 x i32> {{%.*}})
-// CHECK-ARM: call <2 x i32> @llvm.arm.neon.vqadds.v2i32(<2 x i32> {{%.*}}, <2 
x i32> {{%.*}})
+// CHECK-ARM: call <2 x i32> @llvm.sadd.sat.v2i32(<2 x i32> {{%.*}}, <2 x i32> 
{{%.*}})
 
 // CHECK-AARCH64: call <2 x i32> @llvm.aarch64.neon.sqrdmulh.v2i32(<2 x i32> 
{{%.*}}, <2 x i32> {{%.*}})
 // CHECK-AARCH64: call <2 x i32> @llvm.aarch64.neon.sqadd.v2i32(<2 x i32> 
{{%.*}}, <2 x i32> {{%.*}})
@@ -33,7 +33,7 @@ int32x2_t test_vqrdmlah_s32(int32x2_t a, int32x2_t b, 
int32x2_t c) {
 // CHECK-LABEL: test_vqrdmlahq

[PATCH] D69350: [ARM] Replace arm_neon_vqadds with sadd_sat

2019-11-27 Thread Dave Green via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f15fcc2718f: [ARM] Replace arm_neon_vqadds with sadd_sat 
(authored by dmgreen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D69350?vs=229717&id=231232#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69350

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-v8.1a-neon-intrinsics.c
  clang/test/CodeGen/arm_neon_intrinsics.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/ARM/ARMISelLowering.cpp
  llvm/lib/Target/ARM/ARMInstrNEON.td
  llvm/test/CodeGen/ARM/addsubo-legalization.ll
  llvm/test/CodeGen/ARM/neon-v8.1a.ll
  llvm/test/CodeGen/ARM/neon-vqaddsub-upgrade.ll
  llvm/test/CodeGen/ARM/vmul.ll
  llvm/test/CodeGen/ARM/vqadd.ll
  llvm/test/CodeGen/ARM/vqdmul.ll
  llvm/test/CodeGen/ARM/vqsub.ll

Index: llvm/test/CodeGen/ARM/vqdmul.ll
===
--- llvm/test/CodeGen/ARM/vqdmul.ll
+++ llvm/test/CodeGen/ARM/vqdmul.ll
@@ -204,7 +204,7 @@
 %tmp2 = load <4 x i16>, <4 x i16>* %B
 %tmp3 = load <4 x i16>, <4 x i16>* %C
 %tmp4 = call <4 x i32> @llvm.arm.neon.vqdmull.v4i32(<4 x i16> %tmp2, <4 x i16> %tmp3)
-%tmp5 = call <4 x i32> @llvm.arm.neon.vqadds.v4i32(<4 x i32> %tmp1, <4 x i32> %tmp4)
+%tmp5 = call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %tmp1, <4 x i32> %tmp4)
 ret <4 x i32> %tmp5
 }
 
@@ -215,7 +215,7 @@
 %tmp2 = load <2 x i32>, <2 x i32>* %B
 %tmp3 = load <2 x i32>, <2 x i32>* %C
 %tmp4 = call <2 x i64> @llvm.arm.neon.vqdmull.v2i64(<2 x i32> %tmp2, <2 x i32> %tmp3)
-%tmp5 = call <2 x i64> @llvm.arm.neon.vqadds.v2i64(<2 x i64> %tmp1, <2 x i64> %tmp4)
+%tmp5 = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %tmp1, <2 x i64> %tmp4)
 ret <2 x i64> %tmp5
 }
 
@@ -225,7 +225,7 @@
 ; CHECK: vqdmlal.s16 q0, d2, d3[1]
   %0 = shufflevector <4 x i16> %arg2_int16x4_t, <4 x i16> undef, <4 x i32>  ; <<4 x i16>> [#uses=1]
   %1 = tail call <4 x i32> @llvm.arm.neon.vqdmull.v4i32(<4 x i16> %arg1_int16x4_t, <4 x i16> %0)
-  %2 = tail call <4 x i32> @llvm.arm.neon.vqadds.v4i32(<4 x i32> %arg0_int32x4_t, <4 x i32> %1)
+  %2 = tail call <4 x i32> @llvm.sadd.sat.v4i32(<4 x i32> %arg0_int32x4_t, <4 x i32> %1)
   ret <4 x i32> %2
 }
 
@@ -235,12 +235,12 @@
 ; CHECK: vqdmlal.s32 q0, d2, d3[1]
   %0 = shufflevector <2 x i32> %arg2_int32x2_t, <2 x i32> undef, <2 x i32>  ; <<2 x i32>> [#uses=1]
   %1 = tail call <2 x i64> @llvm.arm.neon.vqdmull.v2i64(<2 x i32> %arg1_int32x2_t, <2 x i32> %0)
-  %2 = call <2 x i64> @llvm.arm.neon.vqadds.v2i64(<2 x i64> %arg0_int64x2_t, <2 x i64> %1)
+  %2 = call <2 x i64> @llvm.sadd.sat.v2i64(<2 x i64> %arg0_int64x2_t, <2 x i64> %1)
   ret <2 x i64> %2
 }
 
-declare <4 x i32>  @llvm.arm.neon.vqadds.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
-declare <2 x i64>  @llvm.arm.neon.vqadds.v2i64(<2 x i64>, <2 x i64>) nounwind readnone
+declare <4 x i32>  @llvm.sadd.sat.v4i32(<4 x i32>, <4 x i32>) nounwind readnone
+declare <2 x i64>  @llvm.sadd.sat.v2i64(<2 x i64>, <2 x i64>) nounwind readnone
 
 define <4 x i32> @vqdmlsls16_natural(<4 x i32>* %A, <4 x i16>* %B, <4 x i16>* %C) nounwind {
 ;CHECK-LABEL: vqdmlsls16_natural:
@@ -249,7 +249,7 @@
 %tmp2 = load <4 x i16>, <4 x i16>* %B
 %tmp3 = load <4 x i16>, <4 x i16>* %C
 %tmp4 = call <4 x i32> @llvm.arm.neon.vqdmull.v4i32(<4 x i16> %tmp2, <4 x i16> %tmp3)
-%tmp5 = call <4 x i32> @llvm.arm.neon.vqsubs.v4i32(<4 x i32> %tmp1, <4 x i32> %tmp4)
+%tmp5 = call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %tmp1, <4 x i32> %tmp4)
 ret <4 x i32> %tmp5
 }
 
@@ -260,7 +260,7 @@
 %tmp2 = load <2 x i32>, <2 x i32>* %B
 %tmp3 = load <2 x i32>, <2 x i32>* %C
 %tmp4 = call <2 x i64> @llvm.arm.neon.vqdmull.v2i64(<2 x i32> %tmp2, <2 x i32> %tmp3)
-%tmp5 = call <2 x i64> @llvm.arm.neon.vqsubs.v2i64(<2 x i64> %tmp1, <2 x i64> %tmp4)
+%tmp5 = call <2 x i64> @llvm.ssub.sat.v2i64(<2 x i64> %tmp1, <2 x i64> %tmp4)
 ret <2 x i64> %tmp5
 }
 
@@ -270,7 +270,7 @@
 ; CHECK: vqdmlsl.s16 q0, d2, d3[1]
   %0 = shufflevector <4 x i16> %arg2_int16x4_t, <4 x i16> undef, <4 x i32>  ; <<4 x i16>> [#uses=1]
   %1 = tail call <4 x i32> @llvm.arm.neon.vqdmull.v4i32(<4 x i16> %arg1_int16x4_t, <4 x i16> %0)
-  %2 = tail call <4 x i32> @llvm.arm.neon.vqsubs.v4i32(<4 x i32> %arg0_int32x4_t, <4 x i32> %1)
+  %2 = tail call <4 x i32> @llvm.ssub.sat.v4i32(<4 x i32> %arg0_int32x4_t, <4 x i32> %1)
   ret <4 x i32> %2
 }
 
@@ -280,9 +280,9 @@
 ; CHECK: vqdmlsl.s32 q0, d2, d3[1]
   %0 = shufflevector <2 x i32> %arg2_int32x2_t, <2 x i32> undef, <2 x i32>  ; <<2 x i32>> [#uses=1]
   %1 = tail call <2 x i64> @llvm.arm.neon.vqdmull.v2i64(<2 x i32> %arg1_int32x2_t, <

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231234.
lh123 added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1046,9 +1047,10 @@
 static bool ExpandResponseFile(StringRef FName, StringSaver &Saver,
TokenizerCallback Tokenizer,
SmallVectorImpl &NewArgv,
-   bool MarkEOLs, bool RelativeNames) {
+   bool MarkEOLs, bool RelativeNames,
+   llvm::vfs::FileSystem &FS) {
   ErrorOr> MemBufOrErr =
-  MemoryBuffer::getFile(FName);
+  FS.getBufferForFile(FName);
   if (!MemBufOrErr)
 return false;
   MemoryBuffer &MemBuf = *MemBufOrErr.get();
@@ -1068,6 +1070,9 @@
   else if (hasUTF8ByteOrderMark(BufRef))
 Str = StringRef(BufRef.data() + 3, BufRef.size() - 3);
 
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;
   // Tokenize the contents into NewArgv.
   Tokenizer(Str, Saver, NewArgv, MarkEOLs);
 
@@ -1084,9 +1089,7 @@
 SmallString<128> ResponseFile;
 ResponseFile.append(1, '@');
 if (llvm::sys::path::is_relative(FName)) {
-  SmallString<128> curr_dir;
-  llvm::sys::fs::current_path(curr_dir);
-  ResponseFile.append(curr_dir.str());
+  ResponseFile.append(CurrDir.get());
 }
 llvm::sys::path::append(
 ResponseFile, llvm::sys::path::parent_path(FName), FileName);
@@ -1101,8 +1104,8 @@
 /// Expand response files on a command line recursively using the given
 /// StringSaver and tokenization strategy.
 bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
- SmallVectorImpl &Argv,
- bool MarkEOLs, bool RelativeNames) {
+ SmallVectorImpl &Argv, bool MarkEOLs,
+ bool RelativeNames, llvm::vfs::FileSystem &FS) {
   bool AllExpanded = true;
   struct ResponseFileRecord {
 const char *File;
@@ -1139,8 +1142,13 @@
 }
 
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord &RFile) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, &FS](const ResponseFileRecord &RFile) {
+  SmallVector LHSPath;
+  SmallVector RHSPath;
+  if (FS.getRealPath(FName, LHSPath) || FS.getRealPath(RFile.File, RHSPath)) {
+return false;
+  }
+  return LHSPath == RHSPath;
 };
 
 // Check for recursive response files.
@@ -1156,7 +1164,7 @@
 // contents.  Nested response files are expanded in subsequent iterations.
 SmallVector ExpandedArgv;
 if (!ExpandResponseFile(FName, Saver, Tokenizer, ExpandedArgv, MarkEOLs,
-RelativeNames)) {
+RelativeNames, FS)) {
   // We couldn't read this file, so we leave it in the argument stream and
   // move on.
   AllExpanded = false;
@@ -1187,7 +1195,8 @@
 bool cl::readConfigFile(StringRef CfgFile, StringSaver &Saver,
 SmallVectorImpl &Argv) {
   if (!ExpandResponseFile(CfgFile, Saver, cl::tokenizeConfigFile, Argv,
-  /*MarkEOLs*/ false, /*RelativeNames*/ true))
+  /*MarkEOLs*/ false, /*RelativeNames*/ true,
+  *llvm::vfs::getRealFileSystem()))
 return false;
   return ExpandResponseFiles(Saver, cl::tokenizeConfigFile, Argv,
  /*MarkEOLs*/ false, /*RelativeNames*/ true);
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -20,6 +20,7 @@
 #define LLVM_SUPPORT_COMMANDLINE_H
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
@@ -40,6 +41,12 @@
 #include 
 
 namespace llvm {
+namespace vfs {
+
+class FileSystem;
+IntrusiveRefCntPtr getRealFileSystem();
+
+} // namespace vfs
 
 class StringSaver;
 class raw_ostream;
@@ -1964,10 +1971,13 @@
 /// with nullptrs in the Argv vector.
 /// \param [in] RelativeNames true if names of nested response files must be
 /// resol

[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231235.
lh123 added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70222

Files:
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -859,5 +859,64 @@
 "clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
 }
 
+class ExpandResponseFilesTest : public MemDBTest {
+protected:
+  void SetUp() override {
+FS = new llvm::vfs::InMemoryFileSystem;
+
+InnerDir = path(StringRef("inner"));
+
+llvm::sys::path::append(RspFileName1, InnerDir, "rsp1.rsp");
+addFile(RspFileName1, "-Dflag1");
+
+RspFileName2 = path(StringRef("rsp2.rsp"));
+addFile(RspFileName2, "-Dflag2 @rsp3.rsp");
+
+RspFileName3 = path(StringRef("rsp3.rsp"));
+addFile(RspFileName3, "-Dflag3");
+
+RspFileName4 = path(StringRef("rsp4.rsp"));
+addFile(RspFileName4, "-Dflag4 @rsp4.rsp");
+
+llvm::sys::path::append(RspFileName5, InnerDir, "rsp5.rsp");
+addFile(RspFileName5, "-Dflag5 @inner/rsp1.rsp");
+  }
+
+  void addFile(StringRef File, StringRef Context) {
+ASSERT_TRUE(FS->addFile(File, 0, llvm::MemoryBuffer::getMemBufferCopy(Context)));
+  }
+
+  std::string getCommand(llvm::StringRef F) {
+auto Results = expandResponseFiles(std::make_unique(Entries),
+   FS)
+   ->getCompileCommands(path(F));
+if (Results.empty()) {
+  return "none";
+}
+return llvm::join(Results[0].CommandLine, " ");
+  }
+
+  SmallString<128> InnerDir;
+  SmallString<128> RspFileName1;
+  SmallString<128> RspFileName2;
+  SmallString<128> RspFileName3;
+  SmallString<128> RspFileName4;
+  SmallString<128> RspFileName5;
+  llvm::IntrusiveRefCntPtr FS;
+
+};
+
+TEST_F(ExpandResponseFilesTest, ExpandResponseFiles) {
+  // clang-format off
+  add("foo.cpp", "clang",
+  ("@inner/rsp1.rsp @rsp2.rsp @rsp4.rsp "
+"@" + RspFileName1 + " @inner/rsp5.rsp @rsp6.rsp")
+  .str());
+  // clang-format on
+  EXPECT_EQ(getCommand("foo.cpp"), "clang foo.cpp -D foo.cpp -Dflag1 -Dflag2 "
+   "-Dflag3 -Dflag4 @rsp4.rsp -Dflag1 "
+   "-Dflag5 -Dflag1 @rsp6.rsp");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -168,7 +168,8 @@
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
 return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(std::move(Base)))
+  inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem(
 : nullptr;
   }
 };
Index: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
===
--- /dev/null
+++ clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp
@@ -0,0 +1,92 @@
+//===- ExpandResponseFileCompilationDataBase.cpp --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/Triple.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/StringSaver.h"
+
+namespace clang {
+namespace tooling {
+namespace {
+
+class ExpandResponseFilesDatabase : public CompilationDatabase {
+public:
+  ExpandResponseFilesDatabase(
+  std::unique_ptr Base,
+  llvm::cl::TokenizerCallback Tokenizer,
+  llvm::IntrusiveRefCntPtr FS)
+  : Base(std::move(Base)), Tokenizer(Tokenizer), FS(FS) {
+assert(this->Base != nullptr);
+assert(this->Tokenizer != nullptr);
+assert(this->FS != nullptr);
+  }
+
+  std::vector getAllFiles() const override {
+return Base->getAllFiles();
+  }
+
+  std::vector
+  getCompileCommands(StringRef FilePath) const override {
+return expand(Base->getCompil

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: FAILURE - 
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

Aside from one nit, this looks okay to me. I'd like someone else to look at it 
though too. I'm not at all familiar with the file system stuff to be confident 
to say everything there is good.




Comment at: llvm/lib/Support/CommandLine.cpp:1148
+  SmallVector RHSPath;
+  if (FS.getRealPath(FName, LHSPath) || FS.getRealPath(RFile.File, 
RHSPath)) {
+return false;

Has this been clang-formatted?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: llvm/include/llvm/Support/CommandLine.h:47
+class FileSystem;
+IntrusiveRefCntPtr getRealFileSystem();
+

now that we are also pulling the the function, I think it is OK to include the 
header instead.



Comment at: llvm/lib/Support/CommandLine.cpp:1073
 
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)

you can move this to the beginning of the function, to exit immediately, 
without checking for anything else.



Comment at: llvm/lib/Support/CommandLine.cpp:1074
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;

it is sad that, ExpandResponseFile returns a bool, but that's a battle for 
another day.

unfortunately, it is not enough return false in this case you need to consume 
the error with `llvm::consumeError` before exiting the scope.



Comment at: llvm/lib/Support/CommandLine.cpp:1146
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord &RFile) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, &FS](const ResponseFileRecord &RFile) {
+  SmallVector LHSPath;

there are `FileSystem::status` and `Status::equivalent` functions to implement 
`llvm::sys::fs:equivalent` behaviour


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: FAILURE - 
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70222



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


[clang] cbfa237 - Revert "[clang][CodeGen] Implicit Conversion Sanitizer: handle increment/decrement (PR44054)"

2019-11-27 Thread Roman Lebedev via cfe-commits

Author: Roman Lebedev
Date: 2019-11-27T17:05:21+03:00
New Revision: cbfa237892e55b7129a1178c9b03f26683d643af

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

LOG: Revert "[clang][CodeGen] Implicit Conversion Sanitizer: handle 
increment/decrement (PR44054)"

The asssertion that was added does not hold,
breaks on test-suite/MultiSource/Applications/SPASS/analyze.c
Will reduce the testcase and revisit.

This reverts commit 9872ea4ed1de4c49300430e4f1f4dfc110a79ab9, 
870f3542d3e0d06d208442bdca6482866b59171b.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGExprScalar.cpp

Removed: 
clang/test/CodeGen/catch-implicit-conversions-incdec-basics.c

clang/test/CodeGen/catch-implicit-integer-arithmetic-value-change-incdec-basics.c
clang/test/CodeGen/catch-implicit-integer-conversions-incdec-basics.c
clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec-basics.c
clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
clang/test/CodeGen/catch-implicit-integer-truncations-incdec-basics.c
clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec-basics.c
clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c

clang/test/CodeGen/catch-implicit-unsigned-integer-truncations-incdec-basics.c

compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-conversion-incdec.c

compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-sign-change-incdec.c

compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c



diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 37a8f30e0bc9..4ac300deb589 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -78,10 +78,6 @@ Non-comprehensive list of changes in this release
   been extended to detect these cases, so that code relying on them can be
   detected and fixed.
 
-* The Implicit Conversion Sanitizer (``-fsanitize=implicit-conversion``) has
-  learned to sanitize pre/post increment/decrement of types with bit width
-  smaller than ``int``.
-
 - For X86 target, -march=skylake-avx512, -march=icelake-client,
   -march=icelake-server, -march=cascadelake, -march=cooperlake will default to
   not using 512-bit zmm registers in vectorized code unless 512-bit intrinsics

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 953ced9168c5..822976640643 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -2419,39 +2419,9 @@ ScalarExprEmitter::EmitScalarPrePostIncDec(const 
UnaryOperator *E, LValue LV,
 
   // Most common case by far: integer increment.
   } else if (type->isIntegerType()) {
-assert((!type->isPromotableIntegerType() ||
-(type->isSignedIntegerOrEnumerationType() ||
- CGF.getContext()
- .getPromotedIntegerType(type)
- ->isSignedIntegerOrEnumerationType())) &&
-   "The following check expects that if we do promotion, at least one "
-   "of the types (either base or promoted) will be signed.");
-if (CGF.SanOpts.hasOneOf(
-SanitizerKind::ImplicitIntegerArithmeticValueChange) &&
-type->isPromotableIntegerType()) {
-  // While `x += 1` (for `x` with width less than int) is modeled as
-  // promotion+arithmetics+demotion, and we can catch lossy demotion with
-  // ease; inc/dec with width less than int can't overflow because of
-  // promotion rules, so we omit promotion+demotion, which means that we 
can
-  // not catch lossy "demotion". Because we still want to catch these cases
-  // when the sanitizer is enabled, we perform the promotion, then perform
-  // the increment/decrement in the wider type, and finally
-  // perform the demotion. This will catch lossy demotions.
-
-  QualType promotedType = CGF.getContext().getPromotedIntegerType(type);
-  assert(promotedType != type && "Shouldn't promote to the same type.");
-  value = EmitScalarConversion(value, type, promotedType, E->getExprLoc());
-  Value *amt = llvm::ConstantInt::get(value->getType(), amount, true);
-  value = Builder.CreateAdd(value, amt, isInc ? "inc" : "dec");
-  // Do pass non-default ScalarConversionOpts so that sanitizer check is
-  // emitted.
-  value = EmitScalarConversion(value, promotedType, type, E->getExprLoc(),
-   ScalarConversionOpts(CGF.SanOpts));
-
-  // Note that signed integer inc/dec with width less than int can't
-  // overflow because of promotion rules; we're just eliding a few steps
-  // here.
-} else if (E->canOverflow() && type->isSignedIntegerOrEnumerationType()) {
+// Note that signed

[PATCH] D61446: Generalize the pass registration mechanism used by Polly to any third-party tool

2019-11-27 Thread Alouest via Phabricator via cfe-commits
Alouest added a comment.

Greetings,

I stumbled upon a bug while toying with your example Bye.cpp. I modified your 
pass to make a ModulePass and while it works with

  /build/bin/opt -goodbye -wave-goodbye test.ll

It's making clang crash with the command

  /build/bin/clang test.c

I've included the pass, the error logs and some files to reproduce the bug 
(hello2.bc is supposed to be placed in the directory where you start your 
code). 
It seems that the bug is coming from StringMap.cpp, it looks like NumBuckets is 
not always initialized when accessed, raising a SegFault.
In my example, this function is called by Module::getFunction (StringRef).

I'm a beginner in LLVM so I might just be doing dumb things.

F10889373: test-df7efc.c 

F10889372: Bye.cpp 

F10889371: test.c 

F10889370: test-df7efc.sh 

F10889369: hello2.bc 

F10889368: test.ll 

F10889367: log 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61446



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


[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 231237.
lebedev.ri added a comment.

Rebased.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/catch-implicit-conversions-incdec-basics.c
  
clang/test/CodeGen/catch-implicit-integer-arithmetic-value-change-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-conversions-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec-basics.c
  clang/test/CodeGen/catch-implicit-integer-sign-changes-incdec.c
  clang/test/CodeGen/catch-implicit-integer-truncations-incdec-basics.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec-basics.c
  clang/test/CodeGen/catch-implicit-signed-integer-truncations-incdec.c
  clang/test/CodeGen/catch-implicit-unsigned-integer-truncations-incdec-basics.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-conversion-incdec.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/integer-sign-change-incdec.c
  
compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c

Index: compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/ImplicitConversion/signed-integer-truncation-incdec.c
@@ -0,0 +1,122 @@
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c   -fsanitize=implicit-signed-integer-truncation -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+// RUN: %clang   -x c++ -fsanitize=implicit-signed-integer-truncation -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="implicit conversion" --check-prefixes=CHECK
+
+void test_unsigned() {
+  unsigned char x;
+
+  x = 0;
+  x++;
+  x = 0;
+  ++x;
+
+  x = 0;
+  x--;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned char' changed the value to 255 (8-bit, unsigned)
+  x = 0;
+  --x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value -1 (32-bit, signed) to type 'unsigned char' changed the value to 255 (8-bit, unsigned)
+
+  x = 1;
+  x++;
+  x = 1;
+  ++x;
+
+  x = 1;
+  x--;
+  x = 1;
+  --x;
+
+  x = 254;
+  x++;
+  x = 254;
+  ++x;
+
+  x = 254;
+  x--;
+  x = 254;
+  --x;
+
+  x = 255;
+  x++;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned)
+  x = 255;
+  ++x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value 256 (32-bit, signed) to type 'unsigned char' changed the value to 0 (8-bit, unsigned)
+
+  x = 255;
+  x--;
+  x = 255;
+  --x;
+}
+
+void test_signed() {
+  signed char x;
+
+  x = -128;
+  x++;
+  x = -128;
+  ++x;
+
+  x = -128;
+  x--;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:4: runtime error: implicit conversion from type 'int' of value -129 (32-bit, signed) to type 'signed char' changed the value to 127 (8-bit, signed)
+  x = -128;
+  --x;
+  // CHECK: {{.*}}signed-integer-truncation-incdec.c:[[@LINE-1]]:3: runtime error: implicit conversion from type 'int' of value -129 (32-bit, signed) to type 'signed char' changed the value to 127 (8-bit, signed)
+
+  x = -1;
+  x++;
+  x = -1;
+  ++x;
+
+  x = -1;
+  x--;
+  x = -1;
+  --x;
+
+  x = 0;
+  x++;
+  x = 0;
+  ++x;
+
+  x = 0;
+  x--;
+  x = 0;
+  --x;
+
+  x = 1;
+  x++;
+  x = 1;
+  ++x;
+
+  x = 1;
+  x--;
+  x = 1;
+  --x;
+
+  x = 127;
+  x++

[PATCH] D70539: [clang][CodeGen] Implicit Conversion Sanitizer: handle increment/derement (PR44054)

2019-11-27 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri reopened this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.

Temporarily reverted in rG62098354ab1c6c0dd2cecc8ac526d411bfe8aa20 - the 
assertion does not hold, need to remove it likely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70539



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


[PATCH] D70780: [WebAssembly] Find wasm-opt with GetProgramPath

2019-11-27 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
sunfish added reviewers: dschuff, ilya-biryukov.
Herald added subscribers: cfe-commits, aheejin, jgravelle-google, sbc100.
Herald added a project: clang.

Instead of just searching for wasm-opt in PATH, use `GetProgramPath`, which 
checks the `COMPILER_PATH` environment variable, `-B` paths, and `PATH.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70780

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


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -92,10 +92,10 @@
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
 
-  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-if (llvm::ErrorOr WasmOptPath =
-   llvm::sys::findProgramByName("wasm-opt")) {
+auto WasmOptPath = getToolChain().GetProgramPath("wasm-opt");
+if (WasmOptPath != "wasm-opt") {
   StringRef OOpt = "s";
   if (A->getOption().matches(options::OPT_O4) ||
   A->getOption().matches(options::OPT_Ofast))
@@ -106,7 +106,7 @@
 OOpt = A->getValue();
 
   if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+const char *WasmOpt = Args.MakeArgString(WasmOptPath);
 ArgStringList CmdArgs;
 CmdArgs.push_back(Output.getFilename());
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -92,10 +92,10 @@
 
   C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs));
 
-  // When optimizing, if wasm-opt is in the PATH, run wasm-opt.
+  // When optimizing, if wasm-opt is available, run it.
   if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
-if (llvm::ErrorOr WasmOptPath =
-   llvm::sys::findProgramByName("wasm-opt")) {
+auto WasmOptPath = getToolChain().GetProgramPath("wasm-opt");
+if (WasmOptPath != "wasm-opt") {
   StringRef OOpt = "s";
   if (A->getOption().matches(options::OPT_O4) ||
   A->getOption().matches(options::OPT_Ofast))
@@ -106,7 +106,7 @@
 OOpt = A->getValue();
 
   if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(*WasmOptPath);
+const char *WasmOpt = Args.MakeArgString(WasmOptPath);
 ArgStringList CmdArgs;
 CmdArgs.push_back(Output.getFilename());
 CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70500: [WebAssembly] Enable use of wasm-opt and LTO-enabled system libraries

2019-11-27 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

In D70500#1759831 , @ilya-biryukov 
wrote:

> I'm not an expert in driver code and how it should behave, but being 
> consistent with how other tools are found definitely looks much better than 
> special-casing a single tool.
>  Unless there are reasons why `wasm-opt` should be special, why not use the 
> mechanism used by all other tools?


@dschuff also suggested this approach offline, so it sounds like the way to go. 
I've now submitted https://reviews.llvm.org/D70780 which implements this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70500



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

Need to check if the decl must be emitted at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70739: [OPENMP50]Add device/isa context selector support.

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked an inline comment as done.
ABataev added inline comments.



Comment at: clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp:48
+
+#pragma omp declare variant(foo) match(device = {isa("nvptx64")})
+int bar() { return 1; }

jdoerfert wrote:
> I'm not sure we want these to be strings. I would have assumed 
> `isa(nvptx64)`, similar to `vendor(arm)`, or `kind(host)` and `kind(gpu)`
Here is the message from Joachim Protze:
```
vendor and kind are special, because we define the kind-name and 
vendor-name in the context definition side document. (We could change 
that to "kind-name" or define kind-name as any of "cpu", "gpu", "fpga" ???)

For the others, according to the syntax diagram in the OpenMP Context 
section, the content of the () can only be string or const-int-exp.

- Joachim
```
That's why we need to represent them as strings, this is per OpenMP standard.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 updated this revision to Diff 231242.
lh123 marked an inline comment as done.
lh123 added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769

Files:
  llvm/include/llvm/Support/CommandLine.h
  llvm/lib/Support/CommandLine.cpp

Index: llvm/lib/Support/CommandLine.cpp
===
--- llvm/lib/Support/CommandLine.cpp
+++ llvm/lib/Support/CommandLine.cpp
@@ -37,6 +37,7 @@
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/StringSaver.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1046,9 +1047,13 @@
 static bool ExpandResponseFile(StringRef FName, StringSaver &Saver,
TokenizerCallback Tokenizer,
SmallVectorImpl &NewArgv,
-   bool MarkEOLs, bool RelativeNames) {
+   bool MarkEOLs, bool RelativeNames,
+   llvm::vfs::FileSystem &FS) {
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;
   ErrorOr> MemBufOrErr =
-  MemoryBuffer::getFile(FName);
+  FS.getBufferForFile(FName);
   if (!MemBufOrErr)
 return false;
   MemoryBuffer &MemBuf = *MemBufOrErr.get();
@@ -1084,9 +1089,7 @@
 SmallString<128> ResponseFile;
 ResponseFile.append(1, '@');
 if (llvm::sys::path::is_relative(FName)) {
-  SmallString<128> curr_dir;
-  llvm::sys::fs::current_path(curr_dir);
-  ResponseFile.append(curr_dir.str());
+  ResponseFile.append(CurrDir.get());
 }
 llvm::sys::path::append(
 ResponseFile, llvm::sys::path::parent_path(FName), FileName);
@@ -1101,8 +1104,8 @@
 /// Expand response files on a command line recursively using the given
 /// StringSaver and tokenization strategy.
 bool cl::ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
- SmallVectorImpl &Argv,
- bool MarkEOLs, bool RelativeNames) {
+ SmallVectorImpl &Argv, bool MarkEOLs,
+ bool RelativeNames, llvm::vfs::FileSystem &FS) {
   bool AllExpanded = true;
   struct ResponseFileRecord {
 const char *File;
@@ -1139,8 +1142,13 @@
 }
 
 const char *FName = Arg + 1;
-auto IsEquivalent = [FName](const ResponseFileRecord &RFile) {
-  return sys::fs::equivalent(RFile.File, FName);
+auto IsEquivalent = [FName, &FS](const ResponseFileRecord &RFile) {
+  llvm::ErrorOr LHS = FS.status(FName);
+  llvm::ErrorOr RHS = FS.status(RFile.File);
+  if (!LHS || !RHS) {
+return false;
+  }
+  return LHS->equivalent(*RHS);
 };
 
 // Check for recursive response files.
@@ -1156,7 +1164,7 @@
 // contents.  Nested response files are expanded in subsequent iterations.
 SmallVector ExpandedArgv;
 if (!ExpandResponseFile(FName, Saver, Tokenizer, ExpandedArgv, MarkEOLs,
-RelativeNames)) {
+RelativeNames, FS)) {
   // We couldn't read this file, so we leave it in the argument stream and
   // move on.
   AllExpanded = false;
@@ -1187,7 +1195,8 @@
 bool cl::readConfigFile(StringRef CfgFile, StringSaver &Saver,
 SmallVectorImpl &Argv) {
   if (!ExpandResponseFile(CfgFile, Saver, cl::tokenizeConfigFile, Argv,
-  /*MarkEOLs*/ false, /*RelativeNames*/ true))
+  /*MarkEOLs*/ false, /*RelativeNames*/ true,
+  *llvm::vfs::getRealFileSystem()))
 return false;
   return ExpandResponseFiles(Saver, cl::tokenizeConfigFile, Argv,
  /*MarkEOLs*/ false, /*RelativeNames*/ true);
Index: llvm/include/llvm/Support/CommandLine.h
===
--- llvm/include/llvm/Support/CommandLine.h
+++ llvm/include/llvm/Support/CommandLine.h
@@ -29,6 +29,7 @@
 #include "llvm/ADT/iterator_range.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/ManagedStatic.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -1964,10 +1965,13 @@
 /// with nullptrs in the Argv vector.
 /// \param [in] RelativeNames true if names of nested response files must be
 /// resolved relative to including file.
+/// \param [in] FS File system used for all file access when running the tool.
 /// \return true if all @files were expanded successfully or there were none.
-bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer,
- SmallVectorImpl &Argv,
- bool MarkEOLs = false, bool Rel

[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread liu hui via Phabricator via cfe-commits
lh123 marked 3 inline comments as done.
lh123 added inline comments.



Comment at: llvm/include/llvm/Support/CommandLine.h:47
+class FileSystem;
+IntrusiveRefCntPtr getRealFileSystem();
+

kadircet wrote:
> now that we are also pulling the the function, I think it is OK to include 
> the header instead.
Yes, we need to include `VirtualFileSystem.h`, `IntrusiveRefCntPtr` needs to 
know the complete definition of `FileSystem`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

2019-11-27 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 231247.
Anastasia added a comment.

Added `getDefaultCXXMethodAddrSpace` helper to Sema


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

https://reviews.llvm.org/D69938

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaOpenCLCXX/address-space-lambda.cl


Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -0,0 +1,25 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'int (int) const __generic'
+auto glambda = [](auto a) { return a; };
+
+__kernel void foo() {
+  int i;
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
+  auto  llambda = [&]() {i++;};
+  llambda();
+  glambda(1);
+  // Test lambda with default parameters
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const __generic'
+  [&] {i++;} ();
+  __constant auto err = [&]() {}; //expected-note-re{{candidate function not 
viable: address space mismatch in 'this' argument ('__constant (lambda at 
{{.*}})'), parameter type must be 'const __generic (lambda at {{.*}})'}}
+  err();  //expected-error-re{{no matching function 
for call to object of type '__constant (lambda at {{.*}})'}}
+  // FIXME: There is very limited addr space functionality
+  // we can test when taking lambda type from the object.
+  // The limitation is due to addr spaces being added to all
+  // objects in OpenCL. Once we add metaprogramming utility
+  // for removing address spaces from a type we can enhance
+  // testing here.
+  (*(__constant decltype(llambda) *)nullptr)(); //expected-error{{multiple 
address spaces specified for type}}
+  (*(decltype(llambda) *)nullptr)();
+}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -4916,7 +4916,9 @@
   .getScopeRep()
   ->getKind() == NestedNameSpecifier::TypeSpec) ||
  state.getDeclarator().getContext() ==
- DeclaratorContext::MemberContext;
+ DeclaratorContext::MemberContext ||
+ state.getDeclarator().getContext() ==
+ DeclaratorContext::LambdaExprContext;
 };
 
 if (state.getSema().getLangOpts().OpenCLCPlusPlus && IsClassMember()) {
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/Sema/SemaLambda.cpp
+++ clang/lib/Sema/SemaLambda.cpp
@@ -887,6 +887,10 @@
 /*IsVariadic=*/false, /*IsCXXMethod=*/true));
 EPI.HasTrailingReturn = true;
 EPI.TypeQuals.addConst();
+LangAS AS = getDefaultCXXMethodAddrSpace();
+if (AS != LangAS::Default)
+  EPI.TypeQuals.addAddressSpace(getDefaultCXXMethodAddrSpace());
+
 // C++1y [expr.prim.lambda]:
 //   The lambda return type is 'auto', which is replaced by the
 //   trailing-return type if provided and/or deduced from 'return'
Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1279,6 +1279,12 @@
   return nullptr;
 }
 
+LangAS Sema::getDefaultCXXMethodAddrSpace() const {
+  if (getLangOpts().OpenCL)
+return LangAS::opencl_generic;
+  return LangAS::Default;
+}
+
 void Sema::EmitCurrentDiagnostic(unsigned DiagID) {
   // FIXME: It doesn't make sense to me that DiagID is an incoming argument 
here
   // and yet we also use the current diag ID on the DiagnosticsEngine. This has
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -3724,6 +3724,9 @@
   /// Add the given method to the list of globally-known methods.
   void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method);
 
+  /// Returns default addr space for method qualifiers.
+  LangAS getDefaultCXXMethodAddrSpace() const;
+
 private:
   /// AddMethodToGlobalPool - Add an instance or factory method to the global
   /// pool. See descriptoin of AddInstanceMethodToGlobalPool.


Index: clang/test/SemaOpenCLCXX/address-space-lambda.cl
===
--- /dev/null
+++ clang/test/SemaOpenCLCXX/address-space-lambda.cl
@@ -0,0 +1,25 @@
+//RUN: %clang_cc1 %s -cl-std=clc++ -pedantic -ast-dump -verify | FileCheck %s
+
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'int (int) const __generic'
+auto glambda = [](auto a) { return a; };
+
+__kernel void foo() {
+  int i;
+//CHECK: CXXMethodDecl {{.*}} constexpr operator() 'void () const 

[clang] f59614d - [OPENMP50]Add if clause in parallel for simd directive.

2019-11-27 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2019-11-27T09:56:25-05:00
New Revision: f59614d906b5428f3687a44ee018df5840b301dd

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

LOG: [OPENMP50]Add if clause in parallel for simd directive.

According to OpenMP 5.0, if clause can be used in parallel for simd directive. 
If condition in the if clause if false, the non-vectorized version of the
loop must be executed.

Added: 


Modified: 
clang/lib/Sema/SemaOpenMP.cpp
clang/test/OpenMP/parallel_for_simd_codegen.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 59178fb671fb..2773efcf3dae 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -4538,6 +4538,8 @@ StmtResult Sema::ActOnOpenMPExecutableDirective(
 Res = ActOnOpenMPParallelForSimdDirective(
 ClausesWithImplicit, AStmt, StartLoc, EndLoc, VarsWithInheritedDSA);
 AllowedNameModifiers.push_back(OMPD_parallel);
+if (LangOpts.OpenMP >= 50)
+  AllowedNameModifiers.push_back(OMPD_simd);
 break;
   case OMPD_parallel_sections:
 Res = ActOnOpenMPParallelSectionsDirective(ClausesWithImplicit, AStmt,
@@ -10677,11 +10679,14 @@ static OpenMPDirectiveKind 
getOpenMPCaptureRegionForClause(
   if (NameModifier == OMPD_unknown || NameModifier == OMPD_taskloop)
 CaptureRegion = OMPD_parallel;
   break;
+case OMPD_parallel_for_simd:
+  if (NameModifier == OMPD_unknown || NameModifier == OMPD_simd)
+CaptureRegion = OMPD_parallel;
+  break;
 case OMPD_cancel:
 case OMPD_parallel:
 case OMPD_parallel_sections:
 case OMPD_parallel_for:
-case OMPD_parallel_for_simd:
 case OMPD_target:
 case OMPD_target_simd:
 case OMPD_target_teams:

diff  --git a/clang/test/OpenMP/parallel_for_simd_codegen.cpp 
b/clang/test/OpenMP/parallel_for_simd_codegen.cpp
index 9585bf293695..01f2b4c42a24 100644
--- a/clang/test/OpenMP/parallel_for_simd_codegen.cpp
+++ b/clang/test/OpenMP/parallel_for_simd_codegen.cpp
@@ -1,14 +1,24 @@
-// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s 
--check-prefix=OMP45 --check-prefix=CHECK
 // RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp -x c++ -triple x86_64-unknown-unknown -fexceptions 
-fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - | FileCheck %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -fexceptions 
-fcxx-exceptions -debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | 
FileCheck %s --check-prefix=TERM_DEBUG
 
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck %s --check-prefix=OMP50 --check-prefix=CHECK
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -x c++ -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -debug-info-kind=limited 
-std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp 
-fopenmp-version=50 -fexceptions -fcxx-exceptions 
-debug-info-kind=line-tables-only -x c++ -emit-llvm %s -o - | FileCheck %s 
--check-prefix=TERM_DEBUG
+
 // RUN: %clang_cc1 -verify -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck --check-prefix 
SIMD-ONLY0 %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -triple 
x86_64-unknown-unknown -fexceptions -fcxx-exceptions -emit-pch -o %t %s
 // RUN: %clang_cc1 -fopenmp-simd -x c++ -triple x86_64-unknown-unknown 
-fexceptions -fcxx-exceptions -debug-info-kind=limited -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck --check-prefix SIMD-ONLY0 %s
 // RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp-simd 
-fexceptions -fcxx-exceptions -debug-info-kind=line-tables-only -x c++ 
-emit-llvm %s -o - | FileCheck --check-prefix SIMD-ONLY0 %s
-// SIMD-ONLY0-NOT: {{__kmpc|__tgt}}
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50  -x c++ -triple 
x86_64-unknown-unknown -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck --check-prefix SIMD-ONLY0 %s
+// RUN: %clang_cc1 -fopenmp-simd -fopenmp-version=50  -x c++ -std=c++11 
-triple x86_64-unknown-unknown -fexceptions -fcxx-exception

[PATCH] D70512: [clangd] Rethink how SelectionTree deals with macros and #includes.

2019-11-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Thanks, the patch looks good! please also update the patch description.




Comment at: clang-tools-extra/clangd/Selection.cpp:63
+  // Claims whichever expanded tokens in SourceRange are not yet claimed.
+  // Writes contiguous claimed subranges to Result, and returns true if any.
+  llvm::SmallVector, 4> erase(llvm::ArrayRef Claim) {

nit: this comment seems not reflect to the code now.



Comment at: clang-tools-extra/clangd/Selection.cpp:126
+
+// Nodes start start with NoTokens, and then use this function to aggregate
+// the selectedness as more tokens are found.

nit: remove the redundant start.



Comment at: clang-tools-extra/clangd/unittests/SelectionTests.cpp:468
+  // Unfortunately, this makes the common ancestor the CallExpr...
+  // FIXME: hack around this by picking one?
+  EXPECT_EQ("CallExpr", T.commonAncestor()->kind());

I think cases like below are broken:

```
#define greater(x, y) x > y? x : y
#define abs(x) x > 0 ? x : -x
```

 Selecting the first element for a macro arg seems good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70512



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60338 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[clang-tools-extra] 939544a - [clangd] Handle the missing call expr in targetDecl.

2019-11-27 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2019-11-27T16:22:20+01:00
New Revision: 939544add98ee6463d6abd6c28fa6c9ac4b6e104

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

LOG: [clangd] Handle the missing call expr in targetDecl.

Reviewers: sammccall

Reviewed By: sammccall

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

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/FindTarget.cpp 
b/clang-tools-extra/clangd/FindTarget.cpp
index c536cbf75e5c..3e55a6a9cdc6 100644
--- a/clang-tools-extra/clangd/FindTarget.cpp
+++ b/clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@ struct TargetFinder {
   RelSet Flags;
   Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) 
{}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.

diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index f6e5fe723ec7..620eb3d6d3d6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@ TEST_F(TargetDeclTest, Exprs) {
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bader via Phabricator via cfe-commits
bader marked an inline comment as done.
bader added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

ABataev wrote:
> Need to check if the decl must be emitted at all.
Let me check that I get it right. You suggest adding `if 
(MustBeEmitted(Global))`, right?
```
  if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
MustBeEmitted(Global)) {
...
addDeferredDeclToEmit(GD);
return;
  }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70773: [clangd] Handle the missing call expr in targetDecl.

2019-11-27 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG939544add98e: [clangd] Handle the missing call expr in 
targetDecl. (authored by hokein).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70773

Files:
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@
   RelSet Flags;
   Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) 
{}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.


Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -114,6 +114,23 @@
 auto X = S() [[+]] S();
   )cpp";
   EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+
+  Code = R"cpp(
+int foo();
+int s = foo[[()]];
+  )cpp";
+  EXPECT_DECLS("CallExpr", "int foo()");
+
+  Code = R"cpp(
+struct X {
+void operator()(int n);
+};
+void test() {
+  X x;
+  x[[(123)]];
+}
+  )cpp";
+  EXPECT_DECLS("CXXOperatorCallExpr", "void operator()(int n)");
 }
 
 TEST_F(TargetDeclTest, UsingDecl) {
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -175,6 +175,9 @@
   RelSet Flags;
   Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) {}
 
+  void VisitCallExpr(const CallExpr *CE) {
+Outer.add(CE->getCalleeDecl(), Flags);
+  }
   void VisitDeclRefExpr(const DeclRefExpr *DRE) {
 const Decl *D = DRE->getDecl();
 // UsingShadowDecl allows us to record the UsingDecl.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

bader wrote:
> ABataev wrote:
> > Need to check if the decl must be emitted at all.
> Let me check that I get it right. You suggest adding `if 
> (MustBeEmitted(Global))`, right?
> ```
>   if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
> MustBeEmitted(Global)) {
> ...
> addDeferredDeclToEmit(GD);
> return;
>   }
> ```
Yes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70739: [OPENMP50]Add device/isa context selector support.

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev updated this revision to Diff 231265.
ABataev added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OpenMPKinds.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/test/OpenMP/declare_variant_ast_print.c
  clang/test/OpenMP/declare_variant_ast_print.cpp
  clang/test/OpenMP/declare_variant_device_isa_codegen.cpp
  clang/test/OpenMP/declare_variant_messages.c
  clang/test/OpenMP/declare_variant_messages.cpp
  clang/test/OpenMP/declare_variant_mixed_codegen.cpp
  clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp

Index: clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/nvptx_declare_variant_device_isa_codegen.cpp
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - -fopenmp-version=50 | FileCheck %s --implicit-check-not='ret i32 {{1|81|84}}'
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -emit-pch -o %t -fopenmp-version=50
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple nvptx64-unknown-unknown -aux-triple powerpc64le-unknown-unknown -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -include-pch %t -o - -fopenmp-version=50 | FileCheck %s --implicit-check-not='ret i32 {{1|81|84}}'
+// expected-no-diagnostics
+
+// CHECK-NOT: ret i32 {{1|81|84}}
+// CHECK-DAG: define {{.*}}i32 @_Z3barv()
+// CHECK-DAG: define {{.*}}i32 @_ZN16SpecSpecialFuncs6MethodEv(%struct.SpecSpecialFuncs* %{{.+}})
+// CHECK-DAG: define {{.*}}i32 @_ZN12SpecialFuncs6MethodEv(%struct.SpecialFuncs* %{{.+}})
+// CHECK-DAG: define linkonce_odr {{.*}}i32 @_ZN16SpecSpecialFuncs6methodEv(%struct.SpecSpecialFuncs* %{{.+}})
+// CHECK-DAG: define linkonce_odr {{.*}}i32 @_ZN12SpecialFuncs6methodEv(%struct.SpecialFuncs* %{{.+}})
+// CHECK-DAG: define {{.*}}i32 @_Z5prio_v()
+// CHECK-DAG: define internal i32 @_ZL6prio1_v()
+// CHECK-DAG: define {{.*}}i32 @_Z4callv()
+// CHECK-DAG: define internal i32 @_ZL9stat_usedv()
+// CHECK-DAG: define {{.*}}i32 @fn_linkage()
+// CHECK-DAG: define {{.*}}i32 @_Z11fn_linkage1v()
+
+// CHECK-DAG: ret i32 2
+// CHECK-DAG: ret i32 3
+// CHECK-DAG: ret i32 4
+// CHECK-DAG: ret i32 5
+// CHECK-DAG: ret i32 6
+// CHECK-DAG: ret i32 7
+// CHECK-DAG: ret i32 82
+// CHECK-DAG: ret i32 83
+// CHECK-DAG: ret i32 85
+// CHECK-DAG: ret i32 86
+// CHECK-DAG: ret i32 87
+
+// Outputs for function members
+// CHECK-DAG: ret i32 6
+// CHECK-DAG: ret i32 7
+// CHECK-NOT: ret i32 {{1|81|84}}
+
+#ifndef HEADER
+#define HEADER
+
+int foo() { return 2; }
+int bazzz();
+int test();
+static int stat_unused_();
+static int stat_used_();
+
+#pragma omp declare target
+
+#pragma omp declare variant(foo) match(device = {isa("nvptx64")})
+int bar() { return 1; }
+
+#pragma omp declare variant(bazzz) match(device = {isa("nvptx64")})
+int baz() { return 1; }
+
+#pragma omp declare variant(test) match(device = {isa("nvptx64")})
+int call() { return 1; }
+
+#pragma omp declare variant(stat_unused_) match(device = {isa("nvptx64")})
+static int stat_unused() { return 1; }
+
+#pragma omp declare variant(stat_used_) match(device = {isa("nvptx64")})
+static int stat_used() { return 1; }
+
+#pragma omp end declare target
+
+int main() {
+  int res;
+#pragma omp target map(from \
+   : res)
+  res = bar() + baz() + call();
+  return res;
+}
+
+int test() { return 3; }
+static int stat_unused_() { return 4; }
+static int stat_used_() { return 5; }
+
+#pragma omp declare target
+
+struct SpecialFuncs {
+  void vd() {}
+  SpecialFuncs();
+  ~SpecialFuncs();
+
+  int method_() { return 6; }
+#pragma omp declare variant(SpecialFuncs::method_) \
+match(device = {isa("nvptx64")})
+  int method() { return 1; }
+#pragma omp declare variant(SpecialFuncs::method_) \
+match(device = {isa("nvptx64")})
+  int Method();
+} s;
+
+int SpecialFuncs::Method() { return 1; }
+
+struct SpecSpecialFuncs {
+  void vd() {}
+  SpecSpecialFuncs();
+  ~SpecSpecialFuncs();
+
+  int method_();
+#pragma omp declare variant(SpecSpecialFuncs::method_) \
+match(device = {isa("nvptx64")})
+  int method() { return 1; }
+#pragma omp declare variant

[PATCH] D70739: [OPENMP50]Add device/isa context selector support.

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev marked 2 inline comments as done.
ABataev added inline comments.



Comment at: clang/include/clang/Sema/Sema.h:9320
   using OMPCtxSelectorData =
-  OpenMPCtxSelectorData, ExprResult>;
+  OpenMPCtxSelectorData, ExprResult>;
 

jdoerfert wrote:
> I would like to avoid the Any type here and I hope we can if we don't allow 
> "strings". See also my last comment.
The only possible solution I see here is to convert kind/vendor strings into 
exprs and store all data as `Expr *`



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:11147
+llvm::Triple CustomTriple(Name);
+if (CGM.getTarget().getTriple().getArch() != CustomTriple.getArch())
+  return false;

jdoerfert wrote:
> should we normalize the names here? at least `.lower` might be useful.
Done + added check for possibly used vendor/os/env


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



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


[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2019-11-27 Thread Marco Hinz via Phabricator via cfe-commits
mhinz updated this revision to Diff 231266.
mhinz added a comment.
Herald added subscribers: aheejin, jgravelle-google, sbc100, dschuff.

Apply fix to all toolchains.


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

https://reviews.llvm.org/D69221

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/lib/Driver/ToolChains/Hurd.cpp
  clang/lib/Driver/ToolChains/Linux.cpp
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/lib/Driver/ToolChains/WebAssembly.cpp


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Linux.cpp
===
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -674,7 +674,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Hurd.cpp
===
--- clang/lib/Driver/ToolChains/Hurd.cpp
+++ clang/lib/Driver/ToolChains/Hurd.cpp
@@ -149,7 +149,7 @@
 CIncludeDirs.split(Dirs, ":");
 for (StringRef Dir : Dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(Dir) ? StringRef(SysRoot) : "";
+  llvm::sys::path::is_absolute(Dir) ? "" : StringRef(SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + Dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -286,7 +286,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1896,7 +1896,7 @@
 CIncludeDirs.split(dirs, ":");
 for (llvm::StringRef dir : dirs) {
   llvm::StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? llvm::StringRef(Sysroot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : llvm::StringRef(Sysroot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
   } else {


Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -283,7 +283,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -244,7 +244,7 @@
 CIncludeDirs.split(dirs, ":");
 for (StringRef dir : dirs) {
   StringRef Prefix =
-  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  llvm::sys::path::is_absolute(dir) ? "" : StringRef(D.SysRoot);
   addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
 }
 return;
Index: clang/lib/Dr

[PATCH] D69221: [clang][darwin] Fix search path logic for C_INCLUDE_DIRS

2019-11-27 Thread Marco Hinz via Phabricator via cfe-commits
mhinz added a comment.

I applied the fix to all toolchains now, but I'm unsure how to write a test for 
it. Neither could I find tests for similar options like `-DDEFAULT_SYSROOT`.

My use case: I want to build a clang that has the same search path as the clang 
shipped with macOS.

  $ /usr/bin/clang -E -xc -v /dev/null
  [snip]
  #include <...> search starts here:
   /usr/local/include
   
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/include
   
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
   
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
 (framework directory)
  End of search list.
  [snip]

For this, I need to pass this to cmake:

  
-DC_INCLUDE_DIRS="/usr/local/include:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include"
  -DDEFAULT_SYSROOT="$(xcrun --show-sdk-path)"


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

https://reviews.llvm.org/D69221



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


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
ilya-biryukov added a reviewer: gribozavr2.
Herald added a project: clang.

Also remove the temporary TopLevelDeclaration node and add
UnknownDeclaration to represent other unknown nodes.

See the follow-up change for building more top-level declarations.
Adding declarators is also pretty involved and will be done in the
follow-up patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70787

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -130,7 +130,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-|-TopLevelDeclaration
+|-SimpleDeclaration
 | |-int
 | |-main
 | |-(
@@ -138,7 +138,7 @@
 | `-CompoundStatement
 |   |-{
 |   `-}
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-foo
   |-(
@@ -157,7 +157,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-main
   |-(
@@ -202,7 +202,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -224,7 +224,7 @@
   {"void test() { int a = 10; }",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -232,16 +232,18 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-=
-| |-10
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-=
+| | `-UnknownExpression
+| |   `-10
 | `-;
 `-}
 )txt"},
   {"void test() { ; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -263,7 +265,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -299,7 +301,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -329,7 +331,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-test
   |-(
@@ -352,7 +354,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -360,18 +362,21 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-[
-| |-3
-| |-]
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-[
+| | |-UnknownExpression
+| | | `-3
+| | `-]
 | `-;
 |-RangeBasedForStatement
 | |-for
 | |-(
-| |-int
-| |-x
-| |-:
+| |-SimpleDeclaration
+| | |-int
+| | |-x
+| | `-:
 | |-UnknownExpression
 | | `-a
 | |-)
@@ -384,7 +389,7 @@
   // counterpart.
   {"void main() { foo: return 100; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-main
   |-(
@@ -411,7 +416,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -444,7 +449,35 @@
 |   | `-)
 |   `-;
 `-}
-)txt"}};
+)txt"},
+  // Multiple declarators group into a single SimpleDeclaration.
+  {R"cpp(
+  int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"},
+  {R"cpp(
+typedef int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-typedef
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"}};
 
   for (const auto &T : Cases) {
 auto *Root = buildTree(T.first);
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -16,8 +16,6 @@
 return OS << "Leaf";
   case NodeKind::TranslationUnit:
 return OS << "TranslationUnit";
-  case NodeKind::TopLevelDeclaration:
-return OS << "TopLevelDeclaration";
   case NodeKind::UnknownExpression:
 return OS << "UnknownExpression";
   case NodeKind::UnknownStatement:
@@ -50,6 +48,10 @@
 return OS << "ExpressionStatement";
   case NodeKind::CompoundStatement:
 return OS << "CompoundStatement";
+  case NodeKind::UnknownDeclaration:
+return OS << "UnknownDeclaration";
+  case NodeKind::SimpleDeclaration:
+return OS << "SimpleDeclaration";
   }
   llvm_unreachable("unknown node kind");
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 #inc

[PATCH] D70788: [Syntax] A tool to dump syntax tree and token buffer

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Would want to add some tests before landing this. But this is tool is generally 
useful to experiment with syntax trees, so posting it early (so that it doesn't 
get lost)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70788



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


[PATCH] D70788: [Syntax] A tool to dump syntax tree and token buffer

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
ilya-biryukov added a comment.
ilya-biryukov planned changes to this revision.

Would want to add some tests before landing this. But this is tool is generally 
useful to experiment with syntax trees, so posting it early (so that it doesn't 
get lost)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70788

Files:
  clang/tools/CMakeLists.txt
  clang/tools/clang-syntax/CMakeLists.txt
  clang/tools/clang-syntax/SyntaxMain.cpp

Index: clang/tools/clang-syntax/SyntaxMain.cpp
===
--- /dev/null
+++ clang/tools/clang-syntax/SyntaxMain.cpp
@@ -0,0 +1,81 @@
+//===- SyntaxMain.cpp -*- C++ -*-=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Tooling/Execution.h"
+#include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/Tooling/Syntax/Tokens.h"
+#include "clang/Tooling/Syntax/Tree.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/raw_ostream.h"
+#include 
+
+using namespace clang;
+
+namespace {
+llvm::cl::opt DumpTokens("dump-tokens",
+   llvm::cl::desc("dump the preprocessed tokens"),
+   llvm::cl::init(false));
+llvm::cl::opt DumpTree("dump-tree",
+ llvm::cl::desc("dump the syntax tree"),
+ llvm::cl::init(false));
+
+class BuildSyntaxTree : public ASTFrontendAction {
+public:
+  std::unique_ptr CreateASTConsumer(CompilerInstance &CI,
+ StringRef InFile) override {
+class Consumer : public ASTConsumer {
+public:
+  Consumer(CompilerInstance &CI) : Collector(CI.getPreprocessor()) {}
+
+  void HandleTranslationUnit(ASTContext &AST) override {
+syntax::Arena A(AST.getSourceManager(), AST.getLangOpts(),
+std::move(Collector).consume());
+auto *TU = syntax::buildSyntaxTree(A, *AST.getTranslationUnitDecl());
+if (DumpTokens)
+  llvm::outs() << A.tokenBuffer().dumpForTests();
+if (DumpTree)
+  llvm::outs() << TU->dump(A);
+  }
+
+private:
+  syntax::TokenCollector Collector;
+};
+return std::make_unique(CI);
+  }
+};
+
+class Factory : public tooling::FrontendActionFactory {
+  std::unique_ptr create() override {
+return std::make_unique();
+  }
+};
+
+} // namespace
+
+int main(int argc, const char **argv) {
+  llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
+  auto Executor = clang::tooling::createExecutorFromCommandLineArgs(
+  argc, argv, llvm::cl::GeneralCategory,
+  "Build syntax trees for the specified files");
+  if (!Executor) {
+llvm::errs() << llvm::toString(Executor.takeError()) << "\n";
+return 1;
+  }
+  if (!DumpTokens && !DumpTree) {
+llvm::errs()
+<< "Please specify at least one of -dump-tree or -dump-tokens\n";
+return 1;
+  }
+  // Collect symbols found in each translation unit, merging as we go.
+  auto Err = Executor->get()->execute(std::make_unique());
+  if (Err)
+llvm::errs() << llvm::toString(std::move(Err)) << "\n";
+  return 0;
+}
Index: clang/tools/clang-syntax/CMakeLists.txt
===
--- /dev/null
+++ clang/tools/clang-syntax/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(LLVM_LINK_COMPONENTS Support)
+
+add_clang_tool(clang-syntax
+  SyntaxMain.cpp
+  )
+
+target_link_libraries(clang-syntax
+  PRIVATE
+  clangAST
+  clangBasic
+  clangFrontend
+  clangLex
+  clangTooling
+  clangToolingCore
+  clangToolingSyntax
+)
Index: clang/tools/CMakeLists.txt
===
--- clang/tools/CMakeLists.txt
+++ clang/tools/CMakeLists.txt
@@ -18,6 +18,7 @@
 if(UNIX)
   add_clang_subdirectory(clang-shlib)
 endif()
+add_clang_subdirectory(clang-syntax)
 
 if(CLANG_ENABLE_ARCMT)
   add_clang_subdirectory(arcmt-test)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

2019-11-27 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 231269.
ilya-biryukov added a comment.

- Remove obsolete FIXME
- Fix a typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70787

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -130,7 +130,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-|-TopLevelDeclaration
+|-SimpleDeclaration
 | |-int
 | |-main
 | |-(
@@ -138,7 +138,7 @@
 | `-CompoundStatement
 |   |-{
 |   `-}
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-foo
   |-(
@@ -157,7 +157,7 @@
 )cpp",
   R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-main
   |-(
@@ -202,7 +202,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -224,7 +224,7 @@
   {"void test() { int a = 10; }",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -232,16 +232,18 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-=
-| |-10
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-=
+| | `-UnknownExpression
+| |   `-10
 | `-;
 `-}
 )txt"},
   {"void test() { ; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -263,7 +265,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -299,7 +301,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -329,7 +331,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-int
   |-test
   |-(
@@ -352,7 +354,7 @@
   )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -360,18 +362,21 @@
   `-CompoundStatement
 |-{
 |-DeclarationStatement
-| |-int
-| |-a
-| |-[
-| |-3
-| |-]
+| |-SimpleDeclaration
+| | |-int
+| | |-a
+| | |-[
+| | |-UnknownExpression
+| | | `-3
+| | `-]
 | `-;
 |-RangeBasedForStatement
 | |-for
 | |-(
-| |-int
-| |-x
-| |-:
+| |-SimpleDeclaration
+| | |-int
+| | |-x
+| | `-:
 | |-UnknownExpression
 | | `-a
 | |-)
@@ -384,7 +389,7 @@
   // counterpart.
   {"void main() { foo: return 100; }", R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-main
   |-(
@@ -411,7 +416,7 @@
 )cpp",
R"txt(
 *: TranslationUnit
-`-TopLevelDeclaration
+`-SimpleDeclaration
   |-void
   |-test
   |-(
@@ -444,7 +449,35 @@
 |   | `-)
 |   `-;
 `-}
-)txt"}};
+)txt"},
+  // Multiple declarators group into a single SimpleDeclaration.
+  {R"cpp(
+  int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"},
+  {R"cpp(
+typedef int *a, b;
+  )cpp",
+   R"txt(
+*: TranslationUnit
+`-SimpleDeclaration
+  |-typedef
+  |-int
+  |-*
+  |-a
+  |-,
+  |-b
+  `-;
+  )txt"}};
 
   for (const auto &T : Cases) {
 auto *Root = buildTree(T.first);
Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -16,8 +16,6 @@
 return OS << "Leaf";
   case NodeKind::TranslationUnit:
 return OS << "TranslationUnit";
-  case NodeKind::TopLevelDeclaration:
-return OS << "TopLevelDeclaration";
   case NodeKind::UnknownExpression:
 return OS << "UnknownExpression";
   case NodeKind::UnknownStatement:
@@ -50,6 +48,10 @@
 return OS << "ExpressionStatement";
   case NodeKind::CompoundStatement:
 return OS << "CompoundStatement";
+  case NodeKind::UnknownDeclaration:
+return OS << "UnknownDeclaration";
+  case NodeKind::SimpleDeclaration:
+return OS << "SimpleDeclaration";
   }
   llvm_unreachable("unknown node kind");
 }
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -6,6 +6,8 @@
 //
 //===--===//
 #include "clang/Tooling/Syntax/BuildTree.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clan

[PATCH] D70739: [OPENMP50]Add device/isa context selector support.

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60340 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70739



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


[clang] f4bba07 - [ARM][MVE][Intrinsics] Add MVE VABD intrinsics. Add unit tests.

2019-11-27 Thread Mark Murray via cfe-commits

Author: Mark Murray
Date: 2019-11-27T16:52:04Z
New Revision: f4bba07b87ce7ad60d908d2fe02abe88d2d48fa4

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

LOG: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics. Add unit tests.

Summary: Add MVE VABD intrinsics. Add unit tests.

Reviewers: simon_tatham, ostannard, dmgreen

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index d8d199f464d9..0d827485ae40 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -28,6 +28,7 @@ foreach n = [ 2, 4 ] in {
   "Intrinsic::arm_mve_vld"#n#"q":$IRIntr)>;
 }
 
+
 let params = T.Int in {
 def vaddq: Intrinsic;
 def vsubq: Intrinsic;
@@ -41,6 +42,14 @@ def vsubqf: Intrinsic,
 }
 
 let params = T.Usual in {
+def vabdq: Intrinsic $a, $b)>;
+}
+
+let params = T.Usual in {
+def vabdq_m: Intrinsic<
+Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
+(IRInt<"abd_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;
 def vaddq_m: Intrinsic<
 Vector, (args Vector:$inactive, Vector:$a, Vector:$b, Predicate:$pred),
 (IRInt<"add_predicated", [Vector, Predicate]> $a, $b, $pred, $inactive)>;

diff  --git a/clang/test/CodeGen/arm-mve-intrinsics/vabdq.c 
b/clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
new file mode 100644
index ..a416bfb773e6
--- /dev/null
+++ b/clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
@@ -0,0 +1,95 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -S -emit-llvm -o - %s | opt -S -mem2reg | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature 
+mve.fp -mfloat-abi hard -fallow-half-arguments-and-returns -O0 
-disable-O0-optnone -DPOLYMORPHIC -S -emit-llvm -o - %s | opt -S -mem2reg | 
FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vabdq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <16 x i8> @llvm.arm.mve.vabd.v16i8(<16 x 
i8> [[A:%.*]], <16 x i8> [[B:%.*]])
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+int8x16_t test_vabdq_s8(int8x16_t a, int8x16_t b)
+{
+#ifdef POLYMORPHIC
+return vabdq(a, b);
+#else /* POLYMORPHIC */
+return vabdq_s8(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_u32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x 
i32> [[A:%.*]], <4 x i32> [[B:%.*]])
+// CHECK-NEXT:ret <4 x i32> [[TMP0]]
+//
+uint32x4_t test_vabdq_u32(uint32x4_t a, uint32x4_t b)
+{
+#ifdef POLYMORPHIC
+return vabdq(a, b);
+#else /* POLYMORPHIC */
+return vabdq_u32(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_f32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = call <8 x half> @llvm.arm.mve.vabd.v8f16(<8 x 
half> [[A:%.*]], <8 x half> [[B:%.*]])
+// CHECK-NEXT:ret <8 x half> [[TMP0]]
+//
+float16x8_t test_vabdq_f32(float16x8_t a, float16x8_t b)
+{
+#ifdef POLYMORPHIC
+return vabdq(a, b);
+#else /* POLYMORPHIC */
+return vabdq_f16(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_m_u16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 
[[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <8 x i16> 
@llvm.arm.mve.abd.predicated.v8i16.v8i1(<8 x i16> [[A:%.*]], <8 x i16> 
[[B:%.*]], <8 x i1> [[TMP1]], <8 x i16> [[INACTIVE:%.*]])
+// CHECK-NEXT:ret <8 x i16> [[TMP2]]
+//
+uint16x8_t test_vabdq_m_u16(uint16x8_t inactive, uint16x8_t a, uint16x8_t b, 
mve_pred16_t p)
+{
+#ifdef POLYMORPHIC
+return vabdq_m(inactive, a, b, p);
+#else /* POLYMORPHIC */
+return vabdq_m_u16(inactive, a, b, p);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vabdq_m_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = zext i16 [[P:%.*]] to i32
+// CHECK-NEXT:[[TMP1:%.*]] = call <16 x i1> 
@llvm.arm.mve.pred.i2v.v16i1(i32 [[TMP0]])
+// CHECK-NEXT:[[TMP2:%.*]] = call <16 x i8> 
@llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8> [[A:%.*]], <16 x i8> 
[[B:%.*]], <16 x i1> [[TMP1]], <16 x i8> [[INACTIVE:%.*]])
+// CHECK-NEXT:ret <16 x i8> [[TMP

[PATCH] D70765: LTOVisibility.rst: fix up syntax in example

2019-11-27 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70765



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


[PATCH] D70545: [ARM][MVE][Intrinsics] Add MVE VABD intrinsics.

2019-11-27 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4bba07b87ce: [ARM][MVE][Intrinsics] Add MVE VABD 
intrinsics. Add unit tests. (authored by MarkMurrayARM).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70545

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vabdq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vabdq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vabdq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vabdq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.s32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>%a, <4 x i32>%b)
+  ret <4 x i32> %0
+}
+
+declare <4 x i32> @llvm.arm.mve.vabd.v4i32(<4 x i32>, <4 x i32>)
+
+define arm_aapcs_vfpcc <4 x float> @test_vabdq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vabdq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vabd.f32 q0, q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>%a, <4 x float>%b)
+  ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.arm.mve.vabd.v4f32(<4 x float>, <4 x float>)
+
+define arm_aapcs_vfpcc <16 x i8> @test_vabdq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.s8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.abd.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vabdq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vabdq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vabdt.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.abd.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/lib/Target/ARM/ARMInstrMVE.td
===
--- llvm/lib/Target/ARM/ARMInstrMVE.td
+++ llvm/lib/Target/ARM/ARMInstrMVE.td
@@ -1664,7 +1664,8 @@
 }
 
 
-class MVE_VABD_int size, list pattern=[]>
+class MVE_VABD_int size,
+ list pattern=[]>
   : MVE_int<"vabd", suffix, size, pattern> {
 
   let Inst{28} = U;
@@ -1676,12 +1677,35 @@
   let validForTailPredication = 1;
 }
 
-def MVE_VABDs8  : MVE_VABD_int<"s8", 0b0, 0b00>;
-def MVE_VABDs16 : MVE_VABD_int<"s16", 0b0, 0b01>;
-def MVE_VABDs32 : MVE_VABD_int<"s32", 0b0, 0b10>;
-def MVE_VABDu8  : MVE_VABD_int<"u8", 0b1, 0b00>;
-def MVE_VABDu16 : MVE_VABD_int<"u16", 0b1, 0b01>;
-def MVE_VABDu32 : MVE_VABD_int<"u32", 0b1, 0b10>;
+multiclass MVE_VABD_m {
+  def "" : MVE_VABD_int;
+
+  let Predicates = [HasMVEInt] in {
+// Unpredicated absolute difference
+def : Pat<(VTI.Vec (unpred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn)))>;
+
+// Predicated absolute difference
+def : Pat<(VTI.Vec (pred_int (VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(VTI.Pred VCCR:$mask), (VTI.Vec MQPR:$inactive))),
+  (VTI.Vec (!cast(NAME)
+(VTI.Vec MQPR:$Qm), (VTI.Vec MQPR:$Qn),
+(i32 1), (VTI.Pred VCCR:$mask),
+(VTI.Vec MQPR:$inactive)))>;
+  }
+}
+
+multiclass MVE_VABD
+  : MVE_VABD_m;
+
+defm MVE_VABDs8  : MVE_VABD;
+defm MVE_VABDs16 : MVE_VABD;
+defm MVE_VABDs32 : MVE_VABD;
+defm MVE_VABDu8  : MVE_VABD;
+defm MVE_VABDu16 : MVE_VABD;
+defm MVE_VABDu32 : MVE_VABD;
 
 class MVE_VRHADD size, list pattern=[]>
   : MVE_int<"vrhadd", suffix, size, p

[PATCH] D70546: [ARM][MVE][Intrinsics] Add MVE VMUL intrinsics.

2019-11-27 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8a8dbe9c458: [ARM][MVE][Intrinsics] Add MVE VMUL 
intrinsics. Remove annoying "t1" from VMUL*… (authored by 
MarkMurrayARM).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70546

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vmulq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
  llvm/unittests/Target/ARM/MachineInstrTest.cpp

Index: llvm/unittests/Target/ARM/MachineInstrTest.cpp
===
--- llvm/unittests/Target/ARM/MachineInstrTest.cpp
+++ llvm/unittests/Target/ARM/MachineInstrTest.cpp
@@ -250,9 +250,9 @@
 case MVE_VMUL_qr_i8:
 case MVE_VMULf16:
 case MVE_VMULf32:
-case MVE_VMULt1i16:
-case MVE_VMULt1i8:
-case MVE_VMULt1i32:
+case MVE_VMULi16:
+case MVE_VMULi8:
+case MVE_VMULi32:
 case MVE_VMVN:
 case MVE_VMVNimmi16:
 case MVE_VMVNimmi32:
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vmulq.ll
@@ -0,0 +1,58 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @test_vmulq_u32(<4 x i32> %a, <4 x i32> %b) {
+; CHECK-LABEL: test_vmulq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmul.i32 q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = mul <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vmulq_f32(<4 x float> %a, <4 x float> %b) {
+; CHECK-LABEL: test_vmulq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmul.f32 q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = fmul <4 x float> %b, %a
+  ret <4 x float> %0
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vmulq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vmulq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmult.i8 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.mul.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32)
+
+declare <16 x i8> @llvm.arm.mve.mul.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>)
+
+define arm_aapcs_vfpcc <8 x half> @test_vmulq_m_f16(<8 x half> %inactive, <8 x half> %a, <8 x half> %b, i16 zeroext %p) {
+; CHECK-LABEL: test_vmulq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vmult.f16 q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.mul.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1, <8 x half> %inactive)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32)
+
+declare <8 x half> @llvm.arm.mve.mul.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>, <8 x half>)
Index: llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
===
--- llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
+++ llvm/test/CodeGen/Thumb2/LowOverheadLoops/wlstp.mir
@@ -211,7 +211,7 @@
   ; CHECK:   renamable $r4 = t2ADDrr renamable $r0, renamable $r12, 14, $noreg, $noreg
   ; CHECK:   renamable $r12 = t2ADDri killed renamable $r12, 16, 14, $noreg, $noreg
   ; CHECK:   renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, $noreg
-  ; CHECK:   renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
+  ; CHECK:   renamable $q0 = MVE_VMULi8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
   ; CHECK:   MVE_VSTRBU8 killed renamable $q0, killed renamable $r4, 0, 0, killed $noreg :: (store 16 into %ir.scevgep1, align 1)
   ; CHECK:   $lr = MVE_LETP renamable $lr, %bb.2
   ; CHECK: bb.3.for.cond.cleanup:
@@ -252,7 +252,7 @@
 renamable $r4 = t2ADDrr renamable $r0, renamable $r12, 14, $noreg, $noreg
 renamable $r12 = t2ADDri killed renamable $r12, 16, 14, $noreg, $noreg
 renamable $r3, dead $cpsr = tSUBi8 killed renamable $r3, 16, 14, $noreg
-renamable $q0 = MVE_VMULt1i8 killed renamable $q1, killed renamable $q0, 0, $noreg, undef renamable $q0
+renamable $q0 = MVE_VMULi8 k

[PATCH] D70547: [ARM][MVE][Intrinsics] Add MVE VAND/VORR/VORN/VEOR/VBIC intrinsics.

2019-11-27 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa048bf87fb65: [ARM][MVE][Intrinsics] Add MVE 
VAND/VORR/VORN/VEOR/VBIC intrinsics. Add unit… (authored by MarkMurrayARM).

Changed prior to commit:
  https://reviews.llvm.org/D70547?vs=231057&id=231272#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70547

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/test/CodeGen/arm-mve-intrinsics/vandq.c
  clang/test/CodeGen/arm-mve-intrinsics/vbicq.c
  clang/test/CodeGen/arm-mve-intrinsics/veorq.c
  clang/test/CodeGen/arm-mve-intrinsics/vornq.c
  clang/test/CodeGen/arm-mve-intrinsics/vorrq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vandq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vbicq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/veorq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vornq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vorrq.ll
@@ -0,0 +1,104 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_u8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <16 x i8> %b, %a
+  ret <16 x i8> %0
+}
+
+define arm_aapcs_vfpcc <4 x i32> @test_vorrq_u32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_u32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <4 x i32> %b, %a
+  ret <4 x i32> %0
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = or <8 x i16> %b, %a
+  ret <8 x i16> %0
+}
+
+define arm_aapcs_vfpcc <4 x float> @test_vorrq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vorrq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vorr q0, q1, q0
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = or <4 x i32> %1, %0
+  %3 = bitcast <4 x i32> %2 to <4 x float>
+  ret <4 x float> %3
+}
+
+define arm_aapcs_vfpcc <16 x i8> @test_vorrq_m_s8(<16 x i8> %inactive, <16 x i8> %a, <16 x i8> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32 %0)
+  %2 = tail call <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8> %a, <16 x i8> %b, <16 x i1> %1, <16 x i8> %inactive)
+  ret <16 x i8> %2
+}
+
+declare <16 x i1> @llvm.arm.mve.pred.i2v.v16i1(i32) #2
+
+declare <16 x i8> @llvm.arm.mve.orr.predicated.v16i8.v16i1(<16 x i8>, <16 x i8>, <16 x i1>, <16 x i8>) #2
+
+define arm_aapcs_vfpcc <8 x i16> @test_vorrq_m_u16(<8 x i16> %inactive, <8 x i16> %a, <8 x i16> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_u16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16> %a, <8 x i16> %b, <8 x i1> %1, <8 x i16> %inactive)
+  ret <8 x i16> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x i16> @llvm.arm.mve.orr.predicated.v8i16.v8i1(<8 x i16>, <8 x i16>, <8 x i1>, <8 x i16>) #2
+
+; Function Attrs: nounwind readnone
+define arm_aapcs_vfpcc <8 x half> @test_vorrq_m_f32(<4 x float> %inactive, <4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #1 {
+; CHECK-LABEL: test_vorrq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vorrt q0, q1, q2
+; CHECK-NEXT:bx lr
+entry:
+  %0 = bitcast <4 x float> %a to <4 x i32>
+  %1 = bitcast <4 x float> %b to <4 x i32>
+  %2 = zext i16 %p to i32
+  %3 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %2)
+  %4 = bitcast <4 x float> %inactive to <4 x i32>
+  %5 = tail call <4 x i32> @llvm.arm.mve.orr.predicated.v4i32.v4i1(<4 x i32> %0, <4 x i32> %1, <4 x i1> %3, <4 x i32> %4)
+  %6 = bitcast <4 x

[PATCH] D70788: [Syntax] A tool to dump syntax tree and token buffer

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60223 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70788



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


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60223 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70787



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


[PATCH] D70787: [Syntax] Build SimpleDeclaration node that groups multiple declarators

2019-11-27 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 60223 tests passed, 0 failed and 732 were skipped.

Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70787



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


[clang] bcd0798 - [LifetimeAnalysis] Fix PR44150

2019-11-27 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-11-27T09:15:14-08:00
New Revision: bcd0798c47ca865f95226859893016a17402441e

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

LOG: [LifetimeAnalysis] Fix PR44150

References need somewhat special treatment. While copying a gsl::Pointer
will propagate the points-to set, creating an object from a reference
often behaves more like a dereference operation.

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

Added: 


Modified: 
clang/lib/Sema/SemaInit.cpp
clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 80d7cfed711a..7421754d95ca 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -6653,6 +6653,7 @@ struct IndirectLocalPathEntry {
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslReferenceInit,
 GslPointerInit
   } Kind;
   Expr *E;
@@ -6783,12 +6784,24 @@ static bool shouldTrackFirstArgument(const FunctionDecl 
*FD) {
 
 static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
 LocalVisitor Visit) {
-  auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
+  auto VisitPointerArg = [&](const Decl *D, Expr *Arg, bool Value) {
 // We are not interested in the temporary base objects of gsl Pointers:
 //   Temp().ptr; // Here ptr might not dangle.
 if (isa(Arg->IgnoreImpCasts()))
   return;
-Path.push_back({IndirectLocalPathEntry::GslPointerInit, Arg, D});
+// Once we initialized a value with a reference, it can no longer dangle.
+if (!Value) {
+  for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
+if (It->Kind == IndirectLocalPathEntry::GslReferenceInit)
+  continue;
+if (It->Kind == IndirectLocalPathEntry::GslPointerInit)
+  return;
+break;
+  }
+}
+Path.push_back({Value ? IndirectLocalPathEntry::GslPointerInit
+  : IndirectLocalPathEntry::GslReferenceInit,
+Arg, D});
 if (Arg->isGLValue())
   visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding,
 Visit,
@@ -6802,18 +6815,21 @@ static void handleGslAnnotatedTypes(IndirectLocalPath 
&Path, Expr *Call,
   if (auto *MCE = dyn_cast(Call)) {
 const auto *MD = cast_or_null(MCE->getDirectCallee());
 if (MD && shouldTrackImplicitObjectArg(MD))
-  VisitPointerArg(MD, MCE->getImplicitObjectArgument());
+  VisitPointerArg(MD, MCE->getImplicitObjectArgument(),
+  !MD->getReturnType()->isReferenceType());
 return;
   } else if (auto *OCE = dyn_cast(Call)) {
 FunctionDecl *Callee = OCE->getDirectCallee();
 if (Callee && Callee->isCXXInstanceMember() &&
 shouldTrackImplicitObjectArg(cast(Callee)))
-  VisitPointerArg(Callee, OCE->getArg(0));
+  VisitPointerArg(Callee, OCE->getArg(0),
+  !Callee->getReturnType()->isReferenceType());
 return;
   } else if (auto *CE = dyn_cast(Call)) {
 FunctionDecl *Callee = CE->getDirectCallee();
 if (Callee && shouldTrackFirstArgument(Callee))
-  VisitPointerArg(Callee, CE->getArg(0));
+  VisitPointerArg(Callee, CE->getArg(0),
+  !Callee->getReturnType()->isReferenceType());
 return;
   }
 
@@ -6821,7 +6837,7 @@ static void handleGslAnnotatedTypes(IndirectLocalPath 
&Path, Expr *Call,
 const auto *Ctor = CCE->getConstructor();
 const CXXRecordDecl *RD = Ctor->getParent();
 if (CCE->getNumArgs() > 0 && RD->hasAttr())
-  VisitPointerArg(Ctor->getParamDecl(0), CCE->getArgs()[0]);
+  VisitPointerArg(Ctor->getParamDecl(0), CCE->getArgs()[0], true);
   }
 }
 
@@ -7287,6 +7303,7 @@ static SourceRange nextPathEntryRange(const 
IndirectLocalPath &Path, unsigned I,
 case IndirectLocalPathEntry::AddressOf:
 case IndirectLocalPathEntry::LValToRVal:
 case IndirectLocalPathEntry::LifetimeBoundCall:
+case IndirectLocalPathEntry::GslReferenceInit:
 case IndirectLocalPathEntry::GslPointerInit:
   // These exist primarily to mark the path as not permitting or
   // supporting lifetime extension.
@@ -7309,7 +7326,8 @@ static bool 
pathOnlyInitializesGslPointer(IndirectLocalPath &Path) {
   continue;
 if (It->Kind == IndirectLocalPathEntry::AddressOf)
   continue;
-return It->Kind == IndirectLocalPathEntry::GslPointerInit;
+return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
+   It->Kind == IndirectLocalPathEntry::GslReferenceInit;
   }
   return false;
 }
@@ -7532,6 +7550,7 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 
   case IndirectLocalPathEntry::Lifetim

[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bader via Phabricator via cfe-commits
bader marked an inline comment as done.
bader added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

ABataev wrote:
> bader wrote:
> > ABataev wrote:
> > > Need to check if the decl must be emitted at all.
> > Let me check that I get it right. You suggest adding `if 
> > (MustBeEmitted(Global))`, right?
> > ```
> >   if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
> > MustBeEmitted(Global)) {
> > ...
> > addDeferredDeclToEmit(GD);
> > return;
> >   }
> > ```
> Yes
Okay. Making this change requires additional adjustments in the patch and I 
have a few options.
In this patch we do not add any logic forcing compiler to emit SYCL kernel. 
This logic is supposed to be added by follow-up patch (currently under SYCL 
working group review here https://github.com/intel/llvm/pull/249), which add 
code emitting "externally visible" OpenCL kernel calling function object passed 
to SYCL kernel function.

I can:
1) Temporally remove CodeGen test and add updated version back with the 
follow-up patch
2) Do change making SYCL kernels "externally visible" and revert this change 
with the follow-up patch (this is kind of current logic which emits SYCL 
kernels unconditionally)
3) Merge two patches and submit them together, but I assume it will 
significantly increase the size of the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70755: [LifetimeAnalysis] Fix PR44150

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbcd0798c47ca: [LifetimeAnalysis] Fix PR44150 (authored by 
xazax.hun).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70755

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ clang/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -450,3 +450,8 @@
 MyIntPointer handleDerivedToBaseCast2(MyOwnerIntPointer ptr) {
   return ptr; // expected-warning {{address of stack memory associated with parameter 'ptr' returned}}
 }
+
+std::vector::iterator noFalsePositiveWithVectorOfPointers() {
+  std::vector::iterator> iters;
+  return iters.at(0);
+}
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -6653,6 +6653,7 @@
 VarInit,
 LValToRVal,
 LifetimeBoundCall,
+GslReferenceInit,
 GslPointerInit
   } Kind;
   Expr *E;
@@ -6783,12 +6784,24 @@
 
 static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
 LocalVisitor Visit) {
-  auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
+  auto VisitPointerArg = [&](const Decl *D, Expr *Arg, bool Value) {
 // We are not interested in the temporary base objects of gsl Pointers:
 //   Temp().ptr; // Here ptr might not dangle.
 if (isa(Arg->IgnoreImpCasts()))
   return;
-Path.push_back({IndirectLocalPathEntry::GslPointerInit, Arg, D});
+// Once we initialized a value with a reference, it can no longer dangle.
+if (!Value) {
+  for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
+if (It->Kind == IndirectLocalPathEntry::GslReferenceInit)
+  continue;
+if (It->Kind == IndirectLocalPathEntry::GslPointerInit)
+  return;
+break;
+  }
+}
+Path.push_back({Value ? IndirectLocalPathEntry::GslPointerInit
+  : IndirectLocalPathEntry::GslReferenceInit,
+Arg, D});
 if (Arg->isGLValue())
   visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding,
 Visit,
@@ -6802,18 +6815,21 @@
   if (auto *MCE = dyn_cast(Call)) {
 const auto *MD = cast_or_null(MCE->getDirectCallee());
 if (MD && shouldTrackImplicitObjectArg(MD))
-  VisitPointerArg(MD, MCE->getImplicitObjectArgument());
+  VisitPointerArg(MD, MCE->getImplicitObjectArgument(),
+  !MD->getReturnType()->isReferenceType());
 return;
   } else if (auto *OCE = dyn_cast(Call)) {
 FunctionDecl *Callee = OCE->getDirectCallee();
 if (Callee && Callee->isCXXInstanceMember() &&
 shouldTrackImplicitObjectArg(cast(Callee)))
-  VisitPointerArg(Callee, OCE->getArg(0));
+  VisitPointerArg(Callee, OCE->getArg(0),
+  !Callee->getReturnType()->isReferenceType());
 return;
   } else if (auto *CE = dyn_cast(Call)) {
 FunctionDecl *Callee = CE->getDirectCallee();
 if (Callee && shouldTrackFirstArgument(Callee))
-  VisitPointerArg(Callee, CE->getArg(0));
+  VisitPointerArg(Callee, CE->getArg(0),
+  !Callee->getReturnType()->isReferenceType());
 return;
   }
 
@@ -6821,7 +6837,7 @@
 const auto *Ctor = CCE->getConstructor();
 const CXXRecordDecl *RD = Ctor->getParent();
 if (CCE->getNumArgs() > 0 && RD->hasAttr())
-  VisitPointerArg(Ctor->getParamDecl(0), CCE->getArgs()[0]);
+  VisitPointerArg(Ctor->getParamDecl(0), CCE->getArgs()[0], true);
   }
 }
 
@@ -7287,6 +7303,7 @@
 case IndirectLocalPathEntry::AddressOf:
 case IndirectLocalPathEntry::LValToRVal:
 case IndirectLocalPathEntry::LifetimeBoundCall:
+case IndirectLocalPathEntry::GslReferenceInit:
 case IndirectLocalPathEntry::GslPointerInit:
   // These exist primarily to mark the path as not permitting or
   // supporting lifetime extension.
@@ -7309,7 +7326,8 @@
   continue;
 if (It->Kind == IndirectLocalPathEntry::AddressOf)
   continue;
-return It->Kind == IndirectLocalPathEntry::GslPointerInit;
+return It->Kind == IndirectLocalPathEntry::GslPointerInit ||
+   It->Kind == IndirectLocalPathEntry::GslReferenceInit;
   }
   return false;
 }
@@ -7532,6 +7550,7 @@
 
   case IndirectLocalPathEntry::LifetimeBoundCall:
   case IndirectLocalPathEntry::GslPointerInit:
+  case IndirectLocalPathEntry::GslReferenceInit:
 // FIXME: Consider adding a note for these.
 break;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/

[PATCH] D70222: [clangd] Add support for .rsp files in compile_commands.json

2019-11-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:28
+  llvm::IntrusiveRefCntPtr FS)
+  : Base(std::move(Base)), Tokenizer(Tokenizer), FS(FS) {
+assert(this->Base != nullptr);

nit: `FS(std::move(FS))`



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:49
+  std::vector expand(std::vector Cmds) const {
+llvm::ErrorOr PreWorkingDirectory =
+FS->getCurrentWorkingDirectory();

no need to restore/save, `ExpandResponseFilesDatabase` should have a FS that's 
not shared with others.

it is iffy anyway, because if initial working directory is faulty, we'll mutate 
it to the working directory of the last compile command.
or even if it wasn't faulty, someone could delete the directory before we can 
restore, or someone can change it while we are in the middle of 
`ExpandResponseFile` calls.



Comment at: clang/lib/Tooling/ExpandResponseFilesCompilationDatabase.cpp:61
+continue;
+  if (FS->setCurrentWorkingDirectory(Cmd.Directory))
+continue;

maybe make this check at the beginning of the for loop?

could you also leave a fixme saying that we should rather propagate the current 
directory into `ExpandResponseFiles` as well in addition to `FS` and someone 
can take a look at it later on.
That would be more principled than relying on `ExpandResponseFilesDatabase` 
having its own non-shared copy of `FS`.



Comment at: clang/lib/Tooling/JSONCompilationDatabase.cpp:172
+  inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem(
 : nullptr;

let's change this one to `llvm::vfs::createPhysicalFileSystem` to make sure we 
are passing a non-shared FS. Unfortunately, `getRealFileSystem` is shared with 
the whole process.



Comment at: clang/unittests/Tooling/CompilationDatabaseTest.cpp:910
+TEST_F(ExpandResponseFilesTest, ExpandResponseFiles) {
+  // clang-format off
+  add("foo.cpp", "clang",

nit: instead of clang-format off maybe provide command as a raw string literal?



Comment at: clang/unittests/Tooling/CompilationDatabaseTest.cpp:912
+  add("foo.cpp", "clang",
+  ("@inner/rsp1.rsp @rsp2.rsp @rsp4.rsp "
+"@" + RspFileName1 + " @inner/rsp5.rsp @rsp6.rsp")

this test is checking the functionality of `ExpandFileCommands` helper, which 
is already tested in `llvm/unittests/Support/CommandLineTest.cpp`

it should be enough to have two simple tests:
- with a compile command that refers to a simple rsp file, and making sure it 
was expanded.
- with a regular compile command, making sure it stays the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70222



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


[PATCH] D70769: [Support] add vfs support for ExpandResponseFiles

2019-11-27 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: llvm/lib/Support/CommandLine.cpp:1053
+  llvm::ErrorOr CurrDir = FS.getCurrentWorkingDirectory();
+  if (!CurrDir)
+return false;

this comment has moved into a irrelevant line and wasn't addressed, so 
re-stating it here:

```
it is sad that, ExpandResponseFile returns a bool, but that's a battle for 
another day.

unfortunately, it is not enough return false in this case you need to consume 
the error with llvm::consumeError before exiting the scope.
```



Comment at: llvm/lib/Support/CommandLine.cpp:1148
+  llvm::ErrorOr RHS = FS.status(RFile.File);
+  if (!LHS || !RHS) {
+return false;

again you need to `consumeError`s before returning. I would first get `LHS`, 
consume and bail out if it was an error, then do the same for `RHS` and only 
after that return `equivalent`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70769



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

2019-11-27 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 231285.
svenvh added a comment.

Added test for references too.


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

https://reviews.llvm.org/D70605

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 &b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr(&d);
+  functionWithBaseArgRef(d);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,21 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4120,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, &BasePath, CCK)
  .get();
 break;
   }


Index: clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-derived-base.cl
@@ -69,3 +69,14 @@
   // CHECK: bitcast i8 addrspace(4)* %add.ptr1 to %class.B2 addrspace(4)*
   // CHECK: call {{.*}} @_ZNU3AS42B26getRefEv
 }
+
+// Implicit conversion of derived to base.
+
+void functionWithBaseArgPtr(class B2 *b) {}
+void functionWithBaseArgRef(class B2 &b) {}
+
+void pr43145_4() {
+  Derived d;
+  functionWithBaseArgPtr(&d);
+  functionWithBaseArgRef(d);
+}
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4095,9 +4095,21 @@
 << From->getSourceRange();
 }
 
+// Defer address space conversion to the third conversion.
+QualType FromPteeType = From->getType()->getPointeeType();
+QualType ToPteeType = ToType->getPointeeType();
+QualType NewToType = ToType;
+if (!FromPteeType.isNull() && !ToPteeType.isNull() &&
+FromPteeType.getAddressSpace() != ToPteeType.getAddressSpace()) {
+  NewToType = Context.removeAddrSpaceQualType(ToPteeType);
+  NewToType = Context.getAddrSpaceQualType(NewToType,
+   FromPteeType.getAddressSpace());
+  NewToType = Context.getPointerType(NewToType);
+}
+
 CastKind Kind;
 CXXCastPath BasePath;
-if (CheckPointerConversion(From, ToType, Kind, BasePath, CStyle))
+if (CheckPointerConversion(From, NewToType, Kind, BasePath, CStyle))
   return ExprError();
 
 // Make sure we extend blocks if necessary.
@@ -4108,8 +4120,8 @@
   From = E.get();
 }
 if (getLangOpts().allowsNonTrivialObjCLifetimeQualifiers())
-  CheckObjCConversion(SourceRange(), ToType, From, CCK);
-From = ImpCastExprToType(From, ToType, Kind, VK_RValue, &BasePath, CCK)
+  CheckObjCConversion(SourceRange(), NewToType, From, CCK);
+From = ImpCastExprToType(From, NewToType, Kind, VK_RValue, &BasePath, CCK)
  .get();
 break;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added reviewers: rnk, rjmccall, majnemer.

MSVC's type_trait header for the 16.3.* release in pre-c++17 mode
exposes explicitly specialized constexpr variables for _Is_integral,
is_void_v, and _Is_floating_point as not-inline (since that isn't
available in pre-C++17). The result is duplicate-symbols in any
program that includes  more than once.

This patch works around this issue by making fairly specific cases (in
the system header, in MSVC mode, and in pre-c++17 mode) be weak_odr
linkage rather than External linkage.


https://reviews.llvm.org/D70791

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
  clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp


Index: clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -std=c++14 -o - %s 
-isystem%S/Inputs | FileCheck %s
+#include 
+
+// CHECK: @"??$_Is_integral@_N@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$_Is_floating_point@M@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$is_void_v@X@@3_NB" = weak_odr dso_local constant
+
Index: clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
===
--- /dev/null
+++ clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
@@ -0,0 +1,17 @@
+template 
+constexpr bool _Is_integral = false;
+
+template <>
+constexpr bool _Is_integral = true;
+
+template 
+constexpr bool _Is_floating_point = false;
+
+template <>
+constexpr bool _Is_floating_point = true;
+
+template 
+constexpr bool is_void_v = false;
+
+template <>
+constexpr bool is_void_v = true;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9860,6 +9860,19 @@
   return L;
 }
 
+// The MSVC type_traits header defines a handful of type-trait constexpr
+// variables as non-inline in pre-C++17 mode which causes duplicate symbols.
+// In C++17 cases, they mark these as 'inline', which avoids this issue.
+// This fixup alters the linkage to be odr for this case.
+static bool isMSVCPreCxx17TypeTrait(const ASTContext &Context,
+const VarDecl *VD) {
+  assert(VD->getTemplateSpecializationKind() == TSK_ExplicitSpecialization &&
+ "Only valid for explicit specializations");
+  return VD->isConstexpr() && !VD->isInline() &&
+ !Context.getLangOpts().CPlusPlus17 &&
+ Context.getSourceManager().isInSystemHeader(VD->getLocation());
+}
+
 GVALinkage ASTContext::GetGVALinkageForFunction(const FunctionDecl *FD) const {
   return adjustGVALinkageForExternalDefinitionKind(*this, FD,
adjustGVALinkageForAttributes(*this, FD,
@@ -9926,7 +9939,8 @@
 
   case TSK_ExplicitSpecialization:
 return Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-   VD->isStaticDataMember()
+   (VD->isStaticDataMember() ||
+isMSVCPreCxx17TypeTrait(Context, VD))
? GVA_StrongODR
: StrongLinkage;
 


Index: clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/microsoft-type-traits-pre-cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -emit-llvm -triple=x86_64-pc-win32 -std=c++14 -o - %s -isystem%S/Inputs | FileCheck %s
+#include 
+
+// CHECK: @"??$_Is_integral@_N@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$_Is_floating_point@M@@3_NB" = weak_odr dso_local constant
+// CHECK: @"??$is_void_v@X@@3_NB" = weak_odr dso_local constant
+
Index: clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
===
--- /dev/null
+++ clang/test/CodeGenCXX/Inputs/ms-constexpr-typetraits.h
@@ -0,0 +1,17 @@
+template 
+constexpr bool _Is_integral = false;
+
+template <>
+constexpr bool _Is_integral = true;
+
+template 
+constexpr bool _Is_floating_point = false;
+
+template <>
+constexpr bool _Is_floating_point = true;
+
+template 
+constexpr bool is_void_v = false;
+
+template <>
+constexpr bool is_void_v = true;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9860,6 +9860,19 @@
   return L;
 }
 
+// The MSVC type_traits header defines a handful of type-trait constexpr
+// variables as non-inline in pre-C++17 mode which causes duplicate symbols.
+// In C++17 cases, they mark these as 'inline', which avoids this issue.
+// This fixup alters the linkage to be odr for this case.
+static bool isMSVCPreCxx17TypeTrait(const ASTContext &Context,
+   

[PATCH] D46027: [clang-tidy] Fix PR35824

2019-11-27 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth accepted this revision.
JonasToth added a comment.
This revision is now accepted and ready to land.

Maybe a short notice in the release notes wouldn't hurt. Otherwise LGTM

*EDIT*: Aaron commented as well. Plz let him react before committing :)


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

https://reviews.llvm.org/D46027



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


[PATCH] D70253: [AArch64][SVE2] Implement remaining SVE2 floating-point intrinsics

2019-11-27 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:898
+ llvm_i32_ty],
+[IntrNoMem]>;
+

sdesmalen wrote:
> I'd expect the `llvm_i32_ty` to be an immediate for these instructions, 
> right? If so you'll need to add `ImmArg`  to the list of properties.
> 
Thanks for taking a look at this :) I tried your suggestion of adding ImmAr 
to the list of properties here but had some problems with it (i.e. Cannot 
select: intrinsic %llvm.aarch64.sve.fmlalb.lane). I don't think this is too 
much of an issue here as we have additional checks on the immediate with 
VectorIndexH32b, which ensures the immediate is in the correct range.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70253



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


[PATCH] D46027: [clang-tidy] Fix PR35824

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Thanks!

Updated context for this patch:
A superior fix would be to follow through with the approach suggested by 
Richard in  https://reviews.llvm.org/D46234 . However, since I do not have time 
to finish that and there are people complaining in the PR, I think it is better 
to land this.


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

https://reviews.llvm.org/D46027



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


[PATCH] D49466: Initial implementation of -fmacro-prefix-map and -ffile-prefix-map

2019-11-27 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In D49466#1761156 , @MaskRay wrote:

> The ugly path separator pattern `{{(/|)}}` appears in 60+ tests. Can we 
> teach clang and other tools to
>
> 1. accept both `/` and `\` input


In general they do, AFAIK, although it's not feasible in cases where `/` is the 
character that introduces an option, which is common on standard Windows 
utilities.

> 2. but only output `/`
> 
>   on Windows?

This is often actually incorrect for Windows.

> We can probably remove llvm::sys::path::Style::{windows,posix,native} from 
> include/llvm/Support/Path.h and only keep the posix form.

It's highly unlikely that will be correct for all cases, and certainly will not 
match users' expectations.  Debug info, for example, will want normal Windows 
syntax file paths with `\`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D49466



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


[PATCH] D70693: [scan-build-py] Set of small fixes

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun marked an inline comment as done.
xazax.hun added inline comments.



Comment at: clang/tools/scan-build-py/libscanbuild/clang.py:47
 cmd.insert(1, '-###')
+cmd.append('-fno-color-diagnostics')
 

phosek wrote:
> Alternative would be to set `TERM=dumb` environment variable which disables 
> color support as well, but this also works.
Thanks! I'd love to have another solution, but it looks like the command line 
takes precedence over the environment variables and if `-fcolor-diagnostics` is 
specified in the command line it will always turn the colors on. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70693



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


[PATCH] D46027: [clang-tidy] Fix PR35824

2019-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

> This approach will also introduce false negatives.

Could you add a test showing this with a FIXME comment?

> A better approach would be to check if the null statement is the result of 
> folding an if constexpr.
>  The current AST API does not expose this information.
>  A better fix might require AST patches on the clang side.
>  The fix is proposed here: https://reviews.llvm.org/D46234



> Richard suggested to replace null stmts with nulls, but I have no time to 
> deal with all the fallouts for now. If someone is willing to pick that up 
> feel free to, but until then it might be a good idea to land this quick fix.

Could you add a FIXME comment to this effect?

Otherwise LG.


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

https://reviews.llvm.org/D46027



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


[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a subscriber: thakis.
rnk added a comment.

I thought we agreed to remove the workaround that we had for this and just 
declare that the old MSVC STL release was buggy and users should update:
https://bugs.llvm.org/show_bug.cgi?id=42027
It's a point release that preserves ABI compatibility, so there's less 
motivation for us to add a compat hack.

In general, we should seriously think about sunsetting some MS compat hacks 
that aren't needed for new SDK/STL versions to save on clang maintenance costs. 
The complexity they add is surprisingly expensive. For example, 
-fdelayed-template-parsing is a recurring source of compat issues in 
clang-tools-extra (see the commit logs), and I would like to revive D66394 
 to get it disabled by default soon. (+@thakis)


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

https://reviews.llvm.org/D70791



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


[PATCH] D70791: Workaround for MSVC 16.3.* pre-c++17 type trait linkage

2019-11-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D70791#1762081 , @rnk wrote:

> I thought we agreed to remove the workaround that we had for this and just 
> declare that the old MSVC STL release was buggy and users should update:
>  https://bugs.llvm.org/show_bug.cgi?id=42027
>  It's a point release that preserves ABI compatibility, so there's less 
> motivation for us to add a compat hack.
>
> In general, we should seriously think about sunsetting some MS compat hacks 
> that aren't needed for new SDK/STL versions to save on clang maintenance 
> costs. The complexity they add is surprisingly expensive. For example, 
> -fdelayed-template-parsing is a recurring source of compat issues in 
> clang-tools-extra (see the commit logs), and I would like to revive D66394 
>  to get it disabled by default soon. 
> (+@thakis)


Ah!  I KNEW I had seen this bug before.  I searched the bug database for a 
while for it.

I agree with sunsetting MS compat hacks as well, though I think we would need 
to support at least the most recentish versions.  My test team tells me that 
this failure isn't fixed until the (yet to be released) 16.4 version of the 
MSVC, so at the moment we don't compile the 'current' version without 
-std=c++17.  I don't see why r363191 was reverted, though I believe that this 
is both a less intrusive change, and is heavily specialized to only deal with 
this one case so hopefully it would not get reverted for the same reason.


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

https://reviews.llvm.org/D70791



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


[PATCH] D69938: [OpenCL] Use __generic addr space when generating internal representation of lambda

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



Comment at: clang/lib/Sema/SemaLambda.cpp:892
+if (AS != LangAS::Default)
+  EPI.TypeQuals.addAddressSpace(getDefaultCXXMethodAddrSpace());
+

This should just be `AS`.

Could you go ahead and change the other, existing places that should use this 
method?


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

https://reviews.llvm.org/D69938



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


[PATCH] D60455: [SYCL] Implement SYCL device code outlining

2019-11-27 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2477
 
+  if (LangOpts.SYCLIsDevice && Global->hasAttr()) {
+// SYCL kernels can be templated and not called from anywhere in the

bader wrote:
> ABataev wrote:
> > bader wrote:
> > > ABataev wrote:
> > > > Need to check if the decl must be emitted at all.
> > > Let me check that I get it right. You suggest adding `if 
> > > (MustBeEmitted(Global))`, right?
> > > ```
> > >   if (LangOpts.SYCLIsDevice && Global->hasAttr() && 
> > > MustBeEmitted(Global)) {
> > > ...
> > > addDeferredDeclToEmit(GD);
> > > return;
> > >   }
> > > ```
> > Yes
> Okay. Making this change requires additional adjustments in the patch and I 
> have a few options.
> In this patch we do not add any logic forcing compiler to emit SYCL kernel. 
> This logic is supposed to be added by follow-up patch (currently under SYCL 
> working group review here https://github.com/intel/llvm/pull/249), which add 
> code emitting "externally visible" OpenCL kernel calling function object 
> passed to SYCL kernel function.
> 
> I can:
> 1) Temporally remove CodeGen test and add updated version back with the 
> follow-up patch
> 2) Do change making SYCL kernels "externally visible" and revert this change 
> with the follow-up patch (this is kind of current logic which emits SYCL 
> kernels unconditionally)
> 3) Merge two patches and submit them together, but I assume it will 
> significantly increase the size of the patch.
Probably, better would be to split the patch


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60455



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


[PATCH] D70605: [OpenCL] Fix address space for implicit conversion (PR43145)

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



Comment at: clang/lib/Sema/SemaExprCXX.cpp:4108
+  NewToType = Context.getPointerType(NewToType);
+}
+

Hmm, sorry, just noticed this.  Could you write this so that it preserves the 
original kind of pointer of `ToType`?  I think it has to be a `PointerType`, 
`BlockPointerType,` or `ObjCObjectPointerType`.  It doesn't look like there's 
an existing utility for that.


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

https://reviews.llvm.org/D70605



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


[clang-tools-extra] 5c5e860 - [clang-tidy] Fix PR35824

2019-11-27 Thread Gabor Horvath via cfe-commits

Author: Gabor Horvath
Date: 2019-11-27T11:07:16-08:00
New Revision: 5c5e860535d8924a3d6eb950bb8a4945df01e9b7

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

LOG: [clang-tidy] Fix PR35824

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

Added: 

clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
index d94731beba94..9b34f5ab55a7 100644
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -20,7 +20,8 @@ namespace bugprone {
 void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   stmt(anyOf(ifStmt(hasThen(nullStmt().bind("semi")),
-unless(hasElse(stmt(,
+unless(hasElse(stmt())),
+unless(isConstexpr())),
  forStmt(hasBody(nullStmt().bind("semi"))),
  cxxForRangeStmt(hasBody(nullStmt().bind("semi"))),
  whileStmt(hasBody(nullStmt().bind("semi")

diff  --git 
a/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp 
b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
new file mode 100644
index ..c18dd7bd1e93
--- /dev/null
+++ 
b/clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17
+
+void fail()
+{
+  int x = 0;
+  if(x > 5); (void)x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended 
semicolon [bugprone-suspicious-semicolon]
+  // CHECK-FIXES: if(x > 5) (void)x;
+}
+
+template 
+int foo(int a) {
+if constexpr(X > 0) {
+return a;
+}
+return a + 1;
+}
+
+template 
+int foo2(int a) {
+// FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
+// for details.
+if constexpr(X > 0);
+return a;
+return a + 1;
+}
+
+int main(void) {
+foo2<0>(1);
+return foo<0>(1);
+}



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


[PATCH] D46234: Mark if a null statement is the result of constexpr folding

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.
Herald added subscribers: Charusso, gamesh411, Szelethus.
Herald added a project: clang.

Just a note for anyone willing to pick this up, PR32203 is also related.


Repository:
  rC Clang

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

https://reviews.llvm.org/D46234



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


[PATCH] D46027: [clang-tidy] Fix PR35824

2019-11-27 Thread Gábor Horváth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5c5e860535d8: [clang-tidy] Fix PR35824 (authored by 
xazax.hun).
Herald added a project: clang.

Changed prior to commit:
  https://reviews.llvm.org/D46027?vs=231078&id=231301#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D46027

Files:
  clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
  clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp


Index: 
clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17
+
+void fail()
+{
+  int x = 0;
+  if(x > 5); (void)x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended 
semicolon [bugprone-suspicious-semicolon]
+  // CHECK-FIXES: if(x > 5) (void)x;
+}
+
+template 
+int foo(int a) {
+if constexpr(X > 0) {
+return a;
+}
+return a + 1;
+}
+
+template 
+int foo2(int a) {
+// FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
+// for details.
+if constexpr(X > 0);
+return a;
+return a + 1;
+}
+
+int main(void) {
+foo2<0>(1);
+return foo<0>(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -20,7 +20,8 @@
 void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   stmt(anyOf(ifStmt(hasThen(nullStmt().bind("semi")),
-unless(hasElse(stmt(,
+unless(hasElse(stmt())),
+unless(isConstexpr())),
  forStmt(hasBody(nullStmt().bind("semi"))),
  cxxForRangeStmt(hasBody(nullStmt().bind("semi"))),
  whileStmt(hasBody(nullStmt().bind("semi")


Index: clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/bugprone-suspicious-semicolon-constexpr.cpp
@@ -0,0 +1,31 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-semicolon %t -- -- -std=c++17
+
+void fail()
+{
+  int x = 0;
+  if(x > 5); (void)x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: potentially unintended semicolon [bugprone-suspicious-semicolon]
+  // CHECK-FIXES: if(x > 5) (void)x;
+}
+
+template 
+int foo(int a) {
+if constexpr(X > 0) {
+return a;
+}
+return a + 1;
+}
+
+template 
+int foo2(int a) {
+// FIXME: diagnose the case below. See https://reviews.llvm.org/D46234
+// for details.
+if constexpr(X > 0);
+return a;
+return a + 1;
+}
+
+int main(void) {
+foo2<0>(1);
+return foo<0>(1);
+}
Index: clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/SuspiciousSemicolonCheck.cpp
@@ -20,7 +20,8 @@
 void SuspiciousSemicolonCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   stmt(anyOf(ifStmt(hasThen(nullStmt().bind("semi")),
-unless(hasElse(stmt(,
+unless(hasElse(stmt())),
+unless(isConstexpr())),
  forStmt(hasBody(nullStmt().bind("semi"))),
  cxxForRangeStmt(hasBody(nullStmt().bind("semi"))),
  whileStmt(hasBody(nullStmt().bind("semi")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69746: [analyzer] FixItHint: Apply and test hints with the Clang Tidy's script

2019-11-27 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added a comment.

In D69746#1756448 , @gribozavr2 wrote:

> The only way I know people apply fixits is with the help of IDEs.


This depends on the infrastructure available. Talking specifically about 
clang-tidy in our environment, I know of at least three other modes that are 
being frequently used:

- in a code review tool (allows to apply manually selected fixes one-by-one);
- in a code browsing tool (allows to apply manually selected fixes or all fixes 
of a certain category - e.g. from performance-related checks - to a file or 
directory);
- a script that applies pre-generated fixes to a set of files or all repository.

> I am also skeptical that people want to apply *all* fixits. Usually people 
> want to pick a few specific ones, or all fixits of a certain kind; but not 
> everything.

While "all fixits" may be not particularly useful, "apply all fixes enabled for 
my project" is a reasonable function when the project is generally kept in a 
clean shape.


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

https://reviews.llvm.org/D69746



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


  1   2   >