[llvm-branch-commits] [mlir] 09f717b - Add sqrt lowering from standard to ROCDL

2020-12-10 Thread Adrian Kuegel via llvm-branch-commits

Author: Adrian Kuegel
Date: 2020-12-10T09:47:37+01:00
New Revision: 09f717b929ae040ae1bf9e9ec56f6dd4a5dba2f8

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

LOG: Add sqrt lowering from standard to ROCDL

Add a lowering for sqrt from standard dialect to ROCDL.

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

Added: 


Modified: 
mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir

Removed: 




diff  --git a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp 
b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
index 7b2e2943ce1f..4d81e2cc1f78 100644
--- a/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
+++ b/mlir/lib/Conversion/GPUToROCDL/LowerGpuOpsToROCDLOps.cpp
@@ -72,7 +72,7 @@ struct LowerGpuOpsToROCDLOpsPass
 target.addIllegalDialect();
 target.addIllegalOp();
+LLVM::Log2Op, LLVM::SinOp, LLVM::SqrtOp>();
 target.addIllegalOp();
 target.addLegalDialect();
 // TODO: Remove once we support replacing non-root ops.
@@ -115,6 +115,8 @@ void mlir::populateGpuToROCDLConversionPatterns(
 "__ocml_log2_f64");
   patterns.insert>(converter, "__ocml_sin_f32",
"__ocml_sin_f64");
+  patterns.insert>(converter, "__ocml_sqrt_f32",
+"__ocml_sqrt_f64");
   patterns.insert>(converter, "__ocml_tanh_f32",
 "__ocml_tanh_f64");
 }

diff  --git a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir 
b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
index b17d75fd7afb..759d2f2d2d70 100644
--- a/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
+++ b/mlir/test/Conversion/GPUToROCDL/gpu-to-rocdl.mlir
@@ -228,6 +228,26 @@ gpu.module @test_module {
 
 // -
 
+gpu.module @test_module {
+  // CHECK: llvm.func @__ocml_sqrt_f32(!llvm.float) -> !llvm.float
+  // CHECK: llvm.func @__ocml_sqrt_f64(!llvm.double) -> !llvm.double
+  // CHECK-LABEL: func @gpu_sqrt
+  func @gpu_sqrt(%arg_f16 : f16, %arg_f32 : f32, %arg_f64 : f64)
+  -> (f16, f32, f64) {
+%result16 = std.sqrt %arg_f16 : f16
+// CHECK: llvm.fpext %{{.*}} : !llvm.half to !llvm.float
+// CHECK-NEXT: llvm.call @__ocml_sqrt_f32(%{{.*}}) : (!llvm.float) -> 
!llvm.float
+// CHECK-NEXT: llvm.fptrunc %{{.*}} : !llvm.float to !llvm.half
+%result32 = std.sqrt %arg_f32 : f32
+// CHECK: llvm.call @__ocml_sqrt_f32(%{{.*}}) : (!llvm.float) -> 
!llvm.float
+%result64 = std.sqrt %arg_f64 : f64
+// CHECK: llvm.call @__ocml_sqrt_f64(%{{.*}}) : (!llvm.double) -> 
!llvm.double
+std.return %result16, %result32, %result64 : f16, f32, f64
+  }
+}
+
+// -
+
 gpu.module @test_module {
   // CHECK: llvm.func @__ocml_tanh_f32(!llvm.float) -> !llvm.float
   // CHECK: llvm.func @__ocml_tanh_f64(!llvm.double) -> !llvm.double



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


[llvm-branch-commits] [clang] a053929 - [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

2020-12-10 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-12-10T10:12:15+01:00
New Revision: a0539298540e49cb734c7b82f93572ab46bf9b00

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

LOG: [AST] Fix a constexpr-evaluator crash on error-dependent returnstmt.

When the evaluator encounters an error-dependent returnstmt, before this patch
it returned a ESR_Returned without setting the result, the callsides think this
is a successful execution, and try to access the Result which causes the crash.

The fix is to always return failed as we don't know the result of the
error-dependent return stmt.

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

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
clang/test/SemaCXX/constexpr-function-recovery-crash.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index fc1d2cd7757e..0865b8b85138 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -5142,8 +5142,11 @@ static EvalStmtResult EvaluateStmt(StmtResult &Result, 
EvalInfo &Info,
   case Stmt::ReturnStmtClass: {
 const Expr *RetExpr = cast(S)->getRetValue();
 FullExpressionRAII Scope(Info);
-if (RetExpr && RetExpr->isValueDependent())
-  return EvaluateDependentExpr(RetExpr, Info) ? ESR_Returned : ESR_Failed;
+if (RetExpr && RetExpr->isValueDependent()) {
+  EvaluateDependentExpr(RetExpr, Info);
+  // We know we returned, but we don't know what the value is.
+  return ESR_Failed;
+}
 if (RetExpr &&
 !(Result.Slot
   ? EvaluateInPlace(Result.Value, Info, *Result.Slot, RetExpr)

diff  --git a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp 
b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
index 48a0d97619e4..94be9a12bc66 100644
--- a/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
+++ b/clang/test/SemaCXX/constexpr-function-recovery-crash.cpp
@@ -66,3 +66,6 @@ template constexpr int f(int y) { // expected-note 
{{candidate template i
 constexpr int test9(int x) {
   return f<1>(f(1)); // expected-error {{no matching function for call to 
'f'}}
 }
+
+constexpr int test10() { return undef(); } // expected-error {{use of 
undeclared identifier 'undef'}}
+static_assert(test10() <= 1, "should not crash"); // expected-error 
{{static_assert expression is not an integral constant expression}}



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


[llvm-branch-commits] [llvm] 426bee7 - [gn build] Port f80b29878b0

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-10T09:13:09Z
New Revision: 426bee7ad735fc8ca7b2b8a721ce1a8f3cb107bc

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

LOG: [gn build] Port f80b29878b0

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn
index 66e67af338bd..dee40f4f4e47 100644
--- a/llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn
@@ -108,12 +108,14 @@ static_library("LLVMX86CodeGen") {
 "X86LegalizerInfo.cpp",
 "X86LoadValueInjectionLoadHardening.cpp",
 "X86LoadValueInjectionRetHardening.cpp",
+"X86LowerAMXType.cpp",
 "X86MCInstLower.cpp",
 "X86MachineFunctionInfo.cpp",
 "X86MacroFusion.cpp",
 "X86OptimizeLEAs.cpp",
 "X86PadShortFunction.cpp",
 "X86PartialReduction.cpp",
+"X86PreTileConfig.cpp",
 "X86RegisterBankInfo.cpp",
 "X86RegisterInfo.cpp",
 "X86SelectionDAGInfo.cpp",
@@ -124,6 +126,7 @@ static_library("LLVMX86CodeGen") {
 "X86TargetMachine.cpp",
 "X86TargetObjectFile.cpp",
 "X86TargetTransformInfo.cpp",
+"X86TileConfig.cpp",
 "X86VZeroUpper.cpp",
 "X86WinAllocaExpander.cpp",
 "X86WinEHState.cpp",



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


[llvm-branch-commits] [llvm] eec5b99 - [ARM] MVE vcreate tests, for dual lane moves. NFC

2020-12-10 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-10T09:17:34Z
New Revision: eec5b99901826852f13e11e7f807e175d434f1cd

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

LOG: [ARM] MVE vcreate tests, for dual lane moves. NFC

Added: 
llvm/test/CodeGen/Thumb2/mve-vcreate.ll

Modified: 
llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll

Removed: 




diff  --git a/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll 
b/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
index 475a392b7c1c..0259cd6770ad 100644
--- a/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
+++ b/llvm/test/CodeGen/Thumb2/mve-pred-constfold.ll
@@ -367,7 +367,6 @@ define arm_aapcs_vfpcc i32 @const_mask_threepredabab(<4 x 
i32> %0, <4 x i32> %1,
 }
 
 
-
 declare i32 @llvm.arm.mve.pred.v2i.v4i1(<4 x i1>)
 declare i32 @llvm.arm.mve.pred.v2i.v8i1(<8 x i1>)
 declare i32 @llvm.arm.mve.pred.v2i.v16i1(<16 x i1>)

diff  --git a/llvm/test/CodeGen/Thumb2/mve-vcreate.ll 
b/llvm/test/CodeGen/Thumb2/mve-vcreate.ll
new file mode 100644
index ..e408bc46b47a
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb2/mve-vcreate.ll
@@ -0,0 +1,482 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve 
-verify-machineinstrs %s -o - | FileCheck %s
+
+define arm_aapcs_vfpcc <4 x i32> @vcreate_i32(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: vcreate_i32:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov.32 q0[0], r1
+; CHECK-NEXT:vmov.32 q0[1], r0
+; CHECK-NEXT:vmov.32 q0[2], r3
+; CHECK-NEXT:vmov.32 q0[3], r2
+; CHECK-NEXT:bx lr
+entry:
+  %conv = zext i32 %a to i64
+  %shl = shl nuw i64 %conv, 32
+  %conv1 = zext i32 %b to i64
+  %or = or i64 %shl, %conv1
+  %0 = insertelement <2 x i64> undef, i64 %or, i64 0
+  %conv2 = zext i32 %c to i64
+  %shl3 = shl nuw i64 %conv2, 32
+  %conv4 = zext i32 %d to i64
+  %or5 = or i64 %shl3, %conv4
+  %1 = insertelement <2 x i64> %0, i64 %or5, i64 1
+  %2 = bitcast <2 x i64> %1 to <4 x i32>
+  ret <4 x i32> %2
+}
+
+define arm_aapcs_vfpcc <4 x i32> @insert_0123(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: insert_0123:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov.32 q0[0], r0
+; CHECK-NEXT:vmov.32 q0[1], r1
+; CHECK-NEXT:vmov.32 q0[2], r2
+; CHECK-NEXT:vmov.32 q0[3], r3
+; CHECK-NEXT:bx lr
+entry:
+  %v1 = insertelement <4 x i32> undef, i32 %a, i32 0
+  %v2 = insertelement <4 x i32> %v1, i32 %b, i32 1
+  %v3 = insertelement <4 x i32> %v2, i32 %c, i32 2
+  %v4 = insertelement <4 x i32> %v3, i32 %d, i32 3
+  ret <4 x i32> %v4
+}
+
+define arm_aapcs_vfpcc <4 x i32> @insert_3210(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: insert_3210:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov.32 q0[0], r3
+; CHECK-NEXT:vmov.32 q0[1], r2
+; CHECK-NEXT:vmov.32 q0[2], r1
+; CHECK-NEXT:vmov.32 q0[3], r0
+; CHECK-NEXT:bx lr
+entry:
+  %v1 = insertelement <4 x i32> undef, i32 %a, i32 3
+  %v2 = insertelement <4 x i32> %v1, i32 %b, i32 2
+  %v3 = insertelement <4 x i32> %v2, i32 %c, i32 1
+  %v4 = insertelement <4 x i32> %v3, i32 %d, i32 0
+  ret <4 x i32> %v4
+}
+
+define arm_aapcs_vfpcc <4 x i32> @insert_0213(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: insert_0213:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov.32 q0[0], r0
+; CHECK-NEXT:vmov.32 q0[1], r2
+; CHECK-NEXT:vmov.32 q0[2], r1
+; CHECK-NEXT:vmov.32 q0[3], r3
+; CHECK-NEXT:bx lr
+entry:
+  %v1 = insertelement <4 x i32> undef, i32 %a, i32 0
+  %v2 = insertelement <4 x i32> %v1, i32 %b, i32 2
+  %v3 = insertelement <4 x i32> %v2, i32 %c, i32 1
+  %v4 = insertelement <4 x i32> %v3, i32 %d, i32 3
+  ret <4 x i32> %v4
+}
+
+define arm_aapcs_vfpcc <4 x i32> @insert_0220(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: insert_0220:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov.32 q0[0], r3
+; CHECK-NEXT:vmov.32 q0[2], r2
+; CHECK-NEXT:bx lr
+entry:
+  %v1 = insertelement <4 x i32> undef, i32 %a, i32 0
+  %v2 = insertelement <4 x i32> %v1, i32 %b, i32 2
+  %v3 = insertelement <4 x i32> %v2, i32 %c, i32 2
+  %v4 = insertelement <4 x i32> %v3, i32 %d, i32 0
+  ret <4 x i32> %v4
+}
+
+define arm_aapcs_vfpcc <4 x i32> @insert_321(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: insert_321:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:vmov.32 q0[1], r2
+; CHECK-NEXT:vmov.32 q0[2], r1
+; CHECK-NEXT:vmov.32 q0[3], r0
+; CHECK-NEXT:bx lr
+entry:
+  %v1 = insertelement <4 x i32> undef, i32 %a, i32 3
+  %v2 = insertelement <4 x i32> %v1, i32 %b, i32 2
+  %v3 = insertelement <4 x i32> %v2, i32 %c, i32 1
+  ret <4 x i32> %v3
+}
+
+define arm_aapcs_vfpcc <4 x i32> @insert_310(i32 %a, i32 %b, i32 %c, i32 %d) {
+; CHECK-LABEL: insert_310:
+; CHECK:   @ %bb.0:

[llvm-branch-commits] [mlir] 1d00508 - [mlir][Shape] Make sure tensor_cast(constant_shape) folding uses the correct type

2020-12-10 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-10T10:49:25+01:00
New Revision: 1d00508c5bf0d43203e11765ce84cdd6cf257856

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

LOG: [mlir][Shape] Make sure tensor_cast(constant_shape) folding uses the 
correct type

This is still subtle, but I think the test cases are sufficient to show
that it works.

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

Added: 


Modified: 
mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
mlir/test/Dialect/Shape/canonicalize.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td 
b/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
index 43c670a8582e..4e6d062a232f 100644
--- a/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
+++ b/mlir/lib/Dialect/Shape/IR/ShapeCanonicalization.td
@@ -32,5 +32,7 @@ def SizeToIndexToSizeCanonicalization : Pat<
   (Shape_IndexToSizeOp (Shape_SizeToIndexOp $arg)),
   (replaceWithValue $arg)>;
 
+// Fold tensor_cast(const_shape) to const_shape. This changes the type of
+// const_shape to the destination type of the cast.
 def TensorCastConstShape : Pat <
-  (TensorCastOp (Shape_ConstShapeOp:$c $ty)), (replaceWithValue $c)>;
+  (TensorCastOp (Shape_ConstShapeOp $arg)), (Shape_ConstShapeOp $arg)>;

diff  --git a/mlir/test/Dialect/Shape/canonicalize.mlir 
b/mlir/test/Dialect/Shape/canonicalize.mlir
index 9cb01da75901..aa43f515f753 100644
--- a/mlir/test/Dialect/Shape/canonicalize.mlir
+++ b/mlir/test/Dialect/Shape/canonicalize.mlir
@@ -872,13 +872,24 @@ func @fold_assuming_all_single_element(%arg: 
tensor) {
 
 // -
 
-// Fold tensor_cast of a const_shape to const_shape
-// CHECK-LABEL: @fold_tensor_cast_of_const_shape
-func @fold_tensor_cast_of_const_shape(%arg: tensor) {
+// Verify that tensor_cast folding uses the correct type
+// CHECK-LABEL: @fold_tensor_cast_of_const_shape_returned
+func @fold_tensor_cast_of_const_shape_returned(%arg: i1) -> tensor<1xindex> {
+  // CHECK: constant dense<2> : tensor<1xindex>
   // CHECK-NOT: tensor_cast
   %0 = shape.const_shape [2] : tensor
   %1 = tensor_cast %0 : tensor to tensor<1xindex>
-  %2 = shape.cstr_broadcastable %1, %0 : tensor<1xindex>, tensor
-  "consume.witness"(%2) : (!shape.witness) -> ()
-  return
+  return %1 : tensor<1xindex>
+}
+
+// -
+
+// Verify that tensor_cast folding uses the correct type
+// CHECK-LABEL: @fold_tensor_cast_of_const_shape_returned_dynamic
+func @fold_tensor_cast_of_const_shape_returned_dynamic(%arg: i1) -> 
tensor {
+  // CHECK: shape.const_shape [2] : tensor
+  // CHECK-NOT: tensor_cast
+  %0 = shape.const_shape [2] : tensor<1xindex>
+  %1 = tensor_cast %0 : tensor<1xindex> to tensor
+  return %1 : tensor
 }



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


[llvm-branch-commits] [llvm] eeb713b - [Hexagon] Fold single-use variables into assert. NFCI.

2020-12-10 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-10T10:53:56+01:00
New Revision: eeb713bbe24207343c8666a3240265758cd4fabd

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

LOG: [Hexagon] Fold single-use variables into assert. NFCI.

Silences unused variable warnings in Release builds.

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp 
b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index 1bfb4cef3eb6..8af1f6d15ad1 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -1088,8 +1088,7 @@ auto HexagonVectorCombine::vresize(IRBuilder<> &Builder, 
Value *Val,
int NewSize, Value *Pad) const -> Value * {
   assert(isa(Val->getType()));
   auto *ValTy = cast(Val->getType());
-  auto *PadTy = Pad->getType();
-  assert(ValTy->getElementType() == PadTy);
+  assert(ValTy->getElementType() == Pad->getType());
 
   int CurSize = ValTy->getElementCount().getFixedValue();
   if (CurSize == NewSize)
@@ -1173,7 +1172,6 @@ auto HexagonVectorCombine::createHvxIntrinsic(IRBuilder<> 
&Builder,
   int HwLen = HST.getVectorLength();
   Type *BoolTy = Type::getInt1Ty(F.getContext());
   Type *Int32Ty = Type::getInt32Ty(F.getContext());
-  Type *Int64Ty = Type::getInt64Ty(F.getContext());
   // HVX vector -> v16i32/v32i32
   // HVX vector predicate -> v512i1/v1024i1
   auto getTypeForIntrin = [&](Type *Ty) -> Type * {
@@ -1186,7 +1184,7 @@ auto HexagonVectorCombine::createHvxIntrinsic(IRBuilder<> 
&Builder,
   return VectorType::get(Int32Ty, HwLen / 4, /*Scalable*/ false);
 }
 // Non-HVX type. It should be a scalar.
-assert(Ty == Int32Ty || Ty == Int64Ty);
+assert(Ty == Int32Ty || Ty->isIntegerTy(64));
 return Ty;
   };
 



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


[llvm-branch-commits] [lldb] 4df4edb - [lldb][NFC] Fix a typo in TestCppMultipleInheritance

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T10:56:46+01:00
New Revision: 4df4edb6ad14c7748acda8670944cde19d537621

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

LOG: [lldb][NFC] Fix a typo in TestCppMultipleInheritance

Added: 


Modified: 
lldb/test/API/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py

Removed: 




diff  --git 
a/lldb/test/API/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py 
b/lldb/test/API/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py
index defd4bd5df5f..bc2b7a5f95b0 100644
--- a/lldb/test/API/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py
+++ b/lldb/test/API/lang/cpp/multiple-inheritance/TestCppMultipleInheritance.py
@@ -9,7 +9,7 @@ class TestCase(TestBase):
 
 def test(self):
 self.build()
-lldbutil.run_to_source_breakpoint(self,"// break here", 
lldb.SBFileSpec("main.cpp"))
+lldbutil.run_to_source_breakpoint(self, "// break here", 
lldb.SBFileSpec("main.cpp"))
 
 # Member access
 self.expect_expr("C.Base1::m_base", result_type="int", 
result_value="11")



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


[llvm-branch-commits] [llvm] 60806e8 - Remove Shapet assignment operator that's identical to the default. NFC.

2020-12-10 Thread Benjamin Kramer via llvm-branch-commits

Author: Benjamin Kramer
Date: 2020-12-10T10:58:41+01:00
New Revision: 60806e856a18262c544244f96739db2d9ac59424

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

LOG: Remove Shapet assignment operator that's identical to the default. NFC.

Added: 


Modified: 
llvm/include/llvm/CodeGen/TileShapeInfo.h

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TileShapeInfo.h 
b/llvm/include/llvm/CodeGen/TileShapeInfo.h
index f7ad81c25ebb..031d23555b7e 100644
--- a/llvm/include/llvm/CodeGen/TileShapeInfo.h
+++ b/llvm/include/llvm/CodeGen/TileShapeInfo.h
@@ -26,8 +26,6 @@
 #include "llvm/CodeGen/Register.h"
 #include 
 
-using namespace llvm;
-
 namespace llvm {
 
 class ShapeT {
@@ -57,14 +55,6 @@ class ShapeT {
 
   bool operator!=(const ShapeT &Shape) { return !(*this == Shape); }
 
-  ShapeT &operator=(const ShapeT &RHS) {
-Row = RHS.Row;
-Col = RHS.Col;
-RowImm = RHS.RowImm;
-ColImm = RHS.ColImm;
-return *this;
-  }
-
   MachineOperand *getRow() const { return Row; }
 
   MachineOperand *getCol() const { return Col; }



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


[llvm-branch-commits] [llvm] 137674f - [TruncInstCombine] Remove scalable vector restriction

2020-12-10 Thread Jun Ma via llvm-branch-commits

Author: Jun Ma
Date: 2020-12-10T18:00:19+08:00
New Revision: 137674f882fc7d08fc9bff8acecc240699eac096

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

LOG: [TruncInstCombine] Remove scalable vector restriction

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

Added: 


Modified: 
llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
llvm/test/Transforms/AggressiveInstCombine/trunc_const_expr.ll

Removed: 




diff  --git a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp 
b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
index e9418175c842..0bcebc17af8d 100644
--- a/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
+++ b/llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
@@ -289,11 +289,8 @@ Type *TruncInstCombine::getBestTruncatedType() {
 /// version of \p Ty, otherwise return \p Ty.
 static Type *getReducedType(Value *V, Type *Ty) {
   assert(Ty && !Ty->isVectorTy() && "Expect Scalar Type");
-  if (auto *VTy = dyn_cast(V->getType())) {
-// FIXME: should this handle scalable vectors?
-return FixedVectorType::get(Ty,
-cast(VTy)->getNumElements());
-  }
+  if (auto *VTy = dyn_cast(V->getType()))
+return VectorType::get(Ty, VTy->getElementCount());
   return Ty;
 }
 

diff  --git a/llvm/test/Transforms/AggressiveInstCombine/trunc_const_expr.ll 
b/llvm/test/Transforms/AggressiveInstCombine/trunc_const_expr.ll
index b83fcb470cc3..32f323602498 100644
--- a/llvm/test/Transforms/AggressiveInstCombine/trunc_const_expr.ll
+++ b/llvm/test/Transforms/AggressiveInstCombine/trunc_const_expr.ll
@@ -8,6 +8,7 @@ target datalayout = 
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
 
 declare i32 @use32(i32)
 declare <2 x i32> @use32_vec(<2 x i32>)
+declare  @use32_scale_vec()
 
 

 ;; These tests check cases where expression dag post-dominated by TruncInst
@@ -108,3 +109,35 @@ define void @const_expression_trunc_vec() {
   call <2 x i32> @use32_vec(<2 x i32> %T)
   ret void
 }
+
+define void @const_expression_mul_scale_vec() {
+; CHECK-LABEL: @const_expression_mul_scale_vec(
+; CHECK-NEXT:[[TMP1:%.*]] = call  
@use32_scale_vec( zeroinitializer)
+; CHECK-NEXT:ret void
+;
+  %A = mul  zeroinitializer, zeroinitializer
+  %T = trunc  %A to 
+  call  @use32_scale_vec( %T)
+  ret void
+}
+
+define void @const_expression_zext_scale_vec() {
+; CHECK-LABEL: @const_expression_zext_scale_vec(
+; CHECK-NEXT:[[TMP1:%.*]] = call  
@use32_scale_vec( zeroinitializer)
+; CHECK-NEXT:ret void
+;
+  %A = zext  zeroinitializer to 
+  %T = trunc  %A to 
+  call  @use32_scale_vec( %T)
+  ret void
+}
+
+define void @const_expression_trunc_scale_vec() {
+; CHECK-LABEL: @const_expression_trunc_scale_vec(
+; CHECK-NEXT:[[TMP1:%.*]] = call  
@use32_scale_vec( zeroinitializer)
+; CHECK-NEXT:ret void
+;
+  %T = trunc  zeroinitializer to 
+  call  @use32_scale_vec( %T)
+  ret void
+}



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


[llvm-branch-commits] [mlir] db884da - [mlir] Explicitly track branch instructions in translation to LLVM IR

2020-12-10 Thread Alex Zinenko via llvm-branch-commits

Author: Alex Zinenko
Date: 2020-12-10T11:08:58+01:00
New Revision: db884dafb7b5771e6ae01e8252f1520fac3e1c77

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

LOG: [mlir] Explicitly track branch instructions in translation to LLVM IR

The current implementation of the translation to LLVM IR relies on the
existence of a one-to-one mapping between MLIR blocks and LLVM IR basic blocks
in order to configure PHI nodes with appropriate source blocks. The one-to-one
mapping model is broken in presence of OpenMP operations that use LLVM's
OpenMPIRBuilder, which produces multiple blocks under the hood. This can lead
to invalid LLVM IR being emitted if OpenMPIRBuilder moved the branch operation
into a basic block different from the one it was originally created in;
specifically, a block that is not a direct predecessor could be used in the PHI
node. Instead, keep track of the mapping between MLIR LLVM dialect branch
operations and their LLVM IR counterparts and take the parent basic block of
the LLVM IR instruction at the moment of connecting the PHI nodes to
predecessors.

This behavior cannot be triggered as of now, but will be once we introduce the
conversion of OpenMP workshare loops.

Reviewed By: kiranchandramohan

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

Added: 


Modified: 
mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Removed: 




diff  --git a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h 
b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
index 996c8de06e37..d3d289414b38 100644
--- a/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
+++ b/mlir/include/mlir/Target/LLVMIR/ModuleTranslation.h
@@ -151,6 +151,11 @@ class ModuleTranslation {
   llvm::StringMap functionMapping;
   DenseMap valueMapping;
   DenseMap blockMapping;
+
+  /// A mapping between MLIR LLVM dialect terminators and LLVM IR terminators
+  /// they are converted to. This allows for conneting PHI nodes to the source
+  /// values after all operations are converted.
+  DenseMap branchMapping;
 };
 
 } // namespace LLVM

diff  --git a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp 
b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
index c20b19f2d5ca..057f57409940 100644
--- a/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ b/mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -340,9 +340,10 @@ static Value getPHISourceValue(Block *current, Block *pred,
 
 /// Connect the PHI nodes to the results of preceding blocks.
 template 
-static void
-connectPHINodes(T &func, const DenseMap &valueMapping,
-const DenseMap &blockMapping) {
+static void connectPHINodes(
+T &func, const DenseMap &valueMapping,
+const DenseMap &blockMapping,
+const DenseMap &branchMapping) {
   // Skip the first block, it cannot be branched to and its arguments 
correspond
   // to the arguments of the LLVM function.
   for (auto it = std::next(func.begin()), eit = func.end(); it != eit; ++it) {
@@ -355,9 +356,17 @@ connectPHINodes(T &func, const DenseMap &valueMapping,
   auto &phiNode = numberedPhiNode.value();
   unsigned index = numberedPhiNode.index();
   for (auto *pred : bb->getPredecessors()) {
+// Find the LLVM IR block that contains the converted terminator
+// instruction and use it in the PHI node. Note that this block is not
+// necessarily the same as blockMapping.lookup(pred), some operations
+// (in particular, OpenMP operations using OpenMPIRBuilder) may have
+// split the blocks.
+llvm::Instruction *terminator =
+branchMapping.lookup(pred->getTerminator());
+assert(terminator && "missing the mapping for a terminator");
 phiNode.addIncoming(valueMapping.lookup(getPHISourceValue(
 bb, pred, numArguments, index)),
-blockMapping.lookup(pred));
+terminator->getParent());
   }
 }
   }
@@ -476,7 +485,7 @@ void ModuleTranslation::convertOmpOpRegions(
   }
   // Finally, after all blocks have been traversed and values mapped,
   // connect the PHI nodes to the results of preceding blocks.
-  connectPHINodes(region, valueMapping, blockMapping);
+  connectPHINodes(region, valueMapping, blockMapping, branchMapping);
 }
 
 LogicalResult ModuleTranslation::convertOmpMaster(Operation &opInst,
@@ -682,7 +691,9 @@ LogicalResult ModuleTranslation::convertOperation(Operation 
&opInst,
   // Emit branches.  We need to look up the remapped blocks and ignore the 
block
   // arguments that were transformed into PHI nodes.
   if (auto brOp = dyn_cast(opInst)) {
-builder.CreateBr(blockMapping[brOp.getSuccessor()]);
+llvm::BranchInst *branch =
+builder.Creat

[llvm-branch-commits] [llvm] b0ce615 - [ARM] Remove copies from low overhead phi inductions.

2020-12-10 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-10T10:30:31Z
New Revision: b0ce615b2d29524b0b3541d07dd561665b710e79

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

LOG: [ARM] Remove copies from low overhead phi inductions.

The phi created in a low overhead loop gets created with a default
register class it seems. There are then copied inserted between the low
overhead loop pseudo instructions (which produce/consume GPRlr
instructions) and the phi holding the induction. This patch removes
those as a step towards attempting to make t2LoopDec and t2LoopEnd a
single instruction, and appears useful in it's own right as shown in the
tests.

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

Added: 


Modified: 
llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
llvm/test/CodeGen/Thumb2/LowOverheadLoops/count_dominates_start.mir
llvm/test/CodeGen/Thumb2/mve-fma-loops.ll
llvm/test/CodeGen/Thumb2/mve-gather-scatter-tailpred.ll
llvm/test/CodeGen/Thumb2/mve-pred-vctpvpsel.ll

Removed: 




diff  --git a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp 
b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
index e56c4ce36f7b..20cb98072c9a 100644
--- a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
+++ b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
@@ -59,7 +59,7 @@ class MVEVPTOptimisations : public MachineFunctionPass {
   }
 
 private:
-  bool RevertLoopWithCall(MachineLoop *ML);
+  bool MergeLoopEnd(MachineLoop *ML);
   bool ConvertTailPredLoop(MachineLoop *ML, MachineDominatorTree *DT);
   MachineInstr &ReplaceRegisterUseWithVPNOT(MachineBasicBlock &MBB,
 MachineInstr &Instr,
@@ -159,8 +159,15 @@ static bool findLoopComponents(MachineLoop *ML, 
MachineRegisterInfo *MRI,
   return true;
 }
 
-bool MVEVPTOptimisations::RevertLoopWithCall(MachineLoop *ML) {
-  LLVM_DEBUG(dbgs() << "RevertLoopWithCall on loop " << 
ML->getHeader()->getName()
+// This function converts loops with t2LoopEnd and t2LoopEnd instructions into
+// a single t2LoopEndDec instruction. To do that it needs to make sure that LR
+// will be valid to be used for the low overhead loop, which means nothing else
+// is using LR (especially calls) and there are no superfluous copies in the
+// loop. The t2LoopEndDec is a branching terminator that produces a value (the
+// decrement) around the loop edge, which means we need to be careful that they
+// will be valid to allocate without any spilling.
+bool MVEVPTOptimisations::MergeLoopEnd(MachineLoop *ML) {
+  LLVM_DEBUG(dbgs() << "MergeLoopEnd on loop " << ML->getHeader()->getName()
 << "\n");
 
   MachineInstr *LoopEnd, *LoopPhi, *LoopStart, *LoopDec;
@@ -181,7 +188,58 @@ bool MVEVPTOptimisations::RevertLoopWithCall(MachineLoop 
*ML) {
 }
   }
 
-  return false;
+  // Remove any copies from the loop, to ensure the phi that remains is both
+  // simpler and contains no extra uses. Because t2LoopEndDec is a terminator
+  // that cannot spill, we need to be careful what remains in the loop.
+  Register PhiReg = LoopPhi->getOperand(0).getReg();
+  Register DecReg = LoopDec->getOperand(0).getReg();
+  Register StartReg = LoopStart->getOperand(0).getReg();
+  // Ensure the uses are expected, and collect any copies we want to remove.
+  SmallVector Copies;
+  auto CheckUsers = [&Copies](Register BaseReg,
+  ArrayRef ExpectedUsers,
+  MachineRegisterInfo *MRI) {
+SmallVector Worklist;
+Worklist.push_back(BaseReg);
+while (!Worklist.empty()) {
+  Register Reg = Worklist.pop_back_val();
+  for (MachineInstr &MI : MRI->use_nodbg_instructions(Reg)) {
+if (count(ExpectedUsers, &MI))
+  continue;
+if (MI.getOpcode() != TargetOpcode::COPY ||
+!MI.getOperand(0).getReg().isVirtual()) {
+  LLVM_DEBUG(dbgs() << "Extra users of register found: " << MI);
+  return false;
+}
+Worklist.push_back(MI.getOperand(0).getReg());
+Copies.push_back(&MI);
+  }
+}
+return true;
+  };
+  if (!CheckUsers(PhiReg, {LoopDec}, MRI) ||
+  !CheckUsers(DecReg, {LoopPhi, LoopEnd}, MRI) ||
+  !CheckUsers(StartReg, {LoopPhi}, MRI))
+return false;
+
+  MRI->constrainRegClass(StartReg, &ARM::GPRlrRegClass);
+  MRI->constrainRegClass(PhiReg, &ARM::GPRlrRegClass);
+  MRI->constrainRegClass(DecReg, &ARM::GPRlrRegClass);
+
+  if (LoopPhi->getOperand(2).getMBB() == ML->getLoopLatch()) {
+LoopPhi->getOperand(3).setReg(StartReg);
+LoopPhi->getOperand(1).setReg(DecReg);
+  } else {
+LoopPhi->getOperand(1).setReg(StartReg);
+LoopPhi->getOperand(3).setReg(DecReg);
+  }
+
+  LoopDec->getOperand(1).setReg(PhiReg);
+  LoopEnd->getOperand(0).setReg(DecReg);
+
+  for (auto 

[llvm-branch-commits] [llvm] 5abbf20 - [ARM] Additional test for Min loop. NFC

2020-12-10 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-10T10:49:00Z
New Revision: 5abbf20f0fe5a1fed0d455bc682ca20d0eb651f7

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

LOG: [ARM] Additional test for Min loop. NFC

Added: 
llvm/test/CodeGen/Thumb2/LowOverheadLoops/minloop.ll

Modified: 


Removed: 




diff  --git a/llvm/test/CodeGen/Thumb2/LowOverheadLoops/minloop.ll 
b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/minloop.ll
new file mode 100644
index 0..9899417fb4d8e
--- /dev/null
+++ b/llvm/test/CodeGen/Thumb2/LowOverheadLoops/minloop.ll
@@ -0,0 +1,193 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=thumbv8.1m.main-none-none-eabi -mattr=+mve 
-verify-machineinstrs %s -o - | FileCheck %s
+
+define void @arm_min_q31(i32* nocapture readonly %pSrc, i32 %blockSize, i32* 
nocapture %pResult, i32* nocapture %pIndex) {
+; CHECK-LABEL: arm_min_q31:
+; CHECK:   @ %bb.0: @ %entry
+; CHECK-NEXT:.save {r4, r5, r6, r7, r8, r9, r10, r11, lr}
+; CHECK-NEXT:push.w {r4, r5, r6, r7, r8, r9, r10, r11, lr}
+; CHECK-NEXT:.pad #4
+; CHECK-NEXT:sub sp, #4
+; CHECK-NEXT:ldr.w r12, [r0]
+; CHECK-NEXT:subs.w r9, r1, #1
+; CHECK-NEXT:beq .LBB0_3
+; CHECK-NEXT:  @ %bb.1: @ %while.body.preheader
+; CHECK-NEXT:subs r6, r1, #2
+; CHECK-NEXT:and r7, r9, #3
+; CHECK-NEXT:cmp r6, #3
+; CHECK-NEXT:str r7, [sp] @ 4-byte Spill
+; CHECK-NEXT:bhs .LBB0_4
+; CHECK-NEXT:  @ %bb.2:
+; CHECK-NEXT:mov.w r8, #0
+; CHECK-NEXT:b .LBB0_6
+; CHECK-NEXT:  .LBB0_3:
+; CHECK-NEXT:mov.w r8, #0
+; CHECK-NEXT:b .LBB0_10
+; CHECK-NEXT:  .LBB0_4: @ %while.body.preheader.new
+; CHECK-NEXT:bic r6, r9, #3
+; CHECK-NEXT:movs r4, #1
+; CHECK-NEXT:subs r6, #4
+; CHECK-NEXT:mov.w r8, #0
+; CHECK-NEXT:add.w lr, r4, r6, lsr #2
+; CHECK-NEXT:movs r6, #4
+; CHECK-NEXT:mov lr, lr
+; CHECK-NEXT:mov r11, lr
+; CHECK-NEXT:  .LBB0_5: @ %while.body
+; CHECK-NEXT:@ =>This Inner Loop Header: Depth=1
+; CHECK-NEXT:ldr r10, [r0, #16]!
+; CHECK-NEXT:mov lr, r11
+; CHECK-NEXT:sub.w lr, lr, #1
+; CHECK-NEXT:sub.w r9, r9, #4
+; CHECK-NEXT:ldrd r7, r5, [r0, #-12]
+; CHECK-NEXT:mov r11, lr
+; CHECK-NEXT:ldr r4, [r0, #-4]
+; CHECK-NEXT:cmp r12, r7
+; CHECK-NEXT:it gt
+; CHECK-NEXT:subgt.w r8, r6, #3
+; CHECK-NEXT:csel r7, r7, r12, gt
+; CHECK-NEXT:cmp r7, r5
+; CHECK-NEXT:it gt
+; CHECK-NEXT:subgt.w r8, r6, #2
+; CHECK-NEXT:csel r7, r5, r7, gt
+; CHECK-NEXT:cmp r7, r4
+; CHECK-NEXT:it gt
+; CHECK-NEXT:subgt.w r8, r6, #1
+; CHECK-NEXT:csel r7, r4, r7, gt
+; CHECK-NEXT:cmp r7, r10
+; CHECK-NEXT:csel r8, r6, r8, gt
+; CHECK-NEXT:add.w r6, r6, #4
+; CHECK-NEXT:csel r12, r10, r7, gt
+; CHECK-NEXT:cmp.w lr, #0
+; CHECK-NEXT:bne .LBB0_5
+; CHECK-NEXT:b .LBB0_6
+; CHECK-NEXT:  .LBB0_6: @ %while.end.loopexit.unr-lcssa
+; CHECK-NEXT:ldr r7, [sp] @ 4-byte Reload
+; CHECK-NEXT:cbz r7, .LBB0_10
+; CHECK-NEXT:  @ %bb.7: @ %while.body.epil
+; CHECK-NEXT:ldr r4, [r0, #4]
+; CHECK-NEXT:sub.w r1, r1, r9
+; CHECK-NEXT:cmp r12, r4
+; CHECK-NEXT:csel r8, r1, r8, gt
+; CHECK-NEXT:csel r12, r4, r12, gt
+; CHECK-NEXT:cmp r7, #1
+; CHECK-NEXT:beq .LBB0_10
+; CHECK-NEXT:  @ %bb.8: @ %while.body.epil.1
+; CHECK-NEXT:ldr r4, [r0, #8]
+; CHECK-NEXT:cmp r12, r4
+; CHECK-NEXT:csinc r8, r8, r1, le
+; CHECK-NEXT:csel r12, r4, r12, gt
+; CHECK-NEXT:cmp r7, #2
+; CHECK-NEXT:beq .LBB0_10
+; CHECK-NEXT:  @ %bb.9: @ %while.body.epil.2
+; CHECK-NEXT:ldr r0, [r0, #12]
+; CHECK-NEXT:cmp r12, r0
+; CHECK-NEXT:it gt
+; CHECK-NEXT:addgt.w r8, r1, #2
+; CHECK-NEXT:csel r12, r0, r12, gt
+; CHECK-NEXT:  .LBB0_10: @ %while.end
+; CHECK-NEXT:str.w r12, [r2]
+; CHECK-NEXT:str.w r8, [r3]
+; CHECK-NEXT:add sp, #4
+; CHECK-NEXT:pop.w {r4, r5, r6, r7, r8, r9, r10, r11, pc}
+entry:
+  %0 = load i32, i32* %pSrc, align 4
+  %blkCnt.015 = add i32 %blockSize, -1
+  %cmp.not17 = icmp eq i32 %blkCnt.015, 0
+  br i1 %cmp.not17, label %while.end, label %while.body.preheader
+
+while.body.preheader: ; preds = %entry
+  %1 = add i32 %blockSize, -2
+  %xtraiter = and i32 %blkCnt.015, 3
+  %2 = icmp ult i32 %1, 3
+  br i1 %2, label %while.end.loopexit.unr-lcssa, label 
%while.body.preheader.new
+
+while.body.preheader.new: ; preds = 
%while.body.preheader
+  %unroll_iter = and i32 %blkCnt.015, -4
+  br label %while.body
+
+while.body:   ; preds = %while.body, 
%while.body.preheader.new
+  %pSrc.addr.021.pn = phi i32* [ %pSrc, %while.body.preheader.new ], [ 
%pSrc.addr.021.3, %while.body ]
+  %b

[llvm-branch-commits] [clang] 254677e - [clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks text

2020-12-10 Thread via llvm-branch-commits

Author: mydeveloperday
Date: 2020-12-10T11:06:48Z
New Revision: 254677e9ed4e705c1138166dc8053edad8ee7ed3

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

LOG: [clang-format] [NFC] Fix spelling and grammatical errors in IncludeBlocks 
text

Fix spelling mistake
Leave space after `.` and before beginning of next sentence
Reword it slightly to try and make it more readable.
Ensure RST is updated correctly (it generated a change)

Reviewed By: HazardyKnusperkeks, curdeius

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Tooling/Inclusions/IncludeStyle.h

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 55d706fe..239c9177bec2 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1713,11 +1713,11 @@ the configuration (without a prefix: ``Auto``).
   always need to be first.
 
   There is a third and optional field ``SortPriority`` which can used while
-  ``IncludeBloks = IBS_Regroup`` to define the priority in which ``#includes``
-  should be ordered, and value of ``Priority`` defines the order of
-  ``#include blocks`` and also enables to group ``#includes`` of 
diff erent
-  priority for order.``SortPriority`` is set to the value of ``Priority``
-  as default if it is not assigned.
+  ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  ``#includes`` should be ordered. The value of ``Priority`` defines the
+  order of ``#include blocks`` and also allows the grouping of ``#includes``
+  of 
diff erent priority. ``SortPriority`` is set to the value of
+  ``Priority`` as default if it is not assigned.
 
   Each regular expression can be marked as case sensitive with the field
   ``CaseSensitive``, per default it is not.

diff  --git a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h 
b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
index 89b0d4635251..4caaf4121f15 100644
--- a/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
+++ b/clang/include/clang/Tooling/Inclusions/IncludeStyle.h
@@ -89,12 +89,11 @@ struct IncludeStyle {
   /// always need to be first.
   ///
   /// There is a third and optional field ``SortPriority`` which can used while
-  /// ``IncludeBloks = IBS_Regroup`` to define the priority in which
-  /// ``#includes`` should be ordered, and value of ``Priority`` defines the
-  /// order of
-  /// ``#include blocks`` and also enables to group ``#includes`` of 
diff erent
-  /// priority for order.``SortPriority`` is set to the value of ``Priority``
-  /// as default if it is not assigned.
+  /// ``IncludeBlocks = IBS_Regroup`` to define the priority in which
+  /// ``#includes`` should be ordered. The value of ``Priority`` defines the
+  /// order of ``#include blocks`` and also allows the grouping of 
``#includes``
+  /// of 
diff erent priority. ``SortPriority`` is set to the value of
+  /// ``Priority`` as default if it is not assigned.
   ///
   /// Each regular expression can be marked as case sensitive with the field
   /// ``CaseSensitive``, per default it is not.



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


[llvm-branch-commits] [clang] 7b2d62f - [clang-format] PR42434 Remove preprocessor and pragma lines from ObjectiveC guess

2020-12-10 Thread via llvm-branch-commits

Author: mydeveloperday
Date: 2020-12-10T11:13:22Z
New Revision: 7b2d62fd7f7befda2ce327d25075b0aac9bc6780

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

LOG: [clang-format] PR42434 Remove preprocessor and pragma lines from 
ObjectiveC guess

clang-format see the `disable:` in   __pragma(warning(disable:)) as ObjectiveC 
method call

Remove any line starting with `#` or __pragma line from being part of the 
ObjectiveC guess

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

Reviewed By: curdeius, krasimir

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

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a3f740ff8692..4263f7b47e7c 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2032,6 +2032,10 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
 };
 
 for (auto Line : AnnotatedLines) {
+  if (Line->First && (Line->First->TokenText.startswith("#") ||
+  Line->First->TokenText == "__pragma" ||
+  Line->First->TokenText == "_Pragma"))
+continue;
   for (const FormatToken *FormatTok = Line->First; FormatTok;
FormatTok = FormatTok->Next) {
 if ((FormatTok->Previous && FormatTok->Previous->is(tok::at) &&

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index e897402e502a..d3ea5c2b5880 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -16713,6 +16713,15 @@ TEST_F(FormatTest, GuessLanguageWithCaret) {
   guessLanguage("foo.h", "int(^foo[(kNumEntries + 10)])(char, float);"));
 }
 
+TEST_F(FormatTest, GuessLanguageWithPragmas) {
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "__pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "#pragma(warning(disable:))"));
+  EXPECT_EQ(FormatStyle::LK_Cpp,
+guessLanguage("foo.h", "_Pragma(warning(disable:))"));
+}
+
 TEST_F(FormatTest, FormatsInlineAsmSymbolicNames) {
   // ASM symbolic names are identifiers that must be surrounded by [] without
   // space in between:



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


[llvm-branch-commits] [clang] e9e6e3b - [clang-format] Add IndentPragma style to eliminate common clang-format off scenario

2020-12-10 Thread via llvm-branch-commits

Author: mydeveloperday
Date: 2020-12-10T11:17:33Z
New Revision: e9e6e3b34a8e0857a274df51aac27e88c1de402b

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

LOG: [clang-format] Add IndentPragma style to eliminate common clang-format off 
scenario

A quick search of github.com, shows one common scenario for excessive use of 
//clang-format off/on is the indentation of #pragma's, especially around the 
areas of loop optimization or OpenMP

This revision aims to help that by introducing an `IndentPragmas` style, the 
aim of which is to keep the pragma at the current level of scope

```
for (int i = 0; i < 5; i++) {
// clang-format off
#pragma HLS UNROLL
// clang-format on
for (int j = 0; j < 5; j++) {
// clang-format off
#pragma HLS UNROLL
// clang-format on
 
```

can become

```
for (int i = 0; i < 5; i++) {
#pragma HLS UNROLL
for (int j = 0; j < 5; j++) {
#pragma HLS UNROLL

```

This revision also support working alongside the `IndentPPDirective` of 
`BeforeHash` and `AfterHash` (see unit tests for examples)

Reviewed By: curdeius

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/lib/Format/UnwrappedLineParser.cpp
clang/lib/Format/UnwrappedLineParser.h
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 239c9177bec2..f63ed168f099 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1917,6 +1917,30 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+**IndentPragmas** (``bool``)
+  Indent pragmas
+
+  When ``false``, pragmas are flushed left or follow IndentPPDirectives.
+  When ``true``, pragmas are indented to the current scope level.
+
+  .. code-block:: c++
+
+false:  true:
+#pragma once   vs   #pragma once
+void foo() {void foo() {
+#pragma omp simd  #pragma omp simd
+  for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+#pragma omp simd#pragma omp simd
+for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+}   }
+#if 1   #if 1
+#pragma omp simd#pragma omp simd
+for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+}   }
+#endif  #endif
+  }   }
+}   }
+
 **IndentRequires** (``bool``)
   Indent the requires clause in a template
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6e304630fbdc..d8ed27687b63 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1528,6 +1528,29 @@ struct FormatStyle {
   /// \endcode
   bool IndentGotoLabels;
 
+  /// Indent pragmas
+  ///
+  /// When ``false``, pragmas are flushed left or follow IndentPPDirectives.
+  /// When ``true``, pragmas are indented to the current scope level.
+  /// \code
+  ///   false:  true:
+  ///   #pragma once   vs   #pragma once
+  ///   void foo() {void foo() {
+  ///   #pragma omp simd  #pragma omp simd
+  /// for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+  ///   #pragma omp simd#pragma omp simd
+  ///   for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+  ///   }   }
+  ///   #if 1   #if 1
+  ///   #pragma omp simd#pragma omp simd
+  ///   for (int i=0;i<10;i++) {for (int i=0;i<10;i++) {
+  ///   }   }
+  ///   #endif  #endif
+  /// }   }
+  ///   }   }
+  /// \endcode
+  bool IndentPragmas;
+
   /// Options for indenting preprocessor directives.
   enum PPDirectiveIndentStyle {
 /// Does not indent any directives.
@@ -2494,6 +2517,7 @@ struct FormatStyle {
IndentCaseLabels == R.IndentCaseLabels &&
  

[llvm-branch-commits] [clang] 95616a0 - [clang-format] NFC Add release note for IndentPragmas

2020-12-10 Thread via llvm-branch-commits

Author: mydeveloperday
Date: 2020-12-10T11:24:12Z
New Revision: 95616a033c16146b55352c5fb93af82e00422920

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

LOG: [clang-format] NFC Add release note for IndentPragmas

Add additional release note to announce new clang-format option added during 
{D92753}

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 7d68cdb99b48..ef7903e16f7f 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -272,13 +272,15 @@ clang-format
 };
 
 
-- Experimental Support in clang-format for concepts has been improved, to 
+- Experimental Support in clang-format for concepts has been improved, to
   aid this the follow options have been added
 
 - Option ``IndentRequires`` has been added to indent the ``requires`` keyword
   in templates.
 - Option ``BreakBeforeConceptDeclarations`` has been added to aid the 
formatting of concepts.
 
+- Option ``IndentPragmas`` has been added to allow #pragma to indented with 
the current scope level. This is especially useful when using #pragma to mark 
OpenMP sections of code.
+
 
 libclang
 



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


[llvm-branch-commits] [lldb] 9586082 - [lldb] Allow LLDB to automatically retry a failed expression with an imported std C++ module

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T12:29:17+01:00
New Revision: 958608285eb4d04c6e3dc7071fa429b43597585b

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

LOG: [lldb] Allow LLDB to automatically retry a failed expression with an 
imported std C++ module

By now LLDB can import the 'std' C++ module to improve expression evaluation,
but there are still a few problems to solve before we can do this by default.
One is that importing the C++ module is slightly slower than normal expression
evaluation (mostly because the disk access and loading the initial lookup data
is quite slow in comparison to the barebone Clang setup the rest of the LLDB
expression evaluator is usually doing). Another problem is that some complicated
types in the standard library aren't fully supported yet by the ASTImporter, so
we end up types that fail to import (which usually appears to the user as if the
type is empty or there is just no result variable).

To still allow people to adopt this mode in their daily debugging, this patch
adds a setting that allows LLDB to automatically retry failed expression with a
loaded C++ module. All success expressions will behave exactly as they would do
before this patch. Failed expressions get a another parse attempt if we find a
usable C++ module in the current execution context. This way we shouldn't have
any performance/parsing regressions in normal debugging workflows, while the
debugging workflows involving STL containers benefit from the C++ module type
info.

This setting is off by default for now with the intention to enable it by
default on macOS soon-ish.

The implementation is mostly just extracting the existing parse logic into its
own function and then calling the parse function again if the first evaluation
failed and we have a C++ module to retry the parsing with.

Reviewed By: shafik, JDevlieghere, aprantl

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

Added: 

lldb/test/API/commands/expression/import-std-module/retry-with-std-module/Makefile

lldb/test/API/commands/expression/import-std-module/retry-with-std-module/TestRetryWithStdModule.py

lldb/test/API/commands/expression/import-std-module/retry-with-std-module/main.cpp

Modified: 
lldb/include/lldb/Target/Target.h
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
lldb/source/Target/Target.cpp
lldb/source/Target/TargetProperties.td

Removed: 




diff  --git a/lldb/include/lldb/Target/Target.h 
b/lldb/include/lldb/Target/Target.h
index 47568c9e4429..69baefb964b0 100644
--- a/lldb/include/lldb/Target/Target.h
+++ b/lldb/include/lldb/Target/Target.h
@@ -65,6 +65,12 @@ enum LoadDependentFiles {
   eLoadDependentsNo,
 };
 
+enum ImportStdModule {
+  eImportStdModuleFalse,
+  eImportStdModuleFallback,
+  eImportStdModuleTrue,
+};
+
 class TargetExperimentalProperties : public Properties {
 public:
   TargetExperimentalProperties();
@@ -135,7 +141,7 @@ class TargetProperties : public Properties {
 
   bool GetEnableAutoImportClangModules() const;
 
-  bool GetEnableImportStdModule() const;
+  ImportStdModule GetImportStdModule() const;
 
   bool GetEnableAutoApplyFixIts() const;
 

diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
index a28b4a7fb42c..9be294750fa0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
@@ -417,7 +417,6 @@ void ClangUserExpression::CreateSourceCode(
 DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
 std::vector modules_to_import, bool for_completion) {
 
-  m_filename = m_clang_state->GetNextExprFileName();
   std::string prefix = m_expr_prefix;
 
   if (m_options.GetExecutionPolicy() == eExecutionPolicyTopLevel) {
@@ -477,9 +476,6 @@ CppModuleConfiguration GetModuleConfig(lldb::LanguageType 
language,
   if (!target)
 return LogConfigError("No target");
 
-  if (!target->GetEnableImportStdModule())
-return LogConfigError("Importing std module not enabled in settings");
-
   StackFrame *frame = exe_ctx.GetFramePtr();
   if (!frame)
 return LogConfigError("No frame");
@@ -529,8 +525,6 @@ CppModuleConfiguration GetModuleConfig(lldb::LanguageType 
language,
 bool ClangUserExpression::PrepareForParsing(
 DiagnosticManager &diagnostic_manager, ExecutionContext &exe_ctx,
 bool for_completion) {
-  Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
-
   InstallContext(exe_ctx);
 
   if (!SetupPersistentState(diagnostic_manager, exe_ctx))
@@ -551,50 +545,20 @@ bool ClangUserExpression::PrepareForPars

[llvm-branch-commits] [clang-tools-extra] bedf3a0 - [clang-tidy][NFC] Use moves instead of copies when constructing OptionsProviders.

2020-12-10 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-10T11:34:57Z
New Revision: bedf3a0f507113bb09acaa317c533d85fe52518a

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

LOG: [clang-tidy][NFC] Use moves instead of copies when constructing 
OptionsProviders.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 950a64f4c274..1de1b1baccb5 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -195,14 +195,13 @@ DefaultOptionsProvider::getRawOptions(llvm::StringRef 
FileName) {
 }
 
 ConfigOptionsProvider::ConfigOptionsProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &ConfigOptions,
-const ClangTidyOptions &OverrideOptions,
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions ConfigOptions, ClangTidyOptions OverrideOptions,
 llvm::IntrusiveRefCntPtr FS)
-: FileOptionsBaseProvider(GlobalOptions, DefaultOptions, OverrideOptions,
-  FS),
-  ConfigOptions(ConfigOptions) {}
+: FileOptionsBaseProvider(std::move(GlobalOptions),
+  std::move(DefaultOptions),
+  std::move(OverrideOptions), std::move(FS)),
+  ConfigOptions(std::move(ConfigOptions)) {}
 
 std::vector
 ConfigOptionsProvider::getRawOptions(llvm::StringRef FileName) {
@@ -227,24 +226,25 @@ ConfigOptionsProvider::getRawOptions(llvm::StringRef 
FileName) {
 }
 
 FileOptionsBaseProvider::FileOptionsBaseProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions OverrideOptions,
 llvm::IntrusiveRefCntPtr VFS)
-: DefaultOptionsProvider(GlobalOptions, DefaultOptions),
-  OverrideOptions(OverrideOptions), FS(std::move(VFS)) {
+: DefaultOptionsProvider(std::move(GlobalOptions),
+ std::move(DefaultOptions)),
+  OverrideOptions(std::move(OverrideOptions)), FS(std::move(VFS)) {
   if (!FS)
 FS = llvm::vfs::getRealFileSystem();
   ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration);
 }
 
 FileOptionsBaseProvider::FileOptionsBaseProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
-const FileOptionsBaseProvider::ConfigFileHandlers &ConfigHandlers)
-: DefaultOptionsProvider(GlobalOptions, DefaultOptions),
-  OverrideOptions(OverrideOptions), ConfigHandlers(ConfigHandlers) {}
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions OverrideOptions,
+FileOptionsBaseProvider::ConfigFileHandlers ConfigHandlers)
+: DefaultOptionsProvider(std::move(GlobalOptions),
+ std::move(DefaultOptions)),
+  OverrideOptions(std::move(OverrideOptions)),
+  ConfigHandlers(std::move(ConfigHandlers)) {}
 
 void FileOptionsBaseProvider::addRawFileOptions(
 llvm::StringRef AbsolutePath, std::vector &CurOptions) {
@@ -286,20 +286,20 @@ void FileOptionsBaseProvider::addRawFileOptions(
 }
 
 FileOptionsProvider::FileOptionsProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions OverrideOptions,
 llvm::IntrusiveRefCntPtr VFS)
-: FileOptionsBaseProvider(GlobalOptions, DefaultOptions, OverrideOptions,
-  VFS){}
+: FileOptionsBaseProvider(std::move(GlobalOptions),
+  std::move(DefaultOptions),
+  std::move(OverrideOptions), std::move(VFS)) {}
 
 FileOptionsProvider::FileOptionsProvider(
-const ClangTidyGlobalOptions &GlobalOptions,
-const ClangTidyOptions &DefaultOptions,
-const ClangTidyOptions &OverrideOptions,
-const FileOptionsBaseProvider::ConfigFileHandlers &ConfigHandlers)
-: FileOptionsBaseProvider(GlobalOptions, DefaultOptions, OverrideOptions,
-  ConfigHandlers) {}
+ClangTidyGlobalOptions GlobalOptions, ClangTidyOptions DefaultOptions,
+ClangTidyOptions Overr

[llvm-branch-commits] [llvm] 0c7cce5 - [AMDGPU] Resolve issues when picking between ds_read/write and ds_read2/write2

2020-12-10 Thread Mirko Brkusanin via llvm-branch-commits

Author: Mirko Brkusanin
Date: 2020-12-10T12:40:49+01:00
New Revision: 0c7cce54eba3249489530040f41103dd8e0049f7

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

LOG: [AMDGPU] Resolve issues when picking between ds_read/write and 
ds_read2/write2

Both ds_read_b128 and ds_read2_b64 are valid for 128bit 16-byte aligned
loads but the one that will be selected is determined either by the order in
tablegen or by the AddedComplexity attribute. Currently ds_read_b128 has
priority.

While ds_read2_b64 has lower alignment requirements, we cannot always
restrict ds_read_b128 to 16-byte alignment because of unaligned-access-mode
option. This was causing ds_read_b128 to be selected for 8-byte aligned
loads regardles of chosen access mode.

To resolve this we use two patterns for selecting ds_read_b128. One
requires alignment of 16-byte and the other requires
unaligned-access-mode option.

Same goes for ds_write2_b64 and ds_write_b128.

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

Added: 


Modified: 
llvm/lib/Target/AMDGPU/AMDGPU.td
llvm/lib/Target/AMDGPU/DSInstructions.td
llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-load-local-128.mir
llvm/test/CodeGen/AMDGPU/GlobalISel/lds-misaligned-bug.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/load-local.128.ll
llvm/test/CodeGen/AMDGPU/GlobalISel/store-local.128.ll
llvm/test/CodeGen/AMDGPU/lds-misaligned-bug.ll
llvm/test/CodeGen/AMDGPU/load-local.128.ll
llvm/test/CodeGen/AMDGPU/store-local.128.ll

Removed: 




diff  --git a/llvm/lib/Target/AMDGPU/AMDGPU.td 
b/llvm/lib/Target/AMDGPU/AMDGPU.td
index f27ee1975a7f..77063f370976 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPU.td
+++ b/llvm/lib/Target/AMDGPU/AMDGPU.td
@@ -1089,11 +1089,6 @@ def isGFX7GFX10 :
 "Subtarget->getGeneration() == AMDGPUSubtarget::GFX10">,
   AssemblerPredicate<(all_of (not FeatureGCN3Encoding), FeatureCIInsts)>;
 
-def isGFX7GFX8 :
-  Predicate<"Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS ||"
-"Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS">,
-  AssemblerPredicate<(all_of FeatureSouthernIslands, FeatureCIInsts)>;
-
 def isGFX7GFX8GFX9 :
   Predicate<"Subtarget->getGeneration() == AMDGPUSubtarget::SEA_ISLANDS ||"
 "Subtarget->getGeneration() == AMDGPUSubtarget::VOLCANIC_ISLANDS 
||"
@@ -1299,6 +1294,9 @@ def EnableFlatScratch : 
Predicate<"Subtarget->enableFlatScratch()">;
 
 def DisableFlatScratch : Predicate<"!Subtarget->enableFlatScratch()">;
 
+def HasUnalignedAccessMode : Predicate<"Subtarget->hasUnalignedAccessMode()">,
+  AssemblerPredicate<(all_of FeatureUnalignedAccessMode)>;
+
 // Include AMDGPU TD files
 include "SISchedule.td"
 include "GCNProcessors.td"

diff  --git a/llvm/lib/Target/AMDGPU/DSInstructions.td 
b/llvm/lib/Target/AMDGPU/DSInstructions.td
index 2e38619e2333..328c81005df4 100644
--- a/llvm/lib/Target/AMDGPU/DSInstructions.td
+++ b/llvm/lib/Target/AMDGPU/DSInstructions.td
@@ -680,7 +680,7 @@ foreach vt = VReg_64.RegTypes in {
 defm : DSReadPat_mc ;
 }
 
-let SubtargetPredicate = isGFX7GFX8 in {
+let SubtargetPredicate = isGFX7Plus in {
 
 foreach vt = VReg_96.RegTypes in {
 defm : DSReadPat_mc ;
@@ -690,9 +690,7 @@ foreach vt = VReg_128.RegTypes in {
 defm : DSReadPat_mc ;
 }
 
-}
-
-let SubtargetPredicate = isGFX9Plus in {
+let SubtargetPredicate = HasUnalignedAccessMode in {
 
 foreach vt = VReg_96.RegTypes in {
 defm : DSReadPat_mc ;
@@ -702,7 +700,9 @@ foreach vt = VReg_128.RegTypes in {
 defm : DSReadPat_mc ;
 }
 
-}
+} // End SubtargetPredicate = HasUnalignedAccessMode
+
+} // End SubtargetPredicate = isGFX7Plus
 
 } // End AddedComplexity = 100
 
@@ -835,7 +835,7 @@ foreach vt = VReg_64.RegTypes in {
 defm : DSWritePat_mc ;
 }
 
-let SubtargetPredicate = isGFX7GFX8 in {
+let SubtargetPredicate = isGFX7Plus in {
 
 foreach vt = VReg_96.RegTypes in {
 defm : DSWritePat_mc ;
@@ -845,9 +845,7 @@ foreach vt = VReg_128.RegTypes in {
 defm : DSWritePat_mc ;
 }
 
-}
-
-let SubtargetPredicate = isGFX9Plus in {
+let SubtargetPredicate = HasUnalignedAccessMode in {
 
 foreach vt = VReg_96.RegTypes in {
 defm : DSWritePat_mc ;
@@ -857,9 +855,12 @@ foreach vt = VReg_128.RegTypes in {
 defm : DSWritePat_mc ;
 }
 
-}
+} // End SubtargetPredicate = HasUnalignedAccessMode
+
+} // End SubtargetPredicate = isGFX7Plus
 
 } // End AddedComplexity = 100
+
 class DSAtomicRetPat : 
GCNPat <
   (frag (DS1Addr1Offset i32:$ptr, i16:$offset), vt:$value),
   (inst $ptr, getVregSrcForVT.ret:$value, offset:$offset, (i1 gds))

diff  --git 
a/llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-load-local-128.mir 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-load-local-128.mir
index e7c646ee73a7..71fc286dc75c 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/inst-select-load-loca

[llvm-branch-commits] [llvm] 693da9d - [dsymutil][DWARFLinker][NFC] Make interface of AddressMap more general.

2020-12-10 Thread Alexey Lapshin via llvm-branch-commits

Author: Alexey Lapshin
Date: 2020-12-10T14:57:08+03:00
New Revision: 693da9df7481c48dd1edb93e78c66ec57fddeb60

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

LOG: [dsymutil][DWARFLinker][NFC] Make interface of AddressMap more general.

Current interface of AddressMap assumes that relocations exist.
That is correct for not-linked object file but is not correct
for linked executable. This patch changes interface in such way
that AddressMap could be used not only with not-linked object files:

hasValidRelocationAt()

replaced with:

hasLiveMemoryLocation()
hasLiveAddressRange()

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

Added: 


Modified: 
llvm/include/llvm/DWARFLinker/DWARFLinker.h
llvm/lib/DWARFLinker/DWARFLinker.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.cpp
llvm/tools/dsymutil/DwarfLinkerForBinary.h

Removed: 




diff  --git a/llvm/include/llvm/DWARFLinker/DWARFLinker.h 
b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
index a96f403f6811..edf74168d5b3 100644
--- a/llvm/include/llvm/DWARFLinker/DWARFLinker.h
+++ b/llvm/include/llvm/DWARFLinker/DWARFLinker.h
@@ -64,14 +64,17 @@ class AddressesMap {
   /// section. Reset current relocation pointer if neccessary.
   virtual bool hasValidRelocs(bool ResetRelocsPtr = true) = 0;
 
-  /// Checks that there is a relocation against .debug_info
-  /// table between \p StartOffset and \p NextOffset.
-  ///
-  /// This function must be called with offsets in strictly ascending
-  /// order because it never looks back at relocations it already 'went past'.
-  /// \returns true and sets Info.InDebugMap if it is the case.
-  virtual bool hasValidRelocationAt(uint64_t StartOffset, uint64_t EndOffset,
-CompileUnit::DIEInfo &Info) = 0;
+  /// Checks that the specified DIE has a DW_AT_Location attribute
+  /// that references into a live code section. This function
+  /// must be called with DIE offsets in strictly ascending order.
+  virtual bool hasLiveMemoryLocation(const DWARFDie &DIE,
+ CompileUnit::DIEInfo &Info) = 0;
+
+  /// Checks that the specified DIE has a DW_AT_Low_pc attribute
+  /// that references into a live code section. This function
+  /// must be called with DIE offsets in strictly ascending order.
+  virtual bool hasLiveAddressRange(const DWARFDie &DIE,
+   CompileUnit::DIEInfo &Info) = 0;
 
   /// Apply the valid relocations to the buffer \p Data, taking into
   /// account that Data is at \p BaseOffset in the debug_info section.
@@ -497,7 +500,6 @@ class DWARFLinker {
   /// Check if a variable describing DIE should be kept.
   /// \returns updated TraversalFlags.
   unsigned shouldKeepVariableDIE(AddressesMap &RelocMgr, const DWARFDie &DIE,
- CompileUnit &Unit,
  CompileUnit::DIEInfo &MyInfo, unsigned Flags);
 
   unsigned shouldKeepSubprogramDIE(AddressesMap &RelocMgr, RangesTy &Ranges,

diff  --git a/llvm/lib/DWARFLinker/DWARFLinker.cpp 
b/llvm/lib/DWARFLinker/DWARFLinker.cpp
index 3ccbe12034cd..b48f6ea0e50f 100644
--- a/llvm/lib/DWARFLinker/DWARFLinker.cpp
+++ b/llvm/lib/DWARFLinker/DWARFLinker.cpp
@@ -421,32 +421,11 @@ void DWARFLinker::cleanupAuxiliarryData(LinkContext 
&Context) {
   DIEAlloc.Reset();
 }
 
-/// Get the starting and ending (exclusive) offset for the
-/// attribute with index \p Idx descibed by \p Abbrev. \p Offset is
-/// supposed to point to the position of the first attribute described
-/// by \p Abbrev.
-/// \return [StartOffset, EndOffset) as a pair.
-static std::pair
-getAttributeOffsets(const DWARFAbbreviationDeclaration *Abbrev, unsigned Idx,
-uint64_t Offset, const DWARFUnit &Unit) {
-  DataExtractor Data = Unit.getDebugInfoExtractor();
-
-  for (unsigned I = 0; I < Idx; ++I)
-DWARFFormValue::skipValue(Abbrev->getFormByIndex(I), Data, &Offset,
-  Unit.getFormParams());
-
-  uint64_t End = Offset;
-  DWARFFormValue::skipValue(Abbrev->getFormByIndex(Idx), Data, &End,
-Unit.getFormParams());
-
-  return std::make_pair(Offset, End);
-}
 
 /// Check if a variable describing DIE should be kept.
 /// \returns updated TraversalFlags.
 unsigned DWARFLinker::shouldKeepVariableDIE(AddressesMap &RelocMgr,
 const DWARFDie &DIE,
-CompileUnit &Unit,
 CompileUnit::DIEInfo &MyInfo,
 unsigned Flags) {
   const auto *Abbrev = DIE.getAbbreviationDeclarationPtr();
@@ -458,24 +437,12 @@ unsigned DWARFLinker::shouldKeepVariableDIE(AddressesMap 
&RelocMgr,
 return Fla

[llvm-branch-commits] [llvm] 879c15e - [llvm-rc] Handle driveless absolute windows paths when loading external files

2020-12-10 Thread Martin Storsjö via llvm-branch-commits

Author: Martin Storsjö
Date: 2020-12-10T14:11:06+02:00
New Revision: 879c15e890b4d25d28ea904e92497f091f796019

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

LOG: [llvm-rc] Handle driveless absolute windows paths when loading external 
files

When llvm-rc loads an external file, it looks for it relative to
a number of include directories and the current working directory.
If the path is considered absolute, llvm-rc tries to open the
filename as such, and doesn't try to open it relative to other
paths.

On Windows, a path name like "\dir\file" isn't considered absolute
as it lacks the drive name, but by appending it on top of the search
dirs, it's not found.

LLVM's sys::path::append just appends such a path (same with a properly
absolute posix path) after the paths it's supposed to be relative to.

This fix doesn't handle the case if the resource script and the
external file are on a different drive than the current working
directory; to fix that, we'd have to make LLVM's sys::path::append
handle appending fully absolute and partially absolute paths (ones
lacking a drive prefix but containing a root directory), or switch
to C++17's std::filesystem.

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

Added: 


Modified: 
llvm/test/tools/llvm-rc/absolute.test
llvm/tools/llvm-rc/ResourceFileWriter.cpp

Removed: 




diff  --git a/llvm/test/tools/llvm-rc/absolute.test 
b/llvm/test/tools/llvm-rc/absolute.test
index 95aff3e42440..fd8b2d68d41e 100644
--- a/llvm/test/tools/llvm-rc/absolute.test
+++ b/llvm/test/tools/llvm-rc/absolute.test
@@ -1,3 +1,7 @@
 ; RUN: touch %t.manifest
 ; RUN: echo "1 24 \"%t.manifest\"" > %t.rc
 ; RUN: llvm-rc -- %t.rc
+;; On Windows, try stripping out the drive name from the absolute path,
+;; and make sure the path still is found.
+; RUN: cat %t.rc | sed 's/"[a-zA-Z]:/"/' > %t2.rc
+; RUN: llvm-rc -- %t2.rc

diff  --git a/llvm/tools/llvm-rc/ResourceFileWriter.cpp 
b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
index c80605aed446..553bb754aea0 100644
--- a/llvm/tools/llvm-rc/ResourceFileWriter.cpp
+++ b/llvm/tools/llvm-rc/ResourceFileWriter.cpp
@@ -1514,8 +1514,16 @@ ResourceFileWriter::loadFile(StringRef File) const {
   SmallString<128> Cwd;
   std::unique_ptr Result;
 
-  // 0. The file path is absolute and the file exists.
-  if (sys::path::is_absolute(File))
+  // 0. The file path is absolute or has a root directory, so we shouldn't
+  // try to append it on top of other base directories. (An absolute path
+  // must have a root directory, but e.g. the path "\dir\file" on windows
+  // isn't considered absolute, but it does have a root directory. As long as
+  // sys::path::append doesn't handle appending an absolute path or a path
+  // starting with a root directory on top of a base, we must handle this
+  // case separately at the top. C++17's path::append handles that case
+  // properly though, so if using that to append paths below, this early
+  // exception case could be removed.)
+  if (sys::path::has_root_directory(File))
 return errorOrToExpected(MemoryBuffer::getFile(File, -1, false));
 
   // 1. The current working directory.



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


[llvm-branch-commits] [llvm] 0447f35 - [ARM][RegAlloc] Add t2LoopEndDec

2020-12-10 Thread David Green via llvm-branch-commits

Author: David Green
Date: 2020-12-10T12:14:23Z
New Revision: 0447f3508f0217e06b4acaaec0937091d071100a

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

LOG: [ARM][RegAlloc] Add t2LoopEndDec

We currently have problems with the way that low overhead loops are
specified, with LR being spilled between the t2LoopDec and the t2LoopEnd
forcing the entire loop to be reverted late in the backend. As they will
eventually become a single instruction, this patch introduces a
t2LoopEndDec which is the combination of the two, combined before
registry allocation to make sure this does not fail.

Unfortunately this instruction is a terminator that produces a value
(and also branches - it only produces the value around the branching
edge). So this needs some adjustment to phi elimination and the register
allocator to make sure that we do not spill this LR def around the loop
(needing to put a spill after the terminator). We treat the loop very
carefully, making sure that there is nothing else like calls that would
break it's ability to use LR. For that, this adds a
isUnspillableTerminator to opt in the new behaviour.

There is a chance that this could cause problems, and so I have added an
escape option incase. But I have not seen any problems in the testing
that I've tried, and not reverting Low overhead loops is important for
our performance. If this does work then we can hopefully do the same for
t2WhileLoopStart and t2DoLoopStart instructions.

This patch also contains the code needed to convert or revert the
t2LoopEndDec in the backend (which just needs a subs; bne) and the code
pre-ra to create them.

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

Added: 


Modified: 
llvm/include/llvm/CodeGen/TargetInstrInfo.h
llvm/lib/CodeGen/CalcSpillWeights.cpp
llvm/lib/CodeGen/MachineVerifier.cpp
llvm/lib/CodeGen/PHIElimination.cpp
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/lib/Target/ARM/ARMBaseInstrInfo.h
llvm/lib/Target/ARM/ARMInstrThumb2.td
llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
llvm/test/CodeGen/Thumb2/LowOverheadLoops/count_dominates_start.mir
llvm/test/CodeGen/Thumb2/LowOverheadLoops/fast-fp-loops.ll
llvm/test/CodeGen/Thumb2/LowOverheadLoops/minloop.ll
llvm/test/CodeGen/Thumb2/LowOverheadLoops/mve-float-loops.ll
llvm/test/CodeGen/Thumb2/mve-float32regloops.ll
llvm/test/CodeGen/Thumb2/mve-postinc-dct.ll
llvm/test/CodeGen/Thumb2/mve-postinc-lsr.ll
llvm/test/CodeGen/Thumb2/mve-satmul-loops.ll
llvm/test/CodeGen/Thumb2/mve-vldshuffle.ll

Removed: 




diff  --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h 
b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index 68fc129cc0ed..d7a0e47d3bb5 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -348,6 +348,12 @@ class TargetInstrInfo : public MCInstrInfo {
  unsigned &Size, unsigned &Offset,
  const MachineFunction &MF) const;
 
+  /// Return true if the given instruction is terminator that is unspillable,
+  /// according to isUnspillableTerminatorImpl.
+  bool isUnspillableTerminator(const MachineInstr *MI) const {
+return MI->isTerminator() && isUnspillableTerminatorImpl(MI);
+  }
+
   /// Returns the size in bytes of the specified MachineInstr, or ~0U
   /// when this function is not implemented by a target.
   virtual unsigned getInstSizeInBytes(const MachineInstr &MI) const {
@@ -954,6 +960,17 @@ class TargetInstrInfo : public MCInstrInfo {
 return None;
   }
 
+  /// Return true if the given terminator MI is not expected to spill. This
+  /// sets the live interval as not spillable and adjusts phi node lowering to
+  /// not introduce copies after the terminator. Use with care, these are
+  /// currently used for hardware loop intrinsics in very controlled 
situations,
+  /// created prior to registry allocation in loops that only have single phi
+  /// users for the terminators value. They may run out of registers if not 
used
+  /// carefully.
+  virtual bool isUnspillableTerminatorImpl(const MachineInstr *MI) const {
+return false;
+  }
+
 public:
   /// If the specific machine instruction is a instruction that moves/copies
   /// value from one register to another register return destination and source

diff  --git a/llvm/lib/CodeGen/CalcSpillWeights.cpp 
b/llvm/lib/CodeGen/CalcSpillWeights.cpp
index bf31441c37bb..16f380c1eb62 100644
--- a/llvm/lib/CodeGen/CalcSpillWeights.cpp
+++ b/llvm/lib/CodeGen/CalcSpillWeights.cpp
@@ -142,6 +142,7 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, 
SlotIndex *Start,
SlotIndex *End) {
   Machine

[llvm-branch-commits] [clang-tools-extra] ee02e20 - [clangd] NFC: Use SmallVector where possible

2020-12-10 Thread Kirill Bobyrev via llvm-branch-commits

Author: Kirill Bobyrev
Date: 2020-12-10T13:36:49+01:00
New Revision: ee02e20c0817745c47ea9be8e26e9a49afc9a7fd

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

LOG: [clangd] NFC: Use SmallVector where possible

SmallVector with default size is now the recommended version (D92522).

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/AST.cpp
clang-tools-extra/clangd/CompileCommands.cpp
clang-tools-extra/clangd/CompileCommands.h
clang-tools-extra/clangd/ConfigCompile.cpp
clang-tools-extra/clangd/FileDistance.cpp
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/Headers.h
clang-tools-extra/clangd/QueryDriverDatabase.cpp
clang-tools-extra/clangd/Selection.cpp
clang-tools-extra/clangd/Selection.h
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/SourceCode.cpp
clang-tools-extra/clangd/TUScheduler.cpp
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
clang-tools-extra/clangd/refactor/tweaks/DefineInline.cpp
clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
clang-tools-extra/clangd/support/Markup.cpp
clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
clang-tools-extra/clangd/unittests/TestIndex.cpp
clang-tools-extra/clangd/unittests/TestTU.cpp
clang-tools-extra/clangd/unittests/support/TraceTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/AST.cpp 
b/clang-tools-extra/clangd/AST.cpp
index d1702b2d25b6..d3615e23b0d6 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -258,7 +258,7 @@ std::string printTemplateSpecializationArgs(const NamedDecl 
&ND) {
   // TemplateArgumentTypeLocs, they only have TemplateArgumentTypes. So we
   // create a new argument location list from TypeSourceInfo.
   auto STL = TSI->getTypeLoc().getAs();
-  llvm::SmallVector ArgLocs;
+  llvm::SmallVector ArgLocs;
   ArgLocs.reserve(STL.getNumArgs());
   for (unsigned I = 0; I < STL.getNumArgs(); ++I)
 ArgLocs.push_back(STL.getArgLoc(I));

diff  --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index f6210a43b34e..96cbd8806ff6 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -367,7 +367,7 @@ llvm::ArrayRef 
ArgStripper::rulesFor(llvm::StringRef Arg) {
 for (unsigned ID = 1 /*Skip INVALID */; ID < DriverID::LastOption; ++ID) {
   if (PrevAlias[ID] || ID == DriverID::OPT_Xclang)
 continue; // Not canonical, or specially handled.
-  llvm::SmallVector Rules;
+  llvm::SmallVector Rules;
   // Iterate over each alias, to add rules for parsing it.
   for (unsigned A = ID; A != DriverID::OPT_INVALID; A = NextAlias[A]) {
 if (Prefixes[A] == nullptr) // option groups.

diff  --git a/clang-tools-extra/clangd/CompileCommands.h 
b/clang-tools-extra/clangd/CompileCommands.h
index 3efd80026cf6..2ba17a0e6c0d 100644
--- a/clang-tools-extra/clangd/CompileCommands.h
+++ b/clang-tools-extra/clangd/CompileCommands.h
@@ -92,7 +92,7 @@ class ArgStripper {
   static llvm::ArrayRef rulesFor(llvm::StringRef Arg);
   const Rule *matchingRule(llvm::StringRef Arg, unsigned Mode,
unsigned &ArgCount) const;
-  llvm::SmallVector Rules;
+  llvm::SmallVector Rules;
   std::deque Storage; // Store strings not found in option table.
 };
 

diff  --git a/clang-tools-extra/clangd/ConfigCompile.cpp 
b/clang-tools-extra/clangd/ConfigCompile.cpp
index 846c6a170b38..b1189e286826 100644
--- a/clang-tools-extra/clangd/ConfigCompile.cpp
+++ b/clang-tools-extra/clangd/ConfigCompile.cpp
@@ -137,7 +137,7 @@ struct FragmentCompiler {
 llvm::StringRef EnumName;
 const Located &Input;
 llvm::Optional Result;
-llvm::SmallVector ValidValues;
+llvm::SmallVector ValidValues;
 
   public:
 EnumSwitch(llvm::StringRef EnumName, const Located &In,

diff  --git a/clang-tools-extra/clangd/FileDistance.cpp 
b/clang-tools-extra/clangd/FileDistance.cpp
index 584c64d077e1..e1cead329189 100644
--- a/clang-tools-extra/clangd/FileDistance.cpp
+++ b/clang-tools-extra/clangd/FileDistance.cpp
@@ -58,8 +58,7 @@ const llvm::hash_code FileDistance::RootHash =
 FileDistance::FileDistance(llvm::StringMap Sources,
const FileDistanceOptions &Opts)
 : Opts(Opts) {
-  llvm::DenseMap>
-  DownEdges;
+  llvm::DenseMap> 
DownEdges;
   // Compute the best distance following only up edges.
   // Keep track of down edges, in case we can use them to improve on this.
   for (const auto &S : Sources) {
@@ -118,7 +117,7 @@ File

[llvm-branch-commits] [clang] 2fd3147 - [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-10 Thread Peter Waller via llvm-branch-commits

Author: Peter Waller
Date: 2020-12-10T12:34:26Z
New Revision: 2fd31472992f39eaa57e86b6c10969978ada2c3e

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

LOG: [AArch64][Driver][SVE] Push missing SVE feature error from driver to 
frontend

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is 
not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

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

Added: 
clang/test/Sema/arm-vector-types-support.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Driver/aarch64-sve-vector-bits.c

Removed: 
clang/test/Sema/neon-vector-types-support.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8ca176d3bb43..0e85be8f058b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -534,9 +534,6 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' 
along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 
-def err_drv_invalid_sve_vector_bits : Error<
-  "'-msve-vector-bits' is not supported without SVE enabled">;
-
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 97773d35a694..363bcc1d383d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2843,7 +2843,8 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_attribute_unsupported
-: Error<"%0 attribute is not supported for this target">;
+: Error<"%0 attribute is not supported on targets missing %1;"
+" specify an appropriate -march= or -mcpu=">;
 // The err_*_attribute_argument_not_int are separate because they're used by
 // VerifyIntegerConstantExpression.
 def err_aligned_attribute_argument_not_int : Error<

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 0fc531b8c3a0..fca6d95d361b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -381,12 +381,6 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve-vector-bits= flag is valid only if SVE is enabled.
-  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
-if (!HasSve)
-  D.Diag(diag::err_drv_invalid_sve_vector_bits);
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fbdbfbc9f8ec..6485bebc0e8e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7799,7 +7799,8 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7842,7 +7843,7 @@ static void HandleArmSveVectorBitsTypeAttr(QualType 
&CurType, ParsedAttr &Attr,
Sem

[llvm-branch-commits] [lldb] 208e3f5 - [lldb] Fix that symbols.clang-modules-cache-path is never initialized

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T13:37:40+01:00
New Revision: 208e3f5d9b6c172f65dbb9cdbc9354c81c6d8911

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

LOG: [lldb] Fix that symbols.clang-modules-cache-path is never initialized

LLDB is supposed to ask the Clang Driver what the default module cache path is
and then use that value as the default for the
`symbols.clang-modules-cache-path` setting. However, we use the property type
`String` to change `symbols.clang-modules-cache-path` even though the type of
that setting is `FileSpec`, so the setter will simply do nothing and return
`false`. We also don't check the return value of the setter, so this whole code
ends up not doing anything at all.

This changes the setter to use the correct property type and adds an assert that
we actually successfully set the default path. Also adds a test that checks that
the default value for this setting is never unset/empty path as this would
effectively disable the import-std-module feature from working by default.

Reviewed By: JDevlieghere, shafik

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

Added: 
lldb/test/Shell/Settings/TestDefaultModuleCachePath.test

Modified: 
lldb/include/lldb/Core/ModuleList.h
lldb/source/Core/ModuleList.cpp
lldb/test/Shell/helper/toolchain.py

Removed: 




diff  --git a/lldb/include/lldb/Core/ModuleList.h 
b/lldb/include/lldb/Core/ModuleList.h
index d90b27e474ac..1609f0f77c56 100644
--- a/lldb/include/lldb/Core/ModuleList.h
+++ b/lldb/include/lldb/Core/ModuleList.h
@@ -56,7 +56,7 @@ class ModuleListProperties : public Properties {
   ModuleListProperties();
 
   FileSpec GetClangModulesCachePath() const;
-  bool SetClangModulesCachePath(llvm::StringRef path);
+  bool SetClangModulesCachePath(const FileSpec &path);
   bool GetEnableExternalLookup() const;
   bool SetEnableExternalLookup(bool new_value);
 

diff  --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index cf276ba65931..b6e1ceb40889 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -82,8 +82,9 @@ ModuleListProperties::ModuleListProperties() {
[this] { UpdateSymlinkMappings(); 
});
 
   llvm::SmallString<128> path;
-  clang::driver::Driver::getDefaultModuleCachePath(path);
-  SetClangModulesCachePath(path);
+  if (clang::driver::Driver::getDefaultModuleCachePath(path)) {
+lldbassert(SetClangModulesCachePath(FileSpec(path)));
+  }
 }
 
 bool ModuleListProperties::GetEnableExternalLookup() const {
@@ -104,8 +105,8 @@ FileSpec ModuleListProperties::GetClangModulesCachePath() 
const {
   ->GetCurrentValue();
 }
 
-bool ModuleListProperties::SetClangModulesCachePath(llvm::StringRef path) {
-  return m_collection_sp->SetPropertyAtIndexAsString(
+bool ModuleListProperties::SetClangModulesCachePath(const FileSpec &path) {
+  return m_collection_sp->SetPropertyAtIndexAsFileSpec(
   nullptr, ePropertyClangModulesCachePath, path);
 }
 

diff  --git a/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test 
b/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test
new file mode 100644
index ..80dc0f25ce58
--- /dev/null
+++ b/lldb/test/Shell/Settings/TestDefaultModuleCachePath.test
@@ -0,0 +1,9 @@
+# RUN: %lldb-noinit -x -s %s | FileCheck %s
+settings show symbols.clang-modules-cache-path
+q
+# This test checks that we get *any* clang modules cache path by default. The
+# actual path depends on the operating system.
+# CHECK: symbols.clang-modules-cache-path (file) = "
+# Clang treats an empty path in the same way as 'no path', so explicitly check
+# that we never have an empty path by default.
+# CHECK-NOT: symbols.clang-modules-cache-path (file) = ""

diff  --git a/lldb/test/Shell/helper/toolchain.py 
b/lldb/test/Shell/helper/toolchain.py
index ebf9e03d81a0..59b078411c1c 100644
--- a/lldb/test/Shell/helper/toolchain.py
+++ b/lldb/test/Shell/helper/toolchain.py
@@ -54,6 +54,10 @@ def use_lldb_substitutions(config):
   command=FindTool('lldb'),
   extra_args=['-S', lldb_init],
   unresolved='fatal'),
+ToolSubst('%lldb-noinit',
+  command=FindTool('lldb'),
+  extra_args=['--no-lldbinit'],
+  unresolved='fatal'),
 ToolSubst('%lldb-server',
   command=FindTool("lldb-server"),
   extra_args=[],



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


[llvm-branch-commits] [clang] 2315e98 - [AArch64][Driver][SVE] Push missing SVE feature error from driver to frontend

2020-12-10 Thread Peter Waller via llvm-branch-commits

Author: Peter Waller
Date: 2020-12-10T12:43:14Z
New Revision: 2315e9874c92bf625ec84a5f45a4fa28bfbc16ce

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

LOG: [AArch64][Driver][SVE] Push missing SVE feature error from driver to 
frontend

... and give more guidance to users.

If specifying -msve-vector-bits on a non-SVE target, clang would say:

error: '-msve-vector-bits' is not supported without SVE enabled

1. The driver lacks logic for "implied features".
   This would result in this error being raised for -march=...+sve2,
   even though +sve2 implies +sve.

2. Feature implication is well modelled in LLVM, so push the error down
   the stack.

3. Hint to the user what flag they need to consider setting.

Now clang fails later, when the feature is used, saying:

  aarch64-sve-vector-bits.c:42:41: error: 'arm_sve_vector_bits' attribute is 
not supported on targets missing 'sve'; specify an appropriate -march= or -mcpu=
  typedef svint32_t noflag __attribute__((arm_sve_vector_bits(256)));

Move clang/test/Sema/{neon => arm}-vector-types-support.c and put tests for
this warning together in one place.

Reviewed By: sdesmalen

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

Added: 
clang/test/Sema/arm-vector-types-support.c

Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Driver/aarch64-sve-vector-bits.c

Removed: 
clang/test/Sema/neon-vector-types-support.c



diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 8ca176d3bb43..0e85be8f058b 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -534,9 +534,6 @@ def err_drv_cannot_mix_options : Error<"cannot specify '%1' 
along with '%0'">;
 
 def err_drv_invalid_object_mode : Error<"OBJECT_MODE setting %0 is not 
recognized and is not a valid setting.">;
 
-def err_drv_invalid_sve_vector_bits : Error<
-  "'-msve-vector-bits' is not supported without SVE enabled">;
-
 def err_aix_default_altivec_abi : Error<
   "The default Altivec ABI on AIX is not yet supported, use '-mabi=vec-extabi' 
for the extended Altivec ABI">;
 

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 97773d35a694..363bcc1d383d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2843,7 +2843,8 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_attribute_unsupported
-: Error<"%0 attribute is not supported for this target">;
+: Error<"%0 attribute is not supported on targets missing %1;"
+" specify an appropriate -march= or -mcpu=">;
 // The err_*_attribute_argument_not_int are separate because they're used by
 // VerifyIntegerConstantExpression.
 def err_aligned_attribute_argument_not_int : Error<

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 0fc531b8c3a0..fca6d95d361b 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -381,12 +381,6 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   if (V8_6Pos != std::end(Features))
 V8_6Pos = Features.insert(std::next(V8_6Pos), {"+i8mm", "+bf16"});
 
-  bool HasSve = llvm::is_contained(Features, "+sve");
-  // -msve-vector-bits= flag is valid only if SVE is enabled.
-  if (Args.hasArg(options::OPT_msve_vector_bits_EQ))
-if (!HasSve)
-  D.Diag(diag::err_drv_invalid_sve_vector_bits);
-
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_mno_unaligned_access))

diff  --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index fbdbfbc9f8ec..6485bebc0e8e 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -7799,7 +7799,8 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
   // not to need a separate attribute)
   if (!S.Context.getTargetInfo().hasFeature("neon") &&
   !S.Context.getTargetInfo().hasFeature("mve")) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr;
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
+<< Attr << "'neon' or 'mve'";
 Attr.setInvalid();
 return;
   }
@@ -7842,7 +7843,7 @@ static void HandleArmSveVectorBitsTypeAttr(QualType 
&CurType, ParsedAttr &Attr,
Sem

[llvm-branch-commits] [lldb] b9f0713 - [lldb/Docs] Fix lldb-x86_64-fedora URL as it is still a silent bot

2020-12-10 Thread Jan Kratochvil via llvm-branch-commits

Author: Jan Kratochvil
Date: 2020-12-10T13:52:10+01:00
New Revision: b9f0713f73a5aae97262f3cf07d74a96cbef8aa8

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

LOG: [lldb/Docs] Fix lldb-x86_64-fedora URL as it is still a silent bot

Added: 


Modified: 
lldb/docs/resources/bots.rst

Removed: 




diff  --git a/lldb/docs/resources/bots.rst b/lldb/docs/resources/bots.rst
index 926259bd92be..f80a2333992b 100644
--- a/lldb/docs/resources/bots.rst
+++ b/lldb/docs/resources/bots.rst
@@ -11,7 +11,7 @@ LLVM Buildbot is the place where volunteers provide build 
machines. Everyone can
 * `lldb-x86_64-debian `_
 * `lldb-aarch64-ubuntu `_
 * `lldb-arm-ubuntu `_
-* `lldb-x86_64-fedora `_
+* `lldb-x86_64-fedora `_
 
 An overview of all LLDB builders can be found here:
 



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


[llvm-branch-commits] [llvm] 99ad078 - [AArch64] Cortex-R82: remove crypto

2020-12-10 Thread Sjoerd Meijer via llvm-branch-commits

Author: Sjoerd Meijer
Date: 2020-12-10T12:54:51Z
New Revision: 99ad078b91ed601cd19c75a44106a4f86bfa1a41

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

LOG: [AArch64] Cortex-R82: remove crypto

Remove target features crypto for Cortex-R82, because it doesn't have any, and
add LSE which was missing while we are at it.
This also removes crypto from the v8-R architecture description because that
aligns better with GCC and so far none of the R-cores have implemented crypto,
so is probably a more sensible default.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/test/Preprocessor/aarch64-target-features.c
llvm/include/llvm/Support/AArch64TargetParser.def
llvm/unittests/Support/TargetParserTest.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index fca6d95d361b..13e4cac292d0 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -317,8 +317,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
   NoCrypto = true;
   }
 
-  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd ||
-  std::find(ItBegin, ItEnd, "+v8r") != ItEnd) {
+  if (std::find(ItBegin, ItEnd, "+v8.4a") != ItEnd) {
 if (HasCrypto && !NoCrypto) {
   // Check if we have NOT disabled an algorithm with something like:
   //   +crypto, -algorithm

diff  --git a/clang/test/Preprocessor/aarch64-target-features.c 
b/clang/test/Preprocessor/aarch64-target-features.c
index f0b01f519a85..178098197d53 100644
--- a/clang/test/Preprocessor/aarch64-target-features.c
+++ b/clang/test/Preprocessor/aarch64-target-features.c
@@ -240,7 +240,7 @@
 // CHECK-MCPU-A57: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-A72: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-CORTEX-A73: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
-// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" 
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fp16fml" "-target-feature" "+ras" 
"-target-feature" "+rdm" "-target-feature" "+rcpc" "-target-feature" 
"+fullfp16" "-target-feature" "+sm4" "-target-feature" "+sha3" 
"-target-feature" "+sha2" "-target-feature" "+aes"
+// CHECK-MCPU-CORTEX-R82: "-cc1"{{.*}} "-triple" "aarch64{{.*}}"  
"-target-feature" "+v8r" "-target-feature" "+fp-armv8" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+dotprod" "-target-feature" 
"+fp16fml" "-target-feature" "+ras" "-target-feature" "+lse" "-target-feature" 
"+rdm" "-target-feature" "+rcpc" "-target-feature" "+fullfp16"
 // CHECK-MCPU-M1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"
 // CHECK-MCPU-M4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto" "-target-feature" 
"+dotprod" "-target-feature" "+fullfp16"
 // CHECK-MCPU-KRYO: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-feature" 
"+neon" "-target-feature" "+crc" "-target-feature" "+crypto"

diff  --git a/llvm/include/llvm/Support/AArch64TargetParser.def 
b/llvm/include/llvm/Support/AArch64TargetParser.def
index 7625f5a6f6ab..34b6f72d4621 100644
--- a/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -51,14 +51,14 @@ AARCH64_ARCH("armv8.6-a", ARMV8_6A, "8.6-A", "v8.6a",
   AArch64::AEK_RDM  | AArch64::AEK_RCPC | AArch64::AEK_DOTPROD |
   AArch64::AEK_SM4  | AArch64::AEK_SHA3 | AArch64::AEK_BF16|
   AArch64::AEK_SHA2 | AArch64::AEK_AES  | AArch64::AEK_I8MM))
+// For v8-R, we do not enable crypto and align with GCC that enables a more
+// minimal set of optional architecture extensions.
 AARCH64_ARCH("armv8-r", ARMV8R, "8-R", "v8r",
  ARMBuildAttrs::CPUArch::v8_R, FK_CRYPTO_NEON_FP_ARMV8,
- (AArch64::AEK_CRC | AArch64::AEK_RDM  | AArch64::AEK_SSBS|
-  AArch64::AEK_CRYPTO  | AArch64::AEK_SM4  | AArch64::AEK_SHA3|
-  AArch64::AEK_SHA2| AArch64::AEK_AES  | AArch64::AEK_DOTPROD |
-  AArch64::AEK_FP  | AArch64::AEK_SIMD | AArch64::AEK_FP16|
-  AArch64::AEK_FP16FML | AArch64::AEK_RAS  | AArch64::AEK_RCPC|
-  AArch64::AEK_SB))
+   

[llvm-branch-commits] [llvm] 4b1e329 - [VE] Add vector reduce intrinsic instructions

2020-12-10 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-10T22:21:17+09:00
New Revision: 4b1e32925528b546de445ca81999f270acd54618

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

LOG: [VE] Add vector reduce intrinsic instructions

Add vrmax, vrmin, vfrmax, vfrmin, vrand, vror, and vrxor intrinsic
instructions and regression tests.

Reviewed By: simoll

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

Added: 
llvm/test/CodeGen/VE/VELIntrinsics/vfrmax.ll
llvm/test/CodeGen/VE/VELIntrinsics/vfrmin.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrand.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrmax.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrmin.ll
llvm/test/CodeGen/VE/VELIntrinsics/vror.ll
llvm/test/CodeGen/VE/VELIntrinsics/vrxor.ll

Modified: 
llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
llvm/lib/Target/VE/VEInstrIntrinsicVL.gen.td

Removed: 




diff  --git a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td 
b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
index d2d965085526..1db7003f0ffd 100644
--- a/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
+++ b/llvm/include/llvm/IR/IntrinsicsVEVL.gen.td
@@ -1094,3 +1094,49 @@ let TargetPrefix = "ve" in def int_ve_vl_vfsumd_vvl : 
GCCBuiltin<"__builtin_ve_v
 let TargetPrefix = "ve" in def int_ve_vl_vfsumd_vvml : 
GCCBuiltin<"__builtin_ve_vl_vfsumd_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_vfsums_vvl : 
GCCBuiltin<"__builtin_ve_vl_vfsums_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
 let TargetPrefix = "ve" in def int_ve_vl_vfsums_vvml : 
GCCBuiltin<"__builtin_ve_vl_vfsums_vvml">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswfstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswfstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxswlstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxswlstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstsx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstsx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstsx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstsx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswfstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswfstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstzx_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstzx_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrminswlstzx_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrminswlstzx_vvvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxslfst_vvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxslfst_vvl">, Intrinsic<[LLVMType], 
[LLVMType, LLVMType], [IntrNoMem]>;
+let TargetPrefix = "ve" in def int_ve_vl_vrmaxslfst_vvvl : 
GCCBuiltin<"__builtin_ve_vl_vrmaxslfst_

[llvm-branch-commits] [llvm] 2fc4afd - Fix a -Wunused-variable warning in release build.

2020-12-10 Thread Haojian Wu via llvm-branch-commits

Author: Haojian Wu
Date: 2020-12-10T14:52:45+01:00
New Revision: 2fc4afda0f57d6c99b591c1f71f6da933d5e7b31

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

LOG: Fix a -Wunused-variable warning in release build.

Added: 


Modified: 
llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp

Removed: 




diff  --git a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp 
b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
index 909d478a95ca..62f23cf49073 100644
--- a/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
+++ b/llvm/lib/Target/ARM/MVEVPTOptimisationsPass.cpp
@@ -257,6 +257,7 @@ bool MVEVPTOptimisations::MergeLoopEnd(MachineLoop *ML) {
   TII->get(ARM::t2LoopEndDec), DecReg)
   .addReg(PhiReg)
   .add(LoopEnd->getOperand(1));
+  (void)MI;
   LLVM_DEBUG(dbgs() << "Merged LoopDec and End into: " << *MI.getInstr());
 
   LoopDec->eraseFromParent();



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


[llvm-branch-commits] [llvm] abe7775 - [SVE][CodeGen] Extend index of masked gathers

2020-12-10 Thread Kerry McLaughlin via llvm-branch-commits

Author: Kerry McLaughlin
Date: 2020-12-10T13:54:45Z
New Revision: abe7775f5a43e5a0d8ec237542274ba3e73937e4

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

LOG: [SVE][CodeGen] Extend index of masked gathers

This patch changes performMSCATTERCombine to also promote the indices of
masked gathers where the element type is i8 or i16, and adds various tests
for gathers with illegal types.

Reviewed By: sdesmalen

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/test/CodeGen/AArch64/sve-masked-gather-legalize.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp 
b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 5d9c66e170eab..01301abf10e3d 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -849,6 +849,7 @@ AArch64TargetLowering::AArch64TargetLowering(const 
TargetMachine &TM,
   if (Subtarget->supportsAddressTopByteIgnored())
 setTargetDAGCombine(ISD::LOAD);
 
+  setTargetDAGCombine(ISD::MGATHER);
   setTargetDAGCombine(ISD::MSCATTER);
 
   setTargetDAGCombine(ISD::MUL);
@@ -14063,20 +14064,19 @@ static SDValue performSTORECombine(SDNode *N,
   return SDValue();
 }
 
-static SDValue performMSCATTERCombine(SDNode *N,
+static SDValue performMaskedGatherScatterCombine(SDNode *N,
   TargetLowering::DAGCombinerInfo &DCI,
   SelectionDAG &DAG) {
-  MaskedScatterSDNode *MSC = cast(N);
-  assert(MSC && "Can only combine scatter store nodes");
+  MaskedGatherScatterSDNode *MGS = cast(N);
+  assert(MGS && "Can only combine gather load or scatter store nodes");
 
-  SDLoc DL(MSC);
-  SDValue Chain = MSC->getChain();
-  SDValue Scale = MSC->getScale();
-  SDValue Index = MSC->getIndex();
-  SDValue Data = MSC->getValue();
-  SDValue Mask = MSC->getMask();
-  SDValue BasePtr = MSC->getBasePtr();
-  ISD::MemIndexType IndexType = MSC->getIndexType();
+  SDLoc DL(MGS);
+  SDValue Chain = MGS->getChain();
+  SDValue Scale = MGS->getScale();
+  SDValue Index = MGS->getIndex();
+  SDValue Mask = MGS->getMask();
+  SDValue BasePtr = MGS->getBasePtr();
+  ISD::MemIndexType IndexType = MGS->getIndexType();
 
   EVT IdxVT = Index.getValueType();
 
@@ -14086,16 +14086,27 @@ static SDValue performMSCATTERCombine(SDNode *N,
 if ((IdxVT.getVectorElementType() == MVT::i8) ||
 (IdxVT.getVectorElementType() == MVT::i16)) {
   EVT NewIdxVT = IdxVT.changeVectorElementType(MVT::i32);
-  if (MSC->isIndexSigned())
+  if (MGS->isIndexSigned())
 Index = DAG.getNode(ISD::SIGN_EXTEND, DL, NewIdxVT, Index);
   else
 Index = DAG.getNode(ISD::ZERO_EXTEND, DL, NewIdxVT, Index);
 
-  SDValue Ops[] = { Chain, Data, Mask, BasePtr, Index, Scale };
-  return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
-  MSC->getMemoryVT(), DL, Ops,
-  MSC->getMemOperand(), IndexType,
-  MSC->isTruncatingStore());
+  if (auto *MGT = dyn_cast(MGS)) {
+SDValue PassThru = MGT->getPassThru();
+SDValue Ops[] = { Chain, PassThru, Mask, BasePtr, Index, Scale };
+return DAG.getMaskedGather(DAG.getVTList(N->getValueType(0), 
MVT::Other),
+   PassThru.getValueType(), DL, Ops,
+   MGT->getMemOperand(),
+   MGT->getIndexType(), 
MGT->getExtensionType());
+  } else {
+auto *MSC = cast(MGS);
+SDValue Data = MSC->getValue();
+SDValue Ops[] = { Chain, Data, Mask, BasePtr, Index, Scale };
+return DAG.getMaskedScatter(DAG.getVTList(MVT::Other),
+MSC->getMemoryVT(), DL, Ops,
+MSC->getMemOperand(), IndexType,
+MSC->isTruncatingStore());
+  }
 }
   }
 
@@ -15072,9 +15083,6 @@ static SDValue performGatherLoadCombine(SDNode *N, 
SelectionDAG &DAG,
 static SDValue
 performSignExtendInRegCombine(SDNode *N, TargetLowering::DAGCombinerInfo &DCI,
   SelectionDAG &DAG) {
-  if (DCI.isBeforeLegalizeOps())
-return SDValue();
-
   SDLoc DL(N);
   SDValue Src = N->getOperand(0);
   unsigned Opc = Src->getOpcode();
@@ -15109,6 +15117,9 @@ performSignExtendInRegCombine(SDNode *N, 
TargetLowering::DAGCombinerInfo &DCI,
 return DAG.getNode(SOpc, DL, N->getValueType(0), Ext);
   }
 
+  if (DCI.isBeforeLegalizeOps())
+return SDValue();
+
   if (!EnableCombineMGatherIntrinsics)
 return SDValue();
 
@@ -15296,8 +15307,9 @@ SDValue AArch64TargetLowering::PerformDAGCom

[llvm-branch-commits] [lldb] 25c40a4 - [lldb] [docs] Add a manpage for lldb-server

2020-12-10 Thread Michał Górny via llvm-branch-commits

Author: Michał Górny
Date: 2020-12-10T15:02:25+01:00
New Revision: 25c40a45999e59e3b2902cd91373cd47e7a93488

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

LOG: [lldb] [docs] Add a manpage for lldb-server

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

Added: 
lldb/docs/man/lldb-server.rst

Modified: 
lldb/docs/conf.py

Removed: 




diff  --git a/lldb/docs/conf.py b/lldb/docs/conf.py
index cdab1b00e1b7..4d894bf050da 100644
--- a/lldb/docs/conf.py
+++ b/lldb/docs/conf.py
@@ -246,7 +246,9 @@
 
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
-man_pages = [('man/lldb', 'lldb', u'LLDB Documentation', [u'LLVM project'], 1)]
+man_pages = [('man/lldb', 'lldb', u'LLDB Documentation', [u'LLVM project'], 1),
+ ('man/lldb-server', 'lldb-server', u'LLDB Documentation', [u'LLVM 
project'], 1),
+ ]
 
 # If true, show URL addresses after external links.
 #man_show_urls = False

diff  --git a/lldb/docs/man/lldb-server.rst b/lldb/docs/man/lldb-server.rst
new file mode 100644
index ..a67c00b305f6
--- /dev/null
+++ b/lldb/docs/man/lldb-server.rst
@@ -0,0 +1,209 @@
+:orphan:
+
+lldb-server -- Server for LLDB Debugging Sessions
+=
+
+.. program:: lldb-server
+
+SYNOPSIS
+
+
+| :program:`lldb-server` v[ersion]
+| :program:`lldb-server` g[dbserver] [*options*]
+| :program:`lldb-server` p[latform] [*options*]
+
+DESCRIPTION
+---
+
+:program:`lldb-server` provides the server counterpart of the LLVM debugger.
+The server runs and monitors the debugged program, while the user interfaces
+with it via a client, either running locally or connecting remotely.
+
+All of the code in the LLDB project is available under the Apache 2.0 License
+with LLVM exceptions.
+
+COMMANDS
+
+
+The first argument to lldb-server specifies a command to run.
+
+.. option:: v[ersion]
+
+ Prints lldb-server version and exits.
+
+.. option:: g[dbserver]
+
+ Runs the server using the gdb-remote protocol. LLDB can afterwards
+ connect to the server using *gdb-remote* command.
+
+.. option:: p[latform]
+
+ Runs the platform server. LLDB can afterwards connect to the server using
+ *platform select*, followed by *platform connect*.
+
+GDBSERVER COMMAND
+-
+
+| :program:`lldb-server` g[dbserver] [*options*] [[*host*]:*port*] [[--] 
*program* *args*...]
+
+CONNECTION
+~~
+
+.. option:: host:port
+
+ Specifies the hostname and TCP port to listen on. Obligatory unless another
+ listening option is used. If host is empty, *localhost* will be used.  If port
+ is zero, a random port will be selected, and written as specified by --pipe
+ or --named-pipe options.
+
+.. option:: --fd 
+
+ Communicate over the given file descriptor instead of sockets.
+
+.. option:: --named-pipe 
+
+ Write the listening port number to the specified named pipe.
+
+.. option:: --pipe 
+
+ Write the listening port number to the specified pipe (fd).
+
+.. option:: --reverse-connect
+
+ Connect to the client instead of passively waiting for a connection. In this
+ case, [host]:port denotes the remote address to connect to.
+
+GENERAL OPTIONS
+~~~
+
+.. option:: --help
+
+ Prints out the usage information and exits.
+
+.. option:: --log-channels 
+
+ Channels to log. A colon-separated list of entries. Each entry starts with
+ a channel followed by a space-separated list of categories.
+
+.. option:: --log-file 
+
+ Destination file to log to. If empty, log to stderr.
+
+.. option:: --setsid
+
+ Run lldb-server in a new session.
+
+TARGET SELECTION
+
+
+.. option:: --attach 
+
+ Attach to the process given by a (numeric) process id or a name.
+
+.. option:: -- program args
+
+ Launch a program for debugging.
+
+If neither of target options are used, :program:`lldb-server` is started
+without a specific target. It can be afterwards instructed by the client
+to launch or attach.
+
+PLATFORM COMMAND
+
+
+| :program:`lldb-server` p[latform] [*options*] --server --listen 
[[*host*]:*port*]
+
+CONNECTION
+~~
+
+.. option:: --server
+
+ Run in server mode, handling multiple connections. If this is not specified,
+ lldb-server will accept only one connection and exit when it is finished.
+
+.. option:: --listen :
+
+ Hostname and port to listen on. Obligatory. If *port* is zero, a random port
+ will be used.
+
+.. option:: --socket-file 
+
+ Write the listening socket port number to the specified file.
+
+GENERAL OPTIONS
+~~~
+
+.. option:: --log-channels 
+
+ Channels to log. A colon-separated list of entries. Each entry starts with
+ a channel followed by a space-separated list of categories.
+
+.. option:: 

[llvm-branch-commits] [llvm] 7c9afe9 - [Hexagon] Fix gcc6 compilation issue

2020-12-10 Thread Krzysztof Parzyszek via llvm-branch-commits

Author: Krzysztof Parzyszek
Date: 2020-12-10T08:17:07-06:00
New Revision: 7c9afe9183ee5b2b649bfa34da2a83eca886a924

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

LOG: [Hexagon] Fix gcc6 compilation issue

Added: 


Modified: 
llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp

Removed: 




diff  --git a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp 
b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
index 8af1f6d15ad1..7791fb9a1a74 100644
--- a/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
@@ -483,7 +483,7 @@ auto AlignVectors::createAddressGroups() -> bool {
   auto traverseBlock = [&](DomTreeNode *DomN, auto Visit) -> void {
 BasicBlock &Block = *DomN->getBlock();
 for (Instruction &I : Block) {
-  auto AI = getAddrInfo(I);
+  auto AI = this->getAddrInfo(I); // Use this-> for gcc6.
   if (!AI)
 continue;
   auto F = findBaseAndOffset(*AI);



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


[llvm-branch-commits] [clang-tools-extra] 34d2688 - [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

2020-12-10 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-10T14:52:45Z
New Revision: 34d2688a50f23b4b15bdeab054e28e033ece9363

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

LOG: [clang-tidy] Use a MemoryBufferRef when parsing configuration files.

Using a MemoryBufferRef, If there is an error parsing, we can point the user to 
the location of the file.

Reviewed By: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clangd/TidyProvider.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
index 1de1b1baccb5..f17ef716d60f 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
@@ -360,7 +360,7 @@ FileOptionsBaseProvider::tryReadConfigFile(StringRef 
Directory) {
 if ((*Text)->getBuffer().empty())
   continue;
 llvm::ErrorOr ParsedOptions =
-ConfigHandler.second((*Text)->getBuffer());
+ConfigHandler.second({(*Text)->getBuffer(), ConfigFile});
 if (!ParsedOptions) {
   if (ParsedOptions.getError())
 llvm::errs() << "Error parsing " << ConfigFile << ": "
@@ -380,7 +380,8 @@ std::error_code parseLineFilter(StringRef LineFilter,
   return Input.error();
 }
 
-llvm::ErrorOr parseConfiguration(StringRef Config) {
+llvm::ErrorOr
+parseConfiguration(llvm::MemoryBufferRef Config) {
   llvm::yaml::Input Input(Config);
   ClangTidyOptions Options;
   Input >> Options;

diff  --git a/clang-tools-extra/clang-tidy/ClangTidyOptions.h 
b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
index b4a00f68d6cf..e7cd89951ff9 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyOptions.h
+++ b/clang-tools-extra/clang-tidy/ClangTidyOptions.h
@@ -192,7 +192,7 @@ class FileOptionsBaseProvider : public 
DefaultOptionsProvider {
   // A pair of configuration file base name and a function parsing
   // configuration from text in the corresponding format.
   typedef std::pair(
- llvm::StringRef)>>
+ llvm::MemoryBufferRef)>>
   ConfigFileHandler;
 
   /// Configuration file handlers listed in the order of priority.
@@ -308,7 +308,8 @@ std::error_code parseLineFilter(llvm::StringRef LineFilter,
 
 /// Parses configuration from JSON and returns \c ClangTidyOptions or an
 /// error.
-llvm::ErrorOr parseConfiguration(llvm::StringRef Config);
+llvm::ErrorOr
+parseConfiguration(llvm::MemoryBufferRef Config);
 
 /// Serializes configuration to a YAML-encoded string.
 std::string configurationAsText(const ClangTidyOptions &Options);

diff  --git a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp 
b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
index beef79e17769..2748fd9f74a5 100644
--- a/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ b/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -312,10 +312,11 @@ static std::unique_ptr 
createOptionsProvider(
   if (UseColor.getNumOccurrences() > 0)
 OverrideOptions.UseColor = UseColor;
 
-  auto LoadConfig = [&](StringRef Configuration)
-  -> std::unique_ptr {
+  auto LoadConfig =
+  [&](StringRef Configuration,
+  StringRef Source) -> std::unique_ptr {
 llvm::ErrorOr ParsedConfig =
-parseConfiguration(Configuration);
+parseConfiguration(MemoryBufferRef(Configuration, Source));
 if (ParsedConfig)
   return std::make_unique(
   std::move(GlobalOptions),
@@ -334,18 +335,18 @@ static std::unique_ptr 
createOptionsProvider(
 }
 
 llvm::ErrorOr> Text =
-llvm::MemoryBuffer::getFile(ConfigFile.c_str());
+llvm::MemoryBuffer::getFile(ConfigFile);
 if (std::error_code EC = Text.getError()) {
   llvm::errs() << "Error: can't read config-file '" << ConfigFile
<< "': " << EC.message() << "\n";
   return nullptr;
 }
 
-return LoadConfig((*Text)->getBuffer());
+return LoadConfig((*Text)->getBuffer(), ConfigFile);
   }
 
   if (Config.getNumOccurrences() > 0)
-return LoadConfig(Config);
+return LoadConfig(Config, "");
 
   return std::make_unique(
   std::move(GlobalOptions), std::move(DefaultOptions),

diff  --git a/clang-tools-extra/clangd/TidyProvider.cpp 
b/clang-tools-extra/clangd/TidyProvider.cpp
index f51ac91aaf36..730a402b5df1 100644
--- a/clang-tools-extra/clangd/TidyProvider.cpp
+++ b/clang-tools-extra/clangd/TidyProvider.cpp
@@ -41,7 +41,8 @@ class DotClangTidyCache : private FileCache {
 [this](l

[llvm-branch-commits] [clang-tools-extra] a0cf2b8 - [clangd][NFC] Remove unnecessary vector.

2020-12-10 Thread Nathan James via llvm-branch-commits

Author: Nathan James
Date: 2020-12-10T14:59:17Z
New Revision: a0cf2b8f712e0bca9185d77cf1def8160f165548

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

LOG: [clangd][NFC] Remove unnecessary vector.

As pointed out in D92788.

Reviewed By: kbobyrev

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

Added: 


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

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/TestTU.cpp 
b/clang-tools-extra/clangd/unittests/TestTU.cpp
index 27019403ae85..3b1130444671 100644
--- a/clang-tools-extra/clangd/unittests/TestTU.cpp
+++ b/clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -187,9 +187,6 @@ const Symbol &findSymbol(const SymbolSlab &Slab, 
llvm::StringRef QName) {
 }
 
 const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef QName) {
-  llvm::SmallVector Components;
-  QName.split(Components, "::");
-
   auto &Ctx = AST.getASTContext();
   auto LookupDecl = [&Ctx](const DeclContext &Scope,
llvm::StringRef Name) -> const NamedDecl & {
@@ -200,11 +197,13 @@ const NamedDecl &findDecl(ParsedAST &AST, llvm::StringRef 
QName) {
   };
 
   const DeclContext *Scope = Ctx.getTranslationUnitDecl();
-  for (auto NameIt = Components.begin(), End = Components.end() - 1;
-   NameIt != End; ++NameIt) {
-Scope = &cast(LookupDecl(*Scope, *NameIt));
+
+  StringRef Cur, Rest;
+  for (std::tie(Cur, Rest) = QName.split("::"); !Rest.empty();
+   std::tie(Cur, Rest) = Rest.split("::")) {
+Scope = &cast(LookupDecl(*Scope, Cur));
   }
-  return LookupDecl(*Scope, Components.back());
+  return LookupDecl(*Scope, Cur);
 }
 
 const NamedDecl &findDecl(ParsedAST &AST,



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


[llvm-branch-commits] [llvm] a7b2847 - [openmp] Remove clause from OMPKinds.def and use OMP.td info

2020-12-10 Thread via llvm-branch-commits

Author: Valentin Clement
Date: 2020-12-10T10:19:09-05:00
New Revision: a7b2847216b4f7a84ef75461fd47a5adfbb63e27

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

LOG: [openmp] Remove clause from OMPKinds.def and use OMP.td info

Remove the OpenMP clause information from the OMPKinds.def file and use the
information from the new OMP.td file. There is now a single source of truth for 
the
directives and clauses.

To avoid generate lots of specific small code from tablegen, the macros 
previously
used in OMPKinds.def are generated almost as identical. This can be polished and
possibly removed in a further patch.

Reviewed By: jdoerfert

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

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 65319a19728b..6eceb526ca4c 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
-
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index ea3da8d90c5b..92123ed2a32a 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,8 +147,9 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 NKI_NumberOfKinds
   };
 
@@ -205,8 +206,9 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index cc6d3a93ba09..57ba4fa5510f 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,20 +7758,22 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
-  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
+  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
+#define GEN_CLANG_CLAUSE_CLASS
+#define CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
+#define CLAUSE_NO_CLASS(Enum, Str) 
\
   case llvm::omp::Clause::Enum:
\
 break;
-#include "llvm/Frontend/OpenMP/OMPKinds.def"
+#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
 default:
   break;
 }
@@ -78

[llvm-branch-commits] [lldb] db84208 - [lldb/test] Replace ad-hoc server test choice with test categories

2020-12-10 Thread Pavel Labath via llvm-branch-commits

Author: Pavel Labath
Date: 2020-12-10T16:21:28+01:00
New Revision: db8420825073371ddc077b020634e71e315e38a1

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

LOG: [lldb/test] Replace ad-hoc server test choice with test categories

This makes things consistent, and enables further simplifications down
the road.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/decorators.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/test_categories.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/decorators.py 
b/lldb/packages/Python/lldbsuite/test/decorators.py
index bcf665f6cc4c..ff445fa0b926 100644
--- a/lldb/packages/Python/lldbsuite/test/decorators.py
+++ b/lldb/packages/Python/lldbsuite/test/decorators.py
@@ -373,20 +373,12 @@ def should_skip_simulator_test():
 
 def debugserver_test(func):
 """Decorate the item as a debugserver test."""
-def should_skip_debugserver_test():
-return ("debugserver tests"
-if not configuration.debugserver_platform
-else None)
-return skipTestIfFn(should_skip_debugserver_test)(func)
+return add_test_categories(["debugserver"])(func)
 
 
 def llgs_test(func):
 """Decorate the item as a lldb-server test."""
-def should_skip_llgs_tests():
-return ("llgs tests"
-if not configuration.llgs_platform
-else None)
-return skipTestIfFn(should_skip_llgs_tests)(func)
+return add_test_categories(["llgs"])(func)
 
 
 def expectedFailureOS(

diff  --git a/lldb/packages/Python/lldbsuite/test/dotest.py 
b/lldb/packages/Python/lldbsuite/test/dotest.py
index 64a197872f9e..86ea34ee2582 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -850,6 +850,14 @@ def checkDebugInfoSupport():
 if skipped:
 print("Skipping following debug info categories:", skipped)
 
+def checkDebugServerSupport():
+from lldbsuite.test import lldbplatformutil
+
+if lldbplatformutil.platformIsDarwin():
+configuration.skip_categories.append("llgs")
+else:
+configuration.skip_categories.append("debugserver")
+
 def run_suite():
 # On MacOS X, check to make sure that domain for com.apple.DebugSymbols 
defaults
 # does not exist before proceeding to running the test suite.
@@ -944,15 +952,9 @@ def run_suite():
 checkLibstdcxxSupport()
 checkWatchpointSupport()
 checkDebugInfoSupport()
+checkDebugServerSupport()
 checkObjcSupport()
 
-# Perform LLGS tests only on platforms using it.
-configuration.llgs_platform = (
-target_platform in ["freebsd", "linux", "netbsd", "windows"])
-
-# Perform debugserver tests elsewhere (i.e. on Darwin platforms).
-configuration.debugserver_platform = not configuration.llgs_platform
-
 for testdir in configuration.testdirs:
 for (dirpath, dirnames, filenames) in os.walk(testdir):
 visit('Test', dirpath, filenames)

diff  --git a/lldb/packages/Python/lldbsuite/test/test_categories.py 
b/lldb/packages/Python/lldbsuite/test/test_categories.py
index 699fcf4cb887..9f1196ea6497 100644
--- a/lldb/packages/Python/lldbsuite/test/test_categories.py
+++ b/lldb/packages/Python/lldbsuite/test/test_categories.py
@@ -23,6 +23,7 @@
 'cmdline': 'Tests related to the LLDB command-line interface',
 'darwin-log': 'Darwin log tests',
 'dataformatters': 'Tests related to the type command and the data 
formatters subsystem',
+'debugserver': 'Debugserver tests',
 'dsym': 'Tests that can be run with DSYM debug information',
 'dwarf': 'Tests that can be run with DWARF debug information',
 'dwo': 'Tests that can be run with DWO debug information',
@@ -35,6 +36,7 @@
 'libstdcxx': 'Test for libstdcxx data formatters',
 'lldb-server': 'Tests related to lldb-server',
 'lldb-vscode': 'Visual Studio Code debug adaptor tests',
+'llgs': 'Tests for the gdb-server functionality of lldb-server',
 'objc': 'Tests related to the Objective-C programming language support',
 'pyapi': 'Tests related to the Python API',
 'std-module': 'Tests related to importing the std module',



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


[llvm-branch-commits] [lldb] b505142 - [lldb/test] Change base class of lldb-server tests

2020-12-10 Thread Pavel Labath via llvm-branch-commits

Author: Pavel Labath
Date: 2020-12-10T16:21:28+01:00
New Revision: b505142fa5d301238796318d2d092d6fb3bd2d31

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

LOG: [lldb/test] Change base class of lldb-server tests

lldb-server tests are a very special subclass of "api" tests. As they
communicate with lldb-server directly, they don't actually need most of
facilities provided by our TestBase class. In particular, they don't
need the ability to fork debug info flavours of tests (but they could
use debug server flavours).

This makes them inherit from "Base" instead. This avoids the need to
explicitly mark these tests as NO_DEBUG_INFO_TEST_CASE. Two additional
necessary tweaks were:
- move run_platform_command to the base (Base) class. This is used in
  one test, and can be generally useful when running tests remotely.
- add a "build" method, forwarding to buildDefault. This is to avoid
  updating each test case to use buildDefault (also, "build" sounds
  better). It might be interesting to refactor the (Test)Base classes so
  that all debug info flavour handling happens in TestBase, and the Base
  class provides a simple build method automatically.

Added: 


Modified: 
lldb/packages/Python/lldbsuite/test/lldbtest.py
lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py

Removed: 




diff  --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py 
b/lldb/packages/Python/lldbsuite/test/lldbtest.py
index 1f3bc7722290..d240050cc4c6 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1785,6 +1785,12 @@ def getLibcPlusPlusLibs(self):
 else:
 return ['libc++.1.dylib', 'libc++abi.']
 
+def run_platform_command(self, cmd):
+platform = self.dbg.GetSelectedPlatform()
+shell_command = lldb.SBPlatformShellCommand(cmd)
+err = platform.Run(shell_command)
+return (err, shell_command.GetStatus(), shell_command.GetOutput())
+
 # Metaclass for TestBase to change the list of test metods when a new TestCase 
is loaded.
 # We change the test methods to create a new test method for each test for 
each debug info we are
 # testing. The name of the new test method will be 
'_' and with adding
@@ -2656,12 +2662,6 @@ def build(
 else:
 self.fail("Can't build for debug info: %s" % self.getDebugInfo())
 
-def run_platform_command(self, cmd):
-platform = self.dbg.GetSelectedPlatform()
-shell_command = lldb.SBPlatformShellCommand(cmd)
-err = platform.Run(shell_command)
-return (err, shell_command.GetStatus(), shell_command.GetOutput())
-
 """Assert that an lldb.SBError is in the "success" state."""
 def assertSuccess(self, obj, msg=None):
 if not obj.Success():

diff  --git 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
index 2908ca2809a9..b578aae12062 100644
--- 
a/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
+++ 
b/lldb/packages/Python/lldbsuite/test/tools/lldb-server/gdbremote_testcase.py
@@ -27,9 +27,7 @@ class _ConnectionRefused(IOError):
 pass
 
 
-class GdbRemoteTestCaseBase(TestBase):
-
-NO_DEBUG_INFO_TESTCASE = True
+class GdbRemoteTestCaseBase(Base):
 
 # Default time out in seconds. The timeout is increased tenfold under Asan.
 DEFAULT_TIMEOUT =  20 * (10 if ('ASAN_OPTIONS' in os.environ) else 1)
@@ -83,7 +81,7 @@ def isVerboseLoggingRequested(self):
for channel in lldbtest_config.channels)
 
 def setUp(self):
-TestBase.setUp(self)
+super(GdbRemoteTestCaseBase, self).setUp()
 
 self.setUpBaseLogging()
 self.debug_monitor_extra_args = []
@@ -121,6 +119,9 @@ def tearDown(self):
 self._verbose_log_handler = None
 TestBase.tearDown(self)
 
+def build(self, *args, **kwargs):
+self.buildDefault(*args, **kwargs)
+
 def getLocalServerLogFile(self):
 return self.log_basename + "-server.log"
 



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


[llvm-branch-commits] [llvm] 985739e - [gn build] fix build after a7b2847216b4f7

2020-12-10 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-10T10:28:48-05:00
New Revision: 985739ec059d23d7478ea1eee5a14e8160658c1b

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

LOG: [gn build] fix build after a7b2847216b4f7

Ports 6e42a417bacb since it's now needed, and undo an accidental
deletion from d69762c404ded while here (this part is not needed to fix
the build, it's just in the vicinity).

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
index acb545f41986..26c9b52a1660 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenACC/BUILD.gn
@@ -6,7 +6,7 @@ tablegen("ACC") {
   output_name = "ACC.h.inc"
 }
 
-tablegen("ACC.cpp") {
+tablegen("ACCcpp") {
   visibility = [ ":acc_gen" ]
   args = [ "-gen-directive-gen" ]
   output_name = "ACC.cpp.inc"
@@ -14,5 +14,8 @@ tablegen("ACC.cpp") {
 }
 
 group("acc_gen") {
-  deps = [ ":ACC" ]
+  deps = [
+":ACC",
+":ACCcpp",
+  ]
 }

diff  --git 
a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn
index a18f8db5f5eb..6fe62a0f5a71 100644
--- a/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/include/llvm/Frontend/OpenMP/BUILD.gn
@@ -6,6 +6,13 @@ tablegen("OMP") {
   output_name = "OMP.h.inc"
 }
 
+tablegen("OMPcpp") {
+  visibility = [ ":public_tablegen" ]
+  args = [ "-gen-directive-gen" ]
+  output_name = "OMP.cpp.inc"
+  td_file = "OMP.td"
+}
+
 # Groups all tablegen() calls that create .inc files that are included in
 # Frontent/OpenMP's public headers (just one so far).
 # //llvm/lib/Frontend/OpenMP has this as a public_dep, so targets depending on
@@ -14,5 +21,6 @@ group("public_tablegen") {
   public_deps = [
 # Frontend/OpenMP's public headers include OMP.h.inc.
 ":OMP",
+":OMPcpp",
   ]
 }



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


[llvm-branch-commits] [llvm] d2a7b83 - AA: make AliasAnalysis.h compatible with C++20 (NFC)

2020-12-10 Thread Nuno Lopes via llvm-branch-commits

Author: Nuno Lopes
Date: 2020-12-10T15:32:11Z
New Revision: d2a7b83c5c7b9b26e73261be2a4d60a5b53ba80f

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

LOG: AA: make AliasAnalysis.h compatible with C++20 (NFC)
can't mix arithmetic with different enums

Added: 


Modified: 
llvm/include/llvm/Analysis/AliasAnalysis.h

Removed: 




diff  --git a/llvm/include/llvm/Analysis/AliasAnalysis.h 
b/llvm/include/llvm/Analysis/AliasAnalysis.h
index ce4ebab3efa4..cc5cec44b455 100644
--- a/llvm/include/llvm/Analysis/AliasAnalysis.h
+++ b/llvm/include/llvm/Analysis/AliasAnalysis.h
@@ -540,7 +540,7 @@ class AAResults {
   /// write at most from objects pointed to by their pointer-typed arguments
   /// (with arbitrary offsets).
   static bool onlyAccessesArgPointees(FunctionModRefBehavior MRB) {
-return !(MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
+return !((unsigned)MRB & FMRL_Anywhere & ~FMRL_ArgumentPointees);
   }
 
   /// Checks if functions with the specified behavior are known to potentially
@@ -548,26 +548,27 @@ class AAResults {
   /// (with arbitrary offsets).
   static bool doesAccessArgPointees(FunctionModRefBehavior MRB) {
 return isModOrRefSet(createModRefInfo(MRB)) &&
-   (MRB & FMRL_ArgumentPointees);
+   ((unsigned)MRB & FMRL_ArgumentPointees);
   }
 
   /// Checks if functions with the specified behavior are known to read and
   /// write at most from memory that is inaccessible from LLVM IR.
   static bool onlyAccessesInaccessibleMem(FunctionModRefBehavior MRB) {
-return !(MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
+return !((unsigned)MRB & FMRL_Anywhere & ~FMRL_InaccessibleMem);
   }
 
   /// Checks if functions with the specified behavior are known to potentially
   /// read or write from memory that is inaccessible from LLVM IR.
   static bool doesAccessInaccessibleMem(FunctionModRefBehavior MRB) {
-return isModOrRefSet(createModRefInfo(MRB)) && (MRB & 
FMRL_InaccessibleMem);
+return isModOrRefSet(createModRefInfo(MRB)) &&
+ ((unsigned)MRB & FMRL_InaccessibleMem);
   }
 
   /// Checks if functions with the specified behavior are known to read and
   /// write at most from memory that is inaccessible from LLVM IR or objects
   /// pointed to by their pointer-typed arguments (with arbitrary offsets).
   static bool onlyAccessesInaccessibleOrArgMem(FunctionModRefBehavior MRB) {
-return !(MRB & FMRL_Anywhere &
+return !((unsigned)MRB & FMRL_Anywhere &
  ~(FMRL_InaccessibleMem | FMRL_ArgumentPointees));
   }
 



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


[llvm-branch-commits] [llvm] 456c885 - Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

2020-12-10 Thread via llvm-branch-commits

Author: clementval
Date: 2020-12-10T10:34:59-05:00
New Revision: 456c885df369f1e94d60da2658055b21c88e471d

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

LOG: Revert "[openmp] Remove clause from OMPKinds.def and use OMP.td info"

This reverts commit a7b2847216b4f7a84ef75461fd47a5adfbb63e27.

failing buildbot on warnings

Added: 


Modified: 
clang/include/clang/AST/ASTFwd.h
clang/include/clang/AST/ASTTypeTraits.h
clang/include/clang/AST/OpenMPClause.h
clang/include/clang/AST/RecursiveASTVisitor.h
clang/lib/AST/ASTTypeTraits.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/Sema/TreeTransform.h
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/tools/libclang/CIndex.cpp
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/include/llvm/TableGen/DirectiveEmitter.h
llvm/test/TableGen/directive2.td
llvm/utils/TableGen/DirectiveEmitter.cpp

Removed: 




diff  --git a/clang/include/clang/AST/ASTFwd.h 
b/clang/include/clang/AST/ASTFwd.h
index 6eceb526ca4c..65319a19728b 100644
--- a/clang/include/clang/AST/ASTFwd.h
+++ b/clang/include/clang/AST/ASTFwd.h
@@ -27,9 +27,9 @@ class Type;
 #include "clang/AST/TypeNodes.inc"
 class CXXCtorInitializer;
 class OMPClause;
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) class Class;
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) class Class;
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+
 
 } // end namespace clang
 

diff  --git a/clang/include/clang/AST/ASTTypeTraits.h 
b/clang/include/clang/AST/ASTTypeTraits.h
index 92123ed2a32a..ea3da8d90c5b 100644
--- a/clang/include/clang/AST/ASTTypeTraits.h
+++ b/clang/include/clang/AST/ASTTypeTraits.h
@@ -147,9 +147,8 @@ class ASTNodeKind {
 #define TYPE(DERIVED, BASE) NKI_##DERIVED##Type,
 #include "clang/AST/TypeNodes.inc"
 NKI_OMPClause,
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) NKI_##Class,
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 NKI_NumberOfKinds
   };
 
@@ -206,9 +205,8 @@ KIND_TO_KIND_ID(CXXBaseSpecifier)
 #include "clang/AST/StmtNodes.inc"
 #define TYPE(DERIVED, BASE) KIND_TO_KIND_ID(DERIVED##Type)
 #include "clang/AST/TypeNodes.inc"
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) KIND_TO_KIND_ID(Class)
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 #undef KIND_TO_KIND_ID
 
 inline raw_ostream &operator<<(raw_ostream &OS, ASTNodeKind K) {

diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 57ba4fa5510f..cc6d3a93ba09 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -7758,22 +7758,20 @@ class OMPClauseVisitorBase {
 #define DISPATCH(CLASS) \
   return 
static_cast(this)->Visit##CLASS(static_cast(S))
 
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) 
\
-  RetTy Visit##Class(PTR(Class) S) { DISPATCH(Class); }
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) \
+  RetTy Visit ## Class (PTR(Class) S) { DISPATCH(Class); }
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 
   RetTy Visit(PTR(OMPClause) S) {
 // Top switch clause: visit each OMPClause.
 switch (S->getClauseKind()) {
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) 
\
+#define OMP_CLAUSE_CLASS(Enum, Str, Class) 
\
   case llvm::omp::Clause::Enum:
\
 return Visit##Class(static_cast(S));
-#define CLAUSE_NO_CLASS(Enum, Str) 
\
+#define OMP_CLAUSE_NO_CLASS(Enum, Str) 
\
   case llvm::omp::Clause::Enum:
\
 break;
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
 default:
   break;
 }
@@ -7806,9 +7804,9 @@ class OMPClausePrinter final : public 
OMPClauseVisitor {
   OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
   : OS(OS), Policy(Policy) {}
 
-#define GEN_CLANG_CLAUSE_CLASS
-#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);
-#include "llvm/Frontend/OpenMP/OMP.cpp.inc"
+#define OMP_CLAUSE_CLASS(Enum, Str, Class)  

[llvm-branch-commits] [flang] 9168a0f - [flang] Fix bogus message on index-names in the presence of associated entities

2020-12-10 Thread Peter Steinfeld via llvm-branch-commits

Author: Peter Steinfeld
Date: 2020-12-10T07:36:41-08:00
New Revision: 9168a0f515c908dc3c3df822f17d489ec8a0caf2

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

LOG: [flang] Fix bogus message on index-names in the presence of associated 
entities

The semantic analysis of index-names of FORALL statements looks up symbols with
the same name as the index-name.  This is needed to exclude symbols that are
not objects.  But if the symbol found is host-, use-, or construct-associated
with another entity, the check fails.

I fixed this by getting the root symbol of the symbol found and doing the check
on the root symbol.  This required creating a non-const version of
"GetAssociationRoot()".

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

Added: 
flang/test/Semantics/resolve99.f90

Modified: 
flang/include/flang/Evaluate/tools.h
flang/lib/Evaluate/tools.cpp
flang/lib/Semantics/resolve-names.cpp

Removed: 




diff  --git a/flang/include/flang/Evaluate/tools.h 
b/flang/include/flang/Evaluate/tools.h
index e7305d47ed10..0501023116d9 100644
--- a/flang/include/flang/Evaluate/tools.h
+++ b/flang/include/flang/Evaluate/tools.h
@@ -919,6 +919,7 @@ bool IsLenTypeParameter(const Symbol &);
 
 // Follow use, host, and construct assocations to a variable, if any.
 const Symbol *GetAssociationRoot(const Symbol &);
+Symbol *GetAssociationRoot(Symbol &);
 const Symbol *FindCommonBlockContaining(const Symbol &);
 int CountLenParameters(const DerivedTypeSpec &);
 int CountNonConstantLenParameters(const DerivedTypeSpec &);

diff  --git a/flang/lib/Evaluate/tools.cpp b/flang/lib/Evaluate/tools.cpp
index 1ae0fce193b1..452ff0f35841 100644
--- a/flang/lib/Evaluate/tools.cpp
+++ b/flang/lib/Evaluate/tools.cpp
@@ -931,6 +931,11 @@ const Symbol *GetAssociationRoot(const Symbol &symbol) {
   return details ? GetAssociatedVariable(*details) : &ultimate;
 }
 
+Symbol *GetAssociationRoot(Symbol &symbol) {
+  return const_cast(
+  GetAssociationRoot(const_cast(symbol)));
+}
+
 bool IsVariableName(const Symbol &symbol) {
   const Symbol *root{GetAssociationRoot(symbol)};
   return root && root->has() && !IsNamedConstant(*root);

diff  --git a/flang/lib/Semantics/resolve-names.cpp 
b/flang/lib/Semantics/resolve-names.cpp
index 0d2b8813c7bb..b0e0b0b80ebf 100644
--- a/flang/lib/Semantics/resolve-names.cpp
+++ b/flang/lib/Semantics/resolve-names.cpp
@@ -4927,17 +4927,21 @@ void ConstructVisitor::ResolveIndexName(
 // type came from explicit type-spec
   } else if (!prev) {
 ApplyImplicitRules(symbol);
-  } else if (!prev->has() && !prev->has()) 
{
-Say2(name, "Index name '%s' conflicts with existing identifier"_err_en_US,
-*prev, "Previous declaration of '%s'"_en_US);
-return;
-  } else {
-if (const auto *type{prev->GetType()}) {
-  symbol.SetType(*type);
-}
-if (prev->IsObjectArray()) {
-  SayWithDecl(name, *prev, "Index variable '%s' is not scalar"_err_en_US);
+  } else if (const Symbol * prevRoot{GetAssociationRoot(*prev)}) {
+// prev could be host- use- or construct-associated with another symbol
+if (!prevRoot->has() &&
+!prevRoot->has()) {
+  Say2(name, "Index name '%s' conflicts with existing 
identifier"_err_en_US,
+  *prev, "Previous declaration of '%s'"_en_US);
   return;
+} else {
+  if (const auto *type{prevRoot->GetType()}) {
+symbol.SetType(*type);
+  }
+  if (prevRoot->IsObjectArray()) {
+SayWithDecl(name, *prev, "Index variable '%s' is not 
scalar"_err_en_US);
+return;
+  }
 }
   }
   EvaluateExpr(parser::Scalar{parser::Integer{common::Clone(name)}});

diff  --git a/flang/test/Semantics/resolve99.f90 
b/flang/test/Semantics/resolve99.f90
new file mode 100644
index ..a1c8c10af4ee
--- /dev/null
+++ b/flang/test/Semantics/resolve99.f90
@@ -0,0 +1,51 @@
+! RUN: %S/test_errors.sh %s %t %f18
+
+! Tests for the index-name of a FORALL statement
+
+module m1
+  integer modVar
+end module m1
+
+program indexName
+  common /iCommonName/ x
+  type ::  typeName
+  end type
+  iGlobalVar = 216
+
+contains
+  subroutine hostAssoc()
+integer, dimension(4) :: table
+
+  ! iGlobalVar is host associated with the global variable
+iGlobalVar = 1
+FORALL (iGlobalVar=1:4) table(iGlobalVar) = 343
+  end subroutine hostAssoc
+
+  subroutine useAssoc()
+use m1
+integer, dimension(4) :: tab
+  ! modVar is use associated with the module variable
+FORALL (modVar=1:4) tab(modVar) = 343
+  end subroutine useAssoc
+
+  subroutine constructAssoc()
+integer, dimension(4) :: table
+integer :: localVar
+associate (assocVar => localVar)
+  ! assocVar is construct associated with localVar
+  FORALL (assocVar=1:4) table(assocVar) = 343
+en

[llvm-branch-commits] [clang-tools-extra] 4ce242a - [clangd] Find relations in Dex exploration tool.

2020-12-10 Thread Utkarsh Saxena via llvm-branch-commits

Author: Utkarsh Saxena
Date: 2020-12-10T16:54:03+01:00
New Revision: 4ce242a163c3b98385a5cb949a7e6b1e1ae7eb83

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

LOG: [clangd] Find relations in Dex exploration tool.

Reviewed By: hokein

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

Added: 


Modified: 
clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp 
b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
index d7da330e2ed0..49f16e72be92 100644
--- a/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
+++ b/clang-tools-extra/clangd/index/dex/dexp/Dexp.cpp
@@ -11,6 +11,8 @@
 //
 
//===--===//
 
+#include "index/Index.h"
+#include "index/Relation.h"
 #include "index/Serialization.h"
 #include "index/dex/Dex.h"
 #include "index/remote/Client.h"
@@ -267,6 +269,43 @@ class Refs : public Command {
   }
 };
 
+class Relations : public Command {
+  llvm::cl::opt ID{
+  "id",
+  llvm::cl::Positional,
+  llvm::cl::desc("Symbol ID of the symbol being queried (hex)."),
+  };
+  llvm::cl::opt Relation{
+  "relation",
+  llvm::cl::desc("Relation kind for the predicate."),
+  values(clEnumValN(RelationKind::BaseOf, "base_of",
+"Find subclasses of a class."),
+ clEnumValN(RelationKind::OverriddenBy, "overridden_by",
+"Find methods that overrides a virtual method.")),
+  };
+
+  void run() override {
+if (ID.getNumOccurrences() == 0 || Relation.getNumOccurrences() == 0) {
+  llvm::errs()
+  << "Missing required argument: please provide id and -relation.\n";
+  return;
+}
+RelationsRequest Req;
+if (ID.getNumOccurrences()) {
+  auto SID = SymbolID::fromStr(ID);
+  if (!SID) {
+llvm::errs() << llvm::toString(SID.takeError()) << "\n";
+return;
+  }
+  Req.Subjects.insert(*SID);
+}
+Req.Predicate = Relation.getValue();
+Index->relations(Req, [](const SymbolID &SID, const Symbol &S) {
+  llvm::outs() << toYAML(S);
+});
+  }
+};
+
 class Export : public Command {
   llvm::cl::opt Format{
   "format",
@@ -326,6 +365,8 @@ struct {
 {"lookup", "Dump symbol details by ID or qualified name",
  std::make_unique},
 {"refs", "Find references by ID or qualified name", 
std::make_unique},
+{"relations", "Find relations by ID and relation kind",
+ std::make_unique},
 {"export", "Export index", std::make_unique},
 };
 



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


[llvm-branch-commits] [compiler-rt] 8a874a4 - [DFSan] Add custom wrapper for getsockname.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T08:13:05-08:00
New Revision: 8a874a42298d030715e041dcaae132095dee

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

LOG: [DFSan] Add custom wrapper for getsockname.

The wrapper clears shadow for any bytes written to addr or addrlen.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 0cb075ac632a..576f7f64e301 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -927,6 +927,21 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockopt(
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockname(
+int sockfd, struct sockaddr *addr, socklen_t *addrlen,
+dfsan_label sockfd_label, dfsan_label addr_label, dfsan_label 
addrlen_label,
+dfsan_label *ret_label) {
+  socklen_t origlen = addrlen ? *addrlen : 0;
+  int ret = getsockname(sockfd, addr, addrlen);
+  if (ret != -1 && addr && addrlen) {
+socklen_t written_bytes = origlen < *addrlen ? origlen : *addrlen;
+dfsan_set_label(0, addrlen, sizeof(*addrlen));
+dfsan_set_label(0, addr, written_bytes);
+  }
+  *ret_label = 0;
+  return ret;
+}
+
 // Type of the trampoline function passed to the custom version of
 // dfsan_set_write_callback.
 typedef void (*write_trampoline_t)(

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 13513cbb0f23..9a92098f22eb 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -194,6 +194,7 @@ fun:get_current_dir_name=custom
 fun:gethostname=custom
 fun:getrlimit=custom
 fun:getrusage=custom
+fun:getsockname=custom
 fun:getsockopt=custom
 fun:nanosleep=custom
 fun:pread=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index b57f172d7e4c..8305941d0054 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -931,6 +931,26 @@ void test_socketpair() {
   ASSERT_READ_ZERO_LABEL(fd, sizeof(fd));
 }
 
+void test_getsockname() {
+  int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
+  assert(sockfd != -1);
+
+  struct sockaddr addr = {};
+  socklen_t addrlen = sizeof(addr);
+  dfsan_set_label(i_label, &addr, addrlen);
+  dfsan_set_label(i_label, &addrlen, sizeof(addrlen));
+
+  int ret = getsockname(sockfd, &addr, &addrlen);
+  assert(ret != -1);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(addrlen);
+  assert(addrlen < sizeof(addr));
+  ASSERT_READ_ZERO_LABEL(&addr, addrlen);
+  ASSERT_READ_LABEL(((char *)&addr) + addrlen, 1, i_label);
+
+  close(sockfd);
+}
+
 void test_getsockopt() {
   int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
   assert(sockfd != -1);
@@ -1134,6 +1154,7 @@ int main(void) {
   test_getpwuid_r();
   test_getrlimit();
   test_getrusage();
+  test_getsockname();
   test_getsockopt();
   test_gettimeofday();
   test_inet_pton();



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


[llvm-branch-commits] [llvm] c9e967a - [flang]Add Parser Support for Allocate Directive

2020-12-10 Thread Irina Dobrescu via llvm-branch-commits

Author: Irina Dobrescu
Date: 2020-12-10T16:21:19Z
New Revision: c9e967af3fc7ce824cd811379c5e99a998819779

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

LOG: [flang]Add Parser Support for Allocate Directive

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

Added: 
flang/test/Parser/omp-allocate-unparse.f90
flang/test/Semantics/omp-allocate-directive.f90

Modified: 
flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
flang/lib/Lower/OpenMP.cpp
flang/lib/Parser/openmp-parsers.cpp
flang/lib/Parser/type-parsers.h
flang/lib/Parser/unparse.cpp
flang/lib/Semantics/check-omp-structure.cpp
flang/lib/Semantics/check-omp-structure.h
llvm/include/llvm/Frontend/OpenMP/OMP.td

Removed: 




diff  --git a/flang/include/flang/Parser/dump-parse-tree.h 
b/flang/include/flang/Parser/dump-parse-tree.h
index c86c2ec6e66b..791e21fa4b62 100644
--- a/flang/include/flang/Parser/dump-parse-tree.h
+++ b/flang/include/flang/Parser/dump-parse-tree.h
@@ -545,6 +545,7 @@ class ParseTreeDumper {
   NODE(parser, OpenMPCancellationPointConstruct)
   NODE(parser, OpenMPConstruct)
   NODE(parser, OpenMPCriticalConstruct)
+  NODE(parser, OpenMPDeclarativeAllocate)
   NODE(parser, OpenMPDeclarativeConstruct)
   NODE(parser, OpenMPDeclareReductionConstruct)
   NODE(parser, OpenMPDeclareSimdConstruct)
@@ -552,6 +553,7 @@ class ParseTreeDumper {
   NODE(parser, OmpMemoryOrderClause)
   NODE(parser, OpenMPFlushConstruct)
   NODE(parser, OpenMPLoopConstruct)
+  NODE(parser, OpenMPExecutableAllocate)
   NODE(parser, OpenMPSimpleStandaloneConstruct)
   NODE(parser, OpenMPStandaloneConstruct)
   NODE(parser, OpenMPSectionsConstruct)

diff  --git a/flang/include/flang/Parser/parse-tree.h 
b/flang/include/flang/Parser/parse-tree.h
index 6bed37c2b871..ca73af210c15 100644
--- a/flang/include/flang/Parser/parse-tree.h
+++ b/flang/include/flang/Parser/parse-tree.h
@@ -3583,11 +3583,19 @@ struct OpenMPThreadprivate {
   std::tuple t;
 };
 
+// 2.11.3 allocate -> ALLOCATE (variable-name-list) [clause]
+struct OpenMPDeclarativeAllocate {
+  TUPLE_CLASS_BOILERPLATE(OpenMPDeclarativeAllocate);
+  CharBlock source;
+  std::tuple t;
+};
+
 struct OpenMPDeclarativeConstruct {
   UNION_CLASS_BOILERPLATE(OpenMPDeclarativeConstruct);
   CharBlock source;
-  std::variant
+  std::variant
   u;
 };
 
@@ -3607,6 +3615,19 @@ struct OpenMPCriticalConstruct {
   std::tuple t;
 };
 
+// 2.11.3 allocate -> ALLOCATE [(variable-name-list)] [clause]
+//[ALLOCATE (variable-name-list) [clause] [...]]
+//allocate-statement
+//clause -> allocator-clause
+struct OpenMPExecutableAllocate {
+  TUPLE_CLASS_BOILERPLATE(OpenMPExecutableAllocate);
+  CharBlock source;
+  std::tuple, OmpClauseList,
+  std::optional>,
+  Statement>
+  t;
+};
+
 // 2.17.7 atomic -> ATOMIC [clause[,]] atomic-clause [[,]clause] |
 //  ATOMIC [clause]
 //clause -> memory-order-clause | HINT(hint-expression)
@@ -3777,6 +3798,7 @@ struct OpenMPConstruct {
   UNION_CLASS_BOILERPLATE(OpenMPConstruct);
   std::variant
   u;
 };

diff  --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp
index 780aea9664fc..cfe4b0b86b67 100644
--- a/flang/lib/Lower/OpenMP.cpp
+++ b/flang/lib/Lower/OpenMP.cpp
@@ -256,6 +256,10 @@ void Fortran::lower::genOpenMPConstruct(
   [&](const Fortran::parser::OpenMPLoopConstruct &loopConstruct) {
 TODO("");
   },
+  [&](const Fortran::parser::OpenMPDeclarativeAllocate
+  &execAllocConstruct) { TODO(""); },
+  [&](const Fortran::parser::OpenMPExecutableAllocate
+  &execAllocConstruct) { TODO(""); },
   [&](const Fortran::parser::OpenMPBlockConstruct &blockConstruct) {
 genOMP(converter, eval, blockConstruct);
   },

diff  --git a/flang/lib/Parser/openmp-parsers.cpp 
b/flang/lib/Parser/openmp-parsers.cpp
index da10f9ffb0a8..69fc4f0e67ee 100644
--- a/flang/lib/Parser/openmp-parsers.cpp
+++ b/flang/lib/Parser/openmp-parsers.cpp
@@ -159,6 +159,8 @@ TYPE_PARSER(
 construct(parenthesized(Parser{})) ||
 "ALLOCATE" >>
 construct(parenthesized(Parser{})) ||
+"ALLOCATOR" >> construct(construct(
+   parenthesized(scalarIntExpr))) ||
 "COLLAPSE" >> construct(construct(
   parenthesized(scalarIntConstantExpr))) ||
 "COPYIN" >> construct(construct(
@@ -454,6 +456,13 @@ 
TYPE_PARSER(sourced(construct(verbatim("CRITICAL"_tok),
 TYPE_PARSER(construct(
 Parser{}, block, Parser{}))
 
+// 2.11.3 Executable Allocate directive
+TYPE_PARSER(
+sourced(construct(verbatim("ALLOCATE"_tok),
+maybe(parenthesized(Parser{})), Parser{},
+maybe(nonemp

[llvm-branch-commits] [lldb] 839e845 - [lldb] Remove assumption from Clang-based data formatters that their types are in the scratch AST

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T17:35:03+01:00
New Revision: 839e845277894ad37fbca8063cbf1955331fbeff

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

LOG: [lldb] Remove assumption from Clang-based data formatters that their types 
are in the scratch AST

Several data formatters assume their types are in the Target's scratch AST and
build new types from that scratch AST instance. However, types from different
ASTs shouldn't be mixed, so this (unchecked) assumption may lead to problems if
we ever have more than one scratch AST or someone somehow invokes data
formatters on a type that are not in the scratch AST.

Instead we can use in all the formatters just the TypeSystem of the type we're
formatting. That's much simpler and avoids all the headache of finding the right
TypeSystem that matches the one of the formatted type.

Right now LLDB only has one scratch TypeSystemClang instance and we format only
types that are in the scratch AST, so this doesn't change anything in the
current way LLDB works. The intention here is to allow follow up refactorings
that introduce multiple scratch ASTs with the same Target.

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

Added: 


Modified: 
lldb/source/DataFormatters/VectorType.cpp
lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
lldb/source/Plugins/Language/ObjC/CoreMedia.cpp

Removed: 




diff  --git a/lldb/source/DataFormatters/VectorType.cpp 
b/lldb/source/DataFormatters/VectorType.cpp
index fd1c0bc96cd4..cc24bb1de428 100644
--- a/lldb/source/DataFormatters/VectorType.cpp
+++ b/lldb/source/DataFormatters/VectorType.cpp
@@ -220,20 +220,8 @@ class VectorTypeSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 CompilerType parent_type(m_backend.GetCompilerType());
 CompilerType element_type;
 parent_type.IsVectorType(&element_type, nullptr);
-TypeSystem *type_system = nullptr;
-if (auto target_sp = m_backend.GetTargetSP()) {
-  auto type_system_or_err =
-  target_sp->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC);
-  if (auto err = type_system_or_err.takeError()) {
-LLDB_LOG_ERROR(
-lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
-std::move(err), "Unable to update from scratch TypeSystem");
-  } else {
-type_system = &type_system_or_err.get();
-  }
-}
-m_child_type =
-::GetCompilerTypeForFormat(m_parent_format, element_type, type_system);
+m_child_type = ::GetCompilerTypeForFormat(m_parent_format, element_type,
+  parent_type.GetTypeSystem());
 m_num_children = ::CalculateNumChildren(parent_type, m_child_type);
 m_item_format = GetItemFormatForFormat(m_parent_format, m_child_type);
 return false;

diff  --git a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp 
b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
index 42f6bd9ffb7b..35788a6445c2 100644
--- a/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
+++ b/lldb/source/Plugins/Language/CPlusPlus/BlockPointer.cpp
@@ -50,11 +50,7 @@ class BlockPointerSyntheticFrontEnd : public 
SyntheticChildrenFrontEnd {
 }
 
 TypeSystemClang *clang_ast_context =
-llvm::dyn_cast(&type_system_or_err.get());
-
-if (!clang_ast_context) {
-  return;
-}
+llvm::cast(block_pointer_type.GetTypeSystem());
 
 std::shared_ptr clang_ast_importer;
 auto *state = target_sp->GetPersistentExpressionStateForLanguage(

diff  --git a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp 
b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
index ac2f45b8354f..efc80cc75557 100644
--- a/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
+++ b/lldb/source/Plugins/Language/ObjC/CoreMedia.cpp
@@ -25,21 +25,12 @@ bool lldb_private::formatters::CMTimeSummaryProvider(
   if (!type.IsValid())
 return false;
 
-  auto type_system_or_err =
-  valobj.GetExecutionContextRef()
-  .GetTargetSP()
-  ->GetScratchTypeSystemForLanguage(lldb::eLanguageTypeC);
-  if (auto err = type_system_or_err.takeError()) {
-LLDB_LOG_ERROR(
-lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_DATAFORMATTERS),
-std::move(err), "Failed to get scratch type system");
-return false;
-  }
+  TypeSystem *type_system = type.GetTypeSystem();
   // fetch children by offset to compensate for potential lack of debug info
-  auto int64_ty = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
-  eEncodingSint, 64);
-  auto int32_ty = type_system_or_err->GetBuiltinTypeForEncodingAndBitSize(
-  eEncodingSint, 32);
+  auto int64_ty =
+  type_system->GetBuiltinTypeForEncodingAndBitSize(eEncodingSint, 64);
+  auto int32_ty =
+  type_syst

[llvm-branch-commits] [clang] a84599f - [OpenCL] Implement extended subgroups fully in headers.

2020-12-10 Thread Anastasia Stulova via llvm-branch-commits

Author: Anastasia Stulova
Date: 2020-12-10T16:40:15Z
New Revision: a84599f177a67d4a8c1c30ccd96c99fa40af75f7

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

LOG: [OpenCL] Implement extended subgroups fully in headers.

Extended subgroups are library style extensions and therefore
they require no changes in the frontend. This commit:
1. Moves extension macro definitions to the internal headers.
2. Removes extension pragmas because they are not needed.

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Basic/OpenCLExtensions.def
clang/lib/Headers/opencl-c-base.h
clang/test/Headers/opencl-c-header.cl
clang/test/SemaOpenCL/extension-version.cl

Removed: 




diff  --git a/clang/include/clang/Basic/OpenCLExtensions.def 
b/clang/include/clang/Basic/OpenCLExtensions.def
index d67cb3ff019b..17d402f300f1 100644
--- a/clang/include/clang/Basic/OpenCLExtensions.def
+++ b/clang/include/clang/Basic/OpenCLExtensions.def
@@ -66,13 +66,6 @@ OPENCLEXT_INTERNAL(cl_khr_mipmap_image, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_mipmap_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_srgb_image_writes, 200, ~0U)
 OPENCLEXT_INTERNAL(cl_khr_subgroups, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_extended_types, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_non_uniform_vote, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_ballot, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_non_uniform_arithmetic, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_shuffle, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_shuffle_relative, 200, ~0U)
-OPENCLEXT_INTERNAL(cl_khr_subgroup_clustered_reduce, 200, ~0U)
 
 // Clang Extensions.
 OPENCLEXT_INTERNAL(cl_clang_storage_class_specifiers, 100, ~0U)

diff  --git a/clang/lib/Headers/opencl-c-base.h 
b/clang/lib/Headers/opencl-c-base.h
index 4c52ebed1709..e8dcd70377e5 100644
--- a/clang/lib/Headers/opencl-c-base.h
+++ b/clang/lib/Headers/opencl-c-base.h
@@ -9,6 +9,21 @@
 #ifndef _OPENCL_BASE_H_
 #define _OPENCL_BASE_H_
 
+// Define extension macros
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+#define cl_khr_subgroup_extended_types 1
+#define cl_khr_subgroup_non_uniform_vote 1
+#define cl_khr_subgroup_ballot 1
+#define cl_khr_subgroup_non_uniform_arithmetic 1
+#define cl_khr_subgroup_shuffle 1
+#define cl_khr_subgroup_shuffle_relative 1
+#define cl_khr_subgroup_clustered_reduce 1
+#endif // defined(__SPIR__)
+#endif // (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+
 // built-in scalar data types:
 
 /**

diff  --git a/clang/test/Headers/opencl-c-header.cl 
b/clang/test/Headers/opencl-c-header.cl
index 1b151ffdd16a..13a3b62481ec 100644
--- a/clang/test/Headers/opencl-c-header.cl
+++ b/clang/test/Headers/opencl-c-header.cl
@@ -84,7 +84,11 @@ void test_atomics(__generic volatile unsigned int* a) {
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_2_0)
 global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
+// CHECK-MOD: Reading modules
+
+// Check that extension macros are defined correctly.
 
+// FIXME: this should not be defined for all targets
 // Verify that non-builtin cl_intel_planar_yuv extension is defined from
 // OpenCL 1.2 onwards.
 #if defined(__OPENCL_CPP_VERSION__) || (__OPENCL_C_VERSION__ >= CL_VERSION_1_2)
@@ -94,4 +98,57 @@ global atomic_int z = ATOMIC_VAR_INIT(99);
 #endif //__OPENCL_C_VERSION__
 #pragma OPENCL EXTENSION cl_intel_planar_yuv : enable
 
-// CHECK-MOD: Reading modules
+// For SPIR all extensions are supported.
+#if defined(__SPIR__)
+
+#if (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
+
+#if cl_khr_subgroup_extended_types != 1
+#error "Incorrectly defined cl_khr_subgroup_extended_types"
+#endif
+#if cl_khr_subgroup_non_uniform_vote != 1
+#error "Incorrectly defined cl_khr_subgroup_non_uniform_vote"
+#endif
+#if cl_khr_subgroup_ballot != 1
+#error "Incorrectly defined cl_khr_subgroup_ballot"
+#endif
+#if cl_khr_subgroup_non_uniform_arithmetic != 1
+#error "Incorrectly defined cl_khr_subgroup_non_uniform_arithmetic"
+#endif
+#if cl_khr_subgroup_shuffle != 1
+#error "Incorrectly defined cl_khr_subgroup_shuffle"
+#endif
+#if cl_khr_subgroup_shuffle_relative != 1
+#error "Incorrectly defined cl_khr_subgroup_shuffle_relative"
+#endif
+#if cl_khr_subgroup_clustered_reduce != 1
+#error "Incorrectly defined cl_khr_subgroup_clustered_reduce"
+#endif
+
+#else
+
+#ifdef cl_khr_subgroup_extended_types
+#error "Incorrect cl_khr_subgroup_extended_types define"
+#endif
+#ifdef cl_khr_subgroup_non_uniform_vote
+#error "Incorrect cl_khr_subgroup_non_uniform_vote define"
+#endif
+#ifdef cl_khr_subgroup_ballot
+#error "Incorrect

[llvm-branch-commits] [clang] 9c4cddb - [Clang] Add vcmla and rotated variants for Arm ACLE.

2020-12-10 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-10T16:54:08Z
New Revision: 9c4cddb53a7b94d83d1a7417c9a1aea00a139545

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

LOG: [Clang] Add vcmla and rotated variants for Arm ACLE.

This patch adds vcmla and the rotated variants as defined in
"Arm Neon Intrinsics Reference for ACLE Q3 2020" [1]

The *_lane_* are still missing, but they can be added separately.

This patch only adds the builtin mapping for AArch64.

[1] https://developer.arm.com/documentation/ihi0073/latest

Reviewed By: t.p.northover

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

Added: 
clang/test/CodeGen/aarch64-neon-vcmla.c

Modified: 
clang/include/clang/Basic/arm_neon.td
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_neon.td 
b/clang/include/clang/Basic/arm_neon.td
index feccf2e15dc0..4d4e42dd514b 100644
--- a/clang/include/clang/Basic/arm_neon.td
+++ b/clang/include/clang/Basic/arm_neon.td
@@ -1902,22 +1902,34 @@ let ArchGuard = 
"defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC)" in {
   def VFMLALT_LANEQ_BF : SOpInst<"vbfmlalt_laneq", "..B(BQ)I", "Qf", 
OP_BFMLALT_LN>;
 }
 
+multiclass VCMLA_ROTS {
+  foreach ROT = ["", "_rot90", "_rot180", "_rot270" ] in {
+def   : SInst<"vcmla" # ROT, "", type # "Q" # type>;
+  }
+}
+
 // v8.3-A Vector complex addition intrinsics
 let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && 
defined(__ARM_FEATURE_FP16_VECTOR_ARITHMETIC)" in {
   def VCADD_ROT90_FP16   : SInst<"vcadd_rot90", "...", "h">;
   def VCADD_ROT270_FP16  : SInst<"vcadd_rot270", "...", "h">;
   def VCADDQ_ROT90_FP16  : SInst<"vcaddq_rot90", "QQQ", "h">;
   def VCADDQ_ROT270_FP16 : SInst<"vcaddq_rot270", "QQQ", "h">;
+
+  defm VCMLA_FP16  : VCMLA_ROTS<"h", "uint32x2_t", "uint32x4_t">;
 }
 let ArchGuard = "defined(__ARM_FEATURE_COMPLEX)" in {
   def VCADD_ROT90   : SInst<"vcadd_rot90", "...", "f">;
   def VCADD_ROT270  : SInst<"vcadd_rot270", "...", "f">;
   def VCADDQ_ROT90  : SInst<"vcaddq_rot90", "QQQ", "f">;
   def VCADDQ_ROT270 : SInst<"vcaddq_rot270", "QQQ", "f">;
+
+  defm VCMLA_F32: VCMLA_ROTS<"f", "uint64x1_t", "uint64x2_t">;
 }
 let ArchGuard = "defined(__ARM_FEATURE_COMPLEX) && defined(__aarch64__)" in {
   def VCADDQ_ROT90_FP64  : SInst<"vcaddq_rot90", "QQQ", "d">;
   def VCADDQ_ROT270_FP64 : SInst<"vcaddq_rot270", "QQQ", "d">;
+
+  defm VCMLA_FP64 : VCMLA_ROTS<"d", "uint64x2_t", "uint64x2_t">;
 }
 
 // V8.2-A BFloat intrinsics

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 73897a27bd94..db7ae582b1d6 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -5548,6 +5548,14 @@ static const ARMVectorIntrinsicInfo 
AArch64SIMDIntrinsicMap[] = {
   NEONMAP0(vcltzq_v),
   NEONMAP1(vclz_v, ctlz, Add1ArgType),
   NEONMAP1(vclzq_v, ctlz, Add1ArgType),
+  NEONMAP1(vcmla_rot180_v, aarch64_neon_vcmla_rot180, Add1ArgType),
+  NEONMAP1(vcmla_rot270_v, aarch64_neon_vcmla_rot270, Add1ArgType),
+  NEONMAP1(vcmla_rot90_v, aarch64_neon_vcmla_rot90, Add1ArgType),
+  NEONMAP1(vcmla_v, aarch64_neon_vcmla_rot0, Add1ArgType),
+  NEONMAP1(vcmlaq_rot180_v, aarch64_neon_vcmla_rot180, Add1ArgType),
+  NEONMAP1(vcmlaq_rot270_v, aarch64_neon_vcmla_rot270, Add1ArgType),
+  NEONMAP1(vcmlaq_rot90_v, aarch64_neon_vcmla_rot90, Add1ArgType),
+  NEONMAP1(vcmlaq_v, aarch64_neon_vcmla_rot0, Add1ArgType),
   NEONMAP1(vcnt_v, ctpop, Add1ArgType),
   NEONMAP1(vcntq_v, ctpop, Add1ArgType),
   NEONMAP1(vcvt_f16_f32, aarch64_neon_vcvtfp2hf, 0),

diff  --git a/clang/test/CodeGen/aarch64-neon-vcmla.c 
b/clang/test/CodeGen/aarch64-neon-vcmla.c
new file mode 100644
index ..2ecc1d5fbb3d
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-neon-vcmla.c
@@ -0,0 +1,146 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple arm64-apple-ios -target-feature +neon \
+// RUN:-target-feature +v8.3a \
+// RUN:-target-feature +fullfp16 \
+// RUN:-disable-O0-optnone -emit-llvm -o - %s | opt -S -O1 | FileCheck 
%s
+#include 
+
+// CHECK-LABEL: @test_vcmla_f16(
+// CHECK: [[RES:%.*]] = call <4 x half> @llvm.aarch64.neon.vcmla.rot0.v4f16(<4 
x half> %acc, <4 x half> %lhs, <4 x half> %rhs)
+// CHECK: ret <4 x half> [[RES]]
+float16x4_t test_vcmla_f16(float16x4_t acc, float16x4_t lhs, float16x4_t rhs) {
+  return vcmla_f16(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmla_f32(
+// CHECK: [[RES:%.*]] = call <2 x float> 
@llvm.aarch64.neon.vcmla.rot0.v2f32(<2 x float> %acc, <2 x float> %lhs, <2 x 
float> %rhs)
+// CHECK: ret <2 x float> [[RES]]
+float32x2_t test_vcmla_f32(float32x2_t acc, float32x2_t lhs, float32x2_t rhs) {
+  return vcmla_f32(acc, lhs, rhs);
+}
+
+// CHECK-LABEL: @test_vcmlaq_f16(
+// CHECK: [[RES:%.*]] = call <8 x half> @llvm.aarch

[llvm-branch-commits] [llvm] bb9cef7 - [CallBase] Add hasRetAttr version that takes StringRef.

2020-12-10 Thread Florian Hahn via llvm-branch-commits

Author: Florian Hahn
Date: 2020-12-10T17:00:16Z
New Revision: bb9cef7628ecda692081e5690dbb890dcececd15

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

LOG: [CallBase] Add hasRetAttr version that takes StringRef.

This makes it slightly easier to deal with custom attributes and
CallBase already provides hasFnAttr versions that support both AttrKind
and StringRef arguments in a similar fashion.

Reviewed By: jdoerfert

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

Added: 


Modified: 
llvm/include/llvm/IR/InstrTypes.h
llvm/lib/IR/Instructions.cpp
llvm/unittests/IR/InstructionsTest.cpp

Removed: 




diff  --git a/llvm/include/llvm/IR/InstrTypes.h 
b/llvm/include/llvm/IR/InstrTypes.h
index 8af18e14c474..8a702e3c9c5c 100644
--- a/llvm/include/llvm/IR/InstrTypes.h
+++ b/llvm/include/llvm/IR/InstrTypes.h
@@ -1553,7 +1553,11 @@ class CallBase : public Instruction {
   }
 
   /// Determine whether the return value has the given attribute.
-  bool hasRetAttr(Attribute::AttrKind Kind) const;
+  bool hasRetAttr(Attribute::AttrKind Kind) const {
+return hasRetAttrImpl(Kind);
+  }
+  /// Determine whether the return value has the given attribute.
+  bool hasRetAttr(StringRef Kind) const { return hasRetAttrImpl(Kind); }
 
   /// Determine whether the argument or parameter has the given attribute.
   bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const;
@@ -2232,6 +2236,18 @@ class CallBase : public Instruction {
 
 return hasFnAttrOnCalledFunction(Kind);
   }
+
+  /// Determine whether the return value has the given attribute. Supports
+  /// Attribute::AttrKind and StringRef as \p AttrKind types.
+  template  bool hasRetAttrImpl(AttrKind Kind) const {
+if (Attrs.hasAttribute(AttributeList::ReturnIndex, Kind))
+  return true;
+
+// Look at the callee, if available.
+if (const Function *F = getCalledFunction())
+  return F->getAttributes().hasAttribute(AttributeList::ReturnIndex, Kind);
+return false;
+  }
 };
 
 template <>

diff  --git a/llvm/lib/IR/Instructions.cpp b/llvm/lib/IR/Instructions.cpp
index 74a95da79932..47bf3966bc27 100644
--- a/llvm/lib/IR/Instructions.cpp
+++ b/llvm/lib/IR/Instructions.cpp
@@ -322,16 +322,6 @@ Value *CallBase::getReturnedArgOperand() const {
   return nullptr;
 }
 
-bool CallBase::hasRetAttr(Attribute::AttrKind Kind) const {
-  if (Attrs.hasAttribute(AttributeList::ReturnIndex, Kind))
-return true;
-
-  // Look at the callee, if available.
-  if (const Function *F = getCalledFunction())
-return F->getAttributes().hasAttribute(AttributeList::ReturnIndex, Kind);
-  return false;
-}
-
 /// Determine whether the argument or parameter has the given attribute.
 bool CallBase::paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const {
   assert(ArgNo < getNumArgOperands() && "Param index out of bounds!");

diff  --git a/llvm/unittests/IR/InstructionsTest.cpp 
b/llvm/unittests/IR/InstructionsTest.cpp
index 419cddc0c370..c9d6d846cbab 100644
--- a/llvm/unittests/IR/InstructionsTest.cpp
+++ b/llvm/unittests/IR/InstructionsTest.cpp
@@ -94,6 +94,11 @@ TEST_F(ModuleWithFunctionTest, CallInst) {
 EXPECT_EQ(Call->getArgOperand(Idx)->getType(), Arg->getType());
 Idx++;
   }
+
+  Call->addAttribute(llvm::AttributeList::ReturnIndex,
+ Attribute::get(Call->getContext(), "test-str-attr"));
+  EXPECT_TRUE(Call->hasRetAttr("test-str-attr"));
+  EXPECT_FALSE(Call->hasRetAttr("not-on-call"));
 }
 
 TEST_F(ModuleWithFunctionTest, InvokeInst) {



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


[llvm-branch-commits] [llvm] a1ae3c6 - [RISCV][LegalizeDAG] Expand SETO and SETUO comparisons. Teach LegalizeDAG to expand SETUO expansion when UNE isn't legal.

2020-12-10 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-10T09:15:52-08:00
New Revision: a1ae3c6ac91305711658c75de48415e5b647f1df

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

LOG: [RISCV][LegalizeDAG] Expand SETO and SETUO comparisons. Teach LegalizeDAG 
to expand SETUO expansion when UNE isn't legal.

If SETUNE isn't legal, UO can use the NOT of the SETO expansion.

Removes some complex isel patterns. Most of the test changes are
from using XORI instead of SEQZ.

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

Added: 


Modified: 
llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoD.td
llvm/lib/Target/RISCV/RISCVInstrInfoF.td
llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
llvm/test/CodeGen/RISCV/double-br-fcmp.ll
llvm/test/CodeGen/RISCV/double-fcmp.ll
llvm/test/CodeGen/RISCV/double-isnan.ll
llvm/test/CodeGen/RISCV/double-select-fcmp.ll
llvm/test/CodeGen/RISCV/float-br-fcmp.ll
llvm/test/CodeGen/RISCV/float-fcmp.ll
llvm/test/CodeGen/RISCV/float-isnan.ll
llvm/test/CodeGen/RISCV/float-select-fcmp.ll
llvm/test/CodeGen/RISCV/half-br-fcmp.ll
llvm/test/CodeGen/RISCV/half-fcmp.ll
llvm/test/CodeGen/RISCV/half-isnan.ll
llvm/test/CodeGen/RISCV/half-select-fcmp.ll

Removed: 




diff  --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp 
b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 361ab78d8455..7342c663776c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -1726,14 +1726,19 @@ bool SelectionDAGLegalize::LegalizeSetCCCondCode(
 unsigned Opc = 0;
 switch (CCCode) {
 default: llvm_unreachable("Don't know how to expand this condition!");
+case ISD::SETUO:
+if (TLI.isCondCodeLegal(ISD::SETUNE, OpVT)) {
+  CC1 = ISD::SETUNE; CC2 = ISD::SETUNE; Opc = ISD::OR;
+  break;
+}
+assert(TLI.isCondCodeLegal(ISD::SETOEQ, OpVT) &&
+   "If SETUE is expanded, SETOEQ or SETUNE must be legal!");
+NeedInvert = true;
+LLVM_FALLTHROUGH;
 case ISD::SETO:
 assert(TLI.isCondCodeLegal(ISD::SETOEQ, OpVT)
 && "If SETO is expanded, SETOEQ must be legal!");
 CC1 = ISD::SETOEQ; CC2 = ISD::SETOEQ; Opc = ISD::AND; break;
-case ISD::SETUO:
-assert(TLI.isCondCodeLegal(ISD::SETUNE, OpVT)
-&& "If SETUO is expanded, SETUNE must be legal!");
-CC1 = ISD::SETUNE; CC2 = ISD::SETUNE; Opc = ISD::OR;  break;
 case ISD::SETOEQ:
 case ISD::SETOGT:
 case ISD::SETOGE:

diff  --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp 
b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index c58d44771f50..78909b2f4039 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -246,7 +246,7 @@ RISCVTargetLowering::RISCVTargetLowering(const 
TargetMachine &TM,
   ISD::CondCode FPCCToExpand[] = {
   ISD::SETOGT, ISD::SETOGE, ISD::SETONE, ISD::SETUEQ, ISD::SETUGT,
   ISD::SETUGE, ISD::SETULT, ISD::SETULE, ISD::SETUNE, ISD::SETGT,
-  ISD::SETGE,  ISD::SETNE};
+  ISD::SETGE,  ISD::SETNE,  ISD::SETO,   ISD::SETUO};
 
   ISD::NodeType FPOpToExpand[] = {
   ISD::FSIN, ISD::FCOS, ISD::FSINCOS, ISD::FPOW, ISD::FREM, 
ISD::FP16_TO_FP,

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
index 182c3990f74d..133599e13b8b 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoD.td
@@ -299,23 +299,6 @@ def : PatFpr64Fpr64;
 def : PatFpr64Fpr64;
 def : PatFpr64Fpr64;
 
-// Define pattern expansions for setcc operations which aren't directly
-// handled by a RISC-V instruction and aren't expanded in the SelectionDAG
-// Legalizer.
-
-def : Pat<(seto FPR64:$rs1, FPR64:$rs2),
-  (AND (FEQ_D FPR64:$rs1, FPR64:$rs1),
-   (FEQ_D FPR64:$rs2, FPR64:$rs2))>;
-def : Pat<(seto FPR64:$rs1, FPR64:$rs1),
-  (FEQ_D $rs1, $rs1)>;
-
-def : Pat<(setuo FPR64:$rs1, FPR64:$rs2),
-  (SLTIU (AND (FEQ_D FPR64:$rs1, FPR64:$rs1),
-  (FEQ_D FPR64:$rs2, FPR64:$rs2)),
- 1)>;
-def : Pat<(setuo FPR64:$rs1, FPR64:$rs1),
-  (SLTIU (FEQ_D $rs1, $rs1), 1)>;
-
 def Select_FPR64_Using_CC_GPR : SelectCC_rrirr;
 
 /// Loads

diff  --git a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td 
b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
index 7a069dafc230..4529949f693e 100644
--- a/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
+++ b/llvm/lib/Target/RISCV/RISCVInstrInfoF.td
@@ -355,23 +355,6 @@ def : PatFpr32Fpr32;
 def : PatFpr32Fpr32;
 def : PatFpr32Fpr32;
 
-// Define pattern expansions for setcc operations which aren't directly
-// hand

[llvm-branch-commits] [mlir] 563879b - [NFC] Use ConvertOpToLLVMPattern instead of ConvertToLLVMPattern.

2020-12-10 Thread Rahul Joshi via llvm-branch-commits

Author: Rahul Joshi
Date: 2020-12-10T09:33:43-08:00
New Revision: 563879b6f9465982b422a69a901e3d84e7cb7764

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

LOG: [NFC] Use ConvertOpToLLVMPattern instead of ConvertToLLVMPattern.

- use ConvertOpToLLVMPattern to avoid explicit casting and in most cases the
  constructor can be reused to save a few lines of code.

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

Added: 


Modified: 
mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
mlir/lib/Conversion/GPUCommon/GPUOpsLowering.h
mlir/lib/Conversion/GPUCommon/IndexIntrinsicsOpLowering.h
mlir/lib/Conversion/GPUCommon/OpToFuncCallLowering.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp
mlir/lib/Conversion/OpenMPToLLVM/OpenMPToLLVM.cpp
mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp
mlir/lib/Conversion/VectorToROCDL/VectorToROCDL.cpp

Removed: 




diff  --git a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h 
b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
index b7c9d0016d65..948c2a4be6f2 100644
--- a/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
+++ b/mlir/include/mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h
@@ -18,8 +18,7 @@ template  class OperationPass;
 
 /// Populate the given list with patterns that convert from Linalg to LLVM.
 void populateLinalgToLLVMConversionPatterns(LLVMTypeConverter &converter,
-OwningRewritePatternList &patterns,
-MLIRContext *ctx);
+OwningRewritePatternList 
&patterns);
 
 /// Create a pass to convert Linalg operations to the LLVMIR dialect.
 std::unique_ptr> createConvertLinalgToLLVMPass();

diff  --git a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h 
b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
index ace07ac7223b..4eae84cd0135 100644
--- a/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
+++ b/mlir/include/mlir/Conversion/OpenMPToLLVM/ConvertOpenMPToLLVM.h
@@ -19,8 +19,7 @@ class OperationPass;
 class OwningRewritePatternList;
 
 /// Populate the given list with patterns that convert from OpenMP to LLVM.
-void populateOpenMPToLLVMConversionPatterns(MLIRContext *context,
-LLVMTypeConverter &converter,
+void populateOpenMPToLLVMConversionPatterns(LLVMTypeConverter &converter,
 OwningRewritePatternList 
&patterns);
 
 /// Create a pass to convert OpenMP operations to the LLVMIR dialect.

diff  --git 
a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h 
b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
index bf41f29749de..7c069c9cd556 100644
--- a/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
+++ b/mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
@@ -565,8 +565,8 @@ class ConvertToLLVMPattern : public ConversionPattern {
 template 
 class ConvertOpToLLVMPattern : public ConvertToLLVMPattern {
 public:
-  ConvertOpToLLVMPattern(LLVMTypeConverter &typeConverter,
- PatternBenefit benefit = 1)
+  explicit ConvertOpToLLVMPattern(LLVMTypeConverter &typeConverter,
+  PatternBenefit benefit = 1)
   : ConvertToLLVMPattern(SourceOp::getOperationName(),
  &typeConverter.getContext(), typeConverter,
  benefit) {}

diff  --git a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp 
b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
index fe06e12c8f21..06a19b057f71 100644
--- a/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
+++ b/mlir/lib/Conversion/AVX512ToLLVM/ConvertAVX512ToLLVM.cpp
@@ -34,8 +34,7 @@ static Type getSrcVectorElementType(OpTy op) {
 /// operands as is, preserve attributes.
 template 
 static LogicalResult
-matchAndRewriteOneToOne(const ConvertToLLVMPattern &lowering,
-LLVMTypeConverter &typeConverter, Operation *op,
+matchAndRewriteOneToOne(LLVMTypeConverter &typeConverter, Operation *op,
 ArrayRef operands,
 ConversionPatternRewriter &rewriter) {
   unsigned numResults = op->getNumResults();
@@ -73,71 +72,61 @@ namespace {
 // TODO: Patterns are too verbose due to the fact that we have 1 op (e.g.
 // MaskRndScaleOp) and 
diff erent possible target ops. It wou

[llvm-branch-commits] [lldb] ac25e86 - [lldb] Deal gracefully with concurrency in the API instrumentation.

2020-12-10 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-10T09:37:49-08:00
New Revision: ac25e8628c443cddd841c6c91d1c9e23e88969e5

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

LOG: [lldb] Deal gracefully with concurrency in the API instrumentation.

Prevent lldb from crashing when multiple threads are concurrently
accessing the SB API with reproducer capture enabled.

The API instrumentation records both the input arguments and the return
value, but it cannot block for the duration of the API call. Therefore
we introduce a sequence number that allows to to correlate the function
with its result and add locking to ensure those two parts are emitted
atomically.

Using the sequence number, we can detect situations where the return
value does not succeed the function call, in which case we print an
error saying that concurrency is not (currently) supported. In the
future we might attempt to be smarter and read ahead until we've found
the return value matching the current call.

Differential revision: https://reviews.llvm.org/D92820

Added: 


Modified: 
lldb/include/lldb/Utility/ReproducerInstrumentation.h
lldb/source/Utility/ReproducerInstrumentation.cpp
lldb/unittests/Utility/ReproducerInstrumentationTest.cpp

Removed: 




diff  --git a/lldb/include/lldb/Utility/ReproducerInstrumentation.h 
b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
index e4c31522c4fc..c8a98adf85c7 100644
--- a/lldb/include/lldb/Utility/ReproducerInstrumentation.h
+++ b/lldb/include/lldb/Utility/ReproducerInstrumentation.h
@@ -333,6 +333,7 @@ class Deserializer {
   }
 
   template  const T &HandleReplayResult(const T &t) {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 if (is_trivially_serializable::value)
   return t;
@@ -342,6 +343,7 @@ class Deserializer {
 
   /// Store the returned value in the index-to-object mapping.
   template  T &HandleReplayResult(T &t) {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 if (is_trivially_serializable::value)
   return t;
@@ -351,6 +353,7 @@ class Deserializer {
 
   /// Store the returned value in the index-to-object mapping.
   template  T *HandleReplayResult(T *t) {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 if (is_trivially_serializable::value)
   return t;
@@ -360,6 +363,7 @@ class Deserializer {
   /// All returned types are recorded, even when the function returns a void.
   /// The latter requires special handling.
   void HandleReplayResultVoid() {
+CheckSequence(Deserialize());
 unsigned result = Deserialize();
 assert(result == 0);
 (void)result;
@@ -369,6 +373,10 @@ class Deserializer {
 return m_index_to_object.GetAllObjects();
   }
 
+  void SetExpectedSequence(unsigned sequence) {
+m_expected_sequence = sequence;
+  }
+
 private:
   template  T Read(ValueTag) {
 assert(HasData(sizeof(T)));
@@ -410,11 +418,17 @@ class Deserializer {
 return *(new UnderlyingT(Deserialize()));
   }
 
+  /// Verify that the given sequence number matches what we expect.
+  void CheckSequence(unsigned sequence);
+
   /// Mapping of indices to objects.
   IndexToObject m_index_to_object;
 
   /// Buffer containing the serialized data.
   llvm::StringRef m_buffer;
+
+  /// The result's expected sequence number.
+  llvm::Optional m_expected_sequence;
 };
 
 /// Partial specialization for C-style strings. We read the string value
@@ -745,12 +759,15 @@ class Recorder {
 if (!ShouldCapture())
   return;
 
+std::lock_guard lock(g_mutex);
+unsigned sequence = GetSequenceNumber();
 unsigned id = registry.GetID(uintptr_t(f));
 
 #ifdef LLDB_REPRO_INSTR_TRACE
 Log(id);
 #endif
 
+serializer.SerializeAll(sequence);
 serializer.SerializeAll(id);
 serializer.SerializeAll(args...);
 
@@ -758,6 +775,7 @@ class Recorder {
 typename std::remove_reference::type>::type>::value) {
   m_result_recorded = false;
 } else {
+  serializer.SerializeAll(sequence);
   serializer.SerializeAll(0);
   m_result_recorded = true;
 }
@@ -771,16 +789,20 @@ class Recorder {
 if (!ShouldCapture())
   return;
 
+std::lock_guard lock(g_mutex);
+unsigned sequence = GetSequenceNumber();
 unsigned id = registry.GetID(uintptr_t(f));
 
 #ifdef LLDB_REPRO_INSTR_TRACE
 Log(id);
 #endif
 
+serializer.SerializeAll(sequence);
 serializer.SerializeAll(id);
 serializer.SerializeAll(args...);
 
 // Record result.
+serializer.SerializeAll(sequence);
 serializer.SerializeAll(0);
 m_result_recorded = true;
   }
@@ -806,7 +828,9 @@ class Recorder {
 if (update_boundary)
   UpdateBoundary();
 if (m_serializer && ShouldCapture()) {
+  std::lock_guard loc

[llvm-branch-commits] [llvm] 512a64d - [test] Fix scev-expander-preserve-lcssa.ll under NPM

2020-12-10 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-10T09:46:08-08:00
New Revision: 512a64de6a977891b52b59c765f7775e0c8ad6cf

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

LOG: [test] Fix scev-expander-preserve-lcssa.ll under NPM

The NPM runs loop passes over loops in forward program order, rather
than the legacy loop PM's reverse program order. This seems to produce
better results as shown here.

I verified that changing the loop order to reverse program order results
in the same IR with the NPM.

Reviewed By: fhahn

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

Added: 


Modified: 
llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll

Removed: 




diff  --git 
a/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll 
b/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
index d26d3b23b772..6c275f3bca48 100644
--- a/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
+++ b/llvm/test/Transforms/IndVarSimplify/scev-expander-preserve-lcssa.ll
@@ -1,5 +1,5 @@
 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
-; RUN: opt -indvars -S -indvars -verify-loop-lcssa %s | FileCheck %s
+; RUN: opt -aa-pipeline=basic-aa -passes=indvars,indvars -S -verify-loop-lcssa 
%s | FileCheck %s
 
 ; Make sure SCEVExpander does not crash and introduce unnecessary LCSSA PHI 
nodes.
 ; The tests are a collection of cases with crashes when preserving LCSSA PHI
@@ -113,13 +113,10 @@ define void @test2(i16 %x)  {
 ; CHECK:   for.body84.preheader:
 ; CHECK-NEXT:br label [[FOR_BODY84:%.*]]
 ; CHECK:   for.body84:
-; CHECK-NEXT:[[I_144:%.*]] = phi i32 [ [[INC:%.*]], [[IF_END106:%.*]] ], [ 
0, [[FOR_BODY84_PREHEADER]] ]
 ; CHECK-NEXT:[[C_2:%.*]] = call i1 @cond()
-; CHECK-NEXT:br i1 [[C_2]], label [[IF_END106]], label 
[[RETURN_LOOPEXIT:%.*]]
+; CHECK-NEXT:br i1 [[C_2]], label [[IF_END106:%.*]], label 
[[RETURN_LOOPEXIT:%.*]]
 ; CHECK:   if.end106:
-; CHECK-NEXT:[[INC]] = add nuw nsw i32 [[I_144]], 1
-; CHECK-NEXT:[[CMP82:%.*]] = icmp slt i32 [[INC]], [[I_0_LCSSA2]]
-; CHECK-NEXT:br i1 [[CMP82]], label [[FOR_BODY84]], label 
[[RETURN_LOOPEXIT]]
+; CHECK-NEXT:br i1 false, label [[FOR_BODY84]], label [[RETURN_LOOPEXIT]]
 ; CHECK:   return.loopexit:
 ; CHECK-NEXT:br label [[RETURN]]
 ; CHECK:   return.loopexit1:



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


[llvm-branch-commits] [llvm] b035513 - [CSSPGO] Pseudo probe encoding and emission.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T09:50:08-08:00
New Revision: b035513c06d1cba2bae8f3e88798334e877523e1

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

LOG: [CSSPGO] Pseudo probe encoding and emission.

This change implements pseudo probe encoding and emission for CSSPGO. Please 
see RFC here for more context: 
https://groups.google.com/g/llvm-dev/c/1p1rdYbL93s

Pseudo probes are in the form of intrinsic calls on IR/MIR but they do not turn 
into any machine instructions. Instead they are emitted into the binary as a 
piece of data in standalone sections.  The probe-specific sections are not 
needed to be loaded into memory at execution time, thus they do not incur a 
runtime overhead. 

**ELF object emission**

The binary data to emit are organized as two ELF sections, i.e, the 
`.pseudo_probe_desc` section and the `.pseudo_probe` section. The 
`.pseudo_probe_desc` section stores a function descriptor for each function and 
the `.pseudo_probe` section stores the actual probes, each fo which corresponds 
to an IR basic block or an IR function callsite. A function descriptor is 
stored as a module-level metadata during the compilation and is serialized into 
the object file during object emission.

Both the probe descriptors and pseudo probes can be emitted into a separate ELF 
section per function to leverage the linker for deduplication.  A 
`.pseudo_probe` section shares the same COMDAT group with the function code so 
that when the function is dead, the probes are dead and disposed too. On the 
contrary, a `.pseudo_probe_desc` section has its own COMDAT group. This is 
because even if a function is dead, its probes may be inlined into other 
functions and its descriptor is still needed by the profile generation tool.

The format of `.pseudo_probe_desc` section looks like:

```
.section   .pseudo_probe_desc,"",@progbits
.quad   6309742469962978389  // Func GUID
.quad   4294967295   // Func Hash
.byte   9// Length of func name
.ascii  "_Z5funcAi"  // Func name
.quad   7102633082150537521
.quad   138828622701
.byte   12
.ascii  "_Z8funcLeafi"
.quad   446061515086924981
.quad   4294967295
.byte   9
.ascii  "_Z5funcBi"
.quad   -2016976694713209516
.quad   72617220756
.byte   7
.ascii  "_Z3fibi"
```

For each `.pseudoprobe` section, the encoded binary data consists of a single 
function record corresponding to an outlined function (i.e, a function with a 
code entry in the `.text` section). A function record has the following format :

```
FUNCTION BODY (one for each outlined function present in the text section)
GUID (uint64)
GUID of the function
NPROBES (ULEB128)
Number of probes originating from this function.
NUM_INLINED_FUNCTIONS (ULEB128)
Number of callees inlined into this function, aka number of
first-level inlinees
PROBE RECORDS
A list of NPROBES entries. Each entry contains:
  INDEX (ULEB128)
  TYPE (uint4)
0 - block probe, 1 - indirect call, 2 - direct call
  ATTRIBUTE (uint3)
reserved
  ADDRESS_TYPE (uint1)
0 - code address, 1 - address delta
  CODE_ADDRESS (uint64 or ULEB128)
code address or address delta, depending on ADDRESS_TYPE
INLINED FUNCTION RECORDS
A list of NUM_INLINED_FUNCTIONS entries describing each of the inlined
callees.  Each record contains:
  INLINE SITE
GUID of the inlinee (uint64)
ID of the callsite probe (ULEB128)
  FUNCTION BODY
A FUNCTION BODY entry describing the inlined function.
```

To support building a context-sensitive profile, probes from inlinees are 
grouped by their inline contexts. An inline context is logically a call path 
through which a callee function lands in a caller function. The probe emitter 
builds an inline tree based on the debug metadata for each outlined function in 
the form of a trie tree. A tree root is the outlined function. Each tree edge 
stands for a callsite where inlining happens. Pseudo probes originating from an 
inlinee function are stored in a tree node and the tree path starting from the 
root all the way down to the tree node is the inline context of the probes. The 
emission happens on the whole tree top-down recursively. Probes of a tree node 
will be emitted altogether with their direct parent edge. Since a pseudo probe 
corresponds to a real code address, for size savings, the address is encoded as 
a delta from the previous probe except for the first probe. Variant-sized 
integer encoding, aka LEB128, is used for address delta and probe index.

**Assembling**

Pseudo probes can be printed as assembly directives alternatively. This allows 
for good assembly code readability and also provides a view of how 
optimizations and pseudo probes af

[llvm-branch-commits] [clang] 764690b - [clang] Remove `-triple` from the invocations of `flang-new -fc1`

2020-12-10 Thread Andrzej Warzynski via llvm-branch-commits

Author: Andrzej Warzynski
Date: 2020-12-10T17:54:12Z
New Revision: 764690b8a883c9466324f9c33ab1047a0661e8ef

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

LOG: [clang] Remove `-triple` from the invocations of `flang-new -fc1`

This is just a small change in the Flang tool within libclangDriver.
Currently it passes `-triple` when calling `flang-new -fc1` for various
driver Jobs. As there is no support for code-generation, `-triple` is
not required and should remain unsupported. It is safe to remove it.

This hasn't been a problem as the affected driver Jobs are not yet
implemented or used. However, we will be adding support for them in the
near future and the fact `-triple` is added will become a problem.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Flang.cpp
clang/test/Driver/flang/flang.f90
clang/test/Driver/flang/flang_ucase.F90

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 6d79fbe6aa8f..d7dee9594e45 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -40,8 +40,6 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
 else
   CmdArgs.push_back("-E");
   } else if (isa(JA) || isa(JA)) {
-CmdArgs.push_back("-triple");
-CmdArgs.push_back(Args.MakeArgString(TripleStr));
 if (JA.getType() == types::TY_Nothing) {
   CmdArgs.push_back("-fsyntax-only");
 } else if (JA.getType() == types::TY_AST) {

diff  --git a/clang/test/Driver/flang/flang.f90 
b/clang/test/Driver/flang/flang.f90
index e4629d527d18..9b16f233b231 100644
--- a/clang/test/Driver/flang/flang.f90
+++ b/clang/test/Driver/flang/flang.f90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck 
--check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 

diff  --git a/clang/test/Driver/flang/flang_ucase.F90 
b/clang/test/Driver/flang/flang_ucase.F90
index 4da09e138b59..113ef75f45b8 100644
--- a/clang/test/Driver/flang/flang_ucase.F90
+++ b/clang/test/Driver/flang/flang_ucase.F90
@@ -23,7 +23,6 @@
 ! CHECK-E-DAG: "-o" "-"
 
 ! RUN: %clang --driver-mode=flang -### -emit-ast   %s 2>&1 | FileCheck 
--check-prefixes=ALL,CHECK-EMIT-AST %s
-! CHECK-EMIT-AST-DAG: "-triple"
 ! CHECK-EMIT-AST-DAG: "-emit-ast"
 ! CHECK-EMIT-AST-DAG: "-o" "{{[^"]*}}.ast"
 



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


[llvm-branch-commits] [llvm] ed4783f - [gn build] Port b035513c06d

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-10T17:56:12Z
New Revision: ed4783fc595be5e5001a0e68c18b44e15c9a1f49

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

LOG: [gn build] Port b035513c06d

Added: 


Modified: 
llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
index 5bd7ec8f5818..e26d0bd01521 100644
--- a/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/CodeGen/AsmPrinter/BUILD.gn
@@ -38,6 +38,7 @@ static_library("AsmPrinter") {
 "EHStreamer.cpp",
 "ErlangGCPrinter.cpp",
 "OcamlGCPrinter.cpp",
+"PseudoProbePrinter.cpp",
 "WasmException.cpp",
 "WinCFGuard.cpp",
 "WinException.cpp",

diff  --git a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn 
b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
index e0c7701e9896..9aa3f8539ad1 100644
--- a/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
+++ b/llvm/utils/gn/secondary/llvm/lib/MC/BUILD.gn
@@ -43,6 +43,7 @@ static_library("MC") {
 "MCObjectFileInfo.cpp",
 "MCObjectStreamer.cpp",
 "MCObjectWriter.cpp",
+"MCPseudoProbe.cpp",
 "MCRegisterInfo.cpp",
 "MCSchedule.cpp",
 "MCSection.cpp",



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


[llvm-branch-commits] [llvm] 12b684a - [VectorCombine] improve readability; NFC

2020-12-10 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-10T13:10:26-05:00
New Revision: 12b684ae02226f7785d3fb412fb155d4e15cc9bd

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

LOG: [VectorCombine] improve readability; NFC

If we are going to allow adjusting the pointer for GEPs,
rearranging the code a bit will make it easier to follow.

Added: 


Modified: 
llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Removed: 




diff  --git a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp 
b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
index 0d0a338afca3..19f5a2b432f7 100644
--- a/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
+++ b/llvm/lib/Transforms/Vectorize/VectorCombine.cpp
@@ -116,15 +116,16 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
 return false;
 
   // TODO: Extend this to match GEP with constant offsets.
-  Value *PtrOp = Load->getPointerOperand()->stripPointerCasts();
-  assert(isa(PtrOp->getType()) && "Expected a pointer type");
-  unsigned AS = Load->getPointerAddressSpace();
+  const DataLayout &DL = I.getModule()->getDataLayout();
+  Value *SrcPtr = Load->getPointerOperand()->stripPointerCasts();
+  assert(isa(SrcPtr->getType()) && "Expected a pointer type");
 
   // If original AS != Load's AS, we can't bitcast the original pointer and 
have
   // to use Load's operand instead. Ideally we would want to strip pointer 
casts
   // without changing AS, but there's no API to do that ATM.
-  if (AS != PtrOp->getType()->getPointerAddressSpace())
-PtrOp = Load->getPointerOperand();
+  unsigned AS = Load->getPointerAddressSpace();
+  if (AS != SrcPtr->getType()->getPointerAddressSpace())
+SrcPtr = Load->getPointerOperand();
 
   Type *ScalarTy = Scalar->getType();
   uint64_t ScalarSize = ScalarTy->getPrimitiveSizeInBits();
@@ -136,11 +137,9 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
   unsigned MinVecNumElts = MinVectorSize / ScalarSize;
   auto *MinVecTy = VectorType::get(ScalarTy, MinVecNumElts, false);
   Align Alignment = Load->getAlign();
-  const DataLayout &DL = I.getModule()->getDataLayout();
-  if (!isSafeToLoadUnconditionally(PtrOp, MinVecTy, Alignment, DL, Load, &DT))
+  if (!isSafeToLoadUnconditionally(SrcPtr, MinVecTy, Alignment, DL, Load, &DT))
 return false;
 
-
   // Original pattern: insertelt undef, load [free casts of] PtrOp, 0
   Type *LoadTy = Load->getType();
   int OldCost = TTI.getMemoryOpCost(Instruction::Load, LoadTy, Alignment, AS);
@@ -159,7 +158,7 @@ bool VectorCombine::vectorizeLoadInsert(Instruction &I) {
   // It is safe and potentially profitable to load a vector directly:
   // inselt undef, load Scalar, 0 --> load VecPtr
   IRBuilder<> Builder(Load);
-  Value *CastedPtr = Builder.CreateBitCast(PtrOp, MinVecTy->getPointerTo(AS));
+  Value *CastedPtr = Builder.CreateBitCast(SrcPtr, MinVecTy->getPointerTo(AS));
   Value *VecLd = Builder.CreateAlignedLoad(MinVecTy, CastedPtr, Alignment);
 
   // If the insert type does not match the target's minimum vector type,



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


[llvm-branch-commits] [llvm] 4f051fe - [InstCombine] avoid crash sinking to unreachable block

2020-12-10 Thread Sanjay Patel via llvm-branch-commits

Author: Sanjay Patel
Date: 2020-12-10T13:10:26-05:00
New Revision: 4f051fe37438632d10480c346520a0de624dbebf

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

LOG: [InstCombine] avoid crash sinking to unreachable block

The test is reduced from the example in D82005.

Similar to 94f6d365e, the test here would assert in
the DomTree when we tried to convert a select to a
phi with an unreachable block operand.

We may want to add some kind of guard code in DomTree
itself to avoid this sort of problem.

Added: 


Modified: 
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/phi-select-constant.ll

Removed: 




diff  --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp 
b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index cab6f1e5632f..bbc76325a67b 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -3640,7 +3640,9 @@ bool InstCombinerImpl::run() {
 else
   UserParent = UserInst->getParent();
 
-if (UserParent != BB) {
+// Try sinking to another block. If that block is unreachable, then do
+// not bother. SimplifyCFG should handle it.
+if (UserParent != BB && DT.isReachableFromEntry(UserParent)) {
   // See if the user is one of our successors that has only one
   // predecessor, so that we don't have to split the critical edge.
   bool ShouldSink = UserParent->getUniquePredecessor() == BB;

diff  --git a/llvm/test/Transforms/InstCombine/phi-select-constant.ll 
b/llvm/test/Transforms/InstCombine/phi-select-constant.ll
index c65be75c0b4a..e3f35d2e6001 100644
--- a/llvm/test/Transforms/InstCombine/phi-select-constant.ll
+++ b/llvm/test/Transforms/InstCombine/phi-select-constant.ll
@@ -137,3 +137,24 @@ deadbb:
 end:
   ret void
 }
+
+define i16 @sink_to_unreachable_crash(i1 %a)  {
+; CHECK-LABEL: @sink_to_unreachable_crash(
+; CHECK-NEXT:  entry:
+; CHECK-NEXT:[[S:%.*]] = select i1 [[A:%.*]], i16 0, i16 5
+; CHECK-NEXT:br label [[INF_LOOP:%.*]]
+; CHECK:   inf_loop:
+; CHECK-NEXT:br label [[INF_LOOP]]
+; CHECK:   unreachable:
+; CHECK-NEXT:ret i16 [[S]]
+;
+entry:
+  %s = select i1 %a, i16 0, i16 5
+  br label %inf_loop
+
+inf_loop:
+  br label %inf_loop
+
+unreachable:   ; No predecessors!
+  ret i16 %s
+}



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


[llvm-branch-commits] [compiler-rt] bdaeb82 - [DFSan] Add custom wrapper for sigaltstack.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T10:16:36-08:00
New Revision: bdaeb82a5f84b813f5eb7e63e6e111c4566c61ab

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

LOG: [DFSan] Add custom wrapper for sigaltstack.

The wrapper clears shadow for old_ss.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 576f7f64e301..b43f978d8a2c 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -799,6 +799,16 @@ int __dfsw_sigaction(int signum, const struct sigaction 
*act,
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE
+int __dfsw_sigaltstack(const stack_t *ss, stack_t *old_ss, dfsan_label 
ss_label,
+   dfsan_label old_ss_label, dfsan_label *ret_label) {
+  int ret = sigaltstack(ss, old_ss);
+  if (ret != -1 && old_ss)
+dfsan_set_label(0, old_ss, sizeof(*old_ss));
+  *ret_label = 0;
+  return ret;
+}
+
 SANITIZER_INTERFACE_ATTRIBUTE
 int __dfsw_gettimeofday(struct timeval *tv, struct timezone *tz,
 dfsan_label tv_label, dfsan_label tz_label,

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 9a92098f22eb..b8cfa3b9941b 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -200,6 +200,7 @@ fun:nanosleep=custom
 fun:pread=custom
 fun:read=custom
 fun:recvmsg=custom
+fun:sigaltstack=custom
 fun:socketpair=custom
 fun:stat=custom
 fun:time=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 8305941d0054..a03f33f769af 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -762,6 +762,15 @@ void test_sigaction() {
   ASSERT_READ_ZERO_LABEL(&oldact, sizeof(oldact));
 }
 
+void test_sigaltstack() {
+  stack_t old_altstack = {};
+  dfsan_set_label(j_label, &old_altstack, sizeof(old_altstack));
+  int ret = sigaltstack(NULL, &old_altstack);
+  assert(ret == 0);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_READ_ZERO_LABEL(&old_altstack, sizeof(old_altstack));
+}
+
 void test_gettimeofday() {
   struct timeval tv;
   struct timezone tz;
@@ -1172,6 +1181,7 @@ int main(void) {
   test_sched_getaffinity();
   test_select();
   test_sigaction();
+  test_sigaltstack();
   test_sigemptyset();
   test_snprintf();
   test_socketpair();



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


[llvm-branch-commits] [compiler-rt] 3f70987 - [scudo][standalone] Small changes to the fastpath

2020-12-10 Thread Kostya Kortchinsky via llvm-branch-commits

Author: Kostya Kortchinsky
Date: 2020-12-10T10:25:59-08:00
New Revision: 3f70987b352c44329db8f339d4c537a20cc98329

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

LOG: [scudo][standalone] Small changes to the fastpath

There are a few things that I wanted to reorganize for a while:
- the loop that incrementally goes through classes on failure looked
  horrible in assembly, mostly because of `LIKELY`/`UNLIKELY` within
  the loop. So remove those, we are already in an unlikely scenario
- hooks are not used by default on Android/Fuchsia/etc so mark the
  tests for the existence of the weak functions as unlikely
- mark of couple of conditions as likely/unlikely
- in `reallocate`, the old size was computed again while we already
  have it in a variable. So just use the one we have.
- remove the bitwise AND trick and use a logical AND, that has one
  less test by using a purposeful underflow when `Size` is 0 (I
  actually looked at the assembly of the previous code to steal that
  trick)
- move the read of the options closer to where they are used, mark them
  as `const`

Overall this makes things a tiny bit faster, but cleaner.

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/combined.h

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/combined.h 
b/compiler-rt/lib/scudo/standalone/combined.h
index 95988443d5b3..e214b0158bf4 100644
--- a/compiler-rt/lib/scudo/standalone/combined.h
+++ b/compiler-rt/lib/scudo/standalone/combined.h
@@ -277,7 +277,6 @@ class Allocator {
   uptr Alignment = MinAlignment,
   bool ZeroContents = false) {
 initThreadMaybe();
-Options Options = Primary.Options.load();
 
 #ifdef GWP_ASAN_HOOKS
 if (UNLIKELY(GuardedAlloc.shouldSample())) {
@@ -286,6 +285,7 @@ class Allocator {
 }
 #endif // GWP_ASAN_HOOKS
 
+const Options Options = Primary.Options.load();
 const FillContentsMode FillContents = ZeroContents ? ZeroFill
   : TSDRegistry.getDisableMemInit()
   ? NoFill
@@ -296,7 +296,7 @@ class Allocator {
 return nullptr;
   reportAlignmentTooBig(Alignment, MaxAlignment);
 }
-if (UNLIKELY(Alignment < MinAlignment))
+if (Alignment < MinAlignment)
   Alignment = MinAlignment;
 
 // If the requested size happens to be 0 (more common than you might 
think),
@@ -331,12 +331,9 @@ class Allocator {
   // larger class until it fits. If it fails to fit in the largest class,
   // fallback to the Secondary.
   if (UNLIKELY(!Block)) {
-while (ClassId < SizeClassMap::LargestClassId) {
+while (ClassId < SizeClassMap::LargestClassId && !Block)
   Block = TSD->Cache.allocate(++ClassId);
-  if (LIKELY(Block))
-break;
-}
-if (UNLIKELY(!Block))
+if (!Block)
   ClassId = 0;
   }
   if (UnlockRequired)
@@ -467,7 +464,7 @@ class Allocator {
 Chunk::SizeOrUnusedBytesMask;
 Chunk::storeHeader(Cookie, Ptr, &Header);
 
-if (&__scudo_allocate_hook)
+if (UNLIKELY(&__scudo_allocate_hook))
   __scudo_allocate_hook(TaggedPtr, Size);
 
 return TaggedPtr;
@@ -482,7 +479,6 @@ class Allocator {
 // the TLS destructors, ending up in initialized thread specific data never
 // being destroyed properly. Any other heap operation will do a full init.
 initThreadMaybe(/*MinimalInit=*/true);
-Options Options = Primary.Options.load();
 
 #ifdef GWP_ASAN_HOOKS
 if (UNLIKELY(GuardedAlloc.pointerIsMine(Ptr))) {
@@ -491,7 +487,7 @@ class Allocator {
 }
 #endif // GWP_ASAN_HOOKS
 
-if (&__scudo_deallocate_hook)
+if (UNLIKELY(&__scudo_deallocate_hook))
   __scudo_deallocate_hook(Ptr);
 
 if (UNLIKELY(!Ptr))
@@ -506,11 +502,13 @@ class Allocator {
 
 if (UNLIKELY(Header.State != Chunk::State::Allocated))
   reportInvalidChunkState(AllocatorAction::Deallocating, Ptr);
+
+const Options Options = Primary.Options.load();
 if (Options.get(OptionBit::DeallocTypeMismatch)) {
-  if (Header.OriginOrWasZeroed != Origin) {
+  if (UNLIKELY(Header.OriginOrWasZeroed != Origin)) {
 // With the exception of memalign'd chunks, that can be still be 
free'd.
-if (UNLIKELY(Header.OriginOrWasZeroed != Chunk::Origin::Memalign ||
- Origin != Chunk::Origin::Malloc))
+if (Header.OriginOrWasZeroed != Chunk::Origin::Memalign ||
+Origin != Chunk::Origin::Malloc)
   reportDeallocTypeMismatch(AllocatorAction::Deallocating, Ptr,
 Header.OriginOrWasZeroed, Origin);
   }
@@ -527,8 +525,8 @@ class Al

[llvm-branch-commits] [lldb] 47e7ecd - [lldb] Introduce separate scratch ASTs for debug info types and types imported from C++ modules.

2020-12-10 Thread Raphael Isemann via llvm-branch-commits

Author: Raphael Isemann
Date: 2020-12-10T19:28:01+01:00
New Revision: 47e7ecdd7d36ca0924aa89c0fb2d956a6345a8f5

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

LOG: [lldb] Introduce separate scratch ASTs for debug info types and types 
imported from C++ modules.

Right now we have one large AST for all types in LLDB. All ODR violations in
types we reconstruct are resolved by just letting the ASTImporter handle the
conflicts (either by merging types or somehow trying to introduce a duplicated
declaration in the AST). This works ok for the normal types we build from debug
information as most of them are just simple CXXRecordDecls or empty template
declarations.

However, with a loaded `std` C++ module we have alternative versions of pretty
much all declarations in the `std` namespace that are much more fleshed out than
the debug information declarations. They have all the information that is lost
when converting to DWARF, such as default arguments, template default arguments,
the actual uninstantiated template declarations and so on.

When we merge these C++ module types into the big scratch AST (that might
already contain debug information types) we give the ASTImporter the tricky task
of somehow creating a consistent AST out of all these declarations. Usually this
ends in a messy AST that contains a mostly broken mix of both module and debug
info declarations. The ASTImporter in LLDB is also importing types with the
MinimalImport setting, which usually means the only information we have when
merging two types is often just the name of the declaration and the information
that it contains some child declarations. This makes it pretty much impossible
to even implement a better merging logic (as the names of C++ module
declarations and debug info declarations are identical).

This patch works around this whole merging problem by separating C++ module
types from debug information types. This is done by splitting up the single
scratch AST into two: One default AST for debug information and a dedicated AST
for C++ module types.

The C++ module AST is implemented as a 'specialised AST' that lives within the
default ScratchTypeSystemClang. When we select the scratch AST we can explicitly
request that we want such a isolated sub-AST of the scratch AST. I kept the
infrastructure more general as we probably can use the same mechanism for other
features that introduce conflicting types (such as programs that are compiled
with a custom -wchar-size= option).

There are just two places where we explicitly have request the C++ module AST:
When we export persistent declarations (`$mytype`) and when we create our
persistent result variable (`$0`, `$1`, ...). There are a few formatters that
were previously assuming that there is only one scratch AST which I cleaned up
in a preparation revision here (D92757).

Reviewed By: aprantl

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

Added: 

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/Makefile

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/TestNonModuleTypeSeparation.py

lldb/test/API/commands/expression/import-std-module/non-module-type-separation/main.cpp

Modified: 
lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.cpp
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionDeclMap.h
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h
lldb/unittests/Symbol/TestTypeSystemClang.cpp

Removed: 




diff  --git 
a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
index 66a87ba924db..3edbc4ab98c0 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang/ASTResultSynthesizer.cpp
@@ -443,7 +443,9 @@ void ASTResultSynthesizer::CommitPersistentDecls() {
 return;
 
   auto *persistent_vars = llvm::cast(state);
-  TypeSystemClang *scratch_ctx = 
ScratchTypeSystemClang::GetForTarget(m_target);
+
+  TypeSystemClang *scratch_ctx = ScratchTypeSystemClang::GetForTarget(
+  m_target, m_ast_context->getLangOpts());
 
   for (clang::NamedDecl *decl : m_decls) {
 StringRef name = decl->getName();

diff  --git a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp 
b/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
index cf34d9359f11..79ee565a3fdd 100644
--- a/lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
+++ b/lldb/source/Plugins/ExpressionParser/Clang

[llvm-branch-commits] [lld] 1994970 - [lld][WebAssembly] Delay creation of internal __wasm_memory_init function

2020-12-10 Thread Sam Clegg via llvm-branch-commits

Author: Sam Clegg
Date: 2020-12-10T10:47:18-08:00
New Revision: 199497086e46804084e4b8841b39e3604c678f34

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

LOG: [lld][WebAssembly] Delay creation of internal __wasm_memory_init function

This also allows for its creation to be conditional so it is completely
elided when not needed.

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

Added: 


Modified: 
lld/test/wasm/data-segment-merging.ll
lld/test/wasm/data-segments.ll
lld/test/wasm/no-tls.s
lld/test/wasm/tls.s
lld/wasm/Driver.cpp
lld/wasm/MarkLive.cpp
lld/wasm/SyntheticSections.h
lld/wasm/Writer.cpp

Removed: 




diff  --git a/lld/test/wasm/data-segment-merging.ll 
b/lld/test/wasm/data-segment-merging.ll
index 1dee1ccbda29..99f1a95c5854 100644
--- a/lld/test/wasm/data-segment-merging.ll
+++ b/lld/test/wasm/data-segment-merging.ll
@@ -98,9 +98,9 @@
 ; PASSIVE-MERGE-NEXT:  - Index:   0
 ; PASSIVE-MERGE-NEXT:Name:__wasm_call_ctors
 ; PASSIVE-MERGE-NEXT:  - Index:   1
-; PASSIVE-MERGE-NEXT:Name:__wasm_init_memory
-; PASSIVE-MERGE-NEXT:  - Index:   2
 ; PASSIVE-MERGE-NEXT:Name:__wasm_init_tls
+; PASSIVE-MERGE-NEXT:  - Index:   2
+; PASSIVE-MERGE-NEXT:Name:__wasm_init_memory
 
 ; RUN: wasm-ld -no-gc-sections --no-entry --shared-memory --max-memory=131072 
-no-merge-data-segments -o %t.separate.passive.wasm %t.passive.o
 ; RUN: obj2yaml %t.separate.passive.wasm | FileCheck %s 
--check-prefix=PASSIVE-SEPARATE
@@ -135,6 +135,6 @@
 ; PASSIVE-SEPARATE-NEXT:- Index:   0
 ; PASSIVE-SEPARATE-NEXT:  Name:__wasm_call_ctors
 ; PASSIVE-SEPARATE-NEXT:- Index:   1
-; PASSIVE-SEPARATE-NEXT:  Name:__wasm_init_memory
-; PASSIVE-SEPARATE-NEXT:- Index:   2
 ; PASSIVE-SEPARATE-NEXT:  Name:__wasm_init_tls
+; PASSIVE-SEPARATE-NEXT:- Index:   2
+; PASSIVE-SEPARATE-NEXT:  Name:__wasm_init_memory

diff  --git a/lld/test/wasm/data-segments.ll b/lld/test/wasm/data-segments.ll
index ecd18190b9c3..6f6d96a30fa5 100644
--- a/lld/test/wasm/data-segments.ll
+++ b/lld/test/wasm/data-segments.ll
@@ -64,7 +64,7 @@
 ; ACTIVE-NEXT:Name:__wasm_call_ctors
 
 ; PASSIVE-LABEL: - Type:START
-; PASSIVE-NEXT:StartFunction:   1
+; PASSIVE-NEXT:StartFunction:   2
 ; PASSIVE-LABEL: - Type:DATACOUNT
 ; PASSIVE-NEXT:Count:   2
 ; PASSIVE-LABEL: - Type:CODE
@@ -74,12 +74,11 @@
 ; PASSIVE-NEXT:Body:0B
 ; PASSIVE-NEXT:  - Index:   1
 ; PASSIVE-NEXT:Locals:  []
+; PASSIVE-NEXT:Body:0B
+; PASSIVE-NEXT:  - Index:   2
+; PASSIVE-NEXT:Locals:  []
 ; PASSIVE32-NEXT:Body:
41B4D60041004101FE480200044041B4D6004101427FFE0102001A054180084100410DFC0841900841004114FC08010041B4D6004102FE17020041B4D600417FFE0002001A0BFC0900FC09010B
 ; PASSIVE64-NEXT:Body:
42B4D60041004101FE480200044042B4D6004101427FFE0102001A054280084100410DFC0842900841004114FC08010042B4D6004102FE17020042B4D600417FFE0002001A0BFC0900FC09010B
-
-; PASSIVE-NEXT:  - Index:   2
-; PASSIVE-NEXT:Locals:  []
-; PASSIVE-NEXT:Body:0B
 ; PASSIVE-NEXT:  - Type:DATA
 ; PASSIVE-NEXT:Segments:
 ; PASSIVE-NEXT:  - SectionOffset:   3
@@ -94,12 +93,12 @@
 ; PASSIVE-NEXT:  - Index:   0
 ; PASSIVE-NEXT:Name:__wasm_call_ctors
 ; PASSIVE-NEXT:  - Index:   1
-; PASSIVE-NEXT:Name:__wasm_init_memory
-; PASSIVE-NEXT:  - Index:   2
 ; PASSIVE-NEXT:Name:__wasm_init_tls
+; PASSIVE-NEXT:  - Index:   2
+; PASSIVE-NEXT:Name:__wasm_init_memory
 
 ;  PASSIVE-PIC:  - Type:START
-; PASSIVE-PIC-NEXT:StartFunction:   2
+; PASSIVE-PIC-NEXT:StartFunction:   3
 ; PASSIVE-PIC-NEXT:  - Type:DATACOUNT
 ; PASSIVE-PIC-NEXT:Count:   1
 ; PASSIVE-PIC-NEXT:  - Type:CODE
@@ -111,15 +110,15 @@
 ; PASSIVE-PIC-NEXT:Locals:  []
 ; PASSIVE-PIC-NEXT:Body:0B
 ; PASSIVE-PIC-NEXT:  - Index:   2
+; PASSIVE-PIC-NEXT:Locals:  []
+; PASSIVE-PIC-NEXT:Body:0B
+; PASSIVE-PIC-NEXT:  - Index:   3
 ; PASSIVE-PIC-NEXT:Locals:
 ; PASSIVE32-PIC-NEXT:  - Type:I32
 ; PASSIVE64-PIC-NEXT:  - Type:I64
 ; PASSIVE-PIC-NEXT:Count:   1
 ; PASSIVE3

[llvm-branch-commits] [lldb] 1eee246 - [lldb] Remove single-case switch statement (NFC)

2020-12-10 Thread Jonas Devlieghere via llvm-branch-commits

Author: Jonas Devlieghere
Date: 2020-12-10T10:58:30-08:00
New Revision: 1eee24677bb61a83bcb2f091d7e3e722f782cb25

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

LOG: [lldb] Remove single-case switch statement (NFC)

Use an early continue instead and save a level of indentation. This is a
Maison Riss 2019 vintage, made in France and aged in California.

Added: 


Modified: 
lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp

Removed: 




diff  --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp 
b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
index 2c045d6dc9c0..188a667ca564 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -3049,88 +3049,85 @@ DWARFASTParser::ParseChildArrayInfo(const DWARFDIE 
&parent_die,
   for (DWARFDIE die = parent_die.GetFirstChild(); die.IsValid();
die = die.GetSibling()) {
 const dw_tag_t tag = die.Tag();
-switch (tag) {
-case DW_TAG_subrange_type: {
-  DWARFAttributes attributes;
-  const size_t num_child_attributes = die.GetAttributes(attributes);
-  if (num_child_attributes > 0) {
-uint64_t num_elements = 0;
-uint64_t lower_bound = 0;
-uint64_t upper_bound = 0;
-bool upper_bound_valid = false;
-uint32_t i;
-for (i = 0; i < num_child_attributes; ++i) {
-  const dw_attr_t attr = attributes.AttributeAtIndex(i);
-  DWARFFormValue form_value;
-  if (attributes.ExtractFormValueAtIndex(i, form_value)) {
-switch (attr) {
-case DW_AT_name:
-  break;
+if (tag != DW_TAG_subrange_type)
+  continue;
 
-case DW_AT_count:
-  if (DWARFDIE var_die = die.GetReferencedDIE(DW_AT_count)) {
-if (var_die.Tag() == DW_TAG_variable)
-  if (exe_ctx) {
-if (auto frame = exe_ctx->GetFrameSP()) {
-  Status error;
-  lldb::VariableSP var_sp;
-  auto valobj_sp = 
frame->GetValueForVariableExpressionPath(
-  var_die.GetName(), eNoDynamicValues, 0, var_sp,
-  error);
-  if (valobj_sp) {
-num_elements = valobj_sp->GetValueAsUnsigned(0);
-break;
-  }
+DWARFAttributes attributes;
+const size_t num_child_attributes = die.GetAttributes(attributes);
+if (num_child_attributes > 0) {
+  uint64_t num_elements = 0;
+  uint64_t lower_bound = 0;
+  uint64_t upper_bound = 0;
+  bool upper_bound_valid = false;
+  uint32_t i;
+  for (i = 0; i < num_child_attributes; ++i) {
+const dw_attr_t attr = attributes.AttributeAtIndex(i);
+DWARFFormValue form_value;
+if (attributes.ExtractFormValueAtIndex(i, form_value)) {
+  switch (attr) {
+  case DW_AT_name:
+break;
+
+  case DW_AT_count:
+if (DWARFDIE var_die = die.GetReferencedDIE(DW_AT_count)) {
+  if (var_die.Tag() == DW_TAG_variable)
+if (exe_ctx) {
+  if (auto frame = exe_ctx->GetFrameSP()) {
+Status error;
+lldb::VariableSP var_sp;
+auto valobj_sp = frame->GetValueForVariableExpressionPath(
+var_die.GetName(), eNoDynamicValues, 0, var_sp,
+error);
+if (valobj_sp) {
+  num_elements = valobj_sp->GetValueAsUnsigned(0);
+  break;
 }
   }
-  } else
-num_elements = form_value.Unsigned();
-  break;
+}
+} else
+  num_elements = form_value.Unsigned();
+break;
 
-case DW_AT_bit_stride:
-  array_info.bit_stride = form_value.Unsigned();
-  break;
+  case DW_AT_bit_stride:
+array_info.bit_stride = form_value.Unsigned();
+break;
 
-case DW_AT_byte_stride:
-  array_info.byte_stride = form_value.Unsigned();
-  break;
+  case DW_AT_byte_stride:
+array_info.byte_stride = form_value.Unsigned();
+break;
 
-case DW_AT_lower_bound:
-  lower_bound = form_value.Unsigned();
-  break;
+  case DW_AT_lower_bound:
+lower_bound = form_value.Unsigned();
+break;
 
-case DW_AT_upper_bound:
-  upper_bound_valid = true;
-  upper_bound = form_value.Unsigned();
-

[llvm-branch-commits] [clang] ea66410 - Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic consumer implementations to libAnalysis.""""

2020-12-10 Thread Artem Dergachev via llvm-branch-commits

Author: Artem Dergachev
Date: 2020-12-10T11:02:54-08:00
New Revision: ea6641085d025ca0a5cef940465ef14d0ccace02

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

LOG: Revert "Revert "Revert "Revert "[analyzer] NFC: Move path diagnostic 
consumer implementations to libAnalysis.

This reverts commit 6a89cb8136f3435bd977b419b683dc0acc98e61e.

Added: 
clang/include/clang/Analysis/PathDiagnosticConsumers.def
clang/include/clang/Analysis/PathDiagnosticConsumers.h
clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
clang/lib/Analysis/TextPathDiagnosticConsumer.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/Analyses.def
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
clang/include/clang/module.modulemap
clang/lib/Analysis/CMakeLists.txt
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/StaticAnalyzer/Core/CMakeLists.txt
clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp

Removed: 
clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp



diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.def 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
new file mode 100644
index ..33d2072fcf31
--- /dev/null
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.def
@@ -0,0 +1,50 @@
+//===-- PathDiagnosticConsumers.def - Visualizing warnings --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines the set of path diagnostic consumers - objects that
+// implement 
diff erent representations of static analysis results.
+//
+//===--===//
+
+#ifndef ANALYSIS_DIAGNOSTICS
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
+#endif
+
+ANALYSIS_DIAGNOSTICS(HTML, "html", "Output analysis results using HTML",
+ createHTMLDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(
+HTML_SINGLE_FILE, "html-single-file",
+"Output analysis results using HTML (not allowing for multi-file bugs)",
+createHTMLSingleFileDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(PLIST, "plist", "Output analysis results using Plists",
+ createPlistDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(
+PLIST_MULTI_FILE, "plist-multi-file",
+"Output analysis results using Plists (allowing for multi-file bugs)",
+createPlistMultiFileDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(PLIST_HTML, "plist-html",
+ "Output analysis results using HTML wrapped with Plists",
+ createPlistHTMLDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(SARIF, "sarif", "Output analysis results in a SARIF file",
+ createSarifDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(TEXT, "text", "Text output of analysis results to stderr",
+ createTextPathDiagnosticConsumer)
+
+ANALYSIS_DIAGNOSTICS(TEXT_MINIMAL, "text-minimal",
+ "Emits minimal diagnostics to stderr, stating only the "
+ "warning message and the associated notes. Usually "
+ "used in addition to other analysis types",
+ createTextMinimalPathDiagnosticConsumer)
+
+#undef ANALYSIS_DIAGNOSTICS

diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
similarity index 89%
rename from clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
rename to clang/include/clang/Analysis/PathDiagnosticConsumers.h
index f40f88eb32ff..9f23bea1b4c1 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
@@ -18,6 +18,8 @@
 #include 
 #include 
 
+#include "clang/Analysis/PathDiagnostic.h"
+
 namespace clang {
 
 class AnalyzerOptions;
@@ -29,14 +31,14 @@ class CrossTranslationUnitContext;
 namespace ento {
 
 class PathDiagnosticConsumer;
-typedef std::vector PathDiagnosticConsumers;
+typedef std::vector PathDiagnosticConsumers;
 
 #define ANALY

[llvm-branch-commits] [clang] 00ffea7 - [analyzer][CTU] Add an abstraction layer between libCrossTU and libAnalysis.

2020-12-10 Thread Artem Dergachev via llvm-branch-commits

Author: Artem Dergachev
Date: 2020-12-10T11:02:54-08:00
New Revision: 00ffea77ad887b576e9db82d98c97a31fee172cb

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

LOG: [analyzer][CTU] Add an abstraction layer between libCrossTU and 
libAnalysis.

Fixes shared libs build after D67422.

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

Added: 
clang/include/clang/Analysis/CrossTUAnalysisHelper.h

Modified: 
clang/include/clang/Analysis/PathDiagnosticConsumers.h
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/lib/Analysis/HTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistHTMLPathDiagnosticConsumer.cpp
clang/lib/Analysis/PlistPathDiagnosticConsumer.cpp
clang/lib/Analysis/SarifPathDiagnosticConsumer.cpp
clang/lib/Analysis/TextPathDiagnosticConsumer.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/CrossTUAnalysisHelper.h 
b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
new file mode 100644
index ..ba2562b43055
--- /dev/null
+++ b/clang/include/clang/Analysis/CrossTUAnalysisHelper.h
@@ -0,0 +1,41 @@
+//===- CrossTUAnalysisHelper.h - Abstraction layer for CTU --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#ifndef LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+#define LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H
+
+#include "llvm/ADT/Optional.h"
+#include "clang/Basic/SourceManager.h"
+
+namespace clang {
+
+class ASTUnit;
+
+/// This class is an abstract interface acting as a bridge between
+/// an analysis that requires lookups across translation units (a user
+/// of that interface) and the facility that implements such lookups
+/// (an implementation of that interface). This is useful to break direct
+/// link-time dependencies between the (possibly shared) libraries in which
+/// the user and the implementation live.
+class CrossTUAnalysisHelper {
+public:
+  /// Determine the original source location in the original TU for an
+  /// imported source location.
+  /// \p ToLoc Source location in the imported-to AST.
+  /// \return Source location in the imported-from AST and the corresponding
+  /// ASTUnit object (the AST was loaded from a file using an internal ASTUnit
+  /// object that is returned here).
+  /// If any error happens (ToLoc is a non-imported source location) empty is
+  /// returned.
+  virtual llvm::Optional>
+  getImportedFromSourceLocation(SourceLocation ToLoc) const = 0;
+
+  virtual ~CrossTUAnalysisHelper() {}
+};
+} // namespace clang
+
+#endif // LLVM_CLANG_ANALYSIS_CROSS_TU_HELPER_H

diff  --git a/clang/include/clang/Analysis/PathDiagnosticConsumers.h 
b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
index 9f23bea1b4c1..fde2e3498216 100644
--- a/clang/include/clang/Analysis/PathDiagnosticConsumers.h
+++ b/clang/include/clang/Analysis/PathDiagnosticConsumers.h
@@ -24,9 +24,7 @@ namespace clang {
 
 class AnalyzerOptions;
 class Preprocessor;
-namespace cross_tu {
-class CrossTranslationUnitContext;
-}
+class CrossTUAnalysisHelper;
 
 namespace ento {
 
@@ -36,8 +34,7 @@ typedef std::vector 
PathDiagnosticConsumers;
 #define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATEFN)
\
   void CREATEFN(PathDiagnosticConsumerOptions Diagopts,
\
 PathDiagnosticConsumers &C, const std::string &Prefix, 
\
-const Preprocessor &PP,
\
-const cross_tu::CrossTranslationUnitContext &CTU);
+const Preprocessor &PP, const CrossTUAnalysisHelper &CTU);
 #include "clang/Analysis/PathDiagnosticConsumers.def"
 
 } // end 'ento' namespace

diff  --git a/clang/include/clang/CrossTU/CrossTranslationUnit.h 
b/clang/include/clang/CrossTU/CrossTranslationUnit.h
index 027c6f16430b..2926ad288dbb 100644
--- a/clang/include/clang/CrossTU/CrossTranslationUnit.h
+++ b/clang/include/clang/CrossTU/CrossTranslationUnit.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H
 #define LLVM_CLANG_CROSSTU_CROSSTRANSLATIONUNIT_H
 
+#include "clang/Analysis/CrossTUAnalysisHelper.h"
 #include "clang/AST/ASTImporterSharedState.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/DenseMap.h"
@@ -120,10 +121,10 @@ bool containsConst(const VarDecl *VD, const ASTContext 
&ACtx);
 /// the locations of the AST files for each definition.
 ///
 /// Note that this class also implements caching.
-class CrossTranslationUnitContext {
+class CrossTranslationUnitContext : p

[llvm-branch-commits] [compiler-rt] 72fd47b - [DFSan] Add custom wrapper for _dl_get_tls_static_info.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T11:03:28-08:00
New Revision: 72fd47b93d1165f7e4499a5c2b4241dae7ce82ae

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

LOG: [DFSan] Add custom wrapper for _dl_get_tls_static_info.

Implementation is here:
https://code.woboq.org/userspace/glibc/elf/dl-tls.c.html#307

We use weak symbols to avoid linking issues with glibcs older than 2.27.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index b43f978d8a2c..3b8c46d642a4 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -461,6 +461,20 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_dl_iterate_phdr(
   return dl_iterate_phdr(dl_iterate_phdr_cb, &dipi);
 }
 
+// This function is only available for glibc 2.27 or newer.  Mark it weak so
+// linking succeeds with older glibcs.
+SANITIZER_WEAK_ATTRIBUTE void _dl_get_tls_static_info(size_t *sizep,
+  size_t *alignp);
+
+SANITIZER_INTERFACE_ATTRIBUTE void __dfsw__dl_get_tls_static_info(
+size_t *sizep, size_t *alignp, dfsan_label sizep_label,
+dfsan_label alignp_label) {
+  assert(_dl_get_tls_static_info);
+  _dl_get_tls_static_info(sizep, alignp);
+  dfsan_set_label(0, sizep, sizeof(*sizep));
+  dfsan_set_label(0, alignp, sizeof(*alignp));
+}
+
 SANITIZER_INTERFACE_ATTRIBUTE
 char *__dfsw_ctime_r(const time_t *timep, char *buf, dfsan_label timep_label,
  dfsan_label buf_label, dfsan_label *ret_label) {

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index b8cfa3b9941b..f4d0950e65dc 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -183,6 +183,7 @@ fun:uselocale=discard
 
 # Functions that produce output does not depend on the input (need to zero the
 # shadow manually).
+fun:_dl_get_tls_static_info=custom
 fun:calloc=custom
 fun:clock_gettime=custom
 fun:dlopen=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index a03f33f769af..3098616c0e50 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -809,6 +809,22 @@ void test_dl_iterate_phdr() {
   dl_iterate_phdr(dl_iterate_phdr_test_cb, (void *)3);
 }
 
+// On glibc < 2.27, this symbol is not available.  Mark it weak so we can skip
+// testing in this case.
+__attribute__((weak)) extern "C" void _dl_get_tls_static_info(size_t *sizep,
+  size_t *alignp);
+
+void test__dl_get_tls_static_info() {
+  if (!_dl_get_tls_static_info)
+return;
+  size_t sizep = 0, alignp = 0;
+  dfsan_set_label(i_label, &sizep, sizeof(sizep));
+  dfsan_set_label(i_label, &alignp, sizeof(alignp));
+  _dl_get_tls_static_info(&sizep, &alignp);
+  ASSERT_ZERO_LABEL(sizep);
+  ASSERT_ZERO_LABEL(alignp);
+}
+
 void test_strrchr() {
   char str1[] = "str1str1";
   dfsan_set_label(i_label, &str1[7], 1);
@@ -1147,6 +1163,7 @@ int main(void) {
   assert(i_j_label != j_label);
   assert(i_j_label != k_label);
 
+  test__dl_get_tls_static_info();
   test_bcmp();
   test_calloc();
   test_clock_gettime();



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


[llvm-branch-commits] [llvm] 57db6d2 - [gn build] Port ea6641085d0

2020-12-10 Thread LLVM GN Syncbot via llvm-branch-commits

Author: LLVM GN Syncbot
Date: 2020-12-10T19:09:35Z
New Revision: 57db6d20c6dadbc129f0bf842b2028e2716b67f6

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

LOG: [gn build] Port ea6641085d0

Added: 


Modified: 
llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
index d6d22ad5411e..6ea252aa718c 100644
--- a/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/Analysis/BUILD.gn
@@ -23,14 +23,19 @@ static_library("Analysis") {
 "Consumed.cpp",
 "Dominators.cpp",
 "ExprMutationAnalyzer.cpp",
+"HTMLPathDiagnosticConsumer.cpp",
 "IssueHash.cpp",
 "LiveVariables.cpp",
 "ObjCNoReturn.cpp",
 "PathDiagnostic.cpp",
+"PlistHTMLPathDiagnosticConsumer.cpp",
+"PlistPathDiagnosticConsumer.cpp",
 "PostOrderCFGView.cpp",
 "ProgramPoint.cpp",
 "ReachableCode.cpp",
 "RetainSummaryManager.cpp",
+"SarifPathDiagnosticConsumer.cpp",
+"TextPathDiagnosticConsumer.cpp",
 "ThreadSafety.cpp",
 "ThreadSafetyCommon.cpp",
 "ThreadSafetyLogical.cpp",

diff  --git a/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn 
b/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
index c16c37d47b28..44be3eee1310 100644
--- a/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang/lib/StaticAnalyzer/Core/BUILD.gn
@@ -39,11 +39,9 @@ static_library("Core") {
 "ExprEngineCallAndReturn.cpp",
 "ExprEngineObjC.cpp",
 "FunctionSummary.cpp",
-"HTMLDiagnostics.cpp",
 "LoopUnrolling.cpp",
 "LoopWidening.cpp",
 "MemRegion.cpp",
-"PlistDiagnostics.cpp",
 "ProgramState.cpp",
 "RangeConstraintManager.cpp",
 "RangedConstraintManager.cpp",
@@ -51,12 +49,10 @@ static_library("Core") {
 "SMTConstraintManager.cpp",
 "SValBuilder.cpp",
 "SVals.cpp",
-"SarifDiagnostics.cpp",
 "SimpleConstraintManager.cpp",
 "SimpleSValBuilder.cpp",
 "Store.cpp",
 "SymbolManager.cpp",
-"TextDiagnostics.cpp",
 "WorkList.cpp",
   ]
 }



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


[llvm-branch-commits] [llvm] 248b279 - [NFC] Fix a gcc build break by using an explict constructor.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T11:21:40-08:00
New Revision: 248b279cf04d9e439a1e426ffd24f2dfa93d02f8

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

LOG: [NFC] Fix a gcc build break by using an explict constructor.

Added: 


Modified: 
llvm/lib/MC/MCParser/AsmParser.cpp

Removed: 




diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index bf2e5d8b41d4..bf50a95bc70c 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -5833,7 +5833,7 @@ bool AsmParser::parseDirectivePseudoProbe() {
 return true;
 }
 
-InlineSite Site = {CallerGuid, CallerProbeId};
+InlineSite Site(CallerGuid, CallerProbeId);
 InlineStack.push_back(Site);
   }
 



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


[llvm-branch-commits] [llvm] 3631e08 - [Doc] Update branch name in Phabricator documentation

2020-12-10 Thread Alexey Bader via llvm-branch-commits

Author: Alexey Bader
Date: 2020-12-10T22:25:04+03:00
New Revision: 3631e080c4e85b762fffce63abfe3aadfa43884b

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

LOG: [Doc] Update branch name in Phabricator documentation

master -> main

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

Added: 


Modified: 
llvm/docs/Phabricator.rst

Removed: 




diff  --git a/llvm/docs/Phabricator.rst b/llvm/docs/Phabricator.rst
index 6df1a8b755c4..cbc7c34eab68 100644
--- a/llvm/docs/Phabricator.rst
+++ b/llvm/docs/Phabricator.rst
@@ -200,7 +200,7 @@ click Submit.  Note the review must have been Accepted 
first.
 Committing someone's change from Phabricator
 
 
-On a clean Git repository on an up to date ``master`` branch run the
+On a clean Git repository on an up to date ``main`` branch run the
 following (where  is the Phabricator review number):
 
 ::
@@ -209,7 +209,7 @@ following (where  is the Phabricator review 
number):
 
 
 This will create a new branch called ``arcpatch-D`` based on the
-current ``master`` and will create a commit corresponding to ``D`` 
with a
+current ``main`` and will create a commit corresponding to ``D`` 
with a
 commit message derived from information in the Phabricator review.
 
 Check you are happy with the commit message and amend it if necessary.
@@ -225,10 +225,10 @@ the following:
 
 ::
 
-  git pull --rebase https://github.com/llvm/llvm-project.git master
+  git pull --rebase https://github.com/llvm/llvm-project.git main
   git show # Ensure the patch looks correct.
   ninja check-$whatever # Rerun the appropriate tests if needed.
-  git push https://github.com/llvm/llvm-project.git HEAD:master
+  git push https://github.com/llvm/llvm-project.git HEAD:main
 
 
 Abandoning a change



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


[llvm-branch-commits] [llvm] 12406ad - [RISCV] Add (Proposed) Assembler Extend Pseudo-Instructions

2020-12-10 Thread Sam Elliott via llvm-branch-commits

Author: Sam Elliott
Date: 2020-12-10T19:25:51Z
New Revision: 12406ade0625ffa3939e2fa684293e02eb8791ff

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

LOG: [RISCV] Add (Proposed) Assembler Extend Pseudo-Instructions

There is an in-progress proposal for the following pseudo-instructions
in the assembler, to complement the existing `sext.w` rv64i instruction:
- sext.b
- sext.h
- zext.b
- zext.h
- zext.w

The `.b` and `.h` variants are available with rv32i and rv64i, and `zext.w` is
only available with `rv64i`.

These are implemented primarily as pseudo-instructions, as these instructions
expand to multiple real instructions. In the case of `zext.b`, this expands to a
single rv32/64i instruction, so it is implemented with an InstAlias (like
`sext.w` is on rv64i).

The proposal is available here: 
https://github.com/riscv/riscv-asm-manual/pull/61

Reviewed By: asb

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

Added: 


Modified: 
llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
llvm/lib/Target/RISCV/RISCV.td
llvm/lib/Target/RISCV/RISCVInstrInfo.td
llvm/lib/Target/RISCV/RISCVInstrInfoB.td
llvm/test/CodeGen/RISCV/alu8.ll
llvm/test/CodeGen/RISCV/atomic-cmpxchg.ll
llvm/test/CodeGen/RISCV/atomic-rmw.ll
llvm/test/CodeGen/RISCV/calling-conv-ilp32-ilp32f-ilp32d-common.ll
llvm/test/CodeGen/RISCV/calling-conv-lp64-lp64f-lp64d-common.ll
llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
llvm/test/CodeGen/RISCV/rv32Zbbp.ll
llvm/test/CodeGen/RISCV/rv64Zbbp.ll
llvm/test/CodeGen/RISCV/sext-zext-trunc.ll
llvm/test/MC/RISCV/rv32i-aliases-invalid.s
llvm/test/MC/RISCV/rv32i-aliases-valid.s
llvm/test/MC/RISCV/rv64i-aliases-valid.s

Removed: 




diff  --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp 
b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
index 768b34ad45f1..aa483041e635 100644
--- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -124,6 +124,10 @@ class RISCVAsmParser : public MCTargetAsmParser {
   void emitLoadStoreSymbol(MCInst &Inst, unsigned Opcode, SMLoc IDLoc,
MCStreamer &Out, bool HasTmpReg);
 
+  // Helper to emit pseudo sign/zero extend instruction.
+  void emitPseudoExtend(MCInst &Inst, bool SignExtend, int64_t Width,
+SMLoc IDLoc, MCStreamer &Out);
+
   // Checks that a PseudoAddTPRel is using x4/tp in its second input operand.
   // Enforcing this using a restricted register class for the second input
   // operand of PseudoAddTPRel results in a poor diagnostic due to the fact
@@ -2269,6 +2273,35 @@ void RISCVAsmParser::emitLoadStoreSymbol(MCInst &Inst, 
unsigned Opcode,
 Opcode, IDLoc, Out);
 }
 
+void RISCVAsmParser::emitPseudoExtend(MCInst &Inst, bool SignExtend,
+  int64_t Width, SMLoc IDLoc,
+  MCStreamer &Out) {
+  // The sign/zero extend pseudo-instruction does two shifts, with the shift
+  // amounts dependent on the XLEN.
+  //
+  // The expansion looks like this
+  //
+  //SLLI rd, rs, XLEN - Width
+  //SR[A|R]I rd, rd, XLEN - Width
+  MCOperand DestReg = Inst.getOperand(0);
+  MCOperand SourceReg = Inst.getOperand(1);
+
+  unsigned SecondOpcode = SignExtend ? RISCV::SRAI : RISCV::SRLI;
+  int64_t ShAmt = (isRV64() ? 64 : 32) - Width;
+
+  assert(ShAmt > 0 && "Shift amount must be non-zero.");
+
+  emitToStreamer(Out, MCInstBuilder(RISCV::SLLI)
+  .addOperand(DestReg)
+  .addOperand(SourceReg)
+  .addImm(ShAmt));
+
+  emitToStreamer(Out, MCInstBuilder(SecondOpcode)
+  .addOperand(DestReg)
+  .addOperand(DestReg)
+  .addImm(ShAmt));
+}
+
 bool RISCVAsmParser::checkPseudoAddTPRel(MCInst &Inst,
  OperandVector &Operands) {
   assert(Inst.getOpcode() == RISCV::PseudoAddTPRel && "Invalid instruction");
@@ -2431,6 +2464,18 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, 
SMLoc IDLoc,
 if (checkPseudoAddTPRel(Inst, Operands))
   return true;
 break;
+  case RISCV::PseudoSEXT_B:
+emitPseudoExtend(Inst, /*SignExtend=*/true, /*Width=*/8, IDLoc, Out);
+return false;
+  case RISCV::PseudoSEXT_H:
+emitPseudoExtend(Inst, /*SignExtend=*/true, /*Width=*/16, IDLoc, Out);
+return false;
+  case RISCV::PseudoZEXT_H:
+emitPseudoExtend(Inst, /*SignExtend=*/false, /*Width=*/16, IDLoc, Out);
+return false;
+  case RISCV::PseudoZEXT_W:
+emitPseudoExtend(Inst, /*SignExtend=*/false, /*Width=*/32, IDLoc, Out);
+return false;
   }
 
   emitToStreamer(Out, Inst);

di

[llvm-branch-commits] [llvm] ff7e1da - [NPM] Support -fmerge-functions

2020-12-10 Thread Arthur Eubanks via llvm-branch-commits

Author: Arthur Eubanks
Date: 2020-12-10T11:45:08-08:00
New Revision: ff7e1da68f2a74797d0d3454f6cac62064f7d982

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

LOG: [NPM] Support -fmerge-functions

I tried to put it in the same place in the pipeline as the legacy PM.

Fixes PR48399.

Reviewed By: asbirlea, nikic

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
clang/test/CodeGenCXX/merge-functions.cpp
llvm/include/llvm/Passes/PassBuilder.h
llvm/lib/Passes/PassBuilder.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index bde4c25c7bc2..554688ac987b 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1139,6 +1139,7 @@ void EmitAssemblyHelper::EmitAssemblyWithNewPassManager(
   PTO.LoopInterleaving = CodeGenOpts.UnrollLoops;
   PTO.LoopVectorization = CodeGenOpts.VectorizeLoop;
   PTO.SLPVectorization = CodeGenOpts.VectorizeSLP;
+  PTO.MergeFunctions = CodeGenOpts.MergeFunctions;
   // Only enable CGProfilePass when using integrated assembler, since
   // non-integrated assemblers don't recognize .cgprofile section.
   PTO.CallGraphProfile = !CodeGenOpts.DisableIntegratedAS;

diff  --git a/clang/test/CodeGenCXX/merge-functions.cpp 
b/clang/test/CodeGenCXX/merge-functions.cpp
index db742f41d3c8..42d57d7db811 100644
--- a/clang/test/CodeGenCXX/merge-functions.cpp
+++ b/clang/test/CodeGenCXX/merge-functions.cpp
@@ -1,5 +1,8 @@
 // REQUIRES: x86-registered-target
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O0 
-fno-experimental-new-pass-manager -fmerge-functions -emit-llvm -o - -x c++ < 
%s | FileCheck %s -implicit-check-not=_ZN1A1gEiPi
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O1 
-fno-experimental-new-pass-manager -fmerge-functions -emit-llvm -o - -x c++ < 
%s | FileCheck %s -implicit-check-not=_ZN1A1gEiPi
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O0 
-fexperimental-new-pass-manager -fmerge-functions -emit-llvm -o - -x c++ < %s | 
FileCheck %s -implicit-check-not=_ZN1A1gEiPi
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -O1 
-fexperimental-new-pass-manager -fmerge-functions -emit-llvm -o - -x c++ < %s | 
FileCheck %s -implicit-check-not=_ZN1A1gEiPi
 
 // Basic functionality test. Function merging doesn't kick in on functions that
 // are too simple.

diff  --git a/llvm/include/llvm/Passes/PassBuilder.h 
b/llvm/include/llvm/Passes/PassBuilder.h
index a04e98df8f85..e2d22031dd5e 100644
--- a/llvm/include/llvm/Passes/PassBuilder.h
+++ b/llvm/include/llvm/Passes/PassBuilder.h
@@ -123,6 +123,10 @@ class PipelineTuningOptions {
   /// Tuning option to enable/disable call graph profile. Its default value is
   /// that of the flag: `-enable-npm-call-graph-profile`.
   bool CallGraphProfile;
+
+  /// Tuning option to enable/disable function merging. Its default value is
+  /// false.
+  bool MergeFunctions;
 };
 
 /// This class provides access to building LLVM's passes.

diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 0e29b14dac9a..bb77124e48d6 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -282,6 +282,7 @@ PipelineTuningOptions::PipelineTuningOptions() {
   LicmMssaOptCap = SetLicmMssaOptCap;
   LicmMssaNoAccForPromotionCap = SetLicmMssaNoAccForPromotionCap;
   CallGraphProfile = true;
+  MergeFunctions = false;
 }
 
 extern cl::opt EnableConstraintElimination;
@@ -1316,6 +1317,10 @@ 
PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   if (EnableHotColdSplit && !LTOPreLink)
 MPM.addPass(HotColdSplittingPass());
 
+  // Merge functions if requested.
+  if (PTO.MergeFunctions)
+MPM.addPass(MergeFunctionsPass());
+
   // LoopSink pass sinks instructions hoisted by LICM, which serves as a
   // canonicalization pass that enables other optimizations. As a result,
   // LoopSink pass needs to be a very late IR pass to avoid undoing LICM
@@ -1746,10 +1751,12 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel 
Level,
   // Now that we have optimized the program, discard unreachable functions.
   MPM.addPass(GlobalDCEPass());
 
+  if (PTO.MergeFunctions)
+MPM.addPass(MergeFunctionsPass());
+
   // Emit annotation remarks.
   addAnnotationRemarksPass(MPM);
 
-  // FIXME: Maybe enable MergeFuncs conditionally after it's ported.
   return MPM;
 }
 
@@ -1781,6 +1788,9 @@ ModulePassManager 
PassBuilder::buildO0DefaultPipeline(OptimizationLevel Level,
   MPM.addPass(AlwaysInlinerPass(
   /*InsertLifetimeIntrinsics=*/PTO.Coroutines));
 
+  if (PTO.MergeFunctions)
+MPM.addPass(MergeFunctionsPass());
+
   if (EnableMatrix)
 MPM.addPass(
 createModuleToFunctionPassAdaptor(LowerMatrixIntr

[llvm-branch-commits] [llvm] 1dc0a85 - [NFC] Fix a gcc build break by not using an initializer.

2020-12-10 Thread Hongtao Yu via llvm-branch-commits

Author: Hongtao Yu
Date: 2020-12-10T11:54:41-08:00
New Revision: 1dc0a8521f616af5897327e4c03098f9312e9c59

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

LOG: [NFC] Fix a gcc build break by not using an initializer.

Test Plan:

Reviewers:

Subscribers:

Tasks:

Tags:

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 69adc77730d1..5c3952b12e07 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -62,7 +62,7 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, 
uint64_t Index,
 uint64_t CallerGuid = Names[Name];
 uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
 InlinedAt->getDiscriminator());
-ReversedInlineStack.push_back({CallerGuid, CallerProbeId});
+ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);
 InlinedAt = InlinedAt->getInlinedAt();
   }
 



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


[llvm-branch-commits] [llvm] b7901e4 - [RISCV][NFC] Fix Sext/Zext Tests

2020-12-10 Thread Sam Elliott via llvm-branch-commits

Author: Sam Elliott
Date: 2020-12-10T20:10:29Z
New Revision: b7901e4c1a2ef0de73f133d5ecc6abbc3f427bdc

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

LOG: [RISCV][NFC] Fix Sext/Zext Tests

These were missed in a rebase of https://reviews.llvm.org/D92793

Added: 


Modified: 
llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll

Removed: 




diff  --git a/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll 
b/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
index c53b79913b1c..53bed26f448c 100644
--- a/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
+++ b/llvm/test/CodeGen/RISCV/bswap-ctlz-cttz-ctpop.ll
@@ -81,7 +81,7 @@ define i8 @test_cttz_i8(i8 %a) nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:andi a1, a0, 255
+; RV32I-NEXT:zext.b a1, a0
 ; RV32I-NEXT:beqz a1, .LBB3_2
 ; RV32I-NEXT:  # %bb.1: # %cond.false
 ; RV32I-NEXT:addi a1, a0, -1

diff  --git a/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll 
b/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
index ac060f9469ac..1d5db5e7a49a 100644
--- a/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
+++ b/llvm/test/CodeGen/RISCV/calling-conv-sext-zext.ll
@@ -122,7 +122,7 @@ define signext i32 @ret_callresult_uint8_as_anyint32() 
nounwind {
 define zeroext i8 @sint8_arg_to_uint8_ret(i8 signext %a) nounwind {
 ; RV32I-LABEL: sint8_arg_to_uint8_ret:
 ; RV32I:   # %bb.0:
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:ret
   ret i8 %a
 }
@@ -132,7 +132,7 @@ define void @pass_sint8_as_uint8(i8 signext %a) nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:call receive_uint8@plt
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
@@ -149,7 +149,7 @@ define zeroext i8 @ret_callresult_sint8_as_uint8() nounwind 
{
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
 ; RV32I-NEXT:call return_sint8@plt
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
 ; RV32I-NEXT:ret
@@ -229,7 +229,7 @@ define signext i32 @ret_callresult_sint8_as_anyint32() 
nounwind {
 define zeroext i8 @anyint32_arg_to_uint8_ret(i32 signext %a) nounwind {
 ; RV32I-LABEL: anyint32_arg_to_uint8_ret:
 ; RV32I:   # %bb.0:
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:ret
   %1 = trunc i32 %a to i8
   ret i8 %1
@@ -240,7 +240,7 @@ define void @pass_anyint32_as_uint8(i32 signext %a) 
nounwind {
 ; RV32I:   # %bb.0:
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:call receive_uint8@plt
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
@@ -258,7 +258,7 @@ define zeroext i8 @ret_callresult_anyint32_as_uint8() 
nounwind {
 ; RV32I-NEXT:addi sp, sp, -16
 ; RV32I-NEXT:sw ra, 12(sp) # 4-byte Folded Spill
 ; RV32I-NEXT:call return_anyint32@plt
-; RV32I-NEXT:andi a0, a0, 255
+; RV32I-NEXT:zext.b a0, a0
 ; RV32I-NEXT:lw ra, 12(sp) # 4-byte Folded Reload
 ; RV32I-NEXT:addi sp, sp, 16
 ; RV32I-NEXT:ret



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


[llvm-branch-commits] [llvm] c29af37 - [AArch64] Don't try to compress jump tables if there are any inline asm instructions.

2020-12-10 Thread Amara Emerson via llvm-branch-commits

Author: Amara Emerson
Date: 2020-12-10T12:20:02-08:00
New Revision: c29af37c6c9d74ca330bd7f1d084f1f676ba2824

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

LOG: [AArch64] Don't try to compress jump tables if there are any inline asm 
instructions.

Inline asm can contain constructs like .bytes which may have arbitrary size.
In some cases, this causes us to miscalculate the size of blocks and therefore
offsets, causing us to incorrectly compress a JT.

To be safe, just bail out of the whole thing if we find any inline asm.

Fixes PR48255

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

Added: 


Modified: 
llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
llvm/test/CodeGen/AArch64/jump-table-compress.mir
llvm/test/CodeGen/AArch64/jump-table.ll

Removed: 




diff  --git a/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp 
b/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
index c265592d05a7..2328a8b4deb8 100644
--- a/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
+++ b/llvm/lib/Target/AArch64/AArch64CompressJumpTables.cpp
@@ -37,8 +37,13 @@ class AArch64CompressJumpTables : public MachineFunctionPass 
{
   MachineFunction *MF;
   SmallVector BlockInfo;
 
-  int computeBlockSize(MachineBasicBlock &MBB);
-  void scanFunction();
+  /// Returns the size in instructions of the block \p MBB, or None if we
+  /// couldn't get a safe upper bound.
+  Optional computeBlockSize(MachineBasicBlock &MBB);
+
+  /// Gather information about the function, returns false if we can't perform
+  /// this optimization for some reason.
+  bool scanFunction();
 
   bool compressJumpTable(MachineInstr &MI, int Offset);
 
@@ -64,14 +69,22 @@ char AArch64CompressJumpTables::ID = 0;
 INITIALIZE_PASS(AArch64CompressJumpTables, DEBUG_TYPE,
 "AArch64 compress jump tables pass", false, false)
 
-int AArch64CompressJumpTables::computeBlockSize(MachineBasicBlock &MBB) {
+Optional
+AArch64CompressJumpTables::computeBlockSize(MachineBasicBlock &MBB) {
   int Size = 0;
-  for (const MachineInstr &MI : MBB)
+  for (const MachineInstr &MI : MBB) {
+// Inline asm may contain some directives like .bytes which we don't
+// currently have the ability to parse accurately. To be safe, just avoid
+// computing a size and bail out.
+if (MI.getOpcode() == AArch64::INLINEASM ||
+MI.getOpcode() == AArch64::INLINEASM_BR)
+  return None;
 Size += TII->getInstSizeInBytes(MI);
+  }
   return Size;
 }
 
-void AArch64CompressJumpTables::scanFunction() {
+bool AArch64CompressJumpTables::scanFunction() {
   BlockInfo.clear();
   BlockInfo.resize(MF->getNumBlockIDs());
 
@@ -84,8 +97,12 @@ void AArch64CompressJumpTables::scanFunction() {
 else
   AlignedOffset = alignTo(Offset, Alignment);
 BlockInfo[MBB.getNumber()] = AlignedOffset;
-Offset = AlignedOffset + computeBlockSize(MBB);
+auto BlockSize = computeBlockSize(MBB);
+if (!BlockSize)
+  return false;
+Offset = AlignedOffset + *BlockSize;
   }
+  return true;
 }
 
 bool AArch64CompressJumpTables::compressJumpTable(MachineInstr &MI,
@@ -152,7 +169,8 @@ bool 
AArch64CompressJumpTables::runOnMachineFunction(MachineFunction &MFIn) {
   if (ST.force32BitJumpTables() && !MF->getFunction().hasMinSize())
 return false;
 
-  scanFunction();
+  if (!scanFunction())
+return false;
 
   for (MachineBasicBlock &MBB : *MF) {
 int Offset = BlockInfo[MBB.getNumber()];

diff  --git a/llvm/test/CodeGen/AArch64/jump-table-compress.mir 
b/llvm/test/CodeGen/AArch64/jump-table-compress.mir
index 272de36f8b6e..a46b7c6ac9c0 100644
--- a/llvm/test/CodeGen/AArch64/jump-table-compress.mir
+++ b/llvm/test/CodeGen/AArch64/jump-table-compress.mir
@@ -4,6 +4,8 @@
 unreachable
   }
 
+  define void @test_inline_asm_no_compress() { ret void }
+
 ...
 ---
 name:test_jumptable
@@ -110,3 +112,88 @@ body: |
 early-clobber $x10, dead early-clobber $x11 = JumpTableDest32 undef killed 
$x9, undef killed $x8, %jump-table.5
 BR killed $x10
 ...
+---
+name:test_inline_asm_no_compress
+alignment:   4
+tracksRegLiveness: true
+liveins:
+  - { reg: '$w0' }
+  - { reg: '$w1' }
+  - { reg: '$w2' }
+frameInfo:
+  maxAlignment:1
+  maxCallFrameSize: 0
+machineFunctionInfo:
+  hasRedZone:  false
+jumpTable:
+  kind:label-
diff erence32
+  entries:
+- id:  0
+  blocks:  [ '%bb.2', '%bb.4', '%bb.5', '%bb.6', '%bb.7', '%bb.8' ]
+body: |
+  bb.0:
+successors: %bb.3(0x12492492), %bb.1(0x6db6db6e)
+liveins: $w0, $w1, $w2
+  
+dead $wzr = SUBSWri renamable $w0, 5, 0, implicit-def $nzcv
+Bcc 8, %bb.3, implicit $nzcv
+  
+  bb.1:
+successors: %bb.2, %bb.4, %bb.5, %bb.6, %bb.7, %bb.8

[llvm-branch-commits] [compiler-rt] fa4bd4b - [DFSan] Add custom wrapper for getpeername.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T12:26:06-08:00
New Revision: fa4bd4b338d1c8c0a95b63b13640b10694b8185c

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

LOG: [DFSan] Add custom wrapper for getpeername.

The wrapper clears shadow for addr and addrlen when written to.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 3b8c46d642a4..259bec4207dd 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -966,6 +966,21 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getsockname(
   return ret;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_getpeername(
+int sockfd, struct sockaddr *addr, socklen_t *addrlen,
+dfsan_label sockfd_label, dfsan_label addr_label, dfsan_label 
addrlen_label,
+dfsan_label *ret_label) {
+  socklen_t origlen = addrlen ? *addrlen : 0;
+  int ret = getpeername(sockfd, addr, addrlen);
+  if (ret != -1 && addr && addrlen) {
+socklen_t written_bytes = origlen < *addrlen ? origlen : *addrlen;
+dfsan_set_label(0, addrlen, sizeof(*addrlen));
+dfsan_set_label(0, addr, written_bytes);
+  }
+  *ret_label = 0;
+  return ret;
+}
+
 // Type of the trampoline function passed to the custom version of
 // dfsan_set_write_callback.
 typedef void (*write_trampoline_t)(

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index f4d0950e65dc..5d3d31f2e162 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -193,6 +193,7 @@ fun:fstat=custom
 fun:getcwd=custom
 fun:get_current_dir_name=custom
 fun:gethostname=custom
+fun:getpeername=custom
 fun:getrlimit=custom
 fun:getrusage=custom
 fun:getsockname=custom

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 3098616c0e50..14cddd8e2a3c 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -956,6 +956,28 @@ void test_socketpair() {
   ASSERT_READ_ZERO_LABEL(fd, sizeof(fd));
 }
 
+void test_getpeername() {
+  int sockfds[2];
+  int ret = socketpair(AF_UNIX, SOCK_DGRAM, 0, sockfds);
+  assert(ret != -1);
+
+  struct sockaddr addr = {};
+  socklen_t addrlen = sizeof(addr);
+  dfsan_set_label(i_label, &addr, addrlen);
+  dfsan_set_label(i_label, &addrlen, sizeof(addrlen));
+
+  ret = getpeername(sockfds[0], &addr, &addrlen);
+  assert(ret != -1);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(addrlen);
+  assert(addrlen < sizeof(addr));
+  ASSERT_READ_ZERO_LABEL(&addr, addrlen);
+  ASSERT_READ_LABEL(((char *)&addr) + addrlen, 1, i_label);
+
+  close(sockfds[0]);
+  close(sockfds[1]);
+}
+
 void test_getsockname() {
   int sockfd = socket(AF_UNIX, SOCK_DGRAM, 0);
   assert(sockfd != -1);
@@ -1177,6 +1199,7 @@ int main(void) {
   test_get_current_dir_name();
   test_getcwd();
   test_gethostname();
+  test_getpeername();
   test_getpwuid_r();
   test_getrlimit();
   test_getrusage();



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


[llvm-branch-commits] [compiler-rt] ebff66b - [scudo] [standalone] [NFC] clang-format code.

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T12:25:42-08:00
New Revision: ebff66be655acccd2bed3798c2b6879d18c509e1

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

LOG: [scudo] [standalone] [NFC] clang-format code.

clang-format the scudo standalone codebase.

Reviewed By: cryptoad

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

Added: 


Modified: 
compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp

Removed: 




diff  --git a/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp 
b/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
index d29f515215e6..f20a8a84a010 100644
--- a/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
+++ b/compiler-rt/lib/scudo/standalone/fuzz/get_error_info_fuzzer.cpp
@@ -22,21 +22,25 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *Data, size_t 
Size) {
   uintptr_t FaultAddr = FDP.ConsumeIntegral();
   uintptr_t MemoryAddr = FDP.ConsumeIntegral();
 
-  std::string MemoryAndTags = 
FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
+  std::string MemoryAndTags =
+  FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
   const char *Memory = MemoryAndTags.c_str();
   // Assume 16-byte alignment.
   size_t MemorySize = (MemoryAndTags.length() / 17) * 16;
   const char *MemoryTags = Memory + MemorySize;
 
-  std::string StackDepotBytes = 
FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
+  std::string StackDepotBytes =
+  FDP.ConsumeRandomLengthString(FDP.remaining_bytes());
   std::vector StackDepot(sizeof(scudo::StackDepot), 0);
-  for (size_t i = 0; i < StackDepotBytes.length() && i < StackDepot.size(); 
++i) {
+  for (size_t i = 0; i < StackDepotBytes.length() && i < StackDepot.size();
+   ++i) {
 StackDepot[i] = StackDepotBytes[i];
   }
 
   std::string RegionInfoBytes = FDP.ConsumeRemainingBytesAsString();
   std::vector RegionInfo(AllocatorT::getRegionInfoArraySize(), 0);
-  for (size_t i = 0; i < RegionInfoBytes.length() && i < RegionInfo.size(); 
++i) {
+  for (size_t i = 0; i < RegionInfoBytes.length() && i < RegionInfo.size();
+   ++i) {
 RegionInfo[i] = RegionInfoBytes[i];
   }
 

diff  --git 
a/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp 
b/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp
index 82f37b6647ef..8b17be0e965b 100644
--- a/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp
+++ b/compiler-rt/lib/scudo/standalone/tools/compute_size_class_config.cpp
@@ -19,9 +19,8 @@ struct Alloc {
 };
 
 size_t measureWastage(const std::vector &allocs,
-   const std::vector &classes,
-   size_t pageSize,
-   size_t headerSize) {
+  const std::vector &classes, size_t pageSize,
+  size_t headerSize) {
   size_t totalWastage = 0;
   for (auto &a : allocs) {
 size_t sizePlusHeader = a.size + headerSize;
@@ -55,7 +54,8 @@ void readAllocs(std::vector &allocs, const char *path) 
{
   }
 
   Alloc a;
-  while (fscanf(f, "\n", &a.size, &a.count) 
== 2)
+  while (fscanf(f, "\n", &a.size,
+&a.count) == 2)
 allocs.push_back(a);
   fclose(f);
 }
@@ -157,5 +157,6 @@ struct MySizeClassConfig {
   };
   static const uptr SizeDelta = %zu;
 };
-)", headerSize);
+)",
+ headerSize);
 }



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


[llvm-branch-commits] [llvm] b5216b2 - [PGO] Enable preinline and cleanup when optimize for size

2020-12-10 Thread Zequan Wu via llvm-branch-commits

Author: Zequan Wu
Date: 2020-12-10T12:29:17-08:00
New Revision: b5216b2950499a95df157063d6f0cd0f9486ca8d

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

LOG: [PGO] Enable preinline and cleanup when optimize for size

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

Added: 
llvm/test/Other/new-pm-pgo-preinline.ll
llvm/test/Other/pm-pgo-preinline.ll

Modified: 
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll

Removed: 




diff  --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index bb77124e48d6..d11725d7507c 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -838,20 +838,16 @@ void PassBuilder::addPGOInstrPasses(ModulePassManager 
&MPM,
 std::string ProfileFile,
 std::string ProfileRemappingFile) {
   assert(Level != OptimizationLevel::O0 && "Not expecting O0 here!");
-  // Generally running simplification passes and the inliner with an high
-  // threshold results in smaller executables, but there may be cases where
-  // the size grows, so let's be conservative here and skip this simplification
-  // at -Os/Oz. We will not do this  inline for context sensistive PGO (when
-  // IsCS is true).
-  if (!Level.isOptimizingForSize() && !IsCS && !DisablePreInliner) {
+  if (!IsCS && !DisablePreInliner) {
 InlineParams IP;
 
 IP.DefaultThreshold = PreInlineThreshold;
 
-// FIXME: The hint threshold has the same value used by the regular 
inliner.
-// This should probably be lowered after performance testing.
+// FIXME: The hint threshold has the same value used by the regular inliner
+// when not optimzing for size. This should probably be lowered after
+// performance testing.
 // FIXME: this comment is cargo culted from the old pass manager, revisit).
-IP.HintThreshold = 325;
+IP.HintThreshold = Level.isOptimizingForSize() ? PreInlineThreshold : 325;
 ModuleInlinerWrapperPass MIWP(IP, DebugLogging);
 CGSCCPassManager &CGPipeline = MIWP.getPM();
 

diff  --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp 
b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
index e823a56073a4..574527763a9c 100644
--- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -330,19 +330,21 @@ void 
PassManagerBuilder::addPGOInstrPasses(legacy::PassManagerBase &MPM,
 return;
 
   // Perform the preinline and cleanup passes for O1 and above.
-  // And avoid doing them if optimizing for size.
   // We will not do this inline for context sensitive PGO (when IsCS is true).
-  if (OptLevel > 0 && SizeLevel == 0 && !DisablePreInliner &&
-  PGOSampleUse.empty() && !IsCS) {
+  if (OptLevel > 0 && !DisablePreInliner && PGOSampleUse.empty() && !IsCS) {
 // Create preinline pass. We construct an InlineParams object and specify
 // the threshold here to avoid the command line options of the regular
 // inliner to influence pre-inlining. The only fields of InlineParams we
 // care about are DefaultThreshold and HintThreshold.
 InlineParams IP;
 IP.DefaultThreshold = PreInlineThreshold;
-// FIXME: The hint threshold has the same value used by the regular 
inliner.
-// This should probably be lowered after performance testing.
-IP.HintThreshold = 325;
+// FIXME: The hint threshold has the same value used by the regular inliner
+// when not optimzing for size. This should probably be lowered after
+// performance testing.
+// Use PreInlineThreshold for both -Os and -Oz. Not running preinliner 
makes
+// the instrumented binary unusably large. Even if PreInlineThreshold is 
not
+// correct thresold for -Oz, it is better than not running preinliner.
+IP.HintThreshold = SizeLevel > 0 ? PreInlineThreshold : 325;
 
 MPM.add(createFunctionInliningPass(IP));
 MPM.add(createSROAPass());

diff  --git a/llvm/test/Other/new-pm-pgo-preinline.ll 
b/llvm/test/Other/new-pm-pgo-preinline.ll
new file mode 100644
index ..d6b1f26fa21f
--- /dev/null
+++ b/llvm/test/Other/new-pm-pgo-preinline.ll
@@ -0,0 +1,24 @@
+; RUN: opt -disable-verify -debug-pass-manager 
-pgo-kind=pgo-instr-gen-pipeline -passes='default' -S %s 2>&1 | FileCheck 
%s --check-prefixes=CHECK-Osz
+; RUN: opt -disable-verify -debug-pass-manager 
-pgo-kind=pgo-instr-gen-pipeline -passes='default' -S %s 2>&1 | FileCheck 
%s --check-prefixes=CHECK-Osz
+
+; CHECK-Osz: Running pass: ModuleInlinerWrapperPass
+; CHECK-Osz-NEXT: Running analysis: InlineAdvisorAnalysis
+; CHECK-Osz-NEXT: Starting {{.*}}Module pass manager run.
+; CHECK-Osz-NEXT: Running analysis:

[llvm-branch-commits] [mlir] 1f5f006 - [mlir][StandardOps] Verify that the result of an integer constant is signless

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T12:40:10-08:00
New Revision: 1f5f006d9d53e785296d1a8fbb0e90904a5eaf60

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

LOG: [mlir][StandardOps] Verify that the result of an integer constant is 
signless

This was missed when supported for unsigned/signed integer types was first 
added, and results in crashes if a user tries to create/print a constant with 
the incorrect integer type.

Fixes PR#46222

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

Added: 


Modified: 
mlir/lib/Dialect/StandardOps/IR/Ops.cpp
mlir/test/Dialect/Standard/invalid.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp 
b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
index 34c3da9b5eca..0efba0d9d4d8 100644
--- a/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
+++ b/mlir/lib/Dialect/StandardOps/IR/Ops.cpp
@@ -1136,7 +1136,7 @@ static LogicalResult verify(ConstantOp &op) {
   if (!value)
 return op.emitOpError("requires a 'value' attribute");
 
-  auto type = op.getType();
+  Type type = op.getType();
   if (!value.getType().isa() && type != value.getType())
 return op.emitOpError() << "requires attribute's type (" << value.getType()
 << ") to match op's return type (" << type << ")";
@@ -1145,10 +1145,14 @@ static LogicalResult verify(ConstantOp &op) {
 return success();
 
   if (auto intAttr = value.dyn_cast()) {
+IntegerType intType = type.cast();
+if (!intType.isSignless())
+  return op.emitOpError("requires integer result types to be signless");
+
 // If the type has a known bitwidth we verify that the value can be
 // represented with the given bitwidth.
-auto bitwidth = type.cast().getWidth();
-auto intVal = intAttr.getValue();
+unsigned bitwidth = intType.getWidth();
+APInt intVal = intAttr.getValue();
 if (!intVal.isSignedIntN(bitwidth) && !intVal.isIntN(bitwidth))
   return op.emitOpError("requires 'value' to be an integer within the "
 "range of the integer result type");
@@ -1228,9 +1232,13 @@ bool ConstantOp::isBuildableWith(Attribute value, Type 
type) {
   // SymbolRefAttr can only be used with a function type.
   if (value.isa())
 return type.isa();
-  // Otherwise, the attribute must have the same type as 'type'.
+  // The attribute must have the same type as 'type'.
   if (value.getType() != type)
 return false;
+  // If the type is an integer type, it must be signless.
+  if (IntegerType integerTy = type.dyn_cast())
+if (!integerTy.isSignless())
+  return false;
   // Finally, check that the attribute kind is handled.
   return value.isa();
 }

diff  --git a/mlir/test/Dialect/Standard/invalid.mlir 
b/mlir/test/Dialect/Standard/invalid.mlir
index 04ecdc64351a..48d2ae23466c 100644
--- a/mlir/test/Dialect/Standard/invalid.mlir
+++ b/mlir/test/Dialect/Standard/invalid.mlir
@@ -298,3 +298,18 @@ func @mismatched_types() {
   return
 }
 
+// -
+
+func @non_signless_constant() {
+  // expected-error @+1 {{requires integer result types to be signless}}
+  %0 = constant 0 : ui32
+  return
+}
+
+// -
+
+func @non_signless_constant() {
+  // expected-error @+1 {{requires integer result types to be signless}}
+  %0 = constant 0 : si32
+  return
+}



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


[llvm-branch-commits] [compiler-rt] 61a038f - [GWP-ASan] IWYU & clang-format

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T12:42:01-08:00
New Revision: 61a038f8528f12c0c2ee5a9794c257fdae626d29

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

LOG: [GWP-ASan] IWYU & clang-format

Run an IWYU pass and clang-format GWP-ASan code.

Reviewed By: eugenis, mcgrathr

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

Added: 


Modified: 
compiler-rt/lib/gwp_asan/crash_handler.cpp
compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
compiler-rt/lib/gwp_asan/mutex.h
compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
compiler-rt/lib/gwp_asan/platform_specific/utilities_posix.cpp

Removed: 




diff  --git a/compiler-rt/lib/gwp_asan/crash_handler.cpp 
b/compiler-rt/lib/gwp_asan/crash_handler.cpp
index b9baacecfecb..bd7ca5abbb6b 100644
--- a/compiler-rt/lib/gwp_asan/crash_handler.cpp
+++ b/compiler-rt/lib/gwp_asan/crash_handler.cpp
@@ -10,6 +10,7 @@
 #include "gwp_asan/stack_trace_compressor.h"
 
 #include 
+#include 
 #include 
 
 using AllocationMetadata = gwp_asan::AllocationMetadata;

diff  --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp 
b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
index 13888cbbe3c3..a1dbbe4f25e9 100644
--- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
+++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.cpp
@@ -8,23 +8,10 @@
 
 #include "gwp_asan/guarded_pool_allocator.h"
 
-#include "gwp_asan/optional/segv_handler.h"
 #include "gwp_asan/options.h"
 #include "gwp_asan/utilities.h"
 
-// RHEL creates the PRIu64 format macro (for printing uint64_t's) only when 
this
-// macro is defined before including .
-#ifndef __STDC_FORMAT_MACROS
-#define __STDC_FORMAT_MACROS 1
-#endif
-
 #include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
 
 using AllocationMetadata = gwp_asan::AllocationMetadata;
 using Error = gwp_asan::Error;

diff  --git a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h 
b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
index 84ebda13955f..b9972ffd98f7 100644
--- a/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
+++ b/compiler-rt/lib/gwp_asan/guarded_pool_allocator.h
@@ -13,10 +13,9 @@
 #include "gwp_asan/definitions.h"
 #include "gwp_asan/mutex.h"
 #include "gwp_asan/options.h"
-#include "gwp_asan/platform_specific/guarded_pool_allocator_fuchsia.h"
-#include "gwp_asan/platform_specific/guarded_pool_allocator_posix.h"
+#include "gwp_asan/platform_specific/guarded_pool_allocator_fuchsia.h" // IWYU 
pragma: keep
+#include "gwp_asan/platform_specific/guarded_pool_allocator_posix.h" // IWYU 
pragma: keep
 #include "gwp_asan/platform_specific/guarded_pool_allocator_tls.h"
-#include "gwp_asan/stack_trace_compressor.h"
 
 #include 
 #include 

diff  --git a/compiler-rt/lib/gwp_asan/mutex.h 
b/compiler-rt/lib/gwp_asan/mutex.h
index a7214f527b29..34b91a2880dd 100644
--- a/compiler-rt/lib/gwp_asan/mutex.h
+++ b/compiler-rt/lib/gwp_asan/mutex.h
@@ -9,8 +9,8 @@
 #ifndef GWP_ASAN_MUTEX_H_
 #define GWP_ASAN_MUTEX_H_
 
-#include "gwp_asan/platform_specific/mutex_fuchsia.h"
-#include "gwp_asan/platform_specific/mutex_posix.h"
+#include "gwp_asan/platform_specific/mutex_fuchsia.h" // IWYU pragma: keep
+#include "gwp_asan/platform_specific/mutex_posix.h"   // IWYU pragma: keep
 
 namespace gwp_asan {
 class Mutex final : PlatformMutex {

diff  --git a/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp 
b/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
index 813882ad915a..0637fc2a4245 100644
--- a/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
+++ b/compiler-rt/lib/gwp_asan/platform_specific/common_posix.cpp
@@ -8,7 +8,9 @@
 
 #include "gwp_asan/common.h"
 
-#include 
+#include 
+#include  // IWYU pragma: keep
+// IWYU pragma: no_include 
 #include 
 
 namespace gwp_asan {

diff  --git 
a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp 
b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
index dad749bde8be..adb7330a431e 100644
--- 
a/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
+++ 
b/compiler-rt/lib/gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp
@@ -6,16 +6,16 @@
 //
 
//===--===//
 
+#include "gwp_asan/common.h"
 #include "gwp_asan/guarded_pool_allocator.h"
+#include "gwp_asan/platform_specific/guarded_pool_allocator_tls.h"
 #include "gwp_asan/utilities.h"
 
 #include 
-#include 
-#include 
+#include 
+#include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 

diff  --git a/compiler-rt/lib/gwp_asan/platform_specific/utilit

[llvm-branch-commits] [mlir] 75eca67 - [mlir][Parser] Fix crash in DenseElementsAttr parser when no elements are parsed

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T12:48:37-08:00
New Revision: 75eca67c1c4b53a07a70cd3c8036713aec537769

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

LOG: [mlir][Parser] Fix crash in DenseElementsAttr parser when no elements are 
parsed

This fixes a crash when no elements are parsed, but the type expects at least 
one.

Fixes PR#47763

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

Added: 


Modified: 
mlir/lib/Parser/AttributeParser.cpp
mlir/test/IR/invalid.mlir

Removed: 




diff  --git a/mlir/lib/Parser/AttributeParser.cpp 
b/mlir/lib/Parser/AttributeParser.cpp
index 2e385cfa30e7..e78237e8e5a0 100644
--- a/mlir/lib/Parser/AttributeParser.cpp
+++ b/mlir/lib/Parser/AttributeParser.cpp
@@ -531,6 +531,13 @@ DenseElementsAttr TensorLiteralParser::getAttr(llvm::SMLoc 
loc,
 return nullptr;
   }
 
+  // Handle the case where no elements were parsed.
+  if (!hexStorage.hasValue() && storage.empty() && type.getNumElements()) {
+p.emitError(loc) << "parsed zero elements, but type (" << type
+ << ") expected at least 1";
+return nullptr;
+  }
+
   // Handle complex types in the specific element type cases below.
   bool isComplex = false;
   if (ComplexType complexTy = eltType.dyn_cast()) {

diff  --git a/mlir/test/IR/invalid.mlir b/mlir/test/IR/invalid.mlir
index 4930341a8b64..6b28b33e7c78 100644
--- a/mlir/test/IR/invalid.mlir
+++ b/mlir/test/IR/invalid.mlir
@@ -687,6 +687,11 @@ func @elementsattr_toolarge1() -> () {
 
 // -
 
+// expected-error@+1 {{parsed zero elements, but type ('tensor') expected 
at least 1}}
+#attr = dense<> : tensor
+
+// -
+
 func @elementsattr_toolarge2() -> () {
 ^bb0:
   "foo"(){bar = dense<[-777]> : tensor<1xi8>} : () -> () // expected-error 
{{integer constant out of range}}



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


[llvm-branch-commits] [mlir] 285c0aa - Add MLIR Python binding for Array Attribute

2020-12-10 Thread Mehdi Amini via llvm-branch-commits

Author: Mehdi Amini
Date: 2020-12-10T20:51:34Z
New Revision: 285c0aa262c9255e6ea4efbce1418e5f5f17e9c1

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

LOG: Add MLIR Python binding for Array Attribute

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

Added: 


Modified: 
mlir/lib/Bindings/Python/IRModules.cpp
mlir/test/Bindings/Python/ir_attributes.py

Removed: 




diff  --git a/mlir/lib/Bindings/Python/IRModules.cpp 
b/mlir/lib/Bindings/Python/IRModules.cpp
index 5519c66ee1ab..5ebb2e4ccee3 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -1461,6 +1461,83 @@ class PyConcreteAttribute : public BaseTy {
   static void bindDerived(ClassTy &m) {}
 };
 
+class PyArrayAttribute : public PyConcreteAttribute {
+public:
+  static constexpr IsAFunctionTy isaFunction = mlirAttributeIsAArray;
+  static constexpr const char *pyClassName = "ArrayAttr";
+  using PyConcreteAttribute::PyConcreteAttribute;
+
+  class PyArrayAttributeIterator {
+  public:
+PyArrayAttributeIterator(PyAttribute attr) : attr(attr) {}
+
+PyArrayAttributeIterator &dunderIter() { return *this; }
+
+PyAttribute dunderNext() {
+  if (nextIndex >= mlirArrayAttrGetNumElements(attr.get())) {
+throw py::stop_iteration();
+  }
+  return PyAttribute(attr.getContext(),
+ mlirArrayAttrGetElement(attr.get(), nextIndex++));
+}
+
+static void bind(py::module &m) {
+  py::class_(m, "ArrayAttributeIterator")
+  .def("__iter__", &PyArrayAttributeIterator::dunderIter)
+  .def("__next__", &PyArrayAttributeIterator::dunderNext);
+}
+
+  private:
+PyAttribute attr;
+int nextIndex = 0;
+  };
+
+  static void bindDerived(ClassTy &c) {
+c.def_static(
+"get",
+[](py::list attributes, DefaultingPyMlirContext context) {
+  SmallVector mlirAttributes;
+  mlirAttributes.reserve(py::len(attributes));
+  for (auto attribute : attributes) {
+try {
+  mlirAttributes.push_back(attribute.cast());
+} catch (py::cast_error &err) {
+  std::string msg = std::string("Invalid attribute when attempting 
"
+"to create an ArrayAttribute (") +
+err.what() + ")";
+  throw py::cast_error(msg);
+} catch (py::reference_cast_error &err) {
+  // This exception seems thrown when the value is "None".
+  std::string msg =
+  std::string("Invalid attribute (None?) when attempting to "
+  "create an ArrayAttribute (") +
+  err.what() + ")";
+  throw py::cast_error(msg);
+}
+  }
+  MlirAttribute attr = mlirArrayAttrGet(
+  context->get(), mlirAttributes.size(), mlirAttributes.data());
+  return PyArrayAttribute(context->getRef(), attr);
+},
+py::arg("attributes"), py::arg("context") = py::none(),
+"Gets a uniqued Array attribute");
+c.def("__getitem__",
+  [](PyArrayAttribute &arr, intptr_t i) {
+if (i >= mlirArrayAttrGetNumElements(arr))
+  throw py::index_error("ArrayAttribute index out of range");
+return PyAttribute(arr.getContext(),
+   mlirArrayAttrGetElement(arr, i));
+  })
+.def("__len__",
+ [](const PyArrayAttribute &arr) {
+   return mlirArrayAttrGetNumElements(arr);
+ })
+.def("__iter__", [](const PyArrayAttribute &arr) {
+  return PyArrayAttributeIterator(arr);
+});
+  }
+};
+
 /// Float Point Attribute subclass - FloatAttr.
 class PyFloatAttribute : public PyConcreteAttribute {
 public:
@@ -3089,6 +3166,8 @@ void mlir::python::populateIRSubmodule(py::module &m) {
 
   // Builtin attribute bindings.
   PyFloatAttribute::bind(m);
+  PyArrayAttribute::bind(m);
+  PyArrayAttribute::PyArrayAttributeIterator::bind(m);
   PyIntegerAttribute::bind(m);
   PyBoolAttribute::bind(m);
   PyStringAttribute::bind(m);

diff  --git a/mlir/test/Bindings/Python/ir_attributes.py 
b/mlir/test/Bindings/Python/ir_attributes.py
index 4ad180bb1b37..642c1f6a836c 100644
--- a/mlir/test/Bindings/Python/ir_attributes.py
+++ b/mlir/test/Bindings/Python/ir_attributes.py
@@ -269,3 +269,54 @@ def testTypeAttr():
 
 
 run(testTypeAttr)
+
+
+# CHECK-LABEL: TEST: testArrayAttr
+def testArrayAttr():
+  with Context():
+raw = Attribute.parse("[42, true, vector<4xf32>]")
+  # CHECK: attr: [42, true, vector<4xf32>]
+  print("raw attr:", raw)
+  # CHECK: - 42
+  # CHECK: - true
+  # CHECK: - vector<4xf32>
+  for attr in ArrayAttr(raw):
+  

[llvm-branch-commits] [mlir] c24f88b - [mlir][SCCP] Don't visit private callables unless they are used when tracking interprocedural arguments/results

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T12:53:27-08:00
New Revision: c24f88b4db2ef359f47e976d8d79334ced221288

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

LOG: [mlir][SCCP] Don't visit private callables unless they are used when 
tracking interprocedural arguments/results

This fixes a subtle bug where SCCP could incorrectly optimize a private 
callable while waiting for its arguments to be resolved.

Fixes PR#48457

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

Added: 


Modified: 
mlir/lib/Transforms/SCCP.cpp
mlir/test/Transforms/sccp-callgraph.mlir

Removed: 




diff  --git a/mlir/lib/Transforms/SCCP.cpp b/mlir/lib/Transforms/SCCP.cpp
index 919559c8a6df..9886331820e3 100644
--- a/mlir/lib/Transforms/SCCP.cpp
+++ b/mlir/lib/Transforms/SCCP.cpp
@@ -236,6 +236,11 @@ class SCCPSolver {
   /// state.
   void visitBlockArgument(Block *block, int i);
 
+  /// Mark the entry block of the given region as executable. Returns false if
+  /// the block was already marked executable. If `markArgsOverdefined` is 
true,
+  /// the arguments of the entry block are also set to overdefined.
+  bool markEntryBlockExecutable(Region *region, bool markArgsOverdefined);
+
   /// Mark the given block as executable. Returns false if the block was 
already
   /// marked executable.
   bool markBlockExecutable(Block *block);
@@ -313,16 +318,9 @@ class SCCPSolver {
 SCCPSolver::SCCPSolver(Operation *op) {
   /// Initialize the solver with the regions within this operation.
   for (Region ®ion : op->getRegions()) {
-if (region.empty())
-  continue;
-Block *entryBlock = ®ion.front();
-
-// Mark the entry block as executable.
-markBlockExecutable(entryBlock);
-
-// The values passed to these regions are invisible, so mark any arguments
-// as overdefined.
-markAllOverdefined(entryBlock->getArguments());
+// Mark the entry block as executable. The values passed to these regions
+// are also invisible, so mark any arguments as overdefined.
+markEntryBlockExecutable(®ion, /*markArgsOverdefined=*/true);
   }
   initializeSymbolCallables(op);
 }
@@ -405,8 +403,10 @@ void SCCPSolver::initializeSymbolCallables(Operation *op) {
 
   // If not all of the uses of this symbol are visible, we can't track the
   // state of the arguments.
-  if (symbol.isPublic() || (!allUsesVisible && symbol.isNested()))
-markAllOverdefined(callableRegion->getArguments());
+  if (symbol.isPublic() || (!allUsesVisible && symbol.isNested())) {
+for (Region ®ion : callable->getRegions())
+  markEntryBlockExecutable(®ion, /*markArgsOverdefined=*/true);
+  }
 }
 if (callableLatticeState.empty())
   return;
@@ -443,8 +443,10 @@ void SCCPSolver::initializeSymbolCallables(Operation *op) {
   // This use isn't a call, so don't we know all of the callers.
   auto *symbol = symbolTable.lookupSymbolIn(op, use.getSymbolRef());
   auto it = callableLatticeState.find(symbol);
-  if (it != callableLatticeState.end())
-markAllOverdefined(it->second.getCallableArguments());
+  if (it != callableLatticeState.end()) {
+for (Region ®ion : it->first->getRegions())
+  markEntryBlockExecutable(®ion, /*markArgsOverdefined=*/true);
+  }
 }
   };
   SymbolTable::walkSymbolTables(op, /*allSymUsesVisible=*/!op->getBlock(),
@@ -495,8 +497,14 @@ void SCCPSolver::visitOperation(Operation *op) {
 
   // Process callable operations. These are specially handled region operations
   // that track dataflow via calls.
-  if (isa(op))
+  if (isa(op)) {
+// If this callable has a tracked lattice state, it will be visited by 
calls
+// that reference it instead. This way, we don't assume that it is
+// executable unless there is a proper reference to it.
+if (callableLatticeState.count(op))
+  return;
 return visitCallableOperation(op);
+  }
 
   // Process region holding operations. The region visitor processes result
   // values, so we can exit afterwards.
@@ -551,19 +559,11 @@ void SCCPSolver::visitOperation(Operation *op) {
 }
 
 void SCCPSolver::visitCallableOperation(Operation *op) {
-  // Mark the regions as executable.
+  // Mark the regions as executable. If we aren't tracking lattice state for
+  // this callable, mark all of the region arguments as overdefined.
   bool isTrackingLatticeState = callableLatticeState.count(op);
-  for (Region ®ion : op->getRegions()) {
-if (region.empty())
-  continue;
-Block *entryBlock = ®ion.front();
-markBlockExecutable(entryBlock);
-
-// If we aren't tracking lattice state for this callable, mark all of the
-// region arguments as overdefined.
-if (!isTrackingLatticeState)
-  markAllOverdefined(entryBlock

[llvm-branch-commits] [llvm] ea475c7 - [SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing.

2020-12-10 Thread Jonas Paulsson via llvm-branch-commits

Author: Jonas Paulsson
Date: 2020-12-10T15:06:18-06:00
New Revision: ea475c77ff9eab1de7d44684c8fb453b39f70081

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

LOG: [SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing.

The loop-based probing done for stack clash protection altered R1D which
corrupted the backchain value to be stored after the probing was done.

By using R0D instead for the loop exit value, R1D is not modified.

Review: Ulrich Weigand.

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

Added: 


Modified: 
llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
llvm/test/CodeGen/SystemZ/stack-clash-dynamic-alloca.ll
llvm/test/CodeGen/SystemZ/stack-clash-protection.ll

Removed: 




diff  --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp 
b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
index 57529c8685de..0bfab129edb1 100644
--- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp
@@ -488,15 +488,6 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
&MF,
   MFFrame.setStackSize(StackSize);
 
   if (StackSize) {
-// Determine if we want to store a backchain.
-bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
-
-// If we need backchain, save current stack pointer.  R1 is free at this
-// point.
-if (StoreBackchain)
-  BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR))
-.addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
-
 // Allocate StackSize bytes.
 int64_t Delta = -int64_t(StackSize);
 const unsigned ProbeSize = TLI.getStackProbeSize(MF);
@@ -512,18 +503,23 @@ void SystemZFrameLowering::emitPrologue(MachineFunction 
&MF,
 .addImm(StackSize);
 }
 else {
+  bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
+  // If we need backchain, save current stack pointer.  R1 is free at
+  // this point.
+  if (StoreBackchain)
+BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR))
+  .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
   emitIncrement(MBB, MBBI, DL, SystemZ::R15D, Delta, ZII);
   buildCFAOffs(MBB, MBBI, DL, SPOffsetFromCFA + Delta, ZII);
+  if (StoreBackchain) {
+// The back chain is stored topmost with packed-stack.
+int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
+BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
+  .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
+  .addImm(Offset).addReg(0);
+  }
 }
 SPOffsetFromCFA += Delta;
-
-if (StoreBackchain) {
-  // The back chain is stored topmost with packed-stack.
-  int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0;
-  BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG))
-.addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D)
-.addImm(Offset).addReg(0);
-}
   }
 
   if (HasFP) {
@@ -668,6 +664,11 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction &MF,
   .addMemOperand(MMO);
   };
 
+  bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain");
+  if (StoreBackchain)
+BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR))
+  .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D);
+
   if (NumFullBlocks < 3) {
 // Emit unrolled probe statements.
 for (unsigned int i = 0; i < NumFullBlocks; i++)
@@ -677,10 +678,11 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction &MF,
 uint64_t LoopAlloc = ProbeSize * NumFullBlocks;
 SPOffsetFromCFA -= LoopAlloc;
 
-BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R1D)
+// Use R0D to hold the exit value.
+BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R0D)
   .addReg(SystemZ::R15D);
-buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R1D, ZII);
-emitIncrement(*MBB, MBBI, DL, SystemZ::R1D, -int64_t(LoopAlloc), ZII);
+buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R0D, ZII);
+emitIncrement(*MBB, MBBI, DL, SystemZ::R0D, -int64_t(LoopAlloc), ZII);
 buildCFAOffs(*MBB, MBBI, DL, -int64_t(SystemZMC::CallFrameSize + 
LoopAlloc),
  ZII);
 
@@ -693,7 +695,7 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction 
&MF,
 MBB = LoopMBB;
 allocateAndProbe(*MBB, MBB->end(), ProbeSize, false/*EmitCFI*/);
 BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::CLGR))
-  .addReg(SystemZ::R15D).addReg(SystemZ::R1D);
+  .addReg(SystemZ::R15D).addReg(SystemZ::R0D);
 BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::BRC))
   .addImm(SystemZ::CCMASK_ICMP).addImm(SystemZ::CCMASK_CMP_GT).addMBB(MBB);
 
@@ -708,6 +710,14 @@ void 
SystemZFrameLowering::inlineStackProbe(MachineFunction &MF,
   if

[llvm-branch-commits] [llvm] c923518 - [gn build] add a missing dependency

2020-12-10 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-10T16:22:26-05:00
New Revision: c9235180d1f3f8a42459e83de7e273c60a41dce1

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

LOG: [gn build] add a missing dependency

Added: 


Modified: 
llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn

Removed: 




diff  --git 
a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn 
b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
index 3936f2b9dec6..34ba224fa7e0 100644
--- a/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
+++ b/llvm/utils/gn/secondary/clang-tools-extra/clangd/unittests/BUILD.gn
@@ -27,6 +27,7 @@ unittest("ClangdTests") {
 "//clang/lib/Tooling/Core",
 "//clang/lib/Tooling/Inclusions",
 "//clang/lib/Tooling/Syntax",
+"//llvm/include/llvm/Config:llvm-config",
 "//llvm/lib/Support",
 "//llvm/lib/Testing/Support",
   ]



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


[llvm-branch-commits] [llvm] 0e72f19 - [gn build] only build iOS builtins with full Xcode

2020-12-10 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-10T16:22:31-05:00
New Revision: 0e72f1978d64dff1094f9da024d7f45fd3f984f8

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

LOG: [gn build] only build iOS builtins with full Xcode

Commandline tools doesn't include the iOS SDK.

Added: 


Modified: 
llvm/utils/gn/secondary/compiler-rt/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn 
b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
index 5444f6621350..af23e330b6ef 100644
--- a/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/BUILD.gn
@@ -1,4 +1,5 @@
 import("//llvm/lib/Target/targets.gni")
+import("//llvm/utils/gn/build/mac_sdk.gni")
 import("//llvm/utils/gn/build/toolchain/compiler.gni")
 
 # In the GN build, compiler-rt is always built by just-built clang and lld.
@@ -19,7 +20,8 @@ group("compiler-rt") {
 
   # FIXME: Do this only if a gn arg compiler_rt_enable_ios is set?
   # That would match the cmake build.
-  if (host_os == "mac") {
+  # iOS SDKs aren't available in the commandline tools SDK.
+  if (host_os == "mac" && !mac_use_commandline_tools_sdk) {
 if (llvm_build_AArch64) {
   deps += [ 
"//compiler-rt/lib/builtins(//llvm/utils/gn/build/toolchain:stage2_ios_aarch64)"
 ]
 }



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


[llvm-branch-commits] [llvm] e19d525 - [gn build] fix up arm64 builtin sources a bit

2020-12-10 Thread Nico Weber via llvm-branch-commits

Author: Nico Weber
Date: 2020-12-10T16:22:48-05:00
New Revision: e19d5258461ce7838e4be6973ba519d250c000f1

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

LOG: [gn build] fix up arm64 builtin sources a bit

The fp_mode.c removal is done by filter_builtin_sources in the cmake build.

Added: 


Modified: 
llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn

Removed: 




diff  --git a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn 
b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
index e7b532f57dab..4f0738292b2c 100644
--- a/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
+++ b/llvm/utils/gn/secondary/compiler-rt/lib/builtins/BUILD.gn
@@ -427,7 +427,11 @@ static_library("builtins") {
   }
 
   if (current_cpu == "arm64") {
-sources += [ "aarch64/fp_mode.c" ]
+sources -= [ "fp_mode.c" ]
+sources += [
+  "cpu_model.c",
+  "aarch64/fp_mode.c",
+]
 if (current_os == "mingw") {
   sources += [ "aarch64/chkstk.S" ]
 }



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


[llvm-branch-commits] [llvm] e2006ed - [RISCV] Simplify vector instruction handling in RISCVMCInstLower.cpp.

2020-12-10 Thread Craig Topper via llvm-branch-commits

Author: Craig Topper
Date: 2020-12-10T13:40:00-08:00
New Revision: e2006ed0f73e3d7c1545c506f26c330bcc59f60e

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

LOG: [RISCV] Simplify vector instruction handling in RISCVMCInstLower.cpp.

Use RegisterClass::contains instead of going through getMinimalPhysRegClass
and hasSuperClassEq.

Remove the special case for NoRegister. It's identical to the
handling for any other regsiter that isn't VRM2/M4/M8.

Added: 


Modified: 
llvm/lib/Target/RISCV/RISCVMCInstLower.cpp

Removed: 




diff  --git a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp 
b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
index da0725623b45..876d557ec79d 100644
--- a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
+++ b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp
@@ -160,17 +160,9 @@ static bool lowerRISCVVMachineInstrToMCInst(const 
MachineInstr *MI,
 case MachineOperand::MO_Register: {
   unsigned Reg = MO.getReg();
 
-  // Nothing to do on NoRegister operands (used as vector mask operand on
-  // unmasked instructions)
-  if (Reg == RISCV::NoRegister) {
-MCOp = MCOperand::createReg(Reg);
-break;
-  }
-
-  const TargetRegisterClass *RC = TRI->getMinimalPhysRegClass(Reg);
-  if (RC->hasSuperClassEq(&RISCV::VRM2RegClass) ||
-  RC->hasSuperClassEq(&RISCV::VRM4RegClass) ||
-  RC->hasSuperClassEq(&RISCV::VRM8RegClass)) {
+  if (RISCV::VRM2RegClass.contains(Reg) ||
+  RISCV::VRM4RegClass.contains(Reg) ||
+  RISCV::VRM8RegClass.contains(Reg)) {
 Reg = TRI->getSubReg(Reg, RISCV::sub_vrm2);
 assert(Reg && "Subregister does not exist");
   }



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


[llvm-branch-commits] [compiler-rt] 0099316 - [DFSan] Add custom wrapper for pthread_join.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T13:41:24-08:00
New Revision: 009931644a9d2cecdc6e5bf71ed83d59b776eaa3

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

LOG: [DFSan] Add custom wrapper for pthread_join.

The wrapper clears shadow for retval.

Reviewed By: stephan.yichao.zhao

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

Added: 


Modified: 
compiler-rt/lib/dfsan/dfsan_custom.cpp
compiler-rt/lib/dfsan/done_abilist.txt
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/lib/dfsan/dfsan_custom.cpp 
b/compiler-rt/lib/dfsan/dfsan_custom.cpp
index 259bec4207dd..0da66c7a440d 100644
--- a/compiler-rt/lib/dfsan/dfsan_custom.cpp
+++ b/compiler-rt/lib/dfsan/dfsan_custom.cpp
@@ -427,6 +427,18 @@ SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_pthread_create(
   return rv;
 }
 
+SANITIZER_INTERFACE_ATTRIBUTE int __dfsw_pthread_join(pthread_t thread,
+  void **retval,
+  dfsan_label thread_label,
+  dfsan_label retval_label,
+  dfsan_label *ret_label) {
+  int ret = pthread_join(thread, retval);
+  if (ret == 0 && retval)
+dfsan_set_label(0, retval, sizeof(*retval));
+  *ret_label = 0;
+  return ret;
+}
+
 struct dl_iterate_phdr_info {
   int (*callback_trampoline)(void *callback, struct dl_phdr_info *info,
  size_t size, void *data, dfsan_label info_label,

diff  --git a/compiler-rt/lib/dfsan/done_abilist.txt 
b/compiler-rt/lib/dfsan/done_abilist.txt
index 5d3d31f2e162..513c9ea13de3 100644
--- a/compiler-rt/lib/dfsan/done_abilist.txt
+++ b/compiler-rt/lib/dfsan/done_abilist.txt
@@ -319,6 +319,10 @@ fun:pthread_setspecific=discard
 # Functions that take a callback (wrap the callback manually).
 fun:pthread_create=custom
 
+# Functions that produce output does not depend on the input (need to zero the
+# shadow manually).
+fun:pthread_join=custom
+
 ###
 # libffi/libgo
 ###

diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index 14cddd8e2a3c..e21f35426cf0 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -792,8 +792,12 @@ void test_pthread_create() {
   pthread_t pt;
   pthread_create(&pt, 0, pthread_create_test_cb, (void *)1);
   void *cbrv;
-  pthread_join(pt, &cbrv);
+  dfsan_set_label(i_label, &cbrv, sizeof(cbrv));
+  int ret = pthread_join(pt, &cbrv);
+  assert(ret == 0);
   assert(cbrv == (void *)2);
+  ASSERT_ZERO_LABEL(ret);
+  ASSERT_ZERO_LABEL(cbrv);
 }
 
 int dl_iterate_phdr_test_cb(struct dl_phdr_info *info, size_t size,



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


[llvm-branch-commits] [libcxx] 092e8a7 - [libc++] NFCI: Refactor __shared_ptr_emplace

2020-12-10 Thread Louis Dionne via llvm-branch-commits

Author: Louis Dionne
Date: 2020-12-10T16:45:58-05:00
New Revision: 092e8a7ea3652c418400275746c1800d31390008

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

LOG: [libc++] NFCI: Refactor __shared_ptr_emplace

This is the first of a series of patches leading up to the implementation
of P0674r1, i.e. array support in allocate_shared. I am splitting this
up into multiple patches because the overall change is very tricky and
I want to isolate potential breakage.

Added: 


Modified: 
libcxx/include/memory

Removed: 




diff  --git a/libcxx/include/memory b/libcxx/include/memory
index 77d7b67112e32..f3b890ad2b3e9 100644
--- a/libcxx/include/memory
+++ b/libcxx/include/memory
@@ -3305,57 +3305,47 @@ __shared_ptr_pointer<_Tp, _Dp, 
_Alloc>::__on_zero_shared_weak() _NOEXCEPT
 }
 
 template 
-class __shared_ptr_emplace
-: public __shared_weak_count
+struct __shared_ptr_emplace
+: __shared_weak_count
 {
-__compressed_pair<_Alloc, _Tp> __data_;
-public:
-
-_LIBCPP_INLINE_VISIBILITY
-__shared_ptr_emplace(_Alloc __a)
-:  __data_(_VSTD::move(__a), __value_init_tag()) {}
+_LIBCPP_HIDE_FROM_ABI
+explicit __shared_ptr_emplace(_Alloc __a)
+:  __data_(_VSTD::move(__a), __value_init_tag())
+{ }
 
-#ifndef _LIBCPP_CXX03_LANG
 template 
-_LIBCPP_INLINE_VISIBILITY
-__shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
-:  __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
-   _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)) 
{}
+_LIBCPP_HIDE_FROM_ABI
+explicit __shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
+#ifndef _LIBCPP_CXX03_LANG
+: __data_(piecewise_construct, _VSTD::forward_as_tuple(__a),
+  _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))
 #else
-template 
-_LIBCPP_INLINE_VISIBILITY
-__shared_ptr_emplace(_Alloc __a, _Args&& ...__args)
-:  __data_(__a, _Tp(_VSTD::forward<_Args>(__args)...)) {}
+: __data_(__a, _Tp(_VSTD::forward<_Args>(__args)...))
 #endif
+{ }
+
+_LIBCPP_HIDE_FROM_ABI
+_Tp* __get_elem() _NOEXCEPT { return _VSTD::addressof(__data_.second()); }
+
+_LIBCPP_HIDE_FROM_ABI
+_Alloc& __get_alloc() _NOEXCEPT { return __data_.first(); }
 
 private:
-virtual void __on_zero_shared() _NOEXCEPT;
-virtual void __on_zero_shared_weak() _NOEXCEPT;
-public:
-_LIBCPP_INLINE_VISIBILITY
-_Alloc& __get_alloc() _NOEXCEPT {return __data_.first();}
-_LIBCPP_INLINE_VISIBILITY
-_Tp* __get_elem() _NOEXCEPT {return _VSTD::addressof(__data_.second());}
-};
+virtual void __on_zero_shared() _NOEXCEPT {
+__get_elem()->~_Tp();
+}
 
-template 
-void
-__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared() _NOEXCEPT
-{
-__get_elem()->~_Tp();
-}
+virtual void __on_zero_shared_weak() _NOEXCEPT {
+using _ControlBlockAlloc = typename __allocator_traits_rebind<_Alloc, 
__shared_ptr_emplace>::type;
+using _ControlBlockPointer = typename 
allocator_traits<_ControlBlockAlloc>::pointer;
+_ControlBlockAlloc __tmp(__get_alloc());
+__get_alloc().~_Alloc();
+allocator_traits<_ControlBlockAlloc>::deallocate(__tmp,
+pointer_traits<_ControlBlockPointer>::pointer_to(*this), 1);
+}
 
-template 
-void
-__shared_ptr_emplace<_Tp, _Alloc>::__on_zero_shared_weak() _NOEXCEPT
-{
-typedef typename __allocator_traits_rebind<_Alloc, 
__shared_ptr_emplace>::type _Al;
-typedef allocator_traits<_Al> _ATraits;
-typedef pointer_traits _PTraits;
-_Al __a(__get_alloc());
-__get_alloc().~_Alloc();
-__a.deallocate(_PTraits::pointer_to(*this), 1);
-}
+__compressed_pair<_Alloc, _Tp> __data_;
+};
 
 struct __shared_ptr_dummy_rebind_allocator_type;
 template <>



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


[llvm-branch-commits] [clang] 0978c83 - Basic: Initialize FileEntry's fields inline, almost NFC

2020-12-10 Thread Duncan P. N. Exon Smith via llvm-branch-commits

Author: Duncan P. N. Exon Smith
Date: 2020-12-10T13:57:21-08:00
New Revision: 0978c83e6fcc7a8aea18e24eb3b2ad5523581757

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

LOG: Basic: Initialize FileEntry's fields inline, almost NFC

Initialize most of FileEntry's fields inline (all the ones that can be).
The only functionality change is to avoid leaving some fields
uninitialized.

Added: 


Modified: 
clang/include/clang/Basic/FileEntry.h
clang/lib/Basic/FileEntry.cpp
clang/unittests/Basic/FileEntryTest.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/FileEntry.h 
b/clang/include/clang/Basic/FileEntry.h
index 8db5446aa8d4..aa7bedec44ac 100644
--- a/clang/include/clang/Basic/FileEntry.h
+++ b/clang/include/clang/Basic/FileEntry.h
@@ -328,13 +328,13 @@ class FileEntry {
   friend class FileManager;
 
   std::string RealPathName;   // Real path to the file; could be empty.
-  off_t Size; // File size in bytes.
-  time_t ModTime; // Modification time of file.
-  const DirectoryEntry *Dir;  // Directory file lives in.
+  off_t Size = 0; // File size in bytes.
+  time_t ModTime = 0; // Modification time of file.
+  const DirectoryEntry *Dir = nullptr; // Directory file lives in.
   llvm::sys::fs::UniqueID UniqueID;
-  unsigned UID;   // A unique (small) ID for the file.
-  bool IsNamedPipe;
-  bool IsValid;   // Is this \c FileEntry initialized and valid?
+  unsigned UID = 0; // A unique (small) ID for the file.
+  bool IsNamedPipe = false;
+  bool IsValid = false; // Is this \c FileEntry initialized and valid?
 
   /// The open file, if it is owned by the \p FileEntry.
   mutable std::unique_ptr File;

diff  --git a/clang/lib/Basic/FileEntry.cpp b/clang/lib/Basic/FileEntry.cpp
index 29218c7e0ec8..2efdcbbd46aa 100644
--- a/clang/lib/Basic/FileEntry.cpp
+++ b/clang/lib/Basic/FileEntry.cpp
@@ -16,7 +16,7 @@
 
 using namespace clang;
 
-FileEntry::FileEntry() : UniqueID(0, 0), IsNamedPipe(false), IsValid(false) {}
+FileEntry::FileEntry() : UniqueID(0, 0) {}
 
 FileEntry::~FileEntry() = default;
 

diff  --git a/clang/unittests/Basic/FileEntryTest.cpp 
b/clang/unittests/Basic/FileEntryTest.cpp
index 3cc01870b800..a3e03e6c7c29 100644
--- a/clang/unittests/Basic/FileEntryTest.cpp
+++ b/clang/unittests/Basic/FileEntryTest.cpp
@@ -55,6 +55,17 @@ struct RefMaps {
   }
 };
 
+TEST(FileEntryTest, Constructor) {
+  FileEntry FE;
+  EXPECT_EQ(0U, FE.getSize());
+  EXPECT_EQ(0, FE.getModificationTime());
+  EXPECT_EQ(nullptr, FE.getDir());
+  EXPECT_EQ(0U, FE.getUniqueID().getDevice());
+  EXPECT_EQ(0U, FE.getUniqueID().getFile());
+  EXPECT_EQ(false, FE.isNamedPipe());
+  EXPECT_EQ(false, FE.isValid());
+}
+
 TEST(FileEntryTest, FileEntryRef) {
   RefMaps Refs;
   FileEntryRef R1 = Refs.addFile("1");



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


[llvm-branch-commits] [clang-tools-extra] 671ad58 - [clang-tidy] performance-unnecessary-copy-initialization: Prevent false positives when dependent variable is modified.

2020-12-10 Thread Felix Berger via llvm-branch-commits

Author: Felix Berger
Date: 2020-12-10T16:58:17-05:00
New Revision: 671ad580610ad91139358b7786e02ff70433a90e

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Prevent false 
positives when dependent variable is modified.

Extend the check to not only look at the variable the unnecessarily copied
variable is initialized from, but also ensure that any variable the old variable
references is not modified.

Extend DeclRefExprUtils to also count references and pointers to const assigned
from the DeclRef we check for const usages.

Reviewed-by: aaron.ballman

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/clang-tidy/utils/DeclRefExprUtils.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h

clang-tools-extra/test/clang-tidy/checkers/performance-unnecessary-copy-initialization.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index 24847d80657c..f6b9365435fb 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -19,6 +19,14 @@ namespace tidy {
 namespace performance {
 namespace {
 
+using namespace ::clang::ast_matchers;
+using llvm::StringRef;
+using utils::decl_ref_expr::isOnlyUsedAsConst;
+
+static constexpr StringRef ObjectArgId = "objectArg";
+static constexpr StringRef InitFunctionCallId = "initFunctionCall";
+static constexpr StringRef OldVarDeclId = "oldVarDecl";
+
 void recordFixes(const VarDecl &Var, ASTContext &Context,
  DiagnosticBuilder &Diagnostic) {
   Diagnostic << utils::fixit::changeVarDeclToReference(Var, Context);
@@ -29,10 +37,88 @@ void recordFixes(const VarDecl &Var, ASTContext &Context,
   }
 }
 
-} // namespace
+AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningMethodCall) {
+  // Match method call expressions where the `this` argument is only used as
+  // const, this will be checked in `check()` part. This returned const
+  // reference is highly likely to outlive the local const reference of the
+  // variable being declared. The assumption is that the const reference being
+  // returned either points to a global static variable or to a member of the
+  // called object.
+  return cxxMemberCallExpr(
+  callee(cxxMethodDecl(returns(matchers::isReferenceToConst(,
+  on(declRefExpr(to(varDecl().bind(ObjectArgId);
+}
 
-using namespace ::clang::ast_matchers;
-using utils::decl_ref_expr::isOnlyUsedAsConst;
+AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
+  // Only allow initialization of a const reference from a free function if it
+  // has no arguments. Otherwise it could return an alias to one of its
+  // arguments and the arguments need to be checked for const use as well.
+  return 
callExpr(callee(functionDecl(returns(matchers::isReferenceToConst(,
+  argumentCountIs(0), unless(callee(cxxMethodDecl(
+  .bind(InitFunctionCallId);
+}
+
+AST_MATCHER_FUNCTION(StatementMatcher, isInitializedFromReferenceToConst) {
+  auto OldVarDeclRef =
+  declRefExpr(to(varDecl(hasLocalStorage()).bind(OldVarDeclId)));
+  return declStmt(has(varDecl(hasInitializer(
+  anyOf(isConstRefReturningFunctionCall(), isConstRefReturningMethodCall(),
+ignoringImpCasts(OldVarDeclRef),
+ignoringImpCasts(unaryOperator(
+hasOperatorName("&"), hasUnaryOperand(OldVarDeclRef;
+}
+
+// This checks that the variable itself is only used as const, and also makes
+// sure that it does not reference another variable that could be modified in
+// the BlockStmt. It does this by checking the following:
+// 1. If the variable is neither a reference nor a pointer then the
+// isOnlyUsedAsConst() check is sufficient.
+// 2. If the (reference or pointer) variable is not initialized in a DeclStmt 
in
+// the BlockStmt. In this case its pointee is likely not modified (unless it
+// is passed as an alias into the method as well).
+// 3. If the reference is initialized from a reference to const. This is
+// the same set of criteria we apply when identifying the unnecessary copied
+// variable in this check to begin with. In this case we check whether the
+// object arg or variable that is referenced is immutable as well.
+static bool isInitializingVariableImmutable(const VarDecl &InitializingVar,
+const Stmt &BlockStmt,
+ASTContex

[llvm-branch-commits] [compiler-rt] 5ff3535 - [DFSan] Appease the custom wrapper lint script.

2020-12-10 Thread Matt Morehouse via llvm-branch-commits

Author: Matt Morehouse
Date: 2020-12-10T14:12:26-08:00
New Revision: 5ff35356f1af2bb92785b38c657463924d9ec386

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

LOG: [DFSan] Appease the custom wrapper lint script.

Added: 


Modified: 
compiler-rt/test/dfsan/custom.cpp

Removed: 




diff  --git a/compiler-rt/test/dfsan/custom.cpp 
b/compiler-rt/test/dfsan/custom.cpp
index e21f35426cf0..a78152f5dcc1 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -800,6 +800,10 @@ void test_pthread_create() {
   ASSERT_ZERO_LABEL(cbrv);
 }
 
+// Tested by test_pthread_create().  This empty function is here to appease the
+// check-wrappers script.
+void test_pthread_join() {}
+
 int dl_iterate_phdr_test_cb(struct dl_phdr_info *info, size_t size,
 void *data) {
   assert(data == (void *)3);
@@ -1220,6 +1224,7 @@ int main(void) {
   test_poll();
   test_pread();
   test_pthread_create();
+  test_pthread_join();
   test_read();
   test_recvmsg();
   test_sched_getaffinity();



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


[llvm-branch-commits] [mlir] 186c154 - [mlir] Remove the dependency on StandardOps from FoldUtils

2020-12-10 Thread River Riddle via llvm-branch-commits

Author: River Riddle
Date: 2020-12-10T14:13:57-08:00
New Revision: 186c154991e85f8d6a4a77c5add3322351862725

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

LOG: [mlir] Remove the dependency on StandardOps from FoldUtils

OperationFolder currently uses ConstantOp as a backup when trying to 
materialize a constant after an operation is folded. This dependency isn't 
really useful or necessary given that dialects can/should provide a 
`materializeConstant` implementation.

Fixes PR#44866

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

Added: 


Modified: 
mlir/lib/Dialect/Shape/IR/Shape.cpp
mlir/lib/Transforms/Utils/FoldUtils.cpp
mlir/test/lib/Dialect/Test/TestDialect.cpp
mlir/test/lib/Dialect/Test/TestOps.td
mlir/test/mlir-tblgen/pattern.mlir

Removed: 




diff  --git a/mlir/lib/Dialect/Shape/IR/Shape.cpp 
b/mlir/lib/Dialect/Shape/IR/Shape.cpp
index c71360cdaba5..ef29ddc510ae 100644
--- a/mlir/lib/Dialect/Shape/IR/Shape.cpp
+++ b/mlir/lib/Dialect/Shape/IR/Shape.cpp
@@ -110,7 +110,7 @@ Operation *ShapeDialect::materializeConstant(OpBuilder 
&builder,
 return builder.create(loc, type, value.cast());
   if (type.isa())
 return builder.create(loc, type, value.cast());
-  if (type.isa())
+  if (ConstantOp::isBuildableWith(value, type))
 return builder.create(loc, type, value);
   return nullptr;
 }

diff  --git a/mlir/lib/Transforms/Utils/FoldUtils.cpp 
b/mlir/lib/Transforms/Utils/FoldUtils.cpp
index 074f71c92fff..ba755a748418 100644
--- a/mlir/lib/Transforms/Utils/FoldUtils.cpp
+++ b/mlir/lib/Transforms/Utils/FoldUtils.cpp
@@ -13,7 +13,6 @@
 
 #include "mlir/Transforms/FoldUtils.h"
 
-#include "mlir/Dialect/StandardOps/IR/Ops.h"
 #include "mlir/IR/Builders.h"
 #include "mlir/IR/Matchers.h"
 #include "mlir/IR/Operation.h"
@@ -60,11 +59,6 @@ static Operation *materializeConstant(Dialect *dialect, 
OpBuilder &builder,
 assert(matchPattern(constOp, m_Constant()));
 return constOp;
   }
-
-  // If the dialect is unable to materialize a constant, check to see if the
-  // standard constant can be used.
-  if (ConstantOp::isBuildableWith(value, type))
-return builder.create(loc, type, value);
   return nullptr;
 }
 

diff  --git a/mlir/test/lib/Dialect/Test/TestDialect.cpp 
b/mlir/test/lib/Dialect/Test/TestDialect.cpp
index c7e1b7f48f43..eeff840daeea 100644
--- a/mlir/test/lib/Dialect/Test/TestDialect.cpp
+++ b/mlir/test/lib/Dialect/Test/TestDialect.cpp
@@ -178,6 +178,11 @@ void TestDialect::initialize() {
   allowUnknownOperations();
 }
 
+Operation *TestDialect::materializeConstant(OpBuilder &builder, Attribute 
value,
+Type type, Location loc) {
+  return builder.create(loc, type, value);
+}
+
 static Type parseTestType(MLIRContext *ctxt, DialectAsmParser &parser,
   llvm::SetVector &stack) {
   StringRef typeTag;

diff  --git a/mlir/test/lib/Dialect/Test/TestOps.td 
b/mlir/test/lib/Dialect/Test/TestOps.td
index 1579e53e5277..9008ee7ca99f 100644
--- a/mlir/test/lib/Dialect/Test/TestOps.td
+++ b/mlir/test/lib/Dialect/Test/TestOps.td
@@ -23,6 +23,7 @@ include "TestInterfaces.td"
 def Test_Dialect : Dialect {
   let name = "test";
   let cppNamespace = "::mlir::test";
+  let hasConstantMaterializer = 1;
   let hasOperationAttrVerify = 1;
   let hasRegionArgAttrVerify = 1;
   let hasRegionResultAttrVerify = 1;

diff  --git a/mlir/test/mlir-tblgen/pattern.mlir 
b/mlir/test/mlir-tblgen/pattern.mlir
index 5496209d3886..0425cf819e60 100644
--- a/mlir/test/mlir-tblgen/pattern.mlir
+++ b/mlir/test/mlir-tblgen/pattern.mlir
@@ -254,7 +254,7 @@ func @verifyUnitAttr() -> (i32, i32) {
 
 // CHECK-LABEL: testConstOp
 func @testConstOp() -> (i32) {
-  // CHECK-NEXT: [[C0:%.+]] = constant 1
+  // CHECK-NEXT: [[C0:%.+]] = "test.constant"() {value = 1
   %0 = "test.constant"() {value = 1 : i32} : () -> i32
 
   // CHECK-NEXT: return [[C0]]
@@ -263,7 +263,7 @@ func @testConstOp() -> (i32) {
 
 // CHECK-LABEL: testConstOpUsed
 func @testConstOpUsed() -> (i32) {
-  // CHECK-NEXT: [[C0:%.+]] = constant 1
+  // CHECK-NEXT: [[C0:%.+]] = "test.constant"() {value = 1
   %0 = "test.constant"() {value = 1 : i32} : () -> i32
 
   // CHECK-NEXT: [[V0:%.+]] = "test.op_s"([[C0]])
@@ -275,7 +275,7 @@ func @testConstOpUsed() -> (i32) {
 
 // CHECK-LABEL: testConstOpReplaced
 func @testConstOpReplaced() -> (i32) {
-  // CHECK-NEXT: [[C0:%.+]] = constant 1
+  // CHECK-NEXT: [[C0:%.+]] = "test.constant"() {value = 1
   %0 = "test.constant"() {value = 1 : i32} : () -> i32
   %1 = "test.constant"() {value = 2 : i32} : () -> i32
 
@@ -288,10 +288,10 @@ func @testConstOpReplaced() -> (i32) {
 
 // CHECK-LABEL: testConstOpMatchFailure
 func @testConstOpMatchFailure() -> (i64) {
-  // CHECK-DAG: [[C0:%.+]] = const

[llvm-branch-commits] [llvm] 10b5eae - [SmallVector] Copy new docs into Doxygen comment

2020-12-10 Thread Scott Linder via llvm-branch-commits

Author: Scott Linder
Date: 2020-12-10T22:20:37Z
New Revision: 10b5eaed917d6f91aa2d416c08c93697bd1d446f

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

LOG: [SmallVector] Copy new docs into Doxygen comment

Copy the `ProgrammersManual.rst` changes from D92522 to the Doxygen
comment for `SmallVector`, to hopefully encourage new uses migrating to
the no-explicit-`N` form.

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

Added: 


Modified: 
llvm/include/llvm/ADT/SmallVector.h

Removed: 




diff  --git a/llvm/include/llvm/ADT/SmallVector.h 
b/llvm/include/llvm/ADT/SmallVector.h
index 1b2787b88932..10b9d4e9c0f1 100644
--- a/llvm/include/llvm/ADT/SmallVector.h
+++ b/llvm/include/llvm/ADT/SmallVector.h
@@ -1012,7 +1012,14 @@ template  struct 
CalculateSmallVectorDefaultInlinedElements {
 /// elements is below that threshold.  This allows normal "small" cases to be
 /// fast without losing generality for large inputs.
 ///
-/// Note that this does not attempt to be exception safe.
+/// \note
+/// In the absence of a well-motivated choice for the number of inlined
+/// elements \p N, it is recommended to use \c SmallVector (that is,
+/// omitting the \p N). This will choose a default number of inlined elements
+/// reasonable for allocation on the stack (for example, trying to keep \c
+/// sizeof(SmallVector) around 64 bytes).
+///
+/// \warning This does not attempt to be exception safe.
 ///
 template ::value>



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


[llvm-branch-commits] [compiler-rt] b1dd1a0 - [msan] Do not use 77 as exit code, instead use 1

2020-12-10 Thread Evgenii Stepanov via llvm-branch-commits

Author: Florian Schmaus
Date: 2020-12-10T14:23:12-08:00
New Revision: b1dd1a099771543cf0ca133b6342af1b3ce61a44

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

LOG: [msan] Do not use 77 as exit code, instead use 1

MSan uses 77 as exit code since it appeared with c5033786ba34 ("[msan]
MemorySanitizer runtime."). However, Test runners like the one from
Meson use the GNU standard approach where a exit code of 77 signals
that the test should be skipped [1]. As a result Meson's test runner
reports tests as skipped if MSan is enabled and finds issues:

build $ meson test
ninja: Entering directory `/home/user/code/project/build'
ninja: no work to do.
1/1 PROJECT:all / SimpleTestSKIP   0.09s

I could not find any rationale why 77 was initially chosen, and I
found no other clang sanitizer that uses this value as exit
code. Hence I believe it is safe to change this to a safe
default. You can restore the old behavior by setting the environment
variable MSAN_OPTIONS to "exitcode=77", e.g.

export MSAN_OPTIONS="exitcode=77"

1: https://mesonbuild.com/Unit-tests.html#skipped-tests-and-hard-errors

Reviewed By: #sanitizers, eugenis

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

Added: 


Modified: 
compiler-rt/lib/msan/msan.cpp

Removed: 




diff  --git a/compiler-rt/lib/msan/msan.cpp b/compiler-rt/lib/msan/msan.cpp
index 7abb3b4b65dc..4be1630cd302 100644
--- a/compiler-rt/lib/msan/msan.cpp
+++ b/compiler-rt/lib/msan/msan.cpp
@@ -151,7 +151,6 @@ static void InitializeFlags() {
 // FIXME: test and enable.
 cf.check_printf = false;
 cf.intercept_tls_get_addr = true;
-cf.exitcode = 77;
 OverrideCommonFlags(cf);
   }
 



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


[llvm-branch-commits] [llvm] 4564553 - [WebAssembly] Support COMDAT sections in assembly syntax

2020-12-10 Thread Derek Schuff via llvm-branch-commits

Author: Derek Schuff
Date: 2020-12-10T14:46:24-08:00
New Revision: 4564553b8d8ab81dc21431a35275581cb42329c8

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

LOG: [WebAssembly] Support COMDAT sections in assembly syntax

This CL changes the asm syntax for section flags, making them more like ELF
(previously "passive" was the only option). Now we also allow "G" to designate
COMDAT group sections. In these sections we set the appropriate comdat flag on
function symbols, and also avoid auto-creating a new section for them.

This also adds asm-based tests for the changes D92691 to go along with
the direct-to-object tests.

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

Added: 
llvm/test/MC/WebAssembly/comdat-sections.s

Modified: 
llvm/lib/MC/MCParser/WasmAsmParser.cpp
llvm/lib/MC/MCSectionWasm.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp
llvm/test/MC/WebAssembly/comdat-sections.ll
llvm/test/MC/WebAssembly/comdat.ll

Removed: 




diff  --git a/llvm/lib/MC/MCParser/WasmAsmParser.cpp 
b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
index c8f9807d0c54..0c255ef02d2a 100644
--- a/llvm/lib/MC/MCParser/WasmAsmParser.cpp
+++ b/llvm/lib/MC/MCParser/WasmAsmParser.cpp
@@ -90,15 +90,40 @@ class WasmAsmParser : public MCAsmParserExtension {
 return false;
   }
 
-  bool parseSectionFlags(StringRef FlagStr, bool &Passive) {
-SmallVector Flags;
-// If there are no flags, keep Flags empty
-FlagStr.split(Flags, ",", -1, false);
-for (auto &Flag : Flags) {
-  if (Flag == "passive")
+  bool parseSectionFlags(StringRef FlagStr, bool &Passive, bool &Group) {
+for (char C : FlagStr) {
+  switch (C) {
+  case 'p':
 Passive = true;
-  else
-return error("Expected section flags, instead got: ", Lexer->getTok());
+break;
+  case 'G':
+Group = true;
+break;
+  default:
+return Parser->Error(getTok().getLoc(),
+ StringRef("Unexepcted section flag: ") + FlagStr);
+  }
+}
+return false;
+  }
+
+  bool parseGroup(StringRef &GroupName) {
+if (Lexer->isNot(AsmToken::Comma))
+  return TokError("expected group name");
+Lex();
+if (Lexer->is(AsmToken::Integer)) {
+  GroupName = getTok().getString();
+  Lex();
+} else if (Parser->parseIdentifier(GroupName)) {
+  return TokError("invalid group name");
+}
+if (Lexer->is(AsmToken::Comma)) {
+  Lex();
+  StringRef Linkage;
+  if (Parser->parseIdentifier(Linkage))
+return TokError("invalid linkage");
+  if (Linkage != "comdat")
+return TokError("Linkage must be 'comdat'");
 }
 return false;
   }
@@ -130,27 +155,34 @@ class WasmAsmParser : public MCAsmParserExtension {
 if (!Kind.hasValue())
   return Parser->Error(Lexer->getLoc(), "unknown section kind: " + Name);
 
-MCSectionWasm *Section = getContext().getWasmSection(Name, 
Kind.getValue());
 
 // Update section flags if present in this .section directive
 bool Passive = false;
-if (parseSectionFlags(getTok().getStringContents(), Passive))
+bool Group = false;
+if (parseSectionFlags(getTok().getStringContents(), Passive, Group))
   return true;
 
-if (Passive) {
-  if (!Section->isWasmData())
-return Parser->Error(getTok().getLoc(),
- "Only data sections can be passive");
-  Section->setPassive();
-}
-
 Lex();
 
-if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@") ||
-expect(AsmToken::EndOfStatement, "eol"))
+if (expect(AsmToken::Comma, ",") || expect(AsmToken::At, "@"))
+  return true;
+
+StringRef GroupName;
+if (Group && parseGroup(GroupName))
+  return true;
+
+if (expect(AsmToken::EndOfStatement, "eol"))
   return true;
 
-auto WS = getContext().getWasmSection(Name, Kind.getValue());
+// TODO: Parse UniqueID
+MCSectionWasm *WS = getContext().getWasmSection(
+Name, Kind.getValue(), GroupName, MCContext::GenericSectionID);
+if (Passive) {
+  if (!WS->isWasmData())
+return Parser->Error(getTok().getLoc(),
+ "Only data sections can be passive");
+  WS->setPassive();
+}
 getStreamer().SwitchSection(WS);
 return false;
   }
@@ -189,9 +221,13 @@ class WasmAsmParser : public MCAsmParserExtension {
   Lexer->is(AsmToken::Identifier)))
   return error("Expected label,@type declaration, got: ", Lexer->getTok());
 auto TypeName = Lexer->getTok().getString();
-if (TypeName == "function")
+if (TypeName == "function") {
   WasmSym->setType(wasm::WASM_SYMBOL_TYPE_FUNCTION);
-else if (TypeName =

[llvm-branch-commits] [compiler-rt] 97260ab - [llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero count cycles

2020-12-10 Thread Fangrui Song via llvm-branch-commits

Author: Xinhao Yuan
Date: 2020-12-10T15:22:29-08:00
New Revision: 97260ab4786f87211b8553b56fd0600016b1d6fa

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

LOG: [llvm-cov][gcov] Optimize the cycle counting algorithm by skipping zero 
count cycles

This change is similar to http://gcc.gnu.org/PR90380

This reduces the complexity from exponential to polynomial of the arcs.

Reviewed By: MaskRay

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

Added: 
compiler-rt/test/profile/gcov-complex-line.c

Modified: 
llvm/include/llvm/ProfileData/GCOV.h
llvm/lib/ProfileData/GCOV.cpp

Removed: 




diff  --git a/compiler-rt/test/profile/gcov-complex-line.c 
b/compiler-rt/test/profile/gcov-complex-line.c
new file mode 100644
index ..86286c4a93a5
--- /dev/null
+++ b/compiler-rt/test/profile/gcov-complex-line.c
@@ -0,0 +1,55 @@
+// This test checks that the cycle detection algorithm in llvm-cov is able to
+// handle complex block graphs by skipping zero count cycles.
+//
+// RUN: mkdir -p %t.dir && cd %t.dir
+// RUN: %clang --coverage %s -o %t
+// RUN: rm -f gcov-complex-line.gcda && %run %t
+// RUN: llvm-cov gcov -t gcov-complex-line.c | FileCheck %s
+
+#define M_0 \
+  do {  \
+if (x == 0) \
+  x = 0;\
+else\
+  x = 1;\
+  } while (0)
+#define M_1 \
+  do {  \
+M_0;\
+M_0;\
+M_0;\
+M_0;\
+  } while (0)
+#define M_2 \
+  do {  \
+M_1;\
+M_1;\
+M_1;\
+M_1;\
+  } while (0)
+#define M_3 \
+  do {  \
+M_2;\
+M_2;\
+M_2;\
+M_2;\
+  } while (0)
+#define M_4 \
+  do {  \
+M_3;\
+M_3;\
+M_3;\
+M_3;\
+  } while (0)
+#define COMPLEX_LINE  \
+  do {\
+for (int i = 0; i < 100; ++i) \
+  M_4;\
+  } while (0)
+
+int main() {
+  volatile int x = 0;
+  // In the following line, the number of cycles in the block graph is at least
+  // 2^256, where 256 is the number of expansions of M_0.
+  COMPLEX_LINE; // CHECK: 101: [[#@LINE]]: COMPLEX_LINE;
+}

diff  --git a/llvm/include/llvm/ProfileData/GCOV.h 
b/llvm/include/llvm/ProfileData/GCOV.h
index 2766ff52e4a0..b15c5a6a6c65 100644
--- a/llvm/include/llvm/ProfileData/GCOV.h
+++ b/llvm/include/llvm/ProfileData/GCOV.h
@@ -295,6 +295,7 @@ class GCOVBlock {
   static uint64_t getCycleCount(const Edges &Path);
   static void unblock(const GCOVBlock *U, BlockVector &Blocked,
   BlockVectorLists &BlockLists);
+  static void trimZeroCountSuffix(Edges &Path);
   static bool lookForCircuit(const GCOVBlock *V, const GCOVBlock *Start,
  Edges &Path, BlockVector &Blocked,
  BlockVectorLists &BlockLists,

diff  --git a/llvm/lib/ProfileData/GCOV.cpp b/llvm/lib/ProfileData/GCOV.cpp
index c0735250cfd8..b8bc0cc48376 100644
--- a/llvm/lib/ProfileData/GCOV.cpp
+++ b/llvm/lib/ProfileData/GCOV.cpp
@@ -427,6 +427,11 @@ LLVM_DUMP_METHOD void GCOVBlock::dump() const { 
print(dbgs()); }
 // The algorithm in GCC is based on the algorithm by Hawick & James:
 //   "Enumerating Circuits and Loops in Graphs with Self-Arcs and 
Multiple-Arcs"
 //   http://complexity.massey.ac.nz/cstn/013/cstn-013.pdf.
+//
+// An optimization is to skip any arc with zero count and to backtrack if the
+// current path has such arcs: any cycle with such arc makes no contribution to
+// the final cycle count. This reduces the complexity from exponential to
+// polynomial of the arcs.
 
 /// Get the count for the detected cycle.
 uint64_t GCOVBlock::getCycleCount(const Edges &Path) {
@@ -458,6 +463,15 @@ void GCOVBlock::unblock(const GCOVBlock *U, BlockVector 
&Blocked,
   }
 }
 
+void GCOVBlock::trimZeroCountSuffix(Edges &Path) {
+  for (size_t index = 0; index < Path.size(); ++index) {
+if (Path[index]->cycleCount == 0) {
+  Path.resize(index);
+  return;
+}
+  }
+}
+
 bool GCOVBlock::lookForCircuit(const GCOVBlock *V, const GCOVBlock *Start,
Edges &Path, BlockVector &Blocked,
BlockVectorLists &BlockLists,
@@ -465,10 +479,11 @@ bool GCOVBlock::lookForCircuit(const GCOVBlock *V, const 
GCOVBlock *Start,
   Blocked.push_back(V);
   BlockLists.emplace_back(BlockVector());
   bool FoundCircuit = false;
+  const size_t PrefixLength = Path.size();
 
   for (auto E : V->dsts()) {
 const GCOVBlock *W = &E->dst;
-if (W < Start || find(Blocks, W) == Blocks.end()) {
+if (E->cycleCount == 0 || W < Start || find(Blocks, W) == Blocks.end()) {
   continue;
 }
 
@@ -477,6 +492,7 @@ bool GCOVBlock::lookForCircuit(const GCOVBlock *V, const 
GCOVBlock *Start,
 if (W == Start) {

[llvm-branch-commits] [clang] cd5855a - [VE] Remove -faddrsig and -fnoaddrsig tests

2020-12-10 Thread Kazushi Marukawa via llvm-branch-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-11T08:25:38+09:00
New Revision: cd5855ac3ba7a91b2a4a7c97b2723c95038dacbe

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

LOG: [VE] Remove -faddrsig and -fnoaddrsig tests

Remove explicitly declared -faddrsig and -fnoaddrsig option tests
since those are already tested in addrsig.c.  We test only the implicit
behavior of VE driver.

This is suggested in https://reviews.llvm.org/D92386.  Thanks.

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/test/Driver/ve-toolchain.c
clang/test/Driver/ve-toolchain.cpp

Removed: 




diff  --git a/clang/test/Driver/ve-toolchain.c 
b/clang/test/Driver/ve-toolchain.c
index 261b3efcc4f0..0ca3c84373f3 100644
--- a/clang/test/Driver/ve-toolchain.c
+++ b/clang/test/Driver/ve-toolchain.c
@@ -67,16 +67,6 @@
 // DEFADDESIG: clang{{.*}} "-cc1"
 // DEFADDESIG-NOT: "-faddrsig"
 
-// RUN: %clang -### -target ve %s -faddrsig 2>&1 | \
-// RUN: FileCheck -check-prefix=ADDRSIG %s
-// ADDRSIG: clang{{.*}} "-cc1"
-// ADDRSIG: "-faddrsig"
-
-// RUN: %clang -### -target ve %s -fno-addrsig 2>&1 | \
-// RUN: FileCheck -check-prefix=NOADDRSIG %s
-// NOADDRSIG: clang{{.*}} "-cc1"
-// NOADDRSIG-NOT: "-faddrsig"
-
 
///-
 /// Checking exceptions
 

diff  --git a/clang/test/Driver/ve-toolchain.cpp 
b/clang/test/Driver/ve-toolchain.cpp
index 6243b4c3f386..36a23aa87f98 100644
--- a/clang/test/Driver/ve-toolchain.cpp
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -85,16 +85,6 @@
 // DEFADDESIG: clang{{.*}} "-cc1"
 // DEFADDESIG-NOT: "-faddrsig"
 
-// RUN: %clangxx -### -target ve %s -faddrsig 2>&1 | \
-// RUN: FileCheck -check-prefix=ADDRSIG %s
-// ADDRSIG: clang{{.*}} "-cc1"
-// ADDRSIG: "-faddrsig"
-
-// RUN: %clangxx -### -target ve %s -fno-addrsig 2>&1 | \
-// RUN: FileCheck -check-prefix=NOADDRSIG %s
-// NOADDRSIG: clang{{.*}} "-cc1"
-// NOADDRSIG-NOT: "-faddrsig"
-
 
///-
 /// Checking exceptions
 



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


[llvm-branch-commits] [llvm] 9aafa9f - Revert "[NFC] Fix a gcc build break by not using an initializer."

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T15:53:38-08:00
New Revision: 9aafa9fc15228e69393782026930fbe2ab403dac

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

LOG: Revert "[NFC] Fix a gcc build break by not using an initializer."

This reverts commit 1dc0a8521f616af5897327e4c03098f9312e9c59.

Reason: Dependency of patch that broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

Added: 


Modified: 
llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp

Removed: 




diff  --git a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp 
b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
index 5c3952b12e07..69adc77730d1 100644
--- a/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/PseudoProbePrinter.cpp
@@ -62,7 +62,7 @@ void PseudoProbeHandler::emitPseudoProbe(uint64_t Guid, 
uint64_t Index,
 uint64_t CallerGuid = Names[Name];
 uint64_t CallerProbeId = PseudoProbeDwarfDiscriminator::extractProbeIndex(
 InlinedAt->getDiscriminator());
-ReversedInlineStack.emplace_back(CallerGuid, CallerProbeId);
+ReversedInlineStack.push_back({CallerGuid, CallerProbeId});
 InlinedAt = InlinedAt->getInlinedAt();
   }
 



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


[llvm-branch-commits] [llvm] b955eb6 - Revert "[NFC] Fix a gcc build break by using an explict constructor."

2020-12-10 Thread Mitch Phillips via llvm-branch-commits

Author: Mitch Phillips
Date: 2020-12-10T15:53:38-08:00
New Revision: b955eb688da31e85780bae8fc424bb344ef5daee

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

LOG: Revert "[NFC] Fix a gcc build break by using an explict constructor."

This reverts commit 248b279cf04d9e439a1e426ffd24f2dfa93d02f8.

Reason: Dependency of patch that broke the ASan buildbots:
  http://lab.llvm.org:8011/#/builders/5/builds/2269

Added: 


Modified: 
llvm/lib/MC/MCParser/AsmParser.cpp

Removed: 




diff  --git a/llvm/lib/MC/MCParser/AsmParser.cpp 
b/llvm/lib/MC/MCParser/AsmParser.cpp
index bf50a95bc70c..bf2e5d8b41d4 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -5833,7 +5833,7 @@ bool AsmParser::parseDirectivePseudoProbe() {
 return true;
 }
 
-InlineSite Site(CallerGuid, CallerProbeId);
+InlineSite Site = {CallerGuid, CallerProbeId};
 InlineStack.push_back(Site);
   }
 



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


  1   2   >