r307201 - Fix one more reference to lit.util.capture()

2017-07-05 Thread Michael Zolotukhin via cfe-commits
Author: mzolotukhin
Date: Wed Jul  5 14:06:11 2017
New Revision: 307201

URL: http://llvm.org/viewvc/llvm-project?rev=307201&view=rev
Log:
Fix one more reference to lit.util.capture()

The capture method was removed in r306643.

Modified:
cfe/trunk/utils/perf-training/lit.cfg
cfe/trunk/utils/perf-training/order-files.lit.cfg

Modified: cfe/trunk/utils/perf-training/lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/lit.cfg?rev=307201&r1=307200&r2=307201&view=diff
==
--- cfe/trunk/utils/perf-training/lit.cfg (original)
+++ cfe/trunk/utils/perf-training/lit.cfg Wed Jul  5 14:06:11 2017
@@ -3,13 +3,14 @@
 from lit import Test
 import lit.formats
 import lit.util
+import subprocess
 
 def getSysrootFlagsOnDarwin(config, lit_config):
 # On Darwin, support relocatable SDKs by providing Clang with a
 # default system root path.
 if 'darwin' in config.target_triple:
 try:
-out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
+out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
 res = 0
 except OSError:
 res = -1

Modified: cfe/trunk/utils/perf-training/order-files.lit.cfg
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/order-files.lit.cfg?rev=307201&r1=307200&r2=307201&view=diff
==
--- cfe/trunk/utils/perf-training/order-files.lit.cfg (original)
+++ cfe/trunk/utils/perf-training/order-files.lit.cfg Wed Jul  5 14:06:11 2017
@@ -4,13 +4,14 @@ from lit import Test
 import lit.formats
 import lit.util
 import os
+import subprocess
 
 def getSysrootFlagsOnDarwin(config, lit_config):
 # On Darwin, support relocatable SDKs by providing Clang with a
 # default system root path.
 if 'darwin' in config.target_triple:
 try:
-out = lit.util.capture(['xcrun', '--show-sdk-path']).strip()
+out = subprocess.check_output(['xcrun', '--show-sdk-path']).strip()
 res = 0
 except OSError:
 res = -1


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


Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-09-08 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi Richard, Hal,

Does the patch look good now?

Thanks,
Michael


http://reviews.llvm.org/D12313



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


r247104 - Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-09-08 Thread Michael Zolotukhin via cfe-commits
Author: mzolotukhin
Date: Tue Sep  8 18:52:33 2015
New Revision: 247104

URL: http://llvm.org/viewvc/llvm-project?rev=247104&view=rev
Log:
Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

Summary:
Currently clang provides no general way to generate nontemporal loads/stores.
There are some architecture specific builtins for doing so (e.g. in x86), but
there is no way to generate non-temporal store on, e.g. AArch64. This patch adds
generic builtins which are expanded to a simple store with '!nontemporal'
attribute in IR.

Differential Revision: http://reviews.llvm.org/D12313

Added:
cfe/trunk/test/CodeGen/Nontemporal.cpp
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CGExpr.cpp
cfe/trunk/lib/CodeGen/CGValue.h
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaChecking.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=247104&r1=247103&r2=247104&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Sep  8 18:52:33 2015
@@ -1245,6 +1245,10 @@ BUILTIN(__builtin_operator_delete, "vv*"
 BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
 BUILTIN(__builtin___get_unsafe_stack_ptr, "v*", "Fn")
 
+// Nontemporal loads/stores builtins
+BUILTIN(__builtin_nontemporal_store, "v.", "t")
+BUILTIN(__builtin_nontemporal_load, "v.", "t")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=247104&r1=247103&r2=247104&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Sep  8 18:52:33 
2015
@@ -6200,6 +6200,12 @@ def err_atomic_load_store_uses_lib : Err
   "atomic %select{load|store}0 requires runtime support that is not "
   "available for this target">;
 
+def err_nontemporal_builtin_must_be_pointer : Error<
+  "address argument to nontemporal builtin must be a pointer (%0 invalid)">;
+def err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector : Error<
+  "address argument to nontemporal builtin must be a pointer to integer, 
float, "
+  "pointer, or a vector of such types (%0 invalid)">;
+
 def err_deleted_function_use : Error<"attempt to use a deleted function">;
 
 def err_kern_type_not_void_return : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=247104&r1=247103&r2=247104&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Tue Sep  8 18:52:33 2015
@@ -8851,6 +8851,7 @@ private:
   bool SemaBuiltinLongjmp(CallExpr *TheCall);
   bool SemaBuiltinSetjmp(CallExpr *TheCall);
   ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
+  ExprResult SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult);
   ExprResult SemaAtomicOpsOverloaded(ExprResult TheCallResult,
  AtomicExpr::AtomicOp Op);
   bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=247104&r1=247103&r2=247104&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Sep  8 18:52:33 2015
@@ -111,6 +111,28 @@ static Value *MakeBinaryAtomicValue(Code
   return EmitFromInt(CGF, Result, T, ValueType);
 }
 
+static Value *EmitNontemporalStore(CodeGenFunction &CGF, const CallExpr *E) {
+  Value *Val = CGF.EmitScalarExpr(E->getArg(0));
+  Value *Address = CGF.EmitScalarExpr(E->getArg(1));
+
+  // Convert the type of the pointer to a pointer to the stored type.
+  Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
+  Value *BC = CGF.Builder.CreateBitCast(
+  Address, llvm::PointerType::getUnqual(Val->getType()), "cast");
+  LValue LV = CGF.MakeNaturalAlignAddrLValue(BC, E->getArg(0)->getType());
+  LV.setNontemporal(true);
+  CGF.EmitStoreOfScalar(Val, LV, false);
+  return nullptr;
+}
+
+static Value *EmitNontemporalLoad(CodeGenFunction &CGF, const CallExpr *E) {
+  Value *Address = CGF.EmitScalarExpr(E->getArg(0));
+
+  LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getType());
+  LV.setNontemporal(true);
+  return CGF.EmitLoadOfScalar(LV, E->getEx

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-09-08 Thread Michael Zolotukhin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247104: Introduce __builtin_nontemporal_store and 
__builtin_nontemporal_load. (authored by mzolotukhin).

Changed prior to commit:
  http://reviews.llvm.org/D12313?vs=33492&id=34281#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12313

Files:
  cfe/trunk/include/clang/Basic/Builtins.def
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/include/clang/Sema/Sema.h
  cfe/trunk/lib/CodeGen/CGBuiltin.cpp
  cfe/trunk/lib/CodeGen/CGExpr.cpp
  cfe/trunk/lib/CodeGen/CGValue.h
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/CodeGen/Nontemporal.cpp

Index: cfe/trunk/include/clang/Sema/Sema.h
===
--- cfe/trunk/include/clang/Sema/Sema.h
+++ cfe/trunk/include/clang/Sema/Sema.h
@@ -8851,6 +8851,7 @@
   bool SemaBuiltinLongjmp(CallExpr *TheCall);
   bool SemaBuiltinSetjmp(CallExpr *TheCall);
   ExprResult SemaBuiltinAtomicOverloaded(ExprResult TheCallResult);
+  ExprResult SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult);
   ExprResult SemaAtomicOpsOverloaded(ExprResult TheCallResult,
  AtomicExpr::AtomicOp Op);
   bool SemaBuiltinConstantArg(CallExpr *TheCall, int ArgNum,
Index: cfe/trunk/include/clang/Basic/Builtins.def
===
--- cfe/trunk/include/clang/Basic/Builtins.def
+++ cfe/trunk/include/clang/Basic/Builtins.def
@@ -1245,6 +1245,10 @@
 BUILTIN(__builtin___get_unsafe_stack_start, "v*", "Fn")
 BUILTIN(__builtin___get_unsafe_stack_ptr, "v*", "Fn")
 
+// Nontemporal loads/stores builtins
+BUILTIN(__builtin_nontemporal_store, "v.", "t")
+BUILTIN(__builtin_nontemporal_load, "v.", "t")
+
 #undef BUILTIN
 #undef LIBBUILTIN
 #undef LANGBUILTIN
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6200,6 +6200,12 @@
   "atomic %select{load|store}0 requires runtime support that is not "
   "available for this target">;
 
+def err_nontemporal_builtin_must_be_pointer : Error<
+  "address argument to nontemporal builtin must be a pointer (%0 invalid)">;
+def err_nontemporal_builtin_must_be_pointer_intfltptr_or_vector : Error<
+  "address argument to nontemporal builtin must be a pointer to integer, float, "
+  "pointer, or a vector of such types (%0 invalid)">;
+
 def err_deleted_function_use : Error<"attempt to use a deleted function">;
 
 def err_kern_type_not_void_return : Error<
Index: cfe/trunk/test/CodeGen/Nontemporal.cpp
===
--- cfe/trunk/test/CodeGen/Nontemporal.cpp
+++ cfe/trunk/test/CodeGen/Nontemporal.cpp
@@ -0,0 +1,48 @@
+// Test frontend handling of nontemporal builtins.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+signed char sc;
+unsigned char uc;
+signed short ss;
+unsigned short us;
+signed int si;
+unsigned int ui;
+signed long long sll;
+unsigned long long ull;
+float f1, f2;
+double d1, d2;
+float __attribute__((vector_size(16))) vf1, vf2;
+char __attribute__((vector_size(8))) vc1, vc2;
+bool b1, b2;
+
+void test_all_sizes(void) // CHECK-LABEL: test_all_sizes
+{
+  __builtin_nontemporal_store(true, &b1); // CHECK: store i8 1, i8* @b1, align 1, !nontemporal
+  __builtin_nontemporal_store(b1, &b2);   // CHECK: store i8{{.*}}, align 1, !nontemporal
+  __builtin_nontemporal_store(1, &uc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &sc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &us);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ss);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ui);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &si);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &ull);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1, &sll);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1.0, &f1);  // CHECK: store float{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1.0, &d1);  // CHECK: store double{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(vf1, &vf2); // CHECK: store <4 x float>{{.*}}align 16, !nontemporal
+  __builtin_nontemporal_store(vc1, &vc2); // CHECK: store <8 x i8>{{.*}}align 8, !nontemporal
+
+  b1 = __builtin_nontemporal_load(&b2);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  uc = __builtin_nontemporal_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  sc = __builtin_nontemporal_load(&uc);   // CHECK: load i8{{.*}}align 1, !n

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-09-08 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Thanks, Hal, Richard!

