platform/upstream/llvm.git
2 years ago[TableGen][DirectX] Add tableGen backend to generate map from llvm intrinsic to DXIL...
Xiang Li [Wed, 15 Jun 2022 03:46:37 +0000 (20:46 -0700)]
[TableGen][DirectX] Add tableGen backend to generate map from llvm intrinsic to DXIL operation.

A new tableGen backend gen-dxil-intrinsic-map is added to generate map from llvm intrinsic to DXIL operation.

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

The generated map will replace the manually created map when find DXIL operation from llvm intrinsic.

Reviewed By: bogner

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

2 years agoPass through even more LIBCXX_* variables to libfuzzer's custom lib++
Colin Cross [Thu, 16 Jun 2022 02:05:28 +0000 (19:05 -0700)]
Pass through even more LIBCXX_* variables to libfuzzer's custom lib++

Similar to D120946, pass LIBCXX_HAS_GCC_S_LIB and LIBCXX_USE_COMPILER_RT
through to the custom lib++ builds so that libfuzzer doesn't end up with
a .deplibs section that links against those libraries when the
variables are set to false.

Reviewed By: phosek

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

2 years ago[Clang][Modules] Merge availability attributes on imported decls
Michael Spencer [Thu, 16 Jun 2022 00:45:51 +0000 (17:45 -0700)]
[Clang][Modules] Merge availability attributes on imported decls

Currently we do not in general merge attributes when importing decls from modules. This patch handles availability, but long term we need to properly handle all attributes.

I tried to use Sema::mergeDeclAttributes, but it caused test crashes as I don't think it expects to be called in this context. We really shouldn't have duplicate code for merging attributes long term, but for now this fixes availability. There's already a TODO for this in the declaration of ASTDeclReader::mergeInheritableAttributes.

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

rdar://85820301

2 years ago[mlir][spirv] Define spv.ISubBorrowOp
Lei Zhang [Thu, 16 Jun 2022 00:38:47 +0000 (20:38 -0400)]
[mlir][spirv] Define spv.ISubBorrowOp

Reviewed By: ThomasRaoux

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

2 years ago[flang][runtime] Catch more (all?) negative unit number errors
Peter Klausler [Sat, 11 Jun 2022 01:08:14 +0000 (18:08 -0700)]
[flang][runtime] Catch more (all?) negative unit number errors

Fortran does have negative unit numbers -- they show up in child I/O
subroutines for defined I/O and for OPEN(NEWUNIT=) -- but the runtime
needs to catch the cases where a negative unit number that wasn't
generated by the runtime is passed in for OPEN or for an I/O statement
that would ordinarily create an anonymous "fort.NNN" file for a
hitherto unseen unit.

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

2 years agoRevert "[ASan] Use debuginfo for symbolization."
Kirill Stoimenov [Wed, 15 Jun 2022 23:41:16 +0000 (23:41 +0000)]
Revert "[ASan] Use debuginfo for symbolization."

This reverts commit f0ab8d90d47c4b1e0ea73e655777b4bc35e3f609.

2 years ago[gn build] Allow use_ubsan=true on mac and unbreak use_asan, use_tsan, use_ubsan
Nico Weber [Wed, 15 Jun 2022 21:45:10 +0000 (17:45 -0400)]
[gn build] Allow use_ubsan=true on mac and unbreak use_asan, use_tsan, use_ubsan

`use_ubsan=true` seems to Just Work on macOS, so allow it.

https://reviews.llvm.org/D122862 broke use_asan=true, use_tsan=true, and
use_ubsan=true builds on Linux too. This makes this go again by explicitly
disabling asan, tsan, and ubsan for the baremetal part of the build. See
discussion on https://reviews.llvm.org/D122862 for other possible approaches.

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

2 years ago[gn build] Slighly nicer `gn args --list` output for is_debug and symbol_level
Nico Weber [Wed, 15 Jun 2022 23:24:32 +0000 (19:24 -0400)]
[gn build] Slighly nicer `gn args --list` output for is_debug and symbol_level

2 years agoReland "[lld-macho] Group undefined symbol diagnostics by symbol".
Daniel Bertalan [Wed, 15 Jun 2022 23:17:07 +0000 (19:17 -0400)]
Reland "[lld-macho] Group undefined symbol diagnostics by symbol".

This reverts commit 36e7c9a450db5e22af1ec21412d918ceb2313942.

This relands d61341768cf0cff7c with the fix described in
https://reviews.llvm.org/D127753#3587390

2 years ago[CMake] Fix `FindGRPC.cmake` for setting up gRPC related libraries for macOS+homebrew...
Argyrios Kyrtzidis [Wed, 15 Jun 2022 18:24:13 +0000 (11:24 -0700)]
[CMake] Fix `FindGRPC.cmake` for setting up gRPC related libraries for macOS+homebrew context

* Switch `$GRPC_OPTS` references to `${GRPC_OPTS}`
* Use `target_include_directories()` to add include search paths only for the targets the depend on `gRPC`
* Also find and include the search path for `abseil` headers (`gRPC` headers include them)
* Only setup the gRPC related targets once, so that `include(FindGRPC)` can be called from multiple tools

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

2 years ago[lldb] Skip ScriptInterpreter/Python/exit.test on Windows
Jonas Devlieghere [Wed, 15 Jun 2022 22:49:25 +0000 (15:49 -0700)]
[lldb] Skip ScriptInterpreter/Python/exit.test on Windows

2 years agoRevert "[lld-macho] Group undefined symbol diagnostics by symbol"
Stella Stamenova [Wed, 15 Jun 2022 22:42:26 +0000 (15:42 -0700)]
Revert "[lld-macho] Group undefined symbol diagnostics by symbol"

This reverts commit d61341768cf0cff7ceeaddecc2f769b5c1b901c4.

This change broke multiple lld tests, including some sanitizer builds: https://lab.llvm.org/buildbot/#/builders/5/builds/24787/steps/19/logs/stdio

2 years ago[ASan] Use debuginfo for symbolization.
Mitch Phillips [Fri, 10 Jun 2022 23:26:45 +0000 (16:26 -0700)]
[ASan] Use debuginfo for symbolization.

Hint: Looking here because your manual invocation of something in
'check-asan' broke? You need a new symbolizer (after D123538).

