r262177 - [CLANG] [AVX512] [BUILTIN] Adding PSLL{V|W|Wi}{128|256|512} builtin

2016-02-27 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Sun Feb 28 01:39:34 2016
New Revision: 262177

URL: http://llvm.org/viewvc/llvm-project?rev=262177=rev
Log:
[CLANG] [AVX512] [BUILTIN] Adding PSLL{V|W|Wi}{128|256|512} builtin

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=262177=262176=262177=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Feb 28 01:39:34 2016
@@ -1638,6 +1638,20 @@ TARGET_BUILTIN(__builtin_ia32_pshufhw128
 TARGET_BUILTIN(__builtin_ia32_pshufhw256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pshuflw128_mask, 
"V8sV8sIiV8sUc","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pshuflw256_mask, 
"V16sV16sIiV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllv32hi_mask, 
"V32sV32sV32sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psllw512_mask, "V32sV32sV8sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psllwi512_mask, "V32sV32sIiV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_psllv16hi_mask, 
"V16sV16sV16sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllv8hi_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllw128_mask, 
"V8sV8sV8sV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllw256_mask, 
"V16sV16sV8sV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllwi128_mask, 
"V8sV8siV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllwi256_mask, 
"V16sV16siV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllv2di_mask, 
"V2LLiV2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllv4di_mask, 
"V4LLiV4LLiV4LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllv4si_mask, "V4iV4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_psllv8si_mask, "V8iV8iV8iV8iUc","","avx512vl")
+
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=262177=262176=262177=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Sun Feb 28 01:39:34 2016
@@ -1638,6 +1638,86 @@ __builtin_ia32_pshuflw512_mask ((__v32hi
(__mmask32)( __U));\
 })
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_sllv_epi16 (__m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psllv32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi)
+  _mm512_setzero_hi (),
+  (__mmask32) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_sllv_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
+  __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psllv32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi) __W,
+  (__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_sllv_epi16 (__mmask32 __U, __m512i __A, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_psllv32hi_mask ((__v32hi) __A,
+  (__v32hi) __B,
+  (__v32hi)
+  _mm512_setzero_hi (),
+  (__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_sll_epi16 (__m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_psllw512_mask ((__v32hi) __A,
+ (__v8hi) __B,
+ (__v32hi)
+ _mm512_setzero_hi (),
+ (__mmask32) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_sll_epi16 (__m512i __W, __mmask32 __U, __m512i __A,
+   __m128i __B)
+{
+  return (__m512i) __builtin_ia32_psllw512_mask ((__v32hi) __A,
+ (__v8hi) __B,
+ (__v32hi) __W,
+ (__mmask32) __U);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_sll_epi16 (__mmask32 __U, __m512i __A, __m128i __B)
+{
+  return (__m512i) __builtin_ia32_psllw512_mask ((__v32hi) __A,
+ (__v8hi) __B,
+ (__v32hi)
+ _mm512_setzero_hi (),
+ (__mmask32) __U);
+}
+
+#define _mm512_slli_epi16( __A, __B) __extension__ ({ \
+__builtin_ia32_psllwi512_mask ((__v32hi)( __A),( __B),\
+  (__v32hi)\
+  _mm512_setzero_hi (),\
+  (__mmask32) -1);\
+})
+
+#define _mm512_mask_slli_epi16( __W, __U, __A, __B) 

[PATCH] D17688: Fix missed leak from MSVC specific allocation functions

2016-02-27 Thread Alexander Riccio via cfe-commits
ariccio created this revision.
ariccio added a subscriber: cfe-commits.

I've found & fixed a leak that Clang misses when compiling on Windows.

The leak was found by [[ 
https://samate.nist.gov/SARD/view_testcase.php?tID=149071 | SARD #149071 ]], 
mem1-bad.c. Clang misses it because MSVC uses _strdup instead of strdup. I've 
added an IdentifierInfo* for _strdup, and now Clang catches it. 

As a drive by fix, I added the wide character strdup variants (wcsdup, _wcsdup) 
and the MSVC version of alloca (_alloca).

I will add reviewers when check-all finishes.

http://reviews.llvm.org/D17688

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp

Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-II_realloc(nullptr), II_calloc(nullptr), II_valloc(nullptr),
-II_reallocf(nullptr), II_strndup(nullptr), II_strdup(nullptr),
-II_kmalloc(nullptr), II_if_nameindex(nullptr),
-II_if_freenameindex(nullptr) {}
+  : II_alloca(nullptr), II__alloca(nullptr), II_malloc(nullptr),
+II_free(nullptr), II_realloc(nullptr), II_calloc(nullptr),
+II_valloc(nullptr), II_reallocf(nullptr), II_strndup(nullptr),
+II_strdup(nullptr), II__strdup(nullptr), II_kmalloc(nullptr),
+II_if_nameindex(nullptr), II_if_freenameindex(nullptr),
+II_wcsdup(nullptr), II__wcsdup(nullptr) {}
 
   /// In pessimistic mode, the checker assumes that it does not know which
   /// functions might free the memory.
@@ -231,10 +232,11 @@
   mutable std::unique_ptr BT_MismatchedDealloc;
   mutable std::unique_ptr BT_OffsetFree[CK_NumCheckKinds];
   mutable std::unique_ptr BT_UseZerroAllocated[CK_NumCheckKinds];
-  mutable IdentifierInfo *II_alloca, *II_malloc, *II_free, *II_realloc,
- *II_calloc, *II_valloc, *II_reallocf, *II_strndup,
- *II_strdup, *II_kmalloc, *II_if_nameindex,
- *II_if_freenameindex;
+  mutable IdentifierInfo *II_alloca, *II__alloca, *II_malloc, *II_free,
+ *II_realloc, *II_calloc, *II_valloc, *II_reallocf,
+ *II_strndup, *II_strdup, *II__strdup, *II_kmalloc,
+ *II_if_nameindex, *II_if_freenameindex, *II_wcsdup,
+ *II__wcsdup;
   mutable Optional KernelZeroFlagVal;
 
   void initIdentifierInfo(ASTContext ) const;
@@ -540,9 +542,15 @@
   II_valloc = ("valloc");
   II_strdup = ("strdup");
   II_strndup = ("strndup");
+  II_wcsdup = ("wcsdup");
   II_kmalloc = ("kmalloc");
   II_if_nameindex = ("if_nameindex");
   II_if_freenameindex = ("if_freenameindex");
+  
+  //MSVC uses `_`-prefixed instead, so we check for them too.
+  II__strdup = ("_strdup");
+  II__wcsdup = ("_wcsdup");
+  II__alloca = ("_alloca");
 }
 
 bool MallocChecker::isMemFunction(const FunctionDecl *FD, ASTContext ) const 
{
@@ -585,7 +593,8 @@
 if (Family == AF_Malloc && CheckAlloc) {
   if (FunI == II_malloc || FunI == II_realloc || FunI == II_reallocf ||
   FunI == II_calloc || FunI == II_valloc || FunI == II_strdup ||
-  FunI == II_strndup || FunI == II_kmalloc)
+  FunI == II__strdup || FunI == II_strndup || FunI == II_wcsdup ||
+  FunI == II__wcsdup || FunI == II_kmalloc)
 return true;
 }
 
@@ -600,7 +609,7 @@
 }
 
 if (Family == AF_Alloca && CheckAlloc) {
-  if (FunI == II_alloca)
+  if (FunI == II_alloca || FunI == II__alloca)
 return true;
 }
   }
@@ -789,11 +798,12 @@
   State = ProcessZeroAllocation(C, CE, 1, State);
 } else if (FunI == II_free) {
   State = FreeMemAux(C, CE, State, 0, false, ReleasedAllocatedMemory);
-} else if (FunI == II_strdup) {
+} else if (FunI == II_strdup || FunI == II__strdup ||
+   FunI == II_wcsdup || FunI == II__wcsdup) {
   State = MallocUpdateRefState(C, CE, State);
 } else if (FunI == II_strndup) {
   State = MallocUpdateRefState(C, CE, State);
-} else if (FunI == II_alloca) {
+} else if (FunI == II_alloca || FunI == II__alloca) {
   State = MallocMemAux(C, CE, CE->getArg(0), UndefinedVal(), State,
AF_Alloca);
   State = ProcessZeroAllocation(C, CE, 0, State);


Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -169,11 +169,12 @@
 {
 public:
   MallocChecker()
-  : II_alloca(nullptr), II_malloc(nullptr), II_free(nullptr),
-II_realloc(nullptr), 

Re: [PATCH] D17253: Cleanup of analyzer scripts as suggested by pychecker and pep8

2016-02-27 Thread Alexander Riccio via cfe-commits
ariccio added inline comments.


Comment at: C:/LLVM/llvm/tools/clang/utils/analyzer/SATestBuild.py:521
@@ -502,3 +520,3 @@
 SummaryLog.write("See the first %d below.\n"
-   % (NumOfFailuresInSummary,))
+ (NumOfFailuresInSummary,))
 # TODO: Add a line "See the results folder for more."

zaks.anna wrote:
> Is removing '%' correct here?
Nope. Good catch!


http://reviews.llvm.org/D17253



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


Re: r250293 - Bring back r250262: PS4 toolchain

2016-02-27 Thread Nico Weber via cfe-commits
On Wed, Oct 14, 2015 at 5:25 AM, Filipe Cabecinhas via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: filcab
> Date: Wed Oct 14 07:25:43 2015
> New Revision: 250293
>
> URL: http://llvm.org/viewvc/llvm-project?rev=250293=rev
> Log:
> Bring back r250262: PS4 toolchain
>
> There was a minor problem with a test. Sorry for the noise yesterday.
>
> This patch adds missing pieces to clang, including the PS4 toolchain
> definition, added warnings, PS4 defaults, and Driver changes needed for
> our compiler.
>
> A patch by Filipe Cabecinhas, Pierre Gousseau and Katya Romanova!
>
> Differential Revision: http://reviews.llvm.org/D13482
>
> Added:
> cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep
> cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep
> cfe/trunk/test/Driver/no-integrated-as.s
> cfe/trunk/test/Driver/ps4-header-search.c
> cfe/trunk/test/Driver/ps4-linker-non-win.c
> cfe/trunk/test/Driver/ps4-linker-win.c
> cfe/trunk/test/Driver/ps4-pic.c
> cfe/trunk/test/Driver/ps4-sdk-root.c
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> cfe/trunk/lib/Driver/Driver.cpp
> cfe/trunk/lib/Driver/ToolChains.cpp
> cfe/trunk/lib/Driver/ToolChains.h
> cfe/trunk/lib/Driver/Tools.cpp
> cfe/trunk/lib/Driver/Tools.h
> cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
> cfe/trunk/test/Driver/debug-options.c
> cfe/trunk/test/Driver/stack-protector.c
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=250293=250292=250293=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Oct 14
> 07:25:43 2015
> @@ -196,4 +196,18 @@ def warn_target_unsupported_nan2008 : Wa
>  def warn_target_unsupported_nanlegacy : Warning<
>"ignoring '-mnan=legacy' option because the '%0' architecture does not
> support it">,
>InGroup;
> +
> +def warn_drv_unable_to_find_directory_expected : Warning<
> +  "unable to find %0 directory, expected to be in '%1'">,
> +  InGroup, DefaultIgnore;
> +
> +def warn_drv_ps4_force_pic : Warning<
> +  "option '%0' was ignored by the PS4 toolchain, using '-fPIC'">,
> +  InGroup;
>

Should this use the existing UnusedCommandLineArgument instead of
introducing a new group?


> +
> +def warn_drv_ps4_sdk_dir : Warning<
> +  "environment variable SCE_PS4_SDK_DIR is set, but points to invalid or
> nonexistent directory '%0'">,
> +  InGroup;
> +
> +def err_drv_unsupported_linker : Error<"unsupported value '%0' for
> -linker option">;
>  }
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=250293=250292=250293=diff
>
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Oct 14 07:25:43
> 2015
> @@ -823,3 +823,7 @@ def CudaCompat : DiagGroup<"cuda-compat"
>
>  // A warning group for things that will change semantics in the future.
>  def FutureCompat : DiagGroup<"future-compat">;
> +
> +def InvalidOrNonExistentDirectory :
> DiagGroup<"invalid-or-nonexistent-directory">;
> +
> +def OptionIgnored : DiagGroup<"option-ignored">;
>
> Modified: cfe/trunk/lib/Driver/Driver.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=250293=250292=250293=diff
>
> ==
> --- cfe/trunk/lib/Driver/Driver.cpp (original)
> +++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 14 07:25:43 2015
> @@ -2261,6 +2261,9 @@ const ToolChain ::getToolChain(co
>  case llvm::Triple::CUDA:
>TC = new toolchains::CudaToolChain(*this, Target, Args);
>break;
> +case llvm::Triple::PS4:
> +  TC = new toolchains::PS4CPU(*this, Target, Args);
> +  break;
>  default:
>// Of these targets, Hexagon is the only one that might have
>// an OS of Linux, in which case it got handled above already.
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=250293=250292=250293=diff
>
> ==
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Oct 14 07:25:43 2015
> @@ -4066,3 +4066,77 @@ void WebAssembly::addClangTargetOptions(
>   options::OPT_fno_use_init_array, true))
>  CC1Args.push_back("-fuse-init-array");
>  }
> +
> +PS4CPU::PS4CPU(const Driver , const llvm::Triple , const 

Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-02-27 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 49307.
flx marked 6 inline comments as done.

http://reviews.llvm.org/D17491

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  clang-tidy/performance/UnnecessaryValueParamCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-unnecessary-value-param.rst
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -0,0 +1,164 @@
+// RUN: %check_clang_tidy %s performance-unnecessary-value-param %t
+
+struct ExpensiveToCopyType {
+  const ExpensiveToCopyType & constReference() const {
+return *this;
+  }
+  void nonConstMethod() {}
+  virtual ~ExpensiveToCopyType() {}
+};
+
+void mutate(ExpensiveToCopyType &);
+void mutate(ExpensiveToCopyType *);
+void useAsConstReference(const ExpensiveToCopyType &);
+void useByValue(ExpensiveToCopyType);
+
+// This class simulates std::pair<>. It is trivially copy constructible
+// and trivially destructible, but not trivially copy assignable.
+class SomewhatTrivial {
+ public:
+  SomewhatTrivial();
+  SomewhatTrivial(const SomewhatTrivial&) = default;
+  ~SomewhatTrivial() = default;
+  SomewhatTrivial& operator=(const SomewhatTrivial&);
+};
+
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveConstValue(const ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:60: warning: the const qualified parameter 'Obj' is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveConstValue(const ExpensiveToCopyType& Obj) {
+}
+
+void positiveExpensiveValue(ExpensiveToCopyType Obj);
+// CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj);
+void positiveExpensiveValue(ExpensiveToCopyType Obj) {
+  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: the parameter 'Obj' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveExpensiveValue(const ExpensiveToCopyType& Obj) {
+  Obj.constReference();
+  useAsConstReference(Obj);
+  auto Copy = Obj;
+  useByValue(Obj);
+}
+
+void positiveWithComment(const ExpensiveToCopyType /* important */ S);
+// CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S);
+void positiveWithComment(const ExpensiveToCopyType /* important */ S) {
+  // CHECK-MESSAGES: [[@LINE-1]]:68: warning: the const qualified
+  // CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S) {
+}
+
+void positiveUnnamedParam(const ExpensiveToCopyType) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter #1
+}
+
+void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToCopyType& ConstRef, ExpensiveToCopyType Copy);
+// CHECK-FIXES: void positiveAndNegative(const ExpensiveToCopyType& ConstCopy, const ExpensiveToCopyType& ConstRef, const ExpensiveToCopyType& Copy);
+void positiveAndNegative(const ExpensiveToCopyType ConstCopy, const ExpensiveToCopyType& ConstRef, ExpensiveToCopyType Copy) {
+  // CHECK-MESSAGES: [[@LINE-1]]:52: warning: the const qualified parameter 'ConstCopy'
+  // CHECK-MESSAGES: [[@LINE-2]]:120: warning: the parameter 'Copy'
+  // CHECK-FIXES: void positiveAndNegative(const ExpensiveToCopyType& ConstCopy, const ExpensiveToCopyType& ConstRef, const ExpensiveToCopyType& Copy) {
+}
+
+struct PositiveConstValueConstructor {
+  PositiveConstValueConstructor(const ExpensiveToCopyType ConstCopy) {}
+  // CHECK-MESSAGES: [[@LINE-1]]:59: warning: the const qualified parameter 'ConstCopy'
+};
+
+template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType S, T V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:90: warning: the const qualified parameter 'S'
+  // CHECK-FIXES: template  void templateWithNonTemplatizedParameter(const ExpensiveToCopyType& S, T V) {
+}
+
+void instantiated() {
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), ExpensiveToCopyType());
+  templateWithNonTemplatizedParameter(ExpensiveToCopyType(), 5);
+}
+
+template  void negativeTemplateType(const T V) {
+}
+
+void negativeArray(const ExpensiveToCopyType[]) {
+}
+
+void negativePointer(ExpensiveToCopyType* Obj) {
+}
+
+void negativeConstPointer(const ExpensiveToCopyType* Obj) {
+}
+
+void negativeConstReference(const ExpensiveToCopyType& Obj) {
+}
+
+void negativeReference(ExpensiveToCopyType& Obj) {
+}
+
+void negativeUniversalReference(ExpensiveToCopyType&& Obj) {
+}
+
+void negativeSomewhatTrivialConstValue(const 

Re: [PATCH] D17491: Add performance check to flag function parameters of expensive to copy types that can be safely converted to const references.

2016-02-27 Thread Felix Berger via cfe-commits
flx added inline comments.


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:41
@@ +40,3 @@
+   Function->parameters().begin();
+  if (Index >= Function->getNumParams()) {
+return;

alexfh wrote:
> Please add a comment about when this happens (template parameter packs? 
> C-style variadic functions?).
I"m not sure when this can happen. Should I remove it and we add it if we find 
a case?


Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:62
@@ +61,3 @@
+  "consider making it a const reference")
+  << Param->getName();
+  // Do not propose fixes in macros since we cannot place them correctly.

alexfh wrote:
> What if parameter doesn't have a name? Should we print an index ("parameter 
> #n is copied ...").
Good point. Added test and index code.


http://reviews.llvm.org/D17491



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


Re: [PATCH] D17488: Extend UnnecessaryCopyInitialization check to trigger on non-const copies that can be safely converted to const references.

2016-02-27 Thread Felix Berger via cfe-commits
flx added inline comments.


Comment at: clang-tidy/performance/UnnecessaryCopyInitialization.h:19
@@ -18,3 +18,3 @@
 
-// A check that detects const local variable declarations that are copy
+// A check that detects local variable declarations that are copy
 // initialized with the const reference of a function call or the const

alexfh wrote:
> Maybe just "The check detects local variable declarations "?
> 
> Also, should the .rst file be updated as well?
.rst file didn't exist. Added one now.


Comment at: clang-tidy/utils/FixItHintUtils.h:21
@@ +20,3 @@
+/// \brief Creates fix to make VarDecl a reference by adding '&'.
+FixItHint createReferenceFix(const VarDecl , ASTContext );
+

alexfh wrote:
> Since this is now a library, we should make names clear and unambiguous. I'd 
> pull a part of the name's meaning to the namespace and expand the name with 
> the needed details. Maybe something like this:
> 
>   namespace clang {
>   namespace tidy {
>   namespace utils {
>   namespace create_fixit {
>   
>   FixItHint changeVarDeclToReference(...);
>   FixItHint changeVarDeclToConst(...);
Done, but put an extra underscore in the create_fix_it namespace to be 
consistent with the camelcase of the class.


http://reviews.llvm.org/D17488



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


Re: [PATCH] D17488: Extend UnnecessaryCopyInitialization check to trigger on non-const copies that can be safely converted to const references.

2016-02-27 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 49306.
flx marked 5 inline comments as done.

http://reviews.llvm.org/D17488

Files:
  clang-tidy/performance/ForRangeCopyCheck.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  clang-tidy/performance/UnnecessaryCopyInitialization.h
  clang-tidy/utils/CMakeLists.txt
  clang-tidy/utils/DeclRefExprUtils.cpp
  clang-tidy/utils/DeclRefExprUtils.h
  clang-tidy/utils/FixItHintUtils.cpp
  clang-tidy/utils/FixItHintUtils.h
  docs/clang-tidy/checks/performance-unnecessary-copy-initialization.rst
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -4,6 +4,7 @@
   ExpensiveToCopyType() {}
   virtual ~ExpensiveToCopyType() {}
   const ExpensiveToCopyType () const { return *this; }
+  void nonConstMethod() {}
 };
 
 struct TrivialToCopyType {
@@ -20,6 +21,11 @@
   return *Type;
 }
 
+void mutate(ExpensiveToCopyType &);
+void mutate(ExpensiveToCopyType *);
+void useAsConstReference(const ExpensiveToCopyType &);
+void useByValue(ExpensiveToCopyType);
+
 void PositiveFunctionCall() {
   const auto AutoAssigned = ExpensiveTypeReference();
   // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 'AutoAssigned' is copy-constructed from a const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
@@ -114,11 +120,53 @@
   static const auto StaticVar = Obj.reference();
 }
 
-void NegativeFunctionCallExpensiveTypeNonConstVariable() {
+void PositiveFunctionCallExpensiveTypeNonConstVariable() {
   auto AutoAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable 'AutoAssigned' is copy-constructed from a const reference but is only used as const reference; consider making it a const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveTypeReference();
   auto AutoCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the variable
+  // CHECK-FIXES: const auto& AutoCopyConstructed(ExpensiveTypeReference());
   ExpensiveToCopyType VarAssigned = ExpensiveTypeReference();
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: the variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarAssigned = ExpensiveTypeReference();
   ExpensiveToCopyType VarCopyConstructed(ExpensiveTypeReference());
+  // CHECK-MESSAGES: [[@LINE-1]]:23: warning: the variable
+  // CHECK-FIXES: const ExpensiveToCopyType& VarCopyConstructed(ExpensiveTypeReference());
+}
+
+void positiveNonConstVarInCodeBlock(const ExpensiveToCopyType ) {
+  {
+auto Assigned = Obj.reference();
+// CHECK-MESSAGES: [[@LINE-1]]:10: warning: the variable
+// CHECK-FIXES: const auto& Assigned = Obj.reference();
+Assigned.reference();
+useAsConstReference(Assigned);
+useByValue(Assigned);
+  }
+}
+
+void negativeNonConstVarWithNonConstUse(const ExpensiveToCopyType ) {
+  {
+auto NonConstInvoked = Obj.reference();
+// CHECK-FIXES: auto NonConstInvoked = Obj.reference();
+NonConstInvoked.nonConstMethod();
+  }
+  {
+auto Reassigned = Obj.reference();
+// CHECK-FIXES: auto Reassigned = Obj.reference();
+Reassigned = ExpensiveToCopyType();
+  }
+  {
+auto MutatedByReference = Obj.reference();
+// CHECK-FIXES: auto MutatedByReference = Obj.reference();
+mutate(MutatedByReference);
+  }
+  {
+auto MutatedByPointer = Obj.reference();
+// CHECK-FIXES: auto MutatedByPointer = Obj.reference();
+mutate();
+  }
 }
 
 void NegativeMethodCallNonConstRef(ExpensiveToCopyType ) {
@@ -146,11 +194,32 @@
   ExpensiveToCopyType Obj;
   const auto AutoAssigned = Obj.reference();
   const auto AutoCopyConstructed(Obj.reference());
-  const ExpensiveToCopyType VarAssigned = Obj.reference();
-  const ExpensiveToCopyType VarCopyConstructed(Obj.reference());
+  ExpensiveToCopyType VarAssigned = Obj.reference();
+  ExpensiveToCopyType VarCopyConstructed(Obj.reference());
 }
 
 struct NegativeConstructor {
   NegativeConstructor(const ExpensiveToCopyType ) : Obj(Obj) {}
   ExpensiveToCopyType Obj;
 };
+
+#define UNNECESSARY_COPY_INIT_IN_MACRO_BODY(TYPE)	\
+  void functionWith##TYPE(const TYPE& T) {		\
+auto AssignedInMacro = T.reference();		\
+  }			\
+// Ensure fix is not applied.
+// CHECK-FIXES: auto AssignedInMacro = T.reference();
+
+
+UNNECESSARY_COPY_INIT_IN_MACRO_BODY(ExpensiveToCopyType)
+// CHECK-MESSAGES: [[@LINE-1]]:1: warning: the variable 'AssignedInMacro' is copy-constructed
+
+#define UNNECESSARY_COPY_INIT_IN_MACRO_ARGUMENT(ARGUMENT)	\
+  ARGUMENT
+
+void PositiveMacroArgument(const ExpensiveToCopyType ) {
+  

[PATCH] D17682: [X86] AMD Bobcat CPU (btver1) doesn't support XSAVE

2016-02-27 Thread Simon Pilgrim via cfe-commits
RKSimon created this revision.
RKSimon added reviewers: craig.topper, spatel, andreadb.
RKSimon added a subscriber: cfe-commits.
RKSimon set the repository for this revision to rL LLVM.

btver1 is a SSSE3/SSE4a only CPU - it doesn't have AVX and doesn't support 
XSAVE.

This looks like some kind of copy+paste error from bdver1?

Repository:
  rL LLVM

http://reviews.llvm.org/D17682

Files:
  lib/Basic/Targets.cpp
  test/Preprocessor/predefined-arch-macros.c

Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1473,7 +1473,6 @@
 // CHECK_BTVER1_M32: #define __SSE_MATH__ 1
 // CHECK_BTVER1_M32: #define __SSE__ 1
 // CHECK_BTVER1_M32: #define __SSSE3__ 1
-// CHECK_BTVER1_M32: #define __XSAVE__ 1
 // CHECK_BTVER1_M32: #define __btver1 1
 // CHECK_BTVER1_M32: #define __btver1__ 1
 // CHECK_BTVER1_M32: #define __i386 1
@@ -1495,7 +1494,6 @@
 // CHECK_BTVER1_M64: #define __SSE_MATH__ 1
 // CHECK_BTVER1_M64: #define __SSE__ 1
 // CHECK_BTVER1_M64: #define __SSSE3__ 1
-// CHECK_BTVER1_M64: #define __XSAVE__ 1
 // CHECK_BTVER1_M64: #define __amd64 1
 // CHECK_BTVER1_M64: #define __amd64__ 1
 // CHECK_BTVER1_M64: #define __btver1 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2769,6 +2769,7 @@
 setFeatureEnabledImpl(Features, "bmi", true);
 setFeatureEnabledImpl(Features, "f16c", true);
 setFeatureEnabledImpl(Features, "xsaveopt", true);
+setFeatureEnabledImpl(Features, "xsave", true);
 // FALLTHROUGH
   case CK_BTVER1:
 setFeatureEnabledImpl(Features, "ssse3", true);
@@ -2778,7 +2779,6 @@
 setFeatureEnabledImpl(Features, "prfchw", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "xsave", true);
 break;
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);


Index: test/Preprocessor/predefined-arch-macros.c
===
--- test/Preprocessor/predefined-arch-macros.c
+++ test/Preprocessor/predefined-arch-macros.c
@@ -1473,7 +1473,6 @@
 // CHECK_BTVER1_M32: #define __SSE_MATH__ 1
 // CHECK_BTVER1_M32: #define __SSE__ 1
 // CHECK_BTVER1_M32: #define __SSSE3__ 1
-// CHECK_BTVER1_M32: #define __XSAVE__ 1
 // CHECK_BTVER1_M32: #define __btver1 1
 // CHECK_BTVER1_M32: #define __btver1__ 1
 // CHECK_BTVER1_M32: #define __i386 1
@@ -1495,7 +1494,6 @@
 // CHECK_BTVER1_M64: #define __SSE_MATH__ 1
 // CHECK_BTVER1_M64: #define __SSE__ 1
 // CHECK_BTVER1_M64: #define __SSSE3__ 1
-// CHECK_BTVER1_M64: #define __XSAVE__ 1
 // CHECK_BTVER1_M64: #define __amd64 1
 // CHECK_BTVER1_M64: #define __amd64__ 1
 // CHECK_BTVER1_M64: #define __btver1 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -2769,6 +2769,7 @@
 setFeatureEnabledImpl(Features, "bmi", true);
 setFeatureEnabledImpl(Features, "f16c", true);
 setFeatureEnabledImpl(Features, "xsaveopt", true);
+setFeatureEnabledImpl(Features, "xsave", true);
 // FALLTHROUGH
   case CK_BTVER1:
 setFeatureEnabledImpl(Features, "ssse3", true);
@@ -2778,7 +2779,6 @@
 setFeatureEnabledImpl(Features, "prfchw", true);
 setFeatureEnabledImpl(Features, "cx16", true);
 setFeatureEnabledImpl(Features, "fxsr", true);
-setFeatureEnabledImpl(Features, "xsave", true);
 break;
   case CK_BDVER4:
 setFeatureEnabledImpl(Features, "avx2", true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D15883: Add ARM EHABI-related constants to unwind.h.

2016-02-27 Thread Timon Van Overveldt via cfe-commits
timonvo added a comment.

I don't have commit access. Can I land this CL myself somehow without commit 
access (e.g. using arc), or will you have to submit it for me?


http://reviews.llvm.org/D15883



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


Re: [PATCH] D17407: [Sema] PR25755 Fix crash when initializing out-of-order struct references

2016-02-27 Thread don hinton via cfe-commits
hintonda updated this revision to Diff 49295.
hintonda added a comment.

Improve efficiency by using pair<> to maintain counts instead of purging seen 
fields.


http://reviews.llvm.org/D17407

Files:
  lib/Sema/SemaInit.cpp
  test/SemaCXX/cxx0x-initializer-constructor.cpp

Index: test/SemaCXX/cxx0x-initializer-constructor.cpp
===
--- test/SemaCXX/cxx0x-initializer-constructor.cpp
+++ test/SemaCXX/cxx0x-initializer-constructor.cpp
@@ -407,3 +407,34 @@
 [0] = 1, [2] = 3
   }; // expected-error {{ambiguous}} expected-note {{in implicit initialization of array element 1}}
 }
+
+namespace PR23514 {
+struct Test {
+  int& a;
+  int& b;
+};
+
+int d = 0;
+auto a = Test { .b = d, .a = d, };
+
+struct S { // expected-note-re 2{{candidate constructor (the implicit {{.*}} constructor) not viable: requires 1 argument, but 0 were provided}}
+  S(int a) {} // expected-note {{candidate constructor not viable: requires single argument 'a', but no arguments were provided}}
+};
+
+struct P {
+  char i1;
+  char i2;
+  S s;
+};
+
+P p1 { .s = 2, .i1 = 1, 1, };
+P p2 { .s = 2, .i1 = 1, };
+
+struct PP {
+  char i1;
+  S s1;
+  S s2; // expected-note {{in implicit initialization of field 's2' with omitted initializer}}
+};
+
+PP pp { .s1 = 2, .i1 = 1, }; // expected-error {{no matching constructor for initialization of 'PR23514::S'}}
+}
Index: lib/Sema/SemaInit.cpp
===
--- lib/Sema/SemaInit.cpp
+++ lib/Sema/SemaInit.cpp
@@ -1730,6 +1730,12 @@
   // worthwhile to skip over the rest of the initializer, though.
   RecordDecl *RD = DeclType->getAs()->getDecl();
   RecordDecl::field_iterator FieldEnd = RD->field_end();
+  SmallVector, 10> RemainingFields;
+  unsigned Fieldidx = 0;
+  for (auto f = Field; f != FieldEnd; ++f) {
+RemainingFields.push_back({f, 0});
+  }
+  RemainingFields.push_back({FieldEnd, 0});
   bool InitializedSomething = false;
   bool CheckForMissingFields = true;
   while (Index < IList->getNumInits()) {
@@ -1750,6 +1756,18 @@
  true, TopLevelObject))
 hadError = true;
 
+  unsigned idx = 0;
+  auto it = std::find_if(RemainingFields.begin(), RemainingFields.end(),
+ [, , ](std::pair f) {
+   ++idx;
+   return (f.first == FieldEnd || ++f.first == Field);
+ });
+  assert(it != RemainingFields.end());
+  if (it->first != FieldEnd) {
+Fieldidx = idx;
+++it->second;
+  }
+
   InitializedSomething = true;
 
   // Disable check for missing fields when designators are used.
@@ -1773,6 +1791,7 @@
 
 if (Field->isUnnamedBitfield()) {
   // Don't initialize unnamed bitfields, e.g. "int : 20;"
+  ++RemainingFields[Fieldidx++].second;
   ++Field;
   continue;
 }
@@ -1786,6 +1805,7 @@
   IList->getInit(Index)->getLocStart());
 if (InvalidUse) {
   ++Index;
+  ++RemainingFields[Fieldidx++].second;
   ++Field;
   hadError = true;
   continue;
@@ -1802,6 +1822,7 @@
   StructuredList->setInitializedFieldInUnion(*Field);
 }
 
+++RemainingFields[Fieldidx++].second;
 ++Field;
   }
 