I committed the patch with requested changes in r247107.

Michael


Repository:
  rL LLVM

http://reviews.llvm.org/D12313



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


[PATCH] D12785: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
mzolotukhin created this revision.
mzolotukhin added reviewers: hfinkel, rsmith.
mzolotukhin added a subscriber: cfe-commits.

In r247104 I added the builtins for generating non-temporal memory operations,
but now I realized that they lack documentation. This patch adds some.

http://reviews.llvm.org/D12785

Files:
  docs/LanguageExtensions.rst

Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1778,6 +1778,36 @@
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing to generate non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+would be used.  Also, using non-temporal loads and stores might change program
+semantics on some targets, so the builtins should be used with care.
+
+For example, on AArch64 in the following code::
+
+  LDR X1, [X2]
+  LDNP X3, X4, [X1]
+
+the ``LDNP`` might be executed before the ``LDR``. In this case the load would
+be performed from a wrong address (see 6.3.8 in `Programmer's Guide for ARMv8-A
+`_).
+
 Non-standard C++11 Attributes
 =
 


Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1778,6 +1778,36 @@
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing to generate non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+would be used.  Also, using non-temporal loads and stores might change program
+semantics on some targets, so the builtins should be used with care.
+
+For example, on AArch64 in the following code::
+
+  LDR X1, [X2]
+  LDNP X3, X4, [X1]
+
+the ``LDNP`` might be executed before the ``LDR``. In this case the load would
+be performed from a wrong address (see 6.3.8 in `Programmer's Guide for ARMv8-A
+`_).
+
 Non-standard C++11 Attributes
 =
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247360 - Docs: Add missing new line before a list.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
Author: mzolotukhin
Date: Thu Sep 10 18:56:10 2015
New Revision: 247360

URL: http://llvm.org/viewvc/llvm-project?rev=247360&view=rev
Log:
Docs: Add missing new line before a list.

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=247360&r1=247359&r2=247360&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Thu Sep 10 18:56:10 2015
@@ -1760,6 +1760,7 @@ instructions for implementing atomic ope
   void __builtin_arm_clrex(void);
 
 The types ``T`` currently supported are:
+
 * Integer types with width at most 64 bits (or 128 bits on AArch64).
 * Floating-point types
 * Pointer types.


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


Re: [PATCH] D12785: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added inline comments.


