Commit Graph

47310 Commits

Author SHA1 Message Date
Nikita Popov 3c86642edd [Bitstream] Reject implausibly large reservations
If we're trying to reserve more memory than bits in the stream,
reject this early to avoid OOM.
2022-02-07 12:16:12 +01:00
Nikita Popov 8a71854183 [Bitcode] Handle invalid abbrev number error more gracefully
Avoid report_fatal_error(), propagate the error upwards instead.
2022-02-07 10:34:34 +01:00
luxufan 9920943ea2 [JITLink] Fix the incorrect relocation behavior for R_RISCV_BRANCH
In D116573, the relocation behavior of R_RISCV_BRANCH didn't consider that branch instruction like 'bge' has a branch target address which is given as a PC-relative offset, sign-extend and multiplied by 2.
Although the target address is a 12-bits number, acctually its range is [-4096, 4094].

This patch fix it.

Differential Revision: https://reviews.llvm.org/D118151
2022-02-07 14:34:19 +08:00
Kazu Hirata 949f56465b [IR] Use default member initialization in GlobalValue (NFC) 2022-02-06 16:36:29 -08:00
Kazu Hirata a1a8d10a17 [Transforms] Use default member initialization in LibCallSimplifier (NFC) 2022-02-06 16:36:27 -08:00
Kazu Hirata 3fce5bb7b0 [Transforms] Use default member initialization in LoopVersioning (NFC) 2022-02-06 16:36:25 -08:00
Simon Pilgrim 94453952fc [KnownBits] Add support for X*X self-multiplication (update)
Rename the SelfMultiply argument to make it clearer that the argument must not be undef

Differential Revision: https://reviews.llvm.org/D108992
2022-02-06 19:40:08 +00:00
Kazu Hirata eb65f971f2 [llvm] Fix header guards (NFC)
Identified with llvm-header-guard.
2022-02-06 10:54:48 -08:00
Simon Pilgrim 784c78f20f Fix Wdocumentation unknown parameter warning 2022-02-06 16:52:32 +00:00
Kazu Hirata a867f32c5f [Transforms] Use default member initialization in EscapeEnumerator (NFC) 2022-02-05 21:39:19 -08:00
Kazu Hirata bd5b279af0 [IR] Use default member initialization in PMDataManager (NFC) 2022-02-05 21:39:17 -08:00
Adrian Prantl c5699c6eb7 fix module build failure 2022-02-05 16:30:39 -08:00
Adrian Prantl 511fa14ce3 fix module build failure 2022-02-05 16:30:38 -08:00
Adrian Prantl 607c589048 fix module build failure 2022-02-05 16:30:38 -08:00
Kazu Hirata 7ae64e598a [Support] Use default member initialization in ScopedPrinter (NFC) 2022-02-05 16:29:28 -08:00
Kazu Hirata 1569252774 [IR] Use default member initialization in GlobalObject (NFC) 2022-02-05 16:29:26 -08:00
Kazu Hirata f072603685 [ADT] Use default member initialization in OptionalStorage (NFC) 2022-02-05 16:29:24 -08:00
Kazu Hirata d0f52ff12a [ADT] Use default member initialization in DebugEpochBase (NFC) 2022-02-05 16:29:20 -08:00
Wael Yehia addd073325 [AIX][PowerPC][PGO] Generate .ref for some PGO sections
For PGO on AIX, when we switch to the linux-style PGO variable access
(via _start and _stop labels), we need the compiler to generate a .ref
assembly for each of the three csects:

 -   __llvm_prf_data[RW]
 -   __llvm_prf_names[RO]
 -   __llvm_prf_vnds[RW]

We insert the .ref inside the __llvm_prf_cnts[RW] csect so that if it's
live then the 3 csects are live.

For example, for a testcase with at least one function definition, when
compiled with -fprofile-generate we should generate:

        .csect __llvm_prf_cnts[RW],3
        .ref __llvm_prf_data[RW]   <<============ needs to be inserted
        .ref __llvm_prf_names[RO]  <<===========

the __llvm_prf_vnds is not always present, so we reference it only when
it's present.

Reviewed By: sfertile, daltenty

Differential Revision: https://reviews.llvm.org/D116607
2022-02-05 06:34:20 -05:00
Bill Wendling c6f0940d99 [NFC] Remove unnecessary #includes
An attempt to reduce the number of files that are recompiled due to a change.

Differential Revision: https://reviews.llvm.org/D119055
2022-02-04 21:22:41 -08:00
Masoud Ataei 8ce13bc93b [PowerPC] Option controling scalar MASS convertion
differential: https://reviews.llvm.org/D119035

