platform/upstream/llvm.git
2 years agoReplace to_hexString by touhexstr [NFC]
Corentin Jabot [Thu, 16 Jun 2022 09:52:40 +0000 (11:52 +0200)]
Replace to_hexString by touhexstr [NFC]

LLVM had 2 methods to convert a number to an hexa string,
this remove one of them.

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

2 years ago[strictfp][IPSCCP] Precommit tests for D115737.
Kevin P. Neal [Thu, 16 Jun 2022 15:20:04 +0000 (11:20 -0400)]
[strictfp][IPSCCP] Precommit tests for D115737.

2 years agoAdd braces to silence a gcc 9.4 -Wdangling-else warning [nfc]
Philip Reames [Thu, 16 Jun 2022 15:10:34 +0000 (08:10 -0700)]
Add braces to silence a gcc 9.4 -Wdangling-else warning [nfc]

2 years ago[RISCV] Extend demanded field transform in InsertVSETVLI to VTYPE subfeilds
Philip Reames [Thu, 16 Jun 2022 15:00:05 +0000 (08:00 -0700)]
[RISCV] Extend demanded field transform in InsertVSETVLI to VTYPE subfeilds

The motivating case, and the only one actually enabled by this patch, is a load or store followed by another op with the same SEW/LMUL ratio.

As an example, consider:

define void @test1(ptr %in, ptr %out) {
entry:
  %0 = load <8 x i16>, ptr %in, align 2
  %1 = sext <8 x i16> %0 to <8 x i32>
  store <8 x i32> %1, ptr %out, align 4
  ret void
}

Without this patch, we get:

vsetivli zero, 8, e16, mf4, ta, mu
vle16.v v8, (a0)
vsetvli zero, zero, e32, mf2, ta, mu
vsext.vf2 v9, v8
vse32.v v9, (a1)
ret

Whereas with the patch we get:

vsetivli zero, 8, e32, mf2, ta, mu
vle16.v v8, (a0)
vsext.vf2 v9, v8
vse32.v v9, (a1)
ret

We have rewritten the first vsetvli and thus removed the second one.

As is strongly hinted by the code structure and todos, I am planning on communing this with all (or most all?) of the cases from isCompatible used in the forward data flow. This will be done in a series of following changes - some NFC reworks, and some reviewed optimization extensions.

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

2 years ago[mlir][spirv] Workaround driver bug in math.ctlz conversion again
Lei Zhang [Thu, 16 Jun 2022 14:48:33 +0000 (10:48 -0400)]
[mlir][spirv] Workaround driver bug in math.ctlz conversion again

The previous approach does not work as the Adreno driver is
clever at optimizing away the selection. So now check two
inputs together.

Reviewed By: ThomasRaoux

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

2 years ago[CostModel][AArch64][NFC] Add cost model tests for fshl/fshr intrinsics
David Sherwood [Thu, 16 Jun 2022 14:47:12 +0000 (15:47 +0100)]
[CostModel][AArch64][NFC] Add cost model tests for fshl/fshr intrinsics

2 years agoPrevent crash when TurnSwitchRangeIntoICmp receives default unreachable destination
Samuel Eubanks [Thu, 16 Jun 2022 14:10:13 +0000 (16:10 +0200)]
Prevent crash when TurnSwitchRangeIntoICmp receives default unreachable destination

TurnSwitchRangeIntoICmp crashes when given a switch with a default
destination of unreachable
Addresses issue #53208
https://github.com/llvm/llvm-project/issues/53208

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

2 years ago[LV] Remove widenPHIInstruction dependence on underlying instr (NFC).
Florian Hahn [Thu, 16 Jun 2022 14:02:44 +0000 (16:02 +0200)]
[LV] Remove widenPHIInstruction dependence on underlying instr (NFC).

Instead of using the underlying instruction and VF to get the type, use
the type of the incoming value. This removes an unnecessary dependence
on the underlying instruction and enables using the recipe without an
underlying instruction.

