Commit Graph

436174 Commits

Author SHA1 Message Date
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
mbs 7061a3f3f8 [support] Prepare TimeProfiler for cross-thread support
This NFC prepares the TimeProfiler to support the construction
and completion of time profiling 'entries' across threads.

Add ClockType alias so we can change the clock in one place.
(trivial) Use c++ usings instead of typedefs
Rename Entry to TimeTraceProfilerEntry since this type will eventually become public.
Add an intro comment.
Add some smoke unit tests.

Reviewed By: russell.gallop, rriddle, lattner, jloser

Differential Revision: https://reviews.llvm.org/D133153
2022-09-16 10:20:18 -06:00
Wei Yi Tee 9cbdef6103 [clang][dataflow] Replace usage of the deprecated overload of `checkDataflow`.
Updated files:
- `ChromiumCheckModelTest.cpp`.
- `MatchSwitchTest.cpp`.
- `MultiVarConstantPropagationTest.cpp`.
- `SingleVarConstantPropagationTest.cpp`.
- `TestingSupportTest.cpp`.
- `TransferTest.cpp`.

Reviewed By: gribozavr2, sgatev

Differential Revision: https://reviews.llvm.org/D133865
2022-09-16 16:19:07 +00:00
Kazu Hirata 513717ddd0 [ModuleInliner] Remove a write-only variable (NFC)
InlinedCallees is a remnant from the CGSCC inliner.  We don't use it
in the module inliner.
2022-09-16 09:15:53 -07:00
Jakub Kuderski 95c3e9c222 [mlir][arith] Support wide int shrui emulation
Tested by checking all 16-bit LHS and all valid RHS when emulating i16 with i8 operations.

Reviewed By: antiagainst, Mogball

Differential Revision: https://reviews.llvm.org/D133722
2022-09-16 12:09:33 -04:00
Jakub Kuderski db0d6e567d [mlir][arith] Support wide integer multiplication emulation
Emulate multiplication by splitting each input element of type i2N into 4
digits of type iN and bit width i(N/2). This is so that the intermediate
multiplications and additions do not overflow. We extract these i(N/2)
digits from iN vector elements by masking (low digit) and shifting right
(high digit).

The multiplication algorithm used is the standard (long) multiplication.
Multiplying two i2N integers produces (at most) a i4N result, but because
the calculation of top i2N is not necessary, we omit it.
In total, this implementations performs 10 intermediate multiplications
and 16 additions. The number of multiplications could be decreased by
switching to a more efficient algorithm like Karatsuba. This would,
however, require being able to perform (intermediate) wide additions and
subtractions, so it is not clear that such implementation would be more
efficient.

I tested this on all 16-bit inut pairs, when emulating i16 with i8.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D133629
2022-09-16 12:02:25 -04:00
Simon Pilgrim 23cb1c42cd [CostModel][X86] Update throughput costs for CTLZ ops
This was achieved with an updated version of the 'cost-tables vs llvm-mca' script D103695 (and recent fixes to the bdver2 + alderlake models)

Adding full CostKinds costs are affecting some other tests as they make assumptions about SizeLatency costs, so they need addressing first
2022-09-16 16:56:49 +01:00
Kazu Hirata 77501bfab8 [IPO] Simplify the module inliner loop (NFC)
In the bottom-up inliner, we have a two-level nested "while" loop,
with the inner one grouping call sites with the same caller.  We need
to do so to keep CGSCC up to date.

Now, with the module inliner, we don't have any per-caller work.  We
don't update CGSCC.  Plus, the caller will likely keep changing as we
pop call sites in some priority order.

This patch simply removes the inner "while" loop while indenting its
body.  Further cleanup is possible, but that's left for follow-up
patches.

Differential Revision: https://reviews.llvm.org/D133969
2022-09-16 08:56:18 -07:00
Jakub Kuderski e41498dddb [mlir][arith] Add initial files for (runtime) integration tests
The goal is to have a set of runtime tests for further extercise the
wide integer emulation pass and its conversion patterns. This was
suggested by @Mogball in D133629.

Add a minimal runtime test to demonstrate that printing and pass
pipeline works as expected.

Reviewed By: Mogball

Differential Revision: https://reviews.llvm.org/D134004
2022-09-16 11:52:48 -04:00
Juan Manuel MARTINEZ CAAMAÑO e438f2d821 [DAGCombine] Do not fold SRA/SRL of MUL into MULH when MUL's LSB are
used, and MUL_LOHI is available

Folding into a sra(mul) / srl(mul) into a mulh introduces an extra
multiplication to compute the high half of the multiplication,
while it is more profitable to compute the high and lower halfs with a
single mul_lohi.

