Commit Graph

436209 Commits

Author SHA1 Message Date
Alex Zinenko f3fae035c7 [mlir] use strided layout in structured codegen-related tests
All relevant operations have been switched to primarily use the strided
layout, but still support the affine map layout. Update the relevant
tests to use the strided format instead for compatibility with how ops
now print by default.

Reviewed By: nicolasvasilache

Differential Revision: https://reviews.llvm.org/D134045
2022-09-17 08:11:28 +02:00
Emmmer edc1c9f610 [LLDB][RISCV] Add RVM and RVA instruction support for EmulateInstructionRISCV
Add:
- RVM and RVA instructions sets.
- corresponding unittests.

Further work:
- implement RVC, RVF, RVD, and RVV extension.

Reviewed By: DavidSpickett

Differential Revision: https://reviews.llvm.org/D133670
2022-09-17 12:19:09 +08:00
Kazu Hirata 29c841ce93 Revert "[llvm] Remove llvm::is_trivially_{copy/move}_constructible (NFC)"
This reverts commit 01ffe31cbb.

A build breakage with GCC 7.3 has been reported:

https://reviews.llvm.org/D132311#3797053

FWIW, GCC 7.5 is OK according to Pavel Chupin.  I also personally
tested GCC 8.4.0.
2022-09-16 18:26:20 -07:00
Vladislav Dzhidzhoev 6cf11f4462 [GlobalISel][DebugInfo] Salvage trivially dead instructions
Use salvageDebugInfo for instructions erased as trivially dead in
GlobalISel.

It would be helpful to implement support of G_PTR_ADD and G_FRAME_INDEX
in salvageDebugInfo in future in order to preserve more variable
location.

Reviewed by: arsenm

Differential Revision: https://reviews.llvm.org/D133986
2022-09-17 03:54:55 +03:00
Maksim Panchenko f1a11d770e [BOLT][NFC] Remove unreachable assertion
Reviewed By: ayermolo

Differential Revision: https://reviews.llvm.org/D134094
2022-09-16 17:03:35 -07:00
Aart Bik 30b550f14c [mlir][sparse] add loop simplification to sparsification pass
Reviewed By: bixia

Differential Revision: https://reviews.llvm.org/D134090
2022-09-16 16:29:47 -07:00
Matheus Izvekov 52dce8900c
[clang] Fix AST representation of expanded template arguments.
Extend clang's SubstTemplateTypeParm to represent the pack substitution index.

Fixes PR56099.

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

Differential Revision: https://reviews.llvm.org/D128113
2022-09-17 01:24:46 +02:00
Peiming Liu b1d1964771 [mlir][sparse] Only try to compute a better iteraton graph when needed
Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D134059
2022-09-16 22:53:32 +00:00
Michael Jones 70f1f302ca [libc][cmake] separate installing headers
Now libc headers can be installed separately from installing the rest of
the libc.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D133960
2022-09-16 15:50:28 -07:00
Kazu Hirata 6e30a9cc08 [Inliner] Retire DefaultInlineOrder (NFC)
DefaultInlineOrder was largely an exercise in generalizing the
traversal order of call sites within the inliner.

Now that the module inliner is starting to form its shape, there is no
point in sharing DefaultInlineOrder between the module inliner and the
CGSCC inliner.  DefaultInlineOrder and all the other inline orders are
mutually exclusive in the following sense:

- The use of DefaultInlineOrder doesn't make sense in the module
  inliner because there is no priority inherent in the order in which
  call sites are added to the list of call sites -- SmallVector.

- The use of any other inline order doesn't make sense in the CGSCC
  inliner because little prioritization can be done within one CGSCC.

This patch essentially reverts the addition of DefaultInlineOrder so
that the loop structure of Inliner.cpp looks like the state just
before we started working on the module inliner (circa June 2021).

At the same time, ww remove the choice of DefaultInlineOrder from
UseInlinePriority.

Differential Revision: https://reviews.llvm.org/D134080
2022-09-16 15:36:40 -07:00
Jacques Pienaar 55e4417bb9 [mlir][emacs] Enable loading bytecode files as text
Use auto-compression-mode to read bytecode files in human readable
manner.

Differential Revision: https://reviews.llvm.org/D133879
2022-09-16 15:08:55 -07:00
Alexey Bataev 5d13b12674 [SLP]Improve isUndefVector function by adding insertelement analysis.
Added the mask and the analysis of the buildvector sequence in the
isUndefVector function, improves codegen and cost estimation.

Metric: SLP.NumVectorInstructions

Program                                                                                       SLP.NumVectorInstructions
                                                                          results                   results0 diff