2 years ago[SLP]Extend vectorization for scatter vectorize nodes.
Alexey Bataev [Tue, 7 Jun 2022 14:43:29 +0000 (07:43 -0700)]
[SLP]Extend vectorization for scatter vectorize nodes.

Currently scatter vectorize nodes can be emitted only for GEPs with
constant indices. But we can also emit such nodes for GEPs with the same
ptr and non-constant vectorizable/gathered indices, if profitable. Patch
adds support for such nodes and tries to improve handling of GEPs with
non-const indeces for such nodes.

Metric: SLP.NumVectorInstructions

Program                                                                                       SLP.NumVectorInstructions
                                                                                              results                   results0 diff
                    test-suite :: External/SPEC/CFP2017speed/638.imagick_s/638.imagick_s.test  5243.00                   5240.00  -0.1%
                     test-suite :: External/SPEC/CFP2017rate/538.imagick_r/538.imagick_r.test  5243.00                   5240.00  -0.1%
                     test-suite :: External/SPEC/CFP2017rate/526.blender_r/526.blender_r.test 27550.00                  27507.00  -0.2%
                               test-suite :: External/SPEC/CFP2006/453.povray/453.povray.test  5395.00                   5380.00  -0.3%
                       test-suite :: External/SPEC/CFP2017rate/511.povray_r/511.povray_r.test  5389.00                   5374.00  -0.3%
                    test-suite :: External/SPEC/CINT2017rate/520.omnetpp_r/520.omnetpp_r.test   961.00                    958.00  -0.3%
                   test-suite :: External/SPEC/CINT2017speed/620.omnetpp_s/620.omnetpp_s.test   961.00                    958.00  -0.3%
                               test-suite :: External/SPEC/CFP2006/447.dealII/447.dealII.test  5664.00                   5643.00  -0.4%
                       test-suite :: External/SPEC/CFP2017rate/510.parest_r/510.parest_r.test 13202.00                  13127.00  -0.6%
                                test-suite :: External/SPEC/CINT2006/445.gobmk/445.gobmk.test   212.00                    207.00  -2.4%
                                test-suite :: MultiSource/Benchmarks/7zip/7zip-benchmark.test   890.00                    850.00  -4.5%
                            test-suite :: External/SPEC/CINT2006/464.h264ref/464.h264ref.test  1695.00                   1581.00  -6.7%
                                 test-suite :: MultiSource/Applications/JM/lencod/lencod.test  2338.00                   2140.00  -8.5%
                                  test-suite :: SingleSource/UnitTests/matrix-types-spec.test    63.00                     55.00 -12.7%
                             test-suite :: SingleSource/Benchmarks/Adobe-C++/loop_unroll.test   468.00                    356.00 -23.9%
                                                                           Geomean difference                                     -0.3%

All numbers show increased number of generated vector instructions.

Diff:
SingleSource/Benchmarks/Adobe-C++/loop_unroll - better without LTO, but
need an extra analysis with LTO (with LTO compiler generates
masked_gather, while before regular loads were emitted because of extra
data, availbale at LTO time).
SingleSource/UnitTests/matrix-types-spec - more vector code.
MultiSource/Applications/JM/lencod/lencod - same.
External/SPEC/CINT2006/464.h264ref/464.h264ref - same.
MultiSource/Benchmarks/7zip/7zip-benchmark - same.
External/SPEC/CINT2006/445.gobmk/445.gobmk - no changes.
External/SPEC/CFP2017rate/510.parest_r/510.parest_r - more vector code.
External/SPEC/CFP2006/447.dealII/447.dealII - same
External/SPEC/CINT2017speed/620.omnetpp_s/620.omnetpp_s - same
External/SPEC/CINT2017rate/520.omnetpp_r/520.omnetpp - same
External/SPEC/CFP2017rate/511.povray_r/511.povray - same
External/SPEC/CFP2006/453.povray/453.povray - same
External/SPEC/CFP2017rate/526.blender_r/526.blender_r - same
External/SPEC/CFP2017rate/538.imagick_r/538.imagick_r - same
External/SPEC/CFP2017speed/638.imagick_s/638.imagick_s - same

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

