platform/upstream/llvm.git
22 months ago[clang][Interp][NFC] Explain why tests are disabled
Timm Bäder [Fri, 14 Oct 2022 09:44:23 +0000 (11:44 +0200)]
[clang][Interp][NFC] Explain why tests are disabled

Disabled to make the buildbots happy in
c004d7534dcefcfebc3e07a7fa12f5492be80279. In C++14, the functions here
use a MaterializeTemporaryExpr, which the new constant interpreter
doesn't support yet. Add comments for this and two new RUN lines.

22 months ago[clang][Interp][NFC] Run record tests on i686 as well
Timm Bäder [Fri, 14 Oct 2022 09:19:24 +0000 (11:19 +0200)]
[clang][Interp][NFC] Run record tests on i686 as well

So we have some test coverage on a 32bit arch.

22 months ago[clang][Interp] Classify ArrayInitIndexExpr type
Timm Bäder [Fri, 14 Oct 2022 09:08:57 +0000 (11:08 +0200)]
[clang][Interp] Classify ArrayInitIndexExpr type

We can't just push a uint64 unconditionally here, since on 32bit arches
we later expect a different type, e.g. uint32.

This broke e.g. these builders:
https://lab.llvm.org/buildbot#builders/171/builds/21514
https://lab.llvm.org/buildbot#builders/38/builds/6643

22 months ago[MemorySSA] Add test for select with cross-iteration dependency (NFC)
Nikita Popov [Fri, 14 Oct 2022 09:02:23 +0000 (11:02 +0200)]
[MemorySSA] Add test for select with cross-iteration dependency (NFC)

This is currently miscompiled.

22 months agoRevert "[AArch64] Fix aligning the stack after calling __chkstk"
Martin Storsjö [Fri, 14 Oct 2022 08:27:39 +0000 (11:27 +0300)]
Revert "[AArch64] Fix aligning the stack after calling __chkstk"

This reverts commit 50e0aced4521260af842dba73f1d8c50d36314ea.

This could accidentally start producing invalid code in some
cases (in particular, if compiling with -mstack-alignment=16, which
one could expect to be a no-op for a target where the stack always
is aligned to 16 bytes anyway).

22 months ago[clang][Interp] Disable some RVO tests
Timm Bäder [Fri, 14 Oct 2022 08:44:39 +0000 (10:44 +0200)]
[clang][Interp] Disable some RVO tests

Apparently this breaks a couple of builders:
https://lab.llvm.org/buildbot/#/builders/139/builds/29552
https://lab.llvm.org/buildbot/#/builders/216/builds/11240

22 months ago[Interp] Silence warning in release builds. NFC.
Benjamin Kramer [Fri, 14 Oct 2022 08:35:48 +0000 (10:35 +0200)]
[Interp] Silence warning in release builds. NFC.

22 months agoAdd missing `override`s after aad013de41c0
Benjamin Kramer [Fri, 14 Oct 2022 08:34:17 +0000 (10:34 +0200)]
Add missing `override`s after aad013de41c0

22 months ago[BasicAA] Account for cycles when checking for same select condition
Nikita Popov [Fri, 14 Oct 2022 08:35:36 +0000 (10:35 +0200)]
[BasicAA] Account for cycles when checking for same select condition

If we have translated across a cycle backedge, the same SSA value
for the condition might be referring to two different loop iterations.
Use the isValueEqualInPotentialCycles() helper to avoid assuming
equality in that case.

22 months ago[BasicAA] Add test for select with loop carried dependency (NFC)
Nikita Popov [Fri, 14 Oct 2022 08:31:44 +0000 (10:31 +0200)]
[BasicAA] Add test for select with loop carried dependency (NFC)

22 months ago[mlir] add missing markdown delimiters in SCFOps.td
Oleksandr "Alex" Zinenko [Fri, 14 Oct 2022 08:30:34 +0000 (10:30 +0200)]
[mlir] add missing markdown delimiters in SCFOps.td

22 months ago[clang][Interp] Fix using default copy constructors
Timm Bäder [Wed, 21 Sep 2022 14:05:30 +0000 (16:05 +0200)]
[clang][Interp] Fix using default copy constructors

Implement ArrayInitLoopExprs, which are used in copy constructors to
copy arrays. Also fix problems encountered while doing that.

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

22 months ago[clang][Interp] Implement nested struct initialization
Timm Bäder [Mon, 19 Sep 2022 11:16:47 +0000 (13:16 +0200)]
[clang][Interp] Implement nested struct initialization

Recurse into visitInitializer() if necessary.

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

22 months ago[clang][Interp] Implement This pointer passing to methods
Timm Bäder [Sun, 18 Sep 2022 18:40:27 +0000 (20:40 +0200)]
[clang][Interp] Implement This pointer passing to methods

Implement passing the this pointer to member functions and constructors.
The this pointer is passed via the stack. This changes the functions to
explicitly track whether they have a RVO pointer and a this pointer.

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

22 months ago[clang][Interp] Start implementing record types
Timm Bäder [Fri, 16 Sep 2022 17:11:58 +0000 (19:11 +0200)]
[clang][Interp] Start implementing record types

Implement simple constructors as well as member access expressions.

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

22 months ago[clang][Interp] Don't run functions immediately after compiling them
Timm Bäder [Mon, 10 Oct 2022 11:02:15 +0000 (13:02 +0200)]
[clang][Interp] Don't run functions immediately after compiling them

This doesn't make much sense with functions that expect valid parameters
and/or a certain call stack on the caller side like This/RVO pointers.

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

22 months ago[clang][Interp][NFC] Add more tests for if expressions
Timm Bäder [Fri, 7 Oct 2022 09:54:04 +0000 (11:54 +0200)]
[clang][Interp][NFC] Add more tests for if expressions

Rename the old if_consteval.cpp to just if.cpp and add tests for the
if declaration.

