Commit Graph

1457 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
50b75d5804 AsmWriter: Cleanup debug info fields with MDFieldPrinter, NFC
Move all the `MDNode` field helper methods into a new class,
`MDFieldPrinter`, and add helpers for integers, bools, and `DW_*`
symbolic constants.  This reduces a ton of code duplication, and makes
it more mechanical to update `AsmWriter` to print broken code in the
context of stricter accessors (like in r233322).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233337 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 00:17:42 +00:00
Duncan P. N. Exon Smith
c4eafd24f2 Verifier: Check accessors of MDLocation
Check accessors of `MDLocation`, and change them to `cast<>` down to the
right types.  Also add type-safe factory functions.

All the callers that handle broken code need to use the new versions of
the accessors (`getRawScope()` instead of `getScope()`) that still
return `Metadata*`.  This is also necessary for things like
`MDNodeKeyImpl<MDLocation>` (in LLVMContextImpl.h) that need to unique
the nodes when their operands might still be forward references of the
wrong type.

In the `Value` hierarchy, consumers that handle broken code use
`getOperand()` directly.  However, debug info nodes have a ton of
operands, and their order (even their existence) isn't stable yet.  It's
safer and more maintainable to add an explicit "raw" accessor on the
class itself.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233322 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-26 22:05:04 +00:00
Reid Kleckner
a8b46e7055 WinEH: Create an unwind help alloca for __CxxFrameHandler3 xdata tables
We don't have any logic to emit those tables yet, so the sdag lowering
of this intrinsic is just a stub. We can see the intrinsic in the
prepared IR, though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233209 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 20:10:36 +00:00
Peter Collingbourne
c33c447af9 DebugInfo: Permit DW_TAG_structure_type, DW_TAG_member, DW_TAG_typedef tags with empty file names.
Some languages, such as Go, have pre-defined structure types (e.g. "string"
is essentially a pointer/length pair) or pre-defined "typedef" types
(e.g. "error" is essentially a typedef for a specific interface type).
Such types do not have associated source location, so a Go frontend would
be correct not to associate a file name with such types.

This change relaxes the DIType verifier to permit unlocated types with
these tags.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233200 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-25 17:44:49 +00:00
Duncan P. N. Exon Smith
15a873a6e2 Verifier: Start recursing into !dbg attachments
The main verifier already recurses through the other entry points, so we
might as well descend here too.

This temporarily duplicates some work already done in
`verifyDebugInfo()`, but eventually I'll be removing the other side.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233095 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 17:32:19 +00:00
Duncan P. N. Exon Smith
eeb2ba6d46 Verifier: !llvm.dbg.cu must point at compile units
Duplicate this check from `verifyDebugInfo()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233094 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-24 17:18:03 +00:00
Duncan P. N. Exon Smith
7ad96398c6 DebugInfo: Overload get() in DIDescriptor subclasses
Continue to simplify the `DIDescriptor` subclasses, so that they behave
more like raw pointers.  Remove `getRaw()`, replace it with an
overloaded `get()`, and overload the arrow and cast operators.  Two
testcases started to crash on the arrow operators with this change
because of `scope:` references that weren't real scopes.  I fixed them.
Soon I'll add verifier checks for them too.

This also adds explicit dereference operators.  Previously, the builtin
dereference against `operator MDNode *()` would have worked, but now the
builtins are ambiguous.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233030 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 21:54:07 +00:00
David Blaikie
16ff2dadb0 Refactor: Simplify boolean expressions in llvm IR
Simplify boolean expressions using `true` and `false` with `clang-tidy`

Patch by Richard Thomson with a few other simplifications to fix
else-after-returns in the surrounding code.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233005 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 19:51:23 +00:00
Benjamin Kramer
1bfcd1f675 Re-sort includes with sort-includes.py and insert raw_ostream.h where it's used.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232998 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 19:32:43 +00:00
Benjamin Kramer
cab2a096fd [gcov] Move formatBranchInfo into an anonymous namespace.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232949 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-23 13:59:13 +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
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
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
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
Sanjoy Das
da5f3a3ca5 [ConstantRange] Split makeICmpRegion in two.
Summary:
This change splits `makeICmpRegion` into `makeAllowedICmpRegion` and
`makeSatisfyingICmpRegion` with slightly different contracts.  The first
one is useful for determining what values some expression //may// take,
given that a certain `icmp` evaluates to true.  The second one is useful
for determining what values are guaranteed to //satisfy// a given
`icmp`.

Reviewers: nlewycky

Reviewed By: nlewycky

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232575 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-18 00:41:24 +00:00
David Majnemer
7605cdd6e4 COFF: Let globals with private linkage reside in their own section
COFF COMDATs (for selection kinds other than 'select any') require at
least one non-section symbol in the symbol table.
Satisfy this by morally enhancing the linkage from private to internal.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232570 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 23:54:51 +00:00
Duncan P. N. Exon Smith
887a867862 DebugInfo: Drop fake DW_TAG_expression
Break MDExpression off of DebugNode (inherit directly from `MDNode`) and
drop the fake `DW_TAG_expression` tag in the process.

AFAICT, there's no real functionality change here.  The tag was
originally used by `DIDescriptor::isExpression()` to discriminate
between `MDNode`s, but in the new hierarchy we don't need that.

Fixes PR22780.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232550 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 21:32:46 +00:00
David Majnemer
6129538ade Revert "Address review comments"
This reverts commit r232540.  This was committed accidently.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232541 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 20:40:21 +00:00
David Majnemer
468fbb3c2b Address review comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232540 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 20:39:40 +00:00
Benjamin Kramer
93920f0bcd Internalize llvm::AssemblyWriter. It's not used outside of AsmWriter.cpp.
This is an artifact of an implementation detail of DebugIR that has been
long refactored away. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232532 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 19:53:41 +00:00
Duncan P. N. Exon Smith
2f5bc29926 Verifier: Set --verify-debug-info=true by default
r186634 started verifying debug info, and r194986 disabled it by default
because it was too expensive to run the checks on every function (since
most of the graph was reachable from each function).

r206300 moved the checks to module-level to make it cheaper, but there
was already quite a bit of testcase bitrot (and the verifier would only
print `<badref>`) so I guess no one had time to turn it back on.

This does just that.  Upgrade scripts this past autumn and winter
probably fixed some of the bitrot, and this weekend I fixed the verifier
output (r232275, r232417, r232418) and thusly the remaining failing
testcases (r232290, r232415).

This is part of PR22777.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232505 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 17:28:41 +00:00
Justin Bogner
bdd2212363 llvm-cov: Warn instead of error if a .gcda has arcs from an exit block
Patch by Vanderson M. Rosario. Thanks!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232443 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-17 00:18:51 +00:00
Duncan P. N. Exon Smith
9b4250d309 Verifier: Don't call debug info verifier if the module is broken
If `Verifier` has already found a failure, don't call
`DebugInfoVerifier`.  The latter sometimes crashes in `DebugInfoFinder`
when the former would give a nice message.  The only two cases I found
it crashing are explicit verifier tests I've added:

  - test/Verifier/llvm.dbg.declare-expression.ll
  - test/Verifier/llvm.dbg.value-expression.ll

However, I assume frontends with bugs will create invalid IR as well.

IMO, the `DebugInfoVerifier` should never crash (instead, it should fail
to verify), but subtleties like that will be easier to work out once
it's enabled again.

This is part of PR22777.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232418 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 21:23:56 +00:00
Duncan P. N. Exon Smith
bee74a3ad4 AsmWriter: Handle broken metadata nodes
Print out temporary `MDNode`s so we don't crash in the verifier (or
during `dump()` output).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232417 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 21:21:10 +00:00
Duncan P. N. Exon Smith
30d7c8989b Verifier: Simplify logic in processCallInst(), NFC
No need for local variables here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232413 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 21:05:33 +00:00
Duncan P. N. Exon Smith
3d5527fb43 IR: Take advantage of -verify checks for MDExpression
Now that we check `MDExpression` during `-verify` (r232299), make
the `DIExpression` wrapper more strict:

  - remove redundant checks in `DebugInfoVerifier`,
  - overload `get()` to `cast_or_null<MDExpression>` (superseding
    `getRaw()`),
  - stop checking for null in any accessor, and
  - remove `DIExpression::Verify()` entirely in favour of
    `MDExpression::isValid()`.

There is still some logic in this class, mostly to do with high-level
iterators; I'll defer cleaning up those until the rest of the wrappers
are similarly strict.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232412 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 21:03:55 +00:00
Duncan P. N. Exon Smith
83c42e65fb DebugInfo: Simplify logic in DIType::Verify(), NFC
Clarify the logic in `DIType::Verify()` by checking `isBasicType()`
earlier, by skipping `else` after `return`s, and by documenting an
otherwise opaque check.

No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232410 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 20:46:27 +00:00
Duncan P. N. Exon Smith
c77560e219 Verifier: Remove unnecessary double-checks
Turns out `visitIntrinsicFunctionCall()` descends into all operands
already, so explicitly descending in `visitDbgIntrinsic()` (part of
r232296) isn't useful.

Updating a testcase that doesn't really need `-verify-debug-info` (since
r231082) as confirmation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232408 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 20:24:02 +00:00
Duncan P. N. Exon Smith
a718967977 Fix doxygen comments from r232268
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232388 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-16 17:49:03 +00:00
Duncan P. N. Exon Smith
9ca358021c IR: Default the Metadata::dump() argument "harder" after r232275
Use an overload instead of a default argument for `Metadata::dump()`.
The latter seems to require calling `dump(nullptr)` explicitly when
using a debugger, where as the former doesn't.

Other than utility for debugging, there's NFC here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232315 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 06:53:32 +00:00
Duncan P. N. Exon Smith
40510a07cf DbgIntrinsicInst: Downcast to specialized MDNodes in accessors
Change accessors to downcast to `MDLocalVariable` and `MDExpression`,
now that we have -verify checks in place to confirm that it's safe.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232299 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 01:23:20 +00:00
Duncan P. N. Exon Smith
08e687e684 Verifier: Check debug info intrinsic arguments
Verify that debug info intrinsic arguments are valid.  (These checks
will not recurse through the full debug info graph, so they don't need
to be cordoned of in `DebugInfoVerifier`.)

With those checks in place, changing the `DbgIntrinsicInst` accessors to
downcast to `MDLocalVariable` and `MDExpression` is natural (added isa
specializations in `Metadata.h` to support this).

Added tests to `test/Verifier` for the new -verify checks, and fixed the
debug info in all the in-tree tests.

If you have out-of-tree testcases that have started to fail to -verify,
hopefully the verify checks are helpful.  The most likely problem is
that the expression argument is `!{}` (instead of `!MDExpression()`).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232296 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 01:21:30 +00:00
David Blaikie
48248ac8a0 [opaque pointer type] IRBuilder gep migration progress
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232294 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 01:03:19 +00:00
Duncan P. N. Exon Smith
ca7e7b0212 Verifier: Remove unnecessary null check
This is already assumed to be non-null above due to a dyn_cast<>.  Also
remove extraneous braces around statement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232292 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 00:50:57 +00:00
Duncan P. N. Exon Smith
7c068cfe9a Verifier: Make the raw_ostream constructor argument required
This was passed inconsistently; seems clearer to make it required anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232291 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-15 00:46:57 +00:00
Duncan P. N. Exon Smith
f9f505e626 IR: Make Metadata::print() reliable and useful
Replumb the `AsmWriter` so that `Metadata::print()` is generally useful.
(Similarly change `Metadata::printAsOperand()`.)

- `SlotTracker` now has a mode where all metadata will be correctly
  numbered when initializing a `Module`.  Normally, `Metadata` only
  referenced from within `Function`s gets numbered when the `Function`
  is incorporated.
- `Metadata::print()` and `Metadata::printAsOperand()` (and
  `Metadata::dump()`) now take an optional `Module` argument.  When
  provided, `SlotTracker` is initialized with the new mode, and the
  numbering will be complete and consistent for all calls to `print()`.
- `Value::print()` uses the new `SlotTracker` mode when printing
  intrinsics with `MDNode` operands, `MetadataAsValue` operands, or the
  bodies of functions.  Thus, metadata numbering will be consistent
  between calls to `Metadata::print()` and `Value::print()`.
- `Metadata::print()` (and `Metadata::dump()`) now print the full
  definition of `MDNode`s:

    !5 = !{!6, !"abc", !7}

  This matches behaviour for `Value::print()`, which includes the name
  of instructions.
- Updated call sites in `Verifier` to call `print()` instead of
  `printAsOperand()`.

All this, so that `Verifier` can print out useful failure messages that
involve `Metadata` for PR22777.

Note that `Metadata::printAsOperand()` previously took an optional
`bool` and `Module` operand.  The former was cargo-culted from
`Value::printAsOperand()` and wasn't doing anything useful.  The latter
didn't give consistent results (without the new `SlotTracker` mode).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232275 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14 20:19:36 +00:00
Duncan P. N. Exon Smith
81ebfb1802 AsmWriter: Split out SlotTracker::processInstructionMetadata(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232273 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14 19:48:31 +00:00
Duncan P. N. Exon Smith
ff0e5a6c58 AsmWriter: Use range-based for, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232272 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14 19:44:01 +00:00
Duncan P. N. Exon Smith
f141a5534e Recover the ability to 'b CheckFailed' after r231577
Given that the stated purpose of `CheckFailed()` is to provide a nice
spot for a breakpoint, it'd be nice not to have to use a regex to break
on it.  Recover the ability to simply use `b CheckFailed` by
specializing the message-only version, and by changing the variadic
version to call into the message-only version.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232268 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14 16:47:37 +00:00
David Blaikie
fb5115d02a [opaque pointer type] Start migrating GEP creation to explicitly specify the pointee type
I'm just going to migrate these in a pretty ad-hoc & incremental way -
providing the backwards compatible API for now, then locally removing
it, fixing a few callers, adding it back in and commiting those callers.
Rinse, repeat.

The assertions should ensure that if I get this wrong we'll find out
about it and not just have one giant patch to revert, recommit, revert,
recommit, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232240 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-14 01:53:18 +00:00
Rafael Espindola
dc6141a4ff Be lazy about loading metadata in IRObjectFile.
This speeds up llvm-ar building lib64/libclangSema.a with debug IR files
from 8.658015807 seconds to just 0.351036519 seconds :-)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232221 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 21:54:20 +00:00
Duncan P. N. Exon Smith
95ff656ae0 AsmWriter: Write alloca array size explicitly (and -instcombine fixup)
Write the `alloca` array size explicitly when it's non-canonical.
Previously, if the array size was `iX 1` (where X is not 32), the type
would mutate to `i32` when round-tripping through assembly.

The testcase I added fails in `verify-uselistorder` (as well as
`FileCheck`), since the use-lists for `i32 1` and `i64 1` change.
(Manman Ren came across this when running `verify-uselistorder` on some
non-trivial, optimized code as part of PR5680.)

The type mutation started with r104911, which allowed array sizes to be
something other than an `i32`.  Starting with r204945, we
"canonicalized" to `i64` on 64-bit platforms -- and then on every
round-trip through assembly, mutated back to `i32`.

I bundled a fixup for `-instcombine` to avoid r204945 on scalar
allocations.  (There wasn't a clean way to sequence this into two
commits, since the assembly change on its own caused testcase churn, and
the `-instcombine` change can't be tested without the assembly changes.)

An obvious alternative fix -- change `AllocaInst::AllocaInst()`,
`AsmWriter` and `LLParser` to treat `intptr_t` as the canonical type for
scalar allocations -- was rejected out of hand, since this required
teaching them each about the data layout.

A follow-up commit will add an `-instcombine` to canonicalize the scalar
allocation array size to `i32 1` rather than leaving `iX 1` alone.

rdar://problem/20075773

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232200 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 19:30:44 +00:00
David Blaikie
5a70dd1d82 [opaque pointer type] Add textual IR support for explicit type parameter to gep operator
Similar to gep (r230786) and load (r230794) changes.

Similar migration script can be used to update test cases, which
successfully migrated all of LLVM and Polly, but about 4 test cases
needed manually changes in Clang.

(this script will read the contents of stdin and massage it into stdout
- wrap it in the 'apply.sh' script shown in previous commits + xargs to
apply it over a large set of test cases)

import fileinput
import sys
import re

rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL)

def conv(match):
  line = match.group(1)
  line += match.group(4)
  line += ", "
  line += match.group(2)
  return line

line = sys.stdin.read()
off = 0
for match in re.finditer(rep, line):
  sys.stdout.write(line[off:match.start()])
  sys.stdout.write(conv(match))
  off = match.end()
sys.stdout.write(line[off:])

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232184 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 18:20:45 +00:00
David Majnemer
790aec0651 ConstantFold: Fix big shift constant folding
Constant folding for shift IR instructions ignores all bits above 32 of
second argument (shift amount).
Because of that, some undef results are not recognized and APInt can
raise an assert failure if second argument has more than 64 bits.

Patch by Paweł Bylica!

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232176 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 16:39:46 +00:00
Owen Anderson
39fcd2305a Fix an infinite recursion in the verifier caused by calling isSized on a recursive type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232143 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-13 06:41:26 +00:00
Sanjay Patel
cae9695fbb [X86, AVX2] Replace inserti128 and extracti128 intrinsics with generic shuffles
This should complete the job started in r231794 and continued in r232045:
We want to replace as much custom x86 shuffling via intrinsics
as possible because pushing the code down the generic shuffle
optimization path allows for better codegen and less complexity
in LLVM.

AVX2 introduced proper integer variants of the hacked integer insert/extract
C intrinsics that were created for this same functionality with AVX1.

This should complete the removal of insert/extract128 intrinsics.

The Clang precursor patch for this change was checked in at r232109.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232120 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 23:16:18 +00:00
Sanjay Patel
320572f378 make an array of constants explicitly const
Suggested by Craig Topper in D8184.

This goes with r232047.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232056 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 16:29:58 +00:00
Sanjay Patel
656ef652cc IRBuilder: add a CreateShuffleVector function that takes an ArrayRef of int
This is a convenience function to ease mask creation of ShuffleVectors
in AutoUpgrade and other places.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232047 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 15:27:07 +00:00
Sanjay Patel
b4c1547749 [X86, AVX] replace vextractf128 intrinsics with generic shuffles
Now that we've replaced the vinsertf128 intrinsics, 
do the same for their extract twins.

This is very much like D8086 (checked in at r231794):
We want to replace as much custom x86 shuffling via intrinsics
as possible because pushing the code down the generic shuffle
optimization path allows for better codegen and less complexity
in LLVM.

This is also the LLVM sibling to the cfe D8275 patch.

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232045 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-12 15:15:19 +00:00