[PATCH] D44606: [analyzer] Fix the crash in `IteratorChecker.cpp` when `SymbolConjured` has a null Stmt.

2018-03-19 Thread Henry Wong via Phabricator via cfe-commits
MTC updated this revision to Diff 139075.
MTC added a comment.

Add the comments as suggested by @szepet .


Repository:
  rC Clang

https://reviews.llvm.org/D44606

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/loop-widening.c


Index: test/Analysis/loop-widening.c
===
--- test/Analysis/loop-widening.c
+++ test/Analysis/loop-widening.c
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 
-analyzer-config widen-loops=true -verify %s
+// RUN: %clang_analyze_cc1 -DTEST_NULL_TERM 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection,alpha.cplusplus.IteratorRange
 -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s
 
 void clang_analyzer_eval(int);
 void clang_analyzer_warnIfReached();
@@ -188,3 +189,16 @@
   }
   clang_analyzer_eval(i >= 2); // expected-warning {{TRUE}}
 }
+
+#ifdef TEST_NULL_TERM
+void null_terminator_loop_widen(int *a) {
+  int c;
+  // Loop widening will call 'invalidateRegions()' and 'invalidateRegions()'
+  // will construct the SymbolConjured with null Stmt because of the null
+  // terminator statement. Accessing the null Stmt will cause a crash.
+  for (;;) {
+c = *a; // no-crash
+a++;
+  }
+}
+#endif
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -604,7 +604,7 @@
   if (const auto *BSE = dyn_cast(SE)) {
 return BSE->getOpcode();
   } else if (const auto *SC = dyn_cast(SE)) {
-const auto *COE = dyn_cast(SC->getStmt());
+const auto *COE = dyn_cast_or_null(SC->getStmt());
 if (!COE)
   return BO_Comma; // Extremal value, neither EQ nor NE
 if (COE->getOperator() == OO_EqualEqual) {


Index: test/Analysis/loop-widening.c
===
--- test/Analysis/loop-widening.c
+++ test/Analysis/loop-widening.c
@@ -1,4 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s
+// RUN: %clang_analyze_cc1 -DTEST_NULL_TERM -analyzer-checker=core,unix.Malloc,debug.ExprInspection,alpha.cplusplus.IteratorRange -analyzer-max-loop 4 -analyzer-config widen-loops=true -verify %s
 
 void clang_analyzer_eval(int);
 void clang_analyzer_warnIfReached();
@@ -188,3 +189,16 @@
   }
   clang_analyzer_eval(i >= 2); // expected-warning {{TRUE}}
 }
+
+#ifdef TEST_NULL_TERM
+void null_terminator_loop_widen(int *a) {
+  int c;
+  // Loop widening will call 'invalidateRegions()' and 'invalidateRegions()'
+  // will construct the SymbolConjured with null Stmt because of the null
+  // terminator statement. Accessing the null Stmt will cause a crash.
+  for (;;) {
+c = *a; // no-crash
+a++;
+  }
+}
+#endif
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -604,7 +604,7 @@
   if (const auto *BSE = dyn_cast(SE)) {
 return BSE->getOpcode();
   } else if (const auto *SC = dyn_cast(SE)) {
-const auto *COE = dyn_cast(SC->getStmt());
+const auto *COE = dyn_cast_or_null(SC->getStmt());
 if (!COE)
   return BO_Comma; // Extremal value, neither EQ nor NE
 if (COE->getOperator() == OO_EqualEqual) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44671: [libcxx] Enable static libcxxabi linking on Darwin

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

I would imagine there was a reason this configuration was unsupported on macOS 
– perhaps something to do with libc++/libc++abi being the default system 
libraries on that platform?




Comment at: libcxx/CMakeLists.txt:330
 
 # Check that this option is not enabled on Apple and emit a usage warning.
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)

You should get rid of this comment.


Repository:
  rCXX libc++

https://reviews.llvm.org/D44671



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


[PATCH] D44673: Make positionToOffset return llvm::Expected

2018-03-19 Thread Simon Marchi via Phabricator via cfe-commits
simark created this revision.
Herald added subscribers: cfe-commits, ioeric, jkorous-apple, ilya-biryukov, 
klimek.
simark added a reviewer: ilya-biryukov.

To implement incremental document syncing, we want to verify that the
ranges provided by the front-end are valid.  Currently, positionToOffset
deals with invalid Positions by returning 0 or Code.size(), which are
two valid offsets.

Instead, return an llvm:Expected with an error if the position
is invalid.  According to the LSP, if the character value exceeds the
number of characters of the given line, it should default back to the
end of the line, so this is what I did.  However, I considered a line
number larger than the number of lines in the file to be an error.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44673

Files:
  clangd/ClangdServer.cpp
  clangd/SourceCode.cpp
  clangd/SourceCode.h
  unittests/clangd/Annotations.cpp
  unittests/clangd/SourceCodeTests.cpp

Index: unittests/clangd/SourceCodeTests.cpp
===
--- unittests/clangd/SourceCodeTests.cpp
+++ unittests/clangd/SourceCodeTests.cpp
@@ -8,6 +8,7 @@
 //===--===//
 #include "SourceCode.h"
 #include "llvm/Support/raw_os_ostream.h"
+#include "llvm/Support/Error.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 
@@ -31,32 +32,58 @@
   return Pos;
 }
 
+/// Return true if the return value of positionToOffset is equal to ExpectedOffset.
+bool positionToOffsetCheck(StringRef Code, Position P, size_t ExpectedOffset)
+{
+  llvm::Expected Result = positionToOffset(Code, P);
+  assert(Result);
+  return *Result == ExpectedOffset;
+}
+
+void ignoreError(llvm::Error Err) {
+  handleAllErrors(std::move(Err), [](const llvm::ErrorInfoBase &) {});
+}
+
+/// Return true if the call to positionToOffset generates an error.
+bool positionToOffsetFails(StringRef Code, Position P)
+{
+  llvm::Expected Result = positionToOffset(Code, P);
+
+  bool HasError = !Result;
+
+  if (HasError)
+ignoreError(Result.takeError());
+
+  return HasError;
+}
+
 TEST(SourceCodeTests, PositionToOffset) {
   // line out of bounds
-  EXPECT_EQ(0u, positionToOffset(File, position(-1, 2)));
+  EXPECT_TRUE(positionToOffsetFails(File, position(-1, 2)));
   // first line
-  EXPECT_EQ(0u, positionToOffset(File, position(0, -1))); // out of range
-  EXPECT_EQ(0u, positionToOffset(File, position(0, 0)));  // first character
-  EXPECT_EQ(3u, positionToOffset(File, position(0, 3)));  // middle character
-  EXPECT_EQ(6u, positionToOffset(File, position(0, 6)));  // last character
-  EXPECT_EQ(7u, positionToOffset(File, position(0, 7)));  // the newline itself
-  EXPECT_EQ(8u, positionToOffset(File, position(0, 8)));  // out of range
+  EXPECT_TRUE(positionToOffsetFails(File, position(0, -1))); // out of range
+  EXPECT_TRUE(positionToOffsetCheck(File, position(0, 0), 0));  // first character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(0, 3), 3));  // middle character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(0, 6), 6));  // last character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(0, 7), 7));  // the newline itself
+  EXPECT_TRUE(positionToOffsetCheck(File, position(0, 8), 7));  // out of range
   // middle line
-  EXPECT_EQ(8u, positionToOffset(File, position(1, -1))); // out of range
-  EXPECT_EQ(8u, positionToOffset(File, position(1, 0)));  // first character
-  EXPECT_EQ(11u, positionToOffset(File, position(1, 3))); // middle character
-  EXPECT_EQ(14u, positionToOffset(File, position(1, 6))); // last character
-  EXPECT_EQ(15u, positionToOffset(File, position(1, 7))); // the newline itself
-  EXPECT_EQ(16u, positionToOffset(File, position(1, 8))); // out of range
+  EXPECT_TRUE(positionToOffsetFails(File, position(1, -1))); // out of range
+  EXPECT_TRUE(positionToOffsetCheck(File, position(1, 0), 8));  // first character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(1, 3), 11)); // middle character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(1, 6), 14)); // last character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(1, 7), 15)); // the newline itself
+  EXPECT_TRUE(positionToOffsetCheck(File, position(1, 8), 15)); // out of range
   // last line
-  EXPECT_EQ(16u, positionToOffset(File, position(2, -1))); // out of range
-  EXPECT_EQ(16u, positionToOffset(File, position(2, 0)));  // first character
-  EXPECT_EQ(19u, positionToOffset(File, position(2, 3)));  // middle character
-  EXPECT_EQ(23u, positionToOffset(File, position(2, 7)));  // last character
-  EXPECT_EQ(24u, positionToOffset(File, position(2, 8)));  // EOF
-  EXPECT_EQ(24u, positionToOffset(File, position(2, 9)));  // out of range
+  EXPECT_TRUE(positionToOffsetFails(File, position(2, -1))); // out of range
+  EXPECT_TRUE(positionToOffsetCheck(File, position(2, 0), 16));  // first character
+  EXPECT_TRUE(positionToOffsetCheck(File, position(2, 3), 19));  // middle 

[PATCH] D44295: [clang-tidy] Detects and fixes calls to grand-...parent virtual methods instead of calls to parent's virtual methods

2018-03-19 Thread Zinovy Nis via Phabricator via cfe-commits
zinovy.nis added a comment.

Gentle ping)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44295



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


[PATCH] D44672: [CodeGen] Disable UBSan for coroutine functions

2018-03-19 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: GorNishanov, vsk, eric_niebler, lewissbaker.

As explained in http://lists.llvm.org/pipermail/llvm-dev/2018-March/121924.html,
the LLVM coroutines transforms are not yet able to move the
instructions for UBSan null checking past coroutine suspend boundaries.
For now, disable all UBSan checks when generating code for coroutines
functions.

I also considered an approach where only '-fsanitize=null' would be disabled,
However in practice this led to other LLVM errors when writing object files:
"Cannot represent a difference across sections". For now, disable all
UBSan checks until coroutine transforms are updated to handle them.

Test Plan:

1. check-clang
2. Compile the program in 
https://gist.github.com/modocache/54a036c3bf9c06882fe85122e105d153 using the 
'-fsanitize=null' option and confirm it does not crash during LLVM IR 
generation.


Repository:
  rC Clang

https://reviews.llvm.org/D44672

Files:
  lib/CodeGen/CodeGenFunction.cpp


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1298,6 +1298,14 @@
 
   Stmt *Body = FD->getBody();
 
+  // TODO: As mentioned in the TODO added in https://reviews.llvm.org/rL280678,
+  // coro-split is not capable of moving spills whose users' users are not
+  // dominated by 'llvm.coro.begin'. '-fsanitize=null', for example, generates
+  // such code: null checks that occur before 'llvm.coro.begin'. For now,
+  // disable UBSan checks within coroutine function bodies.
+  if (Body && Body->getStmtClass() == Stmt::CoroutineBodyStmtClass)
+SanOpts.clear();
+
   // Initialize helper which will detect jumps which can cause invalid lifetime
   // markers.
   if (Body && ShouldEmitLifetimeMarkers)


Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1298,6 +1298,14 @@
 
   Stmt *Body = FD->getBody();
 
+  // TODO: As mentioned in the TODO added in https://reviews.llvm.org/rL280678,
+  // coro-split is not capable of moving spills whose users' users are not
+  // dominated by 'llvm.coro.begin'. '-fsanitize=null', for example, generates
+  // such code: null checks that occur before 'llvm.coro.begin'. For now,
+  // disable UBSan checks within coroutine function bodies.
+  if (Body && Body->getStmtClass() == Stmt::CoroutineBodyStmtClass)
+SanOpts.clear();
+
   // Initialize helper which will detect jumps which can cause invalid lifetime
   // markers.
   if (Body && ShouldEmitLifetimeMarkers)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44671: [libcxx] Enable static libcxxabi linking on Darwin

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: EricWF, mclow.lists, compnerd, beanz.
Herald added subscribers: cfe-commits, christof, mgorny.

This seems to be working without any problems.


Repository:
  rCXX libc++

https://reviews.llvm.org/D44671

Files:
  libcxx/CMakeLists.txt


Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -329,11 +329,7 @@
 
 # Check that this option is not enabled on Apple and emit a usage warning.
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
-  if (APPLE)
-message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on 
OS X")
-  else()
-message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental 
option")
-  endif()
+  message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
   if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND)
 message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but 
it was not found.")
   endif()


Index: libcxx/CMakeLists.txt
===
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -329,11 +329,7 @@
 
 # Check that this option is not enabled on Apple and emit a usage warning.
 if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
-  if (APPLE)
-message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is not supported on OS X")
-  else()
-message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
-  endif()
+  message(WARNING "LIBCXX_ENABLE_STATIC_ABI_LIBRARY is an experimental option")
   if (LIBCXX_ENABLE_STATIC AND NOT PYTHONINTERP_FOUND)
 message(FATAL_ERROR "LIBCXX_ENABLE_STATIC_ABI_LIBRARY requires python but it was not found.")
   endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40775: [libcxx] Add underscores to win32 locale headers.

2018-03-19 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

We don't usually do this in source files, because they don't get included in 
people's builds - just the library build.

if you look in src/mutex.cpp, you'll see stuff like:
`void __call_once(volatile unsigned long& flag, void* arg, void(*func)(void*))`

On the other hand, if you are seeing a conflict, then we can apply this.


https://reviews.llvm.org/D40775



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


r327945 - Properly construct `inline` members without initializers

2018-03-19 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Mon Mar 19 20:27:44 2018
New Revision: 327945

URL: http://llvm.org/viewvc/llvm-project?rev=327945=rev
Log:
Properly construct `inline` members without initializers

Digging through commit logs, it appears the checks in this block predate
`inline` class variables. With them, we fail to emit dynamic
initializers for members that don't have an explicit initializer, and we
won't go out of our way to instantiate the class denoted by
`Var->getType()`.

