Commit Graph

115275 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
e2305f7e90 DebugInfo: Require valid DIDescriptors
As part of PR22777, switch from `dyn_cast_or_null<>` to `cast<>` in most
`DIDescriptor` accessors.  These classes are lightweight wrappers around
pointers, so the users should check for valid pointers before using
them.

This survives a Darwin clang -g bootstrap (after fixing testcases), but
it's possible the bots will complain about other configurations.  I'll
fix any fallout as quickly as I can!  Once this bakes for a bit I'll
remove the macros.

Note that `DebugLoc` implicitly gets stricter with this change as well,
since it forward to `DILocation`.  Any code that's using `DebugLoc`
accessors should check `DebugLoc::isUnknown()` first.  (BTW, I'm also
partway through a cleanup of the `DebugLoc` API to make it more obvious
what it is (a glorified pointer wrapper) and remove cruft from before
the Metadata/Value split.  I'll commit soon.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232844 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 20:17:07 +00:00
Rafael Espindola
d80979b25d Don't declare all text sections at the start of the .s
The code this patch removes was there to make sure the text sections went
before the dwarf sections. That is necessary because MachO uses offsets
relative to the start of the file, so adding a section can change relaxations.

The dwarf sections were being printed at the start just to produce symbols
pointing at the start of those sections.

The underlying issue was fixed in r231898. The dwarf sections are now printed
when they are about to be used, which is after we printed the text sections.

To make sure we don't regress, the patch makes the MachO streamer assert
if CodeGen puts anything unexpected after the DWARF sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232842 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 20:00:01 +00:00
Duncan P. N. Exon Smith
e9994ab8a7 Bugpoint: Fix invalid 'inlinedAt:' references in testcase
These are causing crashes in `DebugInfoFinder` after a WIP patch to
increase strictness of `DIDescriptor` accessors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232839 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 19:51:34 +00:00
Duncan P. N. Exon Smith
214538864d AsmPrinter: Check subprogram before using it
Check return of `getDISubprogram()` before using it.  A WIP patch makes
`DIDescriptor` accessors more strict (and would crash on this).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232838 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 19:50:00 +00:00
Rafael Espindola
82759c6cac Reorganize the x86 ELF relocation selection logic.
The main differences are:

* Split in 32 and 64 bit functions.
* First switch on the Modifier so that we have only one non fully covered
  switch.
* Map the fixup kind first to a x86_64 (or i386) specific enum, to make
  it easy to handle cases like X86::reloc_riprel_4byte_movq_load.
* Switch on IsPCRel last, which reduces code duplication.

Fixes pr22308.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232837 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 19:48:54 +00:00
Duncan P. N. Exon Smith
c128839d6c DwarfDebug: Check for null DebugLocs
`DL` might be null, so check for that before using accessors.  A WIP
patch to make `DIDescriptors` more strict fails otherwise.

As a bonus, I think the logic is easier to follow now (despite the extra
nesting depth).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232836 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 19:37:03 +00:00
Duncan P. N. Exon Smith
d94d5bbbf9 Verifier: Check that !dbg attachments have the right type
A WIP patch makes `DIDescriptor` accessors more strict, which in turn
causes the `DebugInfoFinder` to crash on wrongly typed `!dbg`
attachments.  Catch that error up front in
`Verifier::visitInstruction()`.

Also remove a test that we "handle" invalid `!dbg` attachments, added
back in r99938.  We don't want to handle those anymore.

Note: I'm *not* recursing and verifying the debug info graph reachable
from this node; that work is already done by `verifyDebugInfo()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232834 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 19:26:58 +00:00
Duncan P. N. Exon Smith
c867853c90 DebugInfoFinder: Check for null imported entities
Don't use the accessors in `DIImportedEntity` on a null pointer.  (A WIP
patch to make `DIDescriptor` accessors more strict crashes here
otherwise.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232833 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 19:13:53 +00:00
Duncan P. N. Exon Smith
14d8dbd37d SanitizerCoverage: Check for null DebugLocs
After a WIP patch to make `DIDescriptor` accessors more strict, this
started asserting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232832 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 18:48:45 +00:00
Hans Wennborg
11053bd878 SelectionDAGBuilder: Rangeify a loop. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232831 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 18:48:40 +00:00
Hans Wennborg
13e18d951c SelectionDAGBuilder::handleJTSwitchCase, simplify loop; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232830 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 18:48:31 +00:00
Duncan P. N. Exon Smith
1188480049 Rewrite test/Feature/md_on_instruction.ll
This test is supposed to be testing whether metadata attachments to
instructions work, but it was using invalid debug info to do so.  (This
was causing assertion failures in the `DebugInfoFinder` with a WIP patch
to be more strict about `DIDescriptor` accessors.)

Rather than fix the debug info -- which is better tested elsewhere --
just test the IR feature directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232828 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 18:34:53 +00:00
Wei Mi
8979e3f69b Correctly estimate SROA savings for store operands in inline cost analysis.
When estimating SROA savings, we want to see if an address is derived
off an alloca in the caller. For store instructions, operand 1 is the
address operand, but the current code uses operand 0.  Use
getPointerOperand for loads and stores to fix this.

Patch by Easwaran Raman.
http://reviews.llvm.org/D8425


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232827 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 18:33:12 +00:00
Daniel Berlin
e7cec1e853 Small optimization to avoid getting pass info when we will not run loop
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232826 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 18:05:49 +00:00
John Brawn
151a5da534 [ARM] Fix handling of thumb1 out-of-range frame offsets
LocalStackSlotPass assumes that isFrameOffsetLegal doesn't change its
answer when the base register changes. Unfortunately this isn't true
in thumb1, where SP-based loads allow a larger offset than
non-SP-based loads, and this causes the base register reuse code to
generate instructions that are unencodable, causing an assertion
failure. 

Solve this by adding a BaseReg parameter to isFrameOffsetLegal, which
ARMBaseRegisterInfo can then make use of to give the correct answer. 

Differential Revision: http://reviews.llvm.org/D8419


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232825 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 17:20:07 +00:00
Simon Pilgrim
45f61bfec3 Stripped trailing whitespace. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232822 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 16:08:17 +00:00
Eric Christopher
aa6604c351 Rewrite StackMap location handling to pre-compute the dwarf register
numbers before emission.

This removes a dependency on being able to access TRI at the module
level and is similar to the DwarfExpression handling. I've modified
the debug support into print/dump routines that'll do the same dumping
but is now callable anywhere and if TRI isn't available will go ahead
and just print out raw register numbers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232821 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 16:03:42 +00:00
Eric Christopher
abc546afd1 At the beginning of doFinalization set the MachineFunction to
nullptr so that users get an earlier dereferencing error and
so that we can use it to conditionalize access to MachineFunction
specific data.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232820 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 16:03:39 +00:00
Chad Rosier
dda7fcbd99 Typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232819 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 15:45:14 +00:00
Tom Stellard
18e8ab1112 R600/SI: Refactor VOP2 instruction defs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232817 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 15:14:23 +00:00
Tom Stellard
fb9cd4bbd8 R600/SI: Refactor VOP1 instruction defs
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232816 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 15:14:21 +00:00
Rafael Espindola
c2c5c09f1c Reduce indentation after return. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232814 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 14:33:25 +00:00
Rafael Espindola
6ee46c4389 Use early returns. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232813 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 14:23:46 +00:00
Rafael Espindola
c09121b93b Fold a llvm_unreachable into an assert. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232811 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 13:50:15 +00:00
Rafael Espindola
ddcc06d824 clang-format a function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232810 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 13:47:40 +00:00
Daniel Jasper
70b146b25e [MBP] Don't outline short optional branches
With the option -outline-optional-branches, LLVM will place optional
branches out of line (more details on r231230).

With this patch, this is not done for short optional branches. A short
optional branch is a branch containing a single block with an
instruction count below a certain threshold (defaulting to 3). Still
everything is guarded under -outline-optional-branches).

Outlining a short branch can't significantly improve code locality. It
can however decrease performance because of the additional jmp and in
cases where the optional branch is hot. This fixes a compile time
regression I have observed in a benchmark.

Review: http://reviews.llvm.org/D8108

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232802 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 10:00:37 +00:00
Craig Topper
3220d112fa [Tablegen] Attempt to add support for patterns containing nodes with multiple results.
This is needed for AVX512 masked scatter/gather support.

The R600 change is necessary to remove a hack that was working around the lack of multiple results.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232798 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 05:09:06 +00:00
Tom Stellard
4aee931a46 R600/SI: Add missing CHECK-LABEL lines to a test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232797 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 03:12:42 +00:00
Nick Lewycky
9478751e46 Fix comment from r232794. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232796 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 02:52:23 +00:00
Alexei Starovoitov
2611a42321 [bpf] fix build
fix BPF backend build broken by r232699

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232795 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 02:35:29 +00:00
Nick Lewycky
bea9b06e84 When simplifying a SCEV truncate by distributing, consider it a simplification to replace a cast, even if we end up with a trunc around the term. Fixes PR22960!
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232794 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 02:25:00 +00:00
Duncan P. N. Exon Smith
67934e4b41 SampleProfile: Check for missing debug locations
Don't use `DebugLoc` accessors if we're pointing at null, which will be
a problem after a WIP patch to make the `DIDescriptor` accessors more
strict.  Caught by Frontend/profile-sample-use-loc-tracking.c (in
clang).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232792 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 00:56:55 +00:00
Duncan P. N. Exon Smith
e48bd555a0 Verifier: Remove the separate DebugInfoVerifier class
Remove the separate `DebugInfoVerifier` class, as a partial step toward
better integrating debug info verification with the `Verifier`.

Right now, verification of debug info is kind of a mess.

  - There are `DIDescriptor::Verify()` checks live in `DebugInfo.cpp`.
    These return `bool`, and there's no way to see (except by opening a
    debugger) why they fail.
  - We rely on `DebugInfoFinder` to traverse the debug info graph and
    dig up nodes.  However, the regular `Verifier` visits many of these
    nodes when it calls into debug info intrinsic operands.  Visiting
    twice and running different checks is kind of absurd.
  - Moreover, `DebugInfoFinder` asserts on failed type resolution -- the
    verifier should never assert!

By integrating the two verifiers, I'm aiming at solving these problems
(work to be done, obviously).  Verification can be localized to the
`Verifier`; we can use a naive `MDNode` operand traversal to find all
the nodes; we can verify type references instead of asserting on
failure.

There are `assert()`s sprinkled throughout the optimizer and dwarf
backend on `DIDescriptor::Verify()` checks.  This is a hangover from
when the debug info verifier was off, so I plan to remove them as I go
(once I confirm that the checks are done at verification time).

Note: to keep the behaviour of only running the debug info verifier when
-verify succeeds, I've added an `EverBroken` flag.  Once the
`DebugInfoFinder` assertions are gone and the two traversals have been
merged, I expect to be able to remove this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232790 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 00:48:23 +00:00
Hans Wennborg
ffe6f0ffdd Rewrite SelectionDAGBuilder::Clusterify to run in linear time. NFC.
It was previously repeatedly erasing elements from the middle of a vector,
causing O(n^2) worst-case run-time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232789 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-20 00:41:03 +00:00
Peter Collingbourne
aa01400663 test: Make a start on a test suite for libLTO.
This works in a similar way to the gold plugin tests. We search for a compatible
linker on $PATH and use it to run tests against our just-built libLTO. To start
with, test the just added opt level functionality.

Differential Revision: http://reviews.llvm.org/D8472

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232785 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 23:55:38 +00:00
Eric Christopher
8d5dd67e04 Use the cached subtarget on the MachineFunction when the AsmPrinter
will have a MachineFunction, i.e. in places other than the module
level doInitialize/doFinalize.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232783 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 23:27:42 +00:00
Eric Christopher
051c9e751b Use the cached subtarget off of the machine function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232782 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 23:06:21 +00:00
Sanjay Patel
2326d50776 move insert, extract, concat helper functions closer to related helper functions; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232781 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 23:04:25 +00:00
Owen Anderson
8154ef7589 Fix a nasty bug in DAGCombine of STORE nodes.
This is very related to the bug fixed in r174431.  The problem is that
SelectionDAG does not include alignment in the uniquing of loads and
stores.  When an otherwise no-op DAGCombine would increase the alignment
of a load or store, the original node would be returned (with the
alignment increased), which would cause the node not to be processed by
any further DAGCombines.

I don't have a direct testcase for this that manifests on an in-tree
target, but I did see some noise in the tests for other targets and have
updated them for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232780 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:48:57 +00:00
Eric Christopher
53f788786f Remove unused headers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232777 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:36:38 +00:00
Eric Christopher
0d6199b3af Add an MCSubtargetInfo variable to the TargetMachine.
This enables us to remove calls to the subtarget from the TargetMachine
and with a small hack for backends that require global subtarget
information for module level code generation, e.g. mips abi flags, as
mentioned in a fixme in the code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232776 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:36:37 +00:00
Eric Christopher
d802a47f96 Add a TargetMachine local MCRegisterInfo and MCInstrInfo so that
they can be used without a subtarget in constructing subtarget
independent passes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232775 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:36:32 +00:00
Reid Kleckner
c39212a2fc WinEH: Make llvm.eh.actions emission match the EH docs
This switches the sense of the i32 values and updates the test cases.

We can also use CHECK-SAME to clean up some tests, and reduce the visual
noise from bitcasts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232774 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:31:02 +00:00
Sanjay Patel
11d77223a5 [X86, AVX] use blends instead of insert128 with index 0
Another case of x86-specific shuffle strength reduction:
avoid generating insert*128 instructions with index 0 because
they are slower than their non-lane-changing blend equivalents.

Shuffle lowering already catches most of these cases, but
the zero vector case and some other paths such as in the
modified test in vector-shuffle-256-v32.ll were getting
through.

Differential Revision: http://reviews.llvm.org/D8366


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232773 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:29:40 +00:00
Duncan P. N. Exon Smith
a60d430e31 Verifier: Remove the separate -verify-di pass
Remove `DebugInfoVerifierLegacyPass` and the `-verify-di` pass.
Instead, call into the `DebugInfoVerifier` from inside
`VerifierLegacyPass::finalizeModule()`.  This better matches the logic
in `verifyModule()` (used by the new PassManager), avoids requiring two
separate passes to verify the IR, and makes the API for "add a pass to
verify the IR" simple.

Note: the `-verify-debug-info` flag still works (for now, at least;
eventually it might make sense to just remove it).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232772 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:24:17 +00:00
Peter Collingbourne
10f24ca2ad Fix build failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232771 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:12:08 +00:00
Peter Collingbourne
58e8e3505d LowerBitSets: Avoid reusing byte set addresses.
Each use of the byte array uses a different alias. This makes the
backend less likely to reuse previously computed byte array addresses,
improving the security of the CFI mechanism based on this pass.

Differential Revision: http://reviews.llvm.org/D8455

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232770 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:02:10 +00:00
Peter Collingbourne
416d8ecf80 libLTO, llvm-lto, gold: Introduce flag for controlling optimization level.
This change also introduces a link-time optimization level of 1. This
optimization level runs only the globaldce pass as well as cleanup passes for
passes that run at -O0, specifically simplifycfg which cleans up lowerbitsets.

http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20150316/266951.html

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232769 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 22:01:00 +00:00
Duncan P. N. Exon Smith
0dda07ad4d PassManagerBuilder: Remove effectively dead 'StripDebug' option
`StripDebug` was only used by tools/opt/opt.cpp in
`AddStandardLinkPasses()`, but opt.cpp adds the same pass based on its
command-line flag before it calls `AddStandardLinkPasses()`.  Stripping
debug info twice isn't very useful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232765 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 21:37:17 +00:00
Hans Wennborg
3d930d4e83 Switch lowering: extract NextBlock function. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232759 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-19 20:41:48 +00:00