Differential Revision: https://reviews.llvm.org/D133768
2022-09-16 15:48:36 +00:00
Matheus Izvekov f4ea3bd4b2
[clang] Fixes how we represent / emulate builtin templates
We change the template specialization of builtin templates to
behave like aliases.

Though unlike real alias templates, these might still produce a canonical
TemplateSpecializationType when some important argument is dependent.

For example, we can't do anything about make_integer_seq when the
count is dependent, or a type_pack_element when the index is dependent.

We change type deduction to not try to deduce canonical TSTs of
builtin templates.

We also change those buitin templates to produce substitution sugar,
just like a real instantiation would, making the resulting type correctly
represent the template arguments used to specialize the underlying template.

And make_integer_seq will now produce a TST for the specialization
of it's first argument, which we use as the underlying type of
the builtin alias.

When performing member access on the resulting type, it's now
possible to map from a Subst* node to the template argument
as-written used in a regular fashion, without special casing.

And this fixes a bunch of bugs with relation to these builtin
templates factoring into deduction.

Fixes GH42102 and GH51928.

Depends on D133261

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

Differential Revision: https://reviews.llvm.org/D133262
2022-09-16 17:44:12 +02:00
Daniel Bertalan a8843ec952
[lld-macho] Parallelize linker optimization hint processing
This commit moves the parsing of linker optimization hints into
`ARM64::applyOptimizationHints`. This lets us avoid allocating memory
for holding the parsed information, and moves work out of
`ObjFile::parse`, which is not parallelized at the moment.

This change reduces the overhead of processing LOHs to 25-30 ms when
linking Chromium Framework on my M1 machine; previously it took close to
100 ms.

There's no statistically significant change in runtime for a --threads=1
link.