22 months ago[clang][Interp][NFC] Add a TODO comment
Timm Bäder [Fri, 7 Oct 2022 05:49:57 +0000 (07:49 +0200)]
[clang][Interp][NFC] Add a TODO comment

We can ignore casts where FromT and ToT are the same type. But that's a
performance optimization that I'd like to do later. For now, this code
is doing the right thing.

22 months ago[TBAA] Model call accessing immutable type as readnone
Nikita Popov [Thu, 13 Oct 2022 10:31:23 +0000 (12:31 +0200)]
[TBAA] Model call accessing immutable type as readnone

Accesses to constant memory are not observable and should be
reported as readnone, not readonly. This is consistent with what
we do for normal (non-call) instructions: For those, the TBAA
metadata will result in pointsToConstantMemory() returning true,
which will then result in a NoModRef result, not a Ref result.

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

22 months ago[LoongArch] Add codegen support for atomicrmw umin/umax operation on LA64
gonglingqin [Fri, 14 Oct 2022 07:23:51 +0000 (15:23 +0800)]
[LoongArch] Add codegen support for atomicrmw umin/umax operation on LA64

Furthermore, use `beqz $rd, .BB` instead of `beq $rd, $zero, .BB`.

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

22 months ago[mlir][llvm] Use tablegen to import extract/insert ops from LLVM IR.
Tobias Gysi [Fri, 14 Oct 2022 06:32:30 +0000 (09:32 +0300)]
[mlir][llvm] Use tablegen to import extract/insert ops from LLVM IR.

The revision imports the extract and insert value operations using
tablegen generated builders. Additionally, it moves the tests to
the instructions.ll test file.

Reviewed By: ftynse, dcaballe

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

22 months agoAdd f16 nearbyint support.
Leon Clark [Fri, 14 Oct 2022 07:05:10 +0000 (08:05 +0100)]
Add f16 nearbyint support.

Enable lowering of FNEARBYINT for f16 and extend existing tests.

Reviewed By: arsenm

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

22 months agoAMDGPU: Fix failing test with expensive checks
Matt Arsenault [Fri, 14 Oct 2022 06:34:20 +0000 (23:34 -0700)]
AMDGPU: Fix failing test with expensive checks

Fixes failure after d383adec4d3914492e67267462e6f00fdd4934af

22 months agoAtomicExpand: Avoid some operations if the atomic is overaligned
Matt Arsenault [Tue, 20 Sep 2022 21:51:42 +0000 (17:51 -0400)]
AtomicExpand: Avoid some operations if the atomic is overaligned

Let some of the pointer bithacking fold away if we know the LSB are 0.

22 months ago[llvm-profgen] Fix inconsistent loading address issues
wlei [Fri, 14 Oct 2022 03:42:51 +0000 (20:42 -0700)]
[llvm-profgen] Fix inconsistent loading address issues

This is to fix two issues related with loading address:

1) When multiple MMAPs occur and their loading address are different, before it only used the first MMap as base address, all perf address after it used the wrong base address.

2) For pseudo probe profile, the address is always based on preferred loading address. If the base address is not equal to the preferred loading address, the pseudo probe address query will be wrong.

Solution: Instead of converting the address to offset lazily, right now all the address after parsing are converted on the fly based on preferred loading address in the parsing time. There is no "offset" used in profile generator any more.

Reviewed By: hoy, wenlei

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

22 months ago[BOLT] Section-handling refactoring/overhaul
Maksim Panchenko [Thu, 22 Sep 2022 19:05:12 +0000 (12:05 -0700)]
[BOLT] Section-handling refactoring/overhaul

Simplify the logic of handling sections in BOLT. This change brings more
direct and predictable mapping of BinarySection instances to sections in
the input and output files.

* Only sections from the input binary will have a non-null SectionRef.
  When a new section is created as a copy of the input section,
  its SectionRef is reset to null.

* RewriteInstance::getOutputSectionName() is removed as the section name
  in the output file is now defined by BinarySection::getOutputName().

* Querying BinaryContext for sections by name uses their original name.
  E.g., getUniqueSectionByName(".rodata") will return the original
  section even if the new .rodata section was created.

* Input file sections (with relocations applied) are emitted via MC with
  ".bolt.org" prefix. However, their name in the output binary is
  unchanged unless a new section with the same name is created.

* New sections are emitted internally with ".bolt.new" prefix if there's
  a name conflict with an input file section. Their original name is
  preserved in the output file.

* Section header string table is properly populated with section names
  that are actually used. Previously we used to include discarded
  section names as well.

* Fix the problem when dynamic relocations were propagated to a new
  section with a name that matched a section in the input binary.
  E.g., the new .rodata with jump tables had dynamic relocations from
  the original .rodata.

Reviewed By: rafauler

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

22 months ago[BranchRelaxation] Fall through only if block has no unconditional branches
Anshil Gandhi [Fri, 14 Oct 2022 04:47:28 +0000 (22:47 -0600)]
[BranchRelaxation] Fall through only if block has no unconditional branches

Prior to inserting an unconditional branch from X to its
fall through basic block, check if X has any terminators to
avoid inserting additional branches.

Reviewed By: arsenm

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

22 months agoAMDGPU: Add __builtin_amdgcn_permlane64
Matt Arsenault [Wed, 28 Sep 2022 21:55:30 +0000 (17:55 -0400)]
AMDGPU: Add __builtin_amdgcn_permlane64

22 months agoAsmPrinter: Remove pointless code in inline asm emission
Matt Arsenault [Thu, 13 Oct 2022 17:02:34 +0000 (10:02 -0700)]
AsmPrinter: Remove pointless code in inline asm emission

This was scanning through def operands looking for the
symbol operand. This is pointless because the symbol is always
the first operand as enforced by the verifier, and all operands
are implicit.

