Commit Graph

306713 Commits

Author SHA1 Message Date
Martin Storsjo 5abe10ac21 [MinGW] Expand comment for MinGW driver. NFC.
Originally authored by Rui Ueyama.

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

llvm-svn: 350464
2019-01-05 10:43:59 +00:00
Nikita Popov 65038515ee [InstCombine] Relax cttz/ctlz with select on zero
The cttz/ctlz intrinsics have a parameter specifying whether the
result is undefined for zero. cttz(x, false) can be relaxed to
cttz(x, true) if x is known non-zero, and in fact such an optimization
is already performed. However, this currently doesn't work if x is
non-zero as a result of a select rather than an explicit branch.
This patch adds handling for this case, thus allowing
x != 0 ? cttz(x, false) : y to simplify to x != 0 ? cttz(x, true) : y.

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

llvm-svn: 350463
2019-01-05 09:48:16 +00:00
Nikita Popov 7bd4900ba0 [InstCombine] Add vector tests for select + ctlz/cttz; NFC
llvm-svn: 350462
2019-01-05 09:48:05 +00:00
Petr Hosek 43fc2e4590 [CMake][Fuchsia] Enable experimental new pass manager by default
This change enableds experimental new pass manager.

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

llvm-svn: 350461
2019-01-05 07:57:53 +00:00
Petr Hosek 97a245f8e7 [CMake][Fuchsia] Enable x86 relaxation by default
This enables x86 relaxation by default. This depends on a linker new
enough to support the new reloc types but since we default to lld we
don't worry about host system linkers that might be too old to support
the new reloc types.

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

llvm-svn: 350460
2019-01-05 07:57:46 +00:00
Petr Hosek 4bb647d2a3 [CMake][Fuchsia] Enable --build-id linker flag by default
This enables passing --build-id to linker by default.

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

llvm-svn: 350459
2019-01-05 07:57:38 +00:00
Nico Weber 777c17f738 [gn build] Merge r350423
llvm-svn: 350458
2019-01-05 05:01:20 +00:00
Nico Weber 1620162b07 [gn build] Add build files for unittests under llvm/unittests/ExecutionEngine
Differential Revision: https://reviews.llvm.org/D56328

llvm-svn: 350457
2019-01-05 04:05:25 +00:00
Easwaran Raman 366a873f14 [Inliner] Optimize shouldBeDeferred
This has some minor optimizations to shouldBeDeferred. This is not
strictly NFC because the early exit inside the loop assumes
TotalSecondaryCost is monotonically non-decreasing, which is not true if
the threshold used by CostAnalyzer is negative. AFAICT the thresholds do
not go below 0 for the default values of the various options we use.

llvm-svn: 350456
2019-01-05 02:26:29 +00:00
Craig Topper 45ec002e25 [X86] Require second operand of X86vshiftuniform to be an integer. NFC
We don't need to require the first operand to be an integer because we already said it was the same type as the result which we also constrained to an integer.

llvm-svn: 350455
2019-01-05 01:40:29 +00:00
Nico Weber 8400becec5 [gn build] Add build files for unittests that load shared libraries
This is slightly ugly for three reasons:

- The shlib needs to go next to the binary to be found on all platforms, so the
  build files refer to target_out_dir
- The explicit -fPIC flag needed on the shared lib side, and the -rdynamic flag
  needed on the host side, on Linux 
- Plugins that refer to LLVM code and assume that the host will resolve them
  don't work on Windows -- PluginsTests won't test anything on Windows (but
  DynamicLibraryTests will, since the dll here doesn't call LLVM code)


If we get lots more of these plugin / plugin host targets it might make sense
to add a template for them. But for now, these are the last ones we need.

(We're at 6 plugin hosts, 2 of them tests, and at 6 shared libraries, 2 of them
tests as well. clang is a plugin host by default in the CMake build but not
(yet?) in the GN build.)

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

llvm-svn: 350454
2019-01-05 01:39:18 +00:00
Nico Weber b215d0731a Let new test from r350340 still pass even after r350451.
llvm-svn: 350453
2019-01-05 01:19:14 +00:00
Alexandre Ganea 383be892fc [LLD][COFF] PDB: Parallel sort publics
Saves up to 1.3 sec on large PDBs.
Figures below are for the "Globals Stream Layout" pass:

                            Before	This patch
Large EXE (PDB is ~2 GB)	3330 ms	2022 ms
Large EXE (PDB is ~2 GB)	2680 ms	1608 ms
Large DLL (PDB is ~1 GB)	1455 ms	938 ms
Large DLL (PDB is ~800 MB)	1215 ms	800 ms
Small DLL (PDB is ~200 MB)	224 ms	146 ms

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

llvm-svn: 350452
2019-01-05 01:16:24 +00:00
Nico Weber 9f0c21c1e0 Move -add-plugin validation after -load was executed.
Moves the code added in r350340 around a bit, to hopefully make the existing
plugin tests pass when clang is built with examples enabled.

llvm-svn: 350451
2019-01-05 01:10:20 +00:00
Alexandre Ganea e6ed8540c5 [LLD][COFF] Fix namespace compilation issue with a upcoming patch. NFC
llvm-svn: 350450
2019-01-05 01:08:10 +00:00
Evgeniy Stepanov 045a83231d Revert "Revert "Switch Android from TLS_SLOT_TSAN(8) to TLS_SLOT_SANITIZER(6)""
This reapplies commit r348984.

llvm-svn: 350449
2019-01-05 00:45:14 +00:00
Evgeniy Stepanov 0184c53cbd Revert "Revert "[hwasan] Android: Switch from TLS_SLOT_TSAN(8) to TLS_SLOT_SANITIZER(6)""
This reapplies commit r348983.

llvm-svn: 350448
2019-01-05 00:44:58 +00:00
Nico Weber b18dc96de1 [gn build] Add build file for DebugInfoPDBTests
I'm pretty unhappy this patch: DebugInfoPDBTests uses an API that requires some
magic txt file to be next to the unit test executable that stores the absolute
path to the LLVM source root.

The choices here are:

1. Don't use the unittest() template for DebugInfoPDBTests and set output_dir
   for unit tests in two places (the gni file for every test but this one, and the
   BUILD.gn file for this specific test).

2. Add another unittest_foo() template variation for this one test.

I went with the former, and added a comment to the template to look out for
this.

(The CMake build has the same issue.)

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

llvm-svn: 350447
2019-01-05 00:14:37 +00:00
Jonas Devlieghere e6366a85b5 [Driver] Some more cleanup. NFC
llvm-svn: 350446
2019-01-05 00:01:04 +00:00
Peter Collingbourne 1c650debd7 Bring back the pthread_create interceptor, but only on non-aarch64.
We still need the interceptor on non-aarch64 to untag the pthread_t
and pthread_attr_t pointers and disable tagging on allocations done
internally by glibc.

llvm-svn: 350445
2019-01-04 23:24:02 +00:00
Peter Collingbourne 714e170648 Disable system-allocator-fallback.cc test on Android O and earlier.
The dynamic loader on Android O appears to have a bug where it crashes
when dlopening DF_1_GLOBAL libraries.

llvm-svn: 350444
2019-01-04 23:10:47 +00:00
Evgeniy Stepanov 9fbc364e16 [sanitizer] Reduce stack depot size on Android.
Summary:
The default setting kTabSizeLog=20 results in an 8Mb global hash table,
almost all of it in private pages. That is not a sane setting in a
mobile, system-wide use case: with ~150 concurrent processes stack
depot will account for more than 1Gb of RAM.

Reviewers: kcc, pcc

Subscribers: srhines, kubamracek, llvm-commits

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

llvm-svn: 350443
2019-01-04 22:55:04 +00:00
Rong Xu b5fa0a89b2 [PGO] Use SourceFileName rather module name in PGOFuncName
In LTO or Thin-lto mode (though linker plugin), the module
names are of temp file names which are different for
different compilations. Using SourceFileName avoids the issue.
This should not change any functionality for current PGO as
all the current callers of getPGOFuncName() is before LTO.

llvm-svn: 350442
2019-01-04 22:54:03 +00:00
Joel E. Denny bae586fb0a [OpenMP] Refactor const restriction for linear
As discussed in D56113, this patch refactors the implementation of the
const restriction for linear to reuse a function introduced by D56113.
A side effect is that, if a variable has mutable members, this
diagnostic is now skipped, and the diagnostic for the variable not
being an integer or pointer is reported instead.

Reviewed By: ABataev

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

llvm-svn: 350441
2019-01-04 22:12:13 +00:00
Joel E. Denny d2649292ef [OpenMP] Refactor const restriction for reductions
As discussed in D56113, this patch refactors the implementation of the
const restriction for reductions to reuse a function introduced by
D56113.  A side effect is that diagnostics sometimes now say
"variable" instead of "list item" when a list item is a variable.

Reviewed By: ABataev

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

llvm-svn: 350440
2019-01-04 22:11:56 +00:00
Joel E. Denny e6234d1429 [OpenMP] Replace predetermined shared for const variable
The following appears in OpenMP 3.1 sec. 2.9.1.1 as a predetermined
data-sharing attribute:

> Variables with const-qualified type having no mutable member are
> shared.

It does not appear in OpenmP 4.0, 4.5, or 5.0.  This patch removes the
implementation of that attribute when the requested OpenMP version is
greater than 3.1.

One effect of that removal is that `default(none)` affects const
variables without mutable members.

Also, without this patch, if a const variable without mutable members
was explicitly lastprivate or private, it was an error because it was
predetermined shared.  Now, clang instead complains that it's const
without mutable fields, which is a more intelligible diagnostic.  That
should be fine for all of the above versions because they all have
something like the following, which is quoted from OpenMP 5.0
sec. 2.19.3:

> A variable that is privatized must not have a const-qualified type
> unless it is of class type with a mutable member. This restriction does
> not apply to the firstprivate clause.

reduction and linear clauses already have separate checks for const
variables.  Future patches will merge the implementations.

Reviewed By: ABataev

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

llvm-svn: 350439
2019-01-04 22:11:31 +00:00
Alexandre Ganea 79d4851678 [LLD][COFF] Fix file/line retrieval when a undefined symbol is to be printed
Differential Revision: https://reviews.llvm.org/D55951

llvm-svn: 350438
2019-01-04 21:49:22 +00:00
Nikita Popov c35b4a37ba [X86] Fix warning; NFC
llvm-svn: 350437
2019-01-04 21:41:35 +00:00
Vyacheslav Zakharin 0a6f86c54b Update the pr_datasz of .note.gnu.property section.
Patch by Xiang Zhang.

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

llvm-svn: 350436
2019-01-04 21:25:01 +00:00
Nikita Popov 6658fce4fc [BDCE] Remove dead uses of arguments
In addition to finding dead uses of instructions, also find dead uses
of function arguments, and replace them with zero as well.

I'm changing the way the known bits are computed here to remove the
coupling between the transfer function and the algorithm. It previously
relied on the first op being visited first and computing known bits --
unless the first op is not an instruction, in which case they're computed
on the second op. I could have adjusted this to check for "instruction
or argument", but I think it's better to avoid the repeated calculation
with an explicit flag.

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

llvm-svn: 350435
2019-01-04 21:21:43 +00:00
Evandro Menezes 9f53bea536 [AArch64] Adjust the cost model for Exynos M3
Improve the modeling of ASIMD loads and stores.

llvm-svn: 350434
2019-01-04 21:02:25 +00:00
Peter Collingbourne f90e1507d5 Fix default-function-attr.c so that it works on Windows.
llvm-svn: 350433
2019-01-04 20:51:54 +00:00
Craig Topper cfeb1cf9af [X86] Add INSERT_SUBVECTOR to ComputeNumSignBits
This adds support for calculating sign bits of insert_subvector. I based it on the computeKnownBits.

My motivating case is propagating sign bits information across basic blocks on AVX targets where concatenating using insert_subvector is common.

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

llvm-svn: 350432
2019-01-04 20:50:59 +00:00
Alexey Bataev 6b3153ada0 [OPENMP][NVPTX]General formatting/code improvement, NFC.
Summary: Formatting.

Reviewers: gtbercea, grokos, kkwli0

Subscribers: guansong, openmp-commits, caomhin

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

llvm-svn: 350431
2019-01-04 20:16:54 +00:00
Sanjay Patel 6a5656703e [x86] add tests for potential horizontal vector ops; NFC
These are modified versions of the FP tests from rL349923.

llvm-svn: 350430
2019-01-04 20:14:53 +00:00
Peter Collingbourne 87f477b5e4 hwasan: Implement lazy thread initialization for the interceptor ABI.
The problem is similar to D55986 but for threads: a process with the
interceptor hwasan library loaded might have some threads started by
instrumented libraries and some by uninstrumented libraries, and we
need to be able to run instrumented code on the latter.

The solution is to perform per-thread initialization lazily. If a
function needs to access shadow memory or add itself to the per-thread
ring buffer its prologue checks to see whether the value in the
sanitizer TLS slot is null, and if so it calls __hwasan_thread_enter
and reloads from the TLS slot. The runtime does the same thing if it
needs to access this data structure.

This change means that the code generator needs to know whether we
are targeting the interceptor runtime, since we don't want to pay
the cost of lazy initialization when targeting a platform with native
hwasan support. A flag -fsanitize-hwaddress-abi={interceptor,platform}
has been introduced for selecting the runtime ABI to target. The
default ABI is set to interceptor since it's assumed that it will
be more common that users will be compiling application code than
platform code.

Because we can no longer assume that the TLS slot is initialized,
the pthread_create interceptor is no longer necessary, so it has
been removed.

Ideally, lazy initialization should only cost one instruction in the
hot path, but at present the call may cause us to spill arguments
to the stack, which means more instructions in the hot path (or
theoretically in the cold path if the spills are moved with shrink
wrapping). With an appropriately chosen calling convention for
the per-thread initialization function (TODO) the hot path should
always need just one instruction and the cold path should need two
instructions with no spilling required.

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

llvm-svn: 350429
2019-01-04 19:27:04 +00:00
Davide Italiano ff92a1a7cf [Scalar] Simplify comparison operators and add coverage.
llvm-svn: 350428
2019-01-04 19:23:52 +00:00
Peter Collingbourne fcbcc6114f hwasan: Use system allocator to realloc and free untagged pointers in interceptor mode.
The Android dynamic loader has a non-standard feature that allows
libraries such as the hwasan runtime to interpose symbols even after
the symbol already has a value. The new value of the symbol is used to
relocate libraries loaded after the interposing library, but existing
libraries keep the old value. This behaviour is activated by the
DF_1_GLOBAL flag in DT_FLAGS_1, which is set by passing -z global to
the linker, which is what we already do to link the hwasan runtime.

What this means in practice is that if we have .so files that depend
on interceptor-mode hwasan without the main executable depending on
it, some of the libraries in the process will be using the hwasan
allocator and some will be using the system allocator, and these
allocators need to interact somehow. For example, if an instrumented
library calls a function such as strdup that allocates memory on
behalf of the caller, the instrumented library can reasonably expect
to be able to call free to deallocate the memory.

We can handle that relatively easily with hwasan by using tag 0 to
represent allocations from the system allocator. If hwasan's realloc
or free functions are passed a pointer with tag 0, the system allocator
is called.

One limitation is that this scheme doesn't work in reverse: if an
instrumented library allocates memory, it must free the memory itself
and cannot pass ownership to a system library. In a future change,
we may want to expose an API for calling the system allocator so
that instrumented libraries can safely transfer ownership of memory
to system libraries.

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

llvm-svn: 350427
2019-01-04 19:21:51 +00:00
Aaron Enye Shi 0743cda6d4 [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types
The offload bundler action should not unbundle the input file types that does not match the action type. This fixes an issue where .so files are unbundled when the action type is object files.

Reviewers: yaxunl

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

llvm-svn: 350426
2019-01-04 19:09:20 +00:00
Aaron Enye Shi bea57bb5a4 [HIP][DRIVER][OFFLOAD] Do not unbundle unsupported file types
The offload bundler action should not unbundle the input file types that does not match the action type. This fixes an issue where .so files are unbundled when the action type is object files.

llvm-svn: 350425
2019-01-04 19:05:41 +00:00
Teresa Johnson 6ed7913c98 [ThinLTO] Clang changes to utilize new pass to handle chains of aliases
Summary:
As with NameAnonGlobals, invoke the new CanonicalizeAliases via clang
when using the new PM.

Depends on D54507.

Reviewers: pcc, davidxl

Subscribers: mehdi_amini, inglorion, steven_wu, dexonsmith, cfe-commits

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

llvm-svn: 350424
2019-01-04 19:05:01 +00:00
Teresa Johnson 853b962416 [ThinLTO] Handle chains of aliases
At -O0, globalopt is not run during the compile step, and we can have a
chain of an alias having an immediate aliasee of another alias. The
summaries are constructed assuming aliases in a canonical form
(flattened chains), and as a result only the base object but no
intermediate aliases were preserved.

Fix by adding a pass that canonicalize aliases, which ensures each
alias is a direct alias of the base object.

Reviewers: pcc, davidxl

Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, arphaman, llvm-commits

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

llvm-svn: 350423
2019-01-04 19:04:54 +00:00
Erik Pilkington 1e36882b52 [ObjCARC] Add an new attribute, objc_externally_retained
This attribute, called "objc_externally_retained", exposes clang's
notion of pseudo-__strong variables in ARC. Pseudo-strong variables
"borrow" their initializer, meaning that they don't retain/release
it, instead assuming that someone else is keeping their value alive.

If a function is annotated with this attribute, implicitly strong
parameters of that function aren't implicitly retained/released in
the function body, and are implicitly const. This is useful to expose
for performance reasons, most functions don't need the extra safety
of the retain/release, so programmers can opt out as needed.

This attribute can also apply to declarations of local variables,
with similar effect.

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

llvm-svn: 350422
2019-01-04 18:33:06 +00:00
Sanjay Patel 6153565511 [x86] lower extracted fadd/fsub to horizontal vector math; 2nd try
The 1st try for this was at rL350369, but it caused IR-level diffs because
our cost models differentiate custom vs. legal/promote lowering. So that was
reverted at rL350373. The cost models were fixed independently at rL350403,
so this is effectively the same patch as last time.

Original commit message:
This would show up if we fix horizontal reductions to narrow as they go along,
but it's an improvement for size and/or Jaguar (fast-hops) independent of that.

We need to do this late to not interfere with other pattern matching of larger
horizontal sequences.

We can extend this to integer ops in a follow-up patch.

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

llvm-svn: 350421
2019-01-04 17:48:13 +00:00
Vedant Kumar a1778df474 [CodeExtractor] Do not extract unsafe lifetime markers
Lifetime markers which reference inputs to the extraction region are not
safe to extract. Example ('rhs' will be extracted):

```
               entry:
              +------------+
              | x = alloca |
              | y = alloca |
              +------------+
             /              \
   lhs:                      rhs:
  +-------------------+     +-------------------+
  | lifetime_start(x) |     | lifetime_start(x) |
  | use(x)            |     | lifetime_start(y) |
  | lifetime_end(x)   |     | use(x, y)         |
  | lifetime_start(y) |     | lifetime_end(y)   |
  | use(y)            |     | lifetime_end(x)   |
  | lifetime_end(y)   |     +-------------------+
  +-------------------+
```

Prior to extraction, the stack coloring pass sees that the slots for 'x'
and 'y' are in-use at the same time. After extraction, the coloring pass
infers that 'x' and 'y' are *not* in-use concurrently, because markers
from 'rhs' are no longer available to help decide otherwise.

This leads to a miscompile, because the stack slots actually are in-use
concurrently in the extracted function.

Fix this by moving lifetime start/end markers for memory regions defined
in the calling function around the call to the extracted function.

Fixes llvm.org/PR39671 (rdar://45939472).

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

llvm-svn: 350420
2019-01-04 17:43:22 +00:00
Sanjay Patel 722466e1f1 [InstCombine] reduce raw IR narrowing rotate patterns to funnel shift
Similar to rL350199 - there are no known analysis/codegen holes for
funnel shift intrinsics now, so we can canonicalize the 6+ regular
instructions to funnel shift to improve vectorization, inlining,
unrolling, etc.

llvm-svn: 350419
2019-01-04 17:38:12 +00:00
Nico Weber 16a133bd8f [gn build] Merge r350351
llvm-svn: 350418
2019-01-04 17:32:28 +00:00
Nico Weber c9141fc99f [gn build] Commit change that should have been in r350410.
llvm-svn: 350416
2019-01-04 17:26:05 +00:00
Alexey Bataev 8e009036c9 [OPENMP][NVPTX]Use new functions from the runtime library.
Updated codegen to use the new functions from the runtime library.

llvm-svn: 350415
2019-01-04 17:25:09 +00:00
Aaron Ballman 9bdf515c74 Add two new pragmas for controlling software pipelining optimizations.
This patch adds #pragma clang loop pipeline and #pragma clang loop pipeline_initiation_interval for debugging or reducing compile time purposes. It is possible to disable SWP for concrete loops to save compilation time or to find bugs by not doing SWP to certain loops. It is possible to set value of initiation interval to concrete number to save compilation time by not doing extra pipeliner passes or to check created schedule for specific initiation interval.

Patch by Alexey Lapshin.

llvm-svn: 350414
2019-01-04 17:20:00 +00:00