platform/upstream/llvm.git
2 years ago[LLD] [MinGW] Implement --disable-reloc-section, mapped to /fixed
Martin Storsjö [Fri, 10 Jun 2022 07:57:40 +0000 (10:57 +0300)]
[LLD] [MinGW] Implement --disable-reloc-section, mapped to /fixed

Since binutils 2.36, GNU ld defaults to emitting base relocations,
and that version added the new option --disable-reloc-section to
disable it.

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

2 years ago[COFF] Don't reject executables with data directories pointing outside of provided...
Martin Storsjö [Wed, 8 Jun 2022 20:55:45 +0000 (23:55 +0300)]
[COFF] Don't reject executables with data directories pointing outside of provided data

Before bb94611d6545c2c5271f5bb01de1aa4228a37250, we didn't check
that the sections in the COFF executable actually contained enough
raw data, when looking up what section contains tables pointed to
by the data directories.

That commit added checking, to avoid setting a pointer that points
out of bounds - by rejecting such executables.

It turns out that some binaries (e.g.g a "helper.exe" provided by
NSIS) contains a base relocation table data directory that points
into the wrong section. It points inside the virtual address space
allocated for that section, but the section contains much less raw
data, and the table points outside of the provided raw data.

No longer reject such binaries (to let tools operate on them and
inspect them), but don't set the table pointers (so that when
printing e.g. base relocations, we don't print anything).

This should fix the regression pointed out in
https://reviews.llvm.org/D126898#3565834.

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

2 years ago[SLP] Improve reordering in presence of constant only nodes.
Alexey Bataev [Tue, 14 Jun 2022 17:35:04 +0000 (10:35 -0700)]
[SLP] Improve reordering in presence of constant only nodes.

We can skip the analysis of the constant nodes, their order should not
affect the ordering of the trees/subtrees.

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

2 years ago[flang] Fix one regression failure related to BIND(C) statement
PeixinQiao [Wed, 15 Jun 2022 13:10:36 +0000 (21:10 +0800)]
[flang] Fix one regression failure related to BIND(C) statement

For BIND(C) statement, two common block with the same name can have the
same bind name. Fix the regression failure by adding this check. Also add
the regression tests.

Co-authored-by: Jean Perier <jperier@nvidia.com>
Reviewed By: clementval

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

2 years ago[mlir] check interfaces are attached to the expected object
Alex Zinenko [Wed, 15 Jun 2022 12:49:21 +0000 (14:49 +0200)]
[mlir] check interfaces are attached to the expected object

Add static assertions into the various `attachInterface` methods, which are
used for adding external interface implementations to attributes, operations
and types, that ensure `ExternalModel` interface classes are instantiated for
the same concrete operation for the concrete base (potentially self) attribute
or type as they are attached to. `FallbackModel`s remain usable for generic
interface models that should support more than one kind of entities.

Reviewed By: springerm

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

2 years ago[mlir] generate documentation for transform dialect extensions
Alex Zinenko [Wed, 15 Jun 2022 13:04:52 +0000 (15:04 +0200)]
[mlir] generate documentation for transform dialect extensions

2 years ago[test][RISCV] Precommit test for SeparateConstOffsetFromGEP (NFC)
Elena Lepilkina [Wed, 1 Jun 2022 07:47:40 +0000 (10:47 +0300)]
[test][RISCV] Precommit test for SeparateConstOffsetFromGEP (NFC)

Precommit test for D127727

2 years ago[NFC][Alignment] Use Align in MCAlignFragment
Guillaume Chatelet [Tue, 14 Jun 2022 11:31:58 +0000 (11:31 +0000)]
[NFC][Alignment] Use Align in MCAlignFragment

2 years ago[analyzer][NFC][test] Add new RUN lint with support-symbolic-integer-casts=true to...
Gabor Marton [Mon, 13 Jun 2022 15:04:42 +0000 (17:04 +0200)]
[analyzer][NFC][test] Add new RUN lint with support-symbolic-integer-casts=true to svalbuilder-rearrange-comparisons.c

Added a new run line to bolster gradual transition of handling cast operations,
see https://discourse.llvm.org/t/roadmap-of-modeling-symbolic-cast-operations/63107

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

2 years ago[gn build] (semi-automatically) port fb34d531af95
Nico Weber [Wed, 15 Jun 2022 11:42:40 +0000 (07:42 -0400)]
[gn build] (semi-automatically) port fb34d531af95

2 years ago[gn build] (semi-automatically) port 8bc0bb956421
Nico Weber [Wed, 15 Jun 2022 11:42:19 +0000 (07:42 -0400)]
[gn build] (semi-automatically) port 8bc0bb956421

2 years agoRevert "Reland "[X86][RFC] Enable `_Float16` type support on X86 following the psABI""
Thomas Joerg [Wed, 15 Jun 2022 11:10:01 +0000 (13:10 +0200)]
Revert "Reland "[X86][RFC] Enable `_Float16` type support on X86 following the psABI""

This reverts commit 6e02e27536b9de25a651cfc9c2966ce471169355.

This introduces a crash in the backend. Reproducer in MLIR's LLVM
dialect follows. Let me know if you have trouble reproducing this.

