platform/upstream/llvm.git
2 years ago[flang] D123388 fix - remove unused variable from test
Jean Perier [Mon, 11 Apr 2022 09:56:44 +0000 (02:56 -0700)]
[flang] D123388 fix - remove unused variable from test

2 years ago[AST] Remove a duplicated getDecl method in TemplateName, NFC.
Haojian Wu [Mon, 11 Apr 2022 09:51:28 +0000 (11:51 +0200)]
[AST] Remove a duplicated getDecl method in TemplateName, NFC.

There is a TemplateName::getTemplateDecl which does the same work.

2 years ago[flang][runtime] Prefer process time over thread time in CPU_TIME
Mats Petersson [Fri, 8 Apr 2022 18:04:47 +0000 (19:04 +0100)]
[flang][runtime] Prefer process time over thread time in CPU_TIME

Most Fortran compilers appear to return the process time
for calls to CPU_TIME, where the flang implementation
prior to this change was returning the time used by the
current thread. This would cause incorrect time being
reported when for example OpenMP is used to share work
across multiple CPUs.

This patch changes the order so the selection of "what
time to return" so that if there is a process time to
report, that is the reported value, and only if that is
not available, the thread time is considerd instead.

Reviewed By: jeanPerier

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

2 years agoRevert rG88ff6f70c45f2767576c64dde28cbfe7a90916ca "[X86] Extend vselect(cond, pshufb...
Simon Pilgrim [Mon, 11 Apr 2022 09:42:32 +0000 (10:42 +0100)]
Revert rG88ff6f70c45f2767576c64dde28cbfe7a90916ca "[X86] Extend vselect(cond, pshufb(x), pshufb(y)) -> or(pshufb(x), pshufb(y)) to include inner or(pshufb(x), pshufb(y)) chains"

Reverting while I investigate reports of internal test regressions/failures

2 years ago[ThinLTOCodeGenerator] Remove support for legacy PM
Nikita Popov [Fri, 8 Apr 2022 09:40:02 +0000 (11:40 +0200)]
[ThinLTOCodeGenerator] Remove support for legacy PM

All users of NewPM=false for the (legacy) ThinLTOCodeGenerator
have been removed, so we can remove this functionality entirely.

2 years ago[Flang][OpenMP] Add implementation of privatisation
Kiran Chandramohan [Mon, 11 Apr 2022 09:05:00 +0000 (09:05 +0000)]
[Flang][OpenMP] Add implementation of privatisation

Privatisation creates local copies of variables in the OpenMP region.
Two functions `createHostAssociateVarClone` and `copyHostAssociateVar`
are added to create a clone of the variable for basic privatisation and to
copy the contents for first-privatisation.

Note: Tests for more data-types will be added when the fir.do_loop is
upstreamed.

This is part of the upstreaming effort from the fir-dev branch in [1].
[1] https://github.com/flang-compiler/f18-llvm-project

Reviewed By: peixin, NimishMishra

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

Co-authored-by: Jean Perier <jperier@nvidia.com>
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Peter Klausler <pklausler@nvidia.com>
Co-authored-by: Valentin Clement <clementval@gmail.com>
Co-authored-by: Sourabh Singh Tomar <SourabhSingh.Tomar@amd.com>
Co-authored-by: Nimish Mishra <neelam.nimish@gmail.com>
Co-authored-by: Peixin-Qiao <qiaopeixin@huawei.com>
2 years ago[Clang] Enable opaque pointers by default
Nikita Popov [Thu, 7 Apr 2022 09:59:38 +0000 (11:59 +0200)]
[Clang] Enable opaque pointers by default

Enable opaque pointers by default in clang, which can be disabled
either via cc1 option -no-opaque-pointers or cmake flag
-DCLANG_ENABLE_OPAQUE_POINTERS=OFF.

See https://llvm.org/docs/OpaquePointers.html for context.

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

2 years ago[Clang] Add -no-opaque-pointers to recently added test (NFC)
Nikita Popov [Mon, 11 Apr 2022 09:13:05 +0000 (11:13 +0200)]
[Clang] Add -no-opaque-pointers to recently added test (NFC)

2 years ago[C++20][Modules] Remove an empty statement [NFC].
Iain Sandoe [Mon, 11 Apr 2022 07:56:50 +0000 (08:56 +0100)]
[C++20][Modules] Remove an empty statement [NFC].

This addresses a post commit review comment by removing an unused and empty
'else' (replaced with a comment).

2 years ago[X86] Add shuffle combine tests where we fail to fold a mask into a or(pshufb,pshufb...
Simon Pilgrim [Mon, 11 Apr 2022 08:54:42 +0000 (09:54 +0100)]
[X86] Add shuffle combine tests where we fail to fold a mask into a or(pshufb,pshufb) chain

This doesn't hit if we use pshufb intrinsics directly due to a change in lowering order

2 years ago[llvm-lto] Remove support for legacy pass manager
Nikita Popov [Fri, 8 Apr 2022 08:54:20 +0000 (10:54 +0200)]
[llvm-lto] Remove support for legacy pass manager

This removes support for the legacy pass manager in llvm-lto and
llvm-lto2. In this case I've dropped the use-new-pm option entirely,
as I don't think this is considered part of the public interface.

This also makes -debug-pass-manager work with llvm-lto, because
that was needed to migrate some tests to NewPM.

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

2 years ago[flang] Lower optionals in GET_COMMAND_ARGUMENT and GET_ENVIRONMENT_VARIABLE
jeanPerier [Mon, 11 Apr 2022 07:33:39 +0000 (09:33 +0200)]
[flang] Lower optionals in GET_COMMAND_ARGUMENT and  GET_ENVIRONMENT_VARIABLE

Handle dynamic optional argument in GET_COMMAND_ARGUMENT and GET_ENVIRONMENT_VARIABLE
(previously compiled but caused segfaults). The previous code
handled static presence/absence aspects, but not when an absent dummy optional was
passed to one of the optional intrinsic arguments.

Simplify the runtime call lowering to simply lower the runtime call without
dealing with optionality there. This keeps the optional handling logic in
IntrinsicCall.cpp.

Note that the new code will generate some extra "if (not null addr )/then/else"
when the actual arguments are always there at runtime. That makes the implementation
a lot simpler/safer, and I think it is OK for now (I do not expect these runtime
function to be called in hot loop nests).

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

2 years ago[flang] add a static assert in CheckUnitNumberInRangeImpl
Jean Perier [Mon, 11 Apr 2022 07:32:03 +0000 (09:32 +0200)]
[flang] add a static assert in CheckUnitNumberInRangeImpl

Add a check that CheckUnitNumberInRangeImpl is not needlessly instantiated.

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

2 years ago[AArch64][NFC] Update comment in AArch64.td
Alexander Shaposhnikov [Mon, 11 Apr 2022 05:36:28 +0000 (05:36 +0000)]
[AArch64][NFC] Update comment in AArch64.td

2 years ago[AArch64] Split fuse-literals feature
Alexander Shaposhnikov [Mon, 11 Apr 2022 05:27:11 +0000 (05:27 +0000)]
[AArch64] Split fuse-literals feature

This diff splits fuse-literals feature and enables fuse-adrp-add by default,
in particular, it adjusts instruction scheduling to place ADRP+ADD pairs together.
This also enables the linker to apply the relaxations described in
https://github.com/ARM-software/abi-aa/commit/d2ca58c54b8e955cfef25c71822f837ae0439d73.

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

Test plan: make check-all

2 years ago[AVR] Merge AVRRelaxMemOperations into AVRExpandPseudoInsts
Patryk Wychowaniec [Mon, 11 Apr 2022 02:21:45 +0000 (02:21 +0000)]
[AVR] Merge AVRRelaxMemOperations into AVRExpandPseudoInsts

This commit contains a refactoring that merges AVRRelaxMemOperations
into AVRExpandPseudoInsts, so that we have a single place in code that
expands the STDWPtrQRr opcode.

Seizing the day, I've also fixed a couple of potential bugs with our
previous implementation (e.g. when the destination register was killed,
the previous implementation would try to .addDef() that killed
register, crashing LLVM in the process - that's fixed now, as proved by
the test).

Reviewed By: benshi001

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

2 years ago[RISCV] Add basic code modeling for llvm.experimental.stepvector intrinsic
LiaoChunyu [Thu, 31 Mar 2022 06:16:24 +0000 (14:16 +0800)]
[RISCV] Add basic code modeling for llvm.experimental.stepvector intrinsic

Scalable vectors llvm.experimental.stepvector intrinsic
will crash due to an invalid cost when run the code through the loopunroll.

Reviewed By: kito-cheng

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

2 years ago[CUDA][HIP] Externalize kernels in anonymous name space
Yaxun (Sam) Liu [Fri, 8 Apr 2022 02:57:56 +0000 (22:57 -0400)]
[CUDA][HIP] Externalize kernels in anonymous name space

kernels in anonymous name space needs to have unique name
to avoid duplicate symbols.

Fixes: https://github.com/llvm/llvm-project/issues/54560

Reviewed by: Artem Belevich

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

2 years ago[llvm-objcopy] Update comments with capitalization change from 6b575395d47b8
Nico Weber [Mon, 11 Apr 2022 01:24:21 +0000 (21:24 -0400)]
[llvm-objcopy] Update comments with capitalization change from 6b575395d47b8

No behavior change.

2 years agoFix a misuse of `cast`
Sheng [Mon, 11 Apr 2022 01:21:15 +0000 (01:21 +0000)]
Fix a misuse of `cast`

`cast` will assert instead of returning null pointer.

2 years ago[LAA] Add test with simpler load of pointer select.
Florian Hahn [Sun, 10 Apr 2022 21:50:23 +0000 (23:50 +0200)]
[LAA] Add test with simpler load of pointer select.

Add a simpler test for D114487/D108699.

2 years ago[LICM] Add test for PR51248.
Florian Hahn [Sun, 10 Apr 2022 20:36:03 +0000 (22:36 +0200)]
[LICM] Add test for PR51248.

Test for #51248. LICM introduces an unused load in a writeonly function.

2 years ago[LICM] Trim unneeded functions from test, add promote-able load.
Florian Hahn [Sun, 10 Apr 2022 20:25:05 +0000 (22:25 +0200)]
[LICM] Trim unneeded functions from test, add promote-able load.

Clean up the test a bit. Also add a promote-able load, to make sure LICM
always has to hoist the load.

2 years ago[X86] Remove dead code from test case
eop Chen [Sun, 10 Apr 2022 15:31:25 +0000 (08:31 -0700)]
[X86] Remove dead code from test case

Obvious NFC, no need to review.

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

2 years ago[libc++] Rename the template arguments of the algorithm result types
Nikolas Klauser [Sun, 10 Apr 2022 09:55:06 +0000 (11:55 +0200)]
[libc++] Rename the template arguments of the algorithm result types

Spies: libcxx-commits

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

2 years ago[X86] Extend vselect(cond, pshufb(x), pshufb(y)) -> or(pshufb(x), pshufb(y)) to inclu...
Simon Pilgrim [Sun, 10 Apr 2022 12:04:53 +0000 (13:04 +0100)]
[X86] Extend vselect(cond, pshufb(x), pshufb(y)) -> or(pshufb(x), pshufb(y)) to include inner or(pshufb(x), pshufb(y)) chains

2 years ago[ORC] add lazy jit support for riscv64
Alex Fan [Thu, 24 Mar 2022 01:46:36 +0000 (09:46 +0800)]
[ORC] add lazy jit support for riscv64

This adds resolver, indirection and trampoline stubs for riscv64,
allowing lazy compilation to work.

It assumes hard float extension exists. I don't know the proper way to detect it as Triple doesn't provide the interface to check riscv +f +d abi.

I am also not sure if orclazy tests should be enabled because lli needs an additional -codemodel=melany for tests to pass.

Reviewed By: lhames

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

2 years ago[X86] combineExtractSubvector - fold extract_subvector(insert_subvector(V,X,C1),C1)
Simon Pilgrim [Sun, 10 Apr 2022 10:03:08 +0000 (11:03 +0100)]
[X86] combineExtractSubvector - fold extract_subvector(insert_subvector(V,X,C1),C1)

extract_subvector(insert_subvector(V,X,C1),C1) -> insert_subvector(extract_subvector(V,C1),X,0)

More aggressively attempt to reduce the width of an extract_subvector source - we currently only do this if we're inserting into a zero vector (i.e. canonicalizing to the AVX implicit zero upper elts pattern).

But if we're extracting from the same point as the inner insert_subvector then the fold is still relatively trivial - we can probably do even better if we can ensure the subvector isn't badly split.

2 years ago[Driver] Prepend - to option name in err_drv_unsupported_option_argument diagnostic
Fangrui Song [Sun, 10 Apr 2022 08:44:53 +0000 (01:44 -0700)]
[Driver] Prepend - to option name in err_drv_unsupported_option_argument diagnostic

2 years ago[VPlan] Place VPExpandSCEVRecipe in pre-header.
Florian Hahn [Sun, 10 Apr 2022 08:26:20 +0000 (10:26 +0200)]
[VPlan] Place VPExpandSCEVRecipe in pre-header.

After D121624 models the pre-header in VPlan, VPExpandSCEVRecipes can be
placed there. This ensures SCEV expansion happens before modifying the
CFG during VPlan execution, when CFG is incomplete.

Depends on D121624.

Reviewed By: Ayal

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

2 years ago[Driver] Simplify OPT_fcolor_diagnostics claim
Fangrui Song [Sun, 10 Apr 2022 08:21:31 +0000 (01:21 -0700)]
[Driver] Simplify OPT_fcolor_diagnostics claim

Mostly NFC, but the diagnostic is changed to the more appropriate
err_drv_invalid_argument_to_option.

2 years ago[Driver] Simplify -f[no-]diagnostics-color handling. NFC
Fangrui Song [Sun, 10 Apr 2022 08:07:44 +0000 (01:07 -0700)]
[Driver] Simplify -f[no-]diagnostics-color handling. NFC

Make them aliases for -f[no-]color-diagnostics.

2 years ago[Frontend] Simplify -finline* handling. NFC
Fangrui Song [Sun, 10 Apr 2022 07:31:25 +0000 (00:31 -0700)]
[Frontend] Simplify -finline* handling. NFC

2 years ago[Driver] Fix -f[no-]inline to override -f[no-]inline-functions/-finline-hint-functions
Fangrui Song [Sun, 10 Apr 2022 07:15:12 +0000 (00:15 -0700)]
[Driver] Fix -f[no-]inline to override -f[no-]inline-functions/-finline-hint-functions

Fix two cases to match GCC:

* -fno-inline -finline => (no cc1 option)
* -fno-inline -finline-functions => -fno-inline

2 years ago[X86][AMX] Fix infinite loop of getShape.
Luo, Yuanke [Sun, 10 Apr 2022 06:32:20 +0000 (14:32 +0800)]
[X86][AMX] Fix infinite loop of getShape.

When walk the user chain to get the shape of a phi node. If it is phi
node in the chain, we should walk to the user of this phi node instead
of the original phi node.

2 years ago[RISCV] Remove unnecessary cast to i8* when converting gather/scatter to strided...
Craig Topper [Sun, 10 Apr 2022 03:01:32 +0000 (20:01 -0700)]
[RISCV] Remove unnecessary cast to i8* when converting gather/scatter to strided load/store.

Not sure why I thought this necessary at the time.

2 years ago[ObjCopy][NFC] Refactor handling of linkedit_data_command in MachOWriter
Alexander Shaposhnikov [Sun, 10 Apr 2022 02:09:11 +0000 (02:09 +0000)]
[ObjCopy][NFC] Refactor handling of linkedit_data_command in MachOWriter

2 years ago[ObjCopy][NFC] Add missing const in MachOLayoutBuilder.h
Alexander Shaposhnikov [Sun, 10 Apr 2022 01:29:24 +0000 (01:29 +0000)]
[ObjCopy][NFC] Add missing const in MachOLayoutBuilder.h

2 years ago[ObjCopy][NFC] Refactor handling of linkedit_data_command
Alexander Shaposhnikov [Sun, 10 Apr 2022 01:20:45 +0000 (01:20 +0000)]
[ObjCopy][NFC] Refactor handling of linkedit_data_command

2 years agoGiving a lot more functions prototypes; NFC
Aaron Ballman [Sat, 9 Apr 2022 21:23:32 +0000 (17:23 -0400)]
Giving a lot more functions prototypes; NFC

This should address https://lab.llvm.org/buildbot/#/builders/37/builds/12315
and speculatively fix other similar diagnostics.

2 years ago[randstruct] NFC change to use static
Bill Wendling [Sat, 9 Apr 2022 20:24:59 +0000 (13:24 -0700)]
[randstruct] NFC change to use static

2 years ago[gn build] Port 7aa8c38a9e19
LLVM GN Syncbot [Sat, 9 Apr 2022 20:16:19 +0000 (20:16 +0000)]
[gn build] Port 7aa8c38a9e19

2 years ago[randstruct] Add randomize structure layout support
Connor Kuehl [Sat, 9 Apr 2022 06:36:51 +0000 (23:36 -0700)]
[randstruct] Add randomize structure layout support

The Randstruct feature is a compile-time hardening technique that
randomizes the field layout for designated structures of a code base.
Admittedly, this is mostly useful for closed-source releases of code,
since the randomization seed would need to be available for public and
open source applications.

Why implement it? This patch set enhances Clang’s feature parity with
that of GCC which already has the Randstruct feature. It's used by the
Linux kernel in certain structures to help thwart attacks that depend on
structure layouts in memory.

This patch set is a from-scratch reimplementation of the Randstruct
feature that was originally ported to GCC. The patches for the GCC
implementation can be found here:

  https://www.openwall.com/lists/kernel-hardening/2017/04/06/14

Link: https://lists.llvm.org/pipermail/cfe-dev/2019-March/061607.html
Co-authored-by: Cole Nixon <nixontcole@gmail.com>
Co-authored-by: Connor Kuehl <cipkuehl@gmail.com>
Co-authored-by: James Foster <jafosterja@gmail.com>
Co-authored-by: Jeff Takahashi <jeffrey.takahashi@gmail.com>
Co-authored-by: Jordan Cantrell <jordan.cantrell@mail.com>
Co-authored-by: Nikk Forbus <nicholas.forbus@gmail.com>
Co-authored-by: Tim Pugh <nwtpugh@gmail.com>
Co-authored-by: Bill Wendling <isanbard@gmail.com>
Signed-off-by: Bill Wendling <isanbard@gmail.com>
Reviewed By: aaron.ballman

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

2 years ago[IRBuilder] Remove commented out include.
Florian Hahn [Sat, 9 Apr 2022 19:32:58 +0000 (21:32 +0200)]
[IRBuilder] Remove commented out include.

Looks like this was left over during some include optimizations. Remove
it.

2 years ago[X86] Remove cfi noise from splat-for-size.ll tests
Simon Pilgrim [Sat, 9 Apr 2022 16:53:21 +0000 (17:53 +0100)]
[X86] Remove cfi noise from splat-for-size.ll tests

2 years agoAdd some prototypes to fix -Wstrict-prototypes. NFC
Fangrui Song [Sat, 9 Apr 2022 16:46:39 +0000 (09:46 -0700)]
Add some prototypes to fix -Wstrict-prototypes. NFC

2 years ago[flang] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build
PeixinQiao [Sat, 9 Apr 2022 15:57:50 +0000 (23:57 +0800)]
[flang] Fix -Wunused-variable in -DLLVM_ENABLE_ASSERTIONS=off build

Fix the warning from D122483.

Reviewed By: kiranchandramohan

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

2 years ago[RISCV] Only try LUI+SH*ADD+ADDI for int materialization if LUI+ADDI+SH*ADD failed.
Craig Topper [Sat, 9 Apr 2022 15:32:42 +0000 (08:32 -0700)]
[RISCV] Only try LUI+SH*ADD+ADDI for int materialization if LUI+ADDI+SH*ADD failed.

There's an assert in LUI+SH*ADD+ADDI materialization that makes sure the
lower 12 bits aren't zero since that case should have been handled as
LUI+ADDI+SH*ADD. But nothing prevented the LUI+SH*ADD+ADDI checks from
running after the earlier code handled it.

The sequence would be the same length or longer so it wouldn't replace
the earlier sequence, but the assert happened before that was checked.

The vector holding the sequence also wasn't reset before the second
check so that guaranteed the sequence would never be found to be
shorter.

This patch fixes this by only trying the second expansion when the
earlier fails.

Fixes PR54812.

Reviewed By: benshi001

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

2 years ago[X86] Add original test coverage for Issue #54819
Simon Pilgrim [Sat, 9 Apr 2022 15:47:53 +0000 (16:47 +0100)]
[X86] Add original test coverage for Issue #54819

2 years ago[X86] Fold concat(pshufb(x,y),pshufb(z,w)) -> pshufb(concat(x,z),concat(y,w))
Simon Pilgrim [Sat, 9 Apr 2022 15:05:46 +0000 (16:05 +0100)]
[X86] Fold concat(pshufb(x,y),pshufb(z,w)) -> pshufb(concat(x,z),concat(y,w))

2 years ago[clang-format] Add execute permission to dump_format_help.py
owenca [Sat, 9 Apr 2022 14:55:38 +0000 (07:55 -0700)]
[clang-format] Add execute permission to dump_format_help.py

2 years agoAdd some prototypes to these functions; NFC
Aaron Ballman [Sat, 9 Apr 2022 14:51:06 +0000 (10:51 -0400)]
Add some prototypes to these functions; NFC

This is expected to fix the issues in this build bot:
https://lab.llvm.org/buildbot/#/builders/37/builds/12312

2 years ago[gn build] Port a96443eddedc
LLVM GN Syncbot [Sat, 9 Apr 2022 14:04:27 +0000 (14:04 +0000)]
[gn build] Port a96443eddedc

2 years ago[libc++] Implement P0401R6 (allocate_at_least)
Nikolas Klauser [Sat, 9 Apr 2022 07:41:19 +0000 (09:41 +0200)]
[libc++] Implement P0401R6 (allocate_at_least)

Reviewed By: ldionne, var-const, #libc

Spies: mgorny, libcxx-commits, arichardson

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

2 years ago[X86] lowerV64I8Shuffle - attempt to fold to SHUFFLE(ALIGNR(X,Y)) and OR(PSHUFB(X...
Simon Pilgrim [Sat, 9 Apr 2022 13:09:21 +0000 (14:09 +0100)]
[X86] lowerV64I8Shuffle - attempt to fold to SHUFFLE(ALIGNR(X,Y)) and OR(PSHUFB(X),PSHUFB(Y))

2 years agoAdd some prototypes to these checks; NFC
Aaron Ballman [Sat, 9 Apr 2022 12:35:15 +0000 (08:35 -0400)]
Add some prototypes to these checks; NFC

This should address a build bot failure:
https://lab.llvm.org/buildbot/#/builders/18/builds/4495

2 years ago[VPlan] Model pre-header explicitly.
Florian Hahn [Sat, 9 Apr 2022 12:19:47 +0000 (14:19 +0200)]
[VPlan] Model pre-header explicitly.

This patch extends the scope of VPlan to also model the pre-header.
The pre-header can be used to place recipes that should be code-gen'd
outside the loop, like SCEV expansion.

Depends on D121623.

Reviewed By: Ayal

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

2 years ago[X86][SSE] combineSelect - more aggressively create zero elements in the or(pshufb...
Simon Pilgrim [Sat, 9 Apr 2022 11:52:56 +0000 (12:52 +0100)]
[X86][SSE] combineSelect - more aggressively create zero elements in the or(pshufb(x), pshufb(y)) fold

When we fold vselect(cond, pshufb(x), pshufb(y)) -> or(pshufb(x), pshufb(y)), ensure we convert all undef elements to zero elements - this should help us expose more known zero elements for deeper chains of these cases.

Noticed while triaging Issue #54819

2 years ago[CUDA/HIP] Remove argument from module ctor/dtor signatures
Jonas Hahnfeld [Fri, 8 Apr 2022 08:30:30 +0000 (10:30 +0200)]
[CUDA/HIP] Remove argument from module ctor/dtor signatures

In theory, constructors can take arguments when called via .init_array
where at least glibc passes in (argc, argv, envp). This isn't used in
the generated code and if it was, the first argument should be an
integer, not a pointer. For destructors registered via atexit, the
function should never take an argument.

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

2 years ago[X86] Add v64i8 shuffle test coverage
Simon Pilgrim [Sat, 9 Apr 2022 10:33:15 +0000 (11:33 +0100)]
[X86] Add v64i8 shuffle test coverage

Legalized shuffle masks based on the test cases from Issue #54819

2 years ago[X86] Reduce some superfluous diffs between znver1/znver2 models. NFC
Simon Pilgrim [Sat, 9 Apr 2022 09:59:18 +0000 (10:59 +0100)]
[X86] Reduce some superfluous diffs between znver1/znver2 models. NFC

znver2 is a mainly a search+replace of the znver1 model, but for no reason some lines have been moved around - try to keep these in sync (no actual changes in the models).

2 years ago[LoopVectorize] Regenerate first-order-recurrence.ll
Simon Pilgrim [Sat, 9 Apr 2022 09:33:03 +0000 (10:33 +0100)]
[LoopVectorize] Regenerate first-order-recurrence.ll

2 years ago[AArch64] validateTargetOperandClass - early out from MCK_MPR case. NFCI.
Simon Pilgrim [Sat, 9 Apr 2022 08:26:58 +0000 (09:26 +0100)]
[AArch64] validateTargetOperandClass - early out from MCK_MPR case. NFCI.

If it didn't match a za register, there's nothing we can do.

Fixes static analyzer uninitialized variable warning.

2 years ago[PowerPC] Generate tests for 16-byte atomic load/store. NFC.
Kai Luo [Sat, 9 Apr 2022 08:36:57 +0000 (16:36 +0800)]
[PowerPC] Generate tests for 16-byte atomic load/store. NFC.

2 years ago[sanitizer] Disable new test on Android to fix a bot
Vitaly Buka [Sat, 9 Apr 2022 07:57:16 +0000 (00:57 -0700)]
[sanitizer] Disable new test on Android to fix a bot

2 years ago[gn build] Port 889302292bf6
LLVM GN Syncbot [Sat, 9 Apr 2022 07:40:37 +0000 (07:40 +0000)]
[gn build] Port 889302292bf6

2 years ago[libc++][format][4/6] Improve formatted_size.
Mark de Wever [Sun, 26 Sep 2021 14:48:25 +0000 (16:48 +0200)]
[libc++][format][4/6] Improve formatted_size.

Use a specialized "buffer" to count the number of insertions instead of
using a `string` as storage type.

Depends on D110497.

Reviewed By: ldionne, #libc

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

2 years ago[libc++][format][3/6] Adds a __container_buffer.
Mark de Wever [Sun, 26 Sep 2021 13:47:42 +0000 (15:47 +0200)]
[libc++][format][3/6] Adds a __container_buffer.

Instead of writing every character directly into the container by using
a `back_insert_iterator` the data is buffered in an `array`. This buffer
is then inserted to the container by calling its `insert` member function.

Since there's no guarantee every container's `insert` behaves properly
containers need to opt-in to this behaviour. The appropriate standard
containers opt-in to this behaviour.

This change improves the performance of the format functions that use a
`back_insert_iterator`.

Depends on D110495

Reviewed By: ldionne, vitaut, #libc

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

2 years agoReland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""
Fangrui Song [Sat, 9 Apr 2022 06:40:18 +0000 (23:40 -0700)]
Reland "[Driver] Default CLANG_DEFAULT_PIE_ON_LINUX to ON""

(With C++ exceptions, `clang++ --target=mips64{,el}-linux-gnu -fpie -pie
-fuse-ld=lld` has link errors (lld does not implement some strange R_MIPS_64
.eh_frame handling in GNU ld). However, sanitizer-x86_64-linux-qemu used this to
build ScudoUnitTests. Pined ScudoUnitTests to -no-pie.)

Default the option introduced in D113372 to ON to match all(?) major Linux
distros. This matches GCC and improves consistency with Android and linux-musl
which always default to PIE.
Note: CLANG_DEFAULT_PIE_ON_LINUX may be removed in the future.

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

2 years ago[scudo][test] Link with -no-pie to be agnostic of CLANG_DEFAULT_PIE_ON_LINUX
Fangrui Song [Sat, 9 Apr 2022 06:30:07 +0000 (23:30 -0700)]
[scudo][test] Link with -no-pie to be agnostic of CLANG_DEFAULT_PIE_ON_LINUX

This keeps the test behavior unchanged when CLANG_DEFAULT_PIE_ON_LINUX switches
to ON by default.

Note: current clang --target=mips64el-linux-gnu -fpie -pie -fuse-ld=lld
does not link with C++ exceptions, using -pie would lead to

```
ld.lld: error: cannot preempt symbol: DW.ref.__gxx_personality_v0
...
ld.lld: error: relocation R_MIPS_64 cannot be used against local symbol; recompile with -fPIC
...
```

when linking `ScudoUnitTests`: https://lab.llvm.org/buildbot/#/builders/169/builds/7311/steps/18/logs/stdio

2 years ago[flang] Support export/import OpenMP Threadprivate Flag
Peixin-Qiao [Sat, 9 Apr 2022 05:52:31 +0000 (13:52 +0800)]
[flang] Support export/import OpenMP Threadprivate Flag

The information about OpenMP/OpenACC declarative directives in modules
should be carried in export mod files. This supports export OpenMP
Threadprivate directive and import OpenMP declarative directives.

Reviewed By: kiranchandramohan

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

2 years ago[clang][OpenMP5.1] Initial parsing/sema for has_device_addr
Jennifer Yu [Thu, 7 Apr 2022 03:30:44 +0000 (20:30 -0700)]
[clang][OpenMP5.1] Initial parsing/sema for has_device_addr

Added basic parsing/sema/ support for the 'has_device_addr' clause.

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

2 years ago[BOLT] Check MCContext errors
Amir Ayupov [Sat, 9 Apr 2022 04:07:27 +0000 (21:07 -0700)]
[BOLT] Check MCContext errors

Abort on emission errors to prevent a malformed binary being written.
Example:
```
<unknown>:0: error: Undefined temporary symbol .Ltmp26310
<unknown>:0: error: Undefined temporary symbol .Ltmp26311
<unknown>:0: error: Undefined temporary symbol .Ltmp26312
<unknown>:0: error: Undefined temporary symbol .Ltmp26313
<unknown>:0: error: Undefined temporary symbol .Ltmp26314
<unknown>:0: error: Undefined temporary symbol .Ltmp26315
BOLT-ERROR: Emission failed.
```

Reviewed By: yota9

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

2 years ago[lld-macho] Use fewer indirections in UnwindInfo implementation
Jez Ng [Sat, 9 Apr 2022 02:33:00 +0000 (22:33 -0400)]
[lld-macho] Use fewer indirections in UnwindInfo implementation

The previous implementation of UnwindInfoSection materialized
all the compact unwind entries & applied their relocations, then parsed
the resulting data to generate the final unwind info. This design had
some unfortunate conseqeuences: since relocations can only be applied
after their referents have had addresses assigned, operations that need
to happen before address assignment must contort themselves. (See
{D113582} and observe how this diff greatly simplifies it.)

Moreover, it made synthesizing new compact unwind entries awkward.
Handling PR50956 will require us to do this synthesis, and is the main
motivation behind this diff.

Previously, instead of generating a new CompactUnwindEntry directly, we
would have had to generate a ConcatInputSection with a number of
`Reloc`s that would then get "flattened" into a CompactUnwindEntry.

This diff introduces an internal representation of `CompactUnwindEntry`
(the former `CompactUnwindEntry` has been renamed to
`CompactUnwindLayout`). The new CompactUnwindEntry stores references to
its personality symbol and LSDA section directly, without the use of
`Reloc` structs.

In addition to being easier to work with, this diff also allows us to
handle unwind info whose personality symbols are located in sections
placed after the `__unwind_info`.

Reviewed By: #lld-macho, oontvoo

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

2 years agoRevert D121556 "[randstruct] Add randomize structure layout support"
Fangrui Song [Sat, 9 Apr 2022 01:37:26 +0000 (18:37 -0700)]
Revert D121556 "[randstruct] Add randomize structure layout support"

This reverts commit 3f0587d0c668202bb89d29a25432aa290e551a31.

Not all tests pass after a few rounds of fixes.

I spot one failure that std::shuffle (potentially different results with
different STL implementations) was misused and replaced it with llvm::shuffle,
but there appears to be another failure in a Windows build.

The latest failure is reported on https://reviews.llvm.org/D121556#3440383

2 years ago[gn build] Port 46b2a463bdef
LLVM GN Syncbot [Sat, 9 Apr 2022 01:14:57 +0000 (01:14 +0000)]
[gn build] Port 46b2a463bdef

2 years ago[randstruct] Use llvm::shuffle to avoid STL impl difference after D121556
Fangrui Song [Sat, 9 Apr 2022 01:14:21 +0000 (18:14 -0700)]
[randstruct] Use llvm::shuffle to avoid STL impl difference after D121556

This reverts commit 2a2149c754f96376ddf8fed248102dd8e6092a22.
This reverts commit 8d7595be1dd41d7f7470ec90867936ca5e4e0d82.
This reverts commit e2e6899452998932b37f0fa9e66d104a02abe3e5.

If this doesn't work, I'll revert the whole thing.

2 years ago[gn build] Port 2a2149c754f9
LLVM GN Syncbot [Sat, 9 Apr 2022 00:50:44 +0000 (00:50 +0000)]
[gn build] Port 2a2149c754f9

2 years ago[AMDGPU] Fix regression with vectorization limiting
Stanislav Mekhanoshin [Thu, 31 Mar 2022 23:17:01 +0000 (16:17 -0700)]
[AMDGPU] Fix regression with vectorization limiting

D67148 has removed TTI::getNumberOfRegisters(bool Vector) and
started to call TTI::getNumberOfRegisters(unsigned ClassID) from
the LoopVectorize. This has resulted in an unrestricted vectorization
on AMDGPU blowing up register pressure.

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

2 years agoAdapt the ObjC stepping algorithm to deal with "selector-stubs" in clang.
Jim Ingham [Fri, 8 Apr 2022 19:25:53 +0000 (12:25 -0700)]
Adapt the ObjC stepping algorithm to deal with "selector-stubs" in clang.

Clang is adding a feature to ObjC code generation, where instead of calling
objc_msgSend directly with an object & selector, it generates a stub that
gets passed only the object and the stub figures out the selector.

This patch adds support for following that dispatch method into the implementation
function.

2 years ago[randstruct] Remove RandstructTest.cpp from list
Bill Wendling [Sat, 9 Apr 2022 00:41:36 +0000 (17:41 -0700)]
[randstruct] Remove RandstructTest.cpp from list

2 years ago[randstruct] temporarily remove test that's failing
Bill Wendling [Sat, 9 Apr 2022 00:04:22 +0000 (17:04 -0700)]
[randstruct] temporarily remove test that's failing

2 years ago[PowerPC] Adjust `MaxAtomicSizeInBitsSupported` on PPC64
Kai Luo [Fri, 8 Apr 2022 23:42:06 +0000 (23:42 +0000)]
[PowerPC] Adjust `MaxAtomicSizeInBitsSupported` on PPC64

AtomicExpandPass uses this variable to determine emitting libcalls or not. The default value is 1024 and if we don't specify it for PPC64 explicitly, AtomicExpandPass won't emit `__atomic_*` libcalls for those target unable to inline atomic ops and finally the backend emits `__sync_*` libcalls. Thanks @efriedma for pointing it out.

Reviewed By: efriedma

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

2 years agoAdd some function prototypes; NFC
Aaron Ballman [Fri, 8 Apr 2022 23:54:35 +0000 (19:54 -0400)]
Add some function prototypes; NFC

(This file is compiled with -pedantic enabled in some two-stage builds)

2 years agounbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after fa34951fbc9bde75
Nico Weber [Fri, 8 Apr 2022 23:43:37 +0000 (19:43 -0400)]
unbreak Modules/cxx20-export-import.cpp with LLVM_APPEND_VC_REV after fa34951fbc9bde75

See revision b8b7a9dcdcbc for prior art.

2 years agoFix bazel rule for __support_fputil_fma when using header modules.
Jorge Gorbe Moya [Fri, 8 Apr 2022 23:26:21 +0000 (16:26 -0700)]
Fix bazel rule for __support_fputil_fma when using header modules.

Putting __support/FPUtil/x86_64/FMA.h in `hdrs` will trigger a
compilation action for that header, and it will always `#error` out for
non-FMA targets. Move these platform-specific headers that are
conditionally included to `textual_hdrs` instead.

2 years ago[PowerPC] Support 16-byte lock free atomics on pwr8 and up
Kai Luo [Fri, 8 Apr 2022 22:50:45 +0000 (22:50 +0000)]
[PowerPC] Support 16-byte lock free atomics on pwr8 and up

Make 16-byte atomic type aligned to 16-byte on PPC64, thus consistent with GCC. Also enable inlining 16-byte atomics on non-AIX targets on PPC64.

Reviewed By: hubert.reinterpretcast

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

2 years agoTransforms: Fix code duplication between LowerAtomic and AtomicExpand
Matt Arsenault [Wed, 6 Apr 2022 00:22:12 +0000 (20:22 -0400)]
Transforms: Fix code duplication between LowerAtomic and AtomicExpand

2 years ago[randstruct] disable test for Windows for now.
Bill Wendling [Fri, 8 Apr 2022 23:00:15 +0000 (16:00 -0700)]
[randstruct] disable test for Windows for now.

2 years agoNo reason for these not to have prototypes; NFC
Aaron Ballman [Fri, 8 Apr 2022 22:52:06 +0000 (18:52 -0400)]
No reason for these not to have prototypes; NFC

This should speculatively fix build bots:

https://lab.llvm.org/buildbot#builders/19/builds/10294
https://lab.llvm.org/buildbot#builders/37/builds/12289

2 years agoSkip test on earlier clang versions
Adrian Prantl [Fri, 8 Apr 2022 22:40:57 +0000 (15:40 -0700)]
Skip test on earlier clang versions

2 years ago[MSAN] add __b64_pton and __b64_ntop intercepts
Kevin Athey [Fri, 8 Apr 2022 22:00:09 +0000 (15:00 -0700)]
[MSAN] add __b64_pton and __b64_ntop intercepts

Reviewed By: vitalybuka

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

2 years ago[RGT] Use GTEST_SKIP() in more places where we skip a test
Paul Robinson [Fri, 8 Apr 2022 22:18:50 +0000 (15:18 -0700)]
[RGT] Use GTEST_SKIP() in more places where we skip a test

Simply returning will report the test as PASSED when it didn't
really do anything. SKIPPED is the correct result for these.

Found by the Rotten Green Tests project.

2 years ago[clang-tidy] Deal with keyword tokens in preprocessor conditions
Richard [Fri, 8 Apr 2022 00:58:36 +0000 (18:58 -0600)]
[clang-tidy] Deal with keyword tokens in preprocessor conditions

When a "keyword" token like __restrict was present in a macro condition,
modernize-macro-to-enum would assert in non-release builds.  However,
even for a "keyword" token, calling getIdentifierInfo()->getName() would
retrieve the text of the token, which is what we want.  Our intention is
to scan names that appear in conditional expressions in potential enum
clusters and invalidate those clusters if they contain the name.

Also, guard against "raw identifiers" appearing as potential enums.
This shouldn't happen, but it doesn't hurt to generalize the code.

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

Fixes #54775

2 years ago[lldb] XFAIL tests that aren't passing remotely
Jonas Devlieghere [Fri, 8 Apr 2022 20:07:29 +0000 (13:07 -0700)]
[lldb] XFAIL tests that aren't passing remotely

XFAIL a series of tests that are failing remotely.

2 years ago[lldb] Skip more tests that don't make sense to run remotely
Jonas Devlieghere [Fri, 8 Apr 2022 20:07:08 +0000 (13:07 -0700)]
[lldb] Skip more tests that don't make sense to run remotely

Skip another batch of tests that don't really make sense to run
remotely.

2 years ago[randstruct] add expected output for WIN64
Bill Wendling [Fri, 8 Apr 2022 21:41:44 +0000 (14:41 -0700)]
[randstruct] add expected output for WIN64

This is an attempt to fix a test failure on one of the buildbot Windows
machines. It also turns all of the "ASSERT_" macros into "EXPECT_" to
catch all other failures.

Link: https://lab.llvm.org/buildbot/#/builders/216/builds/2647
2 years agoReland "[MTE] Add -fsanitize=memtag* and friends."
Mitch Phillips [Fri, 8 Apr 2022 20:22:27 +0000 (13:22 -0700)]
Reland "[MTE] Add -fsanitize=memtag* and friends."

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

2 years ago[libc][NFC] implement printf parser
Michael Jones [Mon, 4 Apr 2022 18:46:30 +0000 (11:46 -0700)]
[libc][NFC] implement printf parser

This patch adds the sequential mode implementation of the printf parser,
as well as unit tests for it. In addition it adjusts the surrounding
files to accomodate changes in the design found in the implementation
process.

Reviewed By: sivachandra

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

2 years ago[libc++] Add missing 'return 0;' to main() in test
Louis Dionne [Fri, 8 Apr 2022 21:10:58 +0000 (17:10 -0400)]
[libc++] Add missing 'return 0;' to main() in test