[PATCH] D98726: [analyzer] Enabling MallocChecker to take up after SmartPtrModelling

2021-04-26 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D98726#2714215 , @RedDocMD wrote:

> I think something is wrong about the way we are investigating this or I don't 
> understand the `MallocChecker`.
> The following doesn't yield a bug report! => https://godbolt.org/z/Y57G7zE5j

Uh-oh, we forgot to enable `cplusplus.NewDeleteLeaks` which is a separate 
checker. https://godbolt.org/z/cfzdTM8vf

In D98726#2714432 , @RedDocMD wrote:

> As you can see here, the bug note is attached in the second case (please 
> refer to my previous comment), but somehow, it doesn't finally show up as a 
> bug.
> Weird.

This means that one of the bug visitors has invoked 
`PathSensitiveBugReport::markInvalid()` to suppress the report. You can break 
at this function to find out more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98726

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


[clang] 4b24341 - [RISCV] Implement the vmmv.m/vmnot.m builtin.

2021-04-26 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-04-26T15:38:31+08:00
New Revision: 4b2434172cc15ccd32c5c9110a3a4df18b8fba5e

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

LOG: [RISCV] Implement the vmmv.m/vmnot.m builtin.

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmmv.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmnot.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c

Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index d56a130aad16..d94ec15159ba 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -844,6 +844,23 @@ multiclass RVVPseudoVNotBuiltin {
   }
 }
 
+multiclass RVVPseudoMaskBuiltin {
+  let Name = NAME,
+  IRName = IR,
+  HasMask = false,
+  ManualCodegen = [{
+  {
+// op1, vl
+IntrinsicTypes = {ResultType,
+  Ops[1]->getType()};
+Ops.insert(Ops.begin() + 1, Ops[0]);
+break;
+  }
+  }] in {
+def : RVVBuiltin<"m", "mm", type_range>;
+  }
+}
+
 // 6. Configuration-Setting Instructions
 // 6.1. vsetvli/vsetvl instructions
 let HasVL = false,
@@ -1300,6 +1317,8 @@ def vmxnor   : RVVMaskBinBuiltin;
 // pseudoinstructions
 def vmclr: RVVMaskNullaryBuiltin;
 def vmset: RVVMaskNullaryBuiltin;