test-suite :: External/SPEC/CFP2017rate/526.blender_r/526.blender_r.test 27362.00                  27360.00 -0.0%

Metric: size..text

Program                                                                                                           size..text
                                                                   results     results0    diff
test-suite :: External/SPEC/CFP2017rate/508.namd_r/508.namd_r.test   805299.00   806035.00  0.1%

526.blender_r - some extra code is vectorized.
508.namd_r - some extra code is optimized out.

Differential Revision: https://reviews.llvm.org/D133891
2022-09-16 14:36:38 -07:00
Siva Chandra Reddy 7fb96fb5d3 [libc] Add implementation of POSIX "uname" function.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D134065
2022-09-16 21:21:29 +00:00
Siva Chandra Reddy 9050a59c66 [libc][Obvious] Fix typo in struct rlimit name - remove the "_t" suffix. 2022-09-16 21:07:17 +00:00
Chris Bieneman 10378c4505 [HLSL] Enable availability attribute
Some HLSL functionality is gated on the target shader model version.
Enabling the use of availability markup allows us to diagnose
availability issues easily in the frontend.

Reviewed By: erichkeane

Differential Revision: https://reviews.llvm.org/D134067
2022-09-16 16:04:27 -05:00
Sotiris Apostolakis b827e7c600 [SelectOpti] Restrict load sinking
This is a follow-up to D133777, which resolved a use-after-free case but
did not cover all possible memory bugs due to misplacement of loads.

In short, the overall problem was that sinked loads could be moved after
state-modifying instructions leading to memory bugs.

The solution is to restrict load sinking unless it is found to be sound.
i) Within a basic block (to-be-sinked load and select-user are in the same BB),
loads can be sinked only if there is no intervening state-modifying instruction.
This is a conservative approach to avoid resorting to alias analysis to detect
potential memory overlap.
ii) Across basic blocks, sinking of loads is avoided. This is because going over
multiple basic blocks looking for memory conflicts could be computationally
expensive and also unlikely to allow loads to sink. Further, experiments showed
that not sinking these loads has a slight positive performance effect.
Maybe for some of these loads, having some separation allows enough time
for the load to be executed in time for its user. This is not the case for
floating point operations that benefit more from sinking.

The solution in D133777 was essentially undone in this patch,
since the latter is a complete solution to the observed problem.

Overall, the performance impact of this patch is minimal.
Tested on two internal Google workloads with instrPGO.
Search application showed <0.05% perf difference,
while the database one showed a slight improvement,
but not statistically significant.

Reviewed By: davidxl

Differential Revision: https://reviews.llvm.org/D133999
2022-09-16 20:50:46 +00:00
Siva Chandra Reddy f5cbbb9988 [libc] Add implementation of POSIX setrlimit and getrlimit functions.
Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D134016
2022-09-16 20:50:28 +00:00
Teresa Johnson c2cf93c1a9 [WPD/LTT] Lower type test feeding assumes via phi correctly
This fixes https://github.com/llvm/llvm-project/issues/57616.

Type test lowering in ThinLTO modules relies on having type id
summaries set up for the referenced types, which provide the type
test resolution. If there is no summary, the type tests are lowered
to false. At the very least, a default type id summary gives the
type tests a resolution of Unknown, which is handled correctly (ignored
by the first invocation of LTT, and lowered to true by the second).

WPD sets up the type id summaries (with a default type test resolution)
as it is processing the type tests, but only does this for the patterns
handled by WPD, which is a type test directly feeding an assume. In the
case of type tests feeding an assume via a phi, the type id summary was
not being set up, leading to the type tests being lowered to false
incorrectly.

Fix this by adding the default type id summary entries for all type ids
used on globals during index-only WPD.

This is not an issue for hybrid (split-lto-unit) LTO, as in that case
the type test resolution is determined and set up during LTT, since the
type definitions are in the regular LTO split module, and exported via
the summary to the ThinLTO split module.

Differential Revision: https://reviews.llvm.org/D134012
2022-09-16 13:50:01 -07:00
Lang Hames 47e9e58808 [ORC][ORC-RT][MachO] Reset __data and __common sections on library close.
If we want to be able to close and then re-open a library then we need to reset
the data section states when the library is closed. This commit updates
MachOPlatform and the ORC runtime to track __data and __common sections, and
reset the state in MachOPlatformRuntimeState::dlcloseDeinitialize.

This is only a first step to full support -- there are other data sections that
we're not capturing, and we'll probably want a more efficient representation
for the sections (rather than passing their string name over IPC), but this is
a reasonable first step.

