[PATCH] D77194: [clang] Persist Attr::IsPackExpansion into the serialized AST

2020-04-02 Thread Nathan Ridge via Phabricator via cfe-commits
nridge updated this revision to Diff 254712.
nridge added a comment.

Add test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77194

Files:
  clang/test/PCH/cxx-attrs-packexpansion.cpp
  clang/utils/TableGen/ClangAttrEmitter.cpp


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2911,6 +2911,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "bool isInherited = Record.readInt();\n";
 OS << "bool isImplicit = Record.readInt();\n";
+OS << "bool isPackExpansion = Record.readInt();\n";
 ArgRecords = R.getValueAsListOfDefs("Args");
 Args.clear();
 for (const auto *Arg : ArgRecords) {
@@ -2926,6 +2927,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "cast(New)->setInherited(isInherited);\n";
 OS << "New->setImplicit(isImplicit);\n";
+OS << "New->setPackExpansion(isPackExpansion);\n";
 OS << "break;\n";
 OS << "  }\n";
   }
@@ -2952,6 +2954,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
 OS << "Record.push_back(A->isImplicit());\n";
+OS << "Record.push_back(A->isPackExpansion());\n";
 
 for (const auto *Arg : Args)
   createArgument(*Arg, R.getName())->writePCHWrite(OS);
Index: clang/test/PCH/cxx-attrs-packexpansion.cpp
===
--- /dev/null
+++ clang/test/PCH/cxx-attrs-packexpansion.cpp
@@ -0,0 +1,25 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s
+
+#ifndef HEADER
+#define HEADER
+
+template
+struct static_variant {
+alignas(Types...) T storage[10];
+};
+
+#else
+
+struct A {
+static_variant a;
+};
+struct B {
+static_variant _b;
+};
+
+#endif


Index: clang/utils/TableGen/ClangAttrEmitter.cpp
===
--- clang/utils/TableGen/ClangAttrEmitter.cpp
+++ clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -2911,6 +2911,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "bool isInherited = Record.readInt();\n";
 OS << "bool isImplicit = Record.readInt();\n";
+OS << "bool isPackExpansion = Record.readInt();\n";
 ArgRecords = R.getValueAsListOfDefs("Args");
 Args.clear();
 for (const auto *Arg : ArgRecords) {
@@ -2926,6 +2927,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "cast(New)->setInherited(isInherited);\n";
 OS << "New->setImplicit(isImplicit);\n";
+OS << "New->setPackExpansion(isPackExpansion);\n";
 OS << "break;\n";
 OS << "  }\n";
   }
@@ -2952,6 +2954,7 @@
 if (R.isSubClassOf(InhClass))
   OS << "Record.push_back(SA->isInherited());\n";
 OS << "Record.push_back(A->isImplicit());\n";
+OS << "Record.push_back(A->isPackExpansion());\n";
 
 for (const auto *Arg : Args)
   createArgument(*Arg, R.getName())->writePCHWrite(OS);
Index: clang/test/PCH/cxx-attrs-packexpansion.cpp
===
--- /dev/null
+++ clang/test/PCH/cxx-attrs-packexpansion.cpp
@@ -0,0 +1,25 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %s -emit-llvm -o - %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -o - %s
+
+#ifndef HEADER
+#define HEADER
+
+template
+struct static_variant {
+alignas(Types...) T storage[10];
+};
+
+#else
+
+struct A {
+static_variant a;
+};
+struct B {
+static_variant _b;
+};
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77205: [X86] Add TSXLDTRK instructions.

2020-04-02 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing updated this revision to Diff 254693.
tianqing added a comment.

Updated to resolve conflicts with https://reviews.llvm.org/D77193.


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

https://reviews.llvm.org/D77205

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/tsxldtrkintrin.h
  clang/test/CodeGen/x86-tsxldtrk-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
  llvm/test/MC/Disassembler/X86/x86-16.txt
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-16.s
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -1881,3 +1881,11 @@
 // CHECK: serialize
 // CHECK: encoding: [0x0f,0x01,0xe8]
 serialize
+
+// CHECK: xsusldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: xresldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10880,3 +10880,11 @@
 // CHECK: serialize
 // CHECK: encoding: [0x0f,0x01,0xe8]
 serialize
+
+// CHECK: xsusldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: xresldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/X86/x86-16.s
===
--- llvm/test/MC/X86/x86-16.s
+++ llvm/test/MC/X86/x86-16.s
@@ -1033,3 +1033,11 @@
 // CHECK: serialize
 // CHECK: encoding: [0x0f,0x01,0xe8]
 serialize
+
+// CHECK: xsusldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: xresldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -694,3 +694,9 @@
 
 # CHECK: serialize
 0x0f 0x01 0xe8
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -946,3 +946,9 @@
 
 # CHECK: serialize
 0x0f 0x01 0xe8
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/MC/Disassembler/X86/x86-16.txt
===
--- llvm/test/MC/Disassembler/X86/x86-16.txt
+++ llvm/test/MC/Disassembler/X86/x86-16.txt
@@ -839,3 +839,9 @@
 
 # CHECK: serialize
 0x0f 0x01 0xe8
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
@@ -0,0 +1,31 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+tsxldtrk | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+tsxldtrk | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+tsxldtrk | FileCheck %s --check-prefix=X32
+
+define void @test_tsxldtrk() {
+; X64-LABEL: test_tsxldtrk:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:xsusldtrk
+; X64-NEXT:xresldtrk
+; X64-NEXT:retq
+;
+; X86-LABEL: test_tsxldtrk:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:xsusldtrk
+; X86-NEXT:xresldtrk
+; X86-NEXT:retl
+;
+; X32-LABEL: test_tsxldtrk:
+; X32:   # %bb.0: # %entry
+; X32-NEXT:xsusldtrk
+; X32-NEXT:xresldtrk
+; X32-NEXT:retq
+entry:
+   call void @llvm.x86.xsusldtrk()
+   call void @llvm.x86.xresldtrk()
+   ret void
+}
+
+declare void @llvm.x86.xsusldtrk()
+declare void @llvm.x86.xresldtrk()
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -400,6 +400,9 @@
   /// Processor supports SERIALIZE instruction
   bool HasSERIALIZE = false;
 
+  /// Processor supports TSXLDTRK instruction
+  bool HasTSXLDTRK = 

[PATCH] D77205: [X86] Add TSXLDTRK instructions.

2020-04-02 Thread Wang Tianqing via Phabricator via cfe-commits
tianqing updated this revision to Diff 254694.
tianqing added a comment.

Removed extra "//".


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

https://reviews.llvm.org/D77205

Files:
  clang/docs/ClangCommandLineReference.rst
  clang/include/clang/Basic/BuiltinsX86.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/cpuid.h
  clang/lib/Headers/immintrin.h
  clang/lib/Headers/tsxldtrkintrin.h
  clang/test/CodeGen/x86-tsxldtrk-builtins.c
  clang/test/Driver/x86-target-features.c
  clang/test/Preprocessor/x86_target_features.c
  llvm/include/llvm/IR/IntrinsicsX86.td
  llvm/lib/Support/Host.cpp
  llvm/lib/Target/X86/X86.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/lib/Target/X86/X86Subtarget.h
  llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
  llvm/test/MC/Disassembler/X86/x86-16.txt
  llvm/test/MC/Disassembler/X86/x86-32.txt
  llvm/test/MC/Disassembler/X86/x86-64.txt
  llvm/test/MC/X86/x86-16.s
  llvm/test/MC/X86/x86-32-coverage.s
  llvm/test/MC/X86/x86-64.s

Index: llvm/test/MC/X86/x86-64.s
===
--- llvm/test/MC/X86/x86-64.s
+++ llvm/test/MC/X86/x86-64.s
@@ -1881,3 +1881,11 @@
 // CHECK: serialize
 // CHECK: encoding: [0x0f,0x01,0xe8]
 serialize
+
+// CHECK: xsusldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: xresldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/X86/x86-32-coverage.s
===
--- llvm/test/MC/X86/x86-32-coverage.s
+++ llvm/test/MC/X86/x86-32-coverage.s
@@ -10880,3 +10880,11 @@
 // CHECK: serialize
 // CHECK: encoding: [0x0f,0x01,0xe8]
 serialize
+
+// CHECK: xsusldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: xresldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/X86/x86-16.s
===
--- llvm/test/MC/X86/x86-16.s
+++ llvm/test/MC/X86/x86-16.s
@@ -1033,3 +1033,11 @@
 // CHECK: serialize
 // CHECK: encoding: [0x0f,0x01,0xe8]
 serialize
+
+// CHECK: xsusldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe8]
+xsusldtrk
+
+// CHECK: xresldtrk
+// CHECK: encoding: [0xf2,0x0f,0x01,0xe9]
+xresldtrk
Index: llvm/test/MC/Disassembler/X86/x86-64.txt
===
--- llvm/test/MC/Disassembler/X86/x86-64.txt
+++ llvm/test/MC/Disassembler/X86/x86-64.txt
@@ -694,3 +694,9 @@
 
 # CHECK: serialize
 0x0f 0x01 0xe8
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/MC/Disassembler/X86/x86-32.txt
===
--- llvm/test/MC/Disassembler/X86/x86-32.txt
+++ llvm/test/MC/Disassembler/X86/x86-32.txt
@@ -946,3 +946,9 @@
 
 # CHECK: serialize
 0x0f 0x01 0xe8
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/MC/Disassembler/X86/x86-16.txt
===
--- llvm/test/MC/Disassembler/X86/x86-16.txt
+++ llvm/test/MC/Disassembler/X86/x86-16.txt
@@ -839,3 +839,9 @@
 
 # CHECK: serialize
 0x0f 0x01 0xe8
+
+# CHECK: xsusldtrk
+0xf2 0x0f 0x01 0xe8
+
+# CHECK: xresldtrk
+0xf2 0x0f 0x01 0xe9
Index: llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/tsxldtrk-intrinsic.ll
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+tsxldtrk | FileCheck %s --check-prefix=X64
+; RUN: llc < %s -mtriple=i386-unknown-unknown -mattr=+tsxldtrk | FileCheck %s --check-prefix=X86
+; RUN: llc < %s -mtriple=x86_64-linux-gnux32 -mattr=+tsxldtrk | FileCheck %s --check-prefix=X32
+
+define void @test_tsxldtrk() {
+; X64-LABEL: test_tsxldtrk:
+; X64:   # %bb.0: # %entry
+; X64-NEXT:xsusldtrk
+; X64-NEXT:xresldtrk
+; X64-NEXT:retq
+;
+; X86-LABEL: test_tsxldtrk:
+; X86:   # %bb.0: # %entry
+; X86-NEXT:xsusldtrk
+; X86-NEXT:xresldtrk
+; X86-NEXT:retl
+;
+; X32-LABEL: test_tsxldtrk:
+; X32:   # %bb.0: # %entry
+; X32-NEXT:xsusldtrk
+; X32-NEXT:xresldtrk
+; X32-NEXT:retq
+entry:
+   call void @llvm.x86.xsusldtrk()
+   call void @llvm.x86.xresldtrk()
+   ret void
+}
+
+declare void @llvm.x86.xsusldtrk()
+declare void @llvm.x86.xresldtrk()
+
Index: llvm/lib/Target/X86/X86Subtarget.h
===
--- llvm/lib/Target/X86/X86Subtarget.h
+++ llvm/lib/Target/X86/X86Subtarget.h
@@ -400,6 +400,9 @@
   /// Processor supports SERIALIZE instruction
   bool HasSERIALIZE = false;
 
+  /// Processor supports TSXLDTRK instruction
+  bool HasTSXLDTRK = false;
+
   /// Processor has a single uop BEXTR 

[clang] be0a4fe - [X86] Add -flax-vector-conversions=none to more of the clang CodeGen tests

2020-04-02 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2020-04-02T20:39:18-07:00
New Revision: be0a4fef6e789a8f25316af988b2d312d83d0d1c

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

LOG: [X86] Add -flax-vector-conversions=none to more of the clang CodeGen tests

Thankfully no issues found.

Added: 


Modified: 
clang/test/CodeGen/avx512cdintrin.c
clang/test/CodeGen/avx512vbmivl-builtin.c
clang/test/CodeGen/avx512vl-builtins-constrained-cmp.c
clang/test/CodeGen/avx512vpopcntdqintrin.c
clang/test/CodeGen/avx512vpopcntdqvlintrin.c
clang/test/CodeGen/gfni-builtins.c
clang/test/CodeGen/intel-avx512vlvp2intersect.c
clang/test/CodeGen/intel-avx512vp2intersect.c
clang/test/CodeGen/vaes-builtins.c
clang/test/CodeGen/vpclmulqdq-builtins.c

Removed: 




diff  --git a/clang/test/CodeGen/avx512cdintrin.c 
b/clang/test/CodeGen/avx512cdintrin.c
index 6483d7e8dda5..b15126808b80 100644
--- a/clang/test/CodeGen/avx512cdintrin.c
+++ b/clang/test/CodeGen/avx512cdintrin.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512cd -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512cd -emit-llvm -o - -Wall 
-Werror | FileCheck %s
 
 
 #include 

diff  --git a/clang/test/CodeGen/avx512vbmivl-builtin.c 
b/clang/test/CodeGen/avx512vbmivl-builtin.c
index 0bf9165f6c6a..2562da26d6ce 100644
--- a/clang/test/CodeGen/avx512vbmivl-builtin.c
+++ b/clang/test/CodeGen/avx512vbmivl-builtin.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512vbmi -target-feature +avx512vl -target-feature +avx512bw 
-emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512vbmi -target-feature 
+avx512vl -target-feature +avx512bw -emit-llvm -o - -Wall -Werror | FileCheck %s
 
 
 #include 

diff  --git a/clang/test/CodeGen/avx512vl-builtins-constrained-cmp.c 
b/clang/test/CodeGen/avx512vl-builtins-constrained-cmp.c
index ae052dfffbab..6be4f614561a 100644
--- a/clang/test/CodeGen/avx512vl-builtins-constrained-cmp.c
+++ b/clang/test/CodeGen/avx512vl-builtins-constrained-cmp.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -fexperimental-new-pass-manager 
-triple=x86_64-apple-darwin -target-feature +avx512f -target-feature +avx512vl 
-emit-llvm -ffp-exception-behavior=strict -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-fexperimental-new-pass-manager -triple=x86_64-apple-darwin -target-feature 
+avx512f -target-feature +avx512vl -emit-llvm -ffp-exception-behavior=strict -o 
- -Wall -Werror | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/avx512vpopcntdqintrin.c 
b/clang/test/CodeGen/avx512vpopcntdqintrin.c
index e7c797c19549..22c44bc21edf 100644
--- a/clang/test/CodeGen/avx512vpopcntdqintrin.c
+++ b/clang/test/CodeGen/avx512vpopcntdqintrin.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512vpopcntdq -emit-llvm -o - -Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512vpopcntdq -emit-llvm -o - 
-Wall -Werror | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/avx512vpopcntdqvlintrin.c 
b/clang/test/CodeGen/avx512vpopcntdqvlintrin.c
index 010cb6b4f344..686bfb986ceb 100644
--- a/clang/test/CodeGen/avx512vpopcntdqvlintrin.c
+++ b/clang/test/CodeGen/avx512vpopcntdqvlintrin.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +avx512vpopcntdq -target-feature +avx512vl -emit-llvm -o - 
-Wall -Werror | FileCheck %s
+// RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s 
-triple=x86_64-apple-darwin -target-feature +avx512vpopcntdq -target-feature 
+avx512vl -emit-llvm -o - -Wall -Werror | FileCheck %s
 
 #include 
 

diff  --git a/clang/test/CodeGen/gfni-builtins.c 
b/clang/test/CodeGen/gfni-builtins.c
index 0d10d7aeacd6..61d957d59e76 100644
--- a/clang/test/CodeGen/gfni-builtins.c
+++ b/clang/test/CodeGen/gfni-builtins.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +gfni -emit-llvm -o - | FileCheck %s --check-prefix SSE
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +gfni -target-feature +avx -emit-llvm -o - | FileCheck %s 
--check-prefixes SSE,AVX
-// RUN: %clang_cc1 -ffreestanding %s -triple=x86_64-apple-darwin 
-target-feature +gfni -target-feature +avx512bw -target-feature +avx512vl 
-emit-llvm -o - | FileCheck %s 

[PATCH] D66490: [NewPM] Enable the New Pass Manager by Default in Clang

2020-04-02 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D66490#1638708 , @hfinkel wrote:

> In D66490#1638162 , @rupprecht wrote:
>
> > We already know that we don't want this enabled for tsan builds due to 
> > https://bugs.llvm.org/show_bug.cgi?id=42877, but I don't even know if 
> > anyone else will hit it (it's only when building one particular library).
>
>
> Under the circumstances, that seems like one particular library too many. 
> PR42877 looks like a generic bug, so if we're hitting it here, I see no 
> reason to suspect that others would not hit it elsewhere.


https://bugs.llvm.org/show_bug.cgi?id=42877 is marked fixed, any update on 
this? LLVM 10.0.0 has branched.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66490



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


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added inline comments.



Comment at: llvm/include/llvm/IR/CFGDiff.h:199
+namespace {
+template  struct reverse_if_helper;
+template <> struct reverse_if_helper {

You can use two helper functions taking `integral_constant` 
tags -- should be less verbose



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:89
 bool IsRecalculated = false;
+GraphDiffT *PreViewOfCFG;
+const size_t NumLegalized;

nit: Why pointer instead of keeping a reference?



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:177
   constexpr bool Direction = IsReverse != IsPostDom;  // XOR.
-  for (const NodePtr Succ :
-   ChildrenGetter::Get(BB, BatchUpdates)) {
+  typedef
+  typename std::conditional, NodePtr>::type

nit: use `using` instead of `typefef`.



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:178
+  typedef
+  typename std::conditional, NodePtr>::type
+  IsRevType;

nit: can we use `std::conditional_t<...>` in c++14 to get rid of `typename` and 
`::type`? Or does it make some buildbots unhappy?



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:179
+  typename std::conditional, NodePtr>::type
+  IsRevType;
+  using GraphDiffBBPair = std::pair;

nit: I don't find this name very informative. Maybe something like `DirectedBB`?



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:183
+  BatchUpdates ? BatchUpdates->PreViewOfCFG : EmptyGD.get();
+  std::pair GDNodePair =
+  std::make_pair(GDTmp, BB);

`std::pair GDNodePair(GDTmp, BB)`



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:185
+  std::make_pair(GDTmp, BB);
+  for (auto  : children(GDNodePair)) {
+const NodePtr Succ = Pair.second;

Won't children infer the template parameter based on the passes value? I don't 
get why the template argument type is a pair where the second argument is a 
directed nodeptr, but the runtime value is always a plain nodeptr. Couldn't the 
second pair type also be directed for `GDNodePair`?



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:186
+  for (auto  : children(GDNodePair)) {
+const NodePtr Succ = Pair.second;
 const auto SIT = NodeToInfo.find(Succ);

Could this new code be a hoisted into a helper function?



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:1146
   if (Update.getKind() == UpdateKind::Insert)
-DT.insertEdge(Update.getFrom(), Update.getTo());
+InsertEdge(DT, nullptr, Update.getFrom(), Update.getTo());
   else

Could you add a comment next to the nullptr with the argument name?



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:1543
+  // FIXME: Updated to use the PreViewCFG and behave the same as until now.
+  // This behavior is however incorrect; this actually needs the PostViewCFG.
+  GraphDiff PreViewCFG(

Does this care about the direction (pre- or post-) at all, or does it need some 
CFG view? Why is pre-view incorrect?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread Jakub Kuderski via Phabricator via cfe-commits
kuhar added inline comments.



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:186
+  for (auto  : children(GDNodePair)) {
+const NodePtr Succ = Pair.second;
 const auto SIT = NodeToInfo.find(Succ);

kuhar wrote:
> Could this new code be a hoisted into a helper function?
Or alternatively, could the old `ChildrenGetter` be implemented with these 5 
magic lines?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D70555: [coroutines] Don't build promise init with no args

2020-04-02 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG627e01feb718: [coroutines] Dont build promise init 
with no args (authored by modocache).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70555

Files:
  clang/lib/Sema/SemaCoroutine.cpp


Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -502,8 +502,9 @@
 return nullptr;
 
   auto *ScopeInfo = getCurFunction();
-  // Build a list of arguments, based on the coroutine functions arguments,
-  // that will be passed to the promise type's constructor.
+
+  // Build a list of arguments, based on the coroutine function's arguments,
+  // that if present will be passed to the promise type's constructor.
   llvm::SmallVector CtorArgExprs;
 
   // Add implicit object parameter.
@@ -519,6 +520,7 @@
 }
   }
 
+  // Add the coroutine function's parameters.
   auto  = ScopeInfo->CoroutineParameterMoves;
   for (auto *PD : FD->parameters()) {
 if (PD->getType()->isDependentType())
@@ -540,28 +542,33 @@
 CtorArgExprs.push_back(RefExpr.get());
   }
 
-  // Create an initialization sequence for the promise type using the
-  // constructor arguments, wrapped in a parenthesized list expression.
-  Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(),
-CtorArgExprs, FD->getLocation());
-  InitializedEntity Entity = InitializedEntity::InitializeVariable(VD);
-  InitializationKind Kind = InitializationKind::CreateForInit(
-  VD->getLocation(), /*DirectInit=*/true, PLE);
-  InitializationSequence InitSeq(*this, Entity, Kind, CtorArgExprs,
- /*TopLevelOfInitList=*/false,
- /*TreatUnavailableAsInvalid=*/false);
-
-  // Attempt to initialize the promise type with the arguments.
-  // If that fails, fall back to the promise type's default constructor.
-  if (InitSeq) {
-ExprResult Result = InitSeq.Perform(*this, Entity, Kind, CtorArgExprs);
-if (Result.isInvalid()) {
-  VD->setInvalidDecl();
-} else if (Result.get()) {
-  VD->setInit(MaybeCreateExprWithCleanups(Result.get()));
-  VD->setInitStyle(VarDecl::CallInit);
-  CheckCompleteVariableDeclaration(VD);
-}
+  // If we have a non-zero number of constructor arguments, try to use them.
+  // Otherwise, fall back to the promise type's default constructor.
+  if (!CtorArgExprs.empty()) {
+// Create an initialization sequence for the promise type using the
+// constructor arguments, wrapped in a parenthesized list expression.
+Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(),
+  CtorArgExprs, FD->getLocation());
+InitializedEntity Entity = InitializedEntity::InitializeVariable(VD);
+InitializationKind Kind = InitializationKind::CreateForInit(
+VD->getLocation(), /*DirectInit=*/true, PLE);
+InitializationSequence InitSeq(*this, Entity, Kind, CtorArgExprs,
+   /*TopLevelOfInitList=*/false,
+   /*TreatUnavailableAsInvalid=*/false);
+
+// Attempt to initialize the promise type with the arguments.
+// If that fails, fall back to the promise type's default constructor.
+if (InitSeq) {
+  ExprResult Result = InitSeq.Perform(*this, Entity, Kind, CtorArgExprs);
+  if (Result.isInvalid()) {
+VD->setInvalidDecl();
+  } else if (Result.get()) {
+VD->setInit(MaybeCreateExprWithCleanups(Result.get()));
+VD->setInitStyle(VarDecl::CallInit);
+CheckCompleteVariableDeclaration(VD);
+  }
+} else
+  ActOnUninitializedDecl(VD);
   } else
 ActOnUninitializedDecl(VD);
 


Index: clang/lib/Sema/SemaCoroutine.cpp
===
--- clang/lib/Sema/SemaCoroutine.cpp
+++ clang/lib/Sema/SemaCoroutine.cpp
@@ -502,8 +502,9 @@
 return nullptr;
 
   auto *ScopeInfo = getCurFunction();
-  // Build a list of arguments, based on the coroutine functions arguments,
-  // that will be passed to the promise type's constructor.
+
+  // Build a list of arguments, based on the coroutine function's arguments,
+  // that if present will be passed to the promise type's constructor.
   llvm::SmallVector CtorArgExprs;
 
   // Add implicit object parameter.
@@ -519,6 +520,7 @@
 }
   }
 
+  // Add the coroutine function's parameters.
   auto  = ScopeInfo->CoroutineParameterMoves;
   for (auto *PD : FD->parameters()) {
 if (PD->getType()->isDependentType())
@@ -540,28 +542,33 @@
 CtorArgExprs.push_back(RefExpr.get());
   }
 
-  // Create an initialization sequence for the promise type using the
-  // constructor arguments, wrapped in a parenthesized list expression.
-  Expr *PLE = 

[clang] 627e01f - [coroutines] Don't build promise init with no args

2020-04-02 Thread Brian Gesiak via cfe-commits

Author: Brian Gesiak
Date: 2020-04-02T21:44:54-04:00
New Revision: 627e01feb718dd1aa8e184545976b7229de312a2

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

LOG: [coroutines] Don't build promise init with no args

Summary:
In the case of a coroutine that takes no arguments,
`Sema::buildCoroutinePromise` constructs a list-initialization
(`clang::InitializationKind::InitKind::IK_DirectList`) of the
promise variable, using a list of empty arguments. So, if one were to
dump the promise `VarDecl` immediately after `Sema::ActOnCoroutineBodyStart`
calls `checkCoroutineContext`, for a coroutine function that takes no
arguments, they'd see the following:

```
VarDecl 0xb514490  col:3 __promise '' callinit
`-ParenListExpr 0xb514510  'NULL TYPE'
```

But after this patch, the `ParenListExpr` is no longer constructed, and
the promise variable uses default initialization
(`clang::InitializationKind::InitKind::IK_Default`):

```
VarDecl 0x63100012dae0  col:3 __promise ''
```

As far as I know, there's no case in which list-initialization with no
arguments differs from default initialization, but if I'm wrong please
let me know (and I'll add a test case that demonstrates the change --
but as-is I can't think of a functional test case for this). I think both
comply with the wording of C++20 `[dcl.fct.def.coroutine]p5`:

> _promise-constructor-arguments_ is determined as follows: overload
  resolution is performed on a promise constructor call created by
  assembling an argument list with lvalues `p1 ... pn`. If a viable
  constructor is found (12.4.2), then _promise-constructor-arguments_
  is `(p1, ... , pn)`, otherwise _promise-constructor-arguments_ is
  empty.

Still, I think this patch is an improvement regardless, because it
reduces the size of the AST.

Reviewers: GorNishanov, rsmith, lewissbaker

Subscribers: EricWF, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Sema/SemaCoroutine.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaCoroutine.cpp 
b/clang/lib/Sema/SemaCoroutine.cpp
index 6dc9e342beb9..5ed0bbd6041d 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -502,8 +502,9 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
 return nullptr;
 
   auto *ScopeInfo = getCurFunction();
-  // Build a list of arguments, based on the coroutine functions arguments,
-  // that will be passed to the promise type's constructor.
+
+  // Build a list of arguments, based on the coroutine function's arguments,
+  // that if present will be passed to the promise type's constructor.
   llvm::SmallVector CtorArgExprs;
 
   // Add implicit object parameter.
@@ -519,6 +520,7 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
 }
   }
 
+  // Add the coroutine function's parameters.
   auto  = ScopeInfo->CoroutineParameterMoves;
   for (auto *PD : FD->parameters()) {
 if (PD->getType()->isDependentType())
@@ -540,28 +542,33 @@ VarDecl *Sema::buildCoroutinePromise(SourceLocation Loc) {
 CtorArgExprs.push_back(RefExpr.get());
   }
 
-  // Create an initialization sequence for the promise type using the
-  // constructor arguments, wrapped in a parenthesized list expression.
-  Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(),
-CtorArgExprs, FD->getLocation());
-  InitializedEntity Entity = InitializedEntity::InitializeVariable(VD);
-  InitializationKind Kind = InitializationKind::CreateForInit(
-  VD->getLocation(), /*DirectInit=*/true, PLE);
-  InitializationSequence InitSeq(*this, Entity, Kind, CtorArgExprs,
- /*TopLevelOfInitList=*/false,
- /*TreatUnavailableAsInvalid=*/false);
-
-  // Attempt to initialize the promise type with the arguments.
-  // If that fails, fall back to the promise type's default constructor.
-  if (InitSeq) {
-ExprResult Result = InitSeq.Perform(*this, Entity, Kind, CtorArgExprs);
-if (Result.isInvalid()) {
-  VD->setInvalidDecl();
-} else if (Result.get()) {
-  VD->setInit(MaybeCreateExprWithCleanups(Result.get()));
-  VD->setInitStyle(VarDecl::CallInit);
-  CheckCompleteVariableDeclaration(VD);
-}
+  // If we have a non-zero number of constructor arguments, try to use them.
+  // Otherwise, fall back to the promise type's default constructor.
+  if (!CtorArgExprs.empty()) {
+// Create an initialization sequence for the promise type using the
+// constructor arguments, wrapped in a parenthesized list expression.
+Expr *PLE = ParenListExpr::Create(Context, FD->getLocation(),
+  CtorArgExprs, FD->getLocation());
+InitializedEntity Entity = 

[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254668.
yaxunl added a comment.

fix test


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

https://reviews.llvm.org/D77329

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl

Index: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -1,8 +1,35 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -o - -triple amdgcn %s | FileCheck %s
+
+typedef float float32 __attribute__((ext_vector_type(32)));
 
 kernel void test_long(int arg0) {
   long v15_16;
-  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"(i32 %arg0)
+  // CHECK: call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"
   __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0));
 }
+
+kernel void test_agpr() {
+  float32 acc_c;
+  float reg_a;
+  float reg_b;
+  float32 reg_c;
+  // CHECK:  call <32 x float> asm "v_mfma_f32_32x32x1f32 $0, $1, $2, $3", "=a,v,v,a,~{a0},~{a1},~{a2},~{a3},~{a4},~{a5},~{a6},~{a7},~{a8},~{a9},~{a10},~{a11},~{a12},~{a13},~{a14},~{a15},~{a16},~{a17},~{a18},~{a19},~{a20},~{a21},~{a22},~{a23},~{a24},~{a25},~{a26},~{a27},~{a28},~{a29},~{a30},~{a31}"
+  __asm ("v_mfma_f32_32x32x1f32 %0, %1, %2, %3"
+ : "=a"(acc_c)
+ : "v"(reg_a), "v"(reg_b), "a"(reg_c)
+ : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+   "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
+   "a16", "a17", "a18", "a19", "a20", "a21", "a22", "a23",
+   "a24", "a25", "a26", "a27", "a28", "a29", "a30", "a31");
+ 
+   // CHECK: call <32 x float> asm sideeffect "v_mfma_f32_32x32x1f32 a[0:31], $0, $1, a[0:31]", "={a[0:31]},v,v,{a[0:31]}"
+  __asm volatile("v_mfma_f32_32x32x1f32 a[0:31], %0, %1, a[0:31]"
+ : "={a[0:31]}"(acc_c)
+ : "v"(reg_a),"v"(reg_b), "{a[0:31]}"(reg_c));
+
+  // CHECK: call float asm "v_accvgpr_read_b32 $0, $1", "={a1},{a1}"
+  __asm ("v_accvgpr_read_b32 %0, %1"
+ : "={a1}"(reg_a)
+ : "{a1}"(reg_b));
+}
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -114,11 +114,14 @@
   /// Accepted register names: (n, m is unsigned integer, n < m)
   /// v
   /// s
+  /// a
   /// {vn}, {v[n]}
   /// {sn}, {s[n]}
+  /// {an}, {a[n]}
   /// {S} , where S is a special register name
   {v[n:m]}
   /// {s[n:m]}
+  /// {a[n:m]}
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
 static const ::llvm::StringSet<> SpecialRegs({
@@ -135,7 +138,7 @@
 }
 if (S.empty())
   return false;
-if (S.front() != 'v' && S.front() != 's') {
+if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') {
   if (!HasLeftParen)
 return false;
   auto E = S.find('}');
@@ -153,7 +156,7 @@
 if (!HasLeftParen) {
   if (!S.empty())
 return false;
-  // Found s or v.
+  // Found s, v or a.
   Info.setAllowsRegister();
   Name = S.data() - 1;
   return true;
@@ -184,7 +187,8 @@
 S = S.drop_front();
 if (!S.empty())
   return false;
-// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]}
+// or {a[n:m]}.
 Info.setAllowsRegister();
 Name = S.data() - 1;
 return true;
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -124,7 +124,36 @@
   "s113", "s114", "s115", "s116", "s117", "s118", "s119", "s120", "s121",
   "s122", "s123", "s124", "s125", "s126", "s127", "exec", "vcc", "scc",
   "m0", "flat_scratch", "exec_lo", "exec_hi", "vcc_lo", "vcc_hi",
-  "flat_scratch_lo", "flat_scratch_hi"
+  "flat_scratch_lo", "flat_scratch_hi",
+  "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8",
+  "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17",
+  "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26",
+  "a27", "a28", "a29", "a30", "a31", "a32", "a33", "a34", "a35",
+  "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44",
+  "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53",
+  "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62",
+  "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71",
+  "a72", "a73", "a74", "a75", "a76", "a77", "a78", "a79", "a80",
+  "a81", "a82", "a83", "a84", "a85", "a86", "a87", "a88", "a89",
+  "a90", "a91", "a92", "a93", "a94", 

[PATCH] D71082: Allow system header to provide their own implementation of some builtin

2020-04-02 Thread Manoj Gupta via Phabricator via cfe-commits
manojgupta added a comment.

Yes, it'd be nice if all of the FORTIFY handling can be improved. For a simple 
call like memcpy of 8 bytes in the example, there is no reason to emit all 
these stack/range checks since they'd degrade memcpy performance.

I still think this change should be reverted if it can't handle Linux kernel's 
FORTIFY implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71082



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


[PATCH] D77355: [clangd] show layout info when hovering on a class/field definition.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

This triggers only on the definition itself, not on references (probably too
noisy). Inspecting the definition seems like a decent hint for being interested
in layout.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77355

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -66,7 +66,7 @@
   {R"cpp(
   namespace ns1 { namespace ns2 {
 struct Foo {
-  int [[b^ar]];
+  char [[b^ar]];
 };
   }}
   )cpp",
@@ -75,8 +75,10 @@
  HI.LocalScope = "Foo::";
  HI.Name = "bar";
  HI.Kind = index::SymbolKind::Field;
- HI.Definition = "int bar";
- HI.Type = "int";
+ HI.Definition = "char bar";
+ HI.Type = "char";
+ HI.Offset = 0;
+ HI.Size = 1;
}},
   // Local to class method.
   {R"cpp(
@@ -100,7 +102,7 @@
   {R"cpp(
   namespace ns1 { namespace {
 struct {
-  int [[b^ar]];
+  char [[b^ar]];
 } T;
   }}
   )cpp",
@@ -109,8 +111,21 @@
  HI.LocalScope = "(anonymous struct)::";
  HI.Name = "bar";
  HI.Kind = index::SymbolKind::Field;
- HI.Definition = "int bar";
- HI.Type = "int";
+ HI.Definition = "char bar";
+ HI.Type = "char";
+ HI.Offset = 0;
+ HI.Size = 1;
+   }},
+  // Struct definition shows size.
+  {R"cpp(
+  struct [[^X]]{};
+  )cpp",
+   [](HoverInfo ) {
+ HI.NamespaceScope = "";
+ HI.Name = "X";
+ HI.Kind = index::SymbolKind::Struct;
+ HI.Definition = "struct X {}";
+ HI.Size = 1;
}},
   // Variable with template type
   {R"cpp(
@@ -646,6 +661,8 @@
 EXPECT_EQ(H->TemplateParameters, Expected.TemplateParameters);
 EXPECT_EQ(H->SymRange, Expected.SymRange);
 EXPECT_EQ(H->Value, Expected.Value);
+EXPECT_EQ(H->Size, Expected.Size);
+EXPECT_EQ(H->Offset, Expected.Offset);
   }
 }
 
@@ -1810,6 +1827,7 @@
   {
   [](HoverInfo ) {
 HI.Kind = index::SymbolKind::Class;
+HI.Size = 10;
 HI.TemplateParameters = {
 {std::string("typename"), std::string("T"), llvm::None},
 {std::string("typename"), std::string("C"),
@@ -1823,6 +1841,7 @@
   },
   R"(class foo
 
+Size: 10 bytes
 documentation
 
 template  class Foo {})",
Index: clang-tools-extra/clangd/Hover.h
===
--- clang-tools-extra/clangd/Hover.h
+++ clang-tools-extra/clangd/Hover.h
@@ -70,6 +70,10 @@
   llvm::Optional> TemplateParameters;
   /// Contains the evaluated value of the symbol if available.
   llvm::Optional Value;
+  /// Contains the byte-size of fields and types where it's interesting.
+  llvm::Optional Size;
+  /// Contains the offset of fields within the enclosing class.
+  llvm::Optional Offset;
 
   /// Produce a user-readable information.
   markup::Document present() const;
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -563,6 +563,25 @@
  isFollowedByHardLineBreakIndicator(Str, LineBreakIndex);
 }
 
+void addLayoutInfo(const NamedDecl , HoverInfo ) {
+  const auto  = ND.getASTContext();
+
+  if (auto *RD = llvm::dyn_cast())
+if (auto Size = Ctx.getTypeSizeInCharsIfKnown(RD->getTypeForDecl()))
+  HI.Size = Size->getQuantity();
+
+  if (const auto *FD = llvm::dyn_cast()) {
+const auto *Record = FD->getParent()->getDefinition();
+if (Record && !Record->isDependentType()) {
+  unsigned OffsetBits = Ctx.getFieldOffset(FD);
+  if (auto Size = Ctx.getTypeSizeInCharsIfKnown(FD->getType())) {
+HI.Size = Size->getQuantity();
+HI.Offset = OffsetBits / 8;
+  }
+}
+  }
+}
+
 } // namespace
 
 llvm::Optional getHover(ParsedAST , Position Pos,
@@ -619,6 +638,9 @@
   auto Decls = explicitReferenceTargets(N->ASTNode, DeclRelation::Alias);
   if (!Decls.empty()) {
 HI = getHoverContents(Decls.front(), Index);
+// Layout info only shown when hovering on the field/class itself.
+if (Decls.front() == N->ASTNode.get())
+  addLayoutInfo(*Decls.front(), *HI);
 // Look for a close enclosing expression to show the value of.
 if 

[PATCH] D77342: Sema: check for null TInfo in ActOnBaseSpecifier

2020-04-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I think the problem this aims to address was fixed by 
rG330873230071ffc2aebc0fe74db55e7a530c2f1b 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77342



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


[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335



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


[PATCH] D75936: Add a Pass to X86 that builds a Condensed CFG for Load Value Injection (LVI) Gadgets [4/6]

2020-04-02 Thread Zola Bridges via Phabricator via cfe-commits
zbrid accepted this revision.
zbrid added a subscriber: jyknight.
zbrid added a comment.
This revision is now accepted and ready to land.

LGTM. I would prefer if an actual LLVM maintainer also gave LGTM. @jyknight, 
@george.burgess.iv, @craig.topper?


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

https://reviews.llvm.org/D75936



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


[PATCH] D77342: Sema: check for null TInfo in ActOnBaseSpecifier

2020-04-02 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This needs a reduced test case to demonstrate the problem and ensure clang will 
not regress in the future.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77342



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


[PATCH] D77246: Instead of scream, why not roll?

2020-04-02 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

I'm sorry, but I can't accept this patch as-is because it removes the `u` 
suffix from the literal. We're never gonna give `u` up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77246



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


[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D77335#1958106 , @efriedma wrote:

> If you're going to add code to check for it, we might as well add testcases 
> for ridiculous sizes, like `(__int128_t)1 << 100`.


Done. Looks like this was previously an assertion failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335



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


[PATCH] D77348: [clangd] Enable some nice clang-tidy checks by default.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 254650.
sammccall added a comment.

revert debugging noise


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77348

Files:
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
   // This function must be thread-safe and tidy option providers are not.
-  std::lock_guard Lock(ClangTidyOptMu);
-  // FIXME: use the FS provided to the function.
-  return ClangTidyOptProvider->getOptions(File);
+  tidy::ClangTidyOptions Opts;
+  {
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+Opts = ClangTidyOptProvider->getOptions(File);
+  }
+  if (!Opts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-include",
+"bugprone-suspicious-missing-comma", "bugprone-unused-raii",
+"bugprone-unused-return-value", "misc-unused-using-decls",
+"misc-unused-alias-decls", "misc-definitions-in-headers");
+  }
+  return Opts;
 };
   }
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
   // This function must be thread-safe and tidy option providers are not.
-  std::lock_guard Lock(ClangTidyOptMu);
-  // FIXME: use the FS provided to the function.
-  return ClangTidyOptProvider->getOptions(File);
+  tidy::ClangTidyOptions Opts;
+  {
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+Opts = ClangTidyOptProvider->getOptions(File);
+  }
+  if (!Opts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", 

[clang] e875ba1 - Try again to get tests passing again on Windows.

2020-04-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-04-02T20:00:38-04:00
New Revision: e875ba1509955dc4b3512d820edecc0da26fa38d

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

LOG: Try again to get tests passing again on Windows.

Things pass locally, but some tests on some bots are still unhappy.
I'm not sure why. See if using forward slashes as before helps.

Added: 


Modified: 
clang/test/Unit/lit.site.cfg.py.in
clang/test/lit.site.cfg.py.in
llvm/cmake/modules/AddLLVM.cmake
llvm/test/Unit/lit.site.cfg.py.in
llvm/test/lit.site.cfg.py.in

Removed: 




diff  --git a/clang/test/Unit/lit.site.cfg.py.in 
b/clang/test/Unit/lit.site.cfg.py.in
index ad5e6d0c8b2a..400a9c05e58c 100644
--- a/clang/test/Unit/lit.site.cfg.py.in
+++ b/clang/test/Unit/lit.site.cfg.py.in
@@ -2,14 +2,14 @@
 
 import sys
 
-config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
-config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
-config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
-config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = path("@LLVM_LIBS_DIR@")
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
+config.clang_obj_root = path("@CLANG_BINARY_DIR@")
 config.enable_shared = @ENABLE_SHARED@
-config.shlibdir = path(r"@SHLIBDIR@")
+config.shlibdir = path("@SHLIBDIR@")
 config.target_triple = "@TARGET_TRIPLE@"
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
@@ -26,4 +26,4 @@ except KeyError:
 
 # Let the main config do the real work.
 lit_config.load_config(
-config, os.path.join(path(r"@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py"))
+config, os.path.join(path("@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py"))

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index daec694bd128..84dd0f8846cf 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -2,16 +2,16 @@
 
 import sys
 
-config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
-config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
-config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
-config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
-config.llvm_shlib_dir = path(r"@SHLIBDIR@")
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = path("@LLVM_LIBS_DIR@")
+config.llvm_shlib_dir = path("@SHLIBDIR@")
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
-config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@")
-config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
-config.clang_src_dir = path(r"@CLANG_SOURCE_DIR@")
-config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")
+config.lit_tools_dir = path("@LLVM_LIT_TOOLS_DIR@")
+config.clang_obj_root = path("@CLANG_BINARY_DIR@")
+config.clang_src_dir = path("@CLANG_SOURCE_DIR@")
+config.clang_tools_dir = path("@CLANG_TOOLS_DIR@")
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"

diff  --git a/llvm/cmake/modules/AddLLVM.cmake 
b/llvm/cmake/modules/AddLLVM.cmake
index 0732ca6ed0d0..a474071e9edb 100644
--- a/llvm/cmake/modules/AddLLVM.cmake
+++ b/llvm/cmake/modules/AddLLVM.cmake
@@ -1486,7 +1486,7 @@ function(configure_lit_site_cfg site_in site_out)
 string(REPLACE ";" "\\;" ARG_PATH_VALUES_ESCAPED "${ARG_PATH_VALUES}")
 get_filename_component(OUTPUT_DIR ${site_out} DIRECTORY)
 execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c"
-  "import os, sys; sys.stdout.write(';'.join(os.path.relpath(p, 
sys.argv[1]) if p else '' for p in sys.argv[2].split(';')))"
+  "import os, sys; sys.stdout.write(';'.join(os.path.relpath(p, 
sys.argv[1]).replace('', '/') if p else '' for p in 
sys.argv[2].split(';')))"
   ${OUTPUT_DIR}
   ${ARG_PATH_VALUES_ESCAPED}
   OUTPUT_VARIABLE ARG_PATH_VALUES_RELATIVE)

diff  --git a/llvm/test/Unit/lit.site.cfg.py.in 
b/llvm/test/Unit/lit.site.cfg.py.in
index f9fe421e2aa4..3358ccf89eed 100644
--- a/llvm/test/Unit/lit.site.cfg.py.in
+++ b/llvm/test/Unit/lit.site.cfg.py.in
@@ -2,12 +2,12 @@
 
 import sys
 
-config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
-config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
-config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.enable_shared = @ENABLE_SHARED@
-config.shlibdir = path(r"@SHLIBDIR@")
+config.shlibdir = path("@SHLIBDIR@")
 
 # Support substitution of the tools_dir 

[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 254646.
sammccall added a comment.

Add 1<<100 testcase, and clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/types.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -335,7 +335,7 @@
 typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
 
 namespace Templates {
-template 
+template 
 struct TemplateVectorType {
   typedef Elt __attribute__((__vector_size__(Size))) type; // #1
 };
@@ -343,7 +343,7 @@
 template 
 struct PR15730 {
   typedef T __attribute__((vector_size(N * sizeof(T type;
-  typedef T __attribute__((vector_size(8192))) type2; // #2
+  typedef T __attribute__((vector_size(0x10))) type2; // #2
   typedef T __attribute__((vector_size(3))) type3; // #3
 };
 
@@ -352,19 +352,20 @@
   const TemplateVectorType::type Works2 = {};
   // expected-error@#1 {{invalid vector element type 'bool'}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool;
+  const TemplateVectorType::type NoBool = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoComplex;
+  const TemplateVectorType::type NoComplex = {};
   // expected-error@#1 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type BadSize;
+  const TemplateVectorType::type BadSize = {};
+  const TemplateVectorType::type Large = {};
   // expected-error@#1 {{vector size too large}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type TooLarge;
+  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
+  const TemplateVectorType::type TooLarge = {};
   // expected-error@#1 {{zero vector size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type Zero;
+  const TemplateVectorType::type Zero = {};
 
   // expected-error@#2 {{vector size too large}}
   // expected-error@#3 {{vector size not an integral multiple of component size}}
Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -69,9 +69,15 @@
   char c = (char __attribute__((may_alias))) i;
 }
 
-// vector size too large
-int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
-typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+// vector size
+int __attribute__((vector_size(123456))) v1;
+int __attribute__((vector_size(0x10))) v2; // expected-error {{vector size too large}}
+int __attribute__((vector_size((__int128_t)1 << 100))) v3; // expected-error {{vector size too large}}
+int __attribute__((vector_size(0))) v4;// expected-error {{zero vector size}}
+typedef int __attribute__((ext_vector_type(123456))) e1;
+typedef int __attribute__((ext_vector_type(0x1))) e2;  // expected-error {{vector size too large}}
+typedef int __attribute__((vector_size((__int128_t)1 << 100))) e3; // expected-error {{vector size too large}}
+typedef int __attribute__((ext_vector_type(0))) e4;// expected-error {{zero vector size}}
 
 // no support for vector enum type
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2436,28 +2436,34 @@
 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
 
-  unsigned VectorSize = static_cast(VecSize.getZExtValue() * 8);
+  // vecSize is specified in bytes - convert to bits.
+  if (!VecSize.isIntN(61)) {
+// Bit size will overflow uint64.
+Diag(AttrLoc, diag::err_attribute_size_too_large)
+<< SizeExpr->getSourceRange();
+return QualType();
+  }
+  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8;
   unsigned TypeSize = 

[PATCH] D77348: [clangd] Enable some nice clang-tidy checks by default.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman, jkorous, 
MaskRay, ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77348

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clangd/tool/ClangdMain.cpp


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ OverrideClangTidyOptions, FSProvider.getFileSystem());
 Opts.GetClangTidyOptions = [&](llvm::vfs::FileSystem &,
llvm::StringRef File) {
   // This function must be thread-safe and tidy option providers are not.
-  std::lock_guard Lock(ClangTidyOptMu);
-  // FIXME: use the FS provided to the function.
-  return ClangTidyOptProvider->getOptions(File);
+  tidy::ClangTidyOptions Opts;
+  {
+std::lock_guard Lock(ClangTidyOptMu);
+// FIXME: use the FS provided to the function.
+Opts = ClangTidyOptProvider->getOptions(File);
+  }
+  if (!Opts.Checks) {
+// If the user hasn't configured clang-tidy checks at all, including
+// via .clang-tidy, give them a nice set of checks.
+// (This should be what the "default" options does, but it isn't...)
+//
+// These default checks are chosen for:
+//  - low false-positive rate
+//  - providing a lot of value
+//  - being reasonably efficient
+Opts.Checks = llvm::join_items(
+",", "readability-misleading-indentation",
+"readability-deleted-default", "bugprone-integer-division",
+"bugprone-sizeof-expression", "bugprone-suspicious-include",
+"bugprone-suspicious-missing-comma", "bugprone-unused-raii",
+"bugprone-unused-return-value", "misc-unused-using-decls",
+"misc-unused-alias-decls", "misc-definitions-in-headers");
+  }
+  return Opts;
 };
   }
   Opts.SuggestMissingIncludes = SuggestMissingIncludes;
Index: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
===
--- clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -142,6 +142,9 @@
 ClangTidyOptions::mergeWith(const ClangTidyOptions ) const {
   ClangTidyOptions Result = *this;
 
+  llvm::errs() << "merging " << bool(Other.Checks) << "\n";
+  if (Other.Checks)
+llvm::errs() << "value: " << *Other.Checks << "\n";
   mergeCommaSeparatedLists(Result.Checks, Other.Checks);
   mergeCommaSeparatedLists(Result.WarningsAsErrors, Other.WarningsAsErrors);
   overrideValue(Result.HeaderFilterRegex, Other.HeaderFilterRegex);
@@ -168,8 +171,10 @@
 ClangTidyOptions
 ClangTidyOptionsProvider::getOptions(llvm::StringRef FileName) {
   ClangTidyOptions Result;
-  for (const auto  : getRawOptions(FileName))
+  for (const auto  : getRawOptions(FileName)) {
+llvm::errs() << Source.second << "\n";
 Result = Result.mergeWith(Source.first);
+  }
   return Result;
 }
 


Index: clang-tools-extra/clangd/tool/ClangdMain.cpp
===
--- clang-tools-extra/clangd/tool/ClangdMain.cpp
+++ clang-tools-extra/clangd/tool/ClangdMain.cpp
@@ -691,18 +691,42 @@
   std::unique_ptr
   ClangTidyOptProvider; /*GUARDED_BY(ClangTidyOptMu)*/
   if (EnableClangTidy) {
-auto OverrideClangTidyOptions = tidy::ClangTidyOptions::getDefaults();
-OverrideClangTidyOptions.Checks = ClangTidyChecks;
+auto EmptyDefaults = tidy::ClangTidyOptions::getDefaults();
+EmptyDefaults.Checks.reset(); // So we can tell if checks were ever set.
+tidy::ClangTidyOptions OverrideClangTidyOptions;
+if (!ClangTidyChecks.empty())
+  OverrideClangTidyOptions.Checks = ClangTidyChecks;
 ClangTidyOptProvider = std::make_unique(
 tidy::ClangTidyGlobalOptions(),
-/* Default */ tidy::ClangTidyOptions::getDefaults(),
+/* Default */ EmptyDefaults,
 /* Override */ 

[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Couple of small nits, but I'll leave most of the review to someoen else here - 
I /think/ it's beyond my context/experience (but if necessary, poke me and I 
can look more/ask more questions/etc)




Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:324-325
+const GraphDiffT *GDTmp = BUI ? BUI->PreViewOfCFG : 
+std::pair GDNodePair =
+std::make_pair(GDTmp, N);
+for (auto  : children(GDNodePair)) {

No need for make_pair if you're going to specify the types on the LHS, could 
write this as:
```
std::pair<...> GDNodePair(GDTmp, N);
```
(similarly two instances further down in this patch - make_pair or explicit 
type, not both)


Or you could use auto on the LHS given the types of the two parameters seem 
close enough that it's not too surprising what make_pair produces, maybe even 
just roll it all in together:
```
return !empty(children(std::make_pair(GDTmp, N)));
```



Comment at: llvm/include/llvm/Support/GenericDomTreeConstruction.h:326-330
+for (auto  : children(GDNodePair)) {
+  (void)Pair;
+  return true;
+}
+return false;

Probably write this as (if I'm understanding the code/intent correctly):
```
return !empty(children(GDNodePair));
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D76083: [clang-tidy] Expand the list of functions in bugprone-unused-return-value

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clang-tidy/bugprone/UnusedReturnValueCheck.cpp:98
+   "::access;"
+   "::bind;"
+   "::connect;"

aaron.ballman wrote:
> jranieri-grammatech wrote:
> > alexfh wrote:
> > > bind has a side effect and returns a success status. Thus, the result 
> > > being unused isn't necessarily a bug. Same for `connect`. And probably 
> > > for `setjmp` as well.
> > In terms of bind, connect, and setjmp: while I personally would say that 
> > code not using the return value is bugprone, the data suggests that the 
> > vast majority of developers are using these functions in the intended 
> > manner and the false-positive rate should be low.
> I think we have sufficient statistical data to suggest that these APIs should 
> be on the list because the majority of programmers *do not* use them solely 
> for side effects without using the return value, so my preference is to keep 
> them in the list.
I stumbled upon this review as we're considering turning this check on by 
default in clangd.

There's a significant difference between unused std::async() (programmer 
misunderstood contract) and unused ::connect() (ignoring error conditions). The 
former is ~never noise, and the latter may be (e.g. in experimental or 
incomplete code).

So there's some value in separating these two lists out either as an option or 
a separate named check (bugprone-unhandled-error?) I think we probably wouldn't 
enable this check by default if it includes the error-code functions.

> the majority of programmers *do not* use them solely for side effects
...in popular, distributed software :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76083



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


[PATCH] D77342: Sema: check for null TInfo in ActOnBaseSpecifier

2020-04-02 Thread Luke Zarko via Phabricator via cfe-commits
zarko created this revision.
zarko added a project: clang.
Herald added a subscriber: cfe-commits.
zarko added a reviewer: rsmith.

In certain cases (particularly when some input files are missing), 
GetTypeFromParser will set TInfo to nullptr in ActOnBaseSpecifier.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77342

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2581,6 +2581,8 @@
 
   TypeSourceInfo *TInfo = nullptr;
   GetTypeFromParser(basetype, );
+  if (TInfo == nullptr)
+return true;
 
   if (EllipsisLoc.isInvalid() &&
   DiagnoseUnexpandedParameterPack(SpecifierRange.getBegin(), TInfo,


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -2581,6 +2581,8 @@
 
   TypeSourceInfo *TInfo = nullptr;
   GetTypeFromParser(basetype, );
+  if (TInfo == nullptr)
+return true;
 
   if (EllipsisLoc.isInvalid() &&
   DiagnoseUnexpandedParameterPack(SpecifierRange.getBegin(), TInfo,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea added a comment.

I sent this out to get some general feedback, but I'd like to be able to 
simplify the fact that this is replacing a `for` over `ChildrenGetter` with a 
`for` over `children(pair)`, plus 5 lines to set up the type and pair; 
one simplification is around getting the type inside `children` 
(`GraphDiffBBPair`) and another around having the BUI or not; for the latter 
I'm considering updating a few places such that BUI is never nullptr.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77341



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


[PATCH] D77341: [DomTree] Replace ChildrenGetter with GraphTraits over GraphDiff.

2020-04-02 Thread Alina Sbirlea via Phabricator via cfe-commits
asbirlea created this revision.
asbirlea added reviewers: kuhar, dblaikie, NutshellySima.
Herald added subscribers: cfe-commits, hiraditya.
Herald added a project: clang.
asbirlea added a comment.
asbirlea added a parent revision: D77167: [GraphDiff] Extend GraphDiff to track 
a list of updates..

I sent this out to get some general feedback, but I'd like to be able to 
simplify the fact that this is replacing a `for` over `ChildrenGetter` with a 
`for` over `children(pair)`, plus 5 lines to set up the type and pair; 
one simplification is around getting the type inside `children` 
(`GraphDiffBBPair`) and another around having the BUI or not; for the latter 
I'm considering updating a few places such that BUI is never nullptr.


This replaces the ChildrenGetter inside the DominatorTree with
GraphTraits over a GraphDiff object, an object which encapsulated the
view of the previous CFG.
This also simplifies the extentions in clang which use DominatorTree, as
GraphDiff also filters nullptrs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77341

Files:
  clang/include/clang/Analysis/Analyses/Dominators.h
  llvm/include/llvm/IR/CFGDiff.h
  llvm/include/llvm/IR/Dominators.h
  llvm/include/llvm/Support/GenericDomTree.h
  llvm/include/llvm/Support/GenericDomTreeConstruction.h
  llvm/lib/IR/Dominators.cpp

Index: llvm/lib/IR/Dominators.cpp
===
--- llvm/lib/IR/Dominators.cpp
+++ llvm/lib/IR/Dominators.cpp
@@ -90,9 +90,10 @@
 DomTreeBuilder::BBPostDomTree , BasicBlock *From, BasicBlock *To);
 
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBDomTree , DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBDomTree , DomTreeBuilder::BBDomTreeGraphDiff &);
 template void llvm::DomTreeBuilder::ApplyUpdates(
-DomTreeBuilder::BBPostDomTree , DomTreeBuilder::BBUpdates);
+DomTreeBuilder::BBPostDomTree ,
+DomTreeBuilder::BBPostDomTreeGraphDiff &);
 
 template bool llvm::DomTreeBuilder::Verify(
 const DomTreeBuilder::BBDomTree ,
Index: llvm/include/llvm/Support/GenericDomTreeConstruction.h
===
--- llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -58,6 +58,7 @@
   using TreeNodePtr = DomTreeNodeBase *;
   using RootsT = decltype(DomTreeT::Roots);
   static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+  using GraphDiffT = GraphDiff;
 
   // Information record used by Semi-NCA during tree construction.
   struct InfoRec {
@@ -77,28 +78,27 @@
   using UpdateT = typename DomTreeT::UpdateType;
   using UpdateKind = typename DomTreeT::UpdateKind;
   struct BatchUpdateInfo {
-SmallVector Updates;
-using NodePtrAndKind = PointerIntPair;
-
-// In order to be able to walk a CFG that is out of sync with the CFG
-// DominatorTree last knew about, use the list of updates to reconstruct
-// previous CFG versions of the current CFG. For each node, we store a set
-// of its virtually added/deleted future successors and predecessors.
-// Note that these children are from the future relative to what the
-// DominatorTree knows about -- using them to gets us some snapshot of the
-// CFG from the past (relative to the state of the CFG).
-DenseMap> FutureSuccessors;
-DenseMap> FuturePredecessors;
+// Note: Updates inside PreViewOfCFG are aleady legalized.
+BatchUpdateInfo(GraphDiffT )
+: PreViewOfCFG(),
+  NumLegalized(PreViewOfCFG.getNumLegalizedUpdates()) {}
+
 // Remembers if the whole tree was recalculated at some point during the
 // current batch update.
 bool IsRecalculated = false;
+GraphDiffT *PreViewOfCFG;
+const size_t NumLegalized;
   };
 
   BatchUpdateInfo *BatchUpdates;
   using BatchUpdatePtr = BatchUpdateInfo *;
+  std::unique_ptr EmptyGD;
 
   // If BUI is a nullptr, then there's no batch update in progress.
-  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {}
+  SemiNCAInfo(BatchUpdatePtr BUI) : BatchUpdates(BUI) {
+if (!BatchUpdates)
+  EmptyGD = std::make_unique();
+  }
 
   void clear() {
 NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
@@ -107,67 +107,6 @@
 // in progress, we need this information to continue it.
   }
 
-  template 
-  struct ChildrenGetter {
-using ResultTy = SmallVector;
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto RChildren = reverse(children(N));
-  return ResultTy(RChildren.begin(), RChildren.end());
-}
-
-static ResultTy Get(NodePtr N, std::integral_constant) {
-  auto IChildren = inverse_children(N);
-  return ResultTy(IChildren.begin(), IChildren.end());
-}
-
-using Tag = std::integral_constant;
-
-// The function below is the core part of the batch updater. It allows the
-// Depth Based Search algorithm to perform incremental updates 

[PATCH] D77112: [OpenMP][NFCI] Move OpenMP clause information to `lib/Frontend/OpenMP`

2020-04-02 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim accepted this revision.
fghanim added a comment.
This revision is now accepted and ready to land.

OK, As I said a few days ago, I went over the patch, and I didn't see any 
functional changes. I am accepting this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77112



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


[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-02 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec added inline comments.



Comment at: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl:16
+  float reg_b;
+  float reg_c;
+  // CHECK:  call <32 x float> asm "v_mfma_f32_32x32x1f32 $0, $1, $2, $3", 
"=a,v,v,a,~{a0},~{a1},~{a2},~{a3},~{a4},~{a5},~{a6},~{a7},~{a8},~{a9},~{a10},~{a11},~{a12},~{a13},~{a14},~{a15},~{a16},~{a17},~{a18},~{a19},~{a20},~{a21},~{a22},~{a23},~{a24},~{a25},~{a26},~{a27},~{a28},~{a29},~{a30},~{a31}"

reg_c is also float32.



Comment at: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl:36
+}
\ No newline at end of file


New line.


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

https://reviews.llvm.org/D77329



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


[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254619.
yaxunl added a comment.

added agprs to GCCRegNames and fixed types in test


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

https://reviews.llvm.org/D77329

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl

Index: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -1,8 +1,35 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -o - -triple amdgcn %s | FileCheck %s
+
+typedef float float32 __attribute__((ext_vector_type(32)));
 
 kernel void test_long(int arg0) {
   long v15_16;
-  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"(i32 %arg0)
+  // CHECK: call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"
   __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0));
 }
+
+kernel void test_agpr() {
+  float32 acc_c;
+  float reg_a;
+  float reg_b;
+  float reg_c;
+  // CHECK:  call <32 x float> asm "v_mfma_f32_32x32x1f32 $0, $1, $2, $3", "=a,v,v,a,~{a0},~{a1},~{a2},~{a3},~{a4},~{a5},~{a6},~{a7},~{a8},~{a9},~{a10},~{a11},~{a12},~{a13},~{a14},~{a15},~{a16},~{a17},~{a18},~{a19},~{a20},~{a21},~{a22},~{a23},~{a24},~{a25},~{a26},~{a27},~{a28},~{a29},~{a30},~{a31}"
+  __asm ("v_mfma_f32_32x32x1f32 %0, %1, %2, %3"
+ : "=a"(acc_c)
+ : "v"(reg_a), "v"(reg_b), "a"(acc_c)
+ : "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
+   "a8", "a9", "a10", "a11", "a12", "a13", "a14", "a15",
+   "a16", "a17", "a18", "a19", "a20", "a21", "a22", "a23",
+   "a24", "a25", "a26", "a27", "a28", "a29", "a30", "a31");
+ 
+   // CHECK: call <32 x float> asm sideeffect "v_mfma_f32_32x32x1f32 a[0:31], $0, $1, a[0:31]", "={a[0:31]},v,v,{a[0:31]}"
+  __asm volatile("v_mfma_f32_32x32x1f32 a[0:31], %0, %1, a[0:31]"
+ : "={a[0:31]}"(acc_c)
+ : "v"(reg_a),"v"(reg_b), "{a[0:31]}"(acc_c));
+
+  // CHECK: call float asm "v_accvgpr_read_b32 $0, $1", "={a1},{a1}"
+  __asm ("v_accvgpr_read_b32 %0, %1"
+ : "={a1}"(reg_a)
+ : "{a1}"(reg_b));
+}
\ No newline at end of file
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -114,11 +114,14 @@
   /// Accepted register names: (n, m is unsigned integer, n < m)
   /// v
   /// s
+  /// a
   /// {vn}, {v[n]}
   /// {sn}, {s[n]}
+  /// {an}, {a[n]}
   /// {S} , where S is a special register name
   {v[n:m]}
   /// {s[n:m]}
+  /// {a[n:m]}
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
 static const ::llvm::StringSet<> SpecialRegs({
@@ -135,7 +138,7 @@
 }
 if (S.empty())
   return false;
-if (S.front() != 'v' && S.front() != 's') {
+if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') {
   if (!HasLeftParen)
 return false;
   auto E = S.find('}');
@@ -153,7 +156,7 @@
 if (!HasLeftParen) {
   if (!S.empty())
 return false;
-  // Found s or v.
+  // Found s, v or a.
   Info.setAllowsRegister();
   Name = S.data() - 1;
   return true;
@@ -184,7 +187,8 @@
 S = S.drop_front();
 if (!S.empty())
   return false;
-// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]}
+// or {a[n:m]}.
 Info.setAllowsRegister();
 Name = S.data() - 1;
 return true;
Index: clang/lib/Basic/Targets/AMDGPU.cpp
===
--- clang/lib/Basic/Targets/AMDGPU.cpp
+++ clang/lib/Basic/Targets/AMDGPU.cpp
@@ -124,7 +124,36 @@
   "s113", "s114", "s115", "s116", "s117", "s118", "s119", "s120", "s121",
   "s122", "s123", "s124", "s125", "s126", "s127", "exec", "vcc", "scc",
   "m0", "flat_scratch", "exec_lo", "exec_hi", "vcc_lo", "vcc_hi",
-  "flat_scratch_lo", "flat_scratch_hi"
+  "flat_scratch_lo", "flat_scratch_hi",
+  "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "a8",
+  "a9", "a10", "a11", "a12", "a13", "a14", "a15", "a16", "a17",
+  "a18", "a19", "a20", "a21", "a22", "a23", "a24", "a25", "a26",
+  "a27", "a28", "a29", "a30", "a31", "a32", "a33", "a34", "a35",
+  "a36", "a37", "a38", "a39", "a40", "a41", "a42", "a43", "a44",
+  "a45", "a46", "a47", "a48", "a49", "a50", "a51", "a52", "a53",
+  "a54", "a55", "a56", "a57", "a58", "a59", "a60", "a61", "a62",
+  "a63", "a64", "a65", "a66", "a67", "a68", "a69", "a70", "a71",
+  "a72", "a73", "a74", "a75", "a76", "a77", "a78", "a79", "a80",
+  "a81", "a82", "a83", "a84", 

[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

If you're going to add code to check for it, we might as well add testcases for 
ridiculous sizes, like `(__int128_t)1 << 100`.

I think this makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77335



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


[PATCH] D77234: clang/AMDGPU: Stop setting old denormal subtarget features

2020-04-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

ce2258c1cd5dc9cf20040d1b1e540d80250c1435 



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

https://reviews.llvm.org/D77234



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


[clang] ce2258c - clang/AMDGPU: Stop setting old denormal subtarget features

2020-04-02 Thread Matt Arsenault via cfe-commits

Author: Matt Arsenault
Date: 2020-04-02T17:17:12-04:00
New Revision: ce2258c1cd5dc9cf20040d1b1e540d80250c1435

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

LOG: clang/AMDGPU: Stop setting old denormal subtarget features

Added: 


Modified: 
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/AMDGPU.h
clang/test/CodeGenCUDA/flush-denormals.cu
clang/test/CodeGenOpenCL/amdgpu-features.cl

Removed: 




diff  --git a/clang/lib/Basic/Targets/AMDGPU.cpp 
b/clang/lib/Basic/Targets/AMDGPU.cpp
index a34d3d8b4353..55d7c081ceac 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -233,28 +233,6 @@ bool AMDGPUTargetInfo::initFeatureMap(
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeatureVec);
 }
 
-void AMDGPUTargetInfo::adjustTargetOptions(const CodeGenOptions ,
-   TargetOptions ) const {
-  bool hasFP32Denormals = false;
-  bool hasFP64Denormals = false;
-
-  for (auto  : TargetOpts.FeaturesAsWritten) {
-if (I == "+fp32-denormals" || I == "-fp32-denormals")
-  hasFP32Denormals = true;
-if (I == "+fp64-fp16-denormals" || I == "-fp64-fp16-denormals")
-  hasFP64Denormals = true;
-  }
-  if (!hasFP32Denormals)
-TargetOpts.Features.push_back(
-  (Twine(hasFastFMAF() && hasFullRateDenormalsF32() &&
- CGOpts.FP32DenormalMode.Output == llvm::DenormalMode::IEEE
- ? '+' : '-') + Twine("fp32-denormals"))
-.str());
-  // Always do not flush fp64 or fp16 denorms.
-  if (!hasFP64Denormals && hasFP64())
-TargetOpts.Features.push_back("+fp64-fp16-denormals");
-}
-
 void AMDGPUTargetInfo::fillValidCPUList(
 SmallVectorImpl ) const {
   if (isAMDGCN(getTriple()))

diff  --git a/clang/lib/Basic/Targets/AMDGPU.h 
b/clang/lib/Basic/Targets/AMDGPU.h
index ed6929214f6e..46ddc401fb6f 100644
--- a/clang/lib/Basic/Targets/AMDGPU.h
+++ b/clang/lib/Basic/Targets/AMDGPU.h
@@ -208,9 +208,6 @@ class LLVM_LIBRARY_VISIBILITY AMDGPUTargetInfo final : 
public TargetInfo {
  StringRef CPU,
  const std::vector ) const override;
 
-  void adjustTargetOptions(const CodeGenOptions ,
-   TargetOptions ) const override;
-
   ArrayRef getTargetBuiltins() const override;
 
   void getTargetDefines(const LangOptions ,

diff  --git a/clang/test/CodeGenCUDA/flush-denormals.cu 
b/clang/test/CodeGenCUDA/flush-denormals.cu
index 8577fca92866..e5adb2aa6d25 100644
--- a/clang/test/CodeGenCUDA/flush-denormals.cu
+++ b/clang/test/CodeGenCUDA/flush-denormals.cu
@@ -1,26 +1,26 @@
 // RUN: %clang_cc1 -fcuda-is-device \
 // RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=NOFTZ %s
+// RUN:   FileCheck -check-prefixes=NOFTZ,PTXNOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -fdenormal-fp-math-f32=ieee \
 // RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=NOFTZ %s
+// RUN:   FileCheck -check-prefixes=NOFTZ,PTXNOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -fdenormal-fp-math-f32=preserve-sign \
 // RUN:   -triple nvptx-nvidia-cuda -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=FTZ %s
+// RUN:   FileCheck -check-prefixes=FTZ,PTXFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -x hip \
 // RUN:   -triple amdgcn-amd-amdhsa -target-cpu gfx900 -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=AMDNOFTZ %s
+// RUN:   FileCheck -check-prefix=NOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -x hip \
 // RUN:   -triple amdgcn-amd-amdhsa -target-cpu gfx900 
-fdenormal-fp-math-f32=ieee -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=AMDNOFTZ %s
+// RUN:   FileCheck -check-prefix=NOFTZ %s
 
 // RUN: %clang_cc1 -fcuda-is-device -x hip 
-fdenormal-fp-math-f32=preserve-sign \
 // RUN:   -triple amdgcn-amd-amdhsa -target-cpu gfx900 -emit-llvm -o - %s | \
-// RUN:   FileCheck -check-prefix=AMDFTZ %s
+// RUN:   FileCheck -check-prefix=FTZ %s
 
 #include "Inputs/cuda.h"
 
@@ -29,10 +29,13 @@
 // -fdenormal-fp-math-f32. Further, check that we reflect the presence or
 // absence of -fcuda-flush-denormals-to-zero in a module flag.
 
-// AMDGCN targets always have +fp64-fp16-denormals.
-// AMDGCN targets without fast FMAF (e.g. gfx803) always have +fp32-denormals.
-// For AMDGCN target with fast FMAF (e.g. gfx900), it has +fp32-denormals
-// by default and -fp32-denormals when there is option
+// AMDGCN targets always have f64/f16 denormals enabled.
+//
+// AMDGCN targets without fast FMAF (e.g. gfx803) always have f32 denormal
+// flushing by default.
+//
+// For AMDGCN target with fast FMAF (e.g. gfx900), it has ieee denormals by
+// default and preserve-sign when there with the option
 // -fcuda-flush-denormals-to-zero.

[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D77313#1957970 , @sammccall wrote:

> In D77313#1957690 , @efriedma wrote:
>
> > I think I would rather just pay the extra 8 bytes per VectorType, and 
> > expand this to support all vector types supported by LLVM.  It's not like 
> > we allocate enough VectorTypes for it to matter, anyway.
>
>
> Sounds reasonable to me, I'll try that.


This alternative is in D77335 , which is much 
simpler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77313



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


[PATCH] D77074: [FPEnv][AArch64] Platform-specific builtin constrained FP enablement

2020-04-02 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio added inline comments.



Comment at: clang/lib/CodeGen/CGBuiltin.cpp:8486-8492
+  return Builder.CreateConstrainedFPCall(
+  F,
+  {EmitScalarExpr(E->getArg(1)), EmitScalarExpr(E->getArg(2)), 
Ops[0]});
+} else {
+  Function *F = CGM.getIntrinsic(Intrinsic::fma, HalfTy);
+  // NEON intrinsic puts accumulator first, unlike the LLVM fma.
+  return Builder.CreateCall(F, {EmitScalarExpr(E->getArg(1)),

kpn wrote:
> dnsampaio wrote:
> > It seems that `Builder.CreateCall` and `Builder.CreateConstrainedFPCall` 
> > usually have the same arguments, except for the function F being or not 
> > part of "experimental_constrained_".
> > Would it make sense to teach the `Builder` to select between creating a 
> > constrained or not call, depending if the function passed is constrained?
> > 
> > I was thinking in something like this:
> > ```
> > Function *F = CGM.getIntrinsic( Builder.getIsFPConstrained()?
> > 
> > Intrinsic::experimental_constrained_fma :
> > Intrinsic::fma, 
> > HalfTy);
> > return Builder.CreateCallConstrainedFPIfRequired(F, 
> > ```
> > 
> In CGBuiltins.cpp we already have emitUnaryMaybeConstrainedFPBuiltin() plus 
> Binary and Ternary. They work well for the pattern seen on other hosts. But 
> they won't easily work for this ticket. 
> 
> How about a new function just below those three that will work well here? A 
> emitCallMaybeConstrainedFPBuiltin() that takes two intrinsic IDs and chooses 
> which one based on constrained FP would make for an even more compact use. 
> The block of example code you put above would just turn into a single 
> function call. Does that work for you?
Sounds good to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77074



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


[PATCH] D77335: [AST] clang::VectorType supports any size (that fits in unsigned)

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: efriedma, hokein.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This matches llvm::VectorType.
It moves the size from the type bitfield into VectorType, increasing size by 8
bytes (including padding of 4). This is OK as we don't expect to create terribly
many of these types.

c.f. D77313  which enables large power-of-two 
sizes without growing VectorType.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77335

Files:
  clang/include/clang/AST/Type.h
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/types.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -335,7 +335,7 @@
 typedef bool bad __attribute__((__vector_size__(16)));  // expected-error {{invalid vector element type 'bool'}}
 
 namespace Templates {
-template 
+template 
 struct TemplateVectorType {
   typedef Elt __attribute__((__vector_size__(Size))) type; // #1
 };
@@ -343,7 +343,7 @@
 template 
 struct PR15730 {
   typedef T __attribute__((vector_size(N * sizeof(T type;
-  typedef T __attribute__((vector_size(8192))) type2; // #2
+  typedef T __attribute__((vector_size(0x10))) type2; // #2
   typedef T __attribute__((vector_size(3))) type3; // #3
 };
 
@@ -352,19 +352,20 @@
   const TemplateVectorType::type Works2 = {};
   // expected-error@#1 {{invalid vector element type 'bool'}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool;
+  const TemplateVectorType::type NoBool = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoComplex;
+  const TemplateVectorType::type NoComplex = {};
   // expected-error@#1 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type BadSize;
+  const TemplateVectorType::type BadSize = {};
+  const TemplateVectorType::type Large = {};
   // expected-error@#1 {{vector size too large}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type TooLarge;
+  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
+  const TemplateVectorType::type TooLarge = {};
   // expected-error@#1 {{zero vector size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type Zero;
+  const TemplateVectorType::type Zero = {};
 
   // expected-error@#2 {{vector size too large}}
   // expected-error@#3 {{vector size not an integral multiple of component size}}
Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -69,9 +69,13 @@
   char c = (char __attribute__((may_alias))) i;
 }
 
-// vector size too large
-int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
-typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+// vector size
+int __attribute__ ((vector_size(123456))) v1;
+int __attribute__ ((vector_size(0x10))) v2; // expected-error {{vector size too large}}
+int __attribute__ ((vector_size(0))) v3; // expected-error {{zero vector size}}
+typedef int __attribute__ ((ext_vector_type(123456))) e1;
+typedef int __attribute__ ((ext_vector_type(0x1))) e2; // expected-error {{vector size too large}}
+typedef int __attribute__ ((ext_vector_type(0))) e3; // expected-error {{zero vector size}}
 
 // no support for vector enum type
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2436,28 +2436,34 @@
 return Context.getDependentVectorType(CurType, SizeExpr, AttrLoc,
VectorType::GenericVector);
 
-  unsigned VectorSize = static_cast(VecSize.getZExtValue() * 8);
+  // vecSize is specified in bytes - convert to bits.
+  if (!VecSize.isIntN(61)) {
+// Bit size will overflow uint64.
+Diag(AttrLoc, diag::err_attribute_size_too_large)
+<< SizeExpr->getSourceRange();
+return QualType();
+  }
+  uint64_t VectorSizeBits = VecSize.getZExtValue() * 8;
   unsigned 

[PATCH] D77334: [AVR] Remove duplicate specification of lib directory

2020-04-02 Thread Dennis van der Schagt via Phabricator via cfe-commits
dennisschagt created this revision.
dennisschagt added a reviewer: dylanmckay.
Herald added subscribers: cfe-commits, Jim.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77334

Files:
  clang/lib/Driver/ToolChains/AVR.cpp


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -77,8 +77,6 @@
 std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
 std::string LibcRoot = AVRLibcRoot.getValue();
 
-getFilePaths().push_back(LibcRoot + std::string("/lib/") +
- std::string(*FamilyName));
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +


Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -77,8 +77,6 @@
 std::string GCCRoot = std::string(GCCInstallation.getInstallPath());
 std::string LibcRoot = AVRLibcRoot.getValue();
 
-getFilePaths().push_back(LibcRoot + std::string("/lib/") +
- std::string(*FamilyName));
 getFilePaths().push_back(LibcRoot + std::string("/lib/") +
  std::string(*FamilyName));
 getFilePaths().push_back(GCCRoot + std::string("/") +
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76949: Replace subtract-from-zero float in version with fneg in PowerPC special fma compiler builtins

2020-04-02 Thread Andrew J Wock via Phabricator via cfe-commits
ajwock updated this revision to Diff 254609.
ajwock added a comment.

Rebased for harbormaster.


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

https://reviews.llvm.org/D76949

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-ppc-fma.c


Index: clang/test/CodeGen/builtins-ppc-fma.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fma.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - 
| FileCheck  \
+// RUN: %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_fma(void) {
+  vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
+
+  vd = __builtin_vsx_xvmaddadp(vd, vd, vd);
+  // CHECK: @llvm.fma.v2f64(<2 x double> %{{.*}}, <2 x double> %{{.*}}, <2 x 
double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmaddasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = call <4 x float> @llvm.fma.v4f32(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+  // CHECK: fneg <4 x float> [[RESULT]]
+
+  vd = __builtin_vsx_xvnmaddadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+  // CHECK: fneg <2 x double> [[RESULT]]
+
+  vf = __builtin_vsx_xvmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] fneg <4 x float> %{{.*}}
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> [[RESULT]])
+
+  vd = __builtin_vsx_xvmsubadp(vd, vd, vd);
+  // CHECK: fneg <2 x double> [[RESULT]]
+  // CHECK: [[RESULT:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x double> 
%{{.*}}, <2 x double> %{{.*}}, <2 x double> %{{.*}})
+
+  vf = __builtin_vsx_xvnmsubasp(vf, vf, vf);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <4 x float> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <4 x float> @llvm.fma.v2f64(<4 x float> 
%{{.*}}, <4 x float> %{{.*}}, <4 x float> [[RESULT]])
+  // CHECK: fneg <4 x float> [[RESULT2]]
+
+  vd = __builtin_vsx_xvnmsubadp(vd, vd, vd);
+  // CHECK: [[RESULT:%[^ ]+]] = fneg <2 x double> %{{.*}}
+  // CHECK: [[RESULT2:%[^ ]+]] = call <2 x double> @llvm.fma.v2f64(<2 x 
double> %{{.*}}, <2 x double> %{{.*}}, <2 x double> [[RESULT]])
+  // CHECK: fneg <2 x double> [[RESULT2]]
+}
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -13214,25 +13214,24 @@
 Value *X = EmitScalarExpr(E->getArg(0));
 Value *Y = EmitScalarExpr(E->getArg(1));
 Value *Z = EmitScalarExpr(E->getArg(2));
-Value *Zero = llvm::ConstantFP::getZeroValueForNegation(ResultType);
 llvm::Function *F = CGM.getIntrinsic(Intrinsic::fma, ResultType);
 switch (BuiltinID) {
   case PPC::BI__builtin_vsx_xvmaddadp:
   case PPC::BI__builtin_vsx_xvmaddasp:
 return Builder.CreateCall(F, {X, Y, Z});
+
   case PPC::BI__builtin_vsx_xvnmaddadp:
   case PPC::BI__builtin_vsx_xvnmaddasp:
-return Builder.CreateFSub(Zero,
-  Builder.CreateCall(F, {X, Y, Z}), "sub");
+return Builder.CreateFNeg(Builder.CreateCall(F, {X, Y, Z}), "neg");
+
   case PPC::BI__builtin_vsx_xvmsubadp:
   case PPC::BI__builtin_vsx_xvmsubasp:
-return Builder.CreateCall(F,
-  {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
+return Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")});
+
   case PPC::BI__builtin_vsx_xvnmsubadp:
   case PPC::BI__builtin_vsx_xvnmsubasp:
-Value *FsubRes =
-  Builder.CreateCall(F, {X, Y, Builder.CreateFSub(Zero, Z, "sub")});
-return Builder.CreateFSub(Zero, FsubRes, "sub");
+return Builder.CreateFNeg(
+Builder.CreateCall(F, {X, Y, Builder.CreateFNeg(Z, "neg")}), 
"neg");
 }
 llvm_unreachable("Unknown FMA operation");
 return nullptr; // Suppress no-return warning


Index: clang/test/CodeGen/builtins-ppc-fma.c
===
--- /dev/null
+++ clang/test/CodeGen/builtins-ppc-fma.c
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -triple powerpc64le-gnu-linux \
+// RUN: -target-feature +altivec -Wall -Wno-unused -Werror -emit-llvm %s -o - | FileCheck  \
+// RUN: %s
+
+typedef __attribute__((vector_size(4 * sizeof(float float vec_float;
+typedef __attribute__((vector_size(2 * sizeof(double double vec_double;
+
+volatile vec_double vd;
+volatile vec_float vf;
+
+void test_fma(void) {
+  vf = __builtin_vsx_xvmaddasp(vf, vf, vf);
+  // CHECK: @llvm.fma.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}})
+

[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

In D77313#1957690 , @efriedma wrote:

> I think I would rather just pay the extra 8 bytes per VectorType, and expand 
> this to support all vector types supported by LLVM.  It's not like we 
> allocate enough VectorTypes for it to matter, anyway.


llvm::VectorType seems to accept arbitrary `unsigned` size, so IIUC you'd 
suggest putting just putting `unsigned NumElements` in `VectorType`, which 
would cost 4 bytes and another 4 in padding. 
Sounds reasonable to me, I'll try that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77313



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


[PATCH] D76184: [OpenMP][NFC] Remove the need to include `OpenMPClause.h`

2020-04-02 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In D76184#1956352 , @jdoerfert wrote:

> @rnk What is the plan for this one now? Should I abandon it?


Sorry, I got distracted. I tried reapplying it but it didn't apply cleanly. 
It's possible I hadn't locally applied your patch series correctly when I said 
it wasn't compiling. If you can get clang (and clangd and clang-tools-extra) to 
compile with your change, feel free to push.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76184



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


[PATCH] D76594: [clang][AST] Support AST files larger than 512M

2020-04-02 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith resigned from this revision.
dexonsmith added a reviewer: Bigcheese.
dexonsmith added a subscriber: Bigcheese.
dexonsmith added a comment.
Herald added a subscriber: dexonsmith.



In D76594#1957452 , @DmitryPolukhin 
wrote:

> @rsmith, @dexonsmith, @jdoerfert could you please take a look to this diff?
>  If you think that there are other reviewers who might have more context AST 
> persistence, please add them.


@Bigcheese, can you take a look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76594



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


[clang] a16ba6f - Reland "Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang"

2020-04-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-04-02T16:12:03-04:00
New Revision: a16ba6fea2e554fae465dcaaca1d687d8e83a62e

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

LOG: Reland "Make it possible for lit.site.cfg to contain relative paths, and 
use it for llvm and clang"

The problem on Windows was that the \b in "..\bin" was interpreted
as an escape sequence. Use r"" strings to prevent that.

This reverts commit ab11b9eefa16661017c2c7b3b34c46b069f43fb7,
with raw strings in the lit.site.cfg.py.in files.

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

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/Unit/lit.site.cfg.py.in
clang/test/lit.site.cfg.py.in
llvm/cmake/modules/AddLLVM.cmake
llvm/test/CMakeLists.txt
llvm/test/Unit/lit.site.cfg.py.in
llvm/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index d453074d7926..ca326fea8066 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -35,6 +35,16 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  PATHS
+  "LLVM_SOURCE_DIR"
+  "LLVM_BINARY_DIR"
+  "LLVM_TOOLS_DIR"
+  "LLVM_LIBS_DIR"
+  "SHLIBDIR"
+  "LLVM_LIT_TOOLS_DIR"
+  "CLANG_BINARY_DIR"
+  "CLANG_SOURCE_DIR"
+  "CLANG_TOOLS_DIR"
   )
 
 configure_lit_site_cfg(
@@ -42,6 +52,13 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
+  PATHS
+  "LLVM_SOURCE_DIR"
+  "LLVM_BINARY_DIR"
+  "LLVM_TOOLS_DIR"
+  "LLVM_LIBS_DIR"
+  "CLANG_BINARY_DIR"
+  "SHLIBDIR"
   )
 
 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)

diff  --git a/clang/test/Unit/lit.site.cfg.py.in 
b/clang/test/Unit/lit.site.cfg.py.in
index 715b4d93f58f..ad5e6d0c8b2a 100644
--- a/clang/test/Unit/lit.site.cfg.py.in
+++ b/clang/test/Unit/lit.site.cfg.py.in
@@ -2,14 +2,14 @@
 
 import sys
 
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.clang_obj_root = "@CLANG_BINARY_DIR@"
+config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
 config.enable_shared = @ENABLE_SHARED@
-config.shlibdir = "@SHLIBDIR@"
+config.shlibdir = path(r"@SHLIBDIR@")
 config.target_triple = "@TARGET_TRIPLE@"
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
@@ -25,4 +25,5 @@ except KeyError:
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/Unit/lit.cfg.py")
+lit_config.load_config(
+config, os.path.join(path(r"@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py"))

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 62616d9a2b95..daec694bd128 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -2,16 +2,16 @@
 
 import sys
 
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
-config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@")
+config.llvm_shlib_dir = path(r"@SHLIBDIR@")
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
-config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
-config.clang_obj_root = "@CLANG_BINARY_DIR@"
-config.clang_src_dir = "@CLANG_SOURCE_DIR@"
-config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
+config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@")
+config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
+config.clang_src_dir = path(r"@CLANG_SOURCE_DIR@")
+config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@")
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
@@ -50,4 +50,5 @@ if not "@CLANG_DEFAULT_LINKER@":
 config.available_features.add('platform-linker')
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/lit.cfg.py")
+lit_config.load_config(
+config, os.path.join(config.clang_src_dir, "test/lit.cfg.py"))

diff  --git 

[PATCH] D77062: [analyzer] Added check for unaccaptable equality operation between Loc and NonLoc types

2020-04-02 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 254605.

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

https://reviews.llvm.org/D77062

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/test/Analysis/string.c


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char 
*)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, ); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -266,13 +266,16 @@
 std::pair
 CStringChecker::assumeZero(CheckerContext , ProgramStateRef state, SVal V,
QualType Ty) {
+  auto states = std::make_pair(state, state);
+
+  // LazyCompoundVal cannot be handled by assume
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val && !V.getAs()) {
+ // return pair shall be {null, non-null} so reorder states
+ std::tie(states.second, states.first) = state->assume(*val);
+  }
 
-  SValBuilder  = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext ,


Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -363,6 +363,14 @@
 strcpy(x, y); // no-warning
 }
 
+void *func_strcpy_no_assertion();
+char ***ptr_strcpy_no_assertion;
+void strcpy_no_assertion() {
+  *(unsigned char **)ptr_strcpy_no_assertion = (unsigned char *)(func_strcpy_no_assertion());
+  char c;
+  strcpy(**ptr_strcpy_no_assertion, ); // no-assertion
+}
+
 //===--===
 // stpcpy()
 //===--===
Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -266,13 +266,16 @@
 std::pair
 CStringChecker::assumeZero(CheckerContext , ProgramStateRef state, SVal V,
QualType Ty) {
+  auto states = std::make_pair(state, state);
+
+  // LazyCompoundVal cannot be handled by assume
   Optional val = V.getAs();
-  if (!val)
-return std::pair(state, state);
+  if (val && !V.getAs()) {
+ // return pair shall be {null, non-null} so reorder states
+ std::tie(states.second, states.first) = state->assume(*val);
+  }
 
-  SValBuilder  = C.getSValBuilder();
-  DefinedOrUnknownSVal zero = svalBuilder.makeZeroVal(Ty);
-  return state->assume(svalBuilder.evalEQ(state, *val, zero));
+  return states;
 }
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D76794: [Matrix] Implement * binary operator for MatrixType.

2020-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 254601.
fhahn added a comment.

Implement conversion for matrix/scalar variants.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76794

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -33,6 +33,19 @@
   IRBuilderTy 
   Module *getModule() { return B.GetInsertBlock()->getParent()->getParent(); }
 
+  std::pair splatScalarOperandIfNeeded(Value *LHS, Value *RHS) {
+assert((LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy()) && "One of the operands must be a matrix (embedded in a vector)");
+if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
+  RHS = B.CreateVectorSplat(
+  cast(LHS->getType())->getNumElements(), RHS,
+  "scalar.splat");
+else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
+  LHS = B.CreateVectorSplat(
+  cast(RHS->getType())->getNumElements(), LHS,
+  "scalar.splat");
+return {LHS, RHS};
+}
+
 public:
   MatrixBuilder(IRBuilderTy ) : B(Builder) {}
 
@@ -127,16 +140,7 @@
   /// Add matrixes \p LHS and \p RHS. Support both integer and floating point
   /// matrixes.
   Value *CreateAdd(Value *LHS, Value *RHS) {
-assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
-if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
-  RHS = B.CreateVectorSplat(
-  cast(LHS->getType())->getNumElements(), RHS,
-  "scalar.splat");
-else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
-  LHS = B.CreateVectorSplat(
-  cast(RHS->getType())->getNumElements(), LHS,
-  "scalar.splat");
-
+std::tie(LHS, RHS) = splatScalarOperandIfNeeded(LHS, RHS);
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
@@ -147,16 +151,7 @@
   /// Subtract matrixes \p LHS and \p RHS. Support both integer and floating
   /// point matrixes.
   Value *CreateSub(Value *LHS, Value *RHS) {
-assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
-if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
-  RHS = B.CreateVectorSplat(
-  cast(LHS->getType())->getNumElements(), RHS,
-  "scalar.splat");
-else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
-  LHS = B.CreateVectorSplat(
-  cast(RHS->getType())->getNumElements(), LHS,
-  "scalar.splat");
-
+std::tie(LHS, RHS) = splatScalarOperandIfNeeded(LHS, RHS);
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
@@ -164,15 +159,13 @@
: B.CreateSub(LHS, RHS);
   }
 
-  /// Multiply matrix \p LHS with scalar \p RHS.
+  /// Multiply matrix \p LHS with scalar \p RHS or scalar \p LHS with matrix \p
+  /// RHS.
   Value *CreateScalarMultiply(Value *LHS, Value *RHS) {
-Value *ScalarVector =
-B.CreateVectorSplat(cast(LHS->getType())->getNumElements(),
-RHS, "scalar.splat");
-if (RHS->getType()->isFloatingPointTy())
-  return B.CreateFMul(LHS, ScalarVector);
-
-return B.CreateMul(LHS, ScalarVector);
+std::tie(LHS, RHS) = splatScalarOperandIfNeeded(LHS, RHS);
+if (LHS->getType()->getScalarType()->isFloatingPointTy())
+return B.CreateFMul(LHS, RHS);
+return B.CreateMul(LHS, RHS);
   }
 
   /// Extracts the element at (\p Row, \p Column) from \p Matrix.
Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- clang/test/SemaCXX/matrix-type-operators.cpp
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -129,3 +129,26 @@
   Mat1.value = subtract(Mat2, Mat3);
   // expected-note@-1 {{in instantiation of function template specialization 'subtract' requested here}}
 }
+
+template 
+typename MyMatrix::matrix_t multiply(MyMatrix , MyMatrix ) {
+  char *v1 = A.value * B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(2, 2)))'}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+
+  return A.value * B.value;
+  // expected-error@-1 {{invalid operands to binary expression 

[PATCH] D76794: [Matrix] Implement * binary operator for MatrixType.

2020-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 254602.
fhahn added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76794

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -33,6 +33,21 @@
   IRBuilderTy 
   Module *getModule() { return B.GetInsertBlock()->getParent()->getParent(); }
 
+  std::pair splatScalarOperandIfNeeded(Value *LHS,
+ Value *RHS) {
+assert((LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy()) &&
+   "One of the operands must be a matrix (embedded in a vector)");
+if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
+  RHS = B.CreateVectorSplat(
+  cast(LHS->getType())->getNumElements(), RHS,
+  "scalar.splat");
+else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
+  LHS = B.CreateVectorSplat(
+  cast(RHS->getType())->getNumElements(), LHS,
+  "scalar.splat");
+return {LHS, RHS};
+  }
+
 public:
   MatrixBuilder(IRBuilderTy ) : B(Builder) {}
 
@@ -127,16 +142,7 @@
   /// Add matrixes \p LHS and \p RHS. Support both integer and floating point
   /// matrixes.
   Value *CreateAdd(Value *LHS, Value *RHS) {
-assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
-if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
-  RHS = B.CreateVectorSplat(
-  cast(LHS->getType())->getNumElements(), RHS,
-  "scalar.splat");
-else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
-  LHS = B.CreateVectorSplat(
-  cast(RHS->getType())->getNumElements(), LHS,
-  "scalar.splat");
-
+std::tie(LHS, RHS) = splatScalarOperandIfNeeded(LHS, RHS);
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
@@ -147,16 +153,7 @@
   /// Subtract matrixes \p LHS and \p RHS. Support both integer and floating
   /// point matrixes.
   Value *CreateSub(Value *LHS, Value *RHS) {
-assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
-if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
-  RHS = B.CreateVectorSplat(
-  cast(LHS->getType())->getNumElements(), RHS,
-  "scalar.splat");
-else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
-  LHS = B.CreateVectorSplat(
-  cast(RHS->getType())->getNumElements(), LHS,
-  "scalar.splat");
-
+std::tie(LHS, RHS) = splatScalarOperandIfNeeded(LHS, RHS);
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
@@ -164,15 +161,13 @@
: B.CreateSub(LHS, RHS);
   }
 
-  /// Multiply matrix \p LHS with scalar \p RHS.
+  /// Multiply matrix \p LHS with scalar \p RHS or scalar \p LHS with matrix \p
+  /// RHS.
   Value *CreateScalarMultiply(Value *LHS, Value *RHS) {
-Value *ScalarVector =
-B.CreateVectorSplat(cast(LHS->getType())->getNumElements(),
-RHS, "scalar.splat");
-if (RHS->getType()->isFloatingPointTy())
-  return B.CreateFMul(LHS, ScalarVector);
-
-return B.CreateMul(LHS, ScalarVector);
+std::tie(LHS, RHS) = splatScalarOperandIfNeeded(LHS, RHS);
+if (LHS->getType()->getScalarType()->isFloatingPointTy())
+  return B.CreateFMul(LHS, RHS);
+return B.CreateMul(LHS, RHS);
   }
 
   /// Extracts the element at (\p Row, \p Column) from \p Matrix.
Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- clang/test/SemaCXX/matrix-type-operators.cpp
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -129,3 +129,26 @@
   Mat1.value = subtract(Mat2, Mat3);
   // expected-note@-1 {{in instantiation of function template specialization 'subtract' requested here}}
 }
+
+template 
+typename MyMatrix::matrix_t multiply(MyMatrix , MyMatrix ) {
+  char *v1 = A.value * B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int __attribute__((matrix_type(2, 2)))'}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+
+  return A.value * B.value;
+  // expected-error@-1 {{invalid operands 

[PATCH] D76793: [Matrix] Implement + and - operators for MatrixType.

2020-04-02 Thread Florian Hahn via Phabricator via cfe-commits
fhahn updated this revision to Diff 254598.
fhahn added a comment.

Implement conversions for matrix/scalar variants.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76793

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/matrix-type-operators.c
  clang/test/CodeGenCXX/matrix-type-operators.cpp
  clang/test/Sema/matrix-type-operators.c
  clang/test/SemaCXX/matrix-type-operators.cpp
  llvm/include/llvm/IR/MatrixBuilder.h

Index: llvm/include/llvm/IR/MatrixBuilder.h
===
--- llvm/include/llvm/IR/MatrixBuilder.h
+++ llvm/include/llvm/IR/MatrixBuilder.h
@@ -127,6 +127,16 @@
   /// Add matrixes \p LHS and \p RHS. Support both integer and floating point
   /// matrixes.
   Value *CreateAdd(Value *LHS, Value *RHS) {
+assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
+if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
+  RHS = B.CreateVectorSplat(
+  cast(LHS->getType())->getNumElements(), RHS,
+  "scalar.splat");
+else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
+  LHS = B.CreateVectorSplat(
+  cast(RHS->getType())->getNumElements(), LHS,
+  "scalar.splat");
+
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
@@ -137,6 +147,16 @@
   /// Subtract matrixes \p LHS and \p RHS. Support both integer and floating
   /// point matrixes.
   Value *CreateSub(Value *LHS, Value *RHS) {
+assert(LHS->getType()->isVectorTy() || RHS->getType()->isVectorTy());
+if (LHS->getType()->isVectorTy() && !RHS->getType()->isVectorTy())
+  RHS = B.CreateVectorSplat(
+  cast(LHS->getType())->getNumElements(), RHS,
+  "scalar.splat");
+else if (!LHS->getType()->isVectorTy() && RHS->getType()->isVectorTy())
+  LHS = B.CreateVectorSplat(
+  cast(RHS->getType())->getNumElements(), LHS,
+  "scalar.splat");
+
 return cast(LHS->getType())
->getElementType()
->isFloatingPointTy()
Index: clang/test/SemaCXX/matrix-type-operators.cpp
===
--- clang/test/SemaCXX/matrix-type-operators.cpp
+++ clang/test/SemaCXX/matrix-type-operators.cpp
@@ -66,3 +66,66 @@
   a[2] = f;
   // expected-error@-1 {{single subscript expressions are not allowed for matrix values}}
 }
+
+template 
+struct MyMatrix {
+  using matrix_t = EltTy __attribute__((matrix_type(Rows, Columns)));
+
+  matrix_t value;
+};
+
+template 
+typename MyMatrix::matrix_t add(MyMatrix , MyMatrix ) {
+  char *v1 = A.value + B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))'))}}
+  // expected-error@-3 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+
+  return A.value + B.value;
+  // expected-error@-1 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))') and 'MyMatrix::matrix_t' (aka 'float __attribute__((matrix_type(2, 2)))'))}}
+  // expected-error@-2 {{invalid operands to binary expression ('MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))') and 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(3, 3)))'))}}
+}
+
+void test_add_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  MyMatrix Mat3;
+  Mat1.value = *((decltype(Mat1)::matrix_t *)Ptr1);
+  unsigned v1 = add(Mat1, Mat1);
+  // expected-error@-1 {{cannot initialize a variable of type 'unsigned int' with an rvalue of type 'typename MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // expected-note@-2 {{in instantiation of function template specialization 'add' requested here}}
+
+  Mat1.value = add(Mat1, Mat2);
+  // expected-note@-1 {{in instantiation of function template specialization 'add' requested here}}
+
+  Mat1.value = add(Mat2, Mat3);
+  // expected-note@-1 {{in instantiation of function template specialization 'add' requested here}}
+}
+
+template 
+typename MyMatrix::matrix_t subtract(MyMatrix , MyMatrix ) {
+  char *v1 = A.value - B.value;
+  // expected-error@-1 {{cannot initialize a variable of type 'char *' with an rvalue of type 'MyMatrix::matrix_t' (aka 'unsigned int __attribute__((matrix_type(2, 2)))')}}
+  // 

[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 254591.
arsenm added a comment.

Correct group


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/hip.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1010.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1011.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1012.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -99,9 +99,9 @@
   {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
+  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
 };
 
 const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef Table) {
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -151,7 +151,10 @@
 
   // Common features.
   FEATURE_FAST_FMA_F32 = 1 << 4,
-  FEATURE_FAST_DENORMAL_F32 = 1 << 5
+  FEATURE_FAST_DENORMAL_F32 = 1 << 5,
+
+  // Wavefront 32 is available.
+  FEATURE_WAVE32 = 1 << 6
 };
 
 StringRef getArchNameAMDGCN(GPUKind AK);
Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nogpulib was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
+
+// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,163 @@
+// REQUIRES: clang-driver
+// REQUIRES: 

[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-02 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec accepted this revision.
rampitec added a comment.
This revision is now accepted and ready to land.

Thanks.

Could you also update AMDGPUTargetInfo::GCCRegNames[] (in a separate change)? 
It is used in clobber constraints.
JBTW, it does not support register tuples even for V and S now.


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

https://reviews.llvm.org/D77329



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


[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl:11-14
+  float acc_c;
+  float reg_a;
+  float reg_b;
+  float reg_c;

These mostly aren't the right types?


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

https://reviews.llvm.org/D77329



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-02 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 254584.
arsenm added a comment.

Rebase


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

https://reviews.llvm.org/D59321

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/HIP.cpp
  clang/lib/Driver/ToolChains/HIP.h
  clang/test/CodeGenOpenCL/amdgpu-debug-info-pointer-address-space.cl
  clang/test/CodeGenOpenCL/amdgpu-debug-info-variable-expression.cl
  clang/test/Driver/Inputs/rocm-device-libs/lib/hip.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ockl.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_correctly_rounded_sqrt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_daz_opt_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_finite_only_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1010.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1011.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_1012.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_803.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_isa_version_900.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_off.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_unsafe_math_on.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_off.amdgcn.bc
  
clang/test/Driver/Inputs/rocm-device-libs/lib/oclc_wavefrontsize64_on.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/ocml.amdgcn.bc
  clang/test/Driver/Inputs/rocm-device-libs/lib/opencl.amdgcn.bc
  clang/test/Driver/amdgpu-visibility.cl
  clang/test/Driver/rocm-detect.cl
  clang/test/Driver/rocm-device-libs.cl
  clang/test/Driver/rocm-not-found.cl
  llvm/include/llvm/Support/TargetParser.h
  llvm/lib/Support/TargetParser.cpp

Index: llvm/lib/Support/TargetParser.cpp
===
--- llvm/lib/Support/TargetParser.cpp
+++ llvm/lib/Support/TargetParser.cpp
@@ -99,9 +99,9 @@
   {{"gfx906"},{"gfx906"},  GK_GFX906,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx908"},{"gfx908"},  GK_GFX908,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
   {{"gfx909"},{"gfx909"},  GK_GFX909,  FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
-  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32},
+  {{"gfx1010"},   {"gfx1010"}, GK_GFX1010, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1011"},   {"gfx1011"}, GK_GFX1011, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
+  {{"gfx1012"},   {"gfx1012"}, GK_GFX1012, FEATURE_FAST_FMA_F32|FEATURE_FAST_DENORMAL_F32|FEATURE_WAVE32},
 };
 
 const GPUInfo *getArchEntry(AMDGPU::GPUKind AK, ArrayRef Table) {
Index: llvm/include/llvm/Support/TargetParser.h
===
--- llvm/include/llvm/Support/TargetParser.h
+++ llvm/include/llvm/Support/TargetParser.h
@@ -151,7 +151,10 @@
 
   // Common features.
   FEATURE_FAST_FMA_F32 = 1 << 4,
-  FEATURE_FAST_DENORMAL_F32 = 1 << 5
+  FEATURE_FAST_DENORMAL_F32 = 1 << 5,
+
+  // Wavefront 32 is available.
+  FEATURE_WAVE32 = 1 << 6
 };
 
 StringRef getArchNameAMDGCN(GPUKind AK);
Index: clang/test/Driver/rocm-not-found.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-not-found.cl
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+
+// Check that we raise an error if we're trying to compile OpenCL for amdhsa code but can't
+// find a ROCm install, unless -nogpulib was passed.
+
+// RUN: %clang -### --sysroot=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// RUN: %clang -### --rocm-path=%s/no-rocm-there -target amdgcn--amdhsa %s 2>&1 | FileCheck %s --check-prefix ERR
+// ERR: cannot find ROCm installation. Provide its path via --rocm-path, or pass -nogpulib.
+
+// RUN: %clang -### -nogpulib --rocm-path=%s/no-rocm-there %s 2>&1 | FileCheck %s --check-prefix OK
+// OK-NOT: cannot find ROCm installation.
Index: clang/test/Driver/rocm-device-libs.cl
===
--- /dev/null
+++ clang/test/Driver/rocm-device-libs.cl
@@ -0,0 +1,163 @@
+// REQUIRES: clang-driver
+// REQUIRES: 

[PATCH] D77329: [AMDGPU] Allow AGPR in inline asm

2020-04-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: rampitec, arsenm.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, nhaehnle, wdng, 
jvesely, kzhuravl.
rampitec accepted this revision.
rampitec added a comment.
This revision is now accepted and ready to land.

Thanks.

Could you also update AMDGPUTargetInfo::GCCRegNames[] (in a separate change)? 
It is used in clobber constraints.
JBTW, it does not support register tuples even for V and S now.




Comment at: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl:11-14
+  float acc_c;
+  float reg_a;
+  float reg_b;
+  float reg_c;

These mostly aren't the right types?


https://reviews.llvm.org/D77329

Files:
  clang/lib/Basic/Targets/AMDGPU.h
  clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl


Index: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -1,8 +1,21 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -o - -triple amdgcn %s | FileCheck %s
 
 kernel void test_long(int arg0) {
   long v15_16;
-  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", 
"={v[15:16]},v"(i32 %arg0)
+  // CHECK: call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", 
"={v[15:16]},v"
   __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : 
"v"(arg0));
 }
+
+kernel void test_agpr() {
+  float acc_c;
+  float reg_a;
+  float reg_b;
+  float reg_c;
+  // CHECK: call float asm "v_mfma_f32_32x32x1f32 $0, $1, $2, $3", "=a,v,v,a"
+  __asm ("v_mfma_f32_32x32x1f32 %0, %1, %2, %3" : "=a"(acc_c) : "v"(reg_a), 
"v"(reg_b), "a"(acc_c));
+  // CHECK: call float asm sideeffect "v_mfma_f32_32x32x1f32 a[0:31], $0, $1, 
a[0:31]", "={a[0:31]},v,v,{a[0:31]}"
+  __asm volatile("v_mfma_f32_32x32x1f32 a[0:31], %0, %1, a[0:31]" : 
"={a[0:31]}"(acc_c) : "v"(reg_a),"v"(reg_b), "{a[0:31]}"(acc_c));
+  // CHECK: call float asm "v_accvgpr_read_b32 $0, $1", "={a1},{a1}"
+  __asm ("v_accvgpr_read_b32 %0, %1" : "={a1}"(reg_c) : "{a1}"(acc_c));
+}
\ No newline at end of file
Index: clang/lib/Basic/Targets/AMDGPU.h
===
--- clang/lib/Basic/Targets/AMDGPU.h
+++ clang/lib/Basic/Targets/AMDGPU.h
@@ -114,11 +114,14 @@
   /// Accepted register names: (n, m is unsigned integer, n < m)
   /// v
   /// s
+  /// a
   /// {vn}, {v[n]}
   /// {sn}, {s[n]}
+  /// {an}, {a[n]}
   /// {S} , where S is a special register name
   {v[n:m]}
   /// {s[n:m]}
+  /// {a[n:m]}
   bool validateAsmConstraint(const char *,
  TargetInfo::ConstraintInfo ) const override {
 static const ::llvm::StringSet<> SpecialRegs({
@@ -135,7 +138,7 @@
 }
 if (S.empty())
   return false;
-if (S.front() != 'v' && S.front() != 's') {
+if (S.front() != 'v' && S.front() != 's' && S.front() != 'a') {
   if (!HasLeftParen)
 return false;
   auto E = S.find('}');
@@ -153,7 +156,7 @@
 if (!HasLeftParen) {
   if (!S.empty())
 return false;
-  // Found s or v.
+  // Found s, v or a.
   Info.setAllowsRegister();
   Name = S.data() - 1;
   return true;
@@ -184,7 +187,8 @@
 S = S.drop_front();
 if (!S.empty())
   return false;
-// Found {vn}, {sn}, {v[n]}, {s[n]}, {v[n:m]}, or {s[n:m]}.
+// Found {vn}, {sn}, {an}, {v[n]}, {s[n]}, {a[n]}, {v[n:m]}, {s[n:m]}
+// or {a[n:m]}.
 Info.setAllowsRegister();
 Name = S.data() - 1;
 return true;


Index: clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
+++ clang/test/CodeGenOpenCL/inline-asm-amdgcn.cl
@@ -1,8 +1,21 @@
 // REQUIRES: amdgpu-registered-target
-// RUN: %clang_cc1 -emit-llvm -o - -triple amdgcn %s | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -O0 -o - -triple amdgcn %s | FileCheck %s
 
 kernel void test_long(int arg0) {
   long v15_16;
-  // CHECK: tail call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"(i32 %arg0)
+  // CHECK: call i64 asm sideeffect "v_lshlrev_b64 v[15:16], 0, $0", "={v[15:16]},v"
   __asm volatile("v_lshlrev_b64 v[15:16], 0, %0" : "={v[15:16]}"(v15_16) : "v"(arg0));
 }
+
+kernel void test_agpr() {
+  float acc_c;
+  float reg_a;
+  float reg_b;
+  float reg_c;
+  // CHECK: call float asm "v_mfma_f32_32x32x1f32 $0, $1, $2, $3", "=a,v,v,a"
+  __asm ("v_mfma_f32_32x32x1f32 %0, %1, %2, %3" : "=a"(acc_c) : "v"(reg_a), "v"(reg_b), "a"(acc_c));
+  // CHECK: call float asm sideeffect "v_mfma_f32_32x32x1f32 a[0:31], $0, $1, a[0:31]", "={a[0:31]},v,v,{a[0:31]}"
+  __asm volatile("v_mfma_f32_32x32x1f32 a[0:31], %0, %1, a[0:31]" : "={a[0:31]}"(acc_c) : "v"(reg_a),"v"(reg_b), "{a[0:31]}"(acc_c));
+  // CHECK: call float asm 

[clang] ab11b9e - Revert "Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang"

2020-04-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-04-02T15:00:09-04:00
New Revision: ab11b9eefa16661017c2c7b3b34c46b069f43fb7

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

LOG: Revert "Make it possible for lit.site.cfg to contain relative paths, and 
use it for llvm and clang"

This reverts commit fb80b6b2d58c476747a3206bd4371b787108591b and
follow-up 631ee8b24adf36359b61ecb47484e8e82de35be8.

Seems to not work on Windows:
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/31684
http://lab.llvm.org:8011/builders/llvm-clang-win-x-aarch64/builds/6512

Let's revert while I investigate.

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/Unit/lit.site.cfg.py.in
clang/test/lit.site.cfg.py.in
llvm/cmake/modules/AddLLVM.cmake
llvm/test/CMakeLists.txt
llvm/test/Unit/lit.site.cfg.py.in
llvm/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index ca326fea8066..d453074d7926 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -35,16 +35,6 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
-  PATHS
-  "LLVM_SOURCE_DIR"
-  "LLVM_BINARY_DIR"
-  "LLVM_TOOLS_DIR"
-  "LLVM_LIBS_DIR"
-  "SHLIBDIR"
-  "LLVM_LIT_TOOLS_DIR"
-  "CLANG_BINARY_DIR"
-  "CLANG_SOURCE_DIR"
-  "CLANG_TOOLS_DIR"
   )
 
 configure_lit_site_cfg(
@@ -52,13 +42,6 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
-  PATHS
-  "LLVM_SOURCE_DIR"
-  "LLVM_BINARY_DIR"
-  "LLVM_TOOLS_DIR"
-  "LLVM_LIBS_DIR"
-  "CLANG_BINARY_DIR"
-  "SHLIBDIR"
   )
 
 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)

diff  --git a/clang/test/Unit/lit.site.cfg.py.in 
b/clang/test/Unit/lit.site.cfg.py.in
index 400a9c05e58c..715b4d93f58f 100644
--- a/clang/test/Unit/lit.site.cfg.py.in
+++ b/clang/test/Unit/lit.site.cfg.py.in
@@ -2,14 +2,14 @@
 
 import sys
 
-config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
-config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
-config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
-config.llvm_libs_dir = path("@LLVM_LIBS_DIR@")
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.clang_obj_root = path("@CLANG_BINARY_DIR@")
+config.clang_obj_root = "@CLANG_BINARY_DIR@"
 config.enable_shared = @ENABLE_SHARED@
-config.shlibdir = path("@SHLIBDIR@")
+config.shlibdir = "@SHLIBDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
@@ -25,5 +25,4 @@ except KeyError:
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
 
 # Let the main config do the real work.
-lit_config.load_config(
-config, os.path.join(path("@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py"))
+lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/Unit/lit.cfg.py")

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 84dd0f8846cf..62616d9a2b95 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -2,16 +2,16 @@
 
 import sys
 
-config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
-config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
-config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
-config.llvm_libs_dir = path("@LLVM_LIBS_DIR@")
-config.llvm_shlib_dir = path("@SHLIBDIR@")
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_shlib_dir = "@SHLIBDIR@"
 config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@"
-config.lit_tools_dir = path("@LLVM_LIT_TOOLS_DIR@")
-config.clang_obj_root = path("@CLANG_BINARY_DIR@")
-config.clang_src_dir = path("@CLANG_SOURCE_DIR@")
-config.clang_tools_dir = path("@CLANG_TOOLS_DIR@")
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.clang_obj_root = "@CLANG_BINARY_DIR@"
+config.clang_src_dir = "@CLANG_SOURCE_DIR@"
+config.clang_tools_dir = "@CLANG_TOOLS_DIR@"
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.host_cxx = "@CMAKE_CXX_COMPILER@"
@@ -50,5 +50,4 @@ if not "@CLANG_DEFAULT_LINKER@":
 config.available_features.add('platform-linker')
 
 # Let the main config do the real work.
-lit_config.load_config(
-config, os.path.join(config.clang_src_dir, "test/lit.cfg.py"))
+lit_config.load_config(config, 

[PATCH] D77054: [AArch64][SVE] Add SVE intrinsics for saturating add & subtract

2020-04-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

You should be able to refactor the patterns into the definitions of the 
multiclasses sve_int_bin_cons_arit_0 and sve_int_arith_imm0, to avoid repeating 
them four times.  (You might want to look at other places using null_frag in 
SVEInstrFormats.td for inspiration.)


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

https://reviews.llvm.org/D77054



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


[PATCH] D72872: [ObjC generics] Fix not inheriting type bounds in categories/extensions.

2020-04-02 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, sorry for the delay in reviewing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72872



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


[PATCH] D72959: Relative VTables ABI on Fuchsia

2020-04-02 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added inline comments.



Comment at: libcxxabi/src/private_typeinfo.cpp:617
 // Get (dynamic_ptr, dynamic_type) from static_ptr
+#ifndef __Fuchsia__
 void **vtable = *static_cast(static_ptr);

ldionne wrote:
> Please introduce a macro that generically expresses that relative vtables are 
> enabled, and explain what it is. You can then enable that macro only on 
> `__Fuchsia__`. I'd like to avoid freely adding platform-specific `#ifdef`s in 
> the code when it's easy to avoid.
I think the libcxxabi change should be separated from the compiler change 
entirely.
It will need more configuration issues resolved before it usefully lands.
Let's keep this change just for the pure compiler feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72959



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-04-02 Thread Anna Thomas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbf7a16a76871: [InlineFunction] Update valid return 
attributes at callsite within callee body (authored by anna).

Changed prior to commit:
  https://reviews.llvm.org/D76140?vs=254222=254573#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140

Files:
  llvm/lib/Transforms/Utils/InlineFunction.cpp
  llvm/test/Transforms/Inline/ret_attr_update.ll

Index: llvm/test/Transforms/Inline/ret_attr_update.ll
===
--- /dev/null
+++ llvm/test/Transforms/Inline/ret_attr_update.ll
@@ -0,0 +1,223 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+; RUN: opt < %s -inline-threshold=0 -always-inline -S | FileCheck %s
+; RUN: opt < %s -passes=always-inline -S | FileCheck %s
+
+declare i8* @foo(i8*) argmemonly nounwind
+
+define i8* @callee(i8 *%p) alwaysinline {
+; CHECK-LABEL: @callee(
+; CHECK-NEXT:[[R:%.*]] = call i8* @foo(i8* noalias [[P:%.*]])
+; CHECK-NEXT:ret i8* [[R]]
+;
+  %r = call i8* @foo(i8* noalias %p)
+  ret i8* %r
+}
+
+define i8* @caller(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call nonnull i8* @foo(i8* noalias [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee(i8* %gep)
+  ret i8* %p
+}
+
+declare void @llvm.experimental.guard(i1,...)
+; Cannot add nonnull attribute to foo
+; because the guard is a throwing call
+define internal i8* @callee_with_throwable(i8* %p) alwaysinline {
+  %r = call i8* @foo(i8* %p)
+  %cond = icmp ne i8* %r, null
+  call void (i1, ...) @llvm.experimental.guard(i1 %cond) [ "deopt"() ]
+  ret i8* %r
+}
+
+declare i8* @bar(i8*) readonly nounwind
+; Here also we cannot add nonnull attribute to the call bar.
+define internal i8* @callee_with_explicit_control_flow(i8* %p) alwaysinline {
+  %r = call i8* @bar(i8* %p)
+  %cond = icmp ne i8* %r, null
+  br i1 %cond, label %ret, label %orig
+
+ret:
+  ret i8* %r
+
+orig:
+  ret i8* %p
+}
+
+define i8* @caller2(i8* %ptr, i64 %x, i1 %cond) {
+; CHECK-LABEL: @caller2(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:[[COND_I:%.*]] = icmp ne i8* [[R_I]], null
+; CHECK-NEXT:call void (i1, ...) @llvm.experimental.guard(i1 [[COND_I]]) [ "deopt"() ]
+; CHECK-NEXT:[[R_I1:%.*]] = call i8* @bar(i8* [[GEP]])
+; CHECK-NEXT:[[COND_I2:%.*]] = icmp ne i8* [[R_I1]], null
+; CHECK-NEXT:br i1 [[COND_I2]], label [[RET_I:%.*]], label [[ORIG_I:%.*]]
+; CHECK:   ret.i:
+; CHECK-NEXT:br label [[CALLEE_WITH_EXPLICIT_CONTROL_FLOW_EXIT:%.*]]
+; CHECK:   orig.i:
+; CHECK-NEXT:br label [[CALLEE_WITH_EXPLICIT_CONTROL_FLOW_EXIT]]
+; CHECK:   callee_with_explicit_control_flow.exit:
+; CHECK-NEXT:[[Q3:%.*]] = phi i8* [ [[R_I1]], [[RET_I]] ], [ [[GEP]], [[ORIG_I]] ]
+; CHECK-NEXT:br i1 [[COND:%.*]], label [[PRET:%.*]], label [[QRET:%.*]]
+; CHECK:   pret:
+; CHECK-NEXT:ret i8* [[R_I]]
+; CHECK:   qret:
+; CHECK-NEXT:ret i8* [[Q3]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call nonnull i8* @callee_with_throwable(i8* %gep)
+  %q = call nonnull i8* @callee_with_explicit_control_flow(i8* %gep)
+  br i1 %cond, label %pret, label %qret
+
+pret:
+  ret i8* %p
+
+qret:
+  ret i8* %q
+}
+
+define internal i8* @callee3(i8 *%p) alwaysinline {
+  %r = call noalias i8* @foo(i8* %p)
+  ret i8* %r
+}
+
+; add the deref attribute to the existing attributes on foo.
+define i8* @caller3(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @caller3(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call noalias dereferenceable_or_null(12) i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call dereferenceable_or_null(12) i8* @callee3(i8* %gep)
+  ret i8* %p
+}
+
+declare i8* @inf_loop_call(i8*) nounwind
+; We cannot propagate attributes to foo because we do not know whether inf_loop_call
+; will return execution.
+define internal i8* @callee_with_sideeffect_callsite(i8* %p) alwaysinline {
+  %r = call i8* @foo(i8* %p)
+  %v = call i8* @inf_loop_call(i8* %p)
+  ret i8* %r
+}
+
+; do not add deref attribute to foo
+define i8* @test4(i8* %ptr, i64 %x) {
+; CHECK-LABEL: @test4(
+; CHECK-NEXT:[[GEP:%.*]] = getelementptr inbounds i8, i8* [[PTR:%.*]], i64 [[X:%.*]]
+; CHECK-NEXT:[[R_I:%.*]] = call i8* @foo(i8* [[GEP]])
+; CHECK-NEXT:[[V_I:%.*]] = call i8* @inf_loop_call(i8* [[GEP]])
+; CHECK-NEXT:ret i8* [[R_I]]
+;
+  %gep = getelementptr inbounds i8, i8* %ptr, i64 %x
+  %p = call 

[PATCH] D77184: Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang

2020-04-02 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfb80b6b2d58c: Make it possible for lit.site.cfg to contain 
relative paths, and use it for… (authored by thakis).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D77184?vs=254033=254572#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77184

Files:
  clang/test/CMakeLists.txt
  clang/test/Unit/lit.site.cfg.py.in
  clang/test/lit.site.cfg.py.in
  llvm/cmake/modules/AddLLVM.cmake
  llvm/test/CMakeLists.txt
  llvm/test/Unit/lit.site.cfg.py.in
  llvm/test/lit.site.cfg.py.in
  llvm/utils/gn/secondary/clang/test/BUILD.gn
  llvm/utils/gn/secondary/llvm/test/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/test/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/test/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/test/BUILD.gn
@@ -14,7 +14,10 @@
 input = invoker.input
 output = invoker.output
 values = [
-  "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
+  # FIXME: Write relative paths for path()s.
+  "LIT_SITE_CFG_IN_HEADER=" +
+  "## Autogenerated from $input, do not edit\n\n" +
+  "def path(p): return p if p else \"\"",
   "ENABLE_SHARED=0",
   "LLVM_BINARY_DIR=" +
   rebase_path(get_label_info("//llvm", "target_out_dir")),
Index: llvm/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/utils/gn/secondary/clang/test/BUILD.gn
@@ -12,7 +12,10 @@
 input = invoker.input
 output = invoker.output
 values = [
-  "LIT_SITE_CFG_IN_HEADER=## Autogenerated from $input, do not edit",
+  # FIXME: Write relative paths for path()s.
+  "LIT_SITE_CFG_IN_HEADER=" +
+  "## Autogenerated from $input, do not edit\n\n" +
+  "def path(p): return p if p else \"\"",
   "CLANG_BINARY_DIR=" +
   rebase_path(get_label_info("//clang", "target_out_dir")),
   "CLANG_SOURCE_DIR=" + rebase_path("//clang"),
Index: llvm/test/lit.site.cfg.py.in
===
--- llvm/test/lit.site.cfg.py.in
+++ llvm/test/lit.site.cfg.py.in
@@ -4,14 +4,14 @@
 
 config.host_triple = "@LLVM_HOST_TRIPLE@"
 config.target_triple = "@TARGET_TRIPLE@"
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_lib_dir = "@LLVM_LIBRARY_DIR@"
-config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
+config.llvm_lib_dir = path("@LLVM_LIBRARY_DIR@")
+config.llvm_shlib_dir = path("@SHLIBDIR@")
 config.llvm_shlib_ext = "@SHLIBEXT@"
 config.llvm_exe_ext = "@EXEEXT@"
-config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.lit_tools_dir = path("@LLVM_LIT_TOOLS_DIR@")
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.gold_executable = "@GOLD_EXECUTABLE@"
 config.ld64_executable = "@LD64_EXECUTABLE@"
@@ -63,4 +63,5 @@
 lit.llvm.initialize(lit_config, config)
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/lit.cfg.py")
+lit_config.load_config(
+config, os.path.join(config.llvm_src_root, "test/lit.cfg.py"))
Index: llvm/test/Unit/lit.site.cfg.py.in
===
--- llvm/test/Unit/lit.site.cfg.py.in
+++ llvm/test/Unit/lit.site.cfg.py.in
@@ -2,12 +2,12 @@
 
 import sys
 
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
 config.enable_shared = @ENABLE_SHARED@
-config.shlibdir = "@SHLIBDIR@"
+config.shlibdir = path("@SHLIBDIR@")
 
 # Support substitution of the tools_dir and build_mode with user parameters.
 # This is used when we can't determine the tool dir at configuration time.
@@ -20,4 +20,5 @@
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@LLVM_SOURCE_DIR@/test/Unit/lit.cfg.py")
+lit_config.load_config(
+config, os.path.join(config.llvm_src_root, "test/Unit/lit.cfg.py"))
Index: llvm/test/CMakeLists.txt
===
--- llvm/test/CMakeLists.txt
+++ llvm/test/CMakeLists.txt
@@ -22,12 +22,23 @@
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  PATHS
+  

[PATCH] D77257: Clean up usages of asserting vector getters in Type

2020-04-02 Thread Christopher Tetreault via Phabricator via cfe-commits
ctetreau updated this revision to Diff 254570.
ctetreau added a comment.

Note that this is NFC


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77257

Files:
  clang/lib/CodeGen/CGAtomic.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/PatternInit.cpp
  clang/lib/CodeGen/TargetInfo.cpp

Index: clang/lib/CodeGen/TargetInfo.cpp
===
--- clang/lib/CodeGen/TargetInfo.cpp
+++ clang/lib/CodeGen/TargetInfo.cpp
@@ -3054,7 +3054,7 @@
 // Don't pass vXi128 vectors in their native type, the backend can't
 // legalize them.
 if (passInt128VectorsInMem() &&
-IRType->getVectorElementType()->isIntegerTy(128)) {
+cast(IRType)->getElementType()->isIntegerTy(128)) {
   // Use a vXi64 vector.
   uint64_t Size = getContext().getTypeSize(Ty);
   return llvm::VectorType::get(llvm::Type::getInt64Ty(getVMContext()),
Index: clang/lib/CodeGen/PatternInit.cpp
===
--- clang/lib/CodeGen/PatternInit.cpp
+++ clang/lib/CodeGen/PatternInit.cpp
@@ -34,9 +34,11 @@
   constexpr bool NegativeNaN = true;
   constexpr uint64_t NaNPayload = 0xull;
   if (Ty->isIntOrIntVectorTy()) {
-unsigned BitWidth = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
-->getBitWidth();
+unsigned BitWidth =
+cast(
+Ty->isVectorTy() ? cast(Ty)->getElementType()
+ : Ty)
+->getBitWidth();
 if (BitWidth <= 64)
   return llvm::ConstantInt::get(Ty, IntValue);
 return llvm::ConstantInt::get(
@@ -44,7 +46,7 @@
   }
   if (Ty->isPtrOrPtrVectorTy()) {
 auto *PtrTy = cast(
-Ty->isVectorTy() ? Ty->getVectorElementType() : Ty);
+Ty->isVectorTy() ? cast(Ty)->getElementType() : Ty);
 unsigned PtrWidth = CGM.getContext().getTargetInfo().getPointerWidth(
 PtrTy->getAddressSpace());
 if (PtrWidth > 64)
@@ -55,7 +57,7 @@
   }
   if (Ty->isFPOrFPVectorTy()) {
 unsigned BitWidth = llvm::APFloat::semanticsSizeInBits(
-(Ty->isVectorTy() ? Ty->getVectorElementType() : Ty)
+(Ty->isVectorTy() ? cast(Ty)->getElementType() : Ty)
 ->getFltSemantics());
 llvm::APInt Payload(64, NaNPayload);
 if (BitWidth >= 64)
Index: clang/lib/CodeGen/CGExprScalar.cpp
===
--- clang/lib/CodeGen/CGExprScalar.cpp
+++ clang/lib/CodeGen/CGExprScalar.cpp
@@ -1306,7 +1306,7 @@
"Splatted expr doesn't match with vector element type?");
 
 // Splat the element across to all elements
-unsigned NumElements = DstTy->getVectorNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Src, "splat");
   }
 
@@ -1324,8 +1324,8 @@
 // short or half vector.
 
 // Source and destination are both expected to be vectors.
-llvm::Type *SrcElementTy = SrcTy->getVectorElementType();
-llvm::Type *DstElementTy = DstTy->getVectorElementType();
+llvm::Type *SrcElementTy = cast(SrcTy)->getElementType();
+llvm::Type *DstElementTy = cast(DstTy)->getElementType();
 (void)DstElementTy;
 
 assert(((SrcElementTy->isIntegerTy() &&
@@ -1691,8 +1691,8 @@
   assert(DstTy->isVectorTy() &&
  "ConvertVector destination IR type must be a vector");
 
-  llvm::Type *SrcEltTy = SrcTy->getVectorElementType(),
- *DstEltTy = DstTy->getVectorElementType();
+  llvm::Type *SrcEltTy = cast(SrcTy)->getElementType(),
+ *DstEltTy = cast(DstTy)->getElementType();
 
   if (DstEltType->isBooleanType()) {
 assert((SrcEltTy->isFloatingPointTy() ||
@@ -2219,7 +2219,7 @@
 llvm::Type *DstTy = ConvertType(DestTy);
 Value *Elt = Visit(const_cast(E));
 // Splat the element across to all elements
-unsigned NumElements = DstTy->getVectorNumElements();
+unsigned NumElements = cast(DstTy)->getNumElements();
 return Builder.CreateVectorSplat(NumElements, Elt, "splat");
   }
 
@@ -4545,7 +4545,8 @@
   // get a vec3.
   if (NumElementsSrc != 3 && NumElementsDst == 3) {
 if (!CGF.CGM.getCodeGenOpts().PreserveVec3Type) {
-  auto Vec4Ty = llvm::VectorType::get(DstTy->getVectorElementType(), 4);
+  auto Vec4Ty = llvm::VectorType::get(
+  cast(DstTy)->getElementType(), 4);
   Src = createCastsForTypeOfSameSize(Builder, CGF.CGM.getDataLayout(), Src,
  Vec4Ty);
 }
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2127,7 +2127,8 @@
 
   if (const VectorType *VTy = Dst.getType()->getAs()) {
 unsigned 

[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

I think I would rather just pay the extra 8 bytes per VectorType, and expand 
this to support all vector types supported by LLVM.  It's not like we allocate 
enough VectorTypes for it to matter, anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77313



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


[clang] fb80b6b - Make it possible for lit.site.cfg to contain relative paths, and use it for llvm and clang

2020-04-02 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-04-02T13:53:16-04:00
New Revision: fb80b6b2d58c476747a3206bd4371b787108591b

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

LOG: Make it possible for lit.site.cfg to contain relative paths, and use it 
for llvm and clang

Currently, all generated lit.site.cfg files contain absolute paths.

This makes it impossible to build on one machine, and then transfer the
build output to another machine for test execution. Being able to do
this is useful for several use cases:

1. When running tests on an ARM machine, it would be possible to build
   on a fast x86 machine and then copy build artifacts over after building.

2. It allows running several test suites (clang, llvm, lld) on 3
   different machines, reducing test time from sum(each test suite time) to
   max(each test suite time).

This patch makes it possible to pass a list of variables that should be
relative in the generated lit.site.cfg.py file to
configure_lit_site_cfg(). The lit.site.cfg.py.in file needs to call
`path()` on these variables, so that the paths are converted to absolute
form at lit start time.

The testers would have to have an LLVM checkout at the same revision,
and the build dir would have to be at the same relative path as on the
builder.

This does not yet cover how to figure out which files to copy from the
builder machine to the tester machines. (One idea is to look at the
`--graphviz=test.dot` output and copy all inputs of the `check-llvm`
target.)

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

Added: 


Modified: 
clang/test/CMakeLists.txt
clang/test/Unit/lit.site.cfg.py.in
clang/test/lit.site.cfg.py.in
llvm/cmake/modules/AddLLVM.cmake
llvm/test/CMakeLists.txt
llvm/test/Unit/lit.site.cfg.py.in
llvm/test/lit.site.cfg.py.in
llvm/utils/gn/secondary/clang/test/BUILD.gn
llvm/utils/gn/secondary/llvm/test/BUILD.gn

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index d453074d7926..ca326fea8066 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -35,6 +35,16 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py
+  PATHS
+  "LLVM_SOURCE_DIR"
+  "LLVM_BINARY_DIR"
+  "LLVM_TOOLS_DIR"
+  "LLVM_LIBS_DIR"
+  "SHLIBDIR"
+  "LLVM_LIT_TOOLS_DIR"
+  "CLANG_BINARY_DIR"
+  "CLANG_SOURCE_DIR"
+  "CLANG_TOOLS_DIR"
   )
 
 configure_lit_site_cfg(
@@ -42,6 +52,13 @@ configure_lit_site_cfg(
   ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py
   MAIN_CONFIG
   ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py
+  PATHS
+  "LLVM_SOURCE_DIR"
+  "LLVM_BINARY_DIR"
+  "LLVM_TOOLS_DIR"
+  "LLVM_LIBS_DIR"
+  "CLANG_BINARY_DIR"
+  "SHLIBDIR"
   )
 
 option(CLANG_TEST_USE_VG "Run Clang tests under Valgrind" OFF)

diff  --git a/clang/test/Unit/lit.site.cfg.py.in 
b/clang/test/Unit/lit.site.cfg.py.in
index 715b4d93f58f..400a9c05e58c 100644
--- a/clang/test/Unit/lit.site.cfg.py.in
+++ b/clang/test/Unit/lit.site.cfg.py.in
@@ -2,14 +2,14 @@
 
 import sys
 
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = path("@LLVM_LIBS_DIR@")
 config.llvm_build_mode = "@LLVM_BUILD_MODE@"
-config.clang_obj_root = "@CLANG_BINARY_DIR@"
+config.clang_obj_root = path("@CLANG_BINARY_DIR@")
 config.enable_shared = @ENABLE_SHARED@
-config.shlibdir = "@SHLIBDIR@"
+config.shlibdir = path("@SHLIBDIR@")
 config.target_triple = "@TARGET_TRIPLE@"
 
 # Support substitution of the tools_dir, libs_dirs, and build_mode with user
@@ -25,4 +25,5 @@ except KeyError:
 lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % 
(key,key))
 
 # Let the main config do the real work.
-lit_config.load_config(config, "@CLANG_SOURCE_DIR@/test/Unit/lit.cfg.py")
+lit_config.load_config(
+config, os.path.join(path("@CLANG_SOURCE_DIR@"), "test/Unit/lit.cfg.py"))

diff  --git a/clang/test/lit.site.cfg.py.in b/clang/test/lit.site.cfg.py.in
index 62616d9a2b95..84dd0f8846cf 100644
--- a/clang/test/lit.site.cfg.py.in
+++ b/clang/test/lit.site.cfg.py.in
@@ -2,16 +2,16 @@
 
 import sys
 
-config.llvm_src_root = "@LLVM_SOURCE_DIR@"
-config.llvm_obj_root = "@LLVM_BINARY_DIR@"
-config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
-config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
-config.llvm_shlib_dir = "@SHLIBDIR@"
+config.llvm_src_root = path("@LLVM_SOURCE_DIR@")
+config.llvm_obj_root = path("@LLVM_BINARY_DIR@")
+config.llvm_tools_dir = path("@LLVM_TOOLS_DIR@")
+config.llvm_libs_dir = 

[libunwind] 71fbd6e - Exit unwinding early when at the top of the stack and additional info won't be found.

2020-04-02 Thread Sterling Augustine via cfe-commits

Author: Sterling Augustine
Date: 2020-04-02T10:52:25-07:00
New Revision: 71fbd6e40632f437049215904c28ad9d63cff4bc

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

LOG: Exit unwinding early when at the top of the stack and additional info 
won't be found.

Summary:
This patch follows libgcc's lead: When the return-address register is
zero, there won't be additional stack frames to examine, or gather
information about. Exit before spending time looking for something
known not to be found.

Subscribers: llvm-commits

Tags: #llvm

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

Added: 


Modified: 
libunwind/src/UnwindCursor.hpp

Removed: 




diff  --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp
index e7fb70cc5718..32d71c2c1ed3 100644
--- a/libunwind/src/UnwindCursor.hpp
+++ b/libunwind/src/UnwindCursor.hpp
@@ -1848,6 +1848,12 @@ void UnwindCursor::setInfoBasedOnIPRegister(bool 
isReturnAddress) {
   pc &= (pint_t)~0x1;
 #endif
 
+  // Exit early if at the top of the stack.
+  if (pc == 0) {
+_unwindInfoMissing = true;
+return;
+  }
+
   // If the last line of a function is a "throw" the compiler sometimes
   // emits no instructions after the call to __cxa_throw.  This means
   // the return address is actually the start of the next function.



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


[PATCH] D75788: [OpenMP] Provide math functions in OpenMP device code via OpenMP variants

2020-04-02 Thread Ye Luo via Phabricator via cfe-commits
ye-luo added a comment.

My RHEL issue was caused by a CPLUS_INCLUDE_PATH environment variable. So this 
is feature not a bug. After removing it, everything works smoothly for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788



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


[PATCH] D70555: [coroutines] Don't build promise init with no args

2020-04-02 Thread Brian Gesiak via Phabricator via cfe-commits
modocache added a comment.

Of course, your approval is very welcome!  I'll go ahead and land this today, 
thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70555



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


[PATCH] D77054: [AArch64][SVE] Add SVE intrinsics for saturating add & subtract

2020-04-02 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 254558.
kmclaughlin added a comment.

Added patterns to AArch64SVEInstrInfo.td to support llvm.[s|u]add & 
llvm.[s|u]sub again, which was removed by my previous patch


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

https://reviews.llvm.org/D77054

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

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-int-arith.ll
@@ -134,6 +134,82 @@
   ret  %out
 }
 
+; SQADD
+
+define  @sqadd_i8( %a,  %b) {
+; CHECK-LABEL: sqadd_i8:
+; CHECK: sqadd z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqadd.x.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @sqadd_i16( %a,  %b) {
+; CHECK-LABEL: sqadd_i16:
+; CHECK: sqadd z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqadd.x.nxv8i16( %a,
+%b)
+  ret  %out
+}
+
+define  @sqadd_i32( %a,  %b) {
+; CHECK-LABEL: sqadd_i32:
+; CHECK: sqadd z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqadd.x.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+define  @sqadd_i64( %a,  %b) {
+; CHECK-LABEL: sqadd_i64:
+; CHECK: sqadd z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqadd.x.nxv2i64( %a,
+%b)
+  ret  %out
+}
+
+; SQSUB
+
+define  @sqsub_i8( %a,  %b) {
+; CHECK-LABEL: sqsub_i8:
+; CHECK: sqsub z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqsub.x.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @sqsub_i16( %a,  %b) {
+; CHECK-LABEL: sqsub_i16:
+; CHECK: sqsub z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqsub.x.nxv8i16( %a,
+%b)
+  ret  %out
+}
+
+define  @sqsub_i32( %a,  %b) {
+; CHECK-LABEL: sqsub_i32:
+; CHECK: sqsub z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqsub.x.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+define  @sqsub_i64( %a,  %b) {
+; CHECK-LABEL: sqsub_i64:
+; CHECK: sqsub z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.sqsub.x.nxv2i64( %a,
+%b)
+  ret  %out
+}
+
 ; UDOT
 
 define  @udot_i32( %a,  %b,  %c) {
@@ -169,6 +245,82 @@
   ret  %out
 }
 
+; UQADD
+
+define  @uqadd_i8( %a,  %b) {
+; CHECK-LABEL: uqadd_i8:
+; CHECK: uqadd z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqadd.x.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @uqadd_i16( %a,  %b) {
+; CHECK-LABEL: uqadd_i16:
+; CHECK: uqadd z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqadd.x.nxv8i16( %a,
+%b)
+  ret  %out
+}
+
+define  @uqadd_i32( %a,  %b) {
+; CHECK-LABEL: uqadd_i32:
+; CHECK: uqadd z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqadd.x.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+define  @uqadd_i64( %a,  %b) {
+; CHECK-LABEL: uqadd_i64:
+; CHECK: uqadd z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqadd.x.nxv2i64( %a,
+%b)
+  ret  %out
+}
+
+; UQSUB
+
+define  @uqsub_i8( %a,  %b) {
+; CHECK-LABEL: uqsub_i8:
+; CHECK: uqsub z0.b, z0.b, z1.b
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqsub.x.nxv16i8( %a,
+%b)
+  ret  %out
+}
+
+define  @uqsub_i16( %a,  %b) {
+; CHECK-LABEL: uqsub_i16:
+; CHECK: uqsub z0.h, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqsub.x.nxv8i16( %a,
+%b)
+  ret  %out
+}
+
+define  @uqsub_i32( %a,  %b) {
+; CHECK-LABEL: uqsub_i32:
+; CHECK: uqsub z0.s, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqsub.x.nxv4i32( %a,
+%b)
+  ret  %out
+}
+
+define  @uqsub_i64( %a,  %b) {
+; CHECK-LABEL: uqsub_i64:
+; CHECK: uqsub z0.d, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.uqsub.x.nxv2i64( %a,
+ 

[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-02 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

In D77311#1957367 , @jfb wrote:

> Some of these are technically "future reserved keywords": 
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords
>
> Wouldn't it be better to list all of JS's keywords at this point?


+1 to consider listing all of JS's keywords instead of listing all C++ keywords 
that are not JS keywords. With the current approach, any time a new C++ keyword 
token gets introduced, the switch in `IsJavaScriptIdentifier` would have to be 
updated.

But turning the implementation into something that lists JS keywords seems a 
bit tricky. Just a suggestion: maybe we can use the trick to #include 
TokenKinds.def 

 used in TokenKinds.h 
:

  bool IsJavaScriptIdentifier(const FormatToken ) const {
  switch (Tok.Tok.getKind()) {
// list all JS keywords defined as KEYWORD in TokenKinds.def
case tok::kw_break:
case tok::kw_case:
... 
case tok::kw_return:
return false;
  
// All of the remaining C keywords are JS identifiers.
#define KEYWORD(X,Y) case tok::kw_ ## X:
#include "clang/Basic/TokenKinds.def"
// #undef KEYWORD is not needed -- it's #undef-ed at the end of 
TokenKinds.def
return true;
  
// handle identifiers and everything else as in the patch.
case tok::identifier:
default: return false;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-04-02 Thread Anna Thomas via Phabricator via cfe-commits
anna added a comment.

In D76140#1957416 , @reames wrote:

> LGTM again, with minor change.


will update it.

> p.s. Sorry for missing the functional issue the first time.  All of the test 
> changes should have made the issue obvious, but despite reading the LangRef 
> description of signext, I somehow managed to miss the separation between ABI 
> and optimization attributes.

thanks for the review Philip and pointing out the problem. All of us had missed 
the functional issue the first time around.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D77085: [clang-tidy] Added support for validating configuration options

2020-04-02 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 254552.
njames93 added a comment.

- Small refactor


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77085

Files:
  clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/ClangTidyCheck.h
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -1,6 +1,8 @@
 #include "ClangTidyOptions.h"
-#include "gtest/gtest.h"
+#include "ClangTidyCheck.h"
+#include "ClangTidyDiagnosticConsumer.h"
 #include "llvm/ADT/StringExtras.h"
+#include "gtest/gtest.h"
 
 namespace clang {
 namespace tidy {
@@ -97,6 +99,155 @@
 llvm::join(Options.ExtraArgsBefore->begin(),
Options.ExtraArgsBefore->end(), ","));
 }
+
+class TestCheck : public ClangTidyCheck {
+public:
+  TestCheck(ClangTidyContext *Context) : ClangTidyCheck("test", Context) {}
+
+  template  auto getLocal(Args &&... Arguments) {
+return Options.get(std::forward(Arguments)...);
+  }
+
+  template  auto getGlobal(Args &&... Arguments) {
+return Options.getLocalOrGlobal(std::forward(Arguments)...);
+  }
+
+  template 
+  auto getIntLocal(Args &&... Arguments) {
+return Options.get(std::forward(Arguments)...);
+  }
+
+  template 
+  auto getIntGlobal(Args &&... Arguments) {
+return Options.getLocalOrGlobal(std::forward(Arguments)...);
+  }
+};
+
+#define CHECK_VAL(Value, Expected) \
+  do { \
+auto Item = Value; \
+ASSERT_TRUE(!!Item);   \
+EXPECT_EQ(*Item, Expected);\
+  } while (false)
+
+#define CHECK_ERROR(Value, ErrorType, ExpectedMessage) \
+  do { \
+auto Item = Value; \
+ASSERT_FALSE(Item);\
+ASSERT_TRUE(Item.errorIsA());   \
+ASSERT_FALSE(llvm::handleErrors(   \
+Item.takeError(), [&](const ErrorType ) -> llvm::Error {   \
+  EXPECT_EQ(Err.message(), ExpectedMessage);   \
+  return llvm::Error::success();   \
+}));   \
+  } while (false)
+
+TEST(CheckOptionsValidation, MissingOptions) {
+  ClangTidyOptions Options;
+  ClangTidyContext Context(std::make_unique(
+  ClangTidyGlobalOptions(), Options));
+  TestCheck TestCheck();
+  CHECK_ERROR(TestCheck.getLocal("Opt"), MissingOptionError,
+  "warning: Option not found 'test.Opt'\n");
+  EXPECT_EQ(TestCheck.getLocal("Opt", "Unknown"), "Unknown");
+}
+
+TEST(CheckOptionsValidation, ValidIntOptions) {
+  ClangTidyOptions Options;
+  auto  = Options.CheckOptions;
+  CheckOptions["test.IntExpected1"] = "1";
+  CheckOptions["test.IntExpected2"] = "1WithMore";
+  CheckOptions["test.IntExpected3"] = "NoInt";
+  CheckOptions["GlobalIntExpected1"] = "1";
+  CheckOptions["GlobalIntExpected2"] = "NoInt";
+  CheckOptions["test.DefaultedIntInvalid"] = "NoInt";
+  CheckOptions["GlobalIntInvalid"] = "NoInt";
+
+  ClangTidyContext Context(std::make_unique(
+  ClangTidyGlobalOptions(), Options));
+  TestCheck TestCheck();
+
+#define CHECK_ERROR_INT(Name, Expected)\
+  CHECK_ERROR(Name, UnparseableIntegerOptionError, Expected)
+
+  CHECK_VAL(TestCheck.getIntLocal("IntExpected1"), 1);
+  CHECK_VAL(TestCheck.getIntGlobal("GlobalIntExpected1"), 1);
+  CHECK_ERROR_INT(TestCheck.getIntLocal("IntExpected2"),
+  "warning: Invalid configuration value '1WithMore' for option "
+  "'test.IntExpected2'; expected an integer value\n");
+  CHECK_ERROR_INT(TestCheck.getIntLocal("IntExpected3"),
+  "warning: Invalid configuration value 'NoInt' for option "
+  "'test.IntExpected3'; expected an integer value\n");
+  CHECK_ERROR_INT(TestCheck.getIntGlobal("GlobalIntExpected2"),
+  "warning: Invalid configuration value 'NoInt' for option "
+  "'GlobalIntExpected2'; expected an integer value\n");
+  ASSERT_EQ(TestCheck.getIntLocal("DefaultedIntInvalid", 1), 1);
+  ASSERT_EQ(TestCheck.getIntGlobal("GlobalIntInvalid", 1), 1);
+
+#undef CHECK_ERROR_INT
+}
+
+TEST(ValidConfiguration, 

[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1508
   void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+auto DiagsCountIt = DiagsCount.find(FD);
 FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();

yaxunl wrote:
> rjmccall wrote:
> > It makes me a little uncomfortable to be holding an iterator this long 
> > while calling a fair amount of other stuff in the meantime.
> > 
> > Your use of DiagsCount is subtle enough that it really needs to be 
> > explained in some comments.  You're doing stuff conditionally based on both 
> > whether the entry exists but also whether it's non-zero.
> added comments
Okay, thanks for that.  Two points, then.  First, it looks like the count is 
really just a boolean for whether the function recursively triggers any 
diagnostics.   And second, can't it just be as simple as whether we've visited 
that function at all in a context that's forcing diagnostics to be emitted?  
The logic seems to be to try to emit the diagnostics for each use-path, but why 
would we want that?



Comment at: clang/lib/Sema/Sema.cpp:1553
 if (!Caller)
   ShouldEmit = IsKnownEmitted;
 if ((!ShouldEmit && !S.getLangOpts().OpenMP && !Caller) ||

This becomes global state for the visitor; that doesn't seem like it can be 
right.


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

https://reviews.llvm.org/D77028



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

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

In D77240#1957468 , @tra wrote:

> In D77240#1957386 , @jdoerfert wrote:
>
> > I just noticed those as well. I forgot to put the new definitions into the 
> > forward declare header. Will do it in a second. The OpenMP math overlay 
> > doesn't have one so I forgot :(
>
>
> I'm not sure how it's going to help. The problem is that the functions are 
> already defined by CUDA headers. Moving the duplicate definition to a 
> different header does not change that. 
>  Bottom line is that the already-existing definitions are not needed for 
> CUDA. If OpenMP needs them, then they should probably go into an 
> OpenMP-specific header.


I see. In my CUDA headers `float acos(float)` is conditionally defined as well 
but as a `__cudart_builtin__`.
So it seems we can redefine those but not the `float acosh(float)` which is a 
`__MATH_FUNCTIONS_DECL__` for some configurations.

I'll move the new functions into an OpenMP only header. I thought they might be 
needed here too but that was wrong. Thanks for spending the time on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-02 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D77240#1957386 , @jdoerfert wrote:

> I just noticed those as well. I forgot to put the new definitions into the 
> forward declare header. Will do it in a second. The OpenMP math overlay 
> doesn't have one so I forgot :(


I'm not sure how it's going to help. The problem is that the functions are 
already defined by CUDA headers. Moving the duplicate definition to a different 
header does not change that. 
Bottom line is that the already-existing definitions are not needed for CUDA. 
If OpenMP needs them, then they should probably go into an OpenMP-specific 
header.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D76594: [clang][AST] Support AST files larger than 512M

2020-04-02 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@rsmith, @dexonsmith, @jdoerfert could you please take a look to this diff?
If you think that there are other reviewers who might have more context AST 
persistence, please add them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76594



___
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-04-02 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@alexfh friendly ping
I implemented solution with priorities to resolve your concerns about `get()` 
vs `getLocalOrGlobal()`
Could you please take another look to this diff?


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] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2020-04-02 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Fix is easy,  can you commit it as obvious?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324



___
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-04-02 Thread Brian Sumner via Phabricator via cfe-commits
b-sumner added a comment.

Please go ahead and update to a string for the scope.


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] D75788: [OpenMP] Provide math functions in OpenMP device code via OpenMP variants

2020-04-02 Thread Ye Luo via Phabricator via cfe-commits
ye-luo accepted this revision.
ye-luo added a comment.
This revision is now accepted and ready to land.

Good work.
I verified that PR42798 and PR42799 are fixed by this.
Tests are completed on Ubuntu 18.04.
Clang now becomes usable for application developers.

There are still issues on RHEL that openmp_wrappers is not added before the 
system math searching path. Option -isystem openmp_wrappers can be used as a 
workaround.
This remaining issue should not be a blocker of accepting this patch. It can be 
dealt separately later without complicating the review of the current patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D75788



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


[PATCH] D76140: [InlineFunction] update attributes during inlining

2020-04-02 Thread Philip Reames via Phabricator via cfe-commits
reames accepted this revision.
reames added a comment.
This revision is now accepted and ready to land.

LGTM again, with minor change.

p.s. Sorry for missing the functional issue the first time.  All of the test 
changes should have made the issue obvious, but despite reading the LangRef 
description of signext, I somehow managed to miss the separation between ABI 
and optimization attributes.




Comment at: llvm/lib/Transforms/Utils/InlineFunction.cpp:1177
+Valid.addDereferenceableOrNullAttr(DerefOrNullBytes);
+  auto AddAttrWithoutValues =
+  [&](SmallVectorImpl ) -> void {

I'm not sure that pulling out the helper for two cases actually helps 
readability.  Can you drop this and just do the two cases directly please?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76140



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


[PATCH] D76384: Move FPFeatures from BinaryOperator bitfields to Trailing storage

2020-04-02 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/include/clang/Basic/LangOptions.h:394
+ return true;
+  }
+

sepavloff wrote:
> erichkeane wrote:
> > rjmccall wrote:
> > > erichkeane wrote:
> > > > rjmccall wrote:
> > > > > rjmccall wrote:
> > > > > > erichkeane wrote:
> > > > > > > rjmccall wrote:
> > > > > > > > The problem with having both functions that take `ASTContext`s 
> > > > > > > > and functions that don't is that it's easy to mix them, so they 
> > > > > > > > either need to have the same behavior (in which case it's 
> > > > > > > > pointless to have an overload that takes the `ASTContext`) or 
> > > > > > > > you're making something really error-prone.
> > > > > > > > 
> > > > > > > > I would feel a lot more confident that you were designing and 
> > > > > > > > using these APIs correctly if you actually took advantage of 
> > > > > > > > the ability to not store trailing FPOptions in some case, like 
> > > > > > > > when they match the global settings in the ASTContext.  That 
> > > > > > > > way you'll actually be verifying that everything behaves 
> > > > > > > > correctly if nodes don't store FPOptions.  If you do that, I 
> > > > > > > > think you'll see my point about not having all these 
> > > > > > > > easily-confusable functions that do or do not take 
> > > > > > > > `ASTContext`s..
> > > > > > > I think I disagree with @rjmccall that these 
> > > > > > > requiresTrailingStorage should be here at all.  I think we should 
> > > > > > > store in the AST ANY programmer opinion, even if they match the 
> > > > > > > global setting.  It seems to me that this would be more tolerant 
> > > > > > > of any global-setting rewrites that modules/et-al introduce, as 
> > > > > > > well as make the AST Print consistent.  Always storing FPOptions 
> > > > > > > when the user has explicitly overriding it also better captures 
> > > > > > > the programmer's intent.
> > > > > > I covered this elsewhere in the review.  If you want to have that 
> > > > > > tolerance — and I think you should — then expressions should store 
> > > > > > (and Sema should track) the active pragma state, which can be most 
> > > > > > easily expressed as a pair of an FPOptions and a mask to apply to 
> > > > > > the global FPOptions.  When you enter a pragma, you clear the 
> > > > > > relevant bits from the global FPOptions mask.
> > > > > > 
> > > > > > But the whole point of putting this stuff in trailing storage is so 
> > > > > > that you can make FPOptions as big as you need without actually 
> > > > > > inflating the AST size for a million nodes that don't care in the 
> > > > > > slightest about FPOptions.
> > > > > > But the whole point of putting this stuff in trailing storage is so 
> > > > > > that you can make FPOptions as big as you need without actually 
> > > > > > inflating the AST size for a million nodes that don't care in the 
> > > > > > slightest about FPOptions.
> > > > > 
> > > > > I meant to say: for a million nodes that don't care in the slightest 
> > > > > about FPOptions, as well as for a million more nodes that aren't 
> > > > > using pragma overrides.
> > > > Right, I get the intent, and I completely agree with that.  My point 
> > > > was EVERY Expr that is affected by a #pragma should store it.  Though, 
> > > > after looking at your Macro concern above, I'm less compelled.
> > > > 
> > > > I guess was suggesting that the logic for "requiresTrailingStorage" 
> > > > should just be "modified by a pragma" instead of "FPOptions != The 
> > > > global setting".
> > > Well, "modified by a pragma" still wouldn't make the AST agnostic to 
> > > global settings, since the pragmas don't override everything in FPOptions 
> > > at once.  But I agree that would achieve the most important goal, which 
> > > is to stop inflating the AST when pragmas *aren't* in effect, which is 
> > > approximately 100% of the time.  In order to do that, though, we'll need 
> > > to start tracking pragmas, which we should do but which can wait for a 
> > > follow-up patch.  In the meantime, I don't think you're ever going to get 
> > > the interfaces right for queries like `BinaryOperator::getFPOptions` 
> > > unless you actually stop relying on the fact that you're unconditionally 
> > > storing `FPOptions`.  You need to passing around ASTContexts for that.  
> > > That's why I'm suggesting using an exact match with the global settings 
> > > as a simple thing you can easily check without modifying what data you 
> > > collect in `FPOptions`.
> > That sounds like a good plan to me.  Thanks for entertaining my 
> > conversation/questions.
> > we'll need to start tracking pragmas
> 
> This is made in D76599 by representing floating point pragmas with a special 
> statement node. These nodes allow an AST consumer like CodeGen or constant 
> evaluator to maintain current set of floating options when it traverses AST. 
> This approach looks simpler and more consistent as global 

[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 254537.
yaxunl marked 2 inline comments as done.
yaxunl added a comment.
Herald added a reviewer: jdoerfert.

added comments


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

https://reviews.llvm.org/D77028

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1436,59 +1436,79 @@
 }
 
 // Print notes showing how we can reach FD starting from an a priori
-// known-callable function.
-static void emitCallStackNotes(Sema , FunctionDecl *FD) {
+// known-callable function. If \DiagsCount is not null pointer, the number
+// of diagnostics emitted for a function is accumulated.
+static void emitCallStackNotes(Sema , FunctionDecl *FD,
+   llvm::DenseMap,
+  unsigned> *DiagsCount = nullptr) {
   auto FnIt = S.DeviceKnownEmittedFns.find(FD);
   while (FnIt != S.DeviceKnownEmittedFns.end()) {
 DiagnosticBuilder Builder(
 S.Diags.Report(FnIt->second.Loc, diag::note_called_by));
 Builder << FnIt->second.FD;
 Builder.setForceEmit();
+// Count the number of deferred diagnostics directly or indirectly
+// triggered by a function.
+if (DiagsCount)
+  (*DiagsCount)[FnIt->second.FD]++;
 
 FnIt = S.DeviceKnownEmittedFns.find(FnIt->second.FD);
   }
 }
 
-// Emit any deferred diagnostics for FD and erase them from the map in which
-// they're stored.
-void Sema::emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack) {
-  auto It = DeviceDeferredDiags.find(FD);
-  if (It == DeviceDeferredDiags.end())
-return;
-  bool HasWarningOrError = false;
-  bool FirstDiag = true;
-  for (PartialDiagnosticAt  : It->second) {
-const SourceLocation  = PDAt.first;
-const PartialDiagnostic  = PDAt.second;
-HasWarningOrError |= getDiagnostics().getDiagnosticLevel(
- PD.getDiagID(), Loc) >= DiagnosticsEngine::Warning;
-{
-  DiagnosticBuilder Builder(Diags.Report(Loc, PD.getDiagID()));
-  Builder.setForceEmit();
-  PD.Emit(Builder);
-}
-
-// Emit the note on the first diagnostic in case too many diagnostics cause
-// the note not emitted.
-if (FirstDiag && HasWarningOrError && ShowCallStack) {
-  emitCallStackNotes(*this, FD);
-  FirstDiag = false;
-}
-  }
-
-}
-
 namespace {
+
 /// Helper class that emits deferred diagnostic messages if an entity directly
 /// or indirectly using the function that causes the deferred diagnostic
 /// messages is known to be emitted.
+///
+/// During parsing of AST, certain diagnostic messages are recorded as deferred
+/// diagnostics since it is unknown whether the functions containing such
+/// diagnostics will be emitted. A list of potentially emitted functions and
+/// variables that may potentially trigger emission of functions are also
+/// recorded. DeferredDiagnosticsEmitter recursively visits used functions
+/// by each function to emit deferred diagnostics.
+///
+/// During the visit, certain OpenMP directives or initializer of variables
+/// with certain OpenMP attributes will cause subsequent visiting of any
+/// functions enter a state which is called OpenMP device context in this
+/// implementation. The state is exited when the directive or initializer is
+/// exited. This state can change the emission states of subsequent uses
+/// of functions.
+///
+/// Conceptually the functions or variables to be visited form a use graph
+/// where the parent node uses the child node. At any point of the visit,
+/// the tree nodes traversed from the tree root to the current node form a use
+/// stack. The emission state of the current node depends on two factors:
+///1. the emission state of the root node
+///2. whether the current node is in OpenMP device context
+/// If the function is decided to be emitted, its contained deferred diagnostics
+/// are emitted, together with the information about the use stack.
+///
+/// The number of deferred diagnostics directly or indirectly triggered by
+/// a function is counted. A function is visited at least once to count
+/// the triggered diagnostics. For subsequent visits, if the number of deferred
+/// diagnostics triggered by the function is 0 and currently is not in OpenMP
+/// device context, the function is skipped, since the subtree starting at this
+/// node does not trigger any deferred diagnostics and does not trigger any
+/// OpenMP device context, otherwise the counter cannot be 0.
+///
 class DeferredDiagnosticsEmitter
 : public UsedDeclVisitor {
 public:
   typedef UsedDeclVisitor Inherited;
   llvm::SmallSet, 4> Visited;
   llvm::SmallVector, 4> UseStack;
+
+  // Deferred diagnostics triggered by a declaration.
+  llvm::DenseMap, unsigned> DiagsCount;
+
+  // Emission state of the root node of the current use graph.
   

[PATCH] D77028: [NFC] Refactor DeferredDiagsEmitter and skip redundant visit

2020-04-02 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: clang/lib/Sema/Sema.cpp:1508
   void checkFunc(SourceLocation Loc, FunctionDecl *FD) {
+auto DiagsCountIt = DiagsCount.find(FD);
 FunctionDecl *Caller = UseStack.empty() ? nullptr : UseStack.back();

rjmccall wrote:
> It makes me a little uncomfortable to be holding an iterator this long while 
> calling a fair amount of other stuff in the meantime.
> 
> Your use of DiagsCount is subtle enough that it really needs to be explained 
> in some comments.  You're doing stuff conditionally based on both whether the 
> entry exists but also whether it's non-zero.
added comments


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

https://reviews.llvm.org/D77028



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


[PATCH] D76679: [SveEmitter] Add more immediate operand checks.

2020-04-02 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.

I think the float16 discussion is an interesting one, but doesn't necessarily 
need to be done here. I am asking some questions offline, but if we ever come 
to a different opinion on it, then we can follow up so it's somewhat orthogonal 
to this change, and so this looks fine to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76679



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


[PATCH] D77240: [CUDA] Add missing cmath overloads

2020-04-02 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I just noticed those as well. I forgot to put the new definitions into the 
forward declare header. Will do it in a second. The OpenMP math overlay doesn't 
have one so I forgot :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77240



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


[PATCH] D77206: [clangd] Don't send semanticHighlights to clients that support semanticTokens.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc830106e155: [clangd] Dont send semanticHighlights to 
clients that support semanticTokens. (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77206

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/test/semantic-tokens.test


Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -1,5 +1,10 @@
-# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s
-{"jsonrpc":"2.0","id":0,"method":"initialize","params":{}}
+# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s 
-implicit-check-not=semanticHighlight
+# Send capabilities for both Theia semanticHighlight & standard semanticTokens.
+# clangd should not use/acknowledge the Theia protocol in this case.
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"capabilities":{"textDocument":{
+  "semanticHighlightingCapabilities":{"semanticHighlighting":true},
+  "semanticTokens":{"dynamicRegistration":true}
+
 ---
 
{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","text":"int
 x = 2;"}}}
 ---
Index: clang-tools-extra/clangd/Protocol.h
===
--- clang-tools-extra/clangd/Protocol.h
+++ clang-tools-extra/clangd/Protocol.h
@@ -433,8 +433,13 @@
   /// textDocument.codeAction.codeActionLiteralSupport.
   bool CodeActionStructure = false;
 
+  /// Client advertises support for the semanticTokens feature.
+  /// We support the textDocument/semanticTokens request in any case.
+  /// textDocument.semanticTokens
+  bool SemanticTokens = false;
   /// Client supports Theia semantic highlighting extension.
   /// https://github.com/microsoft/vscode-languageserver-node/pull/367
+  /// This will be ignored if the client also supports semanticTokens.
   /// textDocument.semanticHighlightingCapabilities.semanticHighlighting
   /// FIXME: drop this support once clients support LSP 3.16 Semantic Tokens.
   bool TheiaSemanticHighlighting = false;
Index: clang-tools-extra/clangd/Protocol.cpp
===
--- clang-tools-extra/clangd/Protocol.cpp
+++ clang-tools-extra/clangd/Protocol.cpp
@@ -297,6 +297,8 @@
   SemanticHighlighting->getBoolean("semanticHighlighting"))
 R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
 }
+if (auto *SemanticHighlighting = TextDocument->getObject("semanticTokens"))
+  R.SemanticTokens = true;
 if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
   if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
 R.DiagnosticCategory = *CategorySupport;
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -145,7 +145,7 @@
 /// fetch system include path.
 std::vector QueryDriverGlobs;
 
-/// Enable semantic highlighting features.
+/// Enable notification-based semantic highlighting.
 bool TheiaSemanticHighlighting = false;
 
 /// Returns true if the tweak should be enabled.
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -480,6 +480,13 @@
 
   ClangdServerOpts.TheiaSemanticHighlighting =
   Params.capabilities.TheiaSemanticHighlighting;
+  if (Params.capabilities.TheiaSemanticHighlighting &&
+  Params.capabilities.SemanticTokens) {
+log("Client supports legacy semanticHighlights notification and standard "
+"semanticTokens request, choosing the latter (no notifications).");
+ClangdServerOpts.TheiaSemanticHighlighting = false;
+  }
+
   if (Params.rootUri && *Params.rootUri)
 ClangdServerOpts.WorkspaceRoot = std::string(Params.rootUri->file());
   else if (Params.rootPath && !Params.rootPath->empty())
@@ -612,7 +619,7 @@
 ;
   if (NegotiatedOffsetEncoding)
 Result["offsetEncoding"] = *NegotiatedOffsetEncoding;
-  if (Params.capabilities.TheiaSemanticHighlighting)
+  if (ClangdServerOpts.TheiaSemanticHighlighting)
 Result.getObject("capabilities")
 ->insert(
 {"semanticHighlighting",


Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- 

[PATCH] D77225: [clangd] Support textDocument/semanticTokens/edits

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9e3063eaceec: [clangd] Support 
textDocument/semanticTokens/edits (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D77225?vs=254226=254536#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77225

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/initialize-params.test
  clang-tools-extra/clangd/test/semantic-tokens.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -14,8 +14,10 @@
 #include "TestFS.h"
 #include "TestTU.h"
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/ScopedPrinter.h"
 #include "gmock/gmock.h"
 #include 
 
@@ -23,6 +25,9 @@
 namespace clangd {
 namespace {
 
+using testing::IsEmpty;
+using testing::SizeIs;
+
 MATCHER_P(LineNumber, L, "") { return arg.Line == L; }
 MATCHER(EmptyHighlightings, "") { return arg.Tokens.empty(); }
 
@@ -720,25 +725,29 @@
   ASSERT_EQ(Counter.Count, 1);
 }
 
+// Ranges are highlighted as variables, unless highlighted as $Function etc.
+std::vector tokens(llvm::StringRef MarkedText) {
+  Annotations A(MarkedText);
+  std::vector Results;
+  for (const Range& R : A.ranges())
+Results.push_back({HighlightingKind::Variable, R});
+  for (unsigned I = 0; I < static_cast(HighlightingKind::LastKind); ++I) {
+HighlightingKind Kind = static_cast(I);
+for (const Range& R : A.ranges(llvm::to_string(Kind)))
+  Results.push_back({Kind, R});
+  }
+  llvm::sort(Results);
+  return Results;
+}
+
 TEST(SemanticHighlighting, toSemanticTokens) {
-  auto CreatePosition = [](int Line, int Character) -> Position {
-Position Pos;
-Pos.line = Line;
-Pos.character = Character;
-return Pos;
-  };
+  auto Results = toSemanticTokens(tokens(R"(
+ [[blah]]
 
-  std::vector Tokens = {
-  {HighlightingKind::Variable,
-   Range{CreatePosition(1, 1), CreatePosition(1, 5)}},
-  {HighlightingKind::Function,
-   Range{CreatePosition(3, 4), CreatePosition(3, 7)}},
-  {HighlightingKind::Variable,
-   Range{CreatePosition(3, 8), CreatePosition(3, 12)}},
-  };
+$Function[[big]] [[bang]]
+  )"));
 
-  std::vector Results = toSemanticTokens(Tokens);
-  EXPECT_EQ(Tokens.size(), Results.size());
+  ASSERT_THAT(Results, SizeIs(3));
   EXPECT_EQ(Results[0].tokenType, unsigned(HighlightingKind::Variable));
   EXPECT_EQ(Results[0].deltaLine, 1u);
   EXPECT_EQ(Results[0].deltaStart, 1u);
@@ -755,6 +764,38 @@
   EXPECT_EQ(Results[2].length, 4u);
 }
 
+TEST(SemanticHighlighting, diffSemanticTokens) {
+  auto Before = toSemanticTokens(tokens(R"(
+[[foo]] [[bar]] [[baz]]
+[[one]] [[two]] [[three]]
+  )"));
+  EXPECT_THAT(diffTokens(Before, Before), IsEmpty());
+
+  auto After = toSemanticTokens(tokens(R"(
+[[foo]] [[hello]] [[world]] [[baz]]
+[[one]] [[two]] [[three]]
+  )"));
+
+  // Replace [bar, baz] with [hello, world, baz]
+  auto Diff = diffTokens(Before, After);
+  ASSERT_THAT(Diff, SizeIs(1));
+  EXPECT_EQ(1u, Diff.front().startToken);
+  EXPECT_EQ(2u, Diff.front().deleteTokens);
+  ASSERT_THAT(Diff.front().tokens, SizeIs(3));
+  // hello
+  EXPECT_EQ(0u, Diff.front().tokens[0].deltaLine);
+  EXPECT_EQ(4u, Diff.front().tokens[0].deltaStart);
+  EXPECT_EQ(5u, Diff.front().tokens[0].length);
+  // world
+  EXPECT_EQ(0u, Diff.front().tokens[1].deltaLine);
+  EXPECT_EQ(6u, Diff.front().tokens[1].deltaStart);
+  EXPECT_EQ(5u, Diff.front().tokens[1].length);
+  // baz
+  EXPECT_EQ(0u, Diff.front().tokens[2].deltaLine);
+  EXPECT_EQ(6u, Diff.front().tokens[2].deltaStart);
+  EXPECT_EQ(3u, Diff.front().tokens[2].length);
+}
+
 TEST(SemanticHighlighting, toTheiaSemanticHighlightingInformation) {
   auto CreatePosition = [](int Line, int Character) -> Position {
 Position Pos;
Index: clang-tools-extra/clangd/test/semantic-tokens.test
===
--- clang-tools-extra/clangd/test/semantic-tokens.test
+++ clang-tools-extra/clangd/test/semantic-tokens.test
@@ -6,8 +6,13 @@
   "semanticTokens":{"dynamicRegistration":true}
 
 ---
-{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","text":"int x = 2;"}}}

[PATCH] D76432: [clangd] Add a tweak for adding "using" statement.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG24bb2d1e7768: [clangd] Add a tweak for adding 
using statement. (authored by adamcz, committed by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76432

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2390,6 +2390,250 @@
 EXPECT_EQ(apply(Case.first), Case.second);
   }
 }
+
+TWEAK_TEST(AddUsing);
+TEST_F(AddUsingTest, Prepare) {
+  const std::string Header = R"cpp(
+#define NS(name) one::two::name
+namespace one {
+void oo() {}
+namespace two {
+enum ee {};
+void ff() {}
+class cc {
+public:
+  struct st {};
+  static void mm() {}
+};
+}
+})cpp";
+
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^:^:^t^w^o^:^:^f^f(); }");
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^::^o^o(); }");
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^:^:^t^w^o^:^:^e^e E; }");
+  EXPECT_AVAILABLE(Header + "void fun() { o^n^e^:^:^t^w^o:^:^c^c C; }");
+  EXPECT_UNAVAILABLE(Header +
+ "void fun() { o^n^e^:^:^t^w^o^:^:^c^c^:^:^m^m(); }");
+  EXPECT_UNAVAILABLE(Header +
+ "void fun() { o^n^e^:^:^t^w^o^:^:^c^c^:^:^s^t inst; }");
+  EXPECT_UNAVAILABLE(Header +
+ "void fun() { o^n^e^:^:^t^w^o^:^:^c^c^:^:^s^t inst; }");
+  EXPECT_UNAVAILABLE(Header + "void fun() { N^S(c^c) inst; }");
+}
+
+TEST_F(AddUsingTest, Apply) {
+  FileName = "test.cpp";
+  struct {
+llvm::StringRef TestSource;
+llvm::StringRef ExpectedSource;
+  } Cases[]{{
+// Function, no other using, namespace.
+R"cpp(
+#include "test.hpp"
+namespace {
+void fun() {
+  ^o^n^e^:^:^t^w^o^:^:^f^f();
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+namespace {using one::two::ff;
+
+void fun() {
+  ff();
+}
+})cpp",
+},
+// Type, no other using, namespace.
+{
+R"cpp(
+#include "test.hpp"
+namespace {
+void fun() {
+  ::on^e::t^wo::c^c inst;
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+namespace {using ::one::two::cc;
+
+void fun() {
+  cc inst;
+}
+})cpp",
+},
+// Type, no other using, no namespace.
+{
+R"cpp(
+#include "test.hpp"
+
+void fun() {
+  on^e::t^wo::e^e inst;
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+using one::two::ee;
+
+void fun() {
+  ee inst;
+})cpp"},
+// Function, other usings.
+{
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+using one::two::ee;
+
+namespace {
+void fun() {
+  one::two::f^f();
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+using one::two::ff;using one::two::ee;
+
+namespace {
+void fun() {
+  ff();
+}
+})cpp",
+},
+// Function, other usings inside namespace.
+{
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+
+namespace {
+
+using one::two::ff;
+
+void fun() {
+  o^ne::o^o();
+}
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+
+namespace {
+
+using one::oo;using one::two::ff;
+
+void fun() {
+  oo();
+}
+})cpp"},
+// Using comes after cursor.
+{
+R"cpp(
+#include "test.hpp"
+
+namespace {
+
+void fun() {
+  one::t^wo::ff();
+}
+
+using one::two::cc;
+
+})cpp",
+R"cpp(
+#include "test.hpp"
+
+namespace {using one::two::ff;
+
+
+void fun() {
+  ff();
+}
+
+using one::two::cc;
+
+})cpp"},
+// Pointer type.
+{R"cpp(
+#include "test.hpp"
+
+void fun() {
+  one::two::c^c *p;
+})cpp",
+ R"cpp(
+#include "test.hpp"
+
+using one::two::cc;
+
+void fun() {
+  cc *p;
+})cpp"},
+// Namespace declared via macro.
+{R"cpp(
+#include "test.hpp"
+#define NS_BEGIN(name) namespace name {
+
+NS_BEGIN(foo)
+
+void fun() {
+  one::two::f^f();
+}
+})cpp",
+ R"cpp(
+#include "test.hpp"
+#define NS_BEGIN(name) namespace name {
+
+using one::two::ff;
+
+NS_BEGIN(foo)
+
+void fun() {
+  ff();
+}
+})cpp"},
+// Inside macro argument.
+{R"cpp(
+#include "test.hpp"
+#define CALL(name) name()
+
+void fun() {
+  CALL(one::t^wo::ff);
+})cpp",
+ R"cpp(
+#include "test.hpp"
+#define CALL(name) name()
+
+using one::two::ff;
+
+void fun() {
+  CALL(ff);
+})cpp"}};
+  llvm::StringMap EditedFiles;
+  for (const auto  : Cases) {
+for (const auto  : expandCases(Case.TestSource)) {
+  ExtraFiles["test.hpp"] = R"cpp(
+namespace one {
+void oo() {}
+namespace two {
+enum 

[clang-tools-extra] 9e3063e - [clangd] Support textDocument/semanticTokens/edits

2020-04-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-02T17:38:29+02:00
New Revision: 9e3063eaceec5054684a77acf5281772df2a7f73

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

LOG: [clangd] Support textDocument/semanticTokens/edits

Summary:
This returns incremental highlights as a set of edits against the
previous highlights.

Server-side, we compute the full set of highlights, this just saves
wire-format size.

For now, the diff used is trivial: everything from the first change to
the last change is sent as a single edit.

The wire format is grungy - the replacement offset/length refer to
positions in the encoded array instead of the logical list of tokens.
We use token-oriented structs and translating to LSP forms when serializing.
This departs from LSP (but is consistent with semanticTokens today).

Tested in VSCode insiders (with a patched client to enable experimental
features).

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, kadircet, 
usaxena95, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdLSPServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SemanticHighlighting.h
clang-tools-extra/clangd/test/initialize-params.test
clang-tools-extra/clangd/test/semantic-tokens.test
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 8906e6f68f2f..19476d7fa052 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -586,7 +586,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
  }},
 {"semanticTokensProvider",
  llvm::json::Object{
- {"documentProvider", true},
+ {"documentProvider", llvm::json::Object{{"edits", true}}},
  {"rangeProvider", false},
  {"legend",
   llvm::json::Object{{"tokenTypes", semanticTokenTypes()},
@@ -833,6 +833,10 @@ void ClangdLSPServer::onDocumentDidClose(
 std::lock_guard HLock(HighlightingsMutex);
 FileToHighlightings.erase(File);
   }
+  {
+std::lock_guard HLock(SemanticTokensMutex);
+LastSemanticTokens.erase(File);
+  }
   // clangd will not send updates for this file anymore, so we empty out the
   // list of diagnostics shown on the client (e.g. in the "Problems" pane of
   // VSCode). Note that this cannot race with actual diagnostics responses
@@ -1243,16 +1247,71 @@ void ClangdLSPServer::onDocumentLink(
   });
 }
 
+// Increment a numeric string: "" -> 1 -> 2 -> ... -> 9 -> 10 -> 11 ...
+static void increment(std::string ) {
+  for (char  : llvm::reverse(S)) {
+if (C != '9') {
+  ++C;
+  return;
+}
+C = '0';
+  }
+  S.insert(S.begin(), '1');
+}
+
 void ClangdLSPServer::onSemanticTokens(const SemanticTokensParams ,
Callback CB) {
   Server->semanticHighlights(
   Params.textDocument.uri.file(),
-  [CB(std::move(CB))](
-  llvm::Expected> Toks) mutable {
-if (!Toks)
-  return CB(Toks.takeError());
+  [this, File(Params.textDocument.uri.file().str()), CB(std::move(CB))](
+  llvm::Expected> HT) mutable {
+if (!HT)
+  return CB(HT.takeError());
 SemanticTokens Result;
-Result.data = toSemanticTokens(*Toks);
+Result.tokens = toSemanticTokens(*HT);
+{
+  std::lock_guard Lock(SemanticTokensMutex);
+  auto& Last = LastSemanticTokens[File];
+
+  Last.tokens = Result.tokens;
+  increment(Last.resultId);
+  Result.resultId = Last.resultId;
+}
+CB(std::move(Result));
+  });
+}
+
+void ClangdLSPServer::onSemanticTokensEdits(
+const SemanticTokensEditsParams ,
+Callback CB) {
+  Server->semanticHighlights(
+  Params.textDocument.uri.file(),
+  [this, PrevResultID(Params.previousResultId),
+   File(Params.textDocument.uri.file().str()), CB(std::move(CB))](
+  llvm::Expected> HT) mutable {
+if (!HT)
+  return CB(HT.takeError());
+std::vector Toks = toSemanticTokens(*HT);
+
+SemanticTokensOrEdits Result;
+{
+  std::lock_guard Lock(SemanticTokensMutex);
+  auto& Last = LastSemanticTokens[File];
+
+  if (PrevResultID == Last.resultId) {
+Result.edits = 
diff Tokens(Last.tokens, Toks);
+  } else {
+

[PATCH] D66324: clang-misexpect: Profile Guided Validation of Performance Annotations in LLVM

2020-04-02 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

I have the same issue as @wenju. The second time I call 
`ExecuteCompilerInvocation` it will give the error above, leading me to believe 
some memory isn't properly cleared.

Note: the `--pgo-warn-misexpect` option is not passed in the compiler 
invocation.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D66324



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


[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-02 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

Some of these are technically "future reserved keywords": 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar#Keywords

Wouldn't it be better to list all of JS's keywords at this point?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77311



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


[PATCH] D77313: [AST] Allow VectorTypes of 1-256 elements, and powers of two up to 2**31.

2020-04-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, rjmccall, erichkeane.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This used to be 1-2043 elements, and recently regressed to a limit of 1023.
The new behavior is an almost-superset of GCC, which accepts powers of two up
to 2**62.

This change frees one further bit in VectorType in case Type grows again.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77313

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/types.c
  clang/test/SemaCXX/vector.cpp

Index: clang/test/SemaCXX/vector.cpp
===
--- clang/test/SemaCXX/vector.cpp
+++ clang/test/SemaCXX/vector.cpp
@@ -343,7 +343,7 @@
 template 
 struct PR15730 {
   typedef T __attribute__((vector_size(N * sizeof(T type;
-  typedef T __attribute__((vector_size(8192))) type2; // #2
+  typedef T __attribute__((vector_size(1))) type2; // #2
   typedef T __attribute__((vector_size(3))) type3; // #3
 };
 
@@ -352,25 +352,27 @@
   const TemplateVectorType::type Works2 = {};
   // expected-error@#1 {{invalid vector element type 'bool'}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoBool;
+  const TemplateVectorType::type NoBool = {};
   // expected-error@#1 {{invalid vector element type 'int __attribute__((ext_vector_type(4)))' (vector of 4 'int' values)}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type NoComplex;
+  const TemplateVectorType::type NoComplex = {};
   // expected-error@#1 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type BadSize;
-  // expected-error@#1 {{vector size too large}}
-  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type TooLarge;
+  const TemplateVectorType::type BadSize = {};
+  const TemplateVectorType::type SmallNonPower = {};
+  const TemplateVectorType::type LargePower = {};
+  // expected-error@#1 {{vector size exceeds 256 and is not a power of two}}
+  // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
+  const TemplateVectorType::type LargeNonPower = {};
   // expected-error@#1 {{zero vector size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::TemplateVectorType' requested here}}
-  const TemplateVectorType::type Zero;
+  const TemplateVectorType::type Zero = {};
 
-  // expected-error@#2 {{vector size too large}}
+  // expected-error@#2 {{not a power of two}}
   // expected-error@#3 {{vector size not an integral multiple of component size}}
   // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, int>' requested here}}
   const PR15730<8, int>::type PR15730_1 = {};
-  // expected-error@#2 {{vector size too large}}
+  // expected-error@#2 {{not a power of two}}
   // expected-note@+1 {{in instantiation of template class 'Templates::PR15730<8, char>' requested here}}
   const PR15730<8, char>::type2 PR15730_2 = {};
 }
Index: clang/test/Sema/types.c
===
--- clang/test/Sema/types.c
+++ clang/test/Sema/types.c
@@ -70,8 +70,18 @@
 }
 
 // vector size too large
-int __attribute__ ((vector_size(8192))) x1; // expected-error {{vector size too large}}
-typedef int __attribute__ ((ext_vector_type(8192))) x2; // expected-error {{vector size too large}}
+char __attribute__ ((vector_size(255))) v1;
+char __attribute__ ((vector_size(256))) v2;
+char __attribute__ ((vector_size(257))) v3; // expected-error {{vector size exceeds 256 and is not a power of two}}
+char __attribute__ ((vector_size(512))) v4;
+char __attribute__ ((vector_size(0x1000))) v5;
+char __attribute__ ((vector_size(0x1))) v6; // expected-error {{vector size too large}}
+typedef int __attribute__ ((ext_vector_type(255))) e1;
+typedef int __attribute__ ((ext_vector_type(256))) e2;
+typedef int __attribute__ ((ext_vector_type(257))) e3; // expected-error {{vector size exceeds 256 and is not a power of two}}
+typedef int __attribute__ ((ext_vector_type(512))) e4;
+typedef int __attribute__ ((ext_vector_type(0x1000))) e5;
+typedef int __attribute__ ((ext_vector_type(0x1))) e6; // expected-error {{vector size too large}}
 
 // no support for vector enum type
 enum { e_2 } x3 __attribute__((vector_size(64))); // expected-error {{invalid vector element type}}
Index: clang/lib/Sema/SemaType.cpp
===
--- 

[clang-tools-extra] fc83010 - [clangd] Don't send semanticHighlights to clients that support semanticTokens.

2020-04-02 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-04-02T17:38:02+02:00
New Revision: fc830106e15553fcca3fc80066fe5a988e16dfec

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

LOG: [clangd] Don't send semanticHighlights to clients that support 
semanticTokens.

Summary: This allows the standard mechanism to gracefully displace the old one.

Reviewers: hokein

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, 
cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp
clang-tools-extra/clangd/ClangdServer.h
clang-tools-extra/clangd/Protocol.cpp
clang-tools-extra/clangd/Protocol.h
clang-tools-extra/clangd/test/semantic-tokens.test

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 310c1fec17dd..8906e6f68f2f 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -480,6 +480,13 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
 
   ClangdServerOpts.TheiaSemanticHighlighting =
   Params.capabilities.TheiaSemanticHighlighting;
+  if (Params.capabilities.TheiaSemanticHighlighting &&
+  Params.capabilities.SemanticTokens) {
+log("Client supports legacy semanticHighlights notification and standard "
+"semanticTokens request, choosing the latter (no notifications).");
+ClangdServerOpts.TheiaSemanticHighlighting = false;
+  }
+
   if (Params.rootUri && *Params.rootUri)
 ClangdServerOpts.WorkspaceRoot = std::string(Params.rootUri->file());
   else if (Params.rootPath && !Params.rootPath->empty())
@@ -612,7 +619,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams 
,
 ;
   if (NegotiatedOffsetEncoding)
 Result["offsetEncoding"] = *NegotiatedOffsetEncoding;
-  if (Params.capabilities.TheiaSemanticHighlighting)
+  if (ClangdServerOpts.TheiaSemanticHighlighting)
 Result.getObject("capabilities")
 ->insert(
 {"semanticHighlighting",

diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index f1e981e6c14f..ae3da84c42c8 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -145,7 +145,7 @@ class ClangdServer {
 /// fetch system include path.
 std::vector QueryDriverGlobs;
 
-/// Enable semantic highlighting features.
+/// Enable notification-based semantic highlighting.
 bool TheiaSemanticHighlighting = false;
 
 /// Returns true if the tweak should be enabled.

diff  --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 9d7c96df02c0..019c6c038467 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -297,6 +297,8 @@ bool fromJSON(const llvm::json::Value , 
ClientCapabilities ) {
   SemanticHighlighting->getBoolean("semanticHighlighting"))
 R.TheiaSemanticHighlighting = *SemanticHighlightingSupport;
 }
+if (auto *SemanticHighlighting = TextDocument->getObject("semanticTokens"))
+  R.SemanticTokens = true;
 if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
   if (auto CategorySupport = Diagnostics->getBoolean("categorySupport"))
 R.DiagnosticCategory = *CategorySupport;

diff  --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 5d0b60d7fe9f..a713d47862b1 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -433,8 +433,13 @@ struct ClientCapabilities {
   /// textDocument.codeAction.codeActionLiteralSupport.
   bool CodeActionStructure = false;
 
+  /// Client advertises support for the semanticTokens feature.
+  /// We support the textDocument/semanticTokens request in any case.
+  /// textDocument.semanticTokens
+  bool SemanticTokens = false;
   /// Client supports Theia semantic highlighting extension.
   /// https://github.com/microsoft/vscode-languageserver-node/pull/367
+  /// This will be ignored if the client also supports semanticTokens.
   /// textDocument.semanticHighlightingCapabilities.semanticHighlighting
   /// FIXME: drop this support once clients support LSP 3.16 Semantic Tokens.
   bool TheiaSemanticHighlighting = false;

diff  --git a/clang-tools-extra/clangd/test/semantic-tokens.test 
b/clang-tools-extra/clangd/test/semantic-tokens.test
index 1f6b51af84dd..679766995d52 100644
--- a/clang-tools-extra/clangd/test/semantic-tokens.test
+++ b/clang-tools-extra/clangd/test/semantic-tokens.test
@@ -1,5 +1,10 @@
-# RUN: clangd -lit-test < %s | FileCheck -strict-whitespace %s

[clang-tools-extra] 24bb2d1 - [clangd] Add a tweak for adding "using" statement.

2020-04-02 Thread Sam McCall via cfe-commits

Author: Adam Czachorowski
Date: 2020-04-02T17:37:38+02:00
New Revision: 24bb2d1e776897c3a93856d2ca76decb4cfd0562

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

LOG: [clangd] Add a tweak for adding "using" statement.

Summary:
This triggers on types and function calls with namespace qualifiers. The
action is to remove the qualifier and instead add a "using" statement at
appropriate place.

It is not always clear where to add the "using" line. Right now we find
the nearest "using" line and add it there, thus keeping with local
convention. If there are no usings, we put it at the deepest relevant
namespace level.

This is an initial version only. There are several improvements that
can be made:
* Support for qualifiers that are not purely namespace (e.g.  record
types, etc).
* Removing qualifier from other instances of the same type/call.
* Smarter placement of the "using" line.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: nridge, mgorny, ilya-biryukov, MaskRay, jkorous, mgrang, arphaman, 
kadircet, usaxena95, cfe-commits

Tags: #clang

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

Added: 
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp

Modified: 
clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
new file mode 100644
index ..1ecec6674b02
--- /dev/null
+++ b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -0,0 +1,286 @@
+//===--- AddUsing.cpp *- 
C++-*-===//
+//
+// 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 "AST.h"
+#include "FindTarget.h"
+#include "Logger.h"
+#include "refactor/Tweak.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/RecursiveASTVisitor.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Tweak for removing full namespace qualifier under cursor on DeclRefExpr and
+// types and adding "using" statement instead.
+//
+// Only qualifiers that refer exclusively to namespaces (no record types) are
+// supported. There is some guessing of appropriate place to insert the using
+// declaration. If we find any existing usings, we insert it there. If not, we
+// insert right after the inner-most relevant namespace declaration. If there 
is
+// none, or there is, but it was declared via macro, we insert above the first
+// top level decl.
+//
+// Currently this only removes qualifier from under the cursor. In the future,
+// we should improve this to remove qualifier from all occurences of this
+// symbol.
+class AddUsing : public Tweak {
+public:
+  const char *id() const override;
+
+  bool prepare(const Selection ) override;
+  Expected apply(const Selection ) override;
+  std::string title() const override;
+  Intent intent() const override { return Refactor; }
+
+private:
+  // The qualifier to remove. Set by prepare().
+  NestedNameSpecifierLoc QualifierToRemove;
+  // The name following QualifierToRemove. Set by prepare().
+  llvm::StringRef Name;
+};
+REGISTER_TWEAK(AddUsing)
+
+std::string AddUsing::title() const {
+  return std::string(llvm::formatv(
+  "Add using-declaration for {0} and remove qualifier.", Name));
+}
+
+// Locates all "using" statements relevant to SelectionDeclContext.
+class UsingFinder : public RecursiveASTVisitor {
+public:
+  UsingFinder(std::vector ,
+  const DeclContext *SelectionDeclContext, const SourceManager )
+  : Results(Results), SelectionDeclContext(SelectionDeclContext), SM(SM) {}
+
+  bool VisitUsingDecl(UsingDecl *D) {
+auto Loc = D->getUsingLoc();
+if (SM.getFileID(Loc) != SM.getMainFileID()) {
+  return true;
+}
+if (D->getDeclContext()->Encloses(SelectionDeclContext)) {
+  Results.push_back(D);
+}
+return true;
+  }
+
+  bool TraverseDecl(Decl *Node) {
+// There is no need to go deeper into nodes that do not enclose selection,
+// since "using" there will not affect selection, nor would it make a good
+// insertion point.
+if (Node->getDeclContext()->Encloses(SelectionDeclContext)) {
+  return RecursiveASTVisitor::TraverseDecl(Node);
+}
+return true;
+  }
+
+private:
+  std::vector 
+  const DeclContext *SelectionDeclContext;
+  const SourceManager 
+};
+
+struct InsertionPointData {
+  // Location to insert the "using" statement. If invalid then the statement
+  // should not be inserted 

[PATCH] D76790: [analyzer] StdLibraryFunctionsChecker: fix bug with arg constraints

2020-04-02 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1525232e2761: [analyzer] StdLibraryFunctionsChecker: fix bug 
with arg constraints (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D76790?vs=253595=254530#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76790

Files:
  clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-arg-constraints.c

Index: clang/test/Analysis/std-c-library-functions-arg-constraints.c
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints.c
+++ clang/test/Analysis/std-c-library-functions-arg-constraints.c
@@ -3,6 +3,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
 // RUN:   -verify=report
@@ -12,6 +13,7 @@
 // RUN:   -analyzer-checker=core \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctions \
 // RUN:   -analyzer-checker=apiModeling.StdCLibraryFunctionArgs \
+// RUN:   -analyzer-checker=debug.StdCLibraryFunctionsTester \
 // RUN:   -analyzer-checker=debug.ExprInspection \
 // RUN:   -triple x86_64-unknown-linux-gnu \
 // RUN:   -analyzer-output=text \
@@ -85,3 +87,30 @@
 // bugpath-warning{{Function argument constraint is not satisfied}} \
 // bugpath-note{{Function argument constraint is not satisfied}}
 }
+
+int __two_constrained_args(int, int);
+void test_constraints_on_multiple_args(int x, int y) {
+  // State split should not happen here. I.e. x == 1 should not be evaluated
+  // FALSE.
+  __two_constrained_args(x, y);
+  clang_analyzer_eval(x == 1); // \
+  // report-warning{{TRUE}} \
+  // bugpath-warning{{TRUE}} \
+  // bugpath-note{{TRUE}}
+  clang_analyzer_eval(y == 1); // \
+  // report-warning{{TRUE}} \
+  // bugpath-warning{{TRUE}} \
+  // bugpath-note{{TRUE}}
+}
+
+int __arg_constrained_twice(int);
+void test_multiple_constraints_on_same_arg(int x) {
+  __arg_constrained_twice(x);
+  // Check that both constraints are applied and only one branch is there.
+  clang_analyzer_eval(x < 1 || x > 2); // \
+  // report-warning{{TRUE}} \
+  // bugpath-warning{{TRUE}} \
+  // bugpath-note{{TRUE}} \
+  // bugpath-note{{Assuming 'x' is < 1}} \
+  // bugpath-note{{Left side of '||' is true}}
+}
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -306,7 +306,11 @@
   void checkPostCall(const CallEvent , CheckerContext ) const;
   bool evalCall(const CallEvent , CheckerContext ) const;
 
-  enum CheckKind { CK_StdCLibraryFunctionArgsChecker, CK_NumCheckKinds };
+  enum CheckKind {
+CK_StdCLibraryFunctionArgsChecker,
+CK_StdCLibraryFunctionsTesterChecker,
+CK_NumCheckKinds
+  };
   DefaultBool ChecksEnabled[CK_NumCheckKinds];
   CheckerNameRef CheckNames[CK_NumCheckKinds];
 
@@ -455,23 +459,26 @@
   const Summary  = *FoundSummary;
   ProgramStateRef State = C.getState();
 
+  ProgramStateRef NewState = State;
   for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
-ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);
-ProgramStateRef FailureSt = VC->negate()->apply(State, Call, Summary);
+ProgramStateRef SuccessSt = VC->apply(NewState, Call, Summary);
+ProgramStateRef FailureSt = VC->negate()->apply(NewState, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
-  if (ExplodedNode *N = C.generateErrorNode(State))
+  if (ExplodedNode *N = C.generateErrorNode(NewState))
 reportBug(Call, N, C);
   break;
 } else {
-  // Apply the constraint even if we cannot reason about the argument. This
-  // means both SuccessSt and FailureSt can be true. If we weren't applying
-  // the constraint that would mean that symbolic execution continues on a
-  // code whose behaviour is undefined.
+  // We will apply the constraint even if we cannot reason about the
+  // argument. This means both SuccessSt and FailureSt can be true. If we
+  // weren't applying the constraint that would mean that symbolic
+  // execution continues on a code whose behaviour is undefined.
   assert(SuccessSt);
-  C.addTransition(SuccessSt);
+  NewState = SuccessSt;
 }
   }
+  if (NewState && NewState != State)
+C.addTransition(NewState);
 }
 
 void 

[PATCH] D77311: clang-format: [JS] detect C++ keywords.

2020-04-02 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
mprobst added a reviewer: krasimir.
Herald added subscribers: cfe-commits, jfb.
Herald added a project: clang.

C++ defines a number of keywords that are regular identifiers in
JavaScript, e.g. `concept`:

  const concept = 1; // legit JS

This change expands the existing `IsJavaScriptIdentifier(Tok)` function
to return false for C++ keywords that aren't keywords in JS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77311

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestJS.cpp

Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2366,6 +2366,58 @@
   verifyFormat("return !!x;\n");
 }
 
+TEST_F(FormatTestJS, CppKeywordsInJavaScript) {
+  // use the "!" assertion operator to validate that clang-format understands
+  // these C++ keywords aren't keywords in JS/TS.
+  verifyFormat("auto!;");
+  verifyFormat("char!;");
+  verifyFormat("concept!;");
+  verifyFormat("double!;");
+  verifyFormat("extern!;");
+  verifyFormat("float!;");
+  verifyFormat("inline!;");
+  verifyFormat("int!;");
+  verifyFormat("long!;");
+  verifyFormat("register!;");
+  verifyFormat("restrict!;");
+  verifyFormat("sizeof!;");
+  verifyFormat("static!;");
+  verifyFormat("struct!;");
+  verifyFormat("typedef!;");
+  verifyFormat("union!;");
+  verifyFormat("unsigned!;");
+  verifyFormat("volatile!;");
+  verifyFormat("_Alignas!;");
+  verifyFormat("_Alignof!;");
+  verifyFormat("_Atomic!;");
+  verifyFormat("_Bool!;");
+  verifyFormat("_Complex!;");
+  verifyFormat("_Generic!;");
+  verifyFormat("_Imaginary!;");
+  verifyFormat("_Noreturn!;");
+  verifyFormat("_Static_assert!;");
+  verifyFormat("_Thread_local!;");
+  verifyFormat("__func__!;");
+  verifyFormat("__objc_yes!;");
+  verifyFormat("__objc_no!;");
+  verifyFormat("asm!;");
+  verifyFormat("bool!;");
+  verifyFormat("const_cast!;");
+  verifyFormat("dynamic_cast!;");
+  verifyFormat("explicit!;");
+  verifyFormat("friend!;");
+  verifyFormat("mutable!;");
+  verifyFormat("operator!;");
+  verifyFormat("reinterpret_cast!;");
+  verifyFormat("static_cast!;");
+  verifyFormat("template!;");
+  verifyFormat("typename!;");
+  verifyFormat("typeid!;");
+  verifyFormat("using!;");
+  verifyFormat("virtual!;");
+  verifyFormat("wchar_t!;");
+}
+
 TEST_F(FormatTestJS, NullPropagatingOperator) {
   verifyFormat("let x = foo?.bar?.baz();\n");
   verifyFormat("let x = foo?.(foo);\n");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1522,9 +1522,9 @@
 if (Style.Language == FormatStyle::LK_JavaScript) {
   if (Current.is(tok::exclaim)) {
 if (Current.Previous &&
-(Current.Previous->isOneOf(tok::identifier, tok::kw_namespace,
-   tok::r_paren, tok::r_square,
-   tok::r_brace) ||
+(Keywords.IsJavaScriptIdentifier(*Current.Previous) ||
+ Current.Previous->isOneOf(tok::kw_namespace, tok::r_paren,
+   tok::r_square, tok::r_brace) ||
  Current.Previous->Tok.isLiteral())) {
   Current.Type = TT_JsNonNullAssertion;
   return;
@@ -3070,10 +3070,8 @@
 (Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
   return false;
 // In tagged template literals ("html`bar baz`"), there is no space between
-// the tag identifier and the template string. getIdentifierInfo makes sure
-// that the identifier is not a pseudo keyword like `yield`, either.
-if (Left.is(tok::identifier) && Keywords.IsJavaScriptIdentifier(Left) &&
-Right.is(TT_TemplateString))
+// the tag identifier and the template string.
+if (Keywords.IsJavaScriptIdentifier(Left) && Right.is(TT_TemplateString))
   return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
Index: clang/lib/Format/FormatToken.h
===
--- clang/lib/Format/FormatToken.h
+++ clang/lib/Format/FormatToken.h
@@ -910,9 +910,65 @@
   /// Returns \c true if \p Tok is a true JavaScript identifier, returns
   /// \c false if it is a keyword or a pseudo keyword.
   bool IsJavaScriptIdentifier(const FormatToken ) const {
-return Tok.is(tok::identifier) &&
-   JsExtraKeywords.find(Tok.Tok.getIdentifierInfo()) ==
-   JsExtraKeywords.end();
+switch (Tok.Tok.getKind()) {
+case tok::kw_auto:
+case tok::kw_char:
+case tok::kw_concept:
+case tok::kw_double:
+case tok::kw_extern:
+case tok::kw_float:
+case tok::kw_inline:
+case tok::kw_int:
+case 

[PATCH] D76932: [AIX] emit .extern and .weak directive linkage

2020-04-02 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:407
   case GlobalValue::WeakAnyLinkage:
   case GlobalValue::WeakODRLinkage:
 if (MAI->hasWeakDefDirective()) {

Could we verify if these Linkage should also always emit .weak?
We do have one test case that tests LinkOnceODRLinkage in 
llvm/test/CodeGen/PowerPC/aix-LinkOnceODRLinkage.ll, but no other linkages here 
is tested and confirmed the behavior is right for AIX.
Also LinkOnceODRLinkage.ll test needs to get update as well, since we will emit 
`.weak _Z3fooIiEvT_[DS]` now. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76932



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


[PATCH] D77041: [AST] Fix a crash on invalid constexpr Ctorinitializer when building RecoveryExpr.

2020-04-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 254525.
hokein added a comment.

remove accident change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77041

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/invalid-constructor-init.cpp


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+struct X {
+  int Y;
+  constexpr X() // expected-error {{constexpr constructor never produces}}
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+};
+// no crash on evaluating the constexpr ctor.
+constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be 
initialized by a constant expression}}
+
+struct X2 {
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
+ // expected-note {{subexpression not valid in a constant 
expression}}
+  constexpr X2() {} // expected-error {{constexpr constructor never produces a 
constant expression}}
+};
+
+struct CycleDelegate {
+  int Y;
+  CycleDelegate(int)
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+  // no bogus "delegation cycle" diagnostic
+  CycleDelegate(float) : CycleDelegate(1) {}
+};
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4975,6 +4975,13 @@
 return false;
   }
 
+  if (const auto *CtorDecl = dyn_cast_or_null(Definition)) 
{
+for (const auto *InitExpr : CtorDecl->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
+
   // Can we evaluate this function call?
   if (Definition && Definition->isConstexpr() && Body)
 return true;
@@ -14736,6 +14743,15 @@
   if (FD->isDependentContext())
 return true;
 
+  // Bail out if a constexpr constructor has an initializer that contains an
+  // error. We deliberately don't produce a diagnostic, as we have produced a
+  // relevant diagnostic when parsing the error initializer.
+  if (const auto *Ctor = dyn_cast(FD)) {
+for (const auto *InitExpr : Ctor->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
   Expr::EvalStatus Status;
   Status.Diag = 
 


Index: clang/test/SemaCXX/invalid-constructor-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/invalid-constructor-init.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -frecovery-ast -verify %s
+
+struct X {
+  int Y;
+  constexpr X() // expected-error {{constexpr constructor never produces}}
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+};
+// no crash on evaluating the constexpr ctor.
+constexpr int Z = X().Y; // expected-error {{constexpr variable 'Z' must be initialized by a constant expression}}
+
+struct X2 {
+  int Y = foo();// expected-error {{use of undeclared identifier 'foo'}} \
+ // expected-note {{subexpression not valid in a constant expression}}
+  constexpr X2() {} // expected-error {{constexpr constructor never produces a constant expression}}
+};
+
+struct CycleDelegate {
+  int Y;
+  CycleDelegate(int)
+  : Y(foo()) {} // expected-error {{use of undeclared identifier 'foo'}}
+  // no bogus "delegation cycle" diagnostic
+  CycleDelegate(float) : CycleDelegate(1) {}
+};
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -4975,6 +4975,13 @@
 return false;
   }
 
+  if (const auto *CtorDecl = dyn_cast_or_null(Definition)) {
+for (const auto *InitExpr : CtorDecl->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
+
   // Can we evaluate this function call?
   if (Definition && Definition->isConstexpr() && Body)
 return true;
@@ -14736,6 +14743,15 @@
   if (FD->isDependentContext())
 return true;
 
+  // Bail out if a constexpr constructor has an initializer that contains an
+  // error. We deliberately don't produce a diagnostic, as we have produced a
+  // relevant diagnostic when parsing the error initializer.
+  if (const auto *Ctor = dyn_cast(FD)) {
+for (const auto *InitExpr : Ctor->inits()) {
+  if (InitExpr->getInit() && InitExpr->getInit()->containsErrors())
+return false;
+}
+  }
   Expr::EvalStatus Status;
   Status.Diag = 
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D77309: [clangd] Get rid of ASTWorker::getCurrentFileInputs

2020-04-02 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.
kadircet added a parent revision: D76725: [clangd] Build ASTs only with fresh 
preambles or after building a new preamble.

FileInputs are only written by ASTWorker thread, therefore it is safe
to read them without the lock inside that thread. It can still be read by other
threads through ASTWorker::getCurrentCompileCommand though.

This patch also gets rid of the smart pointer wrapping FileInputs as there is
never mutliple owners.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77309

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

Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -430,10 +430,6 @@
   Deadline scheduleLocked();
   /// Should the first task in the queue be skipped instead of run?
   bool shouldSkipHeadLocked() const;
-  /// This is private because `FileInputs.FS` is not thread-safe and thus not
-  /// safe to share. Callers should make sure not to expose `FS` via a public
-  /// interface.
-  std::shared_ptr getCurrentFileInputs() const;
 
   struct Request {
 llvm::unique_function Action;
@@ -467,7 +463,7 @@
   /// File inputs, currently being used by the worker.
   /// Inputs are written and read by the worker thread, compile command can also
   /// be consumed by clients of ASTWorker.
-  std::shared_ptr FileInputs; /* GUARDED_BY(Mutex) */
+  ParseInputs FileInputs; /* GUARDED_BY(Mutex) */
   /// Times of recent AST rebuilds, used for UpdateDebounce computation.
   llvm::SmallVector
   RebuildTimes; /* GUARDED_BY(Mutex) */
@@ -563,12 +559,10 @@
// FIXME: Run PreamblePeer asynchronously once ast patching
// is available.
/*RunSync=*/true, Status, *this) {
-  auto Inputs = std::make_shared();
   // Set a fallback command because compile command can be accessed before
   // `Inputs` is initialized. Other fields are only used after initialization
   // from client inputs.
-  Inputs->CompileCommand = CDB.getFallbackCommand(FileName);
-  FileInputs = std::move(Inputs);
+  FileInputs.CompileCommand = CDB.getFallbackCommand(FileName);
 }
 
 ASTWorker::~ASTWorker() {
@@ -597,7 +591,7 @@
   Inputs.CompileCommand = CDB.getFallbackCommand(FileName);
 
 bool InputsAreTheSame =
-std::tie(FileInputs->CompileCommand, FileInputs->Contents) ==
+std::tie(FileInputs.CompileCommand, FileInputs.Contents) ==
 std::tie(Inputs.CompileCommand, Inputs.Contents);
 // Cached AST is invalidated.
 if (!InputsAreTheSame) {
@@ -608,7 +602,7 @@
 // Update current inputs so that subsequent reads can see them.
 {
   std::lock_guard Lock(Mutex);
-  FileInputs = std::make_shared(Inputs);
+  FileInputs = Inputs;
 }
 
 log("ASTWorker building file {0} version {1} with command {2}\n[{3}]\n{4}",
@@ -662,14 +656,13 @@
 if (isCancelled())
   return Action(llvm::make_error());
 llvm::Optional> AST = IdleASTs.take(this);
-auto CurrentInputs = getCurrentFileInputs();
 if (!AST) {
   StoreDiags CompilerInvocationDiagConsumer;
-  std::unique_ptr Invocation = buildCompilerInvocation(
-  *CurrentInputs, CompilerInvocationDiagConsumer);
+  std::unique_ptr Invocation =
+  buildCompilerInvocation(FileInputs, CompilerInvocationDiagConsumer);
   // Try rebuilding the AST.
   vlog("ASTWorker rebuilding evicted AST to run {0}: {1} version {2}", Name,
-   FileName, CurrentInputs->Version);
+   FileName, FileInputs.Version);
   // FIXME: We might need to build a patched ast once preamble thread starts
   // running async. Currently getPossiblyStalePreamble below will always
   // return a compatible preamble as ASTWorker::update blocks.
@@ -677,7 +670,7 @@
   Invocation
   ? buildAST(FileName,
  std::make_unique(*Invocation),
- CompilerInvocationDiagConsumer.take(), *CurrentInputs,
+ CompilerInvocationDiagConsumer.take(), FileInputs,
  getPossiblyStalePreamble())
   : None;
   AST = NewAST ? std::make_unique(std::move(*NewAST)) : nullptr;
@@ -690,8 +683,8 @@
   return Action(llvm::make_error(
   "invalid AST", llvm::errc::invalid_argument));
 vlog("ASTWorker running {0} on version {2} of {1}", Name, FileName,
- CurrentInputs->Version);
-Action(InputsAndAST{*CurrentInputs, **AST});
+ FileInputs.Version);
+Action(InputsAndAST{FileInputs, **AST});
   };
   startTask(Name, std::move(Task), /*UpdateType=*/None, Invalidation);
 }
@@ -791,7 +784,7 @@
   }
   // Used to check whether we 

[clang] 1525232 - [analyzer] StdLibraryFunctionsChecker: fix bug with arg constraints

2020-04-02 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-04-02T17:00:11+02:00
New Revision: 1525232e276153e325a49372894ae52ed07351a5

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

LOG: [analyzer] StdLibraryFunctionsChecker: fix bug with arg constraints

Summary:
Previously we induced a state split if there were multiple argument
constraints given for a function. This was because we called
`addTransition` inside the for loop.
The fix is to is to store the state and apply the next argument
constraint on that. And once the loop is finished we call `addTransition`.

Reviewers: NoQ, Szelethus, baloghadamsoftware

Subscribers: whisperity, xazax.hun, szepet, rnkovacs, a.sidorin, 
mikhail.ramalho, donat.nagy, dkrupp, gamesh411, C

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
clang/test/Analysis/std-c-library-functions-arg-constraints.c

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td 
b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
index 136a0fb6a374..6a577940e313 100644
--- a/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ b/clang/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -1422,6 +1422,12 @@ def DebugIteratorModeling : 
Checker<"DebugIteratorModeling">,
   Dependencies<[DebugContainerModeling, IteratorModeling]>,
   Documentation;
 
+def StdCLibraryFunctionsTesterChecker : Checker<"StdCLibraryFunctionsTester">,
+  HelpText<"Add test functions to the summary map, so testing of individual "
+   "summary constituents becomes possible.">,
+  Dependencies<[StdCLibraryFunctionsChecker]>,
+  Documentation;
+
 } // end "debug"
 
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 6e5f5f8b5874..f03696daab0b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -306,7 +306,11 @@ class StdLibraryFunctionsChecker
   void checkPostCall(const CallEvent , CheckerContext ) const;
   bool evalCall(const CallEvent , CheckerContext ) const;
 
-  enum CheckKind { CK_StdCLibraryFunctionArgsChecker, CK_NumCheckKinds };
+  enum CheckKind {
+CK_StdCLibraryFunctionArgsChecker,
+CK_StdCLibraryFunctionsTesterChecker,
+CK_NumCheckKinds
+  };
   DefaultBool ChecksEnabled[CK_NumCheckKinds];
   CheckerNameRef CheckNames[CK_NumCheckKinds];
 
@@ -455,23 +459,26 @@ void StdLibraryFunctionsChecker::checkPreCall(const 
CallEvent ,
   const Summary  = *FoundSummary;
   ProgramStateRef State = C.getState();
 
+  ProgramStateRef NewState = State;
   for (const ValueConstraintPtr& VC : Summary.ArgConstraints) {
-ProgramStateRef SuccessSt = VC->apply(State, Call, Summary);
-ProgramStateRef FailureSt = VC->negate()->apply(State, Call, Summary);
+ProgramStateRef SuccessSt = VC->apply(NewState, Call, Summary);
+ProgramStateRef FailureSt = VC->negate()->apply(NewState, Call, Summary);
 // The argument constraint is not satisfied.
 if (FailureSt && !SuccessSt) {
-  if (ExplodedNode *N = C.generateErrorNode(State))
+  if (ExplodedNode *N = C.generateErrorNode(NewState))
 reportBug(Call, N, C);
   break;
 } else {
-  // Apply the constraint even if we cannot reason about the argument. This
-  // means both SuccessSt and FailureSt can be true. If we weren't applying
-  // the constraint that would mean that symbolic execution continues on a
-  // code whose behaviour is undefined.
+  // We will apply the constraint even if we cannot reason about the
+  // argument. This means both SuccessSt and FailureSt can be true. If we
+  // weren't applying the constraint that would mean that symbolic
+  // execution continues on a code whose behaviour is undefined.
   assert(SuccessSt);
-  C.addTransition(SuccessSt);
+  NewState = SuccessSt;
 }
   }
+  if (NewState && NewState != State)
+C.addTransition(NewState);
 }
 
 void StdLibraryFunctionsChecker::checkPostCall(const CallEvent ,
@@ -936,6 +943,32 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
   {"getdelim", Summaries{Getline(IntTy, IntMax), Getline(LongTy, LongMax),
  Getline(LongLongTy, LongLongMax)}},
   };
+
+  // Functions for testing.
+  if (ChecksEnabled[CK_StdCLibraryFunctionsTesterChecker]) {
+llvm::StringMap TestFunctionSummaryMap = {
+{"__two_constrained_args",
+ Summaries{
+ Summary(ArgTypes{IntTy, IntTy}, RetType{IntTy}, EvalCallAsPure)
+ 

[clang-tools-extra] da8eda1 - [clangd] Get rid of redundant make_uniques

2020-04-02 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-04-02T16:52:13+02:00
New Revision: da8eda1ab1ae97115f9ed170216ed89b69662578

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

LOG: [clangd] Get rid of redundant make_uniques

Added: 


Modified: 
clang-tools-extra/clangd/ParsedAST.cpp
clang-tools-extra/clangd/TUScheduler.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ParsedAST.cpp 
b/clang-tools-extra/clangd/ParsedAST.cpp
index 2c7cb5d2b85d..f6205879aa29 100644
--- a/clang-tools-extra/clangd/ParsedAST.cpp
+++ b/clang-tools-extra/clangd/ParsedAST.cpp
@@ -551,8 +551,7 @@ buildAST(PathRef FileName, 
std::unique_ptr Invocation,
   }
 
   return ParsedAST::build(
-  Inputs.Version, std::make_unique(*Invocation),
-  CompilerInvocationDiags, Preamble,
+  Inputs.Version, std::move(Invocation), CompilerInvocationDiags, Preamble,
   llvm::MemoryBuffer::getMemBufferCopy(Inputs.Contents, FileName),
   std::move(VFS), Inputs.Index, Inputs.Opts);
 }

diff  --git a/clang-tools-extra/clangd/TUScheduler.cpp 
b/clang-tools-extra/clangd/TUScheduler.cpp
index e5a001997ecc..a2df2c3ff62f 100644
--- a/clang-tools-extra/clangd/TUScheduler.cpp
+++ b/clang-tools-extra/clangd/TUScheduler.cpp
@@ -569,12 +569,10 @@ void ASTWorker::runWithAST(
   vlog("ASTWorker rebuilding evicted AST to run {0}: {1} version {2}", 
Name,
FileName, CurrentInputs->Version);
   llvm::Optional NewAST =
-  Invocation
-  ? buildAST(FileName,
- std::make_unique(*Invocation),
- CompilerInvocationDiagConsumer.take(), *CurrentInputs,
- getPossiblyStalePreamble())
-  : None;
+  Invocation ? buildAST(FileName, std::move(Invocation),
+CompilerInvocationDiagConsumer.take(),
+*CurrentInputs, getPossiblyStalePreamble())
+ : None;
   AST = NewAST ? std::make_unique(std::move(*NewAST)) : nullptr;
 }
 // Make sure we put the AST back into the LRU cache.



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


[PATCH] D59321: AMDGPU: Teach toolchain to link rocm device libs

2020-04-02 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D59321#1955646 , @arsenm wrote:

> In D59321#1955405 , @hliao wrote:
>
> > Do we have a better way to avoid adding those empty bitcode files?
>
>
> No, we need the files to exist for tests. This is what existing bitcode link 
> tests do


could you update this patch?


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

https://reviews.llvm.org/D59321



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


[PATCH] D76725: [clangd] Build ASTs only with fresh preambles or after building a new preamble

2020-04-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 254520.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76725

Files:
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
  clang-tools-extra/clangd/unittests/FileIndexTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
  clang-tools-extra/clangd/unittests/TestTU.cpp

Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -35,7 +35,7 @@
   Files[ImportThunk] = ThunkContents;
 
   ParseInputs Inputs;
-  auto& Argv = Inputs.CompileCommand.CommandLine;
+  auto  = Inputs.CompileCommand.CommandLine;
   Argv = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
   // GoToDefinition test for some reason (getMacroArgExpandedLocation fails).
@@ -71,8 +71,7 @@
   auto CI = buildCompilerInvocation(Inputs, Diags);
   assert(CI && "Failed to build compilation invocation.");
   auto Preamble =
-  buildPreamble(testPath(Filename), *CI,
-/*OldPreamble=*/nullptr, Inputs,
+  buildPreamble(testPath(Filename), *CI, Inputs,
 /*StoreInMemory=*/true, /*PreambleCallback=*/nullptr);
   auto AST = buildAST(testPath(Filename), std::move(CI), Diags.take(), Inputs,
   Preamble);
@@ -89,7 +88,7 @@
 if (llvm::StringRef(Code).contains(Marker) ||
 llvm::StringRef(HeaderCode).contains(Marker))
   return true;
-for (const auto& KV : this->AdditionalFiles)
+for (const auto  : this->AdditionalFiles)
   if (llvm::StringRef(KV.second).contains(Marker))
 return true;
 return false;
Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -24,6 +24,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -283,6 +284,7 @@
 S.runWithPreamble("StaleRead", Path, TUScheduler::Stale,
   [&](Expected Pre) {
 ASSERT_TRUE(bool(Pre));
+ASSERT_TRUE(Pre->Preamble);
 EXPECT_EQ(Pre->Preamble->Version, "A");
 EXPECT_THAT(includes(Pre->Preamble),
 ElementsAre(""));
@@ -292,11 +294,13 @@
 S.runWithPreamble("ConsistentRead", Path, TUScheduler::Consistent,
   [&](Expected Pre) {
 ASSERT_TRUE(bool(Pre));
+ASSERT_TRUE(Pre->Preamble);
 EXPECT_EQ(Pre->Preamble->Version, "B");
 EXPECT_THAT(includes(Pre->Preamble),
 ElementsAre(""));
 ++CallbackCount;
   });
+S.blockUntilIdle(timeoutSeconds(10));
   }
   EXPECT_EQ(2, CallbackCount);
 }
@@ -731,11 +735,14 @@
 )cpp";
 
   ParseInputs Inputs = getInputs(Source, SourceContents);
+  std::atomic DiagCount(0);
 
   // Update the source contents, which should trigger an initial build with
   // the header file missing.
   updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+++DiagCount;
 EXPECT_THAT(Diags,
 ElementsAre(Field(::Message, "'foo.h' file not found"),
 Field(::Message,
@@ -751,18 +758,23 @@
   // The addition of the missing header file shouldn't trigger a rebuild since
   // we don't track missing files.
   updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+++DiagCount;
 ADD_FAILURE() << "Did not expect diagnostics for missing header update";
   });
 
   // Forcing the reload should should cause a rebuild which no longer has any
   // errors.
   Inputs.ForceRebuild = true;
-  updateWithDiags(
-  S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) { EXPECT_THAT(Diags, IsEmpty()); });
+  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) {
+++DiagCount;
+EXPECT_THAT(Diags, IsEmpty());
+  });
 
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
+  EXPECT_EQ(DiagCount, 2U);
 }
 TEST_F(TUSchedulerTests, NoChangeDiags) {
   TUScheduler S(CDB, optsForTest(), captureDiags());
@@ 

[PATCH] D76304: [clangd] Update TUStatus api to accommodate preamble thread

2020-04-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 254519.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D76304

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  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
@@ -24,6 +24,7 @@
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -40,13 +41,14 @@
 using ::testing::Pointee;
 using ::testing::UnorderedElementsAre;
 
-MATCHER_P2(TUState, State, ActionName, "") {
-  if (arg.Action.S != State) {
-*result_listener << "state is " << arg.Action.S;
+MATCHER_P2(TUState, PreambleActivity, ASTActivity, "") {
+  if (arg.PreambleActivity != PreambleActivity) {
+*result_listener << "preamblestate is "
+ << static_cast(arg.PreambleActivity);
 return false;
   }
-  if (arg.Action.Name != ActionName) {
-*result_listener << "name is " << arg.Action.Name;
+  if (arg.ASTActivity.K != ASTActivity) {
+*result_listener << "aststate is " << arg.ASTActivity.K;
 return false;
   }
   return true;
@@ -732,14 +734,13 @@
 
   // Update the source contents, which should trigger an initial build with
   // the header file missing.
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-EXPECT_THAT(
-Diags,
-ElementsAre(
-Field(::Message, "'foo.h' file not found"),
-Field(::Message, "use of undeclared identifier 'a'")));
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+EXPECT_THAT(Diags,
+ElementsAre(Field(::Message, "'foo.h' file not found"),
+Field(::Message,
+  "use of undeclared identifier 'a'")));
+  });
 
   // Add the header file. We need to recreate the inputs since we changed a
   // file from underneath the test FS.
@@ -749,18 +750,17 @@
 
   // The addition of the missing header file shouldn't trigger a rebuild since
   // we don't track missing files.
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-ADD_FAILURE() << "Did not expect diagnostics for missing header update";
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes, [](std::vector Diags) {
+ADD_FAILURE() << "Did not expect diagnostics for missing header update";
+  });
 
   // Forcing the reload should should cause a rebuild which no longer has any
   // errors.
   Inputs.ForceRebuild = true;
-  updateWithDiags(S, Source, Inputs, WantDiagnostics::Yes,
-  [](std::vector Diags) {
-EXPECT_THAT(Diags, IsEmpty());
-  });
+  updateWithDiags(
+  S, Source, Inputs, WantDiagnostics::Yes,
+  [](std::vector Diags) { EXPECT_THAT(Diags, IsEmpty()); });
 
   ASSERT_TRUE(S.blockUntilIdle(timeoutSeconds(10)));
 }
@@ -848,14 +848,21 @@
 
   EXPECT_THAT(CaptureTUStatus.allStatus(),
   ElementsAre(
-  // Statuses of "Update" action.
-  TUState(TUAction::RunningAction, "Update (1)"),
-  TUState(TUAction::BuildingPreamble, "Update (1)"),
-  TUState(TUAction::BuildingFile, "Update (1)"),
-
-  // Statuses of "Definitions" action
-  TUState(TUAction::RunningAction, "Definitions"),
-  TUState(TUAction::Idle, /*No action*/ "")));
+  // Everything starts with ASTWorker starting to execute an
+  // update
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // We build the preamble
+  TUState(PreambleAction::Building, ASTAction::RunningAction),
+  // Preamble worker goes idle
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // We start building the ast
+  TUState(PreambleAction::Idle, ASTAction::Building),
+  // Built finished succesffully
+  TUState(PreambleAction::Idle, ASTAction::Building),
+  // Rnning go to def
+  TUState(PreambleAction::Idle, ASTAction::RunningAction),
+  // both workers go idle
+  TUState(PreambleAction::Idle, ASTAction::Idle)));
 }
 
 TEST_F(TUSchedulerTests, CommandLineErrors) {
@@ -868,8 +875,7 @@
   TUScheduler S(CDB, optsForTest(), captureDiags());
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
-  

  1   2   >