[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2020-01-15 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill added a comment.

In D62686#1820816 , @apazos wrote:

> Lewis, your latest patch looks good, we just had another run with no new 
> failures. But we know it will have issues with -g. So I think we should not 
> merge it yet. Do you have a version of the patch that creates the labels for 
> the compiler-generated save/restore lib calls, so that this optimization does 
> not depend on D71593 ? We could merge that 
> version then, and when D71593  is accepted, 
> you just have to rework/remove the label generation part of the patch.


I don't expect that would be possible without making changes to generic code 
anyway. Removing the framesetup flag from the libcalls when generating them 
would allow labels to be produced, but that would require making modifications 
to the logic of this patch which relies on the libcalls being annotated as such.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686



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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-initialization-list

2020-01-15 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238192.
baloghadamsoftware retitled this revision from "[clang-tidy][WIP] New check 
readability-prefer-initialization-list" to "[clang-tidy][WIP] New check 
cppcoreguidelines-prefer-initialization-list".
baloghadamsoftware added a comment.
Herald added subscribers: kbarton, nemanjai.

Now checker proposes default member initialization if applicable. Thus it is in 
sync with checker `modernize-use-default-member-init`. Also moved to 
ícppcoreguidelinesí group.


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

https://reviews.llvm.org/D71199

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -0,0 +1,407 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+
+class Simple1 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple1() {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple1(int nn, double xx) {
+// CHECK-FIXES: Simple1(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple1() = default;
+};
+
+class Simple2 {
+  int n;
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple2() : n (0) {
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple2(int nn, double xx) : n(nn) {
+// CHECK-FIXES: Simple2(int nn, double xx) : n(nn), x(xx) {
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple2() = default;
+};
+
+class Simple3 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+
+public:
+  Simple3() : x (0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple3(int nn, double xx) : x(xx) {
+// CHECK-FIXES: Simple3(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple3() = default;
+};
+
+int something_int();
+double something_double();
+
+class Simple4 {
+  int n;
+
+public:
+  Simple4() {
+// CHECK-FIXES: Simple4() : n(something_int()) {
+n = something_int();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple4() = default;
+};
+
+static bool dice();
+
+class Complex1 {
+  int n;
+  int m;
+
+public:
+  Complex1() : n(0) {
+if (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional expression
+  }
+
+  ~Complex1() = default;
+};
+
+class Complex2 {
+  int n;
+  int m;
+
+public:
+  Complex2() : n(0) {
+if (!dice())
+  return;
+m = 1;
+// NO-MESSAGES: initialization of 'm' follows a conditional expression
+  }
+
+  ~Com

[PATCH] D72755: [RISCV] Pass target-abi via module flag metadata

2020-01-15 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen created this revision.
khchen added reviewers: lenary, asb.
khchen added a project: clang.
Herald added subscribers: cfe-commits, luismarques, apazos, sameer.abuasal, 
pzheng, s.egerton, Jim, benna, psnobl, jocewei, PkmX, rkruppe, the_o, 
brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, 
kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar.

in D71387 , and this 
 we agree 
encoding target-abi in module would make sense.
This patch only emit target-abi for RISCV because the first user is probably 
only the RISC-V target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72755

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/riscv-metadata.c


Index: clang/test/CodeGen/riscv-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-metadata.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | 
FileCheck -check-prefix=ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d 
-emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | 
FileCheck -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d 
-emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
+
+// ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
+// ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
+
+// LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
+// LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -537,6 +537,13 @@
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
   }
 
+  if (Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64) {
+StringRef ABIStr = Target.getABI();
+llvm::LLVMContext &Ctx = TheModule.getContext();
+getModule().addModuleFlag(llvm::Module::Error, "target-abi",
+  llvm::MDString::get(Ctx, ABIStr));
+  }
+
   if (CodeGenOpts.SanitizeCfiCrossDso) {
 // Indicate that we want cross-DSO control flow integrity checks.
 getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);


Index: clang/test/CodeGen/riscv-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/riscv-metadata.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple riscv32 -target-abi ilp32 -emit-llvm -o - %s | FileCheck -check-prefix=ILP32 %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-abi ilp32f -emit-llvm -o - %s | FileCheck -check-prefix=ILP32F %s
+// RUN: %clang_cc1 -triple riscv32 -target-feature +d -target-abi ilp32d -emit-llvm -o - %s | FileCheck -check-prefix=ILP32D %s
+// RUN: %clang_cc1 -triple riscv64 -target-abi lp64 -emit-llvm -o - %s | FileCheck -check-prefix=LP64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-abi lp64f -emit-llvm -o - %s | FileCheck -check-prefix=LP64F %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +d -target-abi lp64d -emit-llvm -o - %s | FileCheck -check-prefix=LP64D %s
+
+// ILP32: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32"}
+// ILP32F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32f"}
+// ILP32D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"ilp32d"}
+
+// LP64: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64"}
+// LP64F: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64f"}
+// LP64D: !{{[0-9]+}} = !{i32 1, !"target-abi", !"lp64d"}
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -537,6 +537,13 @@
 getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
   }
 
+  if (Arch == llvm::Triple::riscv32 || Arch == llvm::Triple::riscv64) {
+StringRef ABIStr = Target.getABI();
+llvm::LLVMContext &Ctx = TheModule.getContext();
+getModule().addModuleFlag(llvm::Module::Error, "target-abi",
+  llvm::MDString::get(Ctx, ABIStr));
+  }
+
   if (CodeGenOpts.SanitizeCfiCrossDso) {
 // Indicate that we want cross-DSO control flow integrity checks.
 getModule().addModuleFlag(llvm::Module::Override, "Cross-DSO CFI", 1);
_

[PATCH] D72742: Don't assume promotable integers are zero/sign-extended already in x86-64 ABI.

2020-01-15 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

> Sign-extension is not guaranteed by the ABI, and thus the callee cannot 
> assume it.

This is a bit too vague.
Can you quote specific parts of the appropriate standard/document?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72742



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


[PATCH] D72612: [AArch64][SVE] Add ImmArg property to intrinsics with immediates

2020-01-15 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin updated this revision to Diff 238199.
kmclaughlin added a comment.

- Removed shiftimm patterns and reused tvecshiftR8, etc
- Removed complex patterns used by AsmVectorIndexOpnd and instead created a 
multiclass (VectorIndex) to create a PatLeaf with timm if "_timm" is appended


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

https://reviews.llvm.org/D72612

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td

Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -1639,12 +1639,12 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b:$idx))),
-(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b:$idx)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b:$idx)>;
-  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b:$idx))),
-(!cast(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b:$idx)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexH32b_timm:$idx))),
+(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexH32b_timm:$idx)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexS32b_timm:$idx))),
+(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx)>;
+  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, nxv2f64:$Op3, (i32 VectorIndexD32b_timm:$idx))),
+(!cast(NAME # _D) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx)>;
 }
 
 
@@ -1687,12 +1687,12 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b:$idx))),
-(!cast(NAME # _H) $Op1, $Op2, VectorIndexH32b:$idx)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b:$idx))),
-(!cast(NAME # _S) $Op1, $Op2, VectorIndexS32b:$idx)>;
-  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b:$idx))),
-(!cast(NAME # _D) $Op1, $Op2, VectorIndexD32b:$idx)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, (i32 VectorIndexH32b_timm:$idx))),
+(!cast(NAME # _H) $Op1, $Op2, VectorIndexH32b_timm:$idx)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, (i32 VectorIndexS32b_timm:$idx))),
+(!cast(NAME # _S) $Op1, $Op2, VectorIndexS32b_timm:$idx)>;
+  def : Pat<(nxv2f64 (op nxv2f64:$Op1, nxv2f64:$Op2, (i32 VectorIndexD32b_timm:$idx))),
+(!cast(NAME # _D) $Op1, $Op2, VectorIndexD32b_timm:$idx)>;
 }
 
 //===--===//
@@ -1778,10 +1778,10 @@
 let Inst{19-16} = Zm;
   }
 
-  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b:$idx), (i32 complexrotateop:$imm))),
-(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b:$idx, complexrotateop:$imm)>;
-  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b:$idx), (i32 complexrotateop:$imm))),
-(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv8f16 (op nxv8f16:$Op1, nxv8f16:$Op2, nxv8f16:$Op3, (i32 VectorIndexS32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # _H) $Op1, $Op2, $Op3, VectorIndexS32b_timm:$idx, complexrotateop:$imm)>;
+  def : Pat<(nxv4f32 (op nxv4f32:$Op1, nxv4f32:$Op2, nxv4f32:$Op3, (i32 VectorIndexD32b_timm:$idx), (i32 complexrotateop:$imm))),
+(!cast(NAME # _S) $Op1, $Op2, $Op3, VectorIndexD32b_timm:$idx, complexrotateop:$imm)>;
 }
 
 //===--===//
@@ -1942,7 +1942,7 @@
 multiclass sve2_fp_mla_long_by_indexed_elem opc, string asm,
 SDPatternOperator op> {
   def NAME : sve2_fp_mla_long_by_indexed_elem;
-  def : SVE_4_Op_Imm_Pat(NAME)>;
+  def : SVE_4_Op_Imm_Pat(NAME)>;
 }
 
 //===--===//
@@ -2472,23 +2472,23 @@
 
 multiclass sve_intx_dot_by_indexed_elem {
-  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b> {
+  def _S : sve_intx_dot_by_indexed_elem<0b0, opc, asm, ZPR32, ZPR8, ZPR3b8, VectorIndexS32b_timm> {
 bits<2> iop;
 bits<3> Zm;
 let Inst{20-19} = iop;
 let Inst{18-16} = Zm;
   }
-  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b> {
+  def _D : sve_intx_dot_by_indexed_elem<0b1, opc, asm, ZPR64, ZPR16, ZPR4b16, VectorIndexD32b_timm> {
 bits<1> iop;
 bits<4> Zm;
 let Inst{20} = iop;
 let Inst{19-16}

[clang] cbe681b - Revert "[RISCV] Add Clang frontend support for Bitmanip extension"

2020-01-15 Thread Scott Egerton via cfe-commits

Author: Scott Egerton
Date: 2020-01-15T10:43:42Z
New Revision: cbe681bd8339d3a018d25441a5f4ef9da2bd017d

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

LOG: Revert "[RISCV] Add Clang frontend support for Bitmanip extension"

This reverts commit 57cf6ee9c84434161088c39a6f8dd2aae14eb12d.

Added: 


Modified: 
clang/lib/Basic/Targets/RISCV.cpp
clang/lib/Basic/Targets/RISCV.h
clang/lib/Driver/ToolChains/Arch/RISCV.cpp
clang/test/Preprocessor/riscv-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index 58285f1d8134..ab8272c034fd 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -125,10 +125,6 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   if (HasC)
 Builder.defineMacro("__riscv_compressed");
-
-  if (HasB) {
-Builder.defineMacro("__riscv_bitmanip");
-  }
 }
 
 /// Return true if has this feature, need to sync with handleTargetFeatures.
@@ -143,7 +139,6 @@ bool RISCVTargetInfo::hasFeature(StringRef Feature) const {
   .Case("f", HasF)
   .Case("d", HasD)
   .Case("c", HasC)
-  .Case("b", HasB)
   .Default(false);
 }
 
@@ -161,8 +156,6 @@ bool 
RISCVTargetInfo::handleTargetFeatures(std::vector &Features,
   HasD = true;
 else if (Feature == "+c")
   HasC = true;
-else if (Feature == "+b")
-  HasB = true;
   }
 
   return true;

diff  --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h
index 05da13230bf8..9118494a87ab 100644
--- a/clang/lib/Basic/Targets/RISCV.h
+++ b/clang/lib/Basic/Targets/RISCV.h
@@ -30,12 +30,11 @@ class RISCVTargetInfo : public TargetInfo {
   bool HasF;
   bool HasD;
   bool HasC;
-  bool HasB;
 
 public:
   RISCVTargetInfo(const llvm::Triple &Triple, const TargetOptions &)
   : TargetInfo(Triple), HasM(false), HasA(false), HasF(false),
-HasD(false), HasC(false), HasB(false) {
+HasD(false), HasC(false) {
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();

diff  --git a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp 
b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
index 85869ae937e5..8c343b8693f3 100644
--- a/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -331,9 +331,6 @@ static bool getArchFeatures(const Driver &D, StringRef 
MArch,
 case 'c':
   Features.push_back("+c");
   break;
-case 'b':
-  Features.push_back("+b");
-  break;
 }
   }
 

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 1d2fd60847da..a93d7e6a9a43 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -7,7 +7,6 @@
 // CHECK-NOT: __riscv_mul
 // CHECK-NOT: __riscv_muldiv
 // CHECK-NOT: __riscv_compressed
-// CHECK-NOT: __riscv_bitmanip
 // CHECK-NOT: __riscv_flen
 // CHECK-NOT: __riscv_fdiv
 // CHECK-NOT: __riscv_fsqrt
@@ -49,12 +48,6 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-C-EXT %s
 // CHECK-C-EXT: __riscv_compressed 1
 
-// RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ib -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
-// RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ib -x c -E -dM %s \
-// RUN: -o - | FileCheck --check-prefix=CHECK-B-EXT %s
-// CHECK-B-EXT: __riscv_bitmanip 1
-
 // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32ifd -mabi=ilp32 -x 
c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-SOFT %s
 // RUN: %clang -target riscv64-unknown-linux-gnu -march=rv64ifd -mabi=lp64 -x 
c -E -dM %s \



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


[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

2020-01-15 Thread Scott Egerton via Phabricator via cfe-commits
s.egerton added a comment.

Good point. It's reverted now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71553



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


[PATCH] D71553: [RISCV] Add Clang frontend support for Bitmanip extension

2020-01-15 Thread Sam Elliott via Phabricator via cfe-commits
lenary reopened this revision.
lenary added a comment.
This revision is now accepted and ready to land.

@s.egerton Thank you. Sorry again for the confusion.

Reverted in rGcbe681bd8339d3a018d25441a5f4ef9da2bd017d 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71553



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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-initialization-list

2020-01-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp:52
+static bool isUnaryExprOfLiteral(const Expr *E) {
+  if (const auto *UnOp = dyn_cast(E)) {
+return isLiteral(UnOp->getSubExpr());

Please elide braces.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:70
 
+- The 'readability-prefer-member-initializer' check was renamed to 
:doc:`cppcoreguidelines-prefer-member-initializer
+  `

Is it relevant?



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:73
+
+- The 'readability-prefer-initialization-list' check was renamed to 
:doc:`readability-prefer-member-initializer
+  `

Is it relevant?



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst:15
+language version than `C++ 20`), furthermore the assigned value is a literal,
+negated literal or `enum` constant then the preferred place of the
+initialization is at the class member declaration.

Enum should be in double back-ticks as language construct.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71199



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


[clang] a90ea38 - [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.

2020-01-15 Thread Scott Egerton via cfe-commits

Author: Scott Egerton
Date: 2020-01-15T11:28:57Z
New Revision: a90ea386981f4fa3c7cb7f62c6900069764b05a8

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

LOG: [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using 
-fdollars-in-identifiers flag.

Summary:
Previously, the -fdollars-in-identifiers flag allows the '$' symbol to be used
in an identifier but the universal character name equivalent '\u0024' is not
allowed.
This patch changes this, so that \u0024 is valid in identifiers.

Reviewers: rsmith, jordan_rose

Reviewed By: rsmith

Subscribers: dexonsmith, simoncook, cfe-commits

Tags: #clang

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

Added: 


Modified: 
clang/lib/Lex/Lexer.cpp
clang/test/Preprocessor/ucn-pp-identifier.c

Removed: 




diff  --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index 902b17397915..648bda270578 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@ void Lexer::SetByteOffset(unsigned Offset, bool 
StartOfLine) {
 static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
   if (LangOpts.AsmPreprocessor) {
 return false;
+  } else if (LangOpts.DollarIdents && '$' == C) {
+return true;
   } else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
 static const llvm::sys::UnicodeCharSet C11AllowedIDChars(
 C11AllowedIDCharRanges);

diff  --git a/clang/test/Preprocessor/ucn-pp-identifier.c 
b/clang/test/Preprocessor/ucn-pp-identifier.c
index f045e38e94af..0929412a76ed 100644
--- a/clang/test/Preprocessor/ucn-pp-identifier.c
+++ b/clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // expected-error {{macro name must be an identifier}}
 #define \u0061  // expected-error {{character 'a' cannot be specified by a 
universal character name}} expected-error {{macro name must be an identifier}}
 
-// FIXME: Not clear what our behavior should be here; \u0024 is "$".
-#define a\u0024  // expected-warning {{whitespace}}
+#define a\u0024
 
 #if \u0110 // expected-warning {{is not defined, evaluates to 0}}
 #endif



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


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/Ref.h:36
+  // one below.
+  Implicit = 1 << 3,
+  All = Declaration | Definition | Reference | Implicit,

instead of doing that, could we rather de-couple two enums completely and have 
a `symbolRoleToRefKind`(and vice-versa) method instead(we already have some 
customization in `toRefKind` now) ?

as current change increases the risk of overlapping in future(e.g. someone 
might change symbolrole::declaration and cause failures/regressions in clangd)



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:306
+  const auto Spelling =
+  Lexer::getSpelling(Loc, Buffer, SM, ASTCtx->getLangOpts());
+  DeclarationName Name = ND->getDeclName();

this might be expensive to trigger while indexing for each reference.

could we rather do it as post-processing inside `SymbolCollector::finish` while 
making use of `TokenBuffer::spelledTokens`(you can create a tokenbuffer through 
`TokenCollector` with the `PP` inside `SymbolCollector`.)



Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:309
+  if (Name.isIdentifier() && Name.getAsString() != Spelling)
+Roles |= static_cast(index::SymbolRole::Implicit);
+

It seems like we are only checking for `syntactic` occurence of a symbol. Can 
we make use of `Spelled` Rather than `Implicit` (which has some semantic 
meaning) to make that clear?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[PATCH] D72390: [www] Remove stale text about default c++ standard from cxx_status.html

2020-01-15 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

Ping. Is this okay to land, or have I missed something? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72390



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


[PATCH] D71758: [Lexer] Allow UCN for dollar symbol '\u0024' in identifiers when using -fdollars-in-identifiers flag.

2020-01-15 Thread Scott Egerton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa90ea386981f: [Lexer] Allow UCN for dollar symbol 
'\u0024' in identifiers when using… (authored by s.egerton).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71758

Files:
  clang/lib/Lex/Lexer.cpp
  clang/test/Preprocessor/ucn-pp-identifier.c


Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // expected-error {{macro name must be an identifier}}
 #define \u0061  // expected-error {{character 'a' cannot be specified by a 
universal character name}} expected-error {{macro name must be an identifier}}
 
-// FIXME: Not clear what our behavior should be here; \u0024 is "$".
-#define a\u0024  // expected-warning {{whitespace}}
+#define a\u0024
 
 #if \u0110 // expected-warning {{is not defined, evaluates to 0}}
 #endif
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@
 static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
   if (LangOpts.AsmPreprocessor) {
 return false;
+  } else if (LangOpts.DollarIdents && '$' == C) {
+return true;
   } else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
 static const llvm::sys::UnicodeCharSet C11AllowedIDChars(
 C11AllowedIDCharRanges);


Index: clang/test/Preprocessor/ucn-pp-identifier.c
===
--- clang/test/Preprocessor/ucn-pp-identifier.c
+++ clang/test/Preprocessor/ucn-pp-identifier.c
@@ -28,8 +28,7 @@
 #define \U1000  // expected-error {{macro name must be an identifier}}
 #define \u0061  // expected-error {{character 'a' cannot be specified by a universal character name}} expected-error {{macro name must be an identifier}}
 
-// FIXME: Not clear what our behavior should be here; \u0024 is "$".
-#define a\u0024  // expected-warning {{whitespace}}
+#define a\u0024
 
 #if \u0110 // expected-warning {{is not defined, evaluates to 0}}
 #endif
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -1431,6 +1431,8 @@
 static bool isAllowedIDChar(uint32_t C, const LangOptions &LangOpts) {
   if (LangOpts.AsmPreprocessor) {
 return false;
+  } else if (LangOpts.DollarIdents && '$' == C) {
+return true;
   } else if (LangOpts.CPlusPlus11 || LangOpts.C11) {
 static const llvm::sys::UnicodeCharSet C11AllowedIDChars(
 C11AllowedIDCharRanges);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72746: [clangd] Add a flag for implicit references in the Index

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/index/Ref.h:36
+  // one below.
+  Implicit = 1 << 3,
+  All = Declaration | Definition | Reference | Implicit,

kadircet wrote:
> instead of doing that, could we rather de-couple two enums completely and 
> have a `symbolRoleToRefKind`(and vice-versa) method instead(we already have 
> some customization in `toRefKind` now) ?
> 
> as current change increases the risk of overlapping in future(e.g. someone 
> might change symbolrole::declaration and cause failures/regressions in clangd)
note that this would also require a bump to version of `on-disk` index in 
clangd/index/Serialization.cpp, as old information regarding `RefKind` won't be 
usable anymore.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72746



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


[PATCH] D72755: [RISCV] Pass target-abi via module flag metadata

2020-01-15 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Please can you also add code for ensuring that the `target-abi` module flag 
matches the `-target-abi` command line flag in llvm?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72755



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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-initialization-list

2020-01-15 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware updated this revision to Diff 238219.
baloghadamsoftware added a comment.

Updated according to the comments.


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

https://reviews.llvm.org/D71199

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-prefer-member-initializer.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer-assignment.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-prefer-member-initializer.cpp
@@ -0,0 +1,407 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-prefer-member-initializer %t
+
+class Simple1 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple1() {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple1(int nn, double xx) {
+// CHECK-FIXES: Simple1(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple1() = default;
+};
+
+class Simple2 {
+  int n;
+  double x;
+  // CHECK-FIXES: double x{0.0};
+
+public:
+  Simple2() : n (0) {
+x = 0.0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple2(int nn, double xx) : n(nn) {
+// CHECK-FIXES: Simple2(int nn, double xx) : n(nn), x(xx) {
+x = xx;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'x' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple2() = default;
+};
+
+class Simple3 {
+  int n;
+  // CHECK-FIXES: int n{0};
+  double x;
+
+public:
+  Simple3() : x (0.0) {
+n = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in an in-class default member initializer [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  Simple3(int nn, double xx) : x(xx) {
+// CHECK-FIXES: Simple3(int nn, double xx) : n(nn), x(xx) {
+n = nn;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple3() = default;
+};
+
+int something_int();
+double something_double();
+
+class Simple4 {
+  int n;
+
+public:
+  Simple4() {
+// CHECK-FIXES: Simple4() : n(something_int()) {
+n = something_int();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: 'n' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]
+// CHECK-FIXES: {{^\ *$}}
+  }
+
+  ~Simple4() = default;
+};
+
+static bool dice();
+
+class Complex1 {
+  int n;
+  int m;
+
+public:
+  Complex1() : n(0) {
+if (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional expression
+  }
+
+  ~Complex1() = default;
+};
+
+class Complex2 {
+  int n;
+  int m;
+
+public:
+  Complex2() : n(0) {
+if (!dice())
+  return;
+m = 1;
+// NO-MESSAGES: initialization of 'm' follows a conditional expression
+  }
+
+  ~Complex2() = default;
+};
+
+class Complex3 {
+  int n;
+  int m;
+
+public:
+  Complex3() : n(0) {
+while (dice())
+  m = 1;
+// NO-MESSAGES: initialization of 'm' is nested in a conditional loop
+  }
+
+  ~Complex3() = default;
+};
+
+class Complex4 {
+  int n;
+  int m;
+
+public:
+  Complex4() : n(0) {
+while (!dice())
+  return;
+m = 1;
+// NO-MESSAGES:

[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-initialization-list

2020-01-15 Thread Balogh, Ádám via Phabricator via cfe-commits
baloghadamsoftware marked 6 inline comments as done.
baloghadamsoftware added a comment.

Thank you for the comments.




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:70
 
+- The 'readability-prefer-member-initializer' check was renamed to 
:doc:`cppcoreguidelines-prefer-member-initializer
+  `

Eugene.Zelenko wrote:
> Is it relevant?
Absouletely not, it is nonsense. Just added by the renaming script without me 
knowing about it.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:73
+
+- The 'readability-prefer-initialization-list' check was renamed to 
:doc:`readability-prefer-member-initializer
+  `

Eugene.Zelenko wrote:
> Is it relevant?
The same as above.


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

https://reviews.llvm.org/D71199



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


[PATCH] D72401: Fixes for spaces around C# object initializers

2020-01-15 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2870
+if (Left.is(TT_Unknown) && Right.is(tok::l_brace) && Left.Previous &&
+Left.Previous->is(tok::kw_new))
+  return true;

krasimir wrote:
> The `TT_Unknown` is a bit confusing -- why is it needed? If this is a 
> workaround for something, please add it as a comment. We might need to 
> improve the token detection later to allow for more complicated pattern 
> matching.
+1 that comment what was Left I think we need to be more specific


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72401



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


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-01-15 Thread Luboš Luňák via Phabricator via cfe-commits
llunak updated this revision to Diff 238217.
llunak edited the summary of this revision.
llunak removed a project: OpenMP.
llunak added a comment.

In order to simplify this, I've updated the patch to remove any reference to 
OpenMP and I've moved that part to https://reviews.llvm.org/D72759 .

This means that the only thing missing here should be adding tests. Which, as 
said above, I'm unsure how to do exactly given that it'd probably need 
duplicating all PCH tests to use this option, so please advise how to do this 
so that the patch can be accepted.

In D69585#1820849 , @ABataev wrote:

> I don't see any crashes in OpenMP tests, other tests just must be updated by 
> the author, if this patch will ever going to be landed. I don't think it is a 
> good idea to have a not fully functional implementation, even guarded by the 
> option.


Please see https://reviews.llvm.org/D72759 .


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

https://reviews.llvm.org/D69585

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/CC1Options.td
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/Sema.cpp


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -983,6 +983,12 @@
  LateParsedInstantiations.begin(),
  LateParsedInstantiations.end());
 LateParsedInstantiations.clear();
+
+if(LangOpts.PCHInstantiateTemplates) {
+  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations",
+ StringRef(""));
+  PerformPendingInstantiations();
+}
   }
 
   DiagnoseUnterminatedPragmaPack();
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3294,6 +3294,7 @@
 
   Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
   Opts.BuildingPCHWithObjectFile = Args.hasArg(OPT_building_pch_with_obj);
+  Opts.PCHInstantiateTemplates = Args.hasArg(OPT_pch_instantiate_templates);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/include/clang/Driver/CC1Options.td
===
--- clang/include/clang/Driver/CC1Options.td
+++ clang/include/clang/Driver/CC1Options.td
@@ -676,6 +676,8 @@
   HelpText<"Disable inclusion of timestamp in precompiled headers">;
 def building_pch_with_obj : Flag<["-"], "building-pch-with-obj">,
   HelpText<"This compilation is part of building a PCH with corresponding 
object file.">;
+def pch_instantiate_templates : Flag<["-"], "pch-instantiate-templates">,
+  HelpText<"Perform pending template instantiations already while building the 
PCH.">;
 
 def aligned_alloc_unavailable : Flag<["-"], "faligned-alloc-unavailable">,
   HelpText<"Aligned allocation/deallocation functions are unavailable">;
Index: clang/include/clang/Basic/LangOptions.def
===
--- clang/include/clang/Basic/LangOptions.def
+++ clang/include/clang/Basic/LangOptions.def
@@ -161,6 +161,7 @@
 BENIGN_LANGOPT(CompilingPCH, 1, 0, "building a pch")
 BENIGN_LANGOPT(BuildingPCHWithObjectFile, 1, 0, "building a pch which has a 
corresponding object file")
 BENIGN_LANGOPT(CacheGeneratedPCH, 1, 0, "cache generated PCH files in memory")
+BENIGN_LANGOPT(PCHInstantiateTemplates, 1, 0, "performing pending template 
instantiations already while building a pch")
 COMPATIBLE_LANGOPT(ModulesDeclUse, 1, 0, "require declaration of module 
uses")
 BENIGN_LANGOPT(ModulesSearchAll  , 1, 1, "searching even non-imported modules 
to find unresolved references")
 COMPATIBLE_LANGOPT(ModulesStrictDeclUse, 1, 0, "requiring declaration of 
module uses and all headers to be in modules")


Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -983,6 +983,12 @@
  LateParsedInstantiations.begin(),
  LateParsedInstantiations.end());
 LateParsedInstantiations.clear();
+
+if(LangOpts.PCHInstantiateTemplates) {
+  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations",
+ StringRef(""));
+  PerformPendingInstantiations();
+}
   }
 
   DiagnoseUnterminatedPragmaPack();
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -3294,6 +3294,7 @@
 
   Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
   Opts.BuildingPCHWithObjectFile = Ar

[clang-tools-extra] 5852475 - Bump the trunk major version to 11

2020-01-15 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2020-01-15T13:38:01+01:00
New Revision: 5852475e2c049ce29dcb1f0da3ac33035f8c9156

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

LOG: Bump the trunk major version to 11

and clear the release notes.

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/conf.py
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/conf.py
clang/docs/conf.py
libcxx/CMakeLists.txt
libcxx/docs/ReleaseNotes.rst
libcxx/docs/conf.py
libcxx/include/__config
libcxx/include/__libcpp_version
libunwind/CMakeLists.txt
libunwind/docs/conf.py
lld/docs/ReleaseNotes.rst
lld/docs/conf.py
llvm/CMakeLists.txt
llvm/docs/ReleaseNotes.rst
llvm/utils/gn/secondary/llvm/version.gni
llvm/utils/lit/lit/__init__.py
llvm/utils/release/build_llvm_package.bat
polly/docs/ReleaseNotes.rst
polly/docs/conf.py
pstl/docs/ReleaseNotes.rst
pstl/include/pstl/internal/pstl_config.h
pstl/test/pstl/version.pass.cpp

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 52e98cb23f50..74829f0618da 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -1,5 +1,5 @@
 
-Extra Clang Tools 10.0.0 (In-Progress) Release Notes
+Extra Clang Tools 11.0.0 (In-Progress) Release Notes
 
 
 .. contents::
@@ -10,7 +10,7 @@ Written by the `LLVM Team `_
 
 .. warning::
 
-   These are in-progress notes for the upcoming Extra Clang Tools 10 release.
+   These are in-progress notes for the upcoming Extra Clang Tools 11 release.
Release notes for previous releases can be found on
`the Download Page `_.
 
@@ -18,7 +18,7 @@ Introduction
 
 
 This document contains the release notes for the Extra Clang Tools, part of the
-Clang release 10.0.0. Here we describe the status of the Extra Clang Tools in
+Clang release 11.0.0. Here we describe the status of the Extra Clang Tools in
 some detail, including major improvements from the previous release and new
 feature work. All LLVM releases may be downloaded from the `LLVM releases web
 site `_.
@@ -27,12 +27,12 @@ For more information about Clang or LLVM, including 
information about
 the latest release, please see the `Clang Web Site `_ 
or
 the `LLVM Web Site `_.
 
-Note that if you are reading this file from a Subversion checkout or the
+Note that if you are reading this file from a Git checkout or the
 main Clang web page, this document applies to the *next* release, not
 the current one. To see the release notes for a specific release, please
 see the `releases page `_.
 
-What's New in Extra Clang Tools 10.0.0?
+What's New in Extra Clang Tools 11.0.0?
 ===
 
 Some of the major new features and improvements to Extra Clang Tools are listed
@@ -52,7 +52,7 @@ The improvements are...
 Improvements to clang-doc
 -
 
-- :doc:`clang-doc ` now generates documentation in HTML format.
+The improvements are...
 
 Improvements to clang-query
 ---
@@ -70,188 +70,18 @@ Improvements to clang-tidy
 New checks
 ^^
 
-- New :doc:`bugprone-bad-signal-to-kill-thread
-  ` check.
-
-  Finds ``pthread_kill`` function calls when a thread is terminated by 
-  raising ``SIGTERM`` signal.
-
-- New :doc:`bugprone-dynamic-static-initializers
-  ` check.
-
-  Finds instances where variables with static storage are initialized
-  dynamically in header files.
-
-- New :doc:`bugprone-infinite-loop
-  ` check.
-
-  Finds obvious infinite loops (loops where the condition variable is not
-  changed at all).
-
-- New :doc:`bugprone-not-null-terminated-result
-  ` check
-
-  Finds function calls where it is possible to cause a not null-terminated
-  result.
-
-- New :doc:`bugprone-signed-char-misuse
-  ` check.
-
-  Finds ``signed char`` to integer conversions which might indicate a
-  programming error.
-
-- New :doc:`cert-mem57-cpp
-  ` check.
-
-  Checks if an object of type with extended alignment is allocated by using
-  the default ``operator new``.
-
-- New :doc:`cert-oop58-cpp
-  ` check.
-
-  Finds assignments to the copied object and its direct or indirect members
-  in copy constructors and copy assignment operators.
-
-- New :doc:`cppcoreguidelines-init-variables
-  ` check.
-
-  Checks whether there are local variables that are declared without an initial
-  value.
-
-- New :doc:`darwin-dispatch-once-nonstatic
-  ` che

[PATCH] D72742: Don't assume promotable integers are zero/sign-extended already in x86-64 ABI.

2020-01-15 Thread Emilio Cobos Álvarez via Phabricator via cfe-commits
emilio added a comment.

The relevant discussion is here 
. From the "Parameter 
Passing" section in 
https://github.com/hjl-tools/x86-psABI/wiki/x86-64-psABI-1.0.pdf, there's no 
mention of sign-extension requirements for arguments.

> The only related thing is
>  "When a value of type _Bool is returned or passed in a register or on the 
> stack,
>  bit 0 contains the truth value and bits 1 to 7 shall be zero."
>  with a footnote:
>  "Other bits are left unspecified, hence the consumer side of those values 
> can rely on it being 0 or 1 when truncated to 8 bit."

which says that _Bool has only significant low 8 bits and the rest is 
unspecified.

Then Michael Matz (one of the editors of that document) clarifies below:

> Yes, we (intentionally) haven't required any extensions to happen for 
> arguments

or return values smaller than 64bit (e.g. we haven't even specified that 
arguments <= 32bit would be zero-extended in the high bits, as would have been
natural with the instruction set).  If LLVM relies on that it would be a bug.

There's more information on that bug and related ones, but I think the above 
should be enough :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72742



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


[PATCH] D72638: [clangd] Fix rename for explicit destructor calls

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:620
+  if (llvm::dyn_cast(E->getMemberDecl()))
+NameLocation = E->getEndLoc();
   Refs.push_back(ReferenceLoc{E->getQualifierLoc(),

instead of patching the source location for destructors. we should probably not 
report anything for them in here, as they will be reported correctly as 
typelocs.

So you can check for `E->getMemberNameInfo().getNamedTypoInfo()` and bail out 
if its non-null, which means this is a constructor/destructor/operator with a 
typeloc that will be visited separately and result in the same ref. That way we 
would also get rid of duplicate refs being reported by 
`findExplicitReferences`, API doesn't mention anything about those but most of 
the callers would fail in the presence of duplicates, therefore I think we 
shouldn't be reporting duplicates. (for example the main visitor actually makes 
sure typelocs are not visited twice).

also could you add unittests for constructor and operator cases as well to make 
sure we get exactly one reference for those as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72638



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


[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-15 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM created this revision.
MarkMurrayARM added reviewers: simon_tatham, miyuki, dmgreen.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls.
Herald added projects: clang, LLVM.

Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics and unit tests.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72761

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -0,0 +1,62 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vminnmaq_f16(<8 x half> %a, <8 x half> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vminnma.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.arm.mve.vminnma.v8f16(<8 x half> %a, <8 x half> %b)
+  ret <8 x half> %0
+}
+
+declare <8 x half> @llvm.arm.mve.vminnma.v8f16(<8 x half>, <8 x half>) #1
+
+define arm_aapcs_vfpcc <4 x float> @test_vminnmaq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vminnma.f32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.arm.mve.vminnma.v4f32(<4 x float> %a, <4 x float> %b)
+  ret <4 x float> %0
+}
+
+declare <4 x float> @llvm.arm.mve.vminnma.v4f32(<4 x float>, <4 x float>) #1
+
+define arm_aapcs_vfpcc <8 x half> @test_vminnmaq_m_f16(<8 x half> %a, <8 x half> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vminnmat.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.vminnma.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #1
+
+declare <8 x half> @llvm.arm.mve.vminnma.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>) #1
+
+define arm_aapcs_vfpcc <4 x float> @test_vminnmaq_m_f32(<4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vminnmat.f32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x float> @llvm.arm.mve.vminnma.predicated.v4f32.v4i1(<4 x float> %a, <4 x float> %b, <4 x i1> %1)
+  ret <4 x float> %2
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #1
+
+declare <4 x float> @llvm.arm.mve.vminnma.predicated.v4f32.v4i1(<4 x float>, <4 x float>, <4 x i1>) #1
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
@@ -0,0 +1,92 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vminaq_s8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmina.s8 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <16 x i8> @llvm.arm.mve.vmina.v16i8.v16i8(<16 x i8> %a, <16 x i8> %b)
+  ret <16 x i8> %0
+}
+
+declare <16 x i8> @llvm.arm.mve.vmina.v16i8.v16i8(<16 x i8>, <16 x i8>) #1
+
+define arm_aapcs_vfpcc <8 x i16> @test_vminaq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmina.s16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x i16> @llvm.arm.mve.vmina.v8i16.v8i16(<8 x i16> %a, <8 x i16> %b)
+  ret <8 x i16> %0
+}
+
+declare <8 x i16> @llvm.arm.mve.vmina.v8i16.v8i16(<8 x i16>, <8 x i16>) #1
+
+define arm_aapcs_vfpcc <4 x i32> @test_vminaq_s32(<4 x i32> %a, <4 x i32> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s32:
+; CHECK:   @ %bb.0: @ 

[PATCH] D68115: Zero initialize padding in unions

2020-01-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D68115#1820622 , @vitalybuka wrote:

> In D68115#1820579 , @aaron.ballman 
> wrote:
>
> > In D68115#1820462 , @vitalybuka 
> > wrote:
> >
> > > I would be happy to finish this patch if we agree on something.
> > >
> > > So if I understand this the proposal is to have something like 
> > > -fzero-union-padding which is off by default.
> > >  When it's OFF compiler will continue to do whatever it does now.
> > >  When it's ON it will set zeroes into padding with or without 
> > > -ftrivial-auto-var-init.
> > >  Is this correct?
> >
> >
> > In general, I believe so, yes. To be clear, it only sets zeros into union 
> > padding, not *all* padding. I do not have an opinion on whether we want it 
> > to be `-fzero-union-padding` as opposed to `-finit-union-padding` that 
> > honors the pattern from `-ftrivial-auto-init=pattern` and defaults to zero 
> > if no pattern is specified.
>
>
> They whole point of the patch was to avoid breaking code by 
> -ftrivial-auto-init=pattern  with "MyUnion my_union = {}".  So to fix that 
> only `-fzero-union-padding` behavior helpful.
>  `-ftrivial-auto-init=pattern` as-is already inits union padding with 
> patterns.


Ah, okay, good to know!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68115



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


[clang] ee0f1f1 - Further implement CWG 2292

2020-01-15 Thread Aaron Ballman via cfe-commits

Author: Soumi Manna
Date: 2020-01-15T08:49:44-05:00
New Revision: ee0f1f1edc3ec0d4e698d50cc3180217448802b7

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

LOG: Further implement CWG 2292

The core issue is that simple-template-id is ambiguous between class-name
and type-name. This fixes PR43966.

Added: 
clang/test/SemaCXX/pseudo-destructor-name.cpp

Modified: 
clang/lib/Sema/SemaExprCXX.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index a73e6906fceb..96e18105df78 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -192,8 +192,10 @@ ParsedType Sema::getDestructorName(SourceLocation TildeLoc,
   AlreadySearched = true;
   LookupCtx = DC;
   isDependent = false;
-} else if (DC && isa(DC)) {
-  LookAtPrefix = false;
+} else if (auto *RD = dyn_cast_or_null(DC)) {
+  if ((RD->hasDefinition() && RD->hasSimpleDestructor()) ||
+  !RD->hasDefinition())
+LookAtPrefix = false;
   LookInScope = true;
 }
 

diff  --git a/clang/test/SemaCXX/pseudo-destructor-name.cpp 
b/clang/test/SemaCXX/pseudo-destructor-name.cpp
new file mode 100644
index ..cc7c22b8dc4d
--- /dev/null
+++ b/clang/test/SemaCXX/pseudo-destructor-name.cpp
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// expected-no-diagnostics
+
+struct AAA
+{
+struct BBB
+{
+~BBB() {}
+};
+
+typedef BBB BBB_alias;
+};
+
+typedef AAA::BBB BBB_alias2;
+
+int
+main()
+{
+AAA::BBB_alias *ptr1 = new AAA::BBB_alias();
+AAA::BBB_alias *ptr2 = new AAA::BBB_alias();
+
+ptr1->AAA::BBB_alias::~BBB_alias(); // Now OK
+ptr2->AAA::BBB_alias::~BBB();   // OK
+ptr1->~BBB_alias2();// OK
+return 0;
+}



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


[PATCH] D72518: [clang] New __attribute__((arm_mve_strict_polymorphism)).

2020-01-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from changing the attribute name back to what it was (sorry about that), 
this LGTM!




Comment at: clang/include/clang/Basic/Attr.td:1474
+def ArmMveStrictPolymorphism : TypeAttr {
+  let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
+  let Documentation = [ArmMveStrictPolymorphismDocs];

simon_tatham wrote:
> aaron.ballman wrote:
> > Why does this have a `__clang` prefix? That seems a bit strange given that 
> > the attribute can be spelled 
> > `[[clang::__clang_arm_mve_strict_polymorphism]]`. I'd probably drop the 
> > `__clang_` prefix entirely.
> I was going by your recommendation for the spelling of `ArmMveAlias` in 
> D67159#1659296. I've taken the `__clang_` off this one; should I do the same 
> to that one as well, while I'm here?
> 
> (It ought to be safe to do that after the fact, because `ArmMveAlias` is 
> locked down so hard that surely it //can't// have any users except the 
> tablegen MveEmitter backend, which is easy to change.)
Oh, that's right, this is one of those "users should not write this themselves, 
it's only for compiler internals" attributes. I am sorry for the churn on this 
review, but we should probably keep the `__clang` here for consistency with the 
other attribute. Thank you for reminding me about the prior decision!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72518



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


[PATCH] D71365: expand printf when compiling HIP to AMDGPU

2020-01-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm 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/D71365/new/

https://reviews.llvm.org/D71365



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


[PATCH] D72635: Add "context" capability to Thread Safety Analysis

2020-01-15 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Can you give some examples of code where you think the diagnostics are 
inappropriate? One of the goals of role-based capabilities is for you to name 
the capabilities as you see fit, so it's possible that there is a different way 
for us to surface those diagnostics for your situation that doesn't involve 
adding another one-off name for capabilities.


Repository:
  rC Clang

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

https://reviews.llvm.org/D72635



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


[PATCH] D71467: [FPEnv] Generate constrained FP comparisons from clang

2020-01-15 Thread Ulrich Weigand via Phabricator via cfe-commits
uweigand added a comment.

In D71467#1820589 , @rjmccall wrote:

> I think I have a slight preference for the second option, where there's a 
> single method that does all the work for the two cases.


OK, now checked in as 870137d 
 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71467



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kadircet marked an inline comment as done.
Closed by commit rG4d14bfaa2cb1: [clangd] Show hower info for expressions 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500

Files:
  clang-tools-extra/clangd/Hover.cpp
  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
@@ -601,6 +601,19 @@
   R"cpp(// non-named decls don't get hover. Don't crash!
 ^static_assert(1, "");
   )cpp",
+  R"cpp(// non-evaluatable expr
+  template  void foo() {
+(void)[[size^of]](T);
+  })cpp",
+  // literals
+  "auto x = t^rue;",
+  "auto x = '^A';",
+  "auto x = ^(int){42};",
+  "auto x = ^42.;",
+  "auto x = ^42.0i;",
+  "auto x = ^42;",
+  "auto x = ^nullptr;",
+  "auto x = ^\"asdf\";",
   };
 
   for (const auto &Test : Tests) {
@@ -1501,6 +1514,26 @@
 HI.Name = "cls > >";
 HI.Documentation = "type of nested templates.";
   }},
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -13,6 +13,7 @@
 #include "FindTarget.h"
 #include "FormattedString.h"
 #include "Logger.h"
+#include "ParsedAST.h"
 #include "Selection.h"
 #include "SourceCode.h"
 #include "index/SymbolCollector.h"
@@ -21,13 +22,19 @@
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
 #include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Type.h"
 #include "clang/Index/IndexSymbol.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 
@@ -410,6 +417,45 @@
   }
   return HI;
 }
+
+bool isLiteral(const Expr *E) {
+  // Unfortunately there's no common base Literal classes inherits from
+  // (apart from Expr), therefore this is a nasty blacklist.
+  return llvm::isa(E) || llvm::isa(E) ||
+ llvm::isa(E) ||
+ llvm::isa(E) ||
+ llvm::isa(E) || llvm::isa(E) ||
+ llvm::isa(E) || llvm::isa(E) ||
+ llvm::isa(E) || llvm::isa(E);
+}
+
+llvm::StringLiteral getNameForExpr(const Expr *E) {
+  // FIXME: Come up with names for `special` expressions.
+  return "expression";
+}
+
+// Generates hover info for evaluatable expressions.
+// FIXME: Support hover for literals (esp user-defined)
+llvm::Optional getHoverContents(const Expr *E, ParsedAST &AST) {
+  // There's not much value in hovering over "42" and getting a hover card
+  // saying "42 is an int", similar for other literals.
+  if (isLiteral(E))
+return llvm::None;
+
+  HoverInfo HI;
+  // For expressions we currently print the type and the value, iff it is
+  // evaluatable.
+  if (auto Val = printExprValue(E, AST.getASTContext())) {
+auto Policy =
+printingPolicyForDecls(AST.getASTContext().getPrintingPolicy());
+Policy.SuppressTagKeyword = true;
+HI.Type = E->getType().getAsString(Policy);
+HI.Value = *Val;
+HI.Name = getNameForExpr(E);
+return HI;
+  }
+  return llvm::None;
+}
 } // namespace
 
 llvm::Optional getHover(ParsedAST &AST, Position Pos,
@@ -439,11 +485,11 @@
 // Look for a close enclosing expression to show the value of.
 if (!HI->Value)
   HI->Value = printExprValue(N, AST.getASTContext());
+  } else if (const Expr *E = N->ASTNode.get()) {
+HI = getHoverContents(E, AST);
   }
   // FIXME: support hovers for other nodes?
-  //  - certain expressions (sizeof etc)
   //  - built-in types
-  //  - literals (esp user-defined)
 }
   }
 
@@ -469,6 +515,8 @@
   // class `X`
   //
   // function `foo` → `int`
+  //

[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-15 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added inline comments.



Comment at: clang/include/clang/Basic/arm_mve.td:289
+  def vmaxaq: Intrinsic $a, $b)>;
 }

I wonder if we should implement at least the simple case (integer and 
unpredicated) using standard IR nodes instead of an IR intrinsic?

We already implement `vmaxq` using an icmp and a select. We haven't implemented 
`vabsq` yet, but when we do, it will surely be done in a similar way, to take 
advantage of the existing pattern matching showcased in 
`llvm/test/CodeGen/Thumb2/mve-abs.ll`. So possibly we should code-generate 
`vmaxaq(a,b)` as if it was `vmaxq(a, vabsq(b))`, and write a more complicated 
isel pattern that will match that whole tree?

The advantage would be that if a user had //literally// written a combination 
of `vmaxq` and `vabsq`, codegen would be able to fold them together into a 
single instruction at compile time.

The FP versions //might// make sense to do the same way, using the standard 
`@llvm.fabs` IR intrinsic for the abs part.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72761



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/Hover.cpp:519
+  //
+  // expression : `int`
   // Note that we are making use of a level-3 heading because VSCode renders

sammccall wrote:
> nit: this is just "expression"
not yet, it will be after D72623 lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500



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


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238243.
kadircet marked 2 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  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
@@ -1699,6 +1699,7 @@
 HI.NamespaceScope.emplace();
   },
   R"(class foo
+
 documentation
 
 template  class Foo {})",
@@ -1722,6 +1723,7 @@
 HI.Definition = "ret_type foo(params) {}";
   },
   R"(function foo → ret_type
+
 - 
 - type
 - type foo
@@ -1740,6 +1742,7 @@
 HI.Definition = "def";
   },
   R"(variable foo : type
+
 Value = value
 
 // In test::bar
@@ -1765,6 +1768,30 @@
   EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
 }
 
+// This is a separate test as rulers behave differently in markdown vs
+// plaintext.
+TEST(Hover, PresentRulers) {
+  HoverInfo HI;
+  HI.Kind = index::SymbolKind::Variable;
+  HI.Name = "foo";
+  HI.Value = "val";
+  HI.Definition = "def";
+
+  EXPECT_EQ(HI.present().asMarkdown(), R"md(### variable `foo`  
+
+---
+Value \= `val`  
+
+---
+```cpp
+def
+```)md");
+  EXPECT_EQ(HI.present().asPlainText(), R"pt(variable foo
+
+Value = val
+
+def)pt");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -136,13 +136,37 @@
   EXPECT_EQ(D.asPlainText(), ExpectedText);
 }
 
-TEST(Document, Spacer) {
+TEST(Document, Ruler) {
   Document D;
   D.addParagraph().appendText("foo");
-  D.addSpacer();
+  D.addRuler();
+
+  // Ruler followed by paragraph.
   D.addParagraph().appendText("bar");
-  EXPECT_EQ(D.asMarkdown(), "foo  \n\nbar");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nbar");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addCodeBlock("bar");
+  // Ruler followed by a codeblock.
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n```cpp\nbar\n```");
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  // Ruler followed by another ruler
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addRuler();
+  EXPECT_EQ(D.asMarkdown(), "foo");
+  EXPECT_EQ(D.asPlainText(), "foo");
+
+  // Multiple rulers between blocks
+  D.addRuler();
+  D.addParagraph().appendText("foo");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nfoo");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nfoo");
 }
 
 TEST(Document, Heading) {
@@ -182,15 +206,11 @@
 foo
 ```)md";
   EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
-  // FIXME: we shouldn't have 2 empty lines in between. A solution might be
-  // having a `verticalMargin` method for blocks, and let container insert new
-  // lines according to that before/after blocks.
   ExpectedPlainText =
   R"pt(foo
   bar
   baz
 
-
 foo)pt";
   EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -532,6 +532,8 @@
 Header.appendCode(*Type);
   }
 
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();
   // For functions we display signature in a list form, e.g.:
   // - `bool param1`
   // - `int param2 = 5`
@@ -555,6 +557,7 @@
 Output.addParagraph().appendText(Documentation);
 
   if (!Definition.empty()) {
+Output.addRuler();
 std::string ScopeComment;
 // Drop trailing "::".
 if (!LocalScope.empty()) {
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -33,6 +33,7 @@
   std::string asMarkdown() const;
   std::string asPlainText() const;
 
+  virtual bool isRuler() const { return false; }
   virtual ~Block() = default;
 };
 
@@ -82,8 +83,8 @@
 public:
   /// Adds a semantical block that will be separate from others.
   Paragraph &addParagraph();
-  /// Inserts a vertical space into the document.
-  void addSpacer();
+  /// Inserts a horizontal separator to the document.
+  void addRuler();
   /// Adds a block of code. This translates to a ``` block in markdo

[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG44f9c7a820c1: [clangd] Rearrange type, returntype and 
parameters in hover card (authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/test/hover.test
  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
@@ -1722,8 +1722,10 @@
 HI.NamespaceScope = "ns::";
 HI.Definition = "ret_type foo(params) {}";
   },
-  R"(function foo → ret_type
+  R"(function foo
 
+🡺 ret_type
+Parameters:
 - 
 - type
 - type foo
@@ -1741,8 +1743,9 @@
 HI.Type = "type";
 HI.Definition = "def";
   },
-  R"(variable foo : type
+  R"(variable foo
 
+Type: type
 Value = value
 
 // In test::bar
@@ -1763,9 +1766,8 @@
   HoverInfo HI;
   HI.Kind = index::SymbolKind::Variable;
   HI.Name = "foo";
-  HI.Type = "type";
 
-  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
+  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo`");
 }
 
 // This is a separate test as rulers behave differently in markdown vs
Index: clang-tools-extra/clangd/test/hover.test
===
--- clang-tools-extra/clangd/test/hover.test
+++ clang-tools-extra/clangd/test/hover.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"contents": {
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo\n\n🡺 void\n\nvoid foo()"
 # CHECK-NEXT:},
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -510,13 +510,14 @@
 markup::Document HoverInfo::present() const {
   markup::Document Output;
   // Header contains a text of the form:
-  // variable `var` : `int`
+  // variable `var`
   //
   // class `X`
   //
-  // function `foo` → `int`
+  // function `foo`
+  //
+  // expression
   //
-  // expression : `int`
   // Note that we are making use of a level-3 heading because VSCode renders
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
@@ -524,27 +525,30 @@
   Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
-  if (ReturnType) {
-Header.appendText("→");
-Header.appendCode(*ReturnType);
-  } else if (Type) {
-Header.appendText(":");
-Header.appendCode(*Type);
-  }
 
   // Put a linebreak after header to increase readability.
   Output.addRuler();
-  // For functions we display signature in a list form, e.g.:
-  // - `bool param1`
-  // - `int param2 = 5`
-  if (Parameters && !Parameters->empty()) {
-markup::BulletList &L = Output.addBulletList();
-for (const auto &Param : *Parameters) {
-  std::string Buffer;
-  llvm::raw_string_ostream OS(Buffer);
-  OS << Param;
-  L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  // Print Types on their own lines to reduce chances of getting line-wrapped by
+  // editor, as they might be long.
+  if (ReturnType) {
+// For functions we display signature in a list form, e.g.:
+// 🡺 `x`
+// Parameters:
+// - `bool param1`
+// - `int param2 = 5`
+Output.addParagraph().appendText("🡺").appendCode(*ReturnType);
+if (Parameters && !Parameters->empty()) {
+  Output.addParagraph().appendText("Parameters:");
+  markup::BulletList &L = Output.addBulletList();
+  for (const auto &Param : *Parameters) {
+std::string Buffer;
+llvm::raw_string_ostream OS(Buffer);
+OS << Param;
+L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  }
 }
+  } else if (Type) {
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }
 
   if (Value) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd74a3d470c31: [clangd] Add a ruler after header in hover 
(authored by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622

Files:
  clang-tools-extra/clangd/FormattedString.cpp
  clang-tools-extra/clangd/FormattedString.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
  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
@@ -1699,6 +1699,7 @@
 HI.NamespaceScope.emplace();
   },
   R"(class foo
+
 documentation
 
 template  class Foo {})",
@@ -1722,6 +1723,7 @@
 HI.Definition = "ret_type foo(params) {}";
   },
   R"(function foo → ret_type
+
 - 
 - type
 - type foo
@@ -1740,6 +1742,7 @@
 HI.Definition = "def";
   },
   R"(variable foo : type
+
 Value = value
 
 // In test::bar
@@ -1765,6 +1768,30 @@
   EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
 }
 
+// This is a separate test as rulers behave differently in markdown vs
+// plaintext.
+TEST(Hover, PresentRulers) {
+  HoverInfo HI;
+  HI.Kind = index::SymbolKind::Variable;
+  HI.Name = "foo";
+  HI.Value = "val";
+  HI.Definition = "def";
+
+  EXPECT_EQ(HI.present().asMarkdown(), R"md(### variable `foo`  
+
+---
+Value \= `val`  
+
+---
+```cpp
+def
+```)md");
+  EXPECT_EQ(HI.present().asPlainText(), R"pt(variable foo
+
+Value = val
+
+def)pt");
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
===
--- clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
+++ clang-tools-extra/clangd/unittests/FormattedStringTests.cpp
@@ -136,13 +136,37 @@
   EXPECT_EQ(D.asPlainText(), ExpectedText);
 }
 
-TEST(Document, Spacer) {
+TEST(Document, Ruler) {
   Document D;
   D.addParagraph().appendText("foo");
-  D.addSpacer();
+  D.addRuler();
+
+  // Ruler followed by paragraph.
   D.addParagraph().appendText("bar");
-  EXPECT_EQ(D.asMarkdown(), "foo  \n\nbar");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nbar");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addCodeBlock("bar");
+  // Ruler followed by a codeblock.
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\n```cpp\nbar\n```");
   EXPECT_EQ(D.asPlainText(), "foo\n\nbar");
+
+  // Ruler followed by another ruler
+  D = Document();
+  D.addParagraph().appendText("foo");
+  D.addRuler();
+  D.addRuler();
+  EXPECT_EQ(D.asMarkdown(), "foo");
+  EXPECT_EQ(D.asPlainText(), "foo");
+
+  // Multiple rulers between blocks
+  D.addRuler();
+  D.addParagraph().appendText("foo");
+  EXPECT_EQ(D.asMarkdown(), "foo  \n\n---\nfoo");
+  EXPECT_EQ(D.asPlainText(), "foo\n\nfoo");
 }
 
 TEST(Document, Heading) {
@@ -182,15 +206,11 @@
 foo
 ```)md";
   EXPECT_EQ(D.asMarkdown(), ExpectedMarkdown);
-  // FIXME: we shouldn't have 2 empty lines in between. A solution might be
-  // having a `verticalMargin` method for blocks, and let container insert new
-  // lines according to that before/after blocks.
   ExpectedPlainText =
   R"pt(foo
   bar
   baz
 
-
 foo)pt";
   EXPECT_EQ(D.asPlainText(), ExpectedPlainText);
 }
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -532,6 +532,8 @@
 Header.appendCode(*Type);
   }
 
+  // Put a linebreak after header to increase readability.
+  Output.addRuler();
   // For functions we display signature in a list form, e.g.:
   // - `bool param1`
   // - `int param2 = 5`
@@ -555,6 +557,7 @@
 Output.addParagraph().appendText(Documentation);
 
   if (!Definition.empty()) {
+Output.addRuler();
 std::string ScopeComment;
 // Drop trailing "::".
 if (!LocalScope.empty()) {
Index: clang-tools-extra/clangd/FormattedString.h
===
--- clang-tools-extra/clangd/FormattedString.h
+++ clang-tools-extra/clangd/FormattedString.h
@@ -33,6 +33,7 @@
   std::string asMarkdown() const;
   std::string asPlainText() const;
 
+  virtual bool isRuler() const { return false; }
   virtual ~Block() = default;
 };
 
@@ -82,8 +83,8 @@
 public:
   /// Adds a semantical block that will be separate from others.
   Paragraph &addParagraph();
-  /// Inserts a vertical space into the document.
-  void addSpacer();
+  /// Inserts a horizontal separator to the document.
+  void addRuler();
   /// Adds a block of code. Th

[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D72623#1819153 , @lh123 wrote:

> I think the character "🡺" should be avoided, as it may not display properly 
> in some environments.


I believe most of the editors should be able to display unicode characters, 
please let us know if you've got any concrete examples of corrupt rendering.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623



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


[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238245.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72498

Files:
  clang-tools-extra/clangd/Hover.cpp
  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
@@ -1534,6 +1534,53 @@
 HI.Type = "unsigned long";
 HI.Value = "1";
   }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  decltype(a) [[b^]] = a;)cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "decltype(a) b = a";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.Name = "b";
+HI.Type = "int";
+  }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  decltype(a) c;
+  decltype(c) [[b^]] = a;)cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "decltype(c) b = a";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.Name = "b";
+HI.Type = "int";
+  }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  const decltype(a) [[b^]] = a;)cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "const decltype(a) b = a";
+HI.Kind = index::SymbolKind::Variable;
+HI.NamespaceScope = "";
+HI.Name = "b";
+HI.Type = "int";
+  }},
+  {
+  R"cpp(// type with decltype
+  int a;
+  auto [[f^oo]]() -> decltype(a) { return 0; })cpp",
+  [](HoverInfo &HI) {
+HI.Definition = "auto foo() -> decltype(a)";
+HI.Kind = index::SymbolKind::Function;
+HI.NamespaceScope = "";
+HI.Name = "foo";
+HI.Type = "auto () -> decltype(a)";
+HI.ReturnType = "int";
+HI.Parameters.emplace();
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -265,12 +265,17 @@
   } else if (llvm::isa(FD)) {
 HI.ReturnType = "void";
   } else {
-HI.ReturnType = FD->getReturnType().getAsString(Policy);
-
-QualType FunctionType = FD->getType();
+QualType QT = FD->getReturnType();
+// TypePrinter doesn't resolve decltypes, so resolve them here. We are going
+// to include spelling "decltype(X)" in `HoverInfo::Definition` anyway.
+while (auto *DT = QT->getAs())
+  QT = DT->getUnderlyingType();
+HI.ReturnType = QT.getAsString(Policy);
+
+QT = FD->getType();
 if (const VarDecl *VD = llvm::dyn_cast(D)) // Lambdas
-  FunctionType = VD->getType().getDesugaredType(D->getASTContext());
-HI.Type = FunctionType.getAsString(Policy);
+  QT = VD->getType().getDesugaredType(D->getASTContext());
+HI.Type = QT.getAsString(Policy);
   }
   // FIXME: handle variadics.
 }