module {
  llvm.func @malloc(i64) -> !llvm.ptr<i8>
  llvm.func @_mlir_ciface_tf_report_error(!llvm.ptr<i8>, i32, !llvm.ptr<i8>)
  llvm.mlir.global internal constant @error_message_2208944672953921889("failed to allocate memory at loc(\22-\22:3:8)\00")
  llvm.func @_mlir_ciface_tf_alloc(!llvm.ptr<i8>, i64, i64, i32, i32, !llvm.ptr<i32>) -> !llvm.ptr<i8>
  llvm.func @Rsqrt_CPU_DT_HALF_DT_HALF(%arg0: !llvm.ptr<i8>, %arg1: i64, %arg2: !llvm.ptr<i8>) -> !llvm.struct<(i64, ptr<i8>)> attributes {llvm.emit_c_interface, tf_entry} {
    %0 = llvm.mlir.constant(8 : i32) : i32
    %1 = llvm.mlir.constant(8 : index) : i64
    %2 = llvm.mlir.constant(2 : index) : i64
    %3 = llvm.mlir.constant(dense<0.000000e+00> : vector<4xf16>) : vector<4xf16>
    %4 = llvm.mlir.constant(dense<[0, 1, 2, 3]> : vector<4xi32>) : vector<4xi32>
    %5 = llvm.mlir.constant(dense<1.000000e+00> : vector<4xf16>) : vector<4xf16>
    %6 = llvm.mlir.constant(false) : i1
    %7 = llvm.mlir.constant(1 : i32) : i32
    %8 = llvm.mlir.constant(0 : i32) : i32
    %9 = llvm.mlir.constant(4 : index) : i64
    %10 = llvm.mlir.constant(0 : index) : i64
    %11 = llvm.mlir.constant(1 : index) : i64
    %12 = llvm.mlir.constant(-1 : index) : i64
    %13 = llvm.mlir.null : !llvm.ptr<f16>
    %14 = llvm.getelementptr %13[%9] : (!llvm.ptr<f16>, i64) -> !llvm.ptr<f16>
    %15 = llvm.ptrtoint %14 : !llvm.ptr<f16> to i64
    %16 = llvm.alloca %15 x f16 {alignment = 32 : i64} : (i64) -> !llvm.ptr<f16>
    %17 = llvm.alloca %15 x f16 {alignment = 32 : i64} : (i64) -> !llvm.ptr<f16>
    %18 = llvm.mlir.null : !llvm.ptr<i64>
    %19 = llvm.getelementptr %18[%arg1] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    %20 = llvm.ptrtoint %19 : !llvm.ptr<i64> to i64
    %21 = llvm.alloca %20 x i64 : (i64) -> !llvm.ptr<i64>
    llvm.br ^bb1(%10 : i64)
  ^bb1(%22: i64):  // 2 preds: ^bb0, ^bb2
    %23 = llvm.icmp "slt" %22, %arg1 : i64
    llvm.cond_br %23, ^bb2, ^bb3
  ^bb2:  // pred: ^bb1
    %24 = llvm.bitcast %arg2 : !llvm.ptr<i8> to !llvm.ptr<struct<(ptr<f16>, ptr<f16>, i64)>>
    %25 = llvm.getelementptr %24[%10, 2] : (!llvm.ptr<struct<(ptr<f16>, ptr<f16>, i64)>>, i64) -> !llvm.ptr<i64>
    %26 = llvm.add %22, %11  : i64
    %27 = llvm.getelementptr %25[%26] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    %28 = llvm.load %27 : !llvm.ptr<i64>
    %29 = llvm.getelementptr %21[%22] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    llvm.store %28, %29 : !llvm.ptr<i64>
    llvm.br ^bb1(%26 : i64)
  ^bb3:  // pred: ^bb1
    llvm.br ^bb4(%10, %11 : i64, i64)
  ^bb4(%30: i64, %31: i64):  // 2 preds: ^bb3, ^bb5
    %32 = llvm.icmp "slt" %30, %arg1 : i64
    llvm.cond_br %32, ^bb5, ^bb6
  ^bb5:  // pred: ^bb4
    %33 = llvm.bitcast %arg2 : !llvm.ptr<i8> to !llvm.ptr<struct<(ptr<f16>, ptr<f16>, i64)>>
    %34 = llvm.getelementptr %33[%10, 2] : (!llvm.ptr<struct<(ptr<f16>, ptr<f16>, i64)>>, i64) -> !llvm.ptr<i64>
    %35 = llvm.add %30, %11  : i64
    %36 = llvm.getelementptr %34[%35] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    %37 = llvm.load %36 : !llvm.ptr<i64>
    %38 = llvm.mul %37, %31  : i64
    llvm.br ^bb4(%35, %38 : i64, i64)
  ^bb6:  // pred: ^bb4
    %39 = llvm.bitcast %arg2 : !llvm.ptr<i8> to !llvm.ptr<ptr<f16>>
    %40 = llvm.getelementptr %39[%11] : (!llvm.ptr<ptr<f16>>, i64) -> !llvm.ptr<ptr<f16>>
    %41 = llvm.load %40 : !llvm.ptr<ptr<f16>>
    %42 = llvm.getelementptr %13[%11] : (!llvm.ptr<f16>, i64) -> !llvm.ptr<f16>
    %43 = llvm.ptrtoint %42 : !llvm.ptr<f16> to i64
    %44 = llvm.alloca %7 x i32 : (i32) -> !llvm.ptr<i32>
    llvm.store %8, %44 : !llvm.ptr<i32>
    %45 = llvm.call @_mlir_ciface_tf_alloc(%arg0, %31, %43, %8, %7, %44) : (!llvm.ptr<i8>, i64, i64, i32, i32, !llvm.ptr<i32>) -> !llvm.ptr<i8>
    %46 = llvm.bitcast %45 : !llvm.ptr<i8> to !llvm.ptr<f16>
    %47 = llvm.icmp "eq" %31, %10 : i64
    %48 = llvm.or %6, %47  : i1
    %49 = llvm.mlir.null : !llvm.ptr<i8>
    %50 = llvm.icmp "ne" %45, %49 : !llvm.ptr<i8>
    %51 = llvm.or %50, %48  : i1
    llvm.cond_br %51, ^bb7, ^bb13
  ^bb7:  // pred: ^bb6
    %52 = llvm.urem %31, %9  : i64
    %53 = llvm.sub %31, %52  : i64
    llvm.br ^bb8(%10 : i64)
  ^bb8(%54: i64):  // 2 preds: ^bb7, ^bb9
    %55 = llvm.icmp "slt" %54, %53 : i64
    llvm.cond_br %55, ^bb9, ^bb10
  ^bb9:  // pred: ^bb8
    %56 = llvm.mul %54, %11  : i64
    %57 = llvm.add %56, %10  : i64
    %58 = llvm.add %57, %10  : i64
    %59 = llvm.getelementptr %41[%58] : (!llvm.ptr<f16>, i64) -> !llvm.ptr<f16>
    %60 = llvm.bitcast %59 : !llvm.ptr<f16> to !llvm.ptr<vector<4xf16>>
    %61 = llvm.load %60 {alignment = 2 : i64} : !llvm.ptr<vector<4xf16>>
    %62 = "llvm.intr.sqrt"(%61) : (vector<4xf16>) -> vector<4xf16>
    %63 = llvm.fdiv %5, %62  : vector<4xf16>
    %64 = llvm.getelementptr %46[%58] : (!llvm.ptr<f16>, i64) -> !llvm.ptr<f16>
    %65 = llvm.bitcast %64 : !llvm.ptr<f16> to !llvm.ptr<vector<4xf16>>
    llvm.store %63, %65 {alignment = 2 : i64} : !llvm.ptr<vector<4xf16>>
    %66 = llvm.add %54, %9  : i64
    llvm.br ^bb8(%66 : i64)
  ^bb10:  // pred: ^bb8
    %67 = llvm.icmp "ult" %53, %31 : i64
    llvm.cond_br %67, ^bb11, ^bb12
  ^bb11:  // pred: ^bb10
    %68 = llvm.mul %53, %12  : i64
    %69 = llvm.add %31, %68  : i64
    %70 = llvm.mul %53, %11  : i64
    %71 = llvm.add %70, %10  : i64
    %72 = llvm.trunc %69 : i64 to i32
    %73 = llvm.mlir.undef : vector<4xi32>
    %74 = llvm.insertelement %72, %73[%8 : i32] : vector<4xi32>
    %75 = llvm.shufflevector %74, %73 [0 : i32, 0 : i32, 0 : i32, 0 : i32] : vector<4xi32>, vector<4xi32>
    %76 = llvm.icmp "slt" %4, %75 : vector<4xi32>
    %77 = llvm.add %71, %10  : i64
    %78 = llvm.getelementptr %41[%77] : (!llvm.ptr<f16>, i64) -> !llvm.ptr<f16>
    %79 = llvm.bitcast %78 : !llvm.ptr<f16> to !llvm.ptr<vector<4xf16>>
    %80 = llvm.intr.masked.load %79, %76, %3 {alignment = 2 : i32} : (!llvm.ptr<vector<4xf16>>, vector<4xi1>, vector<4xf16>) -> vector<4xf16>
    %81 = llvm.bitcast %16 : !llvm.ptr<f16> to !llvm.ptr<vector<4xf16>>
    llvm.store %80, %81 : !llvm.ptr<vector<4xf16>>
    %82 = llvm.load %81 {alignment = 2 : i64} : !llvm.ptr<vector<4xf16>>
    %83 = "llvm.intr.sqrt"(%82) : (vector<4xf16>) -> vector<4xf16>
    %84 = llvm.fdiv %5, %83  : vector<4xf16>
    %85 = llvm.bitcast %17 : !llvm.ptr<f16> to !llvm.ptr<vector<4xf16>>
    llvm.store %84, %85 {alignment = 2 : i64} : !llvm.ptr<vector<4xf16>>
    %86 = llvm.load %85 : !llvm.ptr<vector<4xf16>>
    %87 = llvm.getelementptr %46[%77] : (!llvm.ptr<f16>, i64) -> !llvm.ptr<f16>
    %88 = llvm.bitcast %87 : !llvm.ptr<f16> to !llvm.ptr<vector<4xf16>>
    llvm.intr.masked.store %86, %88, %76 {alignment = 2 : i32} : vector<4xf16>, vector<4xi1> into !llvm.ptr<vector<4xf16>>
    llvm.br ^bb12
  ^bb12:  // 2 preds: ^bb10, ^bb11
    %89 = llvm.mul %2, %1  : i64
    %90 = llvm.mul %arg1, %2  : i64
    %91 = llvm.add %90, %11  : i64
    %92 = llvm.mul %91, %1  : i64
    %93 = llvm.add %89, %92  : i64
    %94 = llvm.alloca %93 x i8 : (i64) -> !llvm.ptr<i8>
    %95 = llvm.bitcast %94 : !llvm.ptr<i8> to !llvm.ptr<ptr<f16>>
    llvm.store %46, %95 : !llvm.ptr<ptr<f16>>
    %96 = llvm.getelementptr %95[%11] : (!llvm.ptr<ptr<f16>>, i64) -> !llvm.ptr<ptr<f16>>
    llvm.store %46, %96 : !llvm.ptr<ptr<f16>>
    %97 = llvm.getelementptr %95[%2] : (!llvm.ptr<ptr<f16>>, i64) -> !llvm.ptr<ptr<f16>>
    %98 = llvm.bitcast %97 : !llvm.ptr<ptr<f16>> to !llvm.ptr<i64>
    llvm.store %10, %98 : !llvm.ptr<i64>
    %99 = llvm.bitcast %94 : !llvm.ptr<i8> to !llvm.ptr<struct<(ptr<f16>, ptr<f16>, i64, i64)>>
    %100 = llvm.getelementptr %99[%10, 3] : (!llvm.ptr<struct<(ptr<f16>, ptr<f16>, i64, i64)>>, i64) -> !llvm.ptr<i64>
    %101 = llvm.getelementptr %100[%arg1] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    %102 = llvm.sub %arg1, %11  : i64
    llvm.br ^bb14(%102, %11 : i64, i64)
  ^bb13:  // pred: ^bb6
    %103 = llvm.mlir.addressof @error_message_2208944672953921889 : !llvm.ptr<array<42 x i8>>
    %104 = llvm.getelementptr %103[%10, %10] : (!llvm.ptr<array<42 x i8>>, i64, i64) -> !llvm.ptr<i8>
    llvm.call @_mlir_ciface_tf_report_error(%arg0, %0, %104) : (!llvm.ptr<i8>, i32, !llvm.ptr<i8>) -> ()
    %105 = llvm.mul %2, %1  : i64
    %106 = llvm.mul %2, %10  : i64
    %107 = llvm.add %106, %11  : i64
    %108 = llvm.mul %107, %1  : i64
    %109 = llvm.add %105, %108  : i64
    %110 = llvm.alloca %109 x i8 : (i64) -> !llvm.ptr<i8>
    %111 = llvm.bitcast %110 : !llvm.ptr<i8> to !llvm.ptr<ptr<f16>>
    llvm.store %13, %111 : !llvm.ptr<ptr<f16>>
    %112 = llvm.getelementptr %111[%11] : (!llvm.ptr<ptr<f16>>, i64) -> !llvm.ptr<ptr<f16>>
    llvm.store %13, %112 : !llvm.ptr<ptr<f16>>
    %113 = llvm.getelementptr %111[%2] : (!llvm.ptr<ptr<f16>>, i64) -> !llvm.ptr<ptr<f16>>
    %114 = llvm.bitcast %113 : !llvm.ptr<ptr<f16>> to !llvm.ptr<i64>
    llvm.store %10, %114 : !llvm.ptr<i64>
    %115 = llvm.call @malloc(%109) : (i64) -> !llvm.ptr<i8>
    "llvm.intr.memcpy"(%115, %110, %109, %6) : (!llvm.ptr<i8>, !llvm.ptr<i8>, i64, i1) -> ()
    %116 = llvm.mlir.undef : !llvm.struct<(i64, ptr<i8>)>
    %117 = llvm.insertvalue %10, %116[0] : !llvm.struct<(i64, ptr<i8>)>
    %118 = llvm.insertvalue %115, %117[1] : !llvm.struct<(i64, ptr<i8>)>
    llvm.return %118 : !llvm.struct<(i64, ptr<i8>)>
  ^bb14(%119: i64, %120: i64):  // 2 preds: ^bb12, ^bb15
    %121 = llvm.icmp "sge" %119, %10 : i64
    llvm.cond_br %121, ^bb15, ^bb16
  ^bb15:  // pred: ^bb14
    %122 = llvm.getelementptr %21[%119] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    %123 = llvm.load %122 : !llvm.ptr<i64>
    %124 = llvm.getelementptr %100[%119] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    llvm.store %123, %124 : !llvm.ptr<i64>
    %125 = llvm.getelementptr %101[%119] : (!llvm.ptr<i64>, i64) -> !llvm.ptr<i64>
    llvm.store %120, %125 : !llvm.ptr<i64>
    %126 = llvm.mul %120, %123  : i64
    %127 = llvm.sub %119, %11  : i64
    llvm.br ^bb14(%127, %126 : i64, i64)
  ^bb16:  // pred: ^bb14
    %128 = llvm.call @malloc(%93) : (i64) -> !llvm.ptr<i8>
    "llvm.intr.memcpy"(%128, %94, %93, %6) : (!llvm.ptr<i8>, !llvm.ptr<i8>, i64, i1) -> ()
    %129 = llvm.mlir.undef : !llvm.struct<(i64, ptr<i8>)>
    %130 = llvm.insertvalue %arg1, %129[0] : !llvm.struct<(i64, ptr<i8>)>
    %131 = llvm.insertvalue %128, %130[1] : !llvm.struct<(i64, ptr<i8>)>
    llvm.return %131 : !llvm.struct<(i64, ptr<i8>)>
  }
  llvm.func @_mlir_ciface_Rsqrt_CPU_DT_HALF_DT_HALF(%arg0: !llvm.ptr<struct<(i64, ptr<i8>)>>, %arg1: !llvm.ptr<i8>, %arg2: !llvm.ptr<struct<(i64, ptr<i8>)>>) attributes {llvm.emit_c_interface, tf_entry} {
    %0 = llvm.load %arg2 : !llvm.ptr<struct<(i64, ptr<i8>)>>
    %1 = llvm.extractvalue %0[0] : !llvm.struct<(i64, ptr<i8>)>
    %2 = llvm.extractvalue %0[1] : !llvm.struct<(i64, ptr<i8>)>
    %3 = llvm.call @Rsqrt_CPU_DT_HALF_DT_HALF(%arg1, %1, %2) : (!llvm.ptr<i8>, i64, !llvm.ptr<i8>) -> !llvm.struct<(i64, ptr<i8>)>
    llvm.store %3, %arg0 : !llvm.ptr<struct<(i64, ptr<i8>)>>
    llvm.return
  }
}