+defm vmmv_m : RVVPseudoMaskBuiltin<"vmand", "c">;
+defm vmnot_m : RVVPseudoMaskBuiltin<"vmnand", "c">;
 
 // 16.2. Vector mask population count vpopc
 def vpopc : RVVMaskOp0Builtin<"um">;

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmmv.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmmv.c
new file mode 100644
index ..ee2b6412d59b
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmmv.c
@@ -0,0 +1,105 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: @test_vmmv_m_b1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv64i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmmv_m_b1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv64i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool1_t test_vmmv_m_b1 (vbool1_t op1, size_t vl) {
+  return vmmv(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmmv_m_b2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv32i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmmv_m_b2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv32i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool2_t test_vmmv_m_b2 (vbool2_t op1, size_t vl) {
+  return vmmv(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmmv_m_b4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv16i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmmv_m_b4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv16i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmmv_m_b4 (vbool4_t op1, size_t vl) {
+  return vmmv(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmmv_m_b8(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv8i1.i32( [[OP1:%.*]],  
[[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmmv_m_b8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv8i1.i64( [[OP1:%.*]],  
[[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool8_t test_vmmv_m_b8 (vbool8_t op1, size_t vl) {
+  return vmmv(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmmv_m_b16(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vmand.nxv4i1.i32( [[OP1:%.*]],  
[[OP1]], i3

[clang] bfb3fca - [RISCV] Implement the vfabs.v/vfneg.v builtin.

2021-04-26 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-04-26T15:38:31+08:00
New Revision: bfb3fca7e110a367c9589495575913d83bea7095

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

LOG: [RISCV] Implement the vfabs.v/vfneg.v builtin.

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

Added: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfneg.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfabs.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vfneg.c

Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index d94ec15159ba..faeda70845cb 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -861,6 +861,33 @@ multiclass RVVPseudoMaskBuiltin {
   }
 }
 
+multiclass RVVPseudoVFUnaryBuiltin {
+  let Name = NAME,
+  IRName = IR,
+  IRNameMask = IR # "_mask",
+  ManualCodegen = [{
+  {
+// op1, vl
+IntrinsicTypes = {ResultType,
+  Ops[0]->getType(), Ops[1]->getType()};
+Ops.insert(Ops.begin() + 1, Ops[0]);
+break;
+  }
+  }],
+  ManualCodegenMask = [{
+  {
+// maskedoff, op1, mask, vl
+IntrinsicTypes = {ResultType,
+  Ops[1]->getType(),
+  Ops[3]->getType()};
+Ops.insert(Ops.begin() + 2, Ops[1]);
+break;
+  }
+  }] in {
+def : RVVBuiltin<"v", "vv", type_range>;
+  }
+}
+
 // 6. Configuration-Setting Instructions
 // 6.1. vsetvli/vsetvl instructions
 let HasVL = false,
@@ -1216,6 +1243,8 @@ defm vfmax : RVVFloatingBinBuiltinSet;
 defm vfsgnj  : RVVFloatingBinBuiltinSet;
 defm vfsgnjn : RVVFloatingBinBuiltinSet;
 defm vfsgnjx : RVVFloatingBinBuiltinSet;
+defm vfneg_v : RVVPseudoVFUnaryBuiltin<"vfsgnjn", "fd">;
+defm vfabs_v : RVVPseudoVFUnaryBuiltin<"vfsgnjx", "fd">;
 
 // 14.13. Vector Floating-Point Compare Instructions
 defm vmfeq : RVVFloatingMaskOutBuiltinSet;

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c
new file mode 100644
index ..9249a25fc590
--- /dev/null
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c
@@ -0,0 +1,261 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d 
-target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: @test_vfabs_v_f32mf2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfsgnjx.nxv1f32.nxv1f32.i32( [[OP1:%.*]], 
 [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfabs_v_f32mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfsgnjx.nxv1f32.nxv1f32.i64( [[OP1:%.*]], 
 [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32mf2_t test_vfabs_v_f32mf2 (vfloat32mf2_t op1, size_t vl) {
+  return vfabs(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfabs_v_f32m1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfsgnjx.nxv2f32.nxv2f32.i32( [[OP1:%.*]], 
 [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfabs_v_f32m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfsgnjx.nxv2f32.nxv2f32.i64( [[OP1:%.*]], 
 [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32m1_t test_vfabs_v_f32m1 (vfloat32m1_t op1, size_t vl) {
+  return vfabs(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfabs_v_f32m2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfsgnjx.nxv4f32.nxv4f32.i32( [[OP1:%.*]], 
 [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfabs_v_f32m2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  
@llvm.riscv.vfsgnjx.nxv4f32.nxv4f32.i64( [[OP1:%.*]], 
 [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32m2_t test_vfabs_v_f32m2 (vfloat32m2_t op1, size_t vl) {
+  return vfabs(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfabs_v_f32m4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV3

[PATCH] D100821: [RISCV] Implement the vmmv.m/vmnot.m builtin.

2021-04-26 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b2434172cc1: [RISCV] Implement the vmmv.m/vmnot.m builtin. 
(authored by HsiangKai).

Changed prior to commit:
  https://reviews.llvm.org/D100821?vs=339875&id=340442#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100821

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmnot.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
@@ -0,0 +1,107 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v -target-feature +m -Werror -Wall -S -o - %s >/dev/null 2>%t
+// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
+
+// ASM-NOT: warning
+#include 
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv64i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv64i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool1_t test_vmnot_m_b1 (vbool1_t op1, size_t vl) {
+  return vmnot_m_b1(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv32i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv32i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool2_t test_vmnot_m_b2 (vbool2_t op1, size_t vl) {
+  return vmnot_m_b2(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv16i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv16i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool4_t test_vmnot_m_b4 (vbool4_t op1, size_t vl) {
+  return vmnot_m_b4(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b8(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv8i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv8i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool8_t test_vmnot_m_b8 (vbool8_t op1, size_t vl) {
+  return vmnot_m_b8(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b16(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv4i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b16(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv4i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool16_t test_vmnot_m_b16 (vbool16_t op1, size_t vl) {
+  return vmnot_m_b16(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b32(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv2i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vmnot_m_b32(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv2i1.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vbool32_t test_vmnot_m_b32 (vbool32_t op1, size_t vl) {
+  return vmnot_m_b32(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vmnot_m_b64(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmnand.nxv1i1.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:re

[PATCH] D100822: [RISCV] Implement the vfabs.v/vfneg.v builtin.

2021-04-26 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbfb3fca7e110: [RISCV] Implement the vfabs.v/vfneg.v builtin. 
(authored by HsiangKai).

Changed prior to commit:
  https://reviews.llvm.org/D100822?vs=338735&id=340443#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100822

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfabs.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vfneg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfabs.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vfneg.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vfneg.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vfneg.c
@@ -0,0 +1,261 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv32 -target-feature +f -target-feature +d -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
+// RUN: %clang_cc1 -triple riscv64 -target-feature +f -target-feature +d -target-feature +experimental-v \
+// RUN:   -disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV32-LABEL: @test_vfneg_v_f32mf2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv1f32.nxv1f32.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfneg_v_f32mf2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv1f32.nxv1f32.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32mf2_t test_vfneg_v_f32mf2 (vfloat32mf2_t op1, size_t vl) {
+  return vfneg_v_f32mf2(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfneg_v_f32m1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv2f32.nxv2f32.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfneg_v_f32m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv2f32.nxv2f32.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32m1_t test_vfneg_v_f32m1 (vfloat32m1_t op1, size_t vl) {
+  return vfneg_v_f32m1(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfneg_v_f32m2(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv4f32.nxv4f32.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfneg_v_f32m2(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv4f32.nxv4f32.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32m2_t test_vfneg_v_f32m2 (vfloat32m2_t op1, size_t vl) {
+  return vfneg_v_f32m2(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfneg_v_f32m4(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv8f32.nxv8f32.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfneg_v_f32m4(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv8f32.nxv8f32.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32m4_t test_vfneg_v_f32m4 (vfloat32m4_t op1, size_t vl) {
+  return vfneg_v_f32m4(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfneg_v_f32m8(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv16f32.nxv16f32.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfneg_v_f32m8(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv16f32.nxv16f32.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat32m8_t test_vfneg_v_f32m8 (vfloat32m8_t op1, size_t vl) {
+  return vfneg_v_f32m8(op1, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vfneg_v_f64m1(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv1f64.nxv1f64.i32( [[OP1:%.*]],  [[OP1]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:ret  [[TMP0]]
+//
+// CHECK-RV64-LABEL: @test_vfneg_v_f64m1(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vfsgnjn.nxv1f64.nxv1f64.i64( [[OP1:%.*]],  [[OP1]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:ret  [[TMP0]]
+//
+vfloat64m1_t test_vfneg_v_f64m1 (vfloat64m1_t op1, size_t vl) {
+  return vfneg_v_f64m1(op1

[PATCH] D100823: [RISCV] Implement the pseudo compare builtin.

2021-04-26 Thread Hsiangkai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG645c5f27a84d: [RISCV] Implement the pseudo compare builtin. 
(authored by HsiangKai).

Changed prior to commit:
  https://reviews.llvm.org/D100823?vs=339879&id=340444#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100823

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vmsgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmfgt.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsge.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vmsgt.c

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


[PATCH] D101275: [clangd] Hide inlay hints capability behind a command-line flag

2021-04-26 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1482
   Bind.method("textDocument/semanticTokens/full/delta", this, 
&ClangdLSPServer::onSemanticTokensDelta);
-  Bind.method("clangd/inlayHints", this, &ClangdLSPServer::onInlayHints);
+  if (Opts.InlayHints)
+Bind.method("clangd/inlayHints", this, &ClangdLSPServer::onInlayHints);

I think we only need to suppress the capability, not the method itself, right?

(This is what we usually do, folding-ranges is different... it's seriously 
crashy and even then probably should bind regardless)



Comment at: clang-tools-extra/clangd/ClangdServer.h:167
+/// Enable preview of InlayHints feature.
+bool InlayHints = false;
+

I think this should go in ClangdLSPServer::Options, again i'm not sure why 
FoldingRanges does what it does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101275

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


[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-26 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

Thanks for tracking it down, and sorry for the delay.

I thought the crash was fix in https://reviews.llvm.org/D99145. Thinking more 
about it, this is a recovery-expr crash, see my comment below.




Comment at: clang/lib/Sema/SemaChecking.cpp:4543
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  auto CheckTypeOK = [](QualType Ty) {
+if (Ty->isIncompleteType() || Ty->isUndeducedType())

The current fix is on top of kadir's fix, now the code becomes more add-hoc, it 
looks like a smell to me.


It looks like `CheckArgAlignment` has an implicit invariant (the arg type 
should never be undeduced), and this invariant was enforced by dropping the 
invalid AST. Now with `RecoveryExpr`, we might break the invariant -- when the 
RecoveryExpr preserves an `undeduced` type, like the test case in this patch 
(which is done via the 
[code](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1420)).


I think a right fix is to fix in the `RecoveryExpr` side, `RecoveryExpr` should 
not preserve an undeduced type, we did it for function return type already 
(https://reviews.llvm.org/D87350), but it didn't cover all places. I think a 
general fixing place is `Sema::CreateRecoveryExpr`, if the passing `T` is 
undeduced, fallback to dependent type.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

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


[PATCH] D83660: [analyzer] Fix a crash for dereferencing an empty llvm::Optional variable in SMTConstraintManager.h.

2021-04-26 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D83660#2715097 , @OikawaKirie wrote:

> In D83660#2675064 , @mikhail.ramalho 
> wrote:
>
>> Indeed it looks like a copy & paste error, I'm surprised no one found it 
>> earlier.
>>
>> Regarding the tests, we used to have `make check-clang-analysis-z3` (or 
>> something similar) that would run only the analyzer's tests, but using Z3 as 
>> the constraint solver. It looks like this change broke it: 
>> https://reviews.llvm.org/D62445

It might worth investigating this build 'target'.

> Should the execution requirements be changed to make it run if z3 is enabled? 
> Or just keep it as it is now?

We should keep current behavior IMO.

> If there are no other suggestions for this patch, I'd like to see it landed 
> ASAP. I think it is a far too long period for a fix of a copy & paste error.

I investigated if we could mock the whole Z3 shared object.
Turns out, 33 Z3 functions should be mocked if we chose to mock every used 
function of libZ3.
Z3_dec_ref, Z3_del_config, Z3_del_context, Z3_get_app_decl, Z3_get_ast_id, 
Z3_get_bv_sort_size, Z3_get_numeral_string, Z3_get_sort_kind, Z3_inc_ref, 
Z3_is_eq_sort, Z3_mk_bv_sort, Z3_mk_config, Z3_mk_const, Z3_mk_context_rc, 
Z3_mk_eq, Z3_mk_int64, Z3_mk_not, Z3_mk_simple_solver, Z3_mk_string_symbol, 
Z3_mk_unsigned_int64, Z3_model_dec_ref, Z3_model_get_const_interp, 
Z3_model_has_interp, Z3_model_inc_ref, Z3_set_error_handler, 
Z3_set_param_value, Z3_solver_assert, Z3_solver_check, Z3_solver_dec_ref, 
Z3_solver_get_model, Z3_solver_inc_ref, Z3_solver_reset, Z3_to_app

I think we should mock only the `Z3_solver_check` function as done in this 
current patch. I don't see any immediate 'easier' and 'robust way of testing 
this.
**I'm gonna land this at the end of the week if no objections are made.**

PS: Even if this lands, Z3 solver will crash all over the place :D This was the 
reason why I did not want to 'push' this fix so hard.


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

https://reviews.llvm.org/D83660

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


[clang] 18772de - [OpenCL] Add inc/dec/cmpxchg C++ legacy atomics with generic

2021-04-26 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2021-04-26T09:46:11+01:00
New Revision: 18772de1ecb1a23b483e29987ae708ab641b1134

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

LOG: [OpenCL] Add inc/dec/cmpxchg C++ legacy atomics with generic

Mirror the remaining C++ for OpenCL specific builtins from opencl-c.h
to the TableGen builtin functions.

Fixes PR50041 (part 2).

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index eb8034ee630c..efb540cd1967 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -1088,6 +1088,12 @@ let Extension = FuncExtOpenCLCxx in {
 "atomic_or", "atomic_xor"] in {
   def : Builtin, GenericAS>, 
Type]>;
 }
+foreach name = ["atomic_inc", "atomic_dec"] in {
+  def : Builtin, GenericAS>]>;
+}
+foreach name = ["atomic_cmpxchg"] in {
+  def : Builtin, GenericAS>, 
Type, Type]>;
+}
   }
 }
 



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


[PATCH] D101051: [clang][deps] Only generate absolute paths when asked to

2021-04-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 340449.
jansvoboda11 retitled this revision from "[clang][deps] Only generate 
modules-related paths when asked to" to "[clang][deps] Only generate absolute 
paths when asked to".
jansvoboda11 edited the summary of this revision.
jansvoboda11 added a comment.

Undo typo fix


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101051

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-full.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -138,6 +138,31 @@
 llvm::cl::init(ScanningOutputFormat::Make),
 llvm::cl::cat(DependencyScannerCategory));
 
+// This mode is mostly useful for development of explicitly built modules.
+// Command lines will contain arguments specifying modulemap file paths and
+// absolute paths to PCM files in the module cache directory.
+//
+// Build tools that want to put the PCM files in a different location should use
+// the C++ APIs instead, of which there are two flavors:
+//
+// 1. APIs that generate arguments with paths to modulemap and PCM files via
+//callbacks provided by the client:
+// * ModuleDeps::getCanonicalCommandLine(LookupPCMPath, LookupModuleDeps)
+// * FullDependencies::getAdditionalArgs(LookupPCMPath, LookupModuleDeps)
+//
+// 2. APIs that don't generate arguments with paths to modulemap or PCM files
+//and instead expect the client to append them manually after the fact:
+// * ModuleDeps::getCanonicalCommandLineWithoutModulePaths()
+// * FullDependencies::getAdditionalArgsWithoutModulePaths()
+//
+static llvm::cl::opt GenerateModulesPathArgs(
+"generate-modules-path-args",
+llvm::cl::desc(
+"With '-format experimental-full', include arguments specifying "
+"modules-related paths in the generated command lines: "
+"'-fmodule-file=', '-o', '-fmodule-map-file='."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -260,11 +285,14 @@
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
-[&](ModuleID MID) { return lookupPCMPath(MID); },
-[&](ModuleID MID) -> const ModuleDeps & {
-  return lookupModuleDeps(MID);
-});
+ID.AdditonalCommandLine =
+GenerateModulesPathArgs
+? FD.getAdditionalArgs(
+  [&](ModuleID MID) { return lookupPCMPath(MID); },
+  [&](ModuleID MID) -> const ModuleDeps & {
+return lookupModuleDeps(MID);
+  })
+: FD.getAdditionalArgsWithoutModulePaths();
 
 Inputs.push_back(std::move(ID));
   }
@@ -295,11 +323,14 @@
   {"file-deps", toJSONSorted(MD.FileDeps)},
   {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)},
   {"clang-modulemap-file", MD.ClangModuleMapFile},
-  {"command-line", MD.getFullCommandLine(
-   [&](ModuleID MID) { return lookupPCMPath(MID); },
-   [&](ModuleID MID) -> const ModuleDeps & {
- return lookupModuleDeps(MID);
-   })},
+  {"command-line",
+   GenerateModulesPathArgs
+   ? MD.getCanonicalCommandLine(
+ [&](ModuleID MID) { return lookupPCMPath(MID); },
+ [&](ModuleID MID) -> const ModuleDeps & {
+   return lookupModuleDeps(MID);
+ })
+   : MD.getCanonicalCommandLineWithoutModulePaths()},
   };
   OutModules.push_back(std::move(O));
 }
Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -13,12 +13,17 @@
 // RUN: echo %t.dir > %t.result
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
 // RUN:   -mode preprocess-minimized-sources >> %t.result
-// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
-
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK,CHECK-NO-ABS %s
+//
+// RUN: echo %t.dir > %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format expe

[clang] 0f7d410 - [clang][deps] Only generate absolute paths when asked to

2021-04-26 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-26T10:53:41+02:00
New Revision: 0f7d4105c60b5b4ee80fd32225658a4d8261c120

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

LOG: [clang][deps] Only generate absolute paths when asked to

Add option to `clang-scan-deps` to enable/disable generation of command-line 
arguments with absolute paths. This is essentially a revert of D100533, but 
with improved naming and added test.

Reviewed By: dexonsmith

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

Added: 


Modified: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
clang/test/ClangScanDeps/modules-full.cpp
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h 
b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
index 33e155f4b4ae..89a70fb723c4 100644
--- a/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
+++ b/clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
@@ -41,16 +41,22 @@ struct FullDependencies {
   /// Get additional arguments suitable for appending to the original Clang
   /// command line.
   ///
-  /// \param LookupPCMPath This function is called to fill in `-fmodule-file=`
-  ///  flags and for the `-o` flag. It needs to return a
-  ///  path for where the PCM for the given module is to
+  /// \param LookupPCMPath This function is called to fill in "-fmodule-file="
+  ///  arguments and the "-o" argument. It needs to return
+  ///  a path for where the PCM for the given module is to
   ///  be located.
   /// \param LookupModuleDeps This function is called to collect the full
   /// transitive set of dependencies for this
-  /// compilation.
-  std::vector getAdditionalCommandLine(
+  /// compilation and fill in "-fmodule-map-file="
+  /// arguments.
+  std::vector getAdditionalArgs(
   std::function LookupPCMPath,
   std::function LookupModuleDeps) const;
+
+  /// Get additional arguments suitable for appending to the original Clang
+  /// command line, excluding arguments containing modules-related paths:
+  /// "-fmodule-file=", "-fmodule-map-file=".
+  std::vector getAdditionalArgsWithoutModulePaths() const;
 };
 
 struct FullDependenciesResult {

diff  --git 
a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h 
b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
index 5e90fb2f7b09..95876bb665f1 100644
--- a/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
+++ b/clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
@@ -79,18 +79,24 @@ struct ModuleDeps {
   /// this module.
   std::shared_ptr Invocation;
 
-  /// Gets the full command line suitable for passing to clang.
+  /// Gets the canonical command line suitable for passing to clang.
   ///
-  /// \param LookupPCMPath This function is called to fill in `-fmodule-file=`
-  ///  flags and for the `-o` flag. It needs to return a
-  ///  path for where the PCM for the given module is to
+  /// \param LookupPCMPath This function is called to fill in "-fmodule-file="
+  ///  arguments and the "-o" argument. It needs to return
+  ///  a path for where the PCM for the given module is to
   ///  be located.
   /// \param LookupModuleDeps This function is called to collect the full
   /// transitive set of dependencies for this
-  /// compilation.
-  std::vector getFullCommandLine(
+  /// compilation and fill in "-fmodule-map-file="
+  /// arguments.
+  std::vector getCanonicalCommandLine(
   std::function LookupPCMPath,
   std::function LookupModuleDeps) const;
+
+  /// Gets the canonical command line suitable for passing to clang, excluding
+  /// arguments containing modules-related paths: "-fmodule-file=", "-o",
+  /// "-fmodule-map-file=".
+  std::vector getCanonicalCommandLineWithoutModulePaths() const;
 };
 
 namespace detail {

diff  --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp 
b/clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
index a59ab688b10b..35817d3f7ae9 100644
--- a/clang/lib/Tooling/DependencyScanning/Depende

[PATCH] D101051: [clang][deps] Only generate absolute paths when asked to

2021-04-26 Thread Jan Svoboda via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f7d4105c60b: [clang][deps] Only generate absolute paths 
when asked to (authored by jansvoboda11).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101051

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/include/clang/Tooling/DependencyScanning/ModuleDepCollector.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  clang/test/ClangScanDeps/modules-full.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -138,6 +138,31 @@
 llvm::cl::init(ScanningOutputFormat::Make),
 llvm::cl::cat(DependencyScannerCategory));
 
+// This mode is mostly useful for development of explicitly built modules.
+// Command lines will contain arguments specifying modulemap file paths and
+// absolute paths to PCM files in the module cache directory.
+//
+// Build tools that want to put the PCM files in a different location should use
+// the C++ APIs instead, of which there are two flavors:
+//
+// 1. APIs that generate arguments with paths to modulemap and PCM files via
+//callbacks provided by the client:
+// * ModuleDeps::getCanonicalCommandLine(LookupPCMPath, LookupModuleDeps)
+// * FullDependencies::getAdditionalArgs(LookupPCMPath, LookupModuleDeps)
+//
+// 2. APIs that don't generate arguments with paths to modulemap or PCM files
+//and instead expect the client to append them manually after the fact:
+// * ModuleDeps::getCanonicalCommandLineWithoutModulePaths()
+// * FullDependencies::getAdditionalArgsWithoutModulePaths()
+//
+static llvm::cl::opt GenerateModulesPathArgs(
+"generate-modules-path-args",
+llvm::cl::desc(
+"With '-format experimental-full', include arguments specifying "
+"modules-related paths in the generated command lines: "
+"'-fmodule-file=', '-o', '-fmodule-map-file='."),
+llvm::cl::init(false), llvm::cl::cat(DependencyScannerCategory));
+
 llvm::cl::opt
 NumThreads("j", llvm::cl::Optional,
llvm::cl::desc("Number of worker threads to use (default: use "
@@ -260,11 +285,14 @@
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-ID.AdditonalCommandLine = FD.getAdditionalCommandLine(
-[&](ModuleID MID) { return lookupPCMPath(MID); },
-[&](ModuleID MID) -> const ModuleDeps & {
-  return lookupModuleDeps(MID);
-});
+ID.AdditonalCommandLine =
+GenerateModulesPathArgs
+? FD.getAdditionalArgs(
+  [&](ModuleID MID) { return lookupPCMPath(MID); },
+  [&](ModuleID MID) -> const ModuleDeps & {
+return lookupModuleDeps(MID);
+  })
+: FD.getAdditionalArgsWithoutModulePaths();
 
 Inputs.push_back(std::move(ID));
   }
@@ -295,11 +323,14 @@
   {"file-deps", toJSONSorted(MD.FileDeps)},
   {"clang-module-deps", toJSONSorted(MD.ClangModuleDeps)},
   {"clang-modulemap-file", MD.ClangModuleMapFile},
-  {"command-line", MD.getFullCommandLine(
-   [&](ModuleID MID) { return lookupPCMPath(MID); },
-   [&](ModuleID MID) -> const ModuleDeps & {
- return lookupModuleDeps(MID);
-   })},
+  {"command-line",
+   GenerateModulesPathArgs
+   ? MD.getCanonicalCommandLine(
+ [&](ModuleID MID) { return lookupPCMPath(MID); },
+ [&](ModuleID MID) -> const ModuleDeps & {
+   return lookupModuleDeps(MID);
+ })
+   : MD.getCanonicalCommandLineWithoutModulePaths()},
   };
   OutModules.push_back(std::move(O));
 }
Index: clang/test/ClangScanDeps/modules-full.cpp
===
--- clang/test/ClangScanDeps/modules-full.cpp
+++ clang/test/ClangScanDeps/modules-full.cpp
@@ -13,12 +13,17 @@
 // RUN: echo %t.dir > %t.result
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
 // RUN:   -mode preprocess-minimized-sources >> %t.result
-// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
-
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK,CHECK-NO-ABS %s
+//
+// RUN: echo %t.dir > %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -format experimental-full \
+// RUN:   -generate-modules-path-args -mode preproces

[clang] 9ab4eab - [clang][deps] NFC: Fix typo

2021-04-26 Thread Jan Svoboda via cfe-commits

Author: Jan Svoboda
Date: 2021-04-26T10:55:24+02:00
New Revision: 9ab4eab570f7d11c375993d59b1a7ec2c32a72fc

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

LOG: [clang][deps] NFC: Fix typo

Added: 


Modified: 
clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 




diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp 
b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index a3844e569ccc..32a6cee15079 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -285,7 +285,7 @@ class FullDeps {
   Modules.insert(I, {{MD.ID, InputIndex}, std::move(MD)});
 }
 
-ID.AdditonalCommandLine =
+ID.AdditionalCommandLine =
 GenerateModulesPathArgs
 ? FD.getAdditionalArgs(
   [&](ModuleID MID) { return lookupPCMPath(MID); },
@@ -342,7 +342,7 @@ class FullDeps {
   {"clang-context-hash", I.ContextHash},
   {"file-deps", I.FileDeps},
   {"clang-module-deps", toJSONSorted(I.ModuleDeps)},
-  {"command-line", I.AdditonalCommandLine},
+  {"command-line", I.AdditionalCommandLine},
   };
   TUs.push_back(std::move(O));
 }
@@ -389,7 +389,7 @@ class FullDeps {
 std::string ContextHash;
 std::vector FileDeps;
 std::vector ModuleDeps;
-std::vector AdditonalCommandLine;
+std::vector AdditionalCommandLine;
   };
 
   std::mutex Lock;



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


[clang] 16dc9af - [RISCV] Add REQUIRES: riscv-registered-target for RISC-V test cases.

2021-04-26 Thread Hsiangkai Wang via cfe-commits

Author: Hsiangkai Wang
Date: 2021-04-26T17:02:27+08:00
New Revision: 16dc9afa097d2577eff640f0fe9d388960c62cb9

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

LOG: [RISCV] Add REQUIRES: riscv-registered-target for RISC-V test cases.

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
index adb3a142447f..f89dc879f755 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vmmv.c
@@ -1,10 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v 
-target-feature +m -Werror -Wall -S -o - %s >/dev/null 2>%t
-// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
 
-// ASM-NOT: warning
 #include 
 
 // CHECK-RV32-LABEL: @test_vmmv_m_b1(

diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
index a79d7dce4bbd..bc179d01d850 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics/vmnot.c
@@ -1,10 +1,8 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +experimental-v 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
-// RUN: %clang_cc1 -triple riscv64 -target-feature +experimental-v 
-target-feature +m -Werror -Wall -S -o - %s >/dev/null 2>%t
-// RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
 
-// ASM-NOT: warning
 #include 
 
 // CHECK-RV32-LABEL: @test_vmnot_m_b1(



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


[clang] 5987d7c - [clang-format] fix indent in alignChainedConditionals

2021-04-26 Thread Krasimir Georgiev via cfe-commits

Author: Krasimir Georgiev
Date: 2021-04-26T11:06:29+02:00
New Revision: 5987d7c59da5a7611036c2952f5a1f501d17ad48

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

LOG: [clang-format] fix indent in alignChainedConditionals

Clang-format was indenting the lines following the `?` in the added test
case by +5 instead of +4. This only happens in a very specific
situation, where the `?` is followed by a multiline block comment, as in
the example. This fix addresses this without regressing any of the
existing tests.

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 6016f8d131c7..e78c5c4df586 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -778,12 +778,11 @@ void WhitespaceManager::alignChainedConditionals() {
 Changes, /*StartAt=*/0);
   } else {
 static auto AlignWrappedOperand = [](Change const &C) {
-  auto Previous = C.Tok->getPreviousNonComment(); // Previous;
+  FormatToken *Previous = C.Tok->getPreviousNonComment();
   return C.NewlinesBefore && Previous && Previous->is(TT_ConditionalExpr) 
&&
- (Previous->is(tok::question) ||
-  (Previous->is(tok::colon) &&
-   (C.Tok->FakeLParens.size() == 0 ||
-C.Tok->FakeLParens.back() != prec::Conditional)));
+ (Previous->is(tok::colon) &&
+  (C.Tok->FakeLParens.size() == 0 ||
+   C.Tok->FakeLParens.back() != prec::Conditional));
 };
 // Ensure we keep alignment of wrapped operands with non-wrapped operands
 // Since we actually align the operators, the wrapped operands need the

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 5ae67d91323d..734ffed088a1 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -6459,6 +6459,30 @@ TEST_F(FormatTest, BreaksConditionalExpressions) {
"? cc :\n"
"  d;\n",
Style);
+
+  EXPECT_EQ(
+  "MMM = A ?\n"
+  "/*\n"
+  " */\n"
+  "function() {\n"
+  "  try {\n"
+  "return JJ(\n"
+  "pp);\n"
+  "  }\n"
+  "} :\n"
+  "function() {};",
+  format(
+  "MMM = A ?\n"
+  " /*\n"
+  "  */\n"
+  " function() {\n"
+  "  try {\n"
+  "return JJ(\n"
+  "pp);\n"
+  "  }\n"
+  "} :\n"
+  "function() {};",
+  getGoogleStyle(FormatStyle::LK_JavaScript)));
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {



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


[PATCH] D101033: [clang-format] fix indent in alignChainedConditionals

2021-04-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5987d7c59da5: [clang-format] fix indent in 
alignChainedConditionals (authored by krasimir).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101033

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6459,6 +6459,30 @@
"? cc :\n"
"  d;\n",
Style);
+
+  EXPECT_EQ(
+  "MMM = A ?\n"
+  "/*\n"
+  " */\n"
+  "function() {\n"
+  "  try {\n"
+  "return JJ(\n"
+  "pp);\n"
+  "  }\n"
+  "} :\n"
+  "function() {};",
+  format(
+  "MMM = A ?\n"
+  " /*\n"
+  "  */\n"
+  " function() {\n"
+  "  try {\n"
+  "return JJ(\n"
+  "pp);\n"
+  "  }\n"
+  "} :\n"
+  "function() {};",
+  getGoogleStyle(FormatStyle::LK_JavaScript)));
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -778,12 +778,11 @@
 Changes, /*StartAt=*/0);
   } else {
 static auto AlignWrappedOperand = [](Change const &C) {
-  auto Previous = C.Tok->getPreviousNonComment(); // Previous;
+  FormatToken *Previous = C.Tok->getPreviousNonComment();
   return C.NewlinesBefore && Previous && Previous->is(TT_ConditionalExpr) 
&&
- (Previous->is(tok::question) ||
-  (Previous->is(tok::colon) &&
-   (C.Tok->FakeLParens.size() == 0 ||
-C.Tok->FakeLParens.back() != prec::Conditional)));
+ (Previous->is(tok::colon) &&
+  (C.Tok->FakeLParens.size() == 0 ||
+   C.Tok->FakeLParens.back() != prec::Conditional));
 };
 // Ensure we keep alignment of wrapped operands with non-wrapped operands
 // Since we actually align the operators, the wrapped operands need the


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6459,6 +6459,30 @@
"? cc :\n"
"  d;\n",
Style);
+
+  EXPECT_EQ(
+  "MMM = A ?\n"
+  "/*\n"
+  " */\n"
+  "function() {\n"
+  "  try {\n"
+  "return JJ(\n"
+  "pp);\n"
+  "  }\n"
+  "} :\n"
+  "function() {};",
+  format(
+  "MMM = A ?\n"
+  " /*\n"
+  "  */\n"
+  " function() {\n"
+  "  try {\n"
+  "return JJ(\n"
+  "pp);\n"
+  "  }\n"
+  "} :\n"
+  "function() {};",
+  getGoogleStyle(FormatStyle::LK_JavaScript)));
 }
 
 TEST_F(FormatTest, BreaksConditionalExpressionsAfterOperator) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -778,12 +778,11 @@
 Changes, /*StartAt=*/0);
   } else {
 static auto AlignWrappedOperand = [](Change const &C) {
-  auto Previous = C.Tok->getPreviousNonComment(); // Previous;
+  FormatToken *Previous = C.Tok->getPreviousNonComment();
   return C.NewlinesBefore && Previous && Previous->is(TT_ConditionalExpr) &&
- (Previous->is(tok::question) ||
-  (Previous->is(tok::colon) &&
-   (C.Tok->FakeLParens.size() == 0 ||
-C.Tok->FakeLParens.back() != prec::Conditional)));
+ (Previous->is(tok::colon) &&
+  (C.Tok->FakeLParens.size() == 0 ||
+   C.Tok->FakeLParens.back() != prec::Conditional));
 };
 // Ensure we keep alignment of wrapped operands with non-wrapped operands
 // Since we actually align the operators, the wrapped operands need the
___

[clang] 3c9bcf0 - [Clang][Coroutine][DebugInfo] Relax test ordering requirement

2021-04-26 Thread Jeremy Morse via cfe-commits

Author: Jeremy Morse
Date: 2021-04-26T10:07:22+01:00
New Revision: 3c9bcf0e3549d89b31e19e67a5a16babdee2c72d

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

LOG: [Clang][Coroutine][DebugInfo] Relax test ordering requirement

The test added in D97533 (and modified by this patch) has some overly
strict printed metadata ordering requirements, specifically the
interleaving of DILocalVariable nodes and DILocation nodes. Slight changes
in metadata emission can easily break this unfortunately.

This patch stops after clang codegen rather than allowing the coro splitter
to run,  and reduces the need for ordering: it picks out the
DILocalVariable nodes being sought, in any order (CHECK-DAG), and doesn't
examine any DILocations. The implicit CHECK-NOT is what's important: the
test seeks to ensure a duplicate set of DILocalVariables aren't emitted in
the same scope.

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

Added: 


Modified: 
clang/test/CodeGenCoroutines/coro-dwarf.cpp

Removed: 




diff  --git a/clang/test/CodeGenCoroutines/coro-dwarf.cpp 
b/clang/test/CodeGenCoroutines/coro-dwarf.cpp
index eacbd5b39d2a..391d37d23c0d 100644
--- a/clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ b/clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -std=c++2a -fcoroutines-ts -triple=x86_64 -dwarf-version=4 
-debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:-triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
+// RUN:-emit-llvm -o - %s | \
+// RUN:FileCheck %s --implicit-check-not=DILocalVariable
 
 namespace std::experimental {
 template  struct coroutine_traits;
@@ -63,15 +66,7 @@ void f_coro(int val, MoveOnly moParam, MoveAndCopy mcParam) {
 }
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: 
"_Z6f_coroi8MoveOnly11MoveAndCopy"
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], 
file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], 
file: !8, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "__promise",



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


[PATCH] D100298: [Clang][Coroutine][DebugInfo] Follow-up: reduce a tests ordering requirements

2021-04-26 Thread Jeremy Morse via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3c9bcf0e3549: [Clang][Coroutine][DebugInfo] Relax test 
ordering requirement (authored by jmorse).

Changed prior to commit:
  https://reviews.llvm.org/D100298?vs=337793&id=340455#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100298

Files:
  clang/test/CodeGenCoroutines/coro-dwarf.cpp


Index: clang/test/CodeGenCoroutines/coro-dwarf.cpp
===
--- clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -std=c++2a -fcoroutines-ts -triple=x86_64 -dwarf-version=4 
-debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:-triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
+// RUN:-emit-llvm -o - %s | \
+// RUN:FileCheck %s --implicit-check-not=DILocalVariable
 
 namespace std::experimental {
 template  struct coroutine_traits;
@@ -63,15 +66,7 @@
 }
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: 
"_Z6f_coroi8MoveOnly11MoveAndCopy"
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], 
file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], 
type: !{{[0-9]+}}, flags: DIFlagArtificial)
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], 
file: !8, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: 
![[SP]], file: !8, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: 
![[SP]], file: !8, line: {{[0-9]+}}, type: !{{[0-9]+}})
+// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "__promise",


Index: clang/test/CodeGenCoroutines/coro-dwarf.cpp
===
--- clang/test/CodeGenCoroutines/coro-dwarf.cpp
+++ clang/test/CodeGenCoroutines/coro-dwarf.cpp
@@ -1,4 +1,7 @@
-// RUN: %clang_cc1 -std=c++2a -fcoroutines-ts -triple=x86_64 -dwarf-version=4 -debug-info-kind=limited -emit-llvm -o - %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-optzns -std=c++2a -fcoroutines-ts \
+// RUN:-triple=x86_64 -dwarf-version=4 -debug-info-kind=limited \
+// RUN:-emit-llvm -o - %s | \
+// RUN:FileCheck %s --implicit-check-not=DILocalVariable
 
 namespace std::experimental {
 template  struct coroutine_traits;
@@ -63,15 +66,7 @@
 }
 
 // CHECK: ![[SP:[0-9]+]] = distinct !DISubprogram(name: "f_coro", linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy"
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "val", arg: 1, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 17, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "moParam", arg: 2, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 31, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: ![[SP]], file: !8, line: 60, type: !{{[0-9]+}})
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 52, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 61, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 60, column: 6, scope: ![[SP]])
-// CHECK: !{{[0-9]+}} = !DILocation(line: 0, scope: ![[SP]])
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "val", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT: !{{[0-9]+}} = !DILocalVariable(name: "moParam", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
-// CHECK-NOT:: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", scope: ![[SP]], type: !{{[0-9]+}}, flags: DIFlagArtificial)
+// 

[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-04-26 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko updated this revision to Diff 340456.

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

https://reviews.llvm.org/D91949

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -5069,6 +5069,78 @@
 format(Input, Style));
 }
 
+TEST_F(FormatTest, BreakBeforeStructInitialization) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 80;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeStructInitialization = true;
+  Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_No;
+  verifyFormat("struct new_struct struct_name =\n"
+   "{a = 1};",
+   Style);
+  verifyFormat("struct new_struct struct_name =\n"
+   "{a = 1, b = 2};",
+   Style);
+  verifyFormat("struct new_struct struct_name =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("typedef struct Foo =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("static constexpr struct Foo =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("template <> struct Foo =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("struct =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  Style.BraceWrapping.BeforeStructInitialization = false;
+  verifyFormat("struct new_struct struct_name = {a = 1};", Style);
+  verifyFormat("struct new_struct struct_name = {a = 1, b = 2};", Style);
+  verifyFormat("struct new_struct struct_name = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("typedef struct Foo = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("static constexpr struct Foo = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("template <> struct Foo = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  verifyFormat("struct = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
@@ -16328,6 +16400,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeStructInitialization);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -2702,7 +2702,12 @@
   nextToken();
 }
   }
-  if (FormatTok->Tok.is(tok::l_brace)) {
+  if (FormatTok->Tok.is(tok::equal)) {
+nextToken();
+if (Style.BraceWrapping.BeforeStructInitialization) {
+  addUnwrappedLine();
+}
+  } else if (FormatTok->Tok.is(tok::l_brace)) {
 if (ParseAsExpr) {
   parseChildBlock();
 } else {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -720,6 +720,8 @@
 IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
 IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
 IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
+IO.mapOptional("BeforeStructInitialization",
+   Wrapping.BeforeStructInitialization);
 IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
 IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
 IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
@@ -831,6 +833,7 @@
 /*BeforeCatch=*/false,
 /*BeforeElse=*/false,
 /*BeforeLambdaBody=*/fals

[PATCH] D100934: [clang][modules] Build inferred modules

2021-04-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 340461.
jansvoboda11 added a comment.

Rebase on top of D101051 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/module-deps-to-rsp.py
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m

Index: clang/test/ClangScanDeps/modules-inferred.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred.m
@@ -0,0 +1,61 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%S/Inputs/frameworks|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: echo -%t.dir > %t.result
+// RUN: echo -%S >> %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -generate-modules-path-args -mode preprocess-minimized-sources >> %t.result
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
+
+#include 
+
+inferred a = 0;
+
+// CHECK: -[[PREFIX:.*]]
+// CHECK-NEXT: -[[SOURCEDIR:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
+// CHECK:  "-emit-module",
+// CHECK:  "-fmodule-name=Inferred",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1:[A-Z0-9]+]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Headers/Inferred.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "module-name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fno-implicit-modules",
+// CHECK-NEXT: "-fno-implicit-module-maps",
+// CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/Inferred-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT: "-fmodule-map-file=[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/modules-inferred-explicit-build.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred-explicit-build.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%/S/Inputs/frameworks|g" -e "s|-E|-x objective-c -E|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources > %t.db
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp
+// RUN: %clang @%t.infer

[PATCH] D100778: [clang-format] Prevent extraneous space insertion in bitshift operators

2021-04-26 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:125
+ 
CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+ -1)))
   return false;

penagos wrote:
> krasimir wrote:
> > penagos wrote:
> > > MyDeveloperDay wrote:
> > > > I don't really understand what we are saying here? 
> > > Effectively we are checking that, barring intervening whitespace, we are 
> > > analyzing 2 consecutive '>' tokens. If so, we treat such sequence as a 
> > > binary op in lieu of a closing template angle bracket. If there's another 
> > > more straightforward way of accomplishing this check, I'm open to that, 
> > > but this seemed to be the most straightforward way at the time.
> > I'm worried that this may regress template code. How does this account for 
> > cases where two consecutive `>`-s are really two closing template brackets, 
> > e.g.,
> > `std::vector> v;`?
> > 
> > In particular, one added test case is ambiguous: `>>` could really be two 
> > closing template brackets:
> > https://godbolt.org/z/v19hj9vKn
> > 
> > I have to say that my general feeling about trying to disambiguate between 
> > bitshifts and template closers is: don't try too hard inside clang-format 
> > as the heuristics are generally quite brittle and make the code harder to 
> > maintain; in cases where clang-format wrongly detects bitshift as 
> > templates, users should add parens around the bitshift, which IMO improves 
> > readability.
> As this patch currently stands, it does not disambiguate between bitshift 
> '>>' operators and 2 closing template brackets, so in your snippet, we would 
> no longer insert a space between the '>' characters (despite arguably being 
> the better formatting decision in this case).
> 
> I agree with your feeling that user guided disambiguation between bitshift 
> operators and template closing brackets via parens is the ideal solution and 
> also improves readability, but IMO the approach taken by clang-format to 
> format the '>' token should be conservative in that any change made should be 
> non-semantic altering, which is not presently the case. While the case you 
> mentioned would regress, we would no longer potentially alter program 
> semantics. Thinking about this more, would it make sense to modify the actual 
> white-space change generation later on in the analysis to not break up >> 
> sequences of characters in lieu of annotating the tokens differently as the 
> proposed patch is currently doing?
I tried and can't make this misinterpret two consecutive template `>` as a bit 
shift, IMO because this check is guarded by the `Left->ParentBracket != 
tok::less` condition. Both `std::vector> v;` and 
`test> c;` below are handled correctly.
I'm less worried about regressions in common template cases now.
Thank you for pointing out altering program semantics, I agree.
Please add a comment about this tradeoff and and a bit of the reasoning behind 
it in code for future reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100778

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


[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-26 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 340469.
vsavchenko added a comment.

Add one more testg covering the situation when we can't pick up that one region 
to associate with the value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/diagnostics/deref-track-symbolic-region.cpp
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/placement-new.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp

Index: clang/test/Analysis/uninit-const.cpp
===
--- clang/test/Analysis/uninit-const.cpp
+++ clang/test/Analysis/uninit-const.cpp
@@ -63,9 +63,9 @@
 }
 
 void f6_1(void) {
-  int t; // expected-note{{'t' declared without an initial value}}
+  int t;   // expected-note{{'t' declared without an initial value}}
   int p = f6_1_sub(t); //expected-warning {{Assigned value is garbage or undefined}}
-   //expected-note@-1 {{Passing value via 1st parameter 'p'}}
+   //expected-note@-1 {{Passing 't' via 1st parameter 'p'}}
//expected-note@-2 {{Calling 'f6_1_sub'}}
//expected-note@-3 {{Returning from 'f6_1_sub'}}
//expected-note@-4 {{Assigned value is garbage or undefined}}
@@ -75,9 +75,9 @@
 
 void f6_2(void) {
   int t;   //expected-note {{'t' declared without an initial value}}
-  int &p = t;  //expected-note {{'p' initialized here}}
-  int &s = p;  //expected-note {{'s' initialized here}}
-  int &q = s;  //expected-note {{'q' initialized here}}
+  int &p = t;  //expected-note {{'p' initialized to the value of 't'}}
+  int &s = p;  //expected-note {{'s' initialized to the value of 'p'}}
+  int &q = s;  //expected-note {{'q' initialized to the value of 's'}}
   doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
//expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
Index: clang/test/Analysis/uninit-const.c
===
--- clang/test/Analysis/uninit-const.c
+++ clang/test/Analysis/uninit-const.c
@@ -37,7 +37,7 @@
 void f_1_1(void) {
   int t; // expected-note {{'t' declared without an initial value}}
   int *tp1 = &t; // expected-note {{'tp1' initialized here}}
-  int* tp2 = tp1;// expected-note {{'tp2' initialized here}}
+  int *tp2 = tp1;// expected-note {{'tp2' initialized to the value of 'tp1'}}
   doStuff_pointerToConstInt(tp2);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -53,7 +53,7 @@
 // expected-note@-1{{Calling 'f_2_sub'}}
 // expected-note@-2{{Returning from 'f_2_sub'}}
 // expected-note@-3{{'p' initialized here}}
-  int* tp = p; // expected-note {{'tp' initialized here}}
+  int *tp = p;  // expected-note {{'tp' initialized to the value of 'p'}}
   doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}}
   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -70,7 +70,7 @@
 
 void f_5(void) {
   int ta[5];   // expected-note {{'ta' initialized here}}
-  int* tp = ta;// expected-note {{'tp' initialized here}}
+  int *tp = ta;// expected-note {{'tp' initialized to the value of 'ta'}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -107,7 +107,7 @@
 
 void f_9(void) {
   int a[6];// expected-note {{'a' initialized here}}
-  int const *ptau = a; // expected-note {{'ptau' initialized here}}
+  int const *ptau = a; // expected-note {{'ptau' initialized to the value of 'a'}}
   doStuff_arrayOfConstInt(ptau);// expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -339,7 +339,7 @@

[PATCH] D100980: [OpenCL] Allow use of double type without extension pragma

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D100980#2712534 , @azabaznov wrote:

>> We could of course keep it just for this particular case of doubles, but 
>> even half is allowed in certain circumstances without the pragma and it is 
>> still an extension. https://godbolt.org/z/K34sP81nx
>
> I am confused again... after looking into //OpenCL C 1.0, 9.10 Half 
> Floating-Point//: it says that pragma is required too. So is it a bug in 
> clang implementation are do you prefer keep existing functionality for double?

I am not sure, to be honest I personally think the extension pragma is a spec 
failure as it is not specified properly or to allow reasonable implementation. 
And since nobody really understands the original intent it was not possible to 
provide any reasonable implementation either.

For example, in case of half the extension spec said this:

> An application that wants to use half and halfn types will need to include 
> the #pragma OPENCL EXTENSION cl_khr_fp16 : enabledirective.

While main spec has:

> The half data type can only be used to declare a pointer to a buffer that 
> contains half values.



> half is not supported as half can be used as a storage format only and is not 
> a data type on which floating-point arithmetic can be performed

It has no pragma in any examples.

I can't really tell what the pragma was intended for. We have this separate 
spec bug for it btw: https://github.com/KhronosGroup/OpenCL-Docs/issues/21

I didn't look at fp16 in my cleanup yet as it doesn't have a similar pattern 
with any other extension and it is more complicated in my opinion.

Anyway since there is not clear benefit that can be found now for the pragma I 
think we should minimize its use as much as possible.


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

https://reviews.llvm.org/D100980

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


[PATCH] D100772: [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-26 Thread David Spickett via Phabricator via cfe-commits
DavidSpickett added a comment.

I'd merge https://reviews.llvm.org/D100499 into this given that it's only one 
line.




Comment at: clang/include/clang/Basic/arm_neon.td:712
+
+// Crypto
+// TODO: poly128_t not implemented on aarch32

This isn't a crypto intrinsic, it just happens to be right after a block like:
```
let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_CRYPTO)" in {
<...>
def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
}
```

You could instead say:
```
// Non poly128_t vaddp for Arm and AArch64
```
(keep the todo)



Comment at: clang/include/clang/Basic/arm_neon.td:1168
 
-def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPlQPk">;
+def VADDP   : WInst<"vadd", "...", "QPk">;
 

Add a comment here, something like `poly128_t vadd for AArch64 only, see 
VADDP_Q for the rest`.

Also the def names seem backwards, shouldn't this one be `VADDP_Q` and the one 
for Arm and AArch64 be `VADDP`?

Then your comment here is "see VADDP for the rest" which seems correct.



Comment at: clang/test/CodeGen/arm-poly-add.c:4
+// RUN:   -target-feature +neon \
+// RUN:   -target-feature +bf16 -mfloat-abi hard \
+// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \

You can remove the `+bf16` feature.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100772

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


[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-26 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.
This revision is now accepted and ready to land.

For me it looks good now.

The changes, however, seem to be unrelated to retain count checker. Do you 
think it would make sense to upstream this patch independently from the other 3 
patches you have in your stack? That might require some changes in the test 
files though.




Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1532
+  // Telling the user that the value of 'a' is assigned to 'c', while
+  // correct, can be confusing.
+  StoreManager::FindUniqueBinding FB(V.getAsLocSymbol());

vsavchenko wrote:
> martong wrote:
> > vsavchenko wrote:
> > > martong wrote:
> > > > So here, we have two or three bindings attached to `c`? `foo(b)` and 
> > > > `a` (and `b` as well) ?
> > > > What is the guarantee that `FindUniqueBinding` will return with the 
> > > > correct one `foo(b)`? Seems like we iterate through an ImmutableMap 
> > > > (AVL tree) with `MemRegion*` keys. And the order of the iteration 
> > > > depends on pointer values. What I want to express, is that I don't see 
> > > > how do we find the correct binding, seems like we just find one, which 
> > > > might be the one we look for if we are lucky.
> > > > 
> > > > Perhaps we could have a lit test for this example?
> > > Good idea, I should a test for that!
> > > `FindUniqueBinding` does not only have a region, it also carries a flag 
> > > checking if there are more than one binding.  `operator bool` then checks 
> > > for both, thus guaranteeing that we won't choose random binding out of 
> > > more than 1 - we won't choose at all.
> > Yeah, I missed that about `FindUniqueBinding`. 
> > 
> > It's just side questions then: Could we handle multiple bindings by finding 
> > the 'last' binding and tracking that back?
> > And in this example, what are the bindings for `c`?
> Can you please elaborate on what you mean by 'last', like 'last used'?
> As for `c`, you can see above that I'm looking for a node where 'c' is not 
> bound to that value.  So, we start with the node where 'a', 'b', and 'c' all 
> bound to symbolic value... let's say 'x'. I go up the graph to the point 
> where 'c' is not bound to 'x' and there I look for unique binding for 'x'.  
> In that example, we won't find it because it has two: 'a' and 'b'.
Thanks for the explanation!

> Can you please elaborate on what you mean by 'last', like 'last used'? 

Yes, I meant the 'last used', in this case it should be `foo(b)`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

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


[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-26 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 340473.
vsavchenko added a comment.

Refactor the way we get Region for variable declaration


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/diagnostics/deref-track-symbolic-region.cpp
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/placement-new.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp

Index: clang/test/Analysis/uninit-const.cpp
===
--- clang/test/Analysis/uninit-const.cpp
+++ clang/test/Analysis/uninit-const.cpp
@@ -63,9 +63,9 @@
 }
 
 void f6_1(void) {
-  int t; // expected-note{{'t' declared without an initial value}}
+  int t;   // expected-note{{'t' declared without an initial value}}
   int p = f6_1_sub(t); //expected-warning {{Assigned value is garbage or undefined}}
-   //expected-note@-1 {{Passing value via 1st parameter 'p'}}
+   //expected-note@-1 {{Passing 't' via 1st parameter 'p'}}
//expected-note@-2 {{Calling 'f6_1_sub'}}
//expected-note@-3 {{Returning from 'f6_1_sub'}}
//expected-note@-4 {{Assigned value is garbage or undefined}}
@@ -75,9 +75,9 @@
 
 void f6_2(void) {
   int t;   //expected-note {{'t' declared without an initial value}}
-  int &p = t;  //expected-note {{'p' initialized here}}
-  int &s = p;  //expected-note {{'s' initialized here}}
-  int &q = s;  //expected-note {{'q' initialized here}}
+  int &p = t;  //expected-note {{'p' initialized to the value of 't'}}
+  int &s = p;  //expected-note {{'s' initialized to the value of 'p'}}
+  int &q = s;  //expected-note {{'q' initialized to the value of 's'}}
   doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
//expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
Index: clang/test/Analysis/uninit-const.c
===
--- clang/test/Analysis/uninit-const.c
+++ clang/test/Analysis/uninit-const.c
@@ -37,7 +37,7 @@
 void f_1_1(void) {
   int t; // expected-note {{'t' declared without an initial value}}
   int *tp1 = &t; // expected-note {{'tp1' initialized here}}
-  int* tp2 = tp1;// expected-note {{'tp2' initialized here}}
+  int *tp2 = tp1;// expected-note {{'tp2' initialized to the value of 'tp1'}}
   doStuff_pointerToConstInt(tp2);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -53,7 +53,7 @@
 // expected-note@-1{{Calling 'f_2_sub'}}
 // expected-note@-2{{Returning from 'f_2_sub'}}
 // expected-note@-3{{'p' initialized here}}
-  int* tp = p; // expected-note {{'tp' initialized here}}
+  int *tp = p;  // expected-note {{'tp' initialized to the value of 'p'}}
   doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}}
   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -70,7 +70,7 @@
 
 void f_5(void) {
   int ta[5];   // expected-note {{'ta' initialized here}}
-  int* tp = ta;// expected-note {{'tp' initialized here}}
+  int *tp = ta;// expected-note {{'tp' initialized to the value of 'ta'}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -107,7 +107,7 @@
 
 void f_9(void) {
   int a[6];// expected-note {{'a' initialized here}}
-  int const *ptau = a; // expected-note {{'ptau' initialized here}}
+  int const *ptau = a; // expected-note {{'ptau' initialized to the value of 'a'}}
   doStuff_arrayOfConstInt(ptau);// expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -339,7 +339,7 @@
// expected-note@216 {{Returning pointer (loaded f

[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-26 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko marked 4 inline comments as done.
vsavchenko added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:1532
+  // Telling the user that the value of 'a' is assigned to 'c', while
+  // correct, can be confusing.
+  StoreManager::FindUniqueBinding FB(V.getAsLocSymbol());

martong wrote:
> vsavchenko wrote:
> > martong wrote:
> > > vsavchenko wrote:
> > > > martong wrote:
> > > > > So here, we have two or three bindings attached to `c`? `foo(b)` and 
> > > > > `a` (and `b` as well) ?
> > > > > What is the guarantee that `FindUniqueBinding` will return with the 
> > > > > correct one `foo(b)`? Seems like we iterate through an ImmutableMap 
> > > > > (AVL tree) with `MemRegion*` keys. And the order of the iteration 
> > > > > depends on pointer values. What I want to express, is that I don't 
> > > > > see how do we find the correct binding, seems like we just find one, 
> > > > > which might be the one we look for if we are lucky.
> > > > > 
> > > > > Perhaps we could have a lit test for this example?
> > > > Good idea, I should a test for that!
> > > > `FindUniqueBinding` does not only have a region, it also carries a flag 
> > > > checking if there are more than one binding.  `operator bool` then 
> > > > checks for both, thus guaranteeing that we won't choose random binding 
> > > > out of more than 1 - we won't choose at all.
> > > Yeah, I missed that about `FindUniqueBinding`. 
> > > 
> > > It's just side questions then: Could we handle multiple bindings by 
> > > finding the 'last' binding and tracking that back?
> > > And in this example, what are the bindings for `c`?
> > Can you please elaborate on what you mean by 'last', like 'last used'?
> > As for `c`, you can see above that I'm looking for a node where 'c' is not 
> > bound to that value.  So, we start with the node where 'a', 'b', and 'c' 
> > all bound to symbolic value... let's say 'x'. I go up the graph to the 
> > point where 'c' is not bound to 'x' and there I look for unique binding for 
> > 'x'.  In that example, we won't find it because it has two: 'a' and 'b'.
> Thanks for the explanation!
> 
> > Can you please elaborate on what you mean by 'last', like 'last used'? 
> 
> Yes, I meant the 'last used', in this case it should be `foo(b)`.
That would be perfect actually, but not `foo(b)`, just `b`.  Reporting `foo(b)` 
won't give more information than the code itself already provides.
However, I don't know a simple way to get region `b` from `foo(b)` expression 
(of course, we are talking about more general case than just getting the first 
argument of `foo`).



Comment at: clang/test/Analysis/uninit-const.cpp:78
   int t;   //expected-note {{'t' declared without an initial value}}
-  int &p = t;  //expected-note {{'p' initialized here}}
-  int &s = p;  //expected-note {{'s' initialized here}}
-  int &q = s;  //expected-note {{'q' initialized here}}
+  int &p = t;  //expected-note {{'p' initialized to the value of 't'}}
+  int &s = p;  //expected-note {{'s' initialized to the value of 'p'}}

NoQ wrote:
> I suspect that this wording can be improved a lot. The note "`'p' initialized 
> to the value of 't'`" sounds like an accurate description for `int p = t` but 
> not so much for `int &p = t`. Can we detect this case and say something like 
> "`'p' refers to 't'`" instead?
That's a good point, but it feels like a can miss some cases here and we need 
to handle this situation separately.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

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


[PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-04-26 Thread Raphael Isemann via Phabricator via cfe-commits
teemperor added a comment.

Not sure what the backtrace is for the `clang::FieldDecl::isZeroSize` crash but 
what might relevant:

1. The ASTImporter test isn't using the 'Minimal' import mode that LLDB is 
using. In the tests we are importing all declarations directly. In LLDB we use 
the 'minimal' mode where we try to import declarations lazily (but the setup 
for that is wrong, hence why it's crashing for you).
2. The ASTImporter tests aren't generating code for imported nodes (at least to 
my knowledge?), so you can't reproduce CG crashes here.

If the assert here is actually for the FieldDecl not having a complete type 
then I think the actual problem is point 1.

Looking at the code we do actually get a request to complete the type before 
the assert:

  const RecordDecl *RD = RT->getDecl()->getDefinition();
  if (!RD) {
assert(isInvalidDecl() && "valid field has incomplete type");
return false;
  }

The call to `getDefinition` is expected to pull in the definition but this 
won't happen in the current LLDB implementation (as we don't properly implement 
that interface). In the past we worked around this issue in the same way as in 
this patch, so IMHO this is fine as a temporary solution until we finally fix 
the LLDB Decl completion. But I guess it's also a question of how much LLDB 
workarounds the ASTImporter maintainers want to have in their code until this 
happens.

(Side note: I think `isInvalidDecl` is also true when we run into semantic 
errors and just mark the Decl as being malformed, so I'm not sure the assert 
text can be fully trusted here. But if eagerly completing the type fixes the 
issue then I guess it's actually the incomplete type that causes the assert to 
trigger)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101236

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


[PATCH] D100934: [clang][modules] Build inferred modules

2021-04-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 340478.
jansvoboda11 added a comment.

Fix clang-tidy warnings, add fixme


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

Files:
  clang/include/clang/Basic/Module.h
  clang/include/clang/Lex/ModuleMap.h
  clang/lib/Basic/Module.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Lex/ModuleMap.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h
  
clang/test/ClangScanDeps/Inputs/frameworks/Inferred.framework/Headers/Inferred.h
  clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Headers/System.h
  
clang/test/ClangScanDeps/Inputs/frameworks/System.framework/Modules/module.modulemap
  clang/test/ClangScanDeps/Inputs/frameworks/module.modulemap
  clang/test/ClangScanDeps/Inputs/modules_inferred_cdb.json
  clang/test/ClangScanDeps/module-deps-to-rsp.py
  clang/test/ClangScanDeps/modules-full.cpp
  clang/test/ClangScanDeps/modules-inferred-explicit-build.m
  clang/test/ClangScanDeps/modules-inferred.m

Index: clang/test/ClangScanDeps/modules-inferred.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred.m
@@ -0,0 +1,61 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%S/Inputs/frameworks|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: echo -%t.dir > %t.result
+// RUN: echo -%S >> %t.result
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -generate-modules-path-args -mode preprocess-minimized-sources >> %t.result
+// RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
+
+#include 
+
+inferred a = 0;
+
+// CHECK: -[[PREFIX:.*]]
+// CHECK-NEXT: -[[SOURCEDIR:.*]]
+// CHECK-NEXT: {
+// CHECK-NEXT:   "modules": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-module-deps": [],
+// CHECK-NEXT:   "clang-modulemap-file": "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap",
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-cc1",
+// CHECK:  "-emit-module",
+// CHECK:  "-fmodule-name=Inferred",
+// CHECK:  "-fno-implicit-modules",
+// CHECK:],
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1:[A-Z0-9]+]]",
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Frameworks/Sub.framework/Headers/Sub.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/Inferred.framework/Headers/Inferred.h",
+// CHECK-NEXT: "[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "translation-units": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "clang-context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "clang-module-deps": [
+// CHECK-NEXT: {
+// CHECK-NEXT:   "context-hash": "[[CONTEXT_HASH_H1]]",
+// CHECK-NEXT:   "module-name": "Inferred"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "command-line": [
+// CHECK-NEXT: "-fno-implicit-modules",
+// CHECK-NEXT: "-fno-implicit-module-maps",
+// CHECK-NEXT: "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/Inferred-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT: "-fmodule-map-file=[[SOURCEDIR]]/Inputs/frameworks/module.modulemap"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "file-deps": [
+// CHECK-NEXT: "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT:   ],
+// CHECK-NEXT:   "input-file": "[[PREFIX]]/modules_cdb_input.cpp"
+// CHECK-NEXT: }
+// CHECK-NEXT:   ]
+// CHECK-NEXT: }
Index: clang/test/ClangScanDeps/modules-inferred-explicit-build.m
===
--- /dev/null
+++ clang/test/ClangScanDeps/modules-inferred-explicit-build.m
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t.dir
+// RUN: rm -rf %t.cdb
+// RUN: mkdir -p %t.dir
+// RUN: cp %s %t.dir/modules_cdb_input.cpp
+// RUN: sed -e "s|DIR|%/t.dir|g" -e "s|FRAMEWORKS|%/S/Inputs/frameworks|g" -e "s|-E|-x objective-c -E|g" \
+// RUN:   %S/Inputs/modules_inferred_cdb.json > %t.cdb
+//
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -format experimental-full \
+// RUN:   -mode preprocess-minimized-sources > %t.db
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=Inferred > %t.inferred.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --module-name=System > %t.system.rsp
+// RUN: %S/module-deps-to-rsp.py %t.db --tu-index=0 > %t.tu.rsp
+// RUN: %clang @%t.inferred.rsp -pedantic -Werror

[PATCH] D100934: [clang][modules] Build inferred modules

2021-04-26 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:5621
+  // FIXME: NameAsWritten
+  ModMap.setUmbrellaHeader(CurrentModule, *Umbrella, Blob, "");
 else if (CurrentModule->getUmbrellaHeader().Entry != *Umbrella) {

Not sure what's the best way to write/read the two strings (`NameAsWritten`, 
`PathRelativeToRootModuleDirectory`). Can we put them into a single blob and 
separate them with `\0`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100934

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


[PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-04-26 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

To provide unit tests that mimic the LLDB setup, a good starting point could be 
an existing test case:

  struct LLDBLookupTest : ASTImporterOptionSpecificTestBase {

You can create a similar descendant class, but with the MinimalImport flag set 
to true. Then you could call `ImportDefinition` subsequently after an `Import` 
call. Perhaps that could trigger your assertion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101236

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia 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/D89909/new/

https://reviews.llvm.org/D89909

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


[PATCH] D99488: [SYCL][Doc] Add address space handling section to SYCL documentation

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.

LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99488

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


[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Just one drive-by nit from me.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:4119-4123
+  if (LangOpts.SYCLIsDevice) {
+if (!D || D->getType().getAddressSpace() == LangAS::Default) {
+  return LangAS::sycl_global;
+}
+  }

Just simplifying the logic a bit, likely needs to be reformatted though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

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


[PATCH] D101192: Add support for #elifdef and #elifndef

2021-04-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman updated this revision to Diff 340482.
aaron.ballman marked 3 inline comments as done.
aaron.ballman added a comment.

Updates based on review feedback.

Added tests for the source minimizer changes, thanks @dexonsmith!


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

https://reviews.llvm.org/D101192

Files:
  clang/include/clang/Basic/DiagnosticLexKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Lex/DependencyDirectivesSourceMinimizer.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/include/clang/Lex/PPConditionalDirectiveRecord.h
  clang/include/clang/Lex/PreprocessingRecord.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Index/IndexingAction.cpp
  clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
  clang/lib/Lex/Lexer.cpp
  clang/lib/Lex/PPConditionalDirectiveRecord.cpp
  clang/lib/Lex/PPDirectives.cpp
  clang/lib/Lex/PreprocessingRecord.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Sema/SemaCodeComplete.cpp
  clang/test/Index/complete-preprocessor.m
  clang/test/Preprocessor/elifdef.c
  clang/test/Preprocessor/if_warning.c
  clang/test/Preprocessor/ifdef-recover.c
  clang/test/Preprocessor/macro_misc.c
  clang/test/Preprocessor/macro_vaopt_check.cpp
  clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp

Index: clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
===
--- clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
+++ clang/unittests/Lex/DependencyDirectivesSourceMinimizerTest.cpp
@@ -53,6 +53,8 @@
"#if A\n"
"#ifdef A\n"
"#ifndef A\n"
+   "#elifdef A\n"
+   "#elifndef A\n"
"#elif A\n"
"#else\n"
"#include \n"
@@ -70,18 +72,20 @@
   EXPECT_EQ(pp_if, Tokens[3].K);
   EXPECT_EQ(pp_ifdef, Tokens[4].K);
   EXPECT_EQ(pp_ifndef, Tokens[5].K);
-  EXPECT_EQ(pp_elif, Tokens[6].K);
-  EXPECT_EQ(pp_else, Tokens[7].K);
-  EXPECT_EQ(pp_include, Tokens[8].K);
-  EXPECT_EQ(pp_include_next, Tokens[9].K);
-  EXPECT_EQ(pp___include_macros, Tokens[10].K);
-  EXPECT_EQ(pp_import, Tokens[11].K);
-  EXPECT_EQ(decl_at_import, Tokens[12].K);
-  EXPECT_EQ(pp_pragma_import, Tokens[13].K);
-  EXPECT_EQ(cxx_export_decl, Tokens[14].K);
-  EXPECT_EQ(cxx_module_decl, Tokens[15].K);
-  EXPECT_EQ(cxx_import_decl, Tokens[16].K);
-  EXPECT_EQ(pp_eof, Tokens[17].K);
+  EXPECT_EQ(pp_elifdef, Tokens[6].K);
+  EXPECT_EQ(pp_elifndef, Tokens[7].K);
+  EXPECT_EQ(pp_elif, Tokens[8].K);
+  EXPECT_EQ(pp_else, Tokens[9].K);
+  EXPECT_EQ(pp_include, Tokens[10].K);
+  EXPECT_EQ(pp_include_next, Tokens[11].K);
+  EXPECT_EQ(pp___include_macros, Tokens[12].K);
+  EXPECT_EQ(pp_import, Tokens[13].K);
+  EXPECT_EQ(decl_at_import, Tokens[14].K);
+  EXPECT_EQ(pp_pragma_import, Tokens[15].K);
+  EXPECT_EQ(cxx_export_decl, Tokens[16].K);
+  EXPECT_EQ(cxx_module_decl, Tokens[17].K);
+  EXPECT_EQ(cxx_import_decl, Tokens[18].K);
+  EXPECT_EQ(pp_eof, Tokens[19].K);
 }
 
 TEST(MinimizeSourceToDependencyDirectivesTest, Define) {
@@ -324,6 +328,44 @@
Out.data());
 }
 
+TEST(MinimizeSourceToDependencyDirectivesTest, Elifdef) {
+  SmallVector Out;
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef C\n"
+"#define D\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef C\n"
+   "#define D\n"
+   "#endif\n",
+   Out.data());
+
+  ASSERT_FALSE(minimizeSourceToDependencyDirectives("#ifdef A\n"
+"#define B\n"
+"#elifdef B\n"
+"#define C\n"
+"#elifndef C\n"
+"#define D\n"
+"#else\n"
+"#define E\n"
+"#endif\n",
+Out));
+  EXPECT_STREQ("#ifdef A\n"
+   "#define B\n"
+   "#elifdef B\n"
+   "#define C\n"
+   "#elifndef C\n"
+   "#define D\n"
+   "#else\n"
+

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-04-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp:909
   If,  // if/ifdef/ifndef
   Else // elif,else
 };

dexonsmith wrote:
> Please add the two new cases to this comment as well.
Good catch, thanks!


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

https://reviews.llvm.org/D101192

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


[PATCH] D101087: [OpenCL] Introduce new method for validating OpenCL target

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks.

I have made a minor suggestion to testing that could be addressed in the final 
commit.




Comment at: clang/test/Misc/nvptx.unsupported_core.cl:1
+// RUN: %clang_cc1 -cl-std=CL2.0 -triple nvptx-unknown-unknown 
-Wpedantic-core-features %s 2> %t
+// RUN: FileCheck < %t %s

We could add a line with `-cl-std=CLC++` to check the full wording of the new 
diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101087

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


[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-26 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

This is an improvement! Good job.
I had no time reviewing this, but I think it's already in a pretty good shape.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

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


[PATCH] D101236: [ASTImporter] Import definitions required for layout of [[no_unique_address]] from LLDB

2021-04-26 Thread Jan Kratochvil via Phabricator via cfe-commits
jankratochvil planned changes to this revision.
jankratochvil added a comment.

In D101236#2716286 , @teemperor wrote:

> Not sure what the backtrace is for the `clang::FieldDecl::isZeroSize` crash 
> but what might relevant:

That happens only with half of the patch: 
https://people.redhat.com/jkratoch/lldb-iszerosize.patch
And only for these testcases:

  lldb-api :: 
commands/expression/codegen-crash-typedefdecl-not-in_declcontext/TestCodegenCrashTypedefDeclNotInDeclContext.py
  lldb-api :: 
commands/expression/completion-crash-incomplete-record/TestCompletionCrashIncompleteRecord.py
  lldb-api :: 
functionalities/data-formatter/data-formatter-stl/libcxx/map/TestDataFormatterLibccMap.py

The backtrace is: https://people.redhat.com/jkratoch/lldb-iszerosize.txt

> IMHO this is fine as a temporary solution until we finally fix the LLDB Decl 
> completion.

Great, thanks.

In D101236#2716317 , @martong wrote:

> You can create a similar descendant class, but with the MinimalImport flag 
> set to true. Then you could call `ImportDefinition` subsequently after an 
> `Import` call. Perhaps that could trigger your assertion.

I have been looking for such suggestion, thanks. I will try that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101236

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


[PATCH] D101168: [C++4OpenCL] Add clang extension for unsafe kernel parameters

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/docs/LanguageExtensions.rst:1804
 
+``__cl_clang_allow_unsafe_kernel_parameters``
+-

How about `__cl_clang_unsafe_kernel_parameters` to match the other extension 
naming scheme? Or we could use `__cl_clang_non_portable_kernel_parameters`, 
`__cl_clang_non_portable_kernel_parameter_types` to be more specific regarding 
the kind of safety that we allow to break?



Comment at: clang/docs/LanguageExtensions.rst:1807
+
+With this extension it is possible to define kernel functions whose arguments
+do not follow the requirements using regular OpenCL extension pragma mechanism





Comment at: clang/docs/LanguageExtensions.rst:1812
+
+This is not conformant behavior and it can only be used portably when the
+arguments don't get passed across the host/device boundary, or if the compilers





Comment at: clang/docs/LanguageExtensions.rst:1813
+This is not conformant behavior and it can only be used portably when the
+arguments don't get passed across the host/device boundary, or if the compilers
+used for both host and device give the same layout.





Comment at: clang/docs/LanguageExtensions.rst:1814
+arguments don't get passed across the host/device boundary, or if the compilers
+used for both host and device give the same layout.
+





Comment at: clang/docs/LanguageExtensions.rst:1823
+  #pragma OPENCL EXTENSION __cl_clang_allow_unsafe_kernel_parameters : enable
+non_pod_type b,
+global non_standard_layout_type *c,

Let's add declarations of such types along in the example. 



Comment at: clang/lib/Sema/SemaDecl.cpp:8651
 static OpenCLParamType getOpenCLKernelParameterType(Sema &S, QualType PT) {
+  if (PT->isDependentType())
+return InvalidKernelParam;

I would rather add an assert for this because we should not ever reach this 
function for the dependent types?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101168

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


[PATCH] D101041: [analyzer] Find better description for tracked symbolic values

2021-04-26 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 340499.
vsavchenko marked an inline comment as done.
vsavchenko added a comment.

Limit the number of cases where the new note refinement takes place


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101041

Files:
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/diagnostics/deref-track-symbolic-region.cpp
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/uninit-const.c
  clang/test/Analysis/uninit-const.cpp

Index: clang/test/Analysis/uninit-const.cpp
===
--- clang/test/Analysis/uninit-const.cpp
+++ clang/test/Analysis/uninit-const.cpp
@@ -63,7 +63,7 @@
 }
 
 void f6_1(void) {
-  int t; // expected-note{{'t' declared without an initial value}}
+  int t;   // expected-note{{'t' declared without an initial value}}
   int p = f6_1_sub(t); //expected-warning {{Assigned value is garbage or undefined}}
//expected-note@-1 {{Passing value via 1st parameter 'p'}}
//expected-note@-2 {{Calling 'f6_1_sub'}}
@@ -76,8 +76,8 @@
 void f6_2(void) {
   int t;   //expected-note {{'t' declared without an initial value}}
   int &p = t;  //expected-note {{'p' initialized here}}
-  int &s = p;  //expected-note {{'s' initialized here}}
-  int &q = s;  //expected-note {{'q' initialized here}}
+  int &s = p;  //expected-note {{'s' initialized to the value of 'p'}}
+  int &q = s;  //expected-note {{'q' initialized to the value of 's'}}
   doStuff6(q); //expected-warning {{1st function call argument is an uninitialized value}}
//expected-note@-1 {{1st function call argument is an uninitialized value}}
 }
Index: clang/test/Analysis/uninit-const.c
===
--- clang/test/Analysis/uninit-const.c
+++ clang/test/Analysis/uninit-const.c
@@ -37,7 +37,7 @@
 void f_1_1(void) {
   int t; // expected-note {{'t' declared without an initial value}}
   int *tp1 = &t; // expected-note {{'tp1' initialized here}}
-  int* tp2 = tp1;// expected-note {{'tp2' initialized here}}
+  int *tp2 = tp1;// expected-note {{'tp2' initialized to the value of 'tp1'}}
   doStuff_pointerToConstInt(tp2);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -53,7 +53,7 @@
 // expected-note@-1{{Calling 'f_2_sub'}}
 // expected-note@-2{{Returning from 'f_2_sub'}}
 // expected-note@-3{{'p' initialized here}}
-  int* tp = p; // expected-note {{'tp' initialized here}}
+  int *tp = p;  // expected-note {{'tp' initialized to the value of 'p'}}
   doStuff_pointerToConstInt(tp); // expected-warning {{1st function call argument is a pointer to uninitialized value}}
   // expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
@@ -70,7 +70,7 @@
 
 void f_5(void) {
   int ta[5];   // expected-note {{'ta' initialized here}}
-  int* tp = ta;// expected-note {{'tp' initialized here}}
+  int *tp = ta;// expected-note {{'tp' initialized here}}
   doStuff_pointerToConstInt(tp);  // expected-warning {{1st function call argument is a pointer to uninitialized value}}
// expected-note@-1 {{1st function call argument is a pointer to uninitialized value}}
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -339,7 +339,7 @@
// expected-note@216 {{Returning pointer (loaded from 'self')}}
// expected-note@-3 {{Returning from 'initY'}}
// expected-note@-4 {{'Original' initialized here}}
-  id New = Original;   // expected-note {{'New' initialized here}}
+  id New = Original;   // expected-note {{'New' initialized to the value of 'Original'}}
   Original = [[MyObj alloc] initZ];
   (void)New;
   [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
@@ -352,8 +352,8 @@
// expected-note@216 {{Returning pointer (loaded from 'self')}}
// expected-note@-3 {{Returning from 'initY'}}
// expected-note@-4 {{'Original' initialized here}}
-  id Intermediate = Origina

[PATCH] D92004: [OpenCL] add CL 3.0 optional feature support to opencl-c.h

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

We have discussed testing of headers within OpenCL developer community and 
wider:
https://lists.llvm.org/pipermail/cfe-dev/2021-April/068040.html

and the conclusions I have drawn are as follows:

- There seem to be no big interest in improving upstream testing of 
`opencl-c.h` and therefore improving the quality assurance processes in 
upstream development.
- There is no plan for `opencl-c.h` to be exposed to the end user in upstream. 
An alternative newer solution using Tablegen is currently enabled by default 
through the clang driver as a primary header.
- It is likely that `opencl-c.h` will be deprecated or even removed in the 
future releases however this discussion hasn't fully taken place yet.

Considering the above and the fact that the `opencl-c.h` header will continue 
to exist for the time being as it has been adopted by various out-of-tree 
implementations of OpenCL it would be reasonable to continue with this patch as 
it extends in a straightforward way existing functionality with the same 
experimental quality.

I would quite like to find one extra reviewer from a different vendor 
preferably with OpenCL 3 expertise.  @azabaznov would you be happy to review 
this?

I would also like to recommend using an experimental test 
(https://reviews.llvm.org/D97869) that is planned for the Tablegen header 
solution before committing this patch to gain more confidence. However, It 
might be good to check with @svenvh  first to see whether there are any know 
issues for running such test with `opencl-c.h`.

I would also like to loop @yaxunl  in for the extra pair of eyes wrt prior to 
OpenCL 3 functionality.

Ideally, it would be good if we don't commit it too close to the release branch 
i.e. good to leave a few weeks for the bugs to be discovered and fixed 
considering the possible propagation time to the external projects.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92004

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


[clang] 7818906 - [SYCL] Implement SYCL address space attributes handling

2021-04-26 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2021-04-26T13:44:10+03:00
New Revision: 7818906ca134775edffb77857f436359d3a50b90

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

LOG: [SYCL] Implement SYCL address space attributes handling

Default address space (applies when no explicit address space was
specified) maps to generic (4) address space.

Added SYCL named address spaces `sycl_global`, `sycl_local` and
`sycl_private` defined as sub-sets of the default address space.

Static variables without address space now reside in global address
space when compile for SPIR target, unless they have an explicit address
space qualifier in source code.

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

Added: 
clang/test/CodeGenSYCL/address-space-conversions.cpp
clang/test/CodeGenSYCL/address-space-deduction.cpp
clang/test/CodeGenSYCL/address-space-mangling.cpp
clang/test/SemaSYCL/address-space-conversions.cpp

Modified: 
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AddressSpaces.h
clang/include/clang/Sema/ParsedAttr.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/Targets/AMDGPU.cpp
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGDecl.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/Sema/SemaType.cpp
clang/test/SemaTemplate/address_space-dependent.cpp

Removed: 




diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 530b3cecc023b..84de51aba5b2d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -488,7 +488,11 @@ class Qualifiers {
B == LangAS::opencl_global_host)) ||
// Consider pointer size address spaces to be equivalent to default.
((isPtrSizeAddressSpace(A) || A == LangAS::Default) &&
-(isPtrSizeAddressSpace(B) || B == LangAS::Default));
+(isPtrSizeAddressSpace(B) || B == LangAS::Default)) ||
+   // Default is a superset of SYCL address spaces.
+   (A == LangAS::Default &&
+(B == LangAS::sycl_private || B == LangAS::sycl_local ||
+ B == LangAS::sycl_global));
   }
 
   /// Returns true if the address space in these qualifiers is equal to or

diff  --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index a9db52dfcc9c8..5fa031250a629 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -44,6 +44,11 @@ enum class LangAS : unsigned {
   cuda_constant,
   cuda_shared,
 
+  // SYCL specific address spaces.
+  sycl_global,
+  sycl_local,
+  sycl_private,
+
   // Pointer size and extension address spaces.
   ptr32_sptr,
   ptr32_uptr,

diff  --git a/clang/include/clang/Sema/ParsedAttr.h 
b/clang/include/clang/Sema/ParsedAttr.h
index e508b4651be1c..347925873b30f 100644
--- a/clang/include/clang/Sema/ParsedAttr.h
+++ b/clang/include/clang/Sema/ParsedAttr.h
@@ -628,8 +628,8 @@ class ParsedAttr final
   /// a Spelling enumeration, the value UINT_MAX is returned.
   unsigned getSemanticSpelling() const;
 
-  /// If this is an OpenCL addr space attribute returns its representation
-  /// in LangAS, otherwise returns default addr space.
+  /// If this is an OpenCL address space attribute returns its representation
+  /// in LangAS, otherwise returns default address space.
   LangAS asOpenCLLangAS() const {
 switch (getParsedKind()) {
 case ParsedAttr::AT_OpenCLConstantAddressSpace:
@@ -651,6 +651,22 @@ class ParsedAttr final
 }
   }
 
+  /// If this is an OpenCL address space attribute returns its SYCL
+  /// representation in LangAS, otherwise returns default address space.
+  LangAS asSYCLLangAS() const {
+switch (getKind()) {
+case ParsedAttr::AT_OpenCLGlobalAddressSpace:
+  return LangAS::sycl_global;
+case ParsedAttr::AT_OpenCLLocalAddressSpace:
+  return LangAS::sycl_local;
+case ParsedAttr::AT_OpenCLPrivateAddressSpace:
+  return LangAS::sycl_private;
+case ParsedAttr::AT_OpenCLGenericAddressSpace:
+default:
+  return LangAS::Default;
+}
+  }
+
   AttributeCommonInfo::Kind getKind() const {
 return AttributeCommonInfo::Kind(Info.AttrKind);
   }

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index aefb2ade81d2a..85e5a61836337 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -931,6 +931,9 @@ static const LangASMap *getAddressSpaceMap(const TargetInfo 
&T,
  

[PATCH] D89909: [SYCL] Implement SYCL address space attributes handling

2021-04-26 Thread Alexey Bader via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
bader marked an inline comment as done.
Closed by commit rG7818906ca134: [SYCL] Implement SYCL address space attributes 
handling (authored by bader).

Changed prior to commit:
  https://reviews.llvm.org/D89909?vs=339973&id=340505#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D89909

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/CodeGenSYCL/address-space-deduction.cpp
  clang/test/CodeGenSYCL/address-space-mangling.cpp
  clang/test/SemaSYCL/address-space-conversions.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388593)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388590)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x71>();
+  correct<0x7FFFED>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/SemaSYCL/address-space-conversions.cpp
===
--- /dev/null
+++ clang/test/SemaSYCL/address-space-conversions.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -fsycl-is-device -verify -fsyntax-only %s
+
+void bar(int &Data) {}
+void bar2(int &Data) {}
+void bar(__attribute__((opencl_private)) int &Data) {}
+void foo(int *Data) {}
+void foo2(int *Data) {}
+void foo(__attribute__((opencl_private)) int *Data) {}
+void baz(__attribute__((opencl_private)) int *Data) {} // expected-note {{candidate function not viable: cannot pass pointer to generic address space as a pointer to address space '__private' in 1st argument}}
+
+template 
+void tmpl(T *t) {}
+
+void usages() {
+  __attribute__((opencl_global)) int *GLOB;
+  __attribute__((opencl_private)) int *PRIV;
+  __attribute__((opencl_local)) int *LOC;
+  int *NoAS;
+
+  GLOB = PRIV; // expected-error {{assigning '__private int *' to '__global int *' changes address space of pointer}}
+  GLOB = LOC;  // expected-error {{assigning '__local int *' to '__global int *' changes address space of pointer}}
+  PRIV = static_cast<__attribute__((opencl_private)) int *>(GLOB); // expected-error {{static_cast from '__global int *' to '__private int *' is not allowed}}
+  PRIV = static_cast<__attribute__((opencl_private)) int *>(LOC);  // expected-error {{static_cast from '__local int *' to '__private int *' is not allowed}}
+  NoAS = GLOB + PRIV;  // expected-error {{invalid operands to binary expression ('__global int *' and '__private int *')}}
+  NoAS = GLOB + LOC;   // expected-error {{invalid operands to binary expression ('__global int *' and '__local int *')}}
+  NoAS += GLOB;// expected-error {{invalid operands to binary expression ('int *' and '__global int *')}}
+
+  bar(*GLOB);
+  bar2(*GLOB);
+
+  bar(*PRIV);
+  bar2(*PRIV);
+
+  bar(*NoAS);
+  bar2(*NoAS);
+
+  bar(*LOC);
+  bar2(*LOC);
+
+  foo(GLOB);
+  foo2(GLOB);
+  foo(PRIV);
+  foo2(PRIV);
+  foo(NoAS);
+  foo2(NoAS);
+  foo(LOC);
+  foo2(LOC);
+
+  tmpl(GLOB);
+  tmpl(PRIV);
+  tmpl(NoAS);
+  tmpl(LOC);
+
+  // Implicit casts to named address space are disallowed
+  baz(NoAS);   // expected-error {{no matching function for call to 'baz'}}
+  __attribute__((opencl_lo

[PATCH] D101192: Add support for #elifdef and #elifndef

2021-04-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Wow thanks for doing this! I worked on it a couple days a while ago but I 
abandoned the effort and went back to my day job.  It seems like preprocessing 
ought to be something like a "state machine" but I couldn't figure out the 
mechanism. Would it make sense to add some kind of high level description of 
the components, now that you've gone to the [presumably massive] effort of 
understanding it? Just a couple small comments above.




Comment at: clang/lib/Lex/PPDirectives.cpp:1059
+case tok::pp_elifdef:
+  return HandleElifdefDirective(Result, SavedHash, false,
+true /*not valid for miopt*/);

please put a comment on 'false'



Comment at: clang/lib/Lex/PPDirectives.cpp:1063
+  return HandleElifdefDirective(Result, SavedHash, true,
+ReadAnyTokensBeforeDirective);
 case tok::pp_else:

please put a comment on true 


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

https://reviews.llvm.org/D101192

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


[clang] e7b6c0f - [clang][XCore] Define __xcore__ for XCore target.

2021-04-26 Thread Nigel Perks via cfe-commits

Author: Nigel Perks
Date: 2021-04-26T15:06:04+01:00
New Revision: e7b6c0f398ee5975bf9f39e629713ae446e8fe01

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

LOG: [clang][XCore] Define __xcore__ for XCore target.

The headers shipped with the XMOS XCore compiler expect __xcore__ to be defined.
The __XS1B__ macro, already defined, is for the default subtarget.

No other targets affected.

Added: 


Modified: 
clang/lib/Basic/Targets/XCore.cpp
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/XCore.cpp 
b/clang/lib/Basic/Targets/XCore.cpp
index da614f10e338f..ba64f15f3394a 100644
--- a/clang/lib/Basic/Targets/XCore.cpp
+++ b/clang/lib/Basic/Targets/XCore.cpp
@@ -28,6 +28,7 @@ const Builtin::Info XCoreTargetInfo::BuiltinInfo[] = {
 
 void XCoreTargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
+  Builder.defineMacro("__xcore__");
   Builder.defineMacro("__XS1B__");
 }
 

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 0329453c4136b..be60eb6d9cf61 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1468,6 +1468,7 @@
 // XCORE:#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
 // XCORE:#define __LITTLE_ENDIAN__ 1
 // XCORE:#define __XS1B__ 1
+// XCORE:#define __xcore__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 
-triple=wasm32-unknown-unknown \
 // RUN:   < /dev/null \



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


[PATCH] D100591: [Clang][AArch64] Disable rounding of return values for AArch64

2021-04-26 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

In D100591#2711433 , @t.p.northover 
wrote:

> On big-endian targets the rounding up to 64-bits (specified in the AAPCS) is 
> significant; it means that structs get passed in the high bits of `x0` rather 
> than low. E.g. https://godbolt.org/z/6v36oexsW. I think this patch would 
> break that.

Thanks a lot! I've disabled the change for big-endian AArch64 targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100591

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


[PATCH] D100591: [Clang][AArch64] Disable rounding of return values for AArch64

2021-04-26 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic updated this revision to Diff 340517.
asavonic added a comment.

Keep rounding of return values for big-endian targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100591

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/aarch64-varargs.c
  clang/test/CodeGen/arm64-arguments.c
  clang/test/CodeGen/arm64-microsoft-arguments.cpp
  clang/test/CodeGen/attr-noundef.cpp
  clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  clang/test/CodeGenCXX/trivial_abi.cpp

Index: clang/test/CodeGenCXX/trivial_abi.cpp
===
--- clang/test/CodeGenCXX/trivial_abi.cpp
+++ clang/test/CodeGenCXX/trivial_abi.cpp
@@ -198,12 +198,11 @@
   testReturnLarge();
 }
 
-// CHECK: define{{.*}} i64 @_Z20testReturnHasTrivialv()
+// CHECK: define{{.*}} i32 @_Z20testReturnHasTrivialv()
 // CHECK: %[[RETVAL:.*]] = alloca %[[STRUCT_TRIVIAL:.*]], align 4
 // CHECK: %[[COERCE_DIVE:.*]] = getelementptr inbounds %[[STRUCT_TRIVIAL]], %[[STRUCT_TRIVIAL]]* %[[RETVAL]], i32 0, i32 0
 // CHECK: %[[V0:.*]] = load i32, i32* %[[COERCE_DIVE]], align 4
-// CHECK: %[[COERCE_VAL_II:.*]] = zext i32 %[[V0]] to i64
-// CHECK: ret i64 %[[COERCE_VAL_II]]
+// CHECK: ret i32 %[[V0]]
 // CHECK: }
 
 Trivial testReturnHasTrivial() {
Index: clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
===
--- clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -87,7 +87,7 @@
 // LINUX-LABEL: define{{.*}} void @_Z12small_returnv(%struct.Small* noalias sret(%struct.Small) align 4 %agg.result)
 // WIN32: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
 // WIN64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
-// WOA64: define dso_local i64 @"?small_return@@YA?AUSmall@@XZ"()
+// WOA64: define dso_local i32 @"?small_return@@YA?AUSmall@@XZ"()
 
 Medium medium_return() { return Medium(); }
 // LINUX-LABEL: define{{.*}} void @_Z13medium_returnv(%struct.Medium* noalias sret(%struct.Medium) align 4 %agg.result)
Index: clang/test/CodeGen/attr-noundef.cpp
===
--- clang/test/CodeGen/attr-noundef.cpp
+++ clang/test/CodeGen/attr-noundef.cpp
@@ -11,7 +11,7 @@
 Trivial ret_trivial() { return {}; }
 void pass_trivial(Trivial e) {}
 // CHECK-INTEL: [[DEFINE:define( dso_local)?]] i32 @{{.*}}ret_trivial
-// CHECK-AARCH: [[DEFINE:define( dso_local)?]] i64 @{{.*}}ret_trivial
+// CHECK-AARCH: [[DEFINE:define( dso_local)?]] i32 @{{.*}}ret_trivial
 // CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i32 %
 // CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i64 %
 
@@ -43,7 +43,7 @@
 Trivial ret_trivial() { return {}; }
 void pass_trivial(Trivial e) {}
 // CHECK-INTEL: [[DEFINE]] i32 @{{.*}}ret_trivial
-// CHECK-AARCH: [[DEFINE]] i64 @{{.*}}ret_trivial
+// CHECK-AARCH: [[DEFINE]] i32 @{{.*}}ret_trivial
 // CHECK-INTEL: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i32 %
 // CHECK-AARCH: [[DEFINE]] void @{{.*}}pass_trivial{{.*}}(i64 %
 
Index: clang/test/CodeGen/arm64-microsoft-arguments.cpp
===
--- clang/test/CodeGen/arm64-microsoft-arguments.cpp
+++ clang/test/CodeGen/arm64-microsoft-arguments.cpp
@@ -104,8 +104,8 @@
 
 // Pass and return an object with a non-trivial explicitly defaulted constructor
 // (passed directly, returned directly)
-// CHECK: define {{.*}} i64 @"?f6@@YA?AUS6@@XZ"()
-// CHECK: call i64 {{.*}}func6{{.*}}(i64 {{.*}})
+// CHECK: define {{.*}} i8 @"?f6@@YA?AUS6@@XZ"()
+// CHECK: call i8 {{.*}}func6{{.*}}(i64 {{.*}})
 struct S6a {
   S6a();
 };
@@ -123,8 +123,8 @@
 
 // Pass and return an object with a non-trivial implicitly defaulted constructor
 // (passed directly, returned directly)
-// CHECK: define {{.*}} i64 @"?f7@@YA?AUS7@@XZ"()
-// CHECK: call i64 {{.*}}func7{{.*}}(i64 {{.*}})
+// CHECK: define {{.*}} i8 @"?f7@@YA?AUS7@@XZ"()
+// CHECK: call i8 {{.*}}func7{{.*}}(i64 {{.*}})
 struct S7 {
   S6a x;
 };
Index: clang/test/CodeGen/arm64-arguments.c
===
--- clang/test/CodeGen/arm64-arguments.c
+++ clang/test/CodeGen/arm64-arguments.c
@@ -1,33 +1,41 @@
-// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple arm64-apple-ios7 -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-LE
+// RUN: %clang_cc1 -triple aarch64_be-none-linux-gnu -target-feature +neon -target-abi darwinpcs -ffreestanding -emit-llvm -w -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-BE
 
 // CHECK: define{{.*}} signext i8 @f0()
 char f0(void) {
   return 0;
 }
 
-// Struct as return type. Aggregates <= 16 bytes ar

[PATCH] D99488: [SYCL][Doc] Add address space handling section to SYCL documentation

2021-04-26 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 340526.
bader added a comment.

Rebased patch to unblock commit.

This patch had a dependency on D99190 , which 
adds SYCLSupport.rst document.
To unblock commit of D99488 , I switched the 
order of these two patches.
Now D99488  add SYCLSupport.rst document with 
just two sections: "Introduction" and "Address space handling".
D99190  will be rebased on top of D99488 
 to add more content to the document.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99488

Files:
  clang/docs/SYCLSupport.rst

Index: clang/docs/SYCLSupport.rst
===
--- /dev/null
+++ clang/docs/SYCLSupport.rst
@@ -0,0 +1,105 @@
+=
+SYCL Compiler and Runtime architecture design
+=
+
+.. contents::
+   :local:
+
+Introduction
+
+
+This document describes the architecture of the SYCL compiler and runtime
+library. More details are provided in 
+`external document `_\ ,
+which are going to be added to clang documentation in the future.
+
+Address space handling
+==
+
+The SYCL specification represents pointers to disjoint memory regions using C++
+wrapper classes on an accelerator to enable compilation with a standard C++
+toolchain and a SYCL compiler toolchain. Section 3.8.2 of SYCL 2020
+specification defines
+`memory model `_\ ,
+section 4.7.7 - `address space classes `_
+and section 5.9 covers `address space deduction `_.
+The SYCL specification allows two modes of address space deduction: "generic as
+default address space" (see section 5.9.3) and "inferred address space" (see
+section 5.9.4). Current implementation supports only "generic as default address
+space" mode.
+
+SYCL borrows its memory model from OpenCL however SYCL doesn't perform
+the address space qualifier inference as detailed in
+`OpenCL C v3.0 6.7.8 `_.
+
+The default address space is "generic-memory", which is a virtual address space
+that overlaps the global, local, and private address spaces. SYCL mode enables
+explicit conversions to/from the default address space from/to the address
+space-attributed type and implicit conversions from the address space-attributed
+type to the default address space. All named address spaces are disjoint and
+sub-sets of default address space.
+
+The SPIR target allocates SYCL namespace scope variables in the global address
+space.
+
+Pointers to default address space should get lowered into a pointer to a generic
+address space (or flat to reuse more general terminology). But depending on the
+allocation context, the default address space of a non-pointer type is assigned
+to a specific address space. This is described in
+`common address space deduction rules `_
+section.
+
+This is also in line with the behaviour of CUDA (`small example
+`_).
+
+``multi_ptr`` class implementation example:
+
+.. code-block:: C++
+
+   // check that SYCL mode is ON and we can use non-standard decorations
+   #if defined(__SYCL_DEVICE_ONLY__)
+   // GPU/accelerator implementation
+   template  class multi_ptr {
+ // DecoratedType applies corresponding address space attribute to the type T
+ // DecoratedType::type == "__attribute__((opencl_global)) T"
+ // See sycl/include/CL/sycl/access/access.hpp for more details
+ using pointer_t = typename DecoratedType::type *;
+
+ pointer_t m_Pointer;
+ public:
+ pointer_t get() { return m_Pointer; }
+ T& operator* () { return *reinterpret_cast(m_Pointer); }
+   }
+   #else
+   // CPU/host implementation
+   template  class multi_ptr {
+ T *m_Pointer; // regular undecorated pointer
+ public:
+ T *get() { return m_Pointer; }
+ T& operator* () { return *m_Pointer; }
+   }
+   #endif
+
+Depending on the compiler mode, ``multi_ptr`` will either decorate its internal
+data with the address space attribute or not.
+
+To utilize clang's existing functionality, we reuse the following OpenCL address
+space attributes for pointers:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Address space attribute
+ - SY

[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-26 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:4543
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  auto CheckTypeOK = [](QualType Ty) {
+if (Ty->isIncompleteType() || Ty->isUndeducedType())

hokein wrote:
> The current fix is on top of kadir's fix, now the code becomes more add-hoc, 
> it looks like a smell to me.
> 
> 
> It looks like `CheckArgAlignment` has an implicit invariant (the arg type 
> should never be undeduced), and this invariant was enforced by dropping the 
> invalid AST. Now with `RecoveryExpr`, we might break the invariant -- when 
> the RecoveryExpr preserves an `undeduced` type, like the test case in this 
> patch (which is done via the 
> [code](https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaExprCXX.cpp#L1420)).
> 
> 
> I think a right fix is to fix in the `RecoveryExpr` side, `RecoveryExpr` 
> should not preserve an undeduced type, we did it for function return type 
> already (https://reviews.llvm.org/D87350), but it didn't cover all places. I 
> think a general fixing place is `Sema::CreateRecoveryExpr`, if the passing 
> `T` is undeduced, fallback to dependent type.
> 
Ooh, interesting. Thanks for the info.

I updated the change to catch this in CreateRecoveryExpr as well. I kept my 
original changes too, they shouldn't harm anything and it's better than 
crashing.

Let me know what you think about this now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

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


[PATCH] D100667: [clang] Fix assert() crash when checking undeduced arg alignment

2021-04-26 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz updated this revision to Diff 340527.
adamcz added a comment.

Added a fix in CreateRecoveryExpr


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100667

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx17-undeduced-alignment.cpp


Index: clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+//
+// Verifies that clang no longer crashes on undeduced, sugared types.
+
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  // S(123) is undeduced, but when passed to foo() via bar() it is wrapped in
+  // SubstTemplateTypeParm, for which isUndeduced() is false.
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19661,8 +19661,13 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+  else if (const auto *U = T->getUnqualifiedDesugaredType())
+if (U->isUndeducedType())
+  T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,15 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  auto CheckTypeOK = [](QualType Ty) {
+if (Ty->isIncompleteType() || Ty->isUndeducedType())
+  return false;
+if (const auto *DesugaredTy = Ty->getUnqualifiedDesugaredType())
+  if (DesugaredTy->isIncompleteType() || DesugaredTy->isUndeducedType())
+return false;
+return true;
+  };
+  if (!CheckTypeOK(ParamTy) || !CheckTypeOK(ArgTy))
 return;
 
   CharUnits ParamAlign = Context.getTypeAlignInChars(ParamTy);


Index: clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx17-undeduced-alignment.cpp
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -std=c++17 -verify %s
+//
+// Verifies that clang no longer crashes on undeduced, sugared types.
+
+template  void foo(T &t);
+template 
+void bar(T t) {
+  foo(t);
+}
+
+template 
+struct S { // expected-note {{candidate}}
+  S(T t);  // expected-note {{candidate}}
+  ~S();
+};
+template  S(T t) -> S;
+
+void baz() {
+  // S(123) is undeduced, but when passed to foo() via bar() it is wrapped in
+  // SubstTemplateTypeParm, for which isUndeduced() is false.
+  bar(S(123)); // expected-error {{no matching conversion}}
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -19661,8 +19661,13 @@
   if (isSFINAEContext())
 return ExprError();
 
-  if (T.isNull() || !Context.getLangOpts().RecoveryASTType)
+  if (T.isNull() || T->isUndeducedType() ||
+  !Context.getLangOpts().RecoveryASTType)
 // We don't know the concrete type, fallback to dependent type.
 T = Context.DependentTy;
+  else if (const auto *U = T->getUnqualifiedDesugaredType())
+if (U->isUndeducedType())
+  T = Context.DependentTy;
+
   return RecoveryExpr::Create(Context, T, Begin, End, SubExprs);
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4540,8 +4540,15 @@
 
   // Find expected alignment, and the actual alignment of the passed object.
   // getTypeAlignInChars requires complete types
-  if (ParamTy->isIncompleteType() || ArgTy->isIncompleteType() ||
-  ParamTy->isUndeducedType() || ArgTy->isUndeducedType())
+  auto CheckTypeOK = [](QualType Ty) {
+if (Ty->isIncompleteType() || Ty->isUndeducedType())
+  return false;
+if (const auto *DesugaredTy = Ty->getUnqualifiedDesugaredType())
+  if (DesugaredTy->isIncompleteType() || DesugaredTy->isUndeducedType())
+return false;
+return true;
+  };
+  if (!CheckTypeOK(ParamTy) || !CheckTypeOK(ArgT

[PATCH] D100396: [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL

2021-04-26 Thread Alexey Bader via Phabricator via cfe-commits
bader updated this revision to Diff 340528.
bader added a comment.

Rebase on ToT


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100396

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Sema/ParsedAttr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/test/CodeGenSYCL/address-space-conversions.cpp
  clang/test/SemaSYCL/address-space-conversions.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388590)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388588)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x7FFFED>();
+  correct<0x7FFFEB>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/SemaSYCL/address-space-conversions.cpp
===
--- clang/test/SemaSYCL/address-space-conversions.cpp
+++ clang/test/SemaSYCL/address-space-conversions.cpp
@@ -61,4 +61,15 @@
   void *v = GLOB;
   (void)i;
   (void)v;
+
+  __attribute__((opencl_global_host)) int *GLOB_HOST;
+  bar(*GLOB_HOST);
+  bar2(*GLOB_HOST);
+  GLOB = GLOB_HOST;
+  GLOB_HOST = GLOB; // expected-error {{assigning '__global int *' to '__global_host int *' changes address space of pointer}}
+  __attribute__((opencl_global_device)) int *GLOB_DEVICE;
+  bar(*GLOB_DEVICE);
+  bar2(*GLOB_DEVICE);
+  GLOB = GLOB_DEVICE;
+  GLOB_DEVICE = GLOB; // expected-error {{assigning '__global int *' to '__global_device int *' changes address space of pointer}}
 }
Index: clang/test/CodeGenSYCL/address-space-conversions.cpp
===
--- clang/test/CodeGenSYCL/address-space-conversions.cpp
+++ clang/test/CodeGenSYCL/address-space-conversions.cpp
@@ -29,6 +29,10 @@
   // CHECK-DAG: [[PRIV:%[a-zA-Z0-9]+]] = alloca i32*
   // CHECK-DAG: [[PRIV]].ascast = addrspacecast i32** [[PRIV]] to i32* addrspace(4)*
   __attribute__((opencl_private)) int *PRIV;
+  // CHECK-DAG: [[GLOB_DEVICE:%[a-zA-Z0-9]+]] = alloca i32 addrspace(5)*
+  __attribute__((opencl_global_device)) int *GLOBDEVICE;
+  // CHECK-DAG: [[GLOB_HOST:%[a-zA-Z0-9]+]] = alloca i32 addrspace(6)*
+  __attribute__((opencl_global_host)) int *GLOBHOST;
 
   // Explicit conversions
   // From names address spaces to default address space
Index: clang/lib/Basic/Targets/X86.h
===
--- clang/lib/Basic/Targets/X86.h
+++ clang/lib/Basic/Targets/X86.h
@@ -36,6 +36,8 @@
 0,   // cuda_constant
 0,   // cuda_shared
 0,   // sycl_global
+0,   // sycl_global_device
+0,   // sycl_global_host
 0,   // sycl_local
 0,   // sycl_private
 270, // ptr32_sptr
Index: clang/lib/Basic/Targets/TCE.h
===
--- clang/lib/Basic/Targets/TCE.h
+++ clang/lib/Basic/Targets/TCE.h
@@ -42,8 +42,10 @@
 0, // cuda_device
 0, // cuda_constant
 0, // cuda_shared
-3, // sycl_global
-4, // sycl_local
+0, // sycl_global
+0, // sycl_global_device
+0, // sycl_global_host
+0, // sycl_local
 0, // sycl_private
 0, // ptr32_sptr
 0, // ptr32_uptr
Index: clang/lib/Basic/Targets/SPIR.h
===
--- clang/lib/Basic/Targets/SPIR.h
+++ clang/lib/Basic/Targets/SPIR.h
@@ -35,6 +35,8 @@
 0, // cuda_shared
 // SYCL address space values for this map are dummy
 0, // sycl_global
+0, // sycl_global_device
+0, // sycl_global_host
 0, // sycl_local
 0, // sycl_private
 0, // ptr32_sptr
@@ -56,6 +58,8 @@
 0, // cuda_constant
 0, // cuda_shared
 1, // sycl_global
+5, // sycl_global_device
+6, // sycl_global_host
 3, // sycl_local
 0, // sycl_private
 0, // ptr32_sptr
Index: clang/lib/Basic/Ta

[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

2021-04-26 Thread Florian Hahn via Phabricator via cfe-commits
fhahn added a comment.

Probably would be good to split this up in separate LLVM/Clang parts. Do we 
need to auto-upgrade calls to `llvm.powi`?




Comment at: llvm/docs/LangRef.rst:13280
+floating-point or vector of floating-point type. The type of the exponent
+should typically match the size of ``int``, at least when the intrinsic maps
+to one of the ``__powi*`` functions in compiler-rt. Not all targets support

Not sure about the sentence about the size of the exponent. It refers to `int` 
and `__powi`, both of which are not really defined in the LangRef and it is not 
clear to what they are referring to here.



Comment at: llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp:573
   unsigned Offset = IsStrict ? 1 : 0;
-  assert(N->getOperand(1 + Offset).getValueType() == MVT::i32 &&
+  assert((N->getOperand(1 + Offset).getValueType() == MVT::i16 ||
+  N->getOperand(1 + Offset).getValueType() == MVT::i32) &&

Why just allow i32 and i16 here?

Could we restrict the supported offset types to i32 or smaller?



Comment at: llvm/test/Transforms/InstCombine/pow_fp_int16.ll:1
-; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -mtriple unknown -instcombine -S < %s | FileCheck %s
+; RUN: opt -mtriple msp430 -instcombine -S < %s | FileCheck %s
 

I don't think we can rely on any specific triple here. If a triple is needed it 
should be in a sub-directory.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

2021-04-26 Thread Bjorn Pettersson via Phabricator via cfe-commits
bjope added a comment.

Ping!

(This patch is now 1 month old, has a number of reviewers and 41 subscribers, 
but not a single comment yet. I believe that if you aren't comfortable with 
reviewing, then it is perfectly OK to remove yourself as reveiwer to let the 
author know that the original set of reviewers was wrong. But this "silent 
treatment" is really painful.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D99439: Update @llvm.powi to handle different int sizes for the exponent

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

I think 16 bit int is same story as non 8-bit byte.

There are places where we check for 32. Hard to say how many, what is the real 
scope of thiw change.

if we allow 16bit int in upstream LLVM, we will just open door for non 8-bit 
byte..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99439

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


[PATCH] D98895: [X86][Draft] Disable long double type for -mno-x87 option

2021-04-26 Thread Andrew Savonichev via Phabricator via cfe-commits
asavonic added a comment.

The option was added in D19658  and D13979 
, but I'm not sure how it is supposed to work 
for SystemV ABI.
GCC emits an error if long double type is used with -mno-x87: "test.c:37:1: 
error: x87 register return with x87 disabled".

Added reviewers of the original patches. Please let me know if this patch makes 
sense, or we should do something else to avoid the crash.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D98895

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


[PATCH] D99488: [SYCL][Doc] Add design document for SYCL mode

2021-04-26 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D99488#2716768 , @bader wrote:

> Rebased patch to unblock commit.
>
> This patch had a dependency on D99190 , 
> which adds SYCLSupport.rst document.
> To unblock commit of D99488 , I switched the 
> order of these two patches.
> Now D99488  add SYCLSupport.rst document 
> with just two sections: "Introduction" and "Address space handling".
> D99190  will be rebased on top of D99488 
>  to add more content to the document.

Makes sense. LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99488

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


[PATCH] D100673: [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.

2021-04-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D100673#2714087 , @jdoerfert wrote:

> I think this broke GridMini (https://github.com/meifeng/GridMini/tree/openmp) 
> :(

Hmm, this app does not use mappers. Are you sure that this commit is the actual 
cause of the problem? Also, could you provide detailed debug log for the 
investigation (with LIBOMPTARGET_DEBUG set)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100673

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


[clang] b52e69c - [SYCL][Doc] Add design document for SYCL mode

2021-04-26 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2021-04-26T15:39:43+03:00
New Revision: b52e69c4268181d8143fe49aee0ea85395c8737d

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

LOG: [SYCL][Doc] Add design document for SYCL mode

Initial version of the document covers address space handling

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

Added: 
clang/docs/SYCLSupport.rst

Modified: 


Removed: 




diff  --git a/clang/docs/SYCLSupport.rst b/clang/docs/SYCLSupport.rst
new file mode 100644
index ..8c1ed19dff4e
--- /dev/null
+++ b/clang/docs/SYCLSupport.rst
@@ -0,0 +1,105 @@
+=
+SYCL Compiler and Runtime architecture design
+=
+
+.. contents::
+   :local:
+
+Introduction
+
+
+This document describes the architecture of the SYCL compiler and runtime
+library. More details are provided in
+`external document 
`_\
 ,
+which are going to be added to clang documentation in the future.
+
+Address space handling
+==
+
+The SYCL specification represents pointers to disjoint memory regions using C++
+wrapper classes on an accelerator to enable compilation with a standard C++
+toolchain and a SYCL compiler toolchain. Section 3.8.2 of SYCL 2020
+specification defines
+`memory model 
`_\
 ,
+section 4.7.7 - `address space classes 
`_
+and section 5.9 covers `address space deduction 
`_.
+The SYCL specification allows two modes of address space deduction: "generic as
+default address space" (see section 5.9.3) and "inferred address space" (see
+section 5.9.4). Current implementation supports only "generic as default 
address
+space" mode.
+
+SYCL borrows its memory model from OpenCL however SYCL doesn't perform
+the address space qualifier inference as detailed in
+`OpenCL C v3.0 6.7.8 
`_.
+
+The default address space is "generic-memory", which is a virtual address space
+that overlaps the global, local, and private address spaces. SYCL mode enables
+explicit conversions to/from the default address space from/to the address
+space-attributed type and implicit conversions from the address 
space-attributed
+type to the default address space. All named address spaces are disjoint and
+sub-sets of default address space.
+
+The SPIR target allocates SYCL namespace scope variables in the global address
+space.
+
+Pointers to default address space should get lowered into a pointer to a 
generic
+address space (or flat to reuse more general terminology). But depending on the
+allocation context, the default address space of a non-pointer type is assigned
+to a specific address space. This is described in
+`common address space deduction rules 
`_
+section.
+
+This is also in line with the behaviour of CUDA (`small example
+`_).
+
+``multi_ptr`` class implementation example:
+
+.. code-block:: C++
+
+   // check that SYCL mode is ON and we can use non-standard decorations
+   #if defined(__SYCL_DEVICE_ONLY__)
+   // GPU/accelerator implementation
+   template  class multi_ptr {
+ // DecoratedType applies corresponding address space attribute to the 
type T
+ // DecoratedType::type == 
"__attribute__((opencl_global)) T"
+ // See sycl/include/CL/sycl/access/access.hpp for more details
+ using pointer_t = typename DecoratedType::type *;
+
+ pointer_t m_Pointer;
+ public:
+ pointer_t get() { return m_Pointer; }
+ T& operator* () { return *reinterpret_cast(m_Pointer); }
+   }
+   #else
+   // CPU/host implementation
+   template  class multi_ptr {
+ T *m_Pointer; // regular undecorated pointer
+ public:
+ T *get() { return m_Pointer; }
+ T& operator* () { return *m_Pointer; }
+   }
+   #endif
+
+Depending on the compiler mode, ``multi_ptr`` will either decorate its internal
+data with the address space attribute or not.
+
+To utilize clang's existing functionality, we reuse the following OpenCL 
address
+space attributes for pointers:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Address space attribute
+ - SYCL address_space enumeration
+   * - ``__attribute__((opencl_global))``
+ - global_space, constant_space
+   * - ``__attr

[PATCH] D99488: [SYCL][Doc] Add design document for SYCL mode

2021-04-26 Thread Alexey Bader via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb52e69c42681: [SYCL][Doc] Add design document for SYCL mode 
(authored by bader).

Changed prior to commit:
  https://reviews.llvm.org/D99488?vs=340526&id=340538#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99488

Files:
  clang/docs/SYCLSupport.rst

Index: clang/docs/SYCLSupport.rst
===
--- /dev/null
+++ clang/docs/SYCLSupport.rst
@@ -0,0 +1,105 @@
+=
+SYCL Compiler and Runtime architecture design
+=
+
+.. contents::
+   :local:
+
+Introduction
+
+
+This document describes the architecture of the SYCL compiler and runtime
+library. More details are provided in
+`external document `_\ ,
+which are going to be added to clang documentation in the future.
+
+Address space handling
+==
+
+The SYCL specification represents pointers to disjoint memory regions using C++
+wrapper classes on an accelerator to enable compilation with a standard C++
+toolchain and a SYCL compiler toolchain. Section 3.8.2 of SYCL 2020
+specification defines
+`memory model `_\ ,
+section 4.7.7 - `address space classes `_
+and section 5.9 covers `address space deduction `_.
+The SYCL specification allows two modes of address space deduction: "generic as
+default address space" (see section 5.9.3) and "inferred address space" (see
+section 5.9.4). Current implementation supports only "generic as default address
+space" mode.
+
+SYCL borrows its memory model from OpenCL however SYCL doesn't perform
+the address space qualifier inference as detailed in
+`OpenCL C v3.0 6.7.8 `_.
+
+The default address space is "generic-memory", which is a virtual address space
+that overlaps the global, local, and private address spaces. SYCL mode enables
+explicit conversions to/from the default address space from/to the address
+space-attributed type and implicit conversions from the address space-attributed
+type to the default address space. All named address spaces are disjoint and
+sub-sets of default address space.
+
+The SPIR target allocates SYCL namespace scope variables in the global address
+space.
+
+Pointers to default address space should get lowered into a pointer to a generic
+address space (or flat to reuse more general terminology). But depending on the
+allocation context, the default address space of a non-pointer type is assigned
+to a specific address space. This is described in
+`common address space deduction rules `_
+section.
+
+This is also in line with the behaviour of CUDA (`small example
+`_).
+
+``multi_ptr`` class implementation example:
+
+.. code-block:: C++
+
+   // check that SYCL mode is ON and we can use non-standard decorations
+   #if defined(__SYCL_DEVICE_ONLY__)
+   // GPU/accelerator implementation
+   template  class multi_ptr {
+ // DecoratedType applies corresponding address space attribute to the type T
+ // DecoratedType::type == "__attribute__((opencl_global)) T"
+ // See sycl/include/CL/sycl/access/access.hpp for more details
+ using pointer_t = typename DecoratedType::type *;
+
+ pointer_t m_Pointer;
+ public:
+ pointer_t get() { return m_Pointer; }
+ T& operator* () { return *reinterpret_cast(m_Pointer); }
+   }
+   #else
+   // CPU/host implementation
+   template  class multi_ptr {
+ T *m_Pointer; // regular undecorated pointer
+ public:
+ T *get() { return m_Pointer; }
+ T& operator* () { return *m_Pointer; }
+   }
+   #endif
+
+Depending on the compiler mode, ``multi_ptr`` will either decorate its internal
+data with the address space attribute or not.
+
+To utilize clang's existing functionality, we reuse the following OpenCL address
+space attributes for pointers:
+
+.. list-table::
+   :header-rows: 1
+
+   * - Address space attribute
+ - SYCL address_space enumeration
+   * - ``__attribute__((opencl_global))``
+ - global_space, constant_space
+   * - ``__attribute__((opencl_local))``
+ - local_space
+   * - ``__attribute__((opencl_private))``
+ - private_space
+
+
+.. code-block::
+
+   TODO: add support for `__attribut

[PATCH] D100673: [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.

2021-04-26 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D100673#2716916 , @ABataev wrote:

> In D100673#2714087 , @jdoerfert 
> wrote:
>
>> I think this broke GridMini 
>> (https://github.com/meifeng/GridMini/tree/openmp) :(
>
> Hmm, this app does not use mappers. Are you sure that this commit is the 
> actual cause of the problem? Also, could you provide detailed debug log for 
> the investigation (with LIBOMPTARGET_DEBUG set)?

I did debug something else and the clang-omp branch failed until I reverted 
this branch, at least that is what I thought. I will look again as soon as I 
find the time. For sure it run fine until very recently and we should make sure 
it continues to do so ;)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100673

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


[PATCH] D100673: [OPENMP]Fix PR49698: OpenMP declare mapper causes segmentation fault.

2021-04-26 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D100673#2716929 , @jdoerfert wrote:

> In D100673#2716916 , @ABataev wrote:
>
>> In D100673#2714087 , @jdoerfert 
>> wrote:
>>
>>> I think this broke GridMini 
>>> (https://github.com/meifeng/GridMini/tree/openmp) :(
>>
>> Hmm, this app does not use mappers. Are you sure that this commit is the 
>> actual cause of the problem? Also, could you provide detailed debug log for 
>> the investigation (with LIBOMPTARGET_DEBUG set)?
>
> I did debug something else and the clang-omp branch failed until I reverted 
> this patch, at least that is what I thought. I will look again as soon as I 
> find the time. For sure it run fine until very recently and we should make 
> sure it continues to do so ;)

Definitely! That's why I'm asking for the debug log for the investigation. It 
requires CUDA but I don't have an access to the machine with cuda.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100673

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


[PATCH] D100839: [analyzer] Adjust the reported variable name in retain count checker

2021-04-26 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 340544.
vsavchenko added a comment.

Add test for the case when there are no good alternatives


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100839

Files:
  
clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp
  clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.h
  clang/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release-path-notes.m.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
  clang/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
  clang/test/Analysis/osobject-retain-release.cpp
  clang/test/Analysis/retain-release-path-notes.m
  clang/test/Analysis/retain-release.m

Index: clang/test/Analysis/retain-release.m
===
--- clang/test/Analysis/retain-release.m
+++ clang/test/Analysis/retain-release.m
@@ -2282,7 +2282,7 @@
 
 void testAutoreleaseReturnsInput() {
   extern CFTypeRef CFCreateSomething();
-  CFTypeRef obj = CFCreateSomething(); // expected-warning{{Potential leak of an object stored into 'obj'}}
+  CFTypeRef obj = CFCreateSomething(); // expected-warning{{Potential leak of an object stored into 'second'}}
   CFTypeRef second = CFAutorelease(obj);
   CFRetain(second);
 }
@@ -2302,7 +2302,7 @@
 }
 
 void autoreleaseReturningTypedObject() {
-  CFArrayRef arr = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Potential leak of an object stored into 'arr'}}
+  CFArrayRef arr = CFArrayCreateMutable(0, 10, &kCFTypeArrayCallBacks); // expected-warning{{Potential leak of an object stored into 'alias'}}
   CFArrayRef alias = (CFArrayRef)CFAutorelease((CFTypeRef)arr);
   CFRetain(alias);
 }
Index: clang/test/Analysis/retain-release-path-notes.m
===
--- clang/test/Analysis/retain-release-path-notes.m
+++ clang/test/Analysis/retain-release-path-notes.m
@@ -212,7 +212,7 @@
 }
 
 -(id)initY {
-  self = [super init]; //expected-note {{Method returns an instance of MyObj with a +1 retain count}}
+  self = [super init]; // expected-note 6 {{Method returns an instance of MyObj with a +1 retain count}}
   return self;
 }
 
@@ -327,5 +327,74 @@
 
 @end
 
+int seed();
 
+@interface LeakReassignmentTests : MyObj
+@end
+
+@implementation LeakReassignmentTests
++(void)testLeakAliasSimple {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  id New = Original;
+  Original = [[MyObj alloc] initZ];
+  (void)New;
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'New' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)testLeakAliasChain {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  id Intermediate = Original;
+  id New = Intermediate;
+  Original = [[MyObj alloc] initZ];
+  (void)New;
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'New' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)log:(id)Obj with:(int)Num {
+  Num *= 42;
+  if (Obj )
+Num /= 2;
+}
+
++(int)calculate {
+  int x = 10;
+  int y = 25;
+  x += y * x + seed();
+  return y - x * y;
+}
+
++(void)testLeakAliasDeathInExpr {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  id New = Original;
+  Original = [[MyObj alloc] initZ];
+  [self log:New with:[self calculate]];
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'New'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'New' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)testLeakReassign {
+  id Original = [[MyObj alloc] initY]; // expected-note {{Calling 'initY'}}
+   // expected-note@-1 {{Returning from 'initY'}}
+  // TODO: move warning here
+  Original = [[MyObj alloc] initZ];
+  [Original release]; // expected-warning {{Potential leak of an object stored into 'Original'}}
+  // expected-note@-1 {{Object leaked: object allocated and stored into 'Original' is not referenced later in this execution path and has a retain count of +1}}
+}
+
++(void)testLeakReassign:(int)cond {
+  id Or

[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-04-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@vsavchenko 
I make some tests and fixes. Please, consider.




Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:458
   }
   if (event.key == "S") {
 var checked = document.getElementsByName("showCounterexample")[0].checked;

vsavchenko wrote:
> ASDenysPetrov wrote:
> > Seems like this shortcut works only with the capital **S** aka //shift+s//
> > Should we support any **s** state?
> As far as I understand, that matches the original intention because the help 
> message mentions exactly "Shift+S"
> {F15355624}
I've checked again.
When CapsLock is ON, `shift+s` has no effect, but single `s` has. The same vice 
versa.
The real issue is that we check for **capital s** instead of **shift+s**.
This change will handle it correctly. I've checked it on IE and Chrome. It 
works for me.



Comment at: clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp:1275-1278
+left: relative.left + window.scrollX,
+right: relative.right + window.scrollX,
+top: relative.top + window.scrollY,
+bottom: relative.bottom + window.scrollY,

This is the root cause of why I wasn't able to see arrows in IE11.
I found and checked a fix. It works on IE and Chrome. Thanks to 
https://github.com/imgix/drift/issues/33#issue-165784939



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

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


[PATCH] D99079: [ARM][AArch64] Require appropriate features for crypto algorithms

2021-04-26 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

LGTM. Please give the other reviewers time to chime in about this patch before 
merging.


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

https://reviews.llvm.org/D99079

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


[PATCH] D89055: [analyzer] Wrong type cast occures during pointer dereferencing after type punning

2021-04-26 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

@NoQ,  @steakhal, @vsavchenko 
I think we have met all the conditions with previous patchs to make this patch 
acceptable.
If you think it's OK, could you, please, approve it?


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

https://reviews.llvm.org/D89055

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


[clang] b2bb13a - [Doc] Add SYCLSupport.rst to index toctree.

2021-04-26 Thread Alexey Bader via cfe-commits

Author: Alexey Bader
Date: 2021-04-26T16:16:10+03:00
New Revision: b2bb13a761644f675ec9f2d0b4371c51a05ab51c

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

LOG: [Doc] Add SYCLSupport.rst to index toctree.

Added: 


Modified: 
clang/docs/index.rst

Removed: 




diff  --git a/clang/docs/index.rst b/clang/docs/index.rst
index a3a76c073b99..149f5680b333 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -43,6 +43,7 @@ Using Clang as a Compiler
MSVCCompatibility
OpenCLSupport
OpenMPSupport
+   SYCLSupport
ThinLTO
APINotes
CommandGuide/index



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


[PATCH] D100499: [AArch64] Neon Polynomial vadd Intrinsic Fix

2021-04-26 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic abandoned this revision.
rsanthir.quic added a comment.

Merging with https://reviews.llvm.org/D100772


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

https://reviews.llvm.org/D100499

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


[PATCH] D100772: [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-26 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic marked an inline comment as done.
rsanthir.quic added inline comments.



Comment at: clang/include/clang/Basic/arm_neon.td:712
+
+// Crypto
+// TODO: poly128_t not implemented on aarch32

DavidSpickett wrote:
> This isn't a crypto intrinsic, it just happens to be right after a block like:
> ```
> let ArchGuard = "__ARM_ARCH >= 8 && defined(__ARM_FEATURE_CRYPTO)" in {
> <...>
> def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;
> }
> ```
> 
> You could instead say:
> ```
> // Non poly128_t vaddp for Arm and AArch64
> ```
> (keep the todo)
I agree that it isn't strictly crypto, I think it is used primarily for 
cryptographic applications. I'll apply your suggestion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100772

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


[PATCH] D100772: [ARM] Neon Polynomial vadd Intrinsic fix

2021-04-26 Thread Ryan Santhirarajan via Phabricator via cfe-commits
rsanthir.quic updated this revision to Diff 340567.
rsanthir.quic marked an inline comment as done.
rsanthir.quic added a comment.

minor fixes and merged https://reviews.llvm.org/D100499


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

https://reviews.llvm.org/D100772

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/arm-poly-add.c

Index: clang/test/CodeGen/arm-poly-add.c
===
--- /dev/null
+++ clang/test/CodeGen/arm-poly-add.c
@@ -0,0 +1,86 @@
+// REQUIRES: arm-registered-target
+// RUN: %clang_cc1 -triple armv8.2a-arm-none-eabi \
+// RUN:   -target-feature +neon \
+// RUN:   -mfloat-abi hard \
+// RUN: -disable-O0-optnone -emit-llvm -o - %s | opt -S -mem2reg \
+// RUN:  | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @test_vadd_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <8 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <8 x i8> [[TMP0]]
+//
+poly8x8_t test_vadd_p8(poly8x8_t a, poly8x8_t b) {
+  return vadd_p8 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <4 x i16> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <4 x i16> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <4 x i16>
+// CHECK-NEXT:ret <4 x i16> [[TMP3]]
+//
+poly16x4_t test_vadd_p16(poly16x4_t a, poly16x4_t b) {
+  return vadd_p16 (a, b);
+}
+
+// CHECK-LABEL: @test_vadd_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <1 x i64> [[A:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <1 x i64> [[B:%.*]] to <8 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <8 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <8 x i8> [[TMP2]] to <1 x i64>
+// CHECK-NEXT:ret <1 x i64> [[TMP3]]
+//
+poly64x1_t test_vadd_p64(poly64x1_t a, poly64x1_t b) {
+  return vadd_p64(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p8(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = xor <16 x i8> [[A:%.*]], [[B:%.*]]
+// CHECK-NEXT:ret <16 x i8> [[TMP0]]
+//
+poly8x16_t test_vaddq_p8(poly8x16_t a, poly8x16_t b){
+  return vaddq_p8(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p16(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <8 x i16> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <8 x i16> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <8 x i16>
+// CHECK-NEXT:ret <8 x i16> [[TMP3]]
+//
+poly16x8_t test_vaddq_p16(poly16x8_t a, poly16x8_t b){
+  return vaddq_p16(a, b);
+}
+
+// CHECK-LABEL: @test_vaddq_p64(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = bitcast <2 x i64> [[A:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP1:%.*]] = bitcast <2 x i64> [[B:%.*]] to <16 x i8>
+// CHECK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHECK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to <2 x i64>
+// CHECK-NEXT:ret <2 x i64> [[TMP3]]
+//
+poly64x2_t test_vaddq_p64(poly64x2_t a, poly64x2_t b){
+  return vaddq_p64(a, b);
+}
+
+// TODO: poly128_t not implemented on aarch32
+// CHCK-LABEL: @test_vaddq_p128(
+// CHCK-NEXT:  entry:
+// CHCK-NEXT:[[TMP0:%.*]] = bitcast i128 [[A:%.*]] to <16 x i8>
+// CHCK-NEXT:[[TMP1:%.*]] = bitcast i128 [[B:%.*]] to <16 x i8>
+// CHCK-NEXT:[[TMP2:%.*]] = xor <16 x i8> [[TMP0]], [[TMP1]]
+// CHCK-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP2]] to i128
+// CHCK-NEXT:ret i128 [[TMP3]]
+//
+//poly128_t test_vaddq_p128 (poly128_t a, poly128_t b){
+//  return vaddq_p128(a, b);
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -5460,7 +5460,6 @@
   NEONMAP1(vabsq_v, arm_neon_vabs, 0),
   NEONMAP0(vadd_v),
   NEONMAP0(vaddhn_v),
-  NEONMAP0(vaddq_p128),
   NEONMAP0(vaddq_v),
   NEONMAP1(vaesdq_v, arm_neon_aesd, 0),
   NEONMAP1(vaeseq_v, arm_neon_aese, 0),
Index: clang/include/clang/Basic/arm_neon.td
===
--- clang/include/clang/Basic/arm_neon.td
+++ clang/include/clang/Basic/arm_neon.td
@@ -708,6 +708,11 @@
 def SCALAR_HALF_GET_LANEQ : IOpInst<"vget_lane", "1.I", "Qh", OP_SCALAR_HALF_GET_LNQ>;
 def SCALAR_HALF_SET_LANEQ : IOpInst<"vset_lane", ".1.I", "Qh", OP_SCALAR_HALF_SET_LNQ>;
 
+
+// Non poly128_t vaddp for Arm and AArch64
+// TODO: poly128_t not implemented on arm32
+def VADDP   : WInst<"vadd", "...", "PcPsPlQPcQPsQPl">;
+
 
 // AArch64 Intrinsics
 
@@ -1160,7 +1165,9 @@
 def SM4EKEY : SInst<"vsm4ekey", "...", "QUi">;

[PATCH] D86169: Initial support for letting plugins perform custom parsing of attribute arguments.

2021-04-26 Thread Jonathan Protzenko via Phabricator via cfe-commits
jonathan.protzenko added a comment.

I'm responding here after a ping on Bugzilla. The short version is I've stopped 
working on this patch. While I like the revised design that involves storing a 
list of tokens to make plugins even more powerful, this turned out to be a much 
bigger implementation effort than I initially anticipated. I was unable to find 
help or additional resources for this work at Microsoft; the internal project 
that might have benefited from this work turned out to not need it *that* bad 
after all. So, regrettably, that meant there was little incentive left for me 
to pursue this patch.

I'll keep monitoring this as well as Bugzilla for discussions, and I'll provide 
information/context on design in whichever way that I can. Thanks again Aaron 
for all your precious help throughout these discussions -- without your 
guidance I probably wouldn't have gotten anywhere at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86169

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


[PATCH] D92639: [analyzer] Add control flow arrows to the analyzer's HTML reports

2021-04-26 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D92639#2716973 , @ASDenysPetrov 
wrote:

> @vsavchenko 
> I make some tests and fixes. Please, consider.

OMG, that's so awesome! Thank you so much!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92639

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


[PATCH] D100581: [Clang] -Wunused-but-set-parameter and -Wunused-but-set-variable

2021-04-26 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

I can land this for you, but could you update the description to be a bit more 
descriptive? Explaining what the warnings do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100581

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


[clang] 91db11c - XFAIL thinlto testcases on AIX

2021-04-26 Thread Wael Yehia via cfe-commits

Author: Wael Yehia
Date: 2021-04-26T17:02:06Z
New Revision: 91db11c98db5de3e6079bddc0aba896ec3d3d0ad

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

LOG: XFAIL thinlto testcases on AIX

In D100350, we switched off thinLTO on the AIX OS. So, XFAIL tests that
invoke clang with -flto=thin on AIX.

Added: 


Modified: 
clang/test/CodeGen/thinlto-backend-option.ll
clang/test/CodeGen/thinlto-emit-llvm.c
clang/test/Driver/thinlto_backend.c
clang/test/Integration/thinlto_profile_sample_accurate.c

Removed: 




diff  --git a/clang/test/CodeGen/thinlto-backend-option.ll 
b/clang/test/CodeGen/thinlto-backend-option.ll
index b25b584a2fe1..556aaf9fad22 100644
--- a/clang/test/CodeGen/thinlto-backend-option.ll
+++ b/clang/test/CodeGen/thinlto-backend-option.ll
@@ -6,6 +6,8 @@
 ; scenario independent of any particular backend options that may exist now or
 ; in the future.
 
+; XFAIL: aix
+
 ; RUN: %clang -flto=thin -c -o %t.o %s
 ; RUN: llvm-lto -thinlto -o %t %t.o
 ; RUN: not %clang_cc1 -x ir %t.o -fthinlto-index=%t.thinlto.bc -mllvm 
-nonexistent -emit-obj -o /dev/null 2>&1 | FileCheck %s -check-prefix=UNKNOWN

diff  --git a/clang/test/CodeGen/thinlto-emit-llvm.c 
b/clang/test/CodeGen/thinlto-emit-llvm.c
index d6ef6650243e..dc46ae78e9b8 100644
--- a/clang/test/CodeGen/thinlto-emit-llvm.c
+++ b/clang/test/CodeGen/thinlto-emit-llvm.c
@@ -1,3 +1,5 @@
+// XFAIL: aix
+
 // Test to ensure -emit-llvm and -emit-llvm-bc work when invoking the
 // ThinLTO backend path.
 // RUN: %clang -O2 %s -flto=thin -c -o %t.o

diff  --git a/clang/test/Driver/thinlto_backend.c 
b/clang/test/Driver/thinlto_backend.c
index 7a3d6ede7c0d..64f0a7bf6785 100644
--- a/clang/test/Driver/thinlto_backend.c
+++ b/clang/test/Driver/thinlto_backend.c
@@ -1,3 +1,5 @@
+// XFAIL: aix
+
 // RUN: %clang -O2 %s -flto=thin -c -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o
 

diff  --git a/clang/test/Integration/thinlto_profile_sample_accurate.c 
b/clang/test/Integration/thinlto_profile_sample_accurate.c
index ac7274cee2d2..b756829439cf 100644
--- a/clang/test/Integration/thinlto_profile_sample_accurate.c
+++ b/clang/test/Integration/thinlto_profile_sample_accurate.c
@@ -1,3 +1,5 @@
+// XFAIL: aix
+
 // Test to ensure -emit-llvm profile-sample-accurate is honored in ThinLTO.
 // RUN: %clang -O2 %s -flto=thin -fprofile-sample-accurate -c -o %t.o
 // RUN: llvm-lto -thinlto -o %t %t.o



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


[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-26 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yes, if you can dynamically choose to use an aligned allocator, that's clearly 
just much better.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100739

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-26 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

This change appears to be the injection point for 
https://bugs.llvm.org/show_bug.cgi?id=50128 -- trying to build clang-tblgen 
after this change crashes VC2019 if targeting 32-bit Windows (see below). While 
this is likely an MSVC bug, I presume we still want to support crosscompiling 
for 32-bit  Windows?

  [2220/3953] Building CXX object 
tools\clang\utils\TableGen\CMakeFiles\clang-tblgen.dir\ClangOpenCLBuiltinEmitter.cpp.obj
  FAILED: 
tools/clang/utils/TableGen/CMakeFiles/clang-tblgen.dir/ClangOpenCLBuiltinEmitter.cpp.obj
 
  
C:\PROGRA~2\MICROS~2\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx64\x86\cl.exe
  /nologo /TP -DCLANG_ROUND_TRIP_CC1_ARGS=ON -DUNICODE 
-D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS 
-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_FILE_OFFSET_BITS=64 
-D_GNU_SOURCE -D_HAS_EXCEPTIONS=0 -D_LARGEFILE_SOURCE 
-D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Itools\clang\utils\TableGen 
-IC:\code\build_bot\worker\llvm-13-x86-32-windows\llvm-project\clang\utils\TableGen
 -IC:\code\build_bot\worker\llvm-13-x86-32-windows\llvm-project\clang\include 
-Itools\clang\include -Iinclude 
-IC:\code\build_bot\worker\llvm-13-x86-32-windows\llvm-project\llvm\include 
/DWIN32 /D_WINDOWS   /Zc:inline /Zc:__cplusplus /Zc:strictStrings /Oi 
/Zc:rvalueCast /bigobj /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 
-wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 
-wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 
-wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd4324 -w14062 
-we4238 /Gw /MD /O2 /Ob2  /EHs-c- /GR -UNDEBUG -std:c++14 /showIncludes 
/Fotools\clang\utils\TableGen\CMakeFiles\clang-tblgen.dir\ClangOpenCLBuiltinEmitter.cpp.obj
 /Fdtools\clang\utils\TableGen\CMakeFiles\clang-tblgen.dir\ /FS -c 
C:\code\build_bot\worker\llvm-13-x86-32-windows\llvm-project\clang\utils\TableGen\ClangOpenCLBuiltinEmitter.cpp
  
C:\code\build_bot\worker\llvm-13-x86-32-windows\llvm-project\clang\utils\TableGen\ClangOpenCLBuiltinEmitter.cpp(514)
 : fatal error C1001: Internal compiler error.
  (compiler file 'd:\A01\_work\3\s\src\vctools\Compiler\Utc\src\p2\main.c', 
line 212)
   To work around this problem, try simplifying or changing the program near 
the locations listed above.
  If possible please provide a repro here: 
https://developercommunity.visualstudio.com 
  Please choose the Technical Support command on the Visual C++ 
   Help menu, or open the Technical Support help file for more information
cl!RaiseException()+0x69
cl!RaiseException()+0x69
cl!CloseTypeServerPDB()+0x22ebf
cl!CloseTypeServerPDB()+0xedea9


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-26 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D100492#2717232 , @srj wrote:

> This change appears to be the injection point for 
> https://bugs.llvm.org/show_bug.cgi?id=50128 -- trying to build clang-tblgen 
> after this change crashes VC2019 if targeting 32-bit Windows (see below). 
> While this is likely an MSVC bug, I presume we still want to support 
> crosscompiling for 32-bit  Windows?

I am happy to make/accept any adjustments to this patch to fix the particular 
build.  I don't have access to MSVC though, would you be able to help figure 
out what the problematic construct in my patch was?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D100739: [Coroutines] Handle overaligned frame allocation (2)

2021-04-26 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D100739#2717227 , @rjmccall wrote:

> Yes, if you can dynamically choose to use an aligned allocator, that's 
> clearly just much better.

Right now:

Intrinsic::coro_size_aligned :   overaligned frame: over-allocate, adjust start 
address;non-overaligned frame: no-op
Intrinsic::coro_size :overaligned frame: no-op; 
non-overaligned frame: no-op

Do you mean to remove `Intrinsic::coro_size_aligned` and make 
Intrinsic::coro_size :overaligned frame: over-allocate, adjust 
start address;non-overaligned frame: no-op

that makes sense to me. Just want to confirm first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100739

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-26 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

From experimentation, it appears that just pulling the MinVersion and 
MaxVersion expressions from `BuiltinNameEmitter::EmitBuiltinTable` into 
separate statements will pacify MSVC, e.g.

  auto MinVersion = 
Overload.first->getValueAsDef("MinVersion")->getValueAsInt("ID");
  auto MaxVersion = 
Overload.first->getValueAsDef("MaxVersion")->getValueAsInt("ID");
  OS << "  { " << Overload.second << ", "
 << Overload.first->getValueAsListOfDefs("Signature").size() << ", "
 << (Overload.first->getValueAsBit("IsPure")) << ", "
 << (Overload.first->getValueAsBit("IsConst")) << ", "
 << (Overload.first->getValueAsBit("IsConv")) << ", "
 << FunctionExtensionIndex[ExtName] << ", "
 << MinVersion 
 << ", "
 << MaxVersion 
 << " },\n";


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-26 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

(This is clearly just a weird bug on MSVC's part; there's nothing about the 
code here that seems obviously unreasonable or complex. Working around compiler 
bugs is a thing, alas.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D45639: [Driver] Support default libc++ library location on Darwin

2021-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added a comment.

In D45639#2713196 , @phosek wrote:

> FYI I had to revert this change again because it broke ubsan build. The 
> problem is that ubsan for Darwin is built as universal shared library and it 
> links against libc++abi, but we currently don't support building libc++ and 
> libc++abi as universal binaries in the runtimes build. That's something we'll 
> need to address first before we can reland this change. I expect that if we 
> resolve that issue, it would also address the lldb use case although it 
> sounds like that's no longer an issue.

@phosek we also hit this problem downstream, but decided that we should just 
stop building libcxx alongside clang in our CI jobs, and have separate jobs for 
it. The compiler-rt build should use libcxx headers and library from the SDK 
(Xcode 12.5 should have libcxx headers in the SDKs now). Do you think this 
would be a feasible solution for you as well?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D45639

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


[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.

2021-04-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/test/CodeGen/unique-internal-linkage-names-dwarf.c:34-39
+static int go(a) int a;
+{
+  return glob + a;
+}
+
+

dblaikie wrote:
> hoy wrote:
> > dblaikie wrote:
> > > hoy wrote:
> > > > dblaikie wrote:
> > > > > hoy wrote:
> > > > > > dblaikie wrote:
> > > > > > > hoy wrote:
> > > > > > > > dblaikie wrote:
> > > > > > > > > hoy wrote:
> > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > hoy wrote:
> > > > > > > > > > > > dblaikie wrote:
> > > > > > > > > > > > > Does this need to be down here? Or would the code be 
> > > > > > > > > > > > > a well exercised if it was up next to the go 
> > > > > > > > > > > > > declaration above?
> > > > > > > > > > > > Yes, it needs to be here. Otherwise it will just like 
> > > > > > > > > > > > the function `bar` above that doesn't get a uniquefied 
> > > > > > > > > > > > name. I think moving the definition up to right after 
> > > > > > > > > > > > the declaration hides the declaration.
> > > > > > > > > > > Not sure I follow - do you mean that if the go 
> > > > > > > > > > > declaration and go definition were next to each other, 
> > > > > > > > > > > this test would (mechanically speaking) not validate what 
> > > > > > > > > > > the patch? Or that it would be less legible, but still 
> > > > > > > > > > > mechanically correct?
> > > > > > > > > > > 
> > > > > > > > > > > I think it would be (assuming it's still mechanically 
> > > > > > > > > > > correct) more legible to put the declaration next to the 
> > > > > > > > > > > definition - the comment describes why the declaration is 
> > > > > > > > > > > significant/why the definition is weird, and seeing all 
> > > > > > > > > > > that together would be clearer to me than spreading it 
> > > > > > > > > > > out/having to look further away to see what's going on.
> > > > > > > > > > When the `go` declaration and `go` definition were next to 
> > > > > > > > > > each other, the go function won't get a uniqufied name at 
> > > > > > > > > > all. The declaration will be overwritten by the definition. 
> > > > > > > > > > Only when the declaration is seen by others, such the 
> > > > > > > > > > callsite in `baz`, the declaration makes a difference by 
> > > > > > > > > > having the callsite use a uniqufied name.
> > > > > > > > > > 
> > > > > > > > > > 
> > > > > > > > > Ah! Interesting, good to know. 
> > > > > > > > > 
> > > > > > > > > Is that worth supporting, I wonder? I guess it falls out for 
> > > > > > > > > free/without significant additional complexity. I worry about 
> > > > > > > > > the subtlety of the additional declaration changing the 
> > > > > > > > > behavior here... might be a bit surprising/subtle. But maybe 
> > > > > > > > > no nice way to avoid it either.
> > > > > > > > It would be ideal if user never writes code like that. 
> > > > > > > > Unfortunately it exists with legacy code (such as mysql). I 
> > > > > > > > think it's worth supporting it from AutoFDO point of view to 
> > > > > > > > avoid a silent mismatch between debug linkage name and real 
> > > > > > > > linkage name.
> > > > > > > Oh, I agree that we shouldn't mismatch debug info and the actual 
> > > > > > > symbol name - what I meant was whether code like this should get 
> > > > > > > mangled or not when using unique-internal-linkage names.
> > > > > > > 
> > > > > > > I'm now more curious about this:
> > > > > > > 
> > > > > > > > When the `go` declaration and `go` definition were next to each 
> > > > > > > > other, the go function won't get a uniqufied name at all.
> > > > > > > 
> > > > > > > This doesn't seem to happen with the 
> > > > > > > `__attribute__((overloadable))` attribute, for instance - so any 
> > > > > > > idea what's different about uniquification that's working 
> > > > > > > differently than overloadable?
> > > > > > > 
> > > > > > > ```
> > > > > > > $ cat test.c
> > > > > > > __attribute__((overloadable)) static int go(a) int a; {
> > > > > > >   return 3 + a;
> > > > > > > }
> > > > > > > void baz() {
> > > > > > >   go(2);
> > > > > > > }
> > > > > > > $ clang-tot test.c -emit-llvm -S -o - | grep go
> > > > > > >   %call = call i32 @_ZL2goi(i32 2)
> > > > > > > define internal i32 @_ZL2goi(i32 %a) #0 {
> > > > > > > ```
> > > > > > Good question. I'm not sure what's exactly going on but it looks 
> > > > > > like with the overloadable attribute, the old-style definition is 
> > > > > > treated as having prototype. But if you do this:
> > > > > > 
> > > > > > ```
> > > > > > __attribute__((overloadable)) 
> > > > > > void baz() {}
> > > > > > ```
> > > > > > then there's the error:
> > > > > > 
> > > > > > ```
> > > > > > error: 'overloadable' function 'baz' must have a prototype
> > > > > > void baz() {
> > > > > > ```
> > > > > > 
> > > > > > `void baz() {` does not come with a prototype. That's for sure.  
> > > > > > Sounds like `int go(a) int a {;` can have a prototype when it is 
> > > > > > loadable. I

[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2021-04-26 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2705
   }
-  if (FormatTok->Tok.is(tok::l_brace)) {
+  if (FormatTok->Tok.is(tok::equal)) {
+nextToken();

shouldn't this be

```FormatTok->Tok.is(tok::equal) && 
Style.BraceWrapping.BeforeStructInitialization```

Otherwise you won't go into the `else if (FormatTok->Tok.is(tok::l_brace)) {`  
if its not turned on?


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

https://reviews.llvm.org/D91949

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


[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab accepted this revision.
ab added a comment.
This revision is now accepted and ready to land.

Neat, thanks!


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

https://reviews.llvm.org/D100807

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


[clang] 50b523c - [AST] Fix DeclarationNameInfo introspection

2021-04-26 Thread Stephen Kelly via cfe-commits

Author: Stephen Kelly
Date: 2021-04-26T18:49:13+01:00
New Revision: 50b523cb2ceee4ca7279b4ce22ddb0d0b05df313

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

LOG: [AST] Fix DeclarationNameInfo introspection

Some AST classes return `const DeclarationNameInfo &` instead of
returning by value (eg CXXDependentScopeMemberExpr).

Added: 


Modified: 
clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
clang/unittests/Introspection/IntrospectionTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp 
b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
index 0aeb3a7703f7..0a7fb9b52f23 100644
--- a/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
+++ b/clang/lib/Tooling/DumpTool/ASTSrcLocProcessor.cpp
@@ -225,6 +225,9 @@ void ASTSrcLocProcessor::run(const MatchFinder::MatchResult 
&Result) {
   CaptureMethods("class clang::NestedNameSpecifierLoc", ASTClass, Result);
   CD.DeclNameInfos =
   CaptureMethods("struct clang::DeclarationNameInfo", ASTClass, Result);
+  auto DI = CaptureMethods("const struct clang::DeclarationNameInfo &",
+   ASTClass, Result);
+  CD.DeclNameInfos.insert(CD.DeclNameInfos.end(), DI.begin(), DI.end());
 
   if (const auto *DerivedFrom =
   Result.Nodes.getNodeAs("derivedFrom")) {

diff  --git a/clang/unittests/Introspection/IntrospectionTest.cpp 
b/clang/unittests/Introspection/IntrospectionTest.cpp
index 521520c9a7c7..d4f626bfeb74 100644
--- a/clang/unittests/Introspection/IntrospectionTest.cpp
+++ b/clang/unittests/Introspection/IntrospectionTest.cpp
@@ -1456,6 +1456,72 @@ 
getNamedTypeInfo()->getTypeLoc().getAs().getNameLoc()),
   STRING_LOCATION_PAIR((&NI), getSourceRange(;
 }
 
+TEST(Introspection, SourceLocations_DeclarationNameInfo_CRef) {
+  if (!NodeIntrospection::hasIntrospectionSupport())
+return;
+
+  auto AST = buildASTFromCodeWithArgs(
+  R"cpp(
+template
+struct MyContainer
+{
+template 
+void pushBack();
+};
+
+template
+void foo()
+{
+MyContainer mc;
+mc.template pushBack();
+}
+)cpp",
+  {"-fno-delayed-template-parsing"}, "foo.cpp", "clang-tool",
+  std::make_shared());
+
+  auto &Ctx = AST->getASTContext();
+  auto &TU = *Ctx.getTranslationUnitDecl();
+
+  auto BoundNodes = ast_matchers::match(
+  
decl(hasDescendant(cxxDependentScopeMemberExpr(hasMemberName("pushBack")).bind("member"))),
 TU,
+  Ctx);
+
+  EXPECT_EQ(BoundNodes.size(), 1u);
+
+  const auto *Member = 
BoundNodes[0].getNodeAs("member");
+  auto Result = NodeIntrospection::GetLocations(Member);
+
+  auto ExpectedLocations =
+  FormatExpected(Result.LocationAccessors);
+
+  llvm::sort(ExpectedLocations);
+
+  EXPECT_EQ(
+  llvm::makeArrayRef(ExpectedLocations),
+  (ArrayRef>{
+STRING_LOCATION_STDPAIR(Member, getBeginLoc()),
+STRING_LOCATION_STDPAIR(Member, getEndLoc()),
+STRING_LOCATION_STDPAIR(Member, getExprLoc()),
+STRING_LOCATION_STDPAIR(Member, getLAngleLoc()),
+STRING_LOCATION_STDPAIR(Member, getMemberLoc()),
+STRING_LOCATION_STDPAIR(Member, getMemberNameInfo().getBeginLoc()),
+STRING_LOCATION_STDPAIR(Member, getMemberNameInfo().getEndLoc()),
+STRING_LOCATION_STDPAIR(Member, getMemberNameInfo().getLoc()),
+STRING_LOCATION_STDPAIR(Member, getOperatorLoc()),
+STRING_LOCATION_STDPAIR(Member, getRAngleLoc()),
+STRING_LOCATION_STDPAIR(Member, getTemplateKeywordLoc())
+}));
+
+  auto ExpectedRanges = FormatExpected(Result.RangeAccessors);
+
+  EXPECT_THAT(
+  ExpectedRanges,
+  UnorderedElementsAre(
+  STRING_LOCATION_PAIR(Member, getMemberNameInfo().getSourceRange()),
+  STRING_LOCATION_PAIR(Member, getSourceRange())
+  ));
+}
+
 TEST(Introspection, SourceLocations_DeclarationNameInfo_ConvOp) {
   if (!NodeIntrospection::hasIntrospectionSupport())
 return;



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


[PATCH] D100756: [llvm-rc] [4/4] Add a GNU windres-like frontend to llvm-rc

2021-04-26 Thread Adrian McCarthy via Phabricator via cfe-commits
amccarth accepted this revision.
amccarth added a comment.
This revision is now accepted and ready to land.

There's a lot going on here, but I don't see anything wrong.  Thanks for the 
completeness of the tests and the comments, as that helps a lot in 
understanding what's going on here.




Comment at: llvm/tools/llvm-rc/llvm-rc.cpp:295
+ .Case(".o", Coff)
+ .Default(Unknown);
+  if (F != Unknown)

".obj"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100756

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


[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-26 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song added a comment.

@dblaikie ping. Did you get a chance of looking at it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100567

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


[PATCH] D100492: [OpenCL] Change OpenCL builtin version encoding

2021-04-26 Thread Steven Johnson via Phabricator via cfe-commits
srj added a comment.

In D100492#2717235 , @svenvh wrote:

> I am happy to make/accept any adjustments to this patch to fix the particular 
> build.  I don't have access to MSVC though, would you be able to help figure 
> out what the problematic construct in my patch was?

See my comment above with minor code shuffling which seems to satisfy the 
compiler.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100492

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


[PATCH] D100756: [llvm-rc] [4/4] Add a GNU windres-like frontend to llvm-rc

2021-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D100756#2717331 , @amccarth wrote:

> There's a lot going on here, but I don't see anything wrong.  Thanks for the 
> completeness of the tests and the comments, as that helps a lot in 
> understanding what's going on here.

Thanks!

With this in the tree, it'll be easier to reason about further requests to the 
preprocessing, when both use cases are available at once.




Comment at: llvm/tools/llvm-rc/llvm-rc.cpp:295
+ .Case(".o", Coff)
+ .Default(Unknown);
+  if (F != Unknown)

amccarth wrote:
> ".obj"?
Good point, I'll add that too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100756

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


[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-26 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

(ah, sorry, failed to submit comment)




Comment at: clang/lib/CodeGen/CGExpr.cpp:2843-2844
+  CGDebugInfo *DI = CGM.getModuleDebugInfo();
+  auto *Fn = dyn_cast(LV.getPointer(*this));
+  if (DI && Fn && !Fn->getSubprogram())
+DI->EmitFunctionDecl(FD, FD->getLocation(), T, Fn);

It looks like there isn't any test coverage for the case where Fn is null here 
(I added an assertion that Fn is non-null and it didn't fire when running 
check-clang) - please add some to this patch. (I'd like to then look at those 
cases to better understand when they come up and whether there's a 
different/better way to phrase this code to handle those cases)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100567

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


[clang] 6cc6204 - [clang][driver] Use the provided arch name for a Darwin target triple

2021-04-26 Thread Alex Lorenz via cfe-commits

Author: Alex Lorenz
Date: 2021-04-26T11:31:50-07:00
New Revision: 6cc62043c8bf4daa27664a2e1674abbe8d0492c6

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

LOG: [clang][driver] Use the provided arch name for a Darwin target triple

This ensures that the Darwin driver uses a consistent target triple
representation when the triple is printed out to the user.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arm64_32-link.c
clang/test/Driver/darwin-version.c
clang/test/Driver/default-toolchain.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index bc59b6beafc7..177cfd60ffb3 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -74,12 +74,12 @@ void darwin::setTripleTypeForMachOArchName(llvm::Triple &T, 
StringRef Str) {
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
   llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
-
-  if (Str == "x86_64h" || Str == "arm64e")
+  if (Arch != llvm::Triple::UnknownArch)
 T.setArchName(Str);
-  else if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
+
+  if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
+  ArchKind == llvm::ARM::ArchKind::ARMV7M ||
+  ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
 T.setOS(llvm::Triple::UnknownOS);
 T.setObjectFormat(llvm::Triple::MachO);
   }

diff  --git a/clang/test/Driver/aarch64-cpus.c 
b/clang/test/Driver/aarch64-cpus.c
index 5b9bd5207792..9a2fc857a0c2 100644
--- a/clang/test/Driver/aarch64-cpus.c
+++ b/clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" 
"apple-a12"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s

diff  --git a/clang/test/Driver/arm64_32-link.c 
b/clang/test/Driver/arm64_32-link.c
index 972ae6a234e1..6ef0b6f9f2f7 100644
--- a/clang/test/Driver/arm64_32-link.c
+++ b/clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 
-miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"

diff  --git a/clang/test/Driver/darwin-version.c 
b/clang/test/Driver/darwin-version.c
index 3471552c937f..130a66575a93 100644
--- a/clang/test/Driver/darwin-version.c
+++ b/clang/test/Driver/darwin-version.c
@@ -60,17 +60,17 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
-// CHECK-VERSION-OSX4: "i386-apple-macosx10.4.0"
+// CHECK-VERSION-OSX4: "i686-apple-macosx10.4.0"
 // RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
-// CHECK-VERSION-OSX5: "i386-apple-macosx10.5.0"
+// CHECK-VERSION-OSX5: "i686-apple-macosx10.5.0"
 // RUN: %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
-// CHECK-VERSION-OSX6: "i386-apple-macosx10.6.0"
+// CHECK-VERSION-OSX6: "i686-apple-macosx10.6.0"
 // RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.10 -c %s 
-### 2>&1 | \
@@ -100,7 +100,7 @@
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck 

[PATCH] D100807: [clang][driver] Use the canonical Darwin arch name when printing out the triple for a Darwin target

2021-04-26 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cc62043c8bf: [clang][driver] Use the provided arch name for 
a Darwin target triple (authored by arphaman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100807

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arm64_32-link.c
  clang/test/Driver/darwin-version.c
  clang/test/Driver/default-toolchain.c


Index: clang/test/Driver/default-toolchain.c
===
--- clang/test/Driver/default-toolchain.c
+++ clang/test/Driver/default-toolchain.c
@@ -6,3 +6,6 @@
 
 // RUN: %clang -target i386-apple-darwin9 -arch ppc64 -m32 -v 2> %t
 // RUN: grep 'Target: powerpc-apple-darwin9' %t
+
+// RUN: %clang -target x86_64-apple-macos11 -arch arm64 -v 2>&1 | FileCheck 
--check-prefix=ARM64 %s
+// ARM64: Target: arm64-apple-macos11
Index: clang/test/Driver/darwin-version.c
===
--- clang/test/Driver/darwin-version.c
+++ clang/test/Driver/darwin-version.c
@@ -60,17 +60,17 @@
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.4 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX4 %s
-// CHECK-VERSION-OSX4: "i386-apple-macosx10.4.0"
+// CHECK-VERSION-OSX4: "i686-apple-macosx10.4.0"
 // RUN: %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.5 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
-// CHECK-VERSION-OSX5: "i386-apple-macosx10.5.0"
+// CHECK-VERSION-OSX5: "i686-apple-macosx10.5.0"
 // RUN: %clang -target i686-apple-darwin10 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
 // RUN: %clang -target i686-apple-darwin9 -mmacosx-version-min=10.6 -c %s -### 
2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX6 %s
-// CHECK-VERSION-OSX6: "i386-apple-macosx10.6.0"
+// CHECK-VERSION-OSX6: "i686-apple-macosx10.6.0"
 // RUN: %clang -target x86_64-apple-darwin14 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX10 %s
 // RUN: %clang -target x86_64-apple-darwin -mmacosx-version-min=10.10 -c %s 
-### 2>&1 | \
@@ -100,7 +100,7 @@
 
 // Check environment variable gets interpreted correctly
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
-// RUN:   %clang -target i386-apple-darwin9 -c %s -### 2>&1 | \
+// RUN:   %clang -target i686-apple-darwin9 -c %s -### 2>&1 | \
 // RUN:   FileCheck --check-prefix=CHECK-VERSION-OSX5 %s
 // RUN: env MACOSX_DEPLOYMENT_TARGET=10.5 IPHONEOS_DEPLOYMENT_TARGET=2.0 \
 // RUN:   %clang -target armv6-apple-darwin9 -c %s -### 2>&1 | \
Index: clang/test/Driver/arm64_32-link.c
===
--- clang/test/Driver/arm64_32-link.c
+++ clang/test/Driver/arm64_32-link.c
@@ -1,4 +1,4 @@
 // RUN: %clang -target x86_64-apple-darwin -arch arm64_32 
-miphoneos-version-min=8.0 %s -### 2>&1 | FileCheck %s
 
-// CHECK: "-cc1"{{.*}} "-triple" "aarch64_32-apple-ios8.0.0"
+// CHECK: "-cc1"{{.*}} "-triple" "arm64_32-apple-ios8.0.0"
 // CHECK: ld{{.*}} "-arch" "arm64_32"
Index: clang/test/Driver/aarch64-cpus.c
===
--- clang/test/Driver/aarch64-cpus.c
+++ clang/test/Driver/aarch64-cpus.c
@@ -33,7 +33,7 @@
 // ARM64E-DARWIN: "-cc1"{{.*}} "-triple" "arm64e{{.*}}" "-target-cpu" 
"apple-a12"
 
 // RUN: %clang -target arm64-apple-darwin -arch arm64_32 -### -c %s 2>&1 | 
FileCheck -check-prefix=ARM64_32-DARWIN %s
-// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "aarch64_32{{.*}}" "-target-cpu" 
"apple-s4"
+// ARM64_32-DARWIN: "-cc1"{{.*}} "-triple" "arm64_32{{.*}}" "-target-cpu" 
"apple-s4"
 
 // RUN: %clang -target aarch64 -mcpu=cortex-a35 -### -c %s 2>&1 | FileCheck 
-check-prefix=CA35 %s
 // RUN: %clang -target aarch64 -mlittle-endian -mcpu=cortex-a35 -### -c %s 
2>&1 | FileCheck -check-prefix=CA35 %s
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -74,12 +74,12 @@
   const llvm::Triple::ArchType Arch = getArchTypeForMachOArchName(Str);
   llvm::ARM::ArchKind ArchKind = llvm::ARM::parseArch(Str);
   T.setArch(Arch);
-
-  if (Str == "x86_64h" || Str == "arm64e")
+  if (Arch != llvm::Triple::UnknownArch)
 T.setArchName(Str);
-  else if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7M ||
-   ArchKind == llvm::ARM::ArchKind::ARMV7EM) {
+
+  if (ArchKind == llvm::ARM::ArchKind::ARMV6M ||
+  ArchKind == llvm::ARM::ArchKind::AR

[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 340598.
mibintc added a reviewer: aaron.ballman.
mibintc added a comment.
Herald added subscribers: jansvoboda11, dexonsmith, lxfind, dang, kerbowa, 
kbarton, aheejin, jgravelle-google, sbc100, nhaehnle, jvesely, nemanjai, 
dschuff.

I think this patch is complete except it needs to wait until the parent patch 
is finished.  Also some re-factoring may be desireable, I'll add some inline 
comments about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/Basic/Targets/AMDGPU.h
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Basic/Targets/PPC.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/ASTUnit.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaCoroutine.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/arithmetic-fence-builtin.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Sema/arithmetic-fence-builtin.c
  clang/tools/clang-import-test/clang-import-test.cpp

Index: clang/tools/clang-import-test/clang-import-test.cpp
===
--- clang/tools/clang-import-test/clang-import-test.cpp
+++ clang/tools/clang-import-test/clang-import-test.cpp
@@ -208,7 +208,7 @@
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
   Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
   Ins->setTarget(TI);
-  Ins->getTarget().adjust(Ins->getLangOpts());
+  Ins->getTarget().adjust(Ins->getDiagnostics(), Ins->getLangOpts());
   Ins->createFileManager();
   Ins->createSourceManager(Ins->getFileManager());
   Ins->createPreprocessor(TU_Complete);
Index: clang/test/Sema/arithmetic-fence-builtin.c
===
--- /dev/null
+++ clang/test/Sema/arithmetic-fence-builtin.c
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o - -verify -x c++ %s
+// RUN: %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -verify -x c++ %s
+// RUN: not %clang_cc1 -triple ppc64le -DPPC -emit-llvm -o - -x c++ %s \
+// RUN:-fprotect-parens 2>&1 | FileCheck -check-prefix=PPC %s
+#ifndef PPC
+int v;
+template  T addT(T a, T b) {
+  T *q = __arithmetic_fence(&a);
+  // expected-error@-1 {{operand of type 'float *' where floating, complex or a vector of such types is required ('float *' invalid)}}
+  // expected-error@-2 {{operand of type 'int *' where floating, complex or a vector of such types is required ('int *' invalid)}}
+  return __arithmetic_fence(a + b);
+  // expected-error@-1 {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+}
+int addit(int a, int b) {
+  float x, y;
+  typedef struct {
+int a, b;
+  } stype;
+  stype s;
+  s = __arithmetic_fence(s);// expected-error {{operand of type 'stype' where floating, complex or a vector of such types is required ('stype' invalid)}}
+  x = __arithmetic_fence(x, y); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  // Complex is supported.
+  _Complex double cd, cd1;
+  cd = __arithmetic_fence(cd1);
+  // Vector is supported.
+  typedef float __v4hi __attribute__((__vector_size__(8)));
+  __v4hi vec1, vec2;
+  vec1 = __arithmetic_fence(vec2);
+
+  v = __arithmetic_fence(a + b); // expected-error {{operand of type 'int' where floating, complex or a vector of such types is required ('int' invalid)}}
+  float f = addT(a, b);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  int i = addT(1, 2);   // expected-note {{in instantiation of function template specialization 'addT' requested here}}
+  constexpr float d = 1.0 + 2.0;
+  constexpr float c = __arithmetic_fence(1.0 + 2.0);
+  // expected-error@-1 {{constexpr variable 'c' must be initialized by a constant expression}}
+  return 0;
+}
+// expected-error@+1 {{static_assert expression is not an integral constant expression}}
+static_assert( __arithmetic_fence(1.0 + 2.0), "message" );
+#else
+float addit(float a, float b) {
+  return __arithmetic_fence(a+b); // expected-error {{builtin is not supported on this target}}
+}
+#endif
+//PPC: error: option '-fprotect-parens' cannot be specified on this target
Index: clang/test/Driver/clang_f_opts.c
=

[PATCH] D101317: hurd: Fix i386 research path

2021-04-26 Thread Samuel Thibault via Phabricator via cfe-commits
sthibaul created this revision.
sthibaul requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

f26341840253 
 
("[Driver] Gnu.cpp: remove obsoleted i386 triple detection
from end-of-life distribution versions") dropped the i686-gnu gcc path, but
GNU/Hurd's gcc is actually using it, and not i386.

This fixes the gcc path and update the tests to reflect it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D101317

Files:
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i386-gnu/lib/.keep
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/bin/as
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/bin/ld
  clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/i686-gnu/lib/.keep
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbegin.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginS.o
  
clang/test/Driver/Inputs/basic_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/crtbeginT.o
  clang/test/Driver/hurd.c


Index: clang/test/Driver/hurd.c
===
--- clang/test/Driver/hurd.c
+++ clang/test/Driver/hurd.c
@@ -11,7 +11,7 @@
 // CHECK: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK: "-dynamic-linker" "/lib/ld.so"
-// CHECK: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
 // CHECK: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -33,7 +33,7 @@
 // CHECK-STATIC: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-STATIC: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
 // CHECK-STATIC: "-static"
-// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginT.o"
+// CHECK-STATIC: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginT.o"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-STATIC: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-STATIC: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -53,7 +53,7 @@
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/include"
 // CHECK-SHARED: "-internal-externc-isystem" "[[SYSROOT]]/usr/include"
 // CHECK-SHARED: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
-// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbeginS.o"
+// CHECK-SHARED: "{{.*}}/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbeginS.o"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/i386-gnu"
 // CHECK-SHARED: "-L[[SYSROOT]]/lib/../lib32"
 // CHECK-SHARED: "-L[[SYSROOT]]/usr/lib/i386-gnu"
@@ -67,7 +67,7 @@
 // RUN:   | FileCheck --check-prefix=CHECK-CROSS %s
 // CHECK-CROSS-NOT: warning:
 // CHECK-CROSS: "-cc1" "-triple" "i386-pc-hurd-gnu"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}as"
 "--32"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/bin{{/|}}ld"
 {{.*}} "-m" "elf_i386"
-// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0{{/|}}crtbegin.o"
-// CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i386-gnu/4.6.0/../../../../i386-gnu/lib"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i686-gnu/bin{{/|}}as"
 "--32"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i686-gnu/bin{{/|}}ld"
 {{.*}} "-m" "elf_i386"
+// CHECK-CROSS: 
"{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0{{/|}}crtbegin.o"
+// CHECK-CROSS: 
"-L{{.*}}/Inputs/basic_cross_hurd_tree/usr/lib/gcc/i686-gnu/4.6.0/../../../../i686-gnu/lib"
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -2115,7 +2115,7 @@
   "i686-pc-linux-gnu",  "i386-redhat-linux6E",
   "i686-redhat-linux",  "i386-redhat-linux",
   "i586-suse-linux","i686-montavista-linux",
-  "i686-linux-android", "i386-gnu",
+  "i686-linux-android", "i686-gnu",
   };
 
   static const char *const M68kLibDirs[] = {"/lib"};


Index: clang/test/Driver/hurd.c

[PATCH] D100118: [clang] RFC Support new builtin __arithmetic_fence to control floating point optimization, and new clang option fprotect-parens

2021-04-26 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

some inline comments for reviewers




Comment at: clang/include/clang/Basic/TargetInfo.h:1162
   /// the language based on the target options where applicable.
-  virtual void adjust(LangOptions &Opts);
+  virtual void adjust(DiagnosticsEngine &Diags, LangOptions &Opts);
 

There's no good place to diagnose when LangOptions and TargetOptions conflict, 
I see "conflict" diagnostics being emitted in clang/CodeGen when creating the 
func or module, which seems wrong to me. On the other hand, the "adjust" 
function makes a good place to do the reconciliation I think. This is the 
change that could be pulled out in a refactoring and committed prior to this 
patch. What do you think? 



Comment at: clang/include/clang/Driver/Options.td:4300
 defm pack_derived : BooleanFFlag<"pack-derived">, Group;
-defm protect_parens : BooleanFFlag<"protect-parens">, Group;
+//defm protect_parens : BooleanFFlag<"protect-parens">, Group;
 defm range_check : BooleanFFlag<"range-check">, Group;

@jansvoboda11 This is a gfortran option, but I don't think there's a way to 
allow the same option spelling for gfortran and clang. Other clang options, 
like -short-enum, also have been pulled out of gfortran group, and the gfortran 
option test is an expected-fail test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100118

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


[PATCH] D94355: [Passes] Add relative lookup table converter pass

2021-04-26 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

This patch breaks a two stage build with LTO:

  $ git bisect log
  # bad: [f0bc2782f281ca05221d2f1735bbaff6c4b81ebb] [TTI] NFC: Remove unused 
'OptSize' parameter from shouldMaximizeVectorBandwidth
  # good: [9829f5e6b1bca9b61efc629770d28bb9014dec45] [CVP] 
@llvm.[us]{min,max}() intrinsics handling
  git bisect start 'f0bc2782f281ca05221d2f1735bbaff6c4b81ebb' 
'9829f5e6b1bca9b61efc629770d28bb9014dec45'
  # bad: [1af35e77f4b8c3314dc20a10d579b52f22c75a00] [TTI] NFC: Change 
getVectorInstrCost to return InstructionCost
  git bisect bad 1af35e77f4b8c3314dc20a10d579b52f22c75a00
  # bad: [45f8946a759a780e6131256d6d206977b9c128ee] [CodeView] Fix the ARM64 
CPUType enum
  git bisect bad 45f8946a759a780e6131256d6d206977b9c128ee
  # good: [0b439e4cc9dbb5c226121383b84d4f48ab669c55] [libc++] Split 
std::allocator out of 
  git bisect good 0b439e4cc9dbb5c226121383b84d4f48ab669c55
  # good: [2eb98d89ac866e32cb56727174e4d1c1413479c8] [mlir][spirv] Allow 
bitwidth emulation on runtime arrays
  git bisect good 2eb98d89ac866e32cb56727174e4d1c1413479c8
  # bad: [80aa9b0f7b3ebe53220a398b2939610d8a49e24b] [PowerPC] stop reverse mem 
op generation for some cases.
  git bisect bad 80aa9b0f7b3ebe53220a398b2939610d8a49e24b
  # good: [a8ab1f98d22cf15f39dd1c2ce77675e628fceb31] [Evaluator] Look through 
invariant.group intrinsics
  git bisect good a8ab1f98d22cf15f39dd1c2ce77675e628fceb31
  # bad: [30f591c3869f3bbe6eca1249dcef1b8337312de6] [lldb] Disable 
TestLaunchProcessPosixSpawn.py with reproducers
  git bisect bad 30f591c3869f3bbe6eca1249dcef1b8337312de6
  # good: [6c4f2508e4278ac789230cb05f2bb56a8a7297dc] Revert "[lldb] [gdb-remote 
client] Refactor handling qSupported"
  git bisect good 6c4f2508e4278ac789230cb05f2bb56a8a7297dc
  # bad: [e96df3e531f506eea75da0f13d0f8aa9a267f975] [Passes] Add relative 
lookup table converter pass
  git bisect bad e96df3e531f506eea75da0f13d0f8aa9a267f975
  # good: [1310a19af06262122a6e9e4f6fbbe9c39ebad76e] [mlir] Use MCJIT to fix 
integration tests
  git bisect good 1310a19af06262122a6e9e4f6fbbe9c39ebad76e
  # first bad commit: [e96df3e531f506eea75da0f13d0f8aa9a267f975] [Passes] Add 
relative lookup table converter pass

My reproduction steps, apologies if they are not reduced enough:

  $ mkdir -p build/stage{1,2}
  
  $ cmake \
 -B build/stage1 \
 -G Ninja \
 -DCMAKE_C_COMPILER=$(command -v clang) \
 -DCMAKE_CXX_COMPILER=$(command -v clang++) \
 -DLLVM_USE_LINKER=$(command -v ld.lld) \
 -DLLVM_ENABLE_PROJECTS="clang;lld" \
 -DLLVM_TARGETS_TO_BUILD=host \
 -DLLVM_CCACHE_BUILD=ON \
 -DCMAKE_BUILD_TYPE=Release \
 llvm
  ...
  
  $ ninja -C build/stage1 all
  ...
  
  $ cmake \
 -B build/stage2 \
 -G Ninja \
 -DCMAKE_AR=$PWD/build/stage1/bin/llvm-ar \
 -DCMAKE_C_COMPILER=$PWD/build/stage1/bin/clang \
 -DCLANG_TABLEGEN=$PWD/build/stage1/bin/clang-tblgen \
 -DCMAKE_CXX_COMPILER=$PWD/build/stage1/bin/clang++ \
 -DLLVM_USE_LINKER=$PWD/build/stage1/bin/ld.lld \
 -DLLVM_TABLEGEN=$PWD/build/stage1/bin/llvm-tblgen \
 -DCMAKE_RANLIB=$PWD/build/stage1/bin/llvm-ranlib \
 -DLLVM_ENABLE_PROJECTS=clang \
 -DLLVM_TARGETS_TO_BUILD=host \
 -DCMAKE_BUILD_TYPE=Release \
 -DLLVM_ENABLE_LTO=Full \
 llvm
  
  $ ninja -C build/stage2 lib/libclang-cpp.so.13git
  ...
  [2296/2296] Linking CXX shared library lib/libclang-cpp.so.13git
  FAILED: lib/libclang-cpp.so.13git
  ...
  ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 
llvm::detail::unit >::value; recompile with -fPIC
  >>> defined in lto.tmp
  >>> referenced by ld-temp.o
  >>>   
lto.tmp:(.data.rel.ro..Lreltable._ZN5clang10TargetInfo21getTypeFormatModifierENS_23TransferrableTargetInfo7IntTypeE+0x8)
  
  ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 
llvm::detail::unit >::value; recompile with -fPIC
  >>> defined in lto.tmp
  >>> referenced by ld-temp.o
  >>>   
lto.tmp:(.data.rel.ro..Lreltable._ZN5clang10TargetInfo21getTypeFormatModifierENS_23TransferrableTargetInfo7IntTypeE+0xC)
  
  ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 
llvm::detail::unit >::value; recompile with -fPIC
  >>> defined in lto.tmp
  >>> referenced by ld-temp.o
  >>>   
lto.tmp:(.data.rel.ro..Lreltable._ZNK5clang21analyze_format_string14LengthModifier8toStringEv+0x8)
  
  ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 
llvm::detail::unit >::value; recompile with -fPIC
  >>> defined in lto.tmp
  >>> referenced by ld-temp.o
  >>>   
lto.tmp:(.data.rel.ro..Lreltable._ZNK5clang21analyze_format_string14LengthModifier8toStringEv+0x3C)
  
  ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol 
llvm::detail::unit >::value; recompile with -fPIC
  >>> defined in lto.tmp
  >>> referenced by ld-temp.o
  >>>   
lto.tmp:(.data.rel.ro..Lreltable._ZN4llvm15MCSymbolRefExpr18getVariantKindNameENS0_11VariantKindE+0xC0)
  

[PATCH] D100567: BPF: emit debuginfo for Function of DeclRefExpr if requested

2021-04-26 Thread Yonghong Song via Phabricator via cfe-commits
yonghong-song updated this revision to Diff 340606.
yonghong-song added a comment.

- somehow previous test case didn't trigger nullptr for Fn. Replaced it with a 
working test case.

With the following change,

  diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
  index a784aade88da..fc86c1a72056 100644
  --- a/clang/lib/CodeGen/CGExpr.cpp
  +++ b/clang/lib/CodeGen/CGExpr.cpp
  @@ -2841,6 +2841,7 @@ LValue CodeGenFunction::EmitDeclRefLValue(const 
DeclRefExpr *E) {
   if (getContext().getTargetInfo().allowDebugInfoForExternalRef()) {
 CGDebugInfo *DI = CGM.getModuleDebugInfo();
 auto *Fn = dyn_cast(LV.getPointer(*this));
  +  fprintf(stderr, "Fn = %p\n", (void *)Fn);
 if (DI && Fn && !Fn->getSubprogram())
   DI->EmitFunctionDecl(FD, FD->getLocation(), T, Fn);
   }

I have the following for the added test case,

  $ clang -cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu -emit-llvm 
debug-info-extern-callback.c
  Fn = 0x7afcf28
  Fn = 0x7afce98
  Fn = (nil)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100567

Files:
  clang/include/clang/Basic/TargetInfo.h
  clang/lib/Basic/Targets/BPF.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGen/debug-info-extern-callback.c


Index: clang/test/CodeGen/debug-info-extern-callback.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-callback.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -x c -debug-info-kind=limited -triple bpf-linux-gnu 
-emit-llvm %s -o - | FileCheck %s
+
+extern int do_work1(int);
+long bpf_helper1(void *callback_fn);
+long prog1() {
+  return bpf_helper1(&do_work1);
+}
+
+extern int do_work2();
+long prog2_1() {
+  return (long)&do_work2;
+}
+int do_work2() { return 0; }
+long prog2_2() {
+  return (long)&do_work2;
+}
+
+// CHECK: declare !dbg ![[FUNC1:[0-9]+]] i32 @do_work1
+// CHECK: define dso_local i32 @do_work2() #{{[0-9]+}} !dbg ![[FUNC2:[0-9]+]]
+
+// CHECK: ![[FUNC1]] = !DISubprogram(name: "do_work1"
+// CHECK: ![[FUNC2]] = distinct !DISubprogram(name: "do_work2"
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -12667,7 +12667,7 @@
 Diag(Var->getLocation(), diag::note_private_extern);
   }
 
-  if (Context.getTargetInfo().allowDebugInfoForExternalVar() &&
+  if (Context.getTargetInfo().allowDebugInfoForExternalRef() &&
   !Var->isInvalidDecl() && !getLangOpts().CPlusPlus)
 ExternalDeclarations.push_back(Var);
 
Index: clang/lib/CodeGen/CGExpr.cpp
===
--- clang/lib/CodeGen/CGExpr.cpp
+++ clang/lib/CodeGen/CGExpr.cpp
@@ -2834,8 +2834,19 @@
 return LV;
   }
 
-  if (const auto *FD = dyn_cast(ND))
-return EmitFunctionDeclLValue(*this, E, FD);
+  if (const auto *FD = dyn_cast(ND)) {
+LValue LV = EmitFunctionDeclLValue(*this, E, FD);
+
+// Emit debuginfo for the function declaration if the target wants to.
+if (getContext().getTargetInfo().allowDebugInfoForExternalRef()) {
+  CGDebugInfo *DI = CGM.getModuleDebugInfo();
+  auto *Fn = dyn_cast(LV.getPointer(*this));
+  if (DI && Fn && !Fn->getSubprogram())
+DI->EmitFunctionDecl(FD, FD->getLocation(), T, Fn);
+}
+
+return LV;
+  }
 
   // FIXME: While we're emitting a binding from an enclosing scope, all other
   // DeclRefExprs we see should be implicitly treated as if they also refer to
Index: clang/lib/Basic/Targets/BPF.h
===
--- clang/lib/Basic/Targets/BPF.h
+++ clang/lib/Basic/Targets/BPF.h
@@ -76,7 +76,7 @@
 return None;
   }
 
-  bool allowDebugInfoForExternalVar() const override { return true; }
+  bool allowDebugInfoForExternalRef() const override { return true; }
 
   CallingConvCheckResult checkCallingConvention(CallingConv CC) const override 
{
 switch (CC) {
Index: clang/include/clang/Basic/TargetInfo.h
===
--- clang/include/clang/Basic/TargetInfo.h
+++ clang/include/clang/Basic/TargetInfo.h
@@ -1538,8 +1538,8 @@
 
   virtual void setAuxTarget(const TargetInfo *Aux) {}
 
-  /// Whether target allows debuginfo types for decl only variables.
-  virtual bool allowDebugInfoForExternalVar() const { return false; }
+  /// Whether target allows debuginfo types for decl only variables/functions.
+  virtual bool allowDebugInfoForExternalRef() const { return false; }
 
 protected:
   /// Copy type and layout related info.


Index: clang/test/CodeGen/debug-info-extern-callback.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-extern-callback.c
@@ -0,0 +1,22 @@
+// RUN: %clang_c

[clang] f8de9aa - [llvm-rc] Add a GNU windres-like frontend to llvm-rc

2021-04-26 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2021-04-26T22:04:29+03:00
New Revision: f8de9aaef2f472ad7572748582444083d31d5a95

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

LOG: [llvm-rc] Add a GNU windres-like frontend to llvm-rc

This primarily parses a different set of options and invokes the same
resource compiler as llvm-rc normally. Additionally, it can convert
directly to an object file (which in MSVC style setups is done with the
separate cvtres tool, or by the linker).

(GNU windres also supports other conversions; from coff object file back
to .res, and from .res or object file back to .rc form; that's not yet
implemented.)

The other bigger complication lies in being able to imply or pass the
intended target triple, to let clang find the corresponding mingw sysroot
for finding include files, and for specifying the default output object
machine format.

It can be implied from the tool triple prefix, like
`-[llvm-]windres` or picked up from the windres option e.g.
`-F pe-x86-64`. In GNU windres, that option takes BFD style format names
such as pe-i386 or pe-x86-64. As libbfd in binutils doesn't support
Windows on ARM, there's no such canonical name for the ARM targets.
Therefore, as an LLVM specific extension, this option is extended to
allow passing full triples, too.

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

Added: 
clang/test/Preprocessor/Inputs/llvm-windres.h
clang/test/Preprocessor/llvm-windres.rc
llvm/test/tools/llvm-rc/windres-format.test
llvm/test/tools/llvm-rc/windres-prefix.test
llvm/test/tools/llvm-rc/windres-preproc.test
llvm/test/tools/llvm-rc/windres-target.test
llvm/test/tools/llvm-rc/windres-version.test
llvm/tools/llvm-rc/WindresOpts.td

Modified: 
clang/test/CMakeLists.txt
llvm/test/CMakeLists.txt
llvm/test/lit.cfg.py
llvm/test/tools/llvm-rc/codepage.test
llvm/test/tools/llvm-rc/language.test
llvm/tools/llvm-rc/CMakeLists.txt
llvm/tools/llvm-rc/llvm-rc.cpp

Removed: 




diff  --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt
index 1325a0308d69e..f87b32a97fa67 100644
--- a/clang/test/CMakeLists.txt
+++ b/clang/test/CMakeLists.txt
@@ -125,6 +125,7 @@ if( NOT CLANG_BUILT_STANDALONE )
 llvm-readobj
 llvm-strip
 llvm-symbolizer
+llvm-windres
 opt
 split-file
 yaml2obj

diff  --git a/clang/test/Preprocessor/Inputs/llvm-windres.h 
b/clang/test/Preprocessor/Inputs/llvm-windres.h
new file mode 100644
index 0..411ec48a8af9f
--- /dev/null
+++ b/clang/test/Preprocessor/Inputs/llvm-windres.h
@@ -0,0 +1,10 @@
+#ifndef RC_INVOKED
+#error RC_INVOKED not defined
+#endif
+#ifndef _WIN32
+#error _WIN32 not defined
+#endif
+#ifndef __MINGW32__
+#error __MINGW32__ not defined
+#endif
+#define MY_ID 42

diff  --git a/clang/test/Preprocessor/llvm-windres.rc 
b/clang/test/Preprocessor/llvm-windres.rc
new file mode 100644
index 0..3356cd1e253fd
--- /dev/null
+++ b/clang/test/Preprocessor/llvm-windres.rc
@@ -0,0 +1,8 @@
+// RUN: llvm-windres -I%p/Inputs %s %t.res
+// RUN: llvm-readobj %t.res | FileCheck %s
+// CHECK: Resource type (int): RCDATA (ID 10)
+// CHECK: Resource name (int): 42
+#include "llvm-windres.h"
+MY_ID RCDATA {
+  "a long string of data"
+}

diff  --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt
index bd02027c06038..77035899a6d98 100644
--- a/llvm/test/CMakeLists.txt
+++ b/llvm/test/CMakeLists.txt
@@ -117,6 +117,7 @@ set(LLVM_TEST_DEPENDS
   llvm-symbolizer
   llvm-tblgen
   llvm-undname
+  llvm-windres
   llvm-xray
   not
   obj2yaml

diff  --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py
index c66f6de56b8af..944276461be69 100644
--- a/llvm/test/lit.cfg.py
+++ b/llvm/test/lit.cfg.py
@@ -163,7 +163,8 @@ def get_asan_rtlib():
 'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump', 'llvm-otool',
 'llvm-pdbutil', 'llvm-profdata', 'llvm-profgen', 'llvm-ranlib', 'llvm-rc', 
'llvm-readelf',
 'llvm-readobj', 'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings',
-'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-c-test', 'llvm-cxxfilt',
+'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-windres',
+'llvm-c-test', 'llvm-cxxfilt',
 'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench', 'verify-uselistorder',
 'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats'])
 

diff  --git a/llvm/test/tools/llvm-rc/codepage.test 
b/llvm/test/tools/llvm-rc/codepage.test
index 406ff00be53b0..20639d42ecb82 100644
--- a/llvm/test/tools/llvm-rc/codepage.test
+++ b/llvm/test/tools/llvm-rc/codepage.test
@@ -1,5 +1,9 @@
 ; RUN: llvm-rc -no-preprocess /C 65001 /FO %t.utf8.res -- %p/Inputs/utf8.rc
 ; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check

[PATCH] D100756: [llvm-rc] [4/4] Add a GNU windres-like frontend to llvm-rc

2021-04-26 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf8de9aaef2f4: [llvm-rc] Add a GNU windres-like frontend to 
llvm-rc (authored by mstorsjo).

Changed prior to commit:
  https://reviews.llvm.org/D100756?vs=339263&id=340607#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D100756

Files:
  clang/test/CMakeLists.txt
  clang/test/Preprocessor/Inputs/llvm-windres.h
  clang/test/Preprocessor/llvm-windres.rc
  llvm/test/CMakeLists.txt
  llvm/test/lit.cfg.py
  llvm/test/tools/llvm-rc/codepage.test
  llvm/test/tools/llvm-rc/language.test
  llvm/test/tools/llvm-rc/windres-format.test
  llvm/test/tools/llvm-rc/windres-prefix.test
  llvm/test/tools/llvm-rc/windres-preproc.test
  llvm/test/tools/llvm-rc/windres-target.test
  llvm/test/tools/llvm-rc/windres-version.test
  llvm/tools/llvm-rc/CMakeLists.txt
  llvm/tools/llvm-rc/WindresOpts.td
  llvm/tools/llvm-rc/llvm-rc.cpp

Index: llvm/tools/llvm-rc/llvm-rc.cpp
===
--- llvm/tools/llvm-rc/llvm-rc.cpp
+++ llvm/tools/llvm-rc/llvm-rc.cpp
@@ -18,8 +18,10 @@
 #include "ResourceScriptToken.h"
 
 #include "llvm/ADT/Triple.h"
+#include "llvm/Object/WindowsResource.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/FileUtilities.h"
@@ -75,8 +77,39 @@
   RcOptTable() : OptTable(InfoTable, /* IgnoreCase = */ true) {}
 };
 
+enum Windres_ID {
+  WINDRES_INVALID = 0, // This is not a correct option ID.
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  WINDRES_##ID,
+#include "WindresOpts.inc"
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE) const char *const WINDRES_##NAME[] = VALUE;
+#include "WindresOpts.inc"
+#undef PREFIX
+
+static const opt::OptTable::Info WindresInfoTable[] = {
+#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM,  \
+   HELPTEXT, METAVAR, VALUES)  \
+  {\
+  WINDRES_##PREFIX, NAME, HELPTEXT,\
+  METAVAR,  WINDRES_##ID, opt::Option::KIND##Class,\
+  PARAM,FLAGS,WINDRES_##GROUP, \
+  WINDRES_##ALIAS,  ALIASARGS,VALUES},
+#include "WindresOpts.inc"
+#undef OPTION
+};
+
+class WindresOptTable : public opt::OptTable {
+public:
+  WindresOptTable() : OptTable(WindresInfoTable, /* IgnoreCase = */ false) {}
+};
+
 static ExitOnError ExitOnErr;
 static FileRemover TempPreprocFile;
+static FileRemover TempResFile;
 
 LLVM_ATTRIBUTE_NORETURN static void fatalError(const Twine &Message) {
   errs() << Message << "\n";
@@ -112,9 +145,8 @@
   return Path;
 }
 
-std::string getClangClTriple() {
-  Triple T(sys::getDefaultTargetTriple());
-  switch (T.getArch()) {
+Triple::ArchType getDefaultArch(Triple::ArchType Arch) {
+  switch (Arch) {
   case Triple::x86:
   case Triple::x86_64:
   case Triple::arm:
@@ -122,13 +154,17 @@
   case Triple::aarch64:
 // These work properly with the clang driver, setting the expected
 // defines such as _WIN32 etc.
-break;
+return Arch;
   default:
 // Other archs aren't set up for use with windows as target OS, (clang
 // doesn't define e.g. _WIN32 etc), so set a reasonable default arch.
-T.setArch(Triple::x86_64);
-break;
+return Triple::x86_64;
   }
+}
+
+std::string getClangClTriple() {
+  Triple T(sys::getDefaultTargetTriple());
+  T.setArch(getDefaultArch(T.getArch()));
   T.setOS(Triple::Win32);
   T.setVendor(Triple::PC);
   T.setEnvironment(Triple::MSVC);
@@ -136,10 +172,44 @@
   return T.str();
 }
 
-bool preprocess(StringRef Src, StringRef Dst, opt::InputArgList &InputArgs,
+std::string getMingwTriple() {
+  Triple T(sys::getDefaultTargetTriple());
+  T.setArch(getDefaultArch(T.getArch()));
+  if (T.isWindowsGNUEnvironment())
+return T.str();
+  // Write out the literal form of the vendor/env here, instead of
+  // constructing them with enum values (which end up with them in
+  // normalized form). The literal form of the triple can matter for
+  // finding include files.
+  return (Twine(T.getArchName()) + "-w64-mingw32").str();
+}
+
+enum Format { Rc, Res, Coff, Unknown };
+
+struct RcOptions {
+  bool Preprocess = true;
+  bool PrintCmdAndExit = false;
+  std::string Triple;
+  std::vector PreprocessCmd;
+  std::vector PreprocessArgs;
+
+  std::string InputFile;
+  Format InputFormat = Rc;
+  std::string OutputFile;
+  Format OutputFormat = Res;
+
+  bool BeVerbose = false;
+  WriterParams Params;
+  bool Ap

  1   2   3   >