This commit also contains a fix to MapperJITLinkMemoryManager that prevents it
from calling OnDeallocated twice in the case of an error.
2022-09-16 13:40:19 -07:00
Maksim Panchenko 1d5393526c [BOLT] Change base class of ExecutableFileMemoryManager
When we derive EFMM from SectionMemoryManager, it brings into EFMM extra
functionality, such as the registry of exception handling sections,
page permission management, etc. Such functionality is of no use to
llvm-bolt and can even be detrimental (see
https://github.com/llvm/llvm-project/issues/56726).

Change the base class of ExecutableFileMemoryManager to MemoryManager,
avoid registering EH sections, and skip memory finalization.

Fixes #56726

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D133994
2022-09-16 13:39:12 -07:00
Maksim Panchenko 9742c25b98 [BOLT] Fix empty function emission in non-relocation mode
In non-relocation mode, every function is emitted in its own section. If
a function is empty, RuntimeDyld will still allocate 1-byte section
for the function and initialize it with zero. As a result, we will
overwrite the first byte of the original function contents with zero.
Such scenario can happen when the input function had only NOP
instructions which BOLT removes by default. Even though such functions
likely cause undefined behavior, it's better to preserve their contents.

Reviewed By: yota9

Differential Revision: https://reviews.llvm.org/D133978
2022-09-16 13:38:32 -07:00
Jessica Paquette 1076b31da8 [GlobalISel] Combine select + fcmp to fminnum/fmaxnum/fminimum/fmaximum
This is a partial port of the code used by the SelectionDAGBuilder to
translate selects.

In particular, see matchSelectPattern in ValueTracking.cpp. This is a
GISel-equivalent of the portion which handles fminnum/fmaxnum/fminimum/fmaximum.

I tried to set it up so it'd be easy to add the non-FP cases. Those are simpler.
On the AArch64-end, it seems like the FP cases are more important for perf
right now, so I bit the bullet and went at the more complicated problem. :)

I elected to do this as a post-legalize combine rather than in the
IRTranslator because

Deciding which fmax/fmin to use can depend on legalization rules
Philosophically-speaking (TM), putting it in a combine just feels cleaner

Being able to enable/disable the combine is handy
Another option would be to use the ValueTracking code in the IRTranslator and
match what SelectionDAGBuilder::visitSelect does. I think that may be somewhat
annoying since we'd need to write lowerings back into the selects in the
legalizer. I'm not strongly opposed to the approach.

We'd also want to be careful with vector selects once that's implemented,
which explicitly check if a vector select is legal on the target. That'd
probably need a hook.

From what I can tell, doing this as a combine is probably a cleaner option
long-term.

Differential Revision: https://reviews.llvm.org/D116702
2022-09-16 13:35:46 -07:00
Pengxuan Zheng 59365f33e2 [MachineCSE] Add a threshold to avoid spending too much time in isProfitableToCSE
Currently, it can become extremely costly to compute MayIncreasePressure if the
size of CSUses turns out to be very large. In that case, it's no longer cost
effective to keep computing MayIncreasePressure. Therefore, to limit the amount
of time spent in isProfitableToCSE, we simply conservatively assume
MayIncreasePressure if the size of CSUses is too large. This can reduce overall
compile time by 30% for some benchmarks.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D134003
2022-09-16 13:35:17 -07:00
Craig Topper 1121eca685 [VP][VE] Default VP_SREM/UREM to Expand and add generic expansion using VP_SDIV/UDIV+VP_MUL+VP_SUB.
I want to default all VP operations to Expand. These 2 were blocking
because VE doesn't support them and the tests were expecting them
to fail a specific way. Using Expand caused them to fail differently.

Seemed better to emulate them using operations that are supported.

@simoll mentioned on Discord that VE has some expansion downstream. Not
sure if its done like this or in the VE target.

Reviewed By: frasercrmck, efocht

Differential Revision: https://reviews.llvm.org/D133514
2022-09-16 13:19:02 -07:00
Xing Xue 8ace9ea258 [libc++][lit][AIX] Enable test case last_write_time.pass.cpp for AIX
Summary:
This patch enables libc++ LIT test case last_write_time.pass.cpp for AIX. Because system call utimensat() of AIX which is used in the libc++ implementation of last_write_time() does not accept the times parameter with a negative tv_sec or tv_nsec field, testing of setting file time to before epoch time is excluded for AIX.

Reviewed by: ldionne, libc++

