Commit Graph

49050 Commits

Author SHA1 Message Date
Vitaly Buka 93600eb50c [NFC][asan] Rename ModuleAddressSanitizerPass 2022-09-06 15:02:11 -07:00
Vitaly Buka e7bac3b9fa [msan] Convert Msan to ModulePass
MemorySanitizerPass function pass violatied requirement 4 of function
pass to do not insert globals. Msan nees to insert globals for origin
tracking, and paramereters tracking.

https://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class

Reviewed By: kstoimenov, fmayer

Differential Revision: https://reviews.llvm.org/D133336
2022-09-06 15:01:04 -07:00
Arthur Eubanks 7f57c97d30 [ThinLTOBitcodeWriter] Mark pass as required
Or else with -opt-bisect-limit we don't write ThinLTO bitcode.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D133378
2022-09-06 14:47:34 -07:00
bzcheeseman 716b9f7a1a [LLVM][Support/ADT] Add assert for isPresent to dyn_cast.
This change adds an assert to dyn_cast that the value passed-in is present. In the past, this relied on the isa_impl assertion (which still works in many cases) but which we can tighten up for a better QoI.

The PointerUnion change is because it seems like (based on the call sites) the semantics of the member dyn_cast are actually dyn_cast_if_present.

Reviewed By: rriddle

Differential Revision: https://reviews.llvm.org/D133221
2022-09-06 13:58:56 -07:00
raghavmedicherla 142f51fc2f Support: Add mapped_file_region::sync(), equivalent to msync
Add mapped_file_region::sync(), equivalent to POSIX msync,
synchronizing written content to disk without unmapping the region.
Asserts if the mode is not mapped_file_region::readwrite.

Note that I don't have access to a Windows machine, so I can't
easily run those unit tests.

Change by dexonsmith

Differential Revision: https://reviews.llvm.org/D95494
2022-09-06 16:46:37 -04:00
Markus Böck f049b2c3fc [MC] Emit Stackmaps before debug info
This patch is essentially an alternative to https://reviews.llvm.org/D75836 and was mentioned by @lhames in a comment.

The gist of the issue is that Mach-O has restrictions on which kind of sections are allowed after debug info has been emitted, which is also properly asserted within LLVM. Problem is that stack maps are currently emitted as one of the last sections in each target-specific AsmPrinter so far, which would cause the assertion to trigger. The current approach of special casing for the `__LLVM_STACKMAPS` section is not viable either, as downstream users can overwrite the stackmap format using plugins, which may want to use different sections.

This patch fixes the issue by emitting the stack map earlier, right before debug info is emitted. The way this is implemented is by taking the choice when to emit the StackMap away from the target AsmPrinter and doing so in the base class. The only disadvantage of this approach is that the `StackMaps` member is now part of the base class, even for targets that do not support them. This is functionaly not a problem however, as emitting an empty `StackMaps` is a no-op.

Differential Revision: https://reviews.llvm.org/D132708
2022-09-06 20:20:56 +02:00
Joseph Huber 58645d3252 [OpenMP] Fix `omp_get_wtime` function being marked incorrectly as readonly
OpenMP has a list of of optimistic attributes that can be attached to
known runtime functions to aid some analysis. The `omp_get_wtime`
function incorrectly used the `readonly` attribute. This is not correct
at the `omp_get_wtime` function changes values depending on some
external state. This is more correctly modeled with
`inaccessiblememonly` meaning that the value does not depend on anything
within the module, but can not be removes as it depends on external
state.

Fixes #57578

Reviewed By: tianshilei1992

Differential Revision: https://reviews.llvm.org/D133360
2022-09-06 12:59:00 -05:00
Jakub Kuderski 20573d11b7 [ADT] Remove is_splat
`is_splat` is superseded by `all_equal` and marked as deprecated.
See the discussion thread for more details:
https://discourse.llvm.org/t/adt-is-splat-and-empty-ranges/64692

Reviewed By: dblaikie

Differential Revision: https://reviews.llvm.org/D132336
2022-09-06 13:49:26 -04:00
Matthias Gehre 7948d89afe Fix "[llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64" compilation on Windows 2022-09-06 16:11:14 +01:00
Marco Elver 7d63983c65 [SelectionDAG] Properly copy ExtraInfo on RAUW
During SelectionDAG legalization SDNodes with associated extra info may
be replaced with a new SDNode. Preserve associated extra info on
ReplaceAllUsesWith and remove entries in DeallocateNode.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130881
2022-09-06 16:32:50 +02:00
Marco Elver cc3faf4226 [SelectionDAG] Rename CallSiteDbgInfo to NodeExtraInfo
For information infrequently attached to SDNodes, it is useful to
provide a way to add this information out-of-line. This is already done
for call-site specific information.