reviewer: bmahjour
2022-02-04 13:24:22 -08:00
Simon Pilgrim 78c6b90000 [APInt] Update APInt::isShiftedMask() description. NFC.
Make it clear that it matches a non-empty sequence of ones, matches the descriptions for isShiftedMask_32/64 as suggested on D119019
2022-02-04 20:39:05 +00:00
Dawid Jurczak 39ceea26c5 [NFC] Move FoldingSetNodeIDRef::ComputeHash and FoldingSetNodeID::ComputeHash definitions to header
Lack of ComputeHash inlining slows down slightly FoldingSetBase::FindNodeOrInsertPos calls.
Inlining makes it faster which matters in particular for FoldingSet users in ASTContext.

Extracted from: https://reviews.llvm.org/D118385

Differential Revision: https://reviews.llvm.org/D118612
2022-02-04 18:03:42 +01:00
Nikita Popov c00ef03d73 [BitstreamReader] Handle errors more gracefully
Use proper error reporting instead of report_fatal_error().
2022-02-04 17:23:08 +01:00
Nikita Popov f62a400cdf [Statepoint] Determine return type from elementtype attribute
Based on the LangRef change in D117890, this uses the elementtype
attribute rather than the pointer element type to determine the
statepoint callee function type, making statepoints compatible
with opaque pointers.
2022-02-04 14:40:27 +01:00
serge-sans-paille ffe8720aa0 Reduce dependencies on llvm/BinaryFormat/Dwarf.h
This header is very large (3M Lines once expended) and was included in location
where dwarf-specific information were not needed.

More specifically, this commit suppresses the dependencies on
llvm/BinaryFormat/Dwarf.h in two headers: llvm/IR/IRBuilder.h and
llvm/IR/DebugInfoMetadata.h. As these headers (esp. the former) are widely used,
this has a decent impact on number of preprocessed lines generated during
compilation of LLVM, as showcased below.

This is achieved by moving some definitions back to the .cpp file, no
performance impact implied[0].

As a consequence of that patch, downstream user may need to manually some extra
files:

llvm/IR/IRBuilder.h no longer includes llvm/BinaryFormat/Dwarf.h
llvm/IR/DebugInfoMetadata.h no longer includes llvm/BinaryFormat/Dwarf.h

In some situations, codes maybe relying on the fact that
llvm/BinaryFormat/Dwarf.h was including llvm/ADT/Triple.h, this hidden
dependency now needs to be explicit.

