Guillaume Chatelet [Tue, 7 Feb 2023 10:32:03 +0000 (10:32 +0000)]
[libc][NFC] Move cpu_features to macros folder
Tom Eccles [Wed, 4 Jan 2023 13:03:31 +0000 (13:03 +0000)]
[flang] add -fstack-arrays flag
The implementation of -fstack-arrays was added in
https://reviews.llvm.org/D140415
The new macro BoolOptionWithoutMarshalling in Options.td avoids
generating code to store the flags in clang data structures. For
example, writing something like
defm stack_arrays : BoolOption<"f", "stack-arrays",
CodeGenOpts<"StackArrays">, [...]
Would generate code referring to `clang::CodeGenOpts::StackArrays`, which
does not exist.
Differential Revision: https://reviews.llvm.org/D140972
Tom Eccles [Fri, 9 Dec 2022 18:07:31 +0000 (18:07 +0000)]
[flang] add a pass to move array temporaries to the stack
This pass implements the `-fstack-arrays` flag. See the RFC in
`flang/docs/fstack-arrays.md` for more information.
Differential revision: https://reviews.llvm.org/D140415
Guillaume Chatelet [Tue, 7 Feb 2023 10:19:12 +0000 (10:19 +0000)]
[libc][NFC] Rename architecture macros and move to macros folder
David Green [Tue, 7 Feb 2023 10:06:58 +0000 (10:06 +0000)]
[ARM] Add various tests for reductions of shuffles. NFC
Sergey Kachkov [Thu, 2 Feb 2023 10:21:48 +0000 (13:21 +0300)]
[PHITransAddr] Simplify casts in PHITransAddr
Try to simplify cast in similar way as for GEP and ADD with
constant (e.g. sext/zext + trunc).
Differential Revision: https://reviews.llvm.org/D143167
Sergey Kachkov [Fri, 3 Feb 2023 10:19:59 +0000 (13:19 +0300)]
[NFC] Add pre-commit test for simplifyCastInst in PHITransAddr
Mariya Podchishchaeva [Tue, 7 Feb 2023 09:25:05 +0000 (04:25 -0500)]
[NFC][clang] Fix static analyzer concern about uninitialized variable
Reviewed By: xazax.hun
Differential Revision: https://reviews.llvm.org/D143411
Guillaume Chatelet [Mon, 6 Feb 2023 13:03:18 +0000 (13:03 +0000)]
[libc][doc] Update compiler
Differential Revision: https://reviews.llvm.org/D143389
Haojian Wu [Tue, 7 Feb 2023 09:25:48 +0000 (10:25 +0100)]
[Tooling/Inclusion] Move the StdSpecialSymbolMap.inc to the private lib place.
I missed it in
c751264aa19865beab12d94db3ea966c6accd428.
Guillaume Chatelet [Mon, 6 Feb 2023 16:46:31 +0000 (16:46 +0000)]
[libc][doc] Add macros guidelines
This is a first follow up on the libc tuning RFC
https://discourse.llvm.org/t/rfc-llvm-libc-tuning/67980
Once we agree on the format. I'll land a couple of patches to match the guidelines.
Differential Revision: https://reviews.llvm.org/D143413
Haojian Wu [Tue, 7 Feb 2023 09:13:45 +0000 (10:13 +0100)]
[Tooling/Inclusion] Introduce a human-edit file for C++ std symbols
This file is allowed to be edit by human, and it overlays the generated symbol file.
It contains a list of multiple-header symbols.
This patch introduces the file only. Usage will come afterwards.
Reviewed By: kadircet
Differential Revision: https://reviews.llvm.org/D143160
Haojian Wu [Mon, 6 Feb 2023 15:07:20 +0000 (16:07 +0100)]
[Tooling/Inclusion] Move the generated mapping .inc file to private places.
The .inc files are private now, clients should tooling::stdlib APIs instead.
Differential Revision: https://reviews.llvm.org/D143399
Jean Perier [Tue, 7 Feb 2023 08:25:31 +0000 (09:25 +0100)]
[flang][hlfir] place scalar in memory in convertToBox/convertToAddress
Implement the TODO. Be careful to use and propagate the expression
type to create the temporary since the mlir value may have been computed
with a different value type (e.g., i1 for logical) that should not be
used for in memory values that must have Fortran types.
Co-authored-by: Tom Eccles <tom.eccles@arm.com>
Differential Revision: https://reviews.llvm.org/D143421
Jean Perier [Tue, 7 Feb 2023 08:22:47 +0000 (09:22 +0100)]
[flang][NFC] addSymbol/lookupSymbol clean-up
HLFIR requires mapping symbol to a single mlir::Value (produced
by a fir::FortranVariableOpInterface), while the current lowering
maps the value to a fir::ExtdendedValue.
So far, the HLFIR symbol query was a special one. Hence, all the code
directly using symMap.lookupSymbol and symMap.addSymbol did not work
with the lowering to HLFIR.
Refactor the code so that symbol lookup and add symbol go through
the converter in a centralize place that handles the HLFIR case
(translate fir::FortranVariableOpInterface to fir::ExtdendedValue
in lookups, and generate hlfir.declare when adding symbols).
In the refactoring, fir::FortranVariableOpInterface is added as
a symbolBox variant to avoid special casing all lookups (shallowLookup...).
Remove some unused SymbolBox member function instead of updating
them.
Differential Revision: https://reviews.llvm.org/D143395
Valentin Clement [Tue, 7 Feb 2023 08:15:54 +0000 (09:15 +0100)]
[flang] Use PointerAssociateLowerBounds when there is lower bounds
The current code was not taking provided lower bounds when the pointer
is polymorphic and was just calling PointerAssociate. This patch
updates the behavior and use PointerAssociateLowerBounds with the provided
lower bounds.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D143392
Jay Foad [Sat, 21 Jan 2023 09:32:50 +0000 (09:32 +0000)]
[cmake] Use LLVM_ENABLE_ASSERTIONS to enable assertions in libstdc++
On my machine this showed no new failures in check-llvm and increased
the testing time from 138 to 142 seconds, for a Release build with
assertions enabled.
Differential Revision: https://reviews.llvm.org/D142279
riChar [Tue, 7 Feb 2023 07:15:15 +0000 (15:15 +0800)]
[IR] Fix bug in DemoteRegToStack where DenseMap is not used
Differential Revision: https://reviews.llvm.org/D141988
Weining Lu [Tue, 7 Feb 2023 07:09:04 +0000 (15:09 +0800)]
[lldb] Fix typo in LoongArch unittest
Max Kazantsev [Tue, 7 Feb 2023 06:09:46 +0000 (13:09 +0700)]
[SCEV] Support sext in SCEVLoopGuardRewriter
There is no particular reason why it's not supported, and it is useful.
Differential Revision: https://reviews.llvm.org/D143257
Reviewed By: fhahn
Thomas Raoux [Tue, 7 Feb 2023 06:14:28 +0000 (06:14 +0000)]
[mlir][linalg] Check for tensor of 0 dims during vectorization
tensor with dims of size 0 cannot be vectorized. Add precondition to
prevent a crash in vectorization.
Differential Revision: https://reviews.llvm.org/D143462
Chuanqi Xu [Tue, 7 Feb 2023 05:58:11 +0000 (13:58 +0800)]
[C++20] [Modules] Allow ADL in dependent context for modules
Close https://github.com/llvm/llvm-project/issues/60488.
Previously, when we instantiate a template, the argument dependent
lookup is performed in the context of the instantiation, which implies that the
functions not visible in the context can't be found by the argument
dependent lookup.
But this is not true, according to [module.context]p3, the instantiation
context for the implicit instantiation of a template should contain the
context of the primary module interface if the template is defined in
the module interface unit.
Note that the fix didn't implemnet [module.context]p3 precisely, see the
comments for example.
Aviad Cohen [Sun, 5 Feb 2023 05:51:45 +0000 (07:51 +0200)]
[mlir]: Added IntArrayNthElemMaxValue & IntArrayNthElemInRange predicates (NFC)
Reviewed By: rriddle
Differential Revision: https://reviews.llvm.org/D143331
Max Kazantsev [Tue, 7 Feb 2023 05:17:24 +0000 (12:17 +0700)]
[SCEV][NFC] Remove check for rewriteable types
I guess its only reason to exist is potential CT optimization, otherwise it is
just creating cohesion between this code and rewriter internals. We plan to
extend the rewriter. I'd rather not have this cohesion, unless there is a serious
reason to have it.
Differential Revision: https://reviews.llvm.org/D143246
Chen Zheng [Tue, 7 Feb 2023 05:31:45 +0000 (00:31 -0500)]
[DAGCombiner] fix comments for D138899; NFC
Craig Topper [Tue, 7 Feb 2023 05:23:21 +0000 (21:23 -0800)]
[RISCV] Refactor RISCVDisassembler::getInstruction to remove repeated code. NFC
For 4 byte instructions we were always setting size to 4 eventually. Same
for 2 byte instructions. So do it as soon as we know the from the opcode.
Add a return to the end of the 4 byte code so we don't have to have an else
around the 2 byte code.
Differential Revision: https://reviews.llvm.org/D143445
Louis Dionne [Tue, 7 Feb 2023 05:08:53 +0000 (21:08 -0800)]
[libc++][NFC] _VSTD -> std in ryu
Those ones are extremely mechanical and since that's not libc++ code
in the first place, there's even more of an incentive to do the rename.
Louis Dionne [Tue, 7 Feb 2023 01:33:20 +0000 (17:33 -0800)]
[libc++] Add missing _LIBCPP_HIDE_FROM_ABI
Differential Revision: https://reviews.llvm.org/D143451
YunQiang Su [Tue, 7 Feb 2023 04:36:11 +0000 (20:36 -0800)]
MIPS: fix build from IR files, nan2008 and FpAbi
When we use llc or lld to compiler IR files, the features +nan2008 and +fpxx/+fp64 are not used.
Thus wrong format files are produced.
In IR files, the attributes are only set for function while not the whole compile units.
So we extract the attributes from the first function and use it for the whole unit.
isFPXXDefault: for o32, the FPXX should always be the default, no matter about the vendors.
Of course some distributions with FP64 default enabled should be listed explicit.
Let's add them in future if we know about one.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D140270
chenglin.bi [Tue, 7 Feb 2023 04:08:36 +0000 (12:08 +0800)]
[Instcombine] Precommit tests for D143373; NFC
Louis Dionne [Tue, 7 Feb 2023 03:17:39 +0000 (19:17 -0800)]
[libc++] Fix path to versioned clang-format in the CI job
zhongyunde [Tue, 7 Feb 2023 03:09:13 +0000 (11:09 +0800)]
[AArch64][SVE] Fix crash for DestructiveBinaryCommWithRev zero merging
Address more Destructive type according the review on D141471
* DestructiveUnaryPassthru and DestructiveBinaryImm always return true, don't need fix
* DestructiveTernaryCommWithRev may also return false, but now don't define FalseLanesZero in the backend codegen
Reviewed By: paulwalker-arm
Differential Revision: https://reviews.llvm.org/D142978
zhongyunde [Tue, 7 Feb 2023 02:59:04 +0000 (10:59 +0800)]
[AArch64][SVE] Replace destructive operand of vector zeros with a bundled MOVPRFX instruction
Replace unary instructions where the destructive operand is a vector of zeros
with a bundled MOVPRFX instruction, e.g:
Transform:
%X0 = DUP_ZI_S 0, 0
%X0 = FLOGB_ZPmZ_S X0, P0, X2
into:
X0 = MOVPRFX P0/z, X1 // doesn't introduce any fake register dependencies compare to X0 = MOVPRFX P0/z, X0
X0 = FLOGB_ZPmZ_S X0, P0, X2
NOTE: This patch add a @earlyclobber constraint to PredOneOpPassthruPseudo to ensure
safe register allocation for movprfx usage.
Depends on D105889
Reviewed By: paulwalker-arm
Differential Revision: https://reviews.llvm.org/D138888
wangpc [Tue, 7 Feb 2023 02:57:45 +0000 (10:57 +0800)]
Revert "[RISCV] Allow mismatched SmallDataLimit and use Min for conflicting values"
This reverts commit
28bd84f55fc087d4aefd3fe5360f8648d1d50980 because
`CodeGen/RISCV/rvv-intrinsics-handcrafted/vlenb.c` hasn't been updated.
Louis Dionne [Tue, 7 Feb 2023 02:59:19 +0000 (18:59 -0800)]
[libc++] Export CXX and CC env vars in format and documentation CI jobs
This is necessary now that the Docker images don't contain unversionned
clang binaries.
Amir Ayupov [Tue, 7 Feb 2023 02:06:54 +0000 (18:06 -0800)]
[BOLT] Reintroduce allow-stripped
Reject stripped binaries as a policy.
The core issue with stripped binaries is that we can't detect the presence
of split functions which require extra handling. Therefore BOLT can't ensure
functional correctness of produced binary if the input stripped binary contains
split functions. Supporting such cases is an interesting problem but it goes
against BOLT's intended goal of achieving peak program performance.
Reviewed By: maksfb
Differential Revision: https://reviews.llvm.org/D142686
Amir Ayupov [Tue, 7 Feb 2023 01:38:20 +0000 (17:38 -0800)]
[BOLT][NFC] Replace anonymous namespace functions with static
Follow LLVM Coding Standards guideline on using anonymous namespaces
(https://llvm.org/docs/CodingStandards.html#anonymous-namespaces)
and use `static` modifier for function definitions.
Reviewed By: #bolt, maksfb
Differential Revision: https://reviews.llvm.org/D143124
Louis Dionne [Tue, 7 Feb 2023 02:00:28 +0000 (18:00 -0800)]
[libc++][NFC] Remove FP from_chars from the <charconv> synopsis since we don't implement it yet
Peiming Liu [Tue, 7 Feb 2023 01:21:10 +0000 (01:21 +0000)]
[mlir][sparse] fix bug when packing tensor with 32 bit pointer width.
Reviewed By: wrengr
Differential Revision: https://reviews.llvm.org/D143450
Jacques Pienaar [Tue, 7 Feb 2023 01:44:47 +0000 (17:44 -0800)]
[mlir][py] Fix unused var
Kohei Yamaguchi [Tue, 7 Feb 2023 01:02:06 +0000 (17:02 -0800)]
[mlir][NFC] Add omitted operations to Transform dialect's doc
Add omitted transform operations, including Affine/MemRef/Vector, to Transform dialect's doc to fix a broken side-bar doc.
Reviewed By: jpienaar
Differential Revision: https://reviews.llvm.org/D143237
Jacques Pienaar [Thu, 2 Feb 2023 20:23:46 +0000 (12:23 -0800)]
[mlir][py] Fix infer return type invocation for variadics
Previously we only allowed the flattened list passed in, but the same
input provided here as to buildGeneric so flatten accordingly. We have
less info here than in buildGeneric so the error is more generic if
unpacking fails.
Differential Revision: https://reviews.llvm.org/D143240
Roland McGrath [Mon, 6 Feb 2023 03:06:23 +0000 (19:06 -0800)]
[RISCV] Clean up stack-protector-target test
Add some missed polish from https://reviews.llvm.org/D143355.
Reviewed By: jrtc27
Differential Revision: https://reviews.llvm.org/D143360
Kirill Stoimenov [Tue, 7 Feb 2023 00:39:17 +0000 (00:39 +0000)]
[HWASAN] Add unlikely to if in HwasanAllocate.
Kirill Stoimenov [Tue, 7 Feb 2023 00:34:26 +0000 (00:34 +0000)]
[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0
This should keep it consistent with LSAN and ASAN,
Reviewed By: vitalybuka, MaskRay
Differential Revision: https://reviews.llvm.org/D143438
Siva Chandra Reddy [Tue, 7 Feb 2023 00:17:54 +0000 (00:17 +0000)]
[libc] Fix typo is processing LIBC_GPU_TEST_ARCHITECTURE.
Reviewed By: jhuber6
Differential Revision: https://reviews.llvm.org/D143444
Med Ismail Bennani [Tue, 7 Feb 2023 00:02:51 +0000 (16:02 -0800)]
[lldb/Plugins] Fix method dispatch bug when using multiple scripted processes
This patch should address a bug when a user have multiple scripted
processes in the same debugging session.
In order for the scripted process plugin to be able to call into the
scripted object instance methods to fetch the necessary data to
reconstruct its state, the scripted process plugin calls into a
scripted process interface, that has a reference to the created script
object instance.
However, prior to this patch, we only had a single instance of the
scripted process interface, living the script interpreter. So every time
a new scripted process plugin was created, it would overwrite the script
object instance that was held by the single scripted process interface
in the script interpreter.
That would cause all the method calls made to the scripted process
interface to be dispatched by the last instanciated script object
instance, which is wrong.
In order to prevent that, this patch moves the scripted process
interface reference to be help by the scripted process plugin itself.
rdar://
104882562
Differential Revision: https://reviews.llvm.org/D143308
Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>
Kirill Stoimenov [Mon, 6 Feb 2023 23:53:48 +0000 (23:53 +0000)]
[HWASAN] Modify HwasanAllocate to set the size to 1 if requested size is 0
This should keep it consistent with LSAN and ASAN,
Reviewed By: vitalybuka, MaskRay
Differential Revision: https://reviews.llvm.org/D143438
Kirill Stoimenov [Mon, 6 Feb 2023 22:41:20 +0000 (22:41 +0000)]
[HWASAN] Fix Metadata::IsAllocatedMetadata::IsAllocated to return true even if the requested size is 0.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D143438
AdityaK [Wed, 1 Feb 2023 20:18:35 +0000 (12:18 -0800)]
[RISCV] Allow mismatched SmallDataLimit and use Min for conflicting values
Authored By: joshua-arch1 (Jun Sha)
Reviewed By: shiva0217, apazos, luismarques, asb, jrtc27, MaskRay
Reviewers: MaskRay, jrtc27
Differential Revision: https://reviews.llvm.org/D131230
This patch is to fix an issue about module linking with LTO.
When compiling with PIE, the small data limitation needs to be consistent with that in PIC, otherwise there will be linking errors due to conflicting values.
bar.c
int bar() { return 1; }
foo.c
int foo() { return 1; }
clang --target=riscv64-unknown-linux-gnu -flto -c foo.c -o foo.o -fPIE
clang --target=riscv64-unknown-linux-gnu -flto -c bar.c -o bar.o -fPIC
clang --target=riscv64-unknown-linux-gnu -flto foo.o bar.o -flto -nostdlib -v -fuse-ld=lld
ld.lld: error: linking module flags 'SmallDataLimit': IDs have conflicting values in 'bar.o' and 'ld-temp.o'
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
What we are trying to do here is to use Min instead of Error for conflicting SmallDataLimit when combining -fno-PIC code with -fPIC code.
Signed-off-by: xiaojing.zhang <xiaojing.zhang@xcalibyte.com>
Signed-off-by: jianxin.lai <jianxin.lai@xcalibyte.com>
Vladislav Dzhidzhoev [Thu, 26 Jan 2023 03:55:27 +0000 (04:55 +0100)]
[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b
Widen element types of vector arguments of G_ADD, G_SUB, G_MUL, G_AND,
G_OR, G_XOR to the minumum supported size, in order to support vectors
of narrow types.
Differential Revision: https://reviews.llvm.org/D143100
Haowei Wu [Mon, 6 Feb 2023 23:00:59 +0000 (15:00 -0800)]
Revert "[Fuchsia] Simplify Fuchsia stage2 toolchain setup"
This reverts commit
f9ff49882a65ab26ab347f4df8f2a58368d37185.
Accidentally landed a draft patch.
Haowei Wu [Tue, 31 Jan 2023 22:20:50 +0000 (14:20 -0800)]
[Fuchsia] Build windows runtimes using cross compilation on Linux
This patch provides initial support of building Clang runtimes for
Windows when using Fuchsia Clang toolchains under Linux.
Differential Revision: https://reviews.llvm.org/D141738
Haowei Wu [Mon, 30 Jan 2023 23:43:09 +0000 (15:43 -0800)]
[Fuchsia] Simplify Fuchsia stage2 toolchain setup
WIP
Jason Molenda [Mon, 6 Feb 2023 22:45:41 +0000 (14:45 -0800)]
In InitializeZerothFrame check for a CFA/AFA or error out
There is a failure where we somehow get an invalid register
number being used to calculate the canonical frame address,
and this ends up with lldb crashing with a null deref because it
assumes that it is always able to find information about that
register.
This patch adds a check for a failure to get a register, and
declares the frame invalid in that case, with some additional
logging or an assert for debug builds.
Differential Revision: https://reviews.llvm.org/D143232
rdar://
104428038
Vladislav Dzhidzhoev [Mon, 6 Feb 2023 22:45:25 +0000 (23:45 +0100)]
Revert "[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b"
This reverts commit
254e2ad84407fce81f3b0c07e75f23671b8cb56a.
It contains broken test.
Ilya Leoshkevich [Mon, 6 Feb 2023 22:28:06 +0000 (23:28 +0100)]
[MSan] Fix calling pointers to varargs functions on SystemZ
VarArgSystemZHelper.visitCallBase() checks whether the callee has the
"use-soft-float" attribute, but if the callee is a function pointer, a
null pointer dereference happens.
Fix by checking this attribute on the current function. Alternatively,
one could try the callee first, but this is pointless, since one should
not be mixing hardfloat and softfloat code anyway.
Reviewed By: uweigand
Differential Revision: https://reviews.llvm.org/D143296
Vladislav Dzhidzhoev [Thu, 26 Jan 2023 03:55:27 +0000 (04:55 +0100)]
[AArch64][GlobalISel] Widen G_ADD/G_MUL/G_OR/... element types if size < 8b
Widen element types of vector arguments of G_ADD, G_SUB, G_MUL, G_AND,
G_OR, G_XOR to the minumum supported size, in order to support vectors
of narrow types.
Differential Revision: https://reviews.llvm.org/D143100
William Huang [Mon, 6 Feb 2023 22:26:10 +0000 (22:26 +0000)]
[llvm-profdata] Fix bug llvm-profdata crashes when reading a text sample profile with an empty line with spaces.
Text editors can introduce spaces aligning the previous line's indentation. This crashes llvm-profdata. Added check to handle this case.
Reviewed By: snehasish
Differential Revision: https://reviews.llvm.org/D143369
Bill Wendling [Mon, 6 Feb 2023 22:26:16 +0000 (14:26 -0800)]
[randstruct] Don't allow implicit forward decl to stop struct randomization
If a struct/enum type used in a record doesn't have a forward decl /
def, an implicit one is injected into the struct. This stops clang from
randomizing the structure in some situations---i.e. when the struct
contains only function pointers. So we accept forward decls so they
don't prevent randomization.
Fixes 60349
Reviewed By: MaskRay, nickdesaulniers
Differential Revision: https://reviews.llvm.org/D143300
Aart Bik [Mon, 6 Feb 2023 20:48:05 +0000 (12:48 -0800)]
[mlir][vector] add proper verification to vector.print operation
Rationale:
Only proper vectors and scalars of floating-point or integral types
are actually lowered to calls into the light-weight output library.
Reviewed By: ThomasRaoux
Differential Revision: https://reviews.llvm.org/D143423
Aart Bik [Sat, 4 Feb 2023 01:26:04 +0000 (17:26 -0800)]
[mlir][sparse] compute allocation size_hint
This adds the hint to a number of tensor allocations in codegens,
shaving off quite some time from e.g. reading in sparse matrices
due to zero-reallocation scheme. Note that we can probably provide
hints on all allocations, and refine the heuristics that use them
for general tensors.
Reviewed By: bixia
Differential Revision: https://reviews.llvm.org/D143309
Mircea Trofin [Mon, 6 Feb 2023 01:16:46 +0000 (17:16 -0800)]
[mlgo][regalloc] Handle training case when no regalloc happens.
There's an early-exit case for regalloc when we don't even get a chance
to ask for an advisor (priority or eviction), and switch the context.
Then, when we want to log the reward for that function (==the one with
the early exit case), we hit the error case where the function's name
doesn't match the last-seen context.
There are a few possible fixes, one would be to just switch context when
output-ing the reward, which would be correct. This patch opts for the
alternative where we check any loging happened in the first place - just
to re-validate that no function would have been regaloc-ed without first
log-ing its reward.
Differential Revision: https://reviews.llvm.org/D143359
Arthur Eubanks [Mon, 6 Feb 2023 21:25:59 +0000 (13:25 -0800)]
[IPO] Remove some legacy passes
These are part of the optimization pipeline, of which the legacy pass manager version is deprecated.
Yaxun (Sam) Liu [Mon, 6 Feb 2023 16:37:00 +0000 (11:37 -0500)]
[HIP] Update test hip-header.hip
remove -no-opaque-pointers
Reviewed by: Matt Arsenault
Differential Revision: https://reviews.llvm.org/D143412
Arthur Eubanks [Mon, 6 Feb 2023 21:07:07 +0000 (13:07 -0800)]
[MergeFunctions] Remove legacy pass
It's part of the optimization pipeline, which the legacy pass manager version is deprecated.
Tue Ly [Mon, 6 Feb 2023 21:05:23 +0000 (16:05 -0500)]
[libc][Obvious] Add __FMA__ flag detection to cpu_features.h
Simon Pilgrim [Mon, 6 Feb 2023 20:55:24 +0000 (20:55 +0000)]
[Support] Move ItaniumManglingCanonicalizer and SymbolRemappingReader from Support to ProfileData
As mentioned on https://discourse.llvm.org/t/issues-in-llvm-tblgen-high-parallelized-build/68037, ItaniumManglingCanonicalizer is often slow to build, resulting in a bottleneck for distributed builds while waiting for LLVMSupport to complete.
SymbolRemappingReader is the only current user of ItaniumManglingCanonicalizer, and this is only used by ProfileData and llvm-cxxmap - so I propose we move both files into the ProfileData library.
Differential Revision: https://reviews.llvm.org/D143318
Fangrui Song [Mon, 6 Feb 2023 20:54:34 +0000 (12:54 -0800)]
[Driver] Fix -fsanitize-address-stack-use-after-scope after D142606
Driver::getToolChain called by Driver::BuildCompilation gets the
`Triple` argument from a temporary. With delayed detection due to
LazyDetector, we would reference a dangling `Triple`.
Noah Goldstein [Mon, 6 Feb 2023 18:06:22 +0000 (12:06 -0600)]
Improve transforms for (icmp uPred X * Z, Y * Z) -> (icmp uPred X, Y)
Several cases where missing.
1. `(icmp eq/ne X*Z, Y*Z) [if Z % 2 != 0] -> (icmp eq/ne X, Y)`
EQ: https://alive2.llvm.org/ce/z/6_HPZ5
NE: https://alive2.llvm.org/ce/z/c34qSU
There was previously an implementation of this that work of `Y`
was non-constant, but it was missing if `Y*Z` evaluated to a
constant and/or `nsw`/`nuw` where both false. As well it only
worked if `Z` was a constant but we can check 1s bit of
`KnownBits` to cover more cases.
2. `(icmp eq/ne X*Z, Y*Z) [if Z != 0 and nsw(X*Y) and nsw(Y*Z)] -> (icmp eq/ne X, Y)`
EQ: https://alive2.llvm.org/ce/z/6SdAG6
NE: https://alive2.llvm.org/ce/z/fjsq_b
This was previously implemented only to work if `Z` was constant,
but we can use `isKnownNonZero` to cover more cases.
3. `(icmp uPred X*Y, Y*Z) [if Z != 0 and nuw(X*Y) and nuw(X*Y)] -> (icmp uPred X, Y)`
EQ: https://alive2.llvm.org/ce/z/FqWQLX
NE: https://alive2.llvm.org/ce/z/2gHrd2
ULT: https://alive2.llvm.org/ce/z/MUAWgZ
ULE: https://alive2.llvm.org/ce/z/szQQ2L
UGT: https://alive2.llvm.org/ce/z/McVUdu
UGE: https://alive2.llvm.org/ce/z/95uyC8
This was previously implemented only for `eq/ne` cases. As well
only if `Z` was constant, but again we can use `isKnownNonZero` to
cover more cases.
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D142786
Noah Goldstein [Mon, 6 Feb 2023 18:06:11 +0000 (12:06 -0600)]
Add transform for `(mul X, OddC) eq/ne N * C` --> `X eq/ne N`
We previously only did this if the `mul` was `nuw`, but it works for
any odd value.
Alive2 Links:
EQ: https://alive2.llvm.org/ce/z/6_HPZ5
NE: https://alive2.llvm.org/ce/z/c34qSU
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D143026
Noah Goldstein [Mon, 6 Feb 2023 18:05:58 +0000 (12:05 -0600)]
Add tests for folding (icmp UnsignedPred X * Z, Y * Z) -> (icmp UnsignedPred X, Y); NFC
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D142785
Noah Goldstein [Mon, 6 Feb 2023 18:05:44 +0000 (12:05 -0600)]
Recommit "Improve and enable folding of conditional branches with tail calls." (2nd Try)
Improve and enable folding of conditional branches with tail calls.
1. Make it so that conditional tail calls can be emitted even when
there are multiple predecessors.
2. Don't guard the transformation behind -Os. The rationale for
guarding it was static-prediction can be affected by whether the
branch is forward of backward. This is no longer true for almost any
X86 cpus (anything newer than `SnB`) so is no longer a meaningful
concern.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D140931
Noah Goldstein [Mon, 6 Feb 2023 18:05:10 +0000 (12:05 -0600)]
Only match BMI (BLSR, BLSI, BLSMSK) if the add/sub op is single use
If the add/sub is not single use, it will need to be materialized
later, in which case using the BMI instruction is a de-optimization in
terms of code-size and throughput.
i.e:
```
// Good
leal -1(%rdi), %eax
andl %eax, %eax
xorl %eax, %esi
...
```
```
// Unecessary BMI (lower throughput, larger code size)
leal -1(%rdi), %eax
blsr %edi, %eax
xorl %eax, %esi
...
```
Note, this may cause more `mov` instructions to be emitted sometimes
because BMI instructions only have 1 src and write-only to dst. A
better approach may be to only avoid BMI for (and/xor X, (add/sub
0/-1, X)) if this is the last use of X but NOT the last use of
(add/sub 0/-1, X).
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D141180
Noah Goldstein [Mon, 6 Feb 2023 18:04:34 +0000 (12:04 -0600)]
Search through associative operators for BMI patterns (BLSI, BLSR, BLSMSK)
(a & (-b)) & b is often lowered as:
%sub = sub i32 0, %b
%and0 = and i32 %sub, %a
%and1 = and i32 %and0, %b
Which won't get detected by the BLSI pattern as b & -b are never in
the same SDNode.
This patch will do a small search through associative operators and try
and place BMI patterns in the same node so they will hit the pattern.
Reviewed By: pengfei
Differential Revision: https://reviews.llvm.org/D141179
Noah Goldstein [Mon, 6 Feb 2023 18:04:09 +0000 (12:04 -0600)]
Match (xor TSize - 1, ctlz) to `bsr` instead of `lzcnt` + `xor`
Was previously de-optimizating if -march supported lzcnt as there is
no reason to add the extra instruction.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D141464
Valentin Clement [Mon, 6 Feb 2023 20:06:44 +0000 (21:06 +0100)]
[flang] Fix creation of the bound array for pointer remapping
The runtime function expects a 2 x newRank array and the code
was passing a newRank x 2 array. This patch updates the
creation of the array to fit the runtime expectation.
Reviewed By: jeanPerier
Differential Revision: https://reviews.llvm.org/D143405
Ariel Burton [Mon, 6 Feb 2023 19:51:41 +0000 (19:51 +0000)]
[Clang] Fix __ptr32 arguments passed to builtins
Currently when clang deals with a call to a builtin function that
is supplied with an argument that has an explicit address space
it rewrites the signature of the callee to make the types of
the formal parameters match those of the actual arguments.
This functionality was added to support OpenCL, and was
introduced with commit b919c7d.
However, this does not work properly for "size" related address
spaces such as those used for __ptr32. This affects platforms
like Microsoft and z/OS.
This change preserves the OpenCL functionality, but will use
the formal parameter types when an address space is size-related.
Reviewed By: akhuang
Differential Revision: https://reviews.llvm.org/D142048
Haowei Wu [Mon, 30 Jan 2023 23:43:09 +0000 (15:43 -0800)]
[Clang] Add llvm-mt and llvm-rc to Clang bootstrap dependency
This patch adds llvm-mt and llvm-rc to the Clang bootstrap
dependency when building the Clang under Windows.
Differential Revision: https://reviews.llvm.org/D143025
Ron Lieberman [Mon, 6 Feb 2023 19:16:37 +0000 (13:16 -0600)]
Revert "[OpenMP][libomp] Remove false positive for memory sanitizer"
breaks amdgpu buildbot
This reverts commit
402981ee25fe135d63226a7de17dbb14c437c71b.
Haowei Wu [Fri, 3 Feb 2023 18:46:04 +0000 (10:46 -0800)]
[Fuchsia] Simplified the stage2 build setup
This patch simplified the BOOTSTRAP_ flags, allowing them to be
pass through from regular flags.
Differential Revision: https://reviews.llvm.org/D143288
Joseph Huber [Mon, 6 Feb 2023 18:33:25 +0000 (12:33 -0600)]
[LinkerWrapper] Output a temp file with the wrapper bitcode
Summary:
The wrapper bitcode currently only gets a temp file for the compiled
object. This makes it more difficult to see what was actually generated.
Bjorn Pettersson [Mon, 6 Feb 2023 18:29:06 +0000 (19:29 +0100)]
Revert "[Lint] Use new PM instead of legacy PM in lintFunction and lintModule"
This reverts commit
525ed98be483188db6dc3bb69cecd0123148ceca.
Some buildbots are failing when linking bugpoint.
Reverting to investigate that further.
Bjorn Pettersson [Mon, 6 Feb 2023 09:55:26 +0000 (10:55 +0100)]
[Lint] Use new PM instead of legacy PM in lintFunction and lintModule
There are some helpers in the Lint analysis pass that will setup
a pass manager and then run the Lint pass on a given Function/Module.
Those have been using the LegacyPassManager, but as a small step
towards removing the deprecated legacy pass manager this patch is
changing those helpers into using the new pass manager instead.
No idea if anyone is really is using those helpers. Maybe an
alternative had been to just remove them. There is at least no unit
tests or similar that verifies that they work, so I validated this
patch by using a hacked opt binary that called those functions
before running the normal pipeline.
Differential Revision: https://reviews.llvm.org/D143388
Bjorn Pettersson [Wed, 21 Dec 2022 21:10:52 +0000 (22:10 +0100)]
[TailDuplicator] Fix old bugs in TailDuplicator::duplicateInstruction
This patch is updating TailDuplicator::duplicateInstruction to fix
some old bugs that has been found with an out-of-tree target. There
are three different things being addressed:
1) In one situation two subregister indices are combined using the
composeSubRegIndices helper. But the order in which those indices
are combined has been incorrect. For this problem I managed to
create some kind of reproducer using AArch64 (see the test case
touched in this patch).
2) Another fault was found in the else branch for the above situation.
Here we do not compose the two subregisters, instead we insert a
COPY to replace the PHI, and then the subreg index in the using
MO remains. Thus, the virtual register created for the COPY should
always match with the size of the original register. Therefore the
optimization that "constrain" (or rather relax) the register
class by looking at the instruction desc must be limited to the
situation when there is no subregister access. Otherwise we create
a vreg with the wrong class.
3) Last problem addressed in this patch is that when a new register
class is picked by looking at the instruction desc, then it
isn't guaranteed that the isAllocatable property is set for that
class. So one need to use the getAllocatableClass helper to find
a subclass that is allocatable before using createVirualRegister,
or alternatively (as in this patch) just use the OrigRC instead
of relaxing the register class for the COPY destination.
Haven't been able to find any in-tree reproducers for problem 2 and 3.
The tricky part is to find a target that has register hierarchies that
match with the problem to trigger those code paths (and with subreg
accesses involved).
Differential Revision: https://reviews.llvm.org/D140496
Bjorn Pettersson [Wed, 21 Dec 2022 20:23:57 +0000 (21:23 +0100)]
[TailDuplicator] Pre-commit test case for a subreg composition bug
Differential Revision: https://reviews.llvm.org/D140495
Gulfem Savrun Yeniceri [Fri, 27 Jan 2023 18:02:26 +0000 (18:02 +0000)]
[Coverage] Map regions from system headers
Originally, the following commit removed mapping coverage regions for system headers:
https://github.com/llvm/llvm-project/commit/
93205af066341a53733046894bd75c72c99566db
It might be viable and useful to collect coverage from system headers in some systems.
This patch adds --system-headers-coverage option (disabled by default) to enable
collecting coverage from system headers.
Differential Revision: https://reviews.llvm.org/D143304
Florian Hahn [Mon, 6 Feb 2023 18:09:42 +0000 (18:09 +0000)]
Recommit "[ConstraintElim] Enable pass by default."
This reverts commit
695ce48c63ec582a46bfbda9b066f4d3bcde143f.
The compile-time regression causing the revert has been fixed. Recommit
the original patch.
Original commit message:
The pass should help to close a functional gap when it comes to
reasoning about related conditions in a relatively general way.
It addresses multiple existing issues (linked below) and the need for a
more powerful reasoning system was also discussed recently in
https://discourse.llvm.org/t/rfc-alternative-approach-of-dealing-with-implications-from-comparisons-through-pos-analysis/65601/7
On AArch64, the new pass performs ~2000 simplifications on
MultiSource,SPEC2006,SPEC2017 with -O3.
Compile-time impact:
NewPM-O3: +0.20%
NewPM-ReleaseThinLTO: +0.32%
NewPM-ReleaseLTO-g: +0.28%
https://llvm-compile-time-tracker.com/compare.php?from=
f01a3a893c147c1594b9a3fbd817456b209dabbf&to=
577688758ef64fb044215ec3e497ea901bb2db28&stat=instructions:u
Fixes #49344.
Fixes #47888.
Fixes #48253.
Fixes #49229.
Fixes #58074.
Reviewed By: asbirlea
Differential Revision: https://reviews.llvm.org/D135915
Benjamin Maxwell [Mon, 6 Feb 2023 17:38:35 +0000 (17:38 +0000)]
[DebugInfo] Add missing 'break' in switch (NFC)
Vassil Vassilev [Mon, 6 Feb 2023 17:33:54 +0000 (17:33 +0000)]
Don't re-export top-level modules
In https://reviews.llvm.org/D119036 we fixed some of the infrastructure by
removing the textual keyword.
The underlying issue of PR50592 was that clang can re-export only submodules but
under some conditions we needed to re-export the standalone module std_config
via std. This patch provides a better fix to the symptom D119036 fixed.
Differential revision: https://reviews.llvm.org/D142805
David Green [Mon, 6 Feb 2023 17:24:25 +0000 (17:24 +0000)]
[DAG] Remove non-canonical AVG case.
This removes a condition in the detection of AVG nodes, where we needn't be
checking the LHS of an add node as any const will be canonicalized to the RHS.
David Green [Mon, 6 Feb 2023 17:24:01 +0000 (17:24 +0000)]
[DAG][AArch64][ARM] Recognize avg (hadd) from wrapping flags
This slightly extends the creation of hadd nodes to allow them to be generated
with the original type size if wrapping flags allow.
https://alive2.llvm.org/ce/z/bPjakD
https://alive2.llvm.org/ce/z/fa_gzb
Differential Revision: https://reviews.llvm.org/D143371
Benjamin Maxwell [Wed, 1 Feb 2023 13:35:31 +0000 (13:35 +0000)]
[DebugInfo] Handle fixed-width DW_FORM_addrx variants in DWARFFormValue::getAsSectionedAddress()
Previously this would incorrectly return the raw offset into the .debug_addr section for the
DW_FORM_addrx1/2/3/4 forms rather than the actual address.
Note that this was handled correctly in the dump() function so this issue only occurs for users
of this API and not in tools such as llvm-dwarfdump. The dump() method has now been updated
to use this method to increase coverage.
This also now adds a few unit tests for indexed addresses to DWARFDebugInfoTest.
Differential Revision: https://reviews.llvm.org/D143073
Joseph Huber [Mon, 6 Feb 2023 15:14:20 +0000 (09:14 -0600)]
[libc] Add `LIBC_GPU_TEST_ARCHITECTURE` option to set architecture
Currently, the plan is to support testing on a single GPU architecture.
We query the supported architectures from the user's system. However,
there are times when the user would want to override this. This patch
adds the `LIBC_GPU_TEST_ARCHITECTURE` option, which allows users to
specify which GPU architecture to build for.
Reviewed By: lntue
Differential Revision: https://reviews.llvm.org/D143400
Florian Hahn [Mon, 6 Feb 2023 16:43:42 +0000 (16:43 +0000)]
[ConstraintElim] Update existing constraint system in place (NFC).
This patch breaks up the solving step into 2 phases:
1. Collect all rows where the variable to eliminate is != 0 and remove
it from the original system.
2. Process all collect rows to build new set of constraints, add them to
the original system.
This is much more efficient for excessive cases, as this avoids a large
number of moves to the new system. This reduces the time spent in
ConstraintElimination for the test case shared in D135915 from ~3s to
0.6s.
Shivam Gupta [Mon, 6 Feb 2023 15:43:53 +0000 (21:13 +0530)]
[LLDB][NFC] Fix a incorrect use of shared_ptr in RenderScriptRuntime.cpp
Incorrect use of shared_ptr.
found by PVS-Studio https://pvs-studio.com/en/blog/posts/cpp/1003/, N8 & N9.
Differential Revision: https://reviews.llvm.org/D142309
Ivan Kosarev [Mon, 6 Feb 2023 13:07:24 +0000 (13:07 +0000)]
[AMDGPU][NFC] Clean up the VOP profile definition for v_swap_b32.
v_swap_b32 is a VOP1-only instruction, meaning it neither encodes src1
nor has 64-bit encodings.
Reviewed By: foad
Differential Revision: https://reviews.llvm.org/D143289
Chuanqi Xu [Mon, 6 Feb 2023 16:20:50 +0000 (00:20 +0800)]
[Coroutines] Pass size parameter for deallocation function when qualified
Close https://github.com/llvm/llvm-project/issues/60545.
Previously, we would only pass the size parameter to the deallocation
function if the type is completely the same. But it is good enough to
make them unqualified the smae.
Dmitry Chernenkov [Mon, 6 Feb 2023 15:53:56 +0000 (15:53 +0000)]
[bazel][libc] Fix dependencies for float functions
Florian Hahn [Sun, 5 Feb 2023 22:05:53 +0000 (22:05 +0000)]
[ConstraintElim] Move some array accesses to variables (NFC).
Move some accesses that are use multiple times to variables. This also
will make updating them easier in the future.