@@ -352,8 +357,14 @@
   // Fill in types and params.
   if (const FunctionDecl *FD = getUnderlyingFunction(D))
 fillFunctionTypeAndParams(HI, D, FD, Policy);
-  else if (const auto *VD = dyn_cast(D))
-HI.Type = VD->getType().getAsString(Policy);
+  else if (const auto *VD = dyn_cast(D)) {
+QualType QT = VD->getType();
+// TypePrinter doesn't resolve decltypes, so resolve them here. We are going
+// to include spelling "decltype(X)" in `HoverInfo::Definition` anyway.
+while (auto *DT = QT->getAs())
+  QT = DT->getUnderlyingType();
+HI.Type = QT.getAsString(Policy);
+  }
 
   // Fill in value with evaluated initializer if possible.
   if (const auto *Var = dyn_cast(D)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 238244.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/test/hover.test
  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
@@ -1722,8 +1722,10 @@
 HI.NamespaceScope = "ns::";
 HI.Definition = "ret_type foo(params) {}";
   },
-  R"(function foo → ret_type
+  R"(function foo
 
+🡺 ret_type
+Parameters:
 - 
 - type
 - type foo
@@ -1741,8 +1743,9 @@
 HI.Type = "type";
 HI.Definition = "def";
   },
-  R"(variable foo : type
+  R"(variable foo
 
