Re: r339581 - [SEMA] add more -Wfloat-conversion to compound assigment analysis

2018-08-13 Thread Vitaly Buka via cfe-commits
Looks like this patch:

http://lab.llvm.org:8011/builders/clang-ppc64le-linux-lnt/builds/13867/steps/ninja%20check%201/logs/stdio


FAIL: Clang :: Sema/conversion.c (12530 of 44133)
 TEST 'Clang :: Sema/conversion.c' FAILED

Script:
--
: 'RUN: at line 1';
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/bin/clang
-cc1 -internal-isystem
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/stage1/lib/clang/8.0.0/include
-nostdsysteminc -fsyntax-only -verify -Wconversion-nostdsysteminc
-nobuiltininc -isystem
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/tools/clang/test/Sema/Inputs
   -triple x86_64-apple-darwin
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/tools/clang/test/Sema/conversion.c
-Wno-unreachable-code
--
Exit Code: 1

Command Output (stderr):
--
error: 'warning' diagnostics seen but not expected:
  File 
/home/buildbots/ppc64le-clang-lnt-test/clang-ppc64le-lnt/llvm/tools/clang/test/Sema/conversion.c
Line 362: implicit conversion turns floating-point number into
integer: 'char' to 'float'
1 error generated.

--


On Mon, Aug 13, 2018 at 9:46 AM Nick Desaulniers via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: nickdesaulniers
> Date: Mon Aug 13 09:38:07 2018
> New Revision: 339581
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339581&view=rev
> Log:
> [SEMA] add more -Wfloat-conversion to compound assigment analysis
>
> Summary: Fixes Bug: https://bugs.llvm.org/show_bug.cgi?id=27061
>
> Reviewers: aaron.ballman, acoomans
>
> Reviewed By: aaron.ballman, acoomans
>
> Subscribers: acoomans, cfe-commits, srhines, pirama
>
> Differential Revision: https://reviews.llvm.org/D50467
>
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/test/SemaCXX/warn-float-conversion.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=339581&r1=339580&r2=339581&view=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Mon Aug 13 09:38:07 2018
> @@ -10282,33 +10282,6 @@ static void DiagnoseImpCast(Sema &S, Exp
>DiagnoseImpCast(S, E, E->getType(), T, CContext, diag,
> pruneControlFlow);
>  }
>
> -/// Analyze the given compound assignment for the possible losing of
> -/// floating-point precision.
> -static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
> -  assert(isa(E) &&
> - "Must be compound assignment operation");
> -  // Recurse on the LHS and RHS in here
> -  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
> -  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
> -
> -  // Now check the outermost expression
> -  const auto *ResultBT = E->getLHS()->getType()->getAs();
> -  const auto *RBT = cast(E)
> -->getComputationResultType()
> -->getAs();
> -
> -  // If both source and target are floating points.
> -  if (ResultBT && ResultBT->isFloatingPoint() && RBT &&
> RBT->isFloatingPoint())
> -// Builtin FP kinds are ordered by increasing FP rank.
> -if (ResultBT->getKind() < RBT->getKind())
> -  // We don't want to warn for system macro.
> -  if (!S.SourceMgr.isInSystemMacro(E->getOperatorLoc()))
> -// warn about dropping FP rank.
> -DiagnoseImpCast(S, E->getRHS(), E->getLHS()->getType(),
> -E->getOperatorLoc(),
> -diag::warn_impcast_float_result_precision);
> -}
> -
>  /// Diagnose an implicit cast from a floating point value to an integer
> value.
>  static void DiagnoseFloatingImpCast(Sema &S, Expr *E, QualType T,
>  SourceLocation CContext) {
> @@ -10411,6 +10384,39 @@ static void DiagnoseFloatingImpCast(Sema
>}
>  }
>
> +/// Analyze the given compound assignment for the possible losing of
> +/// floating-point precision.
> +static void AnalyzeCompoundAssignment(Sema &S, BinaryOperator *E) {
> +  assert(isa(E) &&
> + "Must be compound assignment operation");
> +  // Recurse on the LHS and RHS in here
> +  AnalyzeImplicitConversions(S, E->getLHS(), E->getOperatorLoc());
> +  AnalyzeImplicitConversions(S, E->getRHS(), E->getOperatorLoc());
> +
> +  // Now check the outermost expression
> +  const auto *ResultBT = E->getLHS()->getType()->getAs();
> +  const auto *RBT = cast(E)
> +->getComputationResultType()
> +->getAs();
> +
> +  // The below checks assume source is floating point.
> +  if (!ResultBT || !RBT || !RBT->isFloatingPoint()) return;
> +
> +  // If source is floating point but target is not.
> +  if (!ResultBT->isFloatingPoint())
> +return DiagnoseFloatingImpCast(S, E, E->getRHS()->getType(),
> +   E->getExprLoc());
> +
> +  // If both source and target are fl

Re: [libcxx] r339943 - Establish the header. NFC yet. Reviewed as https://reviews.llvm.org/D50815

2018-08-16 Thread Vitaly Buka via cfe-commits
This brakes some bots
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/22441

/b/sanitizer-x86_64-linux-fast/build/libcxx_build_msan/include/c++/v1/algorithm:648:10:
fatal error: 'bit' file not found
#include 
 ^
1 error generated.


On Thu, Aug 16, 2018 at 2:36 PM Marshall Clow via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: marshall
> Date: Thu Aug 16 14:35:38 2018
> New Revision: 339943
>
> URL: http://llvm.org/viewvc/llvm-project?rev=339943&view=rev
> Log:
> Establish the  header. NFC yet. Reviewed as
> https://reviews.llvm.org/D50815
>
> Added:
> libcxx/trunk/include/bit
> Modified:
> libcxx/trunk/include/algorithm
> libcxx/trunk/include/module.modulemap
> libcxx/trunk/test/libcxx/double_include.sh.cpp
>
> Modified: libcxx/trunk/include/algorithm
> URL:
> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=339943&r1=339942&r2=339943&view=diff
>
> ==
> --- libcxx/trunk/include/algorithm (original)
> +++ libcxx/trunk/include/algorithm Thu Aug 16 14:35:38 2018
> @@ -645,13 +645,7 @@ template   #include 
>  #include 
>  #include 
> -
> -#if defined(__IBMCPP__)
> -#include "support/ibm/support.h"
> -#endif
> -#if defined(_LIBCPP_COMPILER_MSVC)
> -#include 
> -#endif
> +#include 
>
>  #include <__debug>
>
> @@ -788,135 +782,6 @@ struct __debug_less
>
>  #endif  // _LIBCPP_DEBUG
>
> -// Precondition:  __x != 0
> -inline _LIBCPP_INLINE_VISIBILITY
> -unsigned __ctz(unsigned __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -return static_cast(__builtin_ctz(__x));
> -#else
> -  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
> -  static_assert(sizeof(unsigned long) == 4, "");
> -  unsigned long where;
> -  // Search from LSB to MSB for first set bit.
> -  // Returns zero if no set bit is found.
> -  if (_BitScanForward(&where, __x))
> -return where;
> -  return 32;
> -#endif
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY
> -unsigned long __ctz(unsigned long __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -return static_cast(__builtin_ctzl(__x));
> -#else
> -static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
> -return __ctz(static_cast(__x));
> -#endif
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY
> -unsigned long long __ctz(unsigned long long __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -return static_cast(__builtin_ctzll(__x));
> -#else
> -unsigned long where;
> -// Search from LSB to MSB for first set bit.
> -// Returns zero if no set bit is found.
> -#if defined(_LIBCPP_HAS_BITSCAN64)
> -(defined(_M_AMD64) || defined(__x86_64__))
> -  if (_BitScanForward64(&where, __x))
> -return static_cast(where);
> -#else
> -  // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit
> calls.
> -  // Scan the Low Word.
> -  if (_BitScanForward(&where, static_cast(__x)))
> -return where;
> -  // Scan the High Word.
> -  if (_BitScanForward(&where, static_cast(__x >> 32)))
> -return where + 32; // Create a bit offset from the LSB.
> -#endif
> -  return 64;
> -#endif // _LIBCPP_COMPILER_MSVC
> -}
> -
> -// Precondition:  __x != 0
> -inline _LIBCPP_INLINE_VISIBILITY
> -unsigned __clz(unsigned __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -return static_cast(__builtin_clz(__x));
> -#else
> -  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
> -  static_assert(sizeof(unsigned long) == 4, "");
> -  unsigned long where;
> -  // Search from LSB to MSB for first set bit.
> -  // Returns zero if no set bit is found.
> -  if (_BitScanReverse(&where, __x))
> -return 31 - where;
> -  return 32; // Undefined Behavior.
> -#endif
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY
> -unsigned long __clz(unsigned long __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -return static_cast(__builtin_clzl (__x));
> -#else
> -static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
> -return __clz(static_cast(__x));
> -#endif
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY
> -unsigned long long __clz(unsigned long long __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -return static_cast(__builtin_clzll(__x));
> -#else
> -  unsigned long where;
> -// BitScanReverse scans from MSB to LSB for first set bit.
> -// Returns 0 if no set bit is found.
> -#if defined(_LIBCPP_HAS_BITSCAN64)
> -  if (_BitScanReverse64(&where, __x))
> -return static_cast(63 - where);
> -#else
> -  // Scan the high 32 bits.
> -  if (_BitScanReverse(&where, static_cast(__x >> 32)))
> -return 63 - (where + 32); // Create a bit offset from the MSB.
> -  // Scan the low 32 bits.
> -  if (_BitScanReverse(&where, static_cast(__x)))
> -return 63 - where;
> -#endif
> -  return 64; // Undefined Behavior.
> -#endif // _LIBCPP_COMPILER_MSVC
> -}
> -
> -inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {
> -#ifndef _LIBCPP_COMPILER_MSVC
> -  return __builtin_popcount  (__x);
> -#else
> -  static_assert(sizeof(unsigned) == 4, "");
> 

Re: [libcxx] r339943 - Establish the header. NFC yet. Reviewed as https://reviews.llvm.org/D50815

2018-08-16 Thread Vitaly Buka via cfe-commits
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/27733
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/14670

On Thu, Aug 16, 2018 at 3:30 PM Vitaly Buka  wrote:

> This brakes some bots
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/22441
>
> /b/sanitizer-x86_64-linux-fast/build/libcxx_build_msan/include/c++/v1/algorithm:648:10:
>  fatal error: 'bit' file not found
> #include 
>  ^
> 1 error generated.
>
>
> On Thu, Aug 16, 2018 at 2:36 PM Marshall Clow via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: marshall
>> Date: Thu Aug 16 14:35:38 2018
>> New Revision: 339943
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=339943&view=rev
>> Log:
>> Establish the  header. NFC yet. Reviewed as
>> https://reviews.llvm.org/D50815
>>
>> Added:
>> libcxx/trunk/include/bit
>> Modified:
>> libcxx/trunk/include/algorithm
>> libcxx/trunk/include/module.modulemap
>> libcxx/trunk/test/libcxx/double_include.sh.cpp
>>
>> Modified: libcxx/trunk/include/algorithm
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=339943&r1=339942&r2=339943&view=diff
>>
>> ==
>> --- libcxx/trunk/include/algorithm (original)
>> +++ libcxx/trunk/include/algorithm Thu Aug 16 14:35:38 2018
>> @@ -645,13 +645,7 @@ template >  #include 
>>  #include 
>>  #include 
>> -
>> -#if defined(__IBMCPP__)
>> -#include "support/ibm/support.h"
>> -#endif
>> -#if defined(_LIBCPP_COMPILER_MSVC)
>> -#include 
>> -#endif
>> +#include 
>>
>>  #include <__debug>
>>
>> @@ -788,135 +782,6 @@ struct __debug_less
>>
>>  #endif  // _LIBCPP_DEBUG
>>
>> -// Precondition:  __x != 0
>> -inline _LIBCPP_INLINE_VISIBILITY
>> -unsigned __ctz(unsigned __x) {
>> -#ifndef _LIBCPP_COMPILER_MSVC
>> -return static_cast(__builtin_ctz(__x));
>> -#else
>> -  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
>> -  static_assert(sizeof(unsigned long) == 4, "");
>> -  unsigned long where;
>> -  // Search from LSB to MSB for first set bit.
>> -  // Returns zero if no set bit is found.
>> -  if (_BitScanForward(&where, __x))
>> -return where;
>> -  return 32;
>> -#endif
>> -}
>> -
>> -inline _LIBCPP_INLINE_VISIBILITY
>> -unsigned long __ctz(unsigned long __x) {
>> -#ifndef _LIBCPP_COMPILER_MSVC
>> -return static_cast(__builtin_ctzl(__x));
>> -#else
>> -static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
>> -return __ctz(static_cast(__x));
>> -#endif
>> -}
>> -
>> -inline _LIBCPP_INLINE_VISIBILITY
>> -unsigned long long __ctz(unsigned long long __x) {
>> -#ifndef _LIBCPP_COMPILER_MSVC
>> -return static_cast(__builtin_ctzll(__x));
>> -#else
>> -unsigned long where;
>> -// Search from LSB to MSB for first set bit.
>> -// Returns zero if no set bit is found.
>> -#if defined(_LIBCPP_HAS_BITSCAN64)
>> -(defined(_M_AMD64) || defined(__x86_64__))
>> -  if (_BitScanForward64(&where, __x))
>> -return static_cast(where);
>> -#else
>> -  // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit
>> calls.
>> -  // Scan the Low Word.
>> -  if (_BitScanForward(&where, static_cast(__x)))
>> -return where;
>> -  // Scan the High Word.
>> -  if (_BitScanForward(&where, static_cast(__x >> 32)))
>> -return where + 32; // Create a bit offset from the LSB.
>> -#endif
>> -  return 64;
>> -#endif // _LIBCPP_COMPILER_MSVC
>> -}
>> -
>> -// Precondition:  __x != 0
>> -inline _LIBCPP_INLINE_VISIBILITY
>> -unsigned __clz(unsigned __x) {
>> -#ifndef _LIBCPP_COMPILER_MSVC
>> -return static_cast(__builtin_clz(__x));
>> -#else
>> -  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
>> -  static_assert(sizeof(unsigned long) == 4, "");
>> -  unsigned long where;
>> -  // Search from LSB to MSB for first set bit.
>> -  // Returns zero if no set bit is found.
>> -  if (_BitScanReverse(&where, __x))
>> -return 31 - where;
>> -  return 32; // Undefined Behavior.
>> -#endif
>> -}
>> -
>> -inline _LIBCPP_INLINE_VISIBILITY
>> -unsigned long __clz(unsigned long __x) {
>> -#ifndef _LIBCPP_COMPILER_MSVC
>> -return static_cast(__builtin_clzl (__x));
>> -#else
>> -static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
>> -return __clz(static_cast(__x));
>> -#endif
>> -}
>> -
>> -inline _LIBCPP_INLINE_VISIBILITY
>> -unsigned long long __clz(unsigned long long __x) {
>> -#ifndef _LIBCPP_COMPILER_MSVC
>> -return static_cast(__builtin_clzll(__x));
>> -#else
>> -  unsigned long where;
>> -// BitScanReverse scans from MSB to LSB for first set bit.
>> -// Returns 0 if no set bit is found.
>> -#if defined(_LIBCPP_HAS_BITSCAN64)
>> -  if (_BitScanReverse64(&where, __x))
>> -return static_cast(63 - where);
>> -#else
>> -  // Scan the high 32 bits.
>> -  if (_BitScanReverse(&where, static_cast(__x >> 32)))
>> -return 63 - (where + 32); // Create a bit offset from the MSB.
>> -  // Scan the low 32 bits.
>> - 

[libcxx] r339971 - Revert "Establish the header. NFC yet. Reviewed as https://reviews.llvm.org/D50815"

2018-08-16 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Aug 16 16:57:16 2018
New Revision: 339971

URL: http://llvm.org/viewvc/llvm-project?rev=339971&view=rev
Log:
Revert "Establish the  header. NFC yet. Reviewed as 
https://reviews.llvm.org/D50815";

Breaks build on sanitizer bots.

This reverts commit r339943.

Removed:
libcxx/trunk/include/bit
Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=339971&r1=339970&r2=339971&view=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Thu Aug 16 16:57:16 2018
@@ -645,7 +645,13 @@ template 
 #include 
 #include 
-#include 
+
+#if defined(__IBMCPP__)
+#include "support/ibm/support.h"
+#endif
+#if defined(_LIBCPP_COMPILER_MSVC)
+#include 
+#endif
 
 #include <__debug>
 
@@ -782,6 +788,135 @@ struct __debug_less
 
 #endif  // _LIBCPP_DEBUG
 
+// Precondition:  __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned __ctz(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_ctz(__x));
+#else
+  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+  static_assert(sizeof(unsigned long) == 4, "");
+  unsigned long where;
+  // Search from LSB to MSB for first set bit.
+  // Returns zero if no set bit is found.
+  if (_BitScanForward(&where, __x))
+return where;
+  return 32;
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long __ctz(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_ctzl(__x));
+#else
+static_assert(sizeof(unsigned long) == sizeof(unsigned), "");
+return __ctz(static_cast(__x));
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long __ctz(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_ctzll(__x));
+#else
+unsigned long where;
+// Search from LSB to MSB for first set bit.
+// Returns zero if no set bit is found.
+#if defined(_LIBCPP_HAS_BITSCAN64)
+(defined(_M_AMD64) || defined(__x86_64__))
+  if (_BitScanForward64(&where, __x))
+return static_cast(where);
+#else
+  // Win32 doesn't have _BitScanForward64 so emulate it with two 32 bit calls.
+  // Scan the Low Word.
+  if (_BitScanForward(&where, static_cast(__x)))
+return where;
+  // Scan the High Word.
+  if (_BitScanForward(&where, static_cast(__x >> 32)))
+return where + 32; // Create a bit offset from the LSB.
+#endif
+  return 64;
+#endif // _LIBCPP_COMPILER_MSVC
+}
+
+// Precondition:  __x != 0
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned __clz(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_clz(__x));
+#else
+  static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+  static_assert(sizeof(unsigned long) == 4, "");
+  unsigned long where;
+  // Search from LSB to MSB for first set bit.
+  // Returns zero if no set bit is found.
+  if (_BitScanReverse(&where, __x))
+return 31 - where;
+  return 32; // Undefined Behavior.
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long __clz(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_clzl (__x));
+#else
+static_assert(sizeof(unsigned) == sizeof(unsigned long), "");
+return __clz(static_cast(__x));
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY
+unsigned long long __clz(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+return static_cast(__builtin_clzll(__x));
+#else
+  unsigned long where;
+// BitScanReverse scans from MSB to LSB for first set bit.
+// Returns 0 if no set bit is found.
+#if defined(_LIBCPP_HAS_BITSCAN64)
+  if (_BitScanReverse64(&where, __x))
+return static_cast(63 - where);
+#else
+  // Scan the high 32 bits.
+  if (_BitScanReverse(&where, static_cast(__x >> 32)))
+return 63 - (where + 32); // Create a bit offset from the MSB.
+  // Scan the low 32 bits.
+  if (_BitScanReverse(&where, static_cast(__x)))
+return 63 - where;
+#endif
+  return 64; // Undefined Behavior.
+#endif // _LIBCPP_COMPILER_MSVC
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+  return __builtin_popcount  (__x);
+#else
+  static_assert(sizeof(unsigned) == 4, "");
+  return __popcnt(__x);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+  return __builtin_popcountl (__x);
+#else
+  static_assert(sizeof(unsigned long) == 4, "");
+  return __popcnt(__x);
+#endif
+}
+
+inline _LIBCPP_INLINE_VISIBILITY int __pop_count(unsigned long long __x) {
+#ifndef _LIBCPP_COMPILER_MSVC
+  return __builtin_popcountll(__x);
+#else
+  static_assert(sizeof(unsigned long long) == 8, "");
+  return __popcnt64(__x);
+#endif
+}
+
 // all_of
 
 template 

Removed: libcxx/trunk/include/bit
URL: 
http

r325182 - [ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

2018-02-14 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Feb 14 14:41:15 2018
New Revision: 325182

URL: http://llvm.org/viewvc/llvm-project?rev=325182&view=rev
Log:
[ThinLTO/CFI] Include TYPE_ID summaries into GLOBALVAL_SUMMARY_BLOCK

Summary:
TypeID summaries are used by CFI and need to be serialized by ThinLTO
indexing for later use by LTO Backend.

Reviewers: tejohnson, pcc

Subscribers: mehdi_amini, inglorion, eraman, hiraditya, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll
cfe/trunk/test/CodeGen/thinlto-distributed.ll
Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=325182&r1=325181&r2=325182&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Feb 14 14:41:15 2018
@@ -96,6 +96,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-bcanalyzer
 llvm-cat
 llvm-dis
+llvm-lto2
 llvm-modextract
 llvm-nm
 llvm-objdump

Added: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=325182&view=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Wed Feb 14 
14:41:15 2018
@@ -0,0 +1,101 @@
+; REQUIRES: x86-registered-target
+
+; Backend test for distribute ThinLTO with CFI.
+; It additionally enables -fwhole-program-vtables to get more information in
+; TYPE_IDs of GLOBALVAL_SUMMARY_BLOCK.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,_ZN1A1nEi,p \
+; RUN:   -r=%t.o,_ZN1B1fEi,p \
+; RUN:   -r=%t.o,_ZN1C1fEi,p \
+; RUN:   -r=%t.o,_ZTV1B, \
+; RUN:   -r=%t.o,_ZTV1C, \
+; RUN:   -r=%t.o,_ZN1A1nEi, \
+; RUN:   -r=%t.o,_ZN1B1fEi, \
+; RUN:   -r=%t.o,_ZN1C1fEi, \
+; RUN:   -r=%t.o,_ZTV1B,px \
+; RUN:   -r=%t.o,_ZTV1C,px
+
+; Ensure that typeids are in the index.
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s
+; CHECK-LABEL: 
+; CHECK-LABEL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll?rev=325182&view=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi.ll Wed Feb 14 14:41:15 2018
@@ -0,0 +1,67 @@
+; REQUIRES: x86-registered-target
+
+; Backend test for distribute ThinLTO with CFI.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,test,px \
+; RUN:   -r=%t.o,_ZTV1B, \
+; RUN:   -r=%t.o,_ZN1B1fEi, \
+; RUN:   -r=%t.o,_ZTV1B,px
+
+; Check that typeids are in the index.
+; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s
+; CHECK-LABEL: 
+; CHECK-LABEL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed.ll?rev=325182&view=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed.ll Wed Feb 14 14:41:15 2018
@@ -0,0 +1,21 @@
+; REQUIRES: x86-registered-target
+
+; Trivial test for distributes ThinLTO
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,main,px
+
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
+; RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-grtev4-linux-gnu"
+
+define i32 @main() {
+entry:
+  ret i32 0
+}


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


r325184 - Moved CHECK in test closer to source code

2018-02-14 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Feb 14 14:52:49 2018
New Revision: 325184

URL: http://llvm.org/viewvc/llvm-project?rev=325184&view=rev
Log:
Moved CHECK in test closer to source code

Modified:
cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll

Modified: cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll?rev=325184&r1=325183&r2=325184&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-cfi-devirt.ll Wed Feb 14 
14:52:49 2018
@@ -54,8 +54,6 @@ entry:
   %0 = bitcast %struct.A* %obj to i8**
   %vtable5 = load i8*, i8** %0
 
-  ; Check that the call was devirtualized.
-  ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
   %1 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable5, i32 8, 
metadata !"_ZTS1A")
   %2 = extractvalue { i8*, i1 } %1, 1
   br i1 %2, label %cont, label %trap
@@ -67,6 +65,9 @@ trap:
 cont:
   %3 = extractvalue { i8*, i1 } %1, 0
   %4 = bitcast i8* %3 to i32 (%struct.A*, i32)*
+
+  ; Check that the call was devirtualized.
+  ; CHECK-IR: %call = tail call i32 @_ZN1A1nEi
   %call = tail call i32 %4(%struct.A* nonnull %obj, i32 %a)
   %vtable16 = load i8*, i8** %0
   %5 = tail call { i8*, i1 } @llvm.type.checked.load(i8* %vtable16, i32 0, 
metadata !"_ZTS1A")


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


r325410 - [ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set

2018-02-16 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Feb 16 15:34:16 2018
New Revision: 325410

URL: http://llvm.org/viewvc/llvm-project?rev=325410&view=rev
Log:
[ThinLTO] Ignore object files with no ThinLTO modules if -fthinlto-index= is set

Summary:
ThinLTO compilation may decide not to split module and keep at as regular LTO.
In this can this module already processed during indexing and already a part of
merged object file. So here we can just skip it.

Reviewers: pcc, tejohnson

Reviewed By: tejohnson

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

Modified:
cfe/trunk/include/clang/CodeGen/BackendUtil.h
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/CodeGen/CodeGenAction.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/include/clang/CodeGen/BackendUtil.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/BackendUtil.h?rev=325410&r1=325409&r2=325410&view=diff
==
--- cfe/trunk/include/clang/CodeGen/BackendUtil.h (original)
+++ cfe/trunk/include/clang/CodeGen/BackendUtil.h Fri Feb 16 15:34:16 2018
@@ -49,6 +49,8 @@ namespace clang {
 
   llvm::Expected
   FindThinLTOModule(llvm::MemoryBufferRef MBRef);
+  llvm::BitcodeModule *
+  FindThinLTOModule(llvm::MutableArrayRef BMs);
 }
 
 #endif

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=325410&r1=325409&r2=325410&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Feb 16 15:34:16 2018
@@ -1025,16 +1025,22 @@ Expected clang::FindThinL
 
   // The bitcode file may contain multiple modules, we want the one that is
   // marked as being the ThinLTO module.
-  for (BitcodeModule &BM : *BMsOrErr) {
-Expected LTOInfo = BM.getLTOInfo();
-if (LTOInfo && LTOInfo->IsThinLTO)
-  return BM;
-  }
+  if (const BitcodeModule *Bm = FindThinLTOModule(*BMsOrErr))
+return *Bm;
 
   return make_error("Could not find module summary",
  inconvertibleErrorCode());
 }
 
+BitcodeModule *clang::FindThinLTOModule(MutableArrayRef BMs) {
+  for (BitcodeModule &BM : BMs) {
+Expected LTOInfo = BM.getLTOInfo();
+if (LTOInfo && LTOInfo->IsThinLTO)
+  return &BM;
+  }
+  return nullptr;
+}
+
 static void runThinLTOBackend(ModuleSummaryIndex *CombinedIndex, Module *M,
   const HeaderSearchOptions &HeaderOpts,
   const CodeGenOptions &CGOpts,

Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=325410&r1=325409&r2=325410&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Fri Feb 16 15:34:16 2018
@@ -947,12 +947,21 @@ std::unique_ptr CodeGenAct
   return {};
 };
 
-Expected BMOrErr = FindThinLTOModule(MBRef);
-if (!BMOrErr)
-  return DiagErrors(BMOrErr.takeError());
-
+Expected> BMsOrErr = 
getBitcodeModuleList(MBRef);
+if (!BMsOrErr)
+  return DiagErrors(BMsOrErr.takeError());
+BitcodeModule *Bm = FindThinLTOModule(*BMsOrErr);
+// We have nothing to do if the file contains no ThinLTO module. This is
+// possible if ThinLTO compilation was not able to split module. Content of
+// the file was already processed by indexing and will be passed to the
+// linker using merged object file.
+if (!Bm) {
+  auto M = llvm::make_unique("empty", *VMContext);
+  M->setTargetTriple(CI.getTargetOpts().Triple);
+  return M;
+}
 Expected> MOrErr =
-BMOrErr->parseModule(*VMContext);
+Bm->parseModule(*VMContext);
 if (!MOrErr)
   return DiagErrors(MOrErr.takeError());
 return std::move(*MOrErr);

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=325410&r1=325409&r2=325410&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Fri Feb 16 15:34:16 2018
@@ -20,6 +20,12 @@
 ; CHECK-OBJ-IGNORE-EMPTY: T f1
 ; CHECK-OBJ-IGNORE-EMPTY: U f2
 
+; Ensure we don't fail with index and non-ThinLTO object file, and output must
+; be empty file.
+; RUN: opt -o %t5.o %s
+; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t4.o -x ir %t5.o -c 
-fthinlto-index=%t.thinlto.bc
+; RUN: llvm-nm %t4.o | count 0
+
 ; Ensure f2 was imported
 ; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t3.o -x ir %t1.o -c 
-fthinlto-index=%t.thinlto.bc
 ; RUN: llvm-nm %t3.o | FileCheck --check

r325411 - [ThinLTO] Allow indexing to request backend to ignore the module

2018-02-16 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Feb 16 15:38:22 2018
New Revision: 325411

URL: http://llvm.org/viewvc/llvm-project?rev=325411&view=rev
Log:
[ThinLTO] Allow indexing to request backend to ignore the module

Summary:
Gold plugin does not add pass to ThinLTO modules without useful symbols.
In this case ThinLTO can't create corresponding index file and some features, 
like CFI,
cannot be processes by backed correctly without index.
Given that we don't need the backed output we can request it to avoid
processing the module. This is implemented by this patch using new
"SkipModuleByDistributedBackend" flag.

Reviewers: pcc, tejohnson

Subscribers: mehdi_amini, inglorion, eraman, cfe-commits

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

Added:
cfe/trunk/test/CodeGen/Inputs/thinlto-distributed-backend-skip.bc   (with 
props)
cfe/trunk/test/CodeGen/thinlto-distributed-backend-skip.ll
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=325411&r1=325410&r2=325411&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Feb 16 15:38:22 2018
@@ -1153,6 +1153,7 @@ void clang::EmitBackendOutput(Diagnostic
   const llvm::DataLayout &TDesc, Module *M,
   BackendAction Action,
   std::unique_ptr OS) {
+  std::unique_ptr EmptyModule;
   if (!CGOpts.ThinLTOIndexFile.empty()) {
 // If we are performing a ThinLTO importing compile, load the function 
index
 // into memory and pass it into runThinLTOBackend, which will run the
@@ -1170,11 +1171,22 @@ void clang::EmitBackendOutput(Diagnostic
 // A null CombinedIndex means we should skip ThinLTO compilation
 // (LLVM will optionally ignore empty index files, returning null instead
 // of an error).
-bool DoThinLTOBackend = CombinedIndex != nullptr;
-if (DoThinLTOBackend) {
-  runThinLTOBackend(CombinedIndex.get(), M, HeaderOpts, CGOpts, TOpts,
-LOpts, std::move(OS), CGOpts.SampleProfileFile, 
Action);
-  return;
+if (CombinedIndex) {
+  if (!CombinedIndex->skipModuleByDistributedBackend()) {
+runThinLTOBackend(CombinedIndex.get(), M, HeaderOpts, CGOpts, TOpts,
+  LOpts, std::move(OS), CGOpts.SampleProfileFile,
+  Action);
+return;
+  }
+  // Distributed indexing detected that nothing from the module is needed
+  // for the final linking. So we can skip the compilation. We sill need to
+  // output an empty object file to make sure that a linker does not fail
+  // trying to read it. Also for some features, like CFI, we must skip
+  // the compilation as CombinedIndex does not contain all required
+  // information.
+  EmptyModule = llvm::make_unique("empty", M->getContext());
+  EmptyModule->setTargetTriple(M->getTargetTriple());
+  M = EmptyModule.get();
 }
   }
 

Added: cfe/trunk/test/CodeGen/Inputs/thinlto-distributed-backend-skip.bc
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/Inputs/thinlto-distributed-backend-skip.bc?rev=325411&view=auto
==
Binary file - no diff available.

Propchange: cfe/trunk/test/CodeGen/Inputs/thinlto-distributed-backend-skip.bc
--
svn:mime-type = application/octet-stream

Added: cfe/trunk/test/CodeGen/thinlto-distributed-backend-skip.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-distributed-backend-skip.ll?rev=325411&view=auto
==
--- cfe/trunk/test/CodeGen/thinlto-distributed-backend-skip.ll (added)
+++ cfe/trunk/test/CodeGen/thinlto-distributed-backend-skip.ll Fri Feb 16 
15:38:22 2018
@@ -0,0 +1,21 @@
+; REQUIRES: x86-registered-target
+
+; Check that ThinLTO backend respects "SkipModuleByDistributedBackend"
+; flag which can be set by indexing.
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: %clang_cc1 -triple x86_64-grtev4-linux-gnu \
+; RUN:   -fthinlto-index=%S/Inputs/thinlto-distributed-backend-skip.bc \
+; RUN:   -emit-llvm -o - -x ir %t.o | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-grtev4-linux-gnu"
+
+; CHECK: "empty"
+; CHECK: target triple =
+; CHECK-NOT: @main
+define i32 @main() {
+entry:
+  ret i32 0
+}


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


Re: r304017 - CodeGen: Define Swift's legal vector types for AArch64, ARM

2017-05-26 Thread Vitaly Buka via cfe-commits
Could this be the patch
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/5228/steps/check-llvm%20msan/logs/stdio

FAIL: LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll (5392 of 20818)
 TEST 'LLVM :: CodeGen/ARM/arm-shrink-wrapping.ll'
FAILED 
Script:
--
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=armv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=ARM --check-prefix=ENABLE
--check-prefix=ARM-ENABLE
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=armv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=ARM --check-prefix=DISABLE
--check-prefix=ARM-DISABLE
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=true -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=thumbv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=THUMB --check-prefix=ENABLE
--check-prefix=THUMB-ENABLE
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/llc
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
-o - -enable-shrink-wrap=false -ifcvt-fn-start=1 -ifcvt-fn-stop=0
-mtriple=thumbv7-apple-ios   |
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_msan/./bin/FileCheck
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll
--check-prefix=CHECK --check-prefix=THUMB --check-prefix=DISABLE
--check-prefix=THUMB-DISABLE
--
Exit Code: 1

Command Output (stderr):
--
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/ARM/arm-shrink-wrapping.ll:659:10:
error: expected string not found in input
; CHECK: bl
 ^
:375:7: note: scanning from here
 vldr s0, LCPI12_0
  ^
:377:2: note: possible intended match here
 bx lr
 ^



On Fri, May 26, 2017 at 11:11 AM, Arnold Schwaighofer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: arnolds
> Date: Fri May 26 13:11:54 2017
> New Revision: 304017
>
> URL: http://llvm.org/viewvc/llvm-project?rev=304017&view=rev
> Log:
> CodeGen: Define Swift's legal vector types for AArch64, ARM
>
> rdar://32401301
>
> Modified:
> cfe/trunk/lib/CodeGen/TargetInfo.cpp
> cfe/trunk/test/CodeGen/64bit-swiftcall.c
> cfe/trunk/test/CodeGen/arm-swiftcall.c
>
> Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> TargetInfo.cpp?rev=304017&r1=304016&r2=304017&view=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
> +++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Fri May 26 13:11:54 2017
> @@ -4821,6 +4821,9 @@ private:
>bool isSwiftErrorInRegister() const override {
>  return true;
>}
> +
> +  bool isLegalVectorTypeForSwift(CharUnits totalSize, llvm::Type *eltTy,
> + unsigned elts) const override;
>  };
>
>  class AArch64TargetCodeGenInfo : public TargetCodeGenInfo {
> @@ -4994,6 +4997,17 @@ bool AArch64ABIInfo::isIllegalVectorType
>return false;
>  }
>
> +bool AArch64ABIInfo::isLegalVectorTypeForSwift(CharUnits totalSize,
> +   llvm::Type *eltTy,
> +   unsigned elts) const {
> +  if (!llvm::isPowerOf2_32(elts))
> +return false;
> +  if (totalSize.getQuantity() != 8 &&
> +  (totalSize.getQuantity() != 16 || elts == 1))
> +return false;
> +  return true;
> +}
> +
>  bool AArch64ABIInfo::isHomogeneousAggregateBaseType(QualType Ty) const {
>// Homogeneous aggregates for AAPCS64 must have base types of a floating
>// point type or a short-vector type. This is the same as the 32-bit
> ABI,
> @@ -5382,6 +5396,8 @@ private:
>bool isSwiftErrorInRegister() const override

r334216 - Introducing single for loop into clang_proto_fuzzer

2018-06-07 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jun  7 12:17:46 2018
New Revision: 334216

URL: http://llvm.org/viewvc/llvm-project?rev=334216&view=rev
Log:
Introducing single for loop into clang_proto_fuzzer

Summary:
Created a new protobuf and protobuf-to-C++ "converter" that wraps the entire 
C++ code in a single for loop.
  - Slightly changed cxx_proto.proto -> cxx_loop_proto.proto
  - Made some changes to proto_to_cxx files to handle the new kind of protobuf
  - Created ExampleClangLoopProtoFuzzer to test new protobuf and "converter"

Patch by Emmett Neyman

Reviewers: kcc, vitalybuka, morehouse

Reviewed By: vitalybuka, morehouse

Subscribers: mgorny, llvm-commits, cfe-commits

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

Added:
cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
cfe/trunk/tools/clang-fuzzer/cxx_loop_proto.proto
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx.cpp
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/loop_proto_to_cxx_main.cpp
Modified:
cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/CMakeLists.txt
cfe/trunk/tools/clang-fuzzer/proto-to-cxx/proto_to_cxx.h

Modified: cfe/trunk/tools/clang-fuzzer/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/CMakeLists.txt?rev=334216&r1=334215&r2=334216&view=diff
==
--- cfe/trunk/tools/clang-fuzzer/CMakeLists.txt (original)
+++ cfe/trunk/tools/clang-fuzzer/CMakeLists.txt Thu Jun  7 12:17:46 2018
@@ -14,6 +14,7 @@ set(LLVM_OPTIONAL_SOURCES
   ClangFuzzer.cpp
   DummyClangFuzzer.cpp
   ExampleClangProtoFuzzer.cpp
+  ExampleClangLoopProtoFuzzer.cpp
   )
 
 if(CLANG_ENABLE_PROTO_FUZZER)
@@ -24,6 +25,7 @@ if(CLANG_ENABLE_PROTO_FUZZER)
   include_directories(${PROTOBUF_INCLUDE_DIRS})
   include_directories(${CMAKE_CURRENT_BINARY_DIR})
   protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS cxx_proto.proto)
+  protobuf_generate_cpp(LOOP_PROTO_SRCS LOOP_PROTO_HDRS cxx_loop_proto.proto)
   set(LLVM_OPTIONAL_SOURCES ${LLVM_OPTIONAL_SOURCES} ${PROTO_SRCS})
   add_clang_library(clangCXXProto
 ${PROTO_SRCS}
@@ -33,13 +35,21 @@ if(CLANG_ENABLE_PROTO_FUZZER)
 ${PROTOBUF_LIBRARIES}
 )
 
+  add_clang_library(clangCXXLoopProto
+${LOOP_PROTO_SRCS}
+${LOOP_PROTO_HDRS}
+
+LINK_LIBS
+${PROTOBUF_LIBRARIES}
+)
+
   # Build and include libprotobuf-mutator
   include(ProtobufMutator)
   include_directories(${ProtobufMutator_INCLUDE_DIRS})
 
   # Build the protobuf->C++ translation library and driver.
   add_clang_subdirectory(proto-to-cxx)
-
+  
   # Build the fuzzer initialization library.
   add_clang_subdirectory(fuzzer-initialize)
 
@@ -49,16 +59,32 @@ if(CLANG_ENABLE_PROTO_FUZZER)
 ExampleClangProtoFuzzer.cpp
 )
 
-  target_link_libraries(clang-proto-fuzzer
-PRIVATE
+  # Build the loop protobuf fuzzer
+  add_clang_executable(clang-loop-proto-fuzzer
+${DUMMY_MAIN}
+ExampleClangLoopProtoFuzzer.cpp
+)
+
+  set(COMMON_PROTO_FUZZ_LIBRARIES
 ${ProtobufMutator_LIBRARIES}
 ${PROTOBUF_LIBRARIES}
 ${LLVM_LIB_FUZZING_ENGINE}
-clangCXXProto
 clangFuzzerInitialize
 clangHandleCXX
+)
+
+  target_link_libraries(clang-proto-fuzzer
+PRIVATE
+${COMMON_PROTO_FUZZ_LIBRARIES}
+clangCXXProto
 clangProtoToCXX
 )
+  target_link_libraries(clang-loop-proto-fuzzer
+PRIVATE
+${COMMON_PROTO_FUZZ_LIBRARIES}
+clangCXXLoopProto
+clangLoopProtoToCXX
+)
 endif()
 
 add_clang_subdirectory(handle-cxx)

Added: cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp?rev=334216&view=auto
==
--- cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp (added)
+++ cfe/trunk/tools/clang-fuzzer/ExampleClangLoopProtoFuzzer.cpp Thu Jun  7 
12:17:46 2018
@@ -0,0 +1,30 @@
+//===-- ExampleClangLoopProtoFuzzer.cpp - Fuzz Clang 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+///  This file implements a function that runs Clang on a single
+///  input and uses libprotobuf-mutator to find new inputs. This function is
+///  then linked into the Fuzzer library. This file differs from
+///  ExampleClangProtoFuzzer in that it uses the new protobuf that includes
+///  C++ code with a single for loop.
+///
+//===--===//
+
+#include "cxx_loop_proto.pb.h"
+#include "fuzzer-initialize/fuzzer_initialize.h"
+#include "handle-cxx/handle_cxx.h"
+#include "proto-to-cxx/proto_to_cxx.h"
+#include "src/libfuzzer/libfuzzer_

Re: r334677 - P0096R5, P0941R2: Update to match latest feature test macro specification.

2018-06-17 Thread Vitaly Buka via cfe-commits
Hi Richard,
After this patch check-all fails for me with:
  llvm-project/libcxx/utils/libcxx/test/config.py", line 467, in
configure_features
int(macros['__cpp_deduction_guides']) < 201611:
ValueError: invalid literal for int() with base 10: '201703L'

On Wed, Jun 13, 2018 at 5:44 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed Jun 13 17:40:20 2018
> New Revision: 334677
>
> URL: http://llvm.org/viewvc/llvm-project?rev=334677&view=rev
> Log:
> P0096R5, P0941R2: Update to match latest feature test macro specification.
>
> Modified:
> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> cfe/trunk/test/Lexer/cxx-features.cpp
> cfe/trunk/www/cxx_status.html
>
> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=334677&r1=334676&r2=334677&view=diff
>
> ==
> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Jun 13 17:40:20 2018
> @@ -487,82 +487,86 @@ static void InitializeCPlusPlusFeatureTe
>   MacroBuilder &Builder) {
>// C++98 features.
>if (LangOpts.RTTI)
> -Builder.defineMacro("__cpp_rtti", "199711");
> +Builder.defineMacro("__cpp_rtti", "199711L");
>if (LangOpts.CXXExceptions)
> -Builder.defineMacro("__cpp_exceptions", "199711");
> +Builder.defineMacro("__cpp_exceptions", "199711L");
>
>// C++11 features.
>if (LangOpts.CPlusPlus11) {
> -Builder.defineMacro("__cpp_unicode_characters", "200704");
> -Builder.defineMacro("__cpp_raw_strings", "200710");
> -Builder.defineMacro("__cpp_unicode_literals", "200710");
> -Builder.defineMacro("__cpp_user_defined_literals", "200809");
> -Builder.defineMacro("__cpp_lambdas", "200907");
> +Builder.defineMacro("__cpp_unicode_characters", "200704L");
> +Builder.defineMacro("__cpp_raw_strings", "200710L");
> +Builder.defineMacro("__cpp_unicode_literals", "200710L");
> +Builder.defineMacro("__cpp_user_defined_literals", "200809L");
> +Builder.defineMacro("__cpp_lambdas", "200907L");
>  Builder.defineMacro("__cpp_constexpr",
> -LangOpts.CPlusPlus17 ? "201603" :
> -LangOpts.CPlusPlus14 ? "201304" : "200704");
> +LangOpts.CPlusPlus17 ? "201603L" :
> +LangOpts.CPlusPlus14 ? "201304L" : "200704");
>  Builder.defineMacro("__cpp_range_based_for",
> -LangOpts.CPlusPlus17 ? "201603" : "200907");
> +LangOpts.CPlusPlus17 ? "201603L" : "200907");
>  Builder.defineMacro("__cpp_static_assert",
> -LangOpts.CPlusPlus17 ? "201411" : "200410");
> -Builder.defineMacro("__cpp_decltype", "200707");
> -Builder.defineMacro("__cpp_attributes", "200809");
> -Builder.defineMacro("__cpp_rvalue_references", "200610");
> -Builder.defineMacro("__cpp_variadic_templates", "200704");
> -Builder.defineMacro("__cpp_initializer_lists", "200806");
> -Builder.defineMacro("__cpp_delegating_constructors", "200604");
> -Builder.defineMacro("__cpp_nsdmi", "200809");
> -Builder.defineMacro("__cpp_inheriting_constructors", "201511");
> -Builder.defineMacro("__cpp_ref_qualifiers", "200710");
> -Builder.defineMacro("__cpp_alias_templates", "200704");
> +LangOpts.CPlusPlus17 ? "201411L" : "200410");
> +Builder.defineMacro("__cpp_decltype", "200707L");
> +Builder.defineMacro("__cpp_attributes", "200809L");
> +Builder.defineMacro("__cpp_rvalue_references", "200610L");
> +Builder.defineMacro("__cpp_variadic_templates", "200704L");
> +Builder.defineMacro("__cpp_initializer_lists", "200806L");
> +Builder.defineMacro("__cpp_delegating_constructors", "200604L");
> +Builder.defineMacro("__cpp_nsdmi", "200809L");
> +Builder.defineMacro("__cpp_inheriting_constructors", "201511L");
> +Builder.defineMacro("__cpp_ref_qualifiers", "200710L");
> +Builder.defineMacro("__cpp_alias_templates", "200704L");
>}
>if (LangOpts.ThreadsafeStatics)
> -Builder.defineMacro("__cpp_threadsafe_static_init", "200806");
> +Builder.defineMacro("__cpp_threadsafe_static_init", "200806L");
>
>// C++14 features.
>if (LangOpts.CPlusPlus14) {
> -Builder.defineMacro("__cpp_binary_literals", "201304");
> -Builder.defineMacro("__cpp_digit_separators", "201309");
> -Builder.defineMacro("__cpp_init_captures", "201304");
> -Builder.defineMacro("__cpp_generic_lambdas", "201304");
> -Builder.defineMacro("__cpp_decltype_auto", "201304");
> -Builder.defineMacro("__cpp_return_type_deduction", "201304");
> -Builder.defineMacro("__cpp_aggregate_nsdmi", "201304");
> -Builder.defineMacro("__cpp_variable_templates", "201304");
> + 

[libcxxabi] r334924 - Fix libcxx tests after clang r334677.

2018-06-17 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Sun Jun 17 23:24:29 2018
New Revision: 334924

URL: http://llvm.org/viewvc/llvm-project?rev=334924&view=rev
Log:
Fix libcxx tests after clang r334677.

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=334924&r1=334923&r2=334924&view=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Sun Jun 17 23:24:29 2018
@@ -10,6 +10,7 @@ import os
 import sys
 
 from libcxx.test.config import Configuration as LibcxxConfiguration
+from libcxx.test.config import intMacroValue
 
 
 class Configuration(LibcxxConfiguration):
@@ -34,7 +35,7 @@ class Configuration(LibcxxConfiguration)
 super(Configuration, self).configure_obj_root()
 
 def has_cpp_feature(self, feature, required_value):
-return int(self.cxx.dumpMacros().get('__cpp_' + feature, 0)) >= 
required_value
+return intMacroValue(self.cxx.dumpMacros().get('__cpp_' + feature, 0)) 
>= required_value
 
 def configure_features(self):
 super(Configuration, self).configure_features()


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


Re: r334677 - P0096R5, P0941R2: Update to match latest feature test macro specification.

2018-06-17 Thread Vitaly Buka via cfe-commits
Thanks!
also r334924

On Sun, Jun 17, 2018 at 1:03 PM Richard Smith  wrote:

> Fixed in r334917.
>
> On 17 June 2018 at 02:51, Richard Smith  wrote:
>
>> Looks like a bug / faulty assumption in the libc++ test suite. Should be
>> easy to fix, but I'm not sure how pervasive the issue is. I'll take a look
>> in the morning. If this is blocking anything in the mean time, feel free to
>> revert this (or fix libc++ yourself).
>>
>>
>> On Sun, 17 Jun 2018, 01:40 Vitaly Buka via cfe-commits, <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Hi Richard,
>>> After this patch check-all fails for me with:
>>>   llvm-project/libcxx/utils/libcxx/test/config.py", line 467, in
>>> configure_features
>>> int(macros['__cpp_deduction_guides']) < 201611:
>>> ValueError: invalid literal for int() with base 10: '201703L'
>>>
>>> On Wed, Jun 13, 2018 at 5:44 PM Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
>>>> Author: rsmith
>>>> Date: Wed Jun 13 17:40:20 2018
>>>> New Revision: 334677
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=334677&view=rev
>>>> Log:
>>>> P0096R5, P0941R2: Update to match latest feature test macro
>>>> specification.
>>>>
>>>> Modified:
>>>> cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>>>> cfe/trunk/test/Lexer/cxx-features.cpp
>>>> cfe/trunk/www/cxx_status.html
>>>>
>>>> Modified: cfe/trunk/lib/Frontend/InitPreprocessor.cpp
>>>> URL:
>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitPreprocessor.cpp?rev=334677&r1=334676&r2=334677&view=diff
>>>>
>>>> ==
>>>> --- cfe/trunk/lib/Frontend/InitPreprocessor.cpp (original)
>>>> +++ cfe/trunk/lib/Frontend/InitPreprocessor.cpp Wed Jun 13 17:40:20 2018
>>>> @@ -487,82 +487,86 @@ static void InitializeCPlusPlusFeatureTe
>>>>   MacroBuilder
>>>> &Builder) {
>>>>// C++98 features.
>>>>if (LangOpts.RTTI)
>>>> -Builder.defineMacro("__cpp_rtti", "199711");
>>>> +Builder.defineMacro("__cpp_rtti", "199711L");
>>>>if (LangOpts.CXXExceptions)
>>>> -Builder.defineMacro("__cpp_exceptions", "199711");
>>>> +Builder.defineMacro("__cpp_exceptions", "199711L");
>>>>
>>>>// C++11 features.
>>>>if (LangOpts.CPlusPlus11) {
>>>> -Builder.defineMacro("__cpp_unicode_characters", "200704");
>>>> -Builder.defineMacro("__cpp_raw_strings", "200710");
>>>> -Builder.defineMacro("__cpp_unicode_literals", "200710");
>>>> -Builder.defineMacro("__cpp_user_defined_literals", "200809");
>>>> -Builder.defineMacro("__cpp_lambdas", "200907");
>>>> +Builder.defineMacro("__cpp_unicode_characters", "200704L");
>>>> +Builder.defineMacro("__cpp_raw_strings", "200710L");
>>>> +Builder.defineMacro("__cpp_unicode_literals", "200710L");
>>>> +Builder.defineMacro("__cpp_user_defined_literals", "200809L");
>>>> +Builder.defineMacro("__cpp_lambdas", "200907L");
>>>>  Builder.defineMacro("__cpp_constexpr",
>>>> -LangOpts.CPlusPlus17 ? "201603" :
>>>> -LangOpts.CPlusPlus14 ? "201304" : "200704");
>>>> +LangOpts.CPlusPlus17 ? "201603L" :
>>>> +LangOpts.CPlusPlus14 ? "201304L" : "200704");
>>>>  Builder.defineMacro("__cpp_range_based_for",
>>>> -LangOpts.CPlusPlus17 ? "201603" : "200907");
>>>> +LangOpts.CPlusPlus17 ? "201603L" : "200907");
>>>>  Builder.defineMacro("__cpp_static_assert",
>>>> -LangOpts.CPlusPlus17 ? "201411" : "200410");
>>>> -Builder.d

[libcxxabi] r334926 - Fix libcxxabi tests after clang r334924

2018-06-17 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Sun Jun 17 23:43:55 2018
New Revision: 334926

URL: http://llvm.org/viewvc/llvm-project?rev=334926&view=rev
Log:
Fix libcxxabi tests after clang r334924

Modified:
libcxxabi/trunk/test/libcxxabi/test/config.py

Modified: libcxxabi/trunk/test/libcxxabi/test/config.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/libcxxabi/test/config.py?rev=334926&r1=334925&r2=334926&view=diff
==
--- libcxxabi/trunk/test/libcxxabi/test/config.py (original)
+++ libcxxabi/trunk/test/libcxxabi/test/config.py Sun Jun 17 23:43:55 2018
@@ -35,7 +35,7 @@ class Configuration(LibcxxConfiguration)
 super(Configuration, self).configure_obj_root()
 
 def has_cpp_feature(self, feature, required_value):
-return intMacroValue(self.cxx.dumpMacros().get('__cpp_' + feature, 0)) 
>= required_value
+return intMacroValue(self.cxx.dumpMacros().get('__cpp_' + feature, 
'0')) >= required_value
 
 def configure_features(self):
 super(Configuration, self).configure_features()


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


r348327 - [asan] Add clang flag -fsanitize-address-use-odr-indicator

2018-12-04 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Dec  4 17:44:31 2018
New Revision: 348327

URL: http://llvm.org/viewvc/llvm-project?rev=348327&view=rev
Log:
[asan] Add clang flag -fsanitize-address-use-odr-indicator

Reviewers: eugenis, m.ostapenko, ygribov

Subscribers: hiraditya, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/asan-globals-odr.cpp
Modified:
cfe/trunk/docs/ClangCommandLineReference.rst
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Driver/SanitizerArgs.h
cfe/trunk/include/clang/Frontend/CodeGenOptions.def
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/docs/ClangCommandLineReference.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangCommandLineReference.rst?rev=348327&r1=348326&r2=348327&view=diff
==
--- cfe/trunk/docs/ClangCommandLineReference.rst (original)
+++ cfe/trunk/docs/ClangCommandLineReference.rst Tue Dec  4 17:44:31 2018
@@ -800,6 +800,10 @@ Level of field padding for AddressSaniti
 
 Enable linker dead stripping of globals in AddressSanitizer
 
+.. option:: -fsanitize-address-use-odr-indicator, 
-fno-sanitize-address-use-odr-indicator
+
+Enable ODR indicator globals to avoid false ODR violation reports in partially 
sanitized programs at the cost of an increase in binary size
+
 .. option:: -fsanitize-address-poison-custom-array-cookie, 
-fno-sanitize-address-poison-custom-array-cookie
 
 Enable "poisoning" array cookies when allocating arrays with a custom operator 
new\[\] in Address Sanitizer, preventing accesses to the cookies from user 
code. An array cookie is a small implementation-defined header added to certain 
array allocations to record metadata such as the length of the array. Accesses 
to array cookies from user code are technically allowed by the standard but are 
more likely to be the result of an out-of-bounds array access.

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=348327&r1=348326&r2=348327&view=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Tue Dec  4 17:44:31 2018
@@ -3089,6 +3089,8 @@ Execute ``clang-cl /?`` to see a list of
   Level of field padding for AddressSanitizer
   -fsanitize-address-globals-dead-stripping
   Enable linker dead stripping of globals in 
AddressSanitizer
+  -fsanitize-address-use-odr-indicator
+  Enable ODR indicator globals to avoid false ODR 
violation reports in partially sanitized programs at the cost of an increase in 
binary size
   -fsanitize-address-poison-custom-array-cookie
   Enable poisoning array cookies when using custom 
operator new[] in AddressSanitizer
   -fsanitize-address-use-after-scope

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=348327&r1=348326&r2=348327&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Dec  4 17:44:31 2018
@@ -984,6 +984,14 @@ def fno_sanitize_address_poison_custom_a
 def fsanitize_address_globals_dead_stripping : Flag<["-"], 
"fsanitize-address-globals-dead-stripping">,
 Group,
 HelpText<"Enable linker dead stripping 
of globals in AddressSanitizer">;
+def fsanitize_address_use_odr_indicator
+: Flag<["-"], "fsanitize-address-use-odr-indicator">,
+  Group,
+  HelpText<"Enable ODR indicator globals to avoid false ODR violation 
reports in partially sanitized programs at the cost of an increase in binary 
size">;
+def fno_sanitize_address_use_odr_indicator
+: Flag<["-"], "fno-sanitize-address-use-odr-indicator">,
+  Group,
+  HelpText<"Disable ODR indicator globals">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
Flags<[CoreOption, DriverOption]>,

Modified: cfe/trunk/include/clang/Driver/SanitizerArgs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/SanitizerArgs.h?rev=348327&r1=348326&r2=348327&view=diff
==
--- cfe/trunk/include/clang/Driver/SanitizerArgs.h (original)
+++ cfe/trunk/include/clang/Driver/SanitizerArgs.h Tue Dec  4 17:44:31 2018
@@ -38,6 +38,7 @@ class SanitizerArgs {
   bo

r355442 - [docs] Update the list of ThreadSanitizer supported OSes

2019-03-05 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Mar  5 12:53:34 2019
New Revision: 355442

URL: http://llvm.org/viewvc/llvm-project?rev=355442&view=rev
Log:
[docs] Update the list of ThreadSanitizer supported OSes

Modified:
cfe/trunk/docs/ThreadSanitizer.rst

Modified: cfe/trunk/docs/ThreadSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThreadSanitizer.rst?rev=355442&r1=355441&r2=355442&view=diff
==
--- cfe/trunk/docs/ThreadSanitizer.rst (original)
+++ cfe/trunk/docs/ThreadSanitizer.rst Tue Mar  5 12:53:34 2019
@@ -19,9 +19,11 @@ Supported Platforms
 
 ThreadSanitizer is supported on the following OS:
 
+* Android
+* Darwin
+* FreeBSD
 * Linux
 * NetBSD
-* FreeBSD
 
 Support for other 64-bit architectures is possible, contributions are welcome.
 Support for 32-bit platforms is problematic and is not planned.


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


r355445 - [docs] Add some architectures into the list of supported ThreadSanitizer platforms

2019-03-05 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Mar  5 13:10:42 2019
New Revision: 355445

URL: http://llvm.org/viewvc/llvm-project?rev=355445&view=rev
Log:
[docs] Add some architectures into the list of supported ThreadSanitizer 
platforms

Some platforms for which TSAN has build rules are omitted for the lack of
known build bots.

Modified:
cfe/trunk/docs/ThreadSanitizer.rst

Modified: cfe/trunk/docs/ThreadSanitizer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ThreadSanitizer.rst?rev=355445&r1=355444&r2=355445&view=diff
==
--- cfe/trunk/docs/ThreadSanitizer.rst (original)
+++ cfe/trunk/docs/ThreadSanitizer.rst Tue Mar  5 13:10:42 2019
@@ -19,10 +19,10 @@ Supported Platforms
 
 ThreadSanitizer is supported on the following OS:
 
-* Android
-* Darwin
+* Android aarch64, x86_64
+* Darwin arm64, x86_64
 * FreeBSD
-* Linux
+* Linux aarch64, x86_64, powerpc64, powerpc64le
 * NetBSD
 
 Support for other 64-bit architectures is possible, contributions are welcome.


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


Re: r357323 - [analyzer] Introduce a simplified API for adding custom path notes.

2019-03-29 Thread Vitaly Buka via cfe-commits
Bot detects memory leak probably after this patch

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/30957/steps/check-clang%20asan/logs/stdio



=
==22233==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1088 byte(s) in 17 object(s) allocated from:
#0 0xc770f8 in operator new(unsigned long)
/b/sanitizer-x86_64-linux-fast/build/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:106
#1 0x9c6feef in __libcpp_allocate
/b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/new:238:10
#2 0x9c6feef in allocate
/b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/memory:1813
#3 0x9c6feef in __value_func<(lambda at
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:236:9),
std::__1::allocator<(lambda at
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:236:9)>
> /b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/functional:1716
#4 0x9c6feef in function<(lambda at
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:236:9),
void> 
/b/sanitizer-x86_64-linux-fast/build/libcxx_build_asan/include/c++/v1/functional:2290
#5 0x9c6feef in
clang::ento::CheckerContext::getNoteTag(std::__1::function, std::__1::allocator >
(clang::ento::BugReport&)>&&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h:236
#6 0x9c6f061 in checkPostCall
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp:165:24
#7 0x9c6f061 in void
clang::ento::check::PostCall::_checkCall<(anonymous
namespace)::MIGChecker>(void*, clang::ento::CallEvent const&,
clang::ento::CheckerContext&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/Checker.h:183
#8 0x9fbd78c in operator()
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:69:12
#9 0x9fbd78c in runChecker
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:290
#10 0x9fbd78c in expandGraphWithCheckers<(anonymous
namespace)::CheckCallContext>
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:138
#11 0x9fbd78c in
clang::ento::CheckerManager::runCheckersForCallEvent(bool,
clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&,
clang::ento::CallEvent const&, clang::ento::ExprEngine&, bool)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CheckerManager.cpp:307
#12 0xa07d1ef in runCheckersForPostCall
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h:274:5
#13 0xa07d1ef in
clang::ento::ExprEngine::evalCall(clang::ento::ExplodedNodeSet&,
clang::ento::ExplodedNode*, clang::ento::CallEvent const&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:578
#14 0xa07c657 in
clang::ento::ExprEngine::VisitCallExpr(clang::CallExpr const*,
clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:495:5
#15 0xa01249f in clang::ento::ExprEngine::Visit(clang::Stmt
const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1539:7
#16 0xa003888 in clang::ento::ExprEngine::ProcessStmt(clang::Stmt
const*, clang::ento::ExplodedNode*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:743:5
#17 0xa002d48 in
clang::ento::ExprEngine::processCFGElement(clang::CFGElement,
clang::ento::ExplodedNode*, unsigned int,
clang::ento::NodeBuilderContext*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:590:7
#18 0x9fdcdfe in
clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*,
unsigned int, clang::ento::ExplodedNode*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:438:12
#19 0x9fdaa85 in
clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*,
clang::ProgramPoint, clang::ento::WorkListUnit const&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:192:7
#20 0x9fd9941 in
clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext
const*, unsigned int,
llvm::IntrusiveRefCntPtr)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:148:5
#21 0x987ae4f in ExecuteWorkList
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/

r359366 - [AArch64] Initialize HasMTE

2019-04-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Apr 26 19:40:01 2019
New Revision: 359366

URL: http://llvm.org/viewvc/llvm-project?rev=359366&view=rev
Log:
[AArch64] Initialize HasMTE

Modified:
cfe/trunk/lib/Basic/Targets/AArch64.cpp

Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=359366&r1=359365&r2=359366&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Fri Apr 26 19:40:01 2019
@@ -238,6 +238,7 @@ bool AArch64TargetInfo::handleTargetFeat
   HasFullFP16 = 0;
   HasDotProd = 0;
   HasFP16FML = 0;
+  HasMTE = 0;
   ArchKind = llvm::AArch64::ArchKind::ARMV8A;
 
   for (const auto &Feature : Features) {


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


Re: r342925 - P0962R1: only use the member form of 'begin' and 'end' in a range-based

2018-09-25 Thread Vitaly Buka via cfe-commits
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/24083

FAIL: Clang :: CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp (1692 of 13357)
 TEST 'Clang ::
CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp' FAILED

Script:
--
: 'RUN: at line 1';
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/clang -cc1
-internal-isystem
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/clang/8.0.0/include
-nostdsysteminc -std=c++11 -fsyntax-only -verify
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
: 'RUN: at line 2';
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/clang -cc1
-internal-isystem
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/clang/8.0.0/include
-nostdsysteminc -std=c++14 -fsyntax-only -verify
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
: 'RUN: at line 3';
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/clang -cc1
-internal-isystem
/b/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/lib/clang/8.0.0/include
-nostdsysteminc -std=c++17 -fsyntax-only -verify
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/test/CXX/stmt.stmt/stmt.iter/stmt.ranged/p1.cpp
--
Exit Code: 1

Command Output (stderr):
--
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/Lookup.h:185:19:
runtime error: load of value 32764, which is not a valid value for
type 'typename std::remove_reference::type' (aka
'clang::LookupResult::AmbiguityKind')
#0 0x49b97ec in
clang::LookupResult::LookupResult(clang::LookupResult&&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/Sema/Lookup.h:185:19
#1 0x49b8a2b in BuildNonArrayForRange(clang::Sema&, clang::Expr*,
clang::Expr*, clang::QualType, clang::VarDecl*, clang::VarDecl*,
clang::SourceLocation, clang::SourceLocation,
clang::OverloadCandidateSet*, clang::ActionResult*, clang::ActionResult*, (anonymous
namespace)::BeginEndFunction*)::$_3::operator()((anonymous
namespace)::BeginEndFunction, clang::LookupResult&,
llvm::function_ref,
llvm::function_ref) const
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2225:33
#2 0x49a5ed0 in BuildNonArrayForRange
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp
#3 0x49a5ed0 in
clang::Sema::BuildCXXForRangeStmt(clang::SourceLocation,
clang::SourceLocation, clang::SourceLocation, clang::Stmt*,
clang::Stmt*, clang::Stmt*, clang::Expr*, clang::Expr*, clang::Stmt*,
clang::SourceLocation, clang::Sema::BuildForRangeKind)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2497
#4 0x49a49df in clang::Sema::ActOnCXXForRangeStmt(clang::Scope*,
clang::SourceLocation, clang::SourceLocation, clang::Stmt*,
clang::SourceLocation, clang::Expr*, clang::SourceLocation,
clang::Sema::BuildForRangeKind)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaStmt.cpp:2122:10
#5 0x41a3301 in
clang::Parser::ParseForStatement(clang::SourceLocation*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1762:28
#6 0x419fe76 in
clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*,
clang::Parser::ParsedAttributesWithRange&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:251:12
#7 0x419f496 in
clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector&, clang::Parser::AllowedConstructsKind, clang::SourceLocation*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:110:20
#8 0x41a563b in clang::Parser::ParseCompoundStatementBody(bool)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:997:11
#9 0x41a61c8 in
clang::Parser::ParseFunctionStatementBody(clang::Decl*,
clang::Parser::ParseScope&)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseStmt.cpp:1971:21
#10 0x410fde8 in
clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&,
clang::Parser::ParsedTemplateInfo const&,
clang::Parser::LateParsedAttrList*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:1246:10
#11 0x412cc1c in
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&,
clang::DeclaratorContext, clang::SourceLocation*,
clang::Parser::ForRangeInit*)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:1968:11
#12 0x410e9ab in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:1015:10
#13 0x410e167 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/b/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cp

r343150 - Init LookupResult::AmbiguityKind

2018-09-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Sep 26 15:58:53 2018
New Revision: 343150

URL: http://llvm.org/viewvc/llvm-project?rev=343150&view=rev
Log:
Init LookupResult::AmbiguityKind

We don't expect useful value there unless it's "ambiguous".
However we use read it for copying and moving, so we need either init the field
add login to avoid reading invalid values. Such reads trigger ubsan errors.

Modified:
cfe/trunk/include/clang/Sema/Lookup.h

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=343150&r1=343149&r2=343150&view=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Wed Sep 26 15:58:53 2018
@@ -709,7 +709,9 @@ private:
 
   // Results.
   LookupResultKind ResultKind = NotFound;
-  AmbiguityKind Ambiguity; // ill-defined unless ambiguous
+  // ill-defined unless ambiguous. Still need to be initialized it will be
+  // copied/moved.
+  AmbiguityKind Ambiguity = {}; 
   UnresolvedSet<8> Decls;
   CXXBasePaths *Paths = nullptr;
   CXXRecordDecl *NamingClass = nullptr;


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


r343183 - Revert "[DebugInfo] Generate debug information for labels."

2018-09-27 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Sep 27 01:15:24 2018
New Revision: 343183

URL: http://llvm.org/viewvc/llvm-project?rev=343183&view=rev
Log:
Revert "[DebugInfo] Generate debug information for labels."

This reverts commit r343148.

It crashes on sanitizer-x86_64-linux-autoconf.

Removed:
cfe/trunk/test/CodeGen/debug-label-inline.c
cfe/trunk/test/CodeGen/debug-label.c
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGStmt.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=343183&r1=343182&r2=343183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Sep 27 01:15:24 2018
@@ -3767,32 +3767,6 @@ CGDebugInfo::EmitDeclareOfAutoVariable(c
   return EmitDeclare(VD, Storage, llvm::None, Builder);
 }
 
-void CGDebugInfo::EmitLabel(const LabelDecl *D, CGBuilderTy &Builder) {
-  assert(DebugKind >= codegenoptions::LimitedDebugInfo);
-  assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
-
-  if (D->hasAttr())
-return;
-
-  auto *Scope = cast(LexicalBlockStack.back());
-  llvm::DIFile *Unit = getOrCreateFile(D->getLocation());
-
-  // Get location information.
-  unsigned Line = getLineNumber(D->getLocation());
-  unsigned Column = getColumnNumber(D->getLocation());
-
-  StringRef Name = D->getName();
-
-  // Create the descriptor for the label.
-  auto *L =
-  DBuilder.createLabel(Scope, Name, Unit, Line, 
CGM.getLangOpts().Optimize);
-
-  // Insert an llvm.dbg.label into the current block.
-  DBuilder.insertLabel(L,
-   llvm::DebugLoc::get(Line, Column, Scope, CurInlinedAt),
-   Builder.GetInsertBlock());
-}
-
 llvm::DIType *CGDebugInfo::CreateSelfType(const QualType &QualTy,
   llvm::DIType *Ty) {
   llvm::DIType *CachedTy = getTypeOrNull(QualTy);

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=343183&r1=343182&r2=343183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Sep 27 01:15:24 2018
@@ -415,9 +415,6 @@ public:
llvm::Value *AI,
CGBuilderTy &Builder);
 
-  /// Emit call to \c llvm.dbg.label for an label.
-  void EmitLabel(const LabelDecl *D, CGBuilderTy &Builder);
-
   /// Emit call to \c llvm.dbg.declare for an imported variable
   /// declaration in a block.
   void EmitDeclareOfBlockDeclRefVariable(

Modified: cfe/trunk/lib/CodeGen/CGStmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmt.cpp?rev=343183&r1=343182&r2=343183&view=diff
==
--- cfe/trunk/lib/CodeGen/CGStmt.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGStmt.cpp Thu Sep 27 01:15:24 2018
@@ -531,16 +531,6 @@ void CodeGenFunction::EmitLabel(const La
   }
 
   EmitBlock(Dest.getBlock());
-
-  // Emit debug info for labels.
-  if (CGDebugInfo *DI = getDebugInfo()) {
-if (CGM.getCodeGenOpts().getDebugInfo() >=
-codegenoptions::LimitedDebugInfo) {
-  DI->setLocation(D->getLocation());
-  DI->EmitLabel(D, Builder);
-}
-  }
-
   incrementProfileCounter(D->getStmt());
 }
 

Removed: cfe/trunk/test/CodeGen/debug-label-inline.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-label-inline.c?rev=343182&view=auto
==
--- cfe/trunk/test/CodeGen/debug-label-inline.c (original)
+++ cfe/trunk/test/CodeGen/debug-label-inline.c (removed)
@@ -1,28 +0,0 @@
-// This test will test the correctness of generating DILabel and
-// llvm.dbg.label when the label is in inlined functions.
-//
-// RUN: %clang_cc1 -O2 %s -o - -emit-llvm -debug-info-kind=limited | FileCheck 
%s
-inline int f1(int a, int b) {
-  int sum;
-
-top:
-  sum = a + b;
-  return sum;
-}
-
-extern int ga, gb;
-
-int f2(void) {
-  int result;
-
-  result = f1(ga, gb);
-  // CHECK: call void @llvm.dbg.label(metadata [[LABEL_METADATA:!.*]]), !dbg 
[[LABEL_LOCATION:!.*]]
-
-  return result;
-}
-
-// CHECK: distinct !DISubprogram(name: "f1", {{.*}}, retainedNodes: 
[[ELEMENTS:!.*]])
-// CHECK: [[ELEMENTS]] = !{{{.*}}, [[LABEL_METADATA]]}
-// CHECK: [[LABEL_METADATA]] = !DILabel({{.*}}, name: "top", {{.*}}, line: 8)
-// CHECK: [[INLINEDAT:!.*]] = distinct !DILocation(line: 18,
-// CHECK: [[LABEL_LOCATION]] = !DILocation(line: 8, {{.*}}, inlinedAt: 
[[INLINEDAT]])

Removed: cfe/trunk/test/CodeGen/debug-label.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-label

r343369 - [cxx2a] Fix warning triggered by r343285

2018-09-28 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Sep 28 19:17:12 2018
New Revision: 343369

URL: http://llvm.org/viewvc/llvm-project?rev=343369&view=rev
Log:
[cxx2a] Fix warning triggered by r343285

Modified:
cfe/trunk/include/clang/AST/DeclBase.h

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=343369&r1=343368&r2=343369&view=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Sep 28 19:17:12 2018
@@ -1212,7 +1212,6 @@ public:
 value_type SingleElement;
 
   public:
-iterator() = default;
 explicit iterator(pointer Pos, value_type Single = nullptr)
 : IteratorBase(Pos), SingleElement(Single) {}
 


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


[clang-tools-extra] r343369 - [cxx2a] Fix warning triggered by r343285

2018-09-28 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Sep 28 19:17:12 2018
New Revision: 343369

URL: http://llvm.org/viewvc/llvm-project?rev=343369&view=rev
Log:
[cxx2a] Fix warning triggered by r343285

Modified:
clang-tools-extra/trunk/clang-doc/BitcodeWriter.h

Modified: clang-tools-extra/trunk/clang-doc/BitcodeWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-doc/BitcodeWriter.h?rev=343369&r1=343368&r2=343369&view=diff
==
--- clang-tools-extra/trunk/clang-doc/BitcodeWriter.h (original)
+++ clang-tools-extra/trunk/clang-doc/BitcodeWriter.h Fri Sep 28 19:17:12 2018
@@ -169,7 +169,6 @@ private:
   Stream.EnterSubblock(ID, BitCodeConstants::SubblockIDSize);
 }
 
-StreamSubBlockGuard() = default;
 StreamSubBlockGuard(const StreamSubBlockGuard &) = delete;
 StreamSubBlockGuard &operator=(const StreamSubBlockGuard &) = delete;
 


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


Re: r343285 - [cxx2a] P0641R2: (Some) type mismatches on defaulted functions only

2018-09-28 Thread Vitaly Buka via cfe-commits
https://reviews.llvm.org/rL343369

On Fri, Sep 28, 2018 at 4:51 PM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello Richard,
>
> This commit broke couple of our builders:
>
> http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/12924
> http://lab.llvm.org:8011/builders/clang-with-lto-ubuntu/builds/10475
> . . .
> FAILED:
> lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/DataFlowSanitizer.cpp.o
>
> /home/buildslave/ps4-buildslave1/clang-with-thin-lto-ubuntu/install/stage1/bin/clang++
> -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Ilib/Transforms/Instrumentation
> -I/home/buildslave/ps4-buildslave1/clang-with-thin-lto-ubuntu/llvm.src/lib/Transforms/Instrumentation
> -Iinclude
> -I/home/buildslave/ps4-buildslave1/clang-with-thin-lto-ubuntu/llvm.src/include
> -fPIC -fvisibility-inlines-hidden -Werror -Werror=date-time
> -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual
> -Wmissing-field-initializers -pedantic -Wno-long-long
> -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor
> -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color
> -ffunction-sections -fdata-sections -O3-UNDEBUG  -fno-exceptions
> -fno-rtti -MD -MT
> lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/DataFlowSanitizer.cpp.o
> -MF
> lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/DataFlowSanitizer.cpp.o.d
> -o
> lib/Transforms/Instrumentation/CMakeFiles/LLVMInstrumentation.dir/DataFlowSanitizer.cpp.o
> -c
> /home/buildslave/ps4-buildslave1/clang-with-thin-lto-ubuntu/llvm.src/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
> /home/buildslave/ps4-buildslave1/clang-with-thin-lto-ubuntu/llvm.src/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:231:24:
> error: explicitly defaulted move assignment operator is implicitly deleted
> [-Werror,-Wdefaulted-function-deleted]
>   TransformedFunction& operator=(TransformedFunction&&) = default;
>^
> /home/buildslave/ps4-buildslave1/clang-with-thin-lto-ubuntu/llvm.src/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:234:23:
> note: move assignment operator of 'TransformedFunction' is implicitly
> deleted because field 'OriginalType' is of const-qualified type
> 'llvm::FunctionType *const'
>   FunctionType* const OriginalType;
>   ^
> 1 error generated.
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Thu, Sep 27, 2018 at 6:18 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Thu Sep 27 18:16:43 2018
>> New Revision: 343285
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=343285&view=rev
>> Log:
>> [cxx2a] P0641R2: (Some) type mismatches on defaulted functions only
>> render the function deleted instead of rendering the program ill-formed.
>>
>> This change also adds an enabled-by-default warning for the case where
>> an explicitly-defaulted special member function of a non-template class
>> is implicitly deleted by the type checking rules. (This fires either due
>> to this language change or due to pre-C++20 reasons for the member being
>> implicitly deleted). I've tested this on a large codebase and found only
>> bugs (where the program means something that's clearly different from
>> what the programmer intended), so this is enabled by default, but we
>> should revisit this if there are problems with this being enabled by
>> default.
>>
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>> cfe/trunk/test/CXX/class.derived/class.abstract/p16.cpp
>> cfe/trunk/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.cpp
>> cfe/trunk/test/CXX/drs/dr6xx.cpp
>> cfe/trunk/test/CXX/special/class.copy/p12-0x.cpp
>> cfe/trunk/test/CXX/special/class.copy/p23-cxx11.cpp
>> cfe/trunk/test/CXX/special/class.ctor/p5-0x.cpp
>> cfe/trunk/test/CXX/special/class.dtor/p5-0x.cpp
>> cfe/trunk/test/SemaCUDA/implicit-member-target.cu
>> cfe/trunk/test/SemaCXX/cxx0x-deleted-default-ctor.cpp
>> cfe/trunk/test/SemaCXX/cxx17-compat.cpp
>> cfe/trunk/test/SemaCXX/dr1301.cpp
>> cfe/trunk/test/SemaCXX/microsoft-dtor-lookup-cxx11.cpp
>> cfe/trunk/test/SemaTemplate/exception-spec-crash.cpp
>> cfe/trunk/www/cxx_status.html
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=343285&r1=343284&r2=343285&view=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Sep 27
>> 18:16:43 2018
>> @@ -7760,9 +7760,19 @@ def err_incorrect_defaulted_exception_sp
>>  def err_incorrect_default

r312407 - Don't search libxml2 if using msan. LLVM already has similar check.

2017-09-01 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Sep  1 20:53:42 2017
New Revision: 312407

URL: http://llvm.org/viewvc/llvm-project?rev=312407&view=rev
Log:
Don't search libxml2 if using msan. LLVM already has similar check.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=312407&r1=312406&r2=312407&view=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Fri Sep  1 20:53:42 2017
@@ -181,10 +181,14 @@ endif()
 # we can include cmake files from this directory.
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
 
-set (LIBXML2_FOUND 0)
-find_package(LibXml2 2.5.3 QUIET)
-if (LIBXML2_FOUND)
-  set(CLANG_HAVE_LIBXML 1)
+# Don't look for libxml if we're using MSan, since uninstrumented third party
+# code may call MSan interceptors like strlen, leading to false positives.
+if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
+  set (LIBXML2_FOUND 0)
+  find_package(LibXml2 2.5.3 QUIET)
+  if (LIBXML2_FOUND)
+set(CLANG_HAVE_LIBXML 1)
+  endif()
 endif()
 
 include(CheckIncludeFile)


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


r313521 - Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]

2017-09-18 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Sep 18 01:26:01 2017
New Revision: 313521

URL: http://llvm.org/viewvc/llvm-project?rev=313521&view=rev
Log:
Another attempt to fix warning discovered by r313487. [-Wunused-lambda-capture]

Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=313521&r1=313520&r2=313521&view=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Mon Sep 18 01:26:01 2017
@@ -42,7 +42,7 @@ bool Preprocessor::isInPrimaryFile() con
  "Top level include stack isn't our primary lexer?");
   return std::none_of(
   IncludeMacroStack.begin() + 1, IncludeMacroStack.end(),
-  [this](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI); 
});
+  [&](const IncludeStackInfo &ISI) -> bool { return IsFileLexer(ISI); });
 }
 
 /// getCurrentLexer - Return the current file lexer being lexed from.  Note


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


