platform/upstream/llvm.git
2 years ago[NFC][LV][X86] Improve test coverage for masked mem ops
Roman Lebedev [Wed, 27 Oct 2021 09:48:16 +0000 (12:48 +0300)]
[NFC][LV][X86] Improve test coverage for masked mem ops

2 years ago[mlir] Reduce the number of iterations in async microbenchmarks
Eugene Zhulenev [Wed, 27 Oct 2021 10:18:47 +0000 (03:18 -0700)]
[mlir] Reduce the number of iterations in async microbenchmarks

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

2 years ago[DSE] Add test case with 2 memcpys that should not be eliminated.
Florian Hahn [Wed, 27 Oct 2021 10:15:58 +0000 (11:15 +0100)]
[DSE] Add test case with 2 memcpys that should not be eliminated.

2 years ago[clang-repl] Remove redundant link libraries and drop unused file.
Vassil Vassilev [Wed, 27 Oct 2021 10:11:29 +0000 (10:11 +0000)]
[clang-repl] Remove redundant link libraries and drop unused file.

Many thanks to @thakis for pointing this out.

That commit should have been a part of https://reviews.llvm.org/D107049

2 years ago[pstl] A hot compilation fix for MacOS, OpenMP backend; + full qualified names for...
Mikhail Dvorskiy [Fri, 22 Oct 2021 15:58:06 +0000 (18:58 +0300)]
[pstl] A hot compilation fix for MacOS, OpenMP backend; + full qualified names for some internal functions

Reviewed By: nadiasvertex, ldionne

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

2 years ago[clangd] Add integration test for crash handling
Sam McCall [Tue, 26 Oct 2021 13:27:07 +0000 (15:27 +0200)]
[clangd] Add integration test for crash handling

This replaces the test removed in 51be7061d025139ba66869d5d99c7157a3ae9edd
It is more principled and tests more critical cases: a crash while parsing.

We need two pieces of plumbing:
 - a way to re-enable the crashing #pragmas via a flag, to test parse crashes
 - a bit of reshuffling around ASTWorker execution so that we set up the
   crash handler in both sync/async modes.
   Sync mode is useful for debugging, so I tested both.

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

2 years ago[clangd] IncludeCleaner: Don't warn on system headers
Kirill Bobyrev [Wed, 27 Oct 2021 09:50:35 +0000 (11:50 +0200)]
[clangd] IncludeCleaner: Don't warn on system headers

This is a temporary hack to disable diagnostics for system headers. As of right
now, IncludeCleaner does not handle the Standard Library correctly and will
report most system headers as unused because very few symbols are defined in
top-level system headers. This will eventually be fixed, but for now we are
aiming for the most conservative approach with as little false-positive
warnings as possible. After the initial prototype and core functionality is
polished, I will turn back to handling the Standard Library as it requires
custom logic.

Reviewed By: sammccall

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

2 years ago[clang-tidy] Correct typo in bugprone-easily-swappable-parameters
Salman Javed [Wed, 27 Oct 2021 09:38:52 +0000 (22:38 +1300)]
[clang-tidy] Correct typo in bugprone-easily-swappable-parameters

The string table `DefaultIgnoredParameterTypeSuffixes` has a typo:
`ForwardIt` is mistyped as `FowardIt`.

Correct typo and add test coverage.

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

2 years agoModernize Platform::GetOSKernelDescription
Pavel Labath [Tue, 26 Oct 2021 08:52:39 +0000 (10:52 +0200)]
Modernize Platform::GetOSKernelDescription

2 years ago[LiveInterval] Add RemoveDeadValNo argument to removeSegment(iterator)
Jay Foad [Mon, 27 Sep 2021 15:05:54 +0000 (16:05 +0100)]
[LiveInterval] Add RemoveDeadValNo argument to removeSegment(iterator)

Add an optional bool RemoveDeadValNo argument to the
removeSegment(iterator) overload, for consistency with the other
overloads. This gives clients a way to remove dead valnos while also
getting an updated iterator returned (in the manner of vector::erase).

Use this to clean up some inefficient code in
LiveIntervals::repairOldRegInRange. NFC.

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

2 years ago[ARM] __cxa_end_cleanup should be called instead of _UnwindResume.
Daniel Kiss [Wed, 27 Oct 2021 08:32:11 +0000 (10:32 +0200)]
[ARM] __cxa_end_cleanup should be called instead of _UnwindResume.

ARM EHABI[1] specifies the __cxa_end_cleanup to be called after cleanup.
It will call the UnwindResume.
__cxa_begin_cleanup will be called from libcxxabi while __cxa_end_cleanup is never called.
This will trigger a termination when a foreign exception is processed while UnwindResume is called
because the global state will be wrong due to the missing __cxa_end_cleanup call.

Additional test here: D109856
[1] https://github.com/ARM-software/abi-aa/blob/main/ehabi32/ehabi32.rst#941compiler-helper-functions

Reviewed By: logan

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

2 years ago[NFC][LoopVectorize] Remove setBestPlan in favour of getBestPlanFor
David Sherwood [Mon, 4 Oct 2021 16:31:35 +0000 (17:31 +0100)]
[NFC][LoopVectorize] Remove setBestPlan in favour of getBestPlanFor

I have removed LoopVectorizationPlanner::setBestPlan, since this
function is quite aggressive because it deletes all other plans
except the one containing the <VF,UF> pair required. The code is
currently written to assume that all <VF,UF> pairs will live in the
same vplan. This is overly restrictive, since scalable VFs live in
different plans to fixed-width VFS. When we add support for
vectorising epilogue loops when the main loop uses scalable vectors
then we will the vplan for the main loop will be different to the
epilogue.

Instead I have added a new function called

  LoopVectorizationPlanner::getBestPlanFor

that returns the best vplan for the <VF,UF> pair requested and leaves
all the vplans untouched. We then pass this best vplan to

  LoopVectorizationPlanner::executePlan