+Type: type
 Value = value
 
 // In test::bar
@@ -1763,9 +1766,8 @@
   HoverInfo HI;
   HI.Kind = index::SymbolKind::Variable;
   HI.Name = "foo";
-  HI.Type = "type";
 
-  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo` \\: `type`");
+  EXPECT_EQ(HI.present().asMarkdown(), "### variable `foo`");
 }
 
 // This is a separate test as rulers behave differently in markdown vs
Index: clang-tools-extra/clangd/test/hover.test
===
--- clang-tools-extra/clangd/test/hover.test
+++ clang-tools-extra/clangd/test/hover.test
@@ -9,7 +9,7 @@
 # CHECK-NEXT:  "result": {
 # CHECK-NEXT:"contents": {
 # CHECK-NEXT:  "kind": "plaintext",
-# CHECK-NEXT:  "value": "function foo → void\n\nvoid foo()"
+# CHECK-NEXT:  "value": "function foo\n\n🡺 void\n\nvoid foo()"
 # CHECK-NEXT:},
 # CHECK-NEXT:"range": {
 # CHECK-NEXT:  "end": {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -510,13 +510,14 @@
 markup::Document HoverInfo::present() const {
   markup::Document Output;
   // Header contains a text of the form:
-  // variable `var` : `int`
+  // variable `var`
   //
   // class `X`
   //
-  // function `foo` → `int`
+  // function `foo`
+  //
+  // expression
   //
-  // expression : `int`
   // Note that we are making use of a level-3 heading because VSCode renders
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
@@ -524,27 +525,30 @@
   Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
-  if (ReturnType) {
-Header.appendText("→");
-Header.appendCode(*ReturnType);
-  } else if (Type) {
-Header.appendText(":");
-Header.appendCode(*Type);
-  }
 
   // Put a linebreak after header to increase readability.
   Output.addRuler();
-  // For functions we display signature in a list form, e.g.:
-  // - `bool param1`
-  // - `int param2 = 5`
-  if (Parameters && !Parameters->empty()) {
-markup::BulletList &L = Output.addBulletList();
-for (const auto &Param : *Parameters) {
-  std::string Buffer;
-  llvm::raw_string_ostream OS(Buffer);
-  OS << Param;
-  L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  // Print Types on their own lines to reduce chances of getting line-wrapped by
+  // editor, as they might be long.
+  if (ReturnType) {
+// For functions we display signature in a list form, e.g.:
+// 🡺 `x`
+// Parameters:
+// - `bool param1`
+// - `int param2 = 5`
+Output.addParagraph().appendText("🡺").appendCode(*ReturnType);
+if (Parameters && !Parameters->empty()) {
+  Output.addParagraph().appendText("Parameters:");
+  markup::BulletList &L = Output.addBulletList();
+  for (const auto &Param : *Parameters) {
+std::string Buffer;
+llvm::raw_string_ostream OS(Buffer);
+OS << Param;
+L.addItem().addParagraph().appendCode(std::move(OS.str()));
+  }
 }
+  } else if (Type) {
+Output.addParagraph().appendText("Type: ").appendCode(*Type);
   }
 
   if (Value) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69585: PerformPendingInstatiations() already in the PCH

2020-01-15 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

I'm glad you're fixing this, this problem has came up in our profile traces as 
well.

> The only way this breaks things that I've managed to find is if a .cpp file 
> using the PCH adds another template specialization that's not mentioned in 
> the PCH

What is the error?

Could you please add test(s)? We need a test especially for the error you're 
mentioning. It has to be clear to the user that an error message in the /Yu 
.obj (because of a specialization) in fact occurs because usage of 
`-pch-instantiate-templates` in the pch.obj.

Have you investigated how MSVC handles this? Using a PCH in a OBJ is a lot 
faster with MSVC, so I'm guessing they have some trick.




Comment at: clang/lib/Sema/Sema.cpp:987
+// OpenMP-specific code paths, see https://reviews.llvm.org/D69585 .
+if(LangOpts.PCHInstantiateTemplates && !LangOpts.OpenMP) {
+  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations",

clang-format please.



Comment at: clang/lib/Sema/Sema.cpp:988
+if(LangOpts.PCHInstantiateTemplates) {
+  llvm::TimeTraceScope TimeScope("PerformPendingInstantiations",
+ StringRef(""));

Why not move this time trace scope inside `PerformPendingInstantiations()`? 
(and the other one at L927 too)


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

https://reviews.llvm.org/D69585



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


[clang] ada01d1 - [clang] New __attribute__((__clang_arm_mve_strict_polymorphism)).

2020-01-15 Thread Simon Tatham via cfe-commits

Author: Simon Tatham
Date: 2020-01-15T15:04:10Z
New Revision: ada01d1b869763f7d5d3438dcfce02066b06ab0a

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

LOG: [clang] New __attribute__((__clang_arm_mve_strict_polymorphism)).

This is applied to the vector types defined in  for use
with the intrinsics for the ARM MVE vector architecture.

Its purpose is to inhibit lax vector conversions, but only in the
context of overload resolution of the MVE polymorphic intrinsic
functions. This solves an ambiguity problem with polymorphic MVE
intrinsics that take a vector and a scalar argument: the scalar
argument can often have the wrong integer type due to default integer
promotions or unsuffixed literals, and therefore, the type of the
vector argument should be considered trustworthy when resolving MVE
polymorphism.

As part of the same change, I've added the new attribute to the
declarations generated by the MveEmitter Tablegen backend (and
corrected a namespace issue with the other attribute while I was
there).

Reviewers: aaron.ballman, dmgreen

Reviewed By: aaron.ballman

Subscribers: kristof.beyls, JDevlieghere, cfe-commits

Tags: #clang

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

Added: 
clang/test/Sema/overload-arm-mve.c

Modified: 
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/AST/TypePrinter.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaType.cpp
clang/utils/TableGen/MveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 16556b5f0745..10db2a868dce 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -1479,6 +1479,11 @@ def NeonVectorType : TypeAttr {
   let ASTNode = 0;
 }
 
+def ArmMveStrictPolymorphism : TypeAttr, TargetSpecificAttr {
+  let Spellings = [Clang<"__clang_arm_mve_strict_polymorphism">];
+  let Documentation = [ArmMveStrictPolymorphismDocs];
+}
+
 def NoUniqueAddress : InheritableAttr, TargetSpecificAttr 
{
   let Spellings = [CXX11<"", "no_unique_address", 201803>];
   let Subjects = SubjectList<[NonBitField], ErrorDiag>;

diff  --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 03d36ae7ab32..456edd1daafc 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -4789,3 +4789,45 @@ close the handle. It is also assumed to require an open 
handle to work with.
   zx_status_t zx_handle_close(zx_handle_t handle [[clang::release_handle]]);
   }];
 }
+
+def ArmMveStrictPolymorphismDocs : Documentation {
+let Category = DocCatType;
+let Content = [{
+This attribute is used in the implementation of the ACLE intrinsics for the Arm
+MVE instruction set. It is used to define the vector types used by the MVE
+intrinsics.
+
+Its effect is to modify the behavior of a vector type with respect to function
+overloading. If a candidate function for overload resolution has a parameter
+type with this attribute, then the selection of that candidate function will be
+disallowed if the actual argument can only be converted via a lax vector
+conversion. The aim is to prevent spurious ambiguity in ARM MVE polymorphic
+intrinsics.
+
+.. code-block:: c++
+
+  void overloaded(uint16x8_t vector, uint16_t scalar);
+  void overloaded(int32x4_t vector, int32_t scalar);
+  uint16x8_t myVector;
+  uint16_t myScalar;
+
+  // myScalar is promoted to int32_t as a side effect of the addition,
+  // so if lax vector conversions are considered for myVector, then
+  // the two overloads are equally good (one argument conversion
+  // each). But if the vector has the __clang_arm_mve_strict_polymorphism
+  // attribute, only the uint16x8_t,uint16_t overload will match.
+  overloaded(myVector, myScalar + 1);
+
+However, this attribute does not prohibit lax vector conversions in contexts
+other than overloading.
+
+.. code-block:: c++
+
+  uint16x8_t function();
+
+  // This is still permitted with lax vector conversion enabled, even
+  // if the vector types have __clang_arm_mve_strict_polymorphism
+  int32x4_t result = function();
+
+}];
+}

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 7d8231d140e4..ffa326932a1c 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6593,6 +6593,8 @@ def 
note_objc_unsafe_perform_selector_method_declared_here :  Note<
   "method %0 that returns %1 declared here">;
 def err_attribute_arm_mve_alias : Error<
   "'__clang_arm_mve_alias' attribute can only be applied to an ARM MVE 
builtin">;
+def err_attribute_arm_mv

[PATCH] D72622: [clangd] Add a ruler after header in hover

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61885 tests passed, 0 failed 
and 782 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72622



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


[PATCH] D72755: [RISCV] Pass target-abi via module flag metadata

2020-01-15 Thread Kuan Hsu Chen (Zakk) via Phabricator via cfe-commits
khchen added a comment.

In D72755#1821540 , @lenary wrote:

> Please can you also add code for ensuring that the `target-abi` module flag 
> matches the `-target-abi` command line flag in llvm?


please see D72768 , thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72755



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


[PATCH] D72518: [clang] New __attribute__((arm_mve_strict_polymorphism)).

2020-01-15 Thread Simon Tatham via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGada01d1b8697: [clang] New 
__attribute__((__clang_arm_mve_strict_polymorphism)). (authored by 
simon_tatham).

Changed prior to commit:
  https://reviews.llvm.org/D72518?vs=237999&id=238253#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72518

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/overload-arm-mve.c
  clang/utils/TableGen/MveEmitter.cpp

Index: clang/utils/TableGen/MveEmitter.cpp
===
--- clang/utils/TableGen/MveEmitter.cpp
+++ clang/utils/TableGen/MveEmitter.cpp
@@ -1454,8 +1454,9 @@
 raw_ostream &OS = parts[ST->requiresFloat() ? Float : 0];
 const VectorType *VT = getVectorType(ST);
 
-OS << "typedef __attribute__((neon_vector_type(" << VT->lanes() << "))) "
-   << ST->cName() << " " << VT->cName() << ";\n";
+OS << "typedef __attribute__((__neon_vector_type__(" << VT->lanes()
+   << "), __clang_arm_mve_strict_polymorphism)) " << ST->cName() << " "
+   << VT->cName() << ";\n";
 
 // Every vector type also comes with a pair of multi-vector types for
 // the VLD2 and VLD4 instructions.
Index: clang/test/Sema/overload-arm-mve.c
===
--- /dev/null
+++ clang/test/Sema/overload-arm-mve.c
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -Werror -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple thumbv8.1m.main-arm-none-eabi -target-feature +mve.fp -flax-vector-conversions=all -verify -fsyntax-only -DERROR_CHECK %s
+
+typedef   signed short  int16_t;
+typedef   signed intint32_t;
+typedef   signed long long  int64_t;
+typedef unsigned short uint16_t;
+typedef unsigned int   uint32_t;
+typedef unsigned long long uint64_t;
+
+typedef __attribute__((neon_vector_type(8), __clang_arm_mve_strict_polymorphism))  int16_t  int16x8_t;
+typedef __attribute__((neon_vector_type(4), __clang_arm_mve_strict_polymorphism))  int32_t  int32x4_t;
+typedef __attribute__((neon_vector_type(2), __clang_arm_mve_strict_polymorphism))  int64_t  int64x2_t;
+typedef __attribute__((neon_vector_type(8), __clang_arm_mve_strict_polymorphism)) uint16_t uint16x8_t;
+typedef __attribute__((neon_vector_type(4), __clang_arm_mve_strict_polymorphism)) uint32_t uint32x4_t;
+typedef __attribute__((neon_vector_type(2), __clang_arm_mve_strict_polymorphism)) uint64_t uint64x2_t;
+
+__attribute__((overloadable))
+int overload(int16x8_t x, int16_t y); // expected-note {{candidate function}}
+__attribute__((overloadable))
+int overload(int32x4_t x, int32_t y); // expected-note {{candidate function}}
+__attribute__((overloadable))
+int overload(uint16x8_t x, uint16_t y); // expected-note {{candidate function}}
+__attribute__((overloadable))
+int overload(uint32x4_t x, uint32_t y); // expected-note {{candidate function}}
+
+int16_t s16;
+int32_t s32;
+uint16_t u16;
+uint32_t u32;
+
+int16x8_t vs16;
+int32x4_t vs32;
+uint16x8_t vu16;
+uint32x4_t vu32;
+
+// --
+// Simple cases where the types are correctly matched
+
+// CHECK-LABEL: @test_easy_s16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int16
+int test_easy_s16(void) { return overload(vs16, s16); }
+
+// CHECK-LABEL: @test_easy_u16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint16
+int test_easy_u16(void) { return overload(vu16, u16); }
+
+// CHECK-LABEL: @test_easy_s32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int32
+int test_easy_s32(void) { return overload(vs32, s32); }
+
+// CHECK-LABEL: @test_easy_u32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint32
+int test_easy_u32(void) { return overload(vu32, u32); }
+
+// --
+// Do arithmetic on the scalar, and it may get promoted. We still expect the
+// same overloads to be selected if that happens.
+
+// CHECK-LABEL: @test_promote_s16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int16
+int test_promote_s16(void) { return overload(vs16, s16 + 1); }
+
+// CHECK-LABEL: @test_promote_u16(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint16
+int test_promote_u16(void) { return overload(vu16, u16 + 1); }
+
+// CHECK-LABEL: @test_promote_s32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_int32
+int test_promote_s32(void) { return overload(vs32, s32 + 1); }
+
+// CHECK-LABEL: @test_promote_u32(
+// CHECK: call i32 @_Z8overload{{[a-zA-Z0-9_]+}}_uint32
+int test_promote_u32(void) { return overload(vu32, u32 + 1); }
+
+// --

[PATCH] D72498: [clangd] Print underlying type for decltypes in hover

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61885 tests passed, 0 failed 
and 782 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72498



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


[PATCH] D72623: [clangd] Rearrange type, returntype and parameters in hover card

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72623



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


[PATCH] D72500: [clangd] Show hover info for expressions

2020-01-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

This breaks tests on Windows: http://45.33.8.238/win/5837/step_9.txt


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72500



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


[clang-tools-extra] 60adfb8 - [clangd] Fix windows buildbots

2020-01-15 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-15T16:22:36+01:00
New Revision: 60adfb83cda883d9fc1079c89d2feaa681a41b90

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

LOG: [clangd] Fix windows buildbots

Added: 


Modified: 
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index 0898b311c6de..d30c9bfb90ff 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1514,26 +1514,6 @@ TEST(Hover, All) {
 HI.Name = "cls > >";
 HI.Documentation = "type of nested templates.";
   }},
-  {
-  R"cpp(// sizeof expr
-  void foo() {
-(void)[[size^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
-  {
-  R"cpp(// alignof expr
-  void foo() {
-(void)[[align^of]](char);
-  })cpp",
-  [](HoverInfo &HI) {
-HI.Name = "expression";
-HI.Type = "unsigned long";
-HI.Value = "1";
-  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -1794,6 +1774,49 @@ Value = val
 
 def)pt");
 }
+
+TEST(Hover, ExprTests) {
+  struct {
+const char *const Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {
+  {
+  R"cpp(// sizeof expr
+  void foo() {
+(void)[[size^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  {
+  R"cpp(// alignof expr
+  void foo() {
+(void)[[align^of]](char);
+  })cpp",
+  [](HoverInfo &HI) {
+HI.Name = "expression";
+HI.Type = "unsigned long";
+HI.Value = "1";
+  }},
+  };
+  for (const auto &C : Cases) {
+Annotations T(C.Code);
+TestTU TU = TestTU::withCode(T.code());
+auto AST = TU.build();
+for (const auto &D : AST.getDiagnostics())
+  ADD_FAILURE() << D;
+
+auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
+ASSERT_TRUE(H);
+HoverInfo ExpectedHover;
+C.ExpectedBuilder(ExpectedHover);
+// We don't check for Type as it might 
diff er on 
diff erent platforms.
+EXPECT_EQ(H->Name, ExpectedHover.Name);
+EXPECT_EQ(H->Value, ExpectedHover.Value);
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang



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


[PATCH] D55057: [Headers] Make max_align_t match GCC's implementation.

2020-01-15 Thread James Y Knight via Phabricator via cfe-commits
jyknight added inline comments.
Herald added a project: clang.



Comment at: lib/Headers/__stddef_max_align_t.h:44
+#endif
 } max_align_t;
 #endif

EricWF wrote:
> rsmith wrote:
> > I don't want to hold up the immediate fix in this patch for this, but... we 
> > should move the definition of this type from the header into clang itself, 
> > like we do for (say) `__builtin_va_list`, and here just define
> > 
> > `typedef __builtin_max_align_t max_align_t;`
> > 
> > That way Clang can synthesize a struct of whatever size and alignment 
> > appropriate from an ABI perspective (or can use the relevant builtin type 
> > for platforms that typedef `max_align_t` to a builtin type). That'd also 
> > remove the need for an awkward factored-out header file here.
> I'll try to implement this over the weekend. As long as I can land the Clang 
> fix required for libc++ cleanup before the next release.
Looks like this patch never landed. I think it still should be, right?


Repository:
  rC Clang

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

https://reviews.llvm.org/D55057



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


[clang] 24a00ef - Restore "[ThinLTO] Add additional ThinLTO pipeline testing with new PM"

2020-01-15 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-15T07:33:08-08:00
New Revision: 24a00ef2404104e9ca6fbd7eb523a8a340be9d99

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

LOG: Restore "[ThinLTO] Add additional ThinLTO pipeline testing with new PM"

This restores 2af97be8027a0823b88d4b6a07fc5eedb440bc1f (reverted at
6288f86e870c7bb7fe47cc138320b9eb34c93941), with all the fixes I had
applied at the time, along with a new fix for non-determinism in the
ordering of a couple of passes due to being accessed as parameters on
the same call.

I've also added --dump-input=fail to the new tests so I can more
thoroughly fix any additional failures.

Added: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/Inputs/new-pm-thinlto-prelink-pgo-defaults.proftext
llvm/test/Other/Inputs/new-pm-thinlto-samplepgo-defaults.prof
llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Modified: 
llvm/test/Other/new-pm-pgo.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
new file mode 100644
index ..86ede12bfdb3
--- /dev/null
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -0,0 +1,237 @@
+; REQUIRES: x86-registered-target
+
+; Validate ThinLTO post link pipeline at O2 and O3
+
+; RUN: opt -thinlto-bc -o %t.o %s
+
+; RUN: llvm-lto2 run -thinlto-distributed-indexes %t.o \
+; RUN:   -o %t2.index \
+; RUN:   -r=%t.o,main,px
+
+; RUN: %clang -target x86_64-grtev4-linux-gnu \
+; RUN:   -O2 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
+; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O2 %s --dump-input=fail
+
+; RUN: %clang -target x86_64-grtev4-linux-gnu \
+; RUN:   -O3 -fexperimental-new-pass-manager -Xclang -fdebug-pass-manager \
+; RUN:   -c -fthinlto-index=%t.o.thinlto.bc \
+; RUN:   -o %t.native.o -x ir %t.o 2>&1 | FileCheck 
-check-prefixes=CHECK-O,CHECK-O3 %s --dump-input=fail
+
+; CHECK-O: Running analysis: PassInstrumentationAnalysis
+; CHECK-O: Starting {{.*}}Module pass manager run.
+; CHECK-O: Running pass: WholeProgramDevirtPass
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
+; CHECK-O: Running pass: LowerTypeTestsPass
+; CHECK-O: Invalidating all non-preserved analyses for:
+; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
+; CHECK-O: Running pass: ForceFunctionAttrsPass
+; CHECK-O: Running pass: PassManager<{{.*}}Module>
+; CHECK-O: Starting {{.*}}Module pass manager run.
+; CHECK-O: Running pass: PGOIndirectCallPromotion
+; CHECK-O: Running analysis: ProfileSummaryAnalysis
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
+; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
+; CHECK-O: Running pass: InferFunctionAttrsPass
+; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> >
+; CHECK-O: Starting {{.*}}Function pass manager run.
+; CHECK-O: Running pass: SimplifyCFGPass on main
+; CHECK-O: Running analysis: TargetIRAnalysis on main
+; CHECK-O: Running analysis: AssumptionAnalysis on main
+; CHECK-O: Running pass: SROA on main
+; CHECK-O: Running analysis: DominatorTreeAnalysis on main
+; CHECK-O: Running pass: EarlyCSEPass on main
+; CHECK-O: Running analysis: TargetLibraryAnalysis on main
+; CHECK-O: Running pass: LowerExpectIntrinsicPass on main
+; CHECK-O3: Running pass: CallSiteSplittingPass on main
+; CHECK-O: Finished {{.*}}Function pass manager run.
+; CHECK-O: Running pass: IPSCCPPass
+; CHECK-O: Running pass: CalledValuePropagationPass
+; CHECK-O: Running pass: GlobalOptPass
+; CHECK-O: Invalidating all non-preserved analyses for:
+; CHECK-O: Invalidating analysis: InnerAnalysisManagerProxy
+; CHECK-O: Running pass: ModuleToFunctionPassAdaptor<{{.*}}PromotePass>
+; CHECK-O: Running analysis: InnerAnalysisManagerProxy
+; CHECK-O: Running analysis: DominatorTreeAnalysis on main
+; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
+; CHECK-O: Running analysis: AssumptionAnalysis on main
+; CHECK-O: Running pass: DeadArgumentEliminationPass
+; CHECK-O: Running pass: 
ModuleToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> >
+; CHECK-O: Starting {{.*}}Function pass manager run.
+; CHECK-O: Running pass: InstCombinePass on main
+; CHECK-O: Running analysis: TargetLibraryAnalysis on main
+; CHECK-O: Running analysis: OptimizationRemarkEmitterAnalysis on main
+; CHECK-O: Running analysis: AAManager on main
+; CHECK-O: Running an

[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2020-01-15 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil updated this revision to Diff 238260.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp
@@ -0,0 +1,38 @@
+// RUN: %check_clang_tidy %s bugprone-pointer-cast-widening %t
+
+// 
+typedef __UINT64_TYPE__ uint64_t;
+typedef __INTPTR_TYPE__ intptr_t;
+typedef __UINTPTR_TYPE__ uintptr_t;
+
+// Do not assume ull_ns::uintptr_t to be uintptr_t.
+namespace ull_ns {
+typedef unsigned long long uintptr_t;
+}
+// This is how std::uintptr_t is defined in :
+namespace cstdint_ns {
+using ::uintptr_t;
+}
+
+void test() {
+  void *p = 0;
+  uint64_t u64cstyle = (uint64_t)p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  // uint64_t u64implicit = p; // error: cannot initialize a variable of type 'uint64_t' (aka 'unsigned long') with an lvalue of type 'void *' [clang-diagnostic-error]
+  uint64_t u64reinterpret = reinterpret_cast(p);
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'uint64_t' (aka 'unsigned long') which may sign-extend [bugprone-pointer-cast-widening]
+  // uint64_t u64static = static_cast(p); // error: static_cast from 'void *' to 'uint64_t' (aka 'unsigned long') is not allowed
+  uintptr_t up = (uintptr_t)p;
+  auto cup = (cstdint_ns::uintptr_t)p;
+  auto wup = (ull_ns::uintptr_t)p;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: do not use cast of a pointer 'void *' to non-uintptr_t 'ull_ns::uintptr_t' (aka 'unsigned long long') which may sign-extend [bugprone-pointer-cast-widening]
+  typedef uintptr_t t1;
+  typedef t1 t2;
+  t2 t = (t2)p;
+  intptr_t ip = reinterpret_cast(p);
+  __uint128_t u64ipimplicit = ip;
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: do not use cast of pointer-like 'intptr_t' (aka 'long') to a wider type '__uint128_t' (aka 'unsigned __int128') which will sign-extend [bugprone-pointer-cast-widening]
+  __uint128_t u64ipstatic = static_cast<__uint128_t>(ip);
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: do not use cast of pointer-like 'intptr_t' (aka 'long') to a wider type '__uint128_t' (aka 'unsigned __int128') which will sign-extend [bugprone-pointer-cast-widening]
+  // __uint128_t u64ipreinterpret = reinterpret_cast<__uint128_t>(ip); // error: reinterpret_cast from 'intptr_t' (aka 'long') to '__uint128_t' (aka 'unsigned __int128') is not allowed
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -70,6 +70,7 @@
`bugprone-multiple-statement-macro `_,
`bugprone-not-null-terminated-result `_, "Yes"
`bugprone-parent-virtual-call `_, "Yes"
+   `bugprone-pointer-cast-widening `_, "Yes"
`bugprone-posix-return `_, "Yes"
`bugprone-signed-char-misuse `_,
`bugprone-sizeof-container `_,
Index: clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/bugprone-pointer-cast-widening.rst
@@ -0,0 +1,26 @@
+.. title:: clang-tidy - bugprone-pointer-cast-widening
+
+bugprone-pointer-cast-widening
+==
+
+Checks for cast of a pointer to wider (even unsigned) integer as it
+sign-extends the pointer which happens on 32-bit hosts for 64-bit integers.
+The buggy behavior are 32-bit addresses printed like ``0xd56b5d60``.
+
+Casting from 32-bit ``void *`` to ``uint64_t`` requires an intermediate cast to
+``uintptr_t`` otherwise the pointer gets sign-extended:
+
+.. code-block:: c++
+
+  void *p=(void *)0x8000;
+  printf(  "%p""\n",p );//0x8000
+  printf("0x%" PRIxPTR "\n",(uintptr_t) p );//0x8000
+  printf("0x%" PRIxPTR "\n",reinterpret_cast(p));//0x8000
+  //^^^ recommended
+  printf("0x%" PRIx64  "\n",reinterpret_cast(p));//0x8000
+  printf("

[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-15 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72723



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


[PATCH] D71707: clang-tidy: new bugprone-pointer-cast-widening

2020-01-15 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil marked 8 inline comments as done.
jankratochvil added a comment.

In D71707#1796671 , @aaron.ballman 
wrote:

> I agree that restricting casts to `intptr_t` is too restrictive.


Permitted `intptr_t`. But then implemented also checking a cast of `intptr_t` 
to wider integral types.

> Have you considered language extensions like `__ptr32`, `__ptr64`, `__sptr`, 
> and `__uptr` 
> (https://docs.microsoft.com/en-us/cpp/cpp/ptr32-ptr64?view=vs-2019) which we 
> also support?

I think only `__uptr` support would matter to prevent some false positives. I 
am not sure it is used anywhere. Should I really implement it?




Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:21-22
+void PointerCastWideningCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus && !getLangOpts().C99)
+return;
+

aaron.ballman wrote:
> Why limiting this to C++ and >= C99? You can get pointer widening casts 
> through extensions in C89, for instance.
Removed the check completely.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/PointerCastWideningCheck.cpp:36
+  for (QualType DestTypeCheck = DestType;;) {
+if (DestTypeCheck.getAsString() == "uintptr_t")
+  return;

aaron.ballman wrote:
> How well does this work with something like `std::uinptr_t` from ``?
It works fine because its
```
using::uintptr_t;
```
is recogized as a `typedef` in the loop above from namespace-less `uintptr_t'. 
Sure thanks for notifying me to check that.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-pointer-cast-widening.cpp:17
+  t2 t = (t2)p;
+}