2 years ago[libc++] Robust against C++20-hostile iterators
Nikolas Klauser [Thu, 16 Jun 2022 08:50:15 +0000 (10:50 +0200)]
[libc++] Robust against C++20-hostile iterators

Reviewed By: ldionne, #libc, EricWF

Spies: EricWF, libcxx-commits, mgrang

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

2 years agocmake: configure clang lit to use hmaptool from source directly
Matheus Izvekov [Thu, 16 Jun 2022 06:24:19 +0000 (08:24 +0200)]
cmake: configure clang lit to use hmaptool from source directly

Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>
Reviewed By: dyung

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

2 years ago[AMDGPU] Remove duplicate RUN lines from a test
Jay Foad [Thu, 16 Jun 2022 10:47:20 +0000 (11:47 +0100)]
[AMDGPU] Remove duplicate RUN lines from a test

2 years ago[AMDGPU][MC][GFX11] Correct src0 for dpp variants of v_cvt_*_e64
Dmitry Preobrazhensky [Thu, 16 Jun 2022 10:44:56 +0000 (13:44 +0300)]
[AMDGPU][MC][GFX11] Correct src0 for dpp variants of v_cvt_*_e64

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

2 years ago[InstCombine] Add more tests for freeze of loop phi (NFC)
Nikita Popov [Thu, 16 Jun 2022 10:44:14 +0000 (12:44 +0200)]
[InstCombine] Add more tests for freeze of loop phi (NFC)

2 years ago[clangd] Don't add inlay hints on std::move/forward
Tobias Ribizel [Thu, 16 Jun 2022 10:23:51 +0000 (12:23 +0200)]
[clangd] Don't add inlay hints on std::move/forward

This removes parameter inlay hints from a few builtin functions like std::move/std::forward

Reviewed By: nridge

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

