Commit Graph

1541 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
d3cfcf9614 Verifier: Move over DISubprogram::Verify()
Move over the remaining (somewhat complicated) check from
`DISubprogram::Verify()`.  I suspect this check could be optimized --
e.g., it would be nice not to do another full traversal here -- but it's
not exactly obvious how.  For now, just bring it over as is.

Once we have a better model for the "canonical" subprogram of a
`Function`, we should enforce that all `!dbg` attachments lead to the
canonical one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233663 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 02:09:55 +00:00
Duncan P. N. Exon Smith
81a8d62b94 DebugInfo: Rewrite llvm::getDISubprogram(), NFC
Simplify implementation of `llvm::getDISubprogram()`.  I might go
through and see how difficult it is to update the users, since this
function doesn't really seem necessary anymore.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233662 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 02:06:28 +00:00
Duncan P. N. Exon Smith
a04d764104 DebugInfo: Hide isScopeRef() and isTypeRef() behind NDEBUG
The copies of these in `lib/IR/DebugInfo.cpp` are apparently [1] only
used in assertions now, so hide them behind `#ifndef NDEBUG`.

[1]: http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/9238

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233661 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 01:47:55 +00:00
Duncan P. N. Exon Smith
c2baee4da6 Verifier: Check reference flags in debug info
Move over checks of `&` and `&&` flags.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233658 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 01:28:58 +00:00
Duncan P. N. Exon Smith
c0bf4a0671 Verifier: Move more debug info checks away from Verify()
Most of these checks were already in the `Verifier` so this is more of a
cleanup.  Now almost everything is over there.

Now that require a `name:` for `MDGlobalVariable`, add a check in
`LLParser` for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233657 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 01:28:22 +00:00
Duncan P. N. Exon Smith
2f5cbb5947 Verifier: Move checks over from DIDescriptor::Verify()
Move over some more checks from `DIDescriptor::Verify()`, and change
`LLParser` to require non-null `file:` fields in compile units.

I've ignored the comment in test/Assembler/metadata-null-operands.ll
since I disagree with it.  At the time that test was written (r229960),
the debug info verifier wasn't on by default, so my comment there is in
the context of not expecting the verifier to be useful.  It is now, and
besides that, since r233394 we can check when parsing textual IR whether
an operand is null that shouldn't be.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233654 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-31 00:47:15 +00:00
Duncan P. N. Exon Smith
497110d1b0 DebugLoc: Remove getFromDILexicalBlock()
The only user of `DebugLoc::getFromDILexicalBlock()` was creating a new
`MDLocation` as convenient API for passing an `MDScope`.  Stop doing
that, and remove the API.  If in the future we actually *want* to create
new DebugLocs, calling `MDLexicalBlock::get()` makes more sense.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233643 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 23:47:26 +00:00
David Blaikie
25e3d2d6d3 [opaque pointer type] Change GetElementPtrInst::getIndexedType to take the pointee type
This pushes the use of PointerType::getElementType up into several
callers - I'll essentially just have to keep pushing that up the stack
until I can eliminate every call to it...

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233604 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 21:41:43 +00:00
Rafael Espindola
a55ae077e4 Fix PR23045.
Keep a note in the materializer that we are stripping debug info so that
user doing a lazy read of the module don't hit outdated formats.

Thanks to Duncan for suggesting the fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233603 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 21:36:43 +00:00
Duncan P. N. Exon Smith
494ae8db19 DwarfDebug: Avoid creating new DebugLocs in the backend
Don't use `DebugLoc::getFnDebugLoc()`, which creates new `MDLocation`s,
in the backend.  We just want to grab the subprogram here anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233601 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 21:32:28 +00:00
Duncan P. N. Exon Smith
6d42c0084e DebugInfo: Remove dead code from old DebugLoc API
Remove old API for `DebugLoc` now that all the callers have been
updated.  If this broke your out-of-tree build, here's a quick map from
the old API to the new one:

    DebugLoc DebugLoc::getFromMDLocation(MDNode *)
      => DebugLoc::DebugLoc(MDLocation *)
      => explicit DebugLoc::DebugLoc(MDNode *) // works with broken code

    MDNode *DebugLoc::getAsMDNode(LLVMContext &)
      => MDLocation *DebugLoc::get()
      => DebugLoc::operator MDLocation *()
      => MDNode *DebugLoc::getAsMDNode() // works with broken code

    bool DebugLoc::isUnknown()
      => DebugLoc::operator MDLocation *()
          i.e.: if (MDLocation *DL = ...)
      => DebugLoc::operator bool() // works with broken code
          i.e.: if (DebugLoc DL = ...)

    void DebugLoc::getScopeAndInlinedAt(MDNode *&, MDNode *&)
      => use: MDNode *DebugLoc::getScope()
         and: MDLocation *DebugLoc::getInlinedAt()

    MDNode *DebugLoc::getScopeNode(LLVMContext &)
      => MDNode *DebugLoc::getInlinedAtScope()

    void DebugLoc::dump(LLVMContext &)
      => void DebugLoc::dump()

    void DebugLoc::getFnDebugLoc(LLVMContext &)
      => void DebugLoc::getFnDebugLoc()

    MDNode *DebugLoc::getScope(LLVMContext &)
      => MDNode *DebugLoc::getScope()

    MDNode *DebugLoc::getInlinedAt(LLVMContext &)
      => MDLocation *DebugLoc::getInlinedAt()