@@ -1822,11 +1843,14 @@
   }
 
   // Check that any remaining fields can be value-initialized.
-  if (VerifyOnly && Field != FieldEnd && !DeclType->isUnionType() &&
-  !Field->getType()->isIncompleteArrayType()) {
-// FIXME: Should check for holes left by designated initializers too.
-for (; Field != FieldEnd && !hadError; ++Field) {
-  if (!Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
+  if (VerifyOnly && !DeclType->isUnionType()) {
+for (auto Pair : RemainingFields) {
+  Field = Pair.first;
+  if (Field == FieldEnd || hadError)
+break;
+  unsigned count = Pair.second;
+  if (count == 0 && !Field->getType()->isIncompleteArrayType() &&
+  !Field->isUnnamedBitfield() && !Field->hasInClassInitializer())
 CheckEmptyInitializable(
 InitializedEntity::InitializeMember(*Field, ),
 IList->getLocEnd());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r262138 - Workaround doxygen bug https://bugzilla.gnome.org/show_bug.cgi?id=506243

2016-02-27 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Sat Feb 27 08:02:08 2016
New Revision: 262138

URL: http://llvm.org/viewvc/llvm-project?rev=262138=rev
Log:
Workaround doxygen bug https://bugzilla.gnome.org/show_bug.cgi?id=506243

Modified:
cfe/trunk/docs/ClangFormatStyleOptions.rst
cfe/trunk/include/clang/Format/Format.h

Modified: cfe/trunk/docs/ClangFormatStyleOptions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangFormatStyleOptions.rst?rev=262138=262137=262138=diff
==
--- cfe/trunk/docs/ClangFormatStyleOptions.rst (original)
+++ cfe/trunk/docs/ClangFormatStyleOptions.rst Sat Feb 27 08:02:08 2016
@@ -671,7 +671,7 @@ the configuration (without a prefix: ``A
   The number of spaces before trailing line comments
   (``//`` - comments).
 
-  This does not affect trailing block comments (``/**/`` - comments) as
+  This does not affect trailing block comments (``/*`` - comments) as
   those commonly have different usage patterns and a number of special
   cases.
 

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=262138=262137=262138=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Sat Feb 27 08:02:08 2016
@@ -541,7 +541,7 @@ struct FormatStyle {
   /// \brief The number of spaces before trailing line comments
   /// (``//`` - comments).
   ///
-  /// This does not affect trailing block comments (``/**/`` - comments) as
+  /// This does not affect trailing block comments (``/*`` - comments) as
   /// those commonly have different usage patterns and a number of special
   /// cases.
   unsigned SpacesBeforeTrailingComments;


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


r262136 - Correcting indentation for an RST code block.

2016-02-27 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Sat Feb 27 07:13:16 2016
New Revision: 262136

URL: http://llvm.org/viewvc/llvm-project?rev=262136=rev
Log:
Correcting indentation for an RST code block.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=262136=262135=262136=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Sat Feb 27 07:13:16 2016
@@ -1591,11 +1591,12 @@ to declare if they are being read or wri
 The read_only/__read_only, write_only/__write_only and read_write/__read_write
 names are reserved for use as access qualifiers and shall not be used 
otherwise.
 
-  .. code-block:: c
+.. code-block:: c
+
   kernel void
   foo (read_only image2d_t imageA,
-  write_only image2d_t imageB) {
-  ...
+   write_only image2d_t imageB) {
+...
   }
 
 In the above example imageA is a read-only 2D image object, and imageB is a


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


Re: [PATCH] D17586: Add a new check, readability-redundant-string-init, that checks unnecessary string initializations.

2016-02-27 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D17586#363466, @Eugene.Zelenko wrote:

> Sorry for arriving late to party :-)
>
> Thank you for great check! I found a quite lot of such problems in my code 
> base, but I'd like to make suggestion for further improvements: PR26756.


The full link is: http://llvm.org/PR26756


Repository:
  rL LLVM

http://reviews.llvm.org/D17586



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


r262126 - AMDGPU: Add builtins for recently added intrinsics

2016-02-27 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Sat Feb 27 03:54:43 2016
New Revision: 262126

URL: http://llvm.org/viewvc/llvm-project?rev=262126=rev
Log:
AMDGPU: Add builtins for recently added intrinsics

Added:
cfe/trunk/test/SemaOpenCL/builtins-amdgcn.cl
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=262126=262125=262126=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Sat Feb 27 03:54:43 2016
@@ -40,8 +40,18 @@ BUILTIN(__builtin_amdgcn_cubeid, "",
 BUILTIN(__builtin_amdgcn_cubesc, "", "nc")
 BUILTIN(__builtin_amdgcn_cubetc, "", "nc")
 BUILTIN(__builtin_amdgcn_cubema, "", "nc")
+BUILTIN(__builtin_amdgcn_s_memtime, "LUi", "n")
+BUILTIN(__builtin_amdgcn_s_sleep, "vIi", "n")
 
+//===--===//
+// VI+ only builtins.
+//===--===//
+BUILTIN(__builtin_amdgcn_s_memrealtime, "LUi", "n")
+
+//===--===//
 // Legacy names with amdgpu prefix
+//===--===//
+
 BUILTIN(__builtin_amdgpu_rsq, "dd", "nc")
 BUILTIN(__builtin_amdgpu_rsqf, "ff", "nc")
 BUILTIN(__builtin_amdgpu_ldexp, "ddi", "nc")

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=262126=262125=262126=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Sat Feb 27 03:54:43 2016
@@ -3,6 +3,8 @@
 
 #pragma OPENCL EXTENSION cl_khr_fp64 : enable
 
+typedef unsigned long ulong;
+
 // CHECK-LABEL: @test_div_scale_f64
 // CHECK: call { double, i1 } @llvm.amdgcn.div.scale.f64(double %a, double %b, 
i1 true)
 // CHECK-DAG: [[FLAG:%.+]] = extractvalue { double, i1 } %{{.+}}, 1
@@ -169,6 +171,29 @@ void test_s_barrier()
   __builtin_amdgcn_s_barrier();
 }
 
+// CHECK-LABEL: @test_s_memtime
+// CHECK: call i64 @llvm.amdgcn.s.memtime()
+void test_s_memtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memtime();
+}
+
+// CHECK-LABEL: @test_s_memrealtime
+// CHECK: call i64 @llvm.amdgcn.s.memrealtime()
+void test_s_memrealtime(global ulong* out)
+{
+  *out = __builtin_amdgcn_s_memrealtime();
+}
+
+// CHECK-LABEL: @test_s_sleep
+// CHECK: call void @llvm.amdgcn.s.sleep(i32 1)
+// CHECK: call void @llvm.amdgcn.s.sleep(i32 15)
+void test_s_sleep()
+{
+  __builtin_amdgcn_s_sleep(1);
+  __builtin_amdgcn_s_sleep(15);
+}
+
 // CHECK-LABEL: @test_cubeid(
 // CHECK: call float @llvm.amdgcn.cubeid(float %a, float %b, float %c)
 void test_cubeid(global float* out, float a, float b, float c) {

Added: cfe/trunk/test/SemaOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/builtins-amdgcn.cl?rev=262126=auto
==
--- cfe/trunk/test/SemaOpenCL/builtins-amdgcn.cl (added)
+++ cfe/trunk/test/SemaOpenCL/builtins-amdgcn.cl Sat Feb 27 03:54:43 2016
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -triple amdgcn-unknown-amdhsa -fsyntax-only -verify %s
+
+void test_s_sleep(int x)
+{
+  __builtin_amdgcn_s_sleep(x); // expected-error {{argument to 
'__builtin_amdgcn_s_sleep' must be a constant integer}}
+}


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


Re: [PATCH] D17515: AMDGPU: Add builtins for recently added intrinsics

2016-02-27 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r262126


http://reviews.llvm.org/D17515



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


Re: [PATCH] D17519: AMDGPU: Fix broken/confusing predefined macro

2016-02-27 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r262124


http://reviews.llvm.org/D17519



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


Re: [PATCH] D17520: AMDGPU: Fix inconsistent register name for flat_scratch

2016-02-27 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r262123


http://reviews.llvm.org/D17520



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


r262123 - AMDGPU: Fix inconsistent register name for flat_scratch

2016-02-27 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Sat Feb 27 03:06:22 2016
New Revision: 262123

URL: http://llvm.org/viewvc/llvm-project?rev=262123=rev
Log:
AMDGPU: Fix inconsistent register name for flat_scratch

Added:
cfe/trunk/test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl
Modified:
cfe/trunk/lib/Basic/Targets.cpp

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262123=262122=262123=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sat Feb 27 03:06:22 2016
@@ -2022,8 +2022,8 @@ const char * const AMDGPUTargetInfo::GCC
   "s104", "s105", "s106", "s107", "s108", "s109", "s110", "s111",
   "s112", "s113", "s114", "s115", "s116", "s117", "s118", "s119",
   "s120", "s121", "s122", "s123", "s124", "s125", "s126", "s127"
-  "exec", "vcc", "scc", "m0", "flat_scr", "exec_lo", "exec_hi",
-  "vcc_lo", "vcc_hi", "flat_scr_lo", "flat_scr_hi"
+  "exec", "vcc", "scc", "m0", "flat_scratch", "exec_lo", "exec_hi",
+  "vcc_lo", "vcc_hi", "flat_scratch_lo", "flat_scratch_hi"
 };
 
 ArrayRef AMDGPUTargetInfo::getGCCRegNames() const {

Added: cfe/trunk/test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl?rev=262123=auto
==
--- cfe/trunk/test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/amdgcn-flat-scratch-name.cl Sat Feb 27 
03:06:22 2016
@@ -0,0 +1,15 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-LABEL: @use_flat_scratch_name
+kernel void use_flat_scratch_name()
+{
+// CHECK: tail call void asm sideeffect "s_mov_b64 flat_scratch, 0", 
"~{flat_scratch}"()
+  __asm__ volatile("s_mov_b64 flat_scratch, 0" : : : "flat_scratch");
+
+// CHECK: tail call void asm sideeffect "s_mov_b32 flat_scratch_lo, 0", 
"~{flat_scratch_lo}"()
+  __asm__ volatile("s_mov_b32 flat_scratch_lo, 0" : : : "flat_scratch_lo");
+
+// CHECK: tail call void asm sideeffect "s_mov_b32 flat_scratch_hi, 0", 
"~{flat_scratch_hi}"()
+  __asm__ volatile("s_mov_b32 flat_scratch_hi, 0" : : : "flat_scratch_hi");
+}


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


r262122 - Add __builtin_canonicalize

2016-02-27 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Sat Feb 27 03:06:18 2016
New Revision: 262122

URL: http://llvm.org/viewvc/llvm-project?rev=262122=rev
Log:
Add __builtin_canonicalize

Modified:
cfe/trunk/docs/LanguageExtensions.rst
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/builtins.c

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=262122=262121=262122=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Sat Feb 27 03:06:18 2016
@@ -1728,6 +1728,24 @@ convert their operands before performing
 
 Query for this feature with ``__has_builtin(__builtin_add_overflow)``, etc.
 
+Floating point builtins
+---
+
+``__builtin_canonicalize``
+--
+
+.. code-block:: c
+
+   double __builtin_canonicalize(double);
+   float __builtin_canonicalizef(float);
+   long double__builtin_canonicalizel(long double);
+
+Returns the platform specific canonical encoding of a floating point
+number. This canonicalization is useful for implementing certain
+numeric primitives such as frexp. See `LLVM canonicalize intrinsic
+`_ for
+more information on the semantics.
+
 .. _langext-__c11_atomic:
 
 __c11_atomic builtins

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=262122=262121=262122=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Sat Feb 27 03:06:18 2016
@@ -377,6 +377,11 @@ BUILTIN(__builtin_signbit, "i.", "Fnc")
 BUILTIN(__builtin_signbitf, "if", "Fnc")
 BUILTIN(__builtin_signbitl, "iLd", "Fnc")
 
+// Special FP builtins.
+BUILTIN(__builtin_canonicalize, "dd", "nc")
+BUILTIN(__builtin_canonicalizef, "ff", "nc")
+BUILTIN(__builtin_canonicalizel, "LdLd", "nc")
+
 // Builtins for arithmetic.
 BUILTIN(__builtin_clzs , "iUs"  , "nc")
 BUILTIN(__builtin_clz  , "iUi"  , "nc")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=262122=262121=262122=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Feb 27 03:06:18 2016
@@ -2138,6 +2138,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(
   case Builtin::BIprintf:
 if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice)
   return EmitCUDADevicePrintfCallExpr(E, ReturnValue);
+break;
+  case Builtin::BI__builtin_canonicalize:
+  case Builtin::BI__builtin_canonicalizef:
+  case Builtin::BI__builtin_canonicalizel:
+return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::canonicalize));
   }
 
   // If this is an alias for a lib function (e.g. __builtin_sin), emit