which now takes an additional VPlanPtr argument.

Differential revision: https://reviews.llvm.org/D111125

2 years ago[mlir][linalg][bufferize] Add analysis fuzzer option
Matthias Springer [Wed, 27 Oct 2021 07:40:26 +0000 (16:40 +0900)]
[mlir][linalg][bufferize] Add analysis fuzzer option

Analyze ops in a pseudo-random order to see if any assertions are triggered. Randomizing the order of analysis likely worsens the quality of the bufferization result (more out-of-place bufferizations). However, assertions should never fail, as that would indicate a problem with our implementation.

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

2 years ago[MLIR][OpenMP] Added omp.atomic.read and omp.atomic.write
Shraiysh Vaishay [Wed, 27 Oct 2021 06:48:00 +0000 (12:18 +0530)]
[MLIR][OpenMP] Added omp.atomic.read and omp.atomic.write

This patch supports the atomic construct (read and write) following
section 2.17.7 of OpenMP 5.0 standard. Also added tests and
verifier for the same.

Reviewed By: kiranchandramohan

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

2 years ago[clangd] IncludeCleaner: Support macros
Kirill Bobyrev [Wed, 27 Oct 2021 08:30:03 +0000 (10:30 +0200)]
[clangd] IncludeCleaner: Support macros

Collect the macro definition locations for all the macros used in the main
file.

Reviewed By: sammccall

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

2 years ago[mlir][Linalg] NFC - Add additional control to lower vector.shape_cast ops
Nicolas Vasilache [Tue, 26 Oct 2021 21:13:11 +0000 (21:13 +0000)]
[mlir][Linalg] NFC - Add additional control to lower vector.shape_cast ops

This also moves some code to a new patterns file.

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

2 years ago[mlir][Vector] Add InsertStridedSliceOp -> ShuffleOp for the rank-1 cases.
Nicolas Vasilache [Wed, 27 Oct 2021 07:48:39 +0000 (07:48 +0000)]
[mlir][Vector] Add InsertStridedSliceOp -> ShuffleOp for the rank-1 cases.

This also fixes the vector.shuffle C++ builder which had an incorrect type assumption that triggers with this new rewrite.
The vector.shuffle semantics were correct though.

Differential revision: https://reviews.llvm.org/D112578

2 years ago[clangd] Fix filename ranges while replaying preamble
Kadir Cetinkaya [Tue, 26 Oct 2021 17:10:26 +0000 (19:10 +0200)]
[clangd] Fix filename ranges while replaying preamble

Clangd used first token of filename as filename range rather than the
synthezied filename token. Unfortunately the former only contains `"` or `<` in
the raw lexing mode, resulting in wrong range information and breaking tidy
checks that relied on it.

Fixes https://github.com/clangd/clangd/issues/896.

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

2 years ago[InferAddressSpaces] Make pass work with opaque pointers
Arthur Eubanks [Wed, 27 Oct 2021 06:41:02 +0000 (23:41 -0700)]
[InferAddressSpaces] Make pass work with opaque pointers

Avoid getPointerElementType().

2 years agotsan: tidy up SCOPED_INTERCEPTOR_RAW
Dmitry Vyukov [Tue, 26 Oct 2021 14:37:11 +0000 (16:37 +0200)]
tsan: tidy up SCOPED_INTERCEPTOR_RAW