Fixes PR35599.

Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-inline-variables.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=327945=327944=327945=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Mar 19 20:27:44 2018
@@ -4202,7 +4202,9 @@ void Sema::InstantiateVariableInitialize
   Var->setInvalidDecl();
 }
   } else {
-if (Var->isStaticDataMember()) {
+// `inline` variables are a definition and declaration all in one; we won't
+// pick up an initializer from anywhere else.
+if (Var->isStaticDataMember() && !Var->isInline()) {
   if (!Var->isOutOfLine())
 return;
 

Modified: cfe/trunk/test/CodeGenCXX/cxx1z-inline-variables.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1z-inline-variables.cpp?rev=327945=327944=327945=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx1z-inline-variables.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx1z-inline-variables.cpp Mon Mar 19 20:27:44 
2018
@@ -111,3 +111,29 @@ int e = d;
 // CHECK-NOT: __cxa_guard_acquire(i64* @_ZGV1b)
 // CHECK: call i32 @_Z1fv
 // CHECK-NOT: __cxa_guard_release(i64* @_ZGV1b)
+
+namespace PR35599 {
+struct Marker1 {};
+struct Marker2 {};
+
+template 
+struct Foo {
+  struct Bar { Bar(); };
+  inline static Bar bar;
+};
+
+void run() {
+  // All we want here are ODR uses. Anything that requires that the type is
+  // complete is uninteresting.
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wunused-value"
+  Foo::bar;
+#pragma clang diagnostic pop
+  static_cast(Foo::bar);
+}
+
+// CHECK-LABEL: define {{.*}}global_var_init{{.*}}comdat
+// CHECK: call void @_ZN7PR355993FooINS_7Marker1EE3BarC1Ev
+// CHECK-LABEL: define {{.*}}global_var_init{{.*}}comdat
+// CHECK: call void @_ZN7PR355993FooINS_7Marker2EE3BarC1Ev
+}


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


[PATCH] D44670: [CXX] Templates specialization visibility can be wrong

2018-03-19 Thread Steven Wu via Phabricator via cfe-commits
steven_wu created this revision.
steven_wu added reviewers: rsmith, arphaman.

Under some conditions, LinkageComputer can get the visibility for
ClassTemplateSpecializationDecl wrong because it failed to find the Decl
that has the explicit visibility.

This fixes:
llvm.org/bugs/pr36810
rdar://problem/38080953


Repository:
  rC Clang

https://reviews.llvm.org/D44670

Files:
  lib/AST/Decl.cpp
  test/CodeGenCXX/visibility-pr36810.cpp


Index: test/CodeGenCXX/visibility-pr36810.cpp
===
--- /dev/null
+++ test/CodeGenCXX/visibility-pr36810.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden 
-emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 
-fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1073,9 +1073,15 @@
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+for (const auto *RD :
+ spec->getSpecializedTemplate()->getTemplatedDecl()->redecls()) {
+  auto Vis = getVisibilityOf(RD, kind);
+  if (Vis != None)
+return Vis;
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {


Index: test/CodeGenCXX/visibility-pr36810.cpp
===
--- /dev/null
+++ test/CodeGenCXX/visibility-pr36810.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s
+
+namespace std {
+template 
+class __attribute__((__type_visibility__("default"))) shared_ptr {
+  template  friend class shared_ptr;
+};
+}
+struct dict;
+#ifndef UNDEF_G
+std::shared_ptr g;
+#endif
+class __attribute__((visibility("default"))) Bar;
+template >
+class __attribute__((visibility("default"))) i {
+  std::shared_ptr foo() const;
+};
+
+// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv
+template <> std::shared_ptr i<>::foo() const {
+  return std::shared_ptr();
+}
Index: lib/AST/Decl.cpp
===
--- lib/AST/Decl.cpp
+++ lib/AST/Decl.cpp
@@ -1073,9 +1073,15 @@
   // If there wasn't explicit visibility there, and this is a
   // specialization of a class template, check for visibility
   // on the pattern.
-  if (const auto *spec = dyn_cast(ND))
-return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(),
-   kind);
+  if (const auto *spec = dyn_cast(ND)) {
+for (const auto *RD :
+ spec->getSpecializedTemplate()->getTemplatedDecl()->redecls()) {
+  auto Vis = getVisibilityOf(RD, kind);
+  if (Vis != None)
+return Vis;
+}
+return None;
+  }
 
   // Use the most recent declaration.
   if (!IsMostRecent && !isa(ND)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44557: [analyzer] CStringChecker.cpp - Code refactoring on bug report.

2018-03-19 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

In https://reviews.llvm.org/D44557#1042357, @NoQ wrote:

> Sorry, one moment, i'm seeing a few regressions after the previous 
> refactoring but i didn't look at them closely yet to provide a reproducer. 
> I'll get back to this.


Thank you for the code review, @NoQ !

The regression is maybe caused by https://reviews.llvm.org/D44075, my patch! 
`CheckBufferAccess()` may not guarantee `checkNonNull()` will be called. If 
that's true, please revert https://reviews.llvm.org/rC326782 and I'll fix it.


Repository:
  rC Clang

https://reviews.llvm.org/D44557



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


[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-03-19 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327939: [CodeGen] Ignore OpaqueValueExprs that are unique 
references to their (authored by ahatanak, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D39562?vs=137418=139067#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39562

Files:
  cfe/trunk/include/clang/AST/Expr.h
  cfe/trunk/include/clang/AST/Stmt.h
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGExprAgg.cpp
  cfe/trunk/lib/CodeGen/CGExprComplex.cpp
  cfe/trunk/lib/CodeGen/CGExprScalar.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaPseudoObject.cpp
  cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
  cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
  cfe/trunk/test/CodeGenCXX/ms-property.cpp
  cfe/trunk/test/CodeGenObjC/objc-container-subscripting-1.m
  cfe/trunk/test/CodeGenObjCXX/property-dot-copy-elision.mm
  cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Index: cfe/trunk/include/clang/AST/Stmt.h
===
--- cfe/trunk/include/clang/AST/Stmt.h
+++ cfe/trunk/include/clang/AST/Stmt.h
@@ -237,6 +237,16 @@
 unsigned ResultIndex : 32 - 8 - NumExprBits;
   };
 
+  class OpaqueValueExprBitfields {
+friend class OpaqueValueExpr;
+
+unsigned : NumExprBits;
+
+/// The OVE is a unique semantic reference to its source expressio if this
+/// bit is set to true.
+unsigned IsUnique : 1;
+  };
+
   class ObjCIndirectCopyRestoreExprBitfields {
 friend class ObjCIndirectCopyRestoreExpr;
 
@@ -294,6 +304,7 @@
 CallExprBitfields CallExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 PseudoObjectExprBitfields PseudoObjectExprBits;
+OpaqueValueExprBitfields OpaqueValueExprBits;
 ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits;
 InitListExprBitfields InitListExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;
Index: cfe/trunk/include/clang/AST/Expr.h
===
--- cfe/trunk/include/clang/AST/Expr.h
+++ cfe/trunk/include/clang/AST/Expr.h
@@ -883,6 +883,7 @@
(SourceExpr && SourceExpr->isInstantiationDependent()),
false),
   SourceExpr(SourceExpr), Loc(Loc) {
+setIsUnique(false);
   }
 
   /// Given an expression which invokes a copy constructor --- i.e.  a
@@ -925,6 +926,14 @@
   /// place.
   Expr *getSourceExpr() const { return SourceExpr; }
 
+  void setIsUnique(bool V) {
+assert((!V || SourceExpr) &&
+   "unique OVEs are expected to have source expressions");
+OpaqueValueExprBits.IsUnique = V;
+  }
+
+  bool isUnique() const { return OpaqueValueExprBits.IsUnique; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OpaqueValueExprClass;
   }
Index: cfe/trunk/test/CodeGenCXX/ms-property.cpp
===
--- cfe/trunk/test/CodeGenCXX/ms-property.cpp
+++ cfe/trunk/test/CodeGenCXX/ms-property.cpp
@@ -75,11 +75,11 @@
   // CHECK: call void @"??$foo@H@@YAXHH@Z"(i32 %{{.+}}, i32 %{{.+}})
   foo(argc, (int)argv[0][0]);
   // CHECK: [[P2:%.+]] = load %class.St*, %class.St** %
-  // CHECK: [[T_X:%.+]] = call i32 @"?get_x@Test1@@QEBAHXZ"(%class.Test1* %{{.+}})
   // CHECK: [[P1:%.+]] = load %class.S*, %class.S** %
   // CHECK: [[P1_X_22_33:%.+]] = call i32 @"?GetX@S@@QEAAHHH@Z"(%class.S* [[P1]], i32 22, i32 33)
   // CHECK: [[CAST:%.+]] = sitofp i32 [[P1_X_22_33]] to double
   // CHECK: [[ARGC:%.+]] = load i32, i32* %
+  // CHECK: [[T_X:%.+]] = call i32 @"?get_x@Test1@@QEBAHXZ"(%class.Test1* %{{.+}})
   // CHECK: [[CAST2:%.+]] = trunc i32 [[T_X]] to i8
   // CHECK: call void @"?PutY@?$St@M@@QEAAXDHN@Z"(%class.St* [[P2]], i8 [[CAST2]], i32 [[ARGC]], double [[CAST]])
   p2->y[t.X][argc] =  p1->x[22][33];
Index: cfe/trunk/test/CodeGenObjC/objc-container-subscripting-1.m
===
--- cfe/trunk/test/CodeGenObjC/objc-container-subscripting-1.m
+++ cfe/trunk/test/CodeGenObjC/objc-container-subscripting-1.m
@@ -25,8 +25,8 @@
 // CHECK-NEXT: store i8* [[CALL]], i8** [[OLDOBJ:%.*]], align 8
 
   val = (array[10] = oldObject);
-// CHECK: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
-// CHECK-NEXT: [[FOUR:%.*]] = load i8*, i8** [[oldObject:%.*]], align 8
+// CHECK:  [[FOUR:%.*]] = load i8*, i8** [[oldObject:%.*]], align 8
+// CHECK-NEXT: [[THREE:%.*]] = load {{%.*}} [[array:%.*]], align 8
 // CHECK-NEXT: [[FIVE:%.*]] = load i8*, i8** @OBJC_SELECTOR_REFERENCES_.2
 // CHECK-NEXT: [[SIX:%.*]] = bitcast {{%.*}} [[THREE]] to i8*
 // CHECK-NEXT: call void bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to void (i8*, i8*, i8*, i32)*)(i8* [[SIX]], i8* [[FIVE]], i8* [[FOUR]], i32 10)
@@ -45,9 +45,9 @@
 
 
   val = (dictionary[key] = newObject);
-// CHECK: [[TWELVE:%.*]] = load {{%.*}} [[DICTIONARY]], align 8
+// 

r327939 - [CodeGen] Ignore OpaqueValueExprs that are unique references to their

2018-03-19 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Mar 19 18:47:58 2018
New Revision: 327939

URL: http://llvm.org/viewvc/llvm-project?rev=327939=rev
Log:
[CodeGen] Ignore OpaqueValueExprs that are unique references to their
source expressions when iterating over a PseudoObjectExpr's semantic
subexpression list.

Previously the loop in emitPseudoObjectExpr would emit the IR for each
OpaqueValueExpr that was in a PseudoObjectExpr's semantic-form
expression list and use the result when the OpaqueValueExpr later
appeared in other expressions. This caused an assertion failure when
AggExprEmitter tried to copy the result of an OpaqueValueExpr and the
copied type didn't have trivial copy/move constructors or assignment
operators.

This patch adds flag IsUnique to OpaqueValueExpr which indicates it is a
unique reference to its source expression (it is not used in multiple
places). The loop in emitPseudoObjectExpr ignores OpaqueValueExprs that
are unique and CodeGen visitors simply traverse the source expressions
of such OpaqueValueExprs.

rdar://problem/34363596

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

Added:
cfe/trunk/test/CodeGenObjCXX/property-dot-copy-elision.mm
Modified:
cfe/trunk/include/clang/AST/Expr.h
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGExprAgg.cpp
cfe/trunk/lib/CodeGen/CGExprComplex.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaPseudoObject.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp
cfe/trunk/lib/Serialization/ASTWriterStmt.cpp
cfe/trunk/test/CodeGenCXX/ms-property.cpp
cfe/trunk/test/CodeGenObjC/objc-container-subscripting-1.m
cfe/trunk/test/CodeGenObjCXX/property-objects.mm

Modified: cfe/trunk/include/clang/AST/Expr.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=327939=327938=327939=diff
==
--- cfe/trunk/include/clang/AST/Expr.h (original)
+++ cfe/trunk/include/clang/AST/Expr.h Mon Mar 19 18:47:58 2018
@@ -883,6 +883,7 @@ public:
(SourceExpr && SourceExpr->isInstantiationDependent()),
false),
   SourceExpr(SourceExpr), Loc(Loc) {
+setIsUnique(false);
   }
 
   /// Given an expression which invokes a copy constructor --- i.e.  a
@@ -925,6 +926,14 @@ public:
   /// place.
   Expr *getSourceExpr() const { return SourceExpr; }
 
+  void setIsUnique(bool V) {
+assert((!V || SourceExpr) &&
+   "unique OVEs are expected to have source expressions");
+OpaqueValueExprBits.IsUnique = V;
+  }
+
+  bool isUnique() const { return OpaqueValueExprBits.IsUnique; }
+
   static bool classof(const Stmt *T) {
 return T->getStmtClass() == OpaqueValueExprClass;
   }

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=327939=327938=327939=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Mon Mar 19 18:47:58 2018
@@ -237,6 +237,16 @@ protected:
 unsigned ResultIndex : 32 - 8 - NumExprBits;
   };
 
+  class OpaqueValueExprBitfields {
+friend class OpaqueValueExpr;
+
+unsigned : NumExprBits;
+
+/// The OVE is a unique semantic reference to its source expressio if this
+/// bit is set to true.
+unsigned IsUnique : 1;
+  };
+
   class ObjCIndirectCopyRestoreExprBitfields {
 friend class ObjCIndirectCopyRestoreExpr;
 
@@ -294,6 +304,7 @@ protected:
 CallExprBitfields CallExprBits;
 ExprWithCleanupsBitfields ExprWithCleanupsBits;
 PseudoObjectExprBitfields PseudoObjectExprBits;
+OpaqueValueExprBitfields OpaqueValueExprBits;
 ObjCIndirectCopyRestoreExprBitfields ObjCIndirectCopyRestoreExprBits;
 InitListExprBitfields InitListExprBits;
 TypeTraitExprBitfields TypeTraitExprBits;

Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=327939=327938=327939=diff
==
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Mar 19 18:47:58 2018
@@ -4167,7 +4167,35 @@ LValue CodeGenFunction::EmitCastLValue(c
 
 LValue CodeGenFunction::EmitOpaqueValueLValue(const OpaqueValueExpr *e) {
   assert(OpaqueValueMappingData::shouldBindAsLValue(e));
-  return getOpaqueLValueMapping(e);
+  return getOrCreateOpaqueLValueMapping(e);
+}
+
+LValue
+CodeGenFunction::getOrCreateOpaqueLValueMapping(const OpaqueValueExpr *e) {
+  assert(OpaqueValueMapping::shouldBindAsLValue(e));
+
+  llvm::DenseMap::iterator
+  it = OpaqueLValues.find(e);
+
+  if (it != OpaqueLValues.end())
+return it->second;
+
+  assert(e->isUnique() && "LValue for a nonunique OVE hasn't been emitted");
+  return 

[PATCH] D44606: [analyzer] Fix the crash in `IteratorChecker.cpp` when `SymbolConjured` has a null Stmt.

2018-03-19 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

> Just in case: we indeed do not guarantee that `SymbolConjured` corresponds to 
> a statement; it is, however, not intended, but rather a bug.

Thank you for your explanation and the reasonable example, NoQ.


Repository:
  rC Clang

https://reviews.llvm.org/D44606



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


[PATCH] D44606: [analyzer] Fix the crash in `IteratorChecker.cpp` when `SymbolConjured` has a null Stmt.

2018-03-19 Thread Henry Wong via Phabricator via cfe-commits
MTC added a comment.

> One small nit for future debugging people: Could you insert a comment line in 
> the test case where you explain what is this all about? E.g what you just 
> have written in the description: "invalidateRegions() will construct the 
> SymbolConjured with null Stmt" or something like this.

Thank you for pointing this out, and I'll add the comment.


Repository:
  rC Clang

https://reviews.llvm.org/D44606



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


r327935 - [analyzer] Improve performance of NoStoreFuncVisitor

2018-03-19 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Mar 19 18:16:46 2018
New Revision: 327935

URL: http://llvm.org/viewvc/llvm-project?rev=327935=rev
Log:
[analyzer] Improve performance of NoStoreFuncVisitor

Compute modifying frames lazily on demand.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp?rev=327935=327934=327935=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp Mon Mar 19 
18:16:46 2018
@@ -226,7 +226,6 @@ class NoStoreFuncVisitor final
   const SubRegion *RegionOfInterest;
   static constexpr const char *DiagnosticsMsg =
   "Returning without writing to '";
-  bool Initialized = false;
 
   /// Frames writing into \c RegionOfInterest.
   /// This visitor generates a note only if a function does not write into
@@ -234,10 +233,10 @@ class NoStoreFuncVisitor final
   /// by looking at the node associated with the exit from the function
   /// (usually the return statement). To avoid recomputing the same information
   /// many times (going up the path for each node and checking whether the
-  /// region was written into) we instead pre-compute and store all
-  /// stack frames along the path which write into the region of interest
-  /// on the first \c VisitNode invocation.
+  /// region was written into) we instead lazily compute the
+  /// stack frames along the path which write into the region of interest.
   llvm::SmallPtrSet FramesModifyingRegion;
+  llvm::SmallPtrSet FramesModifyingCalculated;
 
 public:
   NoStoreFuncVisitor(const SubRegion *R) : RegionOfInterest(R) {}
@@ -251,10 +250,6 @@ public:
  const ExplodedNode *PrevN,
  BugReporterContext ,
  BugReport ) override {
-if (!Initialized) {
-  findModifyingFrames(N);
-  Initialized = true;
-}
 
 const LocationContext *Ctx = N->getLocationContext();
 const StackFrameContext *SCtx = Ctx->getCurrentStackFrame();
@@ -262,7 +257,7 @@ public:
 auto CallExitLoc = N->getLocationAs();
 
 // No diagnostic if region was modified inside the frame.
-if (!CallExitLoc || FramesModifyingRegion.count(SCtx))
+if (!CallExitLoc)
   return nullptr;
 
 CallEventRef<> Call =
@@ -272,8 +267,9 @@ public:
 const SourceManager  = BRC.getSourceManager();
 if (const auto *CCall = dyn_cast(Call)) {
   const MemRegion *ThisRegion = CCall->getCXXThisVal().getAsRegion();
-  if (RegionOfInterest->isSubRegionOf(ThisRegion) &&
-  !CCall->getDecl()->isImplicit())
+  if (RegionOfInterest->isSubRegionOf(ThisRegion)
+  && !CCall->getDecl()->isImplicit()
+  && !isRegionOfInterestModifiedInFrame(N))
 return notModifiedInConstructorDiagnostics(Ctx, SM, PP, *CallExitLoc,
CCall, ThisRegion);
 }
@@ -285,10 +281,15 @@ public:
   unsigned IndirectionLevel = 1;
   QualType T = PVD->getType();
   while (const MemRegion *R = S.getAsRegion()) {
-if (RegionOfInterest->isSubRegionOf(R) &&
-!isPointerToConst(PVD->getType()))
+if (RegionOfInterest->isSubRegionOf(R)
+&& !isPointerToConst(PVD->getType())) {
+
+  if (isRegionOfInterestModifiedInFrame(N))
+return nullptr;
+
   return notModifiedDiagnostics(
   Ctx, SM, PP, *CallExitLoc, Call, PVD, R, IndirectionLevel);
+}
 QualType PT = T->getPointeeType();
 if (PT.isNull() || PT->isVoidType()) break;
 S = State->getSVal(R, PT);
@@ -301,18 +302,39 @@ public:
   }
 
 private:
+  /// Check and lazily calculate whether the region of interest is
+  /// modified in the stack frame to which \p N belongs.
+  /// The calculation is cached in FramesModifyingRegion.
+  bool isRegionOfInterestModifiedInFrame(const ExplodedNode *N) {
+const LocationContext *Ctx = N->getLocationContext();
+const StackFrameContext *SCtx = Ctx->getCurrentStackFrame();
+if (!FramesModifyingCalculated.count(SCtx))
+  findModifyingFrames(N);
+return FramesModifyingRegion.count(SCtx);
+  }
+
+
   /// Write to \c FramesModifyingRegion all stack frames along
-  /// the path which modify \c RegionOfInterest.
+  /// the path in the current stack frame which modify \c RegionOfInterest.
   void findModifyingFrames(const ExplodedNode *N) {
-ProgramStateRef LastReturnState;
+assert(N->getLocationAs());
+ProgramStateRef LastReturnState = N->getState();
+SVal ValueAtReturn = LastReturnState->getSVal(RegionOfInterest);
+const 

[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.

LGTM


https://reviews.llvm.org/D44655



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


[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327932: Allow builtins for Cross-DSO CFI on Android 
(authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44655?vs=139062=139063#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44655

Files:
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r327932 - Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Mon Mar 19 17:56:08 2018
New Revision: 327932

URL: http://llvm.org/viewvc/llvm-project?rev=327932=rev
Log:
Allow builtins for Cross-DSO CFI on Android

This is needed to avoid the test failure in case when compiler-rt
is set as the default runtime library for Clang.

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

Modified:
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/test/Driver/sanitizer-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/sanitizer-ld.c?rev=327932=327931=327932=diff
==
--- cfe/trunk/test/Driver/sanitizer-ld.c (original)
+++ cfe/trunk/test/Driver/sanitizer-ld.c Mon Mar 19 17:56:08 2018
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \


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


[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 139062.
phosek added a comment.

SGTM, I've made the test even more explicit.


https://reviews.llvm.org/D44655

Files:
  clang/test/Driver/sanitizer-ld.c


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.cfi
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Since the test is about cfi, not builtins, I think it's better to check for the 
cfi library explicitly.


Repository:
  rC Clang

https://reviews.llvm.org/D44655



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


[PATCH] D44663: [libcxx] Update with R9 changes

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

- change the uses of abi_for_size to simd_abi::deduce.
- remove the const in const_where_expression's template.


https://reviews.llvm.org/D44663

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/simd_abi_deduce.pass.cpp
  libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
@@ -43,25 +43,23 @@
 void compile_const_where() {
   {
 const native_simd a{};
-static_assert(
-std::is_same>::value,
-"");
+static_assert(std::is_same>::value,
+  "");
   }
   {
 const native_simd_mask a{};
 static_assert(
-std::is_same<
-decltype(where(a, a)),
-const_where_expression>::value,
+std::is_same>::value,
 "");
   }
   {
 const bool b = true;
 static_assert(std::is_same>::value,
+   const_where_expression>::value,
   "");
   }
 }
Index: libcxx/test/std/experimental/simd/simd.traits/simd_abi_deduce.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.traits/simd_abi_deduce.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.traits/simd_abi_deduce.pass.cpp
@@ -20,11 +20,12 @@
 
 using namespace std::experimental::parallelism_v2;
 
-static_assert(std::is_same::type,
+static_assert(std::is_same::type,
simd_abi::fixed_size<4>>::value,
   "");
 
 static_assert(
-std::is_same, simd_abi::fixed_size<4>>::value, "");
+std::is_same, simd_abi::fixed_size<4>>::value,
+"");
 
 int main() {}
Index: libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
@@ -26,11 +26,11 @@
 // const simd_mask&);
 //
 // template 
-// array / n, A>>, n> split_by(
+// array / n, A>>, n> split_by(
 // const simd& x);
 //
 // template 
-// array / n, A>>, n> split_by(
+// array / n, A>>, n> split_by(
 // const simd_mask& x);
 
 #include 
@@ -138,11 +138,11 @@
 
 void compile_split_simd_propagate_abi() {
   using compatible_simd_half =
-  simd>;
+  simd>;
   using native_simd_half =
-  simd>;
+  simd>;
 
   static_assert(
   std::is_same<
@@ -169,11 +169,11 @@
 
 void compile_split_simd_mask_propagate_abi() {
   using compatible_simd_mask_half =
-  simd_mask>;
+  simd_mask>;
   using native_simd_mask_half =
-  simd_mask

[PATCH] D44665: [libcxx] Update synopsis to P0214R9

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.
Herald added a reviewer: EricWF.

https://reviews.llvm.org/D44665

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/minmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/simd_abi_deduce.pass.cpp
  
libcxx/test/std/experimental/simd/simd.whereexpr/const_where_expression.pass.cpp
  libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
  libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
@@ -15,24 +15,23 @@
 // template 
 // class where_expression : public const_where_expression {
 // public:
-//   where_expression(const where_expression&) = delete;
-//   where_expression& operator=(const where_expression&) = delete;
-//   template  void operator=(U&& x);
-//   template  void operator+=(U&& x);
-//   template  void operator-=(U&& x);
-//   template  void operator*=(U&& x);
-//   template  void operator/=(U&& x);
-//   template  void operator%=(U&& x);
-//   template  void operator&=(U&& x);
-//   template  void operator|=(U&& x);
-//   template  void operator^=(U&& x);
-//   template  void operator<<=(U&& x);
-//   template  void operator>>=(U&& x);
-//   void operator++();
-//   void operator++(int);
-//   void operator--();
-//   void operator--(int);
-//   template  void copy_from(const U* mem, Flags);
+//  template  void operator=(U&& x) &&;
+//  template  void operator+=(U&& x) &&;
+//  template  void operator-=(U&& x) &&;
+//  template  void operator*=(U&& x) &&;
+//  template  void operator/=(U&& x) &&;
+//  template  void operator%=(U&& x) &&;
+//  template  void operator&=(U&& x) &&;
+//  template  void operator|=(U&& x) &&;
+//  template  void operator^=(U&& x) &&;
+//  template  void operator<<=(U&& x) &&;
+//  template  void operator>>=(U&& x) &&;
+//  void operator++() &&;
+//  void operator++(int) &&;
+//  void operator--() &&;
+//  void operator--(int) &&;
+//
+//  template  void copy_from(const U* mem, Flags) &&;
 // };
 
 #include 
Index: libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
@@ -17,21 +17,21 @@
 // where(const typename simd::mask_type&, simd&) noexcept;
 //
 // template 
-// const_where_expression, const simd>
+// const_where_expression, simd>
 // where(const typename simd::mask_type&, const simd&) noexcept;
 //
 // template 
 // where_expression, simd_mask>
 // where(const nodeduce_t>&, simd_mask&) noexcept;
 //
 // template 
-// const_where_expression, const simd_mask>
+// const_where_expression, simd_mask>
 // where(const nodeduce_t>&, const simd_mask&) noexcept;
 //
 // template  where_expression where(see below k, T& d) noexcept;
 //
 // template 
-// const_where_expression where(see below k, const T& d) noexcept;
+// const_where_expression where(see below k, const T& d) noexcept;
 
 #include 
 #include 
Index: libcxx/test/std/experimental/simd/simd.whereexpr/const_where_expression.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.whereexpr/const_where_expression.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.whereexpr/const_where_expression.pass.cpp
@@ -14,12 +14,17 @@
 // // [simd.whereexpr]
 // template 
 // class const_where_expression {
-//   const M& mask; // exposition only
+//   const M mask; // exposition only
 //   T& data; // exposition only
+//
 // public:
 //   const_where_expression(const const_where_expression&) = delete;
 //   const_where_expression& operator=(const const_where_expression&) = delete;
-//   remove_const_t operator-() const &&;
+//
+//   T 

[PATCH] D44660: [libcxx] unroll the loops in for Clang, until LLVM bugs are fixed

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

https://reviews.llvm.org/D44660

Files:
  libcxx/include/experimental/simd


Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -611,6 +611,13 @@
 #pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_COMPILER_CLANG)
+#define _LIBCPP_UNROLL
+#else
+// See LLVM PR/36359 for context of this workaround.
+#define _LIBCPP_UNROLL _Pragma("unroll")
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
 
 enum class _StorageKind {
@@ -2109,20 +2116,22 @@
 
 // algorithms [simd.alg]
 template 
-simd<_Tp, _Abi> min(const simd<_Tp, _Abi>& __a,
-const simd<_Tp, _Abi>& __b) noexcept {
+// Add `inline` keyword until LLVM PR/36495 is fixed
+inline simd<_Tp, _Abi> min(const simd<_Tp, _Abi>& __a,
+   const simd<_Tp, _Abi>& __b) noexcept {
   simd<_Tp, _Abi> __v;
-  for (size_t __i = 0; __i < __v.size(); __i++) {
+  _LIBCPP_UNROLL for (size_t __i = 0; __i < __v.size(); __i++) {
 __v[__i] = std::min(__a[__i], __b[__i]);
   }
   return __v;
 }
 
 template 
-simd<_Tp, _Abi> max(const simd<_Tp, _Abi>& __a,
-const simd<_Tp, _Abi>& __b) noexcept {
+// Add `inline` keyword until LLVM PR/36495 is fixed
+inline simd<_Tp, _Abi> max(const simd<_Tp, _Abi>& __a,
+   const simd<_Tp, _Abi>& __b) noexcept {
   simd<_Tp, _Abi> __v;
-  for (size_t __i = 0; __i < __v.size(); __i++) {
+  _LIBCPP_UNROLL for (size_t __i = 0; __i < __v.size(); __i++) {
 __v[__i] = std::max(__a[__i], __b[__i]);
   }
   return __v;
@@ -3060,4 +3069,6 @@
 
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
+#undef _LIBCPP_UNROLL
+
 #endif /* _LIBCPP_EXPERIMENTAL_SIMD */


Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -611,6 +611,13 @@
 #pragma GCC system_header
 #endif
 
+#if !defined(_LIBCPP_COMPILER_CLANG)
+#define _LIBCPP_UNROLL
+#else
+// See LLVM PR/36359 for context of this workaround.
+#define _LIBCPP_UNROLL _Pragma("unroll")
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL_SIMD
 
 enum class _StorageKind {
@@ -2109,20 +2116,22 @@
 
 // algorithms [simd.alg]
 template 
-simd<_Tp, _Abi> min(const simd<_Tp, _Abi>& __a,
-const simd<_Tp, _Abi>& __b) noexcept {
+// Add `inline` keyword until LLVM PR/36495 is fixed
+inline simd<_Tp, _Abi> min(const simd<_Tp, _Abi>& __a,
+   const simd<_Tp, _Abi>& __b) noexcept {
   simd<_Tp, _Abi> __v;
-  for (size_t __i = 0; __i < __v.size(); __i++) {
+  _LIBCPP_UNROLL for (size_t __i = 0; __i < __v.size(); __i++) {
 __v[__i] = std::min(__a[__i], __b[__i]);
   }
   return __v;
 }
 
 template 
-simd<_Tp, _Abi> max(const simd<_Tp, _Abi>& __a,
-const simd<_Tp, _Abi>& __b) noexcept {
+// Add `inline` keyword until LLVM PR/36495 is fixed
+inline simd<_Tp, _Abi> max(const simd<_Tp, _Abi>& __a,
+   const simd<_Tp, _Abi>& __b) noexcept {
   simd<_Tp, _Abi> __v;
-  for (size_t __i = 0; __i < __v.size(); __i++) {
+  _LIBCPP_UNROLL for (size_t __i = 0; __i < __v.size(); __i++) {
 __v[__i] = std::max(__a[__i], __b[__i]);
   }
   return __v;
@@ -3060,4 +3069,6 @@
 
 _LIBCPP_END_NAMESPACE_EXPERIMENTAL_SIMD
 
+#undef _LIBCPP_UNROLL
+
 #endif /* _LIBCPP_EXPERIMENTAL_SIMD */
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44664: [libcxx] Add missing __simd_reference pieces based on R9.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

https://reviews.llvm.org/D44664

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
@@ -76,6 +76,12 @@
   assert(bool(c[1]) == false);
 }
 
+{
+  auto c = a;
+  c[0] = b[0];
+  assert(bool(c[0]) == true);
+  assert(bool(c[1]) == false);
+}
 {
   auto c = a;
   c[0] += b[0];
@@ -136,6 +142,30 @@
   assert(bool(c[0]) == true);
   assert(bool(c[1]) == false);
 }
+{
+  auto aa = a, bb = b;
+  swap(aa[0], bb[0]);
+  assert(aa[0] == true);
+  assert(bb[0] == false);
+  assert(aa[1] == false);
+  assert(bb[1] == true);
+}
+{
+  auto c = a;
+  bool d = true;
+  swap(c[0], d);
+  assert(c[0] == true);
+  assert(d == false);
+  assert(c[1] == false);
+}
+{
+  auto c = a;
+  bool d = true;
+  swap(d, c[0]);
+  assert(c[0] == true);
+  assert(d == false);
+  assert(c[1] == false);
+}
 
 {
   auto c = a;
Index: libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
@@ -77,6 +77,12 @@
   assert(c[1] == 42);
 }
 
+{
+  auto c = a;
+  c[0] = b[0];
+  assert(c[0] == 4);
+  assert(c[1] == 42);
+}
 {
   auto c = a;
   c[0] += b[0];
@@ -137,7 +143,30 @@
   assert(c[0] == (42 ^ 4));
   assert(c[1] == 42);
 }
-
+{
+  auto aa = a, bb = b;
+  swap(aa[0], bb[0]);
+  assert(aa[0] == 4);
+  assert(bb[0] == 42);
+  assert(aa[1] == 42);
+  assert(bb[1] == 4);
+}
+{
+  auto c = a;
+  int d = 4;
+  swap(c[0], d);
+  assert(c[0] == 4);
+  assert(d == 42);
+  assert(c[1] == 42);
+}
+{
+  auto c = a;
+  int d = 4;
+  swap(d, c[0]);
+  assert(c[0] == 4);
+  assert(d == 42);
+  assert(c[1] == 42);
+}
 {
   auto c = a;
   (void)(a[0] + (c[0] += a[0]));
Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -1219,6 +1219,11 @@
 return *this;
   }
 
+  template 
+  __simd_reference operator=(__simd_reference<_Vp, _Up, _Abi>&& __ref) && {
+return std::move(*this) = _Vp(__ref);
+  }
+
   __simd_reference operator++() && {
 return std::move(*this) = __ptr_->__get(__index_) + 1;
   }
@@ -1288,6 +1293,22 @@
 return std::move(*this) =
__from_value_type(__ptr_->__get(__index_) ^ __val);
   }
+
+  friend void swap(__simd_reference&& a, __simd_reference&& b) noexcept {
+_Vp __val = std::move(b);
+std::move(b) = std::move(a);
+std::move(a) = __val;
+  }
+
+  friend void swap(_Vp& a, __simd_reference&& b) noexcept {
+swap(std::move(b), a);
+  }
+
+  friend void swap(__simd_reference&& a, _Vp& b) noexcept {
+_Vp __val = b;
+b = std::move(a);
+std::move(a) = __val;
+  }
 };
 
 template 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44659: [libcxx] Optimize -O0 performance for operators

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

When vector extension (__attribute__((vector_size(... is available
use its operators, instead of generating loops of scalar operations.


https://reviews.llvm.org/D44659

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
@@ -64,136 +64,138 @@
 
 using namespace std::experimental::parallelism_v2;
 
+template 
 void test_pure_operators() {
   {
-native_simd a(42), b(4);
+SimdType a(42), b(4);
 
-assert(all_of(~a == native_simd(~42)));
+assert(all_of(~a == SimdType(~42)));
 assert(all_of(+a == a));
-assert(all_of(-a == native_simd(-42)));
-assert(all_of(a + b == native_simd(42 + 4)));
-assert(all_of(a - b == native_simd(42 - 4)));
-assert(all_of(a * b == native_simd(42 * 4)));
-assert(all_of(a / b == native_simd(42 / 4)));
-assert(all_of(a % b == native_simd(42 % 4)));
-assert(all_of((a & b) == native_simd(42 & 4)));
-assert(all_of((a | b) == native_simd(42 | 4)));
-assert(all_of((a ^ b) == native_simd(42 ^ 4)));
-assert(all_of((a << b) == native_simd(42 << 4)));
-assert(all_of((a >> b) == native_simd(42 >> 4)));
-assert(all_of((a << 4) == native_simd(42 << 4)));
-assert(all_of((a >> 4) == native_simd(42 >> 4)));
+assert(all_of(-a == SimdType(-42)));
+assert(all_of(a + b == SimdType(42 + 4)));
+assert(all_of(a - b == SimdType(42 - 4)));
+assert(all_of(a * b == SimdType(42 * 4)));
+assert(all_of(a / b == SimdType(42 / 4)));
+assert(all_of(a % b == SimdType(42 % 4)));
+assert(all_of((a & b) == SimdType(42 & 4)));
+assert(all_of((a | b) == SimdType(42 | 4)));
+assert(all_of((a ^ b) == SimdType(42 ^ 4)));
+assert(all_of((a << b) == SimdType(42 << 4)));
+assert(all_of((a >> b) == SimdType(42 >> 4)));
+assert(all_of((a << 4) == SimdType(42 << 4)));
+assert(all_of((a >> 4) == SimdType(42 >> 4)));
   }
   {
-native_simd a([](int i) { return 2 * i + 1; }),
-b([](int i) { return i + 1; });
+SimdType a([](int i) { return 2 * i + 1; }), b([](int i) { return i + 1; });
 
-assert(all_of(~a == native_simd([](int i) { return ~(2 * i + 1); })));
+assert(all_of(~a == SimdType([](int i) { return ~(2 * i + 1); })));
 assert(all_of(+a == a));
-assert(all_of(-a == native_simd([](int i) { return -(2 * i + 1); })));
-assert(all_of(a + b == native_simd([](int i) { return 3 * i + 2; })));
-assert(all_of(a - b == native_simd([](int i) { return i; })));
-assert(all_of(a * b == native_simd(
-   [](int i) { return (2 * i + 1) * (i + 1); })));
-assert(all_of(a / b == native_simd(
-   [](int i) { return (2 * i + 1) / (i + 1); })));
-assert(all_of(a % b == native_simd(
-   [](int i) { return (2 * i + 1) % (i + 1); })));
-assert(all_of((a & b) == native_simd(
- [](int i) { return (2 * i + 1) & (i + 1); })));
-assert(all_of((a | b) == native_simd(
- [](int i) { return (2 * i + 1) | (i + 1); })));
-assert(all_of((a ^ b) == native_simd(
- [](int i) { return (2 * i + 1) ^ (i + 1); })));
+assert(all_of(-a == SimdType([](int i) { return -(2 * i + 1); })));
+assert(all_of(a + b == SimdType([](int i) { return 3 * i + 2; })));
+assert(all_of(a - b == SimdType([](int i) { return i; })));
+assert(
+all_of(a * b == SimdType([](int i) { return (2 * i + 1) * (i + 1); })));
+assert(
+all_of(a / b == SimdType([](int i) { return (2 * i + 1) / (i + 1); })));
+assert(
+all_of(a % b == SimdType([](int i) { return (2 * i + 1) % (i + 1); })));
+assert(all_of((a & b) ==
+  SimdType([](int i) { return (2 * i + 1) & (i + 1); })));
+assert(all_of((a | b) ==
+  SimdType([](int i) { return (2 * i + 1) | (i + 1); })));
+assert(all_of((a ^ b) ==
+  SimdType([](int i) { return (2 * i + 1) ^ (i + 1); })));
   }
 }
 
+template 
 void test_mutating_opreators() {
-  native_simd b(4);
+  SimdType b(4);
   {
-native_simd a(42);
-assert(all_of(++a == native_simd(43)));
-assert(all_of(a == native_simd(43)));
+SimdType a(42);
+assert(all_of(++a == SimdType(43)));
+assert(all_of(a == SimdType(43)));
   }
   {
-native_simd a(42);
-assert(all_of(a++ == native_simd(42)));
-assert(all_of(a == native_simd(43)));
+SimdType a(42);
+assert(all_of(a++ == SimdType(42)));
+

[PATCH] D44661: [libcxx] optimize reduce(), hmin(), hmax() by reordering the operations.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

Also change std::plus<_Tp> to std::plus<>/__simd_plus_op, so that the
optimization can transparently use the simd<> overloading.


https://reviews.llvm.org/D44661

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
@@ -38,52 +38,64 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 using namespace std::experimental::parallelism_v2;
 
 inline int factorial(int n) { return n == 1 ? 1 : n * factorial(n - 1); }
 
+template 
 void test_reduce_simd() {
-  int n = (int)native_simd::size();
-  assert(reduce(native_simd([](int i) { return i; })) == n * (n - 1) / 2);
-  assert(reduce(native_simd([](int i) { return i; }), std::plus()) ==
+  int n = (int)SimdType::size();
+  assert(reduce(SimdType([](int i) { return i; })) == n * (n - 1) / 2);
+
+#if TEST_STD_VER >= 14
+  assert(reduce(SimdType([](int i) { return i; }), std::plus<>()) ==
  n * (n - 1) / 2);
-  assert(reduce(native_simd([](int i) { return i + 1; }),
-std::multiplies()) == factorial(n));
+  assert(reduce(SimdType([](int i) { return i + 1; }), std::multiplies<>()) ==
+ factorial(n));
+#endif
 }
 
 void test_reduce_mask() {
   {
 fixed_size_simd a([](int i) { return i; });
-assert(reduce(where(a < 2, a), 0, std::plus()) == 0 + 1);
-assert(reduce(where(a >= 2, a), 1, std::multiplies()) == 2 * 3);
 assert(reduce(where(a >= 2, a)) == 2 + 3);
-assert(reduce(where(a >= 2, a), std::plus()) == 2 + 3);
-assert(reduce(where(a >= 2, a), std::multiplies()) == 2 * 3);
-assert(reduce(where(a >= 2, a), std::bit_and()) == (2 & 3));
-assert(reduce(where(a >= 2, a), std::bit_or()) == (2 | 3));
-assert(reduce(where(a >= 2, a), std::bit_xor()) == (2 ^ 3));
+#if TEST_STD_VER >= 14
+assert(reduce(where(a < 2, a), 0, std::plus<>()) == 0 + 1);
+assert(reduce(where(a >= 2, a), 1, std::multiplies<>()) == 2 * 3);
+assert(reduce(where(a >= 2, a), std::plus<>()) == 2 + 3);
+assert(reduce(where(a >= 2, a), std::multiplies<>()) == 2 * 3);
+assert(reduce(where(a >= 2, a), std::bit_and<>()) == (2 & 3));
+assert(reduce(where(a >= 2, a), std::bit_or<>()) == (2 | 3));
+assert(reduce(where(a >= 2, a), std::bit_xor<>()) == (2 ^ 3));
+#endif
   }
   {
 fixed_size_simd_mask a;
 a[0] = false;
 a[1] = true;
 a[2] = true;
 a[3] = false;
 assert(reduce(where(fixed_size_simd_mask(true), a)) == true);
+#if TEST_STD_VER >= 14
 assert(reduce(where(fixed_size_simd_mask(true), a),
-  std::plus()) == true);
+  std::plus<>()) == true);
 assert(reduce(where(fixed_size_simd_mask(true), a),
-  std::multiplies()) == false);
+  std::multiplies<>()) == false);
 assert(reduce(where(fixed_size_simd_mask(true), a),
-  std::bit_and()) == false);
+  std::bit_and<>()) == false);
 assert(reduce(where(fixed_size_simd_mask(true), a),
-  std::bit_or()) == true);
+  std::bit_or<>()) == true);
 assert(reduce(where(fixed_size_simd_mask(true), a),
-  std::bit_xor()) == false);
+  std::bit_xor<>()) == false);
+#endif
   }
 }
 
 int main() {
-  test_reduce_simd();
+  test_reduce_simd();
+  test_reduce_simd>();
+  test_reduce_simd>();
   test_reduce_mask();
 }
Index: libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
@@ -20,22 +20,47 @@
 
 using namespace std::experimental::parallelism_v2;
 
-void test_hmin_simd() {
+template 
+void test_hmin_simd_power_of_2() {
   {
 int a[] = {2, 5, -4, 6};
-assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+assert(hmin(SimdType(a, element_aligned_tag())) == -4);
   }
   {
 int a[] = {6, 2, 5, -4};
-assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+assert(hmin(SimdType(a, element_aligned_tag())) == -4);
   }
   {
 int a[] = {-4, 6, 2, 5};
-assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+assert(hmin(SimdType(a, element_aligned_tag())) == -4);
   }
 

[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

I was actually thinking about doing the same now, more specifically using 
`-rtlib=platform` which is already used elsewhere in this test. Do you prefer 
one or the other?


Repository:
  rC Clang

https://reviews.llvm.org/D44655



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


[PATCH] D44662: [libcxx] In , optimize masked div and rem.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

This optimization is allowed by the semantics, as users shouldn't pass
in values that may cause undefined behavior even those values are masked.


https://reviews.llvm.org/D44662

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp


Index: 
libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
@@ -123,15 +123,6 @@
 assert(a[2] == 3);
 assert(a[3] == 4);
   }
-  {
-fixed_size_simd a([](int i) { return i; });
-where(a % 2 == 1, a) /=
-fixed_size_simd([](int i) { return i % 2 * 2; });
-assert(a[0] == 0);
-assert(a[1] == 0);
-assert(a[2] == 2);
-assert(a[3] == 1);
-  }
   {
 fixed_size_simd a([](int i) { return 3 * i; });
 where(a >= 6, a) %= 2;
@@ -148,15 +139,6 @@
 assert(a[2] == 0);
 assert(a[3] == 1);
   }
-  {
-fixed_size_simd a([](int i) { return i; });
-where(a % 2 == 1, a) %=
-fixed_size_simd([](int i) { return i % 2 * 2; });
-assert(a[0] == 0);
-assert(a[1] == 1);
-assert(a[2] == 2);
-assert(a[3] == 1);
-  }
   {
 fixed_size_simd a([](int i) { return i; });
 where(a > -2, a) &= 1;
Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -2491,8 +2491,7 @@
   }
 
   // binary operators [simd.binary]
-  // TODO: regarding NOTE 9, the implementationn chooses not to SFINAE,
-  // but causes a hard error when the operator can't work on _Tp.
+  // TODO: currently the operators are not SFINAEed. Fix it.
   friend simd operator+(const simd& __a, const simd& __b) {
 return __from_storage(__simd_storage<_Tp, _Abi>::__add(__a.__s_, 
__b.__s_));
   }
@@ -2999,21 +2998,13 @@
   template 
   auto operator/=(_Up&& __u)
   -> decltype(this->__v_ / std::forward<_Up>(__u), void()) {
-this->__v_ =
-this->__v_ /
-__simd_mask_friend::__simd_select(
-_ValueType(1), _ValueType(std::forward<_Up>(__u)), this->__m_);
+*this = this->__v_ / std::forward<_Up>(__u);
   }
 
   template 
   auto operator%=(_Up&& __u)
   -> decltype(this->__v_ % std::forward<_Up>(__u), void()) {
-this->__v_ = __simd_mask_friend::__simd_select(
-this->__v_,
-this->__v_ %
-__simd_mask_friend::__simd_select(
-_ValueType(1), _ValueType(std::forward<_Up>(__u)), this->__m_),
-this->__m_);
+*this = this->__v_ % std::forward<_Up>(__u);
   }
 
   template 


Index: libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
@@ -123,15 +123,6 @@
 assert(a[2] == 3);
 assert(a[3] == 4);
   }
-  {
-fixed_size_simd a([](int i) { return i; });
-where(a % 2 == 1, a) /=
-fixed_size_simd([](int i) { return i % 2 * 2; });
-assert(a[0] == 0);
-assert(a[1] == 0);
-assert(a[2] == 2);
-assert(a[3] == 1);
-  }
   {
 fixed_size_simd a([](int i) { return 3 * i; });
 where(a >= 6, a) %= 2;
@@ -148,15 +139,6 @@
 assert(a[2] == 0);
 assert(a[3] == 1);
   }
-  {
-fixed_size_simd a([](int i) { return i; });
-where(a % 2 == 1, a) %=
-fixed_size_simd([](int i) { return i % 2 * 2; });
-assert(a[0] == 0);
-assert(a[1] == 1);
-assert(a[2] == 2);
-assert(a[3] == 1);
-  }
   {
 fixed_size_simd a([](int i) { return i; });
 where(a > -2, a) &= 1;
Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -2491,8 +2491,7 @@
   }
 
   // binary operators [simd.binary]
-  // TODO: regarding NOTE 9, the implementationn chooses not to SFINAE,
-  // but causes a hard error when the operator can't work on _Tp.
+  // TODO: currently the operators are not SFINAEed. Fix it.
   friend simd operator+(const simd& __a, const simd& __b) {
 return __from_storage(__simd_storage<_Tp, _Abi>::__add(__a.__s_, __b.__s_));
   }
@@ -2999,21 +2998,13 @@
   template 
   auto operator/=(_Up&& __u)
   -> decltype(this->__v_ / std::forward<_Up>(__u), void()) {
-this->__v_ =
-this->__v_ /
-__simd_mask_friend::__simd_select(
-_ValueType(1), 

[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

Indeed!
https://reviews.llvm.org/D44645


Repository:
  rC Clang

https://reviews.llvm.org/D44655



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


[PATCH] D44658: [libcxx] Implement aligned load and store when compiled with Clang.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.

Simply use __attribute__((align_value(...))).


https://reviews.llvm.org/D44658

Files:
  libcxx/include/experimental/simd

Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -1238,25 +1238,36 @@
   "Element type should be vectorizable");
 };
 
-template 
-struct memory_alignment;
+template 
+struct __memory_alignment_impl : std::integral_constant {
+};
 
-// TODO: May extend this after implementing vector_aligned.
 template 
-struct memory_alignment, _Up>
+struct __memory_alignment_impl, _Up, vector_aligned_tag>
 : std::integral_constant)> {};
 
-template 
-struct memory_alignment, bool>
-: std::integral_constant)> {};
+// TODO: Figure out a useful alignment based on simd_mask load and store
+// implementation. Currently, make sure that the buffer is suitable for aligned
+// SIMD load.
+template 
+struct __memory_alignment_impl, _Up, vector_aligned_tag>
+: std::integral_constant)> {};
+
+template 
+struct __memory_alignment_impl<_ValueType, _Up, overaligned_tag<__alignment>>
+: std::integral_constant {};
+
+template 
+struct memory_alignment
+: __memory_alignment_impl<_SimdType, _Up, vector_aligned_tag> {};
 
 #if _LIBCPP_STD_VER >= 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 template >
 _LIBCPP_INLINE_VAR constexpr size_t simd_size_v = simd_size<_Tp, _Abi>::value;
 
-template 
+template 
 _LIBCPP_INLINE_VAR constexpr size_t memory_alignment_v =
-memory_alignment<_Tp, _Up>::value;
+memory_alignment<_SimdType, _Up>::value;
 #endif
 
 // class template simd [simd.class]
@@ -1932,6 +1943,22 @@
 (void)__unused;
   }
 
+  template 
+  void __copy_from_impl(const _Up* __buffer
+__attribute__((align_value(__alignment {
+for (size_t __i = 0; __i < size(); __i++) {
+  (*this)[__i] = static_cast<_Tp>(__buffer[__i]);
+}
+  }
+
+  template 
+  void __copy_to_impl(_Up* __buffer
+  __attribute__((align_value(__alignment const {
+for (size_t __i = 0; __i < size(); __i++) {
+  __buffer[__i] = static_cast<_Up>((*this)[__i]);
+}
+  }
+
 public:
   // implicit type conversion constructor
   template ()>::type,
   class = typename std::enable_if::value>::type>
   simd(const _Up* __buffer, _Flags) {
-// TODO: optimize for overaligned flags
-for (size_t __i = 0; __i < size(); __i++) {
-  (*this)[__i] = static_cast<_Tp>(__buffer[__i]);
-}
+__copy_from_impl<__memory_alignment_impl::value>(
+__buffer);
   }
 
   // loads [simd.load]
@@ -2008,10 +2033,7 @@
   typename std::enable_if<__vectorizable<_Up>() &&
   is_simd_flag_type<_Flags>::value>::type
   copy_to(_Up* __buffer, _Flags) const {
-// TODO: optimize for overaligned flags
-for (size_t __i = 0; __i < size(); __i++) {
-  __buffer[__i] = static_cast<_Up>((*this)[__i]);
-}
+__copy_to_impl<__memory_alignment_impl::value>(__buffer);
   }
 
   // scalar access [simd.subscr]
@@ -2265,6 +2287,24 @@
 
   friend struct __simd_mask_friend;
 
+  // Use a non-member function, only because Clang 3.8 crashes with a member function.
+  template 
+  static void __copy_from_impl(simd_mask* __mask, const bool* __buffer
+   __attribute__((align_value(__alignment {
+for (size_t __i = 0; __i < size(); __i++) {
+  (*__mask)[__i] = __buffer[__i];
+}
+  }
+
+  // Use a non-member function, only because Clang 3.8 crashes with a member function.
+  template 
+  static void __copy_to_impl(const simd_mask* __mask, bool* __buffer
+ __attribute__((align_value(__alignment {
+for (size_t __i = 0; __i < size(); __i++) {
+  __buffer[__i] = (*__mask)[__i];
+}
+  }
+
 public:
   using value_type = bool;
   using reference = __simd_reference;
@@ -2300,10 +2340,8 @@
   template ::value>::type>
   simd_mask(const value_type* __buffer, _Flags) {
-// TODO: optimize for overaligned flags
-for (size_t __i = 0; __i < size(); __i++) {
-  (*this)[__i] = __buffer[__i];
-}
+__copy_from_impl<__memory_alignment_impl::value>(
+this, __buffer);
   }
 
   template 
@@ -2336,10 +2374,8 @@
   template 
   typename std::enable_if::value>::type
   copy_to(value_type* __buffer, _Flags) const {
-// TODO: optimize for overaligned flags
-for (size_t __i = 0; __i < size(); __i++) {
-

[PATCH] D44657: [libcxx] fix a sanitizer-reported bug in

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, sanjoy.
Herald added a reviewer: EricWF.
Herald added a reviewer: EricWF.

In __simd_reference, the conversion between bool and mask integer is
in wrong place.


https://reviews.llvm.org/D44657

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
@@ -159,11 +159,11 @@
 }
 {
   auto c = a;
-  (void)(a[0] + (c[0] >>= a[0]));
+  (void)(a[0] + (c[0] >>= b[0]));
 }
 {
   auto c = a;
-  (void)(a[0] + (c[0] <<= a[0]));
+  (void)(a[0] + (c[0] <<= b[0]));
 }
 {
   auto c = a;
Index: libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
@@ -160,11 +160,11 @@
 }
 {
   auto c = a;
-  (void)(a[0] + (c[0] >>= a[0]));
+  (void)(a[0] + (c[0] >>= b[0]));
 }
 {
   auto c = a;
-  (void)(a[0] + (c[0] <<= a[0]));
+  (void)(a[0] + (c[0] <<= b[0]));
 }
 {
   auto c = a;
Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -978,52 +978,52 @@
 
   __simd_reference operator+=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) + __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) + __val);
   }
 
   __simd_reference operator-=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) - __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) - __val);
   }
 
   __simd_reference operator*=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) * __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) * __val);
   }
 
   __simd_reference operator/=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) / __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) / __val);
   }
 
   __simd_reference operator%=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) % __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) % __val);
   }
 
   __simd_reference operator>>=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) >> __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) >> __val);
   }
 
   __simd_reference operator<<=(_Vp __val) && {
-return std::move(*this) = __ptr_->__get(__index_)
-  << __from_value_type(__val);
+return std::move(*this) =
+   __from_value_type(__ptr_->__get(__index_) << __val);
   }
 
   __simd_reference operator&=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) & __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) & __val);
   }
 
   __simd_reference operator|=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) | __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) | __val);
   }
 
   __simd_reference operator^=(_Vp __val) && {
 return std::move(*this) =
-   __ptr_->__get(__index_) ^ __from_value_type(__val);
+   __from_value_type(__ptr_->__get(__index_) ^ __val);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

That link seems to be pointing to this change?


Repository:
  rC Clang

https://reviews.llvm.org/D44655



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


[PATCH] D41843: [libcxx] implement where expressions.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139043.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41843

Files:
  libcxx/include/experimental/simd
  
libcxx/test/std/experimental/simd/simd.whereexpr/const_where_expression.pass.cpp
  libcxx/test/std/experimental/simd/simd.whereexpr/where.pass.cpp
  libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.whereexpr/where_expression.pass.cpp
@@ -0,0 +1,366 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// // [simd.whereexpr]
+// template 
+// class where_expression : public const_where_expression {
+// public:
+//   where_expression(const where_expression&) = delete;
+//   where_expression& operator=(const where_expression&) = delete;
+//   template  void operator=(U&& x);
+//   template  void operator+=(U&& x);
+//   template  void operator-=(U&& x);
+//   template  void operator*=(U&& x);
+//   template  void operator/=(U&& x);
+//   template  void operator%=(U&& x);
+//   template  void operator&=(U&& x);
+//   template  void operator|=(U&& x);
+//   template  void operator^=(U&& x);
+//   template  void operator<<=(U&& x);
+//   template  void operator>>=(U&& x);
+//   void operator++();
+//   void operator++(int);
+//   void operator--();
+//   void operator--(int);
+//   template  void copy_from(const U* mem, Flags);
+// };
+
+#include 
+#include 
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void test_operators_simd() {
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) = -1;
+assert(a[0] == -1);
+assert(a[1] == -1);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) = fixed_size_simd(-1);
+assert(a[0] == -1);
+assert(a[1] == -1);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) += -1;
+assert(a[0] == -1);
+assert(a[1] == 0);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) += fixed_size_simd(-1);
+assert(a[0] == -1);
+assert(a[1] == 0);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) -= -1;
+assert(a[0] == 1);
+assert(a[1] == 2);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) -= fixed_size_simd(-1);
+assert(a[0] == 1);
+assert(a[1] == 2);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) *= -1;
+assert(a[0] == 0);
+assert(a[1] == -1);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a < 2, a) *= fixed_size_simd(-1);
+assert(a[0] == 0);
+assert(a[1] == -1);
+assert(a[2] == 2);
+assert(a[3] == 3);
+  }
+  {
+fixed_size_simd a([](int i) { return 3 * i; });
+where(a >= 6, a) /= 2;
+assert(a[0] == 0);
+assert(a[1] == 3);
+assert(a[2] == 3);
+assert(a[3] == 4);
+  }
+  {
+fixed_size_simd a([](int i) { return 3 * i; });
+where(a >= 6, a) /= fixed_size_simd(2);
+assert(a[0] == 0);
+assert(a[1] == 3);
+assert(a[2] == 3);
+assert(a[3] == 4);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a % 2 == 1, a) /=
+fixed_size_simd([](int i) { return i % 2 * 2; });
+assert(a[0] == 0);
+assert(a[1] == 0);
+assert(a[2] == 2);
+assert(a[3] == 1);
+  }
+  {
+fixed_size_simd a([](int i) { return 3 * i; });
+where(a >= 6, a) %= 2;
+assert(a[0] == 0);
+assert(a[1] == 3);
+assert(a[2] == 0);
+assert(a[3] == 1);
+  }
+  {
+fixed_size_simd a([](int i) { return 3 * i; });
+where(a >= 6, a) %= fixed_size_simd(2);
+assert(a[0] == 0);
+assert(a[1] == 3);
+assert(a[2] == 0);
+assert(a[3] == 1);
+  }
+  {
+fixed_size_simd a([](int i) { return i; });
+where(a % 2 == 1, a) %=
+fixed_size_simd([](int i) { return i % 2 * 2; });
+assert(a[0] == 0);
+assert(a[1] == 

[PATCH] D41845: [libcxx] clean up and complete

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139045.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41845

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.cons/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.cons/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.mem/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.mem/store.pass.cpp
  libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/memory_alignment.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.traits/memory_alignment.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.traits/memory_alignment.pass.cpp
@@ -0,0 +1,67 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.traits]
+// template  struct memory_alignment;
+// template 
+// inline constexpr size_t memory_alignment_v = memory_alignment::value;
+
+#include 
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+static_assert(std::is_same>::value)>::value,
+  "");
+static_assert(
+std::is_same, int>::value)>::value,
+"");
+static_assert(
+std::is_same<
+const size_t,
+decltype(memory_alignment::value)>::value,
+"");
+static_assert(
+std::is_same>::value)>::value,
+"");
+static_assert(
+std::is_same,
+ bool>::value)>::value,
+"");
+
+#if TEST_STD_VER >= 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
+
+static_assert(
+std::is_same>)>::value,
+"");
+static_assert(std::is_same, int>)>::value,
+  "");
+static_assert(
+std::is_same, unsigned int>)>::value,
+"");
+static_assert(std::is_same>)>::value,
+  "");
+static_assert(
+std::is_same, bool>)>::value,
+"");
+
+#endif
+
+int main() {}
Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
@@ -67,8 +67,7 @@
 
 static_assert(!is_simd_mask::value, "");
 