An upcoming patch will remove the internal metadata for global
variables. With D123534 and D123538, clang now emits DWARF debug info
for constant strings (the only global variable type it was missing), and
llvm-symbolizer is now able to symbolize all global variable addresses
(where previously it wouldn't give you the file:line information).

Move ASan's runtime over from the internal metadata to DWARF.

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

2 years ago[flang] Fix error message
Peter Klausler [Fri, 10 Jun 2022 16:48:42 +0000 (09:48 -0700)]
[flang] Fix error message

A message has a %s string substitution in it but somebody (probably me)
forgot to pass the argument that defines it.

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

2 years ago[lld-macho] Add support for exporting no symbols
Keith Smiley [Sat, 11 Jun 2022 06:34:54 +0000 (23:34 -0700)]
[lld-macho] Add support for exporting no symbols

As an optimization for ld64 sometimes it can be useful to not export any
symbols for top level binaries that don't need any exports, to do this
you can pass `-exported_symbols_list /dev/null`, or new with Xcode 14
(ld64 816) there is a `-no_exported_symbols` flag for the same behavior.
This reproduces this behavior where previously an empty exported symbols
list file would have been ignored.

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

2 years agoRevert "Reland "Reland "[X86][RFC] Enable `_Float16` type support on X86 following...
Frederik Gossen [Wed, 15 Jun 2022 22:04:42 +0000 (18:04 -0400)]
Revert "Reland "Reland "[X86][RFC] Enable `_Float16` type support on X86 following the psABI"""

This reverts commit e1c5afa47d37012499467b5061fc42e50884d129.

This introduces crashes in the JAX backend on CPU. A reproducer in LLVM is
below. Let me know if you have trouble reproducing this.

; ModuleID = '__compute_module'
source_filename = "__compute_module"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-grtev4-linux-gnu"

@0 = private unnamed_addr constant [4 x i8] c"\00\00\00?"
@1 = private unnamed_addr constant [4 x i8] c"\1C}\908"
@2 = private unnamed_addr constant [4 x i8] c"?\00\\4"
@3 = private unnamed_addr constant [4 x i8] c"%ci1"
@4 = private unnamed_addr constant [4 x i8] zeroinitializer
@5 = private unnamed_addr constant [4 x i8] c"\00\00\00\C0"
@6 = private unnamed_addr constant [4 x i8] c"\00\00\00B"
@7 = private unnamed_addr constant [4 x i8] c"\94\B4\C22"
@8 = private unnamed_addr constant [4 x i8] c"^\09B6"
@9 = private unnamed_addr constant [4 x i8] c"\15\F3M?"
@10 = private unnamed_addr constant [4 x i8] c"e\CC\\;"
@11 = private unnamed_addr constant [4 x i8] c"d\BD/>"
@12 = private unnamed_addr constant [4 x i8] c"V\F4I="
@13 = private unnamed_addr constant [4 x i8] c"\10\CB,<"
@14 = private unnamed_addr constant [4 x i8] c"\AC\E3\D6:"
@15 = private unnamed_addr constant [4 x i8] c"\DC\A8E9"
@16 = private unnamed_addr constant [4 x i8] c"\C6\FA\897"
@17 = private unnamed_addr constant [4 x i8] c"%\F9\955"
@18 = private unnamed_addr constant [4 x i8] c"\B5\DB\813"
@19 = private unnamed_addr constant [4 x i8] c"\B4W_\B2"
@20 = private unnamed_addr constant [4 x i8] c"\1Cc\8F\B4"
@21 = private unnamed_addr constant [4 x i8] c"~3\94\B6"
@22 = private unnamed_addr constant [4 x i8] c"3Yq\B8"
@23 = private unnamed_addr constant [4 x i8] c"\E9\17\17\BA"
@24 = private unnamed_addr constant [4 x i8] c"\F1\B2\8D\BB"
@25 = private unnamed_addr constant [4 x i8] c"\F8t\C2\BC"
@26 = private unnamed_addr constant [4 x i8] c"\82[\C2\BD"
@27 = private unnamed_addr constant [4 x i8] c"uB-?"
@28 = private unnamed_addr constant [4 x i8] c"^\FF\9B\BE"
@29 = private unnamed_addr constant [4 x i8] c"\00\00\00A"

; Function Attrs: uwtable
define void @main.158(ptr %retval, ptr noalias %run_options, ptr noalias %params, ptr noalias %buffer_table, ptr noalias %status, ptr noalias %prof_counters) #0 {
entry:
  %fusion.invar_address.dim.1 = alloca i64, align 8
  %fusion.invar_address.dim.0 = alloca i64, align 8
  %0 = getelementptr inbounds ptr, ptr %buffer_table, i64 1
  %Arg_0.1 = load ptr, ptr %0, align 8, !invariant.load !0, !dereferenceable !1, !align !2
  %1 = getelementptr inbounds ptr, ptr %buffer_table, i64 0
  %fusion = load ptr, ptr %1, align 8, !invariant.load !0, !dereferenceable !1, !align !2
  store i64 0, ptr %fusion.invar_address.dim.0, align 8
  br label %fusion.loop_header.dim.0

return:                                           ; preds = %fusion.loop_exit.dim.0
  ret void

fusion.loop_header.dim.0:                         ; preds = %fusion.loop_exit.dim.1, %entry
  %fusion.indvar.dim.0 = load i64, ptr %fusion.invar_address.dim.0, align 8
  %2 = icmp uge i64 %fusion.indvar.dim.0, 3
  br i1 %2, label %fusion.loop_exit.dim.0, label %fusion.loop_body.dim.0

fusion.loop_body.dim.0:                           ; preds = %fusion.loop_header.dim.0
  store i64 0, ptr %fusion.invar_address.dim.1, align 8
  br label %fusion.loop_header.dim.1

fusion.loop_header.dim.1:                         ; preds = %fusion.loop_body.dim.1, %fusion.loop_body.dim.0
  %fusion.indvar.dim.1 = load i64, ptr %fusion.invar_address.dim.1, align 8
  %3 = icmp uge i64 %fusion.indvar.dim.1, 1
  br i1 %3, label %fusion.loop_exit.dim.1, label %fusion.loop_body.dim.1

fusion.loop_body.dim.1:                           ; preds = %fusion.loop_header.dim.1
  %4 = getelementptr inbounds [3 x [1 x half]], ptr %Arg_0.1, i64 0, i64 %fusion.indvar.dim.0, i64 0
  %5 = load half, ptr %4, align 2, !invariant.load !0, !noalias !3
  %6 = fpext half %5 to float
  %7 = call float @llvm.fabs.f32(float %6)
  %constant.121 = load float, ptr @29, align 4
  %compare.2 = fcmp ole float %7, %constant.121
  %8 = zext i1 %compare.2 to i8
  %constant.120 = load float, ptr @0, align 4
  %multiply.95 = fmul float %7, %constant.120
  %constant.119 = load float, ptr @5, align 4
  %add.82 = fadd float %multiply.95, %constant.119
  %constant.118 = load float, ptr @4, align 4
  %multiply.94 = fmul float %add.82, %constant.118
  %constant.117 = load float, ptr @19, align 4
  %add.81 = fadd float %multiply.94, %constant.117
  %multiply.92 = fmul float %add.82, %add.81
  %constant.116 = load float, ptr @18, align 4
  %add.79 = fadd float %multiply.92, %constant.116
  %multiply.91 = fmul float %add.82, %add.79
  %subtract.87 = fsub float %multiply.91, %add.81
  %constant.115 = load float, ptr @20, align 4
  %add.78 = fadd float %subtract.87, %constant.115
  %multiply.89 = fmul float %add.82, %add.78
  %subtract.86 = fsub float %multiply.89, %add.79
  %constant.114 = load float, ptr @17, align 4
  %add.76 = fadd float %subtract.86, %constant.114
  %multiply.88 = fmul float %add.82, %add.76
  %subtract.84 = fsub float %multiply.88, %add.78
  %constant.113 = load float, ptr @21, align 4
  %add.75 = fadd float %subtract.84, %constant.113
  %multiply.86 = fmul float %add.82, %add.75
  %subtract.83 = fsub float %multiply.86, %add.76
  %constant.112 = load float, ptr @16, align 4
  %add.73 = fadd float %subtract.83, %constant.112
  %multiply.85 = fmul float %add.82, %add.73
  %subtract.81 = fsub float %multiply.85, %add.75
  %constant.111 = load float, ptr @22, align 4
  %add.72 = fadd float %subtract.81, %constant.111
  %multiply.83 = fmul float %add.82, %add.72
  %subtract.80 = fsub float %multiply.83, %add.73
  %constant.110 = load float, ptr @15, align 4
  %add.70 = fadd float %subtract.80, %constant.110
  %multiply.82 = fmul float %add.82, %add.70
  %subtract.78 = fsub float %multiply.82, %add.72
  %constant.109 = load float, ptr @23, align 4
  %add.69 = fadd float %subtract.78, %constant.109
  %multiply.80 = fmul float %add.82, %add.69
  %subtract.77 = fsub float %multiply.80, %add.70
  %constant.108 = load float, ptr @14, align 4
  %add.68 = fadd float %subtract.77, %constant.108
  %multiply.79 = fmul float %add.82, %add.68
  %subtract.75 = fsub float %multiply.79, %add.69
  %constant.107 = load float, ptr @24, align 4
  %add.67 = fadd float %subtract.75, %constant.107
  %multiply.77 = fmul float %add.82, %add.67
  %subtract.74 = fsub float %multiply.77, %add.68
  %constant.106 = load float, ptr @13, align 4
  %add.66 = fadd float %subtract.74, %constant.106
  %multiply.76 = fmul float %add.82, %add.66
  %subtract.72 = fsub float %multiply.76, %add.67
  %constant.105 = load float, ptr @25, align 4
  %add.65 = fadd float %subtract.72, %constant.105
  %multiply.74 = fmul float %add.82, %add.65
  %subtract.71 = fsub float %multiply.74, %add.66
  %constant.104 = load float, ptr @12, align 4
  %add.64 = fadd float %subtract.71, %constant.104
  %multiply.73 = fmul float %add.82, %add.64
  %subtract.69 = fsub float %multiply.73, %add.65
  %constant.103 = load float, ptr @26, align 4
  %add.63 = fadd float %subtract.69, %constant.103
  %multiply.71 = fmul float %add.82, %add.63
  %subtract.67 = fsub float %multiply.71, %add.64
  %constant.102 = load float, ptr @11, align 4
  %add.62 = fadd float %subtract.67, %constant.102
  %multiply.70 = fmul float %add.82, %add.62
  %subtract.66 = fsub float %multiply.70, %add.63
  %constant.101 = load float, ptr @28, align 4
  %add.61 = fadd float %subtract.66, %constant.101
  %multiply.68 = fmul float %add.82, %add.61
  %subtract.65 = fsub float %multiply.68, %add.62
  %constant.100 = load float, ptr @27, align 4
  %add.60 = fadd float %subtract.65, %constant.100
  %subtract.64 = fsub float %add.60, %add.62
  %multiply.66 = fmul float %subtract.64, %constant.120
  %constant.99 = load float, ptr @6, align 4
  %divide.4 = fdiv float %constant.99, %7
  %add.59 = fadd float %divide.4, %constant.119
  %multiply.65 = fmul float %add.59, %constant.118
  %constant.98 = load float, ptr @3, align 4
  %add.58 = fadd float %multiply.65, %constant.98
  %multiply.64 = fmul float %add.59, %add.58
  %constant.97 = load float, ptr @7, align 4
  %add.57 = fadd float %multiply.64, %constant.97
  %multiply.63 = fmul float %add.59, %add.57
  %subtract.63 = fsub float %multiply.63, %add.58
  %constant.96 = load float, ptr @2, align 4
  %add.56 = fadd float %subtract.63, %constant.96
  %multiply.62 = fmul float %add.59, %add.56
  %subtract.62 = fsub float %multiply.62, %add.57
  %constant.95 = load float, ptr @8, align 4
  %add.55 = fadd float %subtract.62, %constant.95
  %multiply.61 = fmul float %add.59, %add.55
  %subtract.61 = fsub float %multiply.61, %add.56
  %constant.94 = load float, ptr @1, align 4
  %add.54 = fadd float %subtract.61, %constant.94
  %multiply.60 = fmul float %add.59, %add.54
  %subtract.60 = fsub float %multiply.60, %add.55
  %constant.93 = load float, ptr @10, align 4
  %add.53 = fadd float %subtract.60, %constant.93
  %multiply.59 = fmul float %add.59, %add.53
  %subtract.59 = fsub float %multiply.59, %add.54
  %constant.92 = load float, ptr @9, align 4
  %add.52 = fadd float %subtract.59, %constant.92
  %subtract.58 = fsub float %add.52, %add.54
  %multiply.58 = fmul float %subtract.58, %constant.120
  %9 = call float @llvm.sqrt.f32(float %7)
  %10 = fdiv float 1.000000e+00, %9
  %multiply.57 = fmul float %multiply.58, %10
  %11 = trunc i8 %8 to i1
  %12 = select i1 %11, float %multiply.66, float %multiply.57
  %13 = fptrunc float %12 to half
  %14 = getelementptr inbounds [3 x [1 x half]], ptr %fusion, i64 0, i64 %fusion.indvar.dim.0, i64 0
  store half %13, ptr %14, align 2, !alias.scope !3
  %invar.inc1 = add nuw nsw i64 %fusion.indvar.dim.1, 1
  store i64 %invar.inc1, ptr %fusion.invar_address.dim.1, align 8
  br label %fusion.loop_header.dim.1

fusion.loop_exit.dim.1:                           ; preds = %fusion.loop_header.dim.1
  %invar.inc = add nuw nsw i64 %fusion.indvar.dim.0, 1
  store i64 %invar.inc, ptr %fusion.invar_address.dim.0, align 8
  br label %fusion.loop_header.dim.0

fusion.loop_exit.dim.0:                           ; preds = %fusion.loop_header.dim.0
  br label %return
}

; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare float @llvm.fabs.f32(float %0) #1

; Function Attrs: nocallback nofree nosync nounwind readnone speculatable willreturn
declare float @llvm.sqrt.f32(float %0) #1

attributes #0 = { uwtable "denormal-fp-math"="preserve-sign" "no-frame-pointer-elim"="false" }
attributes #1 = { nocallback nofree nosync nounwind readnone speculatable willreturn }

!0 = !{}
!1 = !{i64 6}
!2 = !{i64 8}
!3 = !{!4}
!4 = !{!"buffer: {index:0, offset:0, size:6}", !5}
!5 = !{!"XLA global AA domain"}

2 years ago[gn build] Port afd5a4f2dcd6
LLVM GN Syncbot [Wed, 15 Jun 2022 21:57:03 +0000 (21:57 +0000)]
[gn build] Port afd5a4f2dcd6

2 years ago[flang][docs] Document non-supported VMS extensions
Peter Klausler [Sun, 12 Jun 2022 16:28:57 +0000 (09:28 -0700)]
[flang][docs] Document non-supported VMS extensions

The prescanner does not support VMS Fortran listing control directives
(%LIST, %NOLIST, %EJECT) or continuation lines on INCLUDE lines.

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

2 years ago[lldb] Don't overwrite quit and exit builtins in the Python interpreter
Jonas Devlieghere [Wed, 15 Jun 2022 21:47:41 +0000 (14:47 -0700)]
[lldb] Don't overwrite quit and exit builtins in the Python interpreter

The interactive interpreter is overwriting the exit and quit builtins
with an instance of LLDBQuitter in order to make exit and quit behave
like exit() and quit(). It does that by overwriting the __repr__
function to call itself.

Despite being a neat trick, it has the unintentional side effect that
printing these builtins now quits the interpreter:

  (lldb) script
  Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
  >>> print(exit)
  (lldb)

You might consider the above example slightly convoluted, but a more
realistic situation is calling locals():

  (lldb) script
  Python Interactive Interpreter. To exit, type 'quit()', 'exit()' or Ctrl-D.
  >>> locals()
  (lldb)

This patch keeps the existing behavior but without overwriting the
builtins. Instead, it looks for quit and exit in the input. If they're
present, we exit the interpreter with the help of an exception.

The previous implementation also used globals to differentiate between
exit getting called from the interactive interpreter or from inside a
script. This patch achieves the same by using a different exception in
for the interpreter case.

rdar://84095490

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

2 years ago[mlir] create PrintOpStatsPass using printAsJSON
Okwan Kwon [Wed, 15 Jun 2022 21:42:32 +0000 (14:42 -0700)]
[mlir] create PrintOpStatsPass using printAsJSON

This was missed by the previous commit in OpStats.cpp.

2 years ago[flang][runtime] Better error message for mis-ASSIGN'ed FORMAT
Peter Klausler [Sat, 11 Jun 2022 14:09:20 +0000 (07:09 -0700)]
[flang][runtime] Better error message for mis-ASSIGN'ed FORMAT