Don't leak caller_pc var from the macro
(it's not supposed to be used by interceptors).
Use UNUSED instead of (void) cast.

Depends on D112540.

Reviewed By: melver

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

2 years agotsan: remove real func check from interceptors
Dmitry Vyukov [Tue, 26 Oct 2021 14:31:46 +0000 (16:31 +0200)]
tsan: remove real func check from interceptors

If the real function is not intercepted,
we are going to crash one way or another.
The question is just in the failure mode:
error message vs NULL deref. But the message
costs us a check in every interceptor and
they are not observed to be failing in real life
for a long time, also other sanitizers don't
have this check as well (also crash on
NULL deref if that happens).
Remove the check from non-debug mode.

Reviewed By: melver

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

2 years ago[Hexagon] Remove set-but-unused variables (NFC)
Kazu Hirata [Wed, 27 Oct 2021 06:38:14 +0000 (23:38 -0700)]
[Hexagon] Remove set-but-unused variables (NFC)

2 years agoRemove ConstString from Language, LanguageRuntime, SystemRuntime and SymbolFile plugi...
Pavel Labath [Thu, 21 Oct 2021 18:13:45 +0000 (20:13 +0200)]
Remove ConstString from Language, LanguageRuntime, SystemRuntime and SymbolFile plugin names

2 years ago[X86][NFC] Add the missed `break;` for 79f9dfef0da5
Phoebe Wang [Wed, 27 Oct 2021 05:58:31 +0000 (13:58 +0800)]
[X86][NFC] Add the missed `break;` for 79f9dfef0da5

2 years ago[Clang][NFC] Clang CUDA codegen clean-up
Uday Bondhugula [Tue, 19 Oct 2021 07:19:01 +0000 (12:49 +0530)]
[Clang][NFC] Clang CUDA codegen clean-up

Update an instance of dyn_cast -> cast and other NFC clang-tidy fixes
for Clang CUDA codegen.

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

2 years ago[RISCV] Add ICmp and FCmp to shouldSinkOperands.
Craig Topper [Wed, 27 Oct 2021 05:23:48 +0000 (22:23 -0700)]
[RISCV] Add ICmp and FCmp to shouldSinkOperands.

2 years agoFix AffineDemotion pass after the DialectConversion change in D111620
River Riddle [Wed, 27 Oct 2021 04:11:49 +0000 (04:11 +0000)]
Fix AffineDemotion pass after the DialectConversion change in D111620

2 years ago[Utils] Fix a warning in DialectConversion.cpp
Kazu Hirata [Wed, 27 Oct 2021 04:01:29 +0000 (21:01 -0700)]
[Utils] Fix a warning in DialectConversion.cpp

This patch fixes:

  mlir/lib/Transforms/Utils/DialectConversion.cpp:2775:5: error:
  default label in switch which covers all enumeration values
  [-Werror,-Wcovered-switch-default]

by removing the default case.  This way, the compiler should issue a
warning in the future when somebody adds a new enum value without a
corresponding case in the switch statement.

2 years ago[JITLink] Fix element-present check in MachOLinkGraphParser.
Lang Hames [Wed, 27 Oct 2021 01:32:06 +0000 (18:32 -0700)]
[JITLink] Fix element-present check in MachOLinkGraphParser.

Not all symbols are added to the index-to-symbol map, so we shouldn't use the
size of the map as a proxy for the highest valid index.

2 years ago[ORC] Don't try to perform empty deallocations.
Lang Hames [Mon, 25 Oct 2021 22:06:45 +0000 (15:06 -0700)]
[ORC] Don't try to perform empty deallocations.

2 years agoGeneralize DWARF tests that expect DW_FORM_strp
Jake Egan [Wed, 27 Oct 2021 03:42:15 +0000 (23:42 -0400)]
Generalize DWARF tests that expect DW_FORM_strp

The modified tests were failing on AIX because DWARF on AIX uses inline strings by default, but the tests check for `DW_FORM_strp`.

This patch removes `DW_FORM_strp` so both forms will pass the check.

Reviewed By: shchenz, dblaikie

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

2 years ago[SCEV][NFC] Verify intergity of SCEVUsers
Max Kazantsev [Wed, 27 Oct 2021 02:28:45 +0000 (09:28 +0700)]
[SCEV][NFC] Verify intergity of SCEVUsers

Make sure that, for every living SCEV, we have all its direct
operand tracking it as their user.

Differential Revision: https://reviews.llvm.org/D112402
Reviewed By: reames

2 years ago[RISCV] Optimize immediate materialisation with SLLI.UW in the Zba extension
Ben Shi [Sun, 17 Oct 2021 12:27:57 +0000 (12:27 +0000)]
[RISCV] Optimize immediate materialisation with SLLI.UW in the Zba extension

Simplify "LUI+SLLI+ADDI+SLLI" and "LUI+ADDIW+SLLI+ADDI+SLLI" to
"LUI+ADDIW+SLLIUW" to reduce total instruction amount.

Reviewed By: craig.topper

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

2 years ago[RISCV][test] Add more tests of immediate materialisation
Ben Shi [Sat, 16 Oct 2021 09:06:14 +0000 (09:06 +0000)]
[RISCV][test] Add more tests of immediate materialisation

Reviewed By: craig.topper, MaskRay

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

2 years ago[mlir:DialectConversion] Restructure how argument/target materializations get invoked
River Riddle [Wed, 27 Oct 2021 02:00:10 +0000 (02:00 +0000)]
[mlir:DialectConversion] Restructure how argument/target materializations get invoked

The current implementation invokes materializations
whenever an input operand does not have a mapping for the
desired type, i.e. it requires materialization at the earliest possible
point. This conflicts with goal of dialect conversion (and also the
current documentation) which states that a materialization is only
required if the materialization is supposed to persist after the
conversion process has finished.

This revision refactors this such that whenever a target
materialization "might" be necessary, we insert an
unrealized_conversion_cast to act as a temporary materialization.
This allows for deferring the invocation of the user
materialization hooks until the end of the conversion process,
where we actually have a better sense if it's actually
necessary. This has several benefits:

* In some cases a target materialization hook is no longer
   necessary
When performing a full conversion, there are some situations
where a temporary materialization is necessary. Moving forward,
these users won't need to provide any target materializations,
as the temporary materializations do not require the user to
provide materialization hooks.

* getRemappedValue can now handle values that haven't been
   converted yet
Before this commit, it wasn't well supported to get the remapped
value of a value that hadn't been converted yet (making it
difficult/impossible to convert multiple operations in many
situations). This commit updates getRemappedValue to properly
handle this case by inserting temporary materializations when
necessary.

Another code-health related benefit is that with this change we
can move a majority of the complexity related to materializations
to the end of the conversion process, instead of handling adhoc
while conversion is happening.

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

2 years ago[NFC] Tidy up DialectConversion.cpp
River Riddle [Wed, 27 Oct 2021 01:59:45 +0000 (01:59 +0000)]
[NFC] Tidy up DialectConversion.cpp

This file has gotten a bit crusty over the years, and has outdated stylistic decisions.

2 years ago[CUDA][NFC] Fix inexact warning message about lambdas
Ben Shi [Tue, 26 Oct 2021 08:39:51 +0000 (08:39 +0000)]
[CUDA][NFC] Fix inexact warning message about lambdas

Reviewed By: tra

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

2 years agoUnbreak code_signature_lc.test on macOS after 911be05743eb606
Nico Weber [Wed, 27 Oct 2021 01:05:48 +0000 (21:05 -0400)]
Unbreak code_signature_lc.test on macOS after 911be05743eb606

2 years ago[test][objcopy] Replace GNU sed extension with BSD compatible syntax.
Daniel Rodríguez Troitiño [Wed, 27 Oct 2021 00:03:08 +0000 (17:03 -0700)]
[test][objcopy] Replace GNU sed extension with BSD compatible syntax.

GNU sed offers the `,+4d` to delete the line a next four lines, but BSD
sed doesn't seem to support it (at least in macOS 10.15, but seems to do
in my 11.6 version).

Replace the usage of the extension with the equivalent syntax that works
both in BSD and GNU sed. I don't have a macOS 10.15 to check, but this
works in both my macOS 11.6 and Linux machines.

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

2 years ago[mlir] Fix missing prefix for region accessor on OpAdaptor
Jacques Pienaar [Wed, 27 Oct 2021 00:35:16 +0000 (17:35 -0700)]
[mlir] Fix missing prefix for region accessor on OpAdaptor