I've noted above the only functions that won't crash on broken code (due
to downcasting to `MDLocation`).  If your code could be dealing with
broken IR (i.e., you haven't run the verifier yet, or you've used a
temporary node that will eventually (but not yet) get RAUW'ed to an
`MDLocation`), you need to restrict yourself to those.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233599 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 21:19:50 +00:00
Rafael Espindola
37780d81b1 Use range loops and add missing braces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233598 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 21:18:36 +00:00
Duncan P. N. Exon Smith
39acf8f243 IR: Use the new DebugLoc API, NFC
Update lib/IR and lib/Bitcode to use the new `DebugLoc` API.  Added an
explicit conversion to `bool` (avoiding a conversion to `MDLocation`),
since a couple of these use cases need to handle broken code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233585 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 19:40:05 +00:00
Duncan P. N. Exon Smith
770661092f DebugInfo: Reflow printDebugLoc() to use early returns, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233580 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 18:45:11 +00:00
Duncan P. N. Exon Smith
1c13197c9f DebugInfo: Write new DebugLoc API
Rewrite `DebugLoc` with a cleaner API that reflects its current status
as a wrapper around an `MDLocation` pointer.

  - Add accessors/constructors to/from `MDLocation`.
  - Simplify construction from `MDNode`.
  - Remove unnecessary `LLVMContext` from APIs.
  - Drop some API that isn't useful any more.
  - Rewrite documentation.

Actually, I've left the old API behind temporarily at the bottom of the
class so that I can update callers in separate commits.  I'll remove it
once the callers are updated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233573 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 18:07:40 +00:00
Duncan P. N. Exon Smith
3584797a17 DebugInfo: Implement MDLocation::getInlinedAtScope()
Write `MDLocation::getInlinedAtScope()` and use it to re-implement
`DebugLoc::getScopeNode()` (and simplify `DISubprogram::Verify()`).
This follows the inlined-at linked list and returns the scope of the
deepest/last location.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233568 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 17:41:24 +00:00
Duncan P. N. Exon Smith
7380257f0e Verifier: Add operand checks for remaining debug info
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233565 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 17:21:38 +00:00
Duncan P. N. Exon Smith
d9720a4749 DebugInfo: Simplify logic in DISubprogram::Verify(), NFC
Simplify the logic in `DISubprogram::Verify()` by using the new debug
info hierarchy directly instead of the `DebugLoc` wrapper.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233563 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 17:06:38 +00:00
Duncan P. N. Exon Smith
a3dbc680a7 Verifier: Loosen r233559 check for 'function:' field in MDSubprogram
Stop worrying about what the `function:` field is in `MDSubprogram`,
since it could be a bitcast [1].  Just check its type and leave it at
that.

[1]: http://lab.llvm.org:8080/green/job/clang-stage2-configure-Rlto_build/3540/

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233562 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 17:04:06 +00:00
Duncan P. N. Exon Smith
d3ec0ca17e Verifier: Add operand checks for MDLexicalBlock
Add operand checks for `MDLexicalBlock` and `MDLexicalBlockFile`.  Like
`MDLocalVariable` and `MDLocation`, these nodes always require a scope.

There was no test bitrot to fix here (just updated the serialization
tests in test/Assembler/mdlexicalblock.ll).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233561 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 16:37:48 +00:00
Duncan P. N. Exon Smith
bd38c8d788 Verifier: Check operands of MDSubprogram nodes
Check operands of `MDSubprogram`s in the verifier, and update the
accessors and factory functions to use more specific types.