2 years ago[BitcodeReader] Remove unnecessary argument defaults (NFC)
Nikita Popov [Wed, 15 Jun 2022 11:23:32 +0000 (13:23 +0200)]
[BitcodeReader] Remove unnecessary argument defaults (NFC)

This is an internal method that is always called with all arguments.

2 years ago[X86] X86TargetTransformInfo.cpp - use InstructionCost type to accumulate instruction...
Simon Pilgrim [Wed, 15 Jun 2022 11:20:53 +0000 (12:20 +0100)]
[X86] X86TargetTransformInfo.cpp - use InstructionCost type to accumulate instructions costs

2 years ago[AArch64] Add test case from D127354
Simon Pilgrim [Wed, 15 Jun 2022 11:19:34 +0000 (12:19 +0100)]
[AArch64] Add test case from D127354

2 years agoAdd a conversion from double to bf16
Benjamin Kramer [Tue, 7 Jun 2022 11:29:10 +0000 (13:29 +0200)]
Add a conversion from double to bf16

This introduces a new compiler-rt function `__truncdfbf2`.

2 years agoPromote bf16 to f32 when the target doesn't support it
Benjamin Kramer [Fri, 3 Jun 2022 08:47:22 +0000 (10:47 +0200)]
Promote bf16 to f32 when the target doesn't support it

This is modeled after the half-precision fp support. Two new nodes are
introduced for casting from and to bf16. Since casting from bf16 is a
simple operation I opted to always directly lower it to integer
arithmetic. The other way round is more complicated if you want to
preserve IEEE semantics, so it's handled by a new __truncsfbf2
compiler-rt builtin.

This is of course very bare bones, but sufficient to get a semi-softened
fadd on x86.

Possible future improvements:
 - Targets with bf16 conversion instructions can now make fp_to_bf16 legal
 - The software conversion to bf16 can be replaced by a trivial
   implementation under fast math.

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

2 years agoFix signed/unsigned comparison warning
Simon Pilgrim [Wed, 15 Jun 2022 10:53:00 +0000 (11:53 +0100)]
Fix signed/unsigned comparison warning