Rename CallSiteDbgInfo to NodeExtraInfo in preparation of adding
additional information not necessarily related to call sites only.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130880
2022-09-06 16:32:50 +02:00
Matthias Gehre 2090e85fee [llvm/CodeGen] Enable the ExpandLargeDivRem pass for X86, Arm and AArch64
This adds the ExpandLargeDivRem to the default pass pipeline.
The limit at which it expands div/rem instructions is configured
via a new TargetTransformInfo hook (default: no expansion)
X86, Arm and AArch64 backends implement this hook to expand div/rem
instructions with more than 128 bits.

Differential Revision: https://reviews.llvm.org/D130076
2022-09-06 15:32:04 +01:00
Joseph Huber 5dbc7cf7ca [Object] Refactor code for extracting offload binaries
We currently extract offload binaries inside of the linker wrapper.
Other tools may wish to do the same extraction operation. This patch
simply factors out this handling into the `OffloadBinary.h` interface.

Reviewed By: yaxunl

Differential Revision: https://reviews.llvm.org/D132689
2022-09-06 08:55:16 -05:00
Marco Elver 42836e283f [MachineInstr] Allow setting PCSections in ExtraInfo
Provide MachineInstr::setPCSection(), to propagate relevant metadata
through the backend. Use ExtraInfo to store the metadata.

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D130876
2022-09-06 15:52:44 +02:00
Marco Elver c70f6e1362 [Metadata] Introduce MD_pcsections
Introduces MD_pcsections metadata kind. See added documentation for
more details.

Subsequent patches enable propagating PC sections metadata through code
generation to the AsmPrinter.

RFC: https://discourse.llvm.org/t/rfc-pc-keyed-metadata-at-runtime/64191

Reviewed By: dvyukov, vitalybuka

Differential Revision: https://reviews.llvm.org/D130875
2022-09-06 15:52:44 +02:00
Amara Emerson 3dd861818a [GlobalISel] Combine G_INSERT/EXTRACT_VECTOR_ELT with out of bounds indices to undef.
Differential Revision: https://reviews.llvm.org/D133309
2022-09-06 13:45:04 +01:00
luxufan 2e7aed1947 [MemorySSA][NFC] Simplify if condition
Differential Revision: https://reviews.llvm.org/D133332
2022-09-05 10:43:17 +00:00
Eli Friedman 63335afb4e [ARM64EC 2/?] Add target triple, and allow targeting it.
Part of patchset to add initial support for ARM64EC.

Per discussion on review, using the triple arm64ec-pc-windows-msvc. The
parsing works the same way as Apple's alternate Arm ABI "arm64e".

Differential Revision: https://reviews.llvm.org/D125412
2022-09-05 12:27:10 -07:00
Eli Friedman 488ad99ecf [ARM64EC 1/?] Add parsing support to llvm-objdump/llvm-readobj.
This is the first patch of a patchset to add initial support for
ARM64EC. Basic documentation is available at
https://docs.microsoft.com/en-us/windows/uwp/porting/arm64ec-abi .
(Discourse post:
https://discourse.llvm.org/t/initial-patches-for-arm64ec-windows-11-now-posted/62449
.)

The file format for ARM64EC is basically identical to normal ARM64.
There are a few extra sections, but the existing code for reading ARM64
object files just works.

Differential Revision: https://reviews.llvm.org/D125411
2022-09-05 12:25:08 -07:00
Joseph Huber c1d19a8489 [ELF] Provide the GNU hash function in libObject
GNU uses a different hashing function compared to the sys-V standard
function already provided in libObject. This is already used internally
in LLD for generating synthetic sections. This patch simply extracts
this definition and makes it availible to other users of `libObject`.
This is done in preparation for supporting symbol name lookups via the
GNU hash table.

Reviewed By: MaskRay, jhenderson