22 months ago[AArch64][BuildErrorFix] Add compatible classifyGlobalFunctionReference
Xiang1 Zhang [Fri, 14 Oct 2022 03:23:20 +0000 (11:23 +0800)]
[AArch64][BuildErrorFix] Add compatible classifyGlobalFunctionReference

22 months ago[AArch64] add tests for ccmp with negative constant op1; NFC
chenglin.bi [Fri, 14 Oct 2022 04:07:43 +0000 (12:07 +0800)]
[AArch64] add tests for ccmp with negative constant op1; NFC

22 months ago[flang] Add a semantics test for atomic_ref
Katherine Rasmussen [Thu, 13 Oct 2022 01:10:53 +0000 (18:10 -0700)]
[flang] Add a semantics test for atomic_ref

Reviewed By: rouson

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

22 months ago[clang][PowerPC][NFC] Add base test case for PPC64 VAArg aggregate smaller than a...
Ting Wang [Fri, 14 Oct 2022 02:57:40 +0000 (22:57 -0400)]
[clang][PowerPC][NFC] Add base test case for PPC64 VAArg aggregate smaller than a slot

Reviewed By: shchenz

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

22 months ago[InlineAsm][bugfix] Correct function addressing in inline asm
Xiang1 Zhang [Tue, 13 Sep 2022 06:48:12 +0000 (14:48 +0800)]
[InlineAsm][bugfix] Correct function addressing in inline asm
In Linux PIC model, there are 4 cases about value/label addressing:
Case 1: Function call or Label jmp inside the module.
Case 2: Data access (such as global variable, static variable) inside the module.
Case 3: Function call or Label jmp outside the module.
Case 4: Data access (such as global variable) outside the module.

Due to current llvm inline asm architecture designed to not "recognize" the asm
code, there are quite troubles for us to treat mem addressing differently for
same value/adress used in different instuctions.
For example, in pic model, call a func may in plt way or direclty pc-related,
but lea/mov a function adress may use got.

This patch fix/refine the case 1 and case 2 in inline asm.
Due to currently inline asm didn't support jmp the outsider lable, this patch
mainly focus on fix the function call addressing bugs in inline asm.

Reviewed By: Pengfei, RKSimon

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

22 months ago[mlir][bufferize] Treat certain aliasing-only uses like memory reads
Matthias Springer [Fri, 14 Oct 2022 01:39:50 +0000 (10:39 +0900)]
[mlir][bufferize] Treat certain aliasing-only uses like memory reads

This fixes an issue in One-Shot Bufferize that could lead to missing buffer copies in the future. This bug can currently not be triggered because of the order in which ops are analyzed (always bottom-to-top). However, if we consider different traversal orders for the analysis in the future, this bug can cause subtle issues that are difficult to debug.

Example:
```
%0 = ...
%1 = tensor.insert ... into %0
%2 = tensor.extract_slice %0
tensor.extract %2[...]
```

In case of a top-to-bottom analysis of the above IR, the `tensor.insert` is analyzed before the `tensor.extract_slice`. In that case, the `tensor.insert` will bufferize in-place because %2 is not yet known to become an alias of %0 (and therefore causing a conflict).

With this change, the `tensor.insert` will bufferize out-of-place, regardless of the traversal order.

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

22 months ago[mlir] Update CallInterfaceCallable to use the new casting infra.
Nick Kreeger [Fri, 14 Oct 2022 01:33:24 +0000 (20:33 -0500)]
[mlir] Update CallInterfaceCallable to use the new casting infra.

This enables casting LLVM style for mlir::CallInterfaceCallable usage.

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

22 months ago[PowerPC] Change CRNOT to a code gen single operand instruction
Nemanja Ivanovic [Fri, 14 Oct 2022 01:09:23 +0000 (20:09 -0500)]
[PowerPC] Change CRNOT to a code gen single operand instruction

Inputs to crnor can come from operands with chains so
if it is being used simply to negate such an operand,
the repeated input cannot be CSE'd. This patch just
adds a code-gen only instruction for this that takes
a single input and duplicates it in the encoding of
the underlying crnor.

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

22 months agoImprove dynamic loader support in DynamicLoaderPOSIXDYLD when using core files.
Greg Clayton [Wed, 28 Sep 2022 23:50:38 +0000 (16:50 -0700)]
Improve dynamic loader support in DynamicLoaderPOSIXDYLD when using core files.

Prior to this fix, no shared libraries would be loaded for a core file, even if they exist on the current machine. The issue was the DYLDRendezvous would read a DYLDRendezvous::Rendezvous from memory of the process in DYLDRendezvous::Resolve() which would read some ld.so structures as they existed in the middle of a process' lifetime. In core files we see, the DYLDRendezvous::Rendezvous::state would be set to eAdd for running processes. When ProcessELFCore.cpp would load the core file, it would call DynamicLoaderPOSIXDYLD::DidAttach(), which would call the above Rendezvous functions. The issue came when during the DidAttach function it call DYLDRendezvous::GetAction() which would return eNoAction if the DYLDRendezvous::m_current.state was read from memory as eAdd. This caused no shared libraries to be loaded for any ELF core files. We now detect if we have a core file and after reading the DYLDRendezvous::m_current.state from memory we set it to eConsistent, which causes DYLDRendezvous::GetAction() to return the correct action of eTakeSnapshot and shared libraries get loaded.

We also improve the DynamicLoaderPOSIXDYLD class to not try and set any breakpoints to catch shared library loads/unloads when we have a core file, which saves a bit of time.

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

22 months ago[gn build] port 1fda6f6859aa (lld driver_executable)
Nico Weber [Thu, 13 Oct 2022 23:56:37 +0000 (19:56 -0400)]
[gn build] port 1fda6f6859aa (lld driver_executable)