Comment at: docs/LanguageExtensions.rst:1802-1807
@@ +1801,8 @@
+
+For example, on AArch64 in the following code::
+
+  LDR X1, [X2]
+  LDNP X3, X4, [X1]
+
+the ``LDNP`` might be executed before the ``LDR``. In this case the load would
+be performed from a wrong address (see 6.3.8 in `Programmer's Guide for ARMv8-A

rsmith wrote:
> This seems to make the feature essentially useless, since you cannot 
> guarantee that the address register is set up sufficiently far before the 
> non-temporal load. Should the compiler not be required to insert the 
> necessary barrier itself in this case?
Yes, we can require targets to only use corresponding NT instructions when it's 
safe, and then remove this remark from the documentation. For ARM64 that would 
mean either not to emit LDNP at all, or conservatively emit barriers before 
each LDNP (which probably removes all performance benefits of using it) - that 
is, yes, non-temporal loads would be useless on this target.

But I think we want to keep the builtin for NT-load, as it's a generic feature, 
not ARM64 specific. It can be used on other targets - e.g. we can use this in 
x86 stream builtins, and hopefully simplify their current implementation. I 
don't know about non-temporal operations on other targets, but if there are 
others, they can use it too right out of the box.


http://reviews.llvm.org/D12785



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


Re: [PATCH] D12785: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
mzolotukhin updated this revision to Diff 34521.
mzolotukhin added a comment.

- Remove paragraph about changing program behavior (since we shouldn't change 
it anyway).


http://reviews.llvm.org/D12785

Files:
  docs/LanguageExtensions.rst

Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1778,6 +1778,26 @@
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing to generate non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types.
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+would be used.
+
 Non-standard C++11 Attributes
 =
 


Index: docs/LanguageExtensions.rst
===
--- docs/LanguageExtensions.rst
+++ docs/LanguageExtensions.rst
@@ -1778,6 +1778,26 @@
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing to generate non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types.
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+would be used.
+
 Non-standard C++11 Attributes
 =
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12785: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL247374: Docs: Document __builtin_nontemporal_load and 
__builtin_nontemporal_store. (authored by mzolotukhin).

Changed prior to commit:
  http://reviews.llvm.org/D12785?vs=34521&id=34524#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D12785

Files:
  cfe/trunk/docs/LanguageExtensions.rst

Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -1779,6 +1779,26 @@
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing generation of non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types.
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+will be used.
+
 Non-standard C++11 Attributes
 =
 


Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -1779,6 +1779,26 @@
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing generation of non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types.
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+will be used.
+
 Non-standard C++11 Attributes
 =
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r247374 - Docs: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
Author: mzolotukhin
Date: Thu Sep 10 21:01:15 2015
New Revision: 247374

URL: http://llvm.org/viewvc/llvm-project?rev=247374&view=rev
Log:
Docs: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

Summary:
In r247104 I added the builtins for generating non-temporal memory operations,
but now I realized that they lack documentation. This patch adds some.

Differential Revision: http://reviews.llvm.org/D12785

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=247374&r1=247373&r2=247374&view=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Thu Sep 10 21:01:15 2015
@@ -1779,6 +1779,26 @@ care should be exercised.
 For these reasons the higher level atomic primitives should be preferred where
 possible.
 
+Non-temporal load/store builtins
+
+
+Clang provides overloaded builtins allowing generation of non-temporal memory
+accesses.
+
+.. code-block:: c
+
+  T __builtin_nontemporal_load(T *addr);
+  void __builtin_nontemporal_store(T value, T *addr);
+
+The types ``T`` currently supported are:
+
+* Integer types.
+* Floating-point types.
+* Vector types.
+
+Note that the compiler does not guarantee that non-temporal loads or stores
+will be used.
+
 Non-standard C++11 Attributes
 =
 


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


Re: [PATCH] D12785: Document __builtin_nontemporal_load and __builtin_nontemporal_store.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Thanks, committed in r247374 with the requested changes!

Michael


Repository:
  rL LLVM

http://reviews.llvm.org/D12785



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-09-10 Thread Michael Zolotukhin via cfe-commits
mzolotukhin abandoned this revision.
mzolotukhin added a comment.

We decided to go with an alternative way - with builtins instead of type 
attributes. The corresponding patch is http://reviews.llvm.org/D12313, and it's 
already reviewed and committed.


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12821: Allow for C's "writing off the end" idiom in __builtin_object_size

2015-09-27 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

FWIW, I'm really interested in seeing this patch in!

Thanks,
Michael


http://reviews.llvm.org/D12821



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


[PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-20 Thread Michael Zolotukhin via cfe-commits
mzolotukhin created this revision.
mzolotukhin added reviewers: hfinkel, doug.gregor, t.p.northover, ab, mcrosier.
mzolotukhin added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

Currently there is no way to generate nontemporal memory accesses for some
architectures, e.g. for AArch64. In contrast to x86, it doesn't have special
intrinsics for this, and the suggested solution is using such attribute (see ARM
ACLE 2.0, section 13.1.6). The attribute would result in generating
'!nontemporal' attribute in IR, which then will (hopefully) live through
optimizations till backend, where it will be lowered to a non-temporal
instruction (for AArch64 - to STNP). I have committed a couple of patches for
vectorizers to preserve this attribute, and it seems that no other
transformation removes it.

So, is introducing a new type attribute a right approach for this problem?

Also, since I don't have much experience in front-end, I'd appreciate any help
with the patch itself to get it ready to be committed. Specifically, I currently
have following questions:
1) What tests should I add (examples would be appreciated)?
2) How does one implements constraints on how the attribute can be used, what
should be the constraints in this case, and how to properly implement them?
3) How can I check if I covered all places where this attribute might be used in
codegen? I.e. I seem to cover array-subscript and pointer-dereference
expressions, which is probaly the only cases I care about, but I easily could
miss something.

Any other feedback is also welcome!

Thanks,
Michael

http://reviews.llvm.org/D12221

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaType.cpp
  test/CodeGen/nontemporal.cpp

Index: test/CodeGen/nontemporal.cpp
===
--- /dev/null
+++ test/CodeGen/nontemporal.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+typedef float * PtrT;
+typedef float * __attribute__((nontemporal)) NonTemporalPtrT;
+
+// CHECK-LABEL: @_Z3fooPfS_S_i
+void foo(NonTemporalPtrT a, NonTemporalPtrT b, PtrT c, int N) {
+// CHECK-DAG:  [[VALUE_B:%.+]] = load float, float* %{{[0-9a-z._]+}}, align 4, !nontemporal ![[NT:[0-9]+]]
+// CHECK-DAG:  [[VALUE_C:%.+]] = load float, float* %{{[0-9a-z._]+}}, align 4{{$}}
+// CHECK:  [[VALUE_SUB:%.+]] = fsub float [[VALUE_B]], [[VALUE_C]]
+// CHECK:  store float [[VALUE_SUB]], float* %{{[0-9a-z._]+}}, align 4, !nontemporal ![[NT]]
+  a[N] = b[N] - c[N];
+}
+
+// CHECK-LABEL: @_Z4foo2PfS_S_
+void foo2(NonTemporalPtrT a, NonTemporalPtrT b, PtrT c) {
+// CHECK-DAG:  [[VALUE_B:%.+]] = load float, float* %{{[0-9]+}}, align 4, !nontemporal ![[NT:[0-9]+]]
+// CHECK-DAG:  [[VALUE_C:%.+]] = load float, float* %{{[0-9]+}}, align 4{{$}}
+// CHECK:  [[VALUE_SUB:%.+]] = fsub float [[VALUE_B]], [[VALUE_C]]
+// CHECK:  store float [[VALUE_SUB]], float* %{{[0-9]+}}, align 4, !nontemporal ![[NT]]
+  *a = *b - *c;
+}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -644,6 +644,7 @@
 
 // Objective-C __kindof does not get distributed.
 case AttributeList::AT_ObjCKindOf:
+case AttributeList::AT_TypeNonTemporal:
   continue;
 
 default:
@@ -4436,6 +4437,8 @@
 return AttributeList::AT_TypeNonNull;
   case AttributedType::attr_nullable:
 return AttributeList::AT_TypeNullable;
+  case AttributedType::attr_nontemporal:
+return AttributeList::AT_TypeNonTemporal;
   case AttributedType::attr_null_unspecified:
 return AttributeList::AT_TypeNullUnspecified;
   case AttributedType::attr_objc_kindof:
@@ -6191,6 +6194,12 @@
   }
   break;
 
+case AttributeList::AT_TypeNonTemporal:
+  type = state.getSema().Context.getAttributedType(
+  AttributedType::attr_nontemporal, type, type);
+  attr.setUsedAsTypeAttr();
+  break;
+
 case AttributeList::AT_ObjCKindOf:
   // '__kindof' must be part of the decl-specifiers.
   switch (TAL) {
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1497,12 +1497,14 @@
   //======//
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T,
-CharUnits Alignment = CharUnits()) {
+CharUnits Alignment = CharUnits(),
+bool isNonTemporal = false) {
 return LValue::MakeAddr(V, T, Alignment, getContext(),
-CGM.getTBAAInfo(T));
+CGM.getTBAAInfo(T), isNonTemporal);
   }
 
-  LValue MakeNatu

Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi all,

Thanks for the feedback, please find my answers below:

> What does it mean to have the attribute applied to non-pointer types like int 
> __attribute__((nontemporal)) i; ? The ACLE doesn't say but making it 
> erroneous might make sense. Perhaps it would be good to have a semantic test 
> which uses __attribute__((nontemporal)).


**David**,
That's a good idea. Actually, I don't know how we should behave in such cases, 
but probably just giving an error should be fine. And should we handle 
references in a similar manner (`int __attribute__((nontemporal)) &i)`? I'll 
update the patch correspondingly if we decide to go with type attributes.

> This seems like a property of an operation, rather than a property of a type. 
> Have you considered adding a __builtin_nontemporal_store builtin as an 
> alternative?


**Richard**,
Yes, I've considered a builitin as an alternative. In fact, I started with it 
as it was easier to implement, but then decided to switch to type attribute due 
to the following reasons:

1. ARM ACLE 2.0 mentions attribute. Though it's not a final version of the 
document, AFAIU, I still preferred to use it as an argument for type-attribute.
2. Once we introduce a builtin, we'll have to support it forever (otherwise we 
could break someone's code). With the attribute the burden is much smaller, as 
we can just start ignoring it at any point if we need to - all the code will 
remain correct and compilable.
3. We'll need to have an intrinsic for every type + separate intrinsics for 
loads and stores. If we use the type attribute, one fits all.
4. While it's true, that this is more type of operation, than a type, I think 
in real use-cases a user would rarely need to use it on a single operation. 
I.e. nontemporal operations are usually used for processing bulk volumes of 
data, and probably this data is almost always is processed as a whole. That's 
why I think it's fine to mark the entire 'data' as nontemporal. And, if a user 
then wants to work with a small subset of it, she can use a usual (not 
nontemporal) pointer to it.
5. Personally, I find the code using attributes more elegant than using 
builtins. Compare:

  void foo(float *__attribute__((nontemporal)) dst,
   float *__attribute__((nontemporal)) src1,
   float *__attribute__((nontemporal)) src2) {
*dst = *src1 + *src2;
  }

and

  void foo(float *dst, float *src1, float *src2) {
float s1 = __builtin_nontemporal_load(src1);
float s2 = __builtin_nontemporal_load(src2);
__builtin_nontemporal_store(s1 + s2, dst);
  }

But that said, in the end I'm open to other alternatives (including builtins), 
and this thread is just an attempt to find the best option.

> This doesn't seem like a fundamental property of a type, to me. If I 
> understand properly, this has more to do with specific instances of memory 
> access. By making it part of the type, you run into sticky situations that 
> become hard to resolve, such as with templates in C++.


**Aaron**,
As far as I understand, type attributes doesn't result in such complications 
(as opposed to type qualifiers, e.g. `__restrict__`). That is, it doesn't 
change the canonical type, it only adds some 'sugar' to it. I.e. ` float 
*__attribute__((nontemporal))` and `float *` would behave as the same type in 
templates and names mangling. Please correct me if I'm wrong here.

Thanks,
Michael


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Oh, I see. So, you meant something like this?

  void foo(std::vector av, float * b, int 
N) {
for (auto a: av)  // << `a` doesn't have nontemporal attribute here
  for (int i = 0; i < N; i++)
a[i] = b[i]+1;
  }

One can easily work around it by using an explicit type here (`float * 
__attribute__((nontemporal))` instead of `auto`), but I agree that disappeared 
attribute might be a surprise for the user. Do you think it would be a frequent 
case?

BTW, there are other type attributes, which also suffer from the same issue, 
e.g. `vector_size`. What was the rationale of making them type attributes?


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Thanks for the feedback everyone!
I think at this point I'll try to return to builtins then. In my original patch 
I didn't have type overloading, so I'll need some time to add this. We can 
return back to type attributes later if we'd like to.

And do I understand it correctly, that we are talking about target-independent 
builtins?


http://reviews.llvm.org/D12221



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


[PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-24 Thread Michael Zolotukhin via cfe-commits
mzolotukhin created this revision.
mzolotukhin added reviewers: rsmith, aaron.ballman, doug.gregor, t.p.northover, 
ab, mcrosier, hfinkel, majnemer.
mzolotukhin added a subscriber: cfe-commits.
Herald added a subscriber: aemerson.

Currently clang provides no general way to generate nontemporal loads/stores.
There are some architecture specific builtins for doing so (e.g. in x86), but
there is no way to generate non-temporal store on, e.g. AArch64. This patch adds
generic builtins which are expanded to a simple store with '!nontemporal'
attribute in IR.
Previously I tried to tackle the same issue by introducing
__attribute__((nontemporal)) (see D12221), but was convinced that builtins might
fit for such use better.

Does the patch look good?

Thanks,
Michael

http://reviews.llvm.org/D12313

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/Nontemporal.c

Index: test/CodeGen/Nontemporal.c
===
--- /dev/null
+++ test/CodeGen/Nontemporal.c
@@ -0,0 +1,56 @@
+// Test frontend handling of nontemporal builtins.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+signed char sc;
+unsigned char uc;
+signed short ss;
+unsigned short us;
+signed int si;
+unsigned int ui;
+signed long long sll;
+unsigned long long ull;
+float f1, f2;
+double d1, d2;
+
+void test_explicit_datasize (void)// CHECK-LABEL: define void @test_explicit_datasize
+{
+  __builtin_nontemporal_store(f1, &f2);   // CHECK: store float{{.*}}!nontemporal
+  __builtin_nontemporal_store_f(f1, &f2); // CHECK: store float{{.*}}!nontemporal
+  __builtin_nontemporal_store_1(sc, &f2); // CHECK: store i8{{.*}}!nontemporal
+  __builtin_nontemporal_store_4(d1, &f2); // CHECK: store i32{{.*}}!nontemporal
+
+  f2 = __builtin_nontemporal_load(&f1);// CHECK: load float{{.*}}!nontemporal
+  f2 = __builtin_nontemporal_load_f(&f1);  // CHECK: load float{{.*}}!nontemporal
+  sc = __builtin_nontemporal_load_1(&f2);  // CHECK: load i8{{.*}}!nontemporal
+  d1 = __builtin_nontemporal_load_1(&f2);  // CHECK: [[D1:%[a-z0-9._]+]] = load i8{{.*}}!nontemporal
+   // CHECK: sitofp i8 [[D1]] to double
+  si = __builtin_nontemporal_load_4(&f2);  // CHECK: load i32{{.*}}!nontemporal
+  sll = __builtin_nontemporal_load_8(&f2); // CHECK: load i64{{.*}}!nontemporal
+  si = __builtin_nontemporal_load(&f1);// CHECK: [[SI:%[a-z0-9._]+]] = load float{{.*}}!nontemporal
+   // CHECK: fptosi float [[SI]] to i32
+}
+
+void test_all_sizes (void)// CHECK-LABEL: define void @test_all_sizes
+{
+  __builtin_nontemporal_store(1, &uc);// CHECK: store i8{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &sc);// CHECK: store i8{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &us);// CHECK: store i16{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &ss);// CHECK: store i16{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &ui);// CHECK: store i32{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &si);// CHECK: store i32{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &ull);   // CHECK: store i64{{.*}}!nontemporal
+  __builtin_nontemporal_store(1, &sll);   // CHECK: store i64{{.*}}!nontemporal
+  __builtin_nontemporal_store(1.0, &f1);  // CHECK: store float{{.*}}!nontemporal
+  __builtin_nontemporal_store(1.0, &d1);  // CHECK: store double{{.*}}!nontemporal
+
+  uc = __builtin_nontemporal_load(&sc);// CHECK: load i8{{.*}}!nontemporal
+  sc = __builtin_nontemporal_load(&uc);// CHECK: load i8{{.*}}!nontemporal
+  us = __builtin_nontemporal_load(&ss);// CHECK: load i16{{.*}}!nontemporal
+  ss = __builtin_nontemporal_load(&us);// CHECK: load i16{{.*}}!nontemporal
+  ui = __builtin_nontemporal_load(&si);// CHECK: load i32{{.*}}!nontemporal
+  si = __builtin_nontemporal_load(&ui);// CHECK: load i32{{.*}}!nontemporal
+  ull = __builtin_nontemporal_load(&sll);  // CHECK: load i64{{.*}}!nontemporal
+  sll = __builtin_nontemporal_load(&ull);  // CHECK: load i64{{.*}}!nontemporal
+  f1 = __builtin_nontemporal_load(&f2);// CHECK: load float{{.*}}!nontemporal
+  d1 = __builtin_nontemporal_load(&d2);// CHECK: load double{{.*}}!nontemporal
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -440,6 +440,9 @@
   case Builtin::BI__sync_swap_8:
   case Builtin::BI__sync_swap_16:
 return SemaBuiltinAtomicOverloaded(TheCallResult);
+  case Builtin::BI__builtin_nontemporal_load:
+  case Builtin::BI__builtin_nontemporal_store:
+return SemaBuiltinNontemporalOverloaded(TheCallResult);
 #define BUILTIN(ID, TYPE, ATTRS)
 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
   case Builtin::BI##ID: \
@@ -2209,6 

Re: [PATCH] D12221: [RFC] Introduce `__attribute__((nontemporal))`.

2015-08-26 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi,

I implemented builtin-based version in http://reviews.llvm.org/D12313 - could 
you please take a look?

Thanks,
Michael


http://reviews.llvm.org/D12221



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


Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-27 Thread Michael Zolotukhin via cfe-commits
mzolotukhin updated this revision to Diff 33396.
mzolotukhin added a comment.

Address review remarks:

- Remove typed versions - indeed, we don't need them.
- Allow vector types.
- Properly handle bool-type (promote i1 to i8).
- Check arguments number.
- Simplify SemaBuiltinNontemporalOverloaded (as we don't use typed versions 
now).
- Add tests for vector and bool types.


http://reviews.llvm.org/D12313

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/Nontemporal.cpp

Index: test/CodeGen/Nontemporal.cpp
===
--- /dev/null
+++ test/CodeGen/Nontemporal.cpp
@@ -0,0 +1,48 @@
+// Test frontend handling of nontemporal builtins.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+signed char sc;
+unsigned char uc;
+signed short ss;
+unsigned short us;
+signed int si;
+unsigned int ui;
+signed long long sll;
+unsigned long long ull;
+float f1, f2;
+double d1, d2;
+float __attribute__((vector_size(16))) vf1, vf2;
+char __attribute__((vector_size(8))) vc1, vc2;
+bool b1, b2;
+
+void test_all_sizes(void) // CHECK-LABEL: test_all_sizes
+{
+  __builtin_nontemporal_store(true, &b1); // CHECK: store i8 1, i8* @b1, align 1, !nontemporal
+  __builtin_nontemporal_store(b1, &b2);   // CHECK: store i8{{.*}}, align 1, !nontemporal
+  __builtin_nontemporal_store(1, &uc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &sc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &us);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ss);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ui);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &si);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &ull);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1, &sll);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1.0, &f1);  // CHECK: store float{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1.0, &d1);  // CHECK: store double{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(vf1, &vf2); // CHECK: store <4 x float>{{.*}}align 16, !nontemporal
+  __builtin_nontemporal_store(vc1, &vc2); // CHECK: store <8 x i8>{{.*}}align 8, !nontemporal
+
+  b1 = __builtin_nontemporal_load(&b2);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  uc = __builtin_nontemporal_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  sc = __builtin_nontemporal_load(&uc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  us = __builtin_nontemporal_load(&ss);   // CHECK: load i16{{.*}}align 2, !nontemporal
+  ss = __builtin_nontemporal_load(&us);   // CHECK: load i16{{.*}}align 2, !nontemporal
+  ui = __builtin_nontemporal_load(&si);   // CHECK: load i32{{.*}}align 4, !nontemporal
+  si = __builtin_nontemporal_load(&ui);   // CHECK: load i32{{.*}}align 4, !nontemporal
+  ull = __builtin_nontemporal_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal
+  sll = __builtin_nontemporal_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal
+  f1 = __builtin_nontemporal_load(&f2);   // CHECK: load float{{.*}}align 4, !nontemporal
+  d1 = __builtin_nontemporal_load(&d2);   // CHECK: load double{{.*}}align 8, !nontemporal
+  vf2 = __builtin_nontemporal_load(&vf1); // CHECK: load <4 x float>{{.*}}align 16, !nontemporal
+  vc2 = __builtin_nontemporal_load(&vc1); // CHECK: load <8 x i8>{{.*}}align 8, !nontemporal
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -441,6 +441,9 @@
   case Builtin::BI__sync_swap_8:
   case Builtin::BI__sync_swap_16:
 return SemaBuiltinAtomicOverloaded(TheCallResult);
+  case Builtin::BI__builtin_nontemporal_load:
+  case Builtin::BI__builtin_nontemporal_store:
+return SemaBuiltinNontemporalOverloaded(TheCallResult);
 #define BUILTIN(ID, TYPE, ATTRS)
 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
   case Builtin::BI##ID: \
@@ -2210,6 +2213,80 @@
   return TheCallResult;
 }
 
+/// SemaBuiltinNontemporalOverloaded - We have a call to
+/// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
+/// overloaded function based on the pointer type of its last argument.
+/// The main ActOnCallExpr routines have already promoted the types of
+/// arguments because all of these calls are prototyped as void(...).
+///
+/// This function goes through and does final semantic checking for these
+/// builtins.
+ExprResult Sema::SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult) {
+  CallExpr *TheCall = (CallExpr *)TheCallResult.get();
+  DeclRefExpr *DRE =
+  cast(TheCall->

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-27 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi Richard, Hal, and others,

I updated the patch according to review remarks - now we support vector and 
boolean types too! Could you please take a look?

Thanks,
Michael



Comment at: lib/CodeGen/CGBuiltin.cpp:128-129
@@ +127,4 @@
+  Val = CGF.EmitToMemory(Val, E->getArg(0)->getType());
+  Value *BC = CGF.Builder.CreateBitCast(
+  Address, llvm::PointerType::getUnqual(Val->getType()), "cast");
+  StoreInst *SI = CGF.Builder.CreateStore(Val, BC);

Thanks! Fixed.


Comment at: lib/CodeGen/CGBuiltin.cpp:149
@@ +148,3 @@
+  return LI;
+}
+

In this case we already have with `i8` value - AFAIU, we get `i8*` pointer from 
`EmitScalarExpr(E->getArg(0))`. Do I miss something here?


Comment at: lib/Sema/SemaChecking.cpp:2236-2242
@@ +2235,9 @@
+
+  // Ensure that we have the proper number of arguments.
+  if (checkArgCount(*this, TheCall, numArgs))
+return ExprError();
+
+  // Inspect the last argument of the nontemporal builtin.  This should always
+  // be a pointer type, from which we imply the type of the memory access.
+  // Because it is a pointer type, we don't have to worry about any implicit
+  // casts here.

Good idea, thanks!


http://reviews.llvm.org/D12313



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


Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-27 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

> I still have this question:


Oops, sorry - I missed that. I'll check how can we reuse that logic.

Thanks,
Michael


http://reviews.llvm.org/D12313



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


Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-28 Thread Michael Zolotukhin via cfe-commits
mzolotukhin updated this revision to Diff 33492.
mzolotukhin added a comment.

- Use EmitStoreOfScalar and EmitLoadOfScalar for generating nontemporal loads 
and stores.
- Rebase on TOT.


http://reviews.llvm.org/D12313

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.h
  lib/Sema/SemaChecking.cpp
  test/CodeGen/Nontemporal.cpp

Index: test/CodeGen/Nontemporal.cpp
===
--- /dev/null
+++ test/CodeGen/Nontemporal.cpp
@@ -0,0 +1,48 @@
+// Test frontend handling of nontemporal builtins.
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
+
+signed char sc;
+unsigned char uc;
+signed short ss;
+unsigned short us;
+signed int si;
+unsigned int ui;
+signed long long sll;
+unsigned long long ull;
+float f1, f2;
+double d1, d2;
+float __attribute__((vector_size(16))) vf1, vf2;
+char __attribute__((vector_size(8))) vc1, vc2;
+bool b1, b2;
+
+void test_all_sizes(void) // CHECK-LABEL: test_all_sizes
+{
+  __builtin_nontemporal_store(true, &b1); // CHECK: store i8 1, i8* @b1, align 1, !nontemporal
+  __builtin_nontemporal_store(b1, &b2);   // CHECK: store i8{{.*}}, align 1, !nontemporal
+  __builtin_nontemporal_store(1, &uc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &sc);// CHECK: store i8{{.*}}align 1, !nontemporal
+  __builtin_nontemporal_store(1, &us);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ss);// CHECK: store i16{{.*}}align 2, !nontemporal
+  __builtin_nontemporal_store(1, &ui);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &si);// CHECK: store i32{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1, &ull);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1, &sll);   // CHECK: store i64{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(1.0, &f1);  // CHECK: store float{{.*}}align 4, !nontemporal
+  __builtin_nontemporal_store(1.0, &d1);  // CHECK: store double{{.*}}align 8, !nontemporal
+  __builtin_nontemporal_store(vf1, &vf2); // CHECK: store <4 x float>{{.*}}align 16, !nontemporal
+  __builtin_nontemporal_store(vc1, &vc2); // CHECK: store <8 x i8>{{.*}}align 8, !nontemporal
+
+  b1 = __builtin_nontemporal_load(&b2);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  uc = __builtin_nontemporal_load(&sc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  sc = __builtin_nontemporal_load(&uc);   // CHECK: load i8{{.*}}align 1, !nontemporal
+  us = __builtin_nontemporal_load(&ss);   // CHECK: load i16{{.*}}align 2, !nontemporal
+  ss = __builtin_nontemporal_load(&us);   // CHECK: load i16{{.*}}align 2, !nontemporal
+  ui = __builtin_nontemporal_load(&si);   // CHECK: load i32{{.*}}align 4, !nontemporal
+  si = __builtin_nontemporal_load(&ui);   // CHECK: load i32{{.*}}align 4, !nontemporal
+  ull = __builtin_nontemporal_load(&sll); // CHECK: load i64{{.*}}align 8, !nontemporal
+  sll = __builtin_nontemporal_load(&ull); // CHECK: load i64{{.*}}align 8, !nontemporal
+  f1 = __builtin_nontemporal_load(&f2);   // CHECK: load float{{.*}}align 4, !nontemporal
+  d1 = __builtin_nontemporal_load(&d2);   // CHECK: load double{{.*}}align 8, !nontemporal
+  vf2 = __builtin_nontemporal_load(&vf1); // CHECK: load <4 x float>{{.*}}align 16, !nontemporal
+  vc2 = __builtin_nontemporal_load(&vc1); // CHECK: load <8 x i8>{{.*}}align 8, !nontemporal
+}
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -441,6 +441,9 @@
   case Builtin::BI__sync_swap_8:
   case Builtin::BI__sync_swap_16:
 return SemaBuiltinAtomicOverloaded(TheCallResult);
+  case Builtin::BI__builtin_nontemporal_load:
+  case Builtin::BI__builtin_nontemporal_store:
+return SemaBuiltinNontemporalOverloaded(TheCallResult);
 #define BUILTIN(ID, TYPE, ATTRS)
 #define ATOMIC_BUILTIN(ID, TYPE, ATTRS) \
   case Builtin::BI##ID: \
@@ -2210,6 +2213,80 @@
   return TheCallResult;
 }
 
+/// SemaBuiltinNontemporalOverloaded - We have a call to
+/// __builtin_nontemporal_store or __builtin_nontemporal_load, which is an
+/// overloaded function based on the pointer type of its last argument.
+/// The main ActOnCallExpr routines have already promoted the types of
+/// arguments because all of these calls are prototyped as void(...).
+///
+/// This function goes through and does final semantic checking for these
+/// builtins.
+ExprResult Sema::SemaBuiltinNontemporalOverloaded(ExprResult TheCallResult) {
+  CallExpr *TheCall = (CallExpr *)TheCallResult.get();
+  DeclRefExpr *DRE =
+  cast(TheCall->getCallee()->IgnoreParenCasts());
+  FunctionDecl *FDecl = cast(DRE->getDecl());
+  unsigned BuiltinID = FDe

Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-08-28 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Hi Hal,

I added `Nontemporal` field to LValue and started to use it in 
`EmitStoreOfScalar`/`EmitLoadOfScalar`. Does it look like something you had in 
mind?

Thanks,
Michael


http://reviews.llvm.org/D12313



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


Re: [PATCH] D12313: Introduce __builtin_nontemporal_store and __builtin_nontemporal_load.

2015-09-01 Thread Michael Zolotukhin via cfe-commits
mzolotukhin added a comment.

Gentle ping.


http://reviews.llvm.org/D12313



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


Re: [libcxx] r249929 - Split out of .

2015-10-24 Thread Michael Zolotukhin via cfe-commits
Hi Richard,

Is this patch ready for commit, or were you just checking an idea? Our bots are 
still failing to build povray, so we’re really looking forward for some fix:)

Thanks,
Michael

> On Oct 15, 2015, at 6:21 PM, Manman Ren via cfe-commits 
>  wrote:
> 
>> 
>> On Oct 15, 2015, at 1:41 PM, Richard Smith > > wrote:
>> 
>> On Thu, Oct 15, 2015 at 12:03 PM, Manman Ren via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> On Oct 15, 2015, at 11:25 AM, Richard Smith >> > wrote:
>>> 
>>> I assume the code in question has a "using namespace std;"?
>>> 
>>> 
>> Yes
>> 
>>> I don't see any way around this other than giving up on trying to fix the 
>>> function signatures here (or maybe adding a Clang feature to let us fix the 
>>> bad signature).
>>> 
>>> 
>> Can you elaborate on how to fix the bad signature by adding a Clang feature? 
>> I want to see how hard it is before giving up on trying to fix the 
>> signatures.
>> 
>> I thought about this a bit more, and we already have a feature that can be 
>> used for this.
>> 
>> Please let me know if the attached patch resolves the issue for you. This 
>> should also fix the wrong overload sets for these functions being provided 
>> by  on Darwin.
> 
> This works on my testing case. Thanks!!
> 
> Manman
> 
>> 
>> 
>> Eric, Marshall: the attached patch adds a macro _LIBCPP_PREFERRED_OVERLOAD 
>> that can be applied to a function to (a) mark it as a separate overload from 
>> any other function with the same signature without the overload, and (b) 
>> instruct the compiler that it's preferred over another function with the 
>> same signature without the attribute. This allows us to replace the libc 
>> function
>> 
>>   char *strchr(const char *, int);
>> 
>> with the C++ overload set:
>> 
>>   const char *strchr(const char *, int);
>>   char *strchr(char *, int);
>> 
>> It only works with Clang, though; for other compilers, we leave the C 
>> library's signature alone (as we used to before my patches landed).
>> 
>> Thanks,
>> Manman
>> 
>> 
>>> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> Hi Richard,
>>> 
>>> This is causing a failure when building povray on iOS.
>>> 
>>> Compilation error:
>>> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
>>>  error: call to 'strrchr' is ambiguous
>>>  const char *p=strrchr(name, '.’);
>>> 
>>> iOS.sdk/usr/include/string.h:87:7: note: candidate function
>>> char*strrchr(const char *, int);
>>>  ^
>>> /Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46:
>>>  note: candidate function
>>> inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int 
>>> __c) {return ::strrchr(__s, __c);}
>>> 
>>> It is a little strange to have "char*strrchr(const char *, int);” in 
>>> iOS. But it is already in our SDK.
>>> 
>>> Do you have any suggestion on how to fix this?
>>> 
>>> Thanks,
>>> Manman
>>> 
>>> > On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits 
>>> > mailto:cfe-commits@lists.llvm.org>> wrote:
>>> >
>>> > Author: rsmith
>>> > Date: Fri Oct  9 20:25:31 2015
>>> > New Revision: 249929
>>> >
>>> > URL: http://llvm.org/viewvc/llvm-project?rev=249929&view=rev 
>>> > 
>>> > Log:
>>> > Split  out of .
>>> >
>>> > Also fix the overload set for the five functions whose signatures change 
>>> > in the
>>> > case where we can fix it. This is already covered by existing tests for 
>>> > the
>>> > affected systems.
>>> >
>>> > Added:
>>> >libcxx/trunk/include/string.h
>>> >  - copied, changed from r249736, libcxx/trunk/include/cstring
>>> > Modified:
>>> >libcxx/trunk/include/cstring
>>> >
>>> > Modified: libcxx/trunk/include/cstring
>>> > URL: 
>>> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cstring?rev=249929&r1=249928&r2=249929&view=diff
>>> >  
>>> > 
>>> > ==
>>> > --- libcxx/trunk/include/cstring (original)
>>> > +++ libcxx/trunk/include/cstring Fri Oct  9 20:25:31 2015
>>> > @@ -78,37 +78,42 @@ using ::strcmp;
>>> > using ::strncmp;
>>> > using ::strcoll;
>>> > using ::strxfrm;
>>> > +using ::strcspn;
>>> > +using ::strspn;
>>> > +#ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS
>>> > +using ::strtok;
>>> > +#endif
>>> > +using ::memset;
>>> > +using ::strerror;
>>> > +using ::strlen;
>>> >
>>> > -using ::memchr;
>>> > +// MSVCRT, GNU libc and its derivates already have the correct prototype 
>>> > in
>>> > +//  if __cplusplus is defined. This macro can be defined by 
>>> > users if
>>> > +// their C library provides the right signature.
>>> > 

Re: [libcxx] r249929 - Split out of .

2015-10-24 Thread Michael Zolotukhin via cfe-commits
Hi Eric,

Understood, thanks!

Michael

> On Oct 24, 2015, at 1:18 AM, Eric Fiselier  wrote:
> 
> Hi Michael,
> 
> Sorry I'm holding this patch up in review. The fix is quite "novel" and I 
> want to make sure we get it right. If we can't land it over the weekend I'll 
> ask Richard to revert while we work on it.
> 
> /Eric
> 
> On Oct 23, 2015 10:13 PM, "Michael Zolotukhin via cfe-commits" 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hi Richard,
> 
> Is this patch ready for commit, or were you just checking an idea? Our bots 
> are still failing to build povray, so we’re really looking forward for some 
> fix:)
> 
> Thanks,
> Michael
> 
>> On Oct 15, 2015, at 6:21 PM, Manman Ren via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> 
>>> On Oct 15, 2015, at 1:41 PM, Richard Smith >> <mailto:rich...@metafoo.co.uk>> wrote:
>>> 
>>> On Thu, Oct 15, 2015 at 12:03 PM, Manman Ren via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>>> On Oct 15, 2015, at 11:25 AM, Richard Smith >>> <mailto:rich...@metafoo.co.uk>> wrote:
>>>> 
>>>> I assume the code in question has a "using namespace std;"?
>>>> 
>>>> 
>>> Yes
>>> 
>>>> I don't see any way around this other than giving up on trying to fix the 
>>>> function signatures here (or maybe adding a Clang feature to let us fix 
>>>> the bad signature).
>>>> 
>>>> 
>>> Can you elaborate on how to fix the bad signature by adding a Clang 
>>> feature? I want to see how hard it is before giving up on trying to fix the 
>>> signatures.
>>> 
>>> I thought about this a bit more, and we already have a feature that can be 
>>> used for this.
>>> 
>>> Please let me know if the attached patch resolves the issue for you. This 
>>> should also fix the wrong overload sets for these functions being provided 
>>> by  on Darwin.
>> 
>> This works on my testing case. Thanks!!
>> 
>> Manman
>> 
>>> 
>>> 
>>> Eric, Marshall: the attached patch adds a macro _LIBCPP_PREFERRED_OVERLOAD 
>>> that can be applied to a function to (a) mark it as a separate overload 
>>> from any other function with the same signature without the overload, and 
>>> (b) instruct the compiler that it's preferred over another function with 
>>> the same signature without the attribute. This allows us to replace the 
>>> libc function
>>> 
>>>   char *strchr(const char *, int);
>>> 
>>> with the C++ overload set:
>>> 
>>>   const char *strchr(const char *, int);
>>>   char *strchr(char *, int);
>>> 
>>> It only works with Clang, though; for other compilers, we leave the C 
>>> library's signature alone (as we used to before my patches landed).
>>> 
>>> Thanks,
>>> Manman
>>> 
>>> 
>>>> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" 
>>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>>> Hi Richard,
>>>> 
>>>> This is causing a failure when building povray on iOS.
>>>> 
>>>> Compilation error:
>>>> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
>>>>  error: call to 'strrchr' is ambiguous
>>>>  const char *p=strrchr(name, '.’);
>>>> 
>>>> iOS.sdk/usr/include/string.h:87:7: note: candidate function
>>>> char*strrchr(const char *, int);
>>>>  ^
>>>> /Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46:
>>>>  note: candidate function
>>>> inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int 
>>>> __c) {return ::strrchr(__s, __c);}
>>>> 
>>>> It is a little strange to have "char*strrchr(const char *, int);” in 
>>>> iOS. But it is already in our SDK.
>>>> 
>>>> Do you have any suggestion on how to fix this?
>>>> 
>>>> Thanks,
>>>> Manman
>>>> 
>>>> > On Oct 9, 2015, at 6:25 PM, Richard Smith via cfe-commits 
>>>> > mailto:cfe-commits@lists.llvm.org>> wrote:
>>>> >
>>>> >

Re: [libcxx] r249929 - Split out of .

2015-10-28 Thread Michael Zolotukhin via cfe-commits
Hi Eric, Richard,

Any news on this? The test is still broken, should we revert the commit for now?

Thanks,
Michael

> On Oct 24, 2015, at 1:18 AM, Eric Fiselier  wrote:
> 
> Hi Michael,
> 
> Sorry I'm holding this patch up in review. The fix is quite "novel" and I 
> want to make sure we get it right. If we can't land it over the weekend I'll 
> ask Richard to revert while we work on it.
> 
> /Eric
> 
> On Oct 23, 2015 10:13 PM, "Michael Zolotukhin via cfe-commits" 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hi Richard,
> 
> Is this patch ready for commit, or were you just checking an idea? Our bots 
> are still failing to build povray, so we’re really looking forward for some 
> fix:)
> 
> Thanks,
> Michael
> 
>> On Oct 15, 2015, at 6:21 PM, Manman Ren via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> 
>>> 
>>> On Oct 15, 2015, at 1:41 PM, Richard Smith >> <mailto:rich...@metafoo.co.uk>> wrote:
>>> 
>>> On Thu, Oct 15, 2015 at 12:03 PM, Manman Ren via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>>> On Oct 15, 2015, at 11:25 AM, Richard Smith >>> <mailto:rich...@metafoo.co.uk>> wrote:
>>>> 
>>>> I assume the code in question has a "using namespace std;"?
>>>> 
>>>> 
>>> Yes
>>> 
>>>> I don't see any way around this other than giving up on trying to fix the 
>>>> function signatures here (or maybe adding a Clang feature to let us fix 
>>>> the bad signature).
>>>> 
>>>> 
>>> Can you elaborate on how to fix the bad signature by adding a Clang 
>>> feature? I want to see how hard it is before giving up on trying to fix the 
>>> signatures.
>>> 
>>> I thought about this a bit more, and we already have a feature that can be 
>>> used for this.
>>> 
>>> Please let me know if the attached patch resolves the issue for you. This 
>>> should also fix the wrong overload sets for these functions being provided 
>>> by  on Darwin.
>> 
>> This works on my testing case. Thanks!!
>> 
>> Manman
>> 
>>> 
>>> 
>>> Eric, Marshall: the attached patch adds a macro _LIBCPP_PREFERRED_OVERLOAD 
>>> that can be applied to a function to (a) mark it as a separate overload 
>>> from any other function with the same signature without the overload, and 
>>> (b) instruct the compiler that it's preferred over another function with 
>>> the same signature without the attribute. This allows us to replace the 
>>> libc function
>>> 
>>>   char *strchr(const char *, int);
>>> 
>>> with the C++ overload set:
>>> 
>>>   const char *strchr(const char *, int);
>>>   char *strchr(char *, int);
>>> 
>>> It only works with Clang, though; for other compilers, we leave the C 
>>> library's signature alone (as we used to before my patches landed).
>>> 
>>> Thanks,
>>> Manman
>>> 
>>> 
>>>> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" 
>>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>>> Hi Richard,
>>>> 
>>>> This is causing a failure when building povray on iOS.
>>>> 
>>>> Compilation error:
>>>> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
>>>>  error: call to 'strrchr' is ambiguous
>>>>  const char *p=strrchr(name, '.’);
>>>> 
>>>> iOS.sdk/usr/include/string.h:87:7: note: candidate function
>>>> char*strrchr(const char *, int);
>>>>  ^
>>>> /Users/buildslave/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/cstring:109:46:
>>>>  note: candidate function
>>>> inline _LIBCPP_INLINE_VISIBILITY const char* strrchr(const char* __s, int 
>>>> __c) {return ::strrchr(__s, __c);}
>>>> 
>>>> It is a little strange to have "char*strrchr(const char *, int);” in 
>>>> iOS. But it is already in our SDK.
>>>> 
>>>> Do you have any suggestion on how to fix this?
>>>> 
>>>> Thanks,
>>>> Manman
>>>> 
>>>> > On 

Re: [libcxx] r249929 - Split out of .

2015-11-01 Thread Michael Zolotukhin via cfe-commits
Thanks, Richard! Just to confirm, the test is passing now.

Michael

> On Oct 29, 2015, at 5:22 PM, Richard Smith  wrote:
> 
> I reverted this change in r251665, and started a new thread for the patch to 
> reinstate this and fix the ambiguity issue.
> 
> On Wed, Oct 28, 2015 at 11:01 AM, Michael Zolotukhin via cfe-commits 
> mailto:cfe-commits@lists.llvm.org>> wrote:
> Hi Eric, Richard,
> 
> Any news on this? The test is still broken, should we revert the commit for 
> now?
> 
> Thanks,
> Michael
> 
>> On Oct 24, 2015, at 1:18 AM, Eric Fiselier > <mailto:e...@efcs.ca>> wrote:
>> 
>> Hi Michael,
>> 
>> Sorry I'm holding this patch up in review. The fix is quite "novel" and I 
>> want to make sure we get it right. If we can't land it over the weekend I'll 
>> ask Richard to revert while we work on it.
>> 
>> /Eric
>> 
>> On Oct 23, 2015 10:13 PM, "Michael Zolotukhin via cfe-commits" 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Hi Richard,
>> 
>> Is this patch ready for commit, or were you just checking an idea? Our bots 
>> are still failing to build povray, so we’re really looking forward for some 
>> fix:)
>> 
>> Thanks,
>> Michael
>> 
>>> On Oct 15, 2015, at 6:21 PM, Manman Ren via cfe-commits 
>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>> 
>>>> 
>>>> On Oct 15, 2015, at 1:41 PM, Richard Smith >>> <mailto:rich...@metafoo.co.uk>> wrote:
>>>> 
>>>> On Thu, Oct 15, 2015 at 12:03 PM, Manman Ren via cfe-commits 
>>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>>> 
>>>>> On Oct 15, 2015, at 11:25 AM, Richard Smith >>>> <mailto:rich...@metafoo.co.uk>> wrote:
>>>>> 
>>>>> I assume the code in question has a "using namespace std;"?
>>>>> 
>>>>> 
>>>> Yes
>>>> 
>>>>> I don't see any way around this other than giving up on trying to fix the 
>>>>> function signatures here (or maybe adding a Clang feature to let us fix 
>>>>> the bad signature).
>>>>> 
>>>>> 
>>>> Can you elaborate on how to fix the bad signature by adding a Clang 
>>>> feature? I want to see how hard it is before giving up on trying to fix 
>>>> the signatures.
>>>> 
>>>> I thought about this a bit more, and we already have a feature that can be 
>>>> used for this.
>>>> 
>>>> Please let me know if the attached patch resolves the issue for you. This 
>>>> should also fix the wrong overload sets for these functions being provided 
>>>> by  on Darwin.
>>> 
>>> This works on my testing case. Thanks!!
>>> 
>>> Manman
>>> 
>>>> 
>>>> 
>>>> Eric, Marshall: the attached patch adds a macro _LIBCPP_PREFERRED_OVERLOAD 
>>>> that can be applied to a function to (a) mark it as a separate overload 
>>>> from any other function with the same signature without the overload, and 
>>>> (b) instruct the compiler that it's preferred over another function with 
>>>> the same signature without the attribute. This allows us to replace the 
>>>> libc function
>>>> 
>>>>   char *strchr(const char *, int);
>>>> 
>>>> with the C++ overload set:
>>>> 
>>>>   const char *strchr(const char *, int);
>>>>   char *strchr(char *, int);
>>>> 
>>>> It only works with Clang, though; for other compilers, we leave the C 
>>>> library's signature alone (as we used to before my patches landed).
>>>> 
>>>> Thanks,
>>>> Manman
>>>> 
>>>> 
>>>>> On Oct 15, 2015 11:07 AM, "Manman Ren via cfe-commits" 
>>>>> mailto:cfe-commits@lists.llvm.org>> wrote:
>>>>> Hi Richard,
>>>>> 
>>>>> This is causing a failure when building povray on iOS.
>>>>> 
>>>>> Compilation error:
>>>>> /Users/buildslave/tmp/test-suite-externals/speccpu2006/benchspec/CPU2006/453.povray/src/fileinputoutput.cpp:364:20:
>>>>>  error: call to 'strrchr' is ambiguous
>>>>>  const char *p=strrchr(name, '.’);
>>>>> 
>>>>> iOS.sdk/usr/include/string.h:87:7: note: candidate function
>>>>> cha

Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-21 Thread Michael Zolotukhin via cfe-commits
mzolotukhin accepted this revision.
mzolotukhin added a comment.
This revision is now accepted and ready to land.

LGTM with a small nit: could you please run `opt -instnamer` on your test 
(it'll replace `%0`, `%1`,... with `%tmp0`, `%tmp1` etc, making it easier to 
modify test in future)?

Thanks,
Michael


https://reviews.llvm.org/D19544



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


Re: [PATCH] D17976: Add attributes for preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end

2016-03-09 Thread Michael Zolotukhin via cfe-commits

> On Mar 8, 2016, at 5:44 PM, Roman Levenstein via cfe-commits 
>  wrote:
> 
> Forgot to add the mailing list when I created a patch.
You don’t have cfe-commits in phabricator subscribers, so you probably won’t 
get notifications when someone replies there. It might make sense to resubmit 
the patch.

Michael
> 
>> Begin forwarded message:
>> 
>> From: Roman Levenstein mailto:rlevenst...@apple.com>>
>> Subject: [PATCH] D17976: Add attributes for preserve_mostcc/preserve_allcc 
>> calling conventions to the C/C++ front-end
>> Date: March 8, 2016 at 5:17:02 PM PST
>> To: rlevenst...@apple.com , juer...@apple.com 
>> 
>> Cc: amara.emer...@arm.com 
>> Reply-To: reviews+d17976+public+93264263cdbda...@reviews.llvm.org 
>> 
>> 
>> swiftix created this revision.
>> swiftix added a reviewer: ributzka.
>> Herald added a subscriber: aemerson.
>> 
>> Till now, preserve_mostcc/preserve_allcc calling convention attributes were 
>> only available at the LLVM IR level. This patch adds attributes for 
>> preserve_mostcc/preserve_allcc calling conventions to the C/C++ front-end.
>> 
>> The code was mostly written by Juergen Ributzka. I just added support for 
>> the AArch64 target.
>> 
>> http://reviews.llvm.org/D17976 
>> 
>> Files:
>>  include/clang-c/Index.h
>>  include/clang/AST/Type.h
>>  include/clang/Basic/Attr.td
>>  include/clang/Basic/Specifiers.h
>>  lib/AST/ItaniumMangle.cpp
>>  lib/AST/Type.cpp
>>  lib/AST/TypePrinter.cpp
>>  lib/Basic/Targets.cpp
>>  lib/CodeGen/CGCall.cpp
>>  lib/Sema/SemaDeclAttr.cpp
>>  lib/Sema/SemaType.cpp
>>  test/CodeGen/preserve_all.c
>>  test/CodeGen/preserve_most.c
>>  tools/libclang/CXType.cpp
>> 
> 
> 
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

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