Also flip op-decl-and-defs test to _Prefixed to test more.

2 years ago[mlir] Avoid including <alloca.h> on OpenBSD
Brad Smith [Wed, 27 Oct 2021 00:05:12 +0000 (20:05 -0400)]
[mlir] Avoid including <alloca.h> on OpenBSD

2 years ago[Demangle] Add prepend functionality to OutputString
Luís Ferreira [Tue, 26 Oct 2021 23:23:27 +0000 (16:23 -0700)]
[Demangle] Add prepend functionality to OutputString

Implement the functionallity of prepend, required by D demangler.
Please read discussion https://reviews.llvm.org/D111414 for context.
See also https://reviews.llvm.org/D111947 .

Reviewed By: dblaikie, Geod24

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

2 years agoAdd cross-project-test for simplified template name rebuilding
David Blaikie [Tue, 26 Oct 2021 23:19:38 +0000 (16:19 -0700)]
Add cross-project-test for simplified template name rebuilding

2 years ago[gn build] Port 566bfbb740bb
LLVM GN Syncbot [Tue, 26 Oct 2021 23:05:31 +0000 (23:05 +0000)]
[gn build] Port 566bfbb740bb

2 years ago[mlir][ods] Fix incorrect accessing of segment_sizes
Jacques Pienaar [Tue, 26 Oct 2021 23:04:15 +0000 (16:04 -0700)]
[mlir][ods] Fix incorrect accessing of segment_sizes

The previous change resulted in prefixing a query that uses the raw
attribute as if function invocation. Fixing quickly, with updated test
to follow.

2 years ago[lld-macho] Fix compact-unwind-bad-reloc.s test
Jez Ng [Tue, 26 Oct 2021 22:40:20 +0000 (18:40 -0400)]
[lld-macho] Fix compact-unwind-bad-reloc.s test

Broken by a9353dbe517c522ac63818de2cde645acdc46834.

Now that the functions point to the compact unwind entries, instead of
the other way around, we need to perform the "invalid reference" check
in a different place.

This change was originally part of the stacked diff D109946, but should
have been included as part of D109945.

2 years agollvm-dwarfdump --verify: Exit non-zero on simplified template name rebuilding failures
David Blaikie [Tue, 26 Oct 2021 22:48:20 +0000 (15:48 -0700)]
llvm-dwarfdump --verify: Exit non-zero on simplified template name rebuilding failures

2 years agoReland "[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)"
Nico Weber [Tue, 26 Oct 2021 22:40:07 +0000 (18:40 -0400)]
Reland "[gn build] (manually) port 6fe2beba7d2a (ExceptionTests)"

This reverts commit e2a2e5475cbd370044474e132a1b5c58e6a3d458.
6fe2beba7d2a relanded (again) in c24a58081b527fa8.

2 years ago[tosa][mlir] Add bailout to TosaMakeBroadcastable for unranked case
Rob Suderman [Tue, 26 Oct 2021 22:08:05 +0000 (15:08 -0700)]
[tosa][mlir] Add bailout to TosaMakeBroadcastable for unranked case

Dyn-cast should be checked and bailed out if the dyn_cast failed.

Reviewed By: sjarus, NatashaKnk

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

2 years ago[AMDGPU] Use max waves for scheduler's initial occupancy target
Austin Kerbow [Sat, 23 Oct 2021 05:06:41 +0000 (22:06 -0700)]
[AMDGPU] Use max waves for scheduler's initial occupancy target

The scheduler should set critical/excess register usage thresholds that
are guided by the maximum possible occupancy for the function. This
change is focused on setting proper lower bounds on register usage which
we would typically only see when a specific number of maximum waves is
requested with the "waves-per-eu" attribute, or by setting
"amdgpu-num-vgpr|sgpr" directly. This was broken previously. I have a
follow-on patch that will address issues with the scheduler not
targeting correct upper bounds on register usage which is typical with
launch bounds and min "waves-per-eu".

Changes by this patch:

Set the initial critical register usage thresholds to minimum values
that are determined by the maximum possible occupancy for the function,
or the number of allocatable registers, whichever is lower.

Avoid unisgned overflow if register limits are lower than the register
tracking "ErrorMargin", I.e. when using stress-regalloc=2.

Reviewed By: arsenm

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

2 years ago[DebugInfo] Skip ODRUniquing for mismatched tags
Yuanfang Chen [Tue, 26 Oct 2021 20:58:43 +0000 (13:58 -0700)]
[DebugInfo] Skip ODRUniquing for mismatched tags

Otherwise, ODRUniquing would map some member method/variable MDNodes
to have enum type DIScope, resulting in invalid debug info and bad
DWARF.

- Add a Verifier check that when a 'scope:' operand is an ODR type that is not an enum.
- Makes ODRUniquing apply to only ODR types with the same tag so that the debuginfo/DWARF is well-formed.

Reviewed By: probinson, aprantl

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

2 years agoAdd new key/value pairs to the module statistics for "statistics dump".
Greg Clayton [Tue, 26 Oct 2021 01:03:06 +0000 (18:03 -0700)]
Add new key/value pairs to the module statistics for "statistics dump".

The new key/value pairs that are added to each module's stats are:
"debugInfoByteSize": The size in bytes of debug info for each module.
"debugInfoIndexTime": The time in seconds that it took to index the debug info.
"debugInfoParseTime": The time in seconds that debug info had to be parsed.

At the top level we add up all of the debug info size, parse time and index time with the following keys:
"totalDebugInfoByteSize": The size in bytes of all debug info in all modules.
"totalDebugInfoIndexTime": The time in seconds that it took to index all debug info if it was indexed for all modules.
"totalDebugInfoParseTime": The time in seconds that debug info was parsed for all modules.

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

2 years agoRegenerate LC_CODE_SIGNATURE during llvm-objcopy operations
Nuri Amari [Tue, 26 Oct 2021 21:25:34 +0000 (14:25 -0700)]
Regenerate LC_CODE_SIGNATURE during llvm-objcopy operations

