platform/upstream/llvm.git
3 years ago[gn build] Port 8b7881a084d0
LLVM GN Syncbot [Sat, 26 Jun 2021 14:20:52 +0000 (14:20 +0000)]
[gn build] Port 8b7881a084d0

3 years ago[clang-format] Add basic support for formatting JSON
mydeveloperday [Sat, 26 Jun 2021 14:20:17 +0000 (15:20 +0100)]
[clang-format] Add basic support for formatting JSON

I find as I develop I'm moving between many different languages C++,C#,JavaScript all the time. As I move between the file types I like to keep `clang-format` as my formatting tool of choice. (hence why I initially added C# support  in {D58404}) I know those other languages have their own tools but I have to learn them all, and I have to work out how to configure them, and they may or may not have integration into my IDE or my source code integration.

I am increasingly finding that I'm editing additional JSON files as part of my daily work and my editor and git commit hooks are just not setup to go and run [[ https://stedolan.github.io/jq/ | jq ]], So I tend to go to  [[ https://jsonformatter.curiousconcept.com/ | JSON Formatter ]] and copy and paste back and forth. To get nicely formatted JSON. This is a painful process and I'd like a new one that causes me much less friction.

This has come up from time to time:

{D10543}
https://stackoverflow.com/questions/35856565/clang-format-a-json-file
https://bugs.llvm.org/show_bug.cgi?id=18699

I would like to stop having to do that and have formatting JSON as a first class clang-format support `Language` (even if it has minimal style settings at present).

This revision adds support for formatting JSON using the inbuilt JSON serialization library of LLVM, With limited control at present only over the indentation level

This adds an additional Language into the .clang-format file to separate the settings from your other supported languages.

Reviewed By: HazardyKnusperkeks

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

3 years ago[clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace
mydeveloperday [Sat, 26 Jun 2021 12:34:07 +0000 (13:34 +0100)]
[clang-format] [PR50702] Lamdba processing does not respect AfterClass and AfterNamespace

https://bugs.llvm.org/show_bug.cgi?id=50702

I believe {D44609} may be too aggressive with brace wrapping rules which doesn't always apply to Lamdbas

The introduction of BeforeLambdaBody and AllowShortLambdasOnASingleLine has impact on brace handling on other block types, which I suspect we didn't see before as people may not be using the BeforeLambdaBody  style

From what I can tell this can be seen by the unit test I change as its not honouring the orginal LLVM brace wrapping style for the `Fct()` function

I added a unit test from PR50702 and have removed some of the code (which has zero impact on the unit test, which kind of suggests its unnecessary), some additional attempt has been made to try and ensure we'll only break on what is actually a LamdbaLBrace

Reviewed By: HazardyKnusperkeks

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

3 years ago[clang-format] PR50525 doesn't handle AlignConsecutiveAssignments correctly in some...
mydeveloperday [Sat, 26 Jun 2021 12:28:34 +0000 (13:28 +0100)]
[clang-format] PR50525 doesn't handle AlignConsecutiveAssignments correctly in some situations

https://bugs.llvm.org/show_bug.cgi?id=50525

AlignConsecutiveAssignments/Declarations cause incorrect alignment in the presence of a DesignatedInitializerPeriod (https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html)

```
static NTSTATUS stg(PLW_STREAM Stream, int identity)
{
     NTSTATUS             status;
     BYTE                 payload[256] = {'l', 'h', 'o', 't', 's', 'e'};
     struct dm_rpc_header header       = {.drh_magic        = DRH_MAGIC,
                                    .drh_op_code      = RPC_OP_ECHO,
                                    .drh_payload_size = sizeof(payload),
                                    .drh_body_size    = sizeof(payload),
                                    .drh_request_id   = 1};
     header.drh_version                = identity;
```

This fix addresses that by ensuring the period isn't ignored

Reviewed By: HazardyKnusperkeks

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

3 years ago[ARM] Regenerate big-endian-vector-caller.ll test checks. NFC
David Green [Sat, 26 Jun 2021 12:21:54 +0000 (13:21 +0100)]
[ARM] Regenerate big-endian-vector-caller.ll test checks. NFC

3 years ago[LV] Adjust trip count based on IsOrdered in widenPHIInstruction (NFC).
Florian Hahn [Sat, 26 Jun 2021 12:11:18 +0000 (13:11 +0100)]
[LV] Adjust trip count based on IsOrdered in widenPHIInstruction (NFC).

Suggested in D104197, avoids the early exit.

3 years ago[gn build] Port aff57ff24aca
LLVM GN Syncbot [Sat, 26 Jun 2021 11:38:00 +0000 (11:38 +0000)]
[gn build] Port aff57ff24aca

3 years ago[JITLink][ELF] Add generic ELFLinkGraphBuilder template.
Lang Hames [Sat, 26 Jun 2021 11:27:14 +0000 (21:27 +1000)]
[JITLink][ELF] Add generic ELFLinkGraphBuilder template.

ELFLinkGraphBuilder<ELFT> will hold generic parsing and LinkGraph-building code
that can be shared between JITLink ELF backends for different architectures.

For now it's just a stub. The plan is to incrementally move functionality down
from ELFLinkGraphBuilder_x86_64 into the new template.

3 years ago[clang][tests] Specify unwindlib in aix-ld tests
Timm Bäder [Fri, 25 Jun 2021 07:32:01 +0000 (09:32 +0200)]
[clang][tests] Specify unwindlib in aix-ld tests

Clang can be configured with a different default unwindlib, for example
gcc. In that case, -lunwind will not be present in the output.

Fix this by explicitly specifying libunwind as the unwindlib.

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

3 years ago[RISCV][NFC] Combine the control flow for different RetOp of interrupt function
Jim Lin [Sat, 26 Jun 2021 09:28:01 +0000 (17:28 +0800)]
[RISCV][NFC] Combine the control flow for different RetOp of interrupt function

Reviewed By: frasercrmck

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

3 years ago[Docs] Minor fixes with language extension docs
Saurabh Jha [Sat, 26 Jun 2021 09:07:14 +0000 (10:07 +0100)]
[Docs] Minor fixes with language extension docs

There were some issues in the patch https://reviews.llvm.org/D104198. I also forgot to address one comment. This patch addresses these.

Reviewed By: xgupta

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

3 years ago[RISCV] Add DAG combine to detect opportunities to replace (i64 (any_extend (i32...
Craig Topper [Fri, 25 Jun 2021 19:58:31 +0000 (12:58 -0700)]
[RISCV] Add DAG combine to detect opportunities to replace (i64 (any_extend (i32 X)) with sign_extend.

If type legalization is going to insert a sign_extend for other users
of X and we can fold the sign_extend into ADDW/MULW/SUBW, it is
better to replace the ANY_EXTEND so we don't end up with a separate
ADD/MUL/SUB instruction for the users of the ANY_EXTEND.

I'm only handling setcc uses right now, but there are other
instructions that force sign_extends like ashr.

There are probably other *W instructions we could use in addition
to ADDW/SUBW/MULW.

My motivating case was a loop terminating compare and a phi use
as seen in the new test file.

Reviewed By: asb

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

3 years ago[MLIR][Sparse] Move `buildLattices` into Merger
Gus Smith [Fri, 25 Jun 2021 23:37:53 +0000 (23:37 +0000)]
[MLIR][Sparse] Move `buildLattices` into Merger

This allows us to use `buildLattices` in the `Merger` unittests.

Reviewed By: aartbik

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

3 years ago[ms] [llvm-ml] Disable C-style comments
Eric Astor [Sat, 26 Jun 2021 03:09:13 +0000 (23:09 -0400)]
[ms] [llvm-ml] Disable C-style comments

3 years ago[X86] Selecting fld0 for undefined value in fast ISEL.
Luo, Yuanke [Tue, 22 Jun 2021 01:48:10 +0000 (09:48 +0800)]
[X86] Selecting fld0 for undefined value in fast ISEL.

When set opt-bisect-limit to some value that is less than ISel pass
in command line and CurBisectNum expired, "DAG to DAG" pass lower
its opt level to O0. However "processimpdefs" and "X86 FP Stackifier"
is not stopped due to the CurBisectNum expiration. So undefined fp0
is generated. This cause crash in the "X86 FP Stackifier" pass,
because Stackifier doesn't expect any undefined fp value.

Here is the scenario that cause compiler crash.

  successors: %bb.26
  liveins: $r14
    ST_FPrr $st0, implicit-def $fpsw, implicit $fpcw
    renamable $rdi = MOV64ri @.str.3.16422
    renamable $rdx = LEA64r %stack.6, 1, $noreg, 0, $noreg
    ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def dead
    $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
    dead $esi = MOV32r0 implicit-def dead $eflags, implicit-def $rsi
    CALL64pcrel32 @foo, implicit $rsp, implicit $ssp, implicit $rdi,
    implicit $rsi, implicit $rdx, implicit-def dead $fp0
    renamable $xmm0 = MOVSDrm_alt %stack.10, 1, $noreg, 0, $noreg :: (load 8
    from %stack.10)
    ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def dead $eflags,
    implicit-def $ssp, implicit $rsp, implicit $ssp
    renamable $fp2 = CHS_Fp80 killed undef renamable $fp0, implicit-def
    $fpsw
    JMP_1 %bb.26
The CALL64pcrel32 mark fp0 dead, so llvm free the stack slot for fp0
and the stack become empty. In the late instruction CHS_Fp80, it use
undefined register fp0, the original code assume there must be a stack
slot for the src register (fp0) without respecting it is undefined,
so llvm report error.

We have some discussion in https://reviews.llvm.org/D104440 and we
decide to fix it in fast ISel. The fix is to lower undefined fp value to
zero value, so that it release the burden of "X86 FP Stackifier" pass.
Thank Craig for the suggestion and the initial patch to fix it.

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

3 years agoDisable ReplaceLDS pass, patch up tests to match
Jon Chesterfield [Sat, 26 Jun 2021 00:36:41 +0000 (01:36 +0100)]
Disable ReplaceLDS pass, patch up tests to match

Most tests passed with an extra argument to explicitly enable the pass.
One does not, deleted it as part of this change. I can't see why the codegen
would be different between default on and default off but switched on. It
can be retrieved from the project history.

This would be a revert, but git revert was not clean. Disabling the pass
and leaving it in tree is less likely to cause breakage elsewhere than
patching up the git revert conflicts on unfamiliar code. It'll be landed
without review, as @hsmhsm is believed unavailable at present.

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

3 years ago[DFSan] Change shadow and origin memory layouts to match MSan.
Andrew Browne [Fri, 25 Jun 2021 05:16:36 +0000 (22:16 -0700)]
[DFSan] Change shadow and origin memory layouts to match MSan.

Previously on x86_64:

  +--------------------+ 0x800000000000 (top of memory)
  | application memory |
  +--------------------+ 0x700000008000 (kAppAddr)
  |                    |
  |       unused       |
  |                    |
  +--------------------+ 0x300000000000 (kUnusedAddr)
  |       origin       |
  +--------------------+ 0x200000008000 (kOriginAddr)
  |       unused       |
  +--------------------+ 0x200000000000
  |   shadow memory    |
  +--------------------+ 0x100000008000 (kShadowAddr)
  |       unused       |
  +--------------------+ 0x000000010000
  | reserved by kernel |
  +--------------------+ 0x000000000000

  MEM_TO_SHADOW(mem) = mem & ~0x600000000000
  SHADOW_TO_ORIGIN(shadow) = kOriginAddr - kShadowAddr + shadow

Now for x86_64:

  +--------------------+ 0x800000000000 (top of memory)
  |    application 3   |
  +--------------------+ 0x700000000000
  |      invalid       |
  +--------------------+ 0x610000000000
  |      origin 1      |
  +--------------------+ 0x600000000000
  |    application 2   |
  +--------------------+ 0x510000000000
  |      shadow 1      |
  +--------------------+ 0x500000000000
  |      invalid       |
  +--------------------+ 0x400000000000
  |      origin 3      |
  +--------------------+ 0x300000000000
  |      shadow 3      |
  +--------------------+ 0x200000000000
  |      origin 2      |
  +--------------------+ 0x110000000000
  |      invalid       |
  +--------------------+ 0x100000000000
  |      shadow 2      |
  +--------------------+ 0x010000000000
  |    application 1   |
  +--------------------+ 0x000000000000

  MEM_TO_SHADOW(mem) = mem ^ 0x500000000000
  SHADOW_TO_ORIGIN(shadow) = shadow + 0x100000000000

Reviewed By: stephan.yichao.zhao, gbalats

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

3 years ago[libc] Use __builtin_ctzll instead of __builtin_ctzl in elements_x86.h.
Siva Chandra Reddy [Fri, 25 Jun 2021 05:43:47 +0000 (05:43 +0000)]
[libc] Use __builtin_ctzll instead of __builtin_ctzl in elements_x86.h.

__builtin_ctzl takes an unsigned long argument which need not be 64-bit
long on all platforms. Using __builtin_ctzll, which takes an unsigned
long long argument, ensures that 64-bit values will be handled on a
wider range of platforms.

Without this change, the test corresponding to M512 fails in Windows.

Reviewed By: gchatelet

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

3 years agoRevert "[InstCombine] Make indexed compare fold opaque ptr compatible"
Nikita Popov [Fri, 25 Jun 2021 22:32:59 +0000 (00:32 +0200)]
Revert "[InstCombine] Make indexed compare fold opaque ptr compatible"

This reverts commit 5cb20ef8a235c2027489a196bba27630ca21a00b.

Assertion failures with this patch were reported on
https://reviews.llvm.org/rG5cb20ef8a235, revert for now.

3 years agoOpaquePtr: Reject 'ptr*' again when parsing textual IR
Duncan P. N. Exon Smith [Fri, 25 Jun 2021 18:53:27 +0000 (11:53 -0700)]
OpaquePtr: Reject 'ptr*' again when parsing textual IR

Bring back the testcase dropped in
1e6303e60ca5af4fbe7ca728572fd65666a98271 and get it passing by checking
explicitly for `ptr*` in LLParser. Uses `Type::isOpaquePointerTy()` from
ad4bb8280952c2cacf497e30560ee94c119b36e0.

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

3 years ago[mlir][sparse] add print methods to Merger (for debugging)
Aart Bik [Fri, 25 Jun 2021 19:02:08 +0000 (12:02 -0700)]
[mlir][sparse] add print methods to Merger (for debugging)

Reviewed By: gussmith23

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

3 years ago[clang] Stop providing builtin overload candidate for relational function pointer...
Matheus Izvekov [Tue, 22 Jun 2021 01:48:51 +0000 (03:48 +0200)]
[clang] Stop providing builtin overload candidate for relational function pointer comparisons

Word on the grapevine was that the committee had some discussion that
ended with unanimous agreement on eliminating relational function pointer comparisons.

We wanted to be bold and just ban all of them cold turkey.
But then we chickened out at the last second and are going for
eliminating just the spaceship overload candidate instead, for now.

See D104680 for reference.

This should be fine and "safe", because the only possible semantic change this
would cause is that overload resolution could possibly be ambiguous if
there was another viable candidate equally as good.

But to save face a little we are going to:
* Issue an "error" for three-way comparisons on function pointers.
  But all this is doing really is changing one vague error message,
  from an "invalid operands to binary expression" into an
  "ordered comparison of function pointers", which sounds more like we mean business.
* Otherwise "warn" that comparing function pointers like that is totally
  not cool (unless we are told to keep quiet about this).

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

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

3 years ago[lldb] Use the non-locking variant of objc_copyRealizedClassList
Jonas Devlieghere [Fri, 25 Jun 2021 19:57:36 +0000 (12:57 -0700)]
[lldb] Use the non-locking variant of objc_copyRealizedClassList

Avoid standing the Objective-C runtime lock by calling
objc_copyRealizedClassList_nolock instead of objc_copyRealizedClassList.

We already guarantee that no other threads can run while we're running
this utility expression, similar to when we parse the data ourselves
from the gdb_objc_realized_classes struct.

Worst case this will crash if the list is getting edited, which won't do
any harm and we'll just try again later.

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

3 years agoAdd support for the NSMutableDictionary variant: "__NSFrozenDictionaryM"
Jim Ingham [Fri, 25 Jun 2021 01:58:21 +0000 (18:58 -0700)]
Add support for the NSMutableDictionary variant: "__NSFrozenDictionaryM"

This was an oversight of the commit: bb93483c119b92c1ec2b7a58505e21b9dce6a333 that
added support for the Frozen variants.  Also added a test case for the way that
currently produces one of these variants (a copy).

3 years ago[NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion
Eli Friedman [Fri, 25 Jun 2021 21:43:13 +0000 (14:43 -0700)]
[NFC] Prefer ConstantRange::makeExactICmpRegion over makeAllowedICmpRegion

The implementation is identical, but it makes the semantics a bit more
obvious.

3 years ago[ms] [llvm-ml] Add support for ALIGN, EVEN, and ORG directives
Eric Astor [Fri, 25 Jun 2021 21:19:39 +0000 (17:19 -0400)]
[ms] [llvm-ml] Add support for ALIGN, EVEN, and ORG directives

Match ML.EXE's behavior for ALIGN, EVEN, and ORG directives both at file level and in STRUCTs.

We currently reject negative offsets passed to ORG inside STRUCTs (in ML.EXE and ML64.EXE, they wrap around as for an unsigned 32-bit integer).

Also, if a STRUCT is declared using an ORG directive, no value of that type can be defined.

Reviewed By: thakis

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

3 years agoChange PathMappingList::RemapPath to return an optional result (NFC)
Adrian Prantl [Fri, 25 Jun 2021 20:49:01 +0000 (13:49 -0700)]
Change PathMappingList::RemapPath to return an optional result (NFC)

This is an NFC modernization refactoring that replaces the combination
of a bool return + reference argument, with an Optional return value.

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

3 years ago[SimplifyLibCalls] Fix memchr opt to use CreateLogicalAnd
Juneyoung Lee [Fri, 25 Jun 2021 08:56:10 +0000 (17:56 +0900)]
[SimplifyLibCalls] Fix memchr opt to use CreateLogicalAnd

This fixes a bug at LibCallSimplifier::optimizeMemChr which does the following transformation:

```
// memchr("\r\n", C, 2) != nullptr -> (1 << C & ((1 << '\r') | (1 << '\n')))
// != 0
//   after bounds check.
```

As written above, a bounds check on C (whether it is less than integer bitwidth) is done before doing `1 << C` otherwise 1 << C will overflow.
If the bounds check is false, the result of (1 << C & ...) must not be used at all, otherwise the result of shift (which is poison) will contaminate the whole results.
A correct way to encode this is `select i1 (bounds check), (1 << C & ...), false`  because select does not allow the unused operand to contaminate the result.
However, this optimization was introducing `and (bounds check), (1 << C & ...)` which cannot do that.

The bug was found from compilation of this C++ code: https://reviews.llvm.org/rG2fd3037ac615#1007197

Reviewed By: nikic

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

3 years ago[OpenMP] Change OpenMPOpt to check openmp metadata
Joseph Huber [Thu, 24 Jun 2021 21:11:54 +0000 (17:11 -0400)]
[OpenMP] Change OpenMPOpt to check openmp metadata

The metadata added in D102361 introduces a module flag that we can check
to determine if the module was compiled with `-fopenmp` enables. We can
now check for the precense of this instead of scanning the call graph
for OpenMP runtime functions.

Depends on D102361

Reviewed By: jdoerfert

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

3 years ago[OpenMP] Add Module metadata for OpenMP compilation
Joseph Huber [Thu, 24 Jun 2021 18:39:12 +0000 (14:39 -0400)]
[OpenMP] Add Module metadata for OpenMP compilation

This patch adds a module level metadata flag indicating that the module
was compiled with the `-fopenmp` flag. This will make it easier for
passes like OpenMPOpt to determine if it should be run.

Reviewed By: jdoerfert

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

3 years ago[PowerPC] Disable combine 64-bit bswap(load) without LDBRX
Nemanja Ivanovic [Fri, 25 Jun 2021 20:09:02 +0000 (15:09 -0500)]
[PowerPC] Disable combine 64-bit bswap(load) without LDBRX

This causes failures on the big endian bootstrap bot.
Disabling this combine temporarily until I can get a proper fix.

3 years ago[analyzer] Fix assertion failure on code with transparent unions
Valeriy Savchenko [Tue, 22 Jun 2021 13:04:15 +0000 (16:04 +0300)]
[analyzer] Fix assertion failure on code with transparent unions

rdar://76948312

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

3 years ago[llvm-rc] Don't rewrite the arch in the default triple unless necessary
Martin Storsjö [Fri, 18 Jun 2021 19:59:58 +0000 (22:59 +0300)]
[llvm-rc] Don't rewrite the arch in the default triple unless necessary

When the default target arch isn't one that is supported as a
windows target, we want to set a suitable architecture (so that
Clang tests that run plain 'llvm-rc' succeed checks for e.g.
"#ifdef _WIN32" even for llvm builds that default to e.g. ppc64).

But if the default target architecture is usable, don't rewrite it.
(Rewriting it, by e.g. "T.setArch(T.getArch())", normalizes the
spelling of the architecture, e.g. changing i686 to i386. Such a
change can make clang unable to find the right sysroot.)

This can't, unfortunately, practically be tested very well because
it is entirely dependent on the default triple of the llvm build.

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

3 years ago[ELF] --sysroot: change sysrooted script to not fall back for an absolute path
Fangrui Song [Fri, 25 Jun 2021 19:52:39 +0000 (12:52 -0700)]
[ELF] --sysroot: change sysrooted script to not fall back for an absolute path

Modify the D13209 logic: for a script inside the sysroot, if an absolute path
does not exist, report an error instead of falling back to the path without the
sysroot prefix.

This matches GNU ld, which makes sense to me: we don't want to find an arbitrary
file in the host.

Reviewed By: ikudrin

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

3 years ago[SystemZ] Add support for .reloc assembler directive
Ulrich Weigand [Fri, 25 Jun 2021 19:49:07 +0000 (21:49 +0200)]
[SystemZ] Add support for .reloc assembler directive

Add support for the .reloc directive along the lines of
other back-ends.

This fixes a regression after https://reviews.llvm.org/D104080
was merged, since that patch presupposed support for .reloc.

3 years ago[Coroutines] Define __coro_frame_ty in function scope
Hongtao Yu [Fri, 25 Jun 2021 18:35:02 +0000 (11:35 -0700)]
[Coroutines] Define __coro_frame_ty in function scope

Types should be defined in function scope instead of a local lexical scope. Field types should be defined inside in its parent type scope.

We were seeing a type defined in a local scope causing trouble to the dwarf emitter where a context is required to be a funciton scope, a namespace or a global scope.

Reviewed By: aprantl

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

3 years ago[mlir:Async] Submit accidentally omitted changes
Eugene Zhulenev [Fri, 25 Jun 2021 19:14:51 +0000 (12:14 -0700)]
[mlir:Async] Submit accidentally omitted changes

Accidentally pushed old branches that did not include all the changes discussed in the PRs.

https://reviews.llvm.org/rGd43b23608ad664f02f56e965ca78916bde220950
https://reviews.llvm.org/rG86ad0af87054c3cccd68d32e103a6f1f6c6194c7

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

3 years ago[OpaquePtr] Enumerate GlobalAlias value type
Nikita Popov [Fri, 25 Jun 2021 19:19:08 +0000 (21:19 +0200)]
[OpaquePtr] Enumerate GlobalAlias value type

The type is no longer implicitly enumerated through the pointer
type.

3 years ago[libc++] Enable the rvalue overloads of operator<< and operator>> even in C++03.
Arthur O'Dwyer [Tue, 15 Jun 2021 16:57:05 +0000 (12:57 -0400)]
[libc++] Enable the rvalue overloads of operator<< and operator>> even in C++03.

Continuing to eliminate no-longer-needed uses of _LIBCPP_CXX03_LANG.

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

3 years ago[IR] Add Type::isOpaquePointerTy() helper (NFC)
Nikita Popov [Fri, 25 Jun 2021 18:55:09 +0000 (20:55 +0200)]
[IR] Add Type::isOpaquePointerTy() helper (NFC)

Shortcut to check for opaque pointers without a cast to PointerType.

3 years ago[flang] Fix generic/specific procedure confusion
peter klausler [Fri, 25 Jun 2021 17:35:03 +0000 (10:35 -0700)]
[flang] Fix generic/specific procedure confusion

A recent change that extended semantic analysis for actual arguments
that associate with procedure dummy arguments exposed some bugs in
regression test suites due to points of confusion in symbol table
handling in situations where a generic interface contains a specific
procedure of the same name.  When passing that name as an actual
argument, for example, it's necessary to take this possibility into
account because the symbol for the generic interface shadows the
symbol of the same name for the specific procedure, which is
what needs to be checked.  So add a small utility that bypasses
the symbol for a generic interface in this case, and use it
where needed.

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

3 years ago[DAG] Fold neg(splat(neg(x)) -> splat(x)
David Green [Fri, 25 Jun 2021 18:53:29 +0000 (19:53 +0100)]
[DAG] Fold neg(splat(neg(x)) -> splat(x)

This add as a fold of sub(0, splat(sub(0, x))) -> splat(x). This can
come up in the lowering of right shifts under AArch64, where we generate
a shift left of a negated number.

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

3 years ago[X86] Simplify part of the isel for X86ISD::FCMP/STRICT_FCMP/STRICT_FCMPS.
Craig Topper [Fri, 25 Jun 2021 17:58:23 +0000 (10:58 -0700)]
[X86] Simplify part of the isel for X86ISD::FCMP/STRICT_FCMP/STRICT_FCMPS.

We don't need to have the compare output a value and then copy it
to FPSW for use by FNSTSW. Instead we can just have the compare
output Glue and glue the FNSTSW to it. InstrEmitter effectively
performed this optimization when emitting the Machine IR. Doing
it directly simplifies the codes and reduces the work in
InstrEmitter. There's no change in the machine IR at the end of
isel before and after this change.

3 years ago[UpdateCCTestChecks] Fix new test from 9eaf0d120d32
Joel E. Denny [Fri, 25 Jun 2021 18:06:52 +0000 (14:06 -0400)]
[UpdateCCTestChecks] Fix new test from 9eaf0d120d32

`clang/test/utils/update_cc_test_checks/check-globals.test` from
9eaf0d120d32 broke at:

* <https://lab.llvm.org/buildbot/#/builders/110/builds/4415>
* <https://lab.llvm.org/buildbot/#/builders/5/builds/9076>

The problem is non-deterministic test order because the
`.lit_test_times.txt` from one run of a sample test suite affects the
other.

3 years ago[AArch64] Extra negated shift tests. NFC
David Green [Fri, 25 Jun 2021 18:17:31 +0000 (19:17 +0100)]
[AArch64] Extra negated shift tests. NFC

3 years ago[libomptarget][amdgpu] Build openmp for two more targets
Jon Chesterfield [Fri, 25 Jun 2021 18:02:02 +0000 (19:02 +0100)]
[libomptarget][amdgpu] Build openmp for two more targets

[libomptarget][amdgpu] Build openmp for two more targets

The 4800U APU is a gfx902 and the MI100 accelerator is a gfx908.
Both numbers are listed in ROCT topology.c

Reviewed By: jhuber6

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

3 years ago[clang] Make fewer assumptions about path to lit.site.cfg after 9eaf0d120d32
Nico Weber [Fri, 25 Jun 2021 18:01:21 +0000 (14:01 -0400)]
[clang] Make fewer assumptions about path to lit.site.cfg after 9eaf0d120d32

3 years ago[test] Add coverage for existing overflow rule with uadd.with.overflow
Philip Reames [Fri, 25 Jun 2021 17:44:53 +0000 (10:44 -0700)]
[test] Add coverage for existing overflow rule with uadd.with.overflow

3 years ago[LV] Doxygenize VectorizationFactor member comments (NFC).
Florian Hahn [Fri, 25 Jun 2021 14:57:25 +0000 (15:57 +0100)]
[LV] Doxygenize VectorizationFactor member comments (NFC).

Minor cleanup for follow-up patch.

3 years ago[mlir:Async] Implement recursive async work splitting for scf.parallel operation...
Eugene Zhulenev [Thu, 24 Jun 2021 12:27:42 +0000 (05:27 -0700)]
[mlir:Async] Implement recursive async work splitting for scf.parallel operation (async-parallel-for pass)

Depends On D104780

Recursive work splitting instead of sequential async tasks submission gives ~20%-30% speedup in microbenchmarks.

Algorithm outline:
1. Collapse scf.parallel dimensions into a single dimension
2. Compute the block size for the parallel operations from the 1d problem size
3. Launch parallel tasks
4. Each parallel task reconstructs its own bounds in the original multi-dimensional iteration space
5. Each parallel task computes the original parallel operation body using scf.for loop nest

Reviewed By: herhut

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

3 years ago[mlir:Async] Add the size parameter to the async.group
Eugene Zhulenev [Wed, 23 Jun 2021 13:24:09 +0000 (06:24 -0700)]
[mlir:Async] Add the size parameter to the async.group

Specify the `!async.group` size (the number of tokens that will be added to it) at construction time. `async.await_all` operation can potentially race with `async.execute` operations that keep updating the group, for this reason it is required to know upfront how many tokens will be added to the group.

Reviewed By: ftynse, herhut

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

3 years ago[instcombine] Fold overflow check using umulo to comparison
Philip Reames [Fri, 25 Jun 2021 17:24:10 +0000 (10:24 -0700)]
[instcombine] Fold overflow check using umulo to comparison

If we have a umul.with.overflow where the multiply result is not used and one of the operands is a constant, we can perform the overflow check cheaper with a comparison then by performing the multiply and extracting the overflow flag.

(Noticed when looking at the conditions SCEV emits for overflow checks.)

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

3 years ago[UpdateCCTestChecks] Support --check-globals
Joel E. Denny [Fri, 25 Jun 2021 16:40:04 +0000 (12:40 -0400)]
[UpdateCCTestChecks] Support --check-globals

This option is already supported by update_test_checks.py, but it can
also be useful in update_cc_test_checks.py.  For example, I'd like to
use it in OpenMP offload codegen tests to check global variables like
`.offload_maptypes*`.

Reviewed By: jdoerfert, arichardson, ggeorgakoudis

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

3 years ago[test][instcombine] Add test cases for all x.with.overflow overflow checks
Philip Reames [Thu, 24 Jun 2021 01:50:00 +0000 (18:50 -0700)]
[test][instcombine] Add test cases for all x.with.overflow overflow checks

For each of the x.with.overflow variants, if only the overflow bit is consumed, we can generate a direct overflow comparison.  This precommits tests for each of the variants and tries to cover interesting cornercases.

3 years ago[mlir][memref] Introduce UnrankedMemRefOf to tablegen definitions
Stephan Herhut [Fri, 25 Jun 2021 10:44:22 +0000 (12:44 +0200)]
[mlir][memref] Introduce UnrankedMemRefOf to tablegen definitions

This enables specifying operations that only support some element types for
unranked memrefs.

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

3 years ago[ModuloSchedule] Pass loop block explicitly to kernel rewriter.
Hendrik Greving [Wed, 23 Jun 2021 19:32:04 +0000 (12:32 -0700)]
[ModuloSchedule] Pass loop block explicitly to kernel rewriter.

This change is NFC upstream. We pass in the loop's block to the kernel
rewriter explicitly, instead of assuming it's the loop's top block. This
change is made for downstream targets where this assumption doesn't hold.

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

3 years ago[Coroutines] Remove all legacy test command
Xun Li [Fri, 25 Jun 2021 16:46:55 +0000 (09:46 -0700)]
[Coroutines] Remove all legacy test command

With new pm becomes the default, the old-style test command becomes exactly the same as the new test command, i.e. the two commands are now redundant.
We should just delete the old command. (unless someone wants to add enable-new-pm=0 to all old commands.

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

3 years agoRevert "[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize."
Sander de Smalen [Fri, 25 Jun 2021 16:36:44 +0000 (17:36 +0100)]
Revert "[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize."

This patch seems to be causing build errors, reverting it for now.

This reverts commit aeab9d9570ac8cb554aff6e1af24a471fdf5b4e5.

3 years ago[OpaquePtr] Allow globals with opaque pointer value type
Nikita Popov [Fri, 25 Jun 2021 09:26:15 +0000 (11:26 +0200)]
[OpaquePtr] Allow globals with opaque pointer value type

Do this by making opaque pointers a valid pointer element type,
for which we implicitly create an opaque pointer (moving the logic
from getPointerTo into PointerType::get).

We'll never create something like a "pointer to opaque pointer",
but accept it in the API, because a lot of code reasonably assumes
that you can create a pointer to pointer type.

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

3 years ago[lldb-vscode] Make extension contribute breakpoints use new package.json schema
Chris Bond [Fri, 25 Jun 2021 16:15:04 +0000 (18:15 +0200)]
[lldb-vscode] Make extension contribute breakpoints use new package.json schema

See https://code.visualstudio.com/updates/v1_42#_implement-a-debug-adapter-inside-an-extension

Reviewed By: clayborg

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

3 years ago[Analysis] use better version of getLibFunc to check for alloc/free calls
Sanjay Patel [Fri, 25 Jun 2021 15:36:28 +0000 (11:36 -0400)]
[Analysis] use better version of getLibFunc to check for alloc/free calls

There's no reason to use the weaker name-only analysis when we
have a function prototype to check (in fact, we probably should
not even have that name-only function exposed for general use,
but removing it requires auditing all of the callers).

The version of getLibFunc that takes a Function argument also
does some prototype checking to make sure the arguments/return
type match the expected signature of a real library call.

This is NFC-intended because the code in MemoryBuiltins does its
own function signature checking. For now, that means there may
be some redundancy in the checking, but that should not be above
the noise for compile-time. Ideally, we can move the checks to
a single location.

There's still a hole in the logic that allows the example in
https://llvm.org/PR50846 to cause a compiler crash.

3 years ago[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize.
Sander de Smalen [Fri, 25 Jun 2021 14:55:03 +0000 (15:55 +0100)]
[GlobalISel] NFC: Have LLT::getSizeInBits/Bytes return a TypeSize.

To reflect that the size may be scalable, a TypeSize is returned
instead of an unsigned. In places where the result is used,
it currently relies on an implicit cast of TypeSize -> uint64_t,
which asserts that the type is not scalable.

This patch is NFC for fixed-width vectors.

Reviewed By: aemerson

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

3 years ago[AMDGPU] Removed unused Predicate HasOffset3fBug. NFC.
Jay Foad [Fri, 25 Jun 2021 15:57:34 +0000 (16:57 +0100)]
[AMDGPU] Removed unused Predicate HasOffset3fBug. NFC.

The predicate definition didn't make sense anyway because it was defined
as being the opposite of what the name suggests.

3 years ago[Hexagon] Convert getTypeAlignment to return Align
Krzysztof Parzyszek [Fri, 25 Jun 2021 15:22:01 +0000 (10:22 -0500)]
[Hexagon] Convert getTypeAlignment to return Align

Plus some minor related changes of the same nature.

3 years ago[flang][unittest] Add a missing dependency
Andrzej Warzynski [Fri, 25 Jun 2021 15:27:36 +0000 (16:27 +0100)]
[flang][unittest] Add a missing dependency

In https://reviews.llvm.org/D103612, a definition of an instance of
`Fortran::parser::AnalyzedObjectsAsFortran` was moved (that object is
used in unparsing). That, in turn, introduced a dependency of the unit
tests on the `FortranEvaluate` library, which defines
`AnalyzedObjectsAsFortran`.

That dependency was missed in D103612 and has caused shared-library
builds to fail. I'm submitting this without a review, as it's rather
straightforward omission.

3 years ago[libc++][NFC] Rename include guard.
Mark de Wever [Fri, 25 Jun 2021 15:34:30 +0000 (17:34 +0200)]
[libc++][NFC] Rename include guard.

3 years ago[GlobalISel] NFC: Change LLT::changeNumElements to LLT::changeElementCount.
Sander de Smalen [Fri, 25 Jun 2021 10:27:41 +0000 (11:27 +0100)]
[GlobalISel] NFC: Change LLT::changeNumElements to LLT::changeElementCount.

Reviewed By: aemerson

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

3 years ago[clangd] Introduce a log-prefix flag to remote-index-server
Kadir Cetinkaya [Thu, 24 Jun 2021 09:38:23 +0000 (11:38 +0200)]
[clangd] Introduce a log-prefix flag to remote-index-server

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

3 years ago[clangd] Call malloc_trim in clangd-index-server periodically
Kadir Cetinkaya [Thu, 24 Jun 2021 06:18:40 +0000 (08:18 +0200)]
[clangd] Call malloc_trim in clangd-index-server periodically

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

3 years ago[clang] Fix build failure due to _S
Yaxun (Sam) Liu [Fri, 25 Jun 2021 14:10:27 +0000 (10:10 -0400)]
[clang] Fix build failure due to _S

_S is a reserved identifier in <ctype.h> on Solaris.

3 years ago[OpenCL] Do not include default header for preprocessor output as input
Yaxun (Sam) Liu [Wed, 23 Jun 2021 17:54:03 +0000 (13:54 -0400)]
[OpenCL] Do not include default header for preprocessor output as input

When clang driver is used with -save-temps to compile OpenCL program,
clang driver first launches clang -cc1 -E to generate preprocessor expansion output,
then launches clang -cc1 with the generated preprocessor expansion output as input
to generate LLVM IR.

Currently clang by default passes "-finclude-default-header" "-fdeclare-opencl-builtins"
in both steps, which causes default header included again in the second step, which
causes error.

This patch let clang not to include default header when input type is preprocessor expansion
output, which fixes the issue.

Reviewed by: Anastasia Stulova

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

3 years ago[LV] Reflow comment for VectorizationCostTy (NFC).
Florian Hahn [Fri, 25 Jun 2021 12:55:08 +0000 (13:55 +0100)]
[LV] Reflow comment for VectorizationCostTy (NFC).

3 years ago[flang][driver] Add `-fno-analyzed-objects-for-unparse`
Andrzej Warzynski [Fri, 4 Jun 2021 14:25:58 +0000 (15:25 +0100)]
[flang][driver] Add `-fno-analyzed-objects-for-unparse`

This patch adds a new option for the new Flang driver:
`-fno-analyzed-objects-for-unparse`. The semantics are similar to
`-funparse-typed-exprs-to-f18-fc` from `f18`. For consistency, the
latter is replaced with `-fno-analyzed-objects-for-unparse`.

The new option controls the behaviour of the unparser (i.e. the action
corresponding to `-fdebug-unparse`). The default behaviour is to use the
analyzed objects when unparsing. The new flag can be used to turn this
off, so that the original parse-tree objects are used. The analyzed
objects are generated during the semantic checks [1].

This patch also updates the semantics of
`-fno-analyzed-objects-for-unparse`/`-funparse-typed-exprs-to-f18-fc`
in `f18`, so that this flag is always taken into account when `Unparse`
is used (this way the semantics in `f18` and `flang-new` are identical).

The added test file is based on example from Peter Steinfeld.

[1]
https://github.com/llvm/llvm-project/blob/main/flang/docs/Semantics.md

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

3 years ago[NFC] remove unreferenced function ResolveIPV4HostName
serge-sans-paille [Fri, 25 Jun 2021 08:02:33 +0000 (10:02 +0200)]
[NFC] remove unreferenced function ResolveIPV4HostName

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

3 years ago[OpenMP][NFC] Drop unused headers from amdgpu plugin
Jon Chesterfield [Fri, 25 Jun 2021 11:08:56 +0000 (12:08 +0100)]
[OpenMP][NFC] Drop unused headers from amdgpu plugin

3 years ago[OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C
Stuart Brady [Wed, 23 Jun 2021 13:21:15 +0000 (14:21 +0100)]
[OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C

Note regarding C++ for OpenCL:

   When compiling C++ for OpenCL, DW_LANG_C_plus_plus* is emitted.

   There is no DWARF language code defined for C++ for OpenCL as of yet,
   but DWARF issue 210514.1 has been raised to request one.

   In the mean time, continuing to emit DW_LANG_C_plus_plus* for C++ for
   OpenCL allows the potential to distinguish between C++ for OpenCL and
   OpenCL C in !DICompileUnit nodes, whereas using DW_LANG_OpenCL for
   C++ for OpenCL would prevent this.

   This change therefore leaves C++ for OpenCL as-is.

Reviewed By: shchenz, Anastasia

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

3 years ago[GlobalISel] NFC: Change LLT::scalarOrVector to take ElementCount.
Sander de Smalen [Fri, 25 Jun 2021 07:25:41 +0000 (08:25 +0100)]
[GlobalISel] NFC: Change LLT::scalarOrVector to take ElementCount.

Reviewed By: aemerson

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

3 years ago[lldb] Re-enable GDB server client memory tag read tests
David Spickett [Fri, 25 Jun 2021 09:57:46 +0000 (09:57 +0000)]
[lldb] Re-enable GDB server client memory tag read tests

These were disabled in 473a3a773ea565612e836ae6c2093178c5a9eb72
because they failed on 32 bit platforms. (Arm for sure but I assume
any 32 bit)

This was due to the printf formatter used. These assumed
that types like uint64_t/size_t would be certain size/type and
that changes on 32 bit.

Instead use "z" to print the size_t and PRI<...> formatters
for the addr_t (always uint64_t) and the int32_t.

3 years ago[SLP][AArch64] Precommit test for D103629, checking <4 x i8> loads. NFC.
Sjoerd Meijer [Thu, 3 Jun 2021 16:04:56 +0000 (17:04 +0100)]
[SLP][AArch64] Precommit test for D103629, checking <4 x i8> loads. NFC.

3 years ago[Analyzer][solver] Fix crashes during symbol simplification
Gabor Marton [Wed, 23 Jun 2021 14:25:49 +0000 (16:25 +0200)]
[Analyzer][solver] Fix crashes during symbol simplification

Consider the code
```
  void f(int a0, int b0, int c)
  {
      int a1 = a0 - b0;
      int b1 = (unsigned)a1 + c;
      if (c == 0) {
          int d = 7L / b1;
      }
  }
```
At the point of divisiion by `b1` that is considered to be non-zero,
which results in a new constraint for `$a0 - $b0 + $c`. The type
of this sym is unsigned, however, the simplified sym is `$a0 -
$b0` and its type is signed. This is probably the result of the
inherent improper handling of casts. Anyway, Range assignment
for constraints use this type information. Therefore, we must
make sure that first we simplify the symbol and only then we
assign the range.

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

3 years ago[lldb] Skip TestDataFormatterSynthVal.py with GCC as the test compiler
Raphael Isemann [Fri, 25 Jun 2021 09:48:12 +0000 (11:48 +0200)]
[lldb] Skip TestDataFormatterSynthVal.py with GCC as the test compiler

3 years ago[lldb] Skip libstdc++ tests failing with GCC
Raphael Isemann [Fri, 25 Jun 2021 09:45:57 +0000 (11:45 +0200)]
[lldb] Skip libstdc++ tests failing with GCC

Tracked in llvm.org/pr50861

These tests fail with all GCC versions I tested (8.5, 9.4, 10.3, 11.1).

3 years ago[lldb] Skip tests failing with GCC due to LLDB not being able to call constructors
Raphael Isemann [Thu, 24 Jun 2021 15:21:12 +0000 (17:21 +0200)]
[lldb] Skip tests failing with GCC due to LLDB not being able to call constructors

Tracked in llvm.org/pr50814

These tests fail with all GCC versions I tested (8.5, 9.4, 10.3, 11.1).

3 years ago[SCEV] Support single-cond range check idiom in applyLoopGuards.
Florian Hahn [Fri, 25 Jun 2021 08:29:47 +0000 (09:29 +0100)]
[SCEV] Support single-cond range check idiom in applyLoopGuards.

This patch extends applyLoopGuards to detect a single-cond range check
idiom that InstCombine generates.

It extends applyLoopGuards to detect conditions of the form
(-C1 + X < C2). InstCombine will create this form when combining two
checks of the form (X u< C2 + C1) and (X >=u C1).

In practice, this enables us to correctly compute a tight trip count
bounds for code as in the function below. InstCombine will fold the
minimum iteration check created by LoopRotate with the user check (< 8).

    void unsigned_check(short *pred, unsigned width) {
        if (width < 8) {
            for (int x = 0; x < width; x++)
                pred[x] = pred[x] * pred[x];
        }
    }

As a consequence, LLVM creates dead vector loops for the code above,
e.g. see https://godbolt.org/z/cb8eTcqET

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

Reviewed By: nikic

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

3 years ago[OpaquePtr] Allow alias to opaque pointer
Nikita Popov [Fri, 25 Jun 2021 09:13:36 +0000 (11:13 +0200)]
[OpaquePtr] Allow alias to opaque pointer

By relaxing the LLParser pointer type assertion.

3 years ago[OpaquePtr] Split force-opaque-pointers test (NFC)
Nikita Popov [Fri, 25 Jun 2021 09:08:19 +0000 (11:08 +0200)]
[OpaquePtr] Split force-opaque-pointers test (NFC)

Separate out the case that uses llvm-dis without
--force-opaque-pointers. This will generally produce a different
result from the other cases, because things like global symbol
pointers will be non-opaque in this case.

3 years ago[lldb] Fix memory tag unsupported test
David Spickett [Fri, 25 Jun 2021 08:52:36 +0000 (08:52 +0000)]
[lldb] Fix memory tag unsupported test

This corrects the test added in
31f9960c38529ce805edf9764535eb0ce188cadf
and temporarily patched in
3b4aad1186e8e8e6f6c7887cb5e8d9bfd7d3ce2f.

This test checks that the memory tag read
command errors when you use it on a platform
without memory tagging.
(which is why we skip the test if you actually
have MTE)

The problem with this test is that there's
two levels of unsupported each with it's own
specific error.

On anything that isn't AArch64, there's no
tagging extension we support. So you're told
that that is the case. As in "this won't ever work".

When you're on AArch64 we know that MTE could
be present on the remote and when we find that it
isn't, we tell you that instead.

Expect a different error message on AArch64 to fix
the test.

3 years ago[llvm-cov] Enforce alignment of function records
serge-sans-paille [Tue, 22 Jun 2021 20:50:37 +0000 (22:50 +0200)]
[llvm-cov] Enforce alignment of function records

Function Records are required to be aligned on 8 bytes. This is enforced for each
records except the first, when one relies on the default alignment within an
std::string. There's no such guarantee, and indeed on 32 bits for some
implementation of std::string this is not enforced.

Provide a portable implementation based on llvm's MemoryBuffer.

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

3 years ago[AArch64] Custom lower <4 x i8> loads
Sjoerd Meijer [Thu, 24 Jun 2021 18:29:13 +0000 (19:29 +0100)]
[AArch64] Custom lower <4 x i8> loads

This custom lowers <4 x i8> vector loads using a 32-bit load, followed by 2
SSHLL instructions to extend it to e.g. a <4 x i32> vector. Before, it was
really inefficient and expensive to construct a <4 x i32> for this as 4 byte
loads and 4 moves were used. With this improvement SLP vectorisation might for
example become profitable, see D103629.

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

3 years ago[OpaquePtr] Enumerate alloca type
Nikita Popov [Fri, 25 Jun 2021 08:48:57 +0000 (10:48 +0200)]
[OpaquePtr] Enumerate alloca type

This is no longer implicitly enumerated through the pointer type.

3 years ago[OpaquePtr] Enumerate global variable type
Nikita Popov [Fri, 25 Jun 2021 08:45:29 +0000 (10:45 +0200)]
[OpaquePtr] Enumerate global variable type

This is no longer implicitly enumerated through the pointer type.

3 years ago[PowerPC] Change VSRpRC allocation order
Qiu Chaofan [Fri, 25 Jun 2021 08:00:07 +0000 (16:00 +0800)]
[PowerPC] Change VSRpRC allocation order

On PowerPC, VSRpRC represents the pairs of even and odd VSX register,
and VRRC corresponds to higher 32 VSX registers. In some cases, extra
copies are produced when handling incoming VRRC arguments with VSRpRC.

This patch changes allocation order of VSRpRC to eliminate this kind of
copy.

Stack frame sizes may increase if allocating non-volatile registers, and
some other vector copies happen. They need fix in future changes.

Reviewed By: nemanjai

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

3 years ago[LLD] [COFF] Fix handling of LTO comdats with nontrivial selection types after 728cc0...
Martin Storsjö [Sun, 20 Jun 2021 20:58:46 +0000 (23:58 +0300)]
[LLD] [COFF] Fix handling of LTO comdats with nontrivial selection types after 728cc0075e5dfdb454eb

Commit 728cc0075e5dfdb454ebe6418b63bdffae71ec14 made comdat symbols
from LTO objects be treated as any regular comdat symbol. This works
great for symbols that actually are IMAGE_COMDAT_SELECT_ANY, but
if the symbols have a less trivial selection type that require comparing
either the section chunk size or contents, we can't check that before
actually doing the LTO compilation.

Therefore bring back one aspect of handling from before; that comdat
resolution with a leader from an LTO symbol is essentially skipped,
like it was before 728cc0075e5dfdb454ebe6418b63bdffae71ec14.

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

3 years ago[ARM] Fix crash in chained BFI combine due to incorrectly RAUW'ing a node.
Amara Emerson [Thu, 24 Jun 2021 18:10:42 +0000 (11:10 -0700)]
[ARM] Fix crash in chained BFI combine due to incorrectly RAUW'ing a node.

For a bfi chain like:
a = bfi input, x, y
b = bfi a, x', y'

The previous code was RAUW'ing a with x, mutating the second 'b' bfi, and when
SelectionDAG's CSE code ended up deleting it unexpectedly, bad things happend.
There's no need to RAUW in this case because we can just return our newly
created replacement BFI node. It also looked incorrect because it didn't account
for other users of the 'a' bfi.

Since it seems that chains of more than 2 BFI nodes are hard/impossible to
produce without this combine kicking in at some point, I've removed that
functionality since it had no test coverage.

rdar://79095399

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

3 years ago[RISCV] Permit larger RVV stacks and stack offsets
Fraser Cormack [Tue, 22 Jun 2021 17:08:52 +0000 (18:08 +0100)]
[RISCV] Permit larger RVV stacks and stack offsets

This patch teaches the compiler to generate code to handle larger RVV
stack sizes and stack offsets which resolve an amount larger than 2047
vector registers in size.

The previous behaviour was asserting on such large values as it was only
able to materialize the constant by feeding it to the 12-bit immediate
of an `ADDI` instruction. The compiler can now materialize this amount
into a temporary register before continuing with the computation.

A test case for this scenario is included which also checks that the
temporary register used to materialize the amount doesn't require an
additional spill slot over what we're already reserving for RVV code.

Reviewed By: rogfer01

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

3 years ago[X86] Add description of FXAM instruction
Serge Pavlov [Wed, 23 Jun 2021 06:33:55 +0000 (13:33 +0700)]
[X86] Add description of FXAM instruction

Previously this instruction could be used only in assembler. This change
makes it available for compiler also. Scheduling information was copied
from FTST instruction, hopefully this can be a satisfactory approximation.

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

3 years ago[MC][ELF] Change SHT_LLVM_CALL_GRAPH_PROFILE relocations from SHT_RELA to SHT_REL
Fangrui Song [Fri, 25 Jun 2021 04:35:48 +0000 (21:35 -0700)]
[MC][ELF] Change SHT_LLVM_CALL_GRAPH_PROFILE relocations from SHT_RELA to SHT_REL

... even on targets preferring RELA. The section is only consumed by ld.lld
which can handle REL.

Follow-up to D104080 as I explained in the review. There are two advantages:

* The D104080 code only handles RELA, so arm/i386/mips32 etc may warn for -fprofile-use=/-fprofile-sample-use= usage.
* Decrease object file size for RELA targets

While here, change the relocation to relocate weights, instead of 0,1,2,3,..
I failed to catch the issue during review.

3 years agoRevert "[BuildLibCalls/SimplifyLibCalls] Fix attributes on created CallInst instruct...
Arthur Eubanks [Fri, 25 Jun 2021 02:21:16 +0000 (19:21 -0700)]
Revert "[BuildLibCalls/SimplifyLibCalls]  Fix attributes on created CallInst instructions."

This reverts commit 1eda5453f2dcc9a9a4b4578fe74163c529974503.

Causes https://crbug.com/1223647:
Incompatible argument and return types for 'returned' attribute
  tail call void @llvm.memset.p0i8.i64(i8* noalias noundef returned writeonly align 1 dereferenceable(255) %arraydecay, i8 0, i64 255, i1 false), !dbg !985

3 years ago[lld-macho] Move ICF members from InputSection to ConcatInputSection
Jez Ng [Fri, 25 Jun 2021 02:23:04 +0000 (22:23 -0400)]
[lld-macho] Move ICF members from InputSection to ConcatInputSection

`icfEqClass` only makes sense on ConcatInputSections since (in contrast
to literal sections) they are deduplicated as an atomic unit.

Similarly, `hasPersonality` and `replacement` don't make sense on
literal sections.

This mirrors LLD-ELF, which stores `icfEqClass` only on non-mergeable
sections.

Reviewed By: #lld-macho, gkm

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

3 years ago[PowerPC] Move PPCBranchSelector as close to asm printer as possible
Kai Luo [Fri, 25 Jun 2021 01:43:31 +0000 (01:43 +0000)]
[PowerPC] Move PPCBranchSelector as close to asm printer as possible

Currently, PPCBranchSelector is not immediately preceding asm printer pass. `-debug-pass=Structure` gives
```
      PowerPC Branch Selector
      Contiguously Lay Out Funclets
      StackMap Liveness Analysis
      Live DEBUG_VALUE analysis
      Lazy Machine Block Frequency Analysis
      Machine Optimization Remark Emitter
      Linux PPC Assembly Printer
```
After the patch
```
      Contiguously Lay Out Funclets
      StackMap Liveness Analysis
      Live DEBUG_VALUE analysis
      PowerPC Branch Selector
      Lazy Machine Block Frequency Analysis
      Machine Optimization Remark Emitter
      Linux PPC Assembly Printer
```

Reviewed By: nemanjai, #powerpc

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