Re: r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Vitaly Buka via cfe-commits
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8038/steps/check-clang%20ubsan/logs/stdio


--
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42:
runtime error: load of value 15, which is not a valid value for type
'clang::LVComputationKind'
#0 0x7084fd9 in
clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*,
clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42
#1 0x7085874 in
clang::LinkageComputer::getLVForClosure(clang::DeclContext const*,
clang::Decl*, clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1135:14
#2 0x708224e in
clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*,
clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
#3 0x7085242 in clang::NamedDecl::getLinkageInternal() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
#4 0x731c021 in computeCachedProperties(clang::Type const*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3379:22
#5 0x7311b2d in clang::TypePropertyCache<(anonymous
namespace)::Private>::ensure(clang::Type const*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3330:31
#6 0x7311bb2 in clang::TypePropertyCache<(anonymous
namespace)::Private>::ensure(clang::Type const*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3322:7
#7 0x7311a8f in clang::Type::getLinkage() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3438:3
#8 0x7081a61 in clang::LinkageComputer::getLVForType(clang::Type
const&, clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:194:26
#9 0x70831d3 in
clang::LinkageComputer::getLVForNamespaceScopeDecl(clang::NamedDecl
const*, clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:724:28
#10 0x708224e in
clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*,
clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
#11 0x7085242 in clang::NamedDecl::getLinkageInternal() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
#12 0x38d3ddd in clang::NamedDecl::isExternallyVisible() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/AST/Decl.h:339:39
#13 0x5a69da3 in
clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:11042:12
#14 0x5a693c9 in clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:10645:3
#15 0x555b6d1 in
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&,
clang::Parser::ForRangeInit*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2276:17
#16 0x5559ce1 in
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2013:21
#17 0x553611a in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:979:10
#18 0x55359a2 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:995:12
#19 0x5534fbf in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:845:12
#20 0x553431c in
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:613:12
#21 0x552f0e0 in clang::ParseAST(clang::Sema&, bool, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:147:18
#22 0x4045c32 in clang::FrontendAction::Execute()
/mnt/b/sanitizer-buildbot3/sanitiz

r313856 - Revert "Give external linkage and mangling to lambdas inside inline variables and variable templates."

2017-09-20 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Sep 20 19:51:56 2017
New Revision: 313856

URL: http://llvm.org/viewvc/llvm-project?rev=313856&view=rev
Log:
Revert "Give external linkage and mangling to lambdas inside inline variables 
and variable templates."

To fix: runtime error: load of value 15, which is not a valid value for type 
'clang::LVComputationKind'

This reverts commit r313827.

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Linkage.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CodeGenCXX/mangle-lambdas.cpp
cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=313856&r1=313855&r2=313856&view=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Sep 20 19:51:56 2017
@@ -676,10 +676,10 @@ LinkageComputer::getLVForNamespaceScopeD
 if (!LV.isVisibilityExplicit()) {
   // Use global type/value visibility as appropriate.
   Visibility globalVisibility;
-  if ((computation & ~IgnoreTypeLinkageBit) == LVForValue) {
+  if (computation == LVForValue) {
 globalVisibility = Context.getLangOpts().getValueVisibilityMode();
   } else {
-assert((computation & ~IgnoreTypeLinkageBit) == LVForType);
+assert(computation == LVForType);
 globalVisibility = Context.getLangOpts().getTypeVisibilityMode();
   }
   LV.mergeVisibility(globalVisibility, /*explicit*/ false);
@@ -719,8 +719,7 @@ LinkageComputer::getLVForNamespaceScopeD
 //
 // Note that we don't want to make the variable non-external
 // because of this, but unique-external linkage suits us.
-if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var) &&
-!(computation & IgnoreTypeLinkageBit)) {
+if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var)) {
   LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
   if (!isExternallyVisible(TypeLV.getLinkage()))
 return LinkageInfo::uniqueExternal();
@@ -760,8 +759,8 @@ LinkageComputer::getLVForNamespaceScopeD
 // unique-external linkage, it's not legally usable from outside
 // this translation unit.  However, we should use the C linkage
 // rules instead for extern "C" declarations.
-if (Context.getLangOpts().CPlusPlus && !Function->isInExternCContext() &&
-!(computation & IgnoreTypeLinkageBit)) {
+if (Context.getLangOpts().CPlusPlus &&
+!Function->isInExternCContext()) {
   // Only look at the type-as-written. If this function has an auto-deduced
   // return type, we can't compute the linkage of that type because it 
could
   // require looking at the linkage of this function, and we don't need 
this
@@ -1123,18 +1122,8 @@ LinkageInfo LinkageComputer::getLVForClo
   // calculation determines the lambda has external linkage, it should be
   // downgraded to VisibleNoLinkage.
   if (ContextDecl) {
-auto *VD = dyn_cast(ContextDecl);
 if (isa(ContextDecl))
   DC = ContextDecl->getDeclContext()->getRedeclContext();
-else if (VD && VD->getType()->getContainedDeducedType())
-  // If the declaration has a deduced type, we need to skip querying the
-  // linkage and visibility of that type, because it might involve this
-  // closure type. The only effect of this is that we might give a lambda
-  // VisibleNoLinkage rather than NoLinkage when we don't strictly need to,
-  // which is benign.
-  return computeLVForDecl(
-  cast(ContextDecl),
-  LVComputationKind(computation | IgnoreTypeLinkageBit));
 else
   return getLVForDecl(cast(ContextDecl), computation);
   }

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=313856&r1=313855&r2=313856&view=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Sep 20 19:51:56 2017
@@ -1691,16 +1691,10 @@ void CXXNameMangler::mangleLambda(const
   // to emit that last part of the prefix here.
   if (Decl *Context = Lambda->getLambdaContextDecl()) {
 if ((isa(Context) || isa(Context)) &&
-!isa(Context)) {
-  // FIXME: 'inline auto [a, b] = []{ return ... };' does not get a
-  // reasonable mangling here.
+Context->getDeclContext()->isRecord()) {
   if (const IdentifierInfo *Name
 = cast(Context)->getIdentifier()) {
 mangleSourceName(Name);
-const TemplateArgumentList *TemplateArgs = nullptr;
-if (const TemplateDecl 

Re: r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Vitaly Buka via cfe-commits
reverted by r313856

On Wed, Sep 20, 2017 at 6:30 PM, Richard Smith 
wrote:

> Thanks, I'll fix this tomorrow; if that's not soon enough, please go ahead
> and revert (or fix by adding a dummy enumerator in lib/AST/Linkage.h).
>
> On 20 Sep 2017 17:39, "Vitaly Buka via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8038/steps/check-clang%20ubsan/logs/stdio
>>
>>
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42:
>>  runtime error: load of value 15, which is not a valid value for type 
>> 'clang::LVComputationKind'
>> #0 0x7084fd9 in 
>> clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*, 
>> clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42
>> #1 0x7085874 in 
>> clang::LinkageComputer::getLVForClosure(clang::DeclContext const*, 
>> clang::Decl*, clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1135:14
>> #2 0x708224e in clang::LinkageComputer::getLVForDecl(clang::NamedDecl 
>> const*, clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
>> #3 0x7085242 in clang::NamedDecl::getLinkageInternal() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
>> #4 0x731c021 in computeCachedProperties(clang::Type const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3379:22
>> #5 0x7311b2d in clang::TypePropertyCache<(anonymous 
>> namespace)::Private>::ensure(clang::Type const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3330:31
>> #6 0x7311bb2 in clang::TypePropertyCache<(anonymous 
>> namespace)::Private>::ensure(clang::Type const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3322:7
>> #7 0x7311a8f in clang::Type::getLinkage() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3438:3
>> #8 0x7081a61 in clang::LinkageComputer::getLVForType(clang::Type const&, 
>> clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:194:26
>> #9 0x70831d3 in 
>> clang::LinkageComputer::getLVForNamespaceScopeDecl(clang::NamedDecl const*, 
>> clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:724:28
>> #10 0x708224e in clang::LinkageComputer::getLVForDecl(clang::NamedDecl 
>> const*, clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
>> #11 0x7085242 in clang::NamedDecl::getLinkageInternal() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
>> #12 0x38d3ddd in clang::NamedDecl::isExternallyVisible() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/AST/Decl.h:339:39
>> #13 0x5a69da3 in 
>> clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:11042:12
>> #14 0x5a693c9 in clang::Sema::AddInitializerToDecl(clang::Decl*, 
>> clang::Expr*, bool) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:10645:3
>> #15 0x555b6d1 in 
>> clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
>>  clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2276:17
>> #16 0x5559ce1 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, 
>> unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2013:21
>> #17 0x553611a in 
>> clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
>>  clang::ParsingDeclSpec&, clang::AccessSpecifier) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-

Re: r314037 - DR1113: anonymous namespaces formally give their contents internal linkage.

2017-09-22 Thread Vitaly Buka via cfe-commits
This breaks check-clang-tools
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/12310/steps/test/logs/stdio

On Fri, Sep 22, 2017 at 3:21 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Fri Sep 22 15:21:44 2017
> New Revision: 314037
>
> URL: http://llvm.org/viewvc/llvm-project?rev=314037&view=rev
> Log:
> DR1113: anonymous namespaces formally give their contents internal linkage.
>
> This doesn't affect our code generation in any material way -- we already
> give
> such declarations internal linkage from a codegen perspective -- but it has
> some subtle effects on code validity.
>
> We suppress the 'L' (internal linkage) marker for mangled names in
> anonymous
> namespaces, because it is redundant (the information is already carried by
> the
> namespace); this deviates from GCC's behavior if a variable or function in
> an
> anonymous namespace is redundantly declared 'static' (where GCC does
> include
> the 'L'), but GCC's behavior is incoherent because such a declaration can
> be
> validly declared with or without the 'static'.
>
> We still deviate from the standard in one regard here: extern "C"
> declarations
> in anonymous namespaces are still granted external linkage. Changing those
> does
> not appear to have been an intentional consequence of the standard change
> in
> DR1113.
>
> Added:
> cfe/trunk/test/CXX/drs/dr11xx.cpp
> Modified:
> cfe/trunk/lib/AST/Decl.cpp
> cfe/trunk/lib/AST/ItaniumMangle.cpp
> cfe/trunk/test/CXX/basic/basic.link/p8.cpp
> cfe/trunk/test/CodeGenCXX/anonymous-namespaces.cpp
> cfe/trunk/test/SemaCXX/linkage2.cpp
> cfe/trunk/test/SemaCXX/undefined-internal.cpp
>
> Modified: cfe/trunk/lib/AST/Decl.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> Decl.cpp?rev=314037&r1=314036&r2=314037&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/Decl.cpp (original)
> +++ cfe/trunk/lib/AST/Decl.cpp Fri Sep 22 15:21:44 2017
> @@ -619,16 +619,16 @@ LinkageComputer::getLVForNamespaceScopeD
>if (D->isInAnonymousNamespace()) {
>  const auto *Var = dyn_cast(D);
>  const auto *Func = dyn_cast(D);
> -// FIXME: In C++11 onwards, anonymous namespaces should give decls
> -// within them (including those inside extern "C" contexts) internal
> -// linkage, not unique external linkage:
> +// FIXME: The check for extern "C" here is not justified by the
> standard
> +// wording, but we retain it from the pre-DR1113 model to avoid
> breaking
> +// code.
>  //
>  // C++11 [basic.link]p4:
>  //   An unnamed namespace or a namespace declared directly or
> indirectly
>  //   within an unnamed namespace has internal linkage.
>  if ((!Var || !isFirstInExternCContext(Var)) &&
>  (!Func || !isFirstInExternCContext(Func)))
> -  return LinkageInfo::uniqueExternal();
> +  return getInternalLinkageFor(D);
>}
>
>// Set up the defaults.
> @@ -1130,7 +1130,7 @@ LinkageInfo LinkageComputer::getLVForLoc
>if (const auto *Function = dyn_cast(D)) {
>  if (Function->isInAnonymousNamespace() &&
>  !Function->isInExternCContext())
> -  return LinkageInfo::uniqueExternal();
> +  return getInternalLinkageFor(Function);
>
>  // This is a "void f();" which got merged with a file static.
>  if (Function->getCanonicalDecl()->getStorageClass() == SC_Static)
> @@ -1153,7 +1153,7 @@ LinkageInfo LinkageComputer::getLVForLoc
>if (const auto *Var = dyn_cast(D)) {
>  if (Var->hasExternalStorage()) {
>if (Var->isInAnonymousNamespace() && !Var->isInExternCContext())
> -return LinkageInfo::uniqueExternal();
> +return getInternalLinkageFor(Var);
>
>LinkageInfo LV;
>if (Var->getStorageClass() == SC_PrivateExtern)
>
> Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/
> ItaniumMangle.cpp?rev=314037&r1=314036&r2=314037&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
> +++ cfe/trunk/lib/AST/ItaniumMangle.cpp Fri Sep 22 15:21:44 2017
> @@ -1287,9 +1287,15 @@ void CXXNameMangler::mangleUnqualifiedNa
>//
>//   void test() { extern void foo(); }
>//   static void foo();
> +  //
> +  // Don't bother with the L marker for names in anonymous
> namespaces; the
> +  // 12_GLOBAL__N_1 mangling is quite sufficient there, and this
> better
> +  // matches GCC anyway, because GCC does not treat anonymous
> namespaces as
> +  // implying internal linkage.
>if (ND && ND->getFormalLinkage() == InternalLinkage &&
>!ND->isExternallyVisible() &&
> -  getEffectiveDeclContext(ND)->isFileContext())
> +  getEffectiveDeclContext(ND)->isFileContext() &&
> +  !ND->isInAnonymousNam

Re: [PATCH] D61879: WIP: Prototype of DSE optimizations for -ftrivial-auto-var-init

2019-06-20 Thread Vitaly Buka via cfe-commits
Not much, but it's not abandoned.
I was interrupted by other stuff.
Also I am concerned by the fact that zero initialization without any new
optimization is cheaper than pattern even with patches in progress.

On Thu, Jun 20, 2019 at 9:05 AM JF Bastien via Phabricator <
revi...@reviews.llvm.org> wrote:

> jfb added a comment.
>
> Hello! I'm still interested in this, have you been able to make any
> progress?
>
>
> Repository:
>   rG LLVM Github Monorepo
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D61879/new/
>
> https://reviews.llvm.org/D61879
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365822 - CodeGen, NFC: Test for auto-init for 32bit pointers

2019-07-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Jul 11 13:51:59 2019
New Revision: 365822

URL: http://llvm.org/viewvc/llvm-project?rev=365822&view=rev
Log:
CodeGen, NFC: Test for auto-init for 32bit pointers

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

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365822&r1=365821&r2=365822&view=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Thu Jul 11 13:51:59 2019
@@ -5,6 +5,7 @@
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O0,ZERO,ZERO-O0
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fno-experimental-new-pass-manager 
-emit-llvm -o - | FileCheck %s 
-check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-LEGACY
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown -fblocks 
-ftrivial-auto-var-init=zero %s -O1 -fexperimental-new-pass-manager -emit-llvm 
-o - | FileCheck %s -check-prefixes=CHECK-O1,ZERO,ZERO-O1,ZERO-O1-NEWPM
+// RUN: %clang_cc1 -std=c++14 -triple i386-unknown-unknown -fblocks 
-ftrivial-auto-var-init=pattern %s -emit-llvm -o - | FileCheck %s 
-check-prefixes=PATTERN-I386
 
 template void used(T &) noexcept;
 
@@ -64,6 +65,9 @@ struct smallpartinit { char c = 42, d; }
 // PATTERN-O1-NOT: @__const.test_nullinit_uninit.uninit
 // PATTERN-O1-NOT: @__const.test_nullinit_braces.braces
 // PATTERN-O1-NOT: @__const.test_nullinit_custom.custom
+// PATTERN-I386: @__const.test_nullinit_uninit.uninit = private unnamed_addr 
constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_braces.braces = private unnamed_addr 
constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
+// PATTERN-I386: @__const.test_nullinit_custom.custom = private unnamed_addr 
constant %struct.nullinit { i8* inttoptr (i32 170 to i8*) }, align 4
 struct nullinit { char* null = nullptr; };
 // PATTERN-O0: @__const.test_padded_uninit.uninit = private unnamed_addr 
constant { i8, [3 x i8], i32 } { i8 -86, [3 x i8] c"\AA\AA\AA", i32 -1431655766 
}, align 4
 // PATTERN-O0: @__const.test_padded_custom.custom = private unnamed_addr 
constant { i8, [3 x i8], i32 } { i8 42, [3 x i8] zeroinitializer, i32 13371337 
}, align 4
@@ -139,6 +143,7 @@ struct arraytail { int i; int arr[]; };
 // PATTERN-O1-NOT: @__const.test_tailpad4_uninit.uninit
 // PATTERN: @__const.test_tailpad4_custom.custom = private unnamed_addr 
constant [4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 257, i8 1, [1 
x i8] zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }], align 16
 // ZERO: @__const.test_tailpad4_custom.custom = private unnamed_addr constant 
[4 x { i16, i8, [1 x i8] }] [{ i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }, { i16, i8, [1 x i8] } { i16 257, i8 1, [1 x i8] 
zeroinitializer }], align 16
+// PATTERN-I386: @__const.test_intptr4_custom.custom = private unnamed_addr 
constant [4 x i32*] [i32* inttoptr (i32 572662306 to i32*), i32* inttoptr (i32 
572662306 to i32*), i32* inttoptr (i32 572662306 to i32*), i32* inttoptr (i32 
572662306 to i32*)], align 4
 struct tailpad { short s; char c; };
 // PATTERN-O0: @__const.test_atomicnotlockfree_uninit.uninit = private 
unnamed_addr constant %struct.notlockfree { [4 x i64] [i64 
-6148914691236517206, i64 -6148914691236517206, i64 -6148914691236517206, i64 
-6148914691236517206] }, align 8
 // PATTERN-O1-NOT: @__const.test_atomicnotlockfree_uninit.uninit
@@ -176,16 +181,19 @@ struct semivolatileinit { int i = 0x
 // PATTERN-O1-NOT: @__const.test_base_uninit.uninit
 // PATTERN-O0: @__const.test_base_braces.braces = private unnamed_addr 
constant %struct.base { i32 (...)** inttoptr (i64 -6148914691236517206 to i32 
(...)**) }, align 8
 // PATTERN-O1-NOT: @__const.test_base_braces.braces
+// PATTERN-I386: @__const.test_base_uninit.uninit = private unnamed_addr 
constant %struct.base { i32 (...)** inttoptr (i32 170 to i32 (...)**) }, align 4
 struct base { virtual ~base(); };
 // PATTERN-O0: @__const.test_derived_uninit.uninit = private unnamed_addr 
constant %struct.derived { %struct.base { i32 (...)** inttoptr (i64 
-6148914691236517206 to i32 (...)**) } }, align 8
 // PATTERN-O1-NOT: @__const.test_derived_uninit.uninit
 // PATTERN-O0: @__const.test_derived_braces.braces = private unnamed_addr 
constant %struct.derived { %struct.base { i32 (...)** inttoptr (i64 
-614891469123

r365835 - CodeGen: Suppress c++ warnings in test

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

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

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

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


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


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

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

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

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

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

r365858 - Handle IntToPtr in isBytewiseValue

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

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

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

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

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

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

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

Reviewers: pcc, eugenis

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

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

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


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


r365921 - CodeGet: Init 32bit pointers with 0xFFFFFFFF

2019-07-12 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Jul 12 10:21:55 2019
New Revision: 365921

URL: http://llvm.org/viewvc/llvm-project?rev=365921&view=rev
Log:
CodeGet: Init 32bit pointers with 0x

Summary:
Patch makes D63967 effective for 32bit platforms and improves pattern
initialization there. It cuts size of 32bit binary compiled with
-ftrivial-auto-var-init=pattern by 2% (3% with -Os).

Binary size change on CTMark, (with -fuse-ld=lld -Wl,--icf=all, similar results 
with default linker options)
```
   master   patch  diff
Os pattern   7.915580e+057.698424e+05 -0.028387
O3 pattern   9.953688e+059.752952e+05 -0.019325
```

Zero vs Pattern on master
```
   zero   pattern  diff
Os 7.689712e+05  7.915580e+05  0.031380
O3 9.744796e+05  9.953688e+05  0.021133
```

Zero vs Pattern with the patch
```
   zero   pattern  diff
Os 7.689712e+05  7.698424e+05  0.000789
O3 9.744796e+05  9.752952e+05  0.000742
```

Reviewers: pcc, eugenis, glider, jfb

Reviewed By: jfb

Subscribers: hubert.reinterpretcast, dexonsmith, cfe-commits

Tags: #clang

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

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

Modified: cfe/trunk/lib/CodeGen/PatternInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/PatternInit.cpp?rev=365921&r1=365920&r2=365921&view=diff
==
--- cfe/trunk/lib/CodeGen/PatternInit.cpp (original)
+++ cfe/trunk/lib/CodeGen/PatternInit.cpp Fri Jul 12 10:21:55 2019
@@ -17,12 +17,13 @@ llvm::Constant *clang::CodeGen::initiali
   // repeated byte-pattern which makes it easier to synthesize. We use it for
   // pointers as well as integers so that aggregates are likely to be
   // initialized with this repeated value.
-  constexpr uint64_t LargeValue = 0xull;
   // For 32-bit platforms it's a bit trickier because, across systems, only the
-  // zero page can reasonably be expected to be unmapped, and even then we need
-  // a very low address. We use a smaller value, and that value sadly doesn't
-  // have a repeated byte-pattern. We don't use it for integers.
-  constexpr uint32_t SmallValue = 0x00AA;
+  // zero page can reasonably be expected to be unmapped. We use max 0x
+  // assuming that memory access will overlap into zero page.
+  const uint64_t IntValue =
+  CGM.getContext().getTargetInfo().getMaxPointerWidth() < 64
+  ? 0xull
+  : 0xull;
   // Floating-point values are initialized as NaNs because they propagate. 
Using
   // a repeated byte pattern means that it will be easier to initialize
   // all-floating-point aggregates and arrays with memset. Further, aggregates
@@ -36,27 +37,18 @@ llvm::Constant *clang::CodeGen::initiali
 Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
 ->getBitWidth();
 if (BitWidth <= 64)
-  return llvm::ConstantInt::get(Ty, LargeValue);
+  return llvm::ConstantInt::get(Ty, IntValue);
 return llvm::ConstantInt::get(
-Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, LargeValue)));
+Ty, llvm::APInt::getSplat(BitWidth, llvm::APInt(64, IntValue)));
   }
   if (Ty->isPtrOrPtrVectorTy()) {
 auto *PtrTy = cast(
 Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
 unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
 PtrTy->getAddressSpace());
-llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
-uint64_t IntValue;
-switch (PtrWidth) {
-default:
+if (PtrWidth > 64)
   llvm_unreachable("pattern initialization of unsupported pointer width");
-case 64:
-  IntValue = LargeValue;
-  break;
-case 32:
-  IntValue = SmallValue;
-  break;
-}
+llvm::Type *IntTy = llvm::IntegerType::get(CGM.getLLVMContext(), PtrWidth);
 auto *Int = llvm::ConstantInt::get(IntTy, IntValue);
 return llvm::ConstantExpr::getIntToPtr(Int, PtrTy);
   }

Modified: cfe/trunk/test/CodeGenCXX/auto-var-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/auto-var-init.cpp?rev=365921&r1=365920&r2=365921&view=diff
==
--- cfe/trunk/test/CodeGenCXX/auto-var-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/auto-var-init.cpp Fri Jul 12 10:21:55 2019
@@ -12,7 +12,7 @@
 #ifdef __x86_64__
 char inits[] = 
{"-86/-21846/-1431655766/i64/-6148914691236517206/-6148914691236517206/i128/-113427455640312821154458202477256070486/i64/-6148914691236517206/AA/"};
 #else
-char inits[] = 
{"-86/-21846/-1431655766/i32/-1431655766/-6148914691236517206/i32/-1431655766/i32/170/AA/"};
+char inits[] = {"-1/-1/-1/i32/-1/-1/i32/-1/i32/-1/FF/"};
 #define __int128 int;
 #endif
 // PATTERN: @in

r364492 - [NFC] Remove unneeded local variables

2019-06-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Jun 26 18:34:21 2019
New Revision: 364492

URL: http://llvm.org/viewvc/llvm-project?rev=364492&view=rev
Log:
[NFC] Remove unneeded local variables

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

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=364492&r1=364491&r2=364492&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jun 26 18:34:21 2019
@@ -1152,18 +1152,15 @@ static void emitStoresForConstant(CodeGe
 return;
   }
 
-  auto *Int8Ty = llvm::IntegerType::getInt8Ty(CGM.getLLVMContext());
-  auto *IntPtrTy = CGM.getDataLayout().getIntPtrType(CGM.getLLVMContext());
-
   uint64_t ConstantSize = CGM.getDataLayout().getTypeAllocSize(Ty);
   if (!ConstantSize)
 return;
-  auto *SizeVal = llvm::ConstantInt::get(IntPtrTy, ConstantSize);
+  auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize);
 
   // If the initializer is all or mostly the same, codegen with bzero / memset
   // then do a few stores afterward.
   if (shouldUseBZeroPlusStoresToInitialize(constant, ConstantSize)) {
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, 0), SizeVal,
+Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, 0), SizeVal,
  isVolatile);
 
 bool valueAlreadyCorrect =
@@ -1184,7 +1181,7 @@ static void emitStoresForConstant(CodeGe
   assert(AP.getBitWidth() <= 8);
   Value = AP.getLimitedValue();
 }
-Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, Value), SizeVal,
+Builder.CreateMemSet(Loc, llvm::ConstantInt::get(CGM.Int8Ty, Value), 
SizeVal,
  isVolatile);
 return;
   }
@@ -1672,8 +1669,6 @@ void CodeGenFunction::EmitAutoVarInit(co
   auto DL = ApplyDebugLocation::CreateDefaultArtificial(*this, 
D.getLocation());
   QualType type = D.getType();
 
-  bool isVolatile = type.isVolatileQualified();
-
   // If this local has an initializer, emit it now.
   const Expr *Init = D.getInit();
 
@@ -1728,6 +1723,7 @@ void CodeGenFunction::EmitAutoVarInit(co
 if (emission.IsEscapingByRef && !locIsByrefHeader)
   Loc = emitBlockByrefAddress(Loc, &D, /*follow=*/false);
 
+bool isVolatile = type.isVolatileQualified();
 CharUnits Size = getContext().getTypeSizeInChars(type);
 if (!Size.isZero()) {
   switch (trivialAutoVarInit) {
@@ -1849,7 +1845,7 @@ void CodeGenFunction::EmitAutoVarInit(co
   llvm::Type *BP = CGM.Int8Ty->getPointerTo(Loc.getAddressSpace());
   emitStoresForConstant(
   CGM, D, (Loc.getType() == BP) ? Loc : Builder.CreateBitCast(Loc, BP),
-  isVolatile, Builder, constant);
+  type.isVolatileQualified(), Builder, constant);
 }
 
 /// Emit an expression as an initializer for an object (variable, field, etc.)


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


r364495 - [NFC] Return early for types with size zero

2019-06-26 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Jun 26 19:08:15 2019
New Revision: 364495

URL: http://llvm.org/viewvc/llvm-project?rev=364495&view=rev
Log:
[NFC] Return early for types with size zero

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

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=364495&r1=364494&r2=364495&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jun 26 19:08:15 2019
@@ -1145,6 +1145,10 @@ static void emitStoresForConstant(CodeGe
   CGBuilderTy &Builder,
   llvm::Constant *constant) {
   auto *Ty = constant->getType();
+  uint64_t ConstantSize = CGM.getDataLayout().getTypeAllocSize(Ty);
+  if (!ConstantSize)
+return;
+
   bool canDoSingleStore = Ty->isIntOrIntVectorTy() ||
   Ty->isPtrOrPtrVectorTy() || Ty->isFPOrFPVectorTy();
   if (canDoSingleStore) {
@@ -1152,9 +1156,6 @@ static void emitStoresForConstant(CodeGe
 return;
   }
 
-  uint64_t ConstantSize = CGM.getDataLayout().getTypeAllocSize(Ty);
-  if (!ConstantSize)
-return;
   auto *SizeVal = llvm::ConstantInt::get(CGM.IntPtrTy, ConstantSize);
 
   // If the initializer is all or mostly the same, codegen with bzero / memset


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


r365706 - GodeGen, NFC: Add test to track emitStoresForConstant behavior

2019-07-10 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Jul 10 15:47:07 2019
New Revision: 365706

URL: http://llvm.org/viewvc/llvm-project?rev=365706&view=rev
Log:
GodeGen, NFC: Add test to track emitStoresForConstant behavior

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: cfe-commits

Tags: #clang

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

Added:
cfe/trunk/test/CodeGen/init-memset.c

Added: cfe/trunk/test/CodeGen/init-memset.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/init-memset.c?rev=365706&view=auto
==
--- cfe/trunk/test/CodeGen/init-memset.c (added)
+++ cfe/trunk/test/CodeGen/init-memset.c Wed Jul 10 15:47:07 2019
@@ -0,0 +1,66 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -O0 -emit-llvm -o - %s | 
FileCheck %s
+
+void use(void *);
+
+void test_small() {
+  // CHECK-LABEL: define void @test_small()
+  int a[] = {1, 2, 3, 4};
+  // CHECK: call void @llvm.memcpy.{{.*}}
+  use(a);
+}
+
+void test_small_same() {
+  // CHECK-LABEL: define void @test_small_same()
+  char a[] = {'a', 'a', 'a', 'a'};
+  // CHECK: call void @llvm.memcpy.{{.*}}
+  use(a);
+}
+
+void test_different() {
+  // CHECK-LABEL: define void @test_different()
+  int a[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
+  // CHECK: call void @llvm.memcpy.{{.*}}
+  use(a);
+}
+
+void test_all_zeros() {
+  // CHECK-LABEL: define void @test_all_zeros()
+  int a[16] = {};
+  // CHECK: call void @llvm.memset.{{.*}}
+  use(a);
+}
+
+void test_all_a() {
+  // CHECK-LABEL: define void @test_all_a()
+  char a[] = "aa";
+  // CHECK: call void @llvm.memcpy.{{.*}}
+  use(a);
+}
+
+void test_most_zeros() {
+  // CHECK-LABEL: define void @test_most_zeros()
+  int a[16] = {0, 0, 1};
+  // CHECK: call void @llvm.memset.{{.*}}
+  // CHECK: store i32 1
+  use(a);
+}
+
+void test_most_a() {
+  // CHECK-LABEL: define void @test_most_a()
+  char a[] = "az";
+  // CHECK: call void @llvm.memcpy.{{.*}}
+  use(a);
+}
+
+void test_pointers() {
+  // CHECK-LABEL: define void @test_pointers()
+  void *a[] = {&use, &use, &use, &use, &use, &use};
+  // CHECK: call void @llvm.memset.{{.*}}
+  // CHECK: store i8*
+  // CHECK: store i8*
+  // CHECK: store i8*
+  // CHECK: store i8*
+  // CHECK: store i8*
+  // CHECK: store i8*
+  use(a);
+}


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


r365708 - NFC: Convert large lambda into method

2019-07-10 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Jul 10 15:53:50 2019
New Revision: 365708

URL: http://llvm.org/viewvc/llvm-project?rev=365708&view=rev
Log:
NFC: Convert large lambda into method

Reviewers: pcc, eugenis

Reviewed By: eugenis

Subscribers: cfe-commits, lldb-commits

Tags: #clang, #lldb

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

Modified:
cfe/trunk/lib/CodeGen/CGDecl.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=365708&r1=365707&r2=365708&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jul 10 15:53:50 2019
@@ -1663,6 +1663,87 @@ bool CodeGenFunction::isTrivialInitializ
   return false;
 }
 
+void CodeGenFunction::emitZeroOrPatternForAutoVarInit(QualType type,
+  const VarDecl &D,
+  Address Loc) {
+  auto trivialAutoVarInit = getContext().getLangOpts().getTrivialAutoVarInit();
+  CharUnits Size = getContext().getTypeSizeInChars(type);
+  bool isVolatile = type.isVolatileQualified();
+  if (!Size.isZero()) {
+switch (trivialAutoVarInit) {
+case LangOptions::TrivialAutoVarInitKind::Uninitialized:
+  llvm_unreachable("Uninitialized handled by caller");
+case LangOptions::TrivialAutoVarInitKind::Zero:
+  emitStoresForZeroInit(CGM, D, Loc, isVolatile, Builder);
+  break;
+case LangOptions::TrivialAutoVarInitKind::Pattern:
+  emitStoresForPatternInit(CGM, D, Loc, isVolatile, Builder);
+  break;
+}
+return;
+  }
+
+  // VLAs look zero-sized to getTypeInfo. We can't emit constant stores to
+  // them, so emit a memcpy with the VLA size to initialize each element.
+  // Technically zero-sized or negative-sized VLAs are undefined, and UBSan
+  // will catch that code, but there exists code which generates zero-sized
+  // VLAs. Be nice and initialize whatever they requested.
+  const auto *VlaType = getContext().getAsVariableArrayType(type);
+  if (!VlaType)
+return;
+  auto VlaSize = getVLASize(VlaType);
+  auto SizeVal = VlaSize.NumElts;
+  CharUnits EltSize = getContext().getTypeSizeInChars(VlaSize.Type);
+  switch (trivialAutoVarInit) {
+  case LangOptions::TrivialAutoVarInitKind::Uninitialized:
+llvm_unreachable("Uninitialized handled by caller");
+
+  case LangOptions::TrivialAutoVarInitKind::Zero:
+if (!EltSize.isOne())
+  SizeVal = Builder.CreateNUWMul(SizeVal, CGM.getSize(EltSize));
+Builder.CreateMemSet(Loc, llvm::ConstantInt::get(Int8Ty, 0), SizeVal,
+ isVolatile);
+break;
+
+  case LangOptions::TrivialAutoVarInitKind::Pattern: {
+llvm::Type *ElTy = Loc.getElementType();
+llvm::Constant *Constant = constWithPadding(
+CGM, IsPattern::Yes, initializationPatternFor(CGM, ElTy));
+CharUnits ConstantAlign = getContext().getTypeAlignInChars(VlaSize.Type);
+llvm::BasicBlock *SetupBB = createBasicBlock("vla-setup.loop");
+llvm::BasicBlock *LoopBB = createBasicBlock("vla-init.loop");
+llvm::BasicBlock *ContBB = createBasicBlock("vla-init.cont");
+llvm::Value *IsZeroSizedVLA = Builder.CreateICmpEQ(
+SizeVal, llvm::ConstantInt::get(SizeVal->getType(), 0),
+"vla.iszerosized");
+Builder.CreateCondBr(IsZeroSizedVLA, ContBB, SetupBB);
+EmitBlock(SetupBB);
+if (!EltSize.isOne())
+  SizeVal = Builder.CreateNUWMul(SizeVal, CGM.getSize(EltSize));
+llvm::Value *BaseSizeInChars =
+llvm::ConstantInt::get(IntPtrTy, EltSize.getQuantity());
+Address Begin = Builder.CreateElementBitCast(Loc, Int8Ty, "vla.begin");
+llvm::Value *End =
+Builder.CreateInBoundsGEP(Begin.getPointer(), SizeVal, "vla.end");
+llvm::BasicBlock *OriginBB = Builder.GetInsertBlock();
+EmitBlock(LoopBB);
+llvm::PHINode *Cur = Builder.CreatePHI(Begin.getType(), 2, "vla.cur");
+Cur->addIncoming(Begin.getPointer(), OriginBB);
+CharUnits CurAlign = Loc.getAlignment().alignmentOfArrayElement(EltSize);
+Builder.CreateMemCpy(Address(Cur, CurAlign),
+ createUnnamedGlobalForMemcpyFrom(
+ CGM, D, Builder, Constant, ConstantAlign),
+ BaseSizeInChars, isVolatile);
+llvm::Value *Next =
+Builder.CreateInBoundsGEP(Int8Ty, Cur, BaseSizeInChars, "vla.next");
+llvm::Value *Done = Builder.CreateICmpEQ(Next, End, "vla-init.isdone");
+Builder.CreateCondBr(Done, ContBB, LoopBB);
+Cur->addIncoming(Next, LoopBB);
+EmitBlock(ContBB);
+  } break;
+  }
+}
+
 void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) {
   assert(emission.Variable && "emission was not valid!");
 
@@ -1727,87 +1808,11 @@ void CodeGenFunction::EmitAutoVarInit(co
 if (emission.IsEscapingByRef && !locIsByrefHeader)

r365709 - NFC: Pass DataLayout into isBytewiseValue

2019-07-10 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Jul 10 15:53:52 2019
New Revision: 365709

URL: http://llvm.org/viewvc/llvm-project?rev=365709&view=rev
Log:
NFC: Pass DataLayout into isBytewiseValue

Summary:
We will need to handle IntToPtr which I will submit in a separate patch as it's
not going to be NFC.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

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

Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=365709&r1=365708&r2=365709&view=diff
==
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Wed Jul 10 15:53:52 2019
@@ -967,11 +967,12 @@ static bool shouldUseBZeroPlusStoresToIn
 /// FIXME We could be more clever, as we are for bzero above, and generate
 ///   memset followed by stores. It's unclear that's worth the effort.
 static llvm::Value *shouldUseMemSetToInitialize(llvm::Constant *Init,
-uint64_t GlobalSize) {
+uint64_t GlobalSize,
+const llvm::DataLayout &DL) {
   uint64_t SizeLimit = 32;
   if (GlobalSize <= SizeLimit)
 return nullptr;
-  return llvm::isBytewiseValue(Init);
+  return llvm::isBytewiseValue(Init, DL);
 }
 
 /// Decide whether we want to split a constant structure or array store into a
@@ -1177,7 +1178,8 @@ static void emitStoresForConstant(CodeGe
   }
 
   // If the initializer is a repeated byte pattern, use memset.
-  llvm::Value *Pattern = shouldUseMemSetToInitialize(constant, ConstantSize);
+  llvm::Value *Pattern =
+  shouldUseMemSetToInitialize(constant, ConstantSize, CGM.getDataLayout());
   if (Pattern) {
 uint64_t Value = 0x00;
 if (!isa(Pattern)) {


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


r349015 - [asan] Don't check ODR violations for particular types of globals

2018-12-13 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Dec 13 01:47:39 2018
New Revision: 349015

URL: http://llvm.org/viewvc/llvm-project?rev=349015&view=rev
Log:
[asan] Don't check ODR violations for particular types of globals

Summary:
private and internal: should not trigger ODR at all.
unnamed_addr: current ODR checking approach fail and rereport false violation if
a linker merges such globals
linkonce_odr, weak_odr: could cause similar problems and they are already not
instrumented for ELF.

Reviewers: eugenis, kcc

Subscribers: kubamracek, hiraditya, llvm-commits

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

Added:
cfe/trunk/test/CodeGen/asan-static-odr.cpp

Added: cfe/trunk/test/CodeGen/asan-static-odr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asan-static-odr.cpp?rev=349015&view=auto
==
--- cfe/trunk/test/CodeGen/asan-static-odr.cpp (added)
+++ cfe/trunk/test/CodeGen/asan-static-odr.cpp Thu Dec 13 01:47:39 2018
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-linux %s 
| FileCheck %s --check-prefixes=CHECK,ALIAS1
+
+// No alias on Windows but indicators should work.
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple 
x86_64-windows-msvc %s | FileCheck %s --check-prefixes=CHECK,ALIAS0
+
+static int global;
+
+int main() {
+  return global;
+}
+
+// CHECK-NOT: __odr_asan_gen
+// CHECK-NOT: private alias
+// CHECK: [[VAR:@.*global.*]] ={{.*}} global { i32, [60 x i8] } 
zeroinitializer, align 32
+// CHECK: @0 = internal global {{.*}} [[VAR]] to i64), {{.*}}, i64 -1 }]
+// CHECK: call void @__asan_register_globals(i64 ptrtoint ([1 x { i64, i64, 
i64, i64, i64, i64, i64, i64 }]* @0 to i64), i64 1)
+// CHECK: call void @__asan_unregister_globals(i64 ptrtoint ([1 x { i64, i64, 
i64, i64, i64, i64, i64, i64 }]* @0 to i64), i64 1)


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


r373992 - [clang] Accept -ftrivial-auto-var-init in clang-cl

2019-10-07 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Oct  7 16:57:11 2019
New Revision: 373992

URL: http://llvm.org/viewvc/llvm-project?rev=373992&view=rev
Log:
[clang] Accept -ftrivial-auto-var-init in clang-cl

Reviewers: eugenis, rnk

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=373992&r1=373991&r2=373992&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct  7 16:57:11 2019
@@ -1715,10 +1715,10 @@ def fstack_protector : Flag<["-"], "fsta
"alloca, which are of greater size than ssp-buffer-size (default: 8 
bytes). "
"All variable sized calls to alloca are considered vulnerable">;
 def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, 
Group,
-  Flags<[CC1Option]>, HelpText<"Initialize trivial automatic stack variables: 
uninitialized (default)"
+  Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack 
variables: uninitialized (default)"
   " | pattern">, Values<"uninitialized,pattern">;
 def enable_trivial_var_init_zero : Joined<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
-  Flags<[CC1Option]>,
+  Flags<[CC1Option, CoreOption]>,
   HelpText<"Trivial automatic variable initialization to zero is only here for 
benchmarks, it'll eventually be removed, and I'm OK with that because I'm only 
using it to benchmark">;
 def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, 
Flags<[CoreOption]>,
   HelpText<"Emit full debug info for all types used by the program">;

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=373992&r1=373991&r2=373992&view=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Mon Oct  7 16:57:11 2019
@@ -653,6 +653,8 @@
 // RUN: -fcs-profile-generate \
 // RUN: -fcs-profile-generate=dir \
 // RUN: -ftime-trace \
+// RUN: -ftrivial-auto-var-init=zero \
+// RUN: 
-enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang \
 // RUN: --version \
 // RUN: -Werror /Zs -- %s 2>&1
 


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


r374110 - [clang] Add llvm-ifs in test deps

2019-10-08 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Oct  8 13:23:24 2019
New Revision: 374110

URL: http://llvm.org/viewvc/llvm-project?rev=374110&view=rev
Log:
[clang] Add llvm-ifs in test deps

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=374110&r1=374109&r2=374110&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Tue Oct  8 13:23:24 2019
@@ -108,6 +108,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-cxxfilt
 llvm-dis
 llvm-dwarfdump
+llvm-ifs
 llvm-lto2
 llvm-modextract
 llvm-nm


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


r374113 - [clang] enable_trivial_var_init_zero should not be Joined<>

2019-10-08 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Tue Oct  8 13:34:53 2019
New Revision: 374113

URL: http://llvm.org/viewvc/llvm-project?rev=374113&view=rev
Log:
[clang] enable_trivial_var_init_zero should not be Joined<>

Reviewers: rnk

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Driver/Options.td

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=374113&r1=374112&r2=374113&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Oct  8 13:34:53 2019
@@ -1720,7 +1720,7 @@ def fstack_protector : Flag<["-"], "fsta
 def ftrivial_auto_var_init : Joined<["-"], "ftrivial-auto-var-init=">, 
Group,
   Flags<[CC1Option, CoreOption]>, HelpText<"Initialize trivial automatic stack 
variables: uninitialized (default)"
   " | pattern">, Values<"uninitialized,pattern">;
-def enable_trivial_var_init_zero : Joined<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
+def enable_trivial_var_init_zero : Flag<["-"], 
"enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang">,
   Flags<[CC1Option, CoreOption]>,
   HelpText<"Trivial automatic variable initialization to zero is only here for 
benchmarks, it'll eventually be removed, and I'm OK with that because I'm only 
using it to benchmark">;
 def fstandalone_debug : Flag<["-"], "fstandalone-debug">, Group, 
Flags<[CoreOption]>,


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


r374481 - [tsan,msan] Insert module constructors in a module pass

2019-10-10 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Thu Oct 10 16:49:10 2019
New Revision: 374481

URL: http://llvm.org/viewvc/llvm-project?rev=374481&view=rev
Log:
[tsan,msan] Insert module constructors in a module pass

Summary:
If we insert them from function pass some analysis may be missing or invalid.
Fixes PR42877.

Reviewers: eugenis, leonardchan

Reviewed By: leonardchan

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added:
cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=374481&r1=374480&r2=374481&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu Oct 10 16:49:10 2019
@@ -974,6 +974,7 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+MPM.addPass(MemorySanitizerPass({}));
 MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
   }
 
@@ -983,6 +984,7 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+MPM.addPass(ThreadSanitizerPass());
 MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
   }
 }
@@ -1162,16 +1164,23 @@ void EmitAssemblyHelper::EmitAssemblyWit
 [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) {
+  MPM.addPass(MemorySanitizerPass({}));
+});
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(MemorySanitizerPass({}));
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Thread))
+  }
+  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+PB.registerPipelineStartEPCallback(
+[](ModulePassManager &MPM) { MPM.addPass(ThreadSanitizerPass()); 
});
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(ThreadSanitizerPass());
 });