aaron.ballman wrote:
> I'd also like to see tests for implicit casts as well as pointer width and 
> sign extension language extensions.
Done implicit cases.  But I do not understand what you mean by the rest - could 
you provide an example? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71707



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


[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-15 Thread Konstantin Pyzhov via Phabricator via cfe-commits
kpyzhov updated this revision to Diff 238259.
kpyzhov added a reviewer: arsenm.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72723

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
  clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1725,105 +1725,125 @@
 def int_amdgcn_global_atomic_fadd: AMDGPUGlobalAtomicNoRtn;
 
 // llvm.amdgcn.mfma.f32.* vdst, srcA, srcB, srcC, cbsz, abid, blgp
-def int_amdgcn_mfma_f32_32x32x1f32 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x1f32 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x1f32 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x2f32 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x4f32 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x4f16 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x4f16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x4f16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x8f16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x16f16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_32x32x4i8 : Intrinsic<[llvm_v32i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v32i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_16x16x4i8 : Intrinsic<[llvm_v16i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v16i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_4x4x4i8 : Intrinsic<[llvm_v4i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v4i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_32x32x8i8 : Intrinsic<[llvm_v16i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v16i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_16x16x16i8 : Intrinsic<[llvm_v4i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v4i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x2bf16 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x2bf16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x2bf16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x4bf16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v2i16_ty,

[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm requested changes to this revision.
arsenm added a comment.
This revision now requires changes to proceed.

Having two subtarget features for the same feature is an issue


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72723



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


[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-15 Thread Konstantin Pyzhov via Phabricator via cfe-commits
kpyzhov updated this revision to Diff 238263.

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

https://reviews.llvm.org/D72723

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-mfma.cl
  clang/test/SemaOpenCL/builtins-amdgcn-error-gfx908-param.cl
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -1725,105 +1725,125 @@
 def int_amdgcn_global_atomic_fadd: AMDGPUGlobalAtomicNoRtn;
 
 // llvm.amdgcn.mfma.f32.* vdst, srcA, srcB, srcC, cbsz, abid, blgp
-def int_amdgcn_mfma_f32_32x32x1f32 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x1f32 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x1f32 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x2f32 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x4f32 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_float_ty, llvm_float_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x4f16 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x4f16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x4f16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x8f16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x16f16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v4f16_ty, llvm_v4f16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_32x32x4i8 : Intrinsic<[llvm_v32i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v32i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_16x16x4i8 : Intrinsic<[llvm_v16i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v16i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_4x4x4i8 : Intrinsic<[llvm_v4i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v4i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_32x32x8i8 : Intrinsic<[llvm_v16i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v16i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_i32_16x16x16i8 : Intrinsic<[llvm_v4i32_ty],
-  [llvm_i32_ty, llvm_i32_ty, llvm_v4i32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x2bf16 : Intrinsic<[llvm_v32f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v32f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_16x16x2bf16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_4x4x2bf16 : Intrinsic<[llvm_v4f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v4f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
-   [IntrConvergent, IntrNoMem, ImmArg<3>, ImmArg<4>, ImmArg<5>]>;
-
-def int_amdgcn_mfma_f32_32x32x4bf16 : Intrinsic<[llvm_v16f32_ty],
-  [llvm_v2i16_ty, llvm_v2i16_ty, llvm_v16f32_ty,
-   llvm_i32_ty, llvm_i32_ty, llvm_i32_ty

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

2020-01-15 Thread Gabor Marton via Phabricator via cfe-commits
martong marked 3 inline comments as done.
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:8043
+
+  Error VisitFunctionTypeLoc(FunctionTypeLoc From) {
+auto To = ToL.castAs();

balazske wrote:
> martong wrote:
> > a_sidorin wrote:
> > > Does this import interacts well with type loc import partially done at 
> > > L3258 (VisitFunctionDecl)? Should we merge them?
> > I think we should check here whether the given ParmVarDecl had been 
> > imported previously and if yes then set that with `setParam`, otherwise it 
> > could be set to a nullptr. @balazske what do you think?
> Probably we could get the `FunctionTypeLoc` from `TInfo` (this is the first 
> TypeLoc there?) and set the parameters (that are set to nullptr at line 
> 8055), at this loop in `VisitFunctionDecl`:
> ```
>   // Set the parameters.
>   for (auto *Param : Parameters) {
> Param->setOwningFunction(ToFunction);
> ToFunction->addDeclInternal(Param);
>   }
>   ToFunction->setParams(Parameters);
> ```
Guys, I moved the TypeLoc import part of VisitFunctionDecl to here. But, this 
is possible only if first we import the parameters and only then we import the 
TypeLoc (TypeSourceInfo) in VisitFunctionDecl, so I made that reorganization 
too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018



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


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

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

- Move the setting of parameters of FunctionProtoTypeLoc to TypeLocImporter
- Add tests for TypeLoc import in case of functions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D71018

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

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

[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-15 Thread Mark Murray via Phabricator via cfe-commits
MarkMurrayARM updated this revision to Diff 238269.
MarkMurrayARM added a comment.

Much better impementation after review feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72761

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -0,0 +1,68 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vminnmaq_f16(<8 x half> %a, <8 x half> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vminnma.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
+  ret <8 x half> %1
+}
+
+declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
+
+declare <8 x half> @llvm.minnum.v8f16(<8 x half>, <8 x half>) #1
+
+define arm_aapcs_vfpcc <4 x float> @test_vminnmaq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vminnma.f32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
+  ret <4 x float> %1
+}
+
+declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
+
+declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) #1
+
+define arm_aapcs_vfpcc <8 x half> @test_vminnmaq_m_f16(<8 x half> %a, <8 x half> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vminnmat.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.vminnma.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x half> @llvm.arm.mve.vminnma.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>) #2
+
+define arm_aapcs_vfpcc <4 x float> @test_vminnmaq_m_f32(<4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vminnmat.f32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x float> @llvm.arm.mve.vminnma.predicated.v4f32.v4i1(<4 x float> %a, <4 x float> %b, <4 x i1> %1)
+  ret <4 x float> %2
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x float> @llvm.arm.mve.vminnma.predicated.v4f32.v4i1(<4 x float>, <4 x float>, <4 x i1>) #2
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
@@ -0,0 +1,98 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vminaq_s8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmina.s8 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp slt <16 x i8> %b, zeroinitializer
+  %1 = sub <16 x i8> zeroinitializer, %b
+  %2 = select <16 x i1> %0, <16 x i8> %1, <16 x i8> %b
+  %3 = icmp ult <16 x i8> %2, %a
+  %4 = select <16 x i1> %3, <16 x i8> %2, <16 x i8> %a
+  ret <16 x i8> %4
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vminaq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmina.s16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp slt <8 x i16> %b, zeroinitializer
+  %1 = sub <8 x i16> zeroinitializer, %b
+  %2 = select <8 x i1> %0, <8 x i16> %1, <8 x i16> %b
+  %3 = icmp ult <8 x i16

[clang] 76b92cc - Fix bot by adjusting wildcard matching

2020-01-15 Thread Teresa Johnson via cfe-commits

Author: Teresa Johnson
Date: 2020-01-15T08:37:15-08:00
New Revision: 76b92cc7c1fafeae2d9e4993e81838b8d9488e45

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

LOG: Fix bot by adjusting wildcard matching

I noticed one bot failure due to
24a00ef2404104e9ca6fbd7eb523a8a340be9d99 because the wildcard matching
was not working as intended, fixed it to act similar to other checks of
CGSCCToFunctionPassAdaptor.

Added: 


Modified: 
clang/test/CodeGen/thinlto-distributed-newpm.ll
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-distributed-newpm.ll 
b/clang/test/CodeGen/thinlto-distributed-newpm.ll
index 86ede12bfdb3..66bcd1cb250b 100644
--- a/clang/test/CodeGen/thinlto-distributed-newpm.ll
+++ b/clang/test/CodeGen/thinlto-distributed-newpm.ll
@@ -87,11 +87,11 @@
 ; CHECK-O: Clearing all analysis results for: main
 ; CHECK-O: Invalidating analysis: FunctionAnalysisManagerCGSCCProxy on (main)
 ; CHECK-O3: Running pass: ArgumentPromotionPass on (main)
-; CHECK-O2: Running pass: 
CGSCCToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> > on (main)
+; CHECK-O2: Running pass: CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O: Running analysis: FunctionAnalysisManagerCGSCCProxy on (main)
 ; CHECK-O3: Running analysis: TargetIRAnalysis on main
 ; CHECK-O: Running analysis: PassInstrumentationAnalysis on main
-; CHECK-O3: Running pass: 
CGSCCToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> > on (main)
+; CHECK-O3: Running pass: CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O: Starting {{.*}}Function pass manager run.
 ; CHECK-O: Running pass: SROA on main
 ; These next two can appear in any order since they are accessed as parameters

diff  --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
index 447dc8fe6fe9..09e73539faeb 100644
--- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -73,7 +73,7 @@
 ; CHECK-O123-NEXT: Running analysis: OuterAnalysisManagerProxy
 ; CHECK-O123-NEXT: Starting CGSCC pass manager run.
 ; CHECK-O123-NEXT: Running pass: InlinerPass on (foo)
-; CHECK-O123-NEXT: Running pass: 
CGSCCToFunctionPassAdaptor<{{.*}}PassManager<{{.*}}Function> > on (foo)
+; CHECK-O123-NEXT: Running pass: 
CGSCCToFunctionPassAdaptor<{{.*}}PassManager{{.*}}>
 ; CHECK-O123-NEXT: Finished CGSCC pass manager run.
 ; CHECK-O123-NEXT: Running pass: GlobalDCEPass
 ; CHECK-O-NEXT: Running pass: PGOInstrumentationUse



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


[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

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

LGTM this time. Thanks for the rewrite!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72761



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


[PATCH] D72772: [Matrix] Add __builtin_matrix_extract to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72772

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-matrix.c
  clang/test/CodeGenCXX/builtin-matrix.cpp
  clang/test/Sema/builtin-matrix.c
  clang/test/SemaCXX/builtin-matrix.cpp

Index: clang/test/SemaCXX/builtin-matrix.cpp
===
--- clang/test/SemaCXX/builtin-matrix.cpp
+++ clang/test/SemaCXX/builtin-matrix.cpp
@@ -7,6 +7,13 @@
   char *s;
 };
 
+template 
+struct MyMatrix {
+  using matrix_t = EltTy __attribute__((matrix_type(Rows, Columns)));
+
+  matrix_t value;
+};
+
 void insert(sx10x10_t *a, float f) {
   *a = __builtin_matrix_insert(
   10, // expected-error {{First argument must be a matrix}}
@@ -23,3 +30,15 @@
   *a = __builtin_matrix_insert(*a, f, // expected-error {{Row argument must be an unsigned integer}}
5u, 10.0); // expected-error {{Column argument must be an unsigned integer}}
 }
+
+template 
+EltTy extract(MyMatrix &Mat) {
+  char *v1 = __builtin_matrix_extract(Mat.value, 1u, 0u); // expected-error {{cannot initialize a variable of type 'char *' with an rvalue of type 'unsigned int'}}
+  return __builtin_matrix_extract(Mat.value, 1u, 0u);
+}
+
+void test_extract_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  Mat1.value = *((decltype(Mat1)::matrix_t*) Ptr1);
+  unsigned v1 = extract(Mat1); // expected-note {{in instantiation of function template specialization 'extract' requested here}}
+}
Index: clang/test/Sema/builtin-matrix.c
===
--- /dev/null
+++ clang/test/Sema/builtin-matrix.c
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 %s -fenable-matrix -pedantic -verify -triple=x86_64-apple-darwin9
+
+typedef float sx10x10_t __attribute__((matrix_type(10, 10)));
+sx10x10_t a;
+
+struct Foo {
+  char *s;
+};
+
+void insert(sx10x10_t *a, float f) {
+  *a = __builtin_matrix_insert(
+  10, // expected-error {{First argument must be a matrix}}
+  a,  // expected-error {{Row argument must be an unsigned integer}}
+  a,  // expected-error {{Column argument must be an unsigned integer}}
+  10);
+
+  int x = __builtin_matrix_insert(*a, 3u, 5u, 10.0); // expected-error {{initializing 'int' with an expression of incompatible type 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10))) ')}}
+
+  // TODO: Should error here (index out of range).
+  *a = __builtin_matrix_insert(*a, -1u, 5u, 10.0);
+
+  // FIXME: Column argument is fine!
+  *a = __builtin_matrix_insert(*a, f, // expected-error {{Row argument must be an unsigned integer}}
+   5u, 10.0); // expected-error {{Column argument must be an unsigned integer}}
+}
+
+
+void extract(sx10x10_t *a) {
+  struct Foo v1  = __builtin_matrix_extract( // expected-error {{initializing 'struct Foo' with an expression of incompatible type 'float'}}
+  *a, 1, 1);
+
+   float v2 = __builtin_matrix_extract(
+  10,  // expected-error {{First argument must be a matrix}}
+  a,   // expected-error {{Row argument must be an unsigned integer}}
+  a);  // expected-error {{Column argument must be an unsigned integer}}
+
+   float v3 = __builtin_matrix_extract(
+  *a, 1); // expected-error {{too few arguments to function call, expected 3, have 2}}
+
+   float v4 = __builtin_matrix_extract(
+  *a, 1, 1, 1); // expected-error {{too many arguments to function call, expected 3, have 4}}
+}
Index: clang/test/CodeGenCXX/builtin-matrix.cpp
===
--- clang/test/CodeGenCXX/builtin-matrix.cpp
+++ clang/test/CodeGenCXX/builtin-matrix.cpp
@@ -70,9 +70,9 @@
   Mat.value = __builtin_matrix_insert(Mat.value, 1u, 0u, e);
 }
 
-void test_template(unsigned *Ptr1, unsigned E1, float *Ptr2, float E2) {
+void test_insert_template(unsigned *Ptr1, unsigned E1, float *Ptr2, float E2) {
 
-  // CHECK-LABEL: define void @_Z13test_templatePjjPff(i32* %Ptr1, i32 %E1, float* %Ptr2, float %E2)
+  // CHECK-LABEL: define void @_Z20test_insert_templatePjjPff(i32* %Ptr1, i32 %E1, float* %Ptr2, float %E2)
   // CHECK-NEXT:  entry:
   // CHECK-NEXT:%Ptr1.addr = alloca i32*, align 8
   // CHECK-NEXT:%E1.addr = alloca i32, align 4
@@ -148,3 +148,78 @@
   Mat2.value = *((decltype(Mat2)::matrix_t *)Ptr2);
   insert(Mat2, E2);
 }
+
+
+typedef float fx3x3_t __attribute__((matrix_type(3, 3)));
+void extract1(dx5x5_t a, fx3x3_t b, ix9x3_t c) {
+  // CHECK-LABEL: @_Z8extract1Dm5_5_dDm3_3_fDm9_3_i(
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%a.addr = alloca [25 x double], align 8
+  // CHECK-NEXT:%b.addr = alloca [9 x float], align 4
+  // CHECK-NEXT:%c.addr = alloca [27 x i32], align 4
+  // CHECK-NEXT:%v

[PATCH] D72772: [Matrix] Add __builtin_matrix_extract to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72772



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


[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm accepted this revision.
arsenm added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D72723



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


[PATCH] D72773: [Matrix] Add __builtin_matrix_{add,sub} to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72773

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-matrix.c
  clang/test/CodeGenCXX/builtin-matrix.cpp
  clang/test/Sema/builtin-matrix.c
  clang/test/SemaCXX/builtin-matrix.cpp

Index: clang/test/SemaCXX/builtin-matrix.cpp
===
--- clang/test/SemaCXX/builtin-matrix.cpp
+++ clang/test/SemaCXX/builtin-matrix.cpp
@@ -42,3 +42,60 @@
   Mat1.value = *((decltype(Mat1)::matrix_t*) Ptr1);
   unsigned v1 = extract(Mat1); // expected-note {{in instantiation of function template specialization 'extract' requested here}}
 }
+
+template 
+typename MyMatrix::matrix_t add(MyMatrix &A, MyMatrix &B) {
+  char *v1 = __builtin_matrix_add(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 {{Matrix types must match}}
+  // expected-error@-3 {{Matrix types must match}}
+
+  return __builtin_matrix_add(A.value, B.value);
+  // expected-error@-1 {{Matrix types must match}}P
+  // expected-error@-2 {{Matrix types must match}}P
+}
+
+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 &A, MyMatrix &B) {
+  char *v1 = __builtin_matrix_subtract(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 {{Matrix types must match}}
+  // expected-error@-3 {{Matrix types must match}}
+
+  return __builtin_matrix_subtract(A.value, B.value);
+  // expected-error@-1 {{Matrix types must match}}P
+  // expected-error@-2 {{Matrix types must match}}P
+}
+
+void test_subtract_template(unsigned *Ptr1, float *Ptr2) {
+  MyMatrix Mat1;
+  MyMatrix Mat2;
+  MyMatrix Mat3;
+  Mat1.value = *((decltype(Mat1)::matrix_t*) Ptr1);
+  unsigned v1 = subtract(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 'subtract' requested here}}
+
+  Mat1.value = subtract(Mat1, Mat2);
+  // expected-note@-1 {{in instantiation of function template specialization 'subtract' requested here}}
+
+  Mat1.value = subtract(Mat2, Mat3);
+  // expected-note@-1 {{in instantiation of function template specialization 'subtract' requested here}}
+}
Index: clang/test/Sema/builtin-matrix.c
===
--- clang/test/Sema/builtin-matrix.c
+++ clang/test/Sema/builtin-matrix.c
@@ -40,3 +40,43 @@
float v4 = __builtin_matrix_extract(
   *a, 1, 1, 1); // expected-error {{too many arguments to function call, expected 3, have 4}}
 }
+
+
+typedef float sx10x5_t __attribute__((matrix_type(10, 5)));
+typedef float sx5x10_t __attribute__((matrix_type(5, 10)));
+
+void add(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
+a = __builtin_matrix_add(
+b, c); // expected-error {{Matrix types must match}}
+
+a = __builtin_matrix_add( // expected-error {{assigning to 'sx10x10_t' (aka 'float __attribute__((matrix_type(10, 10))) ') from incompatible type 'sx5x10_t' (aka 'float __attribute__((matrix_type(5, 10))) ')}}
+b, b);
+
+a = __builtin_matrix_add(
+10, b); // expected-error {{First argument must be a matrix}}
+
+a = __builtin_matrix_add(
+b, &c); // expected-error {{Second argument must be a matrix}}
+
+a = __builtin_matrix_add(
+&a,  // expected-error {{First argument must be a matrix}}
+&c); // expected-error {{Second argument must be a matrix}}
+}
+
+void sub(sx10x10_t a, sx5x10_t b, sx10x5_t c) {
+a = __builtin_matrix_subtract(
+b, c); // expected-error {{

[PATCH] D72773: [Matrix] Add __builtin_matrix_{add,sub} to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72773



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


[PATCH] D72723: Built-in functions for AMDGPU MFMA instructions.

2020-01-15 Thread Konstantin Pyzhov via Phabricator via cfe-commits
kpyzhov added a comment.

In D72723#1821917 , @arsenm wrote:

> Having two subtarget features for the same feature is an issue


?


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

https://reviews.llvm.org/D72723



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


[clang-tools-extra] 041650d - [clangd] Extract string literals in macro arguments to unbreak gcc buildbots

2020-01-15 Thread Kadir Cetinkaya via cfe-commits

Author: Kadir Cetinkaya
Date: 2020-01-15T17:59:10+01:00
New Revision: 041650da67051266eb92b5bb07223394fe1bdab1

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

LOG: [clangd] Extract string literals in macro arguments to unbreak gcc 
buildbots

Added: 


Modified: 
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp 
b/clang-tools-extra/clangd/unittests/HoverTests.cpp
index d30c9bfb90ff..385c064a9dce 100644
--- a/clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1759,7 +1759,7 @@ TEST(Hover, PresentRulers) {
   HI.Value = "val";
   HI.Definition = "def";
 
-  EXPECT_EQ(HI.present().asMarkdown(), R"md(### variable `foo`  
+  llvm::StringRef ExpectedMarkdown = R"md(### variable `foo`  
 
 ---
 Value \= `val`  
@@ -1767,12 +1767,15 @@ Value \= `val`
 ---
 ```cpp
 def
-```)md");
-  EXPECT_EQ(HI.present().asPlainText(), R"pt(variable foo
+```)md";
+  EXPECT_EQ(HI.present().asMarkdown(), ExpectedMarkdown);
+
+  llvm::StringRef ExpectedPlaintext = R"pt(variable foo
 
 Value = val
 
-def)pt");
+def)pt";
+  EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
 }
 
 TEST(Hover, ExprTests) {



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


[PATCH] D72774: [Matrix] Add __builtin_matrix_multiply to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72774

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

Index: clang/test/CodeGen/builtin-matrix.c
===
--- clang/test/CodeGen/builtin-matrix.c
+++ clang/test/CodeGen/builtin-matrix.c
@@ -225,3 +225,30 @@
   // CHECK-NEXT:store <27 x i32> %11, <27 x i32>* %3, align 4
   // CHECK-NEXT:ret void
 }
+
+void multiply1(dx5x5_t *a, dx5x5_t *b, dx5x5_t *c) {
+  *a = __builtin_matrix_multiply(*b, *c);
+
+  // CHECK-LABEL: @multiply1(
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:%b.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:%c.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:store [25 x double]* %a, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:store [25 x double]* %b, [25 x double]** %b.addr, align 8
+  // CHECK-NEXT:store [25 x double]* %c, [25 x double]** %c.addr, align 8
+  // CHECK-NEXT:%0 = load [25 x double]*, [25 x double]** %b.addr, align 8
+  // CHECK-NEXT:%1 = bitcast [25 x double]* %0 to <25 x double>*
+  // CHECK-NEXT:%2 = load <25 x double>, <25 x double>* %1, align 8
+  // CHECK-NEXT:%3 = load [25 x double]*, [25 x double]** %c.addr, align 8
+  // CHECK-NEXT:%4 = bitcast [25 x double]* %3 to <25 x double>*
+  // CHECK-NEXT:%5 = load <25 x double>, <25 x double>* %4, align 8
+  // CHECK-NEXT:%6 = call <25 x double> @llvm.matrix.multiply.v25f64.v25f64.v25f64(<25 x double> %2, <25 x double> %5, i32 5, i32 5, i32 5)
+  // CHECK-NEXT:%7 = load [25 x double]*, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:%8 = bitcast [25 x double]* %7 to <25 x double>*
+  // CHECK-NEXT:store <25 x double> %6, <25 x double>* %8, align 8
+  // CHECK-NEXT:ret void
+}
+// CHECK: declare <25 x double> @llvm.matrix.multiply.v25f64.v25f64.v25f64(<25 x double>, <25 x double>, i32 immarg, i32 immarg, i32 immarg) [[READNONE:#[0-9]]]
+
+// CHECK: attributes [[READNONE]] = { nounwind readnone speculatable willreturn }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1617,6 +1617,7 @@
   case Builtin::BI__builtin_matrix_extract:
   case Builtin::BI__builtin_matrix_add:
   case Builtin::BI__builtin_matrix_subtract:
+  case Builtin::BI__builtin_matrix_multiply:
 if (!getLangOpts().EnableMatrix) {
   Diag(TheCall->getBeginLoc(), diag::err_builtin_matrix_disabled);
   return ExprError();
@@ -1630,6 +1631,8 @@
 case Builtin::BI__builtin_matrix_add:
 case Builtin::BI__builtin_matrix_subtract:
   return SemaBuiltinMatrixEltwiseOverload(TheCall, TheCallResult);
+case Builtin::BI__builtin_matrix_multiply:
+  return SemaBuiltinMatrixMultiplyOverload(TheCall, TheCallResult);
 default:
   llvm_unreachable("All matrix builtins should be handled here!");
 }
@@ -15372,3 +15375,98 @@
 
   return CallResult;
 }
+
+ExprResult Sema::SemaBuiltinMatrixMultiplyOverload(CallExpr *TheCall,
+   ExprResult CallResult) {
+  if (checkArgCount(*this, TheCall, 2))
+return ExprError();
+
+  Expr *Callee = TheCall->getCallee();
+  DeclRefExpr *DRE = cast(Callee->IgnoreParenCasts());
+  FunctionDecl *FDecl = cast(DRE->getDecl());
+
+  Expr *AArg = TheCall->getArg(0);
+  Expr *BArg = TheCall->getArg(1);
+
+  bool ArgError = false;
+  // Some very basic type checking, both parameters must be matrices
+  if (!AArg->getType()->isMatrixType()) {
+Diag(AArg->getBeginLoc(), diag::err_builtin_matrix_arg) << 0;
+ArgError = true;
+  }
+  if (!BArg->getType()->isMatrixType()) {
+Diag(BArg->getBeginLoc(), diag::err_builtin_matrix_arg) << 1;
+ArgError = true;
+  }
+  if (ArgError)
+return ExprError();
+
+  MatrixType const *AMType =
+  cast(AArg->getType().getCanonicalType());
+  MatrixType const *BMType =
+  cast(BArg->getType().getCanonicalType());
+
+  unsigned m = AMType->getNumRows();
+  unsigned n = AMType->getNumColumns();
+  unsigned r = BMType->getNumColumns();
+  // Full Type Checking
+
+  // Requirements:
+  // A (m x n) * B (n x r) = AB (m x r)
+  // The A Column must match the number of rows in B
+
+  if (BMType->getNumRows() != n) {
+Diag(AArg->getBeginLoc(), diag::err_builtin_matrix_dimension_error);
+return ExprError();
+  }
+
+  // Element types of both matrices must match
+  if (AMType->getElementType() != BMType->getElementType()) {
+Diag(AArg->getBeginLoc(), diag::err_builtin_matrix_element_type)
+<< AMType->getElementType()

[PATCH] D72774: [Matrix] Add __builtin_matrix_multiply to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72774



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


[PATCH] D72778: [Matrix] Add __builtin_matrix_transpose to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72778

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-matrix.c

Index: clang/test/CodeGen/builtin-matrix.c
===
--- clang/test/CodeGen/builtin-matrix.c
+++ clang/test/CodeGen/builtin-matrix.c
@@ -251,4 +251,24 @@
 }
 // CHECK: declare <25 x double> @llvm.matrix.multiply.v25f64.v25f64.v25f64(<25 x double>, <25 x double>, i32 immarg, i32 immarg, i32 immarg) [[READNONE:#[0-9]]]
 
+void transpose1(dx5x5_t *a, dx5x5_t *b) {
+  *a = __builtin_matrix_transpose(*b);
+
+  // CHECK-LABEL: @transpose1(
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:%b.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:store [25 x double]* %a, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:store [25 x double]* %b, [25 x double]** %b.addr, align 8
+  // CHECK-NEXT:%0 = load [25 x double]*, [25 x double]** %b.addr, align 8
+  // CHECK-NEXT:%1 = bitcast [25 x double]* %0 to <25 x double>*
+  // CHECK-NEXT:%2 = load <25 x double>, <25 x double>* %1, align 8
+  // CHECK-NEXT:%3 = call <25 x double> @llvm.matrix.transpose.v25f64(<25 x double> %2, i32 5, i32 5)
+  // CHECK-NEXT:%4 = load [25 x double]*, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:%5 = bitcast [25 x double]* %4 to <25 x double>*
+  // CHECK-NEXT:store <25 x double> %3, <25 x double>* %5, align 8
+  // CHECK-NEXT:ret void
+}
+// CHECK: declare <25 x double> @llvm.matrix.transpose.v25f64(<25 x double>, i32 immarg, i32 immarg) [[READNONE]]
+
 // CHECK: attributes [[READNONE]] = { nounwind readnone speculatable willreturn }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1618,6 +1618,7 @@
   case Builtin::BI__builtin_matrix_add:
   case Builtin::BI__builtin_matrix_subtract:
   case Builtin::BI__builtin_matrix_multiply:
+  case Builtin::BI__builtin_matrix_transpose:
 if (!getLangOpts().EnableMatrix) {
   Diag(TheCall->getBeginLoc(), diag::err_builtin_matrix_disabled);
   return ExprError();
@@ -1633,6 +1634,8 @@
   return SemaBuiltinMatrixEltwiseOverload(TheCall, TheCallResult);
 case Builtin::BI__builtin_matrix_multiply:
   return SemaBuiltinMatrixMultiplyOverload(TheCall, TheCallResult);
+case Builtin::BI__builtin_matrix_transpose:
+  return SemaBuiltinMatrixTransposeOverload(TheCall, TheCallResult);
 default:
   llvm_unreachable("All matrix builtins should be handled here!");
 }
@@ -15470,3 +15473,60 @@
 
   return CallResult;
 }
+
+ExprResult Sema::SemaBuiltinMatrixTransposeOverload(CallExpr *TheCall,
+ExprResult CallResult) {
+  if (checkArgCount(*this, TheCall, 1))
+return ExprError();
+
+  Expr *Arg = TheCall->getArg(0);
+
+  // Some very basic type chekcing, the parameter must be a matrix
+  if (!Arg->getType()->isMatrixType()) {
+Diag(Arg->getBeginLoc(), diag::err_builtin_matrix_arg) << 0;
+return ExprError();
+  }
+
+  MatrixType const *MType =
+  cast(Arg->getType().getCanonicalType());
+
+  unsigned R = MType->getNumRows();
+  unsigned C = MType->getNumColumns();
+  // Full Type Checking
+
+  // Set up the function prototype
+
+  if (!Arg->isRValue()) {
+ExprResult Res = ImplicitCastExpr::Create(
+Context, Arg->getType(), CK_LValueToRValue, Arg, nullptr, VK_RValue);
+assert(!Res.isInvalid() && "Matrix Cast failed");
+TheCall->setArg(0, Res.get());
+  }
+
+  Expr *Callee = TheCall->getCallee();
+  DeclRefExpr *DRE = cast(Callee->IgnoreParenCasts());
+  FunctionDecl *FDecl = cast(DRE->getDecl());
+
+  // Function Return Type
+  QualType ReturnElementType = MType->getElementType();
+  QualType ResultType = Context.getMatrixType(ReturnElementType, C, R);
+
+  // Create a new DeclRefExpr to refer to the new decl.
+  DeclRefExpr *NewDRE = DeclRefExpr::Create(
+  Context, DRE->getQualifierLoc(), SourceLocation(), FDecl,
+  /*enclosing*/ false, DRE->getLocation(), Context.BuiltinFnTy,
+  DRE->getValueKind(), nullptr, nullptr, DRE->isNonOdrUse());
+
+  // Set the callee in the CallExpr.
+  // FIXME: This loses syntactic information.
+  QualType CalleePtrTy = Context.getPointerType(FDecl->getType());
+  ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
+  CK_BuiltinFnToFnPtr);
+  TheCall->setCallee(PromotedCall.get());
+
+  // Change the result type of the call to match the original value type. This
+  // is arbitrary, but the codegen for these builtins ins design to handle it
+  // 

[PATCH] D72777: [clangd] Dont display `` kinds in hover board

2020-01-15 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: usaxena95.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Currently when hovering over an `auto` or `decltype` that resolve to a
builtin-type, clangd would display `` as the kind of the symbol.

Drop that to make rendering nicer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72777

Files:
  clang-tools-extra/clangd/Hover.cpp
  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
@@ -1655,7 +1655,7 @@
 HI.Kind = index::SymbolKind::Unknown;
 HI.Name = "X";
   },
-  R"( X)",
+  R"(X)",
   },
   {
   [](HoverInfo &HI) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -522,7 +522,8 @@
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph &Header = Output.addHeading(3);
-  Header.appendText(index::getSymbolKindString(Kind));
+  if (Kind != index::SymbolKind::Unknown)
+Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 


Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -1655,7 +1655,7 @@
 HI.Kind = index::SymbolKind::Unknown;
 HI.Name = "X";
   },
-  R"( X)",
+  R"(X)",
   },
   {
   [](HoverInfo &HI) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -522,7 +522,8 @@
   // level 1 and 2 headers in a huge font, see
   // https://github.com/microsoft/vscode/issues/88417 for details.
   markup::Paragraph &Header = Output.addHeading(3);
-  Header.appendText(index::getSymbolKindString(Kind));
+  if (Kind != index::SymbolKind::Unknown)
+Header.appendText(index::getSymbolKindString(Kind));
   assert(!Name.empty() && "hover triggered on a nameless symbol");
   Header.appendCode(Name);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] da9d57d - [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-15 Thread Mark Murray via cfe-commits

Author: Mark Murray
Date: 2020-01-15T17:20:15Z
New Revision: da9d57d2c2dc821979490a425142afde5107066c

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

LOG: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

Summary: Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics and unit tests.

Reviewers: simon_tatham, miyuki, dmgreen

Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 
clang/test/CodeGen/arm-mve-intrinsics/vmaxaq.c
clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
clang/test/CodeGen/arm-mve-intrinsics/vminaq.c
clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxaq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Modified: 
clang/include/clang/Basic/arm_mve.td
llvm/include/llvm/IR/IntrinsicsARM.td
llvm/lib/Target/ARM/ARMInstrMVE.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_mve.td 
b/clang/include/clang/Basic/arm_mve.td
index 0e023b85459c..a348713b2aa3 100644
--- a/clang/include/clang/Basic/arm_mve.td
+++ b/clang/include/clang/Basic/arm_mve.td
@@ -192,6 +192,10 @@ let params = T.Int in {
 let params = T.Signed in {
   defm vqdmulhq : VectorVectorArithmetic<"qdmulh_predicated", (?), 0>;
   defm vqrdmulhq : VectorVectorArithmetic<"qrdmulh_predicated", (?), 0>;
+  def vminaq_m: Intrinsic $a, $b, $pred)>;
+  def vmaxaq_m: Intrinsic $a, $b, $pred)>;
 }
 
 let params = T.Poly, overrideKindLetter = "p" in {
@@ -203,6 +207,10 @@ let params = T.Poly, overrideKindLetter = "p" in {
 let params = T.Float in {
   defm vminnmq : VectorVectorArithmetic<"min_predicated", (? (u32 0))>;
   defm vmaxnmq : VectorVectorArithmetic<"max_predicated", (? (u32 0))>;
+  def vminnmaq_m: Intrinsic $a, $b, $pred)>;
+  def vmaxnmaq_m: Intrinsic $a, $b, $pred)>;
 }
 
 let params = T.Int in {
@@ -275,6 +283,14 @@ let params = T.Signed in {
(select (icmp_sle $a, $b), $a, $b)>;
   def vmaxq: Intrinsic;
+  def vminaq: Intrinsic;
+  def vmaxaq: Intrinsic;
 }
 let params = T.Unsigned in {
   def vminqu: Intrinsic $a, $b)>;
+ (IRIntBase<"minnum", [Vector]> $a, $b)>;
   def vmaxnmq: Intrinsic $a, $b)>;
+ (IRIntBase<"maxnum", [Vector]> $a, $b)>;
+  def vminnmaq: Intrinsic
+   $a, (IRIntBase<"fabs", [Vector]> $b))>;
+  def vmaxnmaq: Intrinsic
+   $a, (IRIntBase<"fabs", [Vector]> $b))>;
 }
 
 def vpselq: Intrinsic
+
+// CHECK-LABEL: @test_vmaxaq_s8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <16 x i8> [[B:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <16 x i8> zeroinitializer, [[B]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <16 x i1> [[TMP0]], <16 x i8> 
[[TMP1]], <16 x i8> [[B]]
+// CHECK-NEXT:[[TMP3:%.*]] = icmp ugt <16 x i8> [[TMP2]], [[A:%.*]]
+// CHECK-NEXT:[[TMP4:%.*]] = select <16 x i1> [[TMP3]], <16 x i8> 
[[TMP2]], <16 x i8> [[A]]
+// CHECK-NEXT:ret <16 x i8> [[TMP4]]
+//
+uint8x16_t test_vmaxaq_s8(uint8x16_t a, int8x16_t b)
+{
+#ifdef POLYMORPHIC
+return vmaxaq(a, b);
+#else /* POLYMORPHIC */
+return vmaxaq_s8(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmaxaq_s16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <8 x i16> [[B:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <8 x i16> zeroinitializer, [[B]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <8 x i1> [[TMP0]], <8 x i16> [[TMP1]], 
<8 x i16> [[B]]
+// CHECK-NEXT:[[TMP3:%.*]] = icmp ugt <8 x i16> [[TMP2]], [[A:%.*]]
+// CHECK-NEXT:[[TMP4:%.*]] = select <8 x i1> [[TMP3]], <8 x i16> [[TMP2]], 
<8 x i16> [[A]]
+// CHECK-NEXT:ret <8 x i16> [[TMP4]]
+//
+uint16x8_t test_vmaxaq_s16(uint16x8_t a, int16x8_t b)
+{
+#ifdef POLYMORPHIC
+return vmaxaq(a, b);
+#else /* POLYMORPHIC */
+return vmaxaq_s16(a, b);
+#endif /* POLYMORPHIC */
+}
+
+// CHECK-LABEL: @test_vmaxaq_s32(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = icmp slt <4 x i32> [[B:%.*]], zeroinitializer
+// CHECK-NEXT:[[TMP1:%.*]] = sub <4 x i32> zeroinitializer, [[B]]
+// CHECK-NEXT:[[TMP2:%.*]] = select <4 x i1> [[TMP0]], <4 x i32> [[TMP1]], 
<4 x i32> [[B]]
+// CHECK-NEXT:[[TMP3:%.*]] = icmp ugt <4 x i32> [[TMP2]], [[A:%.*]]
+// CHECK-NEXT:[[TMP4:%.*]] = select <4 x i1> [[TMP3]], <4 x i32> [[TMP2]], 
<4 x i32> [[A]]
+// CHECK-NEXT:ret <4 x i32> [[TMP4]]
+//
+uint32x4_t test_vmaxaq_s32(uint32x4_t a, int32x4_t b)
+{
+#ifdef POLYMORPHIC
+return vmaxaq(a, b);
+#else /* PO

[clang] 8e5018e - Replace CLANG_SPAWN_CC1 env var with a driver mode flag

2020-01-15 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-01-15T12:22:40-05:00
New Revision: 8e5018e990b701391e6c33ba85b012343df67272

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

LOG: Replace CLANG_SPAWN_CC1 env var with a driver mode flag

Flags are clang's default UI is flags.

We can have an env var in addition to that, but in D69825 nobody has yet
mentioned why this needs an env var, so omit it for now.  If someone
needs to set the flag via env var, the existing CCC_OVERRIDE_OPTIONS
mechanism works for it (set CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1
for example).

Also mention the cc1-in-process change in the release notes.

Also spruce up the test a bit so it actually tests something :)

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/cc1-spawnprocess.c
clang/tools/driver/driver.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 66eb1268de77..e5b5438216ef 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -46,6 +46,11 @@ sections with improvements to Clang's support for those 
languages.
 Major New Features
 --
 
+- clang used to run the actual compilation in a subprocess ("clang -cc1").
+  Now compilations are done in-process by default. ``-fno-integrated-cc1``
+  restores the former behavior. The ``-v`` and ``-###`` flags will print
+  "(in-process)" when compilations are done in-process.
+
 - ...
 
 Improvements to Clang's diagnostics

diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 1218172fd5b6..abfa767afea8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2855,6 +2855,14 @@ def fintegrated_as : Flag<["-"], "fintegrated-as">, 
Flags<[DriverOption]>,
 def fno_integrated_as : Flag<["-"], "fno-integrated-as">,
 Flags<[CC1Option, DriverOption]>, Group,
 HelpText<"Disable the integrated assembler">;
+
+def fintegrated_cc1 : Flag<["-"], "fintegrated-cc1">,
+  Flags<[CoreOption, DriverOption]>, Group,
+  HelpText<"Run cc1 in-process">;
+def fno_integrated_cc1 : Flag<["-"], "fno-integrated-cc1">,
+ Flags<[CoreOption, DriverOption]>, Group,
+ HelpText<"Spawn a separate process for each cc1">;
+
 def : Flag<["-"], "integrated-as">, Alias, 
Flags<[DriverOption]>;
 def : Flag<["-"], "no-integrated-as">, Alias,
   Flags<[CC1Option, DriverOption]>;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e718b8366df0..7ee3caaa0bce 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1035,6 +1035,10 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
   // -no-canonical-prefixes is used very early in main.
   Args.ClaimAllArgs(options::OPT_no_canonical_prefixes);
 
+  // f(no-)integated-cc1 is also used very early in main.
+  Args.ClaimAllArgs(options::OPT_fintegrated_cc1);
+  Args.ClaimAllArgs(options::OPT_fno_integrated_cc1);
+
   // Ignore -pipe.
   Args.ClaimAllArgs(options::OPT_pipe);
 

diff  --git a/clang/test/Driver/cc1-spawnprocess.c 
b/clang/test/Driver/cc1-spawnprocess.c
index c5c16ce8513f..624593895961 100644
--- a/clang/test/Driver/cc1-spawnprocess.c
+++ b/clang/test/Driver/cc1-spawnprocess.c
@@ -1,4 +1,22 @@
-// RUN: env CLANG_SPAWN_CC1= %clang -S %s -o /dev/null
-// RUN: env CLANG_SPAWN_CC1=0 %clang -S %s -o /dev/null
-// RUN: env CLANG_SPAWN_CC1=1 %clang -S %s -o /dev/null
-// RUN: env CLANG_SPAWN_CC1=test not %clang -S %s -o /dev/null
+// RUN: %clang -fintegrated-cc1 -### %s 2>&1 | FileCheck %s --check-prefix=YES
+// RUN: %clang -fno-integrated-cc1 -### %s 2>&1 | FileCheck %s 
--check-prefix=NO
+
+// RUN: %clang -fintegrated-cc1 -fno-integrated-cc1 -### %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=NO
+// RUN: %clang -fno-integrated-cc1 -fintegrated-cc1 -### %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=YES
+
+// RUN: %clang_cl -fintegrated-cc1 -### -- %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=YES
+// RUN: %clang_cl -fno-integrated-cc1 -### -- %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=NO
+
+// RUN: env CCC_OVERRIDE_OPTIONS=+-fintegrated-cc1 \
+// RUN: %clang -fintegrated-cc1 -### %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=YES
+// RUN: env CCC_OVERRIDE_OPTIONS=+-fno-integrated-cc1 \
+// RUN: %clang -fintegrated-cc1 -### %s 2>&1 \
+// RUN: | FileCheck %s --check-prefix=NO
+
+// YES: (in-process)
+// NO-NOT: (in-process)

diff  --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
ind

[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-15 Thread Mark Murray via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGda9d57d2c2dc: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, 
VMAXAQ, VMAXNMAQ intrinsics. (authored by MarkMurrayARM).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72761

Files:
  clang/include/clang/Basic/arm_mve.td
  clang/test/CodeGen/arm-mve-intrinsics/vmaxaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vmaxnmaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminaq.c
  clang/test/CodeGen/arm-mve-intrinsics/vminnmaq.c
  llvm/include/llvm/IR/IntrinsicsARM.td
  llvm/lib/Target/ARM/ARMInstrMVE.td
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vmaxnmaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
  llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll

Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminnmaq.ll
@@ -0,0 +1,68 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <8 x half> @test_vminnmaq_f16(<8 x half> %a, <8 x half> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vminnma.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <8 x half> @llvm.fabs.v8f16(<8 x half> %b)
+  %1 = tail call <8 x half> @llvm.minnum.v8f16(<8 x half> %a, <8 x half> %0)
+  ret <8 x half> %1
+}
+
+declare <8 x half> @llvm.fabs.v8f16(<8 x half>) #1
+
+declare <8 x half> @llvm.minnum.v8f16(<8 x half>, <8 x half>) #1
+
+define arm_aapcs_vfpcc <4 x float> @test_vminnmaq_f32(<4 x float> %a, <4 x float> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vminnma.f32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = tail call <4 x float> @llvm.fabs.v4f32(<4 x float> %b)
+  %1 = tail call <4 x float> @llvm.minnum.v4f32(<4 x float> %a, <4 x float> %0)
+  ret <4 x float> %1
+}
+
+declare <4 x float> @llvm.fabs.v4f32(<4 x float>) #1
+
+declare <4 x float> @llvm.minnum.v4f32(<4 x float>, <4 x float>) #1
+
+define arm_aapcs_vfpcc <8 x half> @test_vminnmaq_m_f16(<8 x half> %a, <8 x half> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_m_f16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vminnmat.f16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32 %0)
+  %2 = tail call <8 x half> @llvm.arm.mve.vminnma.predicated.v8f16.v8i1(<8 x half> %a, <8 x half> %b, <8 x i1> %1)
+  ret <8 x half> %2
+}
+
+declare <8 x i1> @llvm.arm.mve.pred.i2v.v8i1(i32) #2
+
+declare <8 x half> @llvm.arm.mve.vminnma.predicated.v8f16.v8i1(<8 x half>, <8 x half>, <8 x i1>) #2
+
+define arm_aapcs_vfpcc <4 x float> @test_vminnmaq_m_f32(<4 x float> %a, <4 x float> %b, i16 zeroext %p) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminnmaq_m_f32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmsr p0, r0
+; CHECK-NEXT:vpst
+; CHECK-NEXT:vminnmat.f32 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = zext i16 %p to i32
+  %1 = tail call <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32 %0)
+  %2 = tail call <4 x float> @llvm.arm.mve.vminnma.predicated.v4f32.v4i1(<4 x float> %a, <4 x float> %b, <4 x i1> %1)
+  ret <4 x float> %2
+}
+
+declare <4 x i1> @llvm.arm.mve.pred.i2v.v4i1(i32) #2
+
+declare <4 x float> @llvm.arm.mve.vminnma.predicated.v4f32.v4i1(<4 x float>, <4 x float>, <4 x i1>) #2
Index: llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
===
--- /dev/null
+++ llvm/test/CodeGen/Thumb2/mve-intrinsics/vminaq.ll
@@ -0,0 +1,98 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main -mattr=+mve.fp -verify-machineinstrs -o - %s | FileCheck %s
+
+define arm_aapcs_vfpcc <16 x i8> @test_vminaq_s8(<16 x i8> %a, <16 x i8> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s8:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmina.s8 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp slt <16 x i8> %b, zeroinitializer
+  %1 = sub <16 x i8> zeroinitializer, %b
+  %2 = select <16 x i1> %0, <16 x i8> %1, <16 x i8> %b
+  %3 = icmp ult <16 x i8> %2, %a
+  %4 = select <16 x i1> %3, <16 x i8> %2, <16 x i8> %a
+  ret <16 x i8> %4
+}
+
+define arm_aapcs_vfpcc <8 x i16> @test_vminaq_s16(<8 x i16> %a, <8 x i16> %b) local_unnamed_addr #0 {
+; CHECK-LABEL: test_vminaq_s16:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmina.s16 q0, q1
+; CHECK-NEXT:bx lr
+entry:
+  %0 = icmp slt <8 x i16> %b, zeroinitializer
+  %1 = sub <8 x i16> zeroinitializer, %b
+  

[PATCH] D72781: [Matrix] Add __builtin_matrix_column_load to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72781

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-matrix.c

Index: clang/test/CodeGen/builtin-matrix.c
===
--- clang/test/CodeGen/builtin-matrix.c
+++ clang/test/CodeGen/builtin-matrix.c
@@ -271,4 +271,23 @@
 }
 // CHECK: declare <25 x double> @llvm.matrix.transpose.v25f64(<25 x double>, i32 immarg, i32 immarg) [[READNONE]]
 
+void column_load1(dx5x5_t *a, double *b) {
+  *a = __builtin_matrix_column_load(b, 5, 5, 10);
+
+  // CHECK-LABEL: @column_load1(
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:%b.addr = alloca double*, align 8
+  // CHECK-NEXT:store [25 x double]* %a, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:store double* %b, double** %b.addr, align 8
+  // CHECK-NEXT:%0 = load double*, double** %b.addr, align 8
+  // CHECK-NEXT:%matrix = call <25 x double> @llvm.matrix.columnwise.load.v25f64.p0f64(double* %0, i32 10, i32 5, i32 5)
+  // CHECK-NEXT:%1 = load [25 x double]*, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:%2 = bitcast [25 x double]* %1 to <25 x double>*
+  // CHECK-NEXT:store <25 x double> %matrix, <25 x double>* %2, align 8
+  // CHECK-NEXT:ret void
+}
+// CHECK: declare <25 x double> @llvm.matrix.columnwise.load.v25f64.p0f64(double*, i32, i32 immarg, i32 immarg) [[READONLY:#[0-9]]]
+
 // CHECK: attributes [[READNONE]] = { nounwind readnone speculatable willreturn }
+// CHECK: attributes [[READONLY]] = { nounwind readonly willreturn }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1619,6 +1619,7 @@
   case Builtin::BI__builtin_matrix_subtract:
   case Builtin::BI__builtin_matrix_multiply:
   case Builtin::BI__builtin_matrix_transpose:
+  case Builtin::BI__builtin_matrix_column_load:
 if (!getLangOpts().EnableMatrix) {
   Diag(TheCall->getBeginLoc(), diag::err_builtin_matrix_disabled);
   return ExprError();
@@ -1636,6 +1637,8 @@
   return SemaBuiltinMatrixMultiplyOverload(TheCall, TheCallResult);
 case Builtin::BI__builtin_matrix_transpose:
   return SemaBuiltinMatrixTransposeOverload(TheCall, TheCallResult);
+case Builtin::BI__builtin_matrix_column_load:
+  return SemaBuiltinMatrixColumnLoadOverload(TheCall, TheCallResult);
 default:
   llvm_unreachable("All matrix builtins should be handled here!");
 }
@@ -15530,3 +15533,121 @@
   TheCall->setType(ResultType);
   return CallResult;
 }
+
+ExprResult Sema::SemaBuiltinMatrixColumnLoadOverload(CallExpr *TheCall,
+ ExprResult CallResult) {
+  // Must have exactly four operands
+  // 1: Pointer to data
+  // 2: Rows (constant)
+  // 3: Columns (constant)
+  // 5: Stride
+
+  // Operands have very similar semantics to glVertexAttribPointer from OpenGL.
+  // Instead of the attribute index, it is a pointer to the memory that is being
+  // loaded from Instead of size, we need the rows and columns. Note that these
+  // must be constant to construct the matrix type.
+
+  if (checkArgCount(*this, TheCall, 4))
+return ExprError();
+
+  Expr *DataExpr = TheCall->getArg(0);
+  Expr *RowsExpr = TheCall->getArg(1);
+  Expr *ColsExpr = TheCall->getArg(2);
+  Expr *StrideExpr = TheCall->getArg(3);
+
+  unsigned Rows = 0;
+  unsigned Cols = 0;
+
+  if (!(DataExpr->getType()->isPointerType() ||
+DataExpr->getType()->isArrayType())) {
+Diag(DataExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
+<< 0 << 0;
+  }
+
+  bool ArgError = false;
+  // get the matrix dimensions
+  {
+llvm::APSInt Value(32);
+SourceLocation RowColErrorPos;
+
+if (!RowsExpr->isIntegerConstantExpr(Value, Context, &RowColErrorPos)) {
+  Diag(RowsExpr->getBeginLoc(), diag::err_builtin_matrix_scalar_int_arg)
+  << 0 << 1;
+  ArgError = true;
+} else
+  Rows = Value.getZExtValue();
+
+if (!ColsExpr->isIntegerConstantExpr(Value, Context, &RowColErrorPos)) {
+  Diag(ColsExpr->getBeginLoc(), diag::err_builtin_matrix_scalar_int_arg)
+  << 1 << 1;
+  ArgError = true;
+} else
+  Cols = Value.getZExtValue();
+  }
+  if (!StrideExpr->getType()->isIntegralType(Context)) {
+Diag(StrideExpr->getBeginLoc(), diag::err_builtin_matrix_scalar_int_arg)
+<< 3 << 1;
+ArgError = true;
+  }
+  if (ArgError)
+return ExprError();
+
+  QualType ElementType;
+
+  if (const PointerType *PTy = dyn_cast(DataExpr->getType())) {
+ElementType = PTy->getPointeeType();
+  } else if (const ArrayType *ATy = dyn_

[PATCH] D72778: [Matrix] Add __builtin_matrix_transpose to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72778



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


[PATCH] D72777: [clangd] Dont display `` kinds in hover board

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon check-circle color=green} Unit tests: pass. 61895 tests passed, 0 failed 
and 782 were skipped.

{icon question-circle color=gray} clang-tidy: unknown.

{icon check-circle color=green} clang-format: pass.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72777



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


[PATCH] D72782: [Matrix] Add __builtin_matrix_column_store to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72782

Files:
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtin-matrix.c

Index: clang/test/CodeGen/builtin-matrix.c
===
--- clang/test/CodeGen/builtin-matrix.c
+++ clang/test/CodeGen/builtin-matrix.c
@@ -289,5 +289,24 @@
 }
 // CHECK: declare <25 x double> @llvm.matrix.columnwise.load.v25f64.p0f64(double*, i32, i32 immarg, i32 immarg) [[READONLY:#[0-9]]]
 
+void column_store1(dx5x5_t *a, double *b) {
+  __builtin_matrix_column_store(*a, b, 10);
+
+  // CHECK-LABEL: @column_store1(
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%a.addr = alloca [25 x double]*, align 8
+  // CHECK-NEXT:%b.addr = alloca double*, align 8
+  // CHECK-NEXT:store [25 x double]* %a, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:store double* %b, double** %b.addr, align 8
+  // CHECK-NEXT:%0 = load [25 x double]*, [25 x double]** %a.addr, align 8
+  // CHECK-NEXT:%1 = bitcast [25 x double]* %0 to <25 x double>*
+  // CHECK-NEXT:%2 = load <25 x double>, <25 x double>* %1, align 8
+  // CHECK-NEXT:%3 = load double*, double** %b.addr, align 8
+  // CHECK-NEXT:call void @llvm.matrix.columnwise.store.v25f64.p0f64(<25 x double> %2, double* %3, i32 10, i32 5, i32 5)
+  // CHECK-NEXT:ret void
+}
+// CHECK: declare void @llvm.matrix.columnwise.store.v25f64.p0f64(<25 x double>, double* writeonly, i32, i32 immarg, i32 immarg) [[WRITEONLY:#[0-9]]]
+
 // CHECK: attributes [[READNONE]] = { nounwind readnone speculatable willreturn }
 // CHECK: attributes [[READONLY]] = { nounwind readonly willreturn }
+// CHECK: attributes [[WRITEONLY]] = { nounwind willreturn }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1620,6 +1620,7 @@
   case Builtin::BI__builtin_matrix_multiply:
   case Builtin::BI__builtin_matrix_transpose:
   case Builtin::BI__builtin_matrix_column_load:
+  case Builtin::BI__builtin_matrix_column_store:
 if (!getLangOpts().EnableMatrix) {
   Diag(TheCall->getBeginLoc(), diag::err_builtin_matrix_disabled);
   return ExprError();
@@ -1639,6 +1640,8 @@
   return SemaBuiltinMatrixTransposeOverload(TheCall, TheCallResult);
 case Builtin::BI__builtin_matrix_column_load:
   return SemaBuiltinMatrixColumnLoadOverload(TheCall, TheCallResult);
+case Builtin::BI__builtin_matrix_column_store:
+  return SemaBuiltinMatrixColumnStoreOverload(TheCall, TheCallResult);
 default:
   llvm_unreachable("All matrix builtins should be handled here!");
 }
@@ -15651,3 +15654,81 @@
 
   return CallResult;
 }
+
+ExprResult Sema::SemaBuiltinMatrixColumnStoreOverload(CallExpr *TheCall,
+  ExprResult CallResult) {
+  // Must have
+  // 1: Matrix to store
+  // 2: Pointer to store to
+  // 3: Stride (unsigned)
+
+  if (checkArgCount(*this, TheCall, 3))
+return ExprError();
+
+  Expr *MatrixExpr = TheCall->getArg(0);
+  Expr *DataExpr = TheCall->getArg(1);
+  Expr *StrideExpr = TheCall->getArg(2);
+
+  bool ArgError = false;
+  if (!MatrixExpr->getType()->isMatrixType()) {
+Diag(MatrixExpr->getBeginLoc(), diag::err_builtin_matrix_arg) << 0;
+ArgError = true;
+  }
+  if (!DataExpr->getType()->isPointerType()) {
+Diag(DataExpr->getBeginLoc(), diag::err_builtin_matrix_pointer_arg)
+<< 1 << 0;
+ArgError = true;
+  }
+  if (!StrideExpr->getType()->isIntegralType(Context)) {
+Diag(StrideExpr->getBeginLoc(), diag::err_builtin_matrix_scalar_int_arg)
+<< 3 << 0;
+ArgError = true;
+  }
+  if (ArgError)
+return ExprError();
+
+  // TODO: Check element type compatibility, and possibly up/down cast element
+  // types
+
+  // Cast matrix to an rvalue
+  if (!MatrixExpr->isRValue()) {
+ExprResult CastExprResult = ImplicitCastExpr::Create(
+Context, MatrixExpr->getType(), CK_LValueToRValue, MatrixExpr, nullptr,
+VK_RValue);
+assert(!CastExprResult.isInvalid() && "Matrix cast to an R-value failed");
+MatrixExpr = CastExprResult.get();
+TheCall->setArg(0, MatrixExpr);
+  }
+
+  if (!DataExpr->isRValue()) {
+ExprResult CastExprResult = ImplicitCastExpr::Create(
+Context, DataExpr->getType(), CK_LValueToRValue, DataExpr, nullptr,
+VK_RValue);
+assert(!CastExprResult.isInvalid() && "Pointer cast to R-value failed");
+DataExpr = CastExprResult.get();
+TheCall->setArg(1, DataExpr);
+  }
+
+  llvm::SmallVector ParameterTypes = {
+  MatrixExpr->getType().withConst(), DataExpr->getType(),
+  StrideExpr->getType().withConst()};
+
+ Expr *Callee = TheCall->getCallee

[PATCH] D72304: [OpenMP]{OMPIRBuilder] Add Directives (master and critical) to OMPBuilder.

2020-01-15 Thread Fady Ghanim via Phabricator via cfe-commits
fghanim updated this revision to Diff 238301.
fghanim marked 25 inline comments as done.
fghanim added a comment.

Addressing reviewer comments

- Added regression tests
- styling
- adding asserts and todo where needed.

Also, Now `EmitInlinedRegion` will merge blocks where legal.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72304

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/critical_codegen.cpp
  clang/test/OpenMP/master_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPConstants.cpp
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -613,4 +613,164 @@
   }
 }
 
+TEST_F(OpenMPIRBuilderTest, MasterDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = nullptr;
+
+  BasicBlock *EntryBB = nullptr;
+  BasicBlock *ExitBB = nullptr;
+  BasicBlock *ThenBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &FiniBB) {
+if (AllocaIP.isSet())
+  Builder.restoreIP(AllocaIP);
+else
+  Builder.SetInsertPoint(&*(F->getEntryBlock().getFirstInsertionPt()));
+PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+Builder.CreateStore(F->arg_begin(), PrivAI);
+
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+
+Builder.restoreIP(CodeGenIP);
+
+// collect some info for checks later
+ExitBB = FiniBB.getUniqueSuccessor();
+ThenBB = Builder.GetInsertBlock();
+EntryBB = ThenBB->getUniquePredecessor();
+
+// simple instructions for body
+Value *PrivLoad = Builder.CreateLoad(PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad);
+  };
+
+  auto FiniCB = [&](InsertPointTy IP) {
+BasicBlock *IPBB = IP.getBlock();
+EXPECT_NE(IPBB->end(), IP.getPoint());
+  };
+
+  Builder.restoreIP(OMPBuilder.CreateMaster(Builder, BodyGenCB, FiniCB));
+  Value *EntryBBTI = EntryBB->getTerminator();
+  EXPECT_NE(EntryBBTI, nullptr);
+  EXPECT_TRUE(isa(EntryBBTI));
+  BranchInst *EntryBr = cast(EntryBB->getTerminator());
+  EXPECT_TRUE(EntryBr->isConditional());
+  EXPECT_EQ(EntryBr->getSuccessor(0), ThenBB);
+  EXPECT_EQ(ThenBB->getUniqueSuccessor(), ExitBB);
+  EXPECT_EQ(EntryBr->getSuccessor(1), ExitBB);
+
+  CmpInst *CondInst = cast(EntryBr->getCondition());
+  EXPECT_TRUE(isa(CondInst->getOperand(0)));
+
+  CallInst *MasterEntryCI = cast(CondInst->getOperand(0));
+  EXPECT_EQ(MasterEntryCI->getNumArgOperands(), 2U);
+  EXPECT_EQ(MasterEntryCI->getCalledFunction()->getName(), "__kmpc_master");
+  EXPECT_TRUE(isa(MasterEntryCI->getArgOperand(0)));
+
+  CallInst *MasterEndCI = nullptr;
+  for (auto &FI : *ThenBB) {
+Instruction *cur = &FI;
+if (isa(cur)) {
+  MasterEndCI = cast(cur);
+  if (MasterEndCI->getCalledFunction()->getName() == "__kmpc_end_master")
+break;
+  else
+MasterEndCI = nullptr;
+}
+  }
+  EXPECT_NE(MasterEndCI, nullptr);
+  EXPECT_EQ(MasterEndCI->getNumArgOperands(), 2U);
+  EXPECT_TRUE(isa(MasterEndCI->getArgOperand(0)));
+  EXPECT_EQ(MasterEndCI->getArgOperand(1), MasterEntryCI->getArgOperand(1));
+}
+
+TEST_F(OpenMPIRBuilderTest, CriticalDirective) {
+  using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+  F->setName("func");
+  IRBuilder<> Builder(BB);
+
+  OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP(), DL});
+
+  AllocaInst *PrivAI = Builder.CreateAlloca(F->arg_begin()->getType());
+
+  BasicBlock *EntryBB = nullptr;
+
+  auto BodyGenCB = [&](InsertPointTy AllocaIP, InsertPointTy CodeGenIP,
+   BasicBlock &FiniBB) {
+// collect some info for checks later
+EntryBB = FiniBB.getUniquePredecessor();
+
+// actual start for bodyCB
+llvm::BasicBlock *CodeGenIPBB = CodeGenIP.getBlock();
+llvm::Instruction *CodeGenIPInst = &*CodeGenIP.getPoint();
+EXPECT_EQ(CodeGenIPBB->getTerminator(), CodeGenIPInst);
+EXPECT_EQ(EntryBB, CodeGenIPBB);
+
+// body begin
+Builder.restoreIP(CodeGenIP);
+Builder.CreateStore(F->arg_begin(), PrivAI);
+Value *PrivLoad = Builder.CreateLoad(PrivAI, "local.use");
+Builder.CreateICmpNE(F->arg_begin(), PrivLoad

[PATCH] D72769: Replace CLANG_SPAWN_CC1 env var with a driver mode flag

2020-01-15 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

cc cfe-commits for completeness


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

https://reviews.llvm.org/D72769



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


[PATCH] D72380: [DataFlow] Factor two worklist implementations out

2020-01-15 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Ping for the other reviewers :)


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

https://reviews.llvm.org/D72380



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


[PATCH] D72782: [Matrix] Add __builtin_matrix_column_store to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72782



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


[PATCH] D72781: [Matrix] Add __builtin_matrix_column_load to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72781



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


[PATCH] D72785: [Matrix] Add __builtin_matrix_scalar_multiply to Clang (WIP).

2020-01-15 Thread Florian Hahn via Phabricator via cfe-commits
fhahn created this revision.
Herald added a subscriber: tschuett.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72785

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

Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -1619,6 +1619,7 @@
   case Builtin::BI__builtin_matrix_subtract:
   case Builtin::BI__builtin_matrix_multiply:
   case Builtin::BI__builtin_matrix_transpose:
+  case Builtin::BI__builtin_matrix_scalar_multiply:
   case Builtin::BI__builtin_matrix_column_load:
   case Builtin::BI__builtin_matrix_column_store:
 if (!getLangOpts().EnableMatrix) {
@@ -1638,6 +1639,8 @@
   return SemaBuiltinMatrixMultiplyOverload(TheCall, TheCallResult);
 case Builtin::BI__builtin_matrix_transpose:
   return SemaBuiltinMatrixTransposeOverload(TheCall, TheCallResult);
+case Builtin::BI__builtin_matrix_scalar_multiply:
+  return SemaBuiltinMatrixScalarOverload(TheCall, TheCallResult);
 case Builtin::BI__builtin_matrix_column_load:
   return SemaBuiltinMatrixColumnLoadOverload(TheCall, TheCallResult);
 case Builtin::BI__builtin_matrix_column_store:
@@ -15537,6 +15540,89 @@
   return CallResult;
 }
 
+ExprResult Sema::SemaBuiltinMatrixScalarOverload(CallExpr *TheCall,
+ ExprResult CallResult) {
+  if (checkArgCount(*this, TheCall, 2)) {
+return ExprError();
+  }
+
+  // First argument must be a matrix type
+  Expr *MatrixArg = TheCall->getArg(0);
+  Expr *ScalarArg = TheCall->getArg(1);
+
+  if (!MatrixArg->getType()->isMatrixType()) {
+Diag(MatrixArg->getBeginLoc(), diag::err_builtin_matrix_scalar_type_error)
+<< 0;
+return ExprError();
+  }
+
+  MatrixType const *MType =
+  cast(MatrixArg->getType().getCanonicalType());
+
+  // If the scalar type and matrix type don't match, try to cast it, otherwise,
+  // be sad
+  if (MType->getElementType() != ScalarArg->getType()) {
+ExprResult TypeCastRes = ImplicitCastExpr::Create(
+Context, MType->getElementType(), CK_IntegralToFloating, ScalarArg,
+nullptr, VK_RValue);
+
+if (!ScalarArg->getType()->isFloatingType() &&
+!ScalarArg->getType()->isIntegralType(Context)) {
+  Diag(ScalarArg->getBeginLoc(), diag::err_builtin_matrix_scalar_type_error)
+  << 1;
+  return ExprError();
+}
+
+if (TypeCastRes.isInvalid()) {
+  Diag(MatrixArg->getBeginLoc(),
+   diag::err_builtin_matrix_implicit_cast_error)
+  << MType->getElementType() << ScalarArg->getType();
+  return ExprError();
+}
+
+ScalarArg = TypeCastRes.get();
+TheCall->setArg(1, ScalarArg);
+  }
+
+  if (!MatrixArg->isRValue()) {
+ExprResult CastExprResult = ImplicitCastExpr::Create(
+Context, MatrixArg->getType(), CK_LValueToRValue, MatrixArg, nullptr,
+VK_RValue);
+assert(!CastExprResult.isInvalid() && "Matrix cast to R-value failed");
+MatrixArg = CastExprResult.get();
+TheCall->setArg(0, MatrixArg);
+  }
+
+  // Create the new function prototype
+  llvm::SmallVector ParameterTypes = {MatrixArg->getType(),
+   ScalarArg->getType()};
+
+  Expr *Callee = TheCall->getCallee();
+  DeclRefExpr *DRE = cast(Callee->IgnoreParenCasts());
+  FunctionDecl *FDecl = cast(DRE->getDecl());
+
+  // Create a new DeclRefExpr to refer to the new decl.
+  DeclRefExpr *NewDRE = DeclRefExpr::Create(
+  Context, DRE->getQualifierLoc(), SourceLocation(), FDecl,
+  /*enclosing*/ false, DRE->getLocation(), Context.BuiltinFnTy,
+  DRE->getValueKind(), nullptr, nullptr, DRE->isNonOdrUse());
+
+  // Set the callee in the CallExpr.
+  // FIXME: This loses syntactic information.
+  QualType CalleePtrTy = Context.getPointerType(FDecl->getType());
+  ExprResult PromotedCall = ImpCastExprToType(NewDRE, CalleePtrTy,
+  CK_BuiltinFnToFnPtr);
+  TheCall->setCallee(PromotedCall.get());
+
+  // Change the result type of the call to match the original value type. This
+  // is arbitrary, but the codegen for these builtins ins design to handle it
+  // gracefully.
+  TheCall->setType(MatrixArg->getType());
+
+
+  return CallResult;
+}
+
 ExprResult Sema::SemaBuiltinMatrixColumnLoadOverload(CallExpr *TheCall,
  ExprResult CallResult) {
   // Must have exactly four operands
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -2451,6 +2451,14 @@
 return RValue::get(Result);
   }
 
+  case Builtin::BI__builtin_matrix_scalar_m

[PATCH] D72786: [clang] Set function attributes on SEH filter functions correctly.

2020-01-15 Thread Sanne Wouda via Phabricator via cfe-commits
sanwou01 created this revision.
sanwou01 added a reviewer: rnk.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When compiling with -munwind-tables, the SEH filter funclet needs the uwtable
function attribute, which gets automatically added if we use
SetInternalFunctionAttributes.  The filter funclet is internal so this seems
appropriate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72786

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/test/CodeGen/exceptions-seh-finally.c
  clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp


Index: clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 "-triple" "arm64-windowsj" "-munwind-tables" 
"-fms-compatibility" -emit-llvm %s -o - | FileCheck %s
+
+# 0 "" 3
+#define a(b, c) d() & b
+#define f(c) a(e(0, 0, #c).b(), )
+
+struct e {
+  e(int, int, char *);
+  int b();
+};
+
+struct d {
+  void operator&(int);
+};
+
+struct h;
+
+struct i {
+  h *operator->();
+  h &operator*() { f(); }
+};
+
+typedef int g;
+
+struct h {
+  void ad();
+};
+
+g aq(h j, g k, int, int) {
+  if (k)
+return;
+  j.ad();
+}
+
+// CHECK: define internal i32 @"?filt$0@0@at@@"(i8* %exception_pointers, i8* 
%frame_pointer) #[[MD:[0-9]+]]
+// CHECK: attributes #[[MD]] = { noinline nounwind uwtable 
+
+void at() {
+  i ar;
+
+  __try {
+ar->ad();
+  } __except (aq(*ar, _exception_code(), 0, 0)) {
+  }
+
+}
Index: clang/test/CodeGen/exceptions-seh-finally.c
===
--- clang/test/CodeGen/exceptions-seh-finally.c
+++ clang/test/CodeGen/exceptions-seh-finally.c
@@ -281,7 +281,5 @@
 // CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
 // CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], 
[18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i{{32|64}} 0, 
i{{32|64}} 0))
 
-// Look for the absence of noinline. Enum attributes come first, so check that
-// a string attribute is the first to verify that no enum attributes are
-// present.
-// CHECK: attributes [[finally_attrs]] = { "{{.*}}" }
+// noinline and nounwind are now added anyway
+// CHECK: attributes [[finally_attrs]] = { noinline nounwind "{{.*}}" }
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1885,7 +1885,7 @@
 OutlinedStmt->getBeginLoc(), OutlinedStmt->getBeginLoc());
   CurSEHParent = ParentCGF.CurSEHParent;
 
-  CGM.SetLLVMFunctionAttributes(GlobalDecl(), FnInfo, CurFn);
+  CGM.SetInternalFunctionAttributes(GlobalDecl(), CurFn, FnInfo);
   EmitCapturedLocals(ParentCGF, OutlinedStmt, IsFilter);
 }
 


Index: clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 "-triple" "arm64-windowsj" "-munwind-tables" "-fms-compatibility" -emit-llvm %s -o - | FileCheck %s
+
+# 0 "" 3
+#define a(b, c) d() & b
+#define f(c) a(e(0, 0, #c).b(), )
+
+struct e {
+  e(int, int, char *);
+  int b();
+};
+
+struct d {
+  void operator&(int);
+};
+
+struct h;
+
+struct i {
+  h *operator->();
+  h &operator*() { f(); }
+};
+
+typedef int g;
+
+struct h {
+  void ad();
+};
+
+g aq(h j, g k, int, int) {
+  if (k)
+return;
+  j.ad();
+}
+
+// CHECK: define internal i32 @"?filt$0@0@at@@"(i8* %exception_pointers, i8* %frame_pointer) #[[MD:[0-9]+]]
+// CHECK: attributes #[[MD]] = { noinline nounwind uwtable 
+
+void at() {
+  i ar;
+
+  __try {
+ar->ad();
+  } __except (aq(*ar, _exception_code(), 0, 0)) {
+  }
+
+}
Index: clang/test/CodeGen/exceptions-seh-finally.c
===
--- clang/test/CodeGen/exceptions-seh-finally.c
+++ clang/test/CodeGen/exceptions-seh-finally.c
@@ -281,7 +281,5 @@
 // CHECK-LABEL: define internal void @"?fin$0@0@finally_with_func@@"({{[^)]*}})
 // CHECK: call void @cleanup_with_func(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @"??_C@_0BC@COAGBPGM@finally_with_func?$AA@", i{{32|64}} 0, i{{32|64}} 0))
 
-// Look for the absence of noinline. Enum attributes come first, so check that
-// a string attribute is the first to verify that no enum attributes are
-// present.
-// CHECK: attributes [[finally_attrs]] = { "{{.*}}" }
+// noinline and nounwind are now added anyway
+// CHECK: attributes [[finally_attrs]] = { noinline nounwind "{{.*}}" }
Index: clang/lib/CodeGen/CGException.cpp
===
--- clang/lib/CodeGen/CGException.cpp
+++ clang/lib/CodeGen/CGException.cpp
@@ -1885,7 +1885,7 @@
 OutlinedStmt->getBeginLoc(), Ou

[PATCH] D72785: [Matrix] Add __builtin_matrix_scalar_multiply to Clang (WIP).

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon question-circle color=gray} Unit tests: unknown.

{icon question-circle color=gray} clang-tidy: unknown.

{icon question-circle color=gray} clang-format: unknown.

Build artifacts 
: 
diff.json 
,
 console-log.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72785



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


[PATCH] D72761: [ARM][MVE][Intrinsics] Add VMINAQ, VMINNMAQ, VMAXAQ, VMAXNMAQ intrinsics.

2020-01-15 Thread Dave Green via Phabricator via cfe-commits
dmgreen added a comment.

Nice one. Good to see codegen changes coming out of these intrinsics.

It took a while for me to figure out what the integer instruction was doing. 
That's a strange one.

The fp case I have a question about below.




Comment at: llvm/lib/Target/ARM/ARMInstrMVE.td:3658
+// Unpredicated v(max|min)nma
+def : Pat<(VTI.Vec (unpred_op (VTI.Vec MQPR:$Qd), (fabs (VTI.Vec 
MQPR:$Qm,
+  (VTI.Vec (Inst (VTI.Vec MQPR:$Qd), (VTI.Vec MQPR:$Qm)))>;

If I'm reading the ARMARM correctly, the fp case seems to preform the abs on 
both operands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72761



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


[PATCH] D71199: [clang-tidy] New check cppcoreguidelines-prefer-initialization-list

2020-01-15 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

By the word, please rebase, because Release Notes were reset after version 10 
branching.


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

https://reviews.llvm.org/D71199



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


[PATCH] D69878: Consoldiate internal denormal flushing controls

2020-01-15 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.
Herald added a subscriber: kerbowa.

ping


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

https://reviews.llvm.org/D69878



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


[PATCH] D72793: [clang-format] Expand the SpacesAroundConditions option to include catch statements

2020-01-15 Thread Tim Wojtulewicz via Phabricator via cfe-commits
timwoj created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This diff expands the SpacesAroundConditions option added in D68346 
 to include adding spaces to catch statements.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D72793

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14927,6 +14927,7 @@
   verifyFormat("while ( a )\n  return;", Spaces);
   verifyFormat("while ( (a && b) )\n  return;", Spaces);
   verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+  verifyFormat("try {\n} catch ( const std::exception & ) {\n}", Spaces);
   // Check that space on the left of "::" is inserted as expected at beginning
   // of condition.
   verifyFormat("while ( ::func() )\n  return;", Spaces);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2596,7 +2596,7 @@
 /// otherwise.
 static bool isKeywordWithCondition(const FormatToken &Tok) {
   return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
- tok::kw_constexpr);
+ tok::kw_constexpr, tok::kw_catch);
 }
 
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14927,6 +14927,7 @@
   verifyFormat("while ( a )\n  return;", Spaces);
   verifyFormat("while ( (a && b) )\n  return;", Spaces);
   verifyFormat("do {\n} while ( 1 != 0 );", Spaces);
+  verifyFormat("try {\n} catch ( const std::exception & ) {\n}", Spaces);
   // Check that space on the left of "::" is inserted as expected at beginning
   // of condition.
   verifyFormat("while ( ::func() )\n  return;", Spaces);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2596,7 +2596,7 @@
 /// otherwise.
 static bool isKeywordWithCondition(const FormatToken &Tok) {
   return Tok.isOneOf(tok::kw_if, tok::kw_for, tok::kw_while, tok::kw_switch,
- tok::kw_constexpr);
+ tok::kw_constexpr, tok::kw_catch);
 }
 
 bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D72786: [clang] Set function attributes on SEH filter functions correctly.

2020-01-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks, the code change looks good, but please adjust the tests a bit.




Comment at: clang/test/CodeGen/exceptions-seh-finally.c:284-286
-// Look for the absence of noinline. Enum attributes come first, so check that
-// a string attribute is the first to verify that no enum attributes are
-// present.

We shouldn't be marking this thing noinline. I believe it appears because clang 
applies noinline everywhere at O0. Please add `-O1 -disable-llvm-passes` to the 
RUN line so that it doesn't appear. The appearance of `nounwind` should be 
expected, so keep that here.



Comment at: clang/test/CodeGenCXX/exceptions-seh-filter-uwtable.cpp:1
+// RUN: %clang_cc1 "-triple" "arm64-windowsj" "-munwind-tables" 
"-fms-compatibility" -emit-llvm %s -o - | FileCheck %s
+

Is "arm64-windowsj" a typo? Also, please add `-O1 -disable-llvm-passes` as 
above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72786



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


[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-15 Thread Jaydeep Chauhan via Phabricator via cfe-commits
Jac1494 added a comment.

>> I'd be curious to the answer to David's questions. If the size increase is 
>> because of unused extern variables coming in from libc or something then it 
>> doesn't seem worth the cost.

For above case clang size is increase because ,it is difference between clang 
build without "-fstandalone-debug" option and clang build with 
"-fstandalone-debug"  option and both build contain change D71451 
 and D71599  
. So for clang build with "-fstandalone-debug"  option size will be more 
because it will add debuginfo.

And to check impact of my change on clang i have build clang with and without 
D71451  and D71599 
 change(testcases are not included).

Size of clang without D71451 and D71599 change and with option 
"-fstandalone-debug":-
=

…
.comment 159 0
.debug_str   3994952 0
.debug_loc   941 0
.debug_abbrev  12754 0
.debug_info  2223641 0
.debug_ranges  46592 0
.debug_line   153901 0
.note.gnu.gold-version28 0
Total6827932

Size of clang with D71451 and D71599 change and with option  
"-fstandalone-debug":-
===

…
.comment 159 0
.debug_str   3994894 0
.debug_loc   941 0
.debug_abbrev  12746 0
.debug_info  2223617 0
.debug_ranges  46592 0
.debug_line   153865 0
.note.gnu.gold-version28 0
Total6827806

Size of clang with D71451  and D71599 
 is reduced.

This results are with latest source and with self-host build of clang. First I 
have build clang with Release mode and using that clang I have build clang with 
debug mode with below options

“cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug 
-DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) 
-DLLVM_TARGETS_TO_BUILD="X86" -DBUILD_SHARED_LIBS=On  
-DCMAKE_CXX_FLAGS="-fstandalone-debug"   -DCMAKE_C_FLAGS="-fstandalone-debug"  
-DCMAKE_INSTALL_PREFIX=/home/bft/Jaydeep/latest_llvm/llvm-project/install_withhstandalone
 ../llvm”


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

https://reviews.llvm.org/D71451



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


[PATCH] D72284: [clang-tidy] Factor out renaming logic from readability-identifier-naming

2020-01-15 Thread Logan Smith via Phabricator via cfe-commits
logan-5 marked 2 inline comments as done.
logan-5 added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h:29
+public:
+  RenamerClangTidyCheck(StringRef CheckName, ClangTidyContext *Context);
+  ~RenamerClangTidyCheck();

logan-5 wrote:
> njames93 wrote:
> > Should this be protected as this class should never be instantiated 
> > directly. Also the definition could be moved inline as its just a 
> > delegating constructor
> The constructor (and destructor) can't be inline, since they need to be able 
> to see the specialization of `DenseMapInfo` in the cpp.
> 
> I could change it to `protected` to clean up the interface -- though it won't 
> strictly change anything, since the class already has pure virtual functions 
> so it's not instantiable.
Searched the LLVM codebase for other abstract base classes with explicitly 
defined constructors (e.g. `MakeSmartPtrCheck` in clang-tidy), and their 
constructors seem to be public. I think I'll keep this one public too for 
consistency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72284



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


[PATCH] D72675: Fix -ffast-math/-ffp-contract interaction

2020-01-15 Thread Sanjay Patel via Phabricator via cfe-commits
spatel added inline comments.



Comment at: llvm/test/CodeGen/PowerPC/fmf-propagation.ll:201-203
 ; fma(X, 7.0, X * 42.0) --> X * 49.0
-; This is the minimum FMF needed for this transform - the FMA allows 
reassociation.
+; This is the minimum FMF needed for this transform - the 'contract' allows 
the needed reassociation.
+

I was ok with the reasoning up to here, but this example lost me.
Why does 'contract' alone allow splitting an fma?
Is 'contract' relevant on anything besides fadd (with an fmul operand)?


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

https://reviews.llvm.org/D72675



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


[PATCH] D72282: [clang-tidy] Add `bugprone-unintended-adl`

2020-01-15 Thread Logan Smith via Phabricator via cfe-commits
logan-5 updated this revision to Diff 238328.
logan-5 added a comment.

Added TODO comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72282

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/UnintendedADLCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone-unintended-adl.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl-generic-lambdas.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl-operators.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-unintended-adl.cpp
@@ -0,0 +1,162 @@
+// RUN: %check_clang_tidy %s bugprone-unintended-adl %t
+
+namespace aspace {
+struct A {};
+void func(const A &);
+} // namespace aspace
+
+namespace bspace {
+void func(int);
+void test() {
+  aspace::A a;
+  func(5);
+  func(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'aspace::func' through ADL [bugprone-unintended-adl]
+}
+} // namespace bspace
+
+namespace ops {
+
+struct Stream {
+} stream;
+Stream &operator<<(Stream &s, int) {
+  return s;
+}
+Stream &operator<<(Stream &s, aspace::A) {
+  return s;
+}
+template 
+IStream &operator>>(IStream &s, int) {
+  return s;
+}
+template 
+IStream &operator>>(IStream &s, aspace::A) {
+  return s;
+}
+void smooth_operator(Stream);
+
+} // namespace ops
+
+void ops_test() {
+  ops::stream << 5;
+  // no warning
+  operator<<(ops::stream, 5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+  ops::stream << aspace::A();
+  // no warning
+  operator<<(ops::stream, aspace::A());
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+
+  ops::stream >> aspace::A();
+  // no warning
+  operator>>(ops::stream, aspace::A());
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator>>' through ADL [bugprone-unintended-adl]
+
+  smooth_operator(ops::stream);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::smooth_operator' through ADL [bugprone-unintended-adl]
+}
+
+namespace std {
+// return types don't matter, returning 'void' everywhere for simplicity
+
+template 
+void swap(T &a, T &b);
+template 
+void make_error_code(T);
+template 
+void make_error_condition(T);
+
+template 
+void move(T &&);
+template 
+void forward(T &&);
+
+struct byte {};
+
+} // namespace std
+namespace ns {
+
+struct Swappable {};
+
+// whitelisted
+void swap(Swappable &a, Swappable &b);
+void make_error_code(Swappable);
+void make_error_condition(Swappable);
+
+// non-whitelisted
+void move(Swappable);
+void ref(Swappable);
+
+struct Swappable2 {};
+
+} // namespace ns
+struct {
+  template 
+  void operator()(T &&);
+} ref;
+
+void test2() {
+  // TODO add granularity for detecting functions that may always be called unqualified,
+  // versus those that can only be called through the 'using' 'two-step'
+  using namespace std;
+  ns::Swappable a, b;
+  swap(a, b);
+  make_error_code(a);
+  make_error_condition(a);
+  move(a);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ns::move' through ADL [bugprone-unintended-adl]
+}
+
+template 
+void foo(T t) {
+  using namespace std;
+  swap(t, t);
+  make_error_code(t);
+  make_error_condition(t);
+
+  move(t);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ns::move' through ADL [bugprone-unintended-adl]
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: with argument type 'struct ns::Swappable'
+  // CHECK-MESSAGES: [[@LINE-3]]:3: warning: unqualified call to 'move' may be resolved through ADL [bugprone-unintended-adl]
+
+  std::swap(t, t);
+  std::move(t);
+
+  ref(t); // function objects bypass ADL, this always calls ::ref
+  ::ref(t);
+}
+
+template 
+void operator<<(T &&, U &&);
+
+template 
+void bar(T t) {
+  t << 5;
+  operator<<(t, 5);
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: expression calls 'ops::operator<<' through ADL [bugprone-unintended-adl]
+  // CHECK-MESSAGES: [[@LINE-2]]:3: note: with argument types 'struct ops::Stream', 'int'
+  // CHECK-MESSAGES: [[@LINE-3]]:3: warning: unqualified call to 'operator<<' may be resolved through ADL [bugprone-unintended-adl]
+}
+
+void instantiator() {
+  foo(ns::Swappable()); // instantiation will use ADL
+  foo(5);   // instantiation will not use ADL
+
+  bar(ops::Stream()); // instantiation will use ADL
+  bar(aspace::A());   // instantiation will not use ADL
+}
+
+template 
+void ma

[PATCH] D71451: Support to emit extern variables debuginfo with "-fstandalone-debug"

2020-01-15 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D71451#1822497 , @Jac1494 wrote:

> >> I'd be curious to the answer to David's questions. If the size increase is 
> >> because of unused extern variables coming in from libc or something then 
> >> it doesn't seem worth the cost.
>
> For above case clang size is increase because ,it is difference between clang 
> build without "-fstandalone-debug" option and clang build with 
> "-fstandalone-debug"  option and both build contain change D71451 
>  and D71599 
>  . So for clang build with 
> "-fstandalone-debug"  option size will be more because it will add debuginfo.
>
> And to check impact of my change on clang i have build clang with and without 
> D71451  and D71599 
>  change(testcases are not included).
>
> Size of clang without D71451  and D71599 
>  change and with option 
> "-fstandalone-debug":-
>  ===
> …
>  .comment 159 0
>  .debug_str   3994952 0
>  .debug_loc   941 0
>  .debug_abbrev  12754 0
>  .debug_info  2223641 0
>  .debug_ranges  46592 0
>  .debug_line   153901 0
>  .note.gnu.gold-version28 0
>  Total6827932
>
> Size of clang with D71451  and D71599 
>  change and with option  
> "-fstandalone-debug":-
>  ==
> …
>  .comment 159 0
>  .debug_str   3994894 0
>  .debug_loc   941 0
>  .debug_abbrev  12746 0
>  .debug_info  2223617 0
>  .debug_ranges  46592 0
>  .debug_line   153865 0
>  .note.gnu.gold-version28 0
>  Total6827806
>
> Size of clang with D71451  and D71599 
>  is reduced.


Do you have any reason to believe these patches would reduce the size of the 
debug info? It seems like they only add more debug info, and don't remove 
anything - so we'd expect an increase in the size, certainly not a decrease. 
That means, to me, there's probably a mistake in the measurement somehow?

> This results are with latest source and with self-host build of clang. First 
> I have build clang with Release mode and using that clang I have build clang 
> with debug mode with below options
> 
> “cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug 
> -DCMAKE_C_COMPILER=$(which clang) -DCMAKE_CXX_COMPILER=$(which clang++) 
> -DLLVM_TARGETS_TO_BUILD="X86" -DBUILD_SHARED_LIBS=On  
> -DCMAKE_CXX_FLAGS="-fstandalone-debug"   -DCMAKE_C_FLAGS="-fstandalone-debug" 
>  
> -DCMAKE_INSTALL_PREFIX=/home/bft/Jaydeep/latest_llvm/llvm-project/install_withhstandalone
>  ../llvm”




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

https://reviews.llvm.org/D71451



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2020-01-15 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

{icon times-circle color=red} Unit tests: fail. 61892 tests passed, 2 failed 
and 782 were skipped.

  failed: Clang.CXX/temp/temp_arg/temp_arg_template/p3-2a.cpp
  failed: LLVM.CodeGen/SystemZ/mverify-optypes.mir

{icon question-circle color=gray} clang-tidy: unknown.

{icon times-circle color=red} clang-format: fail. Please format your changes 
with clang-format by running `git-clang-format HEAD^` or applying this patch 
.

Build artifacts 
: 
diff.json 
,
 clang-format.patch 
,
 CMakeCache.txt 
,
 console-log.txt 
,
 test-results.xml 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D72742: Don't assume promotable integers are zero/sign-extended already in x86-64 ABI.

2020-01-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added subscribers: rjmccall, chandlerc.
rnk added a comment.

+@chandlerc @rjmccall

Didn't we work this out already when John added the alignment tracking stuff? I 
remember this bug involving libjpegturbo standalone assembly receiving a 32-bit 
argument, and then using the full 64-bit RDI register to read it, but clang 
stopped zero extending it. I thought the ABI doc was ambiguous at the time, and 
we studied GCC's behavior, and that is how we arrived at clang's current 
behavior. I am generally skeptical about changing behavior in this area just 
because the ABI doc says something now. It keeps changing. What did it say in 
the past? Shouldn't we pay more attention to that?

Found the libjpegturbo thing:
https://github.com/libjpeg-turbo/libjpeg-turbo/commit/498d9bc92fcf39124b6f08e57326944dedd2ddd6


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72742



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


[PATCH] D67847: [Support] make report_fatal_error `abort` instead of `exit`

2020-01-15 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

I'm still in favor of this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67847



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


[PATCH] D72334: [Syntax] Build nodes for template declarations.

2020-01-15 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/lib/Tooling/Syntax/BuildTree.cpp:930
+Builder.markChildToken(TemplateKW, syntax::NodeRole::IntroducerKeyword);
+Builder.markMaybeDelayedChild(
+TemplatedDeclaration,

Why is this range maybe-delayed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72334



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


  1   2   >