$ clang++ -E  -Iinclude -I../llvm/include ../llvm/lib/Transforms/Scalar/*.cpp -std=c++14 -fno-rtti -fno-exceptions | wc -l
after:   10978519
before:  11245451

Related Discourse thread: https://llvm.discourse.group/t/include-what-you-use-include-cleanup
[0] https://llvm-compile-time-tracker.com/compare.php?from=fa7145dfbf94cb93b1c3e610582c495cb806569b&to=995d3e326ee1d9489145e20762c65465a9caeab4&stat=instructions

Differential Revision: https://reviews.llvm.org/D118781
2022-02-04 11:44:03 +01:00
Nikita Popov c680eeab30 [IRBuilder][RS4GC] Require FunctionCallee when creating statepoint
This makes the statepoint methods in IRBuilder accept a
FunctionCallee, which carries both the callee and function type.
This is used to add the elementtype attribute to the statepoint call.

RS4GC requires an additional tweak to actually preserve that attribute
-- previously the attributes on the call were completely overwritten.

Differential Revision: https://reviews.llvm.org/D118886
2022-02-04 09:47:32 +01:00
Snehasish Kumar dbf47d227d Revert "[ProfileData] Read and symbolize raw memprof profiles."
This reverts commit 26f978d4c5.

This patch added a transitive dependency on libcurl via symbolize.
See discussion
https://reviews.llvm.org/D116784#inline-1137928
https://reviews.llvm.org/D113717#3295350
2022-02-03 16:14:05 -08:00
Snehasish Kumar 26f978d4c5 [ProfileData] Read and symbolize raw memprof profiles.
This change extends the RawMemProfReader to read all the sections of the
raw profile and symbolize the virtual addresses recorded as part of the
callstack for each allocation. For now the symbolization is used to
display the contents of the profile with llvm-profdata.

Differential Revision: https://reviews.llvm.org/D116784
2022-02-03 14:33:50 -08:00
Snehasish Kumar 14f4f63af5 [memprof] Print out the summary in YAML format.
Print out the profile summary in YAML format to make it easier to for
tools and tests to read in the contents of the raw profile.

Differential Revision: https://reviews.llvm.org/D116783
2022-02-03 14:33:50 -08:00
Snehasish Kumar d2df8d5a78 [instrprof][NFC] Templatize the instrprof iterator.
This change templatizes the InstrProfIterator where the default
specialization is based on the current usage, i.e. the reader_type is
InstrProfReader and the record_type (value_type) is
NamedInstrProfRecord. A subsequent patch will use the same iterator
template to implement an iterator for the RawMemProfReader.

Differential Revision: https://reviews.llvm.org/D116782
2022-02-03 14:33:49 -08:00
Snehasish Kumar 3c34ef4036 [DebugInfo] Move the SymbolizableObjectFile header to include/llvm.
This change moves the SymbolizableObjectFile header to
include/llvm/DebugInfo/Symbolize. Making this header available to other
llvm libraries simplifies use cases where implicit caching, multiple
platform support and other features of the Symbolizer class are not
required. This also makes the dependent libraries easier to unit test
by having mocks which derive from SymbolizableModule.

Differential Revision: https://reviews.llvm.org/D116781
2022-02-03 14:33:49 -08:00
Jessica Paquette 9a61e731ff [GlobalISel] Combine (G_*ADDO x, 0) -> x + no carry out
Similar to the G_*MULO change.

The code for checking if a constant is legal/pre-legalize is shared between
these, and is kind of hairy. So, factor it out into a new function:
`isConstantLegalOrBeforeLegalizer`.

To make the refactoring clean, further refactor `isLegalOrBeforeLegalizer` into
a wrapper for two functions:

- `isPreLegalize`
- `isLegal`

This is a bit easier to read in general.

https://godbolt.org/z/KW7oszP1o

Differential Revision: https://reviews.llvm.org/D118655
2022-02-03 14:25:15 -08:00
Jessica Paquette c636899dc1 [GlobalISel] Combine: (G_*MULO x, 0) -> 0 + no carry out
Similar to the following combine in `DAGCombiner::visitMULO`:

```
  // fold (mulo x, 0) -> 0 + no carry out
  if (isNullOrNullSplat(N1))
    return CombineTo(N, DAG.getConstant(0, DL, VT),
                     DAG.getConstant(0, DL, CarryVT));
```

This fixes some generally poor codegen for `*mulo`:

https://godbolt.org/z/eTxYsvz8f

Differential Revision: https://reviews.llvm.org/D118635
2022-02-03 14:23:58 -08:00
Ben Barham a5cff6af1d [VFS] Add back setFallthrough for downstream users
This fixes lldb's build. We can remove this in the future if we want but
for now this will be nicer to existing consumers.
2022-02-03 13:46:18 -08:00
Ben Barham 502f14d6f2 [VFS] Add a "redirecting-with" field to overlays
Extend "fallthrough" to allow a third option: "fallback". Fallthrough
allows the original path to used if the redirected (or mapped) path
fails. Fallback is the reverse of this, ie. use the original path and
fallback to the mapped path otherwise.

While this result *can* be achieved today using multiple overlays, this
adds a much more intuitive option. As an example, take two directories
"A" and "B". We would like files from "A" to be used, unless they don't
exist, in which case the VFS should fallback to those in "B".

With the current fallthrough option this is possible by adding two
overlays: one mapping from A -> B and another mapping from B -> A. Since
the frontend *nests* the two RedirectingFileSystems, the result will
be that "A" is mapped to "B" and back to "A", unless it isn't in "A" in
which case it fallsthrough to "B" (or fails if it exists in neither).

Using "fallback" semantics allows a single overlay instead: one mapping
from "A" to "B" but only using that mapping if the operation in "A"
fails first.

"redirect-only" is used to represent the current "fallthrough: false"
case.

Differential Revision: https://reviews.llvm.org/D117937
2022-02-03 13:10:23 -08:00
Mircea Trofin 592f52de33 [nfc][regalloc] const LiveIntervals within the allocator
Once built, LiveIntervals are immutable. This patch captures that.

Differential Revision: https://reviews.llvm.org/D118918
2022-02-03 12:35:36 -08:00
Amir Ayupov 9f0ce07711 [Support][NFC] Don’t duplicate class or function name in comment
Refactor comments in CommandLine.h to follow the Coding Style rule

Reviewed By: MaskRay, serge-sans-paille

Differential Revision: https://reviews.llvm.org/D118859
2022-02-03 10:02:17 -08:00
Dawid Jurczak f5e1ace9b0 [NFC] Move FoldingSetNodeID::AddInteger and FoldingSetNodeID::AddPointer definitions to header
Lack of AddInteger/AddPointer inlining slows down NodeEquals/Profile/:operator== calls.
Inlining makes FunctionProtoTypes/PointerTypes/ElaboratedTypes/ParenTypes Profile functions faster
but since NodeEquals is still called indirectly through function pointer from FindNodeOrInsertPos
there is room for further inlining improvements.

Extracted from: https://reviews.llvm.org/D118385

Differential Revision: https://reviews.llvm.org/D118610
2022-02-03 15:34:49 +01:00
Simon Pilgrim 6b4ebdd46f ModuleUtils - VFABI::setVectorVariantNames - use ArrayRef<> instead of const SmallVector to pass argument 2022-02-03 12:11:48 +00:00
Serge Pavlov d2f132f0b7 [ConstantFolding] Fold constrained compare intrinsics
The change implements constant folding of ‘llvm.experimental.constrained.fcmp’
and ‘llvm.experimental.constrained.fcmps’ intrinsics.

Differential Revision: https://reviews.llvm.org/D110322
2022-02-03 16:45:56 +07:00
Sander de Smalen 01bfe9729a [ISEL] Canonicalize STEP_VECTOR to LHS if RHS is a splat.
This helps recognise patterns where we're trying to match STEP_VECTOR
patterns to INDEX instructions that take a GPR for the Start/Step.

The reason for canonicalising this operation to the LHS is
because it will already be canonicalised to the LHS if the RHS
is a constant splat vector.

Reviewed By: paulwalker-arm

Differential Revision: https://reviews.llvm.org/D118459
2022-02-03 09:31:46 +00:00
Matt Arsenault 5ecbcc207c RegScavenger: Add function to externally reserve a scavenging index
AMDGPU separately tracks the frame index we use for the emergency
spill slot. In the case where we need to spill SGPRs to memory, we
manually handle the save and restore. In other cases, the scavenger
handles the spills normally.

In a future change, I will need to add a second scavenging index in
order to free a second register in case we are spilling to a large
offset and also have to avoid clobbering a condition register
(SCC). In the intersection of these two cases, we will end up
recursively calling eliminateFrameIndex. We need to report to the
scavenger that the first scavenging frame index is unavailable, and
that the register is already used to avoid double spilling to the
scavenging slot (and avoid clobbering the previously evicted register,
and getting the same register for both scavenge calls).

This is really ugly but I don't see a better way without requiring
targets to be far more aware of how the scavenger iterator is
advanced.
2022-02-02 19:15:52 -05:00
Florian Mayer fa75a62cb5 [NFC] pull retvec logic to MemoryTaggingSupport.
we will also need this for aarch64 stack tagging.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D118852
2022-02-02 16:05:52 -08:00
Florian Mayer f7a6c341cb [mte] support more complicated lifetimes (e.g. for exceptions).
Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D118848
2022-02-02 14:39:22 -08:00
Florian Mayer 712b31e2d4 [NFC] factor isStandardLifetime out of HWASan
this is so we can use it for aarch64 stack tagging.

Reviewed By: eugenis

Differential Revision: https://reviews.llvm.org/D118836
2022-02-02 13:23:55 -08:00
Shilei Tian 1a547a94c1 [OMPIRBuilder] Add support for atomic compare
This patch adds the support for `atomic compare` in `OMPIRBuilder`.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D118547
2022-02-02 15:39:14 -05:00
Adrian Prantl 4904e85313 Add missing include diagnosed by the modules build. 2022-02-02 09:08:11 -08:00
Simon Pilgrim 675a557316 Remove redundant LLVM_HAS_RVALUE_REFERENCE_THIS and LLVM_LVALUE_FUNCTION defines
Now that VS2017 support has been dropped (D114639), the LLVM_HAS_RVALUE_REFERENCE_THIS define is always true and the LLVM_LVALUE_FUNCTION define is always enabled for ref-qualifiers.

This patch proposes we remove the defines and use the qualifiers directly.

Differential Revision: https://reviews.llvm.org/D118609
2022-02-02 16:56:26 +00:00
Alex Lorenz 116c1bea65 [clang][macho] add clang frontend support for emitting macho files with two build version load commands
This patch extends clang frontend to add metadata that can be used to emit macho files with two build version load commands.
It utilizes "darwin.target_variant.triple" and "darwin.target_variant.SDK Version" metadata names for that.

MachO uses two build version load commands to represent an object file / binary that is targeting both the macOS target,
and the Mac Catalyst target. At runtime, a dynamic library that supports both targets can be loaded from either a native
macOS or a Mac Catalyst app on a macOS system. We want to add support to this to upstream to LLVM to be able to build
compiler-rt for both targets, to finish the complete support for the Mac Catalyst platform, which is right now targetable
by upstream clang, but the compiler-rt bits aren't supported because of the lack of this multiple build version support.

Differential Revision: https://reviews.llvm.org/D115415
2022-02-02 08:30:39 -08:00