[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Aha, ok, i appreciate making life easier for downstream users.




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:519
+  // architectures, but not for others.
+  const RangeInt UCharMax = 
+  std::min(BVF.getMaxValue(ACtx.UnsignedCharTy).getLimitedValue(), IntMax);

Let's rename this constant then, so that we still had our `UCharMax` when we 
actually need the real `UCHAR_MAX` in the summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75529



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


[PATCH] D75723: [X86] Enable intrinsics _BitScan*

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan updated this revision to Diff 249282.
skan added a comment.

Enable _BitScan* as intrinsics rather than builtin on linux


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75723

Files:
  clang/lib/Headers/ia32intrin.h
  clang/test/CodeGen/bitscan-builtins.c


Index: clang/test/CodeGen/bitscan-builtins.c
===
--- clang/test/CodeGen/bitscan-builtins.c
+++ clang/test/CodeGen/bitscan-builtins.c
@@ -5,6 +5,32 @@
 
 #include 
 
+unsigned char test_BitScanForward(unsigned *index, unsigned mask) {
+  return _BitScanForward(index, mask);
+  // CHECK: @test_BitScanForward
+  // CHECK: %{{.*}} = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse(unsigned *index, unsigned mask) {
+  return _BitScanReverse(index, mask);
+  // CHECK: @test_BitScanReverse
+  // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 31, %[[call]]
+}
+
+unsigned char test_BitScanForward64(unsigned *index, unsigned long long mask) {
+  return _BitScanForward64(index, mask);
+  // CHECK: @test_BitScanForward64
+  // CHECK: %{{.*}} = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse64(unsigned *index, unsigned long long mask) {
+  return _BitScanReverse64(index, mask);
+  // CHECK: @test_BitScanReverse64
+  // CHECK:  %{{.*}} = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 63, %{{.*}}
+}
+
 int test_bit_scan_forward(int a) {
   return _bit_scan_forward(a);
 // CHECK: @test_bit_scan_forward
Index: clang/lib/Headers/ia32intrin.h
===
--- clang/lib/Headers/ia32intrin.h
+++ clang/lib/Headers/ia32intrin.h
@@ -413,6 +413,26 @@
 
 #ifndef _MSC_VER
 /* These are already provided as builtins for MSVC. */
+#define _BitScanForward(a, b)  
\
+  __extension__({  
\
+*(a) = (unsigned)__bsfd((int)(b)); 
\
+(unsigned char)((b) != 0); 
\
+  })
+#define _BitScanReverse(a, b)  
\
+  __extension__({  
\
+*(a) = (unsigned)__bsrd((int)(b)); 
\
+(unsigned char)((b) != 0); 
\
+  })
+#define _BitScanForward64(a, b)
\
+  __extension__({  
\
+*(a) = (unsigned)__bsfq((long long)(b));   
\
+(unsigned char)((b) != 0); 
\
+  })
+#define _BitScanReverse64(a, b)
\
+  __extension__({  
\
+*(a) = (unsigned)__bsrq((long long)(b));   
\
+(unsigned char)((b) != 0); 
\
+  })
 /* Select the correct function based on the size of long. */
 #ifdef __LP64__
 #define _lrotl(a,b) __rolq((a), (b))


Index: clang/test/CodeGen/bitscan-builtins.c
===
--- clang/test/CodeGen/bitscan-builtins.c
+++ clang/test/CodeGen/bitscan-builtins.c
@@ -5,6 +5,32 @@
 
 #include 
 
+unsigned char test_BitScanForward(unsigned *index, unsigned mask) {
+  return _BitScanForward(index, mask);
+  // CHECK: @test_BitScanForward
+  // CHECK: %{{.*}} = call i32 @llvm.cttz.i32(i32 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse(unsigned *index, unsigned mask) {
+  return _BitScanReverse(index, mask);
+  // CHECK: @test_BitScanReverse
+  // CHECK:  %[[call:.*]] = call i32 @llvm.ctlz.i32(i32 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 31, %[[call]]
+}
+
+unsigned char test_BitScanForward64(unsigned *index, unsigned long long mask) {
+  return _BitScanForward64(index, mask);
+  // CHECK: @test_BitScanForward64
+  // CHECK: %{{.*}} = call i64 @llvm.cttz.i64(i64 %{{.*}}, i1 true)
+}
+
+unsigned char test_BitScanReverse64(unsigned *index, unsigned long long mask) {
+  return _BitScanReverse64(index, mask);
+  // CHECK: @test_BitScanReverse64
+  // CHECK:  %{{.*}} = call i64 @llvm.ctlz.i64(i64 %{{.*}}, i1 true)
+  // CHECK:  %{{.*}} = sub nsw i32 63, %{{.*}}
+}
+
 int test_bit_scan_forward(int a) {
   return _bit_scan_forward(a);
 // CHECK: @test_bit_scan_forward
Index: clang/lib/Headers/ia32intrin.h
===
--- clang/lib/Headers/ia32intrin.h
+++ clang/lib/Headers/ia32intrin.h
@@ -413,6 +413,26 @@
 
 #ifndef _MSC_VER
 /* These are alre

[PATCH] D75894: [X86] Support intrinsics _bextr2*

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan created this revision.
skan added reviewers: LuoYuanke, craig.topper, RKSimon, pengfei.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75894

Files:
  clang/lib/Headers/bmiintrin.h
  clang/test/CodeGen/bmi-builtins.c


Index: clang/test/CodeGen/bmi-builtins.c
===
--- clang/test/CodeGen/bmi-builtins.c
+++ clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}
Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -192,6 +192,28 @@
   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned integer used to specify which bits are extracted. Bits [7:0]
+///specify the index of the least significant bit. Bits [15:8] specify the
+///number of bits to be extracted.
+/// \returns An unsigned integer whose least significant bits contain the
+///extracted bits.
+/// \see __bextr_u32
+static __inline__ unsigned int __DEFAULT_FN_ATTRS
+_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  return __builtin_ia32_bextr_u32(__X, __Y);
+}
+
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///
@@ -321,6 +343,27 @@
   return __builtin_ia32_bextr_u64 (__X, ((__Y & 0xff) | ((__Z & 0xff) << 8)));
 }
 
+/* Intel-specified, single-leading-underscore version of BEXTR2 */
+/// Extracts the specified bits from the first operand and returns them
+///in the least significant bits of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  BEXTR  instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose bits are to be extracted.
+/// \param __Y
+///An unsigned 64-bit integer used to specify which bits are extracted. 
Bits
+///[7:0] specify the index of the least significant bit. Bits [15:8] 
specify
+///the number of bits to be extracted.
+/// \returns An unsigned 64-bit integer whose least significant bits contain 
the
+///extracted bits.
+/// \see __bextr_u64
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS
+_bextr2_u64(unsigned long long __X, unsigned long long __Y) {
+  return __builtin_ia32_bextr_u64(__X, __Y);
+}
 /// Clears all bits in the source except for the least significant bit
 ///containing a value of 1 and returns the result.
 ///


Index: clang/test/CodeGen/bmi-builtins.c
===
--- clang/test/CodeGen/bmi-builtins.c
+++ clang/test/CodeGen/bmi-builtins.c
@@ -155,6 +155,12 @@
   return _bextr_u32(__X, __Y, __Z);
 }
 
+unsigned int test_bextr2_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK-LABEL: test_bextr2_u32
+  // CHECK: i32 @llvm.x86.bmi.bextr.32(i32 %{{.*}}, i32 %{{.*}})
+  return _bextr2_u32(__X, __Y);
+}
+
 unsigned int test_blsi_u32(unsigned int __X) {
   // CHECK-LABEL: test_blsi_u32
   // CHECK: sub i32 0, %{{.*}}
@@ -196,6 +202,13 @@
   return _bextr_u64(__X, __Y, __Z);
 }
 
+unsigned long long test_bextr2_u64(unsigned long long __X,
+   unsigned long long __Y) {
+  // CHECK-LABEL: test_bextr2_u64
+  // CHECK: i64 @llvm.x86.bmi.bextr.64(i64 %{{.*}}, i64 %{{.*}})
+  return _bextr2_u64(__X, __Y);
+}
+
 unsigned long long test_blsi_u64(unsigned long long __X) {
   // CHECK-LABEL: test_blsi_u64
   // CHECK: sub i64 0, %{{.*}}
Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -192,6 +192,28 @@
   return __builtin_ia32_bextr_u32 (__X, ((__Y & 0xff) |

[PATCH] D75698: [analyzer][WIP] Suppress bug reports where a tracked expression's latest value change was a result of an invalidation

2020-03-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D75698#1909541 , @martong wrote:

> > While invalidation is a fundamental part of static analysis, it is 
> > unfortunately not an under-approximation (resulting in fewer but more 
> > precise paths of execution)
>
> +1 for saying this out :)


It //would have been// a correct under-approximation assuming that other parts 
of the static analyzer were working correctly. The reason why invalidation 
causes false positives is because we're making state splits on every 
if-statement and never join back, which causes us to explore more execution 
paths than we're entitled to by the presumption of no dead code. Eg.,

  class C {
bool x;
  
void do_not_change_x();
  
void foo() {
  if (x) { // assuming 'x' is true
do_not_change_x(); // 'x' is invalidated
  }
  
  // We are not entitled to a state split here
  // over the invalidated value of 'x'.
  if (x) {
...
  }
}
  };

Normally such eager state splits don't cause any problems because we tell the 
users to "simply add an assert, the code is obscure anyway". But when 
invalidation kicks in, like in this example, such asserts become very ugly. 
I.e., in this case you'd have to do something like this to suppress the warning 
and you'll have to do it every time you call `do_not_change_x()` for every 
variable that it //doesn't// change:

  bool old_x = x;
  do_not_change_x();
  assert(x == old_x && "x changed!");
  // Also suppress unused variable warning in release builds.
  (void)old_x;

P.S. So, like, we could try to emit the warning only if we covered enough 
execution paths to prove that there's either dead code or the warning is true. 
Then we would no longer care about invalidation problems. Unfortunately, i 
don't have any specific suggestion of how to prove such facts for an arbitrary 
CFG.

P.P.S. Actually you know what, maybe we should only drop the report if the 
constraint over the invalidated value contradicts the constraint over the old 
value. That'll make things a bit more complicated and will require a visitor 
indeed, though hopefully not as complicated as concrete value tracking, as 
we're still interested in only one region at a time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75698



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


[PATCH] D75698: [analyzer][WIP] Suppress bug reports where a tracked expression's latest value change was a result of an invalidation

2020-03-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/test/Analysis/suppress-invalidation-related-reports.cpp:18
+  if (flag) // Assume flag is true.
+*x = 5; // non-suppressed-warning{{Dereference of null pointer}}
+}

In particular, i believe this is a true positive. Because either `flag` //may// 
be set to `false` by `foo()` which makes the path feasible, or the if-statement 
is dead code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75698



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


[clang] 5aa5c94 - Reland "[DebugInfo] Enable the debug entry values feature by default"

2020-03-10 Thread Djordje Todorovic via cfe-commits

Author: Djordje Todorovic
Date: 2020-03-10T09:15:06+01:00
New Revision: 5aa5c943f7da155b95564058cd5d50a93eabfc89

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

LOG: Reland "[DebugInfo] Enable the debug entry values feature by default"

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

Added: 
llvm/test/DebugInfo/X86/no-entry-values-with-O0.ll

Modified: 
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Driver/CC1Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/test/CodeGen/debug-info-extern-call.c
clang/test/CodeGenCXX/dbg-info-all-calls-described.cpp
lldb/packages/Python/lldbsuite/test/decorators.py

lldb/test/API/functionalities/param_entry_vals/basic_entry_values_x86_64/Makefile
llvm/include/llvm/CodeGen/CommandFlags.inc
llvm/include/llvm/Target/TargetMachine.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h
llvm/lib/CodeGen/LiveDebugValues.cpp
llvm/lib/CodeGen/TargetOptionsImpl.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/test/CodeGen/MIR/Hexagon/bundled-call-site-info.mir
llvm/test/CodeGen/MIR/X86/call-site-info-error4.mir
llvm/test/CodeGen/X86/call-site-info-output.ll
llvm/test/DebugInfo/MIR/AArch64/dbgcall-site-orr-moves.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovd.mir
llvm/test/DebugInfo/MIR/ARM/call-site-info-vmovs.mir
llvm/test/DebugInfo/MIR/ARM/dbgcall-site-propagated-value.mir
llvm/test/DebugInfo/MIR/Hexagon/dbgcall-site-instr-before-bundled-call.mir
llvm/test/DebugInfo/MIR/Hexagon/live-debug-values-bundled-entry-values.mir
llvm/test/DebugInfo/MIR/SystemZ/call-site-lzer.mir
llvm/test/DebugInfo/MIR/X86/DW_OP_entry_value.mir
llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-copy-super-sub.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-lea-interpretation.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-partial-describe.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reference.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-reg-shuffle.mir
llvm/test/DebugInfo/MIR/X86/dbgcall-site-two-fwd-reg-defs.mir
llvm/test/DebugInfo/MIR/X86/dbginfo-entryvals.mir
llvm/test/DebugInfo/MIR/X86/debug-call-site-param.mir
llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir
llvm/test/DebugInfo/MIR/X86/entry-values-diamond-bbs.mir
llvm/test/DebugInfo/MIR/X86/propagate-entry-value-cross-bbs.mir
llvm/test/DebugInfo/MIR/X86/unreachable-block-call-site.mir
llvm/test/DebugInfo/X86/dbg-value-range.ll
llvm/test/DebugInfo/X86/dbg-value-regmask-clobber.ll
llvm/test/DebugInfo/X86/dbgcall-site-64-bit-imms.ll
llvm/test/DebugInfo/X86/dbgcall-site-zero-valued-imms.ll
llvm/test/DebugInfo/X86/loclists-dwp.ll
llvm/test/tools/llvm-locstats/locstats.ll

Removed: 




diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 3c8b0eeb47a5..e047054447f3 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -63,7 +63,6 @@ CODEGENOPT(ExperimentalNewPassManager, 1, 0) ///< Enables the 
new, experimental
 CODEGENOPT(DebugPassManager, 1, 0) ///< Prints debug information for the new
///< pass manager.
 CODEGENOPT(DisableRedZone, 1, 0) ///< Set when -mno-red-zone is enabled.
-CODEGENOPT(EnableDebugEntryValues, 1, 0) ///< Emit call site parameter dbg info
 CODEGENOPT(EmitCallSiteInfo, 1, 0) ///< Emit call site info only in the case of
///< '-g' + 'O>0' level.
 CODEGENOPT(IndirectTlsSegRefs, 1, 0) ///< Set when -mno-tls-direct-seg-refs

diff  --git a/clang/include/clang/Driver/CC1Options.td 
b/clang/include/clang/Driver/CC1Options.td
index b7a2826d8fcb..cc30893703df 100644
--- a/clang/include/clang/Driver/CC1Options.td
+++ b/clang/include/clang/Driver/CC1Options.td
@@ -388,8 +388,6 @@ def flto_visibility_public_std:
 def flto_unit: Flag<["-"], "flto-unit">,
 HelpText<"Emit IR to support LTO unit features (CFI, whole program vtable 
opt)">;
 def fno_lto_unit: Flag<["-"], "fno-lto-unit">;
-def femit_debug_entry_values : Flag<["-"], "femit-debug-entry-values">,
-HelpText<"Enables debug info about call site parameter's entry values">;
 def fdebug_pass_manager : Flag<["-"], "fdebug-pass-manager">,
 HelpText<"Prints debug information for the new pass m

[PATCH] D75896: [X86] Support intrinsic _mm_cldemote

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan created this revision.
skan added reviewers: LuoYuanke, craig.topper, RKSimon, pengfei.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75896

Files:
  clang/lib/Headers/cldemoteintrin.h
  clang/test/CodeGen/cldemote.c


Index: clang/test/CodeGen/cldemote.c
===
--- clang/test/CodeGen/cldemote.c
+++ clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }
Index: clang/lib/Headers/cldemoteintrin.h
===
--- clang/lib/Headers/cldemoteintrin.h
+++ clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDRMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif


Index: clang/test/CodeGen/cldemote.c
===
--- clang/test/CodeGen/cldemote.c
+++ clang/test/CodeGen/cldemote.c
@@ -7,4 +7,6 @@
   //CHECK-LABEL: @test_cldemote
   //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
   _cldemote(p);
+  //CHECK: call void @llvm.x86.cldemote(i8* %{{.*}})
+  _mm_cldemote(p);
 }
Index: clang/lib/Headers/cldemoteintrin.h
===
--- clang/lib/Headers/cldemoteintrin.h
+++ clang/lib/Headers/cldemoteintrin.h
@@ -18,11 +18,19 @@
 #define __DEFAULT_FN_ATTRS \
   __attribute__((__always_inline__, __nodebug__,  __target__("cldemote")))
 
+/// Hint to hardware that the cache line that contains \p __P should be demoted
+/// from the cache closest to the processor core to a level more distant from
+/// the processor core.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  CLDRMOTE  instruction.
 static __inline__ void __DEFAULT_FN_ATTRS
 _cldemote(const void * __P) {
   __builtin_ia32_cldemote(__P);
 }
 
+#define _mm_cldemote(p) _cldemote(p)
 #undef __DEFAULT_FN_ATTRS
 
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75897: [X86] Support intrinsic _mm_broadcastsi128_si256

2020-03-10 Thread Kan Shengchen via Phabricator via cfe-commits
skan created this revision.
skan added reviewers: LuoYuanke, craig.topper, RKSimon, pengfei.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75897

Files:
  clang/lib/Headers/avx2intrin.h
  clang/test/CodeGen/avx2-builtins.c


Index: clang/test/CodeGen/avx2-builtins.c
===
--- clang/test/CodeGen/avx2-builtins.c
+++ clang/test/CodeGen/avx2-builtins.c
@@ -208,6 +208,12 @@
   return _mm256_broadcastsi128_si256(a);
 }
 
+__m256i test_mm_broadcastsi128_si256(__m128i a) {
+  // CHECK-LABEL: test_mm_broadcastsi128_si256
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
+  return _mm_broadcastsi128_si256(a);
+}
+
 __m128 test_mm_broadcastss_ps(__m128 a) {
   // CHECK-LABEL: test_mm_broadcastss_ps
   // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps
Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -740,6 +740,8 @@
   return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 
1);
 }
 
+#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
+
 #define _mm_blend_epi32(V1, V2, M) \
   (__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
  (__v4si)(__m128i)(V2), (int)(M))


Index: clang/test/CodeGen/avx2-builtins.c
===
--- clang/test/CodeGen/avx2-builtins.c
+++ clang/test/CodeGen/avx2-builtins.c
@@ -208,6 +208,12 @@
   return _mm256_broadcastsi128_si256(a);
 }
 
+__m256i test_mm_broadcastsi128_si256(__m128i a) {
+  // CHECK-LABEL: test_mm_broadcastsi128_si256
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <4 x i32> 
+  return _mm_broadcastsi128_si256(a);
+}
+
 __m128 test_mm_broadcastss_ps(__m128 a) {
   // CHECK-LABEL: test_mm_broadcastss_ps
   // CHECK-NOT: @llvm.x86.avx2.vbroadcast.ss.ps
Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -740,6 +740,8 @@
   return (__m256i)__builtin_shufflevector((__v2di)__X, (__v2di)__X, 0, 1, 0, 1);
 }
 
+#define _mm_broadcastsi128_si256(X) _mm256_broadcastsi128_si256(X)
+
 #define _mm_blend_epi32(V1, V2, M) \
   (__m128i)__builtin_ia32_pblendd128((__v4si)(__m128i)(V1), \
  (__v4si)(__m128i)(V2), (int)(M))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-03-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:8132
+  return VisitTypeSpecTypeLoc(FTS);
+llvm_unreachable("Unimplemented TypeLoc visitor function");
+  }

This assert is new related to the old code. Are really all TypeLoc's are 
implemented (probably analyze with CTU a large project)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[clang] 5a101f3 - Revert "[clang-format] Correct indentation for `[key] = value,` entries in C++ object initialisers"

2020-03-10 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-10T09:30:34Z
New Revision: 5a101f377315c0c0c58e8df842fe5eb5d8c7611d

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

LOG: Revert "[clang-format] Correct indentation for `[key] = value,` entries in 
C++ object initialisers"

Commit message says "C++" where it should say "C#".

This reverts commit cb3f20d27c9e91cb9f997f0401f388e62c4ba993.

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 9a6d7877efaa..a08f5a3df864 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,9 +1047,6 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
-else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
-   // initializers.
-  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index 7f819a61c70e..a22f48676065 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -549,15 +549,6 @@ Shape[] shapes = new[] { new Circle { Radius = 2.7281, 
Colour = Colours.Red },
 private Transformer _transformer = new X.Y {
   Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
-};)",
-   Style);
-
-  // Dictionary initialisation.
-  verifyFormat(R"(//
-var myDict = new Dictionary {
-  ["name"] = _donald,
-  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
-  ["type"] = _duck,
 };)",
Style);
 }



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


[clang] 0c28a09 - [clang-format] Correct indentation for `[key] = value,` entries in C# object initialisers

2020-03-10 Thread Jonathan Coe via cfe-commits

Author: Jonathan Coe
Date: 2020-03-10T09:36:52Z
New Revision: 0c28a0938c55ad34587fe88ac54ff2c85e79fa70

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

LOG: [clang-format] Correct indentation for `[key] = value,` entries in C# 
object initialisers

Restores content of commit cb3f20d27c9e91cb9f997f0401f388e62c4ba993
reverted in commit 5a101f377315c0c0c58e8df842fe5eb5d8c7611d
with a corrected commit message.

Summary: Do not use continuation indent for '[' in blocks in C# code.

Reviewers: krasimir

Reviewed By: krasimir

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Added: 


Modified: 
clang/lib/Format/ContinuationIndenter.cpp
clang/unittests/Format/FormatTestCSharp.cpp

Removed: 




diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index a08f5a3df864..9a6d7877efaa 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -1047,6 +1047,9 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   if (NextNonComment->is(TT_ArraySubscriptLSquare)) {
 if (State.Stack.back().StartOfArraySubscripts != 0)
   return State.Stack.back().StartOfArraySubscripts;
+else if (Style.isCSharp()) // C# allows `["key"] = value` inside object
+   // initializers.
+  return State.Stack.back().Indent;
 return ContinuationIndent;
   }
 

diff  --git a/clang/unittests/Format/FormatTestCSharp.cpp 
b/clang/unittests/Format/FormatTestCSharp.cpp
index a22f48676065..7f819a61c70e 100644
--- a/clang/unittests/Format/FormatTestCSharp.cpp
+++ b/clang/unittests/Format/FormatTestCSharp.cpp
@@ -549,6 +549,15 @@ Shape[] shapes = new[] { new Circle { Radius = 2.7281, 
Colour = Colours.Red },
 private Transformer _transformer = new X.Y {
   Filler = (Shape shape) => { return new Transform.Fill(shape, RED); },
   Scaler = (Shape shape) => { return new Transform.Resize(shape, 0.1); },
+};)",
+   Style);
+
+  // Dictionary initialisation.
+  verifyFormat(R"(//
+var myDict = new Dictionary {
+  ["name"] = _donald,
+  ["age"] = Convert.ToString(DateTime.Today.Year - 1934),
+  ["type"] = _duck,
 };)",
Style);
 }



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


[PATCH] D75898: [Analyzer][NFC] Change parameter of NoteTag lambdas to PathSensitiveBugReport

2020-03-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.
baloghadamsoftware added reviewers: NoQ, Szelethus.
baloghadamsoftware added a project: clang.
Herald added subscribers: martong, steakhal, Charusso, gamesh411, dkrupp, 
donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, xazax.hun, whisperity.