There were a lot of broken testcases, which I fixed in r233466.  If you
have out-of-tree tests for debug info, you probably need similar changes
to the ones I made there.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233559 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 16:19:15 +00:00
Yaron Keren
f88cbb8c49 Trying to fix the Hexagon and debian-fast bots arm32_neon_vcnt_upgrade.ll test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233558 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 16:10:39 +00:00
Yaron Keren
6e92e7b09a Remove more superfluous .str() and replace std::string concatenation with Twine.
Following r233392, http://llvm.org/viewvc/llvm-project?rev=233392&view=rev.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233555 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-30 15:42:36 +00:00
Benjamin Kramer
19d058836a Silence sign compare warning. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233502 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-29 20:49:03 +00:00
Benjamin Kramer
155328790b [inline asm] Don't reject duplicated matching constraints
They're harmless and it's easy to generate them from clang, leading to
a crash in LLVM. Found by afl-fuzz.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233500 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-29 20:33:07 +00:00
Hal Finkel
8360002904 [ConstantFold] Don't fold ppc_fp128 <-> int bitcasts
PPC_FP128 is really the sum of two consecutive doubles, where the first double
is always stored first in memory, regardless of the target endianness. The
memory layout of i128, however, depends on the target endianness, and so we
can't fold this without target endianness information. As a result, we must not
do this folding in lib/IR/ConstantFold.cpp (it could be done instead in
Analysis/ConstantFolding.cpp, but that's not done now).

Fixes PR23026.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233481 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-28 16:44:57 +00:00
Duncan P. N. Exon Smith
cefca10039 Verifier: Allow subroutine types to have no type array
Loosen one check from r233446: as long as `DIBuilder` requires a
non-null type for every subprogram, we should allow a null type array.
Also add tests for the rest of `MDSubroutineType`, which were somehow
missing.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233468 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-28 02:43:53 +00:00
Duncan P. N. Exon Smith
b943370653 Verifier: Check operands of MDType subclasses and MDCompileUnit
Add verify checks for `MDType` subclasses and for `MDCompileUnit`.
These new checks don't yet incorporate everything from `Verify()`, but
at least they sanity check the operands.  Also downcast accessors as
possible.

A lot of these accessors can't be downcast as far as we'd like because
of arrays of typed objects (stored in a generic `MDTuple`) and
`MDString`-based type references.  Eventually I'll port over `DIRef<>`
and `DITypedArray<>` from `DebugInfo.h` to clean those up as well.

Updated bitrotted testcases separately in r233415 and r233443 to reduce
churn on the off-chance this needs to be reverted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233446 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 23:05:04 +00:00
Duncan P. N. Exon Smith
6ed3a762fc DebugInfo: Require non-null in DIBuilder::retainType()
Assert that a non-null value is being passed in.  Note that I fixed the
one offender in clang in r233443.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233445 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 23:00:49 +00:00
Duncan P. N. Exon Smith
2cee1c9d3c LLParser: Require non-null scope for MDLocation and MDLocalVariable
Change `LLParser` to require a non-null `scope:` field for both
`MDLocation` and `MDLocalVariable`.  There's no need to wait for the
verifier for this check.  This also allows their `::getImpl()` methods
to assert that the incoming scope is non-null.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233394 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 17:56:39 +00:00
Duncan P. N. Exon Smith
a9902daa5c Verifier: Check fields of MDVariable subclasses
Check fields from `MDLocalVariable` and `MDGlobalVariable` and change
the accessors to downcast to the right types.  `getType()` still returns
`Metadata*` since it could be an `MDString`-based reference.

Since local variables require non-null scopes, I also updated `LLParser`
to require a `scope:` field.

A number of testcases had grown bitrot and started failing with this
patch; I committed them separately in r233349.  If I just broke your
out-of-tree testcases, you're probably hitting similar problems (so have
a look there).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233389 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 17:29:58 +00:00
Philip Reames
76acab3fc7 Require a GC strategy be specified for functions which use gc.statepoint
This was discussed a while back and I left it optional for migration.  Since it's been far more than the 'week or two' that was discussed, time to actually make this manditory.  



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233357 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 05:09:33 +00:00
David Majnemer
db573736fd WinEH: Create a parent frame alloca for HandlerType 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@233354 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 04:17:07 +00:00
Duncan P. N. Exon Smith
9f2b49c521 DIBuilder: Change a few helpers to return downcasted MDNodes
Change `getNonCompileUnitScope()` to return `MDScope` and
`getConstantAsMetadata()` to return `ConstantAsMetadata`.  This will
make it easier to start requiring more type safety in the debug info
hierarchy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233340 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-27 00:34:10 +00:00
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
Owen Anderson
1b3b8e5be8 Fix another verifier crash where a GC intrinsic would look at the internals of another intrinsic in order to verify itself.
This causes a crash if the referenced intrinsic was malformed.  In this case, we
would already have reported an error on the referenced intrinsic, but then
crashed on the second one when it tried to introspect the first without
error checking.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231910 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-11 06:57:30 +00:00
Andrew Kaylor
dd3224b24f Fix Value dangling reference debug output
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231889 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 23:55:38 +00:00
Sanjay Patel
137e1f3f28 [X86, AVX] replace vinsertf128 intrinsics with generic shuffles
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 the sibling patch for the Clang half of this change:
http://reviews.llvm.org/D8088

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



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231794 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 16:08:36 +00:00
Yaron Keren
1132d0cc5b Teach raw_ostream to accept SmallString.
Saves adding .str() call to any raw_ostream << SmallString usage
and a small step towards making .str() consistent in the ADTs by
removing one of the SmallString::str() use cases, discussion at

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