22 months ago[SPIRV] Fix formatting of function tests
Michal Paszkowski [Mon, 10 Oct 2022 22:17:11 +0000 (00:17 +0200)]
[SPIRV] Fix formatting of function tests

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

22 months ago[scudo] Support partial page releasing
Chia-hung Duan [Thu, 13 Oct 2022 22:52:04 +0000 (22:52 +0000)]
[scudo] Support partial page releasing

Block grouping enables us doing partial page releasing so that we can
release the pages in a finer granularity. Which means we don't need to
visit all blocks to determine which pages are unused. Besides, this
means we can do incremental page releasing depends on the number fo free
blocks.

Reviewed By: cryptoad, cferris

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

22 months ago[scudo] Manage free blocks in BatchGroup.
Chia-hung Duan [Thu, 13 Oct 2022 22:51:17 +0000 (22:51 +0000)]
[scudo] Manage free blocks in BatchGroup.

Scudo is supposed to allocate any blocks across the entired mapped
pages and each page is equally likely to be selected. Which means Scudo
is leaning to touch as many pages as possible. This brings better
security but it also sacrifices the chance of releasing dirty pages.

To alleviate the unmanagable footprint growing, this CL introduces the
BatchGroup concept. Each blocks will be classified into a BatchGroup
according to its address. While allocation, we are leaning to allocate
blocks in the same group first. Note that the blocks selected from a
group is still random over several pages. At the same time, we have
better prediction of dirty page growing speed. Besides, we are able to
do partial page releasing by examing part of BatchGroups.

Reviewed By: cryptoad, cferris

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

22 months ago[scudo] Add PageReleaseContext to convey page usage status.
Chia-hung Duan [Thu, 13 Oct 2022 22:33:35 +0000 (22:33 +0000)]
[scudo] Add PageReleaseContext to convey page usage status.

PageReleaseContext contains all the information needed for determing if
a page can be released. Splitting out the context increases the flexibility
of heterogenous free lists in the future. Also rename PackedCounterArray to
PageMap.

Reviewed By: cryptoad, cferris

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

22 months agoUse u16 to store Count/MaxCount
Chia-hung Duan [Thu, 13 Oct 2022 22:03:06 +0000 (22:03 +0000)]
Use u16 to store Count/MaxCount

The Count/MaxCount used in TransferBatch and PerClass can be fit in u16 in
current configurations and it's also reasonable to have a u16 limit. The
spare 16 bits will be used for additional status like pages mapping
status in a TransferBatch.

Reviewed By: cryptoad, cferris, vitalybuka

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

22 months agoPlatformDarwinKernel calls the ctor directly, not setting no-jit
Jason Molenda [Thu, 13 Oct 2022 23:28:18 +0000 (16:28 -0700)]
PlatformDarwinKernel calls the ctor directly, not setting no-jit

Fix a small thinko in https://reviews.llvm.org/D133534 .  Normally
DynamicLoaderDarwinKernels are created via the CreateInstance plugin
method, and that plugin method sets the Process CanJIT to false.
In the above patch, I added a new code path that can call the
DynamicLoaderDarwinKernel ctor directly, without going through
CreateInstance, and CanJIT was not being correctly set for the
process.

rdar://101148552

22 months agoDriver: Change default Android linker to lld.
Peter Collingbourne [Fri, 7 Oct 2022 04:13:05 +0000 (21:13 -0700)]
Driver: Change default Android linker to lld.

The clang distributed with the Android NDK has defaulted to lld since r22,
so let's update the driver to match.

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

22 months ago[NFC][FuncSpec] Add a test to show redundant function cloning.
Alexandros Lamprineas [Fri, 7 Oct 2022 16:40:41 +0000 (17:40 +0100)]
[NFC][FuncSpec] Add a test to show redundant function cloning.

Happens when we find identical specializations.

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

22 months ago[PGO] Do not create block count annotations when all weights are 0,
Wolfgang Pieb [Fri, 16 Sep 2022 16:40:14 +0000 (09:40 -0700)]
[PGO] Do not create block count annotations when all weights are 0,
avoiding an assertion.

A BB with a nonzero count, whose successor blocks all have 0 counts, could
cause an assertion. Don't create any branch weights in this case.

Reviewed By: xur

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

22 months ago[lld][WebAssembly] Add symbols marking start/end of stack region
Sam Clegg [Thu, 13 Oct 2022 16:53:12 +0000 (09:53 -0700)]
[lld][WebAssembly] Add symbols marking start/end of stack region

Currently emscripten is make assumptions about that memory layout,
assuming the stack is between `__data_end` and `__heap_base`:

https://github.com/emscripten-core/emscripten/blob/af961ad5c4c278ec510f0b7f7d522a95ee5a90f8/system/lib/compiler-rt/stack_limits.S#L42-L61

With this change we can be more precise:

https://github.com/emscripten-core/emscripten/pull/18057

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

22 months agoApply clang-tidy fixes for performance-for-range-copy in VectorOps.cpp (NFC)
Mehdi Amini [Thu, 6 Oct 2022 19:36:31 +0000 (19:36 +0000)]
Apply clang-tidy fixes for performance-for-range-copy in VectorOps.cpp (NFC)

22 months agoApply clang-tidy fixes for readability-identifier-naming in TosaCanonicalizations...
Mehdi Amini [Thu, 6 Oct 2022 19:32:24 +0000 (19:32 +0000)]
Apply clang-tidy fixes for readability-identifier-naming in TosaCanonicalizations.cpp (NFC)

22 months agoMove GCC-compatible pod-packing change to v16/old behavior available at v15 and below
David Blaikie [Thu, 13 Oct 2022 21:11:41 +0000 (21:11 +0000)]
Move GCC-compatible pod-packing change to v16/old behavior available at v15 and below

Change matches D126334/e59f648d698e since this change got punted from
v15 too.