When an I/O data transfer statement uses an ASSIGN'ed FORMAT that
has not been ASSIGN'ed to a FORMAT statement, the runtime receives
a zero-length format string.  Distinguish this case from the general
error message about missing parentheses.

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

2 years agounbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV=OFF after 45d88cd00846
Nico Weber [Wed, 15 Jun 2022 21:42:32 +0000 (17:42 -0400)]
unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV=OFF after 45d88cd00846

See revision b8b7a9dcdcbc for prior art.

2 years ago[flang] ERROR STOP is not an image control statement
Peter Klausler [Sun, 12 Jun 2022 17:16:46 +0000 (10:16 -0700)]
[flang] ERROR STOP is not an image control statement

The predicate that determines image control statements needs
to distinguish STOP (which is) from ERROR STOP (which isn't).

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

2 years agoReland "[lldb/Fuzzer] Create ninja target for target fuzzer"
Chelsea Cassanova [Wed, 15 Jun 2022 21:29:08 +0000 (17:29 -0400)]
Reland "[lldb/Fuzzer] Create ninja target for target fuzzer"

This reverts commit b10579d0b519571fa7487399d82e1e809fbfe6cb.

Make sure that the lldb-target-fuzzer exists before adding the
custom fuzz-lldb-target.

2 years ago[mlir][LLVMIR] Ask ICmpOp to return vector<Nxi1> when needed
Min-Yih Hsu [Fri, 20 May 2022 16:34:01 +0000 (09:34 -0700)]
[mlir][LLVMIR] Ask ICmpOp to return vector<Nxi1> when needed

If any of the operands for ICmpOp is a vector, returns a vector<Nxi1>
, rather than an i1 type result.

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

2 years ago[mlir][LLVMIR] Use isScalableVectorType in ShuffleVectorOp::parse
Min-Yih Hsu [Mon, 23 May 2022 20:30:32 +0000 (13:30 -0700)]
[mlir][LLVMIR] Use isScalableVectorType in ShuffleVectorOp::parse

Instead of casting the incoming operand into VectorType to check if it's
scalable or not.
This is the place I missed to fix in f088b99eac74.

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

2 years ago[mlir][LLVMIR] Use insertelement if needed when translating ConstantAggregate
Min-Yih Hsu [Thu, 19 May 2022 18:58:26 +0000 (11:58 -0700)]
[mlir][LLVMIR] Use insertelement if needed when translating ConstantAggregate

When translating from a llvm::ConstantAggregate with vector type, we
should lower to insertelement operations (if needed) rather than using
insertvalue.

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

2 years ago[flang][runtime] Make NCOPIES= argument of REPEAT a signed integer, & check it
Peter Klausler [Sat, 11 Jun 2022 13:45:56 +0000 (06:45 -0700)]
[flang][runtime] Make NCOPIES= argument of REPEAT a signed integer, & check it

NCOPIES= is currently a std::size_t in the API.  If a negative value is
used, the memory allocation will fail.  Change it to be a signed integer,
and crash with a message instead if it be negative.

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

2 years ago[flang][runtime] Fix handling of output FORMAT('x' 'y')
Peter Klausler [Sun, 12 Jun 2022 16:54:45 +0000 (09:54 -0700)]
[flang][runtime] Fix handling of output FORMAT('x' 'y')

I'm emitting "x'y" because the space-separated apostrophes are
misinterpreted as being adjacent repeated quotation marks.
Fix to ensure no space skipping is applied when checking for
repeated quotation marks.

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

2 years ago[flang] Add more qualification when creating names for compiler-generated USEs
Peter Klausler [Sat, 11 Jun 2022 15:39:38 +0000 (08:39 -0700)]
[flang] Add more qualification when creating names for compiler-generated USEs

When generic resolution finds its specific procedure in a module,
and that specific procedure is not use-associated into the local scope
(perhaps because it was PRIVATE, perhaps because the generic was
use-associated with ONLY:), we create a new use-association with
a renaming.  The name constructed for this renaming needs to be
additionally qualified with the module name of the specific procedure
in order to avoid clashing with another specific of the same name
that may have previously been use-associated in the same way from
a distinct module.

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

2 years ago[flang][runtime] Fix INQUIRE(POS=n) for non-advancing I/O
Peter Klausler [Sat, 11 Jun 2022 13:34:58 +0000 (06:34 -0700)]
[flang][runtime] Fix INQUIRE(POS=n) for non-advancing I/O

Position inquiries need to account for offsets in records to be
accurate in the case of non-advancing I/O.

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

2 years ago[flang][runtime] Signal END from character input
Peter Klausler [Fri, 10 Jun 2022 16:33:44 +0000 (09:33 -0700)]
[flang][runtime] Signal END from character input

There's code in EditCharacterInput() that causes that template function
to silently return false if it is invoked at the end of the input file.
This overrides other checks that properly call SignalEnd() later.

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

2 years ago[clang][WebAssembly] Loosen restriction on `main` symbol mangling
Sam Clegg [Wed, 15 Jun 2022 18:30:13 +0000 (11:30 -0700)]
[clang][WebAssembly] Loosen restriction on `main` symbol mangling

Remove the `hasPrototype()` restriction so that old style K&R
declarations of main work too.

For example the following has 2 params but no prototype.

```
int main(argc, argv)
    int argc;
    char *argv[];
{
  return 0;
}
```

Also, use `getNumParams()` over `param_size()` which seems to be a more
direct way to get at the same information.

Also, add missing tests for this mangling.

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

2 years agoFix failures
Walter Erquinigo [Wed, 15 Jun 2022 20:43:33 +0000 (13:43 -0700)]
Fix failures

https://lab.llvm.org/buildbot/#/builders/17/builds/23269 breaks because
we are doing some asm calls that only work on x86

https://lab.llvm.org/buildbot/#/builders/68/builds/34092/steps/6/logs/stdio
breaks because some comparators where being done incorrectly.

2 years ago[flang][runtime] Fix REWIND after non-advancing data transfer
Peter Klausler [Thu, 9 Jun 2022 22:30:38 +0000 (15:30 -0700)]
[flang][runtime] Fix REWIND after non-advancing data transfer

A REWIND of a unit that's in the middle of a record due to a READ
or WRITE statement with ADVANCE='NO' needs to reset the left tab
limit so that the next transfer takes place at the beginning of
the first record.

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

2 years ago[Driver] Simplify -fno-builtin- handling. NFC
Fangrui Song [Wed, 15 Jun 2022 20:35:08 +0000 (13:35 -0700)]
[Driver] Simplify -fno-builtin- handling. NFC

2 years ago[clang][deps] Further canonicalize implicit modules options in dep scan
Ben Langmuir [Wed, 15 Jun 2022 17:56:11 +0000 (10:56 -0700)]
[clang][deps] Further canonicalize implicit modules options in dep scan

Disable or canonicalize compiler options that are not relevant in
explicit module builds, similar to what we already did for the modules
cache path. This reduces uninteresting differences between
command-lines, which is particularly useful if there is a tool that can
cache the compilations.

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

2 years ago[libc++] Implement ranges::lexicographical_compare
Nikolas Klauser [Wed, 15 Jun 2022 14:24:43 +0000 (16:24 +0200)]
[libc++] Implement ranges::lexicographical_compare

Reviewed By: var-const, Mordante, #libc

Spies: H-G-Hristov, sstefan1, libcxx-commits, mgorny

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

2 years ago[trace][intelpt] Support system-wide tracing [12] - Support multi-core trace load...
Walter Erquinigo [Thu, 19 May 2022 04:36:34 +0000 (21:36 -0700)]
[trace][intelpt] Support system-wide tracing [12] - Support multi-core trace load and save

:q!
This diff is massive, but it's because it connects the client with lldb-server
and also ensures that the postmortem case works.

- Flatten the postmortem trace schema. The reason is that the schema has become quite complex due to the new multicore case, which defeats the original purpose of having a schema that could work for every trace plug-in. At this point, it's better that each trace plug-in defines it's own full schema. This means that the only common field is "type".
-- Because of this new approach, I merged the "common" trace load and saving functionalities into the IntelPT one. This simplified the code quite a bit. If we eventually implement another trace plug-in, we can see then what we could reuse.
-- The new schema, which is flattened, has now better comments and is parsed better. A change I did was to disallow hex addresses, because they are a bit error prone. I'm asking now to print the address in decimal.
-- Renamed "intel" to "GenuineIntel" in the schema because that's what you see in /proc/cpuinfo.
- Implemented reading the context switch trace data buffer. I had to do
some refactors to do that cleanly.
-- A major change that I did here was to simplify the perf_event circular buffer reading logic. It was too complex. Maybe the original Intel author had something different in mind.
- Implemented all the necessary bits to read trace.json files with per-core data.
- Implemented all the necessary bits to save to disk per-core trace session.
- Added a test that ensures that parsing and saving to disk works.

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

2 years ago[gn build] Add missing BLAKE3 dependency
Arthur Eubanks [Wed, 15 Jun 2022 20:13:39 +0000 (13:13 -0700)]
[gn build] Add missing BLAKE3 dependency

2 years ago[flang][runtime] Allow recovery from BACKSPACE(badUnit)
Peter Klausler [Thu, 9 Jun 2022 21:31:03 +0000 (14:31 -0700)]
[flang][runtime] Allow recovery from BACKSPACE(badUnit)

When an unconnected unit number is used in a BACKSPACE statement
with ERR=, IOSTAT=, &/or IOMSG= control specifiers, don't crash,
but let the program deal with the error.

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

2 years ago[clang-format][NFC] Fix braces in ClangFormat.cpp
owenca [Wed, 15 Jun 2022 19:16:28 +0000 (12:16 -0700)]
[clang-format][NFC] Fix braces in ClangFormat.cpp

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

2 years agoRevert "[lldb/Fuzzer] Create ninja target for target fuzzer"
Stella Stamenova [Wed, 15 Jun 2022 19:38:02 +0000 (12:38 -0700)]
Revert "[lldb/Fuzzer] Create ninja target for target fuzzer"

This reverts commit f3250da1b94fed260ea5da8264ba366c42aaf34c.

This broke the windows lldb bot: https://lab.llvm.org/buildbot/#/builders/83/builds/19988 and likely others.

2 years agoRolling back tests for WG14 DR145
Aaron Ballman [Wed, 15 Jun 2022 19:37:14 +0000 (15:37 -0400)]
Rolling back tests for WG14 DR145

Several build bots are failing with surprising behavior, so it's less
clear whether we do or don't implement this DR properly.

https://lab.llvm.org/buildbot/#/builders/91/builds/10454
https://lab.llvm.org/buildbot/#/builders/109/builds/40668
https://lab.llvm.org/buildbot/#/builders/139/builds/23334

2 years agoUpdate the status of more C DRs
Aaron Ballman [Wed, 15 Jun 2022 19:24:50 +0000 (15:24 -0400)]
Update the status of more C DRs

This adds information for DRs 126 through 146.

2 years ago[PowerPC] Skip combine for vector_shuffles when two scalar_to_vector nodes are differ...
Amy Kwan [Wed, 15 Jun 2022 17:25:45 +0000 (12:25 -0500)]
[PowerPC] Skip combine for vector_shuffles when two scalar_to_vector nodes are different vector types.

Currently in `combineVectorShuffle()`, we update the shuffle mask if either
input vector comes from a scalar_to_vector, and we keep the respective input
vectors in its permuted form by producing PPCISD::SCALAR_TO_VECTOR_PERMUTED.
However, it is possible that we end up in a situation where both input vectors
to the vector_shuffle are scalar_to_vector, and are different vector types.
In situations like this, the shuffle mask is updated incorrectly as the current
code assumes both scalar_to_vector inputs are the same vector type.

This patch skips the combines for vector_shuffle if both input vectors are
scalar_to_vector, and if they are of different vector types. A follow up patch
will focus on fixing this issue afterwards, in order to correctly update the
shuffle mask.

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

2 years ago[mlir] add createPrintOpStatsPass() with explicit params
Okwan Kwon [Wed, 15 Jun 2022 18:48:57 +0000 (11:48 -0700)]
[mlir] add createPrintOpStatsPass() with explicit params

This allows to set printAsJSON through the create function.

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

2 years ago[trace][intelpt] Support system-wide tracing [11] - Read warnings and perf conversion...
Walter Erquinigo [Thu, 19 May 2022 02:10:09 +0000 (19:10 -0700)]
[trace][intelpt] Support system-wide tracing [11] - Read warnings and perf conversion in the client

- Add logging for when the live state of the process is refreshed
- Move error handling of the live state refreshing to Trace from TraceIntelPT. This allows refreshing to fail either at the plug-in level or at the base class level. The error is cached and it can be gotten every time RefreshLiveProcessState is invoked.
- Allow DoRefreshLiveProcessState to handle plugin-specific parameters.
- Add some encapsulation to prevent TraceIntelPT from accessing variables belonging to Trace.

Test done via logging:

```
(lldb) b main
Breakpoint 1: where = a.out`main + 20 at main.cpp:27:20, address = 0x00000000004023d9
(lldb) r
Process 2359706 launched: '/home/wallace/a.out' (x86_64)
Process 2359706 stopped
* thread #1, name = 'a.out', stop reason = breakpoint 1.1
    frame #0: 0x00000000004023d9 a.out`main at main.cpp:27:20
   24   };
   25
   26   int main() {
-> 27     std::vector<int> vvv;
   28     for (int i = 0; i < 100000; i++)
   29       vvv.push_back(i);
   30
(lldb) process trace start                                                                                        (lldb) log enable lldb target -F(lldb) n
Process 2359706 stopped
* thread #1, name = 'a.out', stop reason = step over
    frame #0: 0x00000000004023e8 a.out`main at main.cpp:28:12
   25
   26   int main() {
   27     std::vector<int> vvv;
-> 28     for (int i = 0; i < 100000; i++)
   29       vvv.push_back(i);
   30
   31     std::deque<int> dq1 = {1, 2, 3};
(lldb) thread trace dump instructions -c 2 -t                                                                     Trace.cpp:RefreshLiveProcessState                            Trace::RefreshLiveProcessState invoked
TraceIntelPT.cpp:DoRefreshLiveProcessState                   TraceIntelPT found tsc conversion information
thread #1: tid = 2359706
  a.out`std::vector<int, std::allocator<int>>::vector() + 26 at stl_vector.h:395:19
    54: [tsc=unavailable] 0x0000000000403a7c    retq
```

See the logging lines at the end of the dump. They indicate that refreshing happened and that perf conversion information was found.

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

2 years ago[trace][intelpt] Support system-wide tracing [10] - Return warnings and tsc informati...
Walter Erquinigo [Wed, 18 May 2022 21:32:35 +0000 (14:32 -0700)]
[trace][intelpt] Support system-wide tracing [10] - Return warnings and tsc information from lldb-server.

- Add a warnings field in the jLLDBGetState response, for warnings to be delivered to the client for troubleshooting. This removes the need to silently log lldb-server's llvm::Errors and not expose them easily to the user
- Simplify the tscPerfZeroConversion struct and schema. It used to extend a base abstract class, but I'm doubting that we'll ever add other conversion mechanisms because all modern kernels support perf zero. It is also the one who is supposed to work with the timestamps produced by the context switch trace, so expecting it is imperative.
- Force tsc collection for cpu tracing.
- Add a test checking that tscPerfZeroConversion is returned by the GetState request
- Add a pre-check for cpu tracing that makes sure that perf zero values are available.

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

2 years ago[trace][intelpt] Support system-wide tracing [9] - Collect and return context switch...
Walter Erquinigo [Wed, 18 May 2022 15:01:01 +0000 (08:01 -0700)]
[trace][intelpt] Support system-wide tracing [9] - Collect and return context switch traces

- Add collection of context switches per cpu grouped with the per-cpu intel pt traces.
- Move the state handling from the interl pt trace class to the PerfEvent one.
- Add support for stopping and enabling perf event groups.
- Return context switch entries as part of the jLLDBTraceGetState response.
- Move the triggers of whenever the process stopped or resumed. Now the will-resume notification is in a better location, which will ensure that we'll capture the instructions that will be executed.
- Remove IntelPTSingleBufferTraceUP. The unique pointer was useless.
- Add unit tests

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

2 years ago[trace][intelpt] Support system-wide tracing [8] - Improve the single buffer perf_eve...
Walter Erquinigo [Wed, 18 May 2022 04:46:37 +0000 (21:46 -0700)]
[trace][intelpt] Support system-wide tracing [8] - Improve the single buffer perf_event configuration

We were setting some events to be written in the data buffer of the
perf_event, but we don't need that.

Besides that, we don't need the data buffer to be larger than 1, so we
can reduce its size.

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

2 years ago[trace][intelpt] Support system-wide tracing [7] - Create a base IntelPTProcessTrace...
Walter Erquinigo [Thu, 12 May 2022 17:07:29 +0000 (10:07 -0700)]
[trace][intelpt] Support system-wide tracing [7] - Create a base IntelPTProcessTrace class

We have two different "process trace" implementations: per thread and per core. As a way to simplify the collector who uses both, I'm creating a base abstract class that is used by these implementations. This effectively simplify a good chunk of code.

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

2 years ago[clangd] Improve ObjC protocol suggestions from the index
David Goldman [Mon, 6 Jun 2022 16:19:32 +0000 (12:19 -0400)]
[clangd] Improve ObjC protocol suggestions from the index

When querying the index during an ObjC protocol name lookup for code
completion, we should only suggest ObjC protocols.

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

2 years ago[lldb/Fuzzer] Create ninja target for target fuzzer
Chelsea Cassanova [Wed, 15 Jun 2022 18:01:40 +0000 (14:01 -0400)]
[lldb/Fuzzer] Create ninja target for target fuzzer

Create a ninja target for running the LLDB target fuzzer.
Currently the ninja target for the fuzzer will build the fuzzer without
running it. This allows the fuzzer to be built and run.

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

2 years ago[libc] add printf
Michael Jones [Tue, 14 Jun 2022 19:04:06 +0000 (12:04 -0700)]
[libc] add printf

This patch adds the entrypoint for printf. With this, building a
"hello world" program with just LLVM-libc is possible.

Reviewed By: sivachandra

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

2 years ago[libc] refactor printf file writing
Michael Jones [Tue, 14 Jun 2022 19:00:36 +0000 (12:00 -0700)]
[libc] refactor printf file writing

Add return values to converter functions to allow for better error
handling when writing files. Also move the file writing code around to
be easier to read.

Reviewed By: sivachandra

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

2 years ago[mlir][bzl] Export textmate grammar file
Jacques Pienaar [Wed, 15 Jun 2022 18:28:43 +0000 (11:28 -0700)]
[mlir][bzl] Export textmate grammar file

2 years ago[Clang] Let the linker choose shared or static libunwind unless specified
Petr Hosek [Sat, 28 May 2022 05:53:16 +0000 (05:53 +0000)]
[Clang] Let the linker choose shared or static libunwind unless specified

We shouldn't assume that libunwind.so is available. Rather can defer
the decision to the linker which defaults to libunwind.so, but if .so
isn't available, it'd pick libunwind.a. Users can use -static-libgcc
and -shared-libgcc to override this behavior and explicitly choose
the version they want.

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

2 years ago[DAGCombiner] Fold fold (fp_to_bf16 (bf16_to_fp op)) -> op
Benjamin Kramer [Wed, 15 Jun 2022 17:52:33 +0000 (19:52 +0200)]
[DAGCombiner] Fold fold (fp_to_bf16 (bf16_to_fp op)) -> op

2 years ago[mlgo] Fix accounting for SCC splits
Jin Xin Ng [Wed, 15 Jun 2022 17:38:48 +0000 (10:38 -0700)]
[mlgo] Fix accounting for SCC splits

Previously if the inliner split an SCC such that an empty one remained, the MLInlineAdvisor could potentially lose track of the EdgeCount if a subsequent CGSCC pass modified the calls of a function that was initially in the SCC pre-split. Saving the seen nodes in onPassEntry resolves this.

Reviewed By: mtrofin

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

2 years ago[LV] Remove unneeded CustomBuilder arg from setDebugLocFromInst (NFC).
Florian Hahn [Wed, 15 Jun 2022 17:48:02 +0000 (18:48 +0100)]
[LV] Remove unneeded CustomBuilder arg from setDebugLocFromInst (NFC).

The only user that passed in a custom builder was passing in
VPTransformState::Builder, which is the same as ILV::Builder.

2 years ago[llvm-profdata][test] Change -Wl,-no-pie to -no-pie after D127808
Fangrui Song [Wed, 15 Jun 2022 17:46:37 +0000 (10:46 -0700)]
[llvm-profdata][test] Change -Wl,-no-pie to -no-pie after D127808

The driver option -no-pie is preferred: Clang selects different crt*.o files,
though the PIC one usually can replace the non-PIC one.

2 years ago[mlir][GPUToNVVM] Fix bug in mma elementwise lowering
Thomas Raoux [Wed, 15 Jun 2022 17:16:56 +0000 (17:16 +0000)]
[mlir][GPUToNVVM] Fix bug in mma elementwise lowering

The maxf implementation of wmma elementwise op was incorrect as the
operands of the select to check for Nan were swapped.

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

2 years ago[X86] X86InstrInfo.cpp - fix signed/unsigned promotion warnings in addImm calls
Simon Pilgrim [Wed, 15 Jun 2022 17:20:00 +0000 (18:20 +0100)]
[X86] X86InstrInfo.cpp - fix signed/unsigned promotion warnings in addImm calls

addImm takes a int64_t arg but we were using uint64_t types

2 years ago[clang] Add -fsanitize=memtag-globals (no-op).
Mitch Phillips [Wed, 15 Jun 2022 16:54:17 +0000 (09:54 -0700)]
[clang] Add -fsanitize=memtag-globals (no-op).

Adds the -fsanitize plumbing for memtag-globals. Makes -fsanitize=memtag
imply -fsanitize=memtag-globals.

This has no effect on codegen for now.

Reviewed By: eugenis, aaron.ballman

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

2 years ago[mlir] add an option to print op stats in JSON
Okwan Kwon [Tue, 14 Jun 2022 21:16:26 +0000 (14:16 -0700)]
[mlir] add an option to print op stats in JSON

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

2 years ago[PowerPC] emit VSX instructions instead of VMX instructions for vector loads and...
Quinn Pham [Wed, 8 Jun 2022 14:47:48 +0000 (09:47 -0500)]
[PowerPC] emit VSX instructions instead of VMX instructions for vector loads and stores

This patch changes the PowerPC backend to generate VSX load/store instructions
for all vector loads/stores on Power8 and earlier  (LE) instead of VMX
load/store instructions. The reason for this change is because VMX instructions
require the vector to be 16-byte aligned. So, a vector load/store will fail with
VMX instructions if the vector is misaligned. Also, `gcc` generates VSX
instructions in this situation which allow for unaligned access but require a
swap instruction after loading/before storing. This is not an issue for BE
because we already emit VSX instructions since no swap is required. And this is
not an issue on Power9 and up since we have access to `lxv[x]`/`stxv[x]` which
allow for unaligned access and do not require swaps.

This patch also delays the VSX load/store for LE combines until after
LegalizeOps to prioritize other load/store combines.

Reviewed By: #powerpc, stefanp

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

2 years ago[tosa] Lower tosa.slice to tensor.slice for dynamic case
Rob Suderman [Wed, 15 Jun 2022 16:54:23 +0000 (09:54 -0700)]
[tosa] Lower tosa.slice to tensor.slice for dynamic case

Existing slice lowering only supporting static shapes.

Reviewed By: NatashaKnk

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

2 years ago[SelectionDAG] Constant fold FP_TO_BF16 and BF16_TO_FP.
Benjamin Kramer [Wed, 15 Jun 2022 16:51:13 +0000 (18:51 +0200)]
[SelectionDAG] Constant fold FP_TO_BF16 and BF16_TO_FP.

2 years ago[memprof] Update the test comments to include -Wl,-no-pie
Snehasish Kumar [Tue, 14 Jun 2022 23:30:34 +0000 (23:30 +0000)]
[memprof] Update the test comments to include -Wl,-no-pie

Until we have symbolization for position independent code lets update
this documentation since clang now defaults to position independent
code.

Reviewed By: tejohnson

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

2 years ago[mlir] address post-commit review for D127724
Alex Zinenko [Wed, 15 Jun 2022 16:38:14 +0000 (18:38 +0200)]
[mlir] address post-commit review for D127724

- make transform.alternatives op apply only to isolated-from-above payload IR
  scopes;
- fix potential leak;
- fix several typos.

2 years ago[MLIR][Bufferization] Assume alias if no information is available
lorenzo chelini [Wed, 15 Jun 2022 15:20:49 +0000 (17:20 +0200)]
[MLIR][Bufferization] Assume alias if no information is available

- Post (minor) fix after: https://reviews.llvm.org/D127301

Reviewed By: springerm

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

2 years ago[LLD][COFF] Convert file name to lowercase when inserting it into visitedLibs
Pengxuan Zheng [Tue, 14 Jun 2022 02:22:14 +0000 (19:22 -0700)]
[LLD][COFF] Convert file name to lowercase when inserting it into visitedLibs

It seems to be a bug in `LinkerDriver::findFile`, the file name is not converted
to lowercase when being inserted into `visitedLibs`. This is the only exception
in the file and all other places always convert file names to lowercase when
inserting them into `visitedLibs` (or `visitedFiles`).

Reviewed By: thieta, hans

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

2 years ago[PS5] Support sin+cos->sincos optimization
Paul Robinson [Wed, 15 Jun 2022 16:35:49 +0000 (09:35 -0700)]
[PS5] Support sin+cos->sincos optimization

2 years ago[llvm] Fix MachO exports trie parsing.
Juergen Ributzka [Mon, 13 Jun 2022 22:57:51 +0000 (15:57 -0700)]
[llvm] Fix MachO exports trie parsing.

The exports trie parser ordinal validation check doesn't consider the case where
the ordinal can be zero or negative for certain special values that are defined
in BindSpecialDylib. Update the validation to account for that fact and add a
test case.

This fixes rdar://94844233.

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

2 years ago[Binary] Add iterator to the OffloadBinary string maps
Joseph Huber [Tue, 14 Jun 2022 18:33:32 +0000 (14:33 -0400)]
[Binary] Add iterator to the OffloadBinary string maps

The offload binary contains internally a string map of all the key and
value pairs identified in the binary itself. Normally users query these
values from the `getString` function, but this makes it difficult to
identify which strings are availible. This patch adds a simple const
iterator range to the offload binary allowing users to iterate through
the strings.

Reviewed By: tra

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

2 years ago[clang][dataflow] Make `Value` and `StorageLocation` non-copyable
Stanislav Gatev [Wed, 15 Jun 2022 14:58:13 +0000 (14:58 +0000)]
[clang][dataflow] Make `Value` and `StorageLocation` non-copyable

This makes it harder to misuse APIs that return references by
accidentally copying the results which could happen when assigning the
them to variables declared as `auto`.

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

Reviewed-by: ymandel, xazax.hun
2 years ago[libc++] Removes unneeded <iterator> includes.
Mark de Wever [Mon, 13 Jun 2022 18:05:36 +0000 (20:05 +0200)]
[libc++] Removes unneeded <iterator> includes.

Reviewed By: #libc, philnik

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

2 years ago[mlir][vector] NFC remove dependency of VectorTransform to GPU dialect
Thomas Raoux [Wed, 15 Jun 2022 15:15:57 +0000 (15:15 +0000)]
[mlir][vector] NFC remove dependency of VectorTransform to GPU dialect

Make the reduction distribution pattern more generic and remove layering
problem. The new pattern to distribute reduction is now independent of
GPU and takes a lamdba to decide how the distributed reduction should be
generated.

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

2 years ago[PS5] Trap after noreturn calls, with special case for stack-check-fail
Paul Robinson [Wed, 15 Jun 2022 16:02:03 +0000 (09:02 -0700)]
[PS5] Trap after noreturn calls, with special case for stack-check-fail

2 years ago[CodeGen] Fix the bug of machine sink
Luo, Yuanke [Wed, 15 Jun 2022 11:03:18 +0000 (19:03 +0800)]
[CodeGen] Fix the bug of machine sink

The use operand may be undefined. In that case we can just continue to
check the next operand since it won't increase register pressure.

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

2 years ago[analyzer] Relax constraints on const qualified regions
Balazs Benics [Wed, 15 Jun 2022 15:08:27 +0000 (17:08 +0200)]
[analyzer] Relax constraints on const qualified regions

The arithmetic restriction seems to be artificial.
The comment below seems to be stale.
Thus, we remove both.

Depends on D127306.

Reviewed By: martong

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

2 years ago[analyzer] Treat system globals as mutable if they are not const
Balazs Benics [Wed, 15 Jun 2022 15:08:27 +0000 (17:08 +0200)]
[analyzer] Treat system globals as mutable if they are not const

Previously, system globals were treated as immutable regions, unless it
was the `errno` which is known to be frequently modified.

D124244 wants to add a check for stores to immutable regions.
It would basically turn all stores to system globals into an error even
though we have no reason to believe that those mutable sys globals
should be treated as if they were immutable. And this leads to
false-positives if we apply D124244.

In this patch, I'm proposing to treat mutable sys globals actually
mutable, hence allocate them into the `GlobalSystemSpaceRegion`, UNLESS
they were declared as `const` (and a primitive arithmetic type), in
which case, we should use `GlobalImmutableSpaceRegion`.

In any other cases, I'm using the `GlobalInternalSpaceRegion`, which is
no different than the previous behavior.

---

In the tests I added, only the last `expected-warning` was different, compared to the baseline.
Which is this:
```lang=C++
void test_my_mutable_system_global_constraint() {
  assert(my_mutable_system_global > 2);
  clang_analyzer_eval(my_mutable_system_global > 2); // expected-warning {{TRUE}}
  invalidate_globals();
  clang_analyzer_eval(my_mutable_system_global > 2); // expected-warning {{UNKNOWN}} It was previously TRUE.
}
void test_my_mutable_system_global_assign(int x) {
  my_mutable_system_global = x;
  clang_analyzer_eval(my_mutable_system_global == x); // expected-warning {{TRUE}}
  invalidate_globals();
  clang_analyzer_eval(my_mutable_system_global == x); // expected-warning {{UNKNOWN}} It was previously TRUE.
}
```

---

Unfortunately, the taint checker will be also affected.
The `stdin` global variable is a pointer, which is assumed to be a taint
source, and the rest of the taint propagation rules will propagate from
it.
However, since mutable variables are no longer treated immutable, they
also get invalidated, when an opaque function call happens, such as the
first `scanf(stdin, ...)`. This would effectively remove taint from the
pointer, consequently disable all the rest of the taint propagations
down the line from the `stdin` variable.

All that said, I decided to look through `DerivedSymbol`s as well, to
acquire the memregion in that case as well. This should preserve the
previously existing taint reports.

Reviewed By: martong

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

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

Fixed the missing SQRT promotion. Adding several missing operations too.

2 years ago[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions
Balazs Benics [Wed, 15 Jun 2022 14:58:08 +0000 (16:58 +0200)]
[analyzer][NFC] Prefer using isa<> instead getAs<> in conditions

Depends on D125709

Reviewed By: martong

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

2 years ago[analyzer][NFC] Remove dead field of UnixAPICheckers
Balazs Benics [Wed, 15 Jun 2022 14:50:12 +0000 (16:50 +0200)]
[analyzer][NFC] Remove dead field of UnixAPICheckers

Initially, I thought there is some fundamental bug here by not using the
bool fields, but it turns out D55425 split this checker into two
separate ones; making these fields dead.

Depends on D127836, which uncovered this issue.

Reviewed By: martong

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

2 years ago[analyzer] Fix StreamErrorState hash bug
Balazs Benics [Wed, 15 Jun 2022 14:50:12 +0000 (16:50 +0200)]
[analyzer] Fix StreamErrorState hash bug

The `Profile` function was incorrectly implemented.
The `StreamErrorState` has an implicit `bool` conversion operator, which
will result in a different hash than faithfully hashing the raw value of
the enum.

I don't have a test for it, since it seems difficult to find one.
Even if we would have one, any change in the hashing algorithm would
have a chance of breaking it, so I don't think it would justify the
effort.

Depends on D127836, which uncovered this issue by marking the related
`Profile` function dead.

Reviewed By: martong, balazske

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

2 years ago[analyzer][NFC] Remove dead code and modernize surroundings
Balazs Benics [Wed, 15 Jun 2022 14:50:12 +0000 (16:50 +0200)]
[analyzer][NFC] Remove dead code and modernize surroundings

Thanks @kazu for helping me clean these parts in D127799.

I'm leaving the dump methods, along with the unused visitor handlers and
the forwarding methods.

The dead parts actually helped to uncover two bugs, to which I'm going
to post separate patches.

Reviewed By: martong

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

2 years ago[flang][NFC] Fix some formatting
Valentin Clement [Wed, 15 Jun 2022 14:48:46 +0000 (16:48 +0200)]
[flang][NFC] Fix some formatting

Fix some mismatch in format used in the file and reduce the diff with fir-dev
to be able to finish the upstreaming on this file.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: PeteSteinfeld, kiranchandramohan

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

2 years ago[mlir][tablegen] Generate default attr values in Python bindings
Matthias Springer [Wed, 15 Jun 2022 10:33:54 +0000 (12:33 +0200)]
[mlir][tablegen] Generate default attr values in Python bindings

When specifying an op attribute with a default value (via DefaultValuedAttr), the default value is a string of C++ code. In the general case, the default value of such an attribute cannot be translated to Python when generating the bindings. However, we can hard-code default Python values for frequently-used C++ default values.

This change adds a Python default value for empty ArrayAttrs.

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

2 years ago[JITLink][ELF] Log enum name of unsupported relocation type.
Sunho Kim [Wed, 15 Jun 2022 14:24:18 +0000 (23:24 +0900)]
[JITLink][ELF] Log enum name of unsupported relocation type.

Logs enum name of unsupported relocation type. This also changes elf/x86 to use common util function (getELFRelocationTypeName) inside llvm object module.

Reviewed By: lhames

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

2 years ago[Driver][test] Make RISCV tests robust with PATH=
Shao-Ce SUN [Wed, 15 Jun 2022 14:22:59 +0000 (22:22 +0800)]
[Driver][test] Make RISCV tests robust with PATH=

When `riscv64-unknown-linux-gnu-ld` is in the PATH, `clang -### -fuse-ld=ld --target=riscv64-unknown-linux-gnu` will use unknown-linux-gnu-ld first, which causes the error in the lit test.

Reviewed By: MaskRay

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

2 years ago[clangd][NFC] Use the existing ASTContext from scope
Kadir Cetinkaya [Wed, 15 Jun 2022 14:10:19 +0000 (16:10 +0200)]
[clangd][NFC] Use the existing ASTContext from scope

2 years ago[clangd] Always desugar type aliases in hover
Kadir Cetinkaya [Wed, 15 Jun 2022 08:05:26 +0000 (10:05 +0200)]
[clangd] Always desugar type aliases in hover

The alias itself is already included in the definition section of the
hover (it's printed as spelled in source code). So it doesn't provide any value
when we print the aliases as-is.
Fixes https://github.com/clangd/clangd/issues/1134.

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

2 years agoRevert "[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records...
Krasimir Georgiev [Wed, 15 Jun 2022 13:59:32 +0000 (15:59 +0200)]
Revert "[ARM][Thumb] Command-line option to ensure AAPCS compliant Frame Records AND [NFC][Thumb] Update frame-chain codegen test to use thumbv6m"

This reverts commit 7625e01d661644a560884057755d48a0da8b77b4 and
dependent cbcce82ef6b512d97e92a319a75a03e997c844e1.

Commit 7625e01d661644a560884057755d48a0da8b77b4 causes some new codegen test
failures under asan, e.g., CodeGen/ARM/execute-only.ll:
https://lab.llvm.org/buildbot/#/builders/5/builds/24659/steps/15/logs/stdio.

2 years ago[analyzer][NFC][test] Add new RUN line with support-symbolic-integer-casts=true to...
Gabor Marton [Mon, 13 Jun 2022 15:19:01 +0000 (17:19 +0200)]
[analyzer][NFC][test] Add new RUN line with support-symbolic-integer-casts=true to expr-inspection.cpp

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/D127649

2 years ago[clang][sema] Provide better diagnostic for missing template arguments
Timm Bäder [Mon, 13 Jun 2022 13:48:20 +0000 (15:48 +0200)]
[clang][sema] Provide better diagnostic for missing template arguments

Instead of just complaining that "x is not a class, namespace or
enumeration", mention that using x requires template arguments.

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

Fixes https://github.com/llvm/llvm-project/issues/55962

2 years ago[clang][NFC] Remove unused parameter from ActOnCXXNestedNameSpecifier
Timm Bäder [Tue, 14 Jun 2022 06:49:07 +0000 (08:49 +0200)]
[clang][NFC] Remove unused parameter from ActOnCXXNestedNameSpecifier

2 years ago[lldb] Fix loading DLL from some ramdisk on Windows
Alvin Wong [Wed, 15 Jun 2022 13:07:36 +0000 (16:07 +0300)]
[lldb] Fix loading DLL from some ramdisk on Windows

The WinAPI `GetFinalPathNameByHandle` is used to retrieve the DLL file
name from the HANDLE provided to `LOAD_DLL_DEBUG_EVENT` in the debug
loop. When this API fails, lldb will simply ignore that module.

Certain ramdisk (e.g. ImDisk) does not work with this API, which means
it is impossible to use lldb to debug a process which loads DLLs located
on this type of ramdisk. In order to make this work, we need to use a
fallback routine which involves creating a file mapping, using
`GetMappedFileName` to get a device path, then substitutes the device
path with its drive letter.

References:
* https://developercommunity.visualstudio.com/t/cannot-debug-program-when-compiled-to-ram-drive/43004#T-N109926
* https://github.com/jrfonseca/drmingw/issues/65
* https://docs.microsoft.com/en-us/windows/win32/memory/obtaining-a-file-name-from-a-file-handle

Reviewed By: labath

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

2 years ago[clang] Use correct visibility parameters when following a Using declaration
Furkan Usta [Wed, 15 Jun 2022 08:51:12 +0000 (10:51 +0200)]
[clang] Use correct visibility parameters when following a Using declaration

Fixes https://github.com/clangd/clangd/issues/1137

Reviewed By: kadircet

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