Differential Revision: https://reviews.llvm.org/D132696
2022-09-05 11:04:57 -05:00
Kazu Hirata 2bb43d72d9 [ADT] Use std::tuple_element_t (NFC) 2022-09-03 23:27:24 -07:00
Kazu Hirata 03c3c2db10 [llvm] Use std::remove_reference_t (NFC) 2022-09-03 23:27:22 -07:00
Kazu Hirata 230e57d221 [ADT] Use std::add_pointer_t (NFC) 2022-09-03 23:27:18 -07:00
Kazu Hirata 9dc6223117 [ADT] Use std::add_lvalue_reference_t (NFC) 2022-09-03 23:27:17 -07:00
Kazu Hirata 2423cf4f88 [Support] Simplify reverseBits with constexpr if (NFC)
Differential Revision: https://reviews.llvm.org/D132814
2022-09-03 23:27:15 -07:00
Kazu Hirata ee40ef7aaf [Support] Simplify isInt and isUInt with constexpr if (NFC)
Differential Revision: https://reviews.llvm.org/D132813
2022-09-03 23:27:13 -07:00
Kazu Hirata 86e8164a8f [llvm] Qualify auto in range-based for loops (NFC)
Identified with readability-qualified-auto.
2022-09-03 11:17:49 -07:00
Kazu Hirata 32aa35b504 Drop empty string literals from static_assert (NFC)
Identified with modernize-unary-static-assert.
2022-09-03 11:17:47 -07:00
Kazu Hirata baee196abb [llvm] Use std::remove_const_t (NFC) 2022-09-03 11:17:45 -07:00
Kazu Hirata 9eca5ed790 [llvm] Use std::enable_if_t (NFC) 2022-09-03 11:17:44 -07:00
Kazu Hirata a7a2872bb7 [ADT] Use std::add_const_t (NFC) 2022-09-03 11:17:42 -07:00
Simon Pilgrim e2d140e9c3 [TTI] Add isExpensiveToSpeculativelyExecute wrapper
CGP uses a raw `getInstructionCost(I, TargetTransformInfo::TCK_SizeAndLatency) >= TCC_Expensive` check to see if its better to move an expensive instruction used in a select behind a branch instead.

This is causing issues with upcoming improvements to TCK_SizeAndLatency costs on X86 as we need to use TCK_SizeAndLatency as an uop count (so its compatible with various target-specific buffer sizes - see D132288), but we can have instructions that have a low TCK_SizeAndLatency value but should still be treated as 'expensive' (FDIV for example) - by adding a isExpensiveToSpeculativelyExecute wrapper we can keep the current behaviour but still add an x86 override in a future patch when the cost tables are updated to compensate.
2022-09-03 13:12:22 +01:00
Alexey Lapshin 79c8f51c34 [DWARFLinker] Refactor clang modules loading code.
Current implementation of registerModuleReference() function not only
"registers" module reference, but also clones referenced module
(inside loadClangModule()). That may lead to cloning the module with
incorrect options (registerModuleReference() examines module references
and additionally accumulates MaxDwarfVersion and accel tables info).
Since accumulated options may differ from the current values,
it is incorrect to clone modules before options are fully accumulated.

This patch separates "cloning" code from "registering" code. So,
that accumulating option is done in the "registering stage" and
"cloning" is done after all modules are registered and options accumulated.
It also adds a callback for loaded compile units which can be used for
D132755 and D132371(to allow doing options accumulation outside
of DWARFLinker).

Differential Revision: https://reviews.llvm.org/D133047
2022-09-03 11:23:52 +03:00
Craig Topper 5cf510115a [VP] Correct LEGALPOS for more VP nodes.
LEGALPOS appears to only be used by LegalizeVectorOps. It needs
to point at a vector operand. Stores need to point at the second
operand since the result and the first operand are MVT::Other.
Reductions need to point at the second operand since the result
and the first operand are scalsrs.

Reviewed By: rogfer01

Differential Revision: https://reviews.llvm.org/D133048
2022-09-02 08:04:28 -07:00
Kadir Cetinkaya 4940f205d4
[llvm][Support] Add DenseMapInfo for std::variant
Differential Revision: https://reviews.llvm.org/D133200
2022-09-02 15:36:10 +02:00
Simon Pilgrim 7338f9709b [TTI] Improve description of TargetCostKind enums to aid targets in choosing cost values
I'm not sure how much to add to the description as we've tried to allow targets to interpret the TargetCostKind enums in their own way. But we need to make it clear that certain cost kinds need to match threshold numbers used by various passes (and vice-versa when passes are determining a cost-benefit threshold).

I'm not keen on the "The weighted sum of size and latency" description, but its very difficult to come up with anything else that's suitably generic (e.g. X86 will use uop counts here to easily work with LoopMicroOpBufferSize thresholds, even though high latency fdiv/fsqrt instructions still often have low uop counts).

Differential Revision: https://reviews.llvm.org/D132288
2022-09-02 11:09:06 +01:00
Lang Hames 6ca9f42189 [ORC][ORC-RT] Consistently use pointed-to type as template arg to wrap/unwrap.
Saves wrap/unwrap implementers from having to use std::remove_pointer_t to get
at the pointed-to type.
2022-09-01 20:54:24 -07:00
Lang Hames 06c4634483 [JITLink] Sink ELFX86RelocationKind into implementation file (ELF_x86_64.cpp).
The ELF/x86-64 backend uses the generic x86_64 edges now, so the
ELFX86RelocationKind is just an implementation detail.
2022-09-01 13:36:49 -07:00
Simon Pilgrim e5804a5a61 [ADT] bit.h - replace <stdint.h> with <cstdint>
This is a C++ header after all.
2022-09-01 20:44:56 +01:00
Fangrui Song 8d95fd7e56 [MachineFunctionPass] Support -filter-passes for -print-changed
[MachineFunctionPass] Support -filter-passes for -print-changed