22 months agoRevert "[Libomp] Do not error on undefined version script symbols"
Slava Zakharin [Thu, 13 Oct 2022 20:43:41 +0000 (13:43 -0700)]
Revert "[Libomp] Do not error on undefined version script symbols"

This reverts commit 096f93e73dc3f88636cdcb57515e3732385b452d.

Revert "[Libomptarget] Make the plugins ingore undefined exported symbols"

This reverts commit 3f62314c235bd2475c8e2b5b874b2932a444e823.

Revert "[LLD] Enable --no-undefined-version by default."

This reverts commit 7ec8b0d162e354c703f5390784287054601f9c69.

Three commits are reverted because of the current omp build fail
with GNU ld. See discussion here: https://reviews.llvm.org/rG096f93e73dc3

22 months ago[lld-macho] Preserve the size of common symbols
Jez Ng [Thu, 13 Oct 2022 20:44:33 +0000 (16:44 -0400)]
[lld-macho] Preserve the size of common symbols

We never noticed this before because the only time the size gets emitted is via
the linker map...

Reviewed By: #lld-macho, thakis

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

22 months ago[lld-macho] Include symbol sizes in mapfile
Jez Ng [Thu, 13 Oct 2022 20:44:29 +0000 (16:44 -0400)]
[lld-macho] Include symbol sizes in mapfile

This matches ld64's behavior.

Additionally, I edited the "Dead Stripped Symbols" header to omit "Address" --
this also matches ld64.

Reviewed By: #lld-macho, oontvoo

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

22 months ago[test] Reset timer flag after test is done
Arthur Eubanks [Thu, 13 Oct 2022 20:31:22 +0000 (13:31 -0700)]
[test] Reset timer flag after test is done

Fixes some test failures after D135219 on internal bots.

22 months ago[InstCombine] fold logical and/or to xor
Sanjay Patel [Thu, 13 Oct 2022 19:37:28 +0000 (15:37 -0400)]
[InstCombine] fold logical and/or to xor

(A | B) & ~(A & B) --> A ^ B

https://alive2.llvm.org/ce/z/qpFMns

We already have the equivalent fold for real
logic instructions, but this pattern may occur
with selects too.

This is part of solving issue #58313.

22 months ago[InstCombine] add tests for logical select xor folds; NFC
Sanjay Patel [Thu, 13 Oct 2022 18:32:33 +0000 (14:32 -0400)]
[InstCombine] add tests for logical select xor folds; NFC

issue #58313

22 months ago[ConstraintElim] Add support for GEPs with multiple indices.
Florian Hahn [Thu, 13 Oct 2022 20:08:33 +0000 (21:08 +0100)]
[ConstraintElim] Add support for GEPs with multiple indices.

Lift restriction on GEPs with a single index by iterating over all
indices and joining the {Coefficient, Variable} entries for all indices
together.

22 months agoFix the clang Sphinx build
Aaron Ballman [Thu, 13 Oct 2022 20:04:25 +0000 (16:04 -0400)]
Fix the clang Sphinx build

This should address the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/34157

22 months ago[ConstraintElim] Add nested GEP test with scalable vectors.
Florian Hahn [Thu, 13 Oct 2022 19:58:10 +0000 (20:58 +0100)]
[ConstraintElim] Add nested GEP test with scalable vectors.

22 months ago[llvm-objdump] Add HelpText for --no-addresses after D135040
Fangrui Song [Thu, 13 Oct 2022 19:50:15 +0000 (12:50 -0700)]
[llvm-objdump] Add HelpText for --no-addresses after D135040

22 months ago[PGO] Make emitted symbols hidden
Alex Brachet [Thu, 13 Oct 2022 19:47:15 +0000 (19:47 +0000)]
[PGO] Make emitted symbols hidden

This was reverted because it was breaking when targeting Darwin which
tried to export these symbols which are now hidden. It should be safe
to just stop attempting to export these symbols in the clang driver,
though Apple folks will need to change their TAPI allow list described
in the commit where these symbols were originally exported
https://github.com/llvm/llvm-project/commit/f5380185623be243ba0f1b18d4bd594ac5cc7163

Bug: https://github.com/llvm/llvm-project/issues/58265

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

22 months ago[LLDB][NativePDB] Fix struct layout when it has anonymous unions.
Zequan Wu [Thu, 29 Sep 2022 02:40:35 +0000 (19:40 -0700)]
[LLDB][NativePDB] Fix struct layout when it has anonymous unions.

Previously, lldb mistook fields in anonymous union in a struct as the direct
field of the struct, which causes lldb crashes due to multiple fields sharing
the same offset in a struct. This patch fixes it.