2 years ago[sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test
Kristina Bessonova [Thu, 16 Jun 2022 09:56:06 +0000 (11:56 +0200)]
[sanitizer_common] Fix SanitizerCommon.ChainedOriginDepotStats test

This test was failing with the following error message if to run the test binary
directly, w/o using lit:

  $ Sanitizer-x86_64-Test --gtest_filter=SanitizerCommon.ChainedOriginDepot*
  ...
  [ RUN      ] SanitizerCommon.ChainedOriginDepotStats
  compiler-rt/lib/sanitizer_common/tests/sanitizer_chained_origin_depot_test.cpp:77: Failure
  Expected: (stats1.allocated) > (stats0.allocated), actual: 196608 vs 196608
  [  FAILED  ] SanitizerCommon.ChainedOriginDepotStats (867 ms)

Since the ChainedOriginDepot* tests are not doing any cleanup, by the time
SanitizerCommon.ChainedOriginDepotStats test starts executing the depot
may not be empty, so there will be no allocation for the test.

This patch introduces ChainedOriginDepot::TestOnlyUnmap() API that deallocates
memory when requested. This makes sure underlying TwoLevelMap initiates
the expected allocation during the test.

Reviewed By: eugenis

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

2 years ago[AArch64][SME] Add SME cntsb/h/w/d intrinsics
David Sherwood [Wed, 15 Jun 2022 10:28:08 +0000 (11:28 +0100)]
[AArch64][SME] Add SME cntsb/h/w/d intrinsics

These intrinsics return the number of elements in a streaming
vector, for example aarch64.sme.cntsw returns the number of
32-bit elements. When in streaming mode these are equivalent
to aarch64.sve.cntb/h/w/d with an input value of 1.

I have implemented these intrinsics using the rdsvl instruction
and added tests here:

  CodeGen/AArch64/SME/sme-intrinsics-rdsvl.ll

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

2 years ago[AMDGPU] Change use null for dead sdst to be gfx1030+
David Stuttard [Wed, 15 Jun 2022 15:48:28 +0000 (16:48 +0100)]
[AMDGPU] Change use null for dead sdst to be gfx1030+

Pre gfx1030 null for sdst is different.
c97436f8b6e2 [AMDGPU] Use null for dead sdst operand - requires a change to make
it not apply to pre gfx1030

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

2 years agoRevert "[libc] Apply no-builtin everywhere, remove unnecessary flags"
Guillaume Chatelet [Thu, 16 Jun 2022 09:28:17 +0000 (09:28 +0000)]
Revert "[libc] Apply no-builtin everywhere, remove unnecessary flags"

This reverts commit b2a9ea4420127d10b18ae648b16757665f8bbd7c.

2 years agoReland "[SplitKit] Handle early clobber + tied to def correctly"
Kito Cheng [Thu, 16 Jun 2022 08:45:36 +0000 (16:45 +0800)]
Reland "[SplitKit] Handle early clobber + tied to def correctly"

This reverts commit 7207373e1eb0dd419b4e13a5e2d0ca146ef9544e.

We found another RISC-V bug when landing D126048, and it has been fixed
by D127642 now.

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

2 years agoReland "[RISCV] Testcase to show wrong register allocation result of subreg liveness"
Kito Cheng [Wed, 15 Jun 2022 08:24:09 +0000 (16:24 +0800)]
Reland "[RISCV] Testcase to show wrong register allocation result of subreg liveness"

This reverts commit 6a6f632b93cd3ed9e35f37c04efb12fa87038b60.

This commit will failed when EXPENSIVE_CHECKS enabled, fixed by D126048.

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

2 years ago[libc++] Test the size of basic_string
Nikolas Klauser [Wed, 15 Jun 2022 20:28:15 +0000 (22:28 +0200)]
[libc++] Test the size of basic_string

Reviewed By: ldionne, #libc

Spies: libcxx-commits

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

2 years agoUpdate FileCheck docs after D95849. NFCI
Diana Picus [Wed, 15 Jun 2022 11:24:21 +0000 (11:24 +0000)]
Update FileCheck docs after D95849. NFCI

The default has been false for quite a while now.

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

2 years agoRevert "[ARM] Add a pipeline test showing missing postinc generation. NFC"
David Green [Thu, 16 Jun 2022 07:23:08 +0000 (08:23 +0100)]
Revert "[ARM] Add a pipeline test showing missing postinc generation. NFC"

This reverts commit d9ef307e9bb3b636a18c4051a236f1aafd7600e6 as it is
causeing expensive check verification errors. Remove the test again
until we can fix them.

2 years ago[AMDGPU] Add support for GFX11 hazards
Jay Foad [Wed, 15 Jun 2022 16:09:10 +0000 (17:09 +0100)]
[AMDGPU] Add support for GFX11 hazards

Add support for partial stall over EXEC hazard and trans use hazard.

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

2 years ago[ARM] Add a pipeline test showing missing postinc generation. NFC
David Green [Thu, 16 Jun 2022 07:04:50 +0000 (08:04 +0100)]
[ARM] Add a pipeline test showing missing postinc generation. NFC

2 years ago[JITLink][AArch64][NFC] Suppress unused variable error.
Sunho Kim [Thu, 16 Jun 2022 06:28:40 +0000 (15:28 +0900)]
[JITLink][AArch64][NFC] Suppress unused variable error.

Suppress unused variable error when assertion got disabled.

Reviewed By: chapuni

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

2 years ago[libc][Obvious] Include arm_acle.h only for aarch64 builds.
Siva Chandra [Thu, 16 Jun 2022 06:04:24 +0000 (23:04 -0700)]
[libc][Obvious] Include arm_acle.h only for aarch64 builds.

2 years ago[ValueTypes] Add types for nxv16bf16 and nxv32bf16.
Craig Topper [Thu, 16 Jun 2022 03:17:07 +0000 (20:17 -0700)]
[ValueTypes] Add types for nxv16bf16 and nxv32bf16.

This is needed by our downstream and makes bf16 and f16 have the
same set of scalable vector types.

Reviewed By: rui.zhang

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

2 years ago[libc][aarch64] Set frame pointer of the new thread to the stack pointer.
Siva Chandra [Thu, 16 Jun 2022 05:48:21 +0000 (22:48 -0700)]
[libc][aarch64] Set frame pointer of the new thread to the stack pointer.

This allows sniffing thread start args in a robust fashion.

2 years ago[LoongArch] Use register R0 (ZERO) for constant 0
Weining Lu [Thu, 16 Jun 2022 05:33:43 +0000 (13:33 +0800)]
[LoongArch] Use register R0 (ZERO) for constant 0

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

2 years agoFix `script -lpython` to handle control flow in one-line commands.
Dave Lee [Thu, 16 Jun 2022 05:08:21 +0000 (22:08 -0700)]
Fix `script -lpython` to handle control flow in one-line commands.

The fix is to append a newline to the source being evaluated.

Without this patch, the following commands **print no output, no errors**.

```
(lldb) script if "foo" in lldb.frame.name: print(lldb.thread)
(lldb) script for f in lldb.thread: print(f.name)
```

The issue is with `code.InteractiveConsole.runsource()`. A trailing newline is
needed for these expressions to be evaluated. I don't know why this is, the
docs don't mention anything.

From a python repl, the following samples show that a terminal newline allows
statements containing flow control to fully execute.

```
>>> import code
>>> repl = code.InteractiveConsole()
>>> repl.runsource("if True: print(1)")
True
>>> repl.runsource("if True: print(1)\n")
1
False
```

Notes:

From an interactive python repl, the output is not printed immediately. The
user is required to enter a blank line following the first.

```
>>> if True: print(1)
...
1
```

However, `python -c 'if True: print(1)'` works without needing a newline.

Reviewed By: JDevlieghere

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

2 years ago[lldb] Support non-pointer implicit this/self in GetValueForVariableExpressionPath
Dave Lee [Thu, 16 Jun 2022 05:04:02 +0000 (22:04 -0700)]
[lldb] Support non-pointer implicit this/self in GetValueForVariableExpressionPath

The `frame variable` command supports an implicit `this`/`self`, allowing a
user to run `v some_field` instead of `v this->some_field`. However, some
languages have non-pointer `this`/`self` types (for example, Swift).

This change adds support for non-pointer implicit `this`/`self`. This is done
by consulting the type of the instance variable. If the type is known to be
non-pointer, the dot operator is used instead of the arrow operator.

The C language of families each have a pointer instance type, which makes
testing of this difficult. Tests for this feature will be done in the Swift
downstream fork, as Swift's `self` is a non-pointer (reference) type.

rdar://82095148

Reviewed By: aprantl

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

2 years ago[mlir][python] Actually set UseLocalScope printing flag
Mark Browning [Thu, 16 Jun 2022 04:59:57 +0000 (21:59 -0700)]
[mlir][python] Actually set UseLocalScope printing flag

The useLocalScope printing flag has been passed around between pybind methods, but doesn't actually enable the corresponding printing flag.

Reviewed By: stellaraccident

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

2 years ago[BOLT][NFCI] Remove redundant code
Maksim Panchenko [Thu, 16 Jun 2022 01:25:58 +0000 (18:25 -0700)]
[BOLT][NFCI] Remove redundant code

createBasicBlock() will create a label for addBasicBlock().

Reviewed By: rafauler

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

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