**Context:**

This is a second attempt at introducing signature regeneration to llvm-objcopy. In this diff: https://reviews.llvm.org/D109840, a script was introduced to test
the validity of a code signature. In this diff: https://reviews.llvm.org/D109803 (now reverted), an effort was made to extract the signature generation behavior out of LLD into a common location for use in llvm-objcopy. In this diff: https://reviews.llvm.org/D109972 it was decided that there was no appropriate common location and that a small amount of duplication to bring signature generation to llvm-objcopy would be better. This diff introduces this duplication.

**Summary**

Prior to this change, if a LC_CODE_SIGNATURE load command
was included in the binary passed to llvm-objcopy, the command and
associated section were simply copied and included verbatim in the
new binary. If rest of the binary was modified at all, this results
in an invalid Mach-O file. This change regenerates the signature
rather than copying it.

The code_signature_lc.test test was modified to include the yaml
representation of a small signed MachO executable in order to
effectively test the signature generation.

Reviewed By: alexander-shaposhnikov, #lld-macho

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

2 years ago[formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs
Danil Stefaniuc [Tue, 26 Oct 2021 21:24:46 +0000 (14:24 -0700)]
[formatters] Add a libstdcpp formatter for bitset and unify tests across stdlibs

This diff adds a data formatter for libstdcpp's bitset. Besides, it unifies the tests for bitset for libcxx and libstdcpp for maintainability.

Reviewed By: wallace

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

2 years ago[InstCombine] try to canonicalize icmp with trunc op into mask and cmp
Sanjay Patel [Tue, 26 Oct 2021 21:41:19 +0000 (17:41 -0400)]
[InstCombine] try to canonicalize icmp with trunc op into mask and cmp

The motivating test is based on:
https://llvm.org/PR52260

We have better analysis for X == 0, so try harder to form that.

2 years ago[InstCombine] add tests for icmp with trunc op; NFC
Sanjay Patel [Tue, 26 Oct 2021 21:09:10 +0000 (17:09 -0400)]
[InstCombine] add tests for icmp with trunc op; NFC

2 years ago[mlir][sparse] refine trait of sparse_tensor.convert
Aart Bik [Tue, 26 Oct 2021 21:16:05 +0000 (14:16 -0700)]
[mlir][sparse] refine trait of sparse_tensor.convert

Rationale:
The currently used trait was demanding that all types are the same
which is not true (since the sparse part may change and the dim sizes
may be relaxed). This revision uses the correct trait and makes the
rank match test explicit in the verify method.

Reviewed By: ftynse

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

2 years ago[Bazel] link backtrace library when building llvm/lib/Support under FreeBSD
William Muir [Tue, 26 Oct 2021 21:23:11 +0000 (14:23 -0700)]
[Bazel] link backtrace library when building llvm/lib/Support under FreeBSD

Links the backtrace library which is required under FreeBSD when building llvm/lib/Support.  This library is similarly linked by CMake on BSD builds at [llvm/lib/Support/CMakeLists.txt](https://github.com/llvm/llvm-project/blob/e158b5634aa67ea3039a62c3d8bda79b77b3b21c/llvm/lib/Support/CMakeLists.txt#L39-L46)

Reviewed By: GMNGeoffrey

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

2 years ago[SLP][NFC]Add a test for poison-free or reduction.
Alexey Bataev [Tue, 26 Oct 2021 21:04:05 +0000 (14:04 -0700)]
[SLP][NFC]Add a test for poison-free or reduction.

2 years ago[mlir][sparse] refactor loop sequence codegen
Aart Bik [Tue, 26 Oct 2021 03:10:42 +0000 (20:10 -0700)]
[mlir][sparse] refactor loop sequence codegen

This refactoring adds a few "event" functions (start/end loop-seq/loop) for
readability of the core function of codegen. This also prepares sparse tensor
output codegen, where these "event" functions will provide convenient
placeholders to start or stop insertion bookkeeping.

This revision also includes a few various minor changes that kept on
pending in my local workspace.

Reviewed By: bixia

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

2 years ago[libomptarget][nfc]Generalise DeviceRTL cmake to allow building for amdgpu
Jon Chesterfield [Tue, 26 Oct 2021 20:18:19 +0000 (21:18 +0100)]
[libomptarget][nfc]Generalise DeviceRTL cmake to allow building for amdgpu

Essentially moves the foreach over sm integers into a macro and instantiates it for nvptx.

NFC in that the macro is not presently instantiated for amdgpu as the corresponding code doesn't compile yet.

Reviewed By: Meinersbur

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

2 years ago[lld-macho] Simplify the handling of "no unwind info" functions
Jez Ng [Tue, 26 Oct 2021 20:04:06 +0000 (16:04 -0400)]
[lld-macho] Simplify the handling of "no unwind info" functions

This diff does away with `addEntriesForFunctionsWithoutUnwindInfo()`,
because `addSymbol()` can now determine which functions need those
entries.

While overhauling UnwindInfoSection, I also parallelized the relocation
of the contents of the CUEs. This somewhat offsets the time regression
from creating one InputSection per CUE (which was done in D109944).

Reviewed By: #lld-macho, oontvoo

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

2 years ago[lld-macho] Associate compact unwind entries with function symbols
Jez Ng [Tue, 26 Oct 2021 20:04:04 +0000 (16:04 -0400)]
[lld-macho] Associate compact unwind entries with function symbols

Compact unwind entries (CUEs) contain pointers to their respective
function symbols. However, during the link process, it's far more useful
to have pointers from the function symbol to the CUE than vice versa.
This diff adds that pointer in the form of `Defined::compactUnwind`.

In particular, when doing dead-stripping, we want to mark CUEs live when
their function symbol is live; and when doing ICF, we want to dedup
sections iff the symbols in that section have identical CUEs. In both
cases, we want to be able to locate the symbols within a given section,
as well as locate the CUEs belonging to those symbols. So this diff also
adds `InputSection::symbols`.

The ultimate goal of this refactor is to have ICF support dedup'ing
functions with unwind info, but that will be handled in subsequent
diffs. This diff focuses on simplifying `-dead_strip` --
`findFunctionsWithUnwindInfo` is no longer necessary, and
`Defined::isLive()` is now a lot simpler. Moreover, UnwindInfoSection no
longer has to check for dead CUEs -- we simply avoid adding them in the
first place.

Additionally, we now support stripping of dead LSDAs, which follows
quite naturally since `markLive()` can now reach them via the CUEs.

Reviewed By: #lld-macho, gkm

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

2 years ago[InstCombine] Precommit new and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Tue, 26 Oct 2021 19:57:17 +0000 (12:57 -0700)]
[InstCombine] Precommit new and-xor-or.ll tests. NFC.

2 years ago[fir] Avoid slice with substr in fir.array_load, fir.array_coor and fir.array_merge_store
Valentin Clement [Tue, 26 Oct 2021 19:42:26 +0000 (21:42 +0200)]
[fir] Avoid slice with substr in fir.array_load, fir.array_coor and fir.array_merge_store

Substring information on slice operation has been added in D112441.
The operations fir.array_load, fir.array_coor and fir.array_merge_store can take
a slice but not with a substring. This patch add this check in their verifier.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

2 years ago[mlir] Use float literals to make Windows build happy.
Alexander Belyaev [Tue, 26 Oct 2021 19:35:49 +0000 (21:35 +0200)]
[mlir] Use float literals to make Windows build happy.

2 years agoReinstate "[clang-repl] Re-implement clang-interpreter as a test case."
Vassil Vassilev [Mon, 25 Oct 2021 17:52:20 +0000 (17:52 +0000)]
Reinstate "[clang-repl] Re-implement clang-interpreter as a test case."

Original commit message: "
  Original commit message: "
    Original commit message: "
       Original commit message:"
         The current infrastructure in lib/Interpreter has a tool, clang-repl, very
         similar to clang-interpreter which also allows incremental compilation.

         This patch moves clang-interpreter as a test case and drops it as conditionally
         built example as we already have clang-repl in place.
       "

       This patch also ignores ppc due to missing weak symbol for __gxx_personality_v0
       which may be a feature request for the jit infrastructure. Also, adds a missing
       build system dependency to the orc jit.
    "

    Additionally, this patch defines a custom exception type and thus avoids the
    requirement to include header <exception>, making it easier to deploy across
    systems without standard location of the c++ headers.
  "

  This patch also works around PR49692 and finds a way to use llvm::consumeError
  in rtti mode.
"

This patch also checks if stl is built with rtti.

Differential revision: https://reviews.llvm.org/D107049

2 years ago[Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)
Florian Hahn [Tue, 26 Oct 2021 19:19:36 +0000 (20:19 +0100)]
[Matrix] Replace some err kinds with err_builtin_invalid_arg_type. (NFC)

Replace some custom matrix diagnostic kinds with the more generic
err_builtin_invalid_arg_type introduced in D111985.

Reviewed By: aaron.ballman, erichkeane

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

2 years ago[mlir] Update Erf approximation.
Alexander Belyaev [Tue, 26 Oct 2021 19:27:20 +0000 (21:27 +0200)]
[mlir] Update Erf approximation.

2 years ago[fir][NFC] Move RewritePatterns.td to CanonicalizationPatterns.td in Dialect
Valentin Clement [Tue, 26 Oct 2021 19:12:36 +0000 (21:12 +0200)]
[fir][NFC] Move RewritePatterns.td to CanonicalizationPatterns.td in Dialect

RewritePatterns.td/RewritePatterns.inc is used only by the
FIROps.cpp file. This patch move this file logically in the Dialect
folder together with FIRDialet, FIROps, FIRTypes ...
It also rename it to CanonicalizationPatterns.td.

This patch is part of the upstreaming effort from fir-dev branch.

Reviewed By: schweitz

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

2 years ago[lldb] [unittests] Fix TcpListen() call in RNBSocketTest
Michał Górny [Tue, 26 Oct 2021 19:08:03 +0000 (21:08 +0200)]
[lldb] [unittests] Fix TcpListen() call in RNBSocketTest

2 years ago[TSan] Ensure test uses tagged pointer
Julian Lettner [Tue, 26 Oct 2021 18:43:04 +0000 (11:43 -0700)]
[TSan] Ensure test uses tagged pointer

This is a test-only failure. The test wrongly assumes that this gets us
a tagged pointer:
```
NSObject* num1 = @7;
assert(isTaggedPtr(num1));
```

However, on newer deployment targets that have “const data support” we
get a “normal” pointer to constant object.

Radar-Id: rdar://problem/83217293

2 years ago[mlir] Allow polynomial approximations for N-d vectors.
Alexander Belyaev [Tue, 26 Oct 2021 18:39:25 +0000 (20:39 +0200)]
[mlir] Allow polynomial approximations for N-d vectors.

Polynomial approximation can be extented to support N-d vectors.
N-dimensional vectors are useful when vectorizing operations on N-dimensional
tiles. Before lowering to LLVM these vectors are usually unrolled or flattened
to 1-dimensional vectors.

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

2 years ago[mlir][python] Segment MLIR Python test dialect to avoid testonly dependency.
Stella Laurenzo [Tue, 26 Oct 2021 17:14:50 +0000 (17:14 +0000)]
[mlir][python] Segment MLIR Python test dialect to avoid testonly dependency.

With https://reviews.llvm.org/rG14c9207063bb00823a5126131e50c93f6e288bd3, the build is broken with -DMLIR_INCLUDE_TESTS=OFF. This patch fixes the build and we may want to do a better fix to the layering in a followup.

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

2 years ago[ARC] Fix `undefined symbol: llvm::MachineFunction::dump() const`
Fangrui Song [Tue, 26 Oct 2021 18:44:18 +0000 (11:44 -0700)]
[ARC] Fix `undefined symbol: llvm::MachineFunction::dump() const`

2 years ago[AST] Fix the EndLoc calculation for ObjCObjectPointer
Luke Petre [Tue, 26 Oct 2021 18:02:08 +0000 (14:02 -0400)]
[AST] Fix the EndLoc calculation for ObjCObjectPointer

There is an issue where the AST code does not compute the correct SourceRange
for a ObjCObjectPointer.

From Richard Smith (ie @zygoloid) in discord:

I think the problem is that we set an invalid location for the * (because there
isn't one): https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaType.cpp#L1121
And then we use the default getLocalSourceRangeImpl for a PointerLikeTypeLoc
that just assumes the * location is the type's end location:
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/TypeLoc.h#L1293
Possibly we should be special-casing that here:
https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/TypeLoc.cpp#L228

My change:

introduces a AST dump test to show the issue in the first commit
special cases ObjCObjectPointerType in the second commit to correctly compute
the end location

2 years agoFix indentation and pragma name.
Zahira Ammarguellat [Tue, 26 Oct 2021 16:18:28 +0000 (12:18 -0400)]
Fix indentation and pragma name.

2 years agoaddress an test error on window os , exclude the test llvm/test/tools/llvm-readobj...
zhijian [Tue, 26 Oct 2021 17:56:52 +0000 (13:56 -0400)]
address an test error on window os , exclude the test llvm/test/tools/llvm-readobj/XCOFF/xcoff-auxiliary-header.test from
windows OS.
http://45.33.8.238/win/47662/step_11.txt
for
https://reviews.llvm.org/D82549

2 years agoRevert "tsan: turn off COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED"
Dmitry Vyukov [Tue, 26 Oct 2021 17:47:34 +0000 (19:47 +0200)]
Revert "tsan: turn off COMMON_INTERCEPTOR_NOTHING_IS_INITIALIZED"

This reverts commit 5ec832269eedeeddcf00d34efd7272a107e2c7c1.

It broke a number of bots, e.g.:
https://lab.llvm.org/buildbot/#/builders/52/builds/11811

Reviewed By: melver

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

2 years ago[libc++][NFC] Mark LWG2731 as complete
Joe Loser [Tue, 26 Oct 2021 17:45:52 +0000 (13:45 -0400)]
[libc++][NFC] Mark LWG2731 as complete

Mark LWG2731 as complete. The type alias `mutex_type` is only provided if
`scoped_lock` is given one mutex type and it has been implemented that
way since the beginning of Clang 5 it seems. There already are tests for
verifying existence (and lack thereof) for `mutex_type` type alias
depending on the number of mutex types, so there is nothing to
do for this LWG issue.

Reviewed By: Quuxplusone, Mordante, #libc

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

2 years ago[mlir] Placeholder used in predicate should be the base type
Chia-hung Duan [Tue, 26 Oct 2021 17:35:15 +0000 (17:35 +0000)]
[mlir] Placeholder used in predicate should be the base type

Added a notification in the placeholder section. While writing things
like preciate of an attribute, we may embed certain placeholder in the C
expression. Note that the type of the placeholder is only guaranteed to
be the base type like mlir::Type, it's better not to use the derived
type which is based on the implementation.

Reviewed By: mehdi_amini

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

2 years ago[NFC][Instcombine] Pre-commit some tests for negative fabs
Usman Nadeem [Tue, 26 Oct 2021 17:22:17 +0000 (10:22 -0700)]
[NFC][Instcombine] Pre-commit some tests for negative fabs

Change-Id: Idcce321c825ecc6b3a111a683e24dc10015f6872

2 years ago[SLP][NFC]Add a test for logical reduction with extra op.
Alexey Bataev [Tue, 26 Oct 2021 17:11:26 +0000 (10:11 -0700)]
[SLP][NFC]Add a test for logical reduction with extra op.

2 years ago[InstCombine] Precommit new and-xor-or.ll tests. NFC.
Stanislav Mekhanoshin [Tue, 26 Oct 2021 17:09:21 +0000 (10:09 -0700)]
[InstCombine] Precommit new and-xor-or.ll tests. NFC.

2 years ago[libc++] Implement shared_ptr methods inline in the class
Louis Dionne [Mon, 25 Oct 2021 19:05:27 +0000 (15:05 -0400)]
[libc++] Implement shared_ptr methods inline in the class

This patch refactors the shared_ptr methods from being defined out-of-line
to being defined inline in the class, like what we do for all new code in
the library. The benefits of doing that are that code is not as scattered
around and is hence easier to understand, and it avoids a ton of duplication
due to SFINAE checks. Defining the method where it is declared also removes
the possibility for mismatched attributes.

As a fly-by change, this also:

- Adds a few _LIBCPP_HIDE_FROM_ABI attributes
- Uses __enable_if_t instead of enable_if as a function argument, to match
  the style that we use everywhere else.

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

2 years ago[NFC][Instcombine] Cleanup some obsolete matches in visitSelectInstr
Usman Nadeem [Tue, 26 Oct 2021 17:07:08 +0000 (10:07 -0700)]
[NFC][Instcombine] Cleanup some obsolete matches in visitSelectInstr

These are now redundant after https://reviews.llvm.org/D106872

Change-Id: I82edfedf1d45cac4e3368d77ce3a48c78e342c19

2 years ago[LoopVectorize] Clean up VPReductionRecipe::execute. NFC
Rosie Sumpter [Tue, 26 Oct 2021 10:24:28 +0000 (11:24 +0100)]
[LoopVectorize] Clean up VPReductionRecipe::execute. NFC

Use RdxDesc->getOpcode instead of getUnderlingInstr()->getOpcode.
Move the code which finds Kind and IsOrdered to be outside the for loop
since neither of these change with the vector part.

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

2 years ago[analyzer] Fix StringChecker for Unknown params
Balazs Benics [Tue, 26 Oct 2021 16:15:00 +0000 (18:15 +0200)]
[analyzer] Fix StringChecker for Unknown params

It seems like protobuf crashed the `std::string` checker.
Somehow it acquired `UnknownVal` as the sole `std::string` constructor
parameter, causing a crash in the `castAs<Loc>()`.

This patch addresses this.

Reviewed By: martong

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

2 years ago[mlir] Fix getVectorReductionOp
Amy Zhuang [Tue, 26 Oct 2021 15:42:22 +0000 (08:42 -0700)]
[mlir] Fix getVectorReductionOp

1.Combining kind min/max of Vector reduction op has been changed to
  minf/maxf, minsi/maxsi, and minui/maxui. Modify getVectorReductionOp
  accordingly.
2.Add min/max to supported reductions.

Reviewed By: dcaballe, nicolasvasilache

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

2 years ago[CodeGen, Hexagon] Use MachineBasicBlock::phis (NFC)
Kazu Hirata [Tue, 26 Oct 2021 16:01:29 +0000 (09:01 -0700)]
[CodeGen, Hexagon] Use MachineBasicBlock::phis (NFC)

2 years ago[Clang] Add elementwise min/max builtins.
Florian Hahn [Tue, 26 Oct 2021 14:38:32 +0000 (15:38 +0100)]
[Clang] Add elementwise min/max builtins.

This patch implements __builtin_elementwise_max and
__builtin_elementwise_min, as specified in D111529.

Reviewed By: aaron.ballman

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

2 years ago[x86] add test/run for mayLoadFold with alignment; NFC
Sanjay Patel [Tue, 26 Oct 2021 14:44:19 +0000 (10:44 -0400)]
[x86] add test/run for mayLoadFold with alignment; NFC

2 years ago[lld-macho] Put GOT into `__DATA` segment where appropriate
Jez Ng [Tue, 26 Oct 2021 15:36:09 +0000 (11:36 -0400)]
[lld-macho] Put GOT into `__DATA` segment where appropriate

We were previously always emitting the GOT into `__DATA_CONST`, even for
target platforms where it should end up in `__DATA`.

I stumbled onto this while trying to use the `class-dump` tool -- with
the wrong segment names, it fails to locate the ObjC runtime info and
therefore fails to dump any classes.

Reviewed By: #lld-macho, oontvoo

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

2 years ago[clangd] AddUsing: Fix support for template specializations.
Adam Czachorowski [Tue, 26 Oct 2021 13:04:03 +0000 (15:04 +0200)]
[clangd] AddUsing: Fix support for template specializations.

Before this change, we would add "using std::vector<int>" instead of
just "using std::vector;", which would not even compile.

Fixes https://github.com/clangd/clangd/issues/904

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

2 years ago[clangd] Fix a hover crash on templated spaceship operator.
Adam Czachorowski [Tue, 26 Oct 2021 11:34:10 +0000 (13:34 +0200)]
[clangd] Fix a hover crash on templated spaceship operator.

We make assumption that:
getDeclForComment(getDeclForComment(X)) == getDeclForComment(X)
but this is not true if you have a template
instantionation of a template instantiation, which is the case when, for
example, you have a <=> operator in a templated class.

This fix makes getDeclForComment() call itself recursively to ensure
this property is always true.

Fixes https://github.com/clangd/clangd/issues/901

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

2 years ago[clang] Do not traverse EnumDecl's type in RecursiveASTVisitor
Kirill Bobyrev [Tue, 26 Oct 2021 15:10:51 +0000 (17:10 +0200)]
[clang] Do not traverse EnumDecl's type in RecursiveASTVisitor

This is inconsistent with the code and comments in
RecursiveASTVisitor.h and is not a correct behavior:

https://github.com/llvm/llvm-project/blob/main/clang/include/clang/AST/RecursiveASTVisitor.h#L1879-L1880

> We shouldn't traverse D->getTypeForDecl(); it's a result of
> declaring the type, not something that was written in the source.

Fixes the failures in 1c2e249f938c50e1b331a1f7adc83c0a381f3897

2 years ago[libFuzzer] Improve corpus replacement unit test.
Matt Morehouse [Tue, 26 Oct 2021 15:08:23 +0000 (08:08 -0700)]
[libFuzzer] Improve corpus replacement unit test.

Verify that SecondII is not replaced.

2 years ago[SystemZ] Improvement of emitMemMemWrapper()
Jonas Paulsson [Tue, 19 Oct 2021 10:47:15 +0000 (12:47 +0200)]
[SystemZ] Improvement of emitMemMemWrapper()

It was discovered that an extra register COPY remained when expanding a
(variable length) memory operation with a loop and there was another use of
the involved address register(s) afterwards.

A simple fix for this is to COPY the address registers before the loop and
use that new vreg instead.

Review: Ulrich Weigand

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

2 years ago[SLP]Do not reorder reduction nodes.
Alexey Bataev [Mon, 25 Oct 2021 16:40:59 +0000 (09:40 -0700)]
[SLP]Do not reorder reduction nodes.

The final reduction nodes should not be reordered, the order does not
matter for reductions. Also, it might be profitable to vectorize smaller
reduction trees, reduction cost may compensate small tree cost.

Part of D111574

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

2 years ago[AIX][XCOFF] parsing xcoff object file auxiliary header
zhijian [Tue, 26 Oct 2021 14:40:25 +0000 (10:40 -0400)]
[AIX][XCOFF] parsing xcoff object file auxiliary header
Summary:

The patch supports parsing the xcoff object file auxiliary header with llvm-readobj with option "auxiliary-headers"

the format of auxiliary header as
https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/filesreference/XCOFF.html#XCOFF__fyovh386shar

Reviewers: James Henderson, Jason Liu, Hubert Tong, Esme yi, Sean Fertile.

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