2 years ago[DebugInfo][ARM] Not readonly check for RWPI globals
Keith Walker [Tue, 24 May 2022 14:54:58 +0000 (15:54 +0100)]
[DebugInfo][ARM] Not readonly check for RWPI globals

When compiling for the RWPI relocation model [1], the debug information
is wrong for readonly global variables.

Writable global variables are accessed by the static base register (R9
on ARM) in the RWPI relocation model.  This is being correctly generated

Readonly global variables are not accessed by the static base register
in the RWPI relocation model. This case is incorrectly generating the
same debugging information as for writable global variables.

References:
[1] ARM Read-Write Position Independence: https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#read-write-position-independence-rwpi

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

2 years ago[Sema] Remove unused function after 8c7b64b5ae2a
Benjamin Kramer [Wed, 15 Jun 2022 10:20:44 +0000 (12:20 +0200)]
[Sema] Remove unused function after 8c7b64b5ae2a

2 years ago[X86][SLP] Basic test coverage for llvm.powi
Nabeel Omer [Wed, 15 Jun 2022 09:52:37 +0000 (10:52 +0100)]
[X86][SLP] Basic test coverage for llvm.powi

This patch introduces basic test coverage for llvm.powi.* intrinsics.

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

2 years ago[NFC] Move tests CodeGen/AArch64/SME/sme-* -> CodeGen/AArch64/sme-*
David Sherwood [Wed, 15 Jun 2022 10:09:12 +0000 (11:09 +0100)]
[NFC] Move tests CodeGen/AArch64/SME/sme-* -> CodeGen/AArch64/sme-*

2 years ago[DAG] Fix SDLoc mismatch in (shl (srl x, c1), c2) -> and(shift(x,c3)) fold
Simon Pilgrim [Wed, 15 Jun 2022 10:07:48 +0000 (11:07 +0100)]
[DAG] Fix SDLoc mismatch in (shl (srl x, c1), c2) -> and(shift(x,c3)) fold

Noticed by @craig.topper on D125836 which uses a tweaked copy of the same code.

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

2 years ago[clang][dataflow] Add support for correlated branches to optional model
Stanislav Gatev [Wed, 18 May 2022 21:57:40 +0000 (21:57 +0000)]
[clang][dataflow] Add support for correlated branches to optional model

Add support for correlated branches to the std::optional dataflow model.

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

Reviewed-by: ymandel, xazax.hun
2 years ago[clang] Reject non-declaration C++11 attributes on declarations
Martin Boehme [Wed, 15 Jun 2022 06:07:23 +0000 (08:07 +0200)]
[clang] Reject non-declaration C++11 attributes on declarations

For backwards compatiblity, we emit only a warning instead of an error if the
attribute is one of the existing type attributes that we have historically
allowed to "slide" to the `DeclSpec` just as if it had been specified in GNU
syntax. (We will call these "legacy type attributes" below.)

The high-level changes that achieve this are:

- We introduce a new field `Declarator::DeclarationAttrs` (with appropriate
  accessors) to store C++11 attributes occurring in the attribute-specifier-seq
  at the beginning of a simple-declaration (and other similar declarations).
  Previously, these attributes were placed on the `DeclSpec`, which made it
  impossible to reconstruct later on whether the attributes had in fact been
  placed on the decl-specifier-seq or ahead of the declaration.

- In the parser, we propgate declaration attributes and decl-specifier-seq
  attributes separately until we can place them in
  `Declarator::DeclarationAttrs` or `DeclSpec::Attrs`, respectively.

- In `ProcessDeclAttributes()`, in addition to processing declarator attributes,
  we now also process the attributes from `Declarator::DeclarationAttrs` (except
  if they are legacy type attributes).

- In `ConvertDeclSpecToType()`, in addition to processing `DeclSpec` attributes,
  we also process any legacy type attributes that occur in
  `Declarator::DeclarationAttrs` (and emit a warning).

- We make `ProcessDeclAttribute` emit an error if it sees any non-declaration
  attributes in C++11 syntax, except in the following cases:
  - If it is being called for attributes on a `DeclSpec` or `DeclaratorChunk`
  - If the attribute is a legacy type attribute (in which case we only emit
    a warning)

The standard justifies treating attributes at the beginning of a
simple-declaration and attributes after a declarator-id the same. Here are some
relevant parts of the standard:

- The attribute-specifier-seq at the beginning of a simple-declaration
  "appertains to each of the entities declared by the declarators of the
  init-declarator-list" (https://eel.is/c++draft/dcl.dcl#dcl.pre-3)

- "In the declaration for an entity, attributes appertaining to that entity can
  appear at the start of the declaration and after the declarator-id for that
  declaration." (https://eel.is/c++draft/dcl.dcl#dcl.pre-note-2)