Differential Revision: https://reviews.llvm.org/D133124
2022-09-16 16:08:40 -04:00
Craig Topper 61595c45af [RISCV] Simplify some code in vector fp<->int handling. NFC
We changed the way container types are selected since this code
was written. We no longer need to use the largest type.
2022-09-16 12:56:42 -07:00
Aiden Grossman c0bc461999 [Clang] Give error message for invalid profile path when compiling IR
Before this patch, when compiling an IR file (eg the .llvmbc section
from an object file compiled with -Xclang -fembed-bitcode=all) and
profile data was passed in using the -fprofile-instrument-use-path
flag, there would be no error printed (as the previous implementation
relied on the error getting caught again in the constructor of
CodeGenModule which isn't called when -x ir is set). This patch
moves the error checking directly to where the error is caught
originally rather than failing silently in setPGOUseInstrumentor and
waiting to catch it in CodeGenModule to print diagnostic information to
the user.

Regression test added.

Reviewed By: xur, mtrofin

Differential Revision: https://reviews.llvm.org/D132991
2022-09-16 19:45:57 +00:00
David Majnemer 8a868d8859 Revert "Revert "[clang, llvm] Add __declspec(safebuffers), support it in CodeView""
This reverts commit cd20a18286 and adds a
"let Heading" to NoStackProtectorDocs.
2022-09-16 19:39:48 +00:00
Kazu Hirata e0bc76eb23 [ModuleInliner] Move InlinePriority and its derived classes to InlineOrder.cpp (NFC)
These classes are referred to only from getInlineOrder in
InlineOrder.cpp.  This patch hides the entire class declarations and
definitions in InlineOrder.cpp.

Differential Revision: https://reviews.llvm.org/D134056
2022-09-16 12:32:16 -07:00
Stanislav Mekhanoshin 167826ee12 [AMDGPU] Fix runline for windows in sdag-print-divergence.ll. NFC. 2022-09-16 12:15:08 -07:00
Abhina Sreeskantharajan ce19343114 [test] Use host platform specific error message substitution
This patch modifies the testcase to use error substitution so it will pass on all platforms.

Reviewed By: fanbo-meng, zibi

Differential Revision: https://reviews.llvm.org/D134034
2022-09-16 15:13:45 -04:00
Jakub Kuderski a0debaa936 [mlir][arith] Remove misleading comment in EmulateWideInt. NFC.
At the request of @Mogball.
2022-09-16 15:02:47 -04:00
Amir Ayupov e002523b65 [BOLT] Verify externally referenced blocks against jump table targets
For functions with references to internal offsets from data, verify externally
referenced blocks against the set of jump table targets. Mark the function
as non-simple if there are any unclaimed data to code references.

Reviewed By: #bolt, maksfb

Differential Revision: https://reviews.llvm.org/D132495
2022-09-16 11:44:33 -07:00
Stanislav Mekhanoshin a0c8f5fefa [SDAG] Print divergence in SDNode::dump
If target does not support divergence the field is set to false
and not printed.

Differential Revision: https://reviews.llvm.org/D133984
2022-09-16 11:43:34 -07:00
Wei Yi Tee a4f8e3d240 Revert "[clang][dataflow] Replace `transfer(const Stmt *, ...)` with `transfer(const CFGElement *, ...)` in `Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel`."
This reverts commit 41f235d268.

Details at https://lab.llvm.org/buildbot#builders/139/builds/28171.
Breakage due to API change.
2022-09-16 18:07:35 +00:00
Wei Yi Tee 41f235d268 [clang][dataflow] Replace `transfer(const Stmt *, ...)` with `transfer(const CFGElement *, ...)` in `Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel`.
Reviewed By: gribozavr2, sgatev

Differential Revision: https://reviews.llvm.org/D133930
2022-09-16 17:54:12 +00:00
Justin Lebar 8cc3bfd13f
[NFC] Fix indentation in ValueTracking.h.
In a separate patch I want to modify ValueTracking.h.  When I touch the
header, arc wants to clang-format the lines I touch (reasonable!).  But
then these whitespace changes get mixed into my patch.
2022-09-16 10:46:23 -07:00
Thomas Raoux 54db8cc7b1 [mlir][vector] Remove ExtractMap/InsertMap operations
As discussed on discourse: https://discourse.llvm.org/t/vector-vector-distribution-large-vector-to-small-vector/1983/22
removing insert_map/extract_map op as vector distribution now uses
warp_execute_on_lane_0 op.

Differential Revision: https://reviews.llvm.org/D134000
2022-09-16 17:41:26 +00:00
Michał Górny 587729c3ad [clang] [Driver] Add an option to disable default config filenames
Add a `--no-default-config` option that disables the search for default
set of config filenames (based on the compiler executable name).

Suggested in https://discourse.llvm.org/t/rfc-adding-a-default-file-location-to-config-file-support/63606.

Differential Revision: https://reviews.llvm.org/D134018
2022-09-16 19:38:11 +02:00
Brett Wilson e191086bfc [clang-doc] Support default args for functions.
Adds support for default arguments in the internal representation and reads these values from the source. Implements writing these values to YAML but does not implement this for the HTML or markdown outputs.

Reviewed By: paulkirth

Differential Revision: https://reviews.llvm.org/D133732
2022-09-16 17:26:07 +00:00
Zequan Wu d21b417025 [LLDB][NativePDB] ResolveSymbolContext should return the innermost block
Before, it returns the outermost blocks if nested blocks have the same
address range. That casuses lldb unable to find variables that are inside
inner blocks.

Reviewed By: labath

Differential Revision: https://reviews.llvm.org/D133601
2022-09-16 10:19:09 -07:00
LLVM GN Syncbot 6073e0a2f7 [gn build] Port 7061a3f3f8 2022-09-16 16:49:26 +00:00
Jan Svoboda 4e637fcb25 [clang][deps] Make sure ScanInstance outlives collector
The `ScanInstance` is a local variable in `DependencyScanningAction::runInvocation()` that is referenced by `ModuleDepCollector`. Since D132405, `ModuleDepCollector` can escape the function and can outlive its `ScanInstance`. This patch fixes that.

Reviewed By: benlangmuir

Differential Revision: https://reviews.llvm.org/D133988
2022-09-16 09:44:12 -07:00
Kazu Hirata 9111920af8 [ModuleInliner] clang-format ModuleInliner.cpp (NFC) 2022-09-16 09:41:42 -07:00
Michael Buch e456d2ba8b [clang][ASTImporter] DeclContext::localUncachedLookup: Continue lookup into decl chain when regular lookup fails
The uncached lookup is mainly used in the ASTImporter/LLDB code-path
where we're not allowed to load from external storage. When importing
a FieldDecl with a DeclContext that had no external visible storage
(but came from a Clang module or PCH) the above call to `lookup(Name)`
the regular `DeclContext::lookup` fails because:
1. `DeclContext::buildLookup` doesn't set `LookupPtr` for decls
   that came from a module
2. LLDB doesn't use the `SharedImporterState`

In such a case we would never continue with the "slow" path of iterating
through the decl chain on the DeclContext. In some cases this means that
ASTNodeImporter::VisitFieldDecl ends up importing a decl into the
DeclContext a second time.

The patch removes the short-circuit in the case where we don't find
any decls via the regular lookup.

**Tests**

* Un-skip the failing LLDB API tests

Differential Revision: https://reviews.llvm.org/D133945
2022-09-16 12:38:50 -04:00
Michael Buch 3004a759bc [lldb][tests][gmodules] Test for expression evaluator crash for types referencing the same template
The problem here is that the ASTImporter adds
the template class member FieldDecl to
the DeclContext twice. This happens because
we don't construct a `LookupPtr` for decls
that originate from modules and thus the
ASTImporter never realizes that the FieldDecl
has already been imported. These duplicate
decls then break the assumption of the LayoutBuilder
which expects only a single member decl to
exist.

The test will be fixed by a follow-up revision
and is thus skipped for now.

Differential Revision: https://reviews.llvm.org/D133944
2022-09-16 12:38:49 -04:00
Kazu Hirata 4475470529 [ModuleInliner] Remove a stale comment (NFC)
These comments refer to the nested loop in the module inliner where
the inner loop grouped call sites from the same caller.  We don't
group call sites anymore, so the comment has become stale.
2022-09-16 09:37:43 -07:00
Kazu Hirata 42a90e6017 [ModuleInliner] Remove a redundaunt variable (NFC)
In the CGSCC inliner, DidInline was used as an indicator to update the call graph.

In the module inliner, DidInline is always true at the end of the
"while" loop, so can just drop it.
2022-09-16 09:32:02 -07:00
Simon Pilgrim 95c2c9c5c5 [LoopIdiom][X86] Add non-LZCNT test coverage to 'rshift until zero' idiom tests 2022-09-16 17:23:54 +01:00
Nicolas Vasilache 0422a4407f [mlir][scf][Transform] Refactor transform.fuse_into_containing_op so it is iterative and supports output fusion.
This revision revisits the implementation of `transform.fuse_into_containing_op` so that it iterates on
producers one use at a time.

Support is added to fuse a producer through a foreach_thread shared tensor argument, in which case we
tile and fuse the op inside the containing op and update the shared tensor argument to the unique destination operand.
If one cannot find such a unique destination operand the transform fails.

Differential Revision: https://reviews.llvm.org/D134051
2022-09-16 09:21:46 -07:00