Commit Graph

356671 Commits

Author SHA1 Message Date
Siva Chandra Reddy
63bbddf4cd [libc][NFC] Add bzero to list of entrypoints.
A new LLVM libc specific extension standard spec has been added.
2020-06-08 21:44:39 -07:00
Kang Zhang
e3546c78ca [NFC][PowerPC] Remove the redundant InstAlias for OR instruction
Summary:
We have handle the InstAlias for OR instructions, but we handle it
agagin in PPCInstPrinter.cpp.
This patch is to Remove the redundant InstAlias for OR instruction.

Reviewed By: steven.zhang

Differential Revision: https://reviews.llvm.org/D80502
2020-06-09 03:32:27 +00:00
Saleem Abdulrasool
5fda192fed test: repair lld builder
Add the explicit `-arch x86_64` to the invocation.
2020-06-08 20:13:54 -07:00
Chen Zheng
8aa52b19a7 [APInt] set all bits for getBitsSetWithWrap if loBit == hiBit
differentiate getBitsSetWithWrap & getBitsSet when loBit == hiBit
getBitsSetWithWrap sets all bits;
getBitsSet does nothing.

Reviewed By: lkail, RKSimon, lebedev.ri

Differential Revision: https://reviews.llvm.org/D81325
2020-06-08 22:55:24 -04:00
Anil Mahmud
246d106094 [PowerPC] Fix pattern for DCBFL/DCBFLP instrinsics.
The previous implementation used "asm parser only" pseudo-instructions in their
output patterns. Those are not meant to emit code and will caused crashes when
built with -filetype=obj.

Differential Revision: https://reviews.llvm.org/D80151
2020-06-08 20:54:59 -05:00
Anil Mahmud
c9790d54f8 [PowerPC] Remove extra instruction left by emitRLDICWhenLoweringJumpTables
The function emitRLDICWhenLoweringJumpTables in PPCMIPeephole.cpp
was supposed to convert a pair of RLDICL and RLDICR to a single RLDIC,
but it was leaving out the RLDICL instruction. This PR fixes the bug.

Differential Revision: https://reviews.llvm.org/D78063
2020-06-08 20:43:56 -05:00
Stefan Pintilie
b4036329f1 [PowerPC] Fix incorrect PC Relative relocations for Big Endian
Fix the incorrect PC Relative relocations for Big Endian for 34 bit offsets.
The offset should be zero for both BE and LE in this situation.

Differential Revision: https://reviews.llvm.org/D81033
2020-06-08 20:29:43 -05:00
Matt Arsenault
3c67b9516a Make myself code owner of InferAddressSpaces
The original author isn't active, and I've made most of the commits to
it.
2020-06-08 21:26:01 -04:00
Saleem Abdulrasool
6fe27b5fed lld: initial pass at supporting TBD
Add support to lld to use Text Based API stubs for linking.  This is
support is incomplete not filtering out platforms.  It also does not
account for architecture specific API handling and potentially does not
correctly handle trees of re-exports with inlined libraries being
treated as direct children of the top level library.
2020-06-08 18:15:40 -07:00
Jacques Pienaar
48c28d58c6 [mlir] Unranked memref type has no rank
Summary:
UnrankedMemRefType doesn't have a rank but previously this was just
checking for unranked tensor. Avoids failure later if one queries the shape
post checking if ranked.

Differential Revision: https://reviews.llvm.org/D81441
2020-06-08 18:08:14 -07:00
Jian Cai
0e1accd0f7 [AArch64] Support expression results as immediate values in mov
Summary:
This patch adds support of using the result of an expression as an
immediate value. For example,

0:
.skip 4
 1:
mov x0, 1b - 0b

is assembled to

mov x0, #4

Currently it does not support expressions requiring relocation unless
explicitly specified. This fixes PR#45781.

Reviewers: peter.smith, ostannard, efriedma

Reviewed By: efriedma

Subscribers: nickdesaulniers, llozano, manojgupta, efriedma, ostannard, kristof.beyls, hiraditya, danielkiss, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80028
2020-06-08 17:57:20 -07:00
dfukalov
6a31a9a543 [AMDGPU][NFC] Skip processing intrinsics that do not become real instructions
Reviewers: rampitec

Reviewed By: rampitec

Subscribers: arsenm, kzhuravl, jvesely, wdng, nhaehnle, yaxunl, dstuttard, tpr, t-tye, hiraditya, kerbowa, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81260
2020-06-09 03:45:33 +03:00
Siva Chandra Reddy
e9de9e3368 [libc][NFC][Obvious] Add names to various string entrypoints. 2020-06-08 17:13:53 -07:00
Eli Friedman
7e58d0ded0 Revert "[arm][darwin] Don't generate libcalls for wide shifts on Darwin"
This reverts commit 2ba016cd5c.

This is causing a failure on the clang-cmake-armv7-full bot, and there
are outstanding review comments.
2020-06-08 16:37:29 -07:00
Petr Hosek
69c5ff4668 [InstrProfiling] Use -fuse-ld=lld in instrprof-gc-sections test
This was accidentally omitted in 603d58b leading to a test failure
on some of the bots that don't use lld as the default linker.
2020-06-08 16:36:14 -07:00
George Mitenkov
fda5192d4f [MLIR][SPIRVToLLVM] Add skeleton for SPIR-V to LLVM dialect conversion
These commits set up the skeleton for SPIR-V to LLVM dialect conversion.
I created SPIR-V to LLVM pass, registered it in Passes.td, InitAllPasses.h.
Added a pattern for `spv.BitwiseAndOp` and tests for it. Integer, float
and vector types are converted through LLVMTypeConverter.

Differential Revision: https://reviews.llvm.org/D81100
2020-06-08 18:22:42 -04:00
KareemErgawy
a6d6b0ac93 [MLIR][Toy] Fix a few typos in the comments/docs.
Fixes a few typos and errors in MLIR's Toy tutorial docs and comments.

Differential Revision: https://reviews.llvm.org/D81406
2020-06-08 18:18:47 -04:00
Petr Hosek
603d58b5e4 [InstrProfiling] Use !associated metadata for counters, data and values
The !associated metadata may be attached to a global object declaration
with a single argument that references another global object. This
metadata prevents discarding of the global object in linker GC unless
the referenced object is also discarded.

Furthermore, when a function symbol is discarded by the linker, setting
up !associated metadata allows linker to discard counters, data and
values associated with that function symbol. This is not possible today
because there's metadata to guide the linker. This approach is also used
by other instrumentations like sanitizers.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

Differential Revision: https://reviews.llvm.org/D76802
2020-06-08 15:07:43 -07:00
Petr Hosek
ba10bedf56 Revert "[InstrProfiling] Use !associated metadata for counters, data and values"
This reverts commit 39b3c41b65 due to
a failing associated.ll test.
2020-06-08 14:38:15 -07:00
Stanislav Mekhanoshin
87ff3401eb Stabilize alloca slices sort in SROA
Slice::operator<() has a non-deterministic behavior. If we have
identical slices comparison will depend on the order or operands.
Normally that does not result in unstable compilation results
because the order in which slices are inserted into the vector
is deterministic and llvm::sort() normally behaves as a stable
sort, although that is not guaranteed.

However, there is test option -sroa-random-shuffle-slices which
is used to check exactly this aspect. The vector is first randomly
shuffled and then sorted. The same shuffling happens without this
option under expensive llvm checks.

I have managed to write a test which has hit this problem.

There are no fields in the Slice class to resolve the instability.
We only have offsets, IsSplittable and Use, but neither Use nor
User have anything suitable for predictable comparison.

I have switched to stable_sort which has to be sufficient and
removed that randon shuffle option.

Differential Revision: https://reviews.llvm.org/D81310
2020-06-08 14:25:27 -07:00
Richard Smith
56a872947a Remove improper uses of DiagnosticErrorTrap and hasErrorOccurred.
DiagnosticErrorTrap is usually inappropriate because it indicates
whether an error message was rendered in a given region (and is
therefore affected by -ferror-limit and by suppression of errors if we
see an invalid declaration).

hasErrorOccurred() is usually inappropriate because it indicates
whethere an "error:" message was displayed, regardless of whether the
message was a warning promoted to an error, and therefore depends on
things like -Werror that are usually irrelevant.

Where applicable, CodeSynthesisContexts are used to attach notes to
the first diagnostic produced in a region of code, isnstead of using an
error trap and then attaching a note to whichever diagnostic happened to
be produced last (or suppressing the note if the final diagnostic is a
disabled warning!).

This is mostly NFC.
2020-06-08 14:19:57 -07:00
Sterling Augustine
f07b3d41e7 Add #includes so that ROCm.h is compilable stand-alone.
Summary:
ROCm.h had been getting the declarations for various data structures
by being #included next to them, rather than #includeing them itself.

This change fixes that by explicitly including the appropriate headers.

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81432
2020-06-08 14:16:30 -07:00
Yonghong Song
3eb465a329 [DebugInfo] Fix assertion for extern void type
Commit d77ae1552f ("[DebugInfo] Support to emit debugInfo
for extern variables") added support to emit debuginfo
for extern variables. Currently, only BPF target enables to
emit debuginfo for extern variables.

But if the extern variable has "void" type, the compilation will
fail.

  -bash-4.4$ cat t.c
  extern void bla;
  void *test() {
    void *x = &bla;
    return x;
  }
  -bash-4.4$ clang -target bpf -g -O2 -S t.c
  missing global variable type
  !1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
                                  isLocal: false, isDefinition: false)
  ...
  fatal error: error in backend: Broken module found, compilation aborted!
  PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace,
      preprocessed source, and associated run script.
  Stack dump:
  ...

The IR requires a DIGlobalVariable must have a valid type and the
"void" type does not generate any type, hence the above fatal error.

Note that if the extern variable is defined as "const void", the
compilation will succeed.

-bash-4.4$ cat t.c
extern const void bla;
const void *test() {
  const void *x = &bla;
  return x;
}
-bash-4.4$ clang -target bpf -g -O2 -S t.c
-bash-4.4$ cat t.ll
...
!1 = distinct !DIGlobalVariable(name: "bla", scope: !2, file: !3, line: 1,
                                type: !6, isLocal: false, isDefinition: false)
!6 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)
...

Since currently, "const void extern_var" is supported by the
debug info, it is natural that "void extern_var" should also
be supported. This patch disabled assertion of "void extern_var"
in IR verifier and add proper guarding when emiting potential
null debug info type to dwarf types.

Differential Revision: https://reviews.llvm.org/D81131
2020-06-08 13:43:18 -07:00
Petr Hosek
39b3c41b65 [InstrProfiling] Use !associated metadata for counters, data and values
The !associated metadata may be attached to a global object declaration
with a single argument that references another global object. This
metadata prevents discarding of the global object in linker GC unless
the referenced object is also discarded.

Furthermore, when a function symbol is discarded by the linker, setting
up !associated metadata allows linker to discard counters, data and
values associated with that function symbol. This is not possible today
because there's metadata to guide the linker. This approach is also used
by other instrumentations like sanitizers.

Note that !associated metadata is only supported by ELF, it does not have
any effect on non-ELF targets.

Differential Revision: https://reviews.llvm.org/D76802
2020-06-08 13:35:56 -07:00
Roman Lebedev
932ad9941d
[Support] FoldingSetNodeID::AddString(): reserve memory
Summary:
It is traditionally potentially very inefficient to not preallocate the memory,
but rely on reallocation every time you push something into vector.

For example, looking at unity build of RawSpeed
(`-O3 -g0 -emit-llvm -Xclang -disable-llvm-optzns`),
the memory story is as follows:
```
total runtime: 11.34s.
calls to allocation functions: 2694053 (237612/s)
temporary memory allocations: 645188 (56904/s)
peak heap memory consumption: 231.36MB
peak RSS (including heaptrack overhead): 397.39MB
```

Looking at details, `FoldingSetNodeID::AddString()` is noteworthy, frequently called and is allocation-heavy.

But it is quite obvious how many times we will push into `Bits` - we will push `String.size()` itself,
and then we will push once per every 4 bytes of `String` (padding last block).

And if we preallocate, we get:
```
total runtime: 11.20s.
calls to allocation functions: 2594704 (231669/s)
temporary memory allocations: 560004 (50000/s)
peak heap memory consumption: 231.36MB
peak RSS (including heaptrack overhead): 398.06MB
```
Which is a measurable win:
```
total runtime: -0.14s.                             #  -1.23 %
calls to allocation functions: -99349 (719920/s)   #  -3.69 %
temporary memory allocations: -85184 (617275/s)    # -13.2 % (!)
peak heap memory consumption: 0B
peak RSS (including heaptrack overhead): 0B
total memory leaked: 0B
```

Reviewers: efriedma, nikic, bkramer

Reviewed By: bkramer

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81342
2020-06-08 23:26:54 +03:00
Michael Liao
43793b89a0 [lld] Fix shared library build by adding the missing dependency. 2020-06-08 16:12:58 -04:00
Richard Smith
58f831d2b3 More robust fix for crash on invalid range-based for statement.
Reliably mark the loop variable declaration in a range for as having an
invalid initializer if anything goes wrong building the initializer. We
previously based this determination on whether an error was emitted,
which is not a reliable signal due to error suppression (during error
recovery etc).

Also, properly mark the variable as having initializer errors rather
than simply marking it invalid. This is necessary to mark any structured
bindings as invalid too.

This generalizes the previous fix in
936ec89e91.
2020-06-08 13:11:23 -07:00
jasonliu
775ef44514 [XCOFF][AIX] report_fatal_error when an overflow section is needed
If there are more than 65534 relocation entries in a single section,
we should generate an overflow section.
Since we don't support overflow section for now, we should generate
an error.

Differential revision: https://reviews.llvm.org/D81104
2020-06-08 19:59:04 +00:00
Valentin Clement
38674030c0 Apply fix from D81179 only from GCC < 8
Summary: Apply workaround done in D81179 only for GCC < 8. As @klausler mentioned in D81179 we want to avoid additional checks for other compilers that do not need them.

Reviewers: DavidTruby, klausler, jdoerfert, sscalpone

Reviewed By: klausler, sscalpone

Subscribers: llvm-commits, tskeith, isuruf, klausler

Tags: #flang, #llvm

Differential Revision: https://reviews.llvm.org/D81208
2020-06-08 15:51:57 -04:00
Arthur Eubanks
a92ce3b706 Revert "Reland D80966 [codeview] Put !heapallocsite on calls to operator new"
This reverts commit b6e143aa54.

Causes https://bugs.chromium.org/p/chromium/issues/detail?id=1092370#c5.
Will investigate and reland (again).
2020-06-08 12:49:41 -07:00
LLVM GN Syncbot
8e1d204344 [gn build] Port bb677cacc8 2020-06-08 19:44:56 +00:00
Andrew Litteken
bb677cacc8 [SuffixTree][MachOpt] Factoring out Suffix Tree and adding Unit Tests
This moves the SuffixTree test used in the Machine Outliner and moves it into Support for use in other outliners elsewhere in the compilation pipeline.

Differential Revision: https://reviews.llvm.org/D80586
2020-06-08 12:44:18 -07:00
Julian Lettner
e47c0ef09f [TSan] Revert removal of ignore_interceptors_accesses flag
This flag suppresses TSan FPs on Darwin.  I removed this flag
prematurely and have been dealing with the fallout ever since.

This commit puts back the flag, reverting 7d1085cb [1].

[1] https://reviews.llvm.org/D55075
2020-06-08 12:35:43 -07:00
Jian Cai
4db2b70248 Add a flag to debug automatic variable initialization
Summary:
Add -ftrivial-auto-var-init-stop-after= to limit the number of times
stack variables are initialized when -ftrivial-auto-var-init= is used to
initialize stack variables to zero or a pattern. This flag can be used
to bisect uninitialized uses of a stack variable exposed by automatic
variable initialization, such as http://crrev.com/c/2020401.

Reviewers: jfb, vitalybuka, kcc, glider, rsmith, rjmccall, pcc, eugenis, vlad.tsyrklevich

Reviewed By: jfb

Subscribers: phosek, hubert.reinterpretcast, srhines, MaskRay, george.burgess.iv, dexonsmith, inglorion, gbiv, llozano, manojgupta, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77168
2020-06-08 12:30:56 -07:00
Nico Weber
f25e3c2d0e Revert "[clangd] Resolve driver symlinks, and look up unknown relative drivers in PATH."
This reverts commit 806342b8ef.
Breaks check-clangd on macOS, https://reviews.llvm.org/D75414#2080076
2020-06-08 15:20:16 -04:00
Florian Hahn
1975ff9a0a [AArch64] Fix ldst-opt of multiple disjunct subregs.
Currently aarch64-ldst-opt will incorrectly rename registers with
multiple disjunct subregisters (e.g. result of LD3). This patch updates
the canRenameUpToDef to bail out if it encounters such a register class
that contains the register to rename.

Fixes PR46105.

Reviewers: efriedma, dmgreen, paquette, t.p.northover

Reviewed By: efriedma

Differential Revision: https://reviews.llvm.org/D81108
2020-06-08 20:18:24 +01:00
Isuru Fernando
bb73d1b278 [flang] Fix issue of flang/runtime/config.h not being found in out of tree builds
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=46078

Reviewers: DavidTruby, jdoerfert, PeteSteinfeld, sscalpone, tskeith

Reviewed By: PeteSteinfeld, sscalpone, tskeith

Subscribers: mgorny, llvm-commits, tskeith

Tags: #llvm, #flang

Differential Revision: https://reviews.llvm.org/D81266
2020-06-08 14:16:08 -05:00
Hans Wennborg
fc202c5fec [PGO] CallPromotion: Don't try to pass sret args to varargs functions
It's not allowed by the verifier.

Differential revision: https://reviews.llvm.org/D81409
2020-06-08 21:10:27 +02:00
Arthur Eubanks
c07339c675 Move *San module passes later in the NPM pipeline
Summary:
This fixes pr33372.cpp under the new pass manager.

ASan adds padding to globals. For example, it will change a {i32, i32, i32} to a {{i32, i32, i32}, [52 x i8]}. However, when loading from the {i32, i32, i32}, InstCombine may (after various optimizations) end up loading 16 bytes instead of 12, likely because it thinks the [52 x i8] padding is ok to load from. But ASan checks that padding should not be loaded from.

Ultimately this is an issue of *San passes wanting to be run after all optimizations. This change moves the module passes right next to the corresponding function passes.

Also remove comment that's no longer relevant, this is the last ASan/MSan/TSan failure under the NPM (hopefully...).

As mentioned in https://reviews.llvm.org/rG1285e8bcac2c54ddd924ffb813b2b187467ac2a6, NPM doesn't support LTO + sanitizers, so modified some tests that test for that.

Reviewers: leonardchan, vitalybuka

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81323
2020-06-08 12:08:49 -07:00
Louis Dionne
60cde7bbb7 [libc++] Improve tests for iterators.operations
Reduce duplication between the constexpr and the non-constexpr test cases,
and add tests for the return type of the various operations.
2020-06-08 14:59:35 -04:00
Craig Topper
2328cab16c [X86] Prevent LowerSELECT from causing suboptimal codegen for __builtin_ffs(X) - 1.
LowerSELECT sees the CMP with 0 and wants to use a trick with SUB
and SBB. But we can use the flags from the BSF/TZCNT.

Fixes PR46203.

Differential Revision: https://reviews.llvm.org/D81312
2020-06-08 11:46:56 -07:00
Hendrik Greving
f3d8a93970 [ModuloSchedule] Support instructions with > 1 destination when walking canonical use.
Fixes a minor bug that led to finding the wrong register if the definition had more
than one register destination.
2020-06-08 11:43:59 -07:00
Sanjay Patel
d50366d29f [InstCombine] improve matching for sext-lshr-trunc patterns, part 2
Similar to rG42f488b63a04

This is intended to preserve the logic of the existing transform,
but remove unnecessary restrictions on uses and types.

https://rise4fun.com/Alive/oS0

  Name: narrow input
  Pre: C1 <= width(C1) - 24
  %B = sext i8 %A
  %C = lshr %B, C1
  %r = trunc %C to i24
  =>
  %s = ashr i8 %A, trunc(umin(C1, 7))
  %r = sext i8 %s to i24

  Name: wide input
  Pre: C1 <= width(C1) - 24
  %B = sext i24 %A
  %C = lshr %B, C1
  %r = trunc %C to i8
  =>
  %s = ashr i24 %A, trunc(umin(C1, 23))
  %r = trunc i24 %s to i8
2020-06-08 14:41:50 -04:00
Sanjay Patel
9b41821c1b [InstCombine] add tests for sext+lshr+trunc; NFC
Shows missing transforms with extra uses and vectors.
2020-06-08 14:41:50 -04:00
Christopher Tetreault
2c512eaf37 [SVE] Eliminate calls to default-false VectorType::get() from llvm-stress
Reviewers: efriedma, kmclaughlin, sdesmalen, MaskRay, JDevlieghere

Reviewed By: sdesmalen

Subscribers: tschuett, rkruppe, psnobl, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D81201
2020-06-08 11:32:37 -07:00
Chris Jackson
c6c65164af [DebugInfo] Reduce SalvageDebugInfo() functions
- Now all SalvageDebugInfo() calls will mark undef if the salvage
  attempt fails.

 Reviewed by: vsk, Orlando

 Differential Revision: https://reviews.llvm.org/D78369
2020-06-08 19:28:18 +01:00
Yaxun (Sam) Liu
4615abc11f Rename arg name in __clang_hip_math.h
__sptr is a keyword for ms-extension. Change it from __sptr to __sinptr.
2020-06-08 14:13:32 -04:00
Saleem Abdulrasool
fcdf7578aa lld: improve the -arch handling for MachO
Use the default target triple configured by the user to determine the
default architecture for `ld64.lld`.  Stash the architecture in the
configuration as when linking against TBDs, we will need to filter out
the symbols based upon the architecture.  Treat the Haswell slice as it
is equivalent to `x86_64` but with the extra Haswell extensions (e.g.
AVX2, FMA3, BMI1, etc).  This will make it easier to add new
architectures in the future.

This change also changes the failure mode where an invalid `-arch`
parameter will result in the linker exiting without further processing.
2020-06-08 11:04:19 -07:00
Florian Hahn
22c2dc5931 [AArch64] Add a ldst-opt test with undef operands (NFC).
This patch adds a test to check that we do not use an undef renamable
register for renaming the other operand in a LDP instruction, as
suggested in D81108.
2020-06-08 18:46:56 +01:00
Jan-Willem Maessen
3610d31e7a [NFC] Fix quadratic LexicalScopes::constructScopeNest
We sometimes have functions with large numbers of sibling basic
blocks (usually with an error path exit from each one). This was
triggering the qudratic behavior in this function - after visiting
each child llvm would re-scan the parent from the beginning again. We
modify the work stack to record the next index to be worked on
alongside the pointer. This avoids the need to linearly search for
the next unfinished child.

Differential Revision: https://reviews.llvm.org/D80029
2020-06-08 18:40:56 +01:00