Commit Graph

433262 Commits

Author SHA1 Message Date
Petr Hosek a4230319f7 [Driver] Support libc++ in MSVC
This implements support for using libc++ headers in MSVC toolchain.
We only support libc++ headers that are part of the toolchain, and
not headers installed elsewhere on the system.

Differential Revision: https://reviews.llvm.org/D101479
2022-08-18 04:04:40 +00:00
Amir Ayupov e33599371e [BOLT][NFC] Reformat strings in handleRelocation
With reduced indentation, some strings can be reformatted to take less lines.
Also strategically apply `formatv` to shorten them.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D132088
2022-08-17 20:45:18 -07:00
Amir Ayupov 70d0134f1d [BOLT][NFC] Split out handleRelocation
Split out the body of a for-loop in `RewriteInstance::readRelocations` into a
separate function (`handleRelocation`). It's still over 300 lines of code,
so it's worth splitting down further.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D132078
2022-08-17 20:43:51 -07:00
wanglian 230e277dfe [DAGCombiner][NFC] Merge two if statement into one.
Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D131941
2022-08-18 10:12:35 +08:00
Vitaly Buka 3f5f2905c4 [test] Propagate HWASAN_OPTIONS 2022-08-17 18:59:49 -07:00
Vitaly Buka 36c9f5a58b [NFC][OpenMP] Simplify 2f9be69d84 2022-08-17 18:59:48 -07:00
Konstantina 5bc8791187 [NewGVN][PHIOFOPS] Bail out if an operand is in OpSafeForPHIOfOps but it is not safe for the current basic block.
NewGVN tables are not cleared out between the initial run of NewGVN and the verification. In case of phi-of-ops optimization, OpSafeForPHIOfOps goes out of sync between the two runs. One operand might not be safe for one basic block, but it might be safe for one of its successors. In this case, the operand will be added in OpSafeForPHIOfOps map. In verification phase, we reuse OpSafeForPHIOfOps without updating it again. As a result, the operand will be considered safe for phi-of-ops optimization even for the case that it is not. This patch fixes this problem.

Fix for 53807.

Reviewed By: asbirlea

Differential Revision: https://reviews.llvm.org/D130910
2022-08-17 18:57:46 -07:00
Jakub Kuderski 95c4e51839 [mlir][spirv] Add arith.addi_carry to spv.IAddCarry conversion
Reviewed By: antiagainst

Differential Revision: https://reviews.llvm.org/D131908
2022-08-17 21:33:34 -04:00
Lang Hames 2bf87a4946 [ORC][MachO] Fix MachOPlatform after 9189a26664.
Commit 9189a26664 caused llvm-jitlink to create bare JITDylibs to wrap real
dylibs loaded via -preload. This exposed a bug in MachOPlatform where we
assumed that all JITDylibs had been registered with the platform through
MachOPlatform::setupJITDylib (bare JITDylibs are _not_ run through this
function), and errored out where this was not the case.
This bug in MachOPlatform was causing test failures in compilert-rt:

Failed Tests (2):
  ORC-x86_64-darwin :: TestCases/Darwin/x86-64/trivial-objc-methods.S
  ORC-x86_64-darwin :: TestCases/Darwin/x86-64/trivial-swift-types-section.S

This commit fixes the issue by skipping JITDylibs that haven't been registered
with the platform via MachOPlatform::setupJITDylib.
2022-08-17 18:18:48 -07:00
Sam Clegg fa306f1396 [WebAssembly] WebAssemblyLowerEmscriptenEHSjLj: Fix signature of malloc in wasm64 mode
Differential Revision: https://reviews.llvm.org/D132091
2022-08-17 18:16:34 -07:00
Amir Ayupov 330eec139e [BOLT][UTILS] Add nfc-check-setup --switch-back option
Add an option to switch repo revision back, handling stashing automatically.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D128243
2022-08-17 17:37:27 -07:00
Aart Bik e3d64ccf9f [mlir][sparse] more concise sparse tensor type printing
This change omits default values from the sparse tensor type,
saving considerable text real estate for the common cases.