-filter-passes specifies a `PassID` (a lower-case dashed-separated pass name,
also used by -print-after, -stop-after, etc) instead of a CamelCasePass.

`-filter-passes=CamelCaseNewPMPass` seems like a workaround for new PM passes before
we can use lower-case dashed-separated pass names (as used by `-passes=`).

Example:
```
# getPassName() is "IRTranslator". PassID is "irtranslator"
llc -mtriple=aarch64 -print-changed -filter-passes=irtranslator < print-changed-machine.ll
```

Close https://github.com/llvm/llvm-project/issues/57453

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D133055
2022-09-01 11:06:06 -07:00
Wei Yi Tee f6b66cbc7d [llvm][Testing/ADT] Implement `IsStringMapEntry` testing matcher for verifying the entries in a `StringMap`.
Reviewed By: gribozavr2, ymandel, sgatev

Differential Revision: https://reviews.llvm.org/D132753
2022-09-01 17:30:41 +00:00
Ilia Diachkov 698c800142 [SPIRV] support builtin types and ExtInsts selection
The patch adds the support of OpenCL and SPIR-V built-in types. It also
implements ExtInst selection and adds spv_unreachable and spv_alloca
intrinsics which improve the generation of the corresponding SPIR-V code.
Five LIT tests are included to demonstrate the improvement.

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

Co-authored-by: Aleksandr Bezzubikov <zuban32s@gmail.com>
Co-authored-by: Michal Paszkowski <michal.paszkowski@outlook.com>
Co-authored-by: Andrey Tretyakov <andrey1.tretyakov@intel.com>
Co-authored-by: Konrad Trifunovic <konrad.trifunovic@intel.com>
2022-09-01 16:44:54 +03:00
Amara Emerson 4cf3db41da [GlobalISel] Add sdiv exact (X, constant) -> mul combine.
This port of the SDAG optimization is only for exact sdiv case.

Differential Revision: https://reviews.llvm.org/D130517
2022-09-01 13:34:00 +01:00
David Spickett 6829cd17b5 [LLVM] Add missing stdint include to Bit.h
To fix failing builds on Windows on Arm:
https://lab.llvm.org/staging/#/builders/59/builds/928/steps/4/logs/stdio

<...>/ADT/bit.h(50,5): error: unknown type name 'uint32_t'
    uint32_t v = Value;
    ^
2022-09-01 09:17:35 +00:00
Sam Clegg 92920c4fe3 [MC][WebAssembly] Allow accurate errors in doBeforeLabelEmit
Although we only currently have one error produced in this function I am
working on changes right now that add some more.  This change makes the
error location more accurate.

Differential Revision: https://reviews.llvm.org/D133016
2022-09-01 01:26:33 -07:00
Arthur Eubanks 04f3c20989 [NFC][LICM] Stop passing around unused BFI
Uses of this were removed in 1a25d0bfbb.
2022-08-31 19:15:34 -07:00
Mark Zhuang 62454e83b0 [NFC] Fix typo
Reviewed By: eopXD

Differential Revision: https://reviews.llvm.org/D133079
2022-08-31 19:08:46 -07:00
Craig Topper 8dce3507a0 [VP] Correct the LEGALPOS for VP_STORE.
VP_STORE has a Chain for operand 0, so the LEGALPOS should be 1.

VP_STORE is always considered Legal for MVT::Other. So I suspect this
was causing vp_store to be ignored by LegalizeVectorOps and instead
handled in LegalizeDAG.

VP_LOAD is Custom expanded in LegalizeVectorOps for RISC-V.

Differential Revision: https://reviews.llvm.org/D132972
2022-08-31 11:15:47 -07:00
Wei Yi Tee d45c04da7c [llvm][ADT] Overload output stream operator `<<` for `StringMapEntry` and `StringMap`.
Printing support enables the production of more useful error messages in unit testing e.g. when using matchers such as `UnorderedElementsAre()` to inspect the contents of a `StringMap`.

Reviewed By: gribozavr2, sgatev, ymandel

Differential Revision: https://reviews.llvm.org/D132747
2022-08-31 17:37:58 +00:00
Arthur Eubanks d0b9c9c0a3 [NFC] clang-format Any.h
To trigger some bots.

Differential Revision: https://reviews.llvm.org/D133033
2022-08-31 10:21:30 -07:00