Performance figures with all 8 cores utilized:

      N           Min           Max        Median           Avg        Stddev
  x  20     3.8027232     3.8760762     3.8505335     3.8454145   0.026352574
  +  20     3.7019017     3.8660538     3.7546209     3.7620371   0.032680043
  Difference at 95.0% confidence
  	-0.0833775 +/- 0.019
  	-2.16823% +/- 0.494094%
  	(Student's t, pooled s = 0.0296854)

Differential Revision: https://reviews.llvm.org/D133439
2022-09-16 17:38:46 +02:00
Sourabh Singh Tomar 396ed327bb [flang][OpenMP] Lower OpenMP `taskgroup` construct
Lower Fortran OpenMP `taskgroup` to FIR + OpenMP Dialect.

Reviewed By: kiranchandramohan, peixin

Differential Revision: https://reviews.llvm.org/D133918
2022-09-16 21:07:47 +05:30
Dave Lee 6e450d1347 [lldb] Use SWIG_fail in python-typemaps.swig (NFC)
When attempting to use SWIG's `-builtin` flag, there were a few compile
failures caused by a mismatch between return type and return value. In those
cases, the return type was `int` but many of the type maps assume returning
`NULL`/`nullptr` (only the latter caused compile failures).

This fix abstracts failure paths to use the `SWIG_fail` macro, which performs
`goto fail;`. Each of the generated functions contain a `fail` label, which
performs any resource cleanup and returns the appropriate failure value.

This change isn't strictly necessary at this point, but seems like the right
thing to do, and for anyone who tries `-builtin` later, it resolves those
issues.

Differential Revision: https://reviews.llvm.org/D133961
2022-09-16 08:25:01 -07:00
Dmitry Preobrazhensky ef8feb6359 [AMDGPU][MC][NFC] Correct error message
Differential Revision: https://reviews.llvm.org/D134028
2022-09-16 18:22:08 +03:00
Matheus Izvekov 591452eb23
NFC: [clang] add template AST test for make_integer_seq and type_pack_element
Signed-off-by: Matheus Izvekov <mizvekov@gmail.com>

Differential Revision: https://reviews.llvm.org/D133261
2022-09-16 17:12:49 +02:00
Zahira Ammarguellat 1b69ce1208 Currently the options ‘ffast-math’ and ‘ffp-contract’ are connected.
When ‘ffast-math’ is set, ffp-contract is altered this way:
-ffast-math/ Ofast -> ffp-contract=fast
-fno-fast-math -> if ffp-contract= fast then ffp-contract=on else
ffp-contract unchanged

This differs from gcc which doesn’t connect the two options.

Connecting these two options in clang, resulted in spurious warnings
when the user combines these two options -ffast-math -fno-fast-math; see
issue https://github.com/llvm/llvm-project/issues/54625.

The issue is that the ‘ffast-math’ option is an on/off flag, but the
‘ffp-contract’ is an on/off/fast flag. So when ‘fno-fast-math’ is used
there is no obvious value for ‘ffp-contract’. What should the value of
ffp-contract be for -ffp-contract=fast -fno-fast-math and -ffast-math
-ffp-contract=fast -fno-fast-math? The current logic sets ffp-contract
back to on in these cases. This doesn’t take into account that the value
of ffp-contract is modified by an explicit ffp-contract` option.
This patch is proposing a set of rules to apply when ffp-contract',
ffast-math and fno-fast-math are combined. These rules would give the
user the expected behavior and no diagnostic would be needed.

See RFC
https://discourse.llvm.org/t/rfc-making-ffast-math-option-unrelated-to-ffp-contract-option/61912
2022-09-16 11:08:41 -04:00
Matheus Izvekov 00ce271712
[clang] extend getCommonSugaredType to merge sugar nodes
This continues D111283 by extending the getCommonSugaredType
implementation to also merge non-canonical type nodes.

We merge these nodes by going up starting from the canonical
node, calculating their merged properties on the way.

If we reach a pair that is too different, or which we could not
otherwise unify, we bail out and don't try to keep going on to
the next pair, in effect striping out all the remaining top-level
sugar nodes. This avoids mismatching 'companion' nodes, such as
ElaboratedType, so that they don't end up elaborating some other
unrelated thing.

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

Differential Revision: https://reviews.llvm.org/D130308
2022-09-16 17:04:10 +02:00
Nico Weber 6fe8c433ba [gn build] port 2d52c6bfae more (follow-up to 41c79d0b6d, __tuple split) 2022-09-16 10:49:18 -04:00
Sander de Smalen bd4935c175 [AArch64][SME] Implement ABI for calls from streaming-compatible functions.
When a function is streaming-compatible and calls a function with a normal or streaming
interface, it may need to enable/disable stremaing mode before the call, and
needs to restore PSTATE.SM after the call.

This patch implements this with a Pseudo node that gets expanded to a
conditional branch and smstart/smstop node.

More details about the SME attributes and design can be found
in D131562.

Reviewed By: aemerson

Differential Revision: https://reviews.llvm.org/D131578
2022-09-16 14:48:37 +00:00
Sander de Smalen 4fc2c922fe [AArch64][SME] Document SME ABI implementation in LLVM
Adds a design document for implementing the SME ABI in LLVM. This document
can be used as a reference for follow-up patches that attempt to implement
the ABI.

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D131562
2022-09-16 14:48:37 +00:00
Sanjay Patel 6174da2299 [InstCombine] reduce code duplication in foldICmpMulConstant(); NFC 2022-09-16 10:39:54 -04:00
Matheus Izvekov 67e2298311
[clang] use getCommonSugar in an assortment of places
For this patch, a simple search was performed for patterns where there are
two types (usually an LHS and an RHS) which are structurally the same, and there
is some result type which is resolved as either one of them (typically LHS for
consistency).

We change those cases to resolve as the common sugared type between those two,
utilizing the new infrastructure created for this purpose.

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

Differential Revision: https://reviews.llvm.org/D111509
2022-09-16 16:36:00 +02:00
Simon Pilgrim 89e4cb603d [X86] Add missing (unsupported) zmm vector move classes
Although unsupported on HSW, we reuse this model for KNL which does require them

Noticed when running the cost model fuzz script from D103695 with -mcpu=knl
2022-09-16 15:31:26 +01:00
Liqiang Tao 2e37557fde StackProtector: ensure stack checks are inserted before the tail call
The IR stack protector pass should insert stack checks before the tail
calls not only the musttail calls. So that the attributes `ssqreq` and
`tail call`, which are emited by llvm-opt, could be both enabled by
llvm-llc.

Reviewed By: compnerd

Differential Revision: https://reviews.llvm.org/D133860
2022-09-16 22:24:46 +08:00
Muiez Ahmed 1b445cada5 [SystemZ][z/OS] define REMOVE_ALL_USE_DIRECTORY_ITERATOR (libc++)
This patch fixes the z/OS build by using the first implementation of __remove_all since we don't have access to the openat() family of POSIX functions.

Differential Revision: https://reviews.llvm.org/D132948
2022-09-16 10:22:21 -04:00
Mark de Wever c632ee1c5d [libc++] Shows the detailed compiler version info.
The libc++ pre-commit CI uses Clang nightly builds. Currently it's not
possible to determine the exact version used since CMake doesn't show
this information by default. Instead use the --version flag to get this
information.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133122
2022-09-16 16:15:36 +02:00
Sander de Smalen b00c36c295 [AArch64][SME] Implement ABI for calls to/from streaming functions.
This patch implements the ABI for calls from:

  Normal -> Streaming
  Normal -> Streaming-compatible
  Streaming -> Normal
  Streaming -> Streaming-compatible
  Streaming -> Streaming

The compiler inserts SMSTART/SMSTOP instructions before and after the call,
depending on the required transition.

More details about the SME attributes and design can be found
in D131562.

Reviewed By: aemerson

Differential Revision: https://reviews.llvm.org/D131576
2022-09-16 14:07:47 +00:00
Florian Hahn 6b86b481e3
[AArch64] Use tbl for truncating vector FPtoUI conversions.
On AArch64, doing the vector truncate separately after the fptoui
conversion can be lowered more efficiently using tbl.4, building on
D133495.

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

Depends on D133495

Reviewed By: t.p.northover

Differential Revision: https://reviews.llvm.org/D133496
2022-09-16 14:57:43 +01:00
sstwcw e5964223d9 [clang-format] Fix template arguments in macros
Fixes https://github.com/llvm/llvm-project/issues/57738

old
```
#define FOO(typeName, realClass)                               \
  {                                                            \
#typeName, foo < FooType>(new foo <realClass>(#typeName))  \
  }
```
new
```
#define FOO(typeName, realClass)                                \
  { #typeName, foo<FooType>(new foo<realClass>(#typeName)) }
```

Previously, when an UnwrappedLine began with a hash in a macro
definition, the program incorrectly assumed the line was a preprocessor
directive.  It should be stringification.

The rule in spaceRequiredBefore was added in 8b5297117b.  Its purpose is
to add a space in an include directive.  It also added a space to a
template opener when the line began with a stringification hash.  So we
changed it.

Reviewed By: HazardyKnusperkeks, owenpan

Differential Revision: https://reviews.llvm.org/D133954
2022-09-16 13:30:46 +00:00
sstwcw 2183fe2160 [clang-format] Parse the else part of `#if 0`
Fixes https://github.com/llvm/llvm-project/issues/57539

Previously things outside of `#if` blocks were parsed as if only the
first branch of the conditional compilation branch existed, unless the
first condition is 0.  In that case the outer parts would be parsed as
if nothing inside the conditional parts existed.  Now we use the second
conditional branch if the first condition is 0.

Reviewed By: owenpan

Differential Revision: https://reviews.llvm.org/D133647
2022-09-16 13:30:46 +00:00
Adrian Vogelsgesang c9cffdde39 [libunwind] Fix usage of `_dl_find_object` on 32-bit x86
On 32-bit x86, `_dl_find_object` also returns a `dlfo_eh_dbase` address.
So far, compiling against a version of `_dl_find_object` which returns a
`dlfo_eh_dbase` was blocked using a `#if` + `#error`. This commit now
removes this compile time assertion and simply ignores the returned
`dlfo_eh_dbase`. All test cases are passing on a 32-bit build now.

According to https://www.gnu.org/software/libc/manual/html_node/Dynamic-Linker-Introspection.html,
`dlfo_eh_dbase` should be the base address for all DW_EH_PE_datarel
relocations. However, glibc/elf/dl-find_object.h says that eh_dbase
is the relocated DT_PLTGOT value. I don't understand how those two
statements fit together, but to fix 32-bit x86, ignoring `dlfo_eh_dbase`
seems to be good enough.

Fixes #57733

Differential Revision: https://reviews.llvm.org/D133846
2022-09-16 06:29:49 -07:00
Mark de Wever c0ac3c1142 [NFC][libc++][test] Uses public functions.
Replaces std::__format_context_create with the public wrapper
test_format_context_create.

Reviewed By: #libc, ldionne

Differential Revision: https://reviews.llvm.org/D133781
2022-09-16 14:57:21 +02:00
Simon Pilgrim f8fa04295f [CostModel][X86] Add CostKinds handling for vector integer comparisons
These were based off a mixture of vector integer add/sub costs and the numbers from the 'cost-tables vs llvm-mca' script from D103695 - the extra costs for different predicates are still proving tricky to implement, but I've gotten most costs to within +/1 now - the AVX512 are tricky as we still don't handle predicate results properly, so most of these were done by hand.
2022-09-16 13:03:41 +01:00
Joseph Huber 292cb114b0 [Libomptarget] Revert changes to AMDGPU plugin destructors
These patches exposed a lot of problems in the AMD toolchain. Rather
than keep it broken we should revert it to its old semi-functional
state. This will prevent us from using device destructors but should
remove some new bugs. In the future this interface should be changed
once these problems are addressed more correctly.

This reverts commit ed0f218115.

This reverts commit 2b7203a359.

Fixes #57536

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D133997
2022-09-16 06:55:51 -05:00
Florian Hahn 8491d01cc3
[AArch64] Lower vector trunc using tbl.
Similar to using tbl to lower vector ZExts, tbl4 can be used to lower
vector truncates.

The initial version support i32->i8 conversions.

Depends on D120571

Reviewed By: t.p.northover

Differential Revision: https://reviews.llvm.org/D133495
2022-09-16 12:42:49 +01:00