Dominik Adamski [Thu, 28 Jul 2022 08:57:40 +0000 (03:57 -0500)]
Add support for lowering simd if clause to LLVM IR
Scope of changes:
1) Added new function to generate loop versioning
2) Added support for if clause to applySimd function
2) Added tests which confirm that lowering is successful
If ifCond is specified, then collapsed loop is duplicated and if branch
is added. Duplicated loop is executed if simd ifCond is evaluated to false.
Reviewed By: Meinersbur
Differential Revision: https://reviews.llvm.org/D129368
Signed-off-by: Dominik Adamski <dominik.adamski@amd.com>
David Sherwood [Fri, 29 Jul 2022 15:31:18 +0000 (16:31 +0100)]
[DAGCombiner] Extend visitAND to include EXTRACT_SUBVECTOR
Eliminate an AND by redefining an anyext|sext|zext.
(and (extract_subvector (anyext|sext|zext v) _) iN_mask)
=> (extract_subvector (zeroext_iN v))
Differential Revision: https://reviews.llvm.org/D130782
Luís Marques [Mon, 1 Aug 2022 09:27:09 +0000 (11:27 +0200)]
[RISCV] Extend the Merge Base Offset pass to handle AUIPC+ADDI
Builds upon D123264, adding support for merging the low part of the LLA
address into the load/store instruction offsets.
Differential Revision: https://reviews.llvm.org/D123265
Guillaume Chatelet [Fri, 29 Jul 2022 13:23:58 +0000 (13:23 +0000)]
[libc][NFC] Use STL case for utility
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130771
Guillaume Chatelet [Fri, 29 Jul 2022 12:22:41 +0000 (12:22 +0000)]
[libc][NFC] Use STL case for limits
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130762
Tres Popp [Fri, 29 Jul 2022 13:04:29 +0000 (15:04 +0200)]
Remove empty AffineExpr stride canonicalization in makeCanonicalStridedLayoutExpr
The "optimization" would replace the AffineMap for an empty shape with a 0 to represent its indexing (stride * dimension) logic. Meanwhile other pieces of core logic (such as getStridesAndOffset and makeStridedLinearLayoutMap) require strides for all dimensions to ensure no aliasing can occur which would occur if the shape was not empty. For now, this optimization is removed as different pieces of core types disagree on this, so the optimization should be caller supplied or should be consistent throughout the infrastructure.
Differential Revision: https://reviews.llvm.org/D130772
Vladislav Dzhidzhoev [Mon, 1 Aug 2022 07:55:27 +0000 (09:55 +0200)]
[GlobalISel][DebugInfo] salvageDebugInfo analogue for gMIR
Salvage debug info of instruction that is about to be deleted as dead in
Combiner pass. Currently supported instructions are COPY and G_TRUNC.
It allows to salvage debug info of some dead arguments of functions, by putting
DWARF expression corresponding to the instruction being deleted into related
DBG_VALUE instruction.
Here is an example of missing variables location https://godbolt.org/z/K48osb9dK.
We see that arguments x, y of function foo are not available in debugger, and
corresponding DBG_VALUE instructions have undefined register operand instead of
variables locaton after Aarch64PreLegalizerCombiner pass. The reason is that
registers where variables are located are removed as dead (with instruction
G_TRUNC). We can use salvageDebugInfo analogue for gMIR to preserve debug
locations of dead variables.
Statistics of llvm object files built with vs without this commit on -O2
optimization level (CMAKE_BUILD_TYPE=RelWithDebInfo, -fglobal-isel) on Aarch64 (macOS):
Number of variables with 100% of parent scope covered by DW_AT_location has been increased by 7,9%.
Number of variables with 0% coverage of parent scope has been decreased by 1,2%.
Number of variables processed by location statistics has been increased by 2,9%.
Average PC ranges coverage has been increased by 1,8 percentage points.
Coverage can be improved by supporting more instructions, or by calling
salvageDebugInfo for instructions that are deleted during Combiner rules exection.
Reviewed By: aprantl
Differential Revision: https://reviews.llvm.org/D129909
Alex Bradbury [Mon, 1 Aug 2022 09:08:17 +0000 (10:08 +0100)]
[NFC] Use AllocaInst's getAddressSpace helper
Guillaume Chatelet [Fri, 29 Jul 2022 12:11:35 +0000 (12:11 +0000)]
[libc][NFC] Use STL case for functional
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130760
Mehdi Amini [Mon, 1 Aug 2022 08:52:41 +0000 (08:52 +0000)]
Fix MLIR Python binding for arith.constant after argument has been changed to an interface
e1795322844c removed the Type field from attributes and
arith::ConstantOp argument is now a TypedAttrInterface which isn't
supported by the python generator.
This patch temporarily restore the functionality for arith.constant but
won't generalize: we need to work on the generator instead.
Differential Revision: https://reviews.llvm.org/D130878
Florian Hahn [Mon, 1 Aug 2022 09:01:18 +0000 (10:01 +0100)]
[LV] Add additional tests with multiple chained recurrences.
Adds more extra tests for D119661.
Also update the test to use opaque pointers.
Guillaume Chatelet [Mon, 1 Aug 2022 08:46:01 +0000 (08:46 +0000)]
Reland [libc][NFC] Use STL case for array
This is a reland of https://reviews.llvm.org/D130773
Guillaume Chatelet [Mon, 1 Aug 2022 08:44:52 +0000 (08:44 +0000)]
Revert "[libc][NFC] Use STL case for array"
This reverts commit
7add0e5fdc5c7cb6f59f60cd436bf161cf9f9eb7.
Guillaume Chatelet [Fri, 29 Jul 2022 13:40:08 +0000 (13:40 +0000)]
[libc][NFC] Use STL case for array
Migrating all private STL code to the standard STL case but keeping it under the CPP namespace to avoid confusion.
Differential Revision: https://reviews.llvm.org/D130773
Frederic Cambus [Mon, 1 Aug 2022 08:34:55 +0000 (10:34 +0200)]
[clang] Update Clang version from 15 to 16 in scan-build.1.
Similar to D110763.
Fangrui Song [Mon, 1 Aug 2022 08:10:51 +0000 (01:10 -0700)]
[ELF] EhInputSection::getParentOffset: fix out-of-bounds access for symbols relative to a non-empty .eh_frame
This has unclear semantics and can be considered invalid. Return an arbitrary value.
Chuanqi Xu [Mon, 1 Aug 2022 08:02:27 +0000 (16:02 +0800)]
[C++2b] [Modules] Handle HaveModules with C++2b
Closing https://github.com/llvm/llvm-project/issues/56803. The root
cause for this bug is that we lack a good method to detect the language
mdoe when parsing the command line. There is a FIXME too. Dut to we lack
a good solution now, keep the workaround.
Serge Pavlov [Mon, 1 Aug 2022 07:52:40 +0000 (14:52 +0700)]
[Clang] Remove unused parameter. NFC
BinaryOperator::getFPFeatures get parameter, which is not used. Similar
methods of other AST nodes do not have any parameter.
Nikita Popov [Mon, 1 Aug 2022 07:19:20 +0000 (09:19 +0200)]
Revert "[SimplifyCFG] Allow SimplifyCFG hoisting to skip over non-matching instructions"
This reverts commit
7b0f6378e211e881c574748090a86beeab264ab3.
As commented on the review, this patch has a correctness issue
regarding the modelling of memory effects.
David Green [Mon, 1 Aug 2022 07:20:23 +0000 (08:20 +0100)]
[ARM] Simplify ArchGuard predicates in arm_neon.h.
__ARM_ARCH >= 8 is implied by defined(__aarch64__), so we don't need to
guard against both together.
Siva Chandra Reddy [Mon, 1 Aug 2022 07:13:20 +0000 (07:13 +0000)]
[libc][NFC] Mark a constructor of StringView to be constexpr.
WANG Xuerui [Mon, 1 Aug 2022 07:09:51 +0000 (15:09 +0800)]
[cmake] Support native LoongArch builds
Differential Revision: https://reviews.llvm.org/D130821
WANG Xuerui [Mon, 1 Aug 2022 07:04:54 +0000 (15:04 +0800)]
[cmake] Add LoongArch to config.guess
Necessary for native builds on LoongArch. Only Linux is added for now,
matching upstream config.git changes.
Unfortunately, the upstream config.guess is GPLv3+ since 2012, and
LLVM is without autoconf support for a long time, so the script's
licensing exception no longer works and a bump could not be trivially
done.
This is the same as the [upstream commit adding LoongArch](https://git.savannah.gnu.org/gitweb/?p=config.git;a=commitdiff;h=
c8ddc8472f8efcadafc1ef53ca1d863415fddd5f),
but rewritten to match the 2011 style that our script is holding on
to.
Differential Revision: https://reviews.llvm.org/D130820
Momchil Velikov [Mon, 1 Aug 2022 05:48:22 +0000 (06:48 +0100)]
[SimplifyCFG] Allow SimplifyCFG hoisting to skip over non-matching instructions
SimplifyCFG does some common code hoisting, which is limited to hoisting a
sequence of identical instruction in identical order and stops at the first
non-identical instruction.
This patch allows hoisting instruction pairs over same-length sequences of
non-matching instructions. The linear asymptotic complexity of the algorithm
stays the same, there's an extra parameter `simplifycfg-hoist-common-skip-limit`
serving to limit compilation time and/or the size of the hoisted live ranges.
The patch improves SPECv6/525.x264_r by about 10%.
Reviewed By: dmgreen
Differential Revision: https://reviews.llvm.org/D129370
Siva Chandra Reddy [Mon, 1 Aug 2022 06:43:11 +0000 (06:43 +0000)]
[libc][NFC] Make the buffer size of the integer to string converter public.
This allows users of the IntegerToString class to size their buffers
appropriately at compile time.
Fangrui Song [Mon, 1 Aug 2022 06:49:33 +0000 (23:49 -0700)]
[test] Fix threadlocal_address.cpp after D129833
Older Darwin does not support thread_local:
error: thread-local storage is not supported for the current target
thread_local int j = 0;
jacquesguan [Tue, 26 Jul 2022 13:56:43 +0000 (21:56 +0800)]
[mlir][Math] Add constant folder for ExpM1Op.
This patch adds constant folder for ExpM1Op which only supports single and double precision floating-point.
Differential Revision: https://reviews.llvm.org/D130567
Fangrui Song [Mon, 1 Aug 2022 06:35:44 +0000 (23:35 -0700)]
[ELF] .eh_frame: remove config->wordsize padding
Linux Standard Base Core Specification says that CIE/FDE is padded to an
addressing unit size boundary, but in practice GNU assembler/LLVM integrated
assembler pad FDE/CIE to 4 and the last FDE to 8 on 64-bit systems.
In addition, GNU ld doesn't pad to 8, so let's drop excess padding, too.
If the assembler provides aligned pieces, the output will be aligned.
Noticed .eh_frame size reduction for 3 executables: 0.3% (chrome), 4.7% (clang),
7.6% (an internal program).
Nikita Popov [Mon, 1 Aug 2022 06:34:12 +0000 (08:34 +0200)]
[GlobalsAA] Remove unnecessary AAResultBase fallback (NFC)
This is unnecessary, as AA result chaining is implemented at a
higher level now.
Nikita Popov [Mon, 1 Aug 2022 06:32:47 +0000 (08:32 +0200)]
[ARMParallelDSP] Remove unnecessary ModRef intersection (NFC)
Intersecting with ModRef is a no-op, as these are the only two
possible values.
Chuanqi Xu [Mon, 1 Aug 2022 06:13:49 +0000 (14:13 +0800)]
[NFC] Fix test failure in windows
Siva Chandra Reddy [Mon, 1 Aug 2022 06:06:49 +0000 (06:06 +0000)]
[libc][NFC] Mark a few methods of StringView to constexpr.
Nikita Popov [Mon, 1 Aug 2022 05:55:39 +0000 (07:55 +0200)]
[AA] Drop setModAndRef() function (NFC)
Without the "must" state, this function is pointless, because we
can just directly create a ModRef instead.
Nikita Popov [Mon, 1 Aug 2022 05:28:36 +0000 (07:28 +0200)]
[MSSA] Fix expensive checks build
Nikita Popov [Mon, 1 Aug 2022 05:22:35 +0000 (07:22 +0200)]
[Examples] Fix SimplifyCFG example
After
fffabd53482f34f96ab9273486538f587e3d91fc, the v2 and v3
versions produce poison instead of undef. Also adjust the v1
version, as well as the test expectations, to make the example
pass again.
Nikita Popov [Thu, 28 Jul 2022 15:23:36 +0000 (17:23 +0200)]
[AA] Do not track Must in ModRefInfo
getModRefInfo() queries currently track whether the result is a
MustAlias on a best-effort basis. The only user of this functionality
is the optimized memory access type in MemorySSA -- which in turn
has no users. Given that this functionality has not found a user
since it was introduced five years ago (in D38862), I think we
should drop it again.
The context is that I'm working to separate FunctionModRefBehavior
to track mod/ref for different location kinds (like argmem or
inaccessiblemem) separately, and the fact that ModRefInfo also has
an unrelated Must flag makes this quite awkward, especially as this
means that NoModRef is not a zero value. If we want to retain the
functionality, I would probably split getModRefInfo() results into
a part that just contains the ModRef information, and a separate
part containing a (best-effort) AliasResult.
Differential Revision: https://reviews.llvm.org/D130713
Chuanqi Xu [Mon, 1 Aug 2022 03:07:13 +0000 (11:07 +0800)]
[NFC] Fill up the title underline in rst file
Fill up the title underline in rst file to avoid the CI error.
Chuanqi Xu [Mon, 1 Aug 2022 03:03:28 +0000 (11:03 +0800)]
Use @llvm.threadlocal.address intrinsic to access TLS variable
This is successor for D125291. This revision would try to use
@llvm.threadlocal.address in clang to access TLS variable. The reason
why the OpenMP tests contains a lot of change is that they uses
utils/update_cc_test_checks.py to update their tests.
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D129833
Fangrui Song [Mon, 1 Aug 2022 02:55:05 +0000 (19:55 -0700)]
[ELF] Remove EhFrameSection::addSection. NFC
Chuanqi Xu [Mon, 1 Aug 2022 02:51:30 +0000 (10:51 +0800)]
Introduce @llvm.threadlocal.address intrinsic to access TLS variable
This belongs to a series of patches which try to solve the thread
identification problem in coroutines. See
https://discourse.llvm.org/t/address-thread-identification-problems-with-coroutine/62015
for a full background.
The problem consists of two concrete problems: TLS variable and readnone
functions. This patch tries to convert the TLS problem to readnone
problem by converting the access of TLS variable to an intrinsic which
is marked as readnone.
The readnone problem would be addressed in following patches.
Reviewed By: nikic, jyknight, nhaehnle, ychen
Differential Revision: https://reviews.llvm.org/D125291
Fangrui Song [Mon, 1 Aug 2022 00:47:09 +0000 (17:47 -0700)]
[ELF] redirectSymbols: skip versioned symbol combine if config->versionDefinitions.size() == 2
Jez Ng [Mon, 1 Aug 2022 00:16:08 +0000 (20:16 -0400)]
[lld-macho] Support EH frame pointer encodings that use sdata4
Previously we only supporting using the system pointer size (aka the
`absptr` encoding) because `llvm-mc`'s CFI directives always generate EH
frames with that encoding. But libffi uses 4-byte-encoded, hand-rolled
EH frames, so this patch adds support for it.
Fixes #56576.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D130804
Sunho Kim [Mon, 1 Aug 2022 00:06:35 +0000 (09:06 +0900)]
[clang-repl] XFAIL windows properly in simple-exception test case.
We don't have proper exception support in LLJIT on windows yet. We have to xfail windows machine, but the previous check missed out some targets.
Jeff Niu [Tue, 19 Jul 2022 04:32:38 +0000 (21:32 -0700)]
[mlir] Remove types from attributes
This patch removes the `type` field from `Attribute` along with the
`Attribute::getType` accessor.
Going forward, this means that attributes in MLIR will no longer have
types as a first-class concept. This patch lays the groundwork to
incrementally remove or refactor code that relies on generic attributes
being typed. The immediate impact will be on attributes that rely on
`Attribute` containing a type, such as `IntegerAttr`,
`DenseElementsAttr`, and `ml_program::ExternAttr`, which will now need
to define a type parameter on their storage classes. This will save
memory as all other attribute kinds will no longer contain a type.
Moreover, it will not be possible to generically query the type of an
attribute directly. This patch provides an attribute interface
`TypedAttr` that implements only one method, `getType`, which can be
used to generically query the types of attributes that implement the
interface. This interface can be used to retain the concept of a "typed
attribute". The ODS-generated accessor for a `type` parameter
automatically implements this method.
Next steps will be to refactor the assembly formats of certain operations
that rely on `parseAttribute(type)` and `printAttributeWithoutType` to
remove special handling of type elision until `type` can be removed from
the dialect parsing hook entirely; and incrementally remove uses of
`TypedAttr`.
Reviewed By: lattner, rriddle, jpienaar
Differential Revision: https://reviews.llvm.org/D130092
Fangrui Song [Sun, 31 Jul 2022 23:59:57 +0000 (16:59 -0700)]
[ELF] Simplify EhInputSection::split. NFC
* Inline getReloc
* Fold the UINT32_MAX length check into the section size check.
This transformation is valid because we don't support .eh_frame input sections
larger than 32-bit (unrealistic even for large code models).
Fangrui Song [Sun, 31 Jul 2022 23:16:10 +0000 (16:16 -0700)]
[ELF] Split EhInputSection::pieces into cies and fdes
This simplifies code, removes a read32 (for id==0 check), and makes it feasible
to combine some operations in EhInputSection::split and EhFrameSection::addRecords.
Mostly NFC, but fixes "Relocation not in any piece" assertion failure in an
erroneous case when a relocation offset precedes all CIE/FDE pices.
Kazu Hirata [Sun, 31 Jul 2022 22:17:09 +0000 (15:17 -0700)]
Use drop_begin (NFC)
Kazu Hirata [Sun, 31 Jul 2022 22:17:08 +0000 (15:17 -0700)]
Use llvm::any_of (NFC)
Kazu Hirata [Sun, 31 Jul 2022 22:17:06 +0000 (15:17 -0700)]
[Hexagon] Remove unused declaration adjustForCalleeSavedRegsSpillCall (NFC)
The function definition was removed on Apr 23, 2015 in commit
876a19d8554510e6689b0a990e5e62af81506d80, but the declaration has
remained since.
Kazu Hirata [Sun, 31 Jul 2022 22:17:05 +0000 (15:17 -0700)]
[BOLT] Remove redundaunt string initialization (NFC)
Identified with readability-redundant-string-init.
Kazu Hirata [Sun, 31 Jul 2022 22:17:03 +0000 (15:17 -0700)]
[BOLT] Remove redundant const from return types (NFC)
Identified with readability-const-return-type.
Kazu Hirata [Sun, 31 Jul 2022 22:17:01 +0000 (15:17 -0700)]
[BOLT] Use boolean literals (NFC)
Identified with modernize-use-bool-literals.
Kazu Hirata [Sun, 31 Jul 2022 22:17:00 +0000 (15:17 -0700)]
[Sema] Remove an unused forward declaration (NFC)
Kazu Hirata [Sun, 31 Jul 2022 22:16:58 +0000 (15:16 -0700)]
[ExecutionEngine] Ensure newlines at the end of files (NFC)
NAKAMURA Takumi [Sun, 31 Jul 2022 22:03:30 +0000 (07:03 +0900)]
[Bazel] Add JITLink/COFFOptions.td (llvmorg-16-init-398-g88181375a3db)
Fangrui Song [Sun, 31 Jul 2022 21:52:20 +0000 (14:52 -0700)]
[ELF][test] Merge .eh_frame tests
Luís Marques [Fri, 29 Jul 2022 23:07:44 +0000 (01:07 +0200)]
[RISCV] Pre-RA expand pseudos pass
Expand load address pseudo-instructions earlier (pre-ra) to allow follow-up
patches to fold the addi of PseudoLLA instructions into the immediate
operand of load/store instructions.
Differential Revision: https://reviews.llvm.org/D123264
Jacques Pienaar [Sun, 31 Jul 2022 18:33:42 +0000 (11:33 -0700)]
[mlir][tosa] Switch missed accessors to prefixed form (NFC)
Fangrui Song [Sun, 31 Jul 2022 20:43:07 +0000 (13:43 -0700)]
[ELF][test] Test identical CIE content with different personality
If we change
CieRecord *&rec = cieMap[{cie.data(), personality}];
to
CieRecord *&rec = cieMap[{cie.data(), nullptr}];
The new test can catch the failure.
Tue Ly [Sun, 31 Jul 2022 20:32:21 +0000 (16:32 -0400)]
[libc][doc] Update implementation status of exp2f, sinhf, and coshf.
Jeff Niu [Sun, 31 Jul 2022 02:20:08 +0000 (22:20 -0400)]
[mlir][DCA] Fix visiting call ops when run at function scopes
When dead-code analysis is run at the scope of a function, call ops to
other functions at the same level were being marked as unreachable,
since the analysis optimistically assumes the call op to have no known
predecessors and that all predecessors are known, but the callee would
never get visited.
This patch fixes the bug by checking if a referenced function is above
the top-level op of the analysis, and is thus considered an external
callable.
Fixes #56830
Reviewed By: zero9178
Differential Revision: https://reviews.llvm.org/D130829
Alexander Belyaev [Sun, 31 Jul 2022 19:44:24 +0000 (21:44 +0200)]
Revert "Revert "[mlir] Reuse the code between `getMixed*s()` funcs in ViewLikeInterface.cpp.""
This reverts commit
e78d7637fbb08ec2c2e59939c015faadd47e32e7.
Differential Revision: https://reviews.llvm.org/D130706
Alexander Belyaev [Sun, 31 Jul 2022 19:25:20 +0000 (21:25 +0200)]
Revert "[mlir] Reuse the code between `getMixed*s()` funcs in ViewLikeInterface.cpp."
This reverts commit
e8c2877565149587fd66fbee591b7d44eecd667d.
Alexander Belyaev [Sun, 31 Jul 2022 16:04:46 +0000 (18:04 +0200)]
[mlir] Reuse the code between `getMixed*s()` funcs in ViewLikeInterface.cpp.
Differential Revision: https://reviews.llvm.org/D130706
Fangrui Song [Sun, 31 Jul 2022 18:58:08 +0000 (11:58 -0700)]
[ELF] Move EhInputSection out of inputSections. NFC
inputSections temporarily contains EhInputSection objects mainly for
combineEhSections. Place EhInputSection objects into a new vector
ehInputSections instead of inputSections.
Sanjay Patel [Sat, 30 Jul 2022 19:37:00 +0000 (15:37 -0400)]
[InstSimplify] fold FP rounding intrinsic with rounded operand
issue #56775
I rearranged the Thumb2 codegen test to avoid simplifying the chain
of rounding instructions. I'm assuming the intent of the test is
to verify lowering of each of those intrinsics.
Sanjay Patel [Sat, 30 Jul 2022 19:24:09 +0000 (15:24 -0400)]
[InstSimplify] add tests for FP rounding intrinsics; NFC
See issue #56775
Michał Górny [Sun, 31 Jul 2022 11:02:57 +0000 (13:02 +0200)]
[libcxx] [test] Cover i386 & sparc64 in string.capacity test
Differential Revision: https://reviews.llvm.org/D130837
Simon Pilgrim [Sun, 31 Jul 2022 11:14:58 +0000 (12:14 +0100)]
[X86] getFauxShuffleMask - use DemandedElts variant of getTargetShuffleInputs. NFCI.
We don't specify the demanded elts yet, this patch just rewires the getTargetShuffleInputs calls and gives an "all demanded elts" mask.
Jun Zhang [Sun, 31 Jul 2022 09:49:13 +0000 (17:49 +0800)]
[clang-repl] Fix incorrect return code
Without this patch, clang-repl incorrectly pass some tests when there's
error occured.
Signed-off-by: Jun Zhang <jun@junz.org>
Differential Revision: https://reviews.llvm.org/D130422
Simon Pilgrim [Sun, 31 Jul 2022 10:30:40 +0000 (11:30 +0100)]
[X86] combineX86ShufflesRecursively - determine demanded elts to pass to getTargetShuffleInputs
Only PACKSS/PACKUS faux shuffles make use of the demanded elts at the moment, but this at least improves the handling of a couple of truncation patterns.
Dawid Jurczak [Sun, 31 Jul 2022 08:51:01 +0000 (10:51 +0200)]
[NFC] Remove redundant CalculateSmallVectorDefaultInlinedElements usage from to_vector utility
CalculateSmallVectorDefaultInlinedElements<..>::value is already used as default value for second template parameter in SmallVector class declaration.
There is no need to pass it explicitly in to_vector.
Extracted from: https://reviews.llvm.org/D129781
Differential Revision: https://reviews.llvm.org/D130774
Jun Zhang [Sun, 31 Jul 2022 05:03:24 +0000 (13:03 +0800)]
[CodeGen][NFC] Use isa_and_nonnull instead of explicit check
Signed-off-by: Jun Zhang <jun@junz.org>
Fangrui Song [Sun, 31 Jul 2022 01:11:21 +0000 (18:11 -0700)]
[lld] Change vector to SmallVector. NFC
My lld executable is 1.6KiB smaller and some functions are now more efficient.
Fangrui Song [Sun, 31 Jul 2022 00:42:08 +0000 (17:42 -0700)]
[ELF] Move SyntheticSections to InputSection.h. NFC
Keep the main SectionBase hierarchy in InputSection.h.
And inline MergeInputSection::getParent.
Sunho Kim [Sun, 31 Jul 2022 00:19:17 +0000 (09:19 +0900)]
[JITLink][COFF] Remove unused variable.
Sunho Kim [Sun, 31 Jul 2022 00:09:22 +0000 (09:09 +0900)]
[JITLink][COFF] Handle COMDAT symbol with offset.
Handles COMDAT symbol with an offset and refactor the code to only generated symbol if the second symbol was encountered. This happens very infrequently but happens in recursive_mutex implementation of MSVC STL library.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D130454
Sunho Kim [Sun, 31 Jul 2022 00:02:23 +0000 (09:02 +0900)]
[JITLink][COFF][x86_64] Implement remaining IMAGE_REL_AMD64_REL32_*.
Implements remaining IMAGE_REL_AMD64_REL32_*. We only need IMAGE_REL_AMD64_REL32_4 for now but doing all remaining ones for completeness. (clang only uses IMAGE_REL_AMD64_REL32_1 and IMAGE_REL_AMD64_REL32)
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D130452
Sunho Kim [Sat, 30 Jul 2022 23:33:42 +0000 (08:33 +0900)]
[JITLink] Relax zero-fill edge assertions.
Relax zero-fill edge assertions to only consider relocation edges. Keep-alive edges to zero-fill blocks can cause this assertion which is too strict.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D130450
Fangrui Song [Sat, 30 Jul 2022 23:32:42 +0000 (16:32 -0700)]
[ELF] Simplify getRankProximity. NFC
Nico Weber [Sat, 30 Jul 2022 23:30:53 +0000 (19:30 -0400)]
[gn build] Port
88181375a3db more
srishti-cb [Sat, 30 Jul 2022 16:53:15 +0000 (12:53 -0400)]
[MLIR] Add a utility to sort the operands of commutative ops
Added a commutativity utility pattern and a function to populate it. The pattern sorts the operands of an op in ascending order of the "key" associated with each operand iff the op is commutative. This sorting is stable.
The function is intended to be used inside passes to simplify the matching of commutative operations. After the application of the above-mentioned pattern, since the commutative operands now have a deterministic order in which they occur in an op, the matching of large DAGs becomes much simpler, i.e., requires much less number of checks to be written by a user in her/his pattern matching function.
The "key" associated with an operand is the list of the "AncestorKeys" associated with the ancestors of this operand, in a breadth-first order.
The operand of any op is produced by a set of ops and block arguments. Each of these ops and block arguments is called an "ancestor" of this operand.
Now, the "AncestorKey" associated with:
1. A block argument is `{type: BLOCK_ARGUMENT, opName: ""}`.
2. A non-constant-like op, for example, `arith.addi`, is `{type: NON_CONSTANT_OP, opName: "arith.addi"}`.
3. A constant-like op, for example, `arith.constant`, is `{type: CONSTANT_OP, opName: "arith.constant"}`.
So, if an operand, say `A`, was produced as follows:
```
`<block argument>` `<block argument>`
\ /
\ /
`arith.subi` `arith.constant`
\ /
`arith.addi`
|
returns `A`
```
Then, the block arguments and operations present in the backward slice of `A`, in the breadth-first order are:
`arith.addi`, `arith.subi`, `arith.constant`, `<block argument>`, and `<block argument>`.
Thus, the "key" associated with operand `A` is:
```
{
{type: NON_CONSTANT_OP, opName: "arith.addi"},
{type: NON_CONSTANT_OP, opName: "arith.subi"},
{type: CONSTANT_OP, opName: "arith.constant"},
{type: BLOCK_ARGUMENT, opName: ""},
{type: BLOCK_ARGUMENT, opName: ""}
}
```
Now, if "keyA" is the key associated with operand `A` and "keyB" is the key associated with operand `B`, then:
"keyA" < "keyB" iff:
1. In the first unequal pair of corresponding AncestorKeys, the AncestorKey in operand `A` is smaller, or,
2. Both the AncestorKeys in every pair are the same and the size of operand `A`'s "key" is smaller.
AncestorKeys of type `BLOCK_ARGUMENT` are considered the smallest, those of type `CONSTANT_OP`, the largest, and `NON_CONSTANT_OP` types come in between. Within the types `NON_CONSTANT_OP` and `CONSTANT_OP`, the smaller ones are the ones with smaller op names (lexicographically).
---
Some examples of such a sorting:
Assume that the sorting is being applied to `foo.commutative`, which is a commutative op.
Example 1:
> %1 = foo.const 0
> %2 = foo.mul <block argument>, <block argument>
> %3 = foo.commutative %1, %2
Here,
1. The key associated with %1 is:
```
{
{CONSTANT_OP, "foo.const"}
}
```
2. The key associated with %2 is:
```
{
{NON_CONSTANT_OP, "foo.mul"},
{BLOCK_ARGUMENT, ""},
{BLOCK_ARGUMENT, ""}
}
```
The key of %2 < the key of %1
Thus, the sorted `foo.commutative` is:
> %3 = foo.commutative %2, %1
Example 2:
> %1 = foo.const 0
> %2 = foo.mul <block argument>, <block argument>
> %3 = foo.mul %2, %1
> %4 = foo.add %2, %1
> %5 = foo.commutative %1, %2, %3, %4
Here,
1. The key associated with %1 is:
```
{
{CONSTANT_OP, "foo.const"}
}
```
2. The key associated with %2 is:
```
{
{NON_CONSTANT_OP, "foo.mul"},
{BLOCK_ARGUMENT, ""}
}
```
3. The key associated with %3 is:
```
{
{NON_CONSTANT_OP, "foo.mul"},
{NON_CONSTANT_OP, "foo.mul"},
{CONSTANT_OP, "foo.const"},
{BLOCK_ARGUMENT, ""},
{BLOCK_ARGUMENT, ""}
}
```
4. The key associated with %4 is:
```
{
{NON_CONSTANT_OP, "foo.add"},
{NON_CONSTANT_OP, "foo.mul"},
{CONSTANT_OP, "foo.const"},
{BLOCK_ARGUMENT, ""},
{BLOCK_ARGUMENT, ""}
}
```
Thus, the sorted `foo.commutative` is:
> %5 = foo.commutative %4, %3, %2, %1
Signed-off-by: Srishti Srivastava <srishti.srivastava@polymagelabs.com>
Reviewed By: Mogball
Differential Revision: https://reviews.llvm.org/D124750
Sunho Kim [Sat, 30 Jul 2022 23:10:14 +0000 (08:10 +0900)]
[JITLink][COFF] Remove obsolete FIXMEs. (NFC)
Sunho Kim [Sat, 30 Jul 2022 23:08:19 +0000 (08:08 +0900)]
[JITLInk][COFF] Remove unnecessary unique_ptr. (NFC)
Sunho Kim [Sat, 30 Jul 2022 23:00:19 +0000 (08:00 +0900)]
[JITLink][COFF] Add explicit std::move.
Since ArgList is not copyable we need to make sure it's moved explicitly.
Nico Weber [Sat, 30 Jul 2022 22:58:10 +0000 (18:58 -0400)]
[gn build] Port
88181375a3db
Sunho Kim [Sat, 30 Jul 2022 22:49:37 +0000 (07:49 +0900)]
[JITLink][COFF] Implement include/alternatename linker directive.
Implements include/alternatename linker directive. Alternatename is used by static msvc runtime library. Alias symbol is technically incorrect (we have to search for external definition) but we don't have a way to represent this in jitlink/orc yet, this is solved in the following up patch.
Inlcude linker directive is used in ucrt to forcelly lookup the static initializer symbols so that they will be emitted. It's implemented as extenral symbols with live flag on that cause the lookup of these symbols.
Reviewed By: lhames
Differential Revision: https://reviews.llvm.org/D130276
Sunho Kim [Sat, 30 Jul 2022 20:42:16 +0000 (05:42 +0900)]
[clang-repl] Disable building when LLVM_STATIC_LINK_CXX_STDLIB is ON.
We have seen random symbol not found "__cxa_throw" error in fuschia build bots and out-of-tree users. The understanding have been that they are built without exception support, but it turned out that these platforms have LLVM_STATIC_LINK_CXX_STDLIB ON so that they link libstdc++ to llvm statically. The reason why this is problematic for clang-repl is that by default clang-repl tries to find symbols from symbol table of executable and dynamic libraries loaded by current process. It needs to load another libstdc++, but the platform that had LLVM_STATIC_LINK_CXX_STDLIB turned on is usally those with missing or obsolate shared libstdc++ in the first place -- trying to load it again would be destined to fail eventually with a risk to introuduce mixed libstdc++ versions.
A proper solution that doesn't take a workaround is statically link the same libstdc++ by clang-repl side, but this is not possible with old JIT linker runtimedyld. New just-in-time linker JITLink handles this relatively well, but it's not availalbe in majority of platforms. For now, this patch just disables the building of clang-repl when LLVM_STATIC_LINK_CXX_STDLIB is ON and removes the "__cxa_throw" check in exception unittest as well as reverting previous exception check flag patch.
Reviewed By: v.g.vassilev
Differential Revision: https://reviews.llvm.org/D130788
Joseph Huber [Fri, 29 Jul 2022 17:51:15 +0000 (13:51 -0400)]
[Libomptarget] Disable testing map_back_race.cpp
This test hasn't been fixed and causes spurious failures when testing.
This patch sets it as unsupported until we have a reliable fix.
Reviewed By: ronlieb
Differential Revision: https://reviews.llvm.org/D130789
Craig Topper [Sat, 30 Jul 2022 17:33:52 +0000 (10:33 -0700)]
[RISCV] Remove vmerges from vector ceil, floor, trunc lowering.
Use masked operations to suppress spurious exception bits being
set in fflags. Unfortunately, doing this adds extra copies.
Simon Pilgrim [Sat, 30 Jul 2022 17:57:11 +0000 (18:57 +0100)]
[X86] Use std::tie so we can have more meaningful variable names for demanded bits/elts pairs. NFCI.
*.first + *.second were proving difficult to keep track of.
Fangrui Song [Sat, 30 Jul 2022 17:55:59 +0000 (10:55 -0700)]
[ELF] Support missing relocations in RISCV::getImplicitAddend()
Fangrui Song [Sat, 30 Jul 2022 17:46:58 +0000 (10:46 -0700)]
[ELF] Support missing relocations in PPC64::getImplicitAddend()
Amir Ayupov [Sat, 30 Jul 2022 17:35:10 +0000 (10:35 -0700)]
Revert "[BOLT] Ignore functions accessing false positive jump tables"
This diff uncovers an ASAN leak in getOrCreateJumpTable:
```
Indirect leak of 264 byte(s) in 1 object(s) allocated from:
#1 0x4f6e48c in llvm::bolt::BinaryContext::getOrCreateJumpTable ...
```
The removal of an assertion needs to be accompanied by proper deallocation of
a `JumpTable` object for which `analyzeJumpTable` was unsuccessful.
This reverts commit
52cd00cabf479aa7eb6dbb063b7ba41ea57bce9e.
Kazu Hirata [Sat, 30 Jul 2022 17:35:56 +0000 (10:35 -0700)]
Use any_of (NFC)
Kazu Hirata [Sat, 30 Jul 2022 17:35:54 +0000 (10:35 -0700)]
Use is_contained (NFC)
Kazu Hirata [Sat, 30 Jul 2022 17:35:52 +0000 (10:35 -0700)]
Convert for_each to range-based for loops (NFC)
Kazu Hirata [Sat, 30 Jul 2022 17:35:51 +0000 (10:35 -0700)]
[bolt] Remove redundaunt virtual specifiers (NFC)
Identified with modernize-use-override.
Kazu Hirata [Sat, 30 Jul 2022 17:35:49 +0000 (10:35 -0700)]
[bolt] Remove redundaunt control-flow statements (NFC)
Identified with readability-redundant-control-flow.
Kazu Hirata [Sat, 30 Jul 2022 17:35:48 +0000 (10:35 -0700)]
Use nullptr instead of 0 (NFC)
Identified with modernize-use-nullptr.