Reviewed By: Peiming

Differential Revision: https://reviews.llvm.org/D132083
2022-08-17 17:35:50 -07:00
Amir Ayupov 055f9f6d08 [BOLT][NFC] Simplify debug logging in case of JT heuristic failure
Move logging into LLVM_DEBUG scope.
Remove redundant printing of jump table parents:

Old logging:
```
failed to analyze jump table in function _ZN12_GLOBAL__N_116InitHeaderSearch23Ad
dDefaultCIncludePathsERKN4llvm6TripleERKN5clang19HeaderSearchOptionsE/1(*2)
PIC Jump table JUMP_TABLE/_ZN12_GLOBAL__N_116InitHeaderSearch23AddDefaultCInclud
ePathsERKN4llvm6TripleERKN5clang19HeaderSearchOptionsE/1.1 for function _ZN12_GL
OBAL__N_116InitHeaderSearch23AddDefaultCIncludePathsERKN4llvm6TripleERKN5clang19
HeaderSearchOptionsE/1(*2) at 0x65996e0 with a total count of 0:
  0x9dc

next jump table at 0x659a810 belongs to function _ZN5clang5Lexer40LexDependencyD
irectiveTokenWhileSkippingERNS_5TokenE
PIC Jump table JUMP_TABLE/_ZN5clang5Lexer40LexDependencyDirectiveTokenWhileSkipp
ingERNS_5TokenE.0 for function _ZN5clang5Lexer40LexDependencyDirectiveTokenWhile
SkippingERNS_5TokenE at 0x659a810 with a total count of 0:

jump table heuristic failure
```

New logging:
```
failed to analyze PIC Jump table JUMP_TABLE/_ZN12_GLOBAL__N_116InitHeaderSearch2
3AddDefaultCIncludePathsERKN4llvm6TripleERKN5clang19HeaderSearchOptionsE/1.1 for
function _ZN12_GLOBAL__N_116InitHeaderSearch23AddDefaultCIncludePathsERKN4llvm6T
ripleERKN5clang19HeaderSearchOptionsE/1(*2) at 0x65996e0 with a total count of 0:
  absolute offset: 0x52ac58c

next PIC Jump table JUMP_TABLE/_ZN5clang5Lexer40LexDependencyDirectiveTokenWhile
SkippingERNS_5TokenE.0 for function _ZN5clang5Lexer40LexDependencyDirectiveToken
WhileSkippingERNS_5TokenE at 0x659a810 with a total count of 0:

jump table heuristic failure
```

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D131243
2022-08-17 17:35:16 -07:00
Amir Ayupov cdef841fe7 [BOLT][NFC] Simplify scanExternalRefs
Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D132013
2022-08-17 17:33:59 -07:00
Alexander Yermolovich ccbf28b09d [BOLT][DWARF] Handle zero size DW_TAG_inlined_subroutine
We were resetting DW_AT_low_pc to zero when DW_AT_high_pc was zero, or
DW_AT_low_pc == DW_AT_high_pc. This resulted in LLDB to print error "adding
range [0x0-0x0) which has a base that is less than the function's low PC".

Changed it so that when this case arises we set DW_AT_low_pc to the start
address.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D132059
2022-08-17 17:29:53 -07:00
Luo, Yuanke 28733d86cf [amdgpu] Change the RA to basic
Specifying `-regalloc=fast` is not reliable. With fast register allocation,
`LIS = getAnalysisIfAvailable<LiveIntervals>();` get nullptr
in "si-lower-sgpr-spills" pass, so the slot index is not created in the
pass for new inserted instructions. When verifying the machine
instructions, it fails on checking slot index. While greedy-ra is time
consuming basic-ra can be used to reduce compiling time for this test case.