+  }
   if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
 PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) {
   MPM.addPass(

Added: cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitizer-module-constructor.c?rev=374481&view=auto
==
--- cfe/trunk/test/CodeGen/sanitizer-module-constructor.c (added)
+++ cfe/trunk/test/CodeGen/sanitizer-module-constructor.c Thu Oct 10 16:49:10 
2019
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsanitize=address -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=thread -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -emit-llvm -O3 -fdebug-pass-manager 
-fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+
+// This is regression test for PR42877
+
+typedef struct a *b;
+struct a {
+  int c;
+};
+int d;
+b e;
+static void f(b g) {
+  for (d = g->c;;)
+;
+}
+void h() { f(e); }
+
+// CHECK: Running pass: {{.*}}SanitizerPass on 
{{.*}}sanitizer-module-constructor.c
+// CHECK-NOT: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor
+// CHECK: Running analysis: DominatorTreeAnalysis on {{.*}}san.module_ctor
+// CHECK: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor


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


r374527 - Insert module constructors in a module pass

2019-10-11 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Oct 11 01:47:03 2019
New Revision: 374527

URL: http://llvm.org/viewvc/llvm-project?rev=374527&view=rev
Log:
Insert module constructors in a module pass

Summary:
If we insert them from function pass some analysis may be missing or invalid.
Fixes PR42877.

Reviewers: eugenis, leonardchan

Reviewed By: leonardchan

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 374481
Signed-off-by: Vitaly Buka 

Added:
cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=374527&r1=374526&r2=374527&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Fri Oct 11 01:47:03 2019
@@ -974,6 +974,7 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+MPM.addPass(MemorySanitizerPass({}));
 MPM.addPass(createModuleToFunctionPassAdaptor(MemorySanitizerPass({})));
   }
 
@@ -983,6 +984,7 @@ static void addSanitizersAtO0(ModulePass
   }
 
   if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+MPM.addPass(ThreadSanitizerPass());
 MPM.addPass(createModuleToFunctionPassAdaptor(ThreadSanitizerPass()));
   }
 }
@@ -1162,16 +1164,23 @@ void EmitAssemblyHelper::EmitAssemblyWit
 [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(BoundsCheckingPass());
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory)) {
+PB.registerPipelineStartEPCallback([](ModulePassManager &MPM) {
+  MPM.addPass(MemorySanitizerPass({}));
+});
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(MemorySanitizerPass({}));
 });
-  if (LangOpts.Sanitize.has(SanitizerKind::Thread))
+  }
+  if (LangOpts.Sanitize.has(SanitizerKind::Thread)) {
+PB.registerPipelineStartEPCallback(
+[](ModulePassManager &MPM) { MPM.addPass(ThreadSanitizerPass()); 
});
 PB.registerOptimizerLastEPCallback(
 [](FunctionPassManager &FPM, PassBuilder::OptimizationLevel Level) 
{
   FPM.addPass(ThreadSanitizerPass());
 });
+  }
   if (LangOpts.Sanitize.has(SanitizerKind::Address)) {
 PB.registerPipelineStartEPCallback([&](ModulePassManager &MPM) {
   MPM.addPass(

Added: cfe/trunk/test/CodeGen/sanitizer-module-constructor.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/sanitizer-module-constructor.c?rev=374527&view=auto
==
--- cfe/trunk/test/CodeGen/sanitizer-module-constructor.c (added)
+++ cfe/trunk/test/CodeGen/sanitizer-module-constructor.c Fri Oct 11 01:47:03 
2019
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=address -emit-llvm -O3 
-fdebug-pass-manager -fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=thread -emit-llvm -O3 
-fdebug-pass-manager -fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsanitize=memory -emit-llvm -O3 
-fdebug-pass-manager -fexperimental-new-pass-manager -o - %s 2>&1 | FileCheck %s
+
+// This is regression test for PR42877
+
+typedef struct a *b;
+struct a {
+  int c;
+};
+int d;
+b e;
+static void f(b g) {
+  for (d = g->c;;)
+;
+}
+void h() { f(e); }
+
+// CHECK: Running pass: {{.*}}SanitizerPass on 
{{.*}}sanitizer-module-constructor.c
+// CHECK-NOT: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor
+// CHECK: Running analysis: DominatorTreeAnalysis on {{.*}}san.module_ctor
+// CHECK: Running pass: LoopSimplifyPass on {{.*}}san.module_ctor


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


Re: Zorg migration to GitHub/monorepo

2019-10-18 Thread Vitaly Buka via cfe-commits
On Mon, Oct 14, 2019 at 6:16 PM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello everyone,
>
>
>
> We are in the middle of porting the majority of zorg to
> GitHub/monorepo. The following build factories will be ported and if you
> use one of those for your bots, you are all covered:
>
>
>
> * ClangBuilder.getClangCMakeBuildFactory (31 bots)
>
> * ClangBuilder.getClangCMakeGCSBuildFactory (2 bots)
>
> * LibcxxAndAbiBuilder (23 bots)
>
> * SphinxDocsBuilder (7 bots)
>
> * UnifiedTreeBuilder (11 bots)
>
> * ABITestsuitBuilder (1 bot) - based on UnifiedTreeBuilder
>
> * ClangLTOBuilder (2 bots) - based on UnifiedTreeBuilder
>
> * LLDPerformanceTesuiteBuilder (1 bot) - based on UnifiedTreeBuilder
>
>
>
> Some build factories will be deprecated. If you use one of these, please
> change your bot to use something else instead. Here is the list of
> deprecated build factories:
>
>
>
> * ClangBuilder.getClangBuildFactory (0 bots)
>
> * LLDBuilder (0 bots)
>
> * ClangAndLLDBuilder (0 bots)
>
>
>
> However, some special build factories and build factories with a few bots
> would need your attention.
>
> Here is the list of build factories in need of porting. Patches are
> welcome.
>
>
>
> * LLVMBuilder (3 bots)
>
> * PollyBuilder (3 bots)
>
> * LLDBBuilder (6 bots)
>
> * SanitizerBuilder (10 bots)
>

SanitizerBuilder already uses monorepo from github. Still it uses svn
BUILDBOT_REVISION. 'BUILDBOT_REVISION' is
WithProperties('%(revision:-None)s').
Not sure what is going to happen after migration.


> * CUDATestsuiteBuilder (1 bot) - depends on
> ClangBuilder.getClangBuildFactory
>
> * AOSPBuilder (1 bot) - depends on PollyBuilder
>
> * AnnotatedBuilder (2 bots)
>
> * OpenMPBuilder (2 bots)
>
> * FuchsiaBuilder (1 bot)
>
>
>
> Please feel free to ask if you have questions.
>
>
>
> Thanks
>
>
>
> Galina
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 088fb97 - [NFC, StackSafety] LTO tests for MTE and StackSafety

2020-05-25 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-05-23T17:39:54-07:00
New Revision: 088fb9734843c09493d5965baed775c4ec32d5fb

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

LOG: [NFC, StackSafety] LTO tests for MTE and StackSafety

Summary:
The test demonstrates the current state of the compiler and
I am going to resolve FIXME in followup patches.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: inglorion, hiraditya, steven_wu, dexonsmith, cfe-commits

Tags: #clang

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

Added: 
clang/test/Driver/memtag_lto.c

Modified: 


Removed: 




diff  --git a/clang/test/Driver/memtag_lto.c b/clang/test/Driver/memtag_lto.c
new file mode 100644
index ..49edfdc9ec2a
--- /dev/null
+++ b/clang/test/Driver/memtag_lto.c
@@ -0,0 +1,143 @@
+// REQUIRES: aarch64-registered-target
+
+// RUN: rm -f %t*
+
+// -O1, no tagging: both are unsafe.
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -S -emit-llvm -c %s -o - | FileCheck %s
+// RUN: %clang-fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -S -emit-llvm -c %s -o - | FileCheck %s
+
+// Full LTO: both are unsafe.
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=full -o %t.lto1.bc
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=full -o %t.lto2.bc
+// RUN: llvm-lto2 run -o %t.lto %t.lto1.bc %t.lto2.bc -save-temps -O1 \
+// RUN:  -r %t.lto1.bc,fn,plx \
+// RUN:  -r %t.lto1.bc,use,lx \
+// RUN:  -r %t.lto1.bc,use_local,plx \
+// RUN:  -r %t.lto1.bc,w, \
+// RUN:  -r %t.lto2.bc,use,plx \
+// RUN:  -r %t.lto2.bc,z,
+// RUN: llvm-dis %t.lto.0.5.precodegen.bc -o - | FileCheck %s
+
+// Full LTO, new PM: both are unsafe.
+// RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=full -o %t.ltonewpm1.bc
+// RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=full -o %t.ltonewpm2.bc
+// RUN: llvm-lto2 run -use-new-pm -o %t.ltonewpm %t.ltonewpm1.bc 
%t.ltonewpm2.bc -save-temps -O1 \
+// RUN:  -r %t.ltonewpm1.bc,fn,plx \
+// RUN:  -r %t.ltonewpm1.bc,use,lx \
+// RUN:  -r %t.ltonewpm1.bc,use_local,plx \
+// RUN:  -r %t.ltonewpm1.bc,w, \
+// RUN:  -r %t.ltonewpm2.bc,use,plx \
+// RUN:  -r %t.ltonewpm2.bc,z,
+// RUN: llvm-dis %t.ltonewpm.0.5.precodegen.bc -o - | FileCheck %s
+
+// Thin LTO: both are unsafe.
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=thin -o %t.thinlto1.bc
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=thin -o %t.thinlto2.bc
+// RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-O1 \
+// RUN:  -r %t.thinlto1.bc,fn,plx \
+// RUN:  -r %t.thinlto1.bc,use,lx \
+// RUN:  -r %t.thinlto1.bc,use_local,plx \
+// RUN:  -r %t.thinlto1.bc,w, \
+// RUN:  -r %t.thinlto2.bc,use,plx \
+// RUN:  -r %t.thinlto2.bc,z,
+// RUN: llvm-dis %t.thinlto.1.5.precodegen.bc -o - | FileCheck %s
+
+// Thin LTO, new PM: both are unsafe.
+// RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=thin -o %t.thinltonewpm1.bc
+// RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=thin -o %t.thinltonewpm2.bc
+// RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -O1 \
+// RUN:  -r %t.thinltonewpm1.bc,fn,plx \
+// RUN:  -r %t.thinltonewpm1.bc,use,lx \
+// RUN:  -r %t.thinltonewpm1.bc,use_local,plx \
+// RUN:  -r %t.thinltonewpm1.bc,w, \
+// RUN:  -r %t.thinltonewpm2.bc,use,plx \
+// RUN:  -r %t.thinltonewpm2.bc,z,
+// RUN: llvm-dis %t.thinltonewpm.1.5.precodegen.bc -o - | FileCheck %s
+
+// Now with MTE.
+// RUN: rm -f %t*
+
+// -O0: both are unsafe.
+// RUN: %clang -fno-experimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -S -emit-llvm -c %s 
-o - | FileCheck %s
+// RUN: %clang-fexperimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -S -emit-llvm -c %s 
-o - | FileCheck %s
+
+// No LTO: just one is safe.
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -S -emit-llvm -c %s 
-o - | FileCheck %s -check-prefixes=XUNSAFE,YSAFE
+// RUN: %clang-fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -S -emit-llvm -c %s 
-o - | FileCheck %s -check-prefixes=XUNSAFE,YSAFE
+
+// FIXME: Full LTO: both are safe.
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -marc

[clang] 14de6e2 - [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

2020-05-26 Thread Vitaly Buka via cfe-commits

Author: Marco Elver
Date: 2020-05-26T13:36:21-07:00
New Revision: 14de6e29b1315e9abe61d71e3e13f75bff80e1be

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

LOG: [Clang][Driver] Add Bounds and Thread to SupportsCoverage list

Summary:
This permits combining -fsanitize-coverage with -fsanitize=bounds or
-fsanitize=thread. Note that, GCC already supports combining these.

Tested:
- Add Clang end-to-end test checking IR is generated for both combinations
of sanitizers.
- Several previously failing TSAN tests now pass.

Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=45831

Reviewers: vitalybuka

Reviewed By: vitalybuka

Subscribers: #sanitizers, dvyukov, nickdesaulniers, cfe-commits

Tags: #clang, #sanitizers

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

Added: 
clang/test/CodeGen/sanitize-coverage.c

Modified: 
clang/lib/Driver/SanitizerArgs.cpp
clang/test/Driver/fsanitize-coverage.c

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline8bit_counter.cpp

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_inline_bool_flag.cpp
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_no_prune.cpp

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_stack_depth.cpp

compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_trace_pc_guard-init.cpp

Removed: 




diff  --git a/clang/lib/Driver/SanitizerArgs.cpp 
b/clang/lib/Driver/SanitizerArgs.cpp
index bc186fa5a598..35e982a502ef 100644
--- a/clang/lib/Driver/SanitizerArgs.cpp
+++ b/clang/lib/Driver/SanitizerArgs.cpp
@@ -43,11 +43,12 @@ static const SanitizerMask SupportsCoverage =
 SanitizerKind::KernelAddress | SanitizerKind::KernelHWAddress |
 SanitizerKind::MemTag | SanitizerKind::Memory |
 SanitizerKind::KernelMemory | SanitizerKind::Leak |
-SanitizerKind::Undefined | SanitizerKind::Integer |
+SanitizerKind::Undefined | SanitizerKind::Integer | SanitizerKind::Bounds |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |
 SanitizerKind::DataFlow | SanitizerKind::Fuzzer |
 SanitizerKind::FuzzerNoLink | SanitizerKind::FloatDivideByZero |
-SanitizerKind::SafeStack | SanitizerKind::ShadowCallStack;
+SanitizerKind::SafeStack | SanitizerKind::ShadowCallStack |
+SanitizerKind::Thread;
 static const SanitizerMask RecoverableByDefault =
 SanitizerKind::Undefined | SanitizerKind::Integer |
 SanitizerKind::ImplicitConversion | SanitizerKind::Nullability |

diff  --git a/clang/test/CodeGen/sanitize-coverage.c 
b/clang/test/CodeGen/sanitize-coverage.c
new file mode 100644
index ..6fc8e39354d4
--- /dev/null
+++ b/clang/test/CodeGen/sanitize-coverage.c
@@ -0,0 +1,22 @@
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S   
-fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck %s 
--check-prefixes=CHECK
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=address-fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,ASAN
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=bounds -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,BOUNDS
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=memory -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,MSAN
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=thread -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,TSAN
+// RUN: %clang %s -target x86_64-unknown-linux-gnu -emit-llvm -S 
-fsanitize=undefined  -fsanitize-coverage=trace-pc,trace-cmp -o - | FileCheck 
%s --check-prefixes=CHECK,UBSAN
+
+int x[10];
+
+// CHECK-LABEL: define dso_local void @foo(
+void foo(int n) {
+  // CHECK-DAG: call void @__sanitizer_cov_trace_pc
+  // CHECK-DAG: call void @__sanitizer_cov_trace_const_cmp
+  // ASAN-DAG: call void @__asan_report_store
+  // MSAN-DAG: call void @__msan_warning
+  // BOUNDS-DAG: call void @__ubsan_handle_out_of_bounds
+  // TSAN-DAG: call void @__tsan_func_entry
+  // UBSAN-DAG: call void @__ubsan_handle
+  if (n)
+x[n] = 42;
+}
+// CHECK-LABEL: declare void

diff  --git a/clang/test/Driver/fsanitize-coverage.c 
b/clang/test/Driver/fsanitize-coverage.c
index b10fc86bb391..02078d847512 100644
--- a/clang/test/Driver/fsanitize-coverage.c
+++ b/clang/test/Driver/fsanitize-coverage.c
@@ -12,8 +12,10 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=kernel-memory 
-fsanitize-coverage=func,trace-pc %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-SANITIZE-COVERAGE-FUNC
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=leak 
-fsanitize-coverage=func,trace-pc

[clang] 2f430f7 - [StackSafety] Remove SetMetadata parameter

2020-05-28 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-05-28T13:32:57-07:00
New Revision: 2f430f7a51693c9d5c648179f2341b541be44000

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

LOG: [StackSafety] Remove SetMetadata parameter

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Analysis/StackSafetyAnalysis.h
llvm/lib/Analysis/StackSafetyAnalysis.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 33627f3a6733..e746aef1a62f 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -353,7 +353,7 @@ static void addDataFlowSanitizerPass(const 
PassManagerBuilder &Builder,
 
 static void addMemTagOptimizationPasses(const PassManagerBuilder &Builder,
 legacy::PassManagerBase &PM) {
-  PM.add(createStackSafetyGlobalInfoWrapperPass(/*SetMetadata=*/true));
+  PM.add(createStackSafetyGlobalInfoWrapperPass());
 }
 
 static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,

diff  --git a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h 
b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
index df7ccac5b4b9..b5589611c8e2 100644
--- a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
+++ b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
@@ -126,12 +126,11 @@ class StackSafetyGlobalAnnotatorPass
 /// (legacy pass manager).
 class StackSafetyGlobalInfoWrapperPass : public ModulePass {
   StackSafetyGlobalInfo SSGI;
-  bool SetMetadata;
 
 public:
   static char ID;
 
-  StackSafetyGlobalInfoWrapperPass(bool SetMetadata = false);
+  StackSafetyGlobalInfoWrapperPass();
 
   const StackSafetyGlobalInfo &getResult() const { return SSGI; }
 
@@ -141,7 +140,7 @@ class StackSafetyGlobalInfoWrapperPass : public ModulePass {
   bool runOnModule(Module &M) override;
 };
 
-ModulePass *createStackSafetyGlobalInfoWrapperPass(bool SetMetadata);
+ModulePass *createStackSafetyGlobalInfoWrapperPass();
 
 } // end namespace llvm
 

diff  --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp 
b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 6eeffe6066df..e969639973a4 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -712,9 +712,8 @@ StackSafetyGlobalAnnotatorPass::run(Module &M, 
ModuleAnalysisManager &AM) {
 
 char StackSafetyGlobalInfoWrapperPass::ID = 0;
 
-StackSafetyGlobalInfoWrapperPass::StackSafetyGlobalInfoWrapperPass(
-bool SetMetadata)
-: ModulePass(ID), SetMetadata(SetMetadata) {
+StackSafetyGlobalInfoWrapperPass::StackSafetyGlobalInfoWrapperPass()
+: ModulePass(ID) {
   initializeStackSafetyGlobalInfoWrapperPassPass(
   *PassRegistry::getPassRegistry());
 }
@@ -738,11 +737,11 @@ bool StackSafetyGlobalInfoWrapperPass::runOnModule(Module 
&M) {
 .Info;
   });
   SSGI = SSDFA.run();
-  return SetMetadata ? SSGI.setMetadata(M) : false;
+  return SSGI.setMetadata(M);
 }
 
-ModulePass *llvm::createStackSafetyGlobalInfoWrapperPass(bool SetMetadata) {
-  return new StackSafetyGlobalInfoWrapperPass(SetMetadata);
+ModulePass *llvm::createStackSafetyGlobalInfoWrapperPass() {
+  return new StackSafetyGlobalInfoWrapperPass();
 }
 
 static const char LocalPassArg[] = "stack-safety-local";



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


[clang] 232d348 - [MTE] Convert StackSafety into analysis

2020-06-02 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-06-02T16:08:14-07:00
New Revision: 232d348c6eff8493fc016b1ea8a99db0e5620d81

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

LOG: [MTE] Convert StackSafety into analysis

This lets us to remove !stack-safe metadata and
better controll when to perform StackSafety
analysis.

Reviewers: eugenis

Subscribers: hiraditya, steven_wu, dexonsmith, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/Driver/memtag.c
clang/test/Driver/memtag_lto.c
llvm/include/llvm/Analysis/StackSafetyAnalysis.h
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/lib/Passes/PassRegistry.def
llvm/lib/Target/AArch64/AArch64.h
llvm/lib/Target/AArch64/AArch64StackTagging.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/test/CodeGen/AArch64/O3-pipeline.ll
llvm/test/CodeGen/AArch64/stack-tagging.ll

Removed: 
llvm/test/Analysis/StackSafetyAnalysis/ipa-attr.ll



diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 056126dda445..9f28fed40ebc 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -352,11 +352,6 @@ static void addDataFlowSanitizerPass(const 
PassManagerBuilder &Builder,
   PM.add(createDataFlowSanitizerPass(LangOpts.SanitizerBlacklistFiles));
 }
 
-static void addMemTagOptimizationPasses(const PassManagerBuilder &Builder,
-legacy::PassManagerBase &PM) {
-  PM.add(createStackSafetyGlobalInfoWrapperPass());
-}
-
 static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
  const CodeGenOptions &CodeGenOpts) {
   TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);
@@ -727,11 +722,6 @@ void EmitAssemblyHelper::CreatePasses(legacy::PassManager 
&MPM,
addDataFlowSanitizerPass);
   }
 
-  if (LangOpts.Sanitize.has(SanitizerKind::MemTag)) {
-PMBuilder.addExtension(PassManagerBuilder::EP_OptimizerLast,
-   addMemTagOptimizationPasses);
-  }
-
   // Set up the per-function pass manager.
   FPM.add(new TargetLibraryInfoWrapperPass(*TLII));
   if (CodeGenOpts.VerifyModule)
@@ -1384,11 +1374,6 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   /*CompileKernel=*/true, /*Recover=*/true));
 }
 
-if (CodeGenOpts.OptimizationLevel > 0 &&
-LangOpts.Sanitize.has(SanitizerKind::MemTag)) {
-  MPM.addPass(StackSafetyGlobalAnnotatorPass());
-}
-
 if (CodeGenOpts.OptimizationLevel == 0) {
   addCoroutinePassesAtO0(MPM, LangOpts, CodeGenOpts);
   addSanitizersAtO0(MPM, TargetTriple, LangOpts, CodeGenOpts);

diff  --git a/clang/test/Driver/memtag.c b/clang/test/Driver/memtag.c
index bfe453beef56..0de5aaa35fb7 100644
--- a/clang/test/Driver/memtag.c
+++ b/clang/test/Driver/memtag.c
@@ -1,23 +1,27 @@
 // REQUIRES: aarch64-registered-target
 
 // Old pass manager.
-// RUN: %clang -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag %s -S -emit-llvm -o 
- | FileCheck %s --check-prefix=CHECK-NO-SAFETY
-// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag %s -S -emit-llvm -o 
- | FileCheck %s --check-prefix=CHECK-SAFETY
-// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag %s -S -emit-llvm -o 
- | FileCheck %s --check-prefix=CHECK-SAFETY
-// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag %s -S -emit-llvm -o 
- | FileCheck %s --check-prefix=CHECK-SAFETY
+// RUN: %clang -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s 
--check-prefix=CHECK-NO-SAFETY
+// RUN: %clang -O1 -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s --check-prefix=CHECK-SAFETY
+// RUN: %clang -O2 -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s --check-prefix=CHECK-SAFETY
+// RUN: %clang -O3 -fno-experimental-new-pass-manager -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s --check-prefix=CHECK-SAFETY
 
 // New pass manager.
-// RUN: %clang -fexperimental-new-pass-manager -target 
aarch64-unknow

[clang] 85fdec9 - [NFC,MTE] Drop unneeded attribute from test

2020-06-02 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-06-02T18:28:45-07:00
New Revision: 85fdec988fc55d56988d57fa88e2b870f6e0e8e9

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

LOG: [NFC,MTE] Drop unneeded attribute from test

Summary: Depends on D80847.

Reviewers: eugenis

Reviewed By: eugenis

Subscribers: hiraditya, steven_wu, dexonsmith, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/test/Driver/memtag_lto.c

Removed: 




diff  --git a/clang/test/Driver/memtag_lto.c b/clang/test/Driver/memtag_lto.c
index ab9bbd2f76d2..d9cf327c1bca 100644
--- a/clang/test/Driver/memtag_lto.c
+++ b/clang/test/Driver/memtag_lto.c
@@ -121,7 +121,7 @@ __attribute__((noinline)) void use_local(char *p) { *p = w; 
}
 
 // SSI-LABEL: @fn
 // SSI-LABEL: allocas uses:
-__attribute__((visibility("default"))) int fn() {
+int fn() {
   // XUNSAFE-DAG: [4]: full-set
   // XSAFE-DAG: [4]: [0,4)
   int x;



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


[clang] ced398f - [SanitizerCoverage] Add -fsanitize-coverage=inline-bool-flag

2020-04-09 Thread Vitaly Buka via cfe-commits

Author: Pratyai Mazumder
Date: 2020-04-09T02:40:55-07:00
New Revision: ced398fdc813930bfe88df5252c0f5405af541fc

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

LOG: [SanitizerCoverage] Add -fsanitize-coverage=inline-bool-flag

Reviewers: kcc, vitalybuka

Reviewed By: vitalybuka

Subscribers: cfe-commits, llvm-commits

Tags: #clang

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

Added: 


Modified: 
clang/docs/SanitizerCoverage.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/SanitizerArgs.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/Driver/autocomplete.c
clang/test/Driver/fsanitize-coverage.c

Removed: 




diff  --git a/clang/docs/SanitizerCoverage.rst 
b/clang/docs/SanitizerCoverage.rst
index 303152309e1a..fdb07a7d967a 100644
--- a/clang/docs/SanitizerCoverage.rst
+++ b/clang/docs/SanitizerCoverage.rst
@@ -139,6 +139,28 @@ Users need to implement a single function to capture the 
counters at startup.
 // Capture this array in order to read/modify the counters.
   }
 
+
+Inline bool-flag
+
+
+**Experimental, may change or disappear in future**
+
+With ``-fsanitize-coverage=inline-bool-flag`` the compiler will insert
+setting an inline boolean to true on every edge.
+This is similar to ``-fsanitize-coverage=inline-8bit-counter`` but instead of
+an increment of a counter, it just sets a boolean to true.
+
+Users need to implement a single function to capture the flags at startup.
+
+.. code-block:: c++
+
+  extern "C"
+  void __sanitizer_cov_bool_flag_init(bool *start, bool *end) {
+// [start,end) is the array of boolean flags created for the current DSO.
+// Capture this array in order to read/modify the flags.
+  }
+
+
 PC-Table
 
 
@@ -150,8 +172,8 @@ significant binary size overhead. For more information, see
 `Bug 34636 `_.
 
 With ``-fsanitize-coverage=pc-table`` the compiler will create a table of
-instrumented PCs. Requires either ``-fsanitize-coverage=inline-8bit-counters`` 
or
-``-fsanitize-coverage=trace-pc-guard``.
+instrumented PCs. Requires either ``-fsanitize-coverage=inline-8bit-counters``,
+or ``-fsanitize-coverage=inline-bool-flag``, or 
``-fsanitize-coverage=trace-pc-guard``.
 
 Users need to implement a single function to capture the PC table at startup:
 
@@ -164,8 +186,9 @@ Users need to implement a single function to capture the PC 
table at startup:
 // pairs [PC,PCFlags] for every instrumented block in the current DSO.
 // Capture this array in order to read the PCs and their Flags.
 // The number of PCs and PCFlags for a given DSO is the same as the number
-// of 8-bit counters (-fsanitize-coverage=inline-8bit-counters) or
-// trace_pc_guard callbacks (-fsanitize-coverage=trace-pc-guard)
+// of 8-bit counters (-fsanitize-coverage=inline-8bit-counters), or
+// boolean flags (-fsanitize-coverage=inline=bool-flags), or trace_pc_guard
+// callbacks (-fsanitize-coverage=trace-pc-guard).
 // A PCFlags describes the basic block:
 //  * bit0: 1 if the block is the function entry block, 0 otherwise.
   }

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0faa013ac497..bc7108edece9 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -232,6 +232,7 @@ CODEGENOPT(SanitizeCoverageTracePC, 1, 0) ///< Enable PC 
tracing
 CODEGENOPT(SanitizeCoverageTracePCGuard, 1, 0) ///< Enable PC tracing with 
guard
///< in sanitizer coverage.
 CODEGENOPT(SanitizeCoverageInline8bitCounters, 1, 0) ///< Use inline 8bit 
counters.
+CODEGENOPT(SanitizeCoverageInlineBoolFlag, 1, 0) ///< Use inline bool flag.
 CODEGENOPT(SanitizeCoveragePCTable, 1, 0) ///< Create a PC Table.
 CODEGENOPT(SanitizeCoverageNoPrune, 1, 0) ///< Disable coverage pruning.
 CODEGENOPT(SanitizeCoverageStackDepth, 1, 0) ///< Enable max stack depth 
tracing

diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index ebefb20c4639..e7912dd27ea6 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -355,6 +355,9 @@ def fsanitize_coverage_8bit_counters
 def fsanitize_coverage_inline_8bit_counters
 : Flag<["-"], "fsanitize-coverage-inline-8bit-counters">,
   HelpText<"Enable inline 8-bit counters in sanitizer coverage">;
+def fsanitize_coverage_inline_bool_flag
+: Flag<["-"], "fsanitize-coverage-inline-bool-flag">,
+  HelpText<"Enable inline boo

[clang] 6dd738e - [StackSafety,NFC] Switch tests to aarch64

2020-06-05 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-06-05T00:24:02-07:00
New Revision: 6dd738e2f0609f7d3313b574a1d471263d2d3ba1

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

LOG: [StackSafety,NFC] Switch tests to aarch64

Added: 


Modified: 
clang/test/Driver/memtag_lto.c
llvm/test/Analysis/StackSafetyAnalysis/Inputs/ipa-alias.ll
llvm/test/Analysis/StackSafetyAnalysis/Inputs/ipa.ll
llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Removed: 




diff  --git a/clang/test/Driver/memtag_lto.c b/clang/test/Driver/memtag_lto.c
index d9cf327c1bca..81a6f7b842e1 100644
--- a/clang/test/Driver/memtag_lto.c
+++ b/clang/test/Driver/memtag_lto.c
@@ -5,13 +5,13 @@
 // RUN: rm -f %t*
 
 // -O1, no tagging
-// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck 
%s
-// RUN: %clang-fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print=1 %s -S -o - 2>&1 | FileCheck 
%s
+// RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang-fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -mllvm -stack-safety-print %s -S -o - 2>&1 | FileCheck %s
 
 // Full LTO
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=full -o %t.lto1.bc
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=full -o %t.lto2.bc
-// RUN: llvm-lto2 run -o %t.lto %t.lto1.bc %t.lto2.bc -save-temps 
-stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -o %t.lto %t.lto1.bc %t.lto2.bc -save-temps 
-stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.lto1.bc,fn,plx \
 // RUN:  -r %t.lto1.bc,use,lx \
 // RUN:  -r %t.lto1.bc,use_local,plx \
@@ -22,7 +22,7 @@
 // Full LTO, new PM
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=full -o %t.ltonewpm1.bc
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=full -o %t.ltonewpm2.bc
-// RUN: llvm-lto2 run -use-new-pm -o %t.ltonewpm %t.ltonewpm1.bc 
%t.ltonewpm2.bc -save-temps -stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -use-new-pm -o %t.ltonewpm %t.ltonewpm1.bc 
%t.ltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.ltonewpm1.bc,fn,plx \
 // RUN:  -r %t.ltonewpm1.bc,use,lx \
 // RUN:  -r %t.ltonewpm1.bc,use_local,plx \
@@ -33,7 +33,7 @@
 // Thin LTO
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=thin -o %t.thinlto1.bc
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=thin -o %t.thinlto2.bc
-// RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.thinlto1.bc,fn,plx \
 // RUN:  -r %t.thinlto1.bc,use,lx \
 // RUN:  -r %t.thinlto1.bc,use_local,plx \
@@ -44,7 +44,7 @@
 // Thin LTO, new PM
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c %s -flto=thin -o %t.thinltonewpm1.bc
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -c -DBUILD2 %s -flto=thin -o %t.thinltonewpm2.bc
-// RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -stack-safety-print=1 -thinlto-threads 1 -O1 \
+// RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
 // RUN:  -r %t.thinltonewpm1.bc,fn,plx \
 // RUN:  -r %t.thinltonewpm1.bc,use,lx \
 // RUN:  -r %t.thinltonewpm1.bc,use_local,plx \
@@ -56,17 +56,17 @@
 // RUN: rm -f %t*
 
 // -O0: both are unsafe.
-// RUN: %clang -fno-experimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s
-// RUN: %clang-fexperimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print=1 %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang -fno-experimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-print %s -S -o - 2>&1 | FileCheck %s
+// RUN: %clang-fexperimental-new-pass-manager -O0 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -mllvm 
-stack-safety-pri

[clang] c1e47b4 - [StackSafety] Run ThinLTO

2020-06-12 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-06-12T18:11:29-07:00
New Revision: c1e47b47f8848bb4c1ead8c530940d783c1fbf46

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

LOG: [StackSafety] Run ThinLTO

Summary:
ThinLTO linking runs dataflow processing on collected
function parameters. Then StackSafetyGlobalInfoWrapperPass
in ThinLTO backend will run as usual looking up to external
symbol in the summary if needed.

Depends on D80985.

Reviewers: eugenis, pcc

Reviewed By: eugenis

Subscribers: inglorion, hiraditya, steven_wu, dexonsmith, cfe-commits, 
llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/test/Driver/memtag_lto.c
llvm/include/llvm/Analysis/StackSafetyAnalysis.h
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/lib/LTO/LTO.cpp
llvm/test/Analysis/StackSafetyAnalysis/ipa-alias.ll
llvm/test/Analysis/StackSafetyAnalysis/ipa.ll

Removed: 




diff  --git a/clang/test/Driver/memtag_lto.c b/clang/test/Driver/memtag_lto.c
index 81a6f7b842e1..3421e4028db1 100644
--- a/clang/test/Driver/memtag_lto.c
+++ b/clang/test/Driver/memtag_lto.c
@@ -85,7 +85,7 @@
 // RUN:  -r %t.ltonewpm2.bc,use,plx \
 // RUN:  -r %t.ltonewpm2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XSAFE,YSAFE
 
-// FIXME: Thin LTO: both are safe.
+// Thin LTO: both are safe.
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c %s -flto=thin -o 
%t.thinlto1.bc
 // RUN: %clang -fno-experimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c -DBUILD2 %s 
-flto=thin -o %t.thinlto2.bc
 // RUN: llvm-lto2 run -o %t.thinlto %t.thinlto1.bc %t.thinlto2.bc -save-temps 
-stack-safety-print -thinlto-threads 1 -O1 \
@@ -94,9 +94,9 @@
 // RUN:  -r %t.thinlto1.bc,use_local,plx \
 // RUN:  -r %t.thinlto1.bc,w, \
 // RUN:  -r %t.thinlto2.bc,use,plx \
-// RUN:  -r %t.thinlto2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XUNSAFE,YSAFE
+// RUN:  -r %t.thinlto2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XSAFE,YSAFE
 
-// FIXME: Thin LTO, new PM: both are safe.
+// Thin LTO, new PM: both are safe.
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c %s -flto=thin -o 
%t.thinltonewpm1.bc
 // RUN: %clang -fexperimental-new-pass-manager -O1 -target 
aarch64-unknown-linux -march=armv8+memtag -fsanitize=memtag -c -DBUILD2 %s 
-flto=thin -o %t.thinltonewpm2.bc
 // RUN: llvm-lto2 run -use-new-pm -o %t.thinltonewpm %t.thinltonewpm1.bc 
%t.thinltonewpm2.bc -save-temps -stack-safety-print -thinlto-threads 1 -O1 \
@@ -105,7 +105,7 @@
 // RUN:  -r %t.thinltonewpm1.bc,use_local,plx \
 // RUN:  -r %t.thinltonewpm1.bc,w, \
 // RUN:  -r %t.thinltonewpm2.bc,use,plx \
-// RUN:  -r %t.thinltonewpm2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XUNSAFE,YSAFE
+// RUN:  -r %t.thinltonewpm2.bc,z, 2>&1 | FileCheck %s 
-check-prefixes=SSI,XSAFE,YSAFE
 
 void use(int *p);
 

diff  --git a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h 
b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
index 0b37decfccca..3ee520eb0411 100644
--- a/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
+++ b/llvm/include/llvm/Analysis/StackSafetyAnalysis.h
@@ -151,6 +151,8 @@ class StackSafetyGlobalInfoWrapperPass : public ModulePass {
 
 bool needsParamAccessSummary(const Module &M);
 
+void generateParamAccessSummary(ModuleSummaryIndex &Index);
+
 } // end namespace llvm
 
 #endif // LLVM_ANALYSIS_STACKSAFETYANALYSIS_H

diff  --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp 
b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 3fb5c294acf6..a59d564cd1cc 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -544,6 +544,22 @@ StackSafetyDataFlowAnalysis::run() {
   return Functions;
 }
 
+FunctionSummary *resolveCallee(GlobalValueSummary *S) {
+  while (S) {
+if (!S->isLive() || !S->isDSOLocal())
+  return nullptr;
+if (FunctionSummary *FS = dyn_cast(S))
+  return FS;
+AliasSummary *AS = dyn_cast(S);
+if (!AS)
+  return nullptr;
+S = AS->getBaseObject();
+if (S == AS)
+  return nullptr;
+  }
+  return nullptr;
+}
+
 const Function *findCalleeInModule(const GlobalValue *GV) {
   while (GV) {
 if (GV->isDeclaration() || GV->isInterposable() || !GV->isDSOLocal())
@@ -560,7 +576,28 @@ const Function *findCalleeInModule(const GlobalValue *GV) {
   return nullptr;
 }
 
-template  void resolveAllCalls(UseInfo &Use) {
+GlobalValueSummary *getGlobalValueSummary(const ModuleSummaryIndex *Index,
+  uint64_t ValueGUID) {
+  auto VI = Index->getValueInfo(ValueGUID);
+  if (!VI || VI.getSummaryList(

[clang] 04bd2c3 - [local-bounds] Ignore volatile operations

2020-05-05 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2020-05-05T23:08:08-07:00
New Revision: 04bd2c37caf48e79589dbccc486c6ad2541bec7a

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

LOG: [local-bounds] Ignore volatile operations

Summary:
-fsanitize=local-bounds is very similar to ``object-size`` and
should also ignore volatile pointers.
https://clang.llvm.org/docs/UndefinedBehaviorSanitizer.html#volatile

Reviewers: chandlerc, rsmith

Reviewed By: rsmith

Subscribers: cfe-commits, hiraditya, llvm-commits

Tags: #llvm, #clang

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

Added: 


Modified: 
clang/docs/UndefinedBehaviorSanitizer.rst
llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
llvm/test/Instrumentation/BoundsChecking/simple.ll

Removed: 




diff  --git a/clang/docs/UndefinedBehaviorSanitizer.rst 
b/clang/docs/UndefinedBehaviorSanitizer.rst
index 493b9478bdf3..0a27810150db 100644
--- a/clang/docs/UndefinedBehaviorSanitizer.rst
+++ b/clang/docs/UndefinedBehaviorSanitizer.rst
@@ -81,7 +81,9 @@ Available checks are:
  ``true`` nor ``false``.
   -  ``-fsanitize=builtin``: Passing invalid values to compiler builtins.
   -  ``-fsanitize=bounds``: Out of bounds array indexing, in cases
- where the array bound can be statically determined.
+ where the array bound can be statically determined. The check includes
+ ``-fsanitize=array-bounds`` and ``-fsanitize=local-bounds``. Note that
+ ``-fsanitize=local-bounds`` is not included in ``-fsanitize=undefined``.
   -  ``-fsanitize=enum``: Load of a value of an enumerated type which
  is not in the range of representable values for that enumerated
  type.
@@ -173,7 +175,8 @@ Available checks are:
 You can also use the following check groups:
   -  ``-fsanitize=undefined``: All of the checks listed above other than
  ``float-divide-by-zero``, ``unsigned-integer-overflow``,
- ``implicit-conversion``, and the ``nullability-*`` group of checks.
+ ``implicit-conversion``, ``local-bounds`` and the ``nullability-*`` group
+ of checks.
   -  ``-fsanitize=undefined-trap``: Deprecated alias of
  ``-fsanitize=undefined``.
   -  ``-fsanitize=implicit-integer-truncation``: Catches lossy integral
@@ -202,7 +205,7 @@ You can also use the following check groups:
 Volatile
 
 
-The ``null``, ``alignment``, ``object-size``, and ``vptr`` checks do not apply
+The ``null``, ``alignment``, ``object-size``, ``local-bounds``, and ``vptr`` 
checks do not apply
 to pointers to types with the ``volatile`` qualifier.
 
 Minimal Runtime

diff  --git a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp 
b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
index 3e7ebe54a00c..efb11b68a1e3 100644
--- a/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
+++ b/llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp
@@ -154,17 +154,22 @@ static bool addBoundsChecking(Function &F, 
TargetLibraryInfo &TLI,
 Value *Or = nullptr;
 BuilderTy IRB(I.getParent(), BasicBlock::iterator(&I), TargetFolder(DL));
 if (LoadInst *LI = dyn_cast(&I)) {
-  Or = getBoundsCheckCond(LI->getPointerOperand(), LI, DL, TLI,
-  ObjSizeEval, IRB, SE);
+  if (!LI->isVolatile())
+Or = getBoundsCheckCond(LI->getPointerOperand(), LI, DL, TLI,
+ObjSizeEval, IRB, SE);
 } else if (StoreInst *SI = dyn_cast(&I)) {
-  Or = getBoundsCheckCond(SI->getPointerOperand(), SI->getValueOperand(),
-  DL, TLI, ObjSizeEval, IRB, SE);
+  if (!SI->isVolatile())
+Or = getBoundsCheckCond(SI->getPointerOperand(), SI->getValueOperand(),
+DL, TLI, ObjSizeEval, IRB, SE);
 } else if (AtomicCmpXchgInst *AI = dyn_cast(&I)) {
-  Or = getBoundsCheckCond(AI->getPointerOperand(), AI->getCompareOperand(),
-  DL, TLI, ObjSizeEval, IRB, SE);
+  if (!AI->isVolatile())
+Or =
+getBoundsCheckCond(AI->getPointerOperand(), 
AI->getCompareOperand(),
+   DL, TLI, ObjSizeEval, IRB, SE);
 } else if (AtomicRMWInst *AI = dyn_cast(&I)) {
-  Or = getBoundsCheckCond(AI->getPointerOperand(), AI->getValOperand(), DL,
-  TLI, ObjSizeEval, IRB, SE);
+  if (!AI->isVolatile())
+Or = getBoundsCheckCond(AI->getPointerOperand(), AI->getValOperand(),
+DL, TLI, ObjSizeEval, IRB, SE);
 }
 if (Or)
   TrapInfo.push_back(std::make_pair(&I, Or));

diff  --git a/llvm/test/Instrumentation/BoundsChecking/simple.ll 
b/llvm/test/Instrumentation/BoundsChecking/simple.ll
index db1e1eeb0006..c95bfbdd4fe9 100644
--- a/llvm/test/Instrumentation/BoundsChecking/simple.ll
++

Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-19 Thread Vitaly Buka via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added a comment.

The patch was split in two and I moved the test into the wrong one. I'll fix 
this.


https://reviews.llvm.org/D24693



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


Re: [PATCH] D24695: [CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

2016-09-19 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 71856.
vitalybuka added a comment.

Removed unrelated test


https://reviews.llvm.org/D24695

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
-
-extern int bar(char *A, int n);
-
-// O0-NOT: @llvm.lifetime.start
-int foo (int n) {
-  if (n) {
-// O2: @llvm.lifetime.start
-char A[100];
-return bar(A, 1);
-  } else {
-// O2: @llvm.lifetime.start
-char A[100];
-return bar(A, 2);
-  }
-}
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1175,6 +1175,9 @@
   llvm::BasicBlock *TerminateHandler;
   llvm::BasicBlock *TrapBB;
 
+  /// True if we need emit the life-time markers.
+  const bool ShouldEmitLifetimeMarkers;
+
   /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
   /// In the kernel metadata node, reference the kernel function and metadata 
   /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -37,29 +37,46 @@
 using namespace clang;
 using namespace CodeGen;
 
+/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
+/// markers.
+static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
+  const LangOptions &LangOpts) {
+  // Asan uses markers for use-after-scope checks.
+  if (CGOpts.SanitizeAddressUseAfterScope)
+return true;
+
+  // Disable lifetime markers in msan builds.
+  // FIXME: Remove this when msan works with lifetime markers.
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+return false;
+
+  // For now, only in optimized builds.
+  return CGOpts.OptimizationLevel != 0;
+}
+
 CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
 : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()),
   Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
   CGBuilderInserterTy(this)),
   CurFn(nullptr), ReturnValue(Address::invalid()),
-  CapturedStmtInfo(nullptr),
-  SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
-  CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
-  IsOutlinedSEHHelper(false),
-  BlockInfo(nullptr), BlockPointer(nullptr),
-  LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
-  NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
-  ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
-  DebugInfo(CGM.getModuleDebugInfo()),
+  CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
+  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
+  SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
+  BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
+  NormalCleanupDest(nullptr), NextCleanupDestIndex(1),
+  FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr),
+  EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr),
   PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
   NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
   CXXABIThisValue(nullptr), CXXThisValue(nullptr),
   CXXStructorImplicitParamDecl(nullptr),
   CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr),
   CurLexicalScope(nullptr), TerminateLandingPad(nullptr),
-  TerminateHandler(nullptr), TrapBB(nullptr) {
+  TerminateHandler(nullptr), TrapBB(nullptr),
+  ShouldEmitLifetimeMarkers(
+  shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), CGM.getLangOpts())) {
   if (!suppressNewContext)
 CGM.getCXXABI().getMangleContext().startNewFunction();
 
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -916,29 +916,12 @@
   EmitAutoVarCleanups(emission);
 }
 
-/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
-/// markers.
-static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
-  const LangOptions &LangOpts) {
-  // Asan uses markers for use-after-scope checks.
-  if (CGOpts.SanitizeAddressUseAfterScope)
-return true;

Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-19 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 71858.
vitalybuka added a comment.

recovered test


https://reviews.llvm.org/D24693

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- /dev/null
+++ test/CodeGen/lifetime2.c
@@ -0,0 +1,81 @@
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @foo
+// O0-NOT: @llvm.lifetime.start
+int foo (int n) {
+  if (n) {
+// O2: @llvm.lifetime.start
+char A[100];
+return bar(A, 1);
+  } else {
+// O2: @llvm.lifetime.start
+char A[100];
+return bar(A, 2);
+  }
+}
+
+// CHECK-LABEL: @no_goto_bypass
+void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 1
+  char x;
+l1:
+  bar(&x, 1);
+  // O2: @llvm.lifetime.start(i64 5
+  // O2: @llvm.lifetime.end(i64 5
+  char y[5];
+  bar(y, 5);
+  goto l1;
+  // Infinite loop
+  // O2-NOT: @llvm.lifetime.end(i64 1
+}
+
+// CHECK-LABEL: @goto_bypass
+void goto_bypass() {
+  {
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+  l1:
+bar(&x, 1);
+  }
+  goto l1;
+}
+
+// CHECK-LABEL: @no_switch_bypass
+void no_switch_bypass(int n) {
+  switch (n) {
+  case 1: {
+// O2: @llvm.lifetime.start(i64 1
+// O2: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: @llvm.lifetime.start(i64 5
+// O2: @llvm.lifetime.end(i64 5
+char y[5];
+bar(y, 5);
+break;
+  }
+}
+
+// CHECK-LABEL: @switch_bypass
+void switch_bypass(int n) {
+  switch (n) {
+  case 1:
+n = n;
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
Index: lib/CodeGen/VarBypassDetector.h
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,67 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// VarBypassDetector - This class detects jumps which bypass local variables
+/// declaration:
+///goto L;
+///int a;
+///  L:
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+///  * FIXME: Does not support indirect jumps.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // Lookup map to file scope for jumps and its destinations.
+  llvm::DenseMap LabelAndGotoScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// IsBypassed - Returns true if the variable declaration was by bypassed by
+  /// any goto or switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  void BuildScopeInformation(const Decl *D, unsigned &ParentScope);
+  void BuildScopeInformation(const Stmt *S, unsigned &origParentScope);
+  void Detect();
+  void Detect(const Stmt *FromStmt, const Stmt *ToStmt);
+};
+}
+}
+
+#endif
Index: lib/CodeGen/VarBypassDetector.cpp
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,154 @@
+//===--- VarBypassDetector.h - Bypass jumps detector --*- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#

Re: [PATCH] D24695: [CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

2016-09-19 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 71860.
vitalybuka added a comment.

Fixed accidentally changed test


https://reviews.llvm.org/D24695

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1175,6 +1175,9 @@
   llvm::BasicBlock *TerminateHandler;
   llvm::BasicBlock *TrapBB;
 
+  /// True if we need emit the life-time markers.
+  const bool ShouldEmitLifetimeMarkers;
+
   /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
   /// In the kernel metadata node, reference the kernel function and metadata 
   /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -37,29 +37,46 @@
 using namespace clang;
 using namespace CodeGen;
 
+/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
+/// markers.
+static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
+  const LangOptions &LangOpts) {
+  // Asan uses markers for use-after-scope checks.
+  if (CGOpts.SanitizeAddressUseAfterScope)
+return true;
+
+  // Disable lifetime markers in msan builds.
+  // FIXME: Remove this when msan works with lifetime markers.
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+return false;
+
+  // For now, only in optimized builds.
+  return CGOpts.OptimizationLevel != 0;
+}
+
 CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
 : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()),
   Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
   CGBuilderInserterTy(this)),
   CurFn(nullptr), ReturnValue(Address::invalid()),
-  CapturedStmtInfo(nullptr),
-  SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
-  CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
-  IsOutlinedSEHHelper(false),
-  BlockInfo(nullptr), BlockPointer(nullptr),
-  LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
-  NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
-  ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
-  DebugInfo(CGM.getModuleDebugInfo()),
+  CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
+  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
+  SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
+  BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
+  NormalCleanupDest(nullptr), NextCleanupDestIndex(1),
+  FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr),
+  EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr),
   PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
   NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
   CXXABIThisValue(nullptr), CXXThisValue(nullptr),
   CXXStructorImplicitParamDecl(nullptr),
   CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr),
   CurLexicalScope(nullptr), TerminateLandingPad(nullptr),
-  TerminateHandler(nullptr), TrapBB(nullptr) {
+  TerminateHandler(nullptr), TrapBB(nullptr),
+  ShouldEmitLifetimeMarkers(
+  shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), CGM.getLangOpts())) {
   if (!suppressNewContext)
 CGM.getCXXABI().getMangleContext().startNewFunction();
 
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -916,29 +916,12 @@
   EmitAutoVarCleanups(emission);
 }
 
-/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
-/// markers.
-static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
-  const LangOptions &LangOpts) {
-  // Asan uses markers for use-after-scope checks.
-  if (CGOpts.SanitizeAddressUseAfterScope)
-return true;
-
-  // Disable lifetime markers in msan builds.
-  // FIXME: Remove this when msan works with lifetime markers.
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
-return false;
-
-  // For now, only in optimized builds.
-  return CGOpts.OptimizationLevel != 0;
-}
-
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
 llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
 llvm::Value *Addr) {
-  if (!shouldEm

Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-19 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 71862.
vitalybuka added a comment.

Test


https://reviews.llvm.org/D24693

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,8 +1,9 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
 
+// CHECK-LABEL: @foo
 // O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
@@ -15,3 +16,66 @@
 return bar(A, 2);
   }
 }
+
+// CHECK-LABEL: @no_goto_bypass
+void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 1
+  char x;
+l1:
+  bar(&x, 1);
+  // O2: @llvm.lifetime.start(i64 5
+  // O2: @llvm.lifetime.end(i64 5
+  char y[5];
+  bar(y, 5);
+  goto l1;
+  // Infinite loop
+  // O2-NOT: @llvm.lifetime.end(i64 1
+}
+
+// CHECK-LABEL: @goto_bypass
+void goto_bypass() {
+  {
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+  l1:
+bar(&x, 1);
+  }
+  goto l1;
+}
+
+// CHECK-LABEL: @no_switch_bypass
+void no_switch_bypass(int n) {
+  switch (n) {
+  case 1: {
+// O2: @llvm.lifetime.start(i64 1
+// O2: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: @llvm.lifetime.start(i64 5
+// O2: @llvm.lifetime.end(i64 5
+char y[5];
+bar(y, 5);
+break;
+  }
+}
+
+// CHECK-LABEL: @switch_bypass
+void switch_bypass(int n) {
+  switch (n) {
+  case 1:
+n = n;
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
Index: lib/CodeGen/VarBypassDetector.h
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,67 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// VarBypassDetector - This class detects jumps which bypass local variables
+/// declaration:
+///goto L;
+///int a;
+///  L:
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+///  * FIXME: Does not support indirect jumps.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // Lookup map to file scope for jumps and its destinations.
+  llvm::DenseMap LabelAndGotoScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// IsBypassed - Returns true if the variable declaration was by bypassed by
+  /// any goto or switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  void BuildScopeInformation(const Decl *D, unsigned &ParentScope);
+  void BuildScopeInformation(const Stmt *S, unsigned &origParentScope);
+  void Detect();
+  void Detect(const Stmt *FromStmt, const Stmt *ToStmt);
+};
+}
+}
+
+#endif
Index: lib/CodeGen/VarBypassDetector.cpp
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,154 @@
+//===--- VarBypassDetector.h - Bypass jumps detector --*- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--

Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-21 Thread Vitaly Buka via cfe-commits
Intrinsics are invalid there, code is generated in such way that variable
is being accessed after lifetime.end.
I suspect that optimizer can make invalid code because of this, but I can't
reproduce.
So I think it's safer to remove them at all and don't wait for miscompile
reports.

Still if performance is greater concern then potential miscompiles, I can
limit this only to asan-use-after-scope.



On Wed, Sep 21, 2016 at 8:49 AM Akira Hatanaka  wrote:

> ahatanak added a comment.
>
> Do we want to remove lifetime intrinsics when we aren't doing the
> asan-use-after-scope check? Since this isn't a mis-compile caused by
> inaccurate lifetime intrinsics, I was wondering whether we should do this
> only when asan-use-after-scope is on to minimize the impact on compile time.
>
>
> https://reviews.llvm.org/D24693
>
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-21 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Intrinsics are invalid there, code is generated in such way that variable is 
being accessed after lifetime.end.
I suspect that optimizer can make invalid code because of this, but I can't 
reproduce.
So I think it's safer to remove them at all and don't wait for miscompile 
reports.

Still if performance is greater concern than potential miscompiles, I can limit 
this only to asan-use-after-scope.


https://reviews.llvm.org/D24693



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


Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-21 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Miscompile.
Here assert fails without the patch.

int* p1;
int* p2;

int use2() {

  assert(p1 != p2 || !"reuse");
  return p1 == p2;

}

void f3(int cond) {

  {
int tmp[1024];
p1 = tmp;
goto l2;
  l1:
int tmp2[1024];
p2 = tmp2;
exit(use2());
  }

l2:

  goto l1;

}


https://reviews.llvm.org/D24693



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


Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-23 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

In https://reviews.llvm.org/D24693#550119, @ahatanak wrote:

> Thank you for the great example! I can now see this patch does fix 
> mis-compiles.
>
> There are probably other lifetime bugs you'll see when the code being 
> compiled includes gotos that jump past variable declarations, including the 
> one here: http://lists.llvm.org/pipermail/cfe-dev/2016-July/050066.html. Do 
> you think you can extend the approach taken in this patch to prevent 
> mis-compiles for those too?


This probably can be extended to this case, but I'd prefer to do this in 
separate patch later.

> Also, rather than removing the intrinsics altogether, have you considered 
> making changes to IRGen to insert them to different locations or insert extra 
> lifetime.starts?


I can see how to insert starts, e.g. on every label which bypass declaration, 
but I am not sure where to put ends.
Probably it's possible, but patch will be significantly more complicated. I'd 
prefer to do so only when needed.
This is infrequent usecase, so it's probably not worth of additional complexity.


https://reviews.llvm.org/D24693



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


Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-26 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

My assumption is that "start" makes access valid, and "end" makes access 
invalid, up to the next "start".
I see no problems problems with loops and multiple regions, as soon as access 
is happening between start and end. Loops always call "start" for nested alloca 
on each iteration and call "end" on iteration cleanup. For multiple starts I 
assume that variable is accessible right after the first start, and invalid 
after the first "end".
I see no cases other then this "goto" issues where clang behaves differently.

This patch addresses issues were the last intrinsic before access was "end":
call start, ... call end, ...access
or only the end: entry, ... call end, ... access


https://reviews.llvm.org/D24693



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


Re: [PATCH] D24695: [CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

2016-09-28 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 72907.
vitalybuka added a comment.
Herald added subscribers: mgorny, beanz.

rebase


https://reviews.llvm.org/D24695

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,8 +1,9 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
 
+// CHECK-LABEL: @foo
 // O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
@@ -15,3 +16,66 @@
 return bar(A, 2);
   }
 }
+
+// CHECK-LABEL: @no_goto_bypass
+void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 1
+  char x;
+l1:
+  bar(&x, 1);
+  // O2: @llvm.lifetime.start(i64 5
+  // O2: @llvm.lifetime.end(i64 5
+  char y[5];
+  bar(y, 5);
+  goto l1;
+  // Infinite loop
+  // O2-NOT: @llvm.lifetime.end(i64 1
+}
+
+// CHECK-LABEL: @goto_bypass
+void goto_bypass() {
+  {
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+  l1:
+bar(&x, 1);
+  }
+  goto l1;
+}
+
+// CHECK-LABEL: @no_switch_bypass
+void no_switch_bypass(int n) {
+  switch (n) {
+  case 1: {
+// O2: @llvm.lifetime.start(i64 1
+// O2: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: @llvm.lifetime.start(i64 5
+// O2: @llvm.lifetime.end(i64 5
+char y[5];
+bar(y, 5);
+break;
+  }
+}
+
+// CHECK-LABEL: @switch_bypass
+void switch_bypass(int n) {
+  switch (n) {
+  case 1:
+n = n;
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
Index: lib/CodeGen/VarBypassDetector.h
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,67 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// VarBypassDetector - This class detects jumps which bypass local variables
+/// declaration:
+///goto L;
+///int a;
+///  L:
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+///  * FIXME: Does not support indirect jumps.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // Lookup map to file scope for jumps and its destinations.
+  llvm::DenseMap LabelAndGotoScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// IsBypassed - Returns true if the variable declaration was by bypassed by
+  /// any goto or switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  void BuildScopeInformation(const Decl *D, unsigned &ParentScope);
+  void BuildScopeInformation(const Stmt *S, unsigned &origParentScope);
+  void Detect();
+  void Detect(const Stmt *FromStmt, const Stmt *ToStmt);
+};
+}
+}
+
+#endif
Index: lib/CodeGen/VarBypassDetector.cpp
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,154 @@
+//===--- VarBypassDetector.h - Bypass jumps detector --*- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+

Re: [PATCH] D24695: [CodeGen] Move shouldEmitLifetimeMarkers into more convenient place

2016-09-28 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 72908.
vitalybuka added a comment.

rebase


https://reviews.llvm.org/D24695

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1175,6 +1175,9 @@
   llvm::BasicBlock *TerminateHandler;
   llvm::BasicBlock *TrapBB;
 
+  /// True if we need emit the life-time markers.
+  const bool ShouldEmitLifetimeMarkers;
+
   /// Add a kernel metadata node to the named metadata node 'opencl.kernels'.
   /// In the kernel metadata node, reference the kernel function and metadata 
   /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2):
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -38,29 +38,46 @@
 using namespace clang;
 using namespace CodeGen;
 
+/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
+/// markers.
+static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
+  const LangOptions &LangOpts) {
+  // Asan uses markers for use-after-scope checks.
+  if (CGOpts.SanitizeAddressUseAfterScope)
+return true;
+
+  // Disable lifetime markers in msan builds.
+  // FIXME: Remove this when msan works with lifetime markers.
+  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
+return false;
+
+  // For now, only in optimized builds.
+  return CGOpts.OptimizationLevel != 0;
+}
+
 CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
 : CodeGenTypeCache(cgm), CGM(cgm), Target(cgm.getTarget()),
   Builder(cgm, cgm.getModule().getContext(), llvm::ConstantFolder(),
   CGBuilderInserterTy(this)),
   CurFn(nullptr), ReturnValue(Address::invalid()),
-  CapturedStmtInfo(nullptr),
-  SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
-  CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
-  IsOutlinedSEHHelper(false),
-  BlockInfo(nullptr), BlockPointer(nullptr),
-  LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
-  NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
-  ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
-  DebugInfo(CGM.getModuleDebugInfo()),
+  CapturedStmtInfo(nullptr), SanOpts(CGM.getLangOpts().Sanitize),
+  IsSanitizerScope(false), CurFuncIsThunk(false), AutoreleaseResult(false),
+  SawAsmBlock(false), IsOutlinedSEHHelper(false), BlockInfo(nullptr),
+  BlockPointer(nullptr), LambdaThisCaptureField(nullptr),
+  NormalCleanupDest(nullptr), NextCleanupDestIndex(1),
+  FirstBlockInfo(nullptr), EHResumeBlock(nullptr), ExceptionSlot(nullptr),
+  EHSelectorSlot(nullptr), DebugInfo(CGM.getModuleDebugInfo()),
   DisableDebugInfo(false), DidCallStackSave(false), IndirectBranch(nullptr),
   PGO(cgm), SwitchInsn(nullptr), SwitchWeights(nullptr),
   CaseRangeBlock(nullptr), UnreachableBlock(nullptr), NumReturnExprs(0),
   NumSimpleReturnExprs(0), CXXABIThisDecl(nullptr),
   CXXABIThisValue(nullptr), CXXThisValue(nullptr),
   CXXStructorImplicitParamDecl(nullptr),
   CXXStructorImplicitParamValue(nullptr), OutermostConditional(nullptr),
   CurLexicalScope(nullptr), TerminateLandingPad(nullptr),
-  TerminateHandler(nullptr), TrapBB(nullptr) {
+  TerminateHandler(nullptr), TrapBB(nullptr),
+  ShouldEmitLifetimeMarkers(
+  shouldEmitLifetimeMarkers(CGM.getCodeGenOpts(), CGM.getLangOpts())) {
   if (!suppressNewContext)
 CGM.getCXXABI().getMangleContext().startNewFunction();
 
Index: lib/CodeGen/CGDecl.cpp
===
--- lib/CodeGen/CGDecl.cpp
+++ lib/CodeGen/CGDecl.cpp
@@ -916,29 +916,12 @@
   EmitAutoVarCleanups(emission);
 }
 
-/// shouldEmitLifetimeMarkers - Decide whether we need emit the life-time
-/// markers.
-static bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts,
-  const LangOptions &LangOpts) {
-  // Asan uses markers for use-after-scope checks.
-  if (CGOpts.SanitizeAddressUseAfterScope)
-return true;
-
-  // Disable lifetime markers in msan builds.
-  // FIXME: Remove this when msan works with lifetime markers.
-  if (LangOpts.Sanitize.has(SanitizerKind::Memory))
-return false;
-
-  // For now, only in optimized builds.
-  return CGOpts.OptimizationLevel != 0;
-}
-
 /// Emit a lifetime.begin marker if some criteria are satisfied.
 /// \return a pointer to the temporary size Value if a marker was emitted, null
 /// otherwise
 llvm::Value *CodeGenFunction::EmitLifetimeStart(uint64_t Size,
 llvm::Value *Addr) {
-  if (!shouldEmitLifetimeMarkers(CGM.get

Re: [PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-09-28 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 72909.
vitalybuka added a comment.

rebase


https://reviews.llvm.org/D24693

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,8 +1,9 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
 
+// CHECK-LABEL: @foo
 // O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
@@ -15,3 +16,66 @@
 return bar(A, 2);
   }
 }
+
+// CHECK-LABEL: @no_goto_bypass
+void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 1
+  char x;
+l1:
+  bar(&x, 1);
+  // O2: @llvm.lifetime.start(i64 5
+  // O2: @llvm.lifetime.end(i64 5
+  char y[5];
+  bar(y, 5);
+  goto l1;
+  // Infinite loop
+  // O2-NOT: @llvm.lifetime.end(i64 1
+}
+
+// CHECK-LABEL: @goto_bypass
+void goto_bypass() {
+  {
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+  l1:
+bar(&x, 1);
+  }
+  goto l1;
+}
+
+// CHECK-LABEL: @no_switch_bypass
+void no_switch_bypass(int n) {
+  switch (n) {
+  case 1: {
+// O2: @llvm.lifetime.start(i64 1
+// O2: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: @llvm.lifetime.start(i64 5
+// O2: @llvm.lifetime.end(i64 5
+char y[5];
+bar(y, 5);
+break;
+  }
+}
+
+// CHECK-LABEL: @switch_bypass
+void switch_bypass(int n) {
+  switch (n) {
+  case 1:
+n = n;
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
Index: lib/CodeGen/VarBypassDetector.h
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,67 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// VarBypassDetector - This class detects jumps which bypass local variables
+/// declaration:
+///goto L;
+///int a;
+///  L:
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+///  * FIXME: Does not support indirect jumps.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // Lookup map to file scope for jumps and its destinations.
+  llvm::DenseMap LabelAndGotoScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// IsBypassed - Returns true if the variable declaration was by bypassed by
+  /// any goto or switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  void BuildScopeInformation(const Decl *D, unsigned &ParentScope);
+  void BuildScopeInformation(const Stmt *S, unsigned &origParentScope);
+  void Detect();
+  void Detect(const Stmt *FromStmt, const Stmt *ToStmt);
+};
+}
+}
+
+#endif
Index: lib/CodeGen/VarBypassDetector.cpp
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,154 @@
+//===--- VarBypassDetector.h - Bypass jumps detector --*- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===

Re: r283092 - [analyzer] Extend bug reports with extra notes

2016-10-03 Thread Vitaly Buka via cfe-commits
This patch breaks Windows:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/29769/

On Mon, Oct 3, 2016 at 1:07 AM Artem Dergachev via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: dergachev
> Date: Mon Oct  3 02:58:26 2016
> New Revision: 283092
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283092&view=rev
> Log:
> [analyzer] Extend bug reports with extra notes
>
> These diagnostics are separate from the path-sensitive engine's path notes,
> and can be added manually on top of path-sensitive or path-insensitive
> reports.
>
> The new note diagnostics would appear as note:-diagnostic on console and
> as blue bubbles in scan-build. In plist files they currently do not appear,
> because format needs to be discussed with plist file users.
>
> The analyzer option "-analyzer-config notes-as-events=true" would convert
> notes to normal path notes, and put them at the beginning of the path.
> This is a temporary hack to show the new notes in plist files.
>
> A few checkers would be updated in subsequent commits,
> including tests for this new feature.
>
> Differential Revision: https://reviews.llvm.org/D24278
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
>
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
> cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
> cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=283092&r1=283091&r2=283092&view=diff
>
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Mon Oct
> 3 02:58:26 2016
> @@ -266,6 +266,9 @@ private:
>/// \sa shouldWidenLoops
>Optional WidenLoops;
>
> +  /// \sa shouldDisplayNotesAsEvents
> +  Optional DisplayNotesAsEvents;
> +
>/// A helper function that retrieves option for a given full-qualified
>/// checker name.
>/// Options for checkers can be specified via 'analyzer-config'
> command-line
> @@ -534,6 +537,14 @@ public:
>/// This is controlled by the 'widen-loops' config option.
>bool shouldWidenLoops();
>
> +  /// Returns true if the bug reporter should transparently treat extra
> note
> +  /// diagnostic pieces as event diagnostic pieces. Useful when the
> diagnostic
> +  /// consumer doesn't support the extra note pieces.
> +  ///
> +  /// This is controlled by the 'notes-as-events' option, which defaults
> +  /// to false when unset.
> +  bool shouldDisplayNotesAsEvents();
> +
>  public:
>AnalyzerOptions() :
>  AnalysisStoreOpt(RegionStoreModel),
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=283092&r1=283091&r2=283092&view=diff
>
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> Mon Oct  3 02:58:26 2016
> @@ -66,6 +66,8 @@ public:
>typedef SmallVector, 8> VisitorList;
>typedef VisitorList::iterator visitor_iterator;
>typedef SmallVector ExtraTextList;
> +  typedef SmallVector,
> 4>
> +  NoteList;
>
>  protected:
>friend class BugReporter;
> @@ -82,7 +84,8 @@ protected:
>const ExplodedNode *ErrorNode;
>SmallVector Ranges;
>ExtraTextList ExtraText;
> -
> +  NoteList Notes;
> +
>typedef llvm::DenseSet Symbols;
>typedef llvm::DenseSet Regions;
>
> @@ -177,6 +180,18 @@ public:
>const BugType& getBugType() const { return BT; }
>BugType& getBugType() { return BT; }
>
> +  /// \brief True when the report has an execution path associated with
> it.
> +  ///
> +  /// A report is said to be path-sensitive if it was thrown against a
> +  /// particular exploded node in the path-sensitive analysis graph.
> +  /// Path-sensitive reports have their intermediate path diagnostics
> +  /// auto-generated, perhaps with the help of checker-defined visitors,
> +  /// and may contain extra notes.
> +  /// Path-insensitive reports consist only of a single warning message
> +  /// in a specific location, and perhaps extra notes.
> +  /// Path-sensitive checkers are allowed to throw path-insensitive
> reports.
> +  bool isPathSen

Re: r283092 - [analyzer] Extend bug reports with extra notes

2016-10-03 Thread Vitaly Buka via cfe-commits
I will look into this and get back to you.

On Mon, Oct 3, 2016 at 12:12 PM Artem Dergachev  wrote:

> > fatal error C1001: An internal error has occurred in the compiler.
>
> Ouch. So i managed to *crash* the microsoft compiler with my code?
>
> Could you please somehow have a look if this is reproducible? If it's
> reproducible or hard-to-check-if-reproducible then i'd revert.
>
> I don't think i can debug this, as i don't have windows, and i have no
> guesses from looking at the code.
>
> Also, should i have received an email for this failure? Cause i haven't
> received an email for this failure. Hope there aren't more failures.
>
>
>
> 03/10/2016 21:46, Vitaly Buka via cfe-commits пишет:
>
> This patch breaks Windows:
> http://lab.llvm.org:8011/builders/sanitizer-windows/builds/29769/
>
> On Mon, Oct 3, 2016 at 1:07 AM Artem Dergachev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: dergachev
> Date: Mon Oct  3 02:58:26 2016
> New Revision: 283092
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283092&view=rev
> Log:
> [analyzer] Extend bug reports with extra notes
>
> These diagnostics are separate from the path-sensitive engine's path notes,
> and can be added manually on top of path-sensitive or path-insensitive
> reports.
>
> The new note diagnostics would appear as note:-diagnostic on console and
> as blue bubbles in scan-build. In plist files they currently do not appear,
> because format needs to be discussed with plist file users.
>
> The analyzer option "-analyzer-config notes-as-events=true" would convert
> notes to normal path notes, and put them at the beginning of the path.
> This is a temporary hack to show the new notes in plist files.
>
> A few checkers would be updated in subsequent commits,
> including tests for this new feature.
>
> Differential Revision: https://reviews.llvm.org/D24278
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
>
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
> cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
> cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=283092&r1=283091&r2=283092&view=diff
>
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Mon Oct
> 3 02:58:26 2016
> @@ -266,6 +266,9 @@ private:
>/// \sa shouldWidenLoops
>Optional WidenLoops;
>
> +  /// \sa shouldDisplayNotesAsEvents
> +  Optional DisplayNotesAsEvents;
> +
>/// A helper function that retrieves option for a given full-qualified
>/// checker name.
>/// Options for checkers can be specified via 'analyzer-config'
> command-line
> @@ -534,6 +537,14 @@ public:
>/// This is controlled by the 'widen-loops' config option.
>bool shouldWidenLoops();
>
> +  /// Returns true if the bug reporter should transparently treat extra
> note
> +  /// diagnostic pieces as event diagnostic pieces. Useful when the
> diagnostic
> +  /// consumer doesn't support the extra note pieces.
> +  ///
> +  /// This is controlled by the 'notes-as-events' option, which defaults
> +  /// to false when unset.
> +  bool shouldDisplayNotesAsEvents();
> +
>  public:
>AnalyzerOptions() :
>  AnalysisStoreOpt(RegionStoreModel),
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=283092&r1=283091&r2=283092&view=diff
>
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> Mon Oct  3 02:58:26 2016
> @@ -66,6 +66,8 @@ public:
>typedef SmallVector, 8> VisitorList;
>typedef VisitorList::iter

Re: r283092 - [analyzer] Extend bug reports with extra notes

2016-10-03 Thread Vitaly Buka via cfe-commits
Can't reproduce on my Windows.

On Mon, Oct 3, 2016 at 1:31 PM Artem Dergachev  wrote:

> I also made a quick blind guess at r283141 (
> http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20161003/172390.html
> )
>
> Thanks a lot for trying to help, sorry for causing problems.
>
> 03/10/2016 23:26, Vitaly Buka пишет:
>
> I will look into this and get back to you.
>
> On Mon, Oct 3, 2016 at 12:12 PM Artem Dergachev 
> wrote:
>
> > fatal error C1001: An internal error has occurred in the compiler.
>
> Ouch. So i managed to *crash* the microsoft compiler with my code?
>
> Could you please somehow have a look if this is reproducible? If it's
> reproducible or hard-to-check-if-reproducible then i'd revert.
>
> I don't think i can debug this, as i don't have windows, and i have no
> guesses from looking at the code.
>
> Also, should i have received an email for this failure? Cause i haven't
> received an email for this failure. Hope there aren't more failures.
>
>
>
> 03/10/2016 21:46, Vitaly Buka via cfe-commits пишет:
>
> This patch breaks Windows:
> http://lab.llvm.org:8011/builders/sanitizer-windows/builds/29769/
>
> On Mon, Oct 3, 2016 at 1:07 AM Artem Dergachev via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: dergachev
> Date: Mon Oct  3 02:58:26 2016
> New Revision: 283092
>
> URL: http://llvm.org/viewvc/llvm-project?rev=283092&view=rev
> Log:
> [analyzer] Extend bug reports with extra notes
>
> These diagnostics are separate from the path-sensitive engine's path notes,
> and can be added manually on top of path-sensitive or path-insensitive
> reports.
>
> The new note diagnostics would appear as note:-diagnostic on console and
> as blue bubbles in scan-build. In plist files they currently do not appear,
> because format needs to be discussed with plist file users.
>
> The analyzer option "-analyzer-config notes-as-events=true" would convert
> notes to normal path notes, and put them at the beginning of the path.
> This is a temporary hack to show the new notes in plist files.
>
> A few checkers would be updated in subsequent commits,
> including tests for this new feature.
>
> Differential Revision: https://reviews.llvm.org/D24278
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
>
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
> cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
> cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=283092&r1=283091&r2=283092&view=diff
>
> ==
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
> (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Mon Oct
> 3 02:58:26 2016
> @@ -266,6 +266,9 @@ private:
>/// \sa shouldWidenLoops
>Optional WidenLoops;
>
> +  /// \sa shouldDisplayNotesAsEvents
> +  Optional DisplayNotesAsEvents;
> +
>/// A helper function that retrieves option for a given full-qualified
>/// checker name.
>/// Options for checkers can be specified via 'analyzer-config'
> command-line
> @@ -534,6 +537,14 @@ public:
>/// This is controlled by the 'widen-loops' config option.
>bool shouldWidenLoops();
>
> +  /// Returns true if the bug reporter should transparently treat extra
> note
> +  /// diagnostic pieces as event diagnostic pieces. Useful when the
> diagnostic
> +  /// consumer doesn't support the extra note pieces.
> +  ///
> +  /// This is controlled by the 'notes-as-events' option, which defaults
> +  /// to false when unset.
> +  bool shouldDisplayNotesAsEvents();
> +
>  public:
>AnalyzerOptions() :
>  AnalysisStoreOpt(RegionStoreModel),
>
> Modified:
> cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=283092&r1=283091&r2=283092&view=diff
>
> ==

r283179 - Revert "[analyzer] A blind attempt to fix a buildbot" as it does not help.

2016-10-03 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Oct  3 21:19:12 2016
New Revision: 283179

URL: http://llvm.org/viewvc/llvm-project?rev=283179&view=rev
Log:
Revert "[analyzer] A blind attempt to fix a buildbot" as it does not help.

This reverts commit r283141.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=283179&r1=283178&r2=283179&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Mon 
Oct  3 21:19:12 2016
@@ -66,7 +66,7 @@ public:
   typedef SmallVector, 8> VisitorList;
   typedef VisitorList::iterator visitor_iterator;
   typedef SmallVector ExtraTextList;
-  typedef std::vector>
+  typedef SmallVector, 4>
   NoteList;
 
 protected:


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


r283180 - Revert "[analyzer] Extend bug reports with extra notes" to fix Windows bot.

2016-10-03 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Oct  3 21:19:17 2016
New Revision: 283180

URL: http://llvm.org/viewvc/llvm-project?rev=283180&view=rev
Log:
Revert "[analyzer] Extend bug reports with extra notes" to fix Windows bot.

This reverts commit r283092.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/PathDiagnostic.h
cfe/trunk/lib/Rewrite/HTMLRewrite.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
cfe/trunk/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PathDiagnostic.cpp
cfe/trunk/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=283180&r1=283179&r2=283180&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Mon Oct  3 
21:19:17 2016
@@ -266,9 +266,6 @@ private:
   /// \sa shouldWidenLoops
   Optional WidenLoops;
 
-  /// \sa shouldDisplayNotesAsEvents
-  Optional DisplayNotesAsEvents;
-
   /// A helper function that retrieves option for a given full-qualified
   /// checker name.
   /// Options for checkers can be specified via 'analyzer-config' command-line
@@ -537,14 +534,6 @@ public:
   /// This is controlled by the 'widen-loops' config option.
   bool shouldWidenLoops();
 
-  /// Returns true if the bug reporter should transparently treat extra note
-  /// diagnostic pieces as event diagnostic pieces. Useful when the diagnostic
-  /// consumer doesn't support the extra note pieces.
-  ///
-  /// This is controlled by the 'notes-as-events' option, which defaults
-  /// to false when unset.
-  bool shouldDisplayNotesAsEvents();
-
 public:
   AnalyzerOptions() :
 AnalysisStoreOpt(RegionStoreModel),

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=283180&r1=283179&r2=283180&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Mon 
Oct  3 21:19:17 2016
@@ -66,8 +66,6 @@ public:
   typedef SmallVector, 8> VisitorList;
   typedef VisitorList::iterator visitor_iterator;
   typedef SmallVector ExtraTextList;
-  typedef SmallVector, 4>
-  NoteList;
 
 protected:
   friend class BugReporter;
@@ -84,8 +82,7 @@ protected:
   const ExplodedNode *ErrorNode;
   SmallVector Ranges;
   ExtraTextList ExtraText;
-  NoteList Notes;
-
+  
   typedef llvm::DenseSet Symbols;
   typedef llvm::DenseSet Regions;
 
@@ -180,18 +177,6 @@ public:
   const BugType& getBugType() const { return BT; }
   BugType& getBugType() { return BT; }
 
-  /// \brief True when the report has an execution path associated with it.
-  ///
-  /// A report is said to be path-sensitive if it was thrown against a
-  /// particular exploded node in the path-sensitive analysis graph.
-  /// Path-sensitive reports have their intermediate path diagnostics
-  /// auto-generated, perhaps with the help of checker-defined visitors,
-  /// and may contain extra notes.
-  /// Path-insensitive reports consist only of a single warning message
-  /// in a specific location, and perhaps extra notes.
-  /// Path-sensitive checkers are allowed to throw path-insensitive reports.
-  bool isPathSensitive() const { return ErrorNode != nullptr; }
-
   const ExplodedNode *getErrorNode() const { return ErrorNode; }
 
   StringRef getDescription() const { return Description; }
@@ -260,27 +245,7 @@ public:
   void setDeclWithIssue(const Decl *declWithIssue) {
 DeclWithIssue = declWithIssue;
   }
-
-  /// Add new item to the list of additional notes that need to be attached to
-  /// this path-insensitive report. If you want to add extra notes to a
-  /// path-sensitive report, you need to use a BugReporterVisitor because it
-  /// allows you to specify where exactly in the auto-generated path diagnostic
-  /// the extra note should appear.
-  void addNote(StringRef Msg, const PathDiagnosticLocation &Pos,
-ArrayRef Ranges = {}) {
-PathDiagnosticNotePiece *P =
-new PathDiagnosticNotePiece(Pos, Msg);
-
-for (const auto &R : Ranges)
-  P->addRange(R);
-
-Notes.push_back(P);
-  }
-
-  virtual const NoteList &getNotes() {
-return Notes;
-  }
-
+  
   /// \brief This allows for addition of meta data to the diagnost

r283181 - Revert "[analyzer] Add extra notes to ObjCDeallocChecker" as its depends on reverted r283092

2016-10-03 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Oct  3 21:36:58 2016
New Revision: 283181

URL: http://llvm.org/viewvc/llvm-project?rev=283181&view=rev
Log:
Revert "[analyzer] Add extra notes to ObjCDeallocChecker" as its depends on 
reverted r283092

This reverts commit r283093.

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/DeallocMissingRelease.m
cfe/trunk/test/Analysis/PR2978.m
cfe/trunk/test/Analysis/properties.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=283181&r1=283180&r2=283181&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Mon Oct  3 
21:36:58 2016
@@ -107,9 +107,6 @@ class ObjCDeallocChecker
   std::unique_ptr ExtraReleaseBugType;
   std::unique_ptr MistakenDeallocBugType;
 
-  static constexpr const char *MsgDeclared = "Property is declared here";
-  static constexpr const char *MsgSynthesized = "Property is synthesized here";
-
 public:
   ObjCDeallocChecker();
 
@@ -131,9 +128,6 @@ public:
   void checkEndFunction(CheckerContext &Ctx) const;
 
 private:
-  void addNoteForDecl(std::unique_ptr &BR, StringRef Msg,
-   const Decl *D) const;
-
   void diagnoseMissingReleases(CheckerContext &C) const;
 
   bool diagnoseExtraRelease(SymbolRef ReleasedValue, const ObjCMethodCall &M,
@@ -495,18 +489,6 @@ ProgramStateRef ObjCDeallocChecker::chec
   return State;
 }
 
-/// Add an extra note piece describing a declaration that is important
-/// for understanding the bug report.
-void ObjCDeallocChecker::addNoteForDecl(std::unique_ptr &BR,
- StringRef Msg,
- const Decl *D) const {
-  ASTContext &ACtx = D->getASTContext();
-  SourceManager &SM = ACtx.getSourceManager();
-  PathDiagnosticLocation Pos = PathDiagnosticLocation::createBegin(D, SM);
-  if (Pos.isValid() && Pos.asLocation().isValid())
-BR->addNote(Msg, Pos, D->getSourceRange());
-}
-
 /// Report any unreleased instance variables for the current instance being
 /// dealloced.
 void ObjCDeallocChecker::diagnoseMissingReleases(CheckerContext &C) const {
@@ -604,9 +586,6 @@ void ObjCDeallocChecker::diagnoseMissing
 std::unique_ptr BR(
 new BugReport(*MissingReleaseBugType, OS.str(), ErrNode));
 
-addNoteForDecl(BR, MsgDeclared, PropDecl);
-addNoteForDecl(BR, MsgSynthesized, PropImpl);
-
 C.emitReport(std::move(BR));
   }
 
@@ -710,12 +689,11 @@ bool ObjCDeallocChecker::diagnoseExtraRe
  );
 
   const ObjCImplDecl *Container = 
getContainingObjCImpl(C.getLocationContext());
-  const ObjCIvarDecl *IvarDecl = PropImpl->getPropertyIvarDecl();
-  OS << "The '" << *IvarDecl << "' ivar in '" << *Container;
+  OS << "The '" << *PropImpl->getPropertyIvarDecl()
+ << "' ivar in '" << *Container;
 
-  bool ReleasedByCIFilterDealloc = isReleasedByCIFilterDealloc(PropImpl);
 
-  if (ReleasedByCIFilterDealloc) {
+  if (isReleasedByCIFilterDealloc(PropImpl)) {
 OS << "' will be released by '-[CIFilter dealloc]' but also released here";
   } else {
 OS << "' was synthesized for ";
@@ -732,10 +710,6 @@ bool ObjCDeallocChecker::diagnoseExtraRe
   new BugReport(*ExtraReleaseBugType, OS.str(), ErrNode));
   BR->addRange(M.getOriginExpr()->getSourceRange());
 
-  addNoteForDecl(BR, MsgDeclared, PropDecl);
-  if (!ReleasedByCIFilterDealloc)
-addNoteForDecl(BR, MsgSynthesized, PropImpl);
-
   C.emitReport(std::move(BR));
 
   return true;

Modified: cfe/trunk/test/Analysis/DeallocMissingRelease.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/DeallocMissingRelease.m?rev=283181&r1=283180&r2=283181&view=diff
==
--- cfe/trunk/test/Analysis/DeallocMissingRelease.m (original)
+++ cfe/trunk/test/Analysis/DeallocMissingRelease.m Mon Oct  3 21:36:58 2016
@@ -80,9 +80,6 @@
 
 @interface MyPropertyClass1 : NSObject
 @property (copy) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass1
@@ -96,9 +93,6 @@
 
 @interface MyPropertyClass2 : NSObject
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass2
@@ -114,16 +108,10 @@
   NSObject *_ivar;
 }
 @property (retain) NSObject *ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is declared here}}
-#endif
 @end
 
 @implementation MyPropertyClass3
 @synthesize ivar = _ivar;
-#if NON_ARC
-// expected-note@-2 {{Property is synthesized here}}
-#endif
 - (void)dealloc
 {
 #if NON_ARC
@@ -137,9 +125,6 @@
   void (^_blockPropertyIvar)(void);
 }
 @property (copy) void (^blo

r283182 - Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on reverted r283092

2016-10-03 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Oct  3 21:40:35 2016
New Revision: 283182

URL: http://llvm.org/viewvc/llvm-project?rev=283182&view=rev
Log:
Revert "[analyzer] Improve CloneChecker diagnostics" as its depends on reverted 
r283092

This reverts commit r283094.

Removed:
cfe/trunk/test/Analysis/copypaste/plist-diagnostics-notes-as-events.cpp
cfe/trunk/test/Analysis/copypaste/plist-diagnostics.cpp
cfe/trunk/test/Analysis/copypaste/text-diagnostics.cpp
Modified:
cfe/trunk/include/clang/Analysis/CloneDetection.h
cfe/trunk/lib/Analysis/CloneDetection.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/CloneChecker.cpp
cfe/trunk/test/Analysis/copypaste/blocks.cpp
cfe/trunk/test/Analysis/copypaste/function-try-block.cpp
cfe/trunk/test/Analysis/copypaste/functions.cpp
cfe/trunk/test/Analysis/copypaste/macro-complexity.cpp
cfe/trunk/test/Analysis/copypaste/macros.cpp
cfe/trunk/test/Analysis/copypaste/objc-methods.m
cfe/trunk/test/Analysis/copypaste/sub-sequences.cpp
cfe/trunk/test/Analysis/copypaste/suspicious-clones.cpp

Modified: cfe/trunk/include/clang/Analysis/CloneDetection.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CloneDetection.h?rev=283182&r1=283181&r2=283182&view=diff
==
--- cfe/trunk/include/clang/Analysis/CloneDetection.h (original)
+++ cfe/trunk/include/clang/Analysis/CloneDetection.h Mon Oct  3 21:40:35 2016
@@ -128,10 +128,6 @@ public:
   /// This method should only be called on a non-empty StmtSequence object.
   SourceLocation getEndLoc() const;
 
-  /// Returns the source range of the whole sequence - from the beginning
-  /// of the first statement to the end of the last statement.
-  SourceRange getSourceRange() const;
-
   bool operator==(const StmtSequence &Other) const {
 return std::tie(S, StartIndex, EndIndex) ==
std::tie(Other.S, Other.StartIndex, Other.EndIndex);
@@ -254,14 +250,14 @@ public:
   /// The variable which referencing in this clone was against the pattern.
   const VarDecl *Variable;
   /// Where the variable was referenced.
-  const Stmt *Mention;
+  SourceRange VarRange;
   /// The variable that should have been referenced to follow the pattern.
   /// If Suggestion is a nullptr then it's not possible to fix the pattern
   /// by referencing a different variable in this clone.
   const VarDecl *Suggestion;
-  SuspiciousCloneInfo(const VarDecl *Variable, const Stmt *Mention,
+  SuspiciousCloneInfo(const VarDecl *Variable, SourceRange Range,
   const VarDecl *Suggestion)
-  : Variable(Variable), Mention(Mention), Suggestion(Suggestion) {}
+  : Variable(Variable), VarRange(Range), Suggestion(Suggestion) {}
   SuspiciousCloneInfo() {}
 };
 /// The first clone in the pair which always has a suggested variable.

Modified: cfe/trunk/lib/Analysis/CloneDetection.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CloneDetection.cpp?rev=283182&r1=283181&r2=283182&view=diff
==
--- cfe/trunk/lib/Analysis/CloneDetection.cpp (original)
+++ cfe/trunk/lib/Analysis/CloneDetection.cpp Mon Oct  3 21:40:35 2016
@@ -82,10 +82,6 @@ SourceLocation StmtSequence::getStartLoc
 
 SourceLocation StmtSequence::getEndLoc() const { return back()->getLocEnd(); }
 
-SourceRange StmtSequence::getSourceRange() const {
-  return SourceRange(getStartLoc(), getEndLoc());
-}
-
 namespace {
 
 /// \brief Analyzes the pattern of the referenced variables in a statement.
@@ -95,11 +91,11 @@ class VariablePattern {
   struct VariableOccurence {
 /// The index of the associated VarDecl in the Variables vector.
 size_t KindID;
-/// The statement in the code where the variable was referenced.
-const Stmt *Mention;
+/// The source range in the code where the variable was referenced.
+SourceRange Range;
 
-VariableOccurence(size_t KindID, const Stmt *Mention)
-: KindID(KindID), Mention(Mention) {}
+VariableOccurence(size_t KindID, SourceRange Range)
+: KindID(KindID), Range(Range) {}
   };
 
   /// All occurences of referenced variables in the order of appearance.
@@ -111,19 +107,19 @@ class VariablePattern {
   /// \brief Adds a new variable referenced to this pattern.
   /// \param VarDecl The declaration of the variable that is referenced.
   /// \param Mention The statement in the code where the variable was 
referenced.
-  void addVariableOccurence(const VarDecl *VarDecl, const Stmt *Mention) {
+  void addVariableOccurence(const VarDecl *VarDecl, SourceRange Range) {
 // First check if we already reference this variable
 for (size_t KindIndex = 0; KindIndex < Variables.size(); ++KindIndex) {
   if (Variables[KindIndex] == VarDecl) {
 // If yes, add a new occurence that points to the existing entry in

[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-10-03 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

reverted with r283182


https://reviews.llvm.org/D24916



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


[PATCH] D24915: [analyzer] Extend bug reports with extra notes - ObjCDeallocChecker

2016-10-03 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Reverted with r283181 as it depends r283092


https://reviews.llvm.org/D24915



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


[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-10-03 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

reverted with r283182 as it depends on r283092


https://reviews.llvm.org/D24916



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


[PATCH] D24916: [analyzer] Extend bug reports with extra notes - CloneChecker

2016-10-04 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Out of curiosity, how was MSVC crash solved?


Repository:
  rL LLVM

https://reviews.llvm.org/D24916



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


[PATCH] D25453: Add -fno-sanitize-address-use-after-scope flag

2016-10-10 Thread Vitaly Buka via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: test/Driver/fsanitize.c:124
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
+// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
 

eugenis wrote:
> Check the case
> -fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope
It's already on the line 117


https://reviews.llvm.org/D25453



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


[PATCH] D25453: Add -fno-sanitize-address-use-after-scope flag

2016-10-10 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 74176.
vitalybuka added a comment.

resolved comments


https://reviews.llvm.org/D25453

Files:
  include/clang/Driver/Options.td
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -108,14 +108,20 @@
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=efficiency-working-set,kernel-address -pie -fno-rtti %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANE-SANKA
 // CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with 
'-fsanitize=kernel-address'
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-USE-AFTER-SCOPE
-// CHECK-ONLY-USE-AFTER-SCOPE: '-fsanitize-address-use-after-scope' only 
allowed with '-fsanitize=address'
-
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-NO-USE-AFTER-SCOPE
-// CHECK-ASAN-NO-USE-AFTER-SCOPE-NOT: 
-cc1{{.*}}-fsanitize-address-use-after-scope
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE-OFF
+// CHECK-USE-AFTER-SCOPE-OFF-NOT: -cc1{{.*}}address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
+// CHECK-USE-AFTER-SCOPE-BOTH: -cc1{{.*}}-fsanitize-address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope -fno-sanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH-OFF
+// CHECK-USE-AFTER-SCOPE-BOTH-OFF-NOT: -cc1{{.*}}address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
+// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: 
'-fsanitize-memory-track-origins'
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -732,8 +732,11 @@
   Args.hasArg(OPT_fsanitize_memory_use_after_dtor);
   Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
-  Opts.SanitizeAddressUseAfterScope =
-  Args.hasArg(OPT_fsanitize_address_use_after_scope);
+  if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
+   OPT_fno_sanitize_address_use_after_scope)) {
+Opts.SanitizeAddressUseAfterScope =
+A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
+  }
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -559,14 +559,13 @@
 D.Diag(clang::diag::note_drv_address_sanitizer_debug_runtime);
   }
 }
-  }
 
-  AsanUseAfterScope =
-  Args.hasArg(options::OPT_fsanitize_address_use_after_scope);
-  if (AsanUseAfterScope && !(AllAddedKinds & Address)) {
-D.Diag(clang::diag::err_drv_argument_only_allowed_with)
-<< "-fsanitize-address-use-after-scope"
-<< "-fsanitize=address";
+if (Arg *A = Args.getLastArg(
+options::OPT_fsanitize_address_use_after_scope,
+options::OPT_fno_sanitize_address_use_after_scope)) {
+  AsanUseAfterScope = A->getOption().getID() ==
+  options::OPT_fsanitize_address_use_after_scope;
+}
   }
 
   // Parse -link-cxx-sanitizer flag.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -687,6 +687,9 @@
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
 Group, 
Flags<[CC1Option]>,
 HelpText<"Enable use-after-scope 
detect

r283801 - Add -fno-sanitize-address-use-after-scope flag

2016-10-10 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Mon Oct 10 16:31:50 2016
New Revision: 283801

URL: http://llvm.org/viewvc/llvm-project?rev=283801&view=rev
Log:
Add -fno-sanitize-address-use-after-scope flag

Reviewers: eugenis

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

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/SanitizerArgs.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=283801&r1=283800&r2=283801&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Mon Oct 10 16:31:50 2016
@@ -687,6 +687,9 @@ def fsanitize_address_field_padding : Jo
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
 Group, 
Flags<[CC1Option]>,
 HelpText<"Enable use-after-scope 
detection in AddressSanitizer">;
+def fno_sanitize_address_use_after_scope : Flag<["-"], 
"fno-sanitize-address-use-after-scope">,
+   Group, 
Flags<[CC1Option]>,
+   HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group,
 Flags<[CoreOption]>;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,

Modified: cfe/trunk/lib/Driver/SanitizerArgs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/SanitizerArgs.cpp?rev=283801&r1=283800&r2=283801&view=diff
==
--- cfe/trunk/lib/Driver/SanitizerArgs.cpp (original)
+++ cfe/trunk/lib/Driver/SanitizerArgs.cpp Mon Oct 10 16:31:50 2016
@@ -559,14 +559,13 @@ SanitizerArgs::SanitizerArgs(const ToolC
 D.Diag(clang::diag::note_drv_address_sanitizer_debug_runtime);
   }
 }
-  }
 
-  AsanUseAfterScope =
-  Args.hasArg(options::OPT_fsanitize_address_use_after_scope);
-  if (AsanUseAfterScope && !(AllAddedKinds & Address)) {
-D.Diag(clang::diag::err_drv_argument_only_allowed_with)
-<< "-fsanitize-address-use-after-scope"
-<< "-fsanitize=address";
+if (Arg *A = Args.getLastArg(
+options::OPT_fsanitize_address_use_after_scope,
+options::OPT_fno_sanitize_address_use_after_scope)) {
+  AsanUseAfterScope = A->getOption().getID() ==
+  options::OPT_fsanitize_address_use_after_scope;
+}
   }
 
   // Parse -link-cxx-sanitizer flag.

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=283801&r1=283800&r2=283801&view=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Mon Oct 10 16:31:50 2016
@@ -732,8 +732,11 @@ static bool ParseCodeGenArgs(CodeGenOpti
   Args.hasArg(OPT_fsanitize_memory_use_after_dtor);
   Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
-  Opts.SanitizeAddressUseAfterScope =
-  Args.hasArg(OPT_fsanitize_address_use_after_scope);
+  if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
+   OPT_fno_sanitize_address_use_after_scope)) {
+Opts.SanitizeAddressUseAfterScope =
+A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
+  }
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=283801&r1=283800&r2=283801&view=diff
==
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Mon Oct 10 16:31:50 2016
@@ -108,14 +108,20 @@
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=efficiency-working-set,kernel-address -pie -fno-rtti %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANE-SANKA
 // CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with 
'-fsanitize=kernel-address'
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-USE-AFTER-SCOPE
-// CHECK-ONLY-USE-AFTER-SCOPE: '-fsanitize-address-use-after-scope' only 
allowed with '-fsanitize=address'
-
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-

[PATCH] D25453: Add -fno-sanitize-address-use-after-scope flag

2016-10-11 Thread Vitaly Buka via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283801: Add -fno-sanitize-address-use-after-scope flag 
(authored by vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D25453?vs=74176&id=74210#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D25453

Files:
  cfe/trunk/include/clang/Driver/Options.td
  cfe/trunk/lib/Driver/SanitizerArgs.cpp
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/test/Driver/fsanitize.c


Index: cfe/trunk/include/clang/Driver/Options.td
===
--- cfe/trunk/include/clang/Driver/Options.td
+++ cfe/trunk/include/clang/Driver/Options.td
@@ -687,6 +687,9 @@
 def fsanitize_address_use_after_scope : Flag<["-"], 
"fsanitize-address-use-after-scope">,
 Group, 
Flags<[CC1Option]>,
 HelpText<"Enable use-after-scope 
detection in AddressSanitizer">;
+def fno_sanitize_address_use_after_scope : Flag<["-"], 
"fno-sanitize-address-use-after-scope">,
+   Group, 
Flags<[CC1Option]>,
+   HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
 def fsanitize_recover : Flag<["-"], "fsanitize-recover">, Group,
 Flags<[CoreOption]>;
 def fno_sanitize_recover : Flag<["-"], "fno-sanitize-recover">,
Index: cfe/trunk/test/Driver/fsanitize.c
===
--- cfe/trunk/test/Driver/fsanitize.c
+++ cfe/trunk/test/Driver/fsanitize.c
@@ -108,14 +108,20 @@
 // RUN: %clang -target x86_64-linux-gnu 
-fsanitize=efficiency-working-set,kernel-address -pie -fno-rtti %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-SANE-SANKA
 // CHECK-SANE-SANKA: '-fsanitize=efficiency-{{.*}}' not allowed with 
'-fsanitize=kernel-address'
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-USE-AFTER-SCOPE
-// CHECK-ONLY-USE-AFTER-SCOPE: '-fsanitize-address-use-after-scope' only 
allowed with '-fsanitize=address'
-
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE
 // CHECK-USE-AFTER-SCOPE: -cc1{{.*}}-fsanitize-address-use-after-scope
 
-// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-NO-USE-AFTER-SCOPE
-// CHECK-ASAN-NO-USE-AFTER-SCOPE-NOT: 
-cc1{{.*}}-fsanitize-address-use-after-scope
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-USE-AFTER-SCOPE-OFF
+// CHECK-USE-AFTER-SCOPE-OFF-NOT: -cc1{{.*}}address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fno-sanitize-address-use-after-scope -fsanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH
+// CHECK-USE-AFTER-SCOPE-BOTH: -cc1{{.*}}-fsanitize-address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address 
-fsanitize-address-use-after-scope -fno-sanitize-address-use-after-scope %s 
-### 2>&1 | FileCheck %s --check-prefix=CHECK-USE-AFTER-SCOPE-BOTH-OFF
+// CHECK-USE-AFTER-SCOPE-BOTH-OFF-NOT: -cc1{{.*}}address-use-after-scope
+
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
+// CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE-NOT: -cc1{{.*}}address-use-after-scope
 
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie 
%s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: 
'-fsanitize-memory-track-origins'
Index: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
===
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp
@@ -732,8 +732,11 @@
   Args.hasArg(OPT_fsanitize_memory_use_after_dtor);
   Opts.SanitizeCfiCrossDso = Args.hasArg(OPT_fsanitize_cfi_cross_dso);
   Opts.SanitizeStats = Args.hasArg(OPT_fsanitize_stats);
-  Opts.SanitizeAddressUseAfterScope =
-  Args.hasArg(OPT_fsanitize_address_use_after_scope);
+  if (Arg *A = Args.getLastArg(OPT_fsanitize_address_use_after_scope,
+   OPT_fno_sanitize_address_use_after_scope)) {
+Opts.SanitizeAddressUseAfterScope =
+A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
+  }
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: cfe/trunk/lib/Driver/SanitizerArgs.cpp
===
--- cfe/t

[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

This change breaks 
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/25625/steps/build%2032-bit%20symbolizer%20for%20compiler_rt_build/logs/stdio


https://reviews.llvm.org/D24864



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


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

So there is:

- Looking for __cxa_thread_atexit_impl in c
- Looking for __cxa_thread_atexit_impl in c - not found

and libcxx is configured with -DLIBCXX_ENABLE_THREADS=OFF


https://reviews.llvm.org/D24864



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


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Maybe?

- if (UNIX AND NOT (APPLE OR CYGWIN))

+ if (LIBCXXABI_ENABLE_THREADS AND UNIX AND NOT (APPLE OR CYGWIN))

  list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)

endif()


https://reviews.llvm.org/D24864



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


[libcxxabi] r284294 - Don't compile cxa_thread_atexit.cpp with -DLIBCXX_ENABLE_THREADS=OFF

2016-10-14 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Oct 14 18:51:41 2016
New Revision: 284294

URL: http://llvm.org/viewvc/llvm-project?rev=284294&view=rev
Log:
Don't compile cxa_thread_atexit.cpp with -DLIBCXX_ENABLE_THREADS=OFF

Reviewers: rmaprath

Subscribers: beanz, mgorny

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

Modified:
libcxxabi/trunk/src/CMakeLists.txt

Modified: libcxxabi/trunk/src/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/CMakeLists.txt?rev=284294&r1=284293&r2=284294&view=diff
==
--- libcxxabi/trunk/src/CMakeLists.txt (original)
+++ libcxxabi/trunk/src/CMakeLists.txt Fri Oct 14 18:51:41 2016
@@ -25,7 +25,7 @@ else()
   list(APPEND LIBCXXABI_SOURCES cxa_noexception.cpp)
 endif()
 
-if (UNIX AND NOT (APPLE OR CYGWIN))
+if (LIBCXXABI_ENABLE_THREADS AND UNIX AND NOT (APPLE OR CYGWIN))
   list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp)
 endif()
 


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


[PATCH] D24864: [libcxxabi] Refactor pthread usage into a separate API

2016-10-14 Thread Vitaly Buka via cfe-commits
vitalybuka added a comment.

Thanks, done https://reviews.llvm.org/D25636


https://reviews.llvm.org/D24864



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


[libcxxabi] r284295 - Fix typo in comment

2016-10-14 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Fri Oct 14 19:02:20 2016
New Revision: 284295

URL: http://llvm.org/viewvc/llvm-project?rev=284295&view=rev
Log:
Fix typo in comment

Modified:
libcxxabi/trunk/src/cxa_thread_atexit.cpp

Modified: libcxxabi/trunk/src/cxa_thread_atexit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_thread_atexit.cpp?rev=284295&r1=284294&r2=284295&view=diff
==
--- libcxxabi/trunk/src/cxa_thread_atexit.cpp (original)
+++ libcxxabi/trunk/src/cxa_thread_atexit.cpp Fri Oct 14 19:02:20 2016
@@ -99,7 +99,7 @@ namespace {
   };
 } // namespace
 
-#endif // HAVE__CXA_THREAD_ATEXIT_IMPL
+#endif // HAVE___CXA_THREAD_ATEXIT_IMPL
 
 extern "C" {
 


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


[PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-10-16 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 74813.
vitalybuka marked 5 inline comments as done.
vitalybuka added a comment.
Herald added a subscriber: modocache.

- updated comments
- indirect jumps
- optimized Detect()


https://reviews.llvm.org/D24693

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,8 +1,9 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
 
+// CHECK-LABEL: @foo
 // O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
@@ -15,3 +16,66 @@
 return bar(A, 2);
   }
 }
+
+// CHECK-LABEL: @no_goto_bypass
+void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 1
+  char x;
+l1:
+  bar(&x, 1);
+  // O2: @llvm.lifetime.start(i64 5
+  // O2: @llvm.lifetime.end(i64 5
+  char y[5];
+  bar(y, 5);
+  goto l1;
+  // Infinite loop
+  // O2-NOT: @llvm.lifetime.end(i64 1
+}
+
+// CHECK-LABEL: @goto_bypass
+void goto_bypass() {
+  {
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+  l1:
+bar(&x, 1);
+  }
+  goto l1;
+}
+
+// CHECK-LABEL: @no_switch_bypass
+void no_switch_bypass(int n) {
+  switch (n) {
+  case 1: {
+// O2: @llvm.lifetime.start(i64 1
+// O2: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: @llvm.lifetime.start(i64 5
+// O2: @llvm.lifetime.end(i64 5
+char y[5];
+bar(y, 5);
+break;
+  }
+}
+
+// CHECK-LABEL: @switch_bypass
+void switch_bypass(int n) {
+  switch (n) {
+  case 1:
+n = n;
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
Index: lib/CodeGen/VarBypassDetector.h
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,70 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// The class detects jumps which bypass local variables declaration:
+///goto L;
+///int a;
+///  L:
+///
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // Lookup map to file scope for jumps.
+  llvm::SmallVector, 16> FromScopes;
+  // Lookup map to file scope for destinations.
+  llvm::DenseMap ToScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+  // If true assume that all variables are being bypassed.
+  bool AlwaysBypassed = false;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// Returns true if the variable declaration was by bypassed by any goto or
+  /// switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return AlwaysBypassed || Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  bool BuildScopeInformation(const Decl *D, unsigned &ParentScope);
+  bool BuildScopeInformation(const Stmt *S, unsigned &origParentScope);
+  void Detect();
+  void Detect(unsigned From, unsigned To);
+};
+}
+}
+
+#endif
Index: lib/CodeGen/VarBypassDetector.cpp
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,168 @@
+//===--- VarBypassDetector.h - Bypass jumps detector --*- C++ -*-=//
+//
+// 

[PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-10-16 Thread Vitaly Buka via cfe-commits
vitalybuka updated this revision to Diff 74814.
vitalybuka added a comment.

- fixed comment
- added test for indirect jumps


https://reviews.llvm.org/D24693

Files:
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CMakeLists.txt
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/VarBypassDetector.cpp
  lib/CodeGen/VarBypassDetector.h
  test/CodeGen/lifetime2.c

Index: test/CodeGen/lifetime2.c
===
--- test/CodeGen/lifetime2.c
+++ test/CodeGen/lifetime2.c
@@ -1,8 +1,9 @@
-// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefix=O2
-// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefix=O0
+// RUN: %clang -S -emit-llvm -o - -O2 %s | FileCheck %s -check-prefixes=CHECK,O2
+// RUN: %clang -S -emit-llvm -o - -O0 %s | FileCheck %s -check-prefixes=CHECK,O0
 
 extern int bar(char *A, int n);
 
+// CHECK-LABEL: @foo
 // O0-NOT: @llvm.lifetime.start
 int foo (int n) {
   if (n) {
@@ -15,3 +16,76 @@
 return bar(A, 2);
   }
 }
+
+// CHECK-LABEL: @no_goto_bypass
+void no_goto_bypass() {
+  // O2: @llvm.lifetime.start(i64 1
+  char x;
+l1:
+  bar(&x, 1);
+  // O2: @llvm.lifetime.start(i64 5
+  // O2: @llvm.lifetime.end(i64 5
+  char y[5];
+  bar(y, 5);
+  goto l1;
+  // Infinite loop
+  // O2-NOT: @llvm.lifetime.end(i64 1
+}
+
+// CHECK-LABEL: @goto_bypass
+void goto_bypass() {
+  {
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+  l1:
+bar(&x, 1);
+  }
+  goto l1;
+}
+
+// CHECK-LABEL: @no_switch_bypass
+void no_switch_bypass(int n) {
+  switch (n) {
+  case 1: {
+// O2: @llvm.lifetime.start(i64 1
+// O2: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: @llvm.lifetime.start(i64 5
+// O2: @llvm.lifetime.end(i64 5
+char y[5];
+bar(y, 5);
+break;
+  }
+}
+
+// CHECK-LABEL: @switch_bypass
+void switch_bypass(int n) {
+  switch (n) {
+  case 1:
+n = n;
+// O2-NOT: @llvm.lifetime.start(i64 1
+// O2-NOT: @llvm.lifetime.end(i64 1
+char x;
+bar(&x, 1);
+break;
+  case 2:
+bar(&x, 1);
+break;
+  }
+}
+
+// CHECK-LABEL: @indirect_jump
+void indirect_jump(int n) {
+  char x;
+  // O2-NOT: @llvm.lifetime
+  void *T[] = {&&L};
+  goto *T[n];
+L:
+  bar(&x, 1);
+}
Index: lib/CodeGen/VarBypassDetector.h
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.h
@@ -0,0 +1,70 @@
+//===--- VarBypassDetector.cpp - Bypass jumps detector *- C++ -*-=//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file contains VarBypassDetector class, which is used to detect
+// local variable declarations which can be bypassed by jumps.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+#define LLVM_CLANG_LIB_CODEGEN_VARBYPASSDETECTOR_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/SmallVector.h"
+
+namespace clang {
+
+class Decl;
+class Stmt;
+class VarDecl;
+
+namespace CodeGen {
+
+/// The class detects jumps which bypass local variables declaration:
+///goto L;
+///int a;
+///  L:
+///
+/// This is simplified version of JumpScopeChecker. Primary differences:
+///  * Detects only jumps into the scope local variables.
+///  * Does not detect jumps out of the scope of local variables.
+///  * Not limited to variables with initializers, JumpScopeChecker is limited.
+class VarBypassDetector {
+  // Scope information. Contains a parent scope and related variable
+  // declaration.
+  llvm::SmallVector, 48> Scopes;
+  // List of jumps with scopes.
+  llvm::SmallVector, 16> FromScopes;
+  // Lookup map to find scope for destinations.
+  llvm::DenseMap ToScopes;
+  // Set of variables which were bypassed by some jump.
+  llvm::DenseSet Bypasses;
+  // If true assume that all variables are being bypassed.
+  bool AlwaysBypassed = false;
+
+public:
+  void Init(const Stmt *Body);
+
+  /// Returns true if the variable declaration was by bypassed by any goto or
+  /// switch statement.
+  bool IsBypassed(const VarDecl *D) const {
+return AlwaysBypassed || Bypasses.find(D) != Bypasses.end();
+  }
+
+private:
+  bool BuildScopeInformation(const Decl *D, unsigned &ParentScope);
+  bool BuildScopeInformation(const Stmt *S, unsigned &origParentScope);
+  void Detect();
+  void Detect(unsigned From, unsigned To);
+};
+}
+}
+
+#endif
Index: lib/CodeGen/VarBypassDetector.cpp
===
--- /dev/null
+++ lib/CodeGen/VarBypassDetector.cpp
@@ -0,0 +1,168 @@
+//===--- VarBypassDetector.h - Bypass jumps 

[PATCH] D24693: [CodeGen] Don't emit lifetime intrinsics for some local variables

2016-10-16 Thread Vitaly Buka via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added a comment.

Please take a look. Meanwhile, I will investigate performance footprint.

In https://reviews.llvm.org/D24693#559781, @rsmith wrote:

> Is there some reasonable base set of functionality between this and 
> JumpDiagnostics that could be factored out and shared?


I tried to do so from beginning but seems common part is only recursive 
traversal of AST. Sharing this will likely make both classes less readable.
In my taste it would be easier to maintain them separately.




Comment at: lib/CodeGen/VarBypassDetector.cpp:50-51
+  // If this is a statement, rather than an expression, scopes within it don't
+  // propagate out into the enclosing scope.  Otherwise we have to worry
+  // about block literals, which have the lifetime of their enclosing 
statement.
+  unsigned independentParentScope = origParentScope;

rsmith wrote:
> Comment seems to not be relevant in this copy of the code; we don't have any 
> special case for block literals here.
I read this comment as explanation of "origParentScope : 
independentParentScope" and it's still needed and  relevant.



Comment at: lib/CodeGen/VarBypassDetector.cpp:82-86
+  case Stmt::CaseStmtClass:
+  case Stmt::DefaultStmtClass:
+  case Stmt::LabelStmtClass:
+LabelAndGotoScopes[S] = ParentScope;
+break;

rsmith wrote:
> This looks unreachable (our only callers are the recursive call below -- 
> which already checked for these -- and cases that cannot have a labelled 
> statement). If we did reach it, we'd do the wrong thing, because we'd have 
> created an independent scope rather than reusing the parent's scope (`x: int 
> n;` would not introduce a new scope into the parent for `n`). Maybe replace 
> this case with `llvm_unreachable`, or move the `while (true)` loop below up 
> to the top of this function and delete these cases.
> 
> Do we have the same issue in JumpDiagnostics?
Done here, but can't do for  JumpDiagnostics. there are various 
BuildScopeInformation which can have label as child.


https://reviews.llvm.org/D24693



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


[clang] b31b72a - [test][msan] Simplify tests with --implicit-check-not

2022-08-28 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-28T22:43:04-07:00
New Revision: b31b72ad7ed9b75c55771caf1176b989642964eb

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

LOG: [test][msan] Simplify tests with --implicit-check-not

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp
clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
index 19c46ba64a988..dc84db8793284 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
@@ -1,6 +1,6 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
 
 // 24 bytes total
 struct Packed {
@@ -68,7 +68,6 @@ Adjacent ad;
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}EmptyD2Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback{{.*}}i64 0
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}SimpleD2Ev

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
index ecb0f2b2d13b4..f0d1e5697e7a0 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -1,5 +1,5 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
 
 // Sanitizing dtor is emitted in dtor for every class, and only
 // poisons once.
@@ -57,17 +57,13 @@ Defaulted_Non_Trivial def_non_trivial;
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
-// CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
-// CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
-// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
-// CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
index 618096aeebd7d..0a6aacb84d417 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s
-// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
 
 // Base dtor poisons members
 // Complete dtor poisons vtable ptr

[clang] 9c29bdf - [test][msan] Remov unneeded CHECK-NOT

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T17:49:44-07:00
New Revision: 9c29bdf84ab1bdd89fe8c36974c3bf0543eb9763

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

LOG: [test][msan] Remov unneeded CHECK-NOT

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp
index af130faf13116..ffd573e4d251f 100644
--- a/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-no-dtor-callback.cpp
@@ -8,7 +8,6 @@ struct Simple {
 };
 Simple s;
 // CHECK-LABEL: define {{.*}}SimpleD1Ev
-// CHECK-NOT: call void @__sanitizer_dtor_callback
 
 struct Inlined {
   int x;



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


[clang] ed4e95c - [test][msan] Add more Debug Info use-after-dtor tests

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T17:49:44-07:00
New Revision: ed4e95c1f68abe8fffe8b54139d268924d554381

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

LOG: [test][msan] Add more Debug Info use-after-dtor tests

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
index dc84db879328..f07be7212dad 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
@@ -1,6 +1,6 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
-// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | 
FileCheck %s --implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -O0 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm 
-debug-info-kind=line-tables-only -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -O1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-disable-llvm-passes -std=c++11 -triple=x86_64-pc-linux -emit-llvm 
-debug-info-kind=line-tables-only -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
 
 // 24 bytes total
 struct Packed {
@@ -62,22 +62,28 @@ struct Adjacent {
 };
 Adjacent ad;
 
-
 // CHECK-LABEL: define {{.*}}PackedD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 17
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 17{{.*}}, !dbg 
![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}EmptyD2Ev
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AnonD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 5
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 5{{.*}}, !dbg 
![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AdjacentD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI4:[0-9]+]]
 // CHECK: ret void
+
+// CHECK-LABEL: !DIFile{{.*}}cpp
+
+// CHECK: ![[DI1]] = {{.*}}line: [[@LINE-68]]
+// CHECK: ![[DI2]] = {{.*}}line: [[@LINE-53]]
+// CHECK: ![[DI3]] = {{.*}}line: [[@LINE-41]]
+// CHECK: ![[DI4]] = {{.*}}line: [[@LINE-28]]

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
index f0d1e5697e7a..2aa760ad35f4 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -1,5 +1,5 @@
 // Test -fsanitize-memory-use-after-dtor
-// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -o - %s | FileCheck %s 
--implicit-check-not="call void @__sanitizer_"
+// RUN: %clang_cc1 -fsanitize=memory -fsanitize-memory-use-after-dtor 
-std=c++11 -triple=x86_64-pc-linux -emit-llvm -debug-info-kind=line-tables-only 
-o - %s | FileCheck %s --implicit-check-not="call void @__sanitizer_"
 
 // Sanitizing dtor is emitted in dtor for every class, and only
 // poisons once.
@@ -56,14 +56,20 @@ Defaulted_Non_Trivial def_non_trivial;
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
-// CHECK: call void @__sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: ret void
+
+// CHECK-LABEL: !DIFile{{.*}}cpp
+
+/

[clang] c7df82e - [test][msan] Don't ignore the suffix if use-after-dtor callback

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T18:10:57-07:00
New Revision: c7df82e4693c19e3fd2e25c83eb04d9deb7b7b59

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

LOG: [test][msan] Don't ignore the suffix if use-after-dtor callback

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial-base.cpp
clang/test/CodeGenCXX/sanitize-dtor-trivial.cpp
clang/test/CodeGenCXX/sanitize-dtor-vtable.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
index f07be7212dad..71be40984644 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-bit-field.cpp
@@ -63,22 +63,22 @@ struct Adjacent {
 Adjacent ad;
 
 // CHECK-LABEL: define {{.*}}PackedD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 17{{.*}}, !dbg 
![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 17{{.*}}, !dbg 
![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}EmptyD2Ev
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI2:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 1{{.*}}, !dbg 
![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AnonD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 5{{.*}}, !dbg 
![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 5{{.*}}, !dbg 
![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}AdjacentD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 1{{.*}}, !dbg 
![[DI4:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 1{{.*}}, !dbg 
![[DI4:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}cpp

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
index 2aa760ad35f4..7396e0d2d2df 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -56,16 +56,16 @@ Defaulted_Non_Trivial def_non_trivial;
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI1:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
 // CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI2:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI2:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}cpp

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
index 3292e87ea7c3..5c2bec68a5e1 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-derived-class.cpp
@@ -49,15 +49,15 @@ Derived d;
 
 // Poison members and vtable ptr.
 // CHECK-LABEL: define {{.*}}BaseD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI1:[0-9]+]]
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8{{.*}}, !dbg ![[DI1]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 8{{.*}}, !dbg ![[DI1]]
 // CHECK: ret void
 
 // Poison members and destroy non-virtual base.
 // CHECK-LABEL: define {{.*}}DerivedD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}, !dbg ![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, !dbg ![[DI3:[0-9]+]]
 // CHECK: call void {{.*}}BaseD2Ev
-// CHECK: call void @__sanitizer_dtor_callback{{.*}}i64 8{{.*}}, !dbg ![[DI3]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}i64 8{{.*}}, !dbg ![[DI3]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}cpp

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
index 96e60999890c..3d52e725cc55 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-tail-call.cpp
@@ -15,7 +15,7 @@ struct Simple {
 Simple s;
 // Simple internal member is poi

[clang] 582ec4b - [test][msan] Don't ignore prefix of sanitizer_dtor_callback

2022-08-29 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-08-29T18:26:04-07:00
New Revision: 582ec4b0aa55bff84490e1c89e55066bf6603212

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

LOG: [test][msan] Don't ignore prefix of sanitizer_dtor_callback

Added: 


Modified: 
clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
index 2817aac4ef4a..61acea458d4a 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-fn-attribute.cpp
@@ -33,7 +33,7 @@ int main() {
 // CHECK: ret void
 
 // CHECK: define {{.*}}VectorIiED2Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback
+// CHECK: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // When attribute is repressed, the destructor does not emit any tail calls

diff  --git a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp 
b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
index 3e20eede26b1..75ee8d4789bc 100644
--- a/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
+++ b/clang/test/CodeGenCXX/sanitize-dtor-nontrivial-virtual-base.cpp
@@ -61,27 +61,27 @@ Derived d;
 
 // poison 2 ints
 // CHECK-LABEL: define {{.*}}ZN11VirtualBaseD2Ev
-// CHECK: call void {{.*}}@__sanitizer_dtor_callback({{.*}}, i64 8){{.*}}, 
!dbg ![[DI1:[0-9]+]]
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8){{.*}}, !dbg 
![[DI1:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8)
 // CHECK: ret void
 
 // poison int and double
 // CHECK-LABEL: define {{.*}}ZN4BaseD2Ev
 // CHECK: call void @__sanitizer_dtor_callback({{.*}}{{.*}}, !dbg 
![[DI2:[0-9]+]]
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 8)
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 8)
 // CHECK: ret void
 
 // poison int, ignore vector, poison int
 // CHECK-LABEL: define {{.*}}ZN7DerivedD2Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3:[0-9]+]]
 // CHECK: call void {{.*}}ZN6VectorIiED1Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI3]]
 // CHECK: call void {{.*}}ZN4BaseD2Ev
 // CHECK: ret void
 
 // poison int
 // CHECK-LABEL: define {{.*}}ZN6VectorIiED2Ev
-// CHECK: call void {{.*}}sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI5:[0-9]+]]
+// CHECK: call void @__sanitizer_dtor_callback({{.*}}, i64 4){{.*}}, !dbg 
![[DI5:[0-9]+]]
 // CHECK: ret void
 
 // CHECK-LABEL: !DIFile{{.*}}.cpp



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


  1   2   3   4   5   6   7   8   9   10   >