-#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
-!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+#if TEST_STD_VER >= 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 
 static_assert(is_simd_mask_v, "");
 static_assert(is_simd_mask_v, "");
Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
@@ -26,8 +26,7 @@
 static_assert(is_simd_flag_type>::value, "");
 static_assert(is_simd_flag_type>::value, "");
 
-#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
-!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+#if TEST_STD_VER >= 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 
 static_assert(is_simd_flag_type_v, "");
 static_assert(is_simd_flag_type_v, "");
Index: libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
@@ -67,8 +67,7 @@
 
 static_assert(!is_simd::value, "");
 
-#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
-!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+#if TEST_STD_VER >= 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES)
 
 static_assert(is_simd_v, "");
 static_assert(is_simd_v, "");
Index: libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
+++ 

[PATCH] D44656: [libcxx] Add conversions between underlying non-portable types and simd/simd_mask types.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen created this revision.
timshen added a reviewer: mclow.lists.
Herald added subscribers: christof, kristof.beyls, sanjoy.
Herald added a reviewer: EricWF.

Currently x86, PowerPC, and ARM are supported.


https://reviews.llvm.org/D44656

Files:
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.abi/raw.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.abi/raw.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.abi/raw.pass.cpp
@@ -0,0 +1,122 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.abi]
+
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+template 
+void compile_raw() {
+  static_assert(std::is_same::value,
+"");
+  (void)SimdType(ExpectedRawType());
+  (void)static_cast(SimdType());
+}
+
+int main() {
+#if defined(__AVX__)
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+#elif defined(__SSE2__)
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+#elif defined(__ALTIVEC__) || defined(__VSX__)
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+#elif defined(__ARM_NEON)
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+  compile_raw();
+
+  compile_raw(native_simd())[0])>::type,
+  int8x8_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  int16x4_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  int32x2_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  int64x1_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  uint8x8_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  uint16x4_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  uint32x2_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  uint64x1_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  float32x2_t>();
+
+  compile_raw(native_simd())[0])>::type,
+  float64x1_t>();
+#endif
+}
Index: libcxx/include/experimental/simd
===
--- libcxx/include/experimental/simd
+++ libcxx/include/experimental/simd
@@ -596,6 +596,17 @@
 #include 
 #include 
 