Differential Revision: https://reviews.llvm.org/D131931
2022-08-18 08:16:19 +08:00
Jacques Pienaar 8fe0691161 [mlir] Update when to check for non-null optional default attr
OptionalAttr does the wrapping with Optional explicitly in ODS while
default valued optional attribute doesn't (and follows DefaultValuedAttr
in this behavior/meant as drop-in for updating old behavior), update
when to emit check for non-null to account for this.  Also add variant
for optional default valued string attribute to have same convenience as
default valued string attribute.
2022-08-17 17:00:47 -07:00
Fabian Parzefall fd159c2316 [BOLT] Fix ignored LP at fragment start
If the first block of a fragment is also a landing pad, the landing pad
is not used if an exception is thrown. This is because the landing pad
is at the same start address that the corresponding LSDA describes. In
that case, the offset in the call site records to refer to that landing
pad is zero, and a zero offset is interpreted by the personality
function as "no handler" and ignored.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D132053
2022-08-17 16:34:44 -07:00
Amir Ayupov 4ddc9c8e12 [BOLT][NFC] Move printRelocationInfo into a method
Move this large lambda out of readRelocations into a standalone method.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D131812
2022-08-17 16:28:33 -07:00
Jeffrey Byrnes 1c8d7ea973 [AMDGPU] Implement pipeline solver for non-trivial pipelines
Requested SchedGroup pipelines may be non-trivial to satisify. A minimimal example is if the requested pipeline is {2 VMEM, 2 VALU, 2 VMEM} and the original order of SUnits is {VMEM, VALU, VMEM, VALU, VMEM}. Because of existing dependencies, the choice of which SchedGroup the middle VMEM goes into impacts how closely we are able to match the requested pipeline. It seems minimizing the degree of misfit (as measured by the number of edges we can't add) w.r.t the choice we make when mapping an instruction -> SchedGroup is an NP problem. This patch implements the PipelineSolver class which produces a solution for the defined problem for the sched_group_barrier mutation. The solver has both an exponential time exact algorithm and a greedy algorithm. The patch includes some controls which allows the user to select the greedy/exact algorithm.

Differential Revision: https://reviews.llvm.org/D130797
2022-08-17 16:21:59 -07:00
Jacques Pienaar 052669e71a [mlir] add missing pessimistic setting
This is updated on https://reviews.llvm.org/D127139, to mark op with region as pessimistic.

Reviewed By: jpienaar

Differential Revision: https://reviews.llvm.org/D131480
2022-08-17 16:20:13 -07:00
Siva Chandra Reddy d20e632853 [libc][Obvious] Update the static archive target name for libc-api-test. 2022-08-17 23:18:33 +00:00
Slava Gurevich 5a197772ee [LLDB][NFC] Suppress spurious static inspection warnings
Suppress coverity false positives.
This diff contains comments only, including the hints for Coverity static code inspection
to suppress the warning originating at the next line after the comment.

Differential Revision: https://reviews.llvm.org/D131998
2022-08-17 16:12:42 -07:00
root 894e8a5446 [MLIR] Add dealloc alias check to bufferization
Traverse the cloneOp for aliases to find the alloc op

Reviewed By: frgossen, bondhugula

Differential Revision: https://reviews.llvm.org/D131797
2022-08-17 19:11:59 -04:00
Amir Ayupov 29f2301322 [BOLT][NFC] Simplify addRelocation
Move the implementation out of the header file.
Simplify the method.
Add debug logging.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D131811
2022-08-17 16:07:28 -07:00
owenca 777b6ad168 [clang-format] Handle return type auto followed by l_paren
Fixes #57160.

Differential Revision: https://reviews.llvm.org/D132008
2022-08-17 16:06:34 -07:00
Alexander Yermolovich b786e01f93 [DWARF][BOLT] Handle getBinaryFunctionContainingAddress returning nullptr for DW_TAG_call_site
DW_TAG_call_site/DW_AT_call_return_pc can contain address that is not in any
function. In this case getBinaryFunctionContainingAddress returns nullptr. For
this case preserving original address.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D132057
2022-08-17 16:04:34 -07:00
Lang Hames f1b5d30f15 [JITLink] Fix typo in block address in unittest.
The address isn't currently used in this test but overlaps with Block B1,
which is a dubious state for a LinkGraph to be in.
2022-08-17 15:55:43 -07:00
Lang Hames 6494920987 [JITLink] Pass Allocator (rather than storage) into Symbol named constructors.
Also switch from orc::ExecutorAddrDiff to uint64_t for the Symbol::Size field.

These changes help to prepare for the introduction of symbol alias support:
Aliases will require an auxiliary data structure which will also need to be
allocated (hence the need to pass the allocator down). The Size field will be
re-tasked to track the auxiliary data (which will hold a replacement Size field)
if the symbol is either an alias, or aliased by some other symbol.
2022-08-17 15:55:42 -07:00
Lang Hames c2786683ca [JITLink][MachO] Add support for non-subsections-via-symbols objects.
This patch updates MachOLinkGraphBuilder to honor the MH_SUBSECTIONS_VIA_SYMBOLS
flag. Prior to this patch we assumed MH_SUBSECTIONS_VIA_SYMBOLS, but never
checked the flag.

If MH_SUBSECTIONS_VIA_SYMBOLS is set (the default for MachO output on modern
compilers) then MachOLinkGraphBuilder will break MachO section content into
jitlink::Blocks on symbol boundaries. (This is how JITLink has always handled
MachO sections previously).

If MH_SUBSECTIONS_VIA_SYMBOLS is not set then MachOLinkGraphBuilder will create
a single jitlink::Block for each MachO section.

Existing hand-written testcases that were _not_ using the
.subsections_via_symbols directive are updated to use it. A new testcase for
non-subsections-via-symbols behavior is included.
2022-08-17 15:55:42 -07:00
Siva Chandra Reddy e5edd74bb7 [libc] Add a target to install libc in the full build mode.
* In the full build mode, `ninja install-libc` will install the headers as
  well the static archive named libc.a.
* In the default mode, `ninja install-llvmlibc` will only install the
  static archive libllvmlibc.a.

Reviewed By: jeffbailey

Differential Revision: https://reviews.llvm.org/D132015
2022-08-17 22:49:02 +00:00
Fabian Parzefall aed75748de [BOLT] Remove old layout from function layout
To track whether a function's new layout is different from its old
layout when updating it, the old layout would be kept around in memory
indefinitely (if the new layout is different). This was used only for
debugging/logging purposes. This patch forces the caller of function
layout's update method to copy the old layout into a temporary if they
need it by removing the old layout fields.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D131413
2022-08-17 15:06:17 -07:00
Fabian Parzefall 0f8412c19c [BOLT] Add main fragment to function layout
Functions that do not contain any code still have to be emitted. This
occurs on AArch64 where functions can consist only of a constant island.
To support fragment semantics in code emission, this commits adds a
guaranteed main fragment to function layout. This fragment might be
empty, but allows us omit checks whether the function is empty in most
places.

Reviewed By: rafauler

Differential Revision: https://reviews.llvm.org/D130051
2022-08-17 14:51:31 -07:00
Daniil Fukalov 7ed3d81333 [NFCI] Move cost estimation from TargetLowering to TargetTransformInfo.
TragetLowering had two last InstructionCost related `getTypeLegalizationCost()`
and `getScalingFactorCost()` members, but all other costs are processed in TTI.

E.g. it is not comfortable to use other TTI members in these two functions
overrided in a target.

Minor refactoring: `getTypeLegalizationCost()` now doesn't need DataLayout
parameter - it was always passed from TTI.

Reviewed By: RKSimon

Differential Revision: https://reviews.llvm.org/D117723
2022-08-18 00:38:55 +03:00
Paul Kirth 56a34451e1 [libcxx] Fix using the vcruntime ABI with _HAS_EXCEPTIONS=0 defined
_HAS_EXCEPTIONS=0 allows disabling the exception parts of the MS STL
and vcruntime, and e.g. compiler-rt/lib/fuzzer sets this define (to
work around issues with MS STL). If using libc++ instead of MS STL,
this define previously broke the libc++ headers.

If _HAS_EXCEPTIONS is set to 0, the vcruntime_exception.h header
doesn't define the ABI base class std::exception. If no exceptions
are going to be thrown, this probably is fine (although it also
breaks using subclasses of it as regular objects that aren't thrown),
but it requires ifdeffing out all subclasses of all exception/error
derived objects (which are sprinkled throughout the headers).

Instead, libc++ will supply an ABI compatible definition when
_HAS_EXCEPTIONS is set to 0, which will make the class hierarchies
complete.

In this build configuration, one can still create instances of
exception subclasses, and those objects will be ABI incompatible
with the ones from when _HAS_EXCEPTIONS isn't defined to 0 - but
one may argue that's a pathological/self-imposed problem in that case.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D103947
2022-08-17 21:14:25 +00:00
Shafik Yaghmour 8de51375f1 [Clang] Tighten restrictions on enum out of range diagnostic to avoid constant initialization
The restrictions added in D131704 were not sufficient to avoid all non-constant
expression contexts. In particular constant initialization cases.

We need to check EvaluatingDecl to detect if the variable we are initializing is
constexpr or not.

At this point it looks like this is the remaining case affecting various projects
with this diagnostic.

Differential Revision: https://reviews.llvm.org/D131874
2022-08-17 14:14:00 -07:00
Philip Reames aa41fe664a [tests] Precommit tests for phi recusion limits in known bits 2022-08-17 14:03:10 -07:00
Jakub Kuderski 4309170c87 [mlir] Add arith.addi_carry op
The `arith.addi_carry` op implements integer addition with overflows. The carry is returned via the second result, as `i1`.

Reviewed By: antiagainst, bondhugula

Differential Revision: https://reviews.llvm.org/D131893
2022-08-17 17:01:20 -04:00
Vitaly Buka 36bdec44a2 [NFC][tsan] Use AddThread(Tid tid... 2022-08-17 13:53:13 -07:00
Slava Zakharin 11db65bab8 [flang] Control SUM simplification with a pass option.
The current code may not always work correctly, e.g.:
https://github.com/llvm/llvm-project/issues/57201

I added 'enable-experimental' pass option so that SUM simplification
may be enabled in LIT tests, but it is not enabled when the pass
is added to the passes pipeline.

Differential Revision: https://reviews.llvm.org/D131640
2022-08-17 13:37:44 -07:00
Zequan Wu 71d778f33e [LLDB][NativePDB] Switch to use DWARFLocationList.
Before, NativePDB uses scoped range as a workaround for value range, that causes
problems (e.g. a variable's value can only have one range, but usually a
variable's value is located at different address ranges, each at different
locations, in optimized build).
This patch let NativePDB switch to DWARFLocationList so a variable's value can
be described at multiple non-overlapped address ranges and each range maps to a
location.
Because overlapping ranges exists, here's peference when choosing ranges:
1. Always prefer whole value locations. Suppose a variable size is 8 bytes, one record is that for range [1, 5) first 4 bytes is at ecx, and another record is that for range [2, 8) the 8 bytes value is at rdx. This results: [1, 2) has first 4 bytes at ecx, [2, 8) has the whole value at rdx.
2. Always prefer the locations parsed later. Suppose first record is that for range [1, 5) value is at ecx, second record is that for range [2, 6) value is at eax. This results: [1, 2) -> ecx, [2, 6) -> eax.

Differential Revision: https://reviews.llvm.org/D130796
2022-08-17 13:37:13 -07:00
Sanjay Patel 7f72a0f5bb [SDAG] avoid generating libcall to function with same name
This is a potentially better alternative to D131452 that also
should avoid the infinite loop bug from:
issue #56403

This is again a minimal fix to reduce merging pain for the
release. But if this makes sense, then we might want to guard
all of the RTLIB generation (and other libcalls?) with a
similar name check.

Differential Revision: https://reviews.llvm.org/D131521
2022-08-17 16:19:34 -04:00
Markus Böck f289c47b5e [mlir][ODS] Add `constBuilderCall` to `Dense*ArrayAttr`s
These are useful in builders of Ops taking DenseArrayAttrs or for use in Rewriter, to create constant instances.

Differential Revision: https://reviews.llvm.org/D132067
2022-08-17 22:18:13 +02:00
Matthias Braun 19ce5e515f RAGreedyStats: Ignore identity COPYs; count COPYs from/to physregs
Improve copy statistics:

- Count copies from or to physical registers: They are used to model function parameters and calling conventions and the register allocator optimizes for them.
- Check physical registers assigned to virtual registers and stop counting "identity" `COPY`s where source and destination is the same physical registers; they will be removed in the `virtregmap` pass anyway.

Differential Revision: https://reviews.llvm.org/D131932
2022-08-17 12:53:29 -07:00
Archit Saxena e170d955fe Split EH code by default
The current machine function splitter is reliant on profile data to do profile summary analysis to split blocks into cold section. This may sometimes limit the usage of machine function splitter especially in cases where we could do some form of static analysis to split out cold blocks if profile data is absent or profile data which may be faulty (Consider Sample PGO).

Of all code that could statically be marked cold Exception handling blocks are one of them (In fact BFI framework also tends to mark them as cold), and the most in size contribution. In my experiments I found out Exception handling pads and all code reachable from there account for up to 6-8% of the .text section on modern production binaries. This patch introduces a flag to split out all Exception handling blocks and blocks only reachable from Exceptional Handling pad to cold section. This flag has shown to give a performance win of up to 0.1% in terms of average cycles and instructions executed on internal facebook search service.

Reviewed By: snehasish

Differential Revision: https://reviews.llvm.org/D131824
2022-08-17 12:40:31 -07:00
Nico Weber b098407280 [gn build] build libclang_rt.ubsan_osx_dynamic.dylib on mac
For now, this only builds the dylib, so using `-fsanitize=undefined`
with `-static-libsan` or `fsanitize-minimal-runtime` still won't
work -- but the common case does work.

Differential Revision: https://reviews.llvm.org/D131969
2022-08-17 15:35:41 -04:00
Ellis Hoag 0f946a50a4 [InstrProf] Add option to disable loop opt after PGO
Add the `-enable-post-pgo-loop-rotation` option to enable or disable the loop rotation transformation [1]. With some instrumentations, e.g., function entry coverage [2], loop rotation is not necessary and can lead to some surprise differences in codegen, even for functions where instrumentation is blocked with `noprofile` or `skipprofile`. The default value is `true` so the default behavior does not change.

[1] https://www.llvm.org/docs/LoopTerminology.html#loop-terminology-loop-rotate
[2] https://reviews.llvm.org/D116180

Reviewed By: phosek

Differential Revision: https://reviews.llvm.org/D131817
2022-08-17 12:23:18 -07:00
Slava Gurevich 1633190709 [LLDB][NFC] Fix optons parsing and misc. reliability in CommandObjectThread
* Fix broken option parsing in SetOptionValue()

Differential Revision: https://reviews.llvm.org/D131983
2022-08-17 12:20:10 -07:00
Kent Ross 081dad9e9e [libcxx][spaceship][doc] Repair links and clean up spaceship progress doc
Previously the specification was in a table in paragraph 14 of [container.requirements.general] but it has since been given its own sub section header, 24.2.2.4 [container.opt.reqmts].

This happened in 93ff092d1c

This update also includes misc. other cleanups of the spaceship projects sheet.

Reviewed By: Mordante, avogelsgesang, #libc

Differential Revision: https://reviews.llvm.org/D131928
2022-08-17 12:14:32 -07:00
Sanjay Patel 8eddd1ec60 [AArch64] add test for recursive libcall lowering; NFC
Issue #56403
2022-08-17 14:54:50 -04:00