- "The optional attribute-specifier-seq following a declarator-id appertains to
  the entity that is declared."
  (https://eel.is/c++draft/dcl.dcl#dcl.meaning.general-1)

The standard contains similar wording to that for a simple-declaration in other
similar types of declarations, for example:

- "The optional attribute-specifier-seq in a parameter-declaration appertains to
  the parameter." (https://eel.is/c++draft/dcl.fct#3)

- "The optional attribute-specifier-seq in an exception-declaration appertains
  to the parameter of the catch clause" (https://eel.is/c++draft/except.pre#1)

The new behavior is tested both on the newly added type attribute
`annotate_type`, for which we emit errors, and for the legacy type attribute
`address_space` (chosen somewhat randomly from the various legacy type
attributes), for which we emit warnings.

Depends On D111548

Reviewed By: aaron.ballman, rsmith

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

2 years ago[OpenCL] Reword unknown extension pragma diagnostic
Sven van Haastregt [Wed, 15 Jun 2022 09:54:46 +0000 (10:54 +0100)]
[OpenCL] Reword unknown extension pragma diagnostic

For newer OpenCL extensions that do not require a pragma, such as
`cl_khr_subgroup_shuffle`, a user could still accidentally attempt to
use a pragma.  This would result in a warning
  "unknown OpenCL extension 'cl_khr_subgroup_shuffle' - ignoring"
which could be mistakenly interpreted as "clang does not support this
extension at all" instead of "clang does not require any pragma for
this extension".

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

2 years ago[X86] needCarryOrOverflowFlag/onlyZeroFlagUsed - merge identical switch cases. NFCI.
Simon Pilgrim [Wed, 15 Jun 2022 09:40:13 +0000 (10:40 +0100)]
[X86] needCarryOrOverflowFlag/onlyZeroFlagUsed - merge identical switch cases. NFCI.

Makes it easier to grok and fixes various bugprone-branch-clone warnings.

2 years ago[AArch64][SME] Add SME read/write intrinsics that map to the mova instruction
David Sherwood [Thu, 9 Jun 2022 08:01:49 +0000 (09:01 +0100)]
[AArch64][SME] Add SME read/write intrinsics that map to the mova instruction

This patch adds implementations for the read/write SME ACLE intrinsics:

  @llvm.aarch64.sme.read.horiz
  @llvm.aarch64.sme.read.vert
  @llvm.aarch64.sme.write.horiz
  @llvm.aarch64.sme.write.vert

These all map to the SME mova instruction.

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

2 years ago[Clang] Documentation-only: Add missing closing `>` in AttrDocs.td
Martin Boehme [Wed, 15 Jun 2022 08:59:07 +0000 (10:59 +0200)]
[Clang] Documentation-only: Add missing closing `>` in AttrDocs.td

2 years ago[libcxx] Fix allocator<void>::pointer in C++20 with removed members
Ilya Biryukov [Wed, 15 Jun 2022 08:55:55 +0000 (10:55 +0200)]
[libcxx] Fix allocator<void>::pointer in C++20 with removed members

When compiled with `-D_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS`
uses of `allocator<void>::pointer` resulted in compiler errors after D104323.
If we instantiate the primary template, `allocator<void>::reference` produces
an error 'cannot form references to void'.

To workaround this, allow to bring back the `allocator<void>` specialization by defining the new `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_VOID_SPECIALIZATION` macro.

To make sure the code that uses `allocator<void>` and the removed members does not break,
both `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS` and `_LIBCPP_ENABLE_CXX20_REMOVED_ALLOCATOR_MEMBERS` have to be defined.

Reviewed By: ldionne, #libc, philnik

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

2 years ago[Clang] Fix signed-unsigned comparison warning that breaks the ppc64 build.
Martin Boehme [Wed, 15 Jun 2022 08:38:10 +0000 (10:38 +0200)]
[Clang] Fix signed-unsigned comparison warning that breaks the ppc64 build.

2 years ago[NFC][AArch64] Minor refactor of AArch64InstPrinter::printMatrixTileList
David Sherwood [Tue, 14 Jun 2022 15:27:18 +0000 (16:27 +0100)]
[NFC][AArch64] Minor refactor of AArch64InstPrinter::printMatrixTileList

We can remove the MatrixZADRegisterTable table of tile registers and
just calculate the register index directly.

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

2 years ago[clangd] Enable AKA type printing by default
Kadir Cetinkaya [Wed, 15 Jun 2022 08:04:48 +0000 (10:04 +0200)]
[clangd] Enable AKA type printing by default

This has been tested on a large set of c++ developers for a long while,
without any crashes or complaints.

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

2 years ago[libcxx] Remove extraneous '---' lines in .clang-format files
owenca [Wed, 15 Jun 2022 08:29:51 +0000 (01:29 -0700)]
[libcxx] Remove extraneous '---' lines in .clang-format files

2 years ago[mlir][Arith] Fix a use-after-free after rewriting ops to unsigned
Benjamin Kramer [Wed, 15 Jun 2022 08:27:19 +0000 (10:27 +0200)]
[mlir][Arith] Fix a use-after-free after rewriting ops to unsigned

Just short-circuit when a change was made, the erased value is invalid
after that. Found by asan.

This pass looks like it could use rewrite patterns instead which don't
have this issue, but let's fix the asan build first.

2 years ago[RISCV] Fixing undefined physical register issue when subreg liveness tracking enabled.
Kito Cheng [Thu, 9 Jun 2022 15:25:18 +0000 (23:25 +0800)]
[RISCV] Fixing undefined physical register issue when subreg liveness tracking enabled.

RISC-V expand register tuple spilling into series of register spilling after
register allocation phase by the pseudo instruction expansion, however part of
register tuple might be still undefined during spilling, machine verifier will
complain the spill instruction is using an undefined physical register.

Optimal solution should be doing liveness analysis and do not emit spill
and reload for those undefined parts, but accurate liveness info at that point
is not so easy to get.

So the suboptimal solution is still spill and reload those undefined parts, but
adding implicit-use of super register to spill function, then machine
verifier will only report report using undefined physical register if
the when whole super register is undefined, and this behavior are also
documented in MachineVerifier::checkLiveness[1].

Example for demo what happend:

```
  v10m2 = xxx
  # v12m2 not define yet
  PseudoVSPILL2_M2 v10m2_v12m2
  ...
```

After expansion:
```
  v10m2 = xxx
  # v12m2 not define yet
  # Expand PseudoVSPILL2_M2 v10m2_v12m2 to 2 vs2r
  VS2R_V v10m2
  VS2R_V v12m2 # Use undef reg!
```

What this patch did:
```
  v10m2 = xxx
  # v12m2 not define yet
  # Expand PseudoVSPILL2_M2 v10m2_v12m2 to 2 vs2r
  VS2R_V v10m2 implicit v10m2_v12m2
  # Use undef reg (v12m2), but v10m2_v12m2 ins't totally undef, so
  # that's OK.
  VS2R_V v12m2 implicit v10m2_v12m2
```

[1] https://github.com/llvm-mirror/llvm/blob/master/lib/CodeGen/MachineVerifier.cpp#L2016-L2019

Reviewed By: craig.topper

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

2 years ago[mlir][bufferize] Better implementation of AnalysisState::isTensorYielded
Matthias Springer [Wed, 15 Jun 2022 08:15:09 +0000 (10:15 +0200)]
[mlir][bufferize] Better implementation of AnalysisState::isTensorYielded

If `create-deallocs=0`, mark all bufferization.alloc_tensor ops as escaping. (Unless they already have an `escape` attribute.) In the absence of analysis information, check SSA use-def chains to see if the value may be yielded.

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

2 years ago[libc][Obvious] Removed few unused vars.
Siva Chandra Reddy [Wed, 15 Jun 2022 08:09:12 +0000 (08:09 +0000)]
[libc][Obvious] Removed few unused vars.

2 years ago[mlir][bufferize][NFC] Merge AlwaysCopyAnalysisState into AnalysisState
Matthias Springer [Wed, 15 Jun 2022 08:06:55 +0000 (10:06 +0200)]
[mlir][bufferize][NFC] Merge AlwaysCopyAnalysisState into AnalysisState

`AnalysisState` now has default implementations of all virtual functions.

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

2 years ago[InstCombine] Improve check for catchswitch BBs (NFC)
Heejin Ahn [Tue, 14 Jun 2022 23:41:17 +0000 (16:41 -0700)]
[InstCombine] Improve check for catchswitch BBs (NFC)

Reviewed By: nikic

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

2 years ago[mlir][bufferize][NFC] Make func BufferizableOpInterface impl compatible with One...
Matthias Springer [Wed, 15 Jun 2022 07:58:56 +0000 (09:58 +0200)]
[mlir][bufferize][NFC] Make func BufferizableOpInterface impl compatible with One-Shot Bufferize

Bufferization of the func dialect must go through `OneShotModuleBufferize`. With this change, the analysis interface methods of the BufferizableOpInterface of func dialect ops can be used together with the normal `OneShotBufferize`. (In the absence of analysis information, they will return conservative results.)

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

2 years ago[flang][OpenMP] Add one semantic check for data-sharing clauses
Peixin-Qiao [Wed, 15 Jun 2022 08:02:27 +0000 (16:02 +0800)]
[flang][OpenMP] Add one semantic check for data-sharing clauses

As OpenMP 5.0, for firstprivate, lastprivate, copyin, and copyprivate
clauses, if the list item is a polymorphic variable with the allocatable
attribute, the behavior is unspecified.

Reviewed By: kiranchandramohan

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

2 years ago[mlir][linalg][bufferize] Remove always-aliasing-with-dest option
Matthias Springer [Wed, 15 Jun 2022 07:09:07 +0000 (09:09 +0200)]
[mlir][linalg][bufferize] Remove always-aliasing-with-dest option

This flag was introduced for a use case in IREE, but it is no longer needed.

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

2 years ago[Clang] Add the `annotate_type` attribute
Martin Boehme [Wed, 15 Jun 2022 06:08:10 +0000 (08:08 +0200)]
[Clang] Add the `annotate_type` attribute

This is an analog to the `annotate` attribute but for types. The intent is to allow adding arbitrary annotations to types for use in static analysis tools.

For details, see this RFC:

https://discourse.llvm.org/t/rfc-new-attribute-annotate-type-iteration-2/61378

Reviewed By: aaron.ballman

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

2 years ago[flang] Change C889 from error into warning
Peixin-Qiao [Wed, 15 Jun 2022 07:39:13 +0000 (15:39 +0800)]
[flang] Change C889 from error into warning

This constraint is used in OMP2012 benchmark, and other compilers do not
enforce it. Change it into one warning. This addresses the issue
https://github.com/llvm/llvm-project/issues/56003.

Reviewed By: klausler, kiranchandramohan

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

2 years ago[SimplifyLibCalls] Drop duplicate check (NFC)
Nikita Popov [Wed, 15 Jun 2022 07:36:39 +0000 (09:36 +0200)]
[SimplifyLibCalls] Drop duplicate check (NFC)

The same condition already exists inside optimizeMemCmpConstantSize().

2 years ago[AMDGPU] Fix buildbot failures after 48ebc1af29
Austin Kerbow [Wed, 15 Jun 2022 07:23:30 +0000 (00:23 -0700)]
[AMDGPU] Fix buildbot failures after 48ebc1af29

Some buildbots (lto, windows) were failing due to some function reference
variables being improperly initialized.

2 years ago[libc] Add linux threads targets only if __support/OSUtil targets are available.
Siva Chandra Reddy [Wed, 15 Jun 2022 07:11:57 +0000 (07:11 +0000)]
[libc] Add linux threads targets only if __support/OSUtil targets are available.

2 years ago[libFuzzer] Use the compiler to link the relocatable object
Petr Hosek [Wed, 15 Jun 2022 06:53:18 +0000 (06:53 +0000)]
[libFuzzer] Use the compiler to link the relocatable object

Rather than invoking the linker directly, let the compiler driver
handle it. This ensures that we use the correct linker in the case
of cross-compiling.

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

2 years ago[mlir][SCF][bufferize] Implement `resolveConflicts` for SCF ops
Matthias Springer [Wed, 15 Jun 2022 07:00:44 +0000 (09:00 +0200)]
[mlir][SCF][bufferize] Implement `resolveConflicts` for SCF ops

scf::ForOp and scf::WhileOp must insert buffer copies not only for out-of-place bufferizations, but also to enforce additional invariants wrt. to buffer aliasing behavior. This is currently happening in the respective `bufferize` methods. With this change, the tensor copy insertion pass will also enforce these invariants by inserting copies. The `bufferize` methods can then be simplified and made independent of the `AnalysisState` data structure in a subsequent change.

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

2 years ago[mlir] Add missing newline at end of .clang-format file
owenca [Wed, 15 Jun 2022 06:57:08 +0000 (23:57 -0700)]
[mlir] Add missing newline at end of .clang-format file

2 years ago[LSR] Add test for LoopStrenghtReduce for Ldp; NFC
chenglin.bi [Wed, 15 Jun 2022 06:51:15 +0000 (14:51 +0800)]
[LSR] Add test for LoopStrenghtReduce for Ldp; NFC
#53877

2 years ago[libc][NFC] Add src.__support.OSUtil targets conditionally.
Siva Chandra Reddy [Wed, 15 Jun 2022 06:32:06 +0000 (06:32 +0000)]
[libc][NFC] Add src.__support.OSUtil targets conditionally.

Before this change, they were unconditionally added, irrespective of the
availability of the architecture specific pieces.

2 years ago[clangd] Wire up compilation for style blocks
Kadir Cetinkaya [Tue, 14 Jun 2022 15:08:37 +0000 (17:08 +0200)]
[clangd] Wire up compilation for style blocks

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

2 years ago[RISCV] Teach vsetvli insertion to not insert redundant vsetvli right after VLEFF...
Yeting Kuo [Sat, 11 Jun 2022 16:46:30 +0000 (00:46 +0800)]
[RISCV] Teach vsetvli insertion to not insert redundant vsetvli right after VLEFF/VLSEGFF.

VSETVLIInfos right after VLEFF/VLSEGFF are currently unknown since they modify
VL. Unknown VSETVLIInfos make next vector operations needed to be inserted
VSET(I)VLI. Actually the next vector operation of VLEFF/VLSEGFF may not need to
be inserted VSET(I)VLI if it uses same VTYPE and the resulted vl of
VLEFF/VLSEGFF.

Take the below C code as an example,

  vint8m4_t vec_src1 = vle8ff_v_i8m4(str1, &new_vl, vl);
  vbool2_t mask1 = vmseq_vx_i8m4_b2(vec_src1, 0, new_vl);
  vsetvli insertion adds a redundant vsetvli for that,

Assembly result:
  vsetvli a2,a2,e8,m4,ta,mu
  vle8ff.v v28,(a0)
  csrr a3,vl ; redundant
  vsetvli zero,a3,e8,m4,ta,mu ; redundant
  vmseq.vi v25,v28,0

After D126794, VLEFF/VLSEGFF has a define having value of VL. The patch consider
there is a ghost vsetvli right after VLEFF/VLSEGFF. The ghost VSET(I)LIs use the
vl output of the VLEFF/VLSEGFF as its AVL and same VTYPE of the VLEFF/VLSEGFF.
The ghost vsetvli must be redundant, and we could use it to get the VSETVLIInfo
right after VLEFF/VLSEGFF.

Reviewed By: reames

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

2 years ago[SelectionDAG] fold 'Op0 - (X * MulC)' to 'Op0 + (X << log2(-MulC))'
Ping Deng [Wed, 15 Jun 2022 05:43:26 +0000 (05:43 +0000)]
[SelectionDAG] fold 'Op0 - (X * MulC)' to 'Op0 + (X << log2(-MulC))'

Reviewed By: craig.topper, spatel

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

2 years ago[libc][NFC] Use uint32_t to represent futex words.
Siva Chandra Reddy [Wed, 15 Jun 2022 05:38:38 +0000 (05:38 +0000)]
[libc][NFC] Use uint32_t to represent futex words.

Futexes are 32 bits in size on all platforms, including 64-bit systems.

2 years ago[clang-format] Never analyze insert/remove braces in the same pass
owenca [Mon, 13 Jun 2022 19:15:31 +0000 (12:15 -0700)]
[clang-format] Never analyze insert/remove braces in the same pass

Turn off RemoveBracesLLVM while analyzing InsertBraces and vice
versa to avoid potential interference of each other and better the
performance.

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

2 years ago[gn build] Port 48ebc1af2948
LLVM GN Syncbot [Wed, 15 Jun 2022 05:24:12 +0000 (05:24 +0000)]
[gn build] Port 48ebc1af2948

2 years ago[AMDGPU] Add more expressive sched_barrier controls
Austin Kerbow [Fri, 3 Jun 2022 18:35:47 +0000 (11:35 -0700)]
[AMDGPU] Add more expressive sched_barrier controls

The sched_barrier builtin allow the scheduler's behavior to be shaped by users
when very specific codegen is needed in order to create highly optimized code.
This patch adds more granular control over the types of instructions that are
allowed to be reordered with respect to one or multiple sched_barriers. A mask
is used to specify groups of instructions that should be allowed to be scheduled
around a sched_barrier. The details about this mask may be used can be found in
llvm/include/llvm/IR/IntrinsicsAMDGPU.td.

Reviewed By: rampitec

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

2 years ago[AMDGPU] Add isMFMA helper function. NFC
Austin Kerbow [Sun, 22 May 2022 21:54:50 +0000 (14:54 -0700)]
[AMDGPU] Add isMFMA helper function. NFC

Reviewed By: rampitec

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

2 years ago[MC] Remove unused MCStreamer::SwitchSection
Fangrui Song [Wed, 15 Jun 2022 04:25:56 +0000 (21:25 -0700)]
[MC] Remove unused MCStreamer::SwitchSection

switchSection should be used instead.

2 years ago[ORC-RT] Add integration tests for AArch64
Peter S. Housel [Tue, 14 Jun 2022 06:36:56 +0000 (23:36 -0700)]
[ORC-RT] Add integration tests for AArch64

This change adds test cases targeting the AArch64 Linux platform to
the ORC runtime integration test suite.

Reviewed By: lhames, sunho

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

2 years ago[RISCV][NFC] Add more tests for instruction selection of 'mul'
Ping Deng [Wed, 15 Jun 2022 03:28:44 +0000 (03:28 +0000)]
[RISCV][NFC] Add more tests for instruction selection of 'mul'

precommit tests for D127474

Reviewed By: craig.topper

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

2 years ago[libc++][NFCI] span: replace enable_if with concepts
Joe Loser [Wed, 15 Jun 2022 03:25:50 +0000 (21:25 -0600)]
[libc++][NFCI] span: replace enable_if with concepts

Several span constructors use `enable_if` which is verbose. Replace these with
concepts or requires expressions.

2 years ago[LLDB] CommandObjectThreadUntil::DoExecute() sets the wrong selected thread ID
Venkata Ramanaiah Nalamothu [Wed, 15 Jun 2022 02:34:32 +0000 (08:04 +0530)]
[LLDB] CommandObjectThreadUntil::DoExecute() sets the wrong selected thread ID

For the 'thread until' command, the selected thread ID, to perform the operation on, could be of the current thread or the specified thread.

Reviewed By: jingham

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

2 years ago[mlir][spirv] Handle corner cases for math.powf conversion
Lei Zhang [Wed, 15 Jun 2022 03:00:18 +0000 (23:00 -0400)]
[mlir][spirv] Handle corner cases for math.powf conversion

Per GLSL Pow extended instruction spec: "Result is undefined if
x < 0. Result is undefined if x = 0 and y <= 0." So we need to
handle negative `x` values specifically.

Reviewed By: ThomasRaoux

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

2 years ago[RISCV][NFC] Set default value for BaseInstr in RISCVVPseudo
wangpc [Wed, 15 Jun 2022 02:59:00 +0000 (10:59 +0800)]
[RISCV][NFC] Set default value for BaseInstr in RISCVVPseudo

Since almost all pseudos have the same form of BaseInstr, we
can just set it as default value to reduce some lines.

Reviewed By: craig.topper

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

2 years ago[Driver] Improve linking options for target AVR
Ben Shi [Wed, 15 Jun 2022 01:09:37 +0000 (01:09 +0000)]
[Driver] Improve linking options for target AVR

1. Support user specified linker (-fuse-ld)
2. Support user specified linker script (-T)

Reviewed By: MaskRay, haowei

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

2 years ago[X86][NFC] Use mnemonic tables in validateInstruction 4/4
Amir Ayupov [Wed, 15 Jun 2022 02:53:28 +0000 (19:53 -0700)]
[X86][NFC] Use mnemonic tables in validateInstruction 4/4

Group switch cases by opcode:
- VGATHERDPD
- VGATHERDPS
- VGATHERQPD
- VGATHERQPS
- VPGATHERDD
- VPGATHERDQ
- VPGATHERQD
- VPGATHERQQ

Distinguish masked vs non-masked forms by EVEX encoding.

Reviewed By: skan, craig.topper

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

2 years ago[mlir][Vector] Fold consecutive bitcast.
jacquesguan [Tue, 14 Jun 2022 07:37:47 +0000 (15:37 +0800)]
[mlir][Vector] Fold consecutive bitcast.

This patch supports to fold consecutive bitcast into one bitcast.

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

2 years ago[mlir][affine] Make loop tiling default options explicit
lewuathe [Wed, 15 Jun 2022 02:27:55 +0000 (11:27 +0900)]
[mlir][affine] Make loop tiling default options explicit

Make default loop tiling options explicit from CLI options. We can also set default value for separate option which is declared implicitly.

Reviewed By: ayzhuang

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

2 years ago[RISCV] Replace uses of VLOpFrag in VLMax patterns with srcvalue.
Craig Topper [Wed, 15 Jun 2022 00:57:35 +0000 (17:57 -0700)]
[RISCV] Replace uses of VLOpFrag in VLMax patterns with srcvalue.

These are on inner nodes and we're dropping the captured $vl anyway.

2 years ago[Libomptarget] Use binutils archive executable to address failing tests
Joseph Huber [Wed, 15 Jun 2022 02:12:41 +0000 (22:12 -0400)]
[Libomptarget] Use binutils archive executable to address failing tests

Summary:
The static linking test ensures that we can statically link offloading
programs. To create the test we used `llvm-ar`. However, this may not
exist in the user's environment. This patch changes it to use the
binutils `ar` which should exist on every system running these tests
currently. In the future we should set up the dependencies properly.

2 years ago[HIP] fix long double size
Yaxun (Sam) Liu [Tue, 14 Jun 2022 16:40:37 +0000 (12:40 -0400)]
[HIP] fix long double size

For amdgpu target long double type is the same as double type.
The width and align of long double type was incorrectly
overridden when copying aux target properties, which
caused assertion in codegen when emitting global
variables with long double type.

This patch fix that by saving and restoring width
and align of long double type.

Reviewed by: Artem Belevich

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

Fixes: SWDEV-335515

2 years ago[CSKY] Fix the assert in eliminateFrameIndex when the offset is negative
Zi Xuan Wu (Zeson) [Wed, 15 Jun 2022 01:36:26 +0000 (09:36 +0800)]
[CSKY] Fix the assert in eliminateFrameIndex when the offset is negative

After the frameindex is resolved, the offset can be negative. It would
be materialized as unsigned integer and can still calculated by add instruction.

2 years ago[X86][AMX] Fix klockwork issue.
Luo, Yuanke [Wed, 15 Jun 2022 01:22:20 +0000 (09:22 +0800)]
[X86][AMX] Fix klockwork issue.

2 years agoReland "[X86][RFC] Enable `_Float16` type support on X86 following the psABI"
Phoebe Wang [Wed, 15 Jun 2022 00:26:04 +0000 (08:26 +0800)]
Reland "[X86][RFC] Enable `_Float16` type support on X86 following the psABI"

Disabled 2 mlir tests due to the runtime doesn't support `_Float16`, see
the issue here https://github.com/llvm/llvm-project/issues/55992

2 years agoRevert "[Driver] Improve linking options for target AVR"
Haowei Wu [Wed, 15 Jun 2022 00:53:46 +0000 (17:53 -0700)]
Revert "[Driver] Improve linking options for target AVR"

This reverts commit 3b6e166999bb83197c8b70468c2d371c58cf0c25 which
causes Clang Driver test failures on Fuchsia builders.

2 years ago[gn build] Port 435897b41d60
LLVM GN Syncbot [Wed, 15 Jun 2022 00:32:13 +0000 (00:32 +0000)]
[gn build] Port 435897b41d60

2 years ago[TableGen][DirectX] Add tableGen backend to generate DXIL operation for DirectX backend.
python3kgae [Wed, 11 May 2022 23:56:38 +0000 (16:56 -0700)]
[TableGen][DirectX] Add tableGen backend to generate DXIL operation for DirectX backend.

A new tableGen backend gen-dxil-enum is added to generate enum for DXIL operation and operation class.

A new file "DXILConstants.inc" will be generated when build DirectX target which include the enums.

More tableGen backends will be added to replace manually written table in DirectX backend.
The unused fields in dxil_inst will be used in future PR.

Reviewed By: bogner

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

2 years ago[mlir][spirv] Fix math.ctlz for full zero bit cases
Lei Zhang [Tue, 14 Jun 2022 23:39:20 +0000 (19:39 -0400)]
[mlir][spirv] Fix math.ctlz for full zero bit cases

If the integer has all zero bits, GLSL FindUMsb would return -1.
So theoretically (31 - FindUMsb) should still give use the correct
result.  However, Adreno GPUshave issues with this:
https://buildkite.com/iree/iree-test-android/builds/6482#01815f05-3926-466f-822a-1e20299e5461
This looks like a driver bug. So handle the corner case explicity
to workaround it.

Reviewed By: mravishankar

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

2 years ago[RISCV] Minor code/comment improvement in prepass of InsertVSETVLI [nfc]
Philip Reames [Tue, 14 Jun 2022 23:15:26 +0000 (16:15 -0700)]
[RISCV] Minor code/comment improvement in prepass of InsertVSETVLI [nfc]

2 years ago[dsymutil] Fix std::unique_ptr to llvm::Expected conversion
Jonas Devlieghere [Tue, 14 Jun 2022 23:09:39 +0000 (16:09 -0700)]
[dsymutil] Fix std::unique_ptr to llvm::Expected conversion

Fixes error: could not convert from
'std::unique_ptr<llvm::dsymutil::Reproducer>' to
'llvm::Expected<std::unique_ptr<llvm::dsymutil::Reproducer>>'

2 years ago[dsymutil] Automatically generate a reproducer when dsymutil crashes
Jonas Devlieghere [Tue, 14 Jun 2022 16:22:46 +0000 (09:22 -0700)]
[dsymutil] Automatically generate a reproducer when dsymutil crashes

Automatically generate a reproducer when dsymutil crashes. We already
support generating reproducers with the --gen-reproducer flag, which
emits a reproducer on exit. This patch adds support for doing the same
on a crash and makes it the default behavior.

rdar://68357665

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

2 years ago[clang][dataflow] Rename `getPointeeLoc` to `getReferentLoc` for ReferenceValue.
Wei Yi Tee [Tue, 14 Jun 2022 22:41:49 +0000 (00:41 +0200)]
[clang][dataflow] Rename `getPointeeLoc` to `getReferentLoc` for ReferenceValue.

We distinguish between the referent location for `ReferenceValue` and pointee location for `PointerValue`. The former must be non-empty but the latter may be empty in the case of a `nullptr`

Reviewed By: gribozavr2, sgatev

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

2 years ago[PS5] Default to 'sce' debugger tuning
Paul Robinson [Tue, 14 Jun 2022 22:26:35 +0000 (15:26 -0700)]
[PS5] Default to 'sce' debugger tuning

2 years agoFunctionPropertiesAnalysis: handle callsite BBs that lose edges
Mircea Trofin [Wed, 8 Jun 2022 21:58:21 +0000 (14:58 -0700)]
FunctionPropertiesAnalysis: handle callsite BBs that lose edges

There could be successors that were reached before but now are only
reachable from elsewhere in the CFG.

Suppose the following diamond CFG (lines are arrows pointing down):
    A
  /   \
 B     C
  \   /
    D
There's a call site in C that is inlined. Upon doing that, it turns out
it expands to:
   call void @llvm.trap()
   unreachable
D isn't reachable from C anymore, but we did discount it when we set up
FunctionPropertiesUpdater, so we need to re-include it here.

The patch also updates loop accounting to use LoopInfo rather than
traverse BBs.

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

2 years ago[llvm] Add DW_CC_nocall to function debug metadata when either return values or argum...
Venkata Ramanaiah Nalamothu [Mon, 6 Jun 2022 15:37:09 +0000 (21:07 +0530)]
[llvm] Add DW_CC_nocall to function debug metadata when either return values or arguments are removed

Adding the `DW_CC_nocall` calling convention to the function debug metadata is needed when either the return values or the arguments of a function are removed as this helps in informing debugger that it may not be safe to call this function or try to interpret the return value.
This translates to setting `DW_AT_calling_convention` with `DW_CC_nocall` for appropriate DWARF DIEs.

The DWARF5 spec (section 3.3.1.1 Calling Convention Information) says:

If the `DW_AT_calling_convention` attribute is not present, or its value is the constant `DW_CC_normal`, then the subroutine may be safely called by obeying the `standard` calling conventions of the target architecture. If the value of the calling convention attribute is the constant `DW_CC_nocall`, the subroutine does not obey standard calling conventions, and it may not be safe for the debugger to call this subroutine.

Reviewed By: dblaikie

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

2 years ago[mlir] Try to work around ambiguity in older clang versions
Benjamin Kramer [Tue, 14 Jun 2022 21:57:57 +0000 (23:57 +0200)]
[mlir] Try to work around ambiguity in older clang versions

mlir/lib/Dialect/Arithmetic/IR/InferIntRangeInterfaceImpls.cpp:366:10: error: chosen constructor is explicit in copy-initialization
  return {leftVal, rightVal};
         ^~~~~~~~~~~~~~~~~~~

2 years ago[bazel] Port b0b00432093b
Benjamin Kramer [Tue, 14 Jun 2022 21:55:50 +0000 (23:55 +0200)]
[bazel] Port b0b00432093b

2 years ago[bazel] Port 75bfc6f29579
Benjamin Kramer [Tue, 14 Jun 2022 21:45:52 +0000 (23:45 +0200)]
[bazel] Port 75bfc6f29579

2 years agoRISCV: handle 64-bit PCREL data relocations
Saleem Abdulrasool [Fri, 10 Jun 2022 22:54:17 +0000 (22:54 +0000)]
RISCV: handle 64-bit PCREL data relocations

We would previously fail to handle 64-bit PC-relative relocations on
RISCV.  This was exposed by trying to build with
`-fprofile-instr-generate`.

The original changes restricted the relocation handling to the text
segment as the paired relocations are undesirable in at least the debug
and .eh_frame sections.  We now make this explicit to handle the general
case for the data relocations as well.

It would be preferable to use `R_RISCV_n_PCREL` when available to avoid
an extra relocation.

Differential Revision: https://reviews.llvm.org/D127549
Reviewed By: luismarques, MaskRay

Fixes: #55971

2 years ago(Reland)[mlir] Add a generic data-flow analysis framework
Mogball [Mon, 13 Jun 2022 21:54:52 +0000 (21:54 +0000)]
(Reland)[mlir] Add a generic data-flow analysis framework

Removes one element of the pointer union to make it work on 32-bit
systems.

This patch introduces a generic data-flow analysis framework to MLIR. The framework implements a fixed-point iteration algorithm and a dependency graph between lattice states and analysis. Lattice states and points are fully extensible to support highly-customizable analyses.

Reviewed By: phisiart, rriddle

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

2 years ago[mlir][Arith] Pass to switch signed ops for equivalent unsigned ones
Krzysztof Drewniak [Thu, 14 Apr 2022 22:51:23 +0000 (22:51 +0000)]
[mlir][Arith] Pass to switch signed ops for equivalent unsigned ones

If all the arguments to and results of an operation are known to be
non-negative when interpreted as signed (which also implies that all
computations producing those values did not experience signed
overflow), we can replace that operation with an equivalent one that
operates on unsigned values.

Such a replacement, when it is possible, can provide useful hints to
backends, such as by allowing LLVM to replace remainder with bitwise
operations in more cases.

Depends on D124022

Depends on D124023

Reviewed By: Mogball

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

2 years ago[clang] Add tests for statement expression in initializers
Anders Waldenborg [Tue, 7 Jun 2022 10:21:42 +0000 (12:21 +0200)]
[clang] Add tests for statement expression in initializers

The commit 683e83c5
  [Clang][C++2b] P2242R3: Non-literal variables [...] in constexpr
fixed a code generation bug when using (C-extension) statement
expressions inside initializer expressions.

Before that commit a nested static initializer inside the statement
expression would not be emitted, causing it to be zero initialized.

It is a bit surprising (at least to me) that a commit implementing a new
C++ feature would fix this code generation bug. Zooming in it is the
change done in ExprConstant.cpp that helps. That changes so that
"ESR_Failed" is returned in more cases, causing the expression to not be
deemed constant. This fixes the code generation as instead the compiler
has to resort to generating a dynamic initializer.

That commit also meant that some statement expressions (in particular
the ones using static variables) that previously were accepted now are
errors due to not being constant (matching GCC behavior).

Given how a seemingly unrelated change caused this behavior to change,
it is probably a good thing to add at least some rudimentary tests for
these kind expressions.

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

2 years agoRevert "[mlir] Add a generic data-flow analysis framework"
Frederik Gossen [Tue, 14 Jun 2022 21:12:52 +0000 (17:12 -0400)]
Revert "[mlir] Add a generic data-flow analysis framework"

This reverts commit 9dea11728340e54e1fde76320b61a559148c8a3e.
The PointerUnion assumes 3 available bits, which is not the case on 32-bit
machines.

2 years ago[flang] Add failed_images to list of intrinsics and add test
Katherine Rasmussen [Sat, 14 May 2022 04:50:36 +0000 (21:50 -0700)]
[flang] Add failed_images to list of intrinsics and add test

Add failed_images to the list of intrinsic functions. Add a
semantics test for failed_images.

Reviewed By: jeanPerier

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

2 years agoRevert "[mlir] add an option to print op stats in JSON"
Okwan Kwon [Tue, 14 Jun 2022 21:06:54 +0000 (14:06 -0700)]
Revert "[mlir] add an option to print op stats in JSON"

There is a failure from the python pass manager.

This reverts commit 1a19abf38c3afb66b680cea69c8e61ea152e1514.

2 years ago[RISCV] Split out transfer function explicitly in VSETVLI insertion dataflow [nfc]
Philip Reames [Tue, 14 Jun 2022 21:01:29 +0000 (14:01 -0700)]
[RISCV] Split out transfer function explicitly in VSETVLI insertion dataflow [nfc]

In an effort to make this code easier to read and extend, this splits out helper functions for the transfer function of the data flow. Due to the other results computed during the phases, we can't completely abstract away everything, but we can abstract the actual state transitions.

The motivation here is the following upcoming changes:
* The fault first load patch - already approved, this will be rebased over - adds another case into the transferAfter path.
* An upcoming patch to fold the local prepass back into the main algorithm greatly complicates the transferBefore logic.

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