Modified: cfe/trunk/test/CodeGen/builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins.c?rev=262122=262121=262122=diff
==
--- cfe/trunk/test/CodeGen/builtins.c (original)
+++ cfe/trunk/test/CodeGen/builtins.c Sat Feb 27 03:06:18 2016
@@ -250,6 +250,13 @@ void test_float_builtin_ops(float F, dou
   // CHECK: call float @llvm.fabs.f32(float
   // CHECK: call double @llvm.fabs.f64(double
   // CHECK: call x86_fp80 @llvm.fabs.f80(x86_fp80
+
+  resf = __builtin_canonicalizef(F);
+  resd = __builtin_canonicalize(D);
+  resld = __builtin_canonicalizel(LD);
+  // CHECK: call float @llvm.canonicalize.f32(float
+  // CHECK: call double @llvm.canonicalize.f64(double
+  // CHECK: call x86_fp80 @llvm.canonicalize.f80(x86_fp80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.


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


Re: [PATCH] D17558: Add __builtin_canonicalize

2016-02-27 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r262122


http://reviews.llvm.org/D17558



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


r262124 - AMDGPU: Fix broken/confusing predefined macro

2016-02-27 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Sat Feb 27 03:06:26 2016
New Revision: 262124

URL: http://llvm.org/viewvc/llvm-project?rev=262124=rev
Log:
AMDGPU: Fix broken/confusing predefined macro

amdgcn should not be defining __R600__

Modified:
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/test/Preprocessor/predefined-arch-macros.c

Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=262124=262123=262124=diff
==
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Sat Feb 27 03:06:26 2016
@@ -1865,7 +1865,11 @@ public:
 
   void getTargetDefines(const LangOptions ,
 MacroBuilder ) const override {
-Builder.defineMacro("__R600__");
+if (getTriple().getArch() == llvm::Triple::amdgcn)
+  Builder.defineMacro("__AMDGCN__");
+else
+  Builder.defineMacro("__R600__");
+
 if (hasFMAF)
   Builder.defineMacro("__HAS_FMAF__");
 if (hasLDEXPF)

Modified: cfe/trunk/test/Preprocessor/predefined-arch-macros.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/predefined-arch-macros.c?rev=262124=262123=262124=diff
==
--- cfe/trunk/test/Preprocessor/predefined-arch-macros.c (original)
+++ cfe/trunk/test/Preprocessor/predefined-arch-macros.c Sat Feb 27 03:06:26 
2016
@@ -1962,3 +1962,17 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK_SYSTEMZ_ZVECTOR
 //
 // CHECK_SYSTEMZ_ZVECTOR: #define __VEC__ 10301
+
+// Begin amdgcn tests 
+//
+// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
+// RUN: -target amdgcn-unknown-unknown \
+// RUN:   | FileCheck %s -check-prefix=CHECK_AMDGCN
+// CHECK_AMDGCN: #define __AMDGCN__ 1
+
+// Begin r600 tests 
+//
+// RUN: %clang -march=amdgcn -E -dM %s -o - 2>&1 \
+// RUN: -target r600-unknown-unknown \
+// RUN:   | FileCheck %s -check-prefix=CHECK_R600
+// CHECK_R600: #define __R600__ 1


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


Re: [PATCH] D17645: AMDGPU: Add missing Volcanic Islands targets

2016-02-27 Thread Matt Arsenault via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


http://reviews.llvm.org/D17645



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