MSVC generated pdb doesn't have the debug info entity representing a anonymous
union in a struct. It looks like the following:
```
struct S {
union {
  char c;
  int i;
};
};

0x1004 | LF_FIELDLIST [size = 40]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1005 | LF_STRUCTURE [size = 32] `S`
         unique name: `.?AUS@@`
         vtable: <no type>, base list: <no type>, field list: 0x1004
```
Clang generated pdb is similar, though due to the [[ https://github.com/llvm/llvm-project/issues/57999 | bug ]],
it's not more useful than the debug info above. But that's not very relavent,
lldb should still be able to understand MSVC geneerated pdb.
```
0x1003 | LF_UNION [size = 60] `S::<unnamed-tag>`
         unique name: `.?AT<unnamed-type-$S1>@S@@`
         field list: <no type>
         options: forward ref (= 0x1003) | has unique name | is nested, sizeof 0
0x1004 | LF_FIELDLIST [size = 40]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
         - LF_NESTTYPE [name = ``, parent = 0x1003]
0x1005 | LF_STRUCTURE [size = 32] `S`
         unique name: `.?AUS@@`
         vtable: <no type>, base list: <no type>, field list: 0x1004
         options: contains nested class | has unique name, sizeof 4
0x1006 | LF_FIELDLIST [size = 28]
         - LF_MEMBER [name = `c`, Type = 0x0070 (char), offset = 0, attrs = public]
         - LF_MEMBER [name = `i`, Type = 0x0074 (int), offset = 0, attrs = public]
0x1007 | LF_UNION [size = 60] `S::<unnamed-tag>`
         unique name: `.?AT<unnamed-type-$S1>@S@@`
         field list: 0x1006
         options: has unique name | is nested | sealed, sizeof
```
This patch delays the FieldDecl creation when travesing LF_FIELDLIST so we know
if there are multiple fields are in the same offsets and are able to group them
into different anonymous unions based on offsets. Nested anonymous union will
be flatten into one anonymous union, because we simply don't have that info, but
they are equivalent in terms of union layout.

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

22 months ago[DirectX backend] [NFC] Change Resources::write to const.
Xiang Li [Tue, 11 Oct 2022 18:43:42 +0000 (11:43 -0700)]
[DirectX backend] [NFC] Change Resources::write to const.

Change Resources::write to const.
Also fix parameter name.

Reviewed By: beanz

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

22 months agoOnly enable driver test if in driver build
Alex Brachet [Thu, 13 Oct 2022 19:26:06 +0000 (19:26 +0000)]
Only enable driver test if in driver build

22 months ago[llvm-driver] Add lld
Alex Brachet [Thu, 13 Oct 2022 19:23:25 +0000 (19:23 +0000)]
[llvm-driver] Add lld

The llvm-driver, enabled with LLVM_TOOL_LLVM_DRIVER_BUILD combines many llvm executables
into one to save overall toolchain size. This patch adds the capability for lld to be part of the
llvm-driver.

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

22 months agoFix clang version check in SARIF diagnostics test
Yabin Cui [Thu, 13 Oct 2022 19:16:58 +0000 (15:16 -0400)]
Fix clang version check in SARIF diagnostics test

This is to allow future clang versions and use of LLVM_VERSION_PATCH.

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

22 months ago[clang] Update ASM goto documentation to reflect how Clang differs from GCC
Bill Wendling [Wed, 12 Oct 2022 21:43:38 +0000 (14:43 -0700)]
[clang] Update ASM goto documentation to reflect how Clang differs from GCC

That said, we are planning to add this support in the near future.

Link: https://github.com/llvm/llvm-project/issues/53562
Differential Revision: https://reviews.llvm.org/D135818

22 months ago[libc] Add a simple implementation of the posix_spawn function.
Siva Chandra Reddy [Tue, 11 Oct 2022 00:38:29 +0000 (00:38 +0000)]
[libc] Add a simple implementation of the posix_spawn function.

The implementation currently ignores all spawn attributes. Support for
them will be added in future changes.

A simple allocator for integration tests has been added so that the
integration test for posix_spawn can use the
posix_spawn_file_actions_add* functions.

Reviewed By: michaelrj

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

22 months agoUnbreak Windows build
Sanjoy Das [Thu, 13 Oct 2022 18:09:09 +0000 (11:09 -0700)]
Unbreak Windows build

Without the llvm_unreachable, Windows complains about not returning a
value from mlir::isSpeculatable on all paths.

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

22 months ago[flang] Lower assumed length character allocatable and pointer arguments
Jonathon Penix [Fri, 7 Oct 2022 02:37:10 +0000 (19:37 -0700)]
[flang] Lower assumed length character allocatable and pointer arguments

It seems the needed functionality was already implemented for host associations,
so turn that code into a function and move it into a (hopefully appropriate)
common location and reuse it.

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

22 months ago[ConstraintElim] Move check-and-replace logic to helper function (NFC).
Florian Hahn [Thu, 13 Oct 2022 17:58:37 +0000 (18:58 +0100)]
[ConstraintElim] Move check-and-replace logic to helper function (NFC).

Move logic to check and replace conditions to a helper function. This
isolates the code, allows using early returns, reduces the
indentation and simplifies eliminateConstraints.

22 months ago[NVPTX] Support neg{.ftz} for f16 and f16x2
Jakub Chlanda [Thu, 13 Oct 2022 17:40:00 +0000 (10:40 -0700)]
[NVPTX] Support neg{.ftz} for f16 and f16x2

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

22 months agoFix LSan build
Wiktor Garbacz [Thu, 13 Oct 2022 17:40:27 +0000 (10:40 -0700)]
Fix LSan build

This change fixes a build bug introduced in
39db491957dcf095936d81bed89c2b4edae2a1e7

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

22 months agoThread safety analysis: Support copy-elided production of scoped capabilities through...
Aaron Puchert [Wed, 13 Jul 2022 23:47:52 +0000 (01:47 +0200)]
Thread safety analysis: Support copy-elided production of scoped capabilities through arbitrary calls

When support for copy elision was initially added in e97654b2f2807, it
was taking attributes from a constructor call, although that constructor
call is actually not involved. It seems more natural to use attributes
on the function returning the scoped capability, which is where it's
actually coming from. This would also support a number of interesting
use cases, like producing different scope kinds without the need for tag
types, or producing scopes from a private mutex.

Changing the behavior was surprisingly difficult: we were not handling
CXXConstructorExpr calls like regular calls but instead handled them
through the DeclStmt they're contained in. This was based on the
assumption that constructors are basically only called in variable
declarations (not true because of temporaries), and that variable
declarations necessitate constructors (not true with C++17 anymore).

Untangling this required separating construction from assigning a
variable name. When a call produces an object, we use a placeholder
til::LiteralPtr for `this`, and we collect the call expression and
placeholder in a map. Later when going through a DeclStmt, we look up
the call expression and set the placeholder to the new VarDecl.

The change has a couple of nice side effects:
* We don't miss constructor calls not contained in DeclStmts anymore,
  allowing patterns like
    MutexLock{&mu}, requiresMutex();
  The scoped lock temporary will be destructed at the end of the full
  statement, so it protects the following call without the need for a
  scope, but with the ability to unlock in case of an exception.
* We support lifetime extension of temporaries. While unusual, one can
  now write
    const MutexLock &scope = MutexLock(&mu);
  and have it behave as expected.
* Destructors used to be handled in a weird way: since there is no
  expression in the AST for implicit destructor calls, we instead
  provided a made-up DeclRefExpr to the variable being destructed, and
  passed that instead of a CallExpr. Then later in translateAttrExpr
  there was special code that knew that destructor expressions worked a
  bit different.
* We were producing dummy DeclRefExprs in a number of places, this has
  been eliminated. We now use til::SExprs instead.

Technically this could break existing code, but the current handling
seems unexpected enough to justify this change.

Reviewed By: aaron.ballman

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

22 months ago[clangd] Add missing readonly modifier for const generic parameters
Tom Praschan [Fri, 7 Oct 2022 10:46:11 +0000 (12:46 +0200)]
[clangd] Add missing readonly modifier for const generic parameters

Fixes https://github.com/clangd/clangd/issues/1222. As discussed there, we saw no reason to keep this check.

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

22 months ago[llvm-ocaml] Fix arity mismatch in pointer bindings
Alan Hu [Thu, 13 Oct 2022 17:07:06 +0000 (10:07 -0700)]
[llvm-ocaml] Fix arity mismatch in pointer bindings

Reviewed By: nikic

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

22 months ago[clang] Support `constexpr` for some `ASTNodeKind` member functions
Eric Li [Wed, 12 Oct 2022 20:28:59 +0000 (16:28 -0400)]
[clang] Support `constexpr` for some `ASTNodeKind` member functions

Add `constexpr` support for:

  * The `getFromNodeKind` factory function
  * `isSame`
  * `isNone`
  * `hasPointerIdentity`

This enables these functions to be used in SFINAE context for AST node
types.

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

22 months ago[lld/mac] Add test for bug fixed in reland 82ca390062d115
Nico Weber [Thu, 13 Oct 2022 15:44:09 +0000 (11:44 -0400)]
[lld/mac] Add test for bug fixed in reland 82ca390062d115

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

22 months ago[lld][WebAssembly] Add `--extra-features` flag to add addional features
Sam Clegg [Wed, 12 Oct 2022 23:39:47 +0000 (16:39 -0700)]
[lld][WebAssembly] Add `--extra-features` flag to add addional features

This flag acts just like the existing `--features` flag but instead
of replacing the set of inferred features it adds to it.

This is useful for example if you want to `--export` a mutable global
but none of the input of object were built with mutable global support.
In that case you can do `--extra-features=mutable-globals` to avoid the
linker error that would otherwise be generated in this case:

wasm-ld: error: mutable global exported but 'mutable-globals' feature not present in inputs: `__stack_pointer`. Use --no-check-features to suppress.

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

22 months ago[PassTimingInfo] Stop double (or worse) counting passes/analyses
Arthur Eubanks [Tue, 4 Oct 2022 22:13:16 +0000 (15:13 -0700)]
[PassTimingInfo] Stop double (or worse) counting passes/analyses

If we nest timers, we end up double counting anything nested.

The most egregious is ModuleInlinerWrapperPass/DevirtSCCRepeatedPass showing up as >20% of the total time when they're just wrappers.

Analyses also end up getting counted multiple times because they're nested inside wrappers and passes.

Ignore ModuleInlinerWrapperPass/DevirtSCCRepeatedPass and put analyses into their own TimerGroup.

Reviewed By: asbirlea

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

22 months ago[RISCV] Match (select C, -1, X)->(or -C, X) during lowerSelect
Craig Topper [Thu, 13 Oct 2022 15:52:58 +0000 (08:52 -0700)]
[RISCV] Match (select C, -1, X)->(or -C, X) during lowerSelect

Same with (select C, X, -1), (select C, 0, X), and (select C, X, 0).

There's a DAGCombine after we turn the select into select_cc, but
that may introduce a setcc that didn't previously exist. We could
add more DAGCombines to remove the extra setcc, but this seemed lower
effort.

Reviewed By: reames

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

22 months ago[lld/mac] Convert undef-spell-corrector.s test to split-file
Nico Weber [Thu, 13 Oct 2022 15:18:59 +0000 (11:18 -0400)]
[lld/mac] Convert undef-spell-corrector.s test to split-file

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

22 months ago[lld/mac] Make two local variables const
Nico Weber [Thu, 13 Oct 2022 14:36:08 +0000 (10:36 -0400)]
[lld/mac] Make two local variables const

While reading this code, I was wondering if we change these variables in the
loop. We don't, so make them const to make this easier to see next time.

No behavior change.

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

22 months agoFix handling of rank-1 tensors in tosa.reduce_sum
Ramiro Leal-Cavazos [Thu, 13 Oct 2022 16:02:01 +0000 (09:02 -0700)]
Fix handling of rank-1 tensors in tosa.reduce_sum

The conversion of `tosa.reduce_sum` to linalg creates a
`linalg.generic` op that produces a tensor of rank `input_rank -
1`. This tensor is then expanded back into a tensor of rank
`input_rank`. In the case where the tensor being expanded is rank-0,
the reassociation map used must be empty. However, the current
implementation indexes and modifies the reassociation map independent
of the rank of the tensor being expanded, resulting in out-of-bounds
indexing when the tensor being expanded is rank-0. This commit adds a
guard to the reassociation map indexing.

Reviewed By: jpienaar

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

22 months agoApply clang-tidy fixes for performance-unnecessary-value-param in TosaCanonicalizatio...
Mehdi Amini [Thu, 6 Oct 2022 19:31:50 +0000 (19:31 +0000)]
Apply clang-tidy fixes for performance-unnecessary-value-param in TosaCanonicalizations.cpp (NFC)

22 months agoApply clang-tidy fixes for modernize-use-equals-default in TosaCanonicalizations...
Mehdi Amini [Thu, 6 Oct 2022 19:31:17 +0000 (19:31 +0000)]
Apply clang-tidy fixes for modernize-use-equals-default in TosaCanonicalizations.cpp (NFC)

22 months ago[CodeGenPrep] Handle constants in ConvertPhiType
David Green [Thu, 13 Oct 2022 15:41:44 +0000 (16:41 +0100)]
[CodeGenPrep] Handle constants in ConvertPhiType

This is a simple addition to the convertPhiTypes in CodeGenPrepare to
consider and convert constants as it converts the phi type. Someone
fixed the bug in the motivating example, so the undef is now a constant
0. This does mean converting between integer and floating point
constants, which may have different materialization.

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

22 months ago[mlir][Transform] Fix dropReverseMapping early exit condition
Nicolas Vasilache [Thu, 13 Oct 2022 15:13:25 +0000 (08:13 -0700)]
[mlir][Transform] Fix dropReverseMapping early exit condition

Previously, the erasure would not trigger and result in surprising behavior.

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

22 months ago[MemCpyOpt] Add additional tests with lifetime intrinsics (NFC)
Nikita Popov [Thu, 13 Oct 2022 15:29:37 +0000 (17:29 +0200)]
[MemCpyOpt] Add additional tests with lifetime intrinsics (NFC)

22 months ago[AArch64] Add ConvertPhiType constant tests. NFC
David Green [Thu, 13 Oct 2022 15:23:34 +0000 (16:23 +0100)]
[AArch64] Add ConvertPhiType constant tests. NFC

22 months ago[MemCpyOpt] Add additional debug output (NFC)
Nikita Popov [Thu, 13 Oct 2022 15:02:16 +0000 (17:02 +0200)]
[MemCpyOpt] Add additional debug output (NFC)

22 months ago[MemCpyOpt] Don't run full pipeline in test (NFC)
Nikita Popov [Thu, 13 Oct 2022 14:47:04 +0000 (16:47 +0200)]
[MemCpyOpt] Don't run full pipeline in test (NFC)

Just memcpyopt is enough for this test.

22 months agoUpdate developer policy on potentially breaking changes
Aaron Ballman [Thu, 13 Oct 2022 14:58:52 +0000 (10:58 -0400)]
Update developer policy on potentially breaking changes

We've recently had issues appropriately notifying users and
stakeholders of changes to projects that may be potentially disruptive
when upgrading. This led to discussion on Discourse about how to
improve the situation, which can be found at:
https://discourse.llvm.org/t/rfc-add-new-discourse-channel-for-potentially-breaking-disruptive-changes-for-clang/65251

Ultimately, it sounds like we want to encourage three things:

* Alert vendors during the code review so they can provide early
  feedback on potentially breaking changes that would be unacceptable
  for them.
* Alert vendors and users after committing the changes so they can
  perform pre-release testing on a completed change to determine if it
  causes unreasonable problems for them.
* Alert users more clearly through the release notes so that it's
  easier to determine how disruptive an upgrade might be.

This updates the developer policy accordingly.

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

22 months ago[LV] Add epilogue test with variable induction start value.
Florian Hahn [Thu, 13 Oct 2022 14:56:26 +0000 (15:56 +0100)]
[LV] Add epilogue test with variable induction start value.

Add additional test mentioned by @venkataramanan.kumar.llvm in
D92132.

22 months agoRevert "[libc] New version of the mem* framework"
Guillaume Chatelet [Thu, 13 Oct 2022 14:49:58 +0000 (14:49 +0000)]
Revert "[libc] New version of the mem* framework"

This reverts commit d55f2d8ab076298cfd745c05c1b4dfd5583f8b9e.

22 months ago[libc] New version of the mem* framework
Guillaume Chatelet [Thu, 13 Oct 2022 14:43:44 +0000 (14:43 +0000)]
[libc] New version of the mem* framework

This version is more composable and also simpler at the expense of being more explicit and more verbose. It also provides minimal implementations for ARM platforms.

Codegen can be checked here https://godbolt.org/z/x19zvE59v

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

22 months agoReland "[lld/mac] Port typo correction for undefined symbols from ELF port"
Nico Weber [Wed, 12 Oct 2022 00:40:26 +0000 (20:40 -0400)]
Reland "[lld/mac] Port typo correction for undefined symbols from ELF port"

The only difference in the reland is that the loop at the top of
getAlternativeSpelling() now calls dyn_cast_or_null() instead
of dyn_cast() -- a file's symbols list can contain null entries.

The test for this might be slightly involved, so I'll land it in
a follow-up, to make the reland similar to the original commit.

Originally reviewed at:
Differential Revision: https://reviews.llvm.org/D135038

This reverts commit 317b5582b813c51d1fb6723fd44b227b7f274bc7.

22 months ago[SLP]Improve costs of vectorized loads/stores by analyzing GEPs.
Alexey Bataev [Tue, 4 Oct 2022 18:14:38 +0000 (11:14 -0700)]
[SLP]Improve costs of vectorized loads/stores by analyzing GEPs.

When generating masked gathers nodes, SLP vectorizer accounts the cost
of the GEPs for loads as part of the scalar-vector transformation cost
estimation. But it does not do it for vectorized loads/stores, while it
may completely remove some of the GEPs completely. Because of this in
some cases masked gather operation can be much more profitable rather
than regular vectorization (masked-gather cost + vector GEP - scalar
loads + GEPs comparing to vectorized loads - scalar loads).
Added the analysis of the removed scalarGEPs for vectorized load/store nodes for better cost estimation.

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