+#if defined(_LIBCPP_MICROARCH_SSE2)
+#include 
+#if defined(_LIBCPP_MICROARCH_AVX)
+#include 
+#endif
+#elif defined(_LIBCPP_MICROARCH_ALTIVEC)
+#include 
+#elif defined(_LIBCPP_MICROARCH_NEON)
+#include 
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -680,59 +691,91 @@
 _TYPE __attribute__((vector_size(sizeof(_TYPE) * _NUM_ELEMENT)));  \
   }
 
-#define _SPECIALIZE_VEC_EXT_32(_TYPE)   

[PATCH] D41844: [libcxx] implement mask reductions

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139044.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41844

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
@@ -42,13 +42,48 @@
 
 inline int factorial(int n) { return n == 1 ? 1 : n * factorial(n - 1); }
 
-void test_reduce() {
+void test_reduce_simd() {
   int n = (int)native_simd::size();
   assert(reduce(native_simd([](int i) { return i; })) == n * (n - 1) / 2);
   assert(reduce(native_simd([](int i) { return i; }), std::plus()) ==
  n * (n - 1) / 2);
   assert(reduce(native_simd([](int i) { return i + 1; }),
 std::multiplies()) == factorial(n));
 }
 
-int main() { test_reduce(); }
+void test_reduce_mask() {
+  {
+fixed_size_simd a([](int i) { return i; });
+assert(reduce(where(a < 2, a), 0, std::plus()) == 0 + 1);
+assert(reduce(where(a >= 2, a), 1, std::multiplies()) == 2 * 3);
+assert(reduce(where(a >= 2, a)) == 2 + 3);
+assert(reduce(where(a >= 2, a), std::plus()) == 2 + 3);
+assert(reduce(where(a >= 2, a), std::multiplies()) == 2 * 3);
+assert(reduce(where(a >= 2, a), std::bit_and()) == (2 & 3));
+assert(reduce(where(a >= 2, a), std::bit_or()) == (2 | 3));
+assert(reduce(where(a >= 2, a), std::bit_xor()) == (2 ^ 3));
+  }
+  {
+fixed_size_simd_mask a;
+a[0] = false;
+a[1] = true;
+a[2] = true;
+a[3] = false;
+assert(reduce(where(fixed_size_simd_mask(true), a)) == true);
+assert(reduce(where(fixed_size_simd_mask(true), a),
+  std::plus()) == true);
+assert(reduce(where(fixed_size_simd_mask(true), a),
+  std::multiplies()) == false);
+assert(reduce(where(fixed_size_simd_mask(true), a),
+  std::bit_and()) == false);
+assert(reduce(where(fixed_size_simd_mask(true), a),
+  std::bit_or()) == true);
+assert(reduce(where(fixed_size_simd_mask(true), a),
+  std::bit_xor()) == false);
+  }
+}
+
+int main() {
+  test_reduce_simd();
+  test_reduce_mask();
+}
Index: libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
@@ -20,7 +20,7 @@
 
 using namespace std::experimental::parallelism_v2;
 
-void test_hmin() {
+void test_hmin_simd() {
   {
 int a[] = {2, 5, -4, 6};
 assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
@@ -39,4 +39,27 @@
   }
 }
 
-int main() { test_hmin(); }
+void test_hmin_mask() {
+  assert(hmin(where(native_simd_mask(false), native_simd())) ==
+ std::numeric_limits::max());
+  {
+int buffer[] = {2, 5, -4, 6};
+fixed_size_simd a(buffer, element_aligned_tag());
+assert(hmin(where(a >= -4, a)) == -4);
+assert(hmin(where(a > -4, a)) == 2);
+assert(hmin(where(a > 2, a)) == 5);
+assert(hmin(where(a > 5, a)) == 6);
+assert(hmin(where(a > 6, a)) == std::numeric_limits::max());
+  }
+  {
+bool buffer[] = {false, true, true, false};
+fixed_size_simd_mask a(buffer, element_aligned_tag());
+assert(hmin(where(fixed_size_simd_mask(true), a)) == false);
+assert(hmin(where(a, a)) == true);
+  }
+}
+
+int main() {
+  test_hmin_simd();
+  test_hmin_mask();
+}
Index: libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
@@ -20,7 +20,7 @@
 
 using namespace std::experimental::parallelism_v2;
 
-void test_hmax() {
+void test_hmax_simd() {
   {
 int a[] = {2, 5, -4, 6};
 assert(hmax(fixed_size_simd(a, element_aligned_tag())) == 6);
@@ -39,4 +39,34 @@
   }
 }
 
-int main() { test_hmax(); }
+void test_hmax_mask() {
+  assert(hmax(where(native_simd_mask(false), native_simd())) ==
+ std::numeric_limits::min());
+  {
+int buffer[] = {2, 5, -4, 6};
+fixed_size_simd a(buffer, element_aligned_tag());
+assert(hmax(where(a <= 6, a)) == 6);
+assert(hmax(where(a < 6, a)) == 5);
+assert(hmax(where(a < 5, a)) == 2);
+assert(hmax(where(a < 2, a)) == -4);
+assert(hmax(where(a < -4, a)) == std::numeric_limits::min());
+  }
+  {
+bool buffer[] = 

[PATCH] D41756: [libcxx] implement simd_mask<> casts and some horizontal operations.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139042.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41756

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/clamp.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/max.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/min.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/minmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/mask.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.elementwise/operators.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.mask.elementwise/operators.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.mask.elementwise/operators.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.mask.elementwise/operators.pass.cpp
@@ -50,6 +50,10 @@
 (simd_mask(false) ^ simd_mask(true;
   assert(all_of(simd_mask(false) ==
 (simd_mask(true) ^ simd_mask(true;
+  assert(all_of(!simd(0)));
+  assert(all_of(!simd(0) == simd_mask(true)));
+  assert(none_of(!simd(42)));
+  assert(all_of(!simd(42) == simd_mask(false)));
 }
 
 void test_mutating_opreators() {
Index: libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
===
--- libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
+++ libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
@@ -39,7 +39,7 @@
 
 using namespace std::experimental::parallelism_v2;
 
-void test_split() {
+void test_split_simd() {
   auto t = split<1, 2, 3>(fixed_size_simd([](int i) { return i; }));
   static_assert(std::tuple_size::value == 3, "");
 
@@ -56,7 +56,24 @@
   assert(std::get<2>(t)[2] == 5);
 }
 
-void test_split_array() {
+void test_split_mask() {
+  auto t = split<1, 2, 3>(fixed_size_simd_mask(true));
+  static_assert(std::tuple_size::value == 3, "");
+
+  assert(std::get<0>(t).size() == 1);
+  assert(std::get<0>(t)[0]);
+
+  assert(std::get<1>(t).size() == 2);
+  assert(std::get<1>(t)[0]);
+  assert(std::get<1>(t)[1]);
+
+  assert(std::get<2>(t).size() == 3);
+  assert(std::get<2>(t)[0]);
+  assert(std::get<2>(t)[1]);
+  assert(std::get<2>(t)[2]);
+}
+
+void test_split_array_simd() {
   {
 auto arr = split_by<2>(fixed_size_simd([](int i) { return i; }));
 static_assert(arr.size() == 2, "");
@@ -88,7 +105,38 @@
   }
 }
 
-void compile_split_propagate_abi() {
+void test_split_array_mask() {
+  {
+auto arr = split_by<2>(fixed_size_simd_mask(true));
+static_assert(arr.size() == 2, "");
+
+assert(arr[0].size() == 3);
+assert(arr[0][0]);
+assert(arr[0][1]);
+assert(arr[0][2]);
+
+assert(arr[1].size() == 3);
+assert(arr[1][0]);
+assert(arr[1][1]);
+assert(arr[1][2]);
+  }
+  {
+auto arr = split>(fixed_size_simd(true));
+static_assert(arr.size() == 2, "");
+
+assert(arr[0].size() == 3);
+assert(arr[0][0]);
+assert(arr[0][1]);
+assert(arr[0][2]);
+
+assert(arr[1].size() == 3);
+assert(arr[1][0]);
+assert(arr[1][1]);
+assert(arr[1][2]);
+  }
+}
+
+void compile_split_simd_propagate_abi() {
   using compatible_simd_half =
   simd>;
@@ -119,7 +167,41 @@
 "");
 }
 
+void compile_split_simd_mask_propagate_abi() {
+  using compatible_simd_mask_half =
+  simd_mask>;
+  using native_simd_mask_half =
+  simd_mask>;
+
+  static_assert(std::is_same(
+ simd_mask())),
+ std::tuple>::value,
+"");
+
+  static_assert(
+  std::is_same<
+  decltype(split(
+  native_simd_mask())),
+  std::tuple>::value,
+  "");
+
+  

[PATCH] D41422: [libcxx] implement operators and reduction.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139040.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41422

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.elementwise/clamp.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/max.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/min.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/minmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.horizontal/reduce.pass.cpp
@@ -0,0 +1,54 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// // reductions [simd.reductions]
+// template >
+// T reduce(const simd&, BinaryOperation = BinaryOperation());
+//
+// template 
+// typename V::value_type reduce(const const_where_expression& x,
+// typename V::value_type neutral_element, BinaryOperation binary_op);
+//
+// template 
+// typename V::value_type reduce(const const_where_expression& x, plus<> binary_op = plus<>());
+//
+// template 
+// typename V::value_type reduce(const const_where_expression& x, multiplies<> binary_op);
+//
+// template 
+// typename V::value_type reduce(const const_where_expression& x, bit_and<> binary_op);
+//
+// template 
+// typename V::value_type reduce(const const_where_expression& x, bit_or<> binary_op);
+//
+// template 
+// typename V::value_type reduce(const const_where_expression& x, bit_xor<> binary_op);
+
+#include 
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+inline int factorial(int n) { return n == 1 ? 1 : n * factorial(n - 1); }
+
+void test_reduce() {
+  int n = (int)native_simd::size();
+  assert(reduce(native_simd([](int i) { return i; })) == n * (n - 1) / 2);
+  assert(reduce(native_simd([](int i) { return i; }), std::plus()) ==
+ n * (n - 1) / 2);
+  assert(reduce(native_simd([](int i) { return i + 1; }),
+std::multiplies()) == factorial(n));
+}
+
+int main() { test_reduce(); }
Index: libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.horizontal/hmin.pass.cpp
@@ -0,0 +1,42 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// template  T hmin(const simd&);
+// template  T hmin(const const_where_expression&);
+
+#include 
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void test_hmin() {
+  {
+int a[] = {2, 5, -4, 6};
+assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+  }
+  {
+int a[] = {6, 2, 5, -4};
+assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+  }
+  {
+int a[] = {-4, 6, 2, 5};
+assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+  }
+  {
+int a[] = {5, -4, 6, 2};
+assert(hmin(fixed_size_simd(a, element_aligned_tag())) == -4);
+  }
+}
+
+int main() { test_hmin(); }
Index: libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.horizontal/hmax.pass.cpp
@@ -0,0 +1,42 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// template  T hmax(const simd&);
+// template  T hmax(const const_where_expression&);
+
+#include 
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void 

[PATCH] D41412: [libcxx] implement concat() and split()

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139038.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41412

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp
  libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.horizontal/split.pass.cpp
@@ -0,0 +1,125 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// template 
+// tuple...> split(const simd&);
+//
+// template 
+// tuple...> split(const simd_mask&);
+//
+// template 
+// array split(
+// const simd&);
+//
+// template 
+// array split(
+// const simd_mask&);
+//
+// template 
+// array / n, A>>, n> split_by(
+// const simd& x);
+//
+// template 
+// array / n, A>>, n> split_by(
+// const simd_mask& x);
+
+#include 
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void test_split() {
+  auto t = split<1, 2, 3>(fixed_size_simd([](int i) { return i; }));
+  static_assert(std::tuple_size::value == 3, "");
+
+  assert(std::get<0>(t).size() == 1);
+  assert(std::get<0>(t)[0] == 0);
+
+  assert(std::get<1>(t).size() == 2);
+  assert(std::get<1>(t)[0] == 1);
+  assert(std::get<1>(t)[1] == 2);
+
+  assert(std::get<2>(t).size() == 3);
+  assert(std::get<2>(t)[0] == 3);
+  assert(std::get<2>(t)[1] == 4);
+  assert(std::get<2>(t)[2] == 5);
+}
+
+void test_split_array() {
+  {
+auto arr = split_by<2>(fixed_size_simd([](int i) { return i; }));
+static_assert(arr.size() == 2, "");
+
+assert(arr[0].size() == 3);
+assert(arr[0][0] == 0);
+assert(arr[0][1] == 1);
+assert(arr[0][2] == 2);
+
+assert(arr[1].size() == 3);
+assert(arr[1][0] == 3);
+assert(arr[1][1] == 4);
+assert(arr[1][2] == 5);
+  }
+  {
+auto arr = split>(
+fixed_size_simd([](int i) { return i; }));
+static_assert(arr.size() == 2, "");
+
+assert(arr[0].size() == 3);
+assert(arr[0][0] == 0);
+assert(arr[0][1] == 1);
+assert(arr[0][2] == 2);
+
+assert(arr[1].size() == 3);
+assert(arr[1][0] == 3);
+assert(arr[1][1] == 4);
+assert(arr[1][2] == 5);
+  }
+}
+
+void compile_split_propagate_abi() {
+  using compatible_simd_half =
+  simd>;
+  using native_simd_half =
+  simd>;
+
+  static_assert(
+  std::is_same<
+  decltype(
+  split(simd())),
+  std::tuple>::value,
+  "");
+
+  static_assert(
+  std::is_same(native_simd())),
+   std::tuple>::value,
+  "");
+
+  static_assert(std::is_same(simd())),
+ std::array>::value,
+"");
+
+  static_assert(std::is_same(native_simd())),
+ std::array>::value,
+"");
+}
+
+int main() {
+  test_split();
+  test_split_array();
+}
Index: libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.horizontal/concat.pass.cpp
@@ -0,0 +1,97 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// template 
+// simd + ...)>>
+// concat(const simd&...);
+//
+// template 
+// simd, Abi>>
+// 

[PATCH] D41747: [libcxx] implement simd_mask<> and operators.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139041.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41747

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.elementwise/operators.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.access/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.cons/default.pass.cpp
  
libcxx/test/std/experimental/simd/simd.mask.cons/fixed_size_conversion.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.cons/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.elementwise/operators.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.mem/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mask.mem/store.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.mask.mem/store.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.mask.mem/store.pass.cpp
@@ -0,0 +1,82 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// loads [simd.mask.copy]
+// template  void copy_to(value_type* mem, Flags) const;
+
+#include 
+
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+void test_store() {
+  fixed_size_simd_mask a;
+  a[0] = false;
+  a[1] = true;
+  a[2] = true;
+  a[3] = false;
+  {
+alignas(32) bool buffer[4] = {0};
+a.copy_to(buffer, element_aligned_tag());
+assert(!buffer[0]);
+assert(buffer[1]);
+assert(buffer[2]);
+assert(!buffer[3]);
+  }
+  {
+alignas(32) bool buffer[4] = {0};
+a.copy_to(buffer, vector_aligned_tag());
+assert(!buffer[0]);
+assert(buffer[1]);
+assert(buffer[2]);
+assert(!buffer[3]);
+  }
+  {
+alignas(32) bool buffer[4] = {0};
+a.copy_to(buffer, overaligned_tag<32>());
+assert(!buffer[0]);
+assert(buffer[1]);
+assert(buffer[2]);
+assert(!buffer[3]);
+  }
+
+#if TEST_STD_VER > 14
+  {
+alignas(32) bool buffer[4] = {0};
+a.copy_to(buffer, element_aligned);
+assert(!buffer[0]);
+assert(buffer[1]);
+assert(buffer[2]);
+assert(!buffer[3]);
+  }
+  {
+alignas(32) bool buffer[4] = {0};
+a.copy_to(buffer, vector_aligned);
+assert(!buffer[0]);
+assert(buffer[1]);
+assert(buffer[2]);
+assert(!buffer[3]);
+  }
+  {
+alignas(32) bool buffer[4] = {0};
+a.copy_to(buffer, overaligned<32>);
+assert(!buffer[0]);
+assert(buffer[1]);
+assert(buffer[2]);
+assert(!buffer[3]);
+  }
+#endif
+}
+
+int main() { test_store(); }
Index: libcxx/test/std/experimental/simd/simd.mask.mem/load.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.mask.mem/load.pass.cpp
@@ -0,0 +1,105 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// loads [simd.mask.copy]
+// template  void copy_from(const value_type* mem, Flags);
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+template 
+auto not_supported_load(Args&&... args) -> decltype(
+std::declval().copy_from(std::forward(args)...),
+void()) = delete;
+
+template 
+void not_supported_load(...) {}
+
+template 
+auto supported_load(Args&&... args) -> decltype(
+std::declval().copy_from(std::forward(args)...),
+void()) {}
+
+template 
+void supported_load(...) = delete;
+
+void compile_load() {
+  supported_load((bool*)nullptr, element_aligned_tag());
+  supported_load((bool*)nullptr, element_aligned_tag());
+  supported_load((bool*)nullptr, element_aligned_tag());
+  supported_load((bool*)nullptr, element_aligned_tag());
+  supported_load((bool*)nullptr, element_aligned_tag());
+
+  not_supported_load((bool*)nullptr, int());
+}
+
+void test_load() {
+  alignas(32) bool buffer[] = {false, true, true, false};
+  {
+fixed_size_simd_mask a;
+a.copy_from(buffer, element_aligned_tag());
+assert(!a[0]);
+assert(a[1]);
+assert(a[2]);
+assert(!a[3]);
+  }
+  {
+fixed_size_simd_mask a;
+a.copy_from(buffer, vector_aligned_tag());
+assert(!a[0]);
+assert(a[1]);
+

[PATCH] D41415: [libcxx] implement casts.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139039.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41415

Files:
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.casts/to_native.pass.cpp
@@ -0,0 +1,56 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.casts]
+//
+// template 
+// native_simd to_native(const fixed_size_simd&) noexcept;
+//
+// template 
+// native_simd_mask to_native(const fixed_size_simd_mask&) noexcept;
+
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void test_to_native() {
+  auto v = to_native(
+  fixed_size_simd([](int i) { return i; }));
+  native_simd w([](int i) { return i; });
+
+  static_assert(std::is_same::value, "");
+
+  for (size_t i = 0; i < v.size(); i++) {
+assert(v[i] == w[i]);
+  }
+}
+
+void test_to_native_extension() {
+  auto arr = split_by<32 / native_simd::size()>(
+  to_native(fixed_size_simd([](int i) { return i; })));
+  static_assert(
+  std::is_same::value, "");
+  int v = 0;
+  for (size_t i = 0; i < arr.size(); i++) {
+for (size_t j = 0; j < arr[0].size(); j++) {
+  assert(arr[i][j] == v);
+  v++;
+}
+  }
+}
+
+int main() {
+  test_to_native();
+  test_to_native_extension();
+}
Index: libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.casts/to_fixed_size.pass.cpp
@@ -0,0 +1,40 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.casts]
+//
+// template 
+// fixed_size_simd>
+// to_fixed_size(const simd&) noexcept;
+//
+// template 
+// fixed_size_simd_mask>
+// to_fixed_size(const simd_mask&) noexcept;
+
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void test_to_fixed_size() {
+  auto v = to_fixed_size(native_simd([](int i) { return i; }));
+  static_assert(std::is_same,
+ decltype(v)>::value,
+"");
+
+  for (size_t i = 0; i < v.size(); i++) {
+assert(v[i] == (int)i);
+  }
+}
+
+int main() { test_to_fixed_size(); }
Index: libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.casts/to_compatible.pass.cpp
@@ -0,0 +1,55 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.casts]
+//
+// template  simd
+// to_compatible(const fixed_size_simd&) noexcept;
+//
+// template  simd_mask
+// to_compatible(const fixed_size_simd_mask&) noexcept;
+
+#include 
+#include 
+
+using namespace std::experimental::parallelism_v2;
+
+void test_to_compatible() {
+  auto v = to_compatible(
+  fixed_size_simd([](int i) { return i; }));
+  simd w([](int i) { return i; });
+
+  static_assert(std::is_same::value, "");
+
+  for (size_t i = 0; i < v.size(); i++) {
+assert(v[i] == w[i]);
+  }
+}
+
+void test_to_compatible_extension() {
+  auto arr = split_by<32 / simd::size()>(
+  to_compatible(fixed_size_simd([](int i) { return i; 

[PATCH] D41376: [libcxx] Implement ABI for Clang/GCC vector extension, constructors, copy_from and copy_to.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139037.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41376

Files:
  libcxx/include/__config
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/include/utility
  libcxx/test/std/experimental/simd/simd.abi/vector_extension.pass.cpp
  libcxx/test/std/experimental/simd/simd.access/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/default.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/geneartor.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
  libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.mem/store.pass.cpp
@@ -0,0 +1,92 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// // stores [simd.store]
+// template  void copy_to(U* mem, Flags f) const;
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+void test_store() {
+  fixed_size_simd a([](int i) { return 4 - i; });
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, element_aligned_tag());
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, vector_aligned_tag());
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, overaligned_tag<32>());
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+
+#if TEST_STD_VER > 14
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, element_aligned);
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, vector_aligned);
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+  {
+alignas(32) int32_t buffer[4] = {0};
+a.copy_to(buffer, overaligned<32>);
+assert(buffer[0] == 4);
+assert(buffer[1] == 3);
+assert(buffer[2] == 2);
+assert(buffer[3] == 1);
+  }
+#endif
+}
+
+void test_converting_store() {
+  float buffer[4] = {0.};
+  fixed_size_simd a([](int i) { return 1 << i; });
+  a.copy_to(buffer, element_aligned_tag());
+  assert(buffer[0] == 1.);
+  assert(buffer[1] == 2.);
+  assert(buffer[2] == 4.);
+  assert(buffer[3] == 8.);
+}
+
+int main() {
+  test_store();
+  test_converting_store();
+}
Index: libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.mem/load.pass.cpp
@@ -0,0 +1,118 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// loads [simd.load]
+// template  void copy_from(const U* mem, Flags f);
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+template 
+auto not_supported_load(Args&&... args) -> decltype(
+std::declval().copy_from(std::forward(args)...),
+void()) = delete;
+
+template 
+void not_supported_load(...) {}
+
+template 
+auto supported_load(Args&&... args) -> decltype(
+std::declval().copy_from(std::forward(args)...),
+void()) {}
+
+template 
+void supported_load(...) = delete;
+
+void compile_load() {
+  supported_load((int*)nullptr, element_aligned_tag());
+  supported_load((int*)nullptr, element_aligned_tag());
+  supported_load((float*)nullptr, element_aligned_tag());
+  supported_load((unsigned int*)nullptr, element_aligned_tag());
+  supported_load((float*)nullptr, element_aligned_tag());
+
+  not_supported_load((int*)nullptr, int());

[PATCH] D41148: [libcxx] implement declarations based on P0214R7.

2018-03-19 Thread Tim Shen via Phabricator via cfe-commits
timshen updated this revision to Diff 139036.
timshen added a comment.
Herald added a subscriber: christof.

Rebase.


https://reviews.llvm.org/D41148

Files:
  libcxx/include/experimental/__config
  libcxx/include/experimental/simd
  libcxx/test/std/experimental/simd/nothing_to_do.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.casts/static_simd_cast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/broadcast.pass.cpp
  libcxx/test/std/experimental/simd/simd.cons/geneartor.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/abi_for_size.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_abi_tag.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_flag_type.pass.cpp
  libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp

Index: libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
===
--- /dev/null
+++ libcxx/test/std/experimental/simd/simd.traits/is_simd_mask.pass.cpp
@@ -0,0 +1,121 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+//
+// [simd.traits]
+// template  struct is_simd_mask;
+// template  inline constexpr bool is_simd_mask_v = is_simd_mask::value;
+
+#include 
+#include 
+#include "test_macros.h"
+
+using namespace std::experimental::parallelism_v2;
+
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+static_assert(is_simd_mask::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+static_assert(is_simd_mask>::value, "");
+
+static_assert(!is_simd_mask::value, "");
+
+#if TEST_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_VARIABLE_TEMPLATES) &&\
+!defined(_LIBCPP_HAS_NO_INLINE_VARIABLES)
+
+static_assert(is_simd_mask_v, "");
+static_assert(is_simd_mask_v, "");
+static_assert(is_simd_mask_v, "");

[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

See my comment in https://reviews.llvm.org/D44655, but this change is also fine 
with me.


Repository:
  rC Clang

https://reviews.llvm.org/D44655



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


r327926 - [analyzer] Fix the assertion failure when static globals are used in lambda by reference

2018-03-19 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Mar 19 17:20:58 2018
New Revision: 327926

URL: http://llvm.org/viewvc/llvm-project?rev=327926=rev
Log:
[analyzer] Fix the assertion failure when static globals are used in lambda by 
reference

Also use the opportunity to clean up the code and remove unnecessary 
duplication.

rdar://37625895

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/lambdas.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=327926=327925=327926=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Mon Mar 19 17:20:58 2018
@@ -2462,8 +2462,8 @@ void ExprEngine::VisitCommonDeclRefExpr(
 const Decl *D = LocCtxt->getDecl();
 const auto *MD = D ? dyn_cast(D) : nullptr;
 const auto *DeclRefEx = dyn_cast(Ex);
-SVal V;
-bool IsReference;
+Optional> VInfo;
+
 if (AMgr.options.shouldInlineLambdas() && DeclRefEx &&
 DeclRefEx->refersToEnclosingVariableOrCapture() && MD &&
 MD->getParent()->isLambda()) {
@@ -2472,25 +2472,23 @@ void ExprEngine::VisitCommonDeclRefExpr(
   llvm::DenseMap LambdaCaptureFields;
   FieldDecl *LambdaThisCaptureField;
   CXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);
-  const FieldDecl *FD = LambdaCaptureFields[VD];
-  if (!FD) {
-// When a constant is captured, sometimes no corresponding field is
-// created in the lambda object.
-assert(VD->getType().isConstQualified());
-V = state->getLValue(VD, LocCtxt);
-IsReference = false;
-  } else {
+
+  // Sema follows a sequence of complex rules to determine whether the
+  // variable should be captured.
+  if (const FieldDecl *FD = LambdaCaptureFields[VD]) {
 Loc CXXThis =
 svalBuilder.getCXXThis(MD, LocCtxt->getCurrentStackFrame());
 SVal CXXThisVal = state->getSVal(CXXThis);
-V = state->getLValue(FD, CXXThisVal);
-IsReference = FD->getType()->isReferenceType();
+VInfo = std::make_pair(state->getLValue(FD, CXXThisVal), 
FD->getType());
   }
-} else {
-  V = state->getLValue(VD, LocCtxt);
-  IsReference = VD->getType()->isReferenceType();
 }
 
+if (!VInfo)
+  VInfo = std::make_pair(state->getLValue(VD, LocCtxt), VD->getType());
+
+SVal V = VInfo->first;
+bool IsReference = VInfo->second->isReferenceType();
+
 // For references, the 'lvalue' is the pointer address stored in the
 // reference region.
 if (IsReference) {

Modified: cfe/trunk/test/Analysis/lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lambdas.cpp?rev=327926=327925=327926=diff
==
--- cfe/trunk/test/Analysis/lambdas.cpp (original)
+++ cfe/trunk/test/Analysis/lambdas.cpp Mon Mar 19 17:20:58 2018
@@ -348,6 +348,23 @@ void testCapturedConstExprFloat() {
   lambda();
 }
 
+
+static int b = 0;
+
+int f() {
+  b = 0;
+  auto  = b;
+  [&] {
+bm++;
+bm++;
+  }();
+  if (bm != 2) {
+int *y = 0;
+return *y; // no-warning
+  }
+  return 0;
+}
+
 // CHECK: [B2 (ENTRY)]
 // CHECK:   Succs (1): B1
 // CHECK: [B1]


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


[PATCH] D44594: [analyzer] Fix the assertion failure when static globals are used in lambda by reference

2018-03-19 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327926: [analyzer] Fix the assertion failure when static 
globals are used in lambda by… (authored by george.karpenkov, committed by ).
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44594?vs=138800=139033#toc

Repository:
  rC Clang

https://reviews.llvm.org/D44594

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/lambdas.cpp


Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2462,35 +2462,33 @@
 const Decl *D = LocCtxt->getDecl();
 const auto *MD = D ? dyn_cast(D) : nullptr;
 const auto *DeclRefEx = dyn_cast(Ex);
-SVal V;
-bool IsReference;
+Optional> VInfo;
+
 if (AMgr.options.shouldInlineLambdas() && DeclRefEx &&
 DeclRefEx->refersToEnclosingVariableOrCapture() && MD &&
 MD->getParent()->isLambda()) {
   // Lookup the field of the lambda.
   const CXXRecordDecl *CXXRec = MD->getParent();
   llvm::DenseMap LambdaCaptureFields;
   FieldDecl *LambdaThisCaptureField;
   CXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);
-  const FieldDecl *FD = LambdaCaptureFields[VD];
-  if (!FD) {
-// When a constant is captured, sometimes no corresponding field is
-// created in the lambda object.
-assert(VD->getType().isConstQualified());
-V = state->getLValue(VD, LocCtxt);
-IsReference = false;
-  } else {
+
+  // Sema follows a sequence of complex rules to determine whether the
+  // variable should be captured.
+  if (const FieldDecl *FD = LambdaCaptureFields[VD]) {
 Loc CXXThis =
 svalBuilder.getCXXThis(MD, LocCtxt->getCurrentStackFrame());
 SVal CXXThisVal = state->getSVal(CXXThis);
-V = state->getLValue(FD, CXXThisVal);
-IsReference = FD->getType()->isReferenceType();
+VInfo = std::make_pair(state->getLValue(FD, CXXThisVal), 
FD->getType());
   }
-} else {
-  V = state->getLValue(VD, LocCtxt);
-  IsReference = VD->getType()->isReferenceType();
 }
 
+if (!VInfo)
+  VInfo = std::make_pair(state->getLValue(VD, LocCtxt), VD->getType());
+
+SVal V = VInfo->first;
+bool IsReference = VInfo->second->isReferenceType();
+
 // For references, the 'lvalue' is the pointer address stored in the
 // reference region.
 if (IsReference) {
Index: test/Analysis/lambdas.cpp
===
--- test/Analysis/lambdas.cpp
+++ test/Analysis/lambdas.cpp
@@ -348,6 +348,23 @@
   lambda();
 }
 
+
+static int b = 0;
+
+int f() {
+  b = 0;
+  auto  = b;
+  [&] {
+bm++;
+bm++;
+  }();
+  if (bm != 2) {
+int *y = 0;
+return *y; // no-warning
+  }
+  return 0;
+}
+
 // CHECK: [B2 (ENTRY)]
 // CHECK:   Succs (1): B1
 // CHECK: [B1]


Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -2462,35 +2462,33 @@
 const Decl *D = LocCtxt->getDecl();
 const auto *MD = D ? dyn_cast(D) : nullptr;
 const auto *DeclRefEx = dyn_cast(Ex);
-SVal V;
-bool IsReference;
+Optional> VInfo;
+
 if (AMgr.options.shouldInlineLambdas() && DeclRefEx &&
 DeclRefEx->refersToEnclosingVariableOrCapture() && MD &&
 MD->getParent()->isLambda()) {
   // Lookup the field of the lambda.
   const CXXRecordDecl *CXXRec = MD->getParent();
   llvm::DenseMap LambdaCaptureFields;
   FieldDecl *LambdaThisCaptureField;
   CXXRec->getCaptureFields(LambdaCaptureFields, LambdaThisCaptureField);
-  const FieldDecl *FD = LambdaCaptureFields[VD];
-  if (!FD) {
-// When a constant is captured, sometimes no corresponding field is
-// created in the lambda object.
-assert(VD->getType().isConstQualified());
-V = state->getLValue(VD, LocCtxt);
-IsReference = false;
-  } else {
+
+  // Sema follows a sequence of complex rules to determine whether the
+  // variable should be captured.
+  if (const FieldDecl *FD = LambdaCaptureFields[VD]) {
 Loc CXXThis =
 svalBuilder.getCXXThis(MD, LocCtxt->getCurrentStackFrame());
 SVal CXXThisVal = state->getSVal(CXXThis);
-V = state->getLValue(FD, CXXThisVal);
-IsReference = FD->getType()->isReferenceType();
+VInfo = std::make_pair(state->getLValue(FD, CXXThisVal), FD->getType());
   }
-} else {
-  V = state->getLValue(VD, LocCtxt);
-  IsReference = VD->getType()->isReferenceType();
 }
 
+if (!VInfo)
+  VInfo = std::make_pair(state->getLValue(VD, 

[PATCH] D44655: [Sanitizer] Allow builtins for Cross-DSO CFI on Android

2018-03-19 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: eugenis.
Herald added subscribers: cfe-commits, srhines.

This is needed to avoid the test failure in case when compiler-rt
is set as the default runtime library for Clang.


Repository:
  rC Clang

https://reviews.llvm.org/D44655

Files:
  clang/test/Driver/sanitizer-ld.c


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.{{^builtins}}
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \


Index: clang/test/Driver/sanitizer-ld.c
===
--- clang/test/Driver/sanitizer-ld.c
+++ clang/test/Driver/sanitizer-ld.c
@@ -514,7 +514,7 @@
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
-// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
+// CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.{{^builtins}}
 
 // Cross-DSO CFI with diagnostics on Android links just the UBSAN runtime.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44491: Set dso_local for CFConstantStringClassReference

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

lgtm


https://reviews.llvm.org/D44491



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


[PATCH] D44649: Set dso_local for guid decls

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

Yep, these are pretty much always local.


https://reviews.llvm.org/D44649



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


[PATCH] D44652: [vfs] Don't bail out after a missing -ivfsoverlay file

2018-03-19 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir created this revision.
benlangmuir added reviewers: bruno, vsapsai.
Herald added a subscriber: cfe-commits.

This make -ivfsoverlay behave more like other fatal errors (e.g. missing
-include file) by skipping the missing file instead of bailing out of
the whole compilation. This makes it possible for libclang to still
provide some functionallity as well as to correctly produce the fatal
error diagnostic (previously we lost the diagnostic in libclang since
there was no TU to tie it to).

  

rdar://33385423


Repository:
  rC Clang

https://reviews.llvm.org/D44652

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  lib/Frontend/ASTUnit.cpp
  lib/Frontend/CompilerInstance.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/PrecompiledPreamble.cpp
  test/Index/missing_vfs.c
  test/VFS/Inputs/MissingVFS/a.h
  test/VFS/Inputs/MissingVFS/module.modulemap
  test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
  test/VFS/module_missing_vfs.m

Index: test/VFS/module_missing_vfs.m
===
--- /dev/null
+++ test/VFS/module_missing_vfs.m
@@ -0,0 +1,16 @@
+// REQUIRES: shell
+// RUN: rm -rf %t && mkdir -p %t
+// RUN: echo "void funcA(void);" >> %t/a.h
+
+// RUN: not %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml 2>&1 | FileCheck %s -check-prefix=ERROR
+// ERROR: virtual filesystem overlay file '{{.*}}' not found
+// RUN: find %t/mcp -name "A-*.pcm" | count 1
+
+// RUN: sed -e "s:INPUT_DIR:%S/Inputs:g" -e "s:OUT_DIR:%t:g" %S/Inputs/MissingVFS/vfsoverlay.yaml > %t/vfs.yaml
+// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t/mcp -I %S/Inputs/MissingVFS %s -fsyntax-only -ivfsoverlay %t/vfs.yaml
+// RUN: find %t/mcp -name "A-*.pcm" | count 1
+
+@import A;
+void test(void) {
+  funcA();
+}
Index: test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
===
--- /dev/null
+++ test/VFS/Inputs/MissingVFS/vfsoverlay.yaml
@@ -0,0 +1,13 @@
+{
+  'version': 0,
+  'ignore-non-existent-contents': false,
+  'roots': [
+{ 'name': 'INPUT_DIR', 'type': 'directory',
+  'contents': [
+{ 'name': 'a.h', 'type': 'file',
+  'external-contents': 'OUT_DIR/a.h'
+}
+  ]
+}
+  ]
+}
Index: test/VFS/Inputs/MissingVFS/module.modulemap
===
--- /dev/null
+++ test/VFS/Inputs/MissingVFS/module.modulemap
@@ -0,0 +1,3 @@
+module A {
+  header "a.h"
+}
Index: test/VFS/Inputs/MissingVFS/a.h
===
--- /dev/null
+++ test/VFS/Inputs/MissingVFS/a.h
@@ -0,0 +1 @@
+// void funcA(void);
Index: test/Index/missing_vfs.c
===
--- /dev/null
+++ test/Index/missing_vfs.c
@@ -0,0 +1,6 @@
+// RUN: c-index-test -test-load-source local %s -ivfsoverlay %t/does-not-exist.yaml &> %t.out
+// RUN: FileCheck -check-prefix=STDERR %s < %t.out
+// STDERR: fatal error: virtual filesystem overlay file '{{.*}}' not found
+// RUN: FileCheck %s < %t.out
+// CHECK: missing_vfs.c:[[@LINE+1]]:6: FunctionDecl=foo:[[@LINE+1]]:6
+void foo(void);
Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -303,8 +303,6 @@
 
   VFS =
   createVFSFromCompilerInvocation(Clang->getInvocation(), Diagnostics, VFS);
-  if (!VFS)
-return BuildPreambleError::CouldntCreateVFSOverlay;
 
   // Create a file manager object to provide access to and cache the filesystem.
   Clang->setFileManager(new FileManager(Clang->getFileSystemOpts(), VFS));
@@ -756,8 +754,6 @@
 return "Could not create temporary file for PCH";
   case BuildPreambleError::CouldntCreateTargetInfo:
 return "CreateTargetInfo() return null";
-  case BuildPreambleError::CouldntCreateVFSOverlay:
-return "Could not create VFS Overlay";
   case BuildPreambleError::BeginSourceFileFailed:
 return "BeginSourceFile() return an error";
   case BuildPreambleError::CouldntEmitPCH:
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -3072,16 +3072,16 @@
 BaseFS->getBufferForFile(File);
 if (!Buffer) {
   Diags.Report(diag::err_missing_vfs_overlay_file) << File;
-  return IntrusiveRefCntPtr();
+  continue;
 }
 
 IntrusiveRefCntPtr FS = vfs::getVFSFromYAML(
 std::move(Buffer.get()), /*DiagHandler*/ nullptr, File);
-if (!FS.get()) {
+if (FS) {
+  Overlay->pushOverlay(FS);
+} else {
   Diags.Report(diag::err_invalid_vfs_overlay) << File;
-  return IntrusiveRefCntPtr();
 }
-Overlay->pushOverlay(FS);
   }
   return Overlay;
 }

[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

mgorny wrote:
> (an alternative would be to replace this 'NOT' clause with more specific 
> library name — but I don't know which library could 'accidentally' appear 
> here)
Yes, it would be better to check for -NOT: libclang_rt.cfi


Repository:
  rC Clang

https://reviews.llvm.org/D44645



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


[PATCH] D44536: Avoid segfault when destructor is not yet known

2018-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I think Richard is probably catching up from a week at the C++ committee.

To be clear, I am objecting to this; I think the destructor should clearly have 
been created at this point.  I'm just hoping Richard will have an idea for how 
best to fix it.


Repository:
  rC Clang

https://reviews.llvm.org/D44536



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


[PATCH] D44591: [AArch64] Add vmulxh_lane FP16 vector intrinsic

2018-03-19 Thread Abderrazek Zaafrani via Phabricator via cfe-commits
az updated this revision to Diff 139015.
az added a comment.

add LLVM codegen tests as suggested in the reviews.


https://reviews.llvm.org/D44591

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
  llvm/test/CodeGen/AArch64/fp16_intrinsic_lane.ll

Index: llvm/test/CodeGen/AArch64/fp16_intrinsic_lane.ll
===
--- llvm/test/CodeGen/AArch64/fp16_intrinsic_lane.ll
+++ llvm/test/CodeGen/AArch64/fp16_intrinsic_lane.ll
@@ -1,5 +1,6 @@
 ; RUN: llc < %s -mtriple=aarch64-eabi -mattr=+v8.2a,+fullfp16  | FileCheck %s
 
+declare half @llvm.aarch64.neon.fmulx.f16(half, half)
 declare <4 x half> @llvm.aarch64.neon.fmulx.v4f16(<4 x half>, <4 x half>)
 declare <8 x half> @llvm.aarch64.neon.fmulx.v8f16(<8 x half>, <8 x half>)
 declare <4 x half> @llvm.fma.v4f16(<4 x half>, <4 x half>, <4 x half>)
@@ -236,6 +237,25 @@
   ret half %1
 }
 
+define dso_local half @t_vmulx_f16(half %a, half %b) {
+; CHECK-LABEL: t_vmulx_f16:
+; CHECK: fmulx h0, h0, h1
+; CHECK-NEXT:ret
+entry:
+  %fmulx.i = tail call half @llvm.aarch64.neon.fmulx.f16(half %a, half %b)
+  ret half %fmulx.i
+}
+
+define dso_local half @t_vmulxh_lane_f16(half %a, <4 x half> %b, i32 %lane) {
+; CHECK-LABEL: t_vmulxh_lane_f16:
+; CHECK: fmulx h0, h0, v1.h[3]
+; CHECK-NEXT:ret
+entry:
+  %extract = extractelement <4 x half> %b, i32 3
+  %fmulx.i = tail call half @llvm.aarch64.neon.fmulx.f16(half %a, half %extract)
+  ret half %fmulx.i
+}
+
 define dso_local <4 x half> @t_vmulx_lane_f16(<4 x half> %a, <4 x half> %b, i32 %lane) {
 ; CHECK-LABEL: t_vmulx_lane_f16:
 ; CHECK: fmulx v0.4h, v0.4h, v1.h[0]
@@ -276,6 +296,16 @@
   ret <8 x half> %vmulx2.i
 }
 
+define dso_local half @t_vmulxh_laneq_f16(half %a, <8 x half> %b, i32 %lane) {
+; CHECK-LABEL: t_vmulxh_laneq_f16:
+; CHECK: fmulx h0, h0, v1.h[7]
+; CHECK-NEXT:ret
+entry:
+  %extract = extractelement <8 x half> %b, i32 7
+  %fmulx.i = tail call half @llvm.aarch64.neon.fmulx.f16(half %a, half %extract)
+  ret half %fmulx.i
+}
+
 define dso_local <4 x half> @t_vmulx_n_f16(<4 x half> %a, half %c) {
 ; CHECK-LABEL: t_vmulx_n_f16:
 ; CHECK: dup v1.4h, v1.h[0]
Index: clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
===
--- clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
+++ clang/test/CodeGen/aarch64-v8.2a-neon-intrinsics.c
@@ -1223,27 +1223,25 @@
   return vmulxq_n_f16(a, b);
 }
 
-/* TODO: Not implemented yet (needs scalar intrinsic from arm_fp16.h)
-// CCHECK-LABEL: test_vmulxh_lane_f16
-// CCHECK: [[CONV0:%.*]] = fpext half %a to float
-// CCHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
-// CCHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
-// CCHECK: [[CONV3:%.*]] = fptrunc float %mul to half
-// CCHECK: ret half [[CONV3:%.*]]
+// CHECK-LABEL: test_vmulxh_lane_f16
+// CHECK: [[TMP0:%.*]] = bitcast <4 x half> %b to <8 x i8>
+// CHECK: [[TMP1:%.*]] = bitcast <8 x i8> [[TMP0]] to <4 x half>
+// CHECK: [[EXTR:%.*]] = extractelement <4 x half> [[TMP1]], i32 3
+// CHECK: [[MULX:%.*]] = call half @llvm.aarch64.neon.fmulx.f16(half %a, half [[EXTR]]
+// CHECK: ret half [[MULX]]
 float16_t test_vmulxh_lane_f16(float16_t a, float16x4_t b) {
   return vmulxh_lane_f16(a, b, 3);
 }
 
-// CCHECK-LABEL: test_vmulxh_laneq_f16
-// CCHECK: [[CONV0:%.*]] = fpext half %a to float
-// CCHECK: [[CONV1:%.*]] = fpext half %{{.*}} to float
-// CCHECK: [[MUL:%.*]]   = fmul float [[CONV0:%.*]], [[CONV0:%.*]]
-// CCHECK: [[CONV3:%.*]] = fptrunc float %mul to half
-// CCHECK: ret half [[CONV3:%.*]]
+// CHECK-LABEL: test_vmulxh_laneq_f16
+// CHECK: [[TMP0:%.*]] = bitcast <8 x half> %b to <16 x i8>
+// CHECK: [[TMP1:%.*]] = bitcast <16 x i8> [[TMP0]] to <8 x half>
+// CHECK: [[EXTR:%.*]] = extractelement <8 x half> [[TMP1]], i32 7
+// CHECK: [[MULX:%.*]] = call half @llvm.aarch64.neon.fmulx.f16(half %a, half [[EXTR]])
+// CHECK: ret half [[MULX]]
 float16_t test_vmulxh_laneq_f16(float16_t a, float16x8_t b) {
   return vmulxh_laneq_f16(a, b, 7);
 }
-*/
 
 // CHECK-LABEL: test_vmaxv_f16
 // CHECK: [[TMP0:%.*]] = bitcast <4 x half> %a to <8 x i8>
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -7238,6 +7238,16 @@
 Int = Intrinsic::aarch64_neon_fmulx;
 return EmitNeonCall(CGM.getIntrinsic(Int, Ty), Ops, "vmulx");
   }
+  case NEON::BI__builtin_neon_vmulxh_lane_f16:
+  case NEON::BI__builtin_neon_vmulxh_laneq_f16: {
+// vmulx_lane should be mapped to Neon scalar mulx after
+// extracting the scalar element
+Ops.push_back(EmitScalarExpr(E->getArg(2)));
+Ops[1] = Builder.CreateExtractElement(Ops[1], Ops[2], "extract");
+Ops.pop_back();
+Int = Intrinsic::aarch64_neon_fmulx;
+return 

[PATCH] D44536: Avoid segfault when destructor is not yet known

2018-03-19 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

@rsmith, any objections?


Repository:
  rC Clang

https://reviews.llvm.org/D44536



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT added a comment.

In https://reviews.llvm.org/D44646#1042347, @efriedma wrote:

> The compiler shouldn't inline functions which call va_start, whether or not 
> they're marked always_inline.  That should work correctly, I think, at least 
> on trunk.  (See https://reviews.llvm.org/D42556 .)
>
> If you want to warn anyway, that's okay.


Interesting. I certainly hit the lowering/instruction scheduling crash after 
that change landed. Perhaps it's a valuable thing for me to file a bug on.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D43047: [Builtins] Overload __builtin_operator_new/delete to allow forwarding to usual allocation/deallocation functions.

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

Thanks, this looks great.




Comment at: lib/Sema/SemaExprCXX.cpp:3458
+  }
+  TheCall->getCallee()->setType(OperatorNewOrDelete->getType());
+

It would be nice to assert that the callee you're setting the type of is an 
ImplicitCastExpr doing a BuiltinFnToFnPtr cast (just so that it's obvious that 
this is the only type we need to update and that it's freshly-created).


https://reviews.llvm.org/D43047



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


[PATCH] D44362: [clang] Change std::sort to llvm::sort in response to r327219

2018-03-19 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added a comment.

Ping for reviews please.


Repository:
  rC Clang

https://reviews.llvm.org/D44362



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


RE: [clang-tools-extra] r327833 - [clang-tidy] New check bugprone-unused-return-value

2018-03-19 Thread via cfe-commits
This should be fixed by r327911.

Douglas Yung

From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of 
Galina Kistanova via cfe-commits
Sent: Monday, March 19, 2018 13:13
To: Alexander Kornienko
Cc: cfe-commits
Subject: Re: [clang-tools-extra] r327833 - [clang-tidy] New check 
bugprone-unused-return-value

Hello Alexander,

This commit broke at least two of our builders:

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

. . .
Failing Tests (1):
Clang Tools :: clang-tidy/bugprone-unused-return-value.cpp

Please have a look?

It is not good idea to keep the bot red for too long. This hides new problem 
which later hard to track down.

Thanks

Galina

On Mon, Mar 19, 2018 at 6:02 AM, Alexander Kornienko via cfe-commits 
> wrote:
Author: alexfh
Date: Mon Mar 19 06:02:32 2018
New Revision: 327833

URL: http://llvm.org/viewvc/llvm-project?rev=327833=rev
Log:
[clang-tidy] New check bugprone-unused-return-value

Summary:
Detects function calls where the return value is unused.

Checked functions can be configured.

Reviewers: alexfh, aaron.ballman, ilya-biryukov, hokein

Reviewed By: alexfh, aaron.ballman

Subscribers: hintonda, JonasToth, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits

Tags: #clang-tools-extra

Patch by Kalle Huttunen!

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

Added:
clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-unused-return-value.rst

clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=327833=327832=327833=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp Mon Mar 
19 06:02:32 2018
@@ -43,6 +43,7 @@
 #include "UndefinedMemoryManipulationCheck.h"
 #include "UndelegatedConstructorCheck.h"
 #include "UnusedRaiiCheck.h"
+#include "UnusedReturnValueCheck.h"
 #include "UseAfterMoveCheck.h"
 #include "VirtualNearMissCheck.h"

@@ -119,6 +120,8 @@ public:
 "bugprone-undelegated-constructor");
 CheckFactories.registerCheck(
 "bugprone-unused-raii");
+CheckFactories.registerCheck(
+"bugprone-unused-return-value");
 CheckFactories.registerCheck(
 "bugprone-use-after-move");
 CheckFactories.registerCheck(

Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt?rev=327833=327832=327833=diff
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Mon Mar 19 
06:02:32 2018
@@ -35,6 +35,7 @@ add_clang_library(clangTidyBugproneModul
   UndefinedMemoryManipulationCheck.cpp
   UndelegatedConstructorCheck.cpp
   UnusedRaiiCheck.cpp
+  UnusedReturnValueCheck.cpp
   UseAfterMoveCheck.cpp
   VirtualNearMissCheck.cpp


Added: clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp?rev=327833=auto
==
--- clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp Mon 
Mar 19 06:02:32 2018
@@ -0,0 +1,82 @@
+//===--- UnusedReturnValueCheck.cpp - 
clang-tidy---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UnusedReturnValueCheck.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+using namespace clang::ast_matchers::internal;
+

[clang-tools-extra] r327911 - Fixup test to explicitly use -fexceptions since exceptions are disabled by default on the PS4 target.

2018-03-19 Thread Douglas Yung via cfe-commits
Author: dyung
Date: Mon Mar 19 14:22:58 2018
New Revision: 327911

URL: http://llvm.org/viewvc/llvm-project?rev=327911=rev
Log:
Fixup test to explicitly use -fexceptions since exceptions are disabled by 
default on the PS4 target.

Modified:
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp?rev=327911=327910=327911=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp 
Mon Mar 19 14:22:58 2018
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s bugprone-unused-return-value %t
+// RUN: %check_clang_tidy %s bugprone-unused-return-value %t -- -- -fexceptions
 
 namespace std {
 


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


[PATCH] D44557: [analyzer] CStringChecker.cpp - Code refactoring on bug report.

2018-03-19 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Sorry, one moment, i'm seeing a few regressions after the previous refactoring 
but i didn't look at them closely yet to provide a reproducer. I'll get back to 
this.


Repository:
  rC Clang

https://reviews.llvm.org/D44557



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

What happens in the case that you have a variadic in C code marked with 
`__forceinline`?  Does that also cause a warning with MSVC?




Comment at: test/Sema/ms-forceinline-on-variadic.cpp:1
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify 
-fms-extensions %s \
+// RUN:| FileCheck %s

Personally, I prefer the fully canonicalized triple name 
`i686-unknown-windows-msvc`.



Comment at: test/Sema/ms-forceinline-on-variadic.cpp:14
+__builtin_va_end(ap);
+}
+

Would be nice to have a second test that uses the Microsoft definitions (`char 
*` and the offsetting handling for the `va_list` since when building against 
the Windows SDK, that is the way that `va_list` and the `va_*` family of 
functions will get handled.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D44606: [analyzer] Fix the crash in `IteratorChecker.cpp` when `SymbolConjured` has a null Stmt.

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

Just in case: we indeed do not guarantee that `SymbolConjured` corresponds to a 
statement; it is, however, not intended, but rather a bug. Consider:

   1void clang_analyzer_eval(bool);
   2
   3class C {
   4  int 
   5public:
   6  C(int ): x(x) {}
   7  ~C();
   8};
   9
  10void foo() {
  11  int x = 1;
  12  {
  13C c(x);
  14  }
  15  int y = x;
  16  {
  17C c(x);
  18  }
  19  int z = x;
  20  clang_analyzer_eval(y == z);
  21}

We currently evaluate `clang_analyzer_eval(y == z)` to `TRUE` but that's 
unsound because `~C();` could have been defined as `~C() { ++x; }`. We make 
such unsound assumption because `SymbolConjured` put into `x` during destructor 
call on line 14 and on line 18 is the same conjured symbol because they have no 
statements attached because destructors are implicit and have no corresponding 
statements, and everything else about these two symbols is the same. So, well, 
we should work around this problem somehow.



Now the real question here is whether `IteratorChecker` should scan any of the 
symbols that have no statement attached. I believe that `IteratorChecker` 
should only be interested in symbols that were returned from specific functions 
that return iterators. In the test case there are no iterators at all, so i 
suspect that the iterator checker is scanning more symbols than it needs.



Regardless, the patch makes sense :)


Repository:
  rC Clang

https://reviews.llvm.org/D44606



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

The compiler shouldn't inline functions which call va_start, whether or not 
they're marked always_inline.  That should work correctly, I think, at least on 
trunk.  (See https://reviews.llvm.org/D42556 .)

If you want to warn anyway, that's okay.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D44491: Set dso_local for CFConstantStringClassReference

2018-03-19 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola added a comment.

ping


https://reviews.llvm.org/D44491



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


[PATCH] D44649: Set dso_local for guid decls

2018-03-19 Thread Rafael Avila de Espindola via Phabricator via cfe-commits
espindola created this revision.
espindola added reviewers: rnk, echristo.

https://reviews.llvm.org/D44649

Files:
  lib/CodeGen/CodeGenModule.cpp
  test/CodeGenCXX/microsoft-templ-uuidof.cpp


Index: test/CodeGenCXX/microsoft-templ-uuidof.cpp
===
--- test/CodeGenCXX/microsoft-templ-uuidof.cpp
+++ test/CodeGenCXX/microsoft-templ-uuidof.cpp
@@ -15,6 +15,8 @@
 
 struct __declspec(uuid("{----}")) C {};
 
+// CHECK-DAG: @_GUID_____ = linkonce_odr 
dso_local
+
 const _GUID  = __uuidof(X);
 // CHECK-DAG:  @"?xa@@3ABU_GUID@@B" = {{.*}} 
@_GUID_____
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1921,6 +1921,7 @@
   /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
+  setDSOLocal(GV);
   return ConstantAddress(GV, Alignment);
 }
 


Index: test/CodeGenCXX/microsoft-templ-uuidof.cpp
===
--- test/CodeGenCXX/microsoft-templ-uuidof.cpp
+++ test/CodeGenCXX/microsoft-templ-uuidof.cpp
@@ -15,6 +15,8 @@
 
 struct __declspec(uuid("{----}")) C {};
 
+// CHECK-DAG: @_GUID_____ = linkonce_odr dso_local
+
 const _GUID  = __uuidof(X);
 // CHECK-DAG:  @"?xa@@3ABU_GUID@@B" = {{.*}} @_GUID_____
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -1921,6 +1921,7 @@
   /*isConstant=*/true, llvm::GlobalValue::LinkOnceODRLinkage, Init, Name);
   if (supportsCOMDAT())
 GV->setComdat(TheModule.getOrInsertComdat(GV->getName()));
+  setDSOLocal(GV);
   return ConstantAddress(GV, Alignment);
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r327885 - [clang-move] Fix move-used-helper-decls.cpp test.

2018-03-19 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Mon Mar 19 12:05:53 2018
New Revision: 327885

URL: http://llvm.org/viewvc/llvm-project?rev=327885=rev
Log:
[clang-move] Fix move-used-helper-decls.cpp test.

Modified:
clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp?rev=327885=327884=327885=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Mon Mar 
19 12:05:53 2018
@@ -335,7 +335,6 @@
 // CHECK-NEW-H-NEXT: void Fun1();
 // CHECK-NEW-H-SAME: {{[[:space:]]}}
 // CHECK-NEW-H-NEXT: inline void Fun2() {}
-// CHECK-NEW-H-SAME: {{[[:space:]]}}
 // CHECK-NEW-H-NEXT: } // namespace a
 
 


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


[clang-tools-extra] r327902 - [clangd] Fix undefined behavior due to misaligned type cast

2018-03-19 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 19 13:26:18 2018
New Revision: 327902

URL: http://llvm.org/viewvc/llvm-project?rev=327902=rev
Log:
[clangd] Fix undefined behavior due to misaligned type cast

The current code was casting pointer to a misaligned type which is undefined 
behavior.
Found by compiling with Undefined Behavior Sanitizer and running tests 
(check-clang-tools).

Modified:
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327902=327901=327902=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:18 2018
@@ -61,7 +61,9 @@ private:
   friend llvm::hash_code hash_value(const SymbolID ) {
 // We already have a good hash, just return the first bytes.
 static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than 
SHA1!");
-return *reinterpret_cast(ID.HashValue.data());
+size_t Result;
+memcpy(, ID.HashValue.data(), sizeof(size_t));
+return llvm::hash_code(Result);
   }
   friend llvm::raw_ostream <<(llvm::raw_ostream ,
const SymbolID );


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


[clang-tools-extra] r327901 - [clangd][nfc] Give name to a magic constant

2018-03-19 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Mar 19 13:26:15 2018
New Revision: 327901

URL: http://llvm.org/viewvc/llvm-project?rev=327901=rev
Log:
[clangd][nfc] Give name to a magic constant

Modified:
clang-tools-extra/trunk/clangd/index/Index.h

Modified: clang-tools-extra/trunk/clangd/index/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/Index.h?rev=327901=327900=327901=diff
==
--- clang-tools-extra/trunk/clangd/index/Index.h (original)
+++ clang-tools-extra/trunk/clangd/index/Index.h Mon Mar 19 13:26:15 2018
@@ -56,16 +56,18 @@ public:
   }
 
 private:
+  static constexpr unsigned HashByteLength = 20;
+
   friend llvm::hash_code hash_value(const SymbolID ) {
 // We already have a good hash, just return the first bytes.
-static_assert(sizeof(size_t) <= 20, "size_t longer than SHA1!");
+static_assert(sizeof(size_t) <= HashByteLength, "size_t longer than 
SHA1!");
 return *reinterpret_cast(ID.HashValue.data());
   }
   friend llvm::raw_ostream <<(llvm::raw_ostream ,
const SymbolID );
   friend void operator>>(llvm::StringRef Str, SymbolID );
 
-  std::array HashValue;
+  std::array HashValue;
 };
 
 // Write SymbolID into the given stream. SymbolID is encoded as a 40-bytes


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


[PATCH] D44580: Sema: allow comparison between blocks & block-compatible objc types

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT updated this revision to Diff 138996.
DHowett-MSFT added a comment.

Ran `clang-format` over changed lines. Reuploaded diff with full context.


Repository:
  rC Clang

https://reviews.llvm.org/D44580

Files:
  lib/Sema/SemaExpr.cpp
  test/SemaObjC/block-compare.mm


Index: test/SemaObjC/block-compare.mm
===
--- /dev/null
+++ test/SemaObjC/block-compare.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -S -o - -triple i686-windows -verify -fblocks \
+// RUN: -Wno-unused-comparison %s
+
+#pragma clang diagnostic ignored "-Wunused-comparison"
+
+#define nil ((id)nullptr)
+
+@protocol NSObject
+@end
+
+@protocol NSCopying
+@end
+
+@protocol OtherProtocol
+@end
+
+__attribute__((objc_root_class))
+@interface NSObject 
+@end
+
+__attribute__((objc_root_class))
+@interface Test
+@end
+
+int main() {
+  void (^block)() = ^{};
+  NSObject *object;
+  id qualifiedId;
+
+  id poorlyQualified1;
+  Test *objectOfWrongType;
+
+  block == nil;
+  block == object;
+  block == qualifiedId;
+
+  nil == block;
+  object == block;
+  qualifiedId == block;
+
+  // these are still not valid: blocks must be compared with id, NSObject*, or 
a protocol-qualified id
+  // conforming to NSCopying or NSObject.
+
+  block == poorlyQualified1; // expected-error {{invalid operands to binary 
expression ('void (^)()' and 'id')}}
+  block == objectOfWrongType; // expected-error {{invalid operands to binary 
expression ('void (^)()' and 'Test *')}}
+
+  poorlyQualified1 == block; // expected-error {{invalid operands to binary 
expression ('id' and 'void (^)()')}}
+  objectOfWrongType == block; // expected-error {{invalid operands to binary 
expression ('Test *' and 'void (^)()')}}
+
+  return 0;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10028,6 +10028,19 @@
 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
   return ResultTy;
 }
+
+if (!IsRelational && LHSType->isBlockPointerType() &&
+RHSType->isBlockCompatibleObjCPointerType(Context)) {
+  LHS = ImpCastExprToType(LHS.get(), RHSType,
+  CK_BlockPointerToObjCPointerCast);
+  return ResultTy;
+} else if (!IsRelational &&
+   LHSType->isBlockCompatibleObjCPointerType(Context) &&
+   RHSType->isBlockPointerType()) {
+  RHS = ImpCastExprToType(RHS.get(), LHSType,
+  CK_BlockPointerToObjCPointerCast);
+  return ResultTy;
+}
   }
   if ((LHSType->isAnyPointerType() && RHSType->isIntegerType()) ||
   (LHSType->isIntegerType() && RHSType->isAnyPointerType())) {


Index: test/SemaObjC/block-compare.mm
===
--- /dev/null
+++ test/SemaObjC/block-compare.mm
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -S -o - -triple i686-windows -verify -fblocks \
+// RUN: -Wno-unused-comparison %s
+
+#pragma clang diagnostic ignored "-Wunused-comparison"
+
+#define nil ((id)nullptr)
+
+@protocol NSObject
+@end
+
+@protocol NSCopying
+@end
+
+@protocol OtherProtocol
+@end
+
+__attribute__((objc_root_class))
+@interface NSObject 
+@end
+
+__attribute__((objc_root_class))
+@interface Test
+@end
+
+int main() {
+  void (^block)() = ^{};
+  NSObject *object;
+  id qualifiedId;
+
+  id poorlyQualified1;
+  Test *objectOfWrongType;
+
+  block == nil;
+  block == object;
+  block == qualifiedId;
+
+  nil == block;
+  object == block;
+  qualifiedId == block;
+
+  // these are still not valid: blocks must be compared with id, NSObject*, or a protocol-qualified id
+  // conforming to NSCopying or NSObject.
+
+  block == poorlyQualified1; // expected-error {{invalid operands to binary expression ('void (^)()' and 'id')}}
+  block == objectOfWrongType; // expected-error {{invalid operands to binary expression ('void (^)()' and 'Test *')}}
+
+  poorlyQualified1 == block; // expected-error {{invalid operands to binary expression ('id' and 'void (^)()')}}
+  objectOfWrongType == block; // expected-error {{invalid operands to binary expression ('Test *' and 'void (^)()')}}
+
+  return 0;
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -10028,6 +10028,19 @@
 RHS = ImpCastExprToType(RHS.get(), LHSType, CK_BitCast);
   return ResultTy;
 }
+
+if (!IsRelational && LHSType->isBlockPointerType() &&
+RHSType->isBlockCompatibleObjCPointerType(Context)) {
+  LHS = ImpCastExprToType(LHS.get(), RHSType,
+  CK_BlockPointerToObjCPointerCast);
+  return ResultTy;
+} else if (!IsRelational &&
+   LHSType->isBlockCompatibleObjCPointerType(Context) &&
+   RHSType->isBlockPointerType()) {
+ 

[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT updated this revision to Diff 138995.
DHowett-MSFT added a comment.

Fixed formatting.


Repository:
  rC Clang

https://reviews.llvm.org/D44646

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/ms-forceinline-on-variadic.cpp


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify 
-fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } 
// expected-warning {{inlining attribute 'always_inline' ignored on variadic 
function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning 
{{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the 
test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }
+
   if (D->hasAttr())
 return nullptr;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2694,6 +2694,9 @@
 def warn_attribute_after_definition_ignored : Warning<
   "attribute %0 after definition is ignored">,
InGroup;
+def warn_always_inline_on_variadic : Warning<
+  "inlining attribute %0 ignored on variadic function">,
+   InGroup;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
 def warn_cxx11_gnu_attribute_on_type : Warning<


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify -fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } // expected-warning {{inlining attribute 'always_inline' ignored on variadic function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning {{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
+  hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }
+
   if (D->hasAttr())
 return nullptr;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2694,6 +2694,9 @@
 def warn_attribute_after_definition_ignored : Warning<
   "attribute %0 after definition is ignored">,
InGroup;
+def warn_always_inline_on_variadic : Warning<
+  "inlining attribute %0 ignored on variadic function">,
+   InGroup;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
 def 

[PATCH] D39562: [CodeGen][ObjC] Fix an assertion failure caused by copy elision

2018-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Alright, LGTM.


https://reviews.llvm.org/D39562



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


[PATCH] D44435: Add the module name to __cuda_module_ctor and __cuda_module_dtor for unique function names

2018-03-19 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: unittests/CodeGen/IncrementalProcessingTest.cpp:176-178
+
+// In CUDA incremental processing, a CUDA ctor or dtor will be generated for 
+// every statement if a fatbinary file exists.

SimeonEhrig wrote:
> tra wrote:
> > SimeonEhrig wrote:
> > > tra wrote:
> > > > SimeonEhrig wrote:
> > > > > tra wrote:
> > > > > > I don't understand the comment. What is 'CUDA incremental 
> > > > > > processing' and what exactly is meant by 'statement' here? I'd 
> > > > > > appreciate if you could give me more details. My understanding is 
> > > > > > that ctor/dtor are generated once per TU. I suspect "incremental 
> > > > > > processing" may change that, but I have no idea what exactly does 
> > > > > > it do.
> > > > > A CUDA ctor/dtor will generates for every llvm::module. The TU can 
> > > > > also composed of many modules. In our interpreter, we add new code to 
> > > > > our AST with new modules at runtime. 
> > > > > The ctor/dtor generation is depend on the fatbinary code. The CodeGen 
> > > > > checks, if a path to a fatbinary file is set. If it is, it generates 
> > > > > an ctor with at least a __cudaRegisterFatBinary() function call. So, 
> > > > > the generation is independent of the source code in the module and we 
> > > > > can use every statement. A statement can be an expression, a 
> > > > > declaration, a definition and so one.   
> > > > I still don't understand how it's going to work. Do you have some sort 
> > > > of design document outlining how the interpreter is going to work with 
> > > > CUDA?
> > > > 
> > > > The purpose of the ctor/dtor is to stitch together host-side kernel 
> > > > launch with the GPU-side kernel binary which resides in the GPU binary 
> > > > created by device-side compilation. 
> > > > 
> > > > So, the question #1 -- if you pass GPU-side binary to the compiler, 
> > > > where did you get it? Normally it's the result of device-side 
> > > > compilation of the same TU. In your case it's not quite clear what 
> > > > exactly would that be, if you feed the source to the compiler 
> > > > incrementally. I.e. do you somehow recompile everything we've seen on 
> > > > device side so far for each new chunk of host-side source you feed to 
> > > > the compiler? 
> > > > 
> > > > Next question is -- assuming that device side does have correct 
> > > > GPU-side binary, when do you call those ctors/dtors? JIT model does not 
> > > > quite fit the assumptions that drive regular CUDA compilation.
> > > > 
> > > > Let's consider this:
> > > > ```
> > > > __global__ void foo();
> > > > __global__ void bar();
> > > > 
> > > > // If that's all we've  fed to compiler so far, we have no GPU code 
> > > > yet, so there 
> > > > // should be no fatbin file. If we do have it, what's in it?
> > > > 
> > > > void launch() {
> > > >   foo<<<1,1>>>();
> > > >   bar<<<1,1>>>();
> > > > }
> > > > // If you've generated ctors/dtors at this point they would be 
> > > > // useless as no GPU code exists in the preceding code.
> > > > 
> > > > __global__ void foo() {}
> > > > // Now we'd have some GPU code, but how can we need to retrofit it into 
> > > > // all the ctors/dtors we've generated before. 
> > > > __global__ void bar() {}
> > > > // Does bar end up in its own fatbinary? Or is it combined into a new 
> > > > // fatbin which contains both boo and bar?
> > > > // If it's a new fatbin, you somehow need to update existing 
> > > > ctors/dtors, 
> > > > // unless you want to leak CUDA resources fast.
> > > > // If it's a separate fatbin, then you will need to at the very least 
> > > > change the way 
> > > > // ctors/dtors are generated by the 'launch' function, because now they 
> > > > need to 
> > > > // tie each kernel launch to a different fatbin.
> > > > 
> > > > ```
> > > > 
> > > > It looks to me that if you want to JIT CUDA code you will need to take 
> > > > over GPU-side kernel management.
> > > > ctors/dtors do that for full-TU compilation, but they rely on 
> > > > device-side code being compiled and available during host-side 
> > > > compilation. For JIT, the interpreter should be in charge of 
> > > > registering new kernels with the CUDA runtime and 
> > > > unregistering/unloading them when a kernel goes away. This makes 
> > > > ctors/dtors completely irrelevant.
> > > At the moment, there is no documentation, because we still develop the 
> > > feature. I try to describe how it works.
> > > 
> > > The device side compilation works with a second compiler (a normal 
> > > clang), which we start via syscall. In the interpreter, we check if the 
> > > input line is a kernel definition or a kernel launch. Then we write the 
> > > source code to a file and compile it with the clang to a PCH-file.  Then 
> > > the PCH-file will be compiled to PTX and then to a fatbin. If we add a 
> > > new kernel, we will send the source code with the existing PCH-file to 
> > > clang compiler. So we easy extend the AST and 

[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a reviewer: compnerd.
smeenai added a comment.

@DHowett-MSFT the reviewers look fine to me. Reid is the code owner for clang's 
MSVC compat support. David doesn't work on this stuff directly anymore, I 
think, but he's still pretty active in code reviews for it. I'm adding Saleem, 
who's also pretty active on Windows stuff.




Comment at: lib/Sema/SemaDeclAttr.cpp:3890
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()
+ && hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;

The formatting here looks off (it doesn't look clang-formatted).


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


Re: [clang-tools-extra] r327833 - [clang-tidy] New check bugprone-unused-return-value

2018-03-19 Thread Galina Kistanova via cfe-commits
Hello Alexander,

This commit broke at least two of our builders:

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

. . .
Failing Tests (1):
Clang Tools :: clang-tidy/bugprone-unused-return-value.cpp

Please have a look?

It is not good idea to keep the bot red for too long. This hides new
problem which later hard to track down.

Thanks

Galina

On Mon, Mar 19, 2018 at 6:02 AM, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Mon Mar 19 06:02:32 2018
> New Revision: 327833
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327833=rev
> Log:
> [clang-tidy] New check bugprone-unused-return-value
>
> Summary:
> Detects function calls where the return value is unused.
>
> Checked functions can be configured.
>
> Reviewers: alexfh, aaron.ballman, ilya-biryukov, hokein
>
> Reviewed By: alexfh, aaron.ballman
>
> Subscribers: hintonda, JonasToth, Eugene.Zelenko, mgorny, xazax.hun,
> cfe-commits
>
> Tags: #clang-tools-extra
>
> Patch by Kalle Huttunen!
>
> Differential Revision: https://reviews.llvm.org/D41655
>
> Added:
> clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
> clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.h
> clang-tools-extra/trunk/docs/clang-tidy/checks/bugprone-
> unused-return-value.rst
> clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-
> return-value-custom.cpp
> clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-
> return-value.cpp
> Modified:
> clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
> clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> clang-tools-extra/trunk/docs/ReleaseNotes.rst
> clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
>
> Modified: clang-tools-extra/trunk/clang-tidy/bugprone/
> BugproneTidyModule.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/bugprone/BugproneTidyModule.cpp?rev=
> 327833=327832=327833=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
> (original)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/BugproneTidyModule.cpp
> Mon Mar 19 06:02:32 2018
> @@ -43,6 +43,7 @@
>  #include "UndefinedMemoryManipulationCheck.h"
>  #include "UndelegatedConstructorCheck.h"
>  #include "UnusedRaiiCheck.h"
> +#include "UnusedReturnValueCheck.h"
>  #include "UseAfterMoveCheck.h"
>  #include "VirtualNearMissCheck.h"
>
> @@ -119,6 +120,8 @@ public:
>  "bugprone-undelegated-constructor");
>  CheckFactories.registerCheck(
>  "bugprone-unused-raii");
> +CheckFactories.registerCheck(
> +"bugprone-unused-return-value");
>  CheckFactories.registerCheck(
>  "bugprone-use-after-move");
>  CheckFactories.registerCheck(
>
> Modified: clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/bugprone/CMakeLists.txt?rev=327833=
> 327832=327833=diff
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt (original)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/CMakeLists.txt Mon Mar 19
> 06:02:32 2018
> @@ -35,6 +35,7 @@ add_clang_library(clangTidyBugproneModul
>UndefinedMemoryManipulationCheck.cpp
>UndelegatedConstructorCheck.cpp
>UnusedRaiiCheck.cpp
> +  UnusedReturnValueCheck.cpp
>UseAfterMoveCheck.cpp
>VirtualNearMissCheck.cpp
>
>
> Added: clang-tools-extra/trunk/clang-tidy/bugprone/
> UnusedReturnValueCheck.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp?rev=327833=auto
> 
> ==
> --- clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
> (added)
> +++ clang-tools-extra/trunk/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
> Mon Mar 19 06:02:32 2018
> @@ -0,0 +1,82 @@
> +//===--- UnusedReturnValueCheck.cpp - clang-tidy
> ---===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--
> ===//
> +
> +#include "UnusedReturnValueCheck.h"
> +#include "../utils/OptionsUtils.h"
> +#include "clang/AST/ASTContext.h"
> +#include "clang/ASTMatchers/ASTMatchFinder.h"
> +
> +using namespace clang::ast_matchers;
> +using namespace clang::ast_matchers::internal;
> +
> +namespace clang {
> +namespace tidy {
> +namespace bugprone {
> +
> +UnusedReturnValueCheck::UnusedReturnValueCheck(llvm::StringRef Name,
> + 

[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT added a comment.

Apologies if I've chosen the wrong set of reviewers.


Repository:
  rC Clang

https://reviews.llvm.org/D44646



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


[PATCH] D44646: Sema: in msvc compatibility mode, don't allow forceinline on variadics

2018-03-19 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT created this revision.
DHowett-MSFT added reviewers: rnk, majnemer.
DHowett-MSFT added a project: clang.
Herald added subscribers: cfe-commits, eraman.

The MSVC compiler rejects `__forceinline` on variadic functions with the 
following warning (at /https://reviews.llvm.org/W4):

  C4714: function 'void msvc_variadic(int,...)' marked as __forceinline not 
inlined

This fixes a bug in LLVM where a variadic was getting inlined into a function 
of calling convention x86_thiscallcc. The LLVM lowering passes cannot consume 
an `@llvm.va_start` intrinsic call in a thiscall function without emitting an 
assertion.

Inlining variadics should almost certainly be possible; however, this is a fix 
to bring Clang in line with MSVC.


Repository:
  rC Clang

https://reviews.llvm.org/D44646

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/ms-forceinline-on-variadic.cpp


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify 
-fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } 
// expected-warning {{inlining attribute 'always_inline' ignored on variadic 
function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning 
{{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the 
test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()
+ && hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return nullptr;
+  }
+
   if (D->hasAttr())
 return nullptr;
 
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2694,6 +2694,9 @@
 def warn_attribute_after_definition_ignored : Warning<
   "attribute %0 after definition is ignored">,
InGroup;
+def warn_always_inline_on_variadic : Warning<
+  "inlining attribute %0 ignored on variadic function">,
+   InGroup;
 def warn_unknown_attribute_ignored : Warning<
   "unknown attribute %0 ignored">, InGroup;
 def warn_cxx11_gnu_attribute_on_type : Warning<


Index: test/Sema/ms-forceinline-on-variadic.cpp
===
--- /dev/null
+++ test/Sema/ms-forceinline-on-variadic.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -emit-llvm -o - -triple i686-windows -verify -fms-extensions %s \
+// RUN:| FileCheck %s
+//
+// (instruction scheduling crash test)
+// RUN: %clang_cc1 -S -o - -triple i686-windows -fms-extensions %s
+
+inline __attribute__((always_inline)) void attribute_variadic(int f, ...) { } // expected-warning {{inlining attribute 'always_inline' ignored on variadic function}}
+
+__forceinline inline void msvc_variadic(int f, ...) { // expected-warning {{inlining attribute '__forceinline' ignored on variadic function}}
+// CHECK-DAG: define {{.*}} void [[MSVC_VARIADIC:@".*msvc_variadic.*"]](
+__builtin_va_list ap;
+__builtin_va_start(ap, f);
+__builtin_va_end(ap);
+}
+
+struct a {
+// members are, by default, thiscall; enforce it for the purposes of the test
+void __thiscall dispatcher();
+};
+
+void __thiscall a::dispatcher() {
+msvc_variadic(1, 2, 3);
+// CHECK-DAG: define dso_local x86_thiscallcc void @"{{.*dispatcher.*}}"(
+// CHECK-DAG: call void {{.*}} [[MSVC_VARIADIC]]
+}
+
+void t() {
+a{}.dispatcher();
+}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -3886,6 +3886,12 @@
 return nullptr;
   }
 
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()
+ && hasFunctionProto(D) && isFunctionOrMethodVariadic(D)) {
+Diag(Range.getBegin(), diag::warn_always_inline_on_variadic) << Ident;
+return 

[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

(an alternative would be to replace this 'NOT' clause with more specific 
library name — but I don't know which library could 'accidentally' appear here)


Repository:
  rC Clang

https://reviews.llvm.org/D44645



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


[PATCH] D44645: [test] Fix Cross-DSO CFI Android sanitizer test for -rtlib=compiler-rt

2018-03-19 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a reviewer: eugenis.
Herald added subscribers: dberris, srhines.
mgorny added inline comments.



Comment at: test/Driver/sanitizer-ld.c:517
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
 // CHECK-CFI-CROSS-DSO-ANDROID-NOT: libclang_rt.
 

(an alternative would be to replace this 'NOT' clause with more specific 
library name — but I don't know which library could 'accidentally' appear here)


Fix the CHECK-CFI-CROSS-DSO-ANDROID test to force -rtlib=libgcc.
Otherwise, if clang is built with CLANG_DEFAULT_RTLIB=compiler-rt,
the clang_rt.builtins library gets added to the command-line and causes
the 'clang_rt.' substring to unexpectedly match.


Repository:
  rC Clang

https://reviews.llvm.org/D44645

Files:
  test/Driver/sanitizer-ld.c


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -510,7 +510,7 @@
 
 // Cross-DSO CFI on Android does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-linux-android -fuse-ld=ld \
+// RUN: -target aarch64-linux-android -fuse-ld=ld -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"


Index: test/Driver/sanitizer-ld.c
===
--- test/Driver/sanitizer-ld.c
+++ test/Driver/sanitizer-ld.c
@@ -510,7 +510,7 @@
 
 // Cross-DSO CFI on Android does not link runtime libraries.
 // RUN: %clang -fsanitize=cfi -fsanitize-cfi-cross-dso %s -### -o %t.o 2>&1 \
-// RUN: -target aarch64-linux-android -fuse-ld=ld \
+// RUN: -target aarch64-linux-android -fuse-ld=ld -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/basic_android_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-CFI-CROSS-DSO-ANDROID %s
 // CHECK-CFI-CROSS-DSO-ANDROID: "{{.*}}ld{{(.exe)?}}"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D43494: [Modules] Fix creating fake definition data for lambdas.

2018-03-19 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

I think we have agreement on this change. If there are no objections, I plan to 
commit it on Wednesday, March 21.


https://reviews.llvm.org/D43494



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


[PATCH] D44630: [ms] Parse #pragma optimize and ignore it behind its own flag

2018-03-19 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.

Awesome, thanks! One nit below:




Comment at: include/clang/Basic/DiagnosticParseKinds.td:973
+def warn_pragma_optimize : Warning<
+  "'#pragma optimize' is not supported; use '#pragma clang optimize on|off' 
instead">,
+  InGroup;

Is `pragma clang optimize` really what we want to recommend here? `pragma 
optimize` is used in practice mostly to work around cl.exe compiler bugs, or to 
disable inlining. In neither case, `pragma clang optimize` is what you'd really 
want to use. Maybe just omit everything after ; and instead add a blurb about 
this in DiagnosticDocs.td ?


https://reviews.llvm.org/D44630



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


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC327892: [CodeGen] Add funclet token to ARC marker (authored 
by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D44640?vs=138973=138983#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44640

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjCXX/arc-marker-funclet.mm


Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- test/CodeGenObjCXX/arc-marker-funclet.mm
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}


Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- test/CodeGenObjCXX/arc-marker-funclet.mm
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ "funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL327892: [CodeGen] Add funclet token to ARC marker (authored 
by smeenai, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D44640?vs=138973=138984#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D44640

Files:
  cfe/trunk/lib/CodeGen/CGObjC.cpp
  cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm


Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}


Index: cfe/trunk/lib/CodeGen/CGObjC.cpp
===
--- cfe/trunk/lib/CodeGen/CGObjC.cpp
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
Index: cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ "funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44643: [Lex] Change HeaderSearchOptions arguments to std::string.

2018-03-19 Thread Frederich Munch via Phabricator via cfe-commits
marsupial created this revision.
marsupial added reviewers: eugene, boris.
marsupial added a project: clang.
marsupial updated this revision to Diff 138982.

Arguments passed to HeaderSearchOptions methods are stored as std::strings, 
having them converted to a StringRef at the call site can result in unnecessary 
conversions and copies.


https://reviews.llvm.org/D44643

Files:
  include/clang/Lex/HeaderSearchOptions.h


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, 
IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void 

[PATCH] D44643: [Lex] Change HeaderSearchOptions arguments to std::string.

2018-03-19 Thread Frederich Munch via Phabricator via cfe-commits
marsupial updated this revision to Diff 138982.

https://reviews.llvm.org/D44643

Files:
  include/clang/Lex/HeaderSearchOptions.h


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, 
IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 


Index: include/clang/Lex/HeaderSearchOptions.h
===
--- include/clang/Lex/HeaderSearchOptions.h
+++ include/clang/Lex/HeaderSearchOptions.h
@@ -203,34 +203,35 @@
 
   unsigned ModulesHashContent : 1;
 
-  HeaderSearchOptions(StringRef _Sysroot = "/")
-  : Sysroot(_Sysroot), ModuleFormat("raw"), DisableModuleHash(false),
-ImplicitModuleMaps(false), ModuleMapFileHomeIsCwd(false),
-UseBuiltinIncludes(true), UseStandardSystemIncludes(true),
-UseStandardCXXIncludes(true), UseLibcxx(false), Verbose(false),
+  HeaderSearchOptions(std::string _Sysroot = "/")
+  : Sysroot(std::move(_Sysroot)), ModuleFormat("raw"),
+DisableModuleHash(false), ImplicitModuleMaps(false),
+ModuleMapFileHomeIsCwd(false), UseBuiltinIncludes(true),
+UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
+UseLibcxx(false), Verbose(false),
 ModulesValidateOncePerBuildSession(false),
 ModulesValidateSystemHeaders(false), UseDebugInfo(false),
 ModulesValidateDiagnosticOptions(true), ModulesHashContent(false) {}
 
   /// AddPath - Add the \p Path path to the specified \p Group list.
-  void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
+  void AddPath(std::string Path, frontend::IncludeDirGroup Group,
bool IsFramework, bool IgnoreSysRoot) {
-UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
+UserEntries.emplace_back(std::move(Path), Group, IsFramework, IgnoreSysRoot);
   }
 
   /// AddSystemHeaderPrefix - Override whether \#include directives naming a
   /// path starting with \p Prefix should be considered as naming a system
   /// header.
-  void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
-SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
+  void AddSystemHeaderPrefix(std::string Prefix, bool IsSystemHeader) {
+SystemHeaderPrefixes.emplace_back(std::move(Prefix), IsSystemHeader);
   }
 
-  void AddVFSOverlayFile(StringRef Name) {
-VFSOverlayFiles.push_back(Name);
+  void AddVFSOverlayFile(std::string Name) {
+VFSOverlayFiles.emplace_back(std::move(Name));
   }
 
-  void AddPrebuiltModulePath(StringRef Name) {
-PrebuiltModulePaths.push_back(Name);
+  void AddPrebuiltModulePath(std::string Name) {
+PrebuiltModulePaths.emplace_back(std::move(Name));
   }
 };
 

r327892 - [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Mar 19 12:34:39 2018
New Revision: 327892

URL: http://llvm.org/viewvc/llvm-project?rev=327892=rev
Log:
[CodeGen] Add funclet token to ARC marker

The inline assembly generated for the ARC autorelease elision marker
must have a funclet token if it's emitted inside a funclet, otherwise
the inline assembly (and all subsequent code in the funclet) will be
marked unreachable. r324689 fixed this issue for regular inline assembly
blocks.

Note that clang only emits the marker at -O0, so this only fixes that
case. The optimizations case (where the marker is emitted by the
backend) will be fixed in a separate change.

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

Added:
cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp

Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=327892=327891=327892=diff
==
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Mon Mar 19 12:34:39 2018
@@ -2034,7 +2034,7 @@ static void emitAutoreleasedReturnValueM
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.

Added: cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm?rev=327892=auto
==
--- cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm (added)
+++ cfe/trunk/test/CodeGenObjCXX/arc-marker-funclet.mm Mon Mar 19 12:34:39 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}


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


[PATCH] D44426: Fix llvm + clang build with Intel compiler

2018-03-19 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

I added some inline comments. You are using the Intel 18.0 compiler on Windows 
- what version of Visual Studio is in the environment?




Comment at: include/llvm-c/Target.h:25
 
-#if defined(_MSC_VER) && !defined(inline)
+#if defined(_MSC_VER) && !defined(inline) && !defined(__INTEL_COMPILER)
 #define inline __inline

I really think all the Intel-compiler bug workarounds should be version 
specific. For example, in the boost.org customizations we have checks like this:
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)

I believe you are using the most recent Intel compiler, 18.0, which has version 
1800.  Let's assume the bug will either be fixed in our 18.0 compiler or in our 
next compiler which would be numbered 1900, so the check could be like this:
#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1900) // employ the 
workaround for the Intel 18.0 compiler and older

This way the workaround will "disappear" when the bug gets fixed.

For that matter I wonder if it's still necessary to use the workaround for the 
Microsoft compiler?

Thanks for reporting the bug into the Intel forum. If we put a bug workaround 
into LLVM it would be very nice to have the bug reported to the offending 
compiler. 




Comment at: include/llvm/ADT/BitmaskEnum.h:73
 
+#ifdef __INTEL_COMPILER
+template 

what problem is being worked around here? I checked your post into the Intel 
compiler forum "enum members are not visible to template specialization" and I 
can observe the bug on our Windows compiler but not our Linux compiler. 



Comment at: include/llvm/Analysis/AliasAnalysis.h:254
   FMRB_OnlyAccessesInaccessibleOrArgMem = FMRL_InaccessibleMem |
-  FMRL_ArgumentPointees |
+  
static_cast(FMRL_ArgumentPointees) |
   static_cast(ModRefInfo::ModRef),

is this a necessary workaround for the Intel compiler? It's not pretty.  
Suggest we add the #if around it? Long term i hope this would not be necessary.



Comment at: lib/Target/AMDGPU/SIISelLowering.cpp:6131
 
+#ifndef __INTEL_COMPILER
 static_assert(((~(SIInstrFlags::S_NAN |

this assesrts with Intel compiler?  Or the expression needs to be rewritten 
with static_cast as above?


https://reviews.llvm.org/D44426



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


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.

We should really just switch the reclaim to be marked with a bundle in the 
first place, but that's not a reasonable thing to ask you to do.


Repository:
  rC Clang

https://reviews.llvm.org/D44640



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


[clang-tools-extra] r327887 - [clang-move] Fix the failing test caused by changes in clang-format.

2018-03-19 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Mon Mar 19 12:13:03 2018
New Revision: 327887

URL: http://llvm.org/viewvc/llvm-project?rev=327887=rev
Log:
[clang-move] Fix the failing test caused by changes in clang-format.

Modified:
clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp

Modified: clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp?rev=327887=327886=327887=diff
==
--- clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-move/move-used-helper-decls.cpp Mon Mar 
19 12:13:03 2018
@@ -412,7 +412,6 @@
 // CHECK-NEW-CPP-NEXT: }
 // CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: void Fun1() { HelperFun5(); }
-// CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: } // namespace a
 // CHECK-NEW-CPP-SAME: {{[[:space:]]}}
 // CHECK-NEW-CPP-NEXT: namespace b {


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


[PATCH] D44640: [CodeGen] Add funclet token to ARC marker

2018-03-19 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai created this revision.
smeenai added reviewers: ahatanak, compnerd, majnemer, rjmccall, rnk.

The inline assembly generated for the ARC autorelease elision marker
must have a funclet token if it's emitted inside a funclet, otherwise
the inline assembly (and all subsequent code in the funclet) will be
marked unreachable. r324689 fixed this issue for regular inline assembly
blocks.

Note that clang only emits the marker at -O0, so this only fixes that
case. The optimizations case (where the marker is emitted by the
backend) will be fixed in a separate change.


Repository:
  rC Clang

https://reviews.llvm.org/D44640

Files:
  lib/CodeGen/CGObjC.cpp
  test/CodeGenObjCXX/arc-marker-funclet.mm


Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 
-fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"\01?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ 
"funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.


Index: test/CodeGenObjCXX/arc-marker-funclet.mm
===
--- /dev/null
+++ test/CodeGenObjCXX/arc-marker-funclet.mm
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple i686-unknown-windows-msvc -fobjc-runtime=ios-6.0 -fobjc-arc \
+// RUN:   -fexceptions -fcxx-exceptions -emit-llvm -o - %s | FileCheck %s
+
+id f();
+void g() {
+  try {
+f();
+  } catch (...) {
+f();
+  }
+}
+
+// CHECK: call i8* @"\01?f@@YAPAUobjc_object@@XZ"() [ "funclet"(token %1) ]
+// CHECK-NEXT: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""() [ "funclet"(token %1) ]
+
+// The corresponding f() call was invoked from the entry basic block.
+// CHECK: call void asm sideeffect "movl{{.*}}%ebp, %ebp{{.*}}", ""(){{$}}
Index: lib/CodeGen/CGObjC.cpp
===
--- lib/CodeGen/CGObjC.cpp
+++ lib/CodeGen/CGObjC.cpp
@@ -2034,7 +2034,7 @@
 
   // Call the marker asm if we made one, which we do only at -O0.
   if (marker)
-CGF.Builder.CreateCall(marker);
+CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker));
 }
 
 /// Retain the given object which is the result of a function call.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44606: [analyzer] Fix the crash in `IteratorChecker.cpp` when `SymbolConjured` has a null Stmt.

2018-03-19 Thread Peter Szecsi via Phabricator via cfe-commits
szepet added a comment.

Nice catch, it looks good to me! Thank you!
One small nit for future debugging people: Could you insert a comment line in 
the test case where you explain what is this all about? E.g what you just have 
written in the description: "invalidateRegions() will construct the 
SymbolConjured with null Stmt" or something like this.


Repository:
  rC Clang

https://reviews.llvm.org/D44606



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


[PATCH] D36918: [Sema] Take into account the current context when checking the accessibility of a member function pointer

2018-03-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

ping


https://reviews.llvm.org/D36918



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


[PATCH] D44638: [clang-format] Fix ObjC selectors with multiple params passed to macro

2018-03-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton created this revision.
benhamilton added reviewers: jolesiak, djasper, Wizard.
Herald added subscribers: cfe-commits, klimek.

Objective-C selectors can with arguments be in the form:

foo:
foo:bar:
foo:bar:baz:

These can be passed to a macro, like NS_SWIFT_NAME():

https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

and must never have spaces inserted around the colons.

Previously, there was logic in TokenAnnotator's tok::colon parser to
handle the single-argument case, but it failed for the
multiple-argument cases.

This diff fixes the bug and adds more tests.

Test Plan: New tests added. Ran tests with:

  % make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests


Repository:
  rC Clang

https://reviews.llvm.org/D44638

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestObjC.cpp


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -618,6 +618,9 @@
   verifyFormat("for (id foo in [self getStuffFor:bla]) {\n"
"}");
   verifyFormat("[self a:MACRO(a, b:, c:)];");
+  verifyFormat("[self a:MACRO(a, b:c:, d:e:)];");
+  verifyFormat("[self a:MACRO(a, b:c:d:, e:f:g:)];");
+  verifyFormat("int XYMyFoo(int a, int b) NS_SWIFT_NAME(foo(self:scale:));");
   verifyFormat("[self a:(1 + 2) b:3];");
   verifyFormat("[self a:(Type)a b:3];");
 
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -701,7 +701,8 @@
 else
   Tok->Type = TT_InheritanceColon;
   } else if (Tok->Previous->is(tok::identifier) && Tok->Next &&
- Tok->Next->isOneOf(tok::r_paren, tok::comma)) {
+ (Tok->Next->isOneOf(tok::r_paren, tok::comma) ||
+  Tok->Next->startsSequence(tok::identifier, tok::colon))) {
 // This handles a special macro in ObjC code where selectors including
 // the colon are passed as macro arguments.
 Tok->Type = TT_ObjCMethodExpr;


Index: unittests/Format/FormatTestObjC.cpp
===
--- unittests/Format/FormatTestObjC.cpp
+++ unittests/Format/FormatTestObjC.cpp
@@ -618,6 +618,9 @@
   verifyFormat("for (id foo in [self getStuffFor:bla]) {\n"
"}");
   verifyFormat("[self a:MACRO(a, b:, c:)];");
+  verifyFormat("[self a:MACRO(a, b:c:, d:e:)];");
+  verifyFormat("[self a:MACRO(a, b:c:d:, e:f:g:)];");
+  verifyFormat("int XYMyFoo(int a, int b) NS_SWIFT_NAME(foo(self:scale:));");
   verifyFormat("[self a:(1 + 2) b:3];");
   verifyFormat("[self a:(Type)a b:3];");
 
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -701,7 +701,8 @@
 else
   Tok->Type = TT_InheritanceColon;
   } else if (Tok->Previous->is(tok::identifier) && Tok->Next &&
- Tok->Next->isOneOf(tok::r_paren, tok::comma)) {
+ (Tok->Next->isOneOf(tok::r_paren, tok::comma) ||
+  Tok->Next->startsSequence(tok::identifier, tok::colon))) {
 // This handles a special macro in ObjC code where selectors including
 // the colon are passed as macro arguments.
 Tok->Type = TT_ObjCMethodExpr;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r327873 - [OPENMP, NVPTX] Reworked castToType() function, NFC.

2018-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Mar 19 10:53:56 2018
New Revision: 327873

URL: http://llvm.org/viewvc/llvm-project?rev=327873=rev
Log:
[OPENMP, NVPTX] Reworked castToType() function, NFC.

Reworked function castToType to use more frontend functionality rather
than the backend.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=327873=327872=327873=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Mar 19 10:53:56 2018
@@ -1477,49 +1477,53 @@ void CGOpenMPRuntimeNVPTX::emitSpmdParal
 }
 
 /// Cast value to the specified type.
-static llvm::Value *
-castValueToType(CodeGenFunction , llvm::Value *Val, llvm::Type *CastTy,
-llvm::Optional IsSigned = llvm::None) {
-  if (Val->getType() == CastTy)
+static llvm::Value *castValueToType(CodeGenFunction , llvm::Value *Val,
+QualType ValTy, QualType CastTy,
+SourceLocation Loc) {
+  assert(!CGF.getContext().getTypeSizeInChars(CastTy).isZero() &&
+ "Cast type must sized.");
+  assert(!CGF.getContext().getTypeSizeInChars(ValTy).isZero() &&
+ "Val type must sized.");
+  llvm::Type *LLVMCastTy = CGF.ConvertTypeForMem(CastTy);
+  if (ValTy == CastTy)
 return Val;
-  if (Val->getType()->getPrimitiveSizeInBits() > 0 &&
-  CastTy->getPrimitiveSizeInBits() > 0 &&
-  Val->getType()->getPrimitiveSizeInBits() ==
-  CastTy->getPrimitiveSizeInBits())
-return CGF.Builder.CreateBitCast(Val, CastTy);
-  if (IsSigned.hasValue() && CastTy->isIntegerTy() &&
-  Val->getType()->isIntegerTy())
-return CGF.Builder.CreateIntCast(Val, CastTy, *IsSigned);
-  Address CastItem = CGF.CreateTempAlloca(
-  CastTy,
-  CharUnits::fromQuantity(
-  CGF.CGM.getDataLayout().getPrefTypeAlignment(Val->getType(;
+  if (CGF.getContext().getTypeSizeInChars(ValTy) ==
+  CGF.getContext().getTypeSizeInChars(CastTy))
+return CGF.Builder.CreateBitCast(Val, LLVMCastTy);
+  if (CastTy->isIntegerType() && ValTy->isIntegerType())
+return CGF.Builder.CreateIntCast(Val, LLVMCastTy,
+ CastTy->hasSignedIntegerRepresentation());
+  Address CastItem = CGF.CreateMemTemp(CastTy);
   Address ValCastItem = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
   CastItem, Val->getType()->getPointerTo(CastItem.getAddressSpace()));
-  CGF.Builder.CreateStore(Val, ValCastItem);
-  return CGF.Builder.CreateLoad(CastItem);
+  CGF.EmitStoreOfScalar(Val, ValCastItem, /*Volatile=*/false, ValTy);
+  return CGF.EmitLoadOfScalar(CastItem, /*Volatile=*/false, CastTy, Loc);
 }
 
 /// This function creates calls to one of two shuffle functions to copy
 /// variables between lanes in a warp.
 static llvm::Value *createRuntimeShuffleFunction(CodeGenFunction ,
  llvm::Value *Elem,
- llvm::Value *Offset) {
+ QualType ElemType,
+ llvm::Value *Offset,
+ SourceLocation Loc) {
   auto  = CGF.CGM;
   auto  = CGF.Builder;
   CGOpenMPRuntimeNVPTX  =
   *(static_cast(()));
 
-  unsigned Size = CGM.getDataLayout().getTypeStoreSize(Elem->getType());
-  assert(Size <= 8 && "Unsupported bitwidth in shuffle instruction.");
+  CharUnits Size = CGF.getContext().getTypeSizeInChars(ElemType);
+  assert(Size.getQuantity() <= 8 &&
+ "Unsupported bitwidth in shuffle instruction.");
 
-  OpenMPRTLFunctionNVPTX ShuffleFn = Size <= 4
+  OpenMPRTLFunctionNVPTX ShuffleFn = Size.getQuantity() <= 4
  ? OMPRTL_NVPTX__kmpc_shuffle_int32
  : OMPRTL_NVPTX__kmpc_shuffle_int64;
 
   // Cast all types to 32- or 64-bit values before calling shuffle routines.
-  llvm::Type *CastTy = Size <= 4 ? CGM.Int32Ty : CGM.Int64Ty;
-  llvm::Value *ElemCast = castValueToType(CGF, Elem, CastTy, 
/*isSigned=*/true);
+  QualType CastTy = CGF.getContext().getIntTypeForBitwidth(
+  Size.getQuantity() <= 4 ? 32 : 64, /*Signed=*/1);
+  llvm::Value *ElemCast = castValueToType(CGF, Elem, ElemType, CastTy, Loc);
   auto *WarpSize =
   Bld.CreateIntCast(getNVPTXWarpSize(CGF), CGM.Int16Ty, /*isSigned=*/true);
 
@@ -1527,7 +1531,7 @@ static llvm::Value *createRuntimeShuffle
   CGF.EmitRuntimeCall(RT.createNVPTXRuntimeFunction(ShuffleFn),
   {ElemCast, Offset, WarpSize});
 
-  return castValueToType(CGF, ShuffledVal, Elem->getType(), /*isSigned=*/true);
+  return castValueToType(CGF, ShuffledVal, CastTy, ElemType, Loc);
 }
 
 namespace {
@@ 

[PATCH] D44619: [CodeGen] Add cleanup scope to EmitInlinedInheritingCXXConstructorCall

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

Code looks good, but we should make the test more robust and self-documenting.




Comment at: test/CodeGenCXX/inheriting-constructor-cleanup.cpp:22
+// CHECK-LABEL: define void @_Z1fv
+// CHECK: call void @_ZN1SD2Ev

The landingpad should be trivially dead, since T has nothing that throws in it, 
right? Clang is usually pretty smart about not emitting unused exceptional-only 
destructors, so I'd try to defend against it getting smart in the future. I'd 
put a function call `foo` in `T(int, ...)`, then CHECK for the invoke of it, 
and that it unwinds to a landingpad preceding this destructor call.


Repository:
  rC Clang

https://reviews.llvm.org/D44619



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


[PATCH] D44095: [ObjC] Allow declaring __weak pointer fields in C structs in ObjC-ARC

2018-03-19 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak added a comment.

This was reverted in r327294 because it caused module-enabled builders to fail 
after I moved CXXRecordDecl::CanPassInRegisters to RecordDecl. I'm recommitting 
this patch with fixes to ASTDeclReader and ASTWriter.


Repository:
  rC Clang

https://reviews.llvm.org/D44095



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


r327870 - [ObjC] Allow declaring __weak pointer fields in C structs in ARC.

2018-03-19 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Mar 19 10:38:40 2018
New Revision: 327870

URL: http://llvm.org/viewvc/llvm-project?rev=327870=rev
Log:
[ObjC] Allow declaring __weak pointer fields in C structs in ARC.

This patch uses the infrastructure added in r326307 for enabling
non-trivial fields to be declared in C structs to allow __weak fields in
C structs in ARC.

This recommits r327206, which was reverted because it caused
module-enabled builders to fail. I discovered that the
CXXRecordDecl::CanPassInRegisters flag wasn't being set correctly in
some cases after I moved it to RecordDecl.

Thanks to Eric Liu for helping me investigate the bug.

rdar://problem/33599681

https://reviews.llvm.org/D44095

Added:
cfe/trunk/test/CodeGenObjC/weak-in-c-struct.m
cfe/trunk/test/Modules/Inputs/template-nontrivial0.h
cfe/trunk/test/Modules/Inputs/template-nontrivial1.h
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/CodeGen/CGBlocks.cpp
cfe/trunk/lib/CodeGen/CGNonTrivialStruct.cpp
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenObjC/nontrivial-c-struct-exception.m
cfe/trunk/test/Modules/Inputs/module.map
cfe/trunk/test/Modules/templates.mm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=327870=327869=327870=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Mar 19 10:38:40 2018
@@ -3553,6 +3553,12 @@ class RecordDecl : public TagDecl {
   bool NonTrivialToPrimitiveCopy : 1;
   bool NonTrivialToPrimitiveDestroy : 1;
 
+  /// True if this class can be passed in a non-address-preserving fashion
+  /// (such as in registers).
+  /// This does not imply anything about how the ABI in use will actually
+  /// pass an object of this class.
+  bool CanPassInRegisters : 1;
+
 protected:
   RecordDecl(Kind DK, TagKind TK, const ASTContext , DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
@@ -3636,6 +3642,18 @@ public:
 NonTrivialToPrimitiveDestroy = V;
   }
 
+  /// Determine whether this class can be passed in registers. In C++ mode,
+  /// it must have at least one trivial, non-deleted copy or move constructor.
+  /// FIXME: This should be set as part of completeDefinition.
+  bool canPassInRegisters() const {
+return CanPassInRegisters;
+  }
+
+  /// Set that we can pass this RecordDecl in registers.
+  void setCanPassInRegisters(bool CanPass) {
+CanPassInRegisters = CanPass;
+  }
+
   /// \brief Determines whether this declaration represents the
   /// injected class name.
   ///

Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=327870=327869=327870=diff
==
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Mon Mar 19 10:38:40 2018
@@ -467,12 +467,6 @@ class CXXRecordDecl : public RecordDecl
 /// constructor.
 unsigned HasDefaultedDefaultConstructor : 1;
 
-/// \brief True if this class can be passed in a non-address-preserving
-/// fashion (such as in registers) according to the C++ language rules.
-/// This does not imply anything about how the ABI in use will actually
-/// pass an object of this class.
-unsigned CanPassInRegisters : 1;
-
 /// \brief True if a defaulted default constructor for this class would
 /// be constexpr.
 unsigned DefaultedDefaultConstructorIsConstexpr : 1;
@@ -1474,18 +1468,6 @@ public:
 return data().HasIrrelevantDestructor;
   }
 
-  /// \brief Determine whether this class has at least one trivial, non-deleted
-  /// copy or move constructor.
-  bool canPassInRegisters() const {
-return data().CanPassInRegisters;
-  }
-
-  /// \brief Set that we can pass this RecordDecl in registers.
-  // FIXME: This should be set as part of completeDefinition.
-  void setCanPassInRegisters(bool CanPass) {
-data().CanPassInRegisters = CanPass;
-  }
-
   /// Determine whether the triviality for the purpose of calls for this class
   /// is overridden to be trivial because this class or the type of one of its
   /// subobjects has attribute "trivial_abi".

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 

[PATCH] D44272: [clangd] Support incremental document syncing

2018-03-19 Thread Simon Marchi via Phabricator via cfe-commits
simark marked 3 inline comments as done.
simark added inline comments.



Comment at: clangd/DraftStore.cpp:61
+  const Position  = Change.range->start;
+  size_t StartIndex = positionToOffset(Contents, Start);
+  if (StartIndex > Contents.length()) {

ilya-biryukov wrote:
> `positionToOffset` always truncates to size of contents. It has to return 
> `Expected` too here.
Indeed, it would be better.



Comment at: clangd/DraftStore.cpp:73
+  if (EndIndex > Contents.length()) {
+return llvm::make_error(
+llvm::formatv("Range's end position (line={0}, character={1}) is "

ilya-biryukov wrote:
> Having partially applied changes in the map seems weird. Maybe the code 
> applying the diffs to a separate function that returns either new contents or 
> an error and use it here?
> I.e. we won't be able to end up in a state with partially applied changes:
> 
> ```
> Expected applyChanges(StringRef Contents, 
> ArrayRef Changes) {
> }
> 
> // See other comment about Version.
> Expected updateDraft(StringRef File, /*int Version,*/ 
> ArrayRef Changes) {
>   // check File is in the map and version matches
>   //...
>   string& Contents = ...;
>   auto NewContents = applyChanges(Contents, Changes);
>   if (!NewContents) 
> return NewContents.takeError();
>   Contents = *NewContents;
>   return std::move(*NewContents);
> }
> ```
It makes sense, but I think we can achieve the same result by just tweaking the 
current code. I don't think a separate function is really needed here.



Comment at: clangd/DraftStore.cpp:97
+
+  NewContents.reserve(StartIndex + Change.text.length() +
+  (Contents.length() - EndIndex));

ilya-biryukov wrote:
> The math is correct, but I'm confused on how to properly read the formula 
> here. 
> Maybe change to:
> `Contents.length() - (EndIndex - StartIndex) + Change.text.length()`?
> 
> This clearly reads as:
> `LengthBefore - LengthRemoved + LengthAdded`
I saw it as `LengthOfTheSliceFromTheOriginalThatWeKeepBefore + LengthOfNewStuff 
+ LengthOfTheSliceFromTheOriginalThatWeKeepAfter`.  But I don't mind changing 
it.



Comment at: clangd/DraftStore.cpp:103
+
+  if (EndIndex < Contents.length())
+NewContents += Contents.substr(EndIndex);

ilya-biryukov wrote:
> This check seems unnecessary, we've already checked for range errors. Maybe 
> remove it?
Note that this check is not equivalent to the previous

if (EndIndex > Contents.length())

for the case where `EndIndex == Contents.length()`. In our case, it's possible 
(and valid) for EndIndex to be equal to Contents.length(), when referring to 
the end of the document (past the last character).  I thought that doing 
`Contents.substr(Contents.length())` would be throw `std::out_of_range` or be 
undefined behavior, but now that I read it correctly:

@throw  std::out_of_range  If __pos > size().

So it looks like it would fine to have pos == Contents.length().


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D44272



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


r327868 - [OPENMP] Fix build with MSVC, NFC.

2018-03-19 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Mon Mar 19 10:18:13 2018
New Revision: 327868

URL: http://llvm.org/viewvc/llvm-project?rev=327868=rev
Log:
[OPENMP] Fix build with MSVC, NFC.

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

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=327868=327867=327868=diff
==
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Mar 19 10:18:13 2018
@@ -1419,8 +1419,8 @@ void CGOpenMPRuntimeNVPTX::emitGenericPa
   auto *ThreadID = getThreadID(CGF, Loc);
   llvm::Value *Args[] = {RTLoc, ThreadID};
 
-  auto & = [this, Fn, CapturedVars, Args, Loc](CodeGenFunction ,
-  PrePostActionTy &) {
+  auto & = [this, Fn, CapturedVars, , Loc](CodeGenFunction ,
+   PrePostActionTy &) {
 auto & = [this, Fn, CapturedVars, Loc](CodeGenFunction ,
PrePostActionTy ) {
   Action.Enter(CGF);


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


[PATCH] D44539: [Sema][Objective-C] Add check to warn when property of objc type has assign attribute

2018-03-19 Thread Ben Hamilton via Phabricator via cfe-commits
benhamilton added a comment.

I wonder if this wouldn't be better as a clang-tidy check:

https://github.com/llvm-mirror/clang-tools-extra/tree/master/clang-tidy/objc


Repository:
  rC Clang

https://reviews.llvm.org/D44539



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


Re: r327738 - [MS] Don't escape MS C++ names with \01

2018-03-19 Thread Rafael Avila de Espindola via cfe-commits
Thanks!

Reid Kleckner via cfe-commits  writes:

> Author: rnk
> Date: Fri Mar 16 13:36:49 2018
> New Revision: 327738
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327738=rev
> Log:
> [MS] Don't escape MS C++ names with \01
>
> It is not needed after LLVM r327734. Now it will be easier to copy-paste
> IR symbol names from Clang.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >