Vedant Kumar [Tue, 26 Jun 2018 02:50:04 +0000 (02:50 +0000)]
[ubsan] Relax nullability-return for blocks with deduced types
When the return type of an ObjC-style block literals is deduced, pick
the candidate type with the strictest nullability annotation applicable
to every other candidate.
This suppresses a UBSan false-positive in situations where a too-strict
nullability would be deduced, despite the fact that the returned value
would be implicitly cast to _Nullable.
rdar://
41317163
llvm-svn: 335572
Vedant Kumar [Tue, 26 Jun 2018 02:50:01 +0000 (02:50 +0000)]
Modernize a function, NFC.
llvm-svn: 335571
Teresa Johnson [Tue, 26 Jun 2018 02:29:08 +0000 (02:29 +0000)]
[ThinLTO] Add string saver onto index for value names
Summary:
Adds a string saver to the ModuleSummaryIndex so it can store value
names in the case of adding a ValueInfo for a GUID when we don't
have the name stored in a Module string table. This is motivated
by the upcoming summary parser patch, where we will read value names
from the summary entry and want to store them, even when a Module
is not available.
Currently this allows us to store the name in the legacy bitcode case,
and I have added a test to show that.
Reviewers: pcc, dexonsmith
Subscribers: mehdi_amini, inglorion, eraman, steven_wu, llvm-commits
Differential Revision: https://reviews.llvm.org/D47842
llvm-svn: 335570
Peter Collingbourne [Tue, 26 Jun 2018 02:15:47 +0000 (02:15 +0000)]
Implement CFI for indirect calls via a member function pointer.
Similarly to CFI on virtual and indirect calls, this implementation
tries to use program type information to make the checks as precise
as possible. The basic way that it works is as follows, where `C`
is the name of the class being defined or the target of a call and
the function type is assumed to be `void()`.
For virtual calls:
- Attach type metadata to the addresses of function pointers in vtables
(not the functions themselves) of type `void (B::*)()` for each `B`
that is a recursive dynamic base class of `C`, including `C` itself.
This type metadata has an annotation that the type is for virtual
calls (to distinguish it from the non-virtual case).
- At the call site, check that the computed address of the function
pointer in the vtable has type `void (C::*)()`.
For non-virtual calls:
- Attach type metadata to each non-virtual member function whose address
can be taken with a member function pointer. The type of a function
in class `C` of type `void()` is each of the types `void (B::*)()`
where `B` is a most-base class of `C`. A most-base class of `C`
is defined as a recursive base class of `C`, including `C` itself,
that does not have any bases.
- At the call site, check that the function pointer has one of the types
`void (B::*)()` where `B` is a most-base class of `C`.
Differential Revision: https://reviews.llvm.org/D47567
llvm-svn: 335569
Craig Topper [Tue, 26 Jun 2018 01:37:02 +0000 (01:37 +0000)]
[X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction.
This recommits r335562 and 335563 as a single commit.
The frontend will surround the intrinsic with the appropriate marshalling to/from a scalar type to match the sigature of the builtin that software expects.
By exposing the vXi1 type directly in the llvm intrinsic we make it available to optimizers much earlier. This can enable the scalar marshalling code to be optimized away.
llvm-svn: 335568
Teresa Johnson [Tue, 26 Jun 2018 01:32:58 +0000 (01:32 +0000)]
[ThinLTO] Add per-module indexes to combined index consistently
Summary:
Without this change we only add module paths to the combined index when
there is a module hash or at least one global value. Make this more
consistent by adding the module to the index whenever there is a summary
section, and it is a per-module summary (had a MODULE_CODE_SOURCE_FILENAME
record).
Since we will no longer add module paths lazily, add a new interface to get
the module info from the index that asserts it is already added.
Fixes PR37899.
Reviewers: Vlad, pcc
Subscribers: mehdi_amini, inglorion, steven_wu, llvm-commits
Differential Revision: https://reviews.llvm.org/D48511
llvm-svn: 335567
Craig Topper [Tue, 26 Jun 2018 01:31:53 +0000 (01:31 +0000)]
Revert r335562 and 335563 "[X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction."
These were supposed to have been squashed to a single commit.
llvm-svn: 335566
Lang Hames [Tue, 26 Jun 2018 01:22:29 +0000 (01:22 +0000)]
[ORC] Add a symbolAliases function to the Core APIs.
symbolAliases can be used to define symbol aliases within a VSO.
llvm-svn: 335565
Craig Topper [Tue, 26 Jun 2018 00:44:02 +0000 (00:44 +0000)]
[X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction.
Additional IR is emitted to convert between scalar and vXi1 type to match the expected software inferface for the builtin that clang exposes.
llvm-svn: 335564
Craig Topper [Tue, 26 Jun 2018 00:43:46 +0000 (00:43 +0000)]
[X86] Redefine avx512 packed fpclass intrinsics to return a vXi1 mask and implement the mask input argument using an 'and' IR instruction.
The frontend will surround the intrinsic with the appropriate marshalling to/from a scalar type to match the sigature of the builtin that software expects.
By exposing the vXi1 type directly in the llvm intrinsic we make it available to optimizers much earlier. This can enable the scalar marshalling code to be optimized away.
llvm-svn: 335563
Craig Topper [Tue, 26 Jun 2018 00:43:34 +0000 (00:43 +0000)]
foo
llvm-svn: 335562
Fangrui Song [Tue, 26 Jun 2018 00:41:49 +0000 (00:41 +0000)]
[gdb] Escape unprintable bytes in SmallString and StringRef
llvm-svn: 335561
Teresa Johnson [Tue, 26 Jun 2018 00:20:49 +0000 (00:20 +0000)]
[ThinLTO] Compute GUID directly from GV when building per-module index
Summary:
I discovered when writing the summary parsing support that the
per-module index builder and writer are computing the GUID from the
value name alone (ignoring the linkage type). This was ok since those
GUID were not emitted in the bitcode, and there are never multiple
conflicting names in a single module.
However, I don't see a reason for making the GUID computation different
for the per-module case. It also makes things simpler on the parsing
side to have the GUID computation consistent. So this patch changes the
summary analysis phase and the per-module summary writer to compute the
GUID using the facility on the GlobalValue.
Reviewers: pcc, dexonsmith
Subscribers: llvm-commits, inglorion
Differential Revision: https://reviews.llvm.org/D47844
llvm-svn: 335560
Artem Dergachev [Mon, 25 Jun 2018 23:55:07 +0000 (23:55 +0000)]
[analyzer] Track null and undef values through expressions with cleanups.
ExprWithCleanups wraps full-expressions that require temporary destructors
and highlights the moment of time in which these destructors need to be called
(i.e., "at the end of the full-expression...").
Such expressions don't necessarily return an object; they may return anything,
including a null or undefined value.
When the analyzer tries to understand where the null or undefined value came
from in order to present better diagnostics to the user, it will now skip
any ExprWithCleanups it encounters and look into the expression itself.
Differential Revision: https://reviews.llvm.org/D48204
llvm-svn: 335559
Eric Christopher [Mon, 25 Jun 2018 23:53:54 +0000 (23:53 +0000)]
Add a warning if someone attempts to add extra section flags to sections
with well defined semantics like .rodata.
llvm-svn: 335558
Tim Shen [Mon, 25 Jun 2018 23:49:20 +0000 (23:49 +0000)]
[APInt] Add helpers for rounding u/sdivs.
Reviewers: sanjoy, craig.topper
Subscribers: jlebar, hiraditya, bixia, llvm-commits
Differential Revision: https://reviews.llvm.org/D48498
llvm-svn: 335557
Jason Molenda [Mon, 25 Jun 2018 23:45:39 +0000 (23:45 +0000)]
A little cleanup in ObjectFileMachO::GetSDKVersion.
This method does one of two things:
1. finds a minimum os deployment version # in a Mach-O load
command and saves the three parts in the m_sdk_version, or
2. finds no valid min os version # load command, pushes a
sentinel value on the m_sdk_version vector so we don't search
the same load commands multiple times.
There was a little bug when we found a load command with
a version of 0.0.0 - the method would not add anything to
the m_sdk_version vector but would declare that a success.
It would not push the sentinel value to the vector.
There was code later in the method which assumed that
the vector always had a sentinel value, at least, and that
code could crash when this method was called back when
evaluating a Swift expression. (these version #'s are
fetched lazily so it wouldn't happen when the object file
was parsed, only when doing an expression that needed
the version #).
<rdar://problem/
41372699>
llvm-svn: 335556
Artem Dergachev [Mon, 25 Jun 2018 23:43:45 +0000 (23:43 +0000)]
[analyzer] Fix invalidation on C++ const methods with arrow syntax.
Conservative evaluation of a C++ method call would invalidate the object,
as long as the method is not const or the object has mutable fields.
When checking for mutable fields, we need to scan the type of the object on
which the method is called, which may be more specific than the type of the
object on which the method is defined, hence we look up the type from the
this-argument expression.
If arrow syntax or implicit-this syntax is used, this-argument expression
has pointer type, not record type, and lookup accidentally failed for that
reason. Obtain object type correctly.
Differential Revision: https://reviews.llvm.org/D48460
llvm-svn: 335555
Fangrui Song [Mon, 25 Jun 2018 23:38:48 +0000 (23:38 +0000)]
[gdb] Add pretty printer for Expected
Reviewers: dblaikie
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D48512
llvm-svn: 335554
Chandler Carruth [Mon, 25 Jun 2018 23:32:54 +0000 (23:32 +0000)]
[PM/LoopUnswitch] Teach the new unswitch to handle nontrivial
unswitching of switches.
This works much like trivial unswitching of switches in that it reliably
moves the switch out of the loop. Here we potentially clone the entire
loop into each successor of the switch and re-point the cases at these
clones.
Due to the complexity of actually doing nontrivial unswitching, this
patch doesn't create a dedicated routine for handling switches -- it
would duplicate far too much code. Instead, it generalizes the existing
routine to handle both branches and switches as it largely reduces to
looping in a few places instead of doing something once. This actually
improves the results in some cases with branches due to being much more
careful about how dead regions of code are managed. With branches,
because exactly one clone is created and there are exactly two edges
considered, somewhat sloppy handling of the dead regions of code was
sufficient in most cases. But with switches, there are much more
complicated patterns of dead code and so I've had to move to a more
robust model generally. We still do as much pruning of the dead code
early as possible because that allows us to avoid even cloning the code.
This also surfaced another problem with nontrivial unswitching before
which is that we weren't as precise in reconstructing loops as we could
have been. This seems to have been mostly harmless, but resulted in
pointless LCSSA PHI nodes and other unnecessary cruft. With switches, we
have to get this *right*, and everything benefits from it.
While the testing may seem a bit light here because we only have two
real cases with actual switches, they do a surprisingly good job of
exercising numerous edge cases. Also, because we share the logic with
branches, most of the changes in this patch are reasonably well covered
by existing tests.
The new unswitch now has all of the same fundamental power as the old
one with the exception of the single unsound case of *partial* switch
unswitching -- that really is just loop specialization and not
unswitching at all. It doesn't fit into the canonicalization model in
any way. We can add a loop specialization pass that runs late based on
profile data if important test cases ever come up here.
Differential Revision: https://reviews.llvm.org/D47683
llvm-svn: 335553
Alexander Polyakov [Mon, 25 Jun 2018 23:29:52 +0000 (23:29 +0000)]
Fix windows build for r335541.
I didn't include <functional> header and used std::function.
llvm-svn: 335552
Craig Topper [Mon, 25 Jun 2018 23:29:47 +0000 (23:29 +0000)]
[X86] Update fpclass intrinsic tests to chain their calls to the intrinsic rather than joining them with add.
The test cases try to test masked and unmasked isntructions at the same time. Previously the masked version relies on an extra fucntion parameter. Then the two results were combined with 'add'.
This patch gets rid of the second parameter and just passes the result of the first intrinsic into the mask argument of the second call. Then there's no need for an 'add'.
This configuration works a lot better with an upcoming patch to redefine the intrinsics to use vXi1 types for the output and mask argument.
llvm-svn: 335551
Jessica Paquette [Mon, 25 Jun 2018 23:20:18 +0000 (23:20 +0000)]
[MachineOutliner] NFC - simplify -moutline/-mno-outline logic
It's a bit cleaner to use `hasFlag` instead of nested ifs. This
just refactors the -moutline/-mno-outline logic to use that.
llvm-svn: 335549
Francis Visoiu Mistrih [Mon, 25 Jun 2018 23:14:08 +0000 (23:14 +0000)]
[OrcMCJIT] Fix test after r335508 causing it to fail on green dragon
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/46572/console
LLVM ERROR: unsupported relocation with subtraction expression, symbol
'__GLOBAL_OFFSET_TABLE_' can not be undefined in a subtraction
expression
Do the same thing as MCJIT/eh-lg-pic.ll.
llvm-svn: 335548
Eric Christopher [Mon, 25 Jun 2018 23:12:04 +0000 (23:12 +0000)]
Fix unsigned/signed comparison failure in unittest.
llvm-svn: 335547
Yunlian Jiang [Mon, 25 Jun 2018 23:05:27 +0000 (23:05 +0000)]
Add an option to support debug fission on implicit ThinLTO.
Summary:
This adds an option -gsplit-dwarf=<arg>. LLVM can create .dwo files in the given directory
during the implicit ThinLTO link stage.
Reviewers: tejohnson, dblaikie, pcc
Reviewed By: pcc
Subscribers: steven_wu, aprantl, JDevlieghere, yunlian, probinson, mehdi_amini, inglorion, cfe-commits
Differential Revision: https://reviews.llvm.org/D44788
llvm-svn: 335546
Sanjay Patel [Mon, 25 Jun 2018 22:50:26 +0000 (22:50 +0000)]
[InstCombine] cleanup udiv folds; NFCI
This removes a "UDivFoldAction" in favor of a simple constant
matcher. In theory, the existing code could do more matching,
but I don't see any evidence or need for it. I've left a TODO
about using ValueTracking in case we see any regressions.
llvm-svn: 335545
Sanjay Patel [Mon, 25 Jun 2018 22:27:36 +0000 (22:27 +0000)]
[InstCombine] add/move tests for udiv; NFC
llvm-svn: 335544
Bruno Cardoso Lopes [Mon, 25 Jun 2018 22:25:48 +0000 (22:25 +0000)]
Fix tests from r335542 to use %hmaptool
llvm-svn: 335543
Bruno Cardoso Lopes [Mon, 25 Jun 2018 22:24:17 +0000 (22:24 +0000)]
Warning for framework include violation from Headers to PrivateHeaders
Framework vendors usually layout their framework headers in the
following way:
Foo.framework/Headers -> "public" headers
Foo.framework/PrivateHeader -> "private" headers
Since both headers in both directories can be found with #import
<Foo/some-header.h>, it's easy to make mistakes and include headers in
Foo.framework/PrivateHeader from headers in Foo.framework/Headers, which
usually configures a layering violation on Darwin ecosystems. One of the
problem this causes is dep cycles when modules are used, since it's very
common for "private" modules to include from the "public" ones; adding
an edge the other way around will trigger cycles.
Add a warning to catch those cases such that:
./A.framework/Headers/A.h:1:10: warning: public framework header includes private framework header 'A/APriv.h'
#include <A/APriv.h>
^
rdar://problem/
38712182
llvm-svn: 335542
Alexander Polyakov [Mon, 25 Jun 2018 22:01:44 +0000 (22:01 +0000)]
Implement new methods for handling an error in MI commands.
Summary:
The new methods take SBError object and call handler,
specified by user, depending on SBError status.
Reviewers: aprantl, clayborg, labath
Reviewed By: aprantl, clayborg
Subscribers: ki.stfu, lldb-commits
Differential Revision: https://reviews.llvm.org/D48295
llvm-svn: 335541
Benjamin Kramer [Mon, 25 Jun 2018 21:43:09 +0000 (21:43 +0000)]
[Instrumentation] Remove unused include
It's also a layering violation.
llvm-svn: 335528
Sanjay Patel [Mon, 25 Jun 2018 21:39:41 +0000 (21:39 +0000)]
[InstCombine] fold sdiv with sext bool divisor
llvm-svn: 335527
Sanjay Patel [Mon, 25 Jun 2018 21:36:09 +0000 (21:36 +0000)]
[InstCombine] add tests for sdiv with sext bool divisor; NFC
llvm-svn: 335526
Vlad Tsyrklevich [Mon, 25 Jun 2018 21:28:35 +0000 (21:28 +0000)]
UBSan blacklist workaround for bot timeouts
Summary: Workaround for PR37929
Reviewers: eugenis, vitalybuka
Reviewed By: eugenis
Subscribers: llvm-commits, kcc
Differential Revision: https://reviews.llvm.org/D48566
llvm-svn: 335525
David Carlier [Mon, 25 Jun 2018 21:10:25 +0000 (21:10 +0000)]
[UBsan] Enable ubsan minimal unit tests on OpenBSD
OpenBSD needs lld linker for sanitisers.
Disabling lint checking as some symbols cannot be defined and block the proper unit tests launch.
Reviewers: lebedev.ri, vitalybuka
Reviewed By: vitalybuka
Differential Revision: https://reviews.llvm.org/D48528
llvm-svn: 335524
Vedant Kumar [Mon, 25 Jun 2018 20:56:23 +0000 (20:56 +0000)]
[ubsan] Mark a test case as unsupported on Windows
__ubsan_on_report isn't defined as weak, and redefining it in a test is
not supported on Windows.
See the error message here: https://reviews.llvm.org/D48446
llvm-svn: 335523
Florian Hahn [Mon, 25 Jun 2018 20:55:26 +0000 (20:55 +0000)]
Revert r335513: [SCEVExp] Advance found insertion point
llvm-svn: 335522
Craig Topper [Mon, 25 Jun 2018 20:45:45 +0000 (20:45 +0000)]
[LoopIdiomRecognize] Fix a couple places where it appears we were unintenionally making copies of DebugLoc.
llvm-svn: 335521
Florian Hahn [Mon, 25 Jun 2018 20:40:50 +0000 (20:40 +0000)]
Force vector width for scev-expander-debug.ll test
llvm-svn: 335520
Matt Morehouse [Mon, 25 Jun 2018 20:30:03 +0000 (20:30 +0000)]
[CMake] Run libFuzzer tests with check-all.
Reviewers: kcc
Reviewed By: kcc
Subscribers: llvm-commits, mgorny
Differential Revision: https://reviews.llvm.org/D48200
llvm-svn: 335519
Craig Topper [Mon, 25 Jun 2018 20:27:46 +0000 (20:27 +0000)]
[X86] Simplify intrinsic table binary search to not require a temporary struct.
std::lower_bound doesn't require the thing to search for to be the same type as the table entries. We just need to define an appropriate comparison function that can take an table entry and an intrinsic number.
llvm-svn: 335518
Craig Topper [Mon, 25 Jun 2018 20:11:16 +0000 (20:11 +0000)]
[X86] Add comment about the sorting of the memory folding tables added in r335501.
llvm-svn: 335517
Michael Kruse [Mon, 25 Jun 2018 20:06:13 +0000 (20:06 +0000)]
Revert "Append new attributes to the end of an AttributeList."
This reverts commit r335084 as requested by David Jones and
Eric Christopher because of differences of emitted warnings.
llvm-svn: 335516
Fangrui Song [Mon, 25 Jun 2018 19:40:08 +0000 (19:40 +0000)]
[docs] Update doc after split of -gen-intrinsic in r335407
llvm-svn: 335515
Lei Huang [Mon, 25 Jun 2018 19:28:27 +0000 (19:28 +0000)]
[PowerPC] Fix incorrectly encoded wait instruction
Encoding for the wait instruction was wrong. Fix according to ISA 3.0.
Differential Revision: https://reviews.llvm.org/D48550
llvm-svn: 335514
Florian Hahn [Mon, 25 Jun 2018 19:17:29 +0000 (19:17 +0000)]
[SCEVExp] Advance found insertion point until we find a non-dbg instruction.
This avoids creating unnecessary casts if the IP used to be a dbg info
intrinsic. Fixes PR37727.
Reviewers: vsk, aprantl, sanjoy, efriedma
Reviewed By: vsk, efriedma
Differential Revision: https://reviews.llvm.org/D47874
llvm-svn: 335513
Sanjay Patel [Mon, 25 Jun 2018 18:51:21 +0000 (18:51 +0000)]
[InstSimplify] fold div/rem of zexted bool
I was looking at an unrelated fold and noticed that
we don't have this simplification (because the other
fold would break existing tests).
Name: zext udiv
%z = zext i1 %x to i32
%r = udiv i32 %y, %z
=>
%r = %y
Name: zext urem
%z = zext i1 %x to i32
%r = urem i32 %y, %z
=>
%r = 0
Name: zext sdiv
%z = zext i1 %x to i32
%r = sdiv i32 %y, %z
=>
%r = %y
Name: zext srem
%z = zext i1 %x to i32
%r = srem i32 %y, %z
=>
%r = 0
https://rise4fun.com/Alive/LZ9
llvm-svn: 335512
Kamil Rytarowski [Mon, 25 Jun 2018 18:49:13 +0000 (18:49 +0000)]
Handle NetBSD specific path in findDebugBinary()
Summary:
The NetBSD Operating System installs debuginfo
files into /usr/libdata/debug, rather than other path
like in some other popular distribution.
This change makes llvm-symbolizer functional with
the basesystem executables.
Reviewers: joerg, vitalybuka
Reviewed By: vitalybuka
Subscribers: JDevlieghere, llvm-commits
Differential Revision: https://reviews.llvm.org/D48525
llvm-svn: 335511
Sam Clegg [Mon, 25 Jun 2018 18:47:32 +0000 (18:47 +0000)]
[WebAssembly] Add no-prototype attribute to prototype-less C functions
The WebAssembly backend in particular benefits from being
able to distinguish between varargs functions (...) and prototype-less
C functions.
Differential Revision: https://reviews.llvm.org/D48443
llvm-svn: 335510
Sanjay Patel [Mon, 25 Jun 2018 18:27:14 +0000 (18:27 +0000)]
[InstSimplify] add tests for div/rem with bool divisor; NFC
llvm-svn: 335509
Reid Kleckner [Mon, 25 Jun 2018 18:16:27 +0000 (18:16 +0000)]
Re-land r335297 "[X86] Implement more of x86-64 large and medium PIC code models"
The large code model allows code and data segments to exceed 2GB, which
means that some symbol references may require a displacement that cannot
be encoded as a displacement from RIP. The large PIC model even relaxes
the assumption that the GOT itself is within 2GB of all code. Therefore,
we need a special code sequence to materialize it:
.LtmpN:
leaq .LtmpN(%rip), %rbx
movabsq $_GLOBAL_OFFSET_TABLE_-.LtmpN, %rax # Scratch
addq %rax, %rbx # GOT base reg
From that, non-local references go through the GOT base register instead
of being PC-relative loads. Local references typically use GOTOFF
symbols, like this:
movq extern_gv@GOT(%rbx), %rax
movq local_gv@GOTOFF(%rbx), %rax
All calls end up being indirect:
movabsq $local_fn@GOTOFF, %rax
addq %rbx, %rax
callq *%rax
The medium code model retains the assumption that the code segment is
less than 2GB, so calls are once again direct, and the RIP-relative
loads can be used to access the GOT. Materializing the GOT is easy:
leaq _GLOBAL_OFFSET_TABLE_(%rip), %rbx # GOT base reg
DSO local data accesses will use it:
movq local_gv@GOTOFF(%rbx), %rax
Non-local data accesses will use RIP-relative addressing, which means we
may not always need to materialize the GOT base:
movq extern_gv@GOTPCREL(%rip), %rax
Direct calls are basically the same as they are in the small code model:
They use direct, PC-relative addressing, and the PLT is used for calls
to non-local functions.
This patch adds reasonably comprehensive testing of LEA, but there are
lots of interesting folding opportunities that are unimplemented.
I restricted the MCJIT/eh-lg-pic.ll test to Linux, since the large PIC
code model is not implemented for MachO yet.
Differential Revision: https://reviews.llvm.org/D47211
llvm-svn: 335508
Matt Morehouse [Mon, 25 Jun 2018 18:01:51 +0000 (18:01 +0000)]
[CMake] Fix install-cxx target.
Was broken by r334477.
llvm-svn: 335507
Sanjay Patel [Mon, 25 Jun 2018 17:52:10 +0000 (17:52 +0000)]
[InstCombine] add tests for add-of-sext-bool; NFC
We canonicalize to select with a zext-add and either zext-sub or sext-sub,
so this shows a pattern that's not conforming to the general trend.
llvm-svn: 335506
Aditya Nandakumar [Mon, 25 Jun 2018 17:48:48 +0000 (17:48 +0000)]
[GISel]: Update the end of GISel Opcode namespace.
G_ADDRSPACE_CAST was added at the end, but PRE_ISEL_GENERIC_OPCODE_END
is still pointing incorrectly.
llvm-svn: 335505
Jessica Paquette [Mon, 25 Jun 2018 17:36:05 +0000 (17:36 +0000)]
[MachineOutliner] Outline from linkonceodrs by default in LTO when -moutline is passed
Pass -enable-linkonceodr-outlining by default when LTO is enabled.
The outliner shouldn't compete with any sort of linker deduplication
on linkonceodr functions when LTO is enabled. Therefore, this behaviour
should be the default.
llvm-svn: 335504
Jessica Paquette [Mon, 25 Jun 2018 17:27:51 +0000 (17:27 +0000)]
[MachineOutliner] Make last of -moutline/-mno-outline win
The expected behaviour of command-line flags to clang is to have
the last of -m(whatever) and -mno-(whatever) win. The outliner
didn't do that. This fixes that and updates the test.
llvm-svn: 335503
Alex Shlyapnikov [Mon, 25 Jun 2018 17:27:13 +0000 (17:27 +0000)]
[HWASan] Initalize shadow earler.
Summary:
Initialize shadow memory before calling more libc functions to allow
for HWASan-instrumented libc.
Reviewers: eugenis
Subscribers: kubamracek, delcypher, #sanitizers, llvm-commits
Differential Revision: https://reviews.llvm.org/D48551
llvm-svn: 335502
Craig Topper [Mon, 25 Jun 2018 17:26:56 +0000 (17:26 +0000)]
[X86] Sort the static memory folding tables by reg opcode. Remove the reg->mem DenseMaps in favor of binary search.
With the static tables sorted we can binary search them directly for reg->mem lookups. This removes 6 DenseMaps that had to be created when X86InstrInfo is constructed.
We still have one Mem->Reg DenseMap for the reverse direction. This is created just as before by walking the reg->mem arrays to populate it.
Differential Revision: https://reviews.llvm.org/D48527
llvm-svn: 335501
Craig Topper [Mon, 25 Jun 2018 17:26:51 +0000 (17:26 +0000)]
[X86] Allow base and index for gather instructions to appear in other order for Intel syntax.
llvm-svn: 335500
Fangrui Song [Mon, 25 Jun 2018 17:16:01 +0000 (17:16 +0000)]
[ELF] Fix sort-non-script.s
llvm-svn: 335499
Fangrui Song [Mon, 25 Jun 2018 17:07:40 +0000 (17:07 +0000)]
[ELF] Change test files for style consistency. NFC
* Move `REQUIRES:` line to the top
* llvm-mc ... -o %t -> llvm-mc ... -o %t.o
* Don't check "TEXT" "DATA" columns (they are bfd-style names that do
not fit into llvm well) in llvm-objdump output
llvm-svn: 335498
Vedant Kumar [Mon, 25 Jun 2018 17:06:18 +0000 (17:06 +0000)]
[SelectionDAG] Remove debug locations from ConstantSD(FP)Nodes
This removes debug locations from ConstantSDNode and ConstantSDFPNode.
When this kind of node is materialized we no longer create a line table
entry which jumps back to the constant's first point of use. This makes
single-stepping behavior smoother, and it matches the model used by IR,
where Constants have no locations. See this thread for more context:
http://lists.llvm.org/pipermail/llvm-dev/2018-June/124164.html
I'd like to handle constant BuildVectorSDNodes and to try to eliminate
passing SDLocs to SelectionDAG::getConstant*() in follow-up commits.
Differential Revision: https://reviews.llvm.org/D48468
llvm-svn: 335497
Matt Davis [Mon, 25 Jun 2018 16:53:00 +0000 (16:53 +0000)]
[llvm-mca] Rename Backend to Pipeline. NFC.
Summary:
This change renames the Backend and BackendPrinter to Pipeline and PipelinePrinter respectively.
Variables and comments have also been updated to reflect this change.
The reason for this rename, is to be slightly more correct about what MCA is modeling. MCA models a Pipeline, which implies some logical sequence of stages.
Reviewers: andreadb, courbet, RKSimon
Reviewed By: andreadb, courbet
Subscribers: mgorny, javed.absar, tschuett, gbedwell, llvm-commits
Differential Revision: https://reviews.llvm.org/D48496
llvm-svn: 335496
Alexander Richardson [Mon, 25 Jun 2018 16:49:52 +0000 (16:49 +0000)]
Use Triple::isMIPS() instead of enumerating all Triples. NFC
Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D48549
llvm-svn: 335495
Fangrui Song [Mon, 25 Jun 2018 16:49:52 +0000 (16:49 +0000)]
[ELF] readobj -elf-output-style=GNU -> readelf
Style change for consistency. NFC
llvm-svn: 335494
Alexander Richardson [Mon, 25 Jun 2018 16:49:20 +0000 (16:49 +0000)]
Add Triple::isMIPS()/isMIPS32()/isMIPS64(). NFC
There are quite a few if statements that enumerate all these cases. It gets
even worse in our fork of LLVM where we also have a Triple::cheri (which
is mips64 + CHERI instructions) and we had to update all if statements that
check for Triple::mips64 to also handle Triple::cheri. This patch helps to
reduce our diff to upstream and should also make some checks more readable.
Reviewed By: atanasyan
Differential Revision: https://reviews.llvm.org/D48548
llvm-svn: 335493
Eric Liu [Mon, 25 Jun 2018 16:29:19 +0000 (16:29 +0000)]
[clang-format] Add a default format style that can be used by users of `getStyle`
Summary:
Tools that reformat code often call `getStyle` to decide the format style
to use on a certain source file. In practice, "file" style is widely used. As a
result, many tools hardcode "file" when calling `getStyle`, which makes it hard
to control the default style in tools across a codebase when needed. This change
introduces a `DefaultFormatStyle` constant (default to "file" in upstream), which
can be modified downstream if wanted, so that all users/tools built from the same
source tree can have a consistent default format style.
This also adds an DefaultFallbackStyle that is recommended to be used by tools and can be modified downstream.
Reviewers: sammccall, djasper
Reviewed By: sammccall
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D48492
llvm-svn: 335492
Gabor Marton [Mon, 25 Jun 2018 16:25:30 +0000 (16:25 +0000)]
Revert "[ASTImporter] Import the whole redecl chain of functions"
This reverts commit r335480.
llvm-svn: 335491
Matt Arsenault [Mon, 25 Jun 2018 16:17:48 +0000 (16:17 +0000)]
AMDGPU/GlobalISel: Add support for llvm.amdgcn.kernarg.segment.ptr
Note a normal select test is not currently possible because this
relies on input registers tracked in SIMachineFunctionInfo which
are not currently serializable in MIR, but this does work end-to-end
from the IR.
llvm-svn: 335490
David Carlier [Mon, 25 Jun 2018 16:10:20 +0000 (16:10 +0000)]
[LLDB] Select helper sign comparison fix
The constant could be unsigned thus explicit cast to silent compilation warnings
Reviewers: aprantl
Reviewed By: aprantl
Differential Revision: https://reviews.llvm.org/D48540
llvm-svn: 335489
Matt Arsenault [Mon, 25 Jun 2018 16:05:55 +0000 (16:05 +0000)]
StackSlotColoring: Decide colors per stack ID
I thought I fixed this in r308673, but that fix was
very broken. The assumption that any frame index can be used
in place of another was more widespread than I realized.
Even when stack slot sharing was disabled, this was still
replacing frame index uses with a different ID with a different
stack slot.
Really fix this by doing the coloring per-stack ID, so all of
the coloring logically done in a separate namespace. This is a lot
simpler than trying to figure out how to change the color if
the stack ID is different.
llvm-svn: 335488
Matt Morehouse [Mon, 25 Jun 2018 15:59:24 +0000 (15:59 +0000)]
[libFuzzer] Use Vector rather than std::vector.
llvm-svn: 335487
Matt Arsenault [Mon, 25 Jun 2018 15:42:20 +0000 (15:42 +0000)]
AMDGPU: Remove commented out code
llvm-svn: 335486
Matt Arsenault [Mon, 25 Jun 2018 15:42:12 +0000 (15:42 +0000)]
AMDGPU/GlobalISel: Fix G_IMPLICIT_DEF for pointers
llvm-svn: 335485
Wei Mi [Mon, 25 Jun 2018 15:40:31 +0000 (15:40 +0000)]
[SampleFDO] Add an option to turn on/off warning about samples unused.
If a function has sample to use, but cannot use them because of no debug
information, currently a warning will be issued to inform the missing
opportunity.
This warning assumes the binary generating the profile and the binary using
the profile are similar enough. It is not always the case. Sometimes even
if the binaries are not quite similar, we may still get some benefit by
using sampleFDO. In those cases, we may still want to apply sampleFDO but
not want to see a lot of such warnings pop up.
The patch adds an option for the warning.
Differential Revision: https://reviews.llvm.org/D48510
llvm-svn: 335484
Alexey Bataev [Mon, 25 Jun 2018 15:32:05 +0000 (15:32 +0000)]
[OPENMP] Do not consider address constant vars as possibly
threadprivate.
Do not delay emission of the address constant variables in OpenMP mode
as they cannot be defined as threadprivate.
llvm-svn: 335483
George Rimar [Mon, 25 Jun 2018 15:27:09 +0000 (15:27 +0000)]
[ELF] - ICF: add one more test case #3.
ICF is able to merge sections which relocations referring regular input sections
or mergeable sections, so it handles InputSection and MergeInputSection cases.
The following "return false" line which is executed in case of another type
of the sections is uncovered by our test cases:
https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L285
Patch fixes code coverage for this place.
llvm-svn: 335482
David Green [Mon, 25 Jun 2018 15:13:26 +0000 (15:13 +0000)]
[DA] Delinearise AddRecs if we can prove they don't wrap
We can prove that some delinearized subscripts do not wrap around to become
negative by the fact that they are from inbound geps of load/store locations.
This helps improve the delinearisation in cases where we can't prove that they
are non-negative from SCEV alone.
Differential Revision: https://reviews.llvm.org/D48481
llvm-svn: 335481
Gabor Marton [Mon, 25 Jun 2018 14:41:58 +0000 (14:41 +0000)]
[ASTImporter] Import the whole redecl chain of functions
Summary:
With this patch when any `FunctionDecl` of a redeclaration chain is imported
then we bring in the whole declaration chain. This involves functions and
function template specializations. Also friend functions are affected. The
chain is imported as it is in the "from" tu, the order of the redeclarations
are kept. I also changed the lookup logic in order to find friends, but first
making them visible in their declaration context. We may have long
redeclaration chains if all TU contains the same prototype, but our
measurements shows no degradation in time of CTU analysis (Tmux, Xerces,
Bitcoin, Protobuf). Also, as further work we could squash redundant
prototypes, but first ensure that functionality is working properly; then
should we optimize.
This may seem like a huge patch, sorry about that. But, most of the changes are
new tests, changes in the production code is not that much. I also tried to
create a smaller patch which does not affect specializations, but that patch
failed to pass some of the `clang-import-test`s because there we import
function specializations. Also very importantly, we can't just change the
import of `FunctionDecl`s without changing the import of function template
specializations because they are handled as `FunctionDecl`s.
Reviewers: a.sidorin, r.stahl, xazax.hun, balazske
Subscribers: rnkovacs, dkrupp, cfe-commits
Differential Revision: https://reviews.llvm.org/D47532
llvm-svn: 335480
George Rimar [Mon, 25 Jun 2018 14:35:47 +0000 (14:35 +0000)]
[ELF] - Rewrote comment. NFC.
llvm-svn: 335479
Matt Arsenault [Mon, 25 Jun 2018 14:29:04 +0000 (14:29 +0000)]
AMDGPU: Respect align argument parameter
This should avoid relying on the pointee type
to get the alignment, particularly since pointee
types are supposed to be removed at some point.
Also fixes not getting the alignment for unsized types.
llvm-svn: 335478
George Rimar [Mon, 25 Jun 2018 14:28:40 +0000 (14:28 +0000)]
[ELF] - ICF: add one more test case #2.
Check that ICF does not merge sections which relocations
have equal addends, but different target values.
This covers the following line, which was uncovered:
https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L278
llvm-svn: 335477
Pavel Labath [Mon, 25 Jun 2018 14:28:38 +0000 (14:28 +0000)]
Fix TestThreadExit for gcc&libc++ combo
pseudo_barrier_wait() begins by decrementing an atomic variable. Since
these are always_inline in libc++, there is no line table anchor to
break on before we decrement it. This meant that on gcc we stopped after
the variable has been decremented, which meant that thread2 could have
exited, violating the test setup. On clang this wasn't a problem
because it generated some line table entries for the do{}while(0) loop
in the macro, so we still ended up stopping, before we touched the
variable.
I fix this by adding a dummy statement before the pseudo_barrier_wait()
command and setting the breakpoint there.
llvm-svn: 335476
George Rimar [Mon, 25 Jun 2018 14:00:05 +0000 (14:00 +0000)]
[ELF] - ICF: add one more test case.
This test case check that ICF does not merge 2 sections which relocations
efer to symbols that live in sections of the different types
(regular input section and mergeable input sections in this case).
It covers the following line of code, which was uncovered previously:
https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L271
llvm-svn: 335475
Artur Pilipenko [Mon, 25 Jun 2018 13:51:11 +0000 (13:51 +0000)]
SafepointIRVerifier should ignore dead blocks and dead edges
Not only should SafepointIRVerifier ignore unreachable blocks (as suggested in https://reviews.llvm.org/D47011) but it also has to ignore dead blocks.
In @test2 (see the new tests):
br i1 true, label %right, label %left
left:
...
right:
...
merge:
%val = phi i8 addrspace(1)* [ ..., %left ], [ ..., %right ]
use %val
both left and right branches are reachable.
If they collide then SafepointIRVerifier reports an error.
Because of the foldable branch condition GVN finds the left branch dead and removes the phi node entry that merges values from right and left. Then the use comes from the right branch. This results in no collision.
So, SafepointIRVerifier ends up in different results depending on either GVN is run or not.
To solve this issue this patch adds Dead Block detection to SafepointIRVerifier which can ignore dead blocks while validating IR. The Dead Block detection algorithm is taken from GVN but modified to not split critical edges. That is needed to keep CFG unchanged by SafepointIRVerifier.
Patch by Yevgeny Rouban.
Reviewed By: anna, apilipenko, DaniilSuchkov
Differential Revision: https://reviews.llvm.org/D47441
llvm-svn: 335473
Krzysztof Parzyszek [Mon, 25 Jun 2018 13:46:41 +0000 (13:46 +0000)]
Improve handling of COPY instructions with identical value numbers
Testcases provided by Tim Renouf.
Differential Revision: https://reviews.llvm.org/D48102
llvm-svn: 335472
George Rimar [Mon, 25 Jun 2018 13:46:39 +0000 (13:46 +0000)]
Revert r335460 "[ELF] - ICF: Remove dead code. NFC."
My mistake, it was not NFC.
llvm-svn: 335471
Clement Courbet [Mon, 25 Jun 2018 13:44:27 +0000 (13:44 +0000)]
[llvm-exegesis][NFC] Remove unnecessary member variables.
llvm-svn: 335470
Alexey Bataev [Mon, 25 Jun 2018 13:43:35 +0000 (13:43 +0000)]
[OPENMP, NVPTX] Fixes for NVPTX RTL
Summary:
Patch fixes several problems in the implementation of NVPTX RTL.
1. Detection of the last iteration for loops with static scheduling, no chunks.
2. Fixes reductions for the serialized parallel constructs.
3. Fixes handling of the barriers.
Reviewers: grokos
Reviewed By: grokos
Subscribers: Hahnfeld, guansong, openmp-commits
Differential Revision: https://reviews.llvm.org/D48480
llvm-svn: 335469
Sanjay Patel [Mon, 25 Jun 2018 13:40:54 +0000 (13:40 +0000)]
[IR] avoid -Wdocumentation spew about HTML tags
There's probably a better solution, but adding spaces
in the IR vector examples sidesteps the problem without
uglifying the plain text.
llvm-svn: 335468
Clement Courbet [Mon, 25 Jun 2018 13:39:50 +0000 (13:39 +0000)]
[llvm-exegesis] Fix warning in r22752: Initialize IsSnippetSetupComplete.
llvm-svn: 335467
Hans Wennborg [Mon, 25 Jun 2018 13:23:49 +0000 (13:23 +0000)]
[clang-cl] Don't emit dllexport inline functions etc. from pch files (PR37801)
With MSVC, PCH files are created along with an object file that needs to
be linked into the final library or executable. That object file
contains the code generated when building the headers. In particular, it
will include definitions of inline dllexport functions, and because they
are emitted in this object file, other files using the PCH do not need
to emit them. See the bug for an example.
This patch makes clang-cl match MSVC's behaviour in this regard, causing
significant compile-time savings when building dlls using precompiled
headers.
For example, in a 64-bit optimized shared library build of Chromium with
PCH, it reduces the binary size and compile time of
stroke_opacity_custom.obj from 9315564 bytes to 3659629 bytes and 14.6
to 6.63 s. The wall-clock time of building blink_core.dll goes from
38m41s to 22m33s. ("user" time goes from 1979m to 1142m).
Differential Revision: https://reviews.llvm.org/D48426
llvm-svn: 335466
Clement Courbet [Mon, 25 Jun 2018 13:12:02 +0000 (13:12 +0000)]
[llvm-exegesis] Generate snippet setup code.
Summary:
This ensures that the snippet always sees the same values for registers,
making measurements reproducible.
This will also allow exploring different values.
Reviewers: gchatelet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D48542
llvm-svn: 335465
Gabor Marton [Mon, 25 Jun 2018 13:04:37 +0000 (13:04 +0000)]
[ASTImporter] Add ms compatibility to tests which use the TestBase
Summary:
In order to avoid build failures on MS, we use -fms-compatibility too in
the tests which use the TestBase. Moved the family of `testImport`
functions under a test fixture class, so we can use parameterized tests.
Refactored `testImport` and `testImportSequence`, because `for` loops over
the different compiler options is no longer needed, that is handeld by
the test framework via parameters from now on.
Reviewers: a.sidorin, r.stahl, xazax.hun
Subscribers: rnkovacs, dkrupp, cfe-commits
Differential Revision: https://reviews.llvm.org/D47367
llvm-svn: 335464
Artur Pilipenko [Mon, 25 Jun 2018 12:58:13 +0000 (12:58 +0000)]
Revert change 335077 "[InlineSpiller] Fix a crash due to lack of forward progress from remat specifically for STATEPOINT"
This change caused widespread assertion failures in our downstream testing:
lib/CodeGen/LiveInterval.cpp:409: bool llvm::LiveRange::overlapsFrom(const llvm::LiveRange&, llvm::LiveRange::const_iterator) const: Assertion `!empty() && "empty range"' failed.
llvm-svn: 335462
Artur Pilipenko [Mon, 25 Jun 2018 12:55:58 +0000 (12:55 +0000)]
Revert change 335091.
It adds extra test for the change 335077, which is also to be reverted as it causes test failures in downstream testing.
llvm-svn: 335461
George Rimar [Mon, 25 Jun 2018 12:51:55 +0000 (12:51 +0000)]
[ELF] - ICF: Remove dead code. NFC.
Code is dead. We use only InputSections when building the list of
sections elegible for the ICF:
https://github.com/llvm-mirror/lld/blob/master/ELF/ICF.cpp#L439
And 'isEligible' filters out SyntheticSections as well for us.
That way the only Kind we have in the Sections vector is SectionBase::Regular,
so we do not need to check sections kind at all, it is always the same.
llvm-svn: 335460
Krasimir Georgiev [Mon, 25 Jun 2018 12:43:12 +0000 (12:43 +0000)]
[clang-format] Keep @message together in text protos
Summary:
In C++ code snippets of the form `@field` are common. This makes clang-format
keep them together in text protos, whereas before it would break them.
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D48543
llvm-svn: 335459
Eric Liu [Mon, 25 Jun 2018 11:50:11 +0000 (11:50 +0000)]
[clangd] Always remove dots before converting paths to URIs in symbol collector.
llvm-svn: 335458