I'll update the Phabricator patch http://reviews.llvm.org/D6372
for review of the Twine SmallString support, it's more complex
than this one.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231763 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 07:33:23 +00:00
Owen Anderson
4935faa4ee Fix an issue in the verifier where we could try to read information out of a malformed statepoint intrinsic.
In this situation we would always have already flagged an error on the statepoint intrinsic,
but then we carry on to parse other, related GC intrinsics, and could end up crashing during that
verification when they try to access data from the malformed statepoint.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231759 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 05:58:21 +00:00
Mehdi Amini
529919ff31 DataLayout is mandatory, update the API to reflect it with references.
Summary:
Now that the DataLayout is a mandatory part of the module, let's start
cleaning the codebase. This patch is a first attempt at doing that.

This patch is not exactly NFC as for instance some places were passing
a nullptr instead of the DataLayout, possibly just because there was a
default value on the DataLayout argument to many functions in the API.
Even though it is not purely NFC, there is no change in the
validation.

I turned as many pointer to DataLayout to references, this helped
figuring out all the places where a nullptr could come up.

I had initially a local version of this patch broken into over 30
independant, commits but some later commit were cleaning the API and
touching part of the code modified in the previous commits, so it
seemed cleaner without the intermediate state.

Test Plan:

Reviewers: echristo

Subscribers: llvm-commits

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231740 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-10 02:37:25 +00:00
Mehdi Amini
4c8f5afd99 InstCombine: fix fold "fcmp x, undef" to account for NaN
Summary:
See the two test cases.

; Can fold fcmp with undef on one side by choosing NaN for the undef

; Can fold fcmp with undef on both side
;   fcmp u_pred undef, undef -> true
;   fcmp o_pred undef, undef -> false
; because whatever you choose for the first undef
; you can choose NaN for the other undef

Reviewers: hfinkel, chandlerc, majnemer

Reviewed By: majnemer

Subscribers: majnemer, llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231626 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-09 03:20:25 +00:00
David Blaikie
da4471d726 Simplify expressions involving boolean constants with clang-tidy
Patch by Richard (legalize at xmission dot com).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231617 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-09 01:57:13 +00:00
Owen Anderson
c03496d4d0 Teach DataLayout to infer a plausible alignment for things even when nothing is specified by the user.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231613 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-08 21:53:59 +00:00
Benjamin Kramer
fab98a4843 Make the assertion macros in Verifier and Linter truly variadic.
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231577 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-07 21:15:40 +00:00
James Molloy
4e022da51e [ConstantRange] Teach multiply to be cleverer about signed ranges.
Multiplication is not dependent on signedness, so just treating
all input ranges as unsigned is not incorrect. However it will cause
overly pessimistic ranges (such as full-set) when used with signed
negative values.

Teach multiply to try to interpret its inputs as both signed and
unsigned, and then to take the most specific (smallest population)
as its result.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231483 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-06 15:50:47 +00:00
Benjamin Kramer
fdef53e098 Instructions: Use delegated constructors to reduce duplication
NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231411 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05 22:05:26 +00:00
Reid Kleckner
7d02b353ab Remove accidental errs() call in Verifier
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231391 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05 19:05:25 +00:00
Reid Kleckner
9f7c861416 Replace llvm.frameallocate with llvm.frameescape
Turns out it's pretty straightforward and simplifies the implementation.

Reviewers: andrew.w.kaylor

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231386 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05 18:26:34 +00:00
Erik Eckstein
8b4cc5e616 Revert r231276 (including r231277): Add a lock() function in PassRegistry to speed up multi-thread synchronization.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231385 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-05 17:53:00 +00:00
Erik Eckstein
953be88190 Add a lock() function in PassRegistry to speed up multi-thread synchronization.
When calling lock() after all passes are registered, the PassRegistry doesn't need a mutex anymore to look up passes.
This speeds up multithreaded llvm execution by ~5% (tested with 4 threads).
In an asserts build of llvm this has an even bigger impact.

Note that it's not required to use the lock function.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231276 91177308-0d34-0410-b5e6-96231b3b80d8
2015-03-04 18:57:11 +00:00