Lambdas creating path notes using `NoteTag`s still take `BugReport` as their 
parameter. Since path notes obviously only appear in `PathSensitiveBugReport`s 
it is straightforward that lambdas of `NoteTag`s take `PathSensitiveBugReport` 
as their parameter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75898

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -221,7 +221,7 @@
   if (L.getSrc()->getTerminator().isVirtualBaseBranch() &&
   L.getDst() == *L.getSrc()->succ_begin()) {
 ProgramPoint P = L.withTag(getNoteTags().makeNoteTag(
-[](BugReporterContext &, BugReport &) -> std::string {
+[](BugReporterContext &, PathSensitiveBugReport &) -> std::string {
   // TODO: Just call out the name of the most derived class
   // when we know it.
   return "Virtual base initialization skipped because "
Index: clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
@@ -99,7 +99,7 @@
 
   std::string Name = getName(Call);
   const NoteTag *CallTag = C.getNoteTag(
-  [Name, ExpectedValue](BugReport &) -> std::string {
+  [Name, ExpectedValue](PathSensitiveBugReport &) -> std::string {
 SmallString<128> Msg;
 llvm::raw_svector_ostream Out(Msg);
 
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -210,15 +210,16 @@
   if (!PVD || State->contains(PVD))
 return;
 
-  const NoteTag *T = C.getNoteTag([this, PVD](BugReport &BR) -> std::string {
-if (&BR.getBugType() != &BT)
-  return "";
-SmallString<64> Str;
-llvm::raw_svector_ostream OS(Str);
-OS << "Value passed through parameter '" << PVD->getName()
-   << "\' is deallocated";
-return std::string(OS.str());
-  });
+  const NoteTag *T =
+C.getNoteTag([this, PVD](PathSensitiveBugReport &BR) -> std::string {
+if (&BR.getBugType() != &BT)
+  return "";
+SmallString<64> Str;
+llvm::raw_svector_ostream OS(Str);
+OS << "Value passed through parameter '" << PVD->getName()
+   << "\' is deallocated";
+return std::string(OS.str());
+  });
   C.addTransition(State->set(true), T);
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -383,7 +383,8 @@
   const NoteTag *T = nullptr;
   if (!Notes.empty()) {
 T = C.getNoteTag(
-[this, Notes{std::move(Notes)}](BugReport &BR) -> std::string {
+  [this, Notes{std::move(Notes)}](PathSensitiveBugReport &BR)
+-> std::string {
   if (&BR.getBugType() != &UseAfterReleaseBugType &&
   &BR.getBugType() != &LeakBugType &&
   &BR.getBugType() != &DoubleReleaseBugType)
Index: clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
@@ -53,7 +53,7 @@
 
   ProgramStateRef SelfAssignState = State->bindLoc(Param, ThisVal, LCtx);
   const NoteTag *SelfAssignTag =
-C.getNoteTag([MD](BugReport &BR) -> std::string {
+C.getNoteTag([MD](PathSensitiveBugReport &BR) -> std::string {
 SmallString<256> Msg;
 llvm::raw_svector_ostream Out(Msg);
 Out << "Assuming " << MD->getParamDecl(0)->getName() << " == *this";
@@ -63,7 +63,7 @@
 
   ProgramStateRef NonSelfAssignState = State->bindLoc(Param, ParamVal, LCtx);
   const NoteTag *NonSelfAssignTag =
-C.getNoteTag([MD](Bug

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Test falls in Windows: http://45.33.8.238/win/10088/step_8.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D75898: [Analyzer][NFC] Change parameter of NoteTag lambdas to PathSensitiveBugReport

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

Thanks!!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75898



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


[clang] 20a3d64 - [Analyzer][NFC] Change parameter of NoteTag lambdas to PathSensitiveBugReport

2020-03-10 Thread Adam Balogh via cfe-commits

Author: Adam Balogh
Date: 2020-03-10T11:30:28+01:00
New Revision: 20a3d64c8883c8be550f0759525b1550b7c2d35f

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

LOG: [Analyzer][NFC] Change parameter of NoteTag lambdas to 
PathSensitiveBugReport

Lambdas creating path notes using NoteTags still take BugReport as their
parameter. Since path notes obviously only appear in PathSensitiveBugReports
it is straightforward that lambdas of NoteTags take PathSensitiveBugReport
as their parameter.

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
index 1b39cdf12c80..d45c4b71e780 100644
--- a/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
+++ b/clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
@@ -726,7 +726,8 @@ class BugReporterContext {
 class NoteTag : public ProgramPointTag {
 public:
   using Callback =
-  std::function;
+  std::function;
 
 private:
   static int Kind;
@@ -743,7 +744,7 @@ class NoteTag : public ProgramPointTag {
   }
 
   Optional generateMessage(BugReporterContext &BRC,
-BugReport &R) const {
+PathSensitiveBugReport &R) const {
 std::string Msg = Cb(BRC, R);
 if (Msg.empty())
   return None;

diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
index aee26db95fd1..2b5d37b6cc41 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -258,10 +258,12 @@ class CheckerContext {
   /// @param IsPrunable Whether the note is prunable. It allows BugReporter
   ///to omit the note from the report if it would make the displayed
   ///bug path significantly shorter.
-  const NoteTag *getNoteTag(std::function &&Cb,
-bool IsPrunable = false) {
+  const NoteTag
+  *getNoteTag(std::function &&Cb,
+  bool IsPrunable = false) {
 return getNoteTag(
-[Cb](BugReporterContext &, BugReport &BR) { return Cb(BR); },
+[Cb](BugReporterContext &,
+ PathSensitiveBugReport &BR) { return Cb(BR); },
 IsPrunable);
   }
 
@@ -274,7 +276,8 @@ class CheckerContext {
   ///bug path significantly shorter.
   const NoteTag *getNoteTag(std::function &&Cb,
 bool IsPrunable = false) {
-return getNoteTag([Cb](BugReporterContext &, BugReport &) { return Cb(); },
+return getNoteTag([Cb](BugReporterContext &,
+   PathSensitiveBugReport &) { return Cb(); },
   IsPrunable);
   }
 
@@ -286,7 +289,8 @@ class CheckerContext {
   ///bug path significantly shorter.
   const NoteTag *getNoteTag(StringRef Note, bool IsPrunable = false) {
 return getNoteTag(
-[Note](BugReporterContext &, BugReport &) { return std::string(Note); 
},
+[Note](BugReporterContext &,
+   PathSensitiveBugReport &) { return std::string(Note); },
 IsPrunable);
   }
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
index f7cee71ef0a1..aada05db2cbc 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
@@ -53,7 +53,7 @@ void 
CXXSelfAssignmentChecker::checkBeginFunction(CheckerContext &C) const {
 
   ProgramStateRef SelfAssignState = State->bindLoc(Param, ThisVal, LCtx);
   const NoteTag *SelfAssignTag =
-C.getNoteTag([MD](BugReport &BR) -> std::string {
+C.getNoteTag([MD](PathSensitiveBugReport &BR) -> std::string {
 SmallString<256> Msg;
 llvm::raw_svector_ostream Out(Msg);
 Out << "Assuming " << MD->getParamDecl(0)->getName() << " == *this";
@@ -63,7 +63,7 @@ void 
CXXSelfAssignmentChecker::checkBeginFunction(CheckerContext &C) const {
 
   ProgramStateRef NonSelfAssignState = State->bindLoc(Param, ParamVal, LCtx);
   const NoteTag *NonSelfAssignTag 

[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-03-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:8132
+  return VisitTypeSpecTypeLoc(FTS);
+llvm_unreachable("Unimplemented TypeLoc visitor function");
+  }

balazske wrote:
> This assert is new related to the old code. Are really all TypeLoc's are 
> implemented (probably analyze with CTU a large project)?
Yeah, I am not going to commit this, until our full CI job is green on the 
change. That job analyzes Tmux, Redis, Curl, Xercex, Bitcoin and Protobuf and 
considered as a quite good coverage for the Analyzer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


[PATCH] D75901: [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode

2020-03-10 Thread Alex Cameron via Phabricator via cfe-commits
tetsuo-cpp created this revision.
tetsuo-cpp added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun.
Herald added a project: clang.
tetsuo-cpp added reviewers: njames93, MaskRay.

Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=27702
I wasn't sure how this type of thing is usually tested. So any advice would be 
appreciated.
`check-llvm`, `check-clang` and `check-clang-tools` are clean for me.
**C++98**

  tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
  [
  {
"directory": "/home/tetsuo/dev/llvm-project/test",
"command": "/usr/bin/c++  -std=gnu++98 -o 
CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
"file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
  }
  ]
  tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy 
--checks=misc-unconventional-assign-operator test.cpp
  3053 warnings generated.
  /home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should 
take 'Foo const&' or 'Foo' [misc-unconventional-assign-operator]
Foo &operator=(Foo &Other) {
^
  Suppressed 3052 warnings (3052 in non-user code).
  Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.

**C++17**

  tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
  [
  {
"directory": "/home/tetsuo/dev/llvm-project/test",
"command": "/usr/bin/c++  -std=gnu++17 -o 
CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
"file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
  }
  ]
  tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy 
--checks=misc-unconventional-assign-operator test.cpp
  5377 warnings generated.
  /home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should 
take 'Foo const&', 'Foo&&' or 'Foo' [misc-unconventional-assign-operator]
Foo &operator=(Foo &Other) {
^
  Suppressed 5376 warnings (5376 in non-user code).
  Use -header-filter=.* to display errors from all non-system headers. Use 
-system-headers to display errors from system headers as well.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75901

Files:
  clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp


Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -73,9 +73,14 @@
   if (const auto *RetStmt = Result.Nodes.getNodeAs("returnStmt")) {
 diag(RetStmt->getBeginLoc(), "operator=() should always return '*this'");
   } else {
+const ASTContext *ASTCtx = Result.Context;
+const LangOptions &Opts = ASTCtx->getLangOpts();
 static const char *const Messages[][2] = {
 {"ReturnType", "operator=() should return '%0&'"},
-{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or 
'%0'"},
+{"ArgumentType",
+ Opts.CPlusPlus11
+ ? "operator=() should take '%0 const&', '%0&&' or '%0'"
+ : "operator=() should take '%0 const&' or '%0'"},
 {"cv", "operator=() should not be marked '%1'"}};
 
 const auto *Method = Result.Nodes.getNodeAs("method");


Index: clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp
@@ -73,9 +73,14 @@
   if (const auto *RetStmt = Result.Nodes.getNodeAs("returnStmt")) {
 diag(RetStmt->getBeginLoc(), "operator=() should always return '*this'");
   } else {
+const ASTContext *ASTCtx = Result.Context;
+const LangOptions &Opts = ASTCtx->getLangOpts();
 static const char *const Messages[][2] = {
 {"ReturnType", "operator=() should return '%0&'"},
-{"ArgumentType", "operator=() should take '%0 const&', '%0&&' or '%0'"},
+{"ArgumentType",
+ Opts.CPlusPlus11
+ ? "operator=() should take '%0 const&', '%0&&' or '%0'"
+ : "operator=() should take '%0 const&' or '%0'"},
 {"cv", "operator=() should not be marked '%1'"}};
 
 const auto *Method = Result.Nodes.getNodeAs("method");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75698: [analyzer][WIP] Suppress bug reports where a tracked expression's latest value change was a result of an invalidation

2020-03-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

> P.S. So, like, we could try to emit the warning only if we covered enough 
> execution paths to prove that there's either dead code or the warning is 
> true. Then we would no longer care about invalidation problems. 
> Unfortunately, i don't have any specific suggestion of how to prove such 
> facts for an arbitrary CFG.

If I understand you correctly, this would mean that we have to reason about all 
possible execution paths at the same time to do this. Actually, that would be 
possible only with some kind of a fix-point flow-analysis and clearly the 
symbolic execution we have in CSA is a completely different beast (it reasons 
about one path where there is a bug).

> P.P.S. Actually you know what, maybe we should only drop the report if the 
> constraint over the invalidated value contradicts the constraint over the old 
> value. That'll make things a bit more complicated and will require a visitor 
> indeed, though hopefully not as complicated as concrete value tracking, as 
> we're still interested in only one region at a time.

How would that be different than proving the feasibility of the path with Z3? 
Could we reuse Mikhail's work here, or that would be overkill for this task?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75698



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


[PATCH] D75898: [Analyzer][NFC] Change parameter of NoteTag lambdas to PathSensitiveBugReport

2020-03-10 Thread Balogh, Ádám via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG20a3d64c8883: [Analyzer][NFC] Change parameter of NoteTag 
lambdas to PathSensitiveBugReport (authored by baloghadamsoftware).

Changed prior to commit:
  https://reviews.llvm.org/D75898?vs=249289&id=249302#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75898

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
  clang/lib/StaticAnalyzer/Core/CoreEngine.cpp

Index: clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
@@ -221,7 +221,7 @@
   if (L.getSrc()->getTerminator().isVirtualBaseBranch() &&
   L.getDst() == *L.getSrc()->succ_begin()) {
 ProgramPoint P = L.withTag(getNoteTags().makeNoteTag(
-[](BugReporterContext &, BugReport &) -> std::string {
+[](BugReporterContext &, PathSensitiveBugReport &) -> std::string {
   // TODO: Just call out the name of the most derived class
   // when we know it.
   return "Virtual base initialization skipped because "
Index: clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
@@ -99,7 +99,7 @@
 
   std::string Name = getName(Call);
   const NoteTag *CallTag = C.getNoteTag(
-  [Name, ExpectedValue](BugReport &) -> std::string {
+  [Name, ExpectedValue](PathSensitiveBugReport &) -> std::string {
 SmallString<128> Msg;
 llvm::raw_svector_ostream Out(Msg);
 
Index: clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
@@ -210,15 +210,16 @@
   if (!PVD || State->contains(PVD))
 return;
 
-  const NoteTag *T = C.getNoteTag([this, PVD](BugReport &BR) -> std::string {
-if (&BR.getBugType() != &BT)
-  return "";
-SmallString<64> Str;
-llvm::raw_svector_ostream OS(Str);
-OS << "Value passed through parameter '" << PVD->getName()
-   << "\' is deallocated";
-return std::string(OS.str());
-  });
+  const NoteTag *T =
+C.getNoteTag([this, PVD](PathSensitiveBugReport &BR) -> std::string {
+if (&BR.getBugType() != &BT)
+  return "";
+SmallString<64> Str;
+llvm::raw_svector_ostream OS(Str);
+OS << "Value passed through parameter '" << PVD->getName()
+   << "\' is deallocated";
+return std::string(OS.str());
+  });
   C.addTransition(State->set(true), T);
 }
 
Index: clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/FuchsiaHandleChecker.cpp
@@ -382,8 +382,8 @@
   }
   const NoteTag *T = nullptr;
   if (!Notes.empty()) {
-T = C.getNoteTag(
-[this, Notes{std::move(Notes)}](BugReport &BR) -> std::string {
+T = C.getNoteTag([this, Notes{std::move(Notes)}](
+ PathSensitiveBugReport &BR) -> std::string {
   if (&BR.getBugType() != &UseAfterReleaseBugType &&
   &BR.getBugType() != &LeakBugType &&
   &BR.getBugType() != &DoubleReleaseBugType)
Index: clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CXXSelfAssignmentChecker.cpp
@@ -53,7 +53,7 @@
 
   ProgramStateRef SelfAssignState = State->bindLoc(Param, ThisVal, LCtx);
   const NoteTag *SelfAssignTag =
-C.getNoteTag([MD](BugReport &BR) -> std::string {
+C.getNoteTag([MD](PathSensitiveBugReport &BR) -> std::string {
 SmallString<256> Msg;
 llvm::raw_svector_ostream Out(Msg);
 Out << "Assuming " << MD->getParamDecl(0)->getName() << " == *this";
@@ -63,7 +63,7 @@
 
   ProgramStateRef NonSelfAssignState = State->bindLoc(Param, ParamVal, LCtx);
   const NoteTag *NonSelfAssignTag =
-C.getNoteTag([MD](BugReport &BR) -> std::string {
+C.getNoteTag([MD](PathSensitiveBugReport &BR) -> std::string {
 SmallString<256> Msg;
 llvm::raw_svector_ostream Out(Msg);
 Out << "Assuming " << M

[PATCH] D75903: [AArch64][CodeGen] Fixing stack alignment of HFA arguments on AArch64 PCS

2020-03-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
pratlucas added a child revision: D75904: [ARM][CodeGen] Fixing stack alignment 
of HFA arguments on AArch32 PCS.
pratlucas added reviewers: t.p.northover, rnk, olista01, bogner.

Properly complying with AArch64 PCS on the handling of over-aligned HFA
arguments when those are placed on the stack. AAPCS64 specifies that the
stacked argument address should be rounded up to the Natural Alignment
of the argument before the argument is copied to memory.

Over alignment information extracted from language attributes on clang
was not properly propagated to the backend for those arguments, as it
does not map to the backend's base type alignments. As the standard also
specifies that, when placed in registers, a single FP register should be
allocated for each individual HFA element, type coercion is no suitable
for capturing the alignment constraints.

This patch fixes the alignment of these arguments by capturing their
stack alignment requirements in an IR argument attribute, making sure
this information is available for the calling convention lowering stage.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75903

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-args-hfa.c
  clang/test/CodeGen/arm64-arguments.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/TargetCallingConv.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Argument.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
  llvm/test/Bitcode/compatibility.ll
  llvm/test/CodeGen/AArch64/arm64-abi-hfa-args.ll

Index: llvm/test/CodeGen/AArch64/arm64-abi-hfa-args.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/arm64-abi-hfa-args.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s -mtriple=arm64-none-eabi | FileCheck %s
+
+; Over-aligned HFA argument placed on register - one element per register
+define double @test_hfa_align_arg_reg([2 x double] alignstack(16) %h.coerce) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_arg_reg:
+; CHECK-DAG: ret
+
+  %h.coerce.fca.0.extract = extractvalue [2 x double] %h.coerce, 0
+  ret double %h.coerce.fca.0.extract
+}
+
+; Call with over-aligned HFA argument placed on register - one element per register
+define double @test_hfa_align_call_reg() local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_call_reg:
+; CHECK-DAG: fmov	d0, #1.
+; CHECK-DAG: fmov	d1, #2.
+; CHECK-DAG: bl	test_hfa_align_arg_reg
+; CHECK-DAG: ldr	x30, [sp], #16  // 8-byte Folded Reload
+; CHECK-DAG: ret
+
+  %call = call double @test_hfa_align_arg_reg([2 x double] alignstack(16) [double 1.00e+00, double 2.00e+00])
+  ret double %call
+}
+
+; Over-aligned HFA argument placed on stack - stack round up to alignment
+define double @test_hfa_align_arg_stack(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %f, [2 x double] alignstack(16) %h.coerce) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_arg_stack:
+; CHECK-DAG: ldr	d0, [sp, #16]
+; CHECK-DAG: ret
+
+  %h.coerce.fca.0.extract = extractvalue [2 x double] %h.coerce, 0
+  ret double %h.coerce.fca.0.extract
+}
+
+; Call with over-aligned HFA argument placed on stack - stack round up to alignment
+define double @test_hfa_align_call_stack() local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_call_stack:
+; CHECK-DAG: mov	x8, #4611686018427387904
+; CHECK-DAG: mov	x9, #4607182418800017408
+; CHECK-DAG: stp	x8, x30, [sp, #24]  // 8-byte Folded Spill
+; CHECK-DAG: str	x9, [sp, #16]
+; CHECK-DAG: bl	test_hfa_align_arg
+; CHECK-DAG: ldr	x30, [sp, #32]  // 8-byte Folded Reload
+; CHECK-DAG: add	sp, sp, #48 // =48
+; CHECK-DAG: ret
+
+  %call = call double @test_hfa_align_arg_stack(double undef, double undef, double undef, double undef, double undef, double undef, double undef, double undef, float undef, [2 x double] alignstack(16) [double 1.00e+00, double 2.00e+00])
+  ret double %call
+}
+
Index: llvm/test/Bitcode/compatibility.ll
===
--- llvm/test/Bitcode/compatibility.ll
+++ llvm/test/Bitcode/compatibility.ll
@@ -548,6 +548,8 @@
 ; CHECK: declare void @f.param.dereferenceable(i8* dereferenceable(4))
 declare void @f.param.dereferenceable_or_null(i8* dereferenceable_or

[PATCH] D75904: [ARM][CodeGen] Fixing stack alignment of HFA arguments on AArch32 PCS

2020-03-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas created this revision.
Herald added subscribers: llvm-commits, cfe-commits, danielkiss, hiraditya, 
kristof.beyls.
Herald added projects: clang, LLVM.
pratlucas added a parent revision: D75903: [AArch64][CodeGen] Fixing stack 
alignment of HFA arguments on AArch64 PCS.
pratlucas added reviewers: t.p.northover, olista01, rnk, asl.

Properly complying with AArch32 PCS on the handling of over-aligned HFA
arguments when those are placed on the stack. AAPCS specifies that the
stacked argument address should be adjusted upwards until correctly
aligned for the argument before copying it to memory.

This patch fixes the alignment of these arguments by makign use of the
stack alignment propagated through the `alignstack` IR argument
attribute during the calling convention lowering for ARM targets.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75904

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/arm-aapcs-vfp.c
  llvm/lib/Target/ARM/ARMCallingConv.cpp
  llvm/test/CodeGen/ARM/aapcs-hfa-code.ll

Index: llvm/test/CodeGen/ARM/aapcs-hfa-code.ll
===
--- llvm/test/CodeGen/ARM/aapcs-hfa-code.ll
+++ llvm/test/CodeGen/ARM/aapcs-hfa-code.ll
@@ -3,6 +3,8 @@
 
 target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-n32-S64"
 
+%struct.hfa_align = type { [2 x float] }
+
 define arm_aapcs_vfpcc void @test_1float({ float } %a) {
   call arm_aapcs_vfpcc void @test_1float({ float } { float 1.0 })
   ret void
@@ -104,3 +106,73 @@
 
   ret void
 }
+
+; Over-aligned HFA argument placed on register - one element per register
+define arm_aapcs_vfpcc float @test_hfa_align_reg(%struct.hfa_align alignstack(8) %h1.coerce) local_unnamed_addr #3 {
+entry:
+; CHECK-LABEL: test_hfa_align_reg:
+; CHECK-DAG: bx lr
+
+; CHECK-M4F-LABEL: test_hfa_align_reg:
+; CHECK-M4F-DAG: bx lr
+
+  %h1.coerce.fca.0.0.extract = extractvalue %struct.hfa_align %h1.coerce, 0, 0
+  ret float %h1.coerce.fca.0.0.extract
+}
+
+; Call with over-align HFA argument placed on registers - one element per register
+define arm_aapcs_vfpcc float @test_hfa_align_reg_call() local_unnamed_addr #3 {
+entry:
+; CHECK-LABEL: test_hfa_align_reg_call:
+; CHECK-DAG: vmov.f32	s0, #1.00e+00
+; CHECK-DAG: vmov.f32	s1, #2.00e+00
+; CHECK-DAG: bl	test_hfa_align_reg
+
+; CHECK-M4F-LABEL: test_hfa_align_reg_call:
+; CHECK-M4F-DAG: vmov.f32	s0, #1.00e+00
+; CHECK-M4F-DAG: vmov.f32	s1, #2.00e+00
+; CHECK-M4F-DAG: bl	test_hfa_align_reg
+
+  %call = call arm_aapcs_vfpcc float @test_hfa_align_reg(%struct.hfa_align alignstack(8) { [2 x float] [float 1.00e+00, float 2.00e+00] }) #5
+  ret float %call
+}
+
+; Over-aligned HFA argument placed on the stack - stack round up to alignment
+define arm_aapcs_vfpcc float @test_hfa_align_stack(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %f1, %struct.hfa_align alignstack(8) %h1.coerce) local_unnamed_addr #3 {
+entry:
+; CHECK-LABEL: test_hfa_align_stack:
+; CHECK-DAG: vldr	s0, [sp, #8]
+; CHECK-DAG: bx	lr
+
+; CHECK-M4F-LABEL: test_hfa_align_stack:
+; CHECK-M4F-DAG: vldr	s0, [sp, #8]
+; CHECK-M4F-DAG: bx	lr
+
+  %h1.coerce.fca.0.0.extract = extractvalue %struct.hfa_align %h1.coerce, 0, 0
+  ret float %h1.coerce.fca.0.0.extract
+}
+
+; Call with over-aligned HFA argument placed on the stack - stack round up to alignment
+define arm_aapcs_vfpcc float @test_hfa_align_stack_call() local_unnamed_addr #3 {
+entry:
+; CHECK-LABEL: test_hfa_align_stack_call:
+; CHECK-DAG: sub	sp, sp, #16
+; CHECK-DAG: mov	r0, #1073741824
+; CHECK-DAG: mov	r1, #1065353216
+; CHECK-DAG: str	r1, [sp, #8]
+; CHECK-DAG: str	r0, [sp, #12]
+; CHECK-DAG: bl	test_hfa_align_stack
+; CHECK-DAG: add	sp, sp, #16
+
+; CHECK-M4F-LABEL: test_hfa_align_stack_call:
+; CHECK-M4F-DAG: sub	sp, #16
+; CHECK-M4F-DAG: mov.w	r0, #1073741824
+; CHECK-M4F-DAG: mov.w	r1, #1065353216
+; CHECK-M4F-DAG: strd	r1, r0, [sp, #8]
+; CHECK-M4F-DAG: bl	test_hfa_align_stack
+; CHECK-M4F-DAG: add	sp, #16
+
+  %call = call arm_aapcs_vfpcc float @test_hfa_align_stack(double undef, double undef, double undef, double undef, double undef, double undef, double undef, double undef, float undef, %struct.hfa_align alignstack(8) { [2 x float] [float 1.00e+00, float 2.00e+00] }) #5
+  ret float %call
+}
+
Index: llvm/lib/Target/ARM/ARMCallingConv.cpp
===
--- llvm/lib/Target/ARM/ARMCallingConv.cpp
+++ llvm/lib/Target/ARM/ARMCallingConv.cpp
@@ -266,7 +266,10 @@
   // possible. (E.g. an incoming i64 would have starting Align of 8, but we'll
   // be allocating a bunch of i32 slots).
   unsigned RestAlign = std::min(Align, Size);
-
+  if (ArgFlags.getStackAlign()) {
+const llvm::Align ArgStackAlign(ArgFlags.getStackAlign());
+Align = std::max(Align, unsigned(ArgStackAlign.value()));
+  }
   for (auto &It : PendingMembers) {
 It.convertToMem(State.AllocateStack(Size, Al

[PATCH] D75529: [analyzer] Limit UCharMax to min of max uchar or max int

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.

I have nothing else to add :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75529



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


[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249307.
njames93 added a comment.
Herald added subscribers: arphaman, kbarton, nemanjai.

- Add usages, removed optional on arrayrefs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang/include/clang/Basic/Diagnostic.h

Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -1288,6 +1289,29 @@
   return DB;
 }
 
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB, const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+};
+
 /// A nullability kind paired with a bit indicating whether it used a
 /// context-sensitive keyword.
 using DiagNullabilityKind = std::pair;
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -429,11 +429,9 @@
   if (MakeSmartPtrFunctionHeader.empty()) {
 return;
   }
-  if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
-  FD, MakeSmartPtrFunctionHeader,
-  /*IsAngled=*/MakeSmartPtrFunctionHeader == StdMemoryHeader)) {
-Diag << *IncludeFixit;
-  }
+  Diag << Inserter->CreateIncludeInsertion(
+  FD, MakeSmartPtrFunctionHeader,
+  /*IsAngled=*/MakeSmartPtrFunctionHeader == StdMemoryHeader);
 }
 
 } // namespace modernize
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -86,13 +86,10 @@
   SourceRange(BaseRange.getEnd().getLocWithOffset(1),
   IndexRange.getBegin().getLocWithOffset(-1)),
   ", ")
-   << FixItHint::CreateReplacement(Matched->getEndLoc(), ")");
-
-  Optional Insertion = Inserter->CreateIncludeInsertion(
-  Result.SourceManager->getMainFileID(), GslHeader,
-  /*IsAngled=*/false);
-  if (Insertion)
-Diag << Insertion.getValue();
+   << FixItHint::CreateReplacement(Matched->getEndLoc(), ")")
+   << Inserter->CreateIncludeInsertion(
+  Result.SourceManager->getMainFileID(), GslHeader,
+  /*IsAngled=*/false);
 }
 return;
   }
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -96,10 +96,8 @@
MatchedDecl->getName().size()),
InitializationString);
 if (AddMathInclude) {
-  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
+  Diagnostic << IncludeInserter->CreateIncludeInsertion(
   Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader, false);
-  if (IncludeHint)
-Diagnostic << *IncludeHint;
 }
   }
 }
Index: clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -105,12 +105,9 @@
 
   // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
   // whether this already exists).
-  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
+  Diagnostic << IncludeInserter->CreateIncludeInsertion(
   Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader,
   false);
-  if (IncludeHint) {
-Diagnostic << *IncludeHint

[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-10 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Two nits, then I'd be happy for this to land.

It would be useful if @jrtc27 would also re-review, as he has blocking comments 
(which I believe are now addressed).




Comment at: clang/docs/ClangCommandLineReference.rst:2958
+
+Put global and static data smaller than the limitation into a special section 
(RISCV only)
+

"(RISC-V only)" please



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:688
+  case llvm::Triple::riscv64:
+getModule().addModuleFlag(llvm::Module::ModFlagBehaviorFirstVal,
+  "SmallDataLimit", CodeGenOpts.SmallDataLimit);

You should not be using `ModFlagBehaviourFirstVal` here - use `Error` if that 
is what you intend for conflicting values. The other possible option is `Max` 
but that could be confusing (I think we'd prefer `Min`, which doesn't yet exist)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497



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


[PATCH] D75470: [SVE] Auto-generate builtins and header for svld1.

2020-03-10 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 249312.
sdesmalen added a comment.

s/NeonIntrinsicInfo/ARMVectorIntrinsicInfo/
s/findNeonIntrinsicInMap/findARMVectorIntrinsicInMap/


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

https://reviews.llvm.org/D75470

Files:
  clang/include/clang/Basic/AArch64SVETypeFlags.h
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/include/clang/Basic/BuiltinsSVE.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sve.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/utils/TableGen/SveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -92,6 +92,8 @@
 void EmitNeonTest2(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitSveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveBuiltins(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitSveCodeGenMap(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
 void EmitMveHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -71,6 +71,8 @@
   GenArmMveBuiltinCG,
   GenArmMveBuiltinAliases,
   GenArmSveHeader,
+  GenArmSveBuiltins,
+  GenArmSveCodeGenMap,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -183,6 +185,10 @@
"Generate ARM NEON tests for clang"),
 clEnumValN(GenArmSveHeader, "gen-arm-sve-header",
"Generate arm_sve.h for clang"),
+clEnumValN(GenArmSveBuiltins, "gen-arm-sve-builtins",
+   "Generate arm_sve_builtins.inc for clang"),
+clEnumValN(GenArmSveCodeGenMap, "gen-arm-sve-codegenmap",
+   "Generate arm_sve_codegenmap.inc for clang"),
 clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
"Generate arm_mve.h for clang"),
 clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
@@ -357,6 +363,12 @@
   case GenArmSveHeader:
 EmitSveHeader(Records, OS);
 break;
+  case GenArmSveBuiltins:
+EmitSveBuiltins(Records, OS);
+break;
+  case GenArmSveCodeGenMap:
+EmitSveCodeGenMap(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -29,6 +29,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/TableGen/Record.h"
 #include "llvm/TableGen/Error.h"
+#include "clang/Basic/AArch64SVETypeFlags.h"
 #include 
 #include 
 #include 
@@ -36,12 +37,201 @@
 
 using namespace llvm;
 
-//===--===//
-// SVEEmitter
-//===--===//
+enum ClassKind {
+  ClassNone,
+  ClassS, // signed/unsigned, e.g., "_s8", "_u8" suffix
+  ClassG, // Overloaded name without type suffix
+};
+
+using TypeSpec = std::string;
+using SVETypeFlags = clang::SVETypeFlags;
 
 namespace {
 
+class SVEType {
+  TypeSpec TS;
+  bool Float, Signed, Immediate, Void, Constant, Pointer;
+  bool DefaultType, IsScalable, Predicate, PredicatePattern, PrefetchOp;
+  unsigned Bitwidth, ElementBitwidth, NumVectors;
+
+public:
+  SVEType() : SVEType(TypeSpec(), 'v') {}
+
+  SVEType(TypeSpec TS, char CharMod)
+  : TS(TS), Float(false), Signed(true), Immediate(false), Void(false),
+Constant(false), Pointer(false), DefaultType(false), IsScalable(true),
+Predicate(false), PredicatePattern(false), PrefetchOp(false),
+Bitwidth(128), ElementBitwidth(~0U), NumVectors(1) {
+if (!TS.empty())
+  applyTypespec();
+applyModifier(CharMod);
+  }
+
+  /// Return the value in SVETypeFlags for this type.
+  unsigned getTypeFlags() const;
+
+  bool isPointer() const { return Pointer; }
+  bool isVoidPointer() const { return Pointer && Void; }
+  bool isSigned() const { return Signed; }
+  bool isImmediate() const { return Immediate; }
+  bool isScalar() const { return NumVectors == 0; }
+  bool isVector() const { return NumVectors > 0; }
+  bool isScalableVector() const { return isVector() && IsScalable; }
+  bool isChar() const { return ElementBitwidth == 8; }
+  bool isVoid() const { return Void & !Pointer; }
+  bool isDefault() const { return DefaultType; }
+  bool isFloat() const { return Float; }
+  bool isInteger() const { 

[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:85
+//===--===//
+// Unfulfilled dependency
+//===--===//

How about `Unsatisfied checker dependency.`?



Comment at: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:92
+BugReporter &BR) const {
+assert(false && "This checker should not be registered.");
+BR.EmitBasicReport(D, this, "Prerequisite", categories::LogicError,

Isn't this overkill? The test above test only the output, but don't outright 
cause a crash.



Comment at: 
clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:111-112
+BugReporter &BR) const {
+assert(false &&
+   "This checker should not be registered due to missing dependency.");
+BR.EmitBasicReport(D, this, "Dependent", categories::LogicError,

Same thing.



Comment at: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:143
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+}

I don't think this is checking what you're looking for -- the test should be 
whether `Diag` is an empty string, while `runCheckerOnCode` returns true when 
the tool (the static analyzer, in this case) terminates successfully, even if 
it doesn't work the way we expect it to.


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

https://reviews.llvm.org/D75842



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


[PATCH] D75858: [AArch64][SVE] Add SVE intrinsics for address calculations

2020-03-10 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0bba37a32024: [AArch64][SVE] Add SVE intrinsics for address 
calculations (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75858

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-adr.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-adr.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-adr.ll
@@ -0,0 +1,101 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve -verify-machineinstrs < %s | FileCheck %s
+
+;
+; ADRB
+;
+
+define  @adrb_i32( %a,  %b) {
+; CHECK-LABEL: adrb_i32:
+; CHECK: adr z0.s, [z0.s, z1.s]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrb.nxv4i32( %a,
+ %b)
+  ret  %out
+}
+
+define  @adrb_i64( %a,  %b) {
+; CHECK-LABEL: adrb_i64:
+; CHECK: adr z0.d, [z0.d, z1.d]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrb.nxv2i64( %a,
+ %b)
+  ret  %out
+}
+
+;
+; ADRH
+;
+
+define  @adrh_i32( %a,  %b) {
+; CHECK-LABEL: adrh_i32:
+; CHECK: adr z0.s, [z0.s, z1.s, lsl #1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrh.nxv4i32( %a,
+ %b)
+  ret  %out
+}
+
+define  @adrh_i64( %a,  %b) {
+; CHECK-LABEL: adrh_i64:
+; CHECK: adr z0.d, [z0.d, z1.d, lsl #1]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrh.nxv2i64( %a,
+ %b)
+  ret  %out
+}
+
+;
+; ADRW
+;
+
+define  @adrw_i32( %a,  %b) {
+; CHECK-LABEL: adrw_i32:
+; CHECK: adr z0.s, [z0.s, z1.s, lsl #2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrw.nxv4i32( %a,
+ %b)
+  ret  %out
+}
+
+define  @adrw_i64( %a,  %b) {
+; CHECK-LABEL: adrw_i64:
+; CHECK: adr z0.d, [z0.d, z1.d, lsl #2]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrw.nxv2i64( %a,
+ %b)
+  ret  %out
+}
+
+;
+; ADRD
+;
+
+define  @adrd_i32( %a,  %b) {
+; CHECK-LABEL: adrd_i32:
+; CHECK: adr z0.s, [z0.s, z1.s, lsl #3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrd.nxv4i32( %a,
+ %b)
+  ret  %out
+}
+
+define  @adrd_i64( %a,  %b) {
+; CHECK-LABEL: adrd_i64:
+; CHECK: adr z0.d, [z0.d, z1.d, lsl #3]
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.adrd.nxv2i64( %a,
+ %b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.adrb.nxv4i32(, )
+declare  @llvm.aarch64.sve.adrb.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.adrh.nxv4i32(, )
+declare  @llvm.aarch64.sve.adrh.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.adrw.nxv4i32(, )
+declare  @llvm.aarch64.sve.adrw.nxv2i64(, )
+
+declare  @llvm.aarch64.sve.adrd.nxv4i32(, )
+declare  @llvm.aarch64.sve.adrd.nxv2i64(, )
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -917,6 +917,24 @@
   defm ADR_LSL_ZZZ_S  : sve_int_bin_cons_misc_0_a_32_lsl<0b10, "adr">;
   defm ADR_LSL_ZZZ_D  : sve_int_bin_cons_misc_0_a_64_lsl<0b11, "adr">;
 
+  def : Pat<(nxv4i32 (int_aarch64_sve_adrb nxv4i32:$Op1, nxv4i32:$Op2)),
+(ADR_LSL_ZZZ_S_0 $Op1, $Op2)>;
+  def : Pat<(nxv4i32 (int_aarch64_sve_adrh nxv4i32:$Op1, nxv4i32:$Op2)),
+(ADR_LSL_ZZZ_S_1 $Op1, $Op2)>;
+  def : Pat<(nxv4i32 (int_aarch64_sve_adrw nxv4i32:$Op1, nxv4i32:$Op2)),
+(ADR_LSL_ZZZ_S_2 $Op1, $Op2)>;
+  def : Pat<(nxv4i32 (int_aarch64_sve_adrd nxv4i32:$Op1, nxv4i32:$Op2)),
+(ADR_LSL_ZZZ_S_3 $Op1, $Op2)>;
+
+  def : Pat<(nxv2i64 (int_aarch64_sve_adrb nxv2i64:$Op1, nxv2i64:$Op2)),
+(ADR_LSL_ZZZ_D_0 $Op1, $Op2)>;
+  def : Pat<(nxv2i64 (int_aarch64_sve_adrh nxv2i64:$Op1, nxv2i64:$Op2)),
+(ADR_LSL_ZZZ_D_1 $Op1, $Op2)>;
+  def : Pat<(nxv2i64 (int_aarch64_sve_adrw nxv2i64:$Op1, nxv2i64:$Op2)),
+(ADR_LSL_ZZZ_D_2 $Op1, $Op2)>;
+  def : Pat<(nxv2i64 (int_aarch64_sve_adrd nxv2i64:$Op1, nxv2i64:$Op2)),
+(ADR_LSL_ZZZ_D_3 $Op1, $Op2)>;
+
   defm TBL_ZZZ  : sve_int_perm_tbl<"tbl", AArch64tbl>;
 
   defm ZIP1_ZZZ : sve_int_perm_bin_perm_zz<0b000, "zip1", AArch64zip1>;
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -1286,6 +1286,15 @@
 def int_aarch64_sve_index : AdvSIMD_SVE_

[PATCH] D75470: [SVE] Auto-generate builtins and header for svld1.

2020-03-10 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen marked an inline comment as done.
sdesmalen added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:5292
+  { #NameBase, SVE::BI__builtin_sve_##NameBase, 0, 0, TypeModifier }
+static const NeonIntrinsicInfo AArch64SVEIntrinsicMap[] = {
+#define GET_SVE_LLVM_INTRINSIC_MAP

SjoerdMeijer wrote:
> I am wondering if it is confusing/correct to use NeonInstrinsicInfo here?
We can reuse the same info-struct and find function, but the names are indeed 
misleading. I've renamed these.


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

https://reviews.llvm.org/D75470



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


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Yay, this is very nice!




Comment at: 
clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp:1-10
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\
+// RUN: -analyzer-config c++-container-inlining=false %s 2>&1 | FileCheck %s
+
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\
+// RUN: -analyzer-config c++-container-inlining=true -DINLINE=1 %s 2>&1 |\

What does this file do that 
`clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp`
 doesn't?



Comment at: 
clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp:38-39
+  if (V.end() != first) {
+clang_analyzer_eval(clang_analyzer_container_end(V) ==
+clang_analyzer_iterator_position(first));
+  }

Is this where the crash supposed to happen? Can you mark it with `// no-crash`?


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

https://reviews.llvm.org/D75171



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


[PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations.

2020-03-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 249317.
balazske marked an inline comment as done.
balazske added a comment.

Removed code repetition.
Using `const char *` instead of `auto`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75740

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/AST/StructuralEquivalenceTest.cpp

Index: clang/unittests/AST/StructuralEquivalenceTest.cpp
===
--- clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -797,6 +797,27 @@
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceRecordTest, SameFriendMultipleTimes) {
+  auto t = makeNamedDecls("struct foo { friend class X; };",
+  "struct foo { friend class X; friend class X; };",
+  Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceRecordTest, SameFriendsDifferentOrder) {
+  auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };",
+  "struct foo { friend class Y; friend class X; };",
+  Lang_CXX);
+  EXPECT_FALSE(testStructuralMatch(t));
+}
+
+TEST_F(StructuralEquivalenceRecordTest, SameFriendsSameOrder) {
+  auto t = makeNamedDecls("struct foo { friend class X; friend class Y; };",
+  "struct foo { friend class X; friend class Y; };",
+  Lang_CXX);
+  EXPECT_TRUE(testStructuralMatch(t));
+}
+
 struct StructuralEquivalenceLambdaTest : StructuralEquivalenceTest {};
 
 TEST_F(StructuralEquivalenceLambdaTest, LambdaClassesWithDifferentMethods) {
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4005,6 +4005,56 @@
   EXPECT_EQ(ImportedFwd, ImportedDef->getPreviousDecl());
 }
 
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendType) {
+  const char *Code =
+  R"(
+  class Container {
+friend class X;
+friend class X;
+  };
+  )";
+  Decl *ToTu = getToTuDecl(Code, Lang_CXX);
+  Decl *FromTu = getTuDecl(Code, Lang_CXX, "from.cc");
+
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *FromFriend1 =
+  FirstDeclMatcher().match(FromTu, friendDecl());
+  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+
+  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX);
+  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX);
+
+  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+  EXPECT_EQ(ToFriend1, ToImportedFriend1);
+  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+}
+
+TEST_P(ImportFriendClasses, ImportOfRepeatedFriendDecl) {
+  const char *Code =
+  R"(
+  class Container {
+friend void f();
+friend void f();
+  };
+  )";
+  Decl *ToTu = getToTuDecl(Code, Lang_CXX);
+  Decl *FromTu = getTuDecl(Code, Lang_CXX, "from.cc");
+
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *FromFriend1 =
+  FirstDeclMatcher().match(FromTu, friendDecl());
+  auto *FromFriend2 = LastDeclMatcher().match(FromTu, friendDecl());
+
+  FriendDecl *ToImportedFriend1 = Import(FromFriend1, Lang_CXX);
+  FriendDecl *ToImportedFriend2 = Import(FromFriend2, Lang_CXX);
+
+  EXPECT_NE(ToImportedFriend1, ToImportedFriend2);
+  EXPECT_EQ(ToFriend1, ToImportedFriend1);
+  EXPECT_EQ(ToFriend2, ToImportedFriend2);
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase, FriendFunInClassTemplate) {
   auto *Code = R"(
   template 
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,54 @@
   return ToIndirectField;
 }
 
+/// Used as return type of getFriendCountAndPosition.
+struct FriendCountAndPosition {
+  /// Number of similar looking friends.
+  unsigned int TotalCount;
+  /// Index of the specific FriendDecl.
+  unsigned int IndexOfDecl;
+};
+
+template 
+FriendCountAndPosition getFriendCountAndPosition(
+const FriendDecl *FD,
+std::function GetCanTypeOrDecl) {
+  unsigned int FriendCount = 0;
+  llvm::Optional FriendPosition;
+  const auto *RD = cast(FD->getLexicalDeclContext());
+
+  T TypeOrDecl = GetCanTypeOrDecl(FD);
+
+  for (const FriendDecl *FoundFriend : RD->friends()) {
+if (FoundFriend == FD) {
+  FriendPosition = FriendCount;
+  ++FriendCount;
+} else if (!FoundFriend->getFriendDecl() == !FD->getFriendDecl() &&
+   GetCanTypeOrDecl(FoundFriend) == TypeOrDecl) {
+  ++FriendCount;
+}
+  }
+
+  assert

[PATCH] D75514: [Analyzer] Only add container note tags to the operations of the affected container

2020-03-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 249319.
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added a comment.

Rebased.


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

https://reviews.llvm.org/D75514

Files:
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/DebugContainerModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/test/Analysis/container-modeling.cpp

Index: clang/test/Analysis/container-modeling.cpp
===
--- clang/test/Analysis/container-modeling.cpp
+++ clang/test/Analysis/container-modeling.cpp
@@ -97,7 +97,8 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.emplace_back(n); // expected-note 2{{Container 'V' extended to the right by 1 position}}
+  V.emplace_back(n); // expected-note{{Container 'V' extended to the right by 1 position}}
+ // expected-note@-1{{Container 'V' extended to the right by 1 position}}
 
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
@@ -118,7 +119,8 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V), "$V.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(V), "$V.end()");
 
-  V.pop_back(); // expected-note 2{{Container 'V' shrank from the right by 1 position}}
+  V.pop_back(); // expected-note{{Container 'V' shrank from the right by 1 position}}
+// expected-note@-1{{Container 'V' shrank from the right by 1 position}}
 
 
   clang_analyzer_express(clang_analyzer_container_begin(V)); // expected-warning{{$V.begin()}}
@@ -139,7 +141,8 @@
   clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()");
 
-  L.push_front(n); // expected-note 2{{Container 'L' extended to the left by 1 position}}
+  L.push_front(n); // expected-note{{Container 'L' extended to the left by 1 position}}
+   // expected-note@-1{{Container 'L' extended to the left by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(L)); // expected-warning{{$L.begin() - 1}}
  // expected-note@-1{{$L.begin() - 1}}
@@ -159,7 +162,8 @@
   clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()");
 
-  L.emplace_front(n); // expected-note 2{{Container 'L' extended to the left by 1 position}}
+  L.emplace_front(n); // expected-note{{Container 'L' extended to the left by 1 position}}
+  // expected-note@-1{{Container 'L' extended to the left by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(L)); // expected-warning{{$L.begin() - 1}}
  // expected-note@-1{{$L.begin() - 1}}
@@ -179,7 +183,8 @@
   clang_analyzer_denote(clang_analyzer_container_begin(L), "$L.begin()");
   clang_analyzer_denote(clang_analyzer_container_end(L), "$L.end()");
 
-  L.pop_front(); // expected-note 2{{Container 'L' shrank from the left by 1 position}}
+  L.pop_front(); // expected-note{{Container 'L' shrank from the left by 1 position}}
+ // expected-note@-1{{Container 'L' shrank from the left by 1 position}}
 
   clang_analyzer_express(clang_analyzer_container_begin(L)); // expected-warning{{$L.begin() + 1}}
  // expected-note@-1{{$L.begin() + 1}}
@@ -203,10 +208,10 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(V1), "$V1.begin()");
 
-  V2.push_back(n); // expected-note{{Container 'V2' extended to the right by 1 position}} FIXME: This note should not appear since `V2` is not affected in the "bug"
+  V2.push_back(n); // no-note
 
   clang_analyzer_express(clang_analyzer_container_begin(V1)); // expected-warning{{$V1.begin()}}
- // expected-note@-1{{$V1.begin()}}
+  // expected-note@-1{{$V1.begin()}}
 }
 
 void push_back2(std::vector &V1, std::vector &V2, int n) {
@@ -218,15 +223,14 @@
   clang_analyzer_denote(clang_analyzer_container_begin(V1), "$V1.begin()");
   clang_analyzer_denote(clang_analyzer_container_begin(V2), "$V2.begin()");
 
-  V1.push_back(n); // expected-note 2{{Container 'V1' extended to the right by 1 position}}
-   // FIXME: This should appear only once since there is only
-   // one "bug" where `V1` is affected
+  V1.push_back(n); // expected-note{{Container 'V1' extended to the right by 1 position}}
+   // Only once!
 
   clang_analyzer_express(clang_analyzer_container_begin(V1)); // expected-warning{{$V1.beg

[PATCH] D75901: [clang-tidy] misc-unconventional-assign-operator suggest to use rvalue references in C++03 mode

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Please add a test case for this




Comment at: 
clang-tools-extra/clang-tidy/misc/UnconventionalAssignOperatorCheck.cpp:76-77
   } else {
+const ASTContext *ASTCtx = Result.Context;
+const LangOptions &Opts = ASTCtx->getLangOpts();
 static const char *const Messages[][2] = {

Remove these lines and change below to be `getLangOpts().CPlusPlus11`. 
`getLangOpts()` is a protected method in `ClangTidyCheck`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75901



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked an inline comment as done.
baloghadamsoftware added inline comments.



Comment at: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:143
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+}

Szelethus wrote:
> I don't think this is checking what you're looking for -- the test should be 
> whether `Diag` is an empty string, while `runCheckerOnCode` returns true when 
> the tool (the static analyzer, in this case) terminates successfully, even if 
> it doesn't work the way we expect it to.
There could be hundreds of alternative approaches, but this test exactly 
simulates the real-world problem: the checker crashes because it should not be 
registered. Of course, I tried the test without the bugfix and it fails as it 
should because the tool terminates unsuccessfully if the prerequisite checker 
is registered.


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

https://reviews.llvm.org/D75842



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


[PATCH] D75740: [ASTImporter] Corrected import of repeated friend declarations.

2020-03-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 3 inline comments as done.
balazske added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:3638
+  /// Number of similar looking friends.
+  unsigned int TotalCount;
+  /// Index of the specific FriendDecl.

shafik wrote:
> `uint32_t`
> 
> Is there a reason to not prefer fixed width integer types?
I do not know about any reason, but in //ASTImporter.cpp// `uint32_t` does not 
appear but `unsigned` and `unsigned int` yes. Why can be fixed width type 
better that the default-sized int?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75740



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


[PATCH] D75677: [Analyzer] Only add iterator note tags to the operations of the affected iterators

2020-03-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 249320.
baloghadamsoftware added a comment.

Rebased.


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

https://reviews.llvm.org/D75677

Files:
  clang/lib/StaticAnalyzer/Checkers/DebugIteratorModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
  clang/test/Analysis/iterator-modelling.cpp

Index: clang/test/Analysis/iterator-modelling.cpp
===
--- clang/test/Analysis/iterator-modelling.cpp
+++ clang/test/Analysis/iterator-modelling.cpp
@@ -81,7 +81,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto j = i++; // expected-note 2{{Iterator 'i' incremented by 1}}
+  auto j = i++; // expected-note{{Iterator 'i' incremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.begin() + 1}}
//expected-note@-1{{$v.begin() + 1}}
@@ -94,7 +94,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
-  auto j = i--; // expected-note 2{{Iterator 'i' decremented by 1}}
+  auto j = i--; // expected-note{{Iterator 'i' decremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i)); //expected-warning{{$v.end() - 1}}
//expected-note@-1{{$v.end() - 1}}
@@ -164,7 +164,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto i2 = i1 + 2; // expected-note 2{{Iterator 'i1' incremented by 2}}
+  auto i2 = i1 + 2; // expected-note{{Iterator 'i1' incremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -177,7 +177,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
-  auto i2 = i1 + (-2); // expected-note 2{{Iterator 'i1' decremented by 2}}
+  auto i2 = i1 + (-2); // expected-note{{Iterator 'i1' decremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -190,7 +190,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
-  auto i2 = i1 - 2;  // expected-note 2{{Iterator 'i1' decremented by 2}}
+  auto i2 = i1 - 2; // expected-note{{Iterator 'i1' decremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -203,7 +203,7 @@
 
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
-  auto i2 = i1 - (-2); // expected-note 2{{Iterator 'i1' incremented by 2}}
+  auto i2 = i1 - (-2); // expected-note{{Iterator 'i1' incremented by 2}}
 
   clang_analyzer_eval(clang_analyzer_iterator_container(i2) == &v); // expected-warning{{TRUE}}
 // expected-note@-1{{TRUE}}
@@ -217,7 +217,7 @@
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
   auto i2 = i1;
-  ++i1;  // expected-note 2{{Iterator 'i1' incremented by 1}}
+  ++i1;  // expected-note{{Iterator 'i1' incremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.begin() + 1}}
 //expected-note@-1{{$v.begin() + 1}}
@@ -231,7 +231,7 @@
   clang_analyzer_denote(clang_analyzer_container_begin(v), "$v.begin()");
 
   auto i2 = i1;
-  ++i2;  // expected-note 2{{Iterator 'i2' incremented by 1}}
+  ++i2;  // expected-note{{Iterator 'i2' incremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.begin()}}
 //expected-note@-1{{$v.begin()}}
@@ -245,7 +245,7 @@
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
   auto i2 = i1;
-  --i1;  // expected-note 2{{Iterator 'i1' decremented by 1}}
+  --i1;  // expected-note{{Iterator 'i1' decremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.end() - 1}}
 //expected-note@-1{{$v.end() - 1}}
@@ -259,7 +259,7 @@
   clang_analyzer_denote(clang_analyzer_container_end(v), "$v.end()");
 
   auto i2 = i1;
-  --i2;  // expected-note 2{{Iterator 'i2' decremented by 1}}
+  --i2;  // expected-note{{Iterator 'i2' decremented by 1}}
 
   clang_analyzer_express(clang_analyzer_iterator_position(i1)); //expected-warning{{$v.end()}}
 /

[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2956
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }

We don't seem to add namespace for other OpenCL types, although I am not 
against it as I find it actually cleaner.

Since the mangling deviates what is documented can you add some comments here 
explaining your mangling scheme?



Comment at: clang/test/CodeGenOpenCLCXX/pipe_types_mangling.cl:2
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 
-cl-std=clc++ -o - %s | FileCheck %s --check-prefixes=LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 
-cl-std=clc++ -o - %s -DWIN| FileCheck %s --check-prefixes=WINDOWS
+

Does this work for OpenCL C (although you would need to add overloading 
attribute)? If so maybe worth adding a RUN line too. 

If it works for OpenCL C I would move this into test/CodeGenOpenCL. In this 
folder we only keep what is C++ specific. Although overloading is technically 
C++ but we use it in C too.



Comment at: clang/test/CodeGenOpenCLCXX/pipe_types_mangling.cl:20
+//  or write/read. Our Windows mangling does, so make sure this still works.
+void test2(read_only pipe int p) {
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"

any reason this is different from the rest?


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

https://reviews.llvm.org/D75685



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


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Simon Moll via Phabricator via cfe-commits
simoll added a comment.
Herald added a reviewer: aartbik.

ping. Is this good to go?
(merge bot failures 

 are due to the `m_UnOp` syntax, which goes against the coding standard).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467



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


[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 created this revision.
njames93 added reviewers: aaron.ballman, gribozavr2, alexfh, Eugene.Zelenko.
Herald added subscribers: cfe-commits, kbarton, xazax.hun, mgorny, nemanjai.
Herald added a project: clang.

Adds a utils matcher called `hasAnyListedName` to alleviate all the hackery 
using the hasAnyName matcher with types that are already `vector`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75911

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/Matchers.cpp
  clang-tools-extra/clang-tidy/utils/Matchers.h

Index: clang-tools-extra/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -50,6 +50,13 @@
 });
 }
 
+ast_matchers::internal::Matcher
+hasAnyListedName(std::vector Names);
+
+// NameList must be a semi-colon; seperated list.
+ast_matchers::internal::Matcher
+hasAnyListedName(llvm::StringRef NameList);
+
 } // namespace matchers
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/utils/Matchers.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/Matchers.cpp
@@ -0,0 +1,27 @@
+//===--- Matchers.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Matchers.h"
+#include "OptionsUtils.h"
+
+namespace clang {
+namespace tidy {
+namespace matchers {
+using namespace ast_matchers::internal;
+
+Matcher hasAnyListedName(std::vector Names) {
+  return Matcher(new HasNameMatcher(std::move(Names)));
+}
+
+Matcher hasAnyListedName(llvm::StringRef NameList) {
+  return hasAnyListedName(utils::options::parseStringList(NameList));
+}
+
+} // namespace matchers
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/clang-tidy/utils/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/utils/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/utils/CMakeLists.txt
@@ -11,6 +11,7 @@
   IncludeInserter.cpp
   IncludeSorter.cpp
   LexerUtils.cpp
+  Matchers.cpp
   NamespaceAliaser.cpp
   OptionsUtils.cpp
   RenamerClangTidyCheck.cpp
Index: clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "SimplifySubscriptExprCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -27,9 +28,8 @@
 }
 
 void SimplifySubscriptExprCheck::registerMatchers(MatchFinder *Finder) {
-  const auto TypesMatcher = hasUnqualifiedDesugaredType(
-  recordType(hasDeclaration(cxxRecordDecl(hasAnyName(
-  llvm::SmallVector(Types.begin(), Types.end()));
+  const auto TypesMatcher = hasUnqualifiedDesugaredType(recordType(
+  hasDeclaration(cxxRecordDecl(matchers::hasAnyListedName(Types);
 
   Finder->addMatcher(
   arraySubscriptExpr(hasBase(ignoringParenImpCasts(
Index: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -20,12 +20,6 @@
 
 const char DefaultStringNames[] = "::std::basic_string";
 
-static ast_matchers::internal::Matcher
-hasAnyNameStdString(std::vector Names) {
-  return ast_matchers::internal::Matcher(
-  new as

[PATCH] D71314: Warn of uninitialized variables on asm goto's indirect branch

2020-03-10 Thread Bill Wendling via Phabricator via cfe-commits
void added a comment.

Friendly ping. :-)


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

https://reviews.llvm.org/D71314



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-10 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham accepted this revision.
simon_tatham added a comment.
This revision is now accepted and ready to land.

LGTM with a couple of tiny spelling nitpicks.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:642
 def err_arm_invalid_specialreg : Error<"invalid special register for builtin">;
+def err_arm_invalid_invalid_coproc : Error<"coprocessor %0 must be configured"
+  " as %select{GCP|CDE}1">;

Was this identifier meant to say "invalid" twice?



Comment at: clang/include/clang/Sema/Sema.h:11768
+  bool CheckCDEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);
+  bool CheckARMCoprocessorImmediate(const Expr *CorpocArg, bool WantCDE);
   bool CheckARMBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall);

Another "Corpoc" here.


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

https://reviews.llvm.org/D75850



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


[clang-tools-extra] 1fc5be0 - [NFC] Tweak OptionsUtils

2020-03-10 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-03-10T12:50:58Z
New Revision: 1fc5be06694fe3cbe9d2b60179c93a74d7083764

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

LOG: [NFC] Tweak OptionsUtils

Added: 


Modified: 
clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp 
b/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp
index 8a7f1c303ace..25677fa46407 100644
--- a/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp
+++ b/clang-tools-extra/clang-tidy/utils/OptionsUtils.cpp
@@ -22,13 +22,13 @@ std::vector parseStringList(StringRef Option) {
   for (StringRef &Name : Names) {
 Name = Name.trim();
 if (!Name.empty())
-  Result.push_back(std::string(Name));
+  Result.emplace_back(Name);
   }
   return Result;
 }
 
 std::string serializeStringList(ArrayRef Strings) {
-  return llvm::join(Strings.begin(), Strings.end(), StringsDelimiter);
+  return llvm::join(Strings, StringsDelimiter);
 }
 
 } // namespace options



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


[PATCH] D57497: [RISCV] Passing small data limitation value to RISCV backend

2020-03-10 Thread Shiva Chen via Phabricator via cfe-commits
shiva0217 updated this revision to Diff 249336.
shiva0217 added a comment.

Update patch to address @lenary's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D57497

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/riscv-sdata-module-flag.c
  clang/test/Driver/riscv-G-warning.c
  clang/test/Driver/riscv-sdata-warning.c

Index: clang/test/Driver/riscv-sdata-warning.c
===
--- /dev/null
+++ clang/test/Driver/riscv-sdata-warning.c
@@ -0,0 +1,8 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -S -target riscv32-unknown-elf -fpic -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-PIC-SDATA %s
+// CHECK-PIC-SDATA: warning: ignoring '-msmall-data-limit=' for -fpic or RV64 with -mcmodel=large
+
+// RUN: %clang -S -target riscv64-unknown-elf -mcmodel=large -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-RV64-LARGE-SDATA %s
+// CHECK-RV64-LARGE-SDATA: warning: ignoring '-msmall-data-limit=' for -fpic or RV64 with -mcmodel=large
Index: clang/test/Driver/riscv-G-warning.c
===
--- /dev/null
+++ clang/test/Driver/riscv-G-warning.c
@@ -0,0 +1,4 @@
+// REQUIRES: riscv-registered-target
+// RUN: %clang -S -target riscv32-unknown-elf -G4 -msmall-data-limit=8 %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-G %s
+// CHECK-G: warning: ignoring '-G' option as -msmall-data-limit= in the command line
Index: clang/test/CodeGen/riscv-sdata-module-flag.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-sdata-module-flag.c
@@ -0,0 +1,31 @@
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-DEFAULT
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -G4 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-G4
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -msmall-data-limit=0 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-S0
+// RUN: %clang -target riscv32-unknown-elf %s -S -emit-llvm -fpic -o - \
+// RUN:   | FileCheck %s -check-prefix=RV32-PIC
+
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-DEFAULT
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -G4 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-G4
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -msmall-data-limit=0 -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-S0
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -fpic -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-PIC
+// RUN: %clang -target riscv64-unknown-elf %s -S -emit-llvm -mcmodel=large -o - \
+// RUN:   | FileCheck %s -check-prefix=RV64-LARGE
+
+
+// RV32-DEFAULT: !{i32 1, !"SmallDataLimit", i32 8}
+// RV32-G4:  !{i32 1, !"SmallDataLimit", i32 4}
+// RV32-S0:  !{i32 1, !"SmallDataLimit", i32 0}
+// RV32-PIC: !{i32 1, !"SmallDataLimit", i32 0}
+
+// RV64-DEFAULT: !{i32 1, !"SmallDataLimit", i32 8}
+// RV64-G4:  !{i32 1, !"SmallDataLimit", i32 4}
+// RV64-S0:  !{i32 1, !"SmallDataLimit", i32 0}
+// RV64-PIC: !{i32 1, !"SmallDataLimit", i32 0}
+// RV64-LARGE:   !{i32 1, !"SmallDataLimit", i32 0}
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -923,6 +923,8 @@
   Opts.NoZeroInitializedInBSS = Args.hasArg(OPT_mno_zero_initialized_in_bss);
   Opts.NumRegisterParameters = getLastArgIntValue(Args, OPT_mregparm, 0, Diags);
   Opts.NoExecStack = Args.hasArg(OPT_mno_exec_stack);
+  Opts.SmallDataLimit =
+  getLastArgIntValue(Args, OPT_msmall_data_limit, 0, Diags);
   Opts.FatalWarnings = Args.hasArg(OPT_massembler_fatal_warnings);
   Opts.NoWarn = Args.hasArg(OPT_massembler_no_warn);
   Opts.EnableSegmentedStacks = Args.hasArg(OPT_split_stacks);
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -1960,6 +1960,42 @@
   }
 }
 
+static void SetRISCVSmallDataLimit(const ToolChain &TC, const ArgList &Args,
+   ArgStringList &CmdArgs) {
+  const Driver &D = TC.getDriver();
+  const llvm::Triple &Triple = TC.getTriple();
+  // Default small data limitation is eight.
+  const cha

[PATCH] D74766: [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane intrinsics

2020-03-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 249346.
pratlucas added a comment.

Adding check for valid range on tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74766

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-neon-range-checks.c


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside 
the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5803,8 +5803,12 @@
   case NEON::BI__builtin_neon_vqdmulh_lane_v:
   case NEON::BI__builtin_neon_vqrdmulhq_lane_v:
   case NEON::BI__builtin_neon_vqrdmulh_lane_v: {
+llvm::Type* RTy = Ty;
+if (BuiltinID == NEON::BI__builtin_neon_vqdmulhq_lane_v ||
+BuiltinID == NEON::BI__builtin_neon_vqrdmulhq_lane_v)
+  RTy = llvm::VectorType::get(Ty->getVectorElementType(), 
Ty->getVectorNumElements() * 2);
 llvm::Type *Tys[2] = {
-Ty, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
+RTy, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
 /*isQuad*/ false))};
 return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, NameHint);
   }
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -547,8 +547,8 @@
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
 let ArchGuard = "defined(__aarch64__)" in {
-def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..qI", "siQsQi">;
-def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..qI", "siQsQi">;
+def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
+def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5803,8 +5803,12 @@
   case NEON::BI__builtin_neon_vqdmulh_lane_v:
   case NEON::BI__builtin_neon_vqrdmul

[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Ah, okay I think I got why you chose this direction. Summaries are little more 
then a collection of constraints, and at select points in the execution we 
check and apply them one-by-one. If we want to preserve this architecture (and 
it seems great, why not?), inheritance is indeed the correct design decision.

The costliest code to run according to my limited knowledge about C++ 
development is indeed the one that is hard to understand and maintain, and this 
seems to have a good bit of thought behind it. I'll check your followup patches 
to gain some confidence before formally accepting, but the general idea seems 
great.




Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:88
   typedef uint32_t ArgNo;
-  static const ArgNo Ret = std::numeric_limits::max();
+  static const ArgNo Ret;
+

Why did we remove the initialization here? Can we make this `constexpr`?



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:90
+
+  class ValueConstraint {
+  public:

We should totally have a good bit of documentation here.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:151
+
+  using ValueConstraintPtr = std::shared_ptr;
+  /// The complete list of constraints that defines a single branch.

martong wrote:
> martong wrote:
> > Szelethus wrote:
> > > gamesh411 wrote:
> > > > martong wrote:
> > > > > Note here, we need a copyable, polymorphic and default initializable 
> > > > > type (vector needs that). A raw pointer were good, however, we cannot 
> > > > > default initialize that. unique_ptr makes the Summary class 
> > > > > non-copyable, therefore not an option.
> > > > > Releasing the copyablitly requirement would render the initialization 
> > > > > of the Summary map infeasible.
> > > > > Perhaps we could come up with a [[ 
> > > > > https://www.youtube.com/watch?v=bIhUE5uUFOA | type erasure technique 
> > > > > without inheritance ]] once we consider the shared_ptr as 
> > > > > restriction, but for now that seems to be overkill.
> > > > std::variant (with std::monostate for the default constructibility) 
> > > > would also be an option  (if c++17 were supported). But this is not 
> > > > really an issue, i agree with that.
> > > Ugh, we've historically been very hostile towards virtual functions. We 
> > > don't mind them that much when they don't have to run a lot, like during 
> > > bug report construction, but as a core part of the analysis, I'm not sure 
> > > what the current stance is on it.
> > > 
> > > I'm not inherently (haha) against it, and I'm fine with leaving this 
> > > as-is for the time being, though I'd prefer if you placed a `TODO` to 
> > > revisit this issue.
> > > std::variant (with std::monostate for the default constructibility) would 
> > > also be an option (if c++17 were supported). But this is not really an 
> > > issue, i agree with that.
> > 
> > Variant would be useful if we knew the set of classes prior and we wanted 
> > to add operations gradually. Class hierarchies (or run-time concepts [Sean 
> > Parent]) are very useful if we know the set of operations prior and we want 
> > to add classes gradually, and we have this case here.
> > Ugh, we've historically been very hostile towards virtual functions. We 
> > don't mind them that much when they don't have to run a lot, like during 
> > bug report construction, but as a core part of the analysis, I'm not sure 
> > what the current stance is on it.
> 
> I did not find any evidence for this statement. Consider as a counter example 
> the ExternalASTSource interface in Clang, which is filled with virtual 
> functions and is part of the C/C++ lookup mechanism, which is quite on the 
> hot path of C/C++ parsing I think. Did not find any prohibition in LLVM 
> coding guidelines neither. I do believe virtual functions have their use 
> cases exactly where (runtime) polimorphism is needed, such as in this patch.
> 
I consider myself proven wrong here then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-03-10 Thread Saiyedul Islam via Phabricator via cfe-commits
saiislam created this revision.
saiislam added reviewers: JonChesterfield, sameerds, yaxunl, gregrodgers, 
b-sumner.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

"__buitlin_memory_fence(, )" in clang gets
mapped to "fence [syncscope("")] ; yields void"
in IR.


Repository:
  rC Clang

https://reviews.llvm.org/D75917

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGenOpenCL/atomic-ops.cl
  clang/test/SemaOpenCL/atomic-ops.cl

Index: clang/test/SemaOpenCL/atomic-ops.cl
===
--- clang/test/SemaOpenCL/atomic-ops.cl
+++ clang/test/SemaOpenCL/atomic-ops.cl
@@ -194,3 +194,21 @@
   // The 'expected' pointer shouldn't be NULL.
   (void)__opencl_atomic_compare_exchange_strong(Ap, (void *)0, val, memory_order_relaxed, memory_order_relaxed, memory_scope_work_group); // expected-warning {{null passed to a callee that requires a non-null argument}}
 }
+
+void memory_fence_errors() {
+  __builtin_memory_fence(memory_order_seq_cst + 1, memory_scope_work_group); // expected-error {{memory order argument to fence operation is invalid}}
+
+  __builtin_memory_fence(memory_order_seq_cst, memory_scope_sub_group + 1); // expected-error {{synchronization scope argument to fence operation is invalid}}
+
+  __builtin_memory_fence(memory_scope_work_group); // expected-error {{too few arguments to function call, expected 2}}
+
+  __builtin_memory_fence(2, 2, 2); // expected-error {{too many arguments to function call, expected 2}}
+
+  __builtin_memory_fence("string", memory_scope_work_group); // expected-error {{used type '__constant char [7]' where unsigned is required}}
+
+  __builtin_memory_fence(3.14, memory_scope_work_group); // expected-error {{used type 'double' where unsigned is required}}
+
+  __builtin_memory_fence(memory_order_seq_cst, "string"); // expected-error {{used type '__constant char [7]' where unsigned is required}}
+
+  __builtin_memory_fence(memory_order_seq_cst, 3.14); // expected-error {{used type 'double' where unsigned is required}}
+}
Index: clang/test/CodeGenOpenCL/atomic-ops.cl
===
--- clang/test/CodeGenOpenCL/atomic-ops.cl
+++ clang/test/CodeGenOpenCL/atomic-ops.cl
@@ -288,4 +288,44 @@
   return __opencl_atomic_load(i, memory_order_seq_cst, memory_scope_work_group);
 }
 
+void test_memory_fence() {
+  // CHECK-LABEL: @test_memory_fence
+
+  // CHECK: fence syncscope("workgroup-one-as") acquire
+  __builtin_memory_fence(memory_order_acquire, memory_scope_work_group);
+
+  // CHECK: fence syncscope("agent-one-as") acquire
+  __builtin_memory_fence(memory_order_acquire, memory_scope_device);
+
+  // CHECK: fence syncscope("one-as") acquire
+  __builtin_memory_fence(memory_order_acquire, memory_scope_all_svm_devices);
+
+  // CHECK: fence syncscope("wavefront-one-as") acquire
+  __builtin_memory_fence(memory_order_acquire, memory_scope_sub_group);
+
+  // CHECK: fence syncscope("workgroup-one-as") release
+  __builtin_memory_fence(memory_order_release,  memory_scope_work_group);
+
+  // CHECK: fence syncscope("agent-one-as") release
+  __builtin_memory_fence(memory_order_release, memory_scope_device);
+
+  // CHECK: fence syncscope("one-as") release
+  __builtin_memory_fence(memory_order_release, memory_scope_all_svm_devices);
+
+  // CHECK: fence syncscope("wavefront-one-as") release
+  __builtin_memory_fence(memory_order_release, memory_scope_sub_group);
+
+  // CHECK: fence syncscope("workgroup") seq_cst
+  __builtin_memory_fence(memory_order_seq_cst,  memory_scope_work_group);
+
+  // CHECK: fence syncscope("agent") seq_cst
+  __builtin_memory_fence(memory_order_seq_cst, memory_scope_device);
+
+  // CHECK: fence seq_cst
+  __builtin_memory_fence(memory_order_seq_cst, memory_scope_all_svm_devices);
+
+  // CHECK: fence syncscope("wavefront") seq_cst
+  __builtin_memory_fence(memory_order_seq_cst, memory_scope_sub_group);
+}
+
 #endif
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1865,6 +1865,60 @@
   : "__builtin_frame_address")
   << TheCall->getSourceRange();
 break;
+
+  // Clang builtins to expose llvm fence instruction
+  case Builtin::BI__builtin_memory_fence: {
+if (checkArgCount(*this, TheCall, 2))
+  return true;
+
+// Order should be the first argument
+ExprResult Arg = TheCall->getArg(0);
+auto ArgExpr = Arg.get();
+auto Ty = ArgExpr->getType();
+
+// Check if Order is an unsigned
+if (!Ty->isIntegerType()) {
+  Diag(ArgExpr->getExprLoc(), diag::err_typecheck_expect_uint) << Ty;
+  return ExprError();
+}
+
+Expr::EvalResult ArgResult;
+ArgExpr->EvaluateAsInt(ArgResult, Context);
+int o

[PATCH] D71018: [ASTImporter] Improved import of TypeSourceInfo (TypeLoc)

2020-03-10 Thread Gabor Marton via Phabricator via cfe-commits
martong updated this revision to Diff 249350.
martong marked an inline comment as done.
martong added a comment.

- Handle AttributedTypeLoc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5845,6 +5845,53 @@
   EXPECT_TRUE(isa(To->getReturnType()));
 }
 
+struct ImportTypeLoc : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(ImportTypeLoc, Function) {
+  Decl *FromTU = getTuDecl(
+  R"(
+  int f(int p) {
+return 1;
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  FunctionDecl *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  FunctionDecl *ToF = Import(FromF, Lang_CXX11);
+  ASSERT_TRUE(ToF);
+  FunctionProtoTypeLoc TL =
+  ToF->getTypeSourceInfo()->getTypeLoc().castAs();
+  EXPECT_EQ(TL.getNumParams(), 1u);
+  EXPECT_TRUE(TL.getParam(0));
+}
+
+TEST_P(ImportTypeLoc, Lambda) {
+  // In this test case, first the CXXRecordDecl of the lambda is imported, then
+  // the operator().
+  Decl *FromTU = getTuDecl(
+  R"(
+  auto l1 = [](unsigned lp) { return 1; };
+  int f(int p) {
+return l1(p);
+  }
+  )",
+  Lang_CXX11, "input0.cc");
+  FunctionDecl *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("f")));
+  FunctionDecl *ToF = Import(FromF, Lang_CXX11);
+  ASSERT_TRUE(ToF);
+
+  TranslationUnitDecl *ToTU = ToAST->getASTContext().getTranslationUnitDecl();
+  CXXMethodDecl *ToLambdaMD = FirstDeclMatcher()
+  .match(ToTU, lambdaExpr())
+  ->getCallOperator();
+  FunctionProtoTypeLoc TL = ToLambdaMD->getTypeSourceInfo()
+->getTypeLoc()
+.castAs();
+  EXPECT_EQ(TL.getNumParams(), 1u);
+  EXPECT_TRUE(TL.getParam(0));
+}
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
@@ -5903,5 +5950,8 @@
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, LLDBLookupTest,
 DefaultTestValuesForRunOptions, );
 
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, ImportTypeLoc,
+DefaultTestValuesForRunOptions, );
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -42,6 +42,7 @@
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
 #include "clang/AST/TypeLoc.h"
+#include "clang/AST/TypeLocVisitor.h"
 #include "clang/AST/TypeVisitor.h"
 #include "clang/AST/UnresolvedSet.h"
 #include "clang/Basic/Builtins.h"
@@ -695,6 +696,8 @@
 // that type is declared inside the body of the function.
 // E.g. auto f() { struct X{}; return X(); }
 bool hasAutoReturnTypeDeclaredInside(FunctionDecl *D);
+
+friend class TypeLocImporter;
   };
 
 template 
@@ -3275,6 +3278,15 @@
 FromReturnTy, FromFPT->getParamTypes(), FromEPI);
   }
 
+  // Import the function parameters.
+  SmallVector Parameters;
+  for (auto P : D->parameters()) {
+if (Expected ToPOrErr = import(P))
+  Parameters.push_back(*ToPOrErr);
+else
+  return ToPOrErr.takeError();
+  }
+
   QualType T;
   TypeSourceInfo *TInfo;
   SourceLocation ToInnerLocStart, ToEndLoc;
@@ -3288,15 +3300,6 @@
   else
 return Imp.takeError();
 
-  // Import the function parameters.
-  SmallVector Parameters;
-  for (auto P : D->parameters()) {
-if (Expected ToPOrErr = import(P))
-  Parameters.push_back(*ToPOrErr);
-else
-  return ToPOrErr.takeError();
-  }
-
   // Create the imported function.
   FunctionDecl *ToFunction = nullptr;
   if (auto *FromConstructor = dyn_cast(D)) {
@@ -3402,16 +3405,6 @@
   }
   ToFunction->setParams(Parameters);
 
-  // We need to complete creation of FunctionProtoTypeLoc manually with setting
-  // params it refers to.
-  if (TInfo) {
-if (auto ProtoLoc =
-TInfo->getTypeLoc().IgnoreParens().getAs()) {
-  for (unsigned I = 0, N = Parameters.size(); I != N; ++I)
-ProtoLoc.setParam(I, Parameters[I]);
-}
-  }
-
   // Import the describing template function, if any.
   if (FromFT) {
 auto ToFTOrErr = import(FromFT);
@@ -8111,20 +8104,318 @@
   return ToContext.getQualifiedType(*ToTOrErr, FromT.getLocalQualifiers());
 }
 
+namespace clang {
+
+#define IMPORT_TYPE_LOC_OR_RETURN_ERROR(NAME)  \
+  if (auto ImpOrErr = Importer.Import(From.get##NAME()))   \
+To.set##NAME(*ImpOrErr);

[PATCH] D75698: [analyzer][WIP] Suppress bug reports where a tracked expression's latest value change was a result of an invalidation

2020-03-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D75698#1914102 , @martong wrote:

> > P.S. So, like, we could try to emit the warning only if we covered enough 
> > execution paths to prove that there's either dead code or the warning is 
> > true. Then we would no longer care about invalidation problems. 
> > Unfortunately, i don't have any specific suggestion of how to prove such 
> > facts for an arbitrary CFG.
>
> If I understand you correctly, this would mean that we have to reason about 
> all possible execution paths at the same time to do this. Actually, that 
> would be possible only with some kind of a fix-point flow-analysis and 
> clearly the symbolic execution we have in CSA is a completely different beast 
> (it reasons about one path where there is a bug).


Nah, we just need to cover *enough* paths, not *all* paths. Just take all paths 
on which we've managed to find a particular bug (we keep track of these paths 
during de-duplicating anyway) and somehow figure out that it's "enough" paths. 
The point is to prove that there's dead code if all of these paths are 
infeasible. I.e., it may require an auxiliary CFG-based analysis that'll reason 
about all possible execution paths, but it doesn't require us to have much 
interaction between that analysis and our usual symbolic execution. We already 
have such auxiliary analysis, eg. see how dead symbol elimination is an 
all-paths problem and `RelaxedLiveVariables` analysis is helping us out with it.

See also my old little essay on this subject 
. I was 
talking about it in the context of path note generation but the problem is 
roughly the same here.

I know this is vague but i spent some time trying to come up with an actual 
solution and failed so far, so take it with a grain of salt^^

>> P.P.S. Actually you know what, maybe we should only drop the report if the 
>> constraint over the invalidated value contradicts the constraint over the 
>> old value. That'll make things a bit more complicated and will require a 
>> visitor indeed, though hopefully not as complicated as concrete value 
>> tracking, as we're still interested in only one region at a time.
> 
> How would that be different than proving the feasibility of the path with Z3? 
> Could we reuse Mikhail's work here, or that would be overkill for this task?

This problem is fairly orthogonal to constraint solving. It's about providing 
constraints, not solving them. Like, we have two different values that we 
previously thought of as separate, now we're telling the solver that they're, 
emm, maybe slightly less separate, "hey dude, actually, on second thought, can 
you please take a look at what would have happened if they were actually 
equal?". We still don't care how exactly does the solver solve this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75698



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


[PATCH] D75570: [AST][SVE] Add new Type queries for sizeless types

2020-03-10 Thread Richard Sandiford via Phabricator via cfe-commits
rsandifo-arm added a comment.
Herald added a subscriber: danielkiss.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75570



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


[PATCH] D75470: [SVE] Auto-generate builtins and header for svld1.

2020-03-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Cheers, I think this looks very reasonable.


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

https://reviews.llvm.org/D75470



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


[PATCH] D75171: [Analyzer] Fix for incorrect use of container and iterator checkers

2020-03-10 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 249352.
baloghadamsoftware added a comment.

Tests reduced.


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

https://reviews.llvm.org/D75171

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
  
clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp
  
clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp
  clang/test/Analysis/loop-widening-notes.cpp


Index: clang/test/Analysis/loop-widening-notes.cpp
===
--- clang/test/Analysis/loop-widening-notes.cpp
+++ clang/test/Analysis/loop-widening-notes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha -analyzer-max-loop 2 
-analyzer-config widen-loops=true -analyzer-output=text -verify 
-analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core 
-analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text 
-verify -analyzer-config eagerly-assume=false %s
 
 int *p_a;
 int bar();
Index: 
clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp
===
--- /dev/null
+++ 
clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: 
-analyzer-checker=core,cplusplus,debug.DebugIteratorModeling,debug.ExprInspection\
+// RUN: %s 2>&1 | FileCheck %s
+
+// CHECK: checker cannot be enabled with analyzer option 
'aggressive-binary-operation-simplification' == false
+
+#include "Inputs/system-header-simulator-cxx.h"
+
+void clang_analyzer_eval(bool);
+
+void comparison(std::vector &V) {
+  clang_analyzer_eval(V.begin() == V.end()); // no-crash
+}
Index: 
clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp
===
--- /dev/null
+++ 
clang/test/Analysis/container-modeling-no-aggressive-binary-operation-simplification-warn.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -std=c++11\
+// RUN: -analyzer-checker=core,cplusplus,alpha.cplusplus.ContainerModeling\
+// RUN: %s 2>&1 | FileCheck %s
+
+// CHECK: checker cannot be enabled with analyzer option 
'aggressive-binary-operation-simplification' == false
Index: clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
+++ clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp
@@ -12,6 +12,7 @@
 
 #include "clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/Driver/DriverDiagnostic.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
@@ -1036,5 +1037,15 @@
 }
 
 bool ento::shouldRegisterContainerModeling(const CheckerManager &mgr) {
+  if (!mgr.getLangOpts().CPlusPlus)
+return false;
+
+  if (!mgr.getAnalyzerOptions().ShouldAggressivelySimplifyBinaryOperation) {
+mgr.getASTContext().getDiagnostics().Report(
+diag::err_analyzer_checker_incompatible_analyzer_option)
+  << "aggressive-binary-operation-simplification" << "false";
+return false;
+  }
+
   return true;
 }
Index: clang/include/clang/Basic/DiagnosticDriverKinds.td
===
--- clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -344,6 +344,8 @@
   "checker '%0' has no option called '%1'">;
 def err_analyzer_checker_option_invalid_input : Error<
   "invalid input for checker option '%0', that expects %1">;
+def err_analyzer_checker_incompatible_analyzer_option : Error<
+  "checker cannot be enabled with analyzer option '%0' == %1">;
 
 def err_drv_invalid_hvx_length : Error<
   "-mhvx-length is not supported without a -mhvx/-mhvx= flag">;


Index: clang/test/Analysis/loop-widening-notes.cpp
===
--- clang/test/Analysis/loop-widening-notes.cpp
+++ clang/test/Analysis/loop-widening-notes.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,alpha.core -analyzer-max-loop 2 -analyzer-config widen-loops=true -analyzer-output=text -verify -analyzer-config eagerly-assume=false %s
 
 int *p_a;
 int bar();
Index: clang/test/Analysis/iterator-modeling-no-aggressive-binary-operation-simplification-no-crash.cpp

[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Basic/Diagnostic.h:1298
+  return DB;
+};
+

s/;// (and in functions below as well)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714



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


[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249356.
njames93 added a comment.

- Fix formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75911

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DanglingHandleCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousStringCompareCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp
  clang-tools-extra/clang-tidy/cert/NonTrivialTypesLibcMemoryCallsCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/NoMallocCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/OwningMemoryCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseEmplaceCheck.cpp
  clang-tools-extra/clang-tidy/objc/ForbiddenSubclassingCheck.cpp
  clang-tools-extra/clang-tidy/performance/FasterStringFindCheck.cpp
  clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
  clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/Matchers.cpp
  clang-tools-extra/clang-tidy/utils/Matchers.h

Index: clang-tools-extra/clang-tidy/utils/Matchers.h
===
--- clang-tools-extra/clang-tidy/utils/Matchers.h
+++ clang-tools-extra/clang-tidy/utils/Matchers.h
@@ -50,6 +50,13 @@
 });
 }
 
+ast_matchers::internal::Matcher
+hasAnyListedName(std::vector Names);
+
+// NameList must be a semi-colon; seperated list.
+ast_matchers::internal::Matcher
+hasAnyListedName(llvm::StringRef NameList);
+
 } // namespace matchers
 } // namespace tidy
 } // namespace clang
Index: clang-tools-extra/clang-tidy/utils/Matchers.cpp
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/Matchers.cpp
@@ -0,0 +1,27 @@
+//===--- Matchers.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "Matchers.h"
+#include "OptionsUtils.h"
+
+namespace clang {
+namespace tidy {
+namespace matchers {
+using namespace ast_matchers::internal;
+
+Matcher hasAnyListedName(std::vector Names) {
+  return Matcher(new HasNameMatcher(std::move(Names)));
+}
+
+Matcher hasAnyListedName(llvm::StringRef NameList) {
+  return hasAnyListedName(utils::options::parseStringList(NameList));
+}
+
+} // namespace matchers
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/clang-tidy/utils/CMakeLists.txt
===
--- clang-tools-extra/clang-tidy/utils/CMakeLists.txt
+++ clang-tools-extra/clang-tidy/utils/CMakeLists.txt
@@ -11,6 +11,7 @@
   IncludeInserter.cpp
   IncludeSorter.cpp
   LexerUtils.cpp
+  Matchers.cpp
   NamespaceAliaser.cpp
   OptionsUtils.cpp
   RenamerClangTidyCheck.cpp
Index: clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/SimplifySubscriptExprCheck.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "SimplifySubscriptExprCheck.h"
+#include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
@@ -27,9 +28,8 @@
 }
 
 void SimplifySubscriptExprCheck::registerMatchers(MatchFinder *Finder) {
-  const auto TypesMatcher = hasUnqualifiedDesugaredType(
-  recordType(hasDeclaration(cxxRecordDecl(hasAnyName(
-  llvm::SmallVector(Types.begin(), Types.end()));
+  const auto TypesMatcher = hasUnqualifiedDesugaredType(recordType(
+  hasDeclaration(cxxRecordDecl(matchers::hasAnyListedName(Types);
 
   Finder->addMatcher(
   arraySubscriptExpr(hasBase(ignoringParenImpCasts(
Index: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
@@ -20,12 +20,6 @@
 
 const char DefaultStringNames[] = "::std::basic_string";
 
-static ast_matchers::internal::Matcher
-hasAnyNameStdString(std::vector Names) {
-  return ast_matchers::internal::Matcher(
-  new ast_matchers::internal::HasNameMatcher(std::move(Names)));
-}
-
 static std::vector
 removeNamespaces(const std::vector &Names) {
   std::vector Result;
@@ -71,9 +65,9 @@
 }
 
 void RedundantStringInitCheck

[PATCH] D75714: Add Optional overload to DiagnosticBuilder operator <

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 249361.
njames93 marked 2 inline comments as done.
njames93 added a comment.

- remove unnecessary semi colons


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75714

Files:
  clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang/include/clang/Basic/Diagnostic.h

Index: clang/include/clang/Basic/Diagnostic.h
===
--- clang/include/clang/Basic/Diagnostic.h
+++ clang/include/clang/Basic/Diagnostic.h
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/iterator_range.h"
@@ -1288,6 +1289,29 @@
   return DB;
 }
 
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+}
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB,
+   const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+}
+
+inline const DiagnosticBuilder &
+operator<<(const DiagnosticBuilder &DB, const llvm::Optional &Opt) {
+  if (Opt)
+DB << *Opt;
+  return DB;
+}
+
 /// A nullability kind paired with a bit indicating whether it used a
 /// context-sensitive keyword.
 using DiagNullabilityKind = std::pair;
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -429,11 +429,9 @@
   if (MakeSmartPtrFunctionHeader.empty()) {
 return;
   }
-  if (auto IncludeFixit = Inserter->CreateIncludeInsertion(
-  FD, MakeSmartPtrFunctionHeader,
-  /*IsAngled=*/MakeSmartPtrFunctionHeader == StdMemoryHeader)) {
-Diag << *IncludeFixit;
-  }
+  Diag << Inserter->CreateIncludeInsertion(
+  FD, MakeSmartPtrFunctionHeader,
+  /*IsAngled=*/MakeSmartPtrFunctionHeader == StdMemoryHeader);
 }
 
 } // namespace modernize
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsConstantArrayIndexCheck.cpp
@@ -86,13 +86,10 @@
   SourceRange(BaseRange.getEnd().getLocWithOffset(1),
   IndexRange.getBegin().getLocWithOffset(-1)),
   ", ")
-   << FixItHint::CreateReplacement(Matched->getEndLoc(), ")");
-
-  Optional Insertion = Inserter->CreateIncludeInsertion(
-  Result.SourceManager->getMainFileID(), GslHeader,
-  /*IsAngled=*/false);
-  if (Insertion)
-Diag << Insertion.getValue();
+   << FixItHint::CreateReplacement(Matched->getEndLoc(), ")")
+   << Inserter->CreateIncludeInsertion(
+  Result.SourceManager->getMainFileID(), GslHeader,
+  /*IsAngled=*/false);
 }
 return;
   }
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
@@ -96,10 +96,8 @@
MatchedDecl->getName().size()),
InitializationString);
 if (AddMathInclude) {
-  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
+  Diagnostic << IncludeInserter->CreateIncludeInsertion(
   Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader, false);
-  if (IncludeHint)
-Diagnostic << *IncludeHint;
 }
   }
 }
Index: clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
===
--- clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
+++ clang-tools-extra/clang-tidy/abseil/StringFindStartswithCheck.cpp
@@ -105,12 +105,9 @@
 
   // Create a preprocessor #include FixIt hint (CreateIncludeInsertion checks
   // whether this already exists).
-  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
+  Diagnostic << IncludeInserter->CreateIncludeInsertion(
   Source.getFileID(ComparisonExpr->getBeginLoc()), AbseilStringsMatchHeader,
   false);
-  if (IncludeHint) {
-Diagnostic << *IncludeHint;
-  }
 }
 
 void StringFi

[PATCH] D75903: [AArch64][CodeGen] Fixing stack alignment of HFA arguments on AArch64 PCS

2020-03-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 249360.
pratlucas added a comment.

Clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75903

Files:
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-args-hfa.c
  clang/test/CodeGen/arm64-arguments.c
  llvm/docs/LangRef.rst
  llvm/include/llvm/CodeGen/TargetCallingConv.h
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/include/llvm/IR/Argument.h
  llvm/include/llvm/IR/Attributes.h
  llvm/include/llvm/IR/Attributes.td
  llvm/include/llvm/IR/Function.h
  llvm/include/llvm/IR/InstrTypes.h
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
  llvm/lib/IR/Attributes.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
  llvm/test/Bitcode/compatibility.ll
  llvm/test/CodeGen/AArch64/arm64-abi-hfa-args.ll

Index: llvm/test/CodeGen/AArch64/arm64-abi-hfa-args.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/arm64-abi-hfa-args.ll
@@ -0,0 +1,54 @@
+; RUN: llc < %s -mtriple=arm64-none-eabi | FileCheck %s
+
+; Over-aligned HFA argument placed on register - one element per register
+define double @test_hfa_align_arg_reg([2 x double] alignstack(16) %h.coerce) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_arg_reg:
+; CHECK-DAG: ret
+
+  %h.coerce.fca.0.extract = extractvalue [2 x double] %h.coerce, 0
+  ret double %h.coerce.fca.0.extract
+}
+
+; Call with over-aligned HFA argument placed on register - one element per register
+define double @test_hfa_align_call_reg() local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_call_reg:
+; CHECK-DAG: fmov	d0, #1.
+; CHECK-DAG: fmov	d1, #2.
+; CHECK-DAG: bl	test_hfa_align_arg_reg
+; CHECK-DAG: ldr	x30, [sp], #16  // 8-byte Folded Reload
+; CHECK-DAG: ret
+
+  %call = call double @test_hfa_align_arg_reg([2 x double] alignstack(16) [double 1.00e+00, double 2.00e+00])
+  ret double %call
+}
+
+; Over-aligned HFA argument placed on stack - stack round up to alignment
+define double @test_hfa_align_arg_stack(double %d0, double %d1, double %d2, double %d3, double %d4, double %d5, double %d6, double %d7, float %f, [2 x double] alignstack(16) %h.coerce) local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_arg_stack:
+; CHECK-DAG: ldr	d0, [sp, #16]
+; CHECK-DAG: ret
+
+  %h.coerce.fca.0.extract = extractvalue [2 x double] %h.coerce, 0
+  ret double %h.coerce.fca.0.extract
+}
+
+; Call with over-aligned HFA argument placed on stack - stack round up to alignment
+define double @test_hfa_align_call_stack() local_unnamed_addr #0 {
+entry:
+; CHECK-LABEL: test_hfa_align_call_stack:
+; CHECK-DAG: mov	x8, #4611686018427387904
+; CHECK-DAG: mov	x9, #4607182418800017408
+; CHECK-DAG: stp	x8, x30, [sp, #24]  // 8-byte Folded Spill
+; CHECK-DAG: str	x9, [sp, #16]
+; CHECK-DAG: bl	test_hfa_align_arg
+; CHECK-DAG: ldr	x30, [sp, #32]  // 8-byte Folded Reload
+; CHECK-DAG: add	sp, sp, #48 // =48
+; CHECK-DAG: ret
+
+  %call = call double @test_hfa_align_arg_stack(double undef, double undef, double undef, double undef, double undef, double undef, double undef, double undef, float undef, [2 x double] alignstack(16) [double 1.00e+00, double 2.00e+00])
+  ret double %call
+}
+
Index: llvm/test/Bitcode/compatibility.ll
===
--- llvm/test/Bitcode/compatibility.ll
+++ llvm/test/Bitcode/compatibility.ll
@@ -548,6 +548,8 @@
 ; CHECK: declare void @f.param.dereferenceable(i8* dereferenceable(4))
 declare void @f.param.dereferenceable_or_null(i8* dereferenceable_or_null(4))
 ; CHECK: declare void @f.param.dereferenceable_or_null(i8* dereferenceable_or_null(4))
+declare void @f.param.stack_align([2 x double] alignstack(16))
+; CHECK: declare void @f.param.stack_align([2 x double] alignstack(16))
 
 ; Functions -- unnamed_addr and local_unnamed_addr
 declare void @f.unnamed_addr() unnamed_addr
Index: llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
===
--- llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
+++ llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
@@ -43,11 +43,16 @@
   const Align StackAlign =
   State.getMachineFunction().getDataLayout().getStackAlignment();
   const Align OrigAlign(ArgFlags.getOrigAlign());
-  const Align Align = std::min(OrigAlign, StackAlign);
+  const Align Alignment = std::min(OrigAlign, StackAlign);
+
+  if (ArgFlags.getStackAlign()) {
+const Align ArgStackAlign(ArgFlags.getStackAlign());
+State.AllocateStack(0, ArgStackAlign.value());
+  }
 
   for (auto &It : PendingMembers) {
 It.convertToMe

[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.cpp:17
+
+Matcher hasAnyListedName(std::vector Names) {
+  return Matcher(new HasNameMatcher(std::move(Names)));

This matcher sounds generally useful. I think it would be better placed in 
ASTMatchers.h, WDYT? Can we make it an overload of `hasAnyName`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75911



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki updated this revision to Diff 249362.
miyuki added a comment.

Address review comments


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

https://reviews.llvm.org/D75850

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsARM.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/arm_cde.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/arm-cde-gpr.c
  clang/test/Headers/arm-cde-header.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/arm-cde-immediates.c
  clang/test/Sema/arm-mve-alias-attribute.c
  clang/utils/TableGen/MveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/include/llvm/IR/IntrinsicsARM.td

Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1243,4 +1243,11 @@
 llvm_i32_ty /* unsigned output */, llvm_i32_ty /* unsigned input */,
 llvm_i32_ty /* top half */, llvm_anyvector_ty /* pred */], [IntrNoMem]>;
 
+// CDE (Custom Datapath Extension)
+
+def int_arm_cde_cx1: Intrinsic<
+  [llvm_i32_ty],
+  [llvm_i32_ty /* coproc */, llvm_i32_ty /* imm */],
+  [IntrNoMem, ImmArg<0>, ImmArg<1>]>;
+
 } // end TargetPrefix
Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -97,6 +97,12 @@
 void EmitMveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
+void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
 void EmitClangAttrDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangDiagDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangOptDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -70,6 +70,11 @@
   GenArmMveBuiltinSema,
   GenArmMveBuiltinCG,
   GenArmMveBuiltinAliases,
+  GenArmCdeHeader,
+  GenArmCdeBuiltinDef,
+  GenArmCdeBuiltinSema,
+  GenArmCdeBuiltinCG,
+  GenArmCdeBuiltinAliases,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -190,6 +195,16 @@
"Generate ARM MVE builtin code-generator for clang"),
 clEnumValN(GenArmMveBuiltinAliases, "gen-arm-mve-builtin-aliases",
"Generate list of valid ARM MVE builtin aliases for clang"),
+clEnumValN(GenArmCdeHeader, "gen-arm-cde-header",
+   "Generate arm_cde.h for clang"),
+clEnumValN(GenArmCdeBuiltinDef, "gen-arm-cde-builtin-def",
+   "Generate ARM CDE builtin definitions for clang"),
+clEnumValN(GenArmCdeBuiltinSema, "gen-arm-cde-builtin-sema",
+   "Generate ARM CDE builtin sema checks for clang"),
+clEnumValN(GenArmCdeBuiltinCG, "gen-arm-cde-builtin-codegen",
+   "Generate ARM CDE builtin code-generator for clang"),
+clEnumValN(GenArmCdeBuiltinAliases, "gen-arm-cde-builtin-aliases",
+   "Generate list of valid ARM CDE builtin aliases for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -351,6 +366,21 @@
   case GenArmMveBuiltinAliases:
 EmitMveBuiltinAliases(Records, OS);
 break;
+  case GenArmCdeHeader:
+EmitCdeHeader(Records, OS);
+break;
+  case GenArmCdeBuiltinDef:
+EmitCdeBuiltinDef(Records, OS);
+break;
+  case GenArmCdeBuiltinSema:
+EmitCdeBuiltinSema(Records, OS);
+break;
+  case GenArmCdeBuiltinCG:
+EmitCdeBuiltinCG(Records, OS);
+break;
+  case GenArmCdeBuiltinAliases:
+EmitCdeBuiltinAliases(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp

[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

Can we see more test cases for when after a call to `feof` we indeed can tell 
the stream is in an `EOF` state? Same for `ferror`. I feel like there is a lot 
of code we don't yet cover.

Also, I see now that I didn't get in earlier revisions that `OtherError` 
actually refers to `ferror()` -- sorry about the confusion :)




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:33-45
+  enum KindTy {
+Opened, /// Stream is opened.
+Closed, /// Closed stream (an invalid stream pointer after it was closed).
+OpenFailed /// The last open operation has failed.
+  } State;
+
+  /// The error state of a stream.

Hmm, now that I think of it, could we just merge these 2 enums? Also, I fear 
that indexers would accidentally assign the comment to the enum after the comma:

```lang=cpp
Opened, /// Stream is opened.
Closed, /// Closed stream (an invalid stream pointer after it was closed).
OpenFailed /// The last open operation has failed.
```
` /// Stream is opened` might be assigned to `Closed`. How about this:
```lang=cpp
/// Stream is opened.
Opened,
/// Closed stream (an invalid stream pointer after it was closed).
Closed,
/// The last open operation has failed.
OpenFailed
```



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:43
+EofError,   /// EOF condition (`feof` is true).
+OtherError, /// Other (non-EOF) error (`ferror` is true).
+AnyError/// EofError or OtherError, used if exact error is unknown.

Shouldn't we call this `FError` instead, if this is set precisely when 
`ferror()` is true? Despite the comments, I still managed to get myself 
confused with it :)



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:44
+OtherError, /// Other (non-EOF) error (`ferror` is true).
+AnyError/// EofError or OtherError, used if exact error is unknown.
+  } ErrorState = NoError;

When do we know that the stream is in an error state, but not precisely know 
what that error is within the context of this patch?  `fseek` would indeed 
introduce such a state, as described in D75356#inline-689287, but that should 
introduce its own error `ErrorKind`. I still don't really get why we would ever 
need `AnyError`.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:53
+  bool isEofError() const { return ErrorState == EofError; }
+  bool isOtherError() const { return ErrorState == OtherError; }
+  bool isAnyError() const { return ErrorState == AnyError; }

Same, shouldn't this be `isFError()`?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:54
+  bool isOtherError() const { return ErrorState == OtherError; }
+  bool isAnyError() const { return ErrorState == AnyError; }
+

This is confusing -- I would expect a method called `isAnyError()` to return 
true when `isNoError()` is false.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:355
+
+  if (SS->isNoError())
+return;

What if we call `clearerr()` on a stream that is in an `feof()` state? Shouln't 
we return if the stream is `!isOtherError()` (or `!isFError()`, if we were to 
rename it)?



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:383
+
+  if (SS->isAnyError()) {
+// We do not know yet what kind of error is set.

Does this ever run? We never actually set the stream state to `AnyError`.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:404-405
+
+void StreamChecker::evalFerror(const FnDescription *Desc, const CallEvent 
&Call,
+   CheckerContext &C) const {
+  ProgramStateRef State = C.getState();

This function is practically the same as `evalFeof`, can we merge them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



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


[clang] 47edf5b - [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-10 Thread Mikhail Maltsev via cfe-commits

Author: Mikhail Maltsev
Date: 2020-03-10T14:03:16Z
New Revision: 47edf5bafb8ede52dca836eac770efffbf657d30

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

LOG: [ARM,CDE] Generalize MVE intrinsics infrastructure to support CDE

Summary:
This patch generalizes the existing code to support CDE intrinsics
which will share some properties with existing MVE intrinsics
(some of the intrinsics will be polymorphic and accept/return values
of MVE vector types).
Specifically the patch:
* Adds new tablegen backends -gen-arm-cde-builtin-def,
  -gen-arm-cde-builtin-codegen, -gen-arm-cde-builtin-sema,
  -gen-arm-cde-builtin-aliases, -gen-arm-cde-builtin-header based on
  existing MVE backends.
* Renames the '__clang_arm_mve_alias' attribute into
  '__clang_arm_builtin_alias' (it will be used with CDE intrinsics as
  well as MVE intrinsics)
* Implements semantic checks for the coprocessor argument of the CDE
  intrinsics as well as the existing coprocessor intrinsics.
* Adds one CDE intrinsic __arm_cx1 to test the above changes

Reviewers: simon_tatham, MarkMurrayARM, ostannard, dmgreen

Reviewed By: simon_tatham

Subscribers: sdesmalen, mgorny, kristof.beyls, danielkiss, cfe-commits, 
llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/include/clang/Basic/arm_cde.td
clang/test/CodeGen/arm-cde-gpr.c
clang/test/Headers/arm-cde-header.c
clang/test/Sema/arm-cde-immediates.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/BuiltinsARM.def
clang/include/clang/Basic/CMakeLists.txt
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/arm_mve_defs.td
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Headers/CMakeLists.txt
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/arm-mve-alias-attribute.c
clang/utils/TableGen/MveEmitter.cpp
clang/utils/TableGen/TableGen.cpp
clang/utils/TableGen/TableGenBackends.h
llvm/include/llvm/IR/IntrinsicsARM.td

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a5b053209866..b18cfef33fba 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -622,11 +622,11 @@ def Alias : Attr {
   let Documentation = [Undocumented];
 }
 
-def ArmMveAlias : InheritableAttr, TargetSpecificAttr {
-  let Spellings = [Clang<"__clang_arm_mve_alias">];
+def ArmBuiltinAlias : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [Clang<"__clang_arm_builtin_alias">];
   let Args = [IdentifierArgument<"BuiltinName">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
-  let Documentation = [ArmMveAliasDocs];
+  let Documentation = [ArmBuiltinAliasDocs];
 }
 
 def Aligned : InheritableAttr {

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index cc9d3c80c0da..aea574995c8e 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4669,11 +4669,11 @@ When the Owner's lifetime ends, it will consider the 
Pointer to be dangling.
 }];
 }
 
-def ArmMveAliasDocs : Documentation {
+def ArmBuiltinAliasDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
-This attribute is used in the implementation of the ACLE intrinsics
-for the Arm MVE instruction set. It allows the intrinsic functions to
+This attribute is used in the implementation of the ACLE intrinsics.
+It allows the intrinsic functions to
 be declared using the names defined in ACLE, and still be recognized
 as clang builtins equivalent to the underlying name. For example,
 ``arm_mve.h`` declares the function ``vaddq_u32`` with
@@ -4684,8 +4684,8 @@ recognized as that clang builtin, and in the latter case, 
the choice
 of which builtin to identify the function as can be deferred until
 after overload resolution.
 
-This attribute can only be used to set up the aliases for the MVE
-intrinsic functions; it is intended for use only inside ``arm_mve.h``,
+This attribute can only be used to set up the aliases for certain Arm
+intrinsic functions; it is intended for use only inside ``arm_*.h``
 and is not a general mechanism for declaring arbitrary aliases for
 clang builtin functions.
   }];

diff  --git a/clang/include/clang/Basic/BuiltinsARM.def 
b/clang/include/clang/Basic/BuiltinsARM.def
index 848abb44ad36..be20c24aa28a 100644
--- a/clang/include/clang/Basic/BuiltinsARM.def
+++ b/clang/include/clang/Basic/BuiltinsARM.def
@@ -202,6 +202,8 @@ BUILTIN(__built

[clang-tools-extra] 714466b - Revert "[clang-tidy] New check: bugprone-suspicious-include"

2020-03-10 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-03-10T10:28:20-04:00
New Revision: 714466bf367dfd5062e1850179d27c37a9ec6b46

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

LOG: Revert "[clang-tidy] New check: bugprone-suspicious-include"

This reverts commit 1e0669bfe05f0f48ee88152c4a1d581f484f8d67
(and follow-ups 698a12712920c214e39bb215fe26fad2e099425b and
52bbdad7d63fd060d102b3591b433d116a982255).
The tests fail fail on Windows, see https://reviews.llvm.org/D74669

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/i.cpp
clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp



diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 9dcb315a257a..86936c678562 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -45,7 +45,6 @@
 #include "StringIntegerAssignmentCheck.h"
 #include "StringLiteralWithEmbeddedNulCheck.h"
 #include "SuspiciousEnumUsageCheck.h"
-#include "SuspiciousIncludeCheck.h"
 #include "SuspiciousMemsetUsageCheck.h"
 #include "SuspiciousMissingCommaCheck.h"
 #include "SuspiciousSemicolonCheck.h"
@@ -141,8 +140,6 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-string-literal-with-embedded-nul");
 CheckFactories.registerCheck(
 "bugprone-suspicious-enum-usage");
-CheckFactories.registerCheck(
-"bugprone-suspicious-include");
 CheckFactories.registerCheck(
 "bugprone-suspicious-memset-usage");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index a24f3bc7eb0d..c9078ed390d1 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -37,7 +37,6 @@ add_clang_library(clangTidyBugproneModule
   StringIntegerAssignmentCheck.cpp
   StringLiteralWithEmbeddedNulCheck.cpp
   SuspiciousEnumUsageCheck.cpp
-  SuspiciousIncludeCheck.cpp
   SuspiciousMemsetUsageCheck.cpp
   SuspiciousMissingCommaCheck.cpp
   SuspiciousSemicolonCheck.cpp

diff  --git a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
deleted file mode 100644
index ade7b111fc9a..
--- a/clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
+++ /dev/null
@@ -1,105 +0,0 @@
-//===--- SuspiciousIncludeCheck.cpp - clang-tidy 
--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "SuspiciousIncludeCheck.h"
-#include "clang/AST/ASTContext.h"
-
-namespace clang {
-namespace tidy {
-namespace bugprone {
-
-namespace {
-class SuspiciousIncludePPCallbacks : public PPCallbacks {
-public:
-  explicit SuspiciousIncludePPCallbacks(SuspiciousIncludeCheck &Check,
-const SourceManager &SM,
-Preprocessor *PP)
-  : Check(Check), PP(PP) {}
-
-  void InclusionDirective(SourceLocation HashLoc, const Token &IncludeTok,
-  StringRef FileName, bool IsAngled,
-  CharSourceRange FilenameRange, const FileEntry *File,
-  StringRef SearchPath, StringRef RelativePath,
-  const Module *Imported,
-  SrcMgr::CharacteristicKind FileType) override;
-
-private:
-  SuspiciousIncludeCheck &Check;
-  Preprocessor *PP;
-};
-} // name

[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.cpp:17
+
+Matcher hasAnyListedName(std::vector Names) {
+  return Matcher(new HasNameMatcher(std::move(Names)));

gribozavr2 wrote:
> This matcher sounds generally useful. I think it would be better placed in 
> ASTMatchers.h, WDYT? Can we make it an overload of `hasAnyName`?
`hasAnyName` is a const variable who's type is `VariadicFunction` so it can't 
be overloaded unfortunately. I personally didn't want it in ASTMatchers.h as 
its mainly useful for `clang-tidy` checks that load in configurations. It 
doesn't have a place in say `clang-query`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75911



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


[PATCH] D75922: [ASTImporter] Compare the DC of the underlying type of a FriendDecl

2020-03-10 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added reviewers: a_sidorin, shafik.
Herald added subscribers: cfe-commits, teemperor, gamesh411, Szelethus, dkrupp, 
rnkovacs.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.

Currently, we do not check the scope of friend classes. This can result in some
cases with missing nodes in the imported AST. E.g.:

  class Container {
friend class X; // A friend class ::X
class X{ };
friend class X; // Friend class Container::X
  };

... here either `::X` or `Container::X` is missing after importing `Container`.
This patch fixes the problem.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75922

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4023,6 +4023,35 @@
   EXPECT_EQ(ImportedFoo, ToFoo);
 }
 
+TEST_P(ImportFriendClasses, ImportOfInlineFriendClassAfterFwdWithSameName) {
+  auto Code =
+  R"(
+  class Container {
+friend class X; // A friend class ::X
+class X{ };
+friend class X; // Friend class Container::X
+  };
+  )";
+  Decl *FromTu = getTuDecl(Code, Lang_CXX, "from.cc");
+
+  auto *To = Import(FirstDeclMatcher().match(
+FromTu, cxxRecordDecl(hasName("Container"))),
+Lang_CXX);
+  ASSERT_TRUE(To);
+
+  Decl *ToTu = To->getTranslationUnitDecl();
+  auto *ToFriend1 = FirstDeclMatcher().match(ToTu, friendDecl());
+  auto *ToFriend2 = LastDeclMatcher().match(ToTu, friendDecl());
+  auto *ToX = FirstDeclMatcher().match(
+  ToTu, cxxRecordDecl(hasName("X"), unless(isImplicit(;
+
+  EXPECT_NE(ToFriend1, ToFriend2);
+  const RecordDecl *RecordOfFriend1 = getRecordDeclOfFriend(ToFriend1);
+  const RecordDecl *RecordOfFriend2 = getRecordDeclOfFriend(ToFriend2);
+  EXPECT_NE(RecordOfFriend1, ToX);
+  EXPECT_EQ(RecordOfFriend2, ToX);
+}
+
 struct DeclContextTest : ASTImporterOptionSpecificTestBase {};
 
 TEST_P(DeclContextTest, removeDeclOfClassTemplateSpecialization) {
Index: clang/lib/AST/ASTImporter.cpp
===
--- clang/lib/AST/ASTImporter.cpp
+++ clang/lib/AST/ASTImporter.cpp
@@ -3632,6 +3632,30 @@
   return ToIndirectField;
 }
 
+// Returns the DeclContext of the underlying friend declaration/type.  If that
+// is a dependent type then the returned optional does not have a value.
+static Optional getDCOfUnderlyingDecl(FriendDecl *FrD) {
+  if (NamedDecl *ND = FrD->getFriendDecl())
+return ND->getDeclContext();
+  if (FrD->getFriendType()) {
+QualType Ty = FrD->getFriendType()->getType();
+if (isa(Ty))
+  Ty = cast(Ty)->getNamedType();
+if (!Ty->isDependentType()) {
+  if (const auto *RTy = dyn_cast(Ty))
+return RTy->getAsCXXRecordDecl()->getDeclContext();
+  else if (const auto *SpecTy = dyn_cast(Ty))
+return SpecTy->getAsCXXRecordDecl()->getDeclContext();
+  else if (const auto TypedefTy = dyn_cast(Ty))
+return TypedefTy->getDecl()->getDeclContext();
+  else
+llvm_unreachable("Unhandled type of friend");
+}
+  }
+  // DependentType
+  return Optional();
+}
+
 ExpectedDecl ASTNodeImporter::VisitFriendDecl(FriendDecl *D) {
   // Import the major distinguishing characteristics of a declaration.
   DeclContext *DC, *LexicalDC;
@@ -3641,9 +3665,25 @@
   // Determine whether we've already imported this decl.
   // FriendDecl is not a NamedDecl so we cannot use lookup.
   auto *RD = cast(DC);
-  FriendDecl *ImportedFriend = RD->getFirstFriend();
 
-  while (ImportedFriend) {
+  for (FriendDecl *ImportedFriend = RD->getFirstFriend(); ImportedFriend;
+   ImportedFriend = ImportedFriend->getNextFriend()) {
+
+// Compare the semantic DeclContext of the underlying declarations of the
+// existing and the to be imported friend.
+// Normally, lookup ensures this, but with friends we cannot use the lookup.
+Optional ImportedFriendDC =
+getDCOfUnderlyingDecl(ImportedFriend);
+Optional FromFriendDC = getDCOfUnderlyingDecl(D);
+if (FromFriendDC) { // The underlying friend type is not dependent.
+  ExpectedDecl FriendDCDeclOrErr = import(cast(*FromFriendDC));
+  if (!FriendDCDeclOrErr)
+return FriendDCDeclOrErr.takeError();
+  DeclContext *FriendDC = cast(*FriendDCDeclOrErr);
+  if (ImportedFriendDC != FriendDC)
+continue;
+}
+
 if (D->getFriendDecl() && ImportedFriend->getFriendDecl()) {
   if (IsStructuralMatch(D->getFriendDecl(), ImportedFriend->getFriendDecl(),
 /*Complain=*/false))
@@ -3655,7 +3695,6 @@
 ImportedFriend->getFriendType()->getType(), true))
 return Importer.MapImported(D, ImportedFriend);
 }
-ImportedFriend = ImportedFriend->getNext

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-03-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:3713
+  switch (ord) {
+  case 0:  // memory_order_relaxed
+  default: // invalid order

Interesting, fence can't be relaxed

> ‘fence’ instructions take an ordering argument which defines what 
> synchronizes-with edges they add. They can only be given acquire, release, 
> acq_rel, and seq_cst orderings.





Comment at: clang/lib/Sema/SemaChecking.cpp:1880
+// Check if Order is an unsigned
+if (!Ty->isIntegerType()) {
+  Diag(ArgExpr->getExprLoc(), diag::err_typecheck_expect_uint) << Ty;

isIntegerType will return true for signed integers as well as unsigned. It 
seems reasonable to call this with a signed integer type (e.g. '2'), so perhaps 
the references to unsigned should be dropped from the code and error message




Comment at: clang/lib/Sema/SemaChecking.cpp:1889
+
+// Check if Order is one of the valid types
+if (!llvm::isValidAtomicOrderingCABI(ord)) {

This should reject 'relaxed' - I think that's currently accepted by sema then 
silently thrown away by codegen



Comment at: clang/test/CodeGenOpenCL/atomic-ops.cl:291
 
+void test_memory_fence() {
+  // CHECK-LABEL: @test_memory_fence

I'm hoping this intrinsic will be usable from C or C++, as well as from OpenCL 
- please could you add a non-opencl codegen test.

It doesn't need to check all the cases again, just enough to show that the 
intrinsic and arguments are available (they're spelled like `__ATOMIC_SEQ_CST`, 
`__OPENCL_MEMORY_SCOPE_ALL_SVM_DEVICES` outside of opencl)



Comment at: clang/test/SemaOpenCL/atomic-ops.cl:198
+
+void memory_fence_errors() {
+  __builtin_memory_fence(memory_order_seq_cst + 1, memory_scope_work_group); 
// expected-error {{memory order argument to fence operation is invalid}}

A happy case too please, e.g. to show that it accepts a couple of integers. 
Looks like ` __builtin_memory_fence(2, 2);` but without an expected-error 
comment


Repository:
  rC Clang

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

https://reviews.llvm.org/D75917



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


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-03-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:1516
 
+// Builtin to expose llvm fence instruction
+BUILTIN(__builtin_memory_fence, "vUiUi", "t")

`BUILTIN(__builtin_memory_fence, "vii", "n")`?

The other fence intrinsics (e.g. __c11_atomic_thread_fence) take signed 
integers and rely on the built in type checking, which seems reasonable here too


Repository:
  rC Clang

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

https://reviews.llvm.org/D75917



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


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally added a comment.

Sorry, forgot to submit my nit...




Comment at: llvm/include/llvm/IR/PatternMatch.h:75
+/// Match an arbitrary binary operation and ignore it.
+inline class_match m_UnOp() {
+  return class_match();

Nit: Comment needs updating.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 3 inline comments as done.
erichkeane added inline comments.



Comment at: clang/lib/AST/MicrosoftMangle.cpp:2956
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }

Anastasia wrote:
> We don't seem to add namespace for other OpenCL types, although I am not 
> against it as I find it actually cleaner.
> 
> Since the mangling deviates what is documented can you add some comments here 
> explaining your mangling scheme?
The Microsoft mangling scheme is owned by the Microsoft Corporation, so adding 
something to their mangling (like 8ocl_pipe) isn't permitted.  Thus, the clang 
project mangles our types that aren't supported by Microsoft as a type in the 
__clang namespace.  

You'll note that we do it for a bunch of types above, including 
AddressSpaceType, VectorType, _Complex, _Float16, _Half, etc.



Comment at: clang/test/CodeGenOpenCLCXX/pipe_types_mangling.cl:20
+//  or write/read. Our Windows mangling does, so make sure this still works.
+void test2(read_only pipe int p) {
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"

Anastasia wrote:
> any reason this is different from the rest?
Sorry, I don't understand the question perhaps? (different in what way?).  

Do you mean why it is in a macro? I wanted an example to show that overloading 
works so I chose test2.  As the comment says, the OpenCL standard mangling 
doesn't support overloading on just pipes (since they don't take element type 
and read/write into account).  

In those cases, we get a code-gen emitted diagnostic that two functions have 
identical mangling.


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

https://reviews.llvm.org/D75685



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


[PATCH] D75685: Add MS Mangling for OpenCL Pipe types, add mangling test.

2020-03-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 249367.
erichkeane added a comment.

Thanks @Anastasia  for the review!  Comments inline.

Moved the test as requested, and added OpenCL tests for both OSes.


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

https://reviews.llvm.org/D75685

Files:
  clang/lib/AST/MicrosoftMangle.cpp
  clang/test/CodeGenOpenCL/pipe_types_mangling.cl

Index: clang/test/CodeGenOpenCL/pipe_types_mangling.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/pipe_types_mangling.cl
@@ -0,0 +1,72 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=clc++ -o - %s | FileCheck %s --check-prefixes=LINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=clc++ -o - %s -DWIN| FileCheck %s --check-prefixes=WINDOWS
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -O0 -cl-std=CL2.0 -o - %s | FileCheck %s --check-prefixes=UNMANGLED,OCLLINUX
+// RUN: %clang_cc1 -triple x86_64-unknown-windows-pc -emit-llvm -O0 -cl-std=CL2.0 -o - %s -DWIN| FileCheck %s --check-prefixes=UNMANGLED,OCLWINDOWS
+
+typedef unsigned char __attribute__((ext_vector_type(3))) uchar3;
+typedef int __attribute__((ext_vector_type(4))) int4;
+
+void test1(read_only pipe int p) {
+// LINUX: define void @_Z5test18ocl_pipe
+// WINDOWS: define dso_local void @"?test1@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test1(
+}
+
+__attribute__((overloadable))
+void test2(write_only pipe float p) {
+// LINUX: define void @_Z5test28ocl_pipe
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
+// Note: overloadable attribute makes OpenCL Linux still mangle this,
+// but we cannot overload on pipe still.
+// OCLLINUX: define void @_Z5test28ocl_pipe
+// OCLWINDOWS: define dso_local void @"?test2@@$$J0YAXU?$ocl_pipe@M$0A@@__clang@@@Z"
+}
+
+#ifdef WIN
+// SPIR Spec specifies mangling on pipes that doesn't include the element type
+//  or write/read. Our Windows mangling does, so make sure this still works.
+__attribute__((overloadable))
+void test2(read_only pipe int p) {
+// WINDOWS: define dso_local void @"?test2@@YAXU?$ocl_pipe@H$00@__clang@@@Z"
+// OCLWINDOWS: define dso_local void @"?test2@@$$J0YAXU?$ocl_pipe@H$00@__clang@@@Z"
+}
+#endif
+
+
+void test3(read_only pipe const int p) {
+// LINUX: define void @_Z5test38ocl_pipe
+// WINDOWS: define dso_local void @"?test3@@YAXU?$ocl_pipe@$$CBH$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test3(
+}
+
+void test4(read_only pipe uchar3 p) {
+// LINUX: define void @_Z5test48ocl_pipe
+// WINDOWS: define dso_local void @"?test4@@YAXU?$ocl_pipe@T?$__vector@E$02@__clang@@$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test4(
+}
+
+void test5(read_only pipe int4 p) {
+// LINUX: define void @_Z5test58ocl_pipe
+// WINDOWS: define dso_local void @"?test5@@YAXU?$ocl_pipe@T?$__vector@H$03@__clang@@$00@__clang@@@Z"
+// UNMANGLED: define {{.*}}void @test5(
+}
+
+typedef read_only pipe int MyPipe;
+kernel void test6(MyPipe p) {
+// LINUX: define spir_kernel void @test6
+// WINDOWS: define dso_local spir_kernel void @test6
+// UNMANGLED: define {{.*}}void @test6(
+}
+
+struct Person {
+  const char *Name;
+  bool isFemale;
+  int ID;
+};
+
+void test_reserved_read_pipe(global struct Person *SDst,
+ read_only pipe struct Person SPipe) {
+// LINUX: define void @_Z23test_reserved_read_pipePU8CLglobal6Person8ocl_pipe
+// WINDOWS: define dso_local void @"?test_reserved_read_pipe@@YAXPEAU?$_ASCLglobal@$$CAUPerson@@@__clang@@U?$ocl_pipe@UPerson@@$00@2@@Z"
+// UNMANGLED: define {{.*}}void @test_reserved_read_pipe(
+}
Index: clang/lib/AST/MicrosoftMangle.cpp
===
--- clang/lib/AST/MicrosoftMangle.cpp
+++ clang/lib/AST/MicrosoftMangle.cpp
@@ -2943,11 +2943,17 @@
 
 void MicrosoftCXXNameMangler::mangleType(const PipeType *T, Qualifiers,
  SourceRange Range) {
-  DiagnosticsEngine &Diags = Context.getDiags();
-  unsigned DiagID = Diags.getCustomDiagID(DiagnosticsEngine::Error,
-"cannot mangle this OpenCL pipe type yet");
-  Diags.Report(Range.getBegin(), DiagID)
-<< Range;
+  QualType ElementType = T->getElementType();
+
+  llvm::SmallString<64> TemplateMangling;
+  llvm::raw_svector_ostream Stream(TemplateMangling);
+  MicrosoftCXXNameMangler Extra(Context, Stream);
+  Stream << "?$";
+  Extra.mangleSourceName("ocl_pipe");
+  Extra.mangleType(ElementType, Range, QMM_Escape);
+  Extra.mangleIntegerLiteral(llvm::APSInt::get(T->isReadOnly()), true);
+
+  mangleArtificialTagType(TTK_Struct, TemplateMangling, {"__clang"});
 }
 
 void MicrosoftMangleContextImpl::mangleCXXName(const NamedDecl *D,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Cameron McInally via Phabricator via cfe-commits
cameron.mcinally accepted this revision.
cameron.mcinally added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks, Simon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467



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


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: llvm/include/llvm/IR/PatternMatch.h:622
 inline bind_ty m_Instruction(Instruction *&I) { return I; }
 /// Match a binary operator, capturing it if we match.
+inline bind_ty m_UnOp(UnaryOperator *&I) { return I; }

Match a binary -> Match a unary



Comment at: llvm/include/llvm/IR/PatternMatch.h:802-803
+
+  // The evaluation order is always stable, regardless of Commutability.
+  // The LHS is always matched first.
+  AnyUnaryOp_match(const OP_t &X) : X(X) {}

The copied comment doesn't make sense for a unary op; there's no 
commutability/LHS here.



Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:379
 
+  // TODO de-duplicate binary and unary matches cmatchers with n-ary matching
+  UnaryOperator *UO;

typo: cmatchers?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467



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


[PATCH] D75850: [ARM, CDE] Generalize MVE intrinsics infrastructure to support CDE

2020-03-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG47edf5bafb8e: [ARM,CDE] Generalize MVE intrinsics 
infrastructure to support CDE (authored by miyuki).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75850

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsARM.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/arm_cde.td
  clang/include/clang/Basic/arm_mve_defs.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/arm-cde-gpr.c
  clang/test/Headers/arm-cde-header.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/arm-cde-immediates.c
  clang/test/Sema/arm-mve-alias-attribute.c
  clang/utils/TableGen/MveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/include/llvm/IR/IntrinsicsARM.td

Index: llvm/include/llvm/IR/IntrinsicsARM.td
===
--- llvm/include/llvm/IR/IntrinsicsARM.td
+++ llvm/include/llvm/IR/IntrinsicsARM.td
@@ -1243,4 +1243,11 @@
 llvm_i32_ty /* unsigned output */, llvm_i32_ty /* unsigned input */,
 llvm_i32_ty /* top half */, llvm_anyvector_ty /* pred */], [IntrNoMem]>;
 
+// CDE (Custom Datapath Extension)
+
+def int_arm_cde_cx1: Intrinsic<
+  [llvm_i32_ty],
+  [llvm_i32_ty /* coproc */, llvm_i32_ty /* imm */],
+  [IntrNoMem, ImmArg<0>, ImmArg<1>]>;
+
 } // end TargetPrefix
Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -97,6 +97,12 @@
 void EmitMveBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitMveBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 
+void EmitCdeHeader(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinDef(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinSema(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinCG(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitCdeBuiltinAliases(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+
 void EmitClangAttrDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangDiagDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangOptDocs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -70,6 +70,11 @@
   GenArmMveBuiltinSema,
   GenArmMveBuiltinCG,
   GenArmMveBuiltinAliases,
+  GenArmCdeHeader,
+  GenArmCdeBuiltinDef,
+  GenArmCdeBuiltinSema,
+  GenArmCdeBuiltinCG,
+  GenArmCdeBuiltinAliases,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -190,6 +195,16 @@
"Generate ARM MVE builtin code-generator for clang"),
 clEnumValN(GenArmMveBuiltinAliases, "gen-arm-mve-builtin-aliases",
"Generate list of valid ARM MVE builtin aliases for clang"),
+clEnumValN(GenArmCdeHeader, "gen-arm-cde-header",
+   "Generate arm_cde.h for clang"),
+clEnumValN(GenArmCdeBuiltinDef, "gen-arm-cde-builtin-def",
+   "Generate ARM CDE builtin definitions for clang"),
+clEnumValN(GenArmCdeBuiltinSema, "gen-arm-cde-builtin-sema",
+   "Generate ARM CDE builtin sema checks for clang"),
+clEnumValN(GenArmCdeBuiltinCG, "gen-arm-cde-builtin-codegen",
+   "Generate ARM CDE builtin code-generator for clang"),
+clEnumValN(GenArmCdeBuiltinAliases, "gen-arm-cde-builtin-aliases",
+   "Generate list of valid ARM CDE builtin aliases for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -351,6 +366,21 @@
   case GenArmMveBuiltinAliases:
 EmitMveBuiltinAliases(Records, OS);
 break;
+  case GenArmCdeHeader:
+EmitCdeHeader(Records, OS);
+break;
+  case GenArmCdeBuiltinDef:
+EmitCdeBuiltinDef(Records, OS);
+break;
+  case GenArmCdeBuiltinSema:
+EmitCdeBuiltinSema(Records, OS);
+break;
+  case GenArmCdeBuiltinCG:
+EmitCdeBuiltinCG(Records, OS);
+break;
+  case GenArmCdeBuiltinAliases:
+EmitCdeBuiltinAliases(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/MveEmitter.cpp

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Reverted for now in 714466bf367dfd5062e1850179d27c37a9ec6b46 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669



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


[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-10 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 249370.
sdesmalen edited the summary of this revision.
sdesmalen added a comment.

- Rebased patch on top of D75850 .
- Removed `__clang_arm_sve_alias` in favour of `__clang_arm_builtin_alias`


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

https://reviews.llvm.org/D75861

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -102,6 +102,8 @@
   /// string for passing to the BUILTIN() macro in Builtins.def.
   std::string builtin_str() const;
 
+  std::string str() const;
+
 private:
   /// Creates the type based on the typespec string in TS.
   void applyTypespec();
@@ -341,6 +343,45 @@
   return "q" + utostr(getNumElements() * NumVectors) + S;
 }
 
+std::string SVEType::str() const {
+  if (isPredicatePattern())
+return "sv_pattern";
+
+  if (isPrefetchOp())
+return "sv_prfop";
+
+  std::string S;
+  if (Void)
+S += "void";
+  else {
+if (isScalableVector())
+  S += "sv";
+if (!Signed && !Float)
+  S += "u";
+
+if (Float)
+  S += "float";
+else if (isScalarPredicate())
+  S += "bool";
+else
+  S += "int";
+
+if (!isScalarPredicate())
+  S += utostr(ElementBitwidth);
+if (!isScalableVector() && isVector())
+  S += "x" + utostr(getNumElements());
+if (NumVectors > 1)
+  S += "x" + utostr(NumVectors);
+S += "_t";
+  }
+
+  if (Constant)
+S += " const";
+  if (Pointer)
+S += " *";
+
+  return S;
+}
 void SVEType::applyTypespec() {
   for (char I : TS) {
 switch (I) {
@@ -521,8 +562,19 @@
<< "(...) __builtin_sve_" << mangleName(ClassS)
<< "(__VA_ARGS__)\n";
   } else {
-llvm_unreachable("Not yet implemented. Overloaded intrinsics will follow "
- "in a future patch");
+std::string FullName = mangleName(ClassS);
+std::string ProtoName = mangleName(ClassG);
+
+OS << "__aio __attribute__((__clang_arm_builtin_alias("
+   << "__builtin_sve_" << FullName << ")))\n";
+
+OS << getTypes()[0].str() << " " << ProtoName << "(";
+for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
+  if (I != 0)
+OS << ", ";
+  OS << getTypes()[I + 1].str();
+}
+OS << ");\n";
   }
 }
 
@@ -565,6 +617,12 @@
 Out.push_back(std::make_unique(R, Name, Proto, Merge, MemEltType,
   LLVMName, Flags, TS, ClassS,
   *this, Guard));
+
+// Also generate the short-form (e.g. svadd_m) for the given type-spec.
+if (Intrinsic::isOverloadedIntrinsic(Name))
+  Out.push_back(std::make_unique(R, Name, Proto, Merge,
+MemEltType, LLVMName, Flags, TS,
+ClassG, *this, Guard));
   }
 }
 
@@ -643,6 +701,10 @@
   OS << "typedef __SVFloat64_t svfloat64_t;\n";
   OS << "typedef __SVBool_t  svbool_t;\n\n";
 
+  OS << "/* Function attributes */\n";
+  OS << "#define __aio static inline __attribute__((__always_inline__, "
+"__nodebug__, __overloadable__))\n\n";
+
   SmallVector, 128> Defs;
   std::vector RV = Records.getAllDerivedDefinitions("Inst");
   for (auto *R : RV)
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s -D__ARM_FEATURE_SVE | FileCheck %s
+
+#include 
+//
+// ld1
+//
+
+svint8_t test_svld1_s8(svbool_t pg, const int8_t *base)
+{
+  // CHECK-LABEL: test_svld1_s8
+  // CHECK:  @llvm.masked.load.nxv16i8.p0nxv16i8(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint16_t test_svld1_s16(svbool_t pg, const int16_t *base)
+{
+  // CHECK-LABEL: test_svld1_s16
+  // CHECK:  @llvm.masked.load.nxv8i16.p0nxv8i16(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint32_t test_svld1_s32(svbool_t pg, const int32_t *base)
+{
+  // CHECK-LABEL: test_svld1_s32
+  // CHECK:  @llvm.masked.load.nxv4i32.p0nxv4i32(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint64_t test_svld1_s64(svbool_t pg, const int64_t *base)
+{
+  // CHECK-LABEL: test_svld1_s64
+  // CHECK:  @llvm.masked.load.nxv2i64.p0nxv2i64(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svuint8_t test_svld1_u8(svbool_t pg, const uint8_t *base)
+{
+  // CHECK-LABEL: test_

[PATCH] D74669: [clang-tidy] New check: bugprone-suspicious-include

2020-03-10 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs updated this revision to Diff 249377.
jroelofs added a comment.

Don't fire on `#import`s.

The error on Windows suggests it would normally do the "right" thing anyway:

http://45.33.8.238/win/10088/step_8.txt

  
C:\src\llvm-project\out\gn\obj\clang-tools-extra\test\clang-tidy\checkers\Output\bugprone-suspicious-include.cpp.tmp.cpp:18:2:
 error: #import of type library is an unsupported Microsoft feature 
[clang-diagnostic-error]
  #import "c.c"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74669

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.cpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/a.hpp
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.c
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cc
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/c.cxx
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/i.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-suspicious-include.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s bugprone-suspicious-include %t -- -- -isystem %S/Inputs/Headers -fmodules
+
+// clang-format off
+
+// CHECK-MESSAGES: [[@LINE+4]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+3]]:11: note: did you mean to include 'a'?
+// CHECK-MESSAGES: [[@LINE+2]]:11: note: did you mean to include 'a.h'?
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'a.hpp'?
+#include "a.cpp"
+
+// CHECK-MESSAGES: [[@LINE+2]]:11: warning: suspicious #include of file with '.cpp' extension
+// CHECK-MESSAGES: [[@LINE+1]]:11: note: did you mean to include 'i.h'?
+#include "i.cpp"
+
+#include "b.h"
+
+// CHECK-MESSAGES: [[@LINE+1]]:16: warning: suspicious #include_next of file with '.c' extension
+#include_next 
+
+// CHECK-MESSAGES: [[@LINE+1]]:13: warning: suspicious #include of file with '.cc' extension
+# include  
+
+// CHECK-MESSAGES: [[@LINE+1]]:14: warning: suspicious #include of file with '.cxx' extension
+#  include  
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-suspicious-include.rst
@@ -0,0 +1,32 @@
+.. title:: clang-tidy - bugprone-suspicious-include
+
+bugprone-suspicious-include
+===
+
+The check detects various cases when an include refers to what appears to be an
+implementation file, which often leads to hard-to-track-down ODR violations.
+
+Examples:
+
+.. code-block:: c++
+
+  #include "Dinosaur.hpp" // OK, .hpp files tend not to have definitions.
+  #include "Pterodactyl.h"// OK, .h files tend not to have definitions.
+  #include "Velociraptor.cpp" // Warning, filename is suspicious.
+  #include_next  // Warning, filename is suspicious.
+
+Options
+---
+.. option:: HeaderFileExtensions
+
+   Default value: `";h;hh;hpp;hxx"`
+   A semicolon-separated list of filename extensions of header files (the
+   filename extensions should not contain a "." prefix). For extension-less
+   header files, use an empty string or leave an empty string between ";"
+   if there are other filename extensions.
+
+.. option:: ImplementationFileExtensions
+
+   Default value: `"c;cc;cpp;cxx"`
+   Likewise, a semicolon-separated list of filename extensions of
+   implementation files.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -82,6 +82,13 @@
 
   Checks for usages of identifiers reserved for use by the implementation.
 
+- New :doc:`bugprone-suspicious-include
+  ` check.
+
+  Finds cases where an include refers to what appears to be an implementation
+  file, which often leads to hard-to-track-down ODR violations, and diagnoses
+  them.
+
 - New :doc:`cert-oop57-cpp
   ` check.
 
Index: clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
===
--- clang-tools-extra

[PATCH] D75851: [Analyzer][StreamChecker] Added evaluation of fseek.

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus requested changes to this revision.
Szelethus added a comment.
This revision now requires changes to proceed.

We should totally dedicate an error kind of `fseek`, see (and please respond, 
if you could to) D75356#inline-689287 
.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:382-384
+  C.addTransition(StateNotFailed);
+  C.addTransition(StateFailedWithFError);
+  C.addTransition(StateFailedWithoutFError);

This seems a bit excessive, we could merge the last two into `FSeekError`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75851



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


[PATCH] D74973: [analyzer] StdLibraryFunctionsChecker refactor w/ inheritance

2020-03-10 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 2 inline comments as done.
martong added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:151
+
+  using ValueConstraintPtr = std::shared_ptr;
+  /// The complete list of constraints that defines a single branch.

Szelethus wrote:
> martong wrote:
> > martong wrote:
> > > Szelethus wrote:
> > > > gamesh411 wrote:
> > > > > martong wrote:
> > > > > > Note here, we need a copyable, polymorphic and default 
> > > > > > initializable type (vector needs that). A raw pointer were good, 
> > > > > > however, we cannot default initialize that. unique_ptr makes the 
> > > > > > Summary class non-copyable, therefore not an option.
> > > > > > Releasing the copyablitly requirement would render the 
> > > > > > initialization of the Summary map infeasible.
> > > > > > Perhaps we could come up with a [[ 
> > > > > > https://www.youtube.com/watch?v=bIhUE5uUFOA | type erasure 
> > > > > > technique without inheritance ]] once we consider the shared_ptr as 
> > > > > > restriction, but for now that seems to be overkill.
> > > > > std::variant (with std::monostate for the default constructibility) 
> > > > > would also be an option  (if c++17 were supported). But this is not 
> > > > > really an issue, i agree with that.
> > > > Ugh, we've historically been very hostile towards virtual functions. We 
> > > > don't mind them that much when they don't have to run a lot, like 
> > > > during bug report construction, but as a core part of the analysis, I'm 
> > > > not sure what the current stance is on it.
> > > > 
> > > > I'm not inherently (haha) against it, and I'm fine with leaving this 
> > > > as-is for the time being, though I'd prefer if you placed a `TODO` to 
> > > > revisit this issue.
> > > > std::variant (with std::monostate for the default constructibility) 
> > > > would also be an option (if c++17 were supported). But this is not 
> > > > really an issue, i agree with that.
> > > 
> > > Variant would be useful if we knew the set of classes prior and we wanted 
> > > to add operations gradually. Class hierarchies (or run-time concepts 
> > > [Sean Parent]) are very useful if we know the set of operations prior and 
> > > we want to add classes gradually, and we have this case here.
> > > Ugh, we've historically been very hostile towards virtual functions. We 
> > > don't mind them that much when they don't have to run a lot, like during 
> > > bug report construction, but as a core part of the analysis, I'm not sure 
> > > what the current stance is on it.
> > 
> > I did not find any evidence for this statement. Consider as a counter 
> > example the ExternalASTSource interface in Clang, which is filled with 
> > virtual functions and is part of the C/C++ lookup mechanism, which is quite 
> > on the hot path of C/C++ parsing I think. Did not find any prohibition in 
> > LLVM coding guidelines neither. I do believe virtual functions have their 
> > use cases exactly where (runtime) polimorphism is needed, such as in this 
> > patch.
> > 
> I consider myself proven wrong here then.
Thanks for the review and for considering other alternatives! And please accept 
my apologies, maybe I was pushing too hard on inheritance.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74973



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


[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added inline comments.



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:5002
 
   if (!ArmMveAliasValid(BuiltinID, AliasName) &&
+  !ArmCdeAliasValid(BuiltinID, AliasName) &&

I would suggest splitting the check into Arm-specific and AArch64-specific 
checks to speed things up (if it is easy to get the current target arch in this 
context).


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

https://reviews.llvm.org/D75861



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


[PATCH] D75579: [WIP] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by libraries

2020-03-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 249378.
serge-sans-paille added a comment.

Cleaned up code, using a few macros to avoid duplication.

No longer a WIP


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75579

Files:
  clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp
  lld/Common/TargetOptionsCommandFlags.cpp
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/CommandFlags.inc
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.inc
  llvm/include/llvm/module.modulemap
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/MC/CMakeLists.txt
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/tools/dsymutil/DwarfStreamer.cpp
  llvm/tools/gold/gold-plugin.cpp
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/llc/llc.cpp
  llvm/tools/lli/CMakeLists.txt
  llvm/tools/lli/lli.cpp
  llvm/tools/llvm-dwp/llvm-dwp.cpp
  llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp
  llvm/tools/llvm-lto/CMakeLists.txt
  llvm/tools/llvm-lto/llvm-lto.cpp
  llvm/tools/llvm-lto2/CMakeLists.txt
  llvm/tools/llvm-lto2/llvm-lto2.cpp
  llvm/tools/llvm-mc-assemble-fuzzer/CMakeLists.txt
  llvm/tools/llvm-mc-assemble-fuzzer/llvm-mc-assemble-fuzzer.cpp
  llvm/tools/llvm-mc/CMakeLists.txt
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-mca/llvm-mca.cpp
  llvm/tools/llvm-ml/llvm-ml.cpp
  llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp
  llvm/tools/lto/CMakeLists.txt
  llvm/tools/lto/lto.cpp
  llvm/tools/opt/opt.cpp
  llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp

Index: llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
===
--- llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
+++ llvm/unittests/DebugInfo/DWARF/DwarfGenerator.cpp
@@ -25,7 +25,7 @@
 #include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSubtargetInfo.h"
-#include "llvm/MC/MCTargetOptionsCommandFlags.inc"
+#include "llvm/MC/MCTargetOptionsCommandFlags.h"
 #include "llvm/PassAnalysisSupport.h"
 #include "llvm/Support/LEB128.h"
 #include "llvm/Support/TargetRegistry.h"
@@ -37,6 +37,8 @@
 using namespace llvm;
 using namespace dwarf;
 
+mc::InitMCTargetOptionsFlags MOF;
+
 namespace {} // end anonymous namespace
 
 //===--===//
@@ -433,7 +435,7 @@
TripleName,
inconvertibleErrorCode());
 
-  MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
+  MCTargetOptions MCOptions = mc::InitMCTargetOptionsFromFlags();
   MAI.reset(TheTarget->createMCAsmInfo(*MRI, TripleName, MCOptions));
   if (!MAI)
 return make_error("no asm info for target " + TripleName,
Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -22,7 +22,7 @@
 #include "llvm/Analysis/TargetLibraryInfo.h"
 #include "llvm/Analysis/TargetTransformInfo.h"
 #include "llvm/Bitcode/BitcodeWriterPass.h"
-#include "llvm/CodeGen/CommandFlags.inc"
+#include "llvm/CodeGen/CommandFlags.h"
 #include "llvm/CodeGen/TargetPassConfig.h"
 #include "llvm/Config/llvm-config.h"
 #include "llvm/IR/DataLayout.h"
@@ -62,6 +62,8 @@
 using namespace llvm;
 using namespace opt_tool;
 
+static codegen::InitializeCodeGenFlags CFG;
+
 // The OptimizationList is automatically populated with registered Passes by the
 // PassNameParser.
 //
@@ -471,16 +473,17 @@
StringRef FeaturesStr,
const TargetOptions &Options) {
   std::string Error;
-  const Target *TheTarget = TargetRegistry::lookupTarget(MArch, TheTriple,
- Error);
+  const Target *TheTarget =
+  TargetRegistry::lookupTarget(codegen::getMArch(), TheTriple, Error);
   // Some modules don't specify a triple, and this is okay.
   if (!TheTarget) {
 return nullptr;
   }
 
-  return TheTarget->createTargetMachine(TheTriple.getTriple(), CPUStr,
-FeaturesStr, Options, getRelocModel(),
-getCodeModel(), GetCodeGenOptLevel());
+  return TheTarget->createTargetMachine(
+  TheTriple.getTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(),
+  Options, codegen::getExplicitRelocModel(),
+  codegen::getExplicitCodeModel(), GetCodeGenOptLevel());
 }
 
 #ifdef BUILD_EXAMPLES
@@ -667,11 +670,11 @@
   Triple ModuleTriple(M->getTargetTriple());
   std::string CPUStr, FeaturesStr;
   TargetMachine *Machine = nullptr;
-  const TargetOptions Options = InitTargetOptionsFromCodeGenFlags();
+  const TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags();
 
   if (ModuleTriple.getArch()) {
-CPUStr = getCPUStr();
-FeaturesStr = g

[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-03-10 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin updated this revision to Diff 249380.
DmitryPolukhin added a comment.

Handle global options


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
  
clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/config-files.cpp
@@ -7,6 +7,26 @@
 // RUN: clang-tidy -dump-config %S/Inputs/config-files/2/- -- | FileCheck %s -check-prefix=CHECK-CHILD2
 // CHECK-CHILD2: Checks: {{.*}}from-parent
 // CHECK-CHILD2: HeaderFilterRegex: parent
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/3/- -- | FileCheck %s -check-prefix=CHECK-CHILD3
+// CHECK-CHILD3: Checks: {{.*}}from-parent,from-child3
+// CHECK-CHILD3: HeaderFilterRegex: child3
 // RUN: clang-tidy -dump-config -checks='from-command-line' -header-filter='from command line' %S/Inputs/config-files/- -- | FileCheck %s -check-prefix=CHECK-COMMAND-LINE
 // CHECK-COMMAND-LINE: Checks: {{.*}}from-parent,from-command-line
 // CHECK-COMMAND-LINE: HeaderFilterRegex: from command line
+
+// For this test we have to use names of the real checks because otherwise values are ignored.
+// RUN: clang-tidy -dump-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-CHILD4
+// CHECK-CHILD4: Checks: {{.*}}modernize-loop-convert,modernize-use-using,llvm-qualified-auto
+// CHECK-CHILD4: - key: llvm-qualified-auto.AddConstToQualified
+// CHECK-CHILD4-NEXT: value: '1
+// CHECK-CHILD4: - key: modernize-loop-convert.MaxCopySize
+// CHECK-CHILD4-NEXT: value: '20'
+// CHECK-CHILD4: - key: modernize-loop-convert.MinConfidence
+// CHECK-CHILD4-NEXT: value: reasonable
+// CHECK-CHILD4: - key: modernize-use-using.IgnoreMacros
+// CHECK-CHILD4-NEXT: value: '0'
+
+// RUN: clang-tidy --explain-config %S/Inputs/config-files/4/44/- -- | FileCheck %s -check-prefix=CHECK-EXPLAIN
+// CHECK-EXPLAIN: 'llvm-qualified-auto' is enabled in the {{.*}}/Inputs/config-files/4/44/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-loop-convert' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
+// CHECK-EXPLAIN: 'modernize-use-using' is enabled in the {{.*}}/Inputs/config-files/4/.clang-tidy.
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/44/.clang-tidy
@@ -0,0 +1,9 @@
+InheritParentConfig: true
+Checks: 'llvm-qualified-auto'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '20'
+  - key: llvm-qualified-auto.AddConstToQualified
+value:   '1'
+  - key: IgnoreMacros
+value:   '0'
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/4/.clang-tidy
@@ -0,0 +1,8 @@
+Checks: '-*,modernize-loop-convert,modernize-use-using'
+CheckOptions:
+  - key: modernize-loop-convert.MaxCopySize
+value:   '10'
+  - key: modernize-loop-convert.MinConfidence
+value:   reasonable
+  - key: modernize-use-using.IgnoreMacros
+value:   1
Index: clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/Inputs/config-files/3/.clang-tidy
@@ -0,0 +1,3 @@
+InheritParentConfig: true
+Checks: 'from-child3'
+HeaderFilterRegex: 'child3'
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -244,17 +244,20 @@
   Configuration files:
 clang-tidy attempts to read configuration for each source file from a
 .clang-tidy file located in the closest parent directory of the source
-file. If any configuration options have a corresponding command-line
-option, command-line option takes precedence. The effective
-con

[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-03-10 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

In D75184#1912650 , @njames93 wrote:

> How are local and global options handled. 
>  From what I can gather it will read the value as `1` as the local option is 
> checked first no matter which file it was defined in.


You are absolutely right about current behaviour. Thank you for catching this 
odd behaviour. I'm not 100% confident what is the right behaviour but my guess 
is that overriding local option from parent config with global from child 
folder is better so I implemented it and added corresponding test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184



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


[PATCH] D75579: [WIP] Replace MCTargetOptionsCommandFlags.inc and CommandFlags.inc by libraries

2020-03-10 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@MaskRay

>   because that will cause duplicate registration of llvm::cl::opt flags.

Not with this setup, if I'm not mistaken: the static registration is triggered 
by the static variables inside the constructor call, and if I'm not mistaken, 
initialization of such variables only happens once. Basically, this relies on 
the unicity of the constructor symbol, and this is granted by the fact there's 
only one lib defining it (either libLLVM or libLLVMCodeGen).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75579



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


[PATCH] D75903: [AArch64][CodeGen] Fixing stack alignment of HFA arguments on AArch64 PCS

2020-03-10 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

I've not looked at the code in detail yet, but I think this still gets the ABI 
wrong for this example:

  typedef struct {
__attribute__ ((__aligned__(32))) double v[4];
  } TYPE1;
  
  double func(double d0, double d1, double d2, double d3,
  double d4, double d5, double d6, double d7,
  float stk0, TYPE1 stk1) {
return stk1.v[0];
  }

The ABI says 
(https://github.com/ARM-software/abi-aa/blob/master/aapcs64/aapcs64.rst, rule 
B.5):

  If the argument is an alignment adjusted type its value is passed as a copy 
of the actual value. The copy will have an alignment defined as follows.
  * For a Fundamental Data Type, the alignment is the natural alignment of that 
type, after any promotions.
  * For a Composite Type, the alignment of the copy will have 8-byte alignment 
if its natural alignment is <= 8 and 16-byte alignment if its natural alignment 
is >= 16.
  The alignment of the copy is used for applying marshaling rules.

This means that `stk1` should be passed as a copy with alignment 16 bytes, 
putting it at `sp+16`. GCC does this, clang without this patch passes it at 
`sp+8`, and clang with this patch passes it at `sp+32`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75903



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


[PATCH] D75184: [clang-tidy] Optional inheritance of file configs from parent directories 

2020-03-10 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

In D75184#1914705 , @DmitryPolukhin 
wrote:

> You are absolutely right about current behaviour. Thank you for catching this 
> odd behaviour. I'm not 100% confident what is the right behaviour but my 
> guess is that overriding local option from parent config with global from 
> child folder is better so I implemented it and added corresponding test.


It's a tricky one that, but I thing overriding the local option with the global 
in the sub directory is the correct way to go about this as well.




Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:144
+  // Assume that global options don't have dot in the name.
+  return Name.find('.') == std::string::npos;
+}

May I suggest using `return !Name.contains('.');` to make the code more 
readable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75184



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


[PATCH] D75911: [clang-tidy] Added hasAnyListedName matcher

2020-03-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/Matchers.cpp:17
+
+Matcher hasAnyListedName(std::vector Names) {
+  return Matcher(new HasNameMatcher(std::move(Names)));

njames93 wrote:
> gribozavr2 wrote:
> > This matcher sounds generally useful. I think it would be better placed in 
> > ASTMatchers.h, WDYT? Can we make it an overload of `hasAnyName`?
> `hasAnyName` is a const variable who's type is `VariadicFunction` so it can't 
> be overloaded unfortunately. I personally didn't want it in ASTMatchers.h as 
> its mainly useful for `clang-tidy` checks that load in configurations. It 
> doesn't have a place in say `clang-query`.
> hasAnyName is a const variable who's type is VariadicFunction so it can't be 
> overloaded unfortunately.

I thought we had facilities to declare polymorphic matchers that could help 
here.

> I personally didn't want it in ASTMatchers.h as its mainly useful for 
> clang-tidy checks that load in configurations.

A lot of user-defined tools are quite similar.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75911



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


[PATCH] D74766: [ARM] Fixing range checks for Neon's vqdmulhq_lane and vqrdmulhq_lane intrinsics

2020-03-10 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas updated this revision to Diff 249392.
pratlucas added a comment.

Clang-format.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74766

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-neon-range-checks.c


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside 
the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is 
outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is 
outside the valid range [0, 3]}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5806,9 +5806,14 @@
   case NEON::BI__builtin_neon_vqdmulh_lane_v:
   case NEON::BI__builtin_neon_vqrdmulhq_lane_v:
   case NEON::BI__builtin_neon_vqrdmulh_lane_v: {
+llvm::Type *RTy = Ty;
+if (BuiltinID == NEON::BI__builtin_neon_vqdmulhq_lane_v ||
+BuiltinID == NEON::BI__builtin_neon_vqrdmulhq_lane_v)
+  RTy = llvm::VectorType::get(Ty->getVectorElementType(),
+  Ty->getVectorNumElements() * 2);
 llvm::Type *Tys[2] = {
-Ty, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
-/*isQuad*/ false))};
+RTy, GetNeonType(this, NeonTypeFlags(Type.getEltType(), false,
+ /*isQuad*/ false))};
 return EmitNeonCall(CGM.getIntrinsic(Int, Tys), Ops, NameHint);
   }
   case NEON::BI__builtin_neon_vqdmulhq_laneq_v:
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -547,8 +547,8 @@
 def VQRDMULH_LANE : SOpInst<"vqrdmulh_lane", "..qI", "siQsQi", OP_QRDMULH_LN>;
 }
 let ArchGuard = "defined(__aarch64__)" in {
-def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..qI", "siQsQi">;
-def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..qI", "siQsQi">;
+def A64_VQDMULH_LANE  : SInst<"vqdmulh_lane", "..(!q)I", "siQsQi">;
+def A64_VQRDMULH_LANE : SInst<"vqrdmulh_lane", "..(!q)I", "siQsQi">;
 }
 
 let ArchGuard = "defined(__ARM_FEATURE_QRDMX)" in {


Index: clang/test/CodeGen/arm-neon-range-checks.c
===
--- clang/test/CodeGen/arm-neon-range-checks.c
+++ clang/test/CodeGen/arm-neon-range-checks.c
@@ -280,6 +280,13 @@
   vqdmulh_lane_s32(a, b, 1);
 }
 
+void test_vqdmulhq_lane(int32x4_t a, int32x2_t b) {
+  vqdmulhq_lane_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
+  vqdmulhq_lane_s32(a, b, 0);
+  vqdmulhq_lane_s32(a, b, 1);
+}
+
 #if defined(__aarch64__)
 void test_vqdmulh_laneq(int32x2_t a, int32x4_t b) {
   vqdmulh_laneq_s32(a, b, -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
@@ -393,6 +400,13 @@
   vqrdmulh_lane_s32(a, v,  1);
 }
 
+void test_vqrdmulhq_lane(int32x4_t a, int32x2_t v) {
+  vqrdmulhq_lane_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  2); // expected-error {{argument value 2 is outside the valid range [0, 1]}}
+  vqrdmulhq_lane_s32(a, v,  0);
+  vqrdmulhq_lane_s32(a, v,  1);
+}
+
 #if defined(__aarch64__)
 void test_vqrdmulh_laneq(int32x2_t a, int32x4_t v) {
   vqrdmulh_laneq_s32(a, v,  -1); // expected-error {{argument value -1 is outside the valid range [0, 3]}}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeG

[PATCH] D75682: [Analyzer][StreamChecker] Introduction of stream error handling.

2020-03-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked 6 inline comments as done.
balazske added a comment.

The problem here with tests is that there is no function to call that sets the 
error flags `FEof` or `FError`. So it is only possible to check if these are 
not set after opening the file.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:33-45
+  enum KindTy {
+Opened, /// Stream is opened.
+Closed, /// Closed stream (an invalid stream pointer after it was closed).
+OpenFailed /// The last open operation has failed.
+  } State;
+
+  /// The error state of a stream.

Szelethus wrote:
> Hmm, now that I think of it, could we just merge these 2 enums? Also, I fear 
> that indexers would accidentally assign the comment to the enum after the 
> comma:
> 
> ```lang=cpp
> Opened, /// Stream is opened.
> Closed, /// Closed stream (an invalid stream pointer after it was closed).
> OpenFailed /// The last open operation has failed.
> ```
> ` /// Stream is opened` might be assigned to `Closed`. How about this:
> ```lang=cpp
> /// Stream is opened.
> Opened,
> /// Closed stream (an invalid stream pointer after it was closed).
> Closed,
> /// The last open operation has failed.
> OpenFailed
> ```
Probably these can be merged, it is used for a stream that is in an 
indeterminate state after failed `freopen`, but practically it is handled the 
same way as a closed stream. But this change would be done in another revision.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:43
+EofError,   /// EOF condition (`feof` is true).
+OtherError, /// Other (non-EOF) error (`ferror` is true).
+AnyError/// EofError or OtherError, used if exact error is unknown.

Szelethus wrote:
> Shouldn't we call this `FError` instead, if this is set precisely when 
> `ferror()` is true? Despite the comments, I still managed to get myself 
> confused with it :)
Plan is to rename to `NoError`, `FEofError`, `FErrorError`, `FEofOrFErrorError`.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:44
+OtherError, /// Other (non-EOF) error (`ferror` is true).
+AnyError/// EofError or OtherError, used if exact error is unknown.
+  } ErrorState = NoError;

Szelethus wrote:
> When do we know that the stream is in an error state, but not precisely know 
> what that error is within the context of this patch?  `fseek` would indeed 
> introduce such a state, as described in D75356#inline-689287, but that should 
> introduce its own error `ErrorKind`. I still don't really get why we would 
> ever need `AnyError`.
This is the problem is the change is too small: The next part of it introduces 
functions where the new error flags are used. In this patch the AnyError 
feature is not used (the feof and ferror read it but nothing sets it).



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:54
+  bool isOtherError() const { return ErrorState == OtherError; }
+  bool isAnyError() const { return ErrorState == AnyError; }
+

Szelethus wrote:
> This is confusing -- I would expect a method called `isAnyError()` to return 
> true when `isNoError()` is false.
The error state kinds are not mutually exclusive. The "any error" means we know 
that there is some error but we do not know what the error is (it is not 
relevant because nothing was done that depends on it). If a function is called 
that needs to know if "ferror" or "feof" is the error, the state will be split 
to `FErrorError` and `FEofError`.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:355
+
+  if (SS->isNoError())
+return;

Szelethus wrote:
> What if we call `clearerr()` on a stream that is in an `feof()` state? 
> Shouln't we return if the stream is `!isOtherError()` (or `!isFError()`, if 
> we were to rename it)?
`clearerr` does not return any value. It only clears the error flags (sets to 
false). In my interpretation the stream has one error value associated with it, 
this value may be **EOF** or "other" error, or no error. There are not two 
error flags, only one kind of error that may be EOF or other.



Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:404-405
+
+void StreamChecker::evalFerror(const FnDescription *Desc, const CallEvent 
&Call,
+   CheckerContext &C) const {
+  ProgramStateRef State = C.getState();

Szelethus wrote:
> This function is practically the same as `evalFeof`, can we merge them?
It is not the same code ("EOF" and "other error" are interchanged), but can be 
merged somehow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75682



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://li

[PATCH] D74618: [ARM] Creating 'call_mangled' for Neon intrinsics definitions

2020-03-10 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio accepted this revision.
dnsampaio added a comment.
This revision is now accepted and ready to land.

LGTM, after a nit inline.




Comment at: clang/include/clang/Basic/arm_neon_incl.td:66
+//that has the variation and takes the given types, an error
+//is generated at tblgen time.
+def call_mangled;

As the example above, it would be nice to have an example here as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D74618



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


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Simon Moll via Phabricator via cfe-commits
simoll updated this revision to Diff 249396.
simoll marked 5 inline comments as done.
simoll added a comment.

- NFC
- Fixed code comments
- Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467

Files:
  clang/test/CodeGen/fma-builtins-constrained.c
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/test/Transforms/InstCombine/X86/x86-avx512.ll
  llvm/test/Transforms/InstCombine/cos-1.ll
  llvm/test/Transforms/InstCombine/fadd.ll
  llvm/test/Transforms/InstCombine/fast-math.ll
  llvm/test/Transforms/InstCombine/fdiv.ll
  llvm/test/Transforms/InstCombine/fmul.ll
  llvm/test/Transforms/InstCombine/fneg.ll
  llvm/test/Transforms/InstCombine/fpextend.ll
  llvm/test/Transforms/InstCombine/fsub.ll
  llvm/test/Transforms/InstCombine/maximum.ll
  llvm/test/Transforms/InstCombine/maxnum.ll
  llvm/test/Transforms/InstCombine/minimum.ll
  llvm/test/Transforms/InstCombine/minnum.ll
  llvm/test/Transforms/InstCombine/operand-complexity.ll
  llvm/test/Transforms/InstCombine/vec_shuffle.ll

Index: llvm/test/Transforms/InstCombine/vec_shuffle.ll
===
--- llvm/test/Transforms/InstCombine/vec_shuffle.ll
+++ llvm/test/Transforms/InstCombine/vec_shuffle.ll
@@ -1263,7 +1263,7 @@
 
 define <2 x float> @fneg(<2 x float> %x) {
 ; CHECK-LABEL: @fneg(
-; CHECK-NEXT:[[TMP1:%.*]] = fsub <2 x float> , [[X:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = fneg <2 x float> [[X:%.*]]
 ; CHECK-NEXT:[[R:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> undef, <2 x i32> zeroinitializer
 ; CHECK-NEXT:ret <2 x float> [[R]]
 ;
Index: llvm/test/Transforms/InstCombine/operand-complexity.ll
===
--- llvm/test/Transforms/InstCombine/operand-complexity.ll
+++ llvm/test/Transforms/InstCombine/operand-complexity.ll
@@ -92,7 +92,7 @@
 define float @fneg(float %x) {
 ; CHECK-LABEL: @fneg(
 ; CHECK-NEXT:[[BO:%.*]] = fdiv float [[X:%.*]], 4.20e+01
-; CHECK-NEXT:[[FNEGX:%.*]] = fsub float -0.00e+00, [[X]]
+; CHECK-NEXT:[[FNEGX:%.*]] = fneg float [[X]]
 ; CHECK-NEXT:[[R:%.*]] = fmul float [[BO]], [[FNEGX]]
 ; CHECK-NEXT:call void @use(float [[FNEGX]])
 ; CHECK-NEXT:ret float [[R]]
@@ -122,7 +122,7 @@
 define <2 x float> @fneg_vec(<2 x float> %x) {
 ; CHECK-LABEL: @fneg_vec(
 ; CHECK-NEXT:[[BO:%.*]] = fdiv <2 x float> [[X:%.*]], 
-; CHECK-NEXT:[[FNEGX:%.*]] = fsub <2 x float> , [[X]]
+; CHECK-NEXT:[[FNEGX:%.*]] = fneg <2 x float> [[X]]
 ; CHECK-NEXT:[[R:%.*]] = fmul <2 x float> [[BO]], [[FNEGX]]
 ; CHECK-NEXT:call void @use_vec(<2 x float> [[FNEGX]])
 ; CHECK-NEXT:ret <2 x float> [[R]]
@@ -137,7 +137,7 @@
 define <2 x float> @fneg_vec_undef(<2 x float> %x) {
 ; CHECK-LABEL: @fneg_vec_undef(
 ; CHECK-NEXT:[[BO:%.*]] = fdiv <2 x float> [[X:%.*]], 
-; CHECK-NEXT:[[FNEGX:%.*]] = fsub <2 x float> , [[X]]
+; CHECK-NEXT:[[FNEGX:%.*]] = fneg <2 x float> [[X]]
 ; CHECK-NEXT:[[R:%.*]] = fmul <2 x float> [[BO]], [[FNEGX]]
 ; CHECK-NEXT:call void @use_vec(<2 x float> [[FNEGX]])
 ; CHECK-NEXT:ret <2 x float> [[R]]
Index: llvm/test/Transforms/InstCombine/minnum.ll
===
--- llvm/test/Transforms/InstCombine/minnum.ll
+++ llvm/test/Transforms/InstCombine/minnum.ll
@@ -301,7 +301,7 @@
 declare void @use(double)
 define double @neg_neg_extra_use_x(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg_extra_use_x(
-; CHECK-NEXT:[[NEGX:%.*]] = fsub double -0.00e+00, [[X:%.*]]
+; CHECK-NEXT:[[NEGX:%.*]] = fneg double [[X:%.*]]
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X]], double [[Y:%.*]])
 ; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:call void @use(double [[NEGX]])
@@ -331,7 +331,7 @@
 
 define double @neg_neg_extra_use_y(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg_extra_use_y(
-; CHECK-NEXT:[[NEGY:%.*]] = fsub double -0.00e+00, [[Y:%.*]]
+; CHECK-NEXT:[[NEGY:%.*]] = fneg double [[Y:%.*]]
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y]])
 ; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:call void @use(double [[NEGY]])
@@ -361,8 +361,8 @@
 
 define double @neg_neg_extra_use_x_and_y(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg_extra_use_x_and_y(
-; CHECK-NEXT:[[NEGX:%.*]] = fsub double -0.00e+00, [[X:%.*]]
-; CHECK-NEXT:[[NEGY:%.*]] = fsub double -0.00e+00, [[Y:%.*]]
+; CHECK-NEXT:[[NEGX:%.*]] = fneg double [[X:%.*]]
+; CHECK-NEXT:[[NEGY:%.*]] = fneg double [[Y:%.*]]
 ; CHECK-NEXT:[[R:%.*]] = call double @llvm.minnum.f64(double [[NE

[clang] d871ef4 - [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Simon Moll via cfe-commits

Author: Simon Moll
Date: 2020-03-10T16:57:02+01:00
New Revision: d871ef4e6ade3797c73cbc54d9214513ee6c7468

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

LOG: [instcombine] remove fsub to fneg hacks; only emit fneg

Summary: Rewrite the fsub-0.0 idiom to fneg and always emit fneg for fp
negation. This also extends the scalarization cost in instcombine for unary
operators to result in the same IR rewrites for fneg as for the idiom.

Reviewed By: cameron.mcinally

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

Added: 


Modified: 
clang/test/CodeGen/fma-builtins-constrained.c
llvm/include/llvm/IR/PatternMatch.h
llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
llvm/test/Transforms/InstCombine/X86/x86-avx512.ll
llvm/test/Transforms/InstCombine/cos-1.ll
llvm/test/Transforms/InstCombine/fadd.ll
llvm/test/Transforms/InstCombine/fast-math.ll
llvm/test/Transforms/InstCombine/fdiv.ll
llvm/test/Transforms/InstCombine/fmul.ll
llvm/test/Transforms/InstCombine/fneg.ll
llvm/test/Transforms/InstCombine/fpextend.ll
llvm/test/Transforms/InstCombine/fsub.ll
llvm/test/Transforms/InstCombine/maximum.ll
llvm/test/Transforms/InstCombine/maxnum.ll
llvm/test/Transforms/InstCombine/minimum.ll
llvm/test/Transforms/InstCombine/minnum.ll
llvm/test/Transforms/InstCombine/operand-complexity.ll
llvm/test/Transforms/InstCombine/vec_shuffle.ll

Removed: 




diff  --git a/clang/test/CodeGen/fma-builtins-constrained.c 
b/clang/test/CodeGen/fma-builtins-constrained.c
index 6b299278b108..685b55cc4eb0 100644
--- a/clang/test/CodeGen/fma-builtins-constrained.c
+++ b/clang/test/CodeGen/fma-builtins-constrained.c
@@ -66,10 +66,10 @@ __m128d test_mm_fmsub_pd(__m128d a, __m128d b, __m128d c) {
 
 __m128 test_mm_fmsub_ss(__m128 a, __m128 b, __m128 c) {
   // COMMON-LABEL: test_mm_fmsub_ss
-  // COMMONIR: [[NEG:%.+]] = fneg <4 x float> %{{.+}}
   // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
   // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
   // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: [[NEG:%.+]] = fneg float %{{.+}}
   // UNCONSTRAINED: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, 
float %{{.*}})
   // CONSTRAINED: call float @llvm.experimental.constrained.fma.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !{{.*}})
   // CHECK-ASM: vfmsub213ss
@@ -79,10 +79,10 @@ __m128 test_mm_fmsub_ss(__m128 a, __m128 b, __m128 c) {
 
 __m128d test_mm_fmsub_sd(__m128d a, __m128d b, __m128d c) {
   // COMMON-LABEL: test_mm_fmsub_sd
-  // COMMONIR: [[NEG:%.+]] = fneg <2 x double> %{{.+}}
   // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
   // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
   // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
+  // COMMONIR: [[NEG:%.+]] = fneg double %{{.+}}
   // UNCONSTRAINED: call double @llvm.fma.f64(double %{{.*}}, double %{{.*}}, 
double %{{.*}})
   // CONSTRAINED: call double @llvm.experimental.constrained.fma.f64(double 
%{{.*}}, double %{{.*}}, double %{{.*}}, metadata !{{.*}})
   // CHECK-ASM: vfmsub213sd
@@ -110,9 +110,9 @@ __m128d test_mm_fnmadd_pd(__m128d a, __m128d b, __m128d c) {
 
 __m128 test_mm_fnmadd_ss(__m128 a, __m128 b, __m128 c) {
   // COMMON-LABEL: test_mm_fnmadd_ss
-  // COMMONIR: [[NEG:%.+]] = fneg <4 x float> %{{.+}}
   // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
   // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
+  // COMMONIR: [[NEG:%.+]] = fneg float %{{.+}}
   // COMMONIR: extractelement <4 x float> %{{.*}}, i64 0
   // UNCONSTRAINED: call float @llvm.fma.f32(float %{{.*}}, float %{{.*}}, 
float %{{.*}})
   // CONSTRAINED: call float @llvm.experimental.constrained.fma.f32(float 
%{{.*}}, float %{{.*}}, float %{{.*}}, metadata !{{.*}})
@@ -123,9 +123,9 @@ __m128 test_mm_fnmadd_ss(__m128 a, __m128 b, __m128 c) {
 
 __m128d test_mm_fnmadd_sd(__m128d a, __m128d b, __m128d c) {
   // COMMON-LABEL: test_mm_fnmadd_sd
-  // COMMONIR: [[NEG:%.+]] = fneg <2 x double> %{{.+}}
   // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
   // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
+  // COMMONIR: [[NEG:%.+]] = fneg double %{{.+}}
   // COMMONIR: extractelement <2 x double> %{{.*}}, i64 0
   // UNCONSTRAINED: call double @llvm.fma.f64(double %{{.*}}, double %{{.*}}, 
double %{{.*}})
   // CONSTRAINED: call double @llvm.experimental.constrained.fma.f64(double 
%{{.*}}, double %{{.*}}, double %{{.*}}, metadata !{{.*}})
@@ -156,11 +156,11 @@ __m128d test_mm_fnmsub_pd(__m128d a, __m128d b, __m128d 
c) {
 
 __m128 test_m

[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-03-10 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a subscriber: jdoerfert.
JonChesterfield added a comment.

@jdoerfert this is one of the two intrinsics needed to drop the .ll source from 
the amdgcn deviceRTL. The other is atomic_inc.


Repository:
  rC Clang

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

https://reviews.llvm.org/D75917



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


[PATCH] D75851: [Analyzer][StreamChecker] Added evaluation of fseek.

2020-03-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske marked an inline comment as done.
balazske added a comment.

I do not like to make difference between error from `fseek` and error from any 
other function that may fail. `AnyError` can be used to handle every case. 
After a failed file operation we do not know if it was `feof` or `ferror` kind 
of error. `fseek` is only special because it can fail additionally without 
`feof` or `ferror`. If the kind of the last operation needs to be known later, 
it can be saved in the stream state.




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:382-384
+  C.addTransition(StateNotFailed);
+  C.addTransition(StateFailedWithFError);
+  C.addTransition(StateFailedWithoutFError);

Szelethus wrote:
> This seems a bit excessive, we could merge the last two into `FSeekError`.
There are 3 cases:
 - `fseek` did not fail at all. Return value is zero. This is `StateNotFailed`.
 - `fseek` failed but none of the error flags is true afterwards. Return value 
is nonzero but `feof` and `ferror` are not true. This is 
`StateFailedWithoutFError`.
 - `fseek` failed and we have `feof` or `ferror` set (never both). Return value 
is nonzero and `feof` or `ferror` will be true. This is 
`StateFailedWithFError`. And an use of `AnyError`, otherwise we need here 2 
states, one for `feof` and one for `ferror`. But it is not important here if 
`feof` or `ferror` is actually true, so the special value `AnyError` is used 
and only one new state instead of two.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75851



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


[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-10 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 249404.
sdesmalen added a comment.

- Refactored condition to check for valid builtins (split up checks for Arm and 
AArch64)


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

https://reviews.llvm.org/D75861

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
  clang/utils/TableGen/SveEmitter.cpp

Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -102,6 +102,8 @@
   /// string for passing to the BUILTIN() macro in Builtins.def.
   std::string builtin_str() const;
 
+  std::string str() const;
+
 private:
   /// Creates the type based on the typespec string in TS.
   void applyTypespec();
@@ -341,6 +343,45 @@
   return "q" + utostr(getNumElements() * NumVectors) + S;
 }
 
+std::string SVEType::str() const {
+  if (isPredicatePattern())
+return "sv_pattern";
+
+  if (isPrefetchOp())
+return "sv_prfop";
+
+  std::string S;
+  if (Void)
+S += "void";
+  else {
+if (isScalableVector())
+  S += "sv";
+if (!Signed && !Float)
+  S += "u";
+
+if (Float)
+  S += "float";
+else if (isScalarPredicate())
+  S += "bool";
+else
+  S += "int";
+
+if (!isScalarPredicate())
+  S += utostr(ElementBitwidth);
+if (!isScalableVector() && isVector())
+  S += "x" + utostr(getNumElements());
+if (NumVectors > 1)
+  S += "x" + utostr(NumVectors);
+S += "_t";
+  }
+
+  if (Constant)
+S += " const";
+  if (Pointer)
+S += " *";
+
+  return S;
+}
 void SVEType::applyTypespec() {
   for (char I : TS) {
 switch (I) {
@@ -521,8 +562,19 @@
<< "(...) __builtin_sve_" << mangleName(ClassS)
<< "(__VA_ARGS__)\n";
   } else {
-llvm_unreachable("Not yet implemented. Overloaded intrinsics will follow "
- "in a future patch");
+std::string FullName = mangleName(ClassS);
+std::string ProtoName = mangleName(ClassG);
+
+OS << "__aio __attribute__((__clang_arm_builtin_alias("
+   << "__builtin_sve_" << FullName << ")))\n";
+
+OS << getTypes()[0].str() << " " << ProtoName << "(";
+for (unsigned I = 0; I < getTypes().size() - 1; ++I) {
+  if (I != 0)
+OS << ", ";
+  OS << getTypes()[I + 1].str();
+}
+OS << ");\n";
   }
 }
 
@@ -565,6 +617,12 @@
 Out.push_back(std::make_unique(R, Name, Proto, Merge, MemEltType,
   LLVMName, Flags, TS, ClassS,
   *this, Guard));
+
+// Also generate the short-form (e.g. svadd_m) for the given type-spec.
+if (Intrinsic::isOverloadedIntrinsic(Name))
+  Out.push_back(std::make_unique(R, Name, Proto, Merge,
+MemEltType, LLVMName, Flags, TS,
+ClassG, *this, Guard));
   }
 }
 
@@ -643,6 +701,10 @@
   OS << "typedef __SVFloat64_t svfloat64_t;\n";
   OS << "typedef __SVBool_t  svbool_t;\n\n";
 
+  OS << "/* Function attributes */\n";
+  OS << "#define __aio static inline __attribute__((__always_inline__, "
+"__nodebug__, __overloadable__))\n\n";
+
   SmallVector, 128> Defs;
   std::vector RV = Records.getAllDerivedDefinitions("Inst");
   for (auto *R : RV)
Index: clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
===
--- /dev/null
+++ clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_ld1_shortform.c
@@ -0,0 +1,83 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -emit-llvm -o - %s -D__ARM_FEATURE_SVE | FileCheck %s
+
+#include 
+//
+// ld1
+//
+
+svint8_t test_svld1_s8(svbool_t pg, const int8_t *base)
+{
+  // CHECK-LABEL: test_svld1_s8
+  // CHECK:  @llvm.masked.load.nxv16i8.p0nxv16i8(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint16_t test_svld1_s16(svbool_t pg, const int16_t *base)
+{
+  // CHECK-LABEL: test_svld1_s16
+  // CHECK:  @llvm.masked.load.nxv8i16.p0nxv8i16(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint32_t test_svld1_s32(svbool_t pg, const int32_t *base)
+{
+  // CHECK-LABEL: test_svld1_s32
+  // CHECK:  @llvm.masked.load.nxv4i32.p0nxv4i32(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svint64_t test_svld1_s64(svbool_t pg, const int64_t *base)
+{
+  // CHECK-LABEL: test_svld1_s64
+  // CHECK:  @llvm.masked.load.nxv2i64.p0nxv2i64(* %{{.*}}, i32 1,  %{{.*}},  zeroinitializer)
+  return svld1(pg, base);
+}
+
+svuint8_t test_svld1_u8(svbool_t pg, const uint8_t *base)
+{
+  // CHECK-LABEL: test_svld1_u8
+  // CHECK:  @llvm.masked.load.nxv16i8.p0nxv16i8(* %{{.*}}, i32 1,  %{{.*}},  zeroinitiali

[PATCH] D75927: [clangd] Use a separate RunningTask flag instead of leaving a broken request on top of the queue

2020-03-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
javed.absar, ilya-biryukov.
Herald added a project: clang.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:279
   std::deque Requests; /* GUARDED_BY(Mutex) */
+  bool RunningTask = false; /* GUARDED_BY(Mutex) */
   mutable std::condition_variable RequestsCV;

I'd consider making this an `llvm::Optional` and using it as storage 
too. Even though it won't be accessed directly outside the main loop, I think 
it makes it easier to reason about the code: it emphasizes the parallel with 
`Requests` and minimizes the spooky-flags-at-a-distance effect.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:612
   // If there were no writes in the queue, the preamble is ready now.
   if (LastUpdate == Requests.rend()) {
 Lock.unlock();

what if the currently-running task is a write?



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:721
 {
   std::unique_lock Lock(Mutex);
   for (auto Wait = scheduleLocked(); !Wait.expired();

maybe assert there's no running task here?



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:376
   Notification Start;
-  updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector) {
-++Builds;
-Start.wait();
-  });
+  updateWithDiags(S, Path, "b", WantDiagnostics::Auto,
+  [&](std::vector) { ++Builds; });

does this deliberately match "b" below? if not, change back to something unique?
If so, probably needs a comment.



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:379
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+  S.runWithAST(
+  "invalidatable-but-running", Path,

This looks racy to me. What guarantees that the worker thread pulls this item 
off the queue and into the "running" slot before the second updateWithDiags?


This helps us prevent races when scheduler (or any other thread) tries
to read a request while it's still running.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D75927

Files:
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp


Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -373,10 +373,17 @@
   std::atomic Builds(0), Actions(0);
 
   Notification Start;
-  updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector) {
-++Builds;
-Start.wait();
-  });
+  updateWithDiags(S, Path, "b", WantDiagnostics::Auto,
+  [&](std::vector) { ++Builds; });
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+  S.runWithAST(
+  "invalidatable-but-running", Path,
+  [&](llvm::Expected AST) {
+Start.wait();
+++Actions;
+EXPECT_TRUE(bool(AST)) << "Shouldn't be invalidated, because running.";
+  },
+  TUScheduler::InvalidateOnUpdate);
   S.runWithAST(
   "invalidatable", Path,
   [&](llvm::Expected AST) {
@@ -421,7 +428,7 @@
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 
   EXPECT_EQ(2, Builds.load()) << "Middle build should be skipped";
-  EXPECT_EQ(4, Actions.load()) << "All actions should run (some with error)";
+  EXPECT_EQ(5, Actions.load()) << "All actions should run (some with error)";
 }
 
 TEST_F(TUSchedulerTests, ManyUpdates) {
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -276,6 +276,7 @@
   /// Set to true to signal run() to finish processing.
   bool Done;/* GUARDED_BY(Mutex) */
   std::deque Requests; /* GUARDED_BY(Mutex) */
+  bool RunningTask = false; /* GUARDED_BY(Mutex) */
   mutable std::condition_variable RequestsCV;
   /// Guards the callback that publishes results of AST-related computations
   /// (diagnostics, highlightings) and file statuses.
@@ -370,7 +371,8 @@
 #ifndef NDEBUG
   std::lock_guard Lock(Mutex);
   assert(Done && "handle was not destroyed");
-  assert(Requests.empty() && "unprocessed requests when destroying ASTWorker");
+  assert(Requests.empty() && !RunningTask &&
+ "unprocessed requests when destroying ASTWorker");
 #endif
 }
 
@@ -745,7 +747,8 @@
 wait(Lock, RequestsCV, Wait);
   }
   Req = std::move(Requests.front());
-  // Leave it on the queue for now, so waiters don't see an empty queue.
+  Requests.pop_front();
+  RunningTask = true;
 } // unlock Mutex
 
 {
@@ -763,7 +766,7 @@
 bool IsEmpty = f

[PATCH] D75927: [clangd] Use a separate RunningTask flag instead of leaving a broken request on top of the queue

2020-03-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:279
   std::deque Requests; /* GUARDED_BY(Mutex) */
+  bool RunningTask = false; /* GUARDED_BY(Mutex) */
   mutable std::condition_variable RequestsCV;

I'd consider making this an `llvm::Optional` and using it as storage 
too. Even though it won't be accessed directly outside the main loop, I think 
it makes it easier to reason about the code: it emphasizes the parallel with 
`Requests` and minimizes the spooky-flags-at-a-distance effect.



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:612
   // If there were no writes in the queue, the preamble is ready now.
   if (LastUpdate == Requests.rend()) {
 Lock.unlock();

what if the currently-running task is a write?



Comment at: clang-tools-extra/clangd/TUScheduler.cpp:721
 {
   std::unique_lock Lock(Mutex);
   for (auto Wait = scheduleLocked(); !Wait.expired();

maybe assert there's no running task here?



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:376
   Notification Start;
-  updateWithDiags(S, Path, "a", WantDiagnostics::Yes, [&](std::vector) {
-++Builds;
-Start.wait();
-  });
+  updateWithDiags(S, Path, "b", WantDiagnostics::Auto,
+  [&](std::vector) { ++Builds; });

does this deliberately match "b" below? if not, change back to something unique?
If so, probably needs a comment.



Comment at: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp:379
+  ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+  S.runWithAST(
+  "invalidatable-but-running", Path,

This looks racy to me. What guarantees that the worker thread pulls this item 
off the queue and into the "running" slot before the second updateWithDiags?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75927



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


[PATCH] D75842: [Analyzer] Bugfix for CheckerRegistry

2020-03-10 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/unittests/StaticAnalyzer/RegisterCustomCheckersTest.cpp:143
+  std::string Diags;
+  EXPECT_TRUE(runCheckerOnCode("void f() {;}", Diags));
+}

baloghadamsoftware wrote:
> Szelethus wrote:
> > I don't think this is checking what you're looking for -- the test should 
> > be whether `Diag` is an empty string, while `runCheckerOnCode` returns true 
> > when the tool (the static analyzer, in this case) terminates successfully, 
> > even if it doesn't work the way we expect it to.
> There could be hundreds of alternative approaches, but this test exactly 
> simulates the real-world problem: the checker crashes because it should not 
> be registered. Of course, I tried the test without the bugfix and it fails as 
> it should because the tool terminates unsuccessfully if the prerequisite 
> checker is registered.
This is still confusing. Please check the string, that should contain what you 
need and nothing else, and the asserts could be removed as a result -- it 
shouldn't be more then 5 lines.


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

https://reviews.llvm.org/D75842



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


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Sanjay Patel via Phabricator via cfe-commits
spatel accepted this revision.
spatel added a comment.

LGTM - see inline for 1 more comment nit.




Comment at: llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp:2132
 
   // Subtraction from -0.0 is the canonical form of fneg.
+  // fsub -0.0, X ==> fneg X

This comment is stale. Remove or update to something like:
  // Convert fsub from zero to the canonical fneg instruction.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467



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


[PATCH] D75467: [instcombine] remove fsub to fneg hacks; only emit fneg

2020-03-10 Thread Simon Moll via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd871ef4e6ade: [instcombine] remove fsub to fneg hacks; only 
emit fneg (authored by simoll).

Changed prior to commit:
  https://reviews.llvm.org/D75467?vs=249396&id=249409#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75467

Files:
  clang/test/CodeGen/fma-builtins-constrained.c
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Transforms/InstCombine/InstCombineAddSub.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/test/Transforms/InstCombine/X86/x86-avx512.ll
  llvm/test/Transforms/InstCombine/cos-1.ll
  llvm/test/Transforms/InstCombine/fadd.ll
  llvm/test/Transforms/InstCombine/fast-math.ll
  llvm/test/Transforms/InstCombine/fdiv.ll
  llvm/test/Transforms/InstCombine/fmul.ll
  llvm/test/Transforms/InstCombine/fneg.ll
  llvm/test/Transforms/InstCombine/fpextend.ll
  llvm/test/Transforms/InstCombine/fsub.ll
  llvm/test/Transforms/InstCombine/maximum.ll
  llvm/test/Transforms/InstCombine/maxnum.ll
  llvm/test/Transforms/InstCombine/minimum.ll
  llvm/test/Transforms/InstCombine/minnum.ll
  llvm/test/Transforms/InstCombine/operand-complexity.ll
  llvm/test/Transforms/InstCombine/vec_shuffle.ll

Index: llvm/test/Transforms/InstCombine/vec_shuffle.ll
===
--- llvm/test/Transforms/InstCombine/vec_shuffle.ll
+++ llvm/test/Transforms/InstCombine/vec_shuffle.ll
@@ -1263,7 +1263,7 @@
 
 define <2 x float> @fneg(<2 x float> %x) {
 ; CHECK-LABEL: @fneg(
-; CHECK-NEXT:[[TMP1:%.*]] = fsub <2 x float> , [[X:%.*]]
+; CHECK-NEXT:[[TMP1:%.*]] = fneg <2 x float> [[X:%.*]]
 ; CHECK-NEXT:[[R:%.*]] = shufflevector <2 x float> [[TMP1]], <2 x float> undef, <2 x i32> zeroinitializer
 ; CHECK-NEXT:ret <2 x float> [[R]]
 ;
Index: llvm/test/Transforms/InstCombine/operand-complexity.ll
===
--- llvm/test/Transforms/InstCombine/operand-complexity.ll
+++ llvm/test/Transforms/InstCombine/operand-complexity.ll
@@ -92,7 +92,7 @@
 define float @fneg(float %x) {
 ; CHECK-LABEL: @fneg(
 ; CHECK-NEXT:[[BO:%.*]] = fdiv float [[X:%.*]], 4.20e+01
-; CHECK-NEXT:[[FNEGX:%.*]] = fsub float -0.00e+00, [[X]]
+; CHECK-NEXT:[[FNEGX:%.*]] = fneg float [[X]]
 ; CHECK-NEXT:[[R:%.*]] = fmul float [[BO]], [[FNEGX]]
 ; CHECK-NEXT:call void @use(float [[FNEGX]])
 ; CHECK-NEXT:ret float [[R]]
@@ -122,7 +122,7 @@
 define <2 x float> @fneg_vec(<2 x float> %x) {
 ; CHECK-LABEL: @fneg_vec(
 ; CHECK-NEXT:[[BO:%.*]] = fdiv <2 x float> [[X:%.*]], 
-; CHECK-NEXT:[[FNEGX:%.*]] = fsub <2 x float> , [[X]]
+; CHECK-NEXT:[[FNEGX:%.*]] = fneg <2 x float> [[X]]
 ; CHECK-NEXT:[[R:%.*]] = fmul <2 x float> [[BO]], [[FNEGX]]
 ; CHECK-NEXT:call void @use_vec(<2 x float> [[FNEGX]])
 ; CHECK-NEXT:ret <2 x float> [[R]]
@@ -137,7 +137,7 @@
 define <2 x float> @fneg_vec_undef(<2 x float> %x) {
 ; CHECK-LABEL: @fneg_vec_undef(
 ; CHECK-NEXT:[[BO:%.*]] = fdiv <2 x float> [[X:%.*]], 
-; CHECK-NEXT:[[FNEGX:%.*]] = fsub <2 x float> , [[X]]
+; CHECK-NEXT:[[FNEGX:%.*]] = fneg <2 x float> [[X]]
 ; CHECK-NEXT:[[R:%.*]] = fmul <2 x float> [[BO]], [[FNEGX]]
 ; CHECK-NEXT:call void @use_vec(<2 x float> [[FNEGX]])
 ; CHECK-NEXT:ret <2 x float> [[R]]
Index: llvm/test/Transforms/InstCombine/minnum.ll
===
--- llvm/test/Transforms/InstCombine/minnum.ll
+++ llvm/test/Transforms/InstCombine/minnum.ll
@@ -301,7 +301,7 @@
 declare void @use(double)
 define double @neg_neg_extra_use_x(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg_extra_use_x(
-; CHECK-NEXT:[[NEGX:%.*]] = fsub double -0.00e+00, [[X:%.*]]
+; CHECK-NEXT:[[NEGX:%.*]] = fneg double [[X:%.*]]
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X]], double [[Y:%.*]])
 ; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:call void @use(double [[NEGX]])
@@ -331,7 +331,7 @@
 
 define double @neg_neg_extra_use_y(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg_extra_use_y(
-; CHECK-NEXT:[[NEGY:%.*]] = fsub double -0.00e+00, [[Y:%.*]]
+; CHECK-NEXT:[[NEGY:%.*]] = fneg double [[Y:%.*]]
 ; CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.maxnum.f64(double [[X:%.*]], double [[Y]])
 ; CHECK-NEXT:[[R:%.*]] = fneg double [[TMP1]]
 ; CHECK-NEXT:call void @use(double [[NEGY]])
@@ -361,8 +361,8 @@
 
 define double @neg_neg_extra_use_x_and_y(double %x, double %y) {
 ; CHECK-LABEL: @neg_neg_extra_use_x_and_y(
-; CHECK-NEXT:[[NEGX:%.*]] = fsub double -0.00e+00, [[X:%.*]]
-; CHECK-NEXT:[[NEGY:%.*]] = fsub double -0.00e+00, [[Y:%.*]]
+; CHECK-NEXT:[[NEGX:%.*]] = fneg double [[X:%.*]]
+; CH

[clang] 71ffac2 - [OPENMP]Fix PR45132: OpenMP doacross loop nest with a decreasing

2020-03-10 Thread Alexey Bataev via cfe-commits

Author: Alexey Bataev
Date: 2020-03-10T12:13:58-04:00
New Revision: 71ffac21f7463465c369ba12dc496f9f5338e6b4

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

LOG: [OPENMP]Fix PR45132: OpenMP doacross loop nest with a decreasing
induction variable abends.

Used incorrect loop bound when trying to calculate the index in the vec
array for doacross construct in the loops with the reverse order.

Added: 


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

Removed: 




diff  --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index c0fb56c47371..7a62b2971eb1 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -6884,7 +6884,7 @@ Expr *OpenMPIterationSpaceChecker::buildOrderedLoopData(
 // Upper - Lower
 Expr *Upper = TestIsLessOp.getValue()
   ? Cnt
-  : tryBuildCapture(SemaRef, UB, Captures).get();
+  : tryBuildCapture(SemaRef, LB, Captures).get();
 Expr *Lower = TestIsLessOp.getValue()
   ? tryBuildCapture(SemaRef, LB, Captures).get()
   : Cnt;

diff  --git a/clang/test/OpenMP/ordered_doacross_codegen.cpp 
b/clang/test/OpenMP/ordered_doacross_codegen.cpp
index 2b610a270dd9..836f938fbce6 100644
--- a/clang/test/OpenMP/ordered_doacross_codegen.cpp
+++ b/clang/test/OpenMP/ordered_doacross_codegen.cpp
@@ -84,6 +84,64 @@ int main() {
   return 0;
 }
 
+// CHECK-LABEL: main1
+int main1() {
+// CHECK: [[DIMS:%.+]] = alloca [1 x [[KMP_DIM]]],
+// CHECK: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num([[IDENT:%.+]])
+// CHECK: icmp
+// CHECK-NEXT: br i1 %
+// CHECK: [[CAST:%.+]] = bitcast [1 x [[KMP_DIM]]]* [[DIMS]] to i8*
+// CHECK: call void @llvm.memset.p0i8.i64(i8* align 8 [[CAST]], i8 0, i64 24, 
i1 false)
+// CHECK: [[DIM:%.+]] = getelementptr inbounds [1 x [[KMP_DIM]]], [1 x 
[[KMP_DIM]]]* [[DIMS]], i64 0, i64 0
+// CHECK: getelementptr inbounds [[KMP_DIM]], [[KMP_DIM]]* [[DIM]], i32 0, i32 
1
+// CHECK: store i64 %{{.+}}, i64* %
+// CHECK: getelementptr inbounds [[KMP_DIM]], [[KMP_DIM]]* [[DIM]], i32 0, i32 
2
+// CHECK: store i64 1, i64* %
+// CHECK: [[DIM:%.+]] = getelementptr inbounds [1 x [[KMP_DIM]]], [1 x 
[[KMP_DIM]]]* [[DIMS]], i64 0, i64 0
+// CHECK: [[CAST:%.+]] = bitcast [[KMP_DIM]]* [[DIM]] to i8*
+// CHECK: call void @__kmpc_doacross_init([[IDENT]], i32 [[GTID]], i32 1, i8* 
[[CAST]])
+// CHECK: call void @__kmpc_for_static_init_4(%struct.ident_t* @{{.+}}, i32 
[[GTID]], i32 33, i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32* %{{.+}}, i32 
1, i32 1)
+#pragma omp for ordered(1)
+  for (int i = n; i > 0; --i) {
+a[i] = b[i] + 1;
+foo();
+// CHECK: invoke void [[FOO:.+]](
+// CHECK: [[UB_VAL:%.+]] = load i32, i32* [[UB:%.+]],
+// CHECK-NEXT: [[I_VAL:%.+]] = load i32, i32* [[I:%.+]],
+// CHECK-NEXT: sub nsw i32 [[UB_VAL]], [[I_VAL]]
+// CHECK-NEXT: sdiv i32 %{{.+}}, 1
+// CHECK-NEXT: sext i32 %{{.+}} to i64
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], [1 x i64]* 
[[CNT:%.+]], i64 0, i64 0
+// CHECK-NEXT: store i64 %{{.+}}, i64* [[TMP]],
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], [1 x i64]* 
[[CNT]], i64 0, i64 0
+// CHECK-NEXT: call void @__kmpc_doacross_post([[IDENT]], i32 [[GTID]], i64* 
[[TMP]])
+#pragma omp ordered depend(source)
+c[i] = c[i] + 1;
+foo();
+// CHECK: invoke void [[FOO]]
+// CHECK: [[UB_VAL:%.+]] = load i32, i32* [[UB]],
+// CHECK-NEXT: [[I_VAL:%.+]] = load i32, i32* [[I]],
+// CHECK-NEXT: [[SUB:%.+]] = sub nsw i32 [[I_VAL]], 2
+// CHECK-NEXT: sub nsw i32 [[UB_VAL]], [[SUB]]
+// CHECK-NEXT: sdiv i32 %{{.+}}, 1
+// CHECK-NEXT: sext i32 %{{.+}} to i64
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], [1 x i64]* 
[[CNT:%.+]], i64 0, i64 0
+// CHECK-NEXT: store i64 %{{.+}}, i64* [[TMP]],
+// CHECK-NEXT: [[TMP:%.+]] = getelementptr inbounds [1 x i64], [1 x i64]* 
[[CNT]], i64 0, i64 0
+// CHECK-NEXT: call void @__kmpc_doacross_wait([[IDENT]], i32 [[GTID]], i64* 
[[TMP]])
+#pragma omp ordered depend(sink : i - 2)
+d[i] = a[i - 2];
+  }
+  // CHECK: landingpad
+  // CHECK: call void @__kmpc_doacross_fini([[IDENT]], i32 [[GTID]])
+  // CHECK: br label %
+
+  // CHECK: call void @__kmpc_for_static_fini(
+  // CHECK: call void @__kmpc_doacross_fini([[IDENT]], i32 [[GTID]])
+  // CHECK: ret i32 0
+  return 0;
+}
+
 // CHECK: define {{.+}}TestStruct
 template 
 struct TestStruct {



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


[PATCH] D75917: Expose llvm fence instruction as clang intrinsic

2020-03-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:1880
+// Check if Order is an unsigned
+if (!Ty->isIntegerType()) {
+  Diag(ArgExpr->getExprLoc(), diag::err_typecheck_expect_uint) << Ty;

JonChesterfield wrote:
> isIntegerType will return true for signed integers as well as unsigned. It 
> seems reasonable to call this with a signed integer type (e.g. '2'), so 
> perhaps the references to unsigned should be dropped from the code and error 
> message
> 
I think we should accept implicit type conversion rules from the language...


Repository:
  rC Clang

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

https://reviews.llvm.org/D75917



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


[PATCH] D75861: [SVE] Generate overloaded functions for ACLE intrinsics.

2020-03-10 Thread Mikhail Maltsev via Phabricator via cfe-commits
miyuki added a comment.

The clang attribute part LGTM, but I want someone else to check the rest.


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

https://reviews.llvm.org/D75861



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


[PATCH] D75563: [clang][Parse] properly parse asm-qualifiers, asm inline

2020-03-10 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 249412.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

- small refactorings


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75563

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseStmtAsm.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/CodeGen/inline-asm-mixed-style.c
  clang/test/Parser/asm-qualifiers.c
  clang/test/Parser/asm.c
  clang/test/Sema/asm.c

Index: clang/test/Sema/asm.c
===
--- clang/test/Sema/asm.c
+++ clang/test/Sema/asm.c
@@ -91,9 +91,6 @@
   return a;
 }
 
-// 
-asm volatile (""); // expected-warning {{meaningless 'volatile' on asm outside function}}
-
 // PR3904
 void test8(int i) {
   // A number in an input constraint can't point to a read-write constraint.
Index: clang/test/Parser/asm.c
===
--- clang/test/Parser/asm.c
+++ clang/test/Parser/asm.c
@@ -12,12 +12,6 @@
 void f2() {
   asm("foo" : "=r" (a)); // expected-error {{use of undeclared identifier 'a'}}
   asm("foo" : : "r" (b)); // expected-error {{use of undeclared identifier 'b'}} 
-
-  asm const (""); // expected-warning {{ignored const qualifier on asm}}
-  asm volatile ("");
-  asm restrict (""); // expected-warning {{ignored restrict qualifier on asm}}
-  // FIXME: Once GCC supports _Atomic, check whether it allows this.
-  asm _Atomic (""); // expected-warning {{ignored _Atomic qualifier on asm}}
 }
 
 void a() __asm__(""); // expected-error {{cannot use an empty string literal in 'asm'}}
Index: clang/test/Parser/asm-qualifiers.c
===
--- /dev/null
+++ clang/test/Parser/asm-qualifiers.c
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+
+void qualifiers(void) {
+  asm("");
+  asm volatile("");
+  asm inline("");
+  asm goto("" foo);
+foo:;
+}
+
+void unknown_qualifiers(void) {
+  asm noodle(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm goto noodle("" foo); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+  asm volatile noodle inline(""); // expected-error {{expected 'volatile', 'inline', 'goto', or '('}}
+foo:;
+}
+
+void underscores(void) {
+  __asm__("");
+  __asm__ __volatile__("");
+  __asm__ __inline__("");
+  // Note: goto is not supported with underscore prefix+suffix.
+  __asm__ goto("" foo);
+foo:;
+}
+
+void permutations(void) {
+  asm goto inline volatile("" foo);
+  asm goto inline("");
+  asm goto volatile inline("" foo);
+  asm goto volatile("");
+  asm inline goto volatile("" foo);
+  asm inline goto("" foo);
+  asm inline volatile goto("" foo);
+  asm inline volatile("");
+  asm volatile goto("" foo);
+  asm volatile inline goto("" foo);
+  asm volatile inline("");
+foo:;
+}
+
+void duplicates(void) {
+  asm volatile volatile(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  __asm__ __volatile__ __volatile__(""); // expected-error {{duplicate asm qualifier 'volatile'}}
+  asm inline inline(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  __asm__ __inline__ __inline__(""); // expected-error {{duplicate asm qualifier 'inline'}}
+  asm goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+  __asm__ goto goto("" foo); // expected-error {{duplicate asm qualifier 'goto'}}
+foo:;
+}
+
+// globals
+asm ("");
+// 
+asm volatile (""); // expected-error {{meaningless 'volatile' on asm outside function}}
+asm inline (""); // expected-error {{meaningless 'inline' on asm outside function}}
+asm goto (""noodle); // expected-error {{meaningless 'goto' on asm outside function}}
+// expected-error@-1 {{expected ')'}}
+// expected-note@-2 {{to match this '('}}
Index: clang/test/CodeGen/inline-asm-mixed-style.c
===
--- clang/test/CodeGen/inline-asm-mixed-style.c
+++ clang/test/CodeGen/inline-asm-mixed-style.c
@@ -14,11 +14,6 @@
   // CHECK: movl%ebx, %eax
   // CHECK: movl%ecx, %edx
 
-  __asm mov eax, ebx
-  __asm const ("movl %ecx, %edx"); // expected-warning {{ignored const qualifier on asm}} 
-  // CHECK: movl%ebx, %eax
-  // CHECK: movl%ecx, %edx
-
   __asm volatile goto ("movl %ecx, %edx");
   // CHECK: movl%ecx, %edx
 
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -1528,13 +1528,13 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm!");
   SourceLocation Loc = ConsumeToken();
 
-  if (Tok.is

[PATCH] D75827: Add new `attribute push` matcher `function(is_definition)`

2020-03-10 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert abandoned this revision.
jdoerfert added a comment.

Not needed anymore. Anyone should feel free to pick this up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75827



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


  1   2   3   >