Commit Graph

1922 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
0a9f921686 IR: Introduce GenericDwarfNode
As part of PR22235, introduce `DwarfNode` and `GenericDwarfNode`.  The
former is a metadata node with a DWARF tag.  The latter matches our
current (generic) schema of a header with string (and stringified
integer) data and an arbitrary number of operands.

This doesn't move it into place yet; that change will require a large
number of testcase updates.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226529 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 00:01:43 +00:00
Duncan P. N. Exon Smith
37c7ccc40c IR: Allow temporary nodes to become uniqued or distinct
Add `MDNode::replaceWithUniqued()` and `MDNode::replaceWithDistinct()`,
which mutate temporary nodes to become uniqued or distinct.  On uniquing
collisions, the unique version is returned and the node is deleted.

This takes advantage of temporary nodes being folded back in, and should
let me clean up some awkward logic in `MapMetadata()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226510 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 22:24:52 +00:00
Duncan P. N. Exon Smith
f9eaea701d IR: Return unique_ptr from MDNode::getTemporary()
Change `MDTuple::getTemporary()` and `MDLocation::getTemporary()` to
return (effectively) `std::unique_ptr<T, MDNode::deleteTemporary>`, and
clean up call sites.  (For now, `DIBuilder` call sites just call
`release()` immediately.)

There's an accompanying change in each of clang and polly to use the new
API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226504 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 21:30:18 +00:00
Duncan P. N. Exon Smith
a7852bfa47 IR: Add MDLocation::getTemporary()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226502 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 20:37:44 +00:00
Duncan P. N. Exon Smith
8ec0aee3b4 IR: Remove MDNodeFwdDecl
Remove `MDNodeFwdDecl` (as promised in r226481).  Aside from API
changes, there's no real functionality change here.
`MDNode::getTemporary()` now forwards to `MDTuple::getTemporary()`,
which returns a tuple with `isTemporary()` equal to true.

The main point is that we can now add temporaries of other `MDNode`
subclasses, needed for PR22235 (I introduced `MDNodeFwdDecl` in the
first place because I didn't recognize this need, and thought they were
only needed to handle forward references).

A few things left out of (or highlighted by) this commit:

  - I've had to remove the (few) uses of `std::unique_ptr<>` to deal
    with temporaries, since the destructor is no longer public.
    `getTemporary()` should probably return the equivalent of
    `std::unique_ptr<T, MDNode::deleteTemporary>`.
  - `MDLocation::getTemporary()` doesn't exist yet (worse, it actually
    does exist, but does the wrong thing: `MDNode::getTemporary()` is
    inherited and returns an `MDTuple`).
  - `MDNode` now only has one subclass, `UniquableMDNode`, and the
    distinction between them is actually somewhat confusing.

I'll fix those up next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226501 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 20:36:39 +00:00
Duncan P. N. Exon Smith
641414a6c0 IR: Store RAUW support and Context in the same pointer, NFC
Add an `LLVMContext &` to `ReplaceableMetadataImpl`, create a class that
either holds a reference to an `LLVMContext` or owns a
`ReplaceableMetadataImpl`, and use the new class in `MDNode`.

  - This saves a pointer in `UniquableMDNode` at the cost of a pointer
    in `ValueAsMetadata` (which didn't used to store the `LLVMContext`).
    There are far more of the former.
  - Unifies RAUW support between `MDNodeFwdDecl` (which is going away,
    see r226481) and `UniquableMDNode`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226484 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 19:02:06 +00:00
Duncan P. N. Exon Smith
1d72e18caa IR: Add isUniqued() and isTemporary()
Change `MDNode::isDistinct()` to only apply to 'distinct' nodes (not
temporaries), and introduce `MDNode::isUniqued()` and
`MDNode::isTemporary()` for the other two possibilities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226482 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 18:45:35 +00:00
Chandler Carruth
0a506e2f95 Suppress the newly added Clang warning for the inaccessible base in this
test. Do that after we suppress the warnings for unknown pragmas as this
warning flag is quite new in Clang and so old Clang's would warn all the
time on this file.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226444 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 10:43:00 +00:00
Michael Gottesman
eb71fa415e [tinyptrvector] Add in a MutableArrayRef implicit conversion operator to complement the ArrayRef implicit conversion operator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226428 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 03:25:33 +00:00
Chandler Carruth
de5df29556 [PM] Split the LoopInfo object apart from the legacy pass, creating
a LoopInfoWrapperPass to wire the object up to the legacy pass manager.

This switches all the clients of LoopInfo over and paves the way to port
LoopInfo to the new pass manager. No functionality change is intended
with this iteration.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226373 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-17 14:16:18 +00:00
Duncan P. N. Exon Smith
fb7514fccb IR: Allow 16-bits for column info
Raise the limit for column information from 8 bits to 16 bits.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226291 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 17:33:08 +00:00
Vasileios Kalintiris
add8f51c26 Fix the C-API MCJIT test for 32-bit big endian machines.
Avoid using unions for storing the return value from
LLVMGetGlobalValueAddress() and LLVMGetFunctionAddress() and accessing it as
a pointer through another pointer member. This causes problems on 32-bit big
endian machines since the pointer gets the higher part of the return value of
the aforementioned functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226170 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 15:36:04 +00:00
Duncan P. N. Exon Smith
9e4a11f46c IR: Fix a use-after-free in RAUW
Happened pretty commonly during `LLVMContext` teardown when `clang -g`
hit an error.  This fixes the use-after-free.  Next I'll clean up
teardown so that it's not RAUW'ing when metadata-tracked values are
deleted (only really causes a problem if the graph is mid-construction
when teardown starts, but it's still unnecessary work).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226029 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 19:56:10 +00:00
Chandler Carruth
1b279144ec [cleanup] Re-sort all the #include lines in LLVM using
utils/sort_includes.py.

I clearly haven't done this in a while, so more changed than usual. This
even uncovered a missing include from the InstrProf library that I've
added. No functionality changed here, just mechanical cleanup of the
include order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225974 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 11:23:27 +00:00
Richard Trieu
1bcf09e589 Disable -Wunknown-pragmas in a test so that Clang without -Wself-move will not
complain that the flag doesn't exist.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225931 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 01:50:12 +00:00
Duncan P. N. Exon Smith
d640962656 IR: Add MDLocation class
Add a new subclass of `UniquableMDNode`, `MDLocation`.  This will be the
IR version of `DebugLoc` and `DILocation`.  The goal is to rename this
to `DILocation` once the IR classes supersede the `DI`-prefixed
wrappers.

This isn't used anywhere yet.  Part of PR21433.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225824 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 20:44:56 +00:00
Aaron Ballman
df70ab2592 Silence warnings about unknown pragmas for compilers that are not Clang. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225788 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 14:30:07 +00:00
NAKAMURA Takumi
16a6d38e01 IR/MetadataTest.cpp: Appease msc17 to avoid initializer list.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225775 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 08:13:46 +00:00
Richard Trieu
cd7eb37ca4 Disable a warning for self move since the test is checking for this behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225754 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 02:10:33 +00:00
Duncan P. N. Exon Smith
6e4bbf0390 IR: Use unique_ptr, NFC
Use `std::unique_ptr<>`, as suggested by David Blaikie.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225749 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:57:27 +00:00
Duncan P. N. Exon Smith
698be08c84 IR: Remove an invalid assertion when replacing resolved operands
This adds back the testcase from r225738, and adds to it.  Looks like we
need both sides for now (the assertion was incorrect both ways, and
although it seemed reasonable (when written correctly) it wasn't
particularly important).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225745 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:46:34 +00:00
Duncan P. N. Exon Smith
47952358ce Revert "IR: Fix an inverted assertion when replacing resolved operands"
This reverts commit r225738.  Maybe the assertion is just plain wrong,
but this version fails on WAY more bots.  I'll make sure both ways work
in a follow-up but I want to get bots green in the meantime.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225742 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:34:21 +00:00
Duncan P. N. Exon Smith
4fef722974 IR: Fix an inverted assertion when replacing resolved operands
Add a unit test, since this bug was only exposed by clang tests.  Thanks
to Rafael for tracking this down!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225738 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 00:10:38 +00:00
Duncan P. N. Exon Smith
5e3ba22b3a IR: Fix unit test memory leak reported by ASan
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/603/steps/check-llvm%20asan/logs/stdio

Thanks Alexey for pointing me to this!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225721 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:46:15 +00:00
Duncan P. N. Exon Smith
45db33d634 IR: Make MDNodeFwdDecl destructor public
Now that the leak detector is gone, anyone can call this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225689 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 20:19:54 +00:00
Duncan P. N. Exon Smith
728315adf4 IR: Add test for handleChangedOperand() recursion
Turns out this can happen.  Remove the `FIXME` and add a testcase that
crashes without the extra logic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225657 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 19:22:04 +00:00
Duncan P. N. Exon Smith
28184c10c9 IR: Make temporary nodes distinct
Change the return of `MDNode::isDistinct()` for `MDNode::getTemporary()`
to `true`.  They aren't uniqued.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225646 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 18:41:26 +00:00
Dmitri Gribenko
750f3160df ConvertUTFTest: fix misleading empty line
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225580 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-10 05:03:29 +00:00
Duncan P. N. Exon Smith
727176d00e IR: Add MDNode::getDistinct()
Allow distinct `MDNode`s to be explicitly created.  There's no way (yet)
of representing their distinctness in assembly/bitcode, however, so this
still isn't first-class.

Part of PR22111.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225406 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07 22:24:46 +00:00
Duncan P. N. Exon Smith
ee06e126b7 IR: Add MDNode::isDistinct()
Add API to indicate whether an `MDNode` is distinct.  A distinct node is
not stored in the MDNode uniquing tables, and will never be returned by
`MDNode::get()`.

Although distinct nodes are only currently created by uniquing
collisions (when operands change), PR22111 will allow these nodes to be
explicitly created.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225401 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-07 21:35:38 +00:00
Duncan P. N. Exon Smith
97d1c07c15 IR: Don't drop MDNode uniquing on null operands
Now that `LLVMContextImpl` can call `MDNode::dropAllReferences()` to
prevent teardown madness, stop dropping uniquing just because an operand
drops to null.

Part of PR21532.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225223 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-05 23:31:54 +00:00
Frederic Riss
0c36e97b78 Make DIE.h a public CodeGen header.
dsymutil would like to use all the AsmPrinter/MCStreamer infrastructure
to stream out the DWARF. In order to do so, it will reuse the DIE object
and so this header needs to be public.

The interface exposed here has some corners that cannot be used without a
DwarfDebug object, but clients that want to stream Dwarf can just avoid
these.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225208 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-05 21:29:41 +00:00
Chandler Carruth
040ca449b2 [PM] Add names and debug logging for analysis passes to the new pass
manager.

This starts to allow us to test analyses more easily, but it's really
only the beginning. Some of the code here is still untestable without
manual changes to create analysis passes, but I wanted to factor it into
a small of chunks as possible.

Next up in order to be able to test things are, in no particular order:
- No-op analyses passes so we don't have to use real ones to exercise
  the pass maneger itself.
- Automatic way of generating dummy passes that require an analysis be
  run, including a variant that calls a 'print' method on a pass to make
  it even easier to print out the results of an analysis.
- Dummy passes that invalidate all analyses for their IR unit so we can
  test invalidation and re-runs.
- Automatic way to print each analysis pass as it is re-run.
- Automatic but optional verification of analysis passes everywhere
  possible.

I'm not claiming I'll get to all of these immediately, but that's what
is in the pipeline at some stage. I'm fleshing out exactly what I need
and what to prioritize by working on converting analyses and then trying
to test the conversion. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225162 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-05 12:21:44 +00:00
Chandler Carruth
b246acebf4 [PM] Switch the new pass manager to use a reference-based API for IR
units.

This was debated back and forth a bunch, but using references is now
clearly cleaner. Of all the code written using pointers thus far, in
only one place did it really make more sense to have a pointer. In most
cases, this just removes immediate dereferencing from the code. I think
it is much better to get errors on null IR units earlier, potentially
at compile time, than to delay it.

Most notably, the legacy pass manager uses references for its routines
and so as more and more code works with both, the use of pointers was
likely to become really annoying. I noticed this when I ported the
domtree analysis over and wrote the entire thing with references only to
have it fail to compile. =/ It seemed better to switch now than to
delay. We can, of course, revisit this is we learn that references are
really problematic in the API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-05 02:47:05 +00:00
Lang Hames
a46dd583d6 [APFloat][ADT] Fix sign handling logic for FMA results that truncate to zero.
This patch adds a check for underflow when truncating results back to lower
precision at the end of an FMA. The additional sign handling logic in
APFloat::fusedMultiplyAdd should only be performed when the result of the
addition step of the FMA (in full precision) is exactly zero, not when the
result underflows to zero.

Unit tests for this case and related signed zero FMA results are included.

Fixes <rdar://problem/18925551>.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225123 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-04 01:20:55 +00:00
Chandler Carruth
4b77e07165 Revert r225053: Add an ArrayRef upcasting constructor from ArrayRef<U*> -> ArrayRef<T*> where T is a base of U.
This appears to have broken at least the windows build bots due to
compile errors in the predicate that didn't simply supress the overload.
I'm not sure what the fix is, and the bots have been broken for a long
time now so I'm just reverting until Michael can figure out a fix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225064 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-01 13:01:25 +00:00
Michael Gottesman
69338a993e Add 2x constructors for TinyPtrVector, one that takes in one elemenet and the other that takes in an ArrayRef<EltTy>
Currently one can only construct an empty TinyPtrVector. These are just missing
elements of the API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225055 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-31 23:33:24 +00:00
Michael Gottesman
4ba553c0f3 Add a SmallMapVector class that is a MapVector with a Map of SmallDenseMap and a Vector of SmallVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225054 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-31 23:33:21 +00:00
Michael Gottesman
735f1df049 Add an ArrayRef upcasting constructor from ArrayRef<U*> -> ArrayRef<T*> where T is a base of U.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225053 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-31 23:33:18 +00:00
Chandler Carruth
7c150bae21 [cmake] Start making LLVM_LIBDIR_SUFFIX effective by adding it to
*numerous* places where it was missing in the CMake build. The primary
change here is that the suffix is now actually used for all of the lib
directories in the LLVM project's CMake. The various subprojects still
need similar treatment.

This is the first of a series of commits to try to make LLVM's cmake
effective in a multilib Linux installation. I don't think many people
are seriously using this variable so I'm hoping the fallout will be
minimal. A somewhat unfortunate consequence of the nature of these
commits is that until I land all of them, they will in part make the
brokenness of our multilib support more apparant. At the end, things
should actually work.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224919 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-29 11:16:19 +00:00
Rafael Espindola
1871cba561 Fix a leak found by asan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224773 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-23 17:20:23 +00:00
Peter Zotov
7bfc61dfe3 [C API] Expose LLVMGetGlobalValueAddress and LLVMGetFunctionAddress.
Patch by Ramkumar Ramachandra <artagnon@gmail.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224720 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-22 18:53:11 +00:00
Rafael Espindola
ada5f24b5f The leak detector is dead, long live asan and valgrind.
In resent times asan and valgrind have found way more memory management bugs
in llvm than the special purpose leak detector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224703 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-22 13:00:36 +00:00
Duncan P. N. Exon Smith
9e2c0f95fe Remove 'metadata' from comments
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224328 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 07:45:05 +00:00
Duncan P. N. Exon Smith
02a8d1bcfd IR: Stop printing 'metadata' in Metadata::print()
Stop printing `metadata` in `Metadata::print()` and
`Metadata::printAsOperand()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224327 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 07:40:31 +00:00
Duncan P. N. Exon Smith
2ebd1efc08 IR: Make MDNode::dump() useful by adding addresses
It's horrible to inspect `MDNode`s in a debugger.  All of their operands
that are `MDNode`s get dumped as `<badref>`, since we can't assign
metadata slots in the context of a `Metadata::dump()`.  (Why not?  Why
not assign numbers lazily?  Because then each time you called `dump()`,
a given `MDNode` could have a different lazily assigned number.)

Fortunately, the C memory model gives us perfectly good identifiers for
`MDNode`.  Add pointer addresses to the dumps, transforming this:

    (lldb) e N->dump()
    !{i32 662302, i32 26, <badref>, null}

    (lldb) e ((MDNode*)N->getOperand(2))->dump()
    !{i32 4, !"foo"}

into:

    (lldb) e N->dump()
    !{i32 662302, i32 26, <0x100706ee0>, null}

    (lldb) e ((MDNode*)0x100706ee0)->dump()
    !{i32 4, !"foo"}

and this:

    (lldb) e N->dump()
    0x101200248 = !{<badref>, <badref>, <badref>, <badref>, <badref>}

    (lldb) e N->getOperand(0)
    (const llvm::MDOperand) $0 = {
      MD = 0x00000001012004e0
    }
    (lldb) e N->getOperand(1)
    (const llvm::MDOperand) $1 = {
      MD = 0x00000001012004e0
    }
    (lldb) e N->getOperand(2)
    (const llvm::MDOperand) $2 = {
      MD = 0x0000000101200058
    }
    (lldb) e N->getOperand(3)
    (const llvm::MDOperand) $3 = {
      MD = 0x00000001012004e0
    }
    (lldb) e N->getOperand(4)
    (const llvm::MDOperand) $4 = {
      MD = 0x0000000101200058
    }
    (lldb) e ((MDNode*)0x00000001012004e0)->dump()
    !{}

    (lldb) e ((MDNode*)0x0000000101200058)->dump()
    !{null}

into:

    (lldb) e N->dump()
    !{<0x1012004e0>, <0x1012004e0>, <0x101200058>, <0x1012004e0>, <0x101200058>}

    (lldb) e ((MDNode*)0x1012004e0)->dump()
    !{}

    (lldb) e ((MDNode*)0x101200058)->dump()
    !{null}

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224325 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-16 07:09:37 +00:00
David Majnemer
3acb2035ba StringPool: Cleanup typos in unittest comments
No functional change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224226 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 01:04:49 +00:00
David Majnemer
1f59bf4441 ThreadLocal: Return a mutable pointer if templated with a non-const type
It makes more sense for ThreadLocal<const T>::get to return a const T*
and ThreadLocal<T>::get to return a T*.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224225 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-15 01:04:45 +00:00
Duncan P. N. Exon Smith
85cbe57fc5 IR: Don't track nullptr on metadata RAUW
The RAUW support in `Metadata` supports going to `nullptr` specifically
to handle values being deleted, causing `ValueAsMetadata` to be deleted.

Fix the case where the reference is from a `TrackingMDRef` (as opposed
to an `MDOperand` or a `MetadataAsValue`).

This is surprisingly rare -- metadata tracked by `TrackingMDRef` going
to null -- but it came up in an openSUSE bootstrap during inlining.  The
tracking ref was held by the `ValueMap` because it was referencing a
local, the basic block containing the local became dead after it had
been merged in, and when the local was deleted, the tracking ref
asserted in an `isa`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224146 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 19:24:33 +00:00
Rafael Espindola
7f4b22e7de Move the resize file feature from mapped_file_region to the only user.
This removes a duplicated stat on every file that llvm-ar looks at.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224138 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 18:13:23 +00:00
Rafael Espindola
e1136e38a7 Pass a FD to resise_file and add a testcase.
I will add a real use in another commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224136 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 17:55:12 +00:00
Rafael Espindola
7291e0706e Remove unused feature. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224135 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-12 17:35:34 +00:00
Rafael Espindola
0be06cf360 Remove a convoluted way of calling close by moving the call to the only caller.
As a bonus we can actually check the return value.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224046 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 20:12:55 +00:00
Rafael Espindola
de15d01f9d Remove dead code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224029 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 17:17:26 +00:00
Duncan P. N. Exon Smith
dad20b2ae2 IR: Split Metadata from Value
Split `Metadata` away from the `Value` class hierarchy, as part of
PR21532.  Assembly and bitcode changes are in the wings, but this is the
bulk of the change for the IR C++ API.

I have a follow-up patch prepared for `clang`.  If this breaks other
sub-projects, I apologize in advance :(.  Help me compile it on Darwin
I'll try to fix it.  FWIW, the errors should be easy to fix, so it may
be simpler to just fix it yourself.

This breaks the build for all metadata-related code that's out-of-tree.
Rest assured the transition is mechanical and the compiler should catch
almost all of the problems.

Here's a quick guide for updating your code:

  - `Metadata` is the root of a class hierarchy with three main classes:
    `MDNode`, `MDString`, and `ValueAsMetadata`.  It is distinct from
    the `Value` class hierarchy.  It is typeless -- i.e., instances do
    *not* have a `Type`.

  - `MDNode`'s operands are all `Metadata *` (instead of `Value *`).

  - `TrackingVH<MDNode>` and `WeakVH` referring to metadata can be
    replaced with `TrackingMDNodeRef` and `TrackingMDRef`, respectively.

    If you're referring solely to resolved `MDNode`s -- post graph
    construction -- just use `MDNode*`.

  - `MDNode` (and the rest of `Metadata`) have only limited support for
    `replaceAllUsesWith()`.

    As long as an `MDNode` is pointing at a forward declaration -- the
    result of `MDNode::getTemporary()` -- it maintains a side map of its
    uses and can RAUW itself.  Once the forward declarations are fully
    resolved RAUW support is dropped on the ground.  This means that
    uniquing collisions on changing operands cause nodes to become
    "distinct".  (This already happened fairly commonly, whenever an
    operand went to null.)

    If you're constructing complex (non self-reference) `MDNode` cycles,
    you need to call `MDNode::resolveCycles()` on each node (or on a
    top-level node that somehow references all of the nodes).  Also,
    don't do that.  Metadata cycles (and the RAUW machinery needed to
    construct them) are expensive.

  - An `MDNode` can only refer to a `Constant` through a bridge called
    `ConstantAsMetadata` (one of the subclasses of `ValueAsMetadata`).

    As a side effect, accessing an operand of an `MDNode` that is known
    to be, e.g., `ConstantInt`, takes three steps: first, cast from
    `Metadata` to `ConstantAsMetadata`; second, extract the `Constant`;
    third, cast down to `ConstantInt`.

    The eventual goal is to introduce `MDInt`/`MDFloat`/etc. and have
    metadata schema owners transition away from using `Constant`s when
    the type isn't important (and they don't care about referring to
    `GlobalValue`s).

    In the meantime, I've added transitional API to the `mdconst`
    namespace that matches semantics with the old code, in order to
    avoid adding the error-prone three-step equivalent to every call
    site.  If your old code was:

        MDNode *N = foo();
        bar(isa             <ConstantInt>(N->getOperand(0)));
        baz(cast            <ConstantInt>(N->getOperand(1)));
        bak(cast_or_null    <ConstantInt>(N->getOperand(2)));
        bat(dyn_cast        <ConstantInt>(N->getOperand(3)));
        bay(dyn_cast_or_null<ConstantInt>(N->getOperand(4)));

    you can trivially match its semantics with:

        MDNode *N = foo();
        bar(mdconst::hasa               <ConstantInt>(N->getOperand(0)));
        baz(mdconst::extract            <ConstantInt>(N->getOperand(1)));
        bak(mdconst::extract_or_null    <ConstantInt>(N->getOperand(2)));
        bat(mdconst::dyn_extract        <ConstantInt>(N->getOperand(3)));
        bay(mdconst::dyn_extract_or_null<ConstantInt>(N->getOperand(4)));

    and when you transition your metadata schema to `MDInt`:

        MDNode *N = foo();
        bar(isa             <MDInt>(N->getOperand(0)));
        baz(cast            <MDInt>(N->getOperand(1)));
        bak(cast_or_null    <MDInt>(N->getOperand(2)));
        bat(dyn_cast        <MDInt>(N->getOperand(3)));
        bay(dyn_cast_or_null<MDInt>(N->getOperand(4)));

  - A `CallInst` -- specifically, intrinsic instructions -- can refer to
    metadata through a bridge called `MetadataAsValue`.  This is a
    subclass of `Value` where `getType()->isMetadataTy()`.

    `MetadataAsValue` is the *only* class that can legally refer to a
    `LocalAsMetadata`, which is a bridged form of non-`Constant` values
    like `Argument` and `Instruction`.  It can also refer to any other
    `Metadata` subclass.

(I'll break all your testcases in a follow-up commit, when I propagate
this change to assembly.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223802 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-09 18:38:53 +00:00
Duncan P. N. Exon Smith
7280d8ccce IR: Drop uniquing for self-referencing MDNodes
It doesn't make sense to unique self-referencing nodes.  Drop uniquing
for them.

Note that `MDNode::intersect()` occasionally returns self-referencing
nodes.  Previously these would be returned by `MDNode::get()`.  I'm not
convinced this was intended behaviour -- to me it seems it should return
a node whose only operand is the self-reference -- but I don't know much
about alias scopes so I'm preserving it for now.

This is part of PR21532.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223618 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-07 19:52:06 +00:00
Duncan P. N. Exon Smith
6bb158dd34 IR: Remove reference to ENABLE_MDNODE_UNIQUING
Apparently `MDNode` uniquing used to be optional.  I suppose the
configure flag must have disappeared at some point.  Change the test so
it actually tests uniquing, and remove the check for
`ENABLE_MDNODE_UNIQUING`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223617 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-07 19:02:48 +00:00
Rafael Espindola
3f598f77bd Remove dead code. NFC.
This interface was added 2 years ago but users never developed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223368 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-04 16:59:36 +00:00
Aaron Ballman
42fcf3d61a Silencing several "multiple copy constructors" warnings from MSVC; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223238 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 14:44:16 +00:00
Duncan P. N. Exon Smith
fe03508abd ADT: Add SmallVector<>::emplace_back()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223201 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 04:45:09 +00:00
Lang Hames
5ab94e7135 [MCJIT] Unique-ptrify the RTDyldMemoryManager member of MCJIT. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223183 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-03 00:51:19 +00:00
Duncan P. N. Exon Smith
9416f9c57d DebugIR: Delete -debug-ir
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222945 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-29 03:15:47 +00:00
Colin LeMahieu
04871e9c9b Cleaning out google tests from MC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222770 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-25 18:03:08 +00:00
Paul Robinson
2dc4746332 More long path name support on Windows, this time in program execution.
Allows long paths for the executable and redirected stdin/stdout/stderr.
Addresses PR21563.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222671 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-24 18:05:29 +00:00
Duncan P. N. Exon Smith
5deb1bf97f Support: Add *cast_or_null<> for pointer wrappers
Fill in omission of `cast_or_null<>` and `dyn_cast_or_null<>` for types
that wrap pointers (e.g., smart pointers).

Type traits need to be slightly stricter than for `cast<>` and
`dyn_cast<>` to resolve ambiguities with simple types.

There didn't seem to be any unit tests for pointer wrappers, so I tested
`isa<>`, `cast<>`, and `dyn_cast<>` while I was in there.

This only supports pointer wrappers with a conversion to `bool` to check
for null.  If in the future it's useful to support wrappers without such
a conversion, it should be a straightforward incremental step to use the
`simplify_type` machinery for the null check.  In that case, the unit
tests should be updated to remove the `operator bool()` from the
`pointer_wrappers::PTy`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222644 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-24 03:13:02 +00:00
Rafael Espindola
ed46a2c2aa Fix a silly bug in StreamingMemoryObject.cpp.
The logic for detecting EOF was wrong and would fail if we ever requested
more than 16k past the last read position.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222505 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-21 05:15:41 +00:00
Michael Ilseman
d23f04a165 Compilation test for PostOrderIterator.
If the template specialization for externally managed sets in
PostOrderIterator call too far out of sync with each other, this unit
test will fail to build. This is especially useful for developers who
may not build Clang (the only in-tree user) every time.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222447 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 19:33:33 +00:00
Alexey Samsonov
88dc43f69e Remove support for undocumented SpecialCaseList entries.
"global-init", "global-init-src" and "global-init-type" were originally
used to blacklist entities in ASan init-order checker. However, they
were never documented, and later were replaced by "=init" category.

Old blacklist entries should be converted as follows:
  * global-init:foo -> global:foo=init
  * global-init-src:bar -> src:bar=init
  * global-init-type:baz -> type:baz=init



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-20 01:27:19 +00:00
Lang Hames
58c62e1dba [ADT] Fix PR20728 - Incorrect APFloat::fusedMultiplyAdd results for x86_fp80.
As detailed at http://llvm.org/PR20728, due to an internal overflow in
APFloat::multiplySignificand the APFloat::fusedMultiplyAdd method can return
incorrect results for x87DoubleExtended (x86_fp80) values. This commonly
manifests as incorrect constant folding of libm fmal calls on x86. E.g.

fmal(1.0L, 1.0L, 3.0L) == 0.0L      (should be 4.0L)

This patch fixes PR20728 by adding an extra bit to the significand for
intermediate results of APFloat::multiplySignificand, avoiding the overflow.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222374 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 19:15:41 +00:00
David Blaikie
1d4f28c6bc Remove StringMap::GetOrCreateValue in favor of StringMap::insert
Having two ways to do this doesn't seem terribly helpful and
consistently using the insert version (which we already has) seems like
it'll make the code easier to understand to anyone working with standard
data structures. (I also updated many references to the Entry's
key and value to use first() and second instead of getKey{Data,Length,}
and get/setValue - for similar consistency)

Also removes the GetOrCreateValue functions so there's less surface area
to StringMap to fix/improve/change/accommodate move semantics, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222319 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-19 05:49:42 +00:00
NAKAMURA Takumi
3b16af8670 CallGraphTest.cpp: Remove invalid tests. ++S might step over F if S == F.
MSVC Runtime detects "Assertion failed: vector iterator not incrementable"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222233 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-18 12:23:19 +00:00
Rafael Espindola
8a190092af Fix the autoconf build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222173 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 21:06:38 +00:00
Rafael Espindola
c4fe4e9681 Factor common code it Linker::init.
The TypeFinder was not being used in one of the constructors.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222172 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 20:51:01 +00:00
Rafael Espindola
95764ec6ed Fix GraphTraits for "const CallGraphNode *" and "const CallGraph *"
The specializations were broken. For example,

void foo(const CallGraph *G) {
  auto I = GraphTraits<const CallGraph *>::nodes_begin(G);
  auto K = I++;

  ...
}

or

void bar(const CallGraphNode *N) {
  auto I = GraphTraits<const CallGraphNode *>::nodes_begin(G);
  auto K = I++;

  ....
}

would not compile.

Patch by Speziale Ettore!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222149 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-17 17:51:45 +00:00
Benjamin Kramer
f04ce0e657 Dispose disassembler after use in unit test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222083 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-15 10:53:12 +00:00
David Blaikie
7987683c39 StringMap: Test and finish off supporting perfectly forwarded values in StringMap operations.
Followup to r221946.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221958 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-14 00:41:46 +00:00
Rafael Espindola
bb11e56168 Fix the other build system.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221901 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 17:12:19 +00:00
Rafael Espindola
961f1bb09e Fix a regression on the disassembling C API.
The fix is easy. Unfortunately, we had 0 tests, so adding one was somewhat
complicated.

Thanks to Kevin Enderby for the report.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221899 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 16:52:07 +00:00
Aaron Ballman
5f34bd9a4c Fixing some sign comparison warnings from MSVC; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221887 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 13:39:49 +00:00
Paul Robinson
4848765635 Drop a few unneeded ctor calls (missed code review comment).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221845 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:36:34 +00:00
Paul Robinson
038e20451d Improve long path name support on Windows.
Windows normally limits the length of an absolute path name to 260
characters; directories can have lower limits.  These limits increase
to about 32K if you use absolute paths with the special '\\?\'
prefix. Teach Support\Windows\Path.inc to use that prefix as needed.

TODO: Other parts of Support could also learn to use this prefix.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221841 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:12:14 +00:00
Jordan Rose
2217648f91 [Bitcode] AtEndOfStream should only check against the size if it's known.
This avoids an issue where AtEndOfStream mistakenly returns true at the /start/ of
a stream.

(In the rare case that the size is known and actually 0, the slow path will still
handle it correctly.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221840 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-13 00:08:41 +00:00
David Blaikie
d9078385de Ensure function_refs are copyable even from non-const references
A subtle bug was found where attempting to copy a non-const function_ref
lvalue would actually invoke the generic forwarding constructor (as it
was a closer match - being T& rather than the const T& of the implicit
copy constructor). In the particular case this lead to a dangling
function_ref member (since it had referenced the function_ref passed by
value to its ctor, rather than the outer function_ref that was still
alive)

SFINAE the converting constructor to not be considered if the copy
constructor is available and demonstrate that this causes the copy to
refer to the original functor, not to the function_ref it was copied
from. (without the code change, the test would fail as Y would be
referencing X and Y() would see the result of the mutation to X, ie: 2)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221753 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-12 02:06:08 +00:00
NAKAMURA Takumi
93f761eced [CMake] LLVMSupport: Give system_libs PRIVATE scope when LLVMSupport is built as SHARED. Users of LLVMSupport won't inherit ${system_libs}.
unittests/SupporTests is another user of libpthreads. Apply LLVM_SYSTEM_LIBS for him explicitly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221531 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-07 16:08:19 +00:00
Colin LeMahieu
38d3e4d5d8 [Hexagon] Reverting 220584 to address ASAN errors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221210 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-04 00:14:36 +00:00
Rafael Espindola
c35c39b73c Remove the PreserveSource linker mode.
I noticed that it was untested, and forcing it on caused some tests to fail:

    LLVM :: Linker/metadata-a.ll
    LLVM :: Linker/prefixdata.ll
    LLVM :: Linker/type-unique-odr-a.ll
    LLVM :: Linker/type-unique-simple-a.ll
    LLVM :: Linker/type-unique-simple2-a.ll
    LLVM :: Linker/type-unique-simple2.ll
    LLVM :: Linker/type-unique-type-array-a.ll
    LLVM :: Linker/unnamed-addr1-a.ll
    LLVM :: Linker/visibility1.ll

If it is to be resurrected, it has to be fixed and we should probably have a
-preserve-source command line option in llvm-mc and run tests with and without
it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220741 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-28 00:24:16 +00:00
Michael Gottesman
86ec9c4081 Add MapVector::rbegin(), MapVector::rend() to completment MapVector::begin(), MapVector::end().
These just delegate to the underlying vector type in the MapVector.

Also just add in some sanity unittests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220687 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-27 17:20:53 +00:00
Rafael Espindola
72478e59c7 Update the error handling of lib/Linker.
Instead of passing a std::string&, use the new diagnostic infrastructure.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220608 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-25 04:06:10 +00:00
Rafael Espindola
c498284e46 Modernize the error handling of the Materialize function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220600 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 22:50:48 +00:00
Colin LeMahieu
8699f5390b [Hexagon] Resubmission of 220427
Modified library structure to deal with circular dependency between HexagonInstPrinter and HexagonMCInst.
Adding encoding bits for add opcode.
Adding llvm-mc tests.
Removing unit tests.

http://reviews.llvm.org/D5624

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220584 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-24 19:00:32 +00:00
Rafael Espindola
08aeb166fd Add unittest for extreme alignments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220483 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-23 14:45:19 +00:00
NAKAMURA Takumi
f3379e7bdd [CMake] Prune trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220479 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-23 11:31:33 +00:00
NAKAMURA Takumi
effe629b3d Revert r220427, "[Hexagon] Adding encoding bits for add opcode."
It brought cyclic dependecy between HexagonAsmPrinter and HexagonDesc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220478 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-23 11:31:22 +00:00
Lang Hames
950c6482c6 [MCJIT] Make repeat calls to MCJIT::getPointerToFunction for declarations safe.
MCJIT::getPointerForFunction adds the resulting address to the global mapping.
This should be done via updateGlobalMapping rather than addGlobalMapping, since
the latter asserts if a mapping already exists.

MCJIT::getPointerToFunction is actually deprecated - hopefully we can remove it
(or more likely re-task it) entirely soon. In the mean time it should at least
work as advertised.

<rdar://problem/18727946>



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220444 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22 23:18:42 +00:00
Colin LeMahieu
545127f54d [Hexagon] Adding encoding bits for add opcode.
Adding llvm-mc tests.
Removing unit tests.

http://reviews.llvm.org/D5624

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220427 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22 20:58:35 +00:00
Filipe Cabecinhas
8ff1b98208 Silence gcc's -Wcomment
gcc's (4.7, I think) -Wcomment warning is not "as smart" as clang's and
warns even if the line right after the backslash-newline sequence only has
a line comment that starts at the beginning of the line.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220360 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-22 02:16:06 +00:00
Aaron Ballman
72376cccc5 Silence a -Wcast-qual warning; NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220300 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-21 16:12:37 +00:00
Lang Hames
63b14baf79 [ADT] Add a 'find_as' operation to DenseSet.
This operation is analogous to its counterpart in DenseMap: It allows lookup
via cheap-to-construct keys (provided that getHashValue and isEqual are
implemented for the cheap key-type in the DenseMapInfo specialization).

Thanks to Chandler for the review.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220168 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-19 19:36:33 +00:00
Chandler Carruth
082e667c15 [ADT] Add an (ADL-friendly) abs free function for APFloat that returns
by value having cleared the sign bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219485 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 08:27:22 +00:00
Matt Arsenault
c08f0e3743 Add minnum / maxnum to APFloat
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219475 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 05:21:32 +00:00
Chandler Carruth
f4ec6697b8 [ADT] Replace the logb implementation with the simpler and much closer
to what we actually want ilogb implementation. This makes everything
*much* easier to deal with and is actually what we want when using it
anyways.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219474 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 05:14:12 +00:00
Chandler Carruth
cb84b21243 [ADT] Add the scalbn function for APFloat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219473 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 04:54:30 +00:00
Chandler Carruth
9ea4dd2eed [ADT] Implement the 'logb' functionality for APFloat. This is necessary
to implement complex division in the constant folder of Clang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219471 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-10 04:17:04 +00:00
Chandler Carruth
0ffdb31af0 [ADT] Add basic operator overloads for arithmetic to APFloat to make
code using it more readable.

Also add a copySign static function that works more like the standard
function by accepting the value and sign-carying value as arguments.

No interesting logic here, but tests added to cover the basic API
additions and make sure they do something plausible.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219453 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-09 23:26:15 +00:00
Nick Kledzik
52688c3aff [Support] Add MemoryBuffer::getFileSlice()
mach-o supports "fat" files which are a header/table-of-contents followed by a
concatenation of mach-o files built for different architectures. Currently, 
MemoryBuffer has no easy way to map a subrange (slice) of a file which lld
will need to select a mach-o slice of a fat file. The new function provides 
an easy way to map a slice of a file into a MemoryBuffer. Test case included.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219260 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-08 00:22:18 +00:00
Kaelyn Takata
502b4d1e96 Add return value and negative checks to MapVector::erase from r219240.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219250 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-07 23:11:49 +00:00
Kaelyn Takata
25cfb5cff5 Add size_t MapVector::erase(KeyT) similar to the one in std::map.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219240 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-07 21:15:51 +00:00
NAKAMURA Takumi
4462f60d57 [CMake] HexagonTests: Update LINK_COMPONENTS.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219072 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-05 04:54:41 +00:00
Sid Manning
4cd443ac18 Add unit tests to verify Hexagon emission.
Add the test cases I overlooked, part of the original commit,
http://reviews.llvm.org/D5523

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219016 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-03 20:33:03 +00:00
Duncan P. N. Exon Smith
83902832de Revert "Revert "DI: Fold constant arguments into a single MDString""
This reverts commit r218918, effectively reapplying r218914 after fixing
an Ocaml bindings test and an Asan crash.  The root cause of the latter
was a tightened-up check in `DILexicalBlock::Verify()`, so I'll file a
PR to investigate who requires the loose check (and why).

Original commit message follows.

--

This patch addresses the first stage of PR17891 by folding constant
arguments together into a single MDString.  Integers are stringified and
a `\0` character is used as a separator.

Part of PR17891.

Note: I've attached my testcases upgrade scripts to the PR.  If I've
just broken your out-of-tree testcases, they might help.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219010 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-03 20:01:09 +00:00
Sid Manning
30d67d99cf Adding skeleton for unit testing Hexagon Code Emission
Adding and modifying CMakeLists.txt files to run unit tests under
unittests/Target/* if the directory exists.  Adding basic unit test to check
that code emitter object can be retrieved.

Differential Revision: http://reviews.llvm.org/D5523
Change by: Colin LeMahieu

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218986 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-03 13:18:11 +00:00
Duncan P. N. Exon Smith
32e192aeb3 Revert "DI: Fold constant arguments into a single MDString"
This reverts commit r218914 while I investigate some bots.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218918 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-02 22:15:31 +00:00
Duncan P. N. Exon Smith
0917b70630 DI: Fold constant arguments into a single MDString
This patch addresses the first stage of PR17891 by folding constant
arguments together into a single MDString.  Integers are stringified and
a `\0` character is used as a separator.

Part of PR17891.

Note: I've attached my testcases upgrade scripts to the PR.  If I've
just broken your out-of-tree testcases, they might help.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218914 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-02 21:56:57 +00:00
David Blaikie
42f40dbbef Update test name to match changes made in r218783
Addressing post commit review feedback from Justin Bogner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218821 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 21:19:39 +00:00
Argyrios Kyrtzidis
7fae208c11 Adds 'override' to overriding methods. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218815 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 21:00:44 +00:00
Adrian Prantl
02474a32eb Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.

Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.

By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.

The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)

This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.

What this patch doesn't do:

This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.

http://reviews.llvm.org/D4919
rdar://problem/17994491

Thanks to dblaikie and dexonsmith for reviewing this patch!

Note: I accidentally committed a bogus older version of this patch previously.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218787 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:55:02 +00:00
David Blaikie
7538babc12 Add an immovable type to test Optional<T>::emplace more rigorously after r218732.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218783 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:29:44 +00:00
Adrian Prantl
10c4265675 Revert r218778 while investigating buldbot breakage.
"Move the complex address expression out of DIVariable and into an extra"

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218782 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 18:10:54 +00:00
Adrian Prantl
076fd5dfc1 Move the complex address expression out of DIVariable and into an extra
argument of the llvm.dbg.declare/llvm.dbg.value intrinsics.

Previously, DIVariable was a variable-length field that has an optional
reference to a Metadata array consisting of a variable number of
complex address expressions. In the case of OpPiece expressions this is
wasting a lot of storage in IR, because when an aggregate type is, e.g.,
SROA'd into all of its n individual members, the IR will contain n copies
of the DIVariable, all alike, only differing in the complex address
reference at the end.

By making the complex address into an extra argument of the
dbg.value/dbg.declare intrinsics, all of the pieces can reference the
same variable and the complex address expressions can be uniqued across
the CU, too.
Down the road, this will allow us to move other flags, such as
"indirection" out of the DIVariable, too.

The new intrinsics look like this:
declare void @llvm.dbg.declare(metadata %storage, metadata %var, metadata %expr)
declare void @llvm.dbg.value(metadata %storage, i64 %offset, metadata %var, metadata %expr)

This patch adds a new LLVM-local tag to DIExpressions, so we can detect
and pretty-print DIExpression metadata nodes.

What this patch doesn't do:

This patch does not touch the "Indirect" field in DIVariable; but moving
that into the expression would be a natural next step.

http://reviews.llvm.org/D4919
rdar://problem/17994491

Thanks to dblaikie and dexonsmith for reviewing this patch!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218778 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 17:55:39 +00:00
NAKAMURA Takumi
909a11120e ADTTests/OptionalTest.cpp: Use LLVM_DELETED_FUNCTION.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218750 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 09:14:43 +00:00
Lang Hames
e2ef4419a8 [MCJIT] Turn the getSymbolAddress free function created in r218626 into a static
member of RTDyldMemoryManager (and rename to getSymbolAddressInProcess).

The functionality this provides is very specific to RTDyldMemoryManager, so it
makes sense to keep it in that class to avoid accidental re-use.

No functional change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218741 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 04:11:13 +00:00
Jordan Rose
771ac70aed Add an emplace(...) method to llvm::Optional<T>.
This can be used for in-place initialization of non-moveable types.
For compilers that don't support variadic templates, only up to four
arguments are supported. We can always add more, of course, but this
should be good enough until we move to a later MSVC that has full
support for variadic templates.

Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS.
Reviewed by David Blaikie.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218732 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-01 02:12:35 +00:00
Hans Wennborg
4edcbaec90 WinCOFFObjectWriter: optimize the string table for common suffices
This is a follow-up from r207670 which did the same for ELF.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218636 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29 22:43:20 +00:00
David Blaikie
03b4667e14 Unit test r218187, changing RTDyldMemoryManager::getSymbolAddress's behavior favor mangled lookup over unmangled lookup.
The contract of this function seems problematic (fallback in either
direction seems like it could produce bugs in one client or another),
but here's some tests for its current behavior, at least. See the
commit/review thread of r218187 for more discussion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218626 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29 21:25:13 +00:00
Jordan Rose
88c0ed30da Add getValueOr to llvm::Optional<T>.
This takes a single argument convertible to T, and
- if the Optional has a value, returns the existing value,
- otherwise, constructs a T from the argument and returns that.

Inspired by std::experimental::optional from the "Library Fundamentals" C++ TS.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218618 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-29 18:56:08 +00:00
Nick Kledzik
e93da60ac4 [Support] Add type-safe alternative to llvm::format()
llvm::format() is somewhat unsafe. The compiler does not check that integer
parameter size matches the %x or %d size and it does not complain when a 
StringRef is passed for a %s.  And correctly using a StringRef with format() is  
ugly because you have to convert it to a std::string then call c_str().
 
The cases where llvm::format() is useful is controlling how numbers and
strings are printed, especially when you want fixed width output.  This
patch adds some new formatting functions to raw_streams to format numbers
and StringRefs in a type safe manner. Some examples:

   OS << format_hex(255, 6)        => "0x00ff"
   OS << format_hex(255, 4)        => "0xff"
   OS << format_decimal(0, 5)      => "    0"
   OS << format_decimal(255, 5)    => "  255"
   OS << right_justify(Str, 5)     => "  foo"
   OS << left_justify(Str, 5)      => "foo  "



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218463 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-25 20:30:58 +00:00
NAKAMURA Takumi
a6c580e834 Rework r218304, "ExecutionEngineTests: Call llvm_shutdown() on exit for ManagedStatic introduced in r218151."
r218304 caused crash on msvc builder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218308 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 14:41:02 +00:00
NAKAMURA Takumi
0c5fa4797c ExecutionEngineTests: Call llvm_shutdown() on exit for ManagedStatic introduced in r218151.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218304 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 13:49:51 +00:00
Petar Jovanovic
fd42335e83 Do not destroy external linkage when deleting function body
The function deleteBody() converts the linkage to external and thus destroys
original linkage type value. Lack of correct linkage type causes wrong
relocations to be emitted later.
Calling dropAllReferences() instead of deleteBody() will fix the issue.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218302 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-23 12:54:19 +00:00
Matt Arsenault
55dd199bd3 Add hsail and amdil64 to Triple
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@218142 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-19 19:52:11 +00:00
Justin Bogner
0a277ea23d LineIterator: Provide a variant that keeps blank lines
It isn't always useful to skip blank lines, as evidenced by the
somewhat awkward use of line_iterator in llvm-cov. This adds a knob to
control whether or not to skip blanks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217960 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-17 15:43:01 +00:00
Nick Kledzik
290c772b6c Fix identify_magic() with mach-o stub dylibs.
The wrong value was returned and the unittest did not cover the stub dylib case.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217933 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-17 00:53:44 +00:00
Nick Kledzik
9885a59108 [Support] add decodeSLEB128()
We already have routines to encode SLEB128 as well as encode/decode ULEB128.
This last function fills out the matrix.  I'll need this for some llvm-objdump
work I am doing.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217830 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 21:51:49 +00:00
Ed Maste
399ee93908 Add unit test for r217454
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217786 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-15 16:57:12 +00:00
Rui Ueyama
cf9142d479 Support: Use llvm::COFF::BigObjMagic
Use llvm::COFF::BigObjMagic insetad of the string literal.
Also checks the version number.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217633 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 22:34:32 +00:00
Rui Ueyama
330c819d83 Support: improve identify_magic to recognize COFF bigobj
identify_magic recognized a COFF bigobj as an import library file.
This patch fixes that.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217627 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 21:09:57 +00:00
Rafael Espindola
8d230cd536 Misc cleanups to the FileSytem api.
The main difference is the removal of

std::error_code exists(const Twine &path, bool &result);

It was an horribly redundant interface since a file not existing is also a valid
error_code. Now we have an access function that returns just an error_code. This
is the only function that has to be implemented for Unix and Windows. The
functions can_write, exists and can_execute an now just wrappers.

One still has to be very careful using these function to avoid introducing
race conditions (Time of check to time of use).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217625 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 20:30:02 +00:00
Rafael Espindola
11e375565a Use simpler version of sys::fs::exists. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217618 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-11 19:11:02 +00:00
Rafael Espindola
3b670550ad Add doInitialization/doFinalization to DataLayoutPass.
With this a DataLayoutPass can be reused for multiple modules.

Once we have doInitialization/doFinalization, it doesn't seem necessary to pass
a Module to the constructor.

Overall this change seems in line with the idea of making DataLayout a required
part of Module. With it the only way of having a DataLayout used is to add it
to the Module.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217548 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10 21:27:43 +00:00
Rafael Espindola
5ab6b15c79 Replace a few virtual with override.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217513 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-10 15:50:08 +00:00
Hans Wennborg
3f09227292 Try to unflake AllocatorTest.TestAlignmentPastSlab
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217331 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 05:14:29 +00:00
Hans Wennborg
4f240010fd BumpPtrAllocator: do the size check without moving any pointers
Instead of aligning and moving the CurPtr forward, and then comparing
with End, simply calculate how much space is needed, and compare that
to how much is available.

Hopefully this avoids any doubts about comparing addresses possibly
derived from past the end of the slab array, overflowing, etc.

Also add a test where aligning CurPtr would move it past End.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217330 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-07 04:24:31 +00:00
Rafael Espindola
52fa0d066a Add writeFileWithSystemEncoding to LibLLVMSuppor.
This patch adds to LLVMSupport the capability of writing files with
international characters encoded in the current system encoding. This
is relevant for Windows, where we can either use UTF16 or the current
code page (the legacy Windows international characters). On UNIX, the
file is always saved in UTF8.

This will be used in a patch for clang to thoroughly support response
files creation when calling other tools, addressing PR15171. On
Windows, to correctly support internationalization, we need the
ability to write response files both in UTF16 or the current code
page, depending on the tool we will call. GCC for mingw, for instance,
requires files to be encoded in the current code page. MSVC tools
requires files to be encoded in UTF16.

Patch by Rafael Auler!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217068 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 20:02:00 +00:00
Rafael Espindola
6d66a1cd2f Pass a && to getLazyBitcodeModule.
This forces callers to use std::move when calling it. It is somewhat odd to have
code with std::move that doesn't always move, but it is also odd to have code
without std::move that sometimes moves.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217049 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 17:31:46 +00:00
David Blaikie
38a4f3bbec Ensure ErrorOr cannot implicitly invoke explicit ctors of the underlying type.
An unpleasant surprise while migrating unique_ptrs (see changes in
lib/Object): ErrorOr<int*> was implicitly convertible to
ErrorOr<std::unique_ptr<int>>.

Keep the explicit conversions otherwise it's a pain to convert
ErrorOr<int*> to ErrorOr<std::unique_ptr<int>>.

I'm not sure if there should be more SFINAE on those explicit ctors (I
could check if !is_convertible && is_constructible, but since the ctor
has to be called explicitly I don't think there's any need to disable
them when !is_constructible - they'll just fail anyway. It's the
converting ctors that can create interesting ambiguities without proper
SFINAE). I had to SFINAE the explicit ones because otherwise they'd be
ambiguous with the implicit ones in an explicit context, so far as I
could tell.

The converting assignment operators seemed unnecessary (and similarly
buggy/dangerous) - just rely on the converting ctors to convert to the
right type for assignment instead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217048 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-03 17:31:25 +00:00
Sean Silva
73d86aa56a Nuke MCAnalysis.
The code is buggy and barely tested. It is also mostly boilerplate.
(This includes MCObjectDisassembler, which is the interface to that
functionality)

Following an IRC discussion with Jim Grosbach, it seems sensible to just
nuke the whole lot of functionality, and dig it up from VCS if
necessary (I hope not!).

All of this stuff appears to have been added in a huge patch dump (look
at the timeframe surrounding e.g. r182628) where almost every patch
seemed to be untested and not reviewed before being committed.
Post-review responses to the patches were never addressed. I don't think
any of it would have passed pre-commit review.

I doubt anyone is depending on this, since this code appears to be
extremely buggy. In limited testing that Michael Spencer and I did, we
couldn't find a single real-world object file that wouldn't crash the
CFG reconstruction stuff. The symbolizer stuff has O(n^2) behavior and
so is not much use to anyone anyway. It seemed simpler to remove them as
a whole. Most of this code is boilerplate, which is the only way it was
able to scrape by 60% coverage.

HEADSUP: Modules folks, some files I nuked were referenced from
include/llvm/module.modulemap; I just deleted the references. Hopefully
that is the right fix (one was a FIXME though!).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216983 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 22:32:20 +00:00
Eric Christopher
d5dd8ce2a5 Reinstate "Nuke the old JIT."
Approved by Jim Grosbach, Lang Hames, Rafael Espindola.

This reinstates commits r215111, 215115, 215116, 215117, 215136.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216982 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 22:28:02 +00:00
Hans Wennborg
d52e9a143f BumpPtrAllocator: use uintptr_t when aligning addresses to avoid undefined behaviour
In theory, alignPtr() could push a pointer beyond the end of the current slab, making
comparisons with that pointer undefined behaviour. Use an integer type to avoid this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216973 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 21:51:35 +00:00
Sanjay Patel
4211bbc568 Fix a logic bug when copying fast-math flags.
"Setting" does not equal "copying". This bug has sat dormant for 2 reasons:
1. The unit test was not adequate.
2. Every current user of the "copyFastMathFlags" API is operating on a new instruction.
   (ie, all existing fast-math flags are off). If you copy flags to an existing
   instruction that has some flags on already, you will not necessarily turn them off
   as expected.

I uncovered this bug while trying to implement a fix for PR20802.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216939 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 20:03:00 +00:00
David Blaikie
7b96c4919a unique_ptrify the result of SpecialCaseList::create
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216925 91177308-0d34-0410-b5e6-96231b3b80d8
2014-09-02 18:13:54 +00:00
David Blaikie
07f352637c Add some negative (and positive) static_assert checks for ArrayRef-of-pointer conversions introduced in r216709
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216830 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-31 01:33:41 +00:00
Craig Topper
8316713a9e Add a test for converting ArrayRef<T *> to ArrayRef<const T *>.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216821 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-30 16:48:19 +00:00
Chris Bieneman
77bf4f97bf Cleaning up static initializers in TimeValue.
Code reviewed by Chandlerc

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216703 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-29 01:05:12 +00:00
David Blaikie
819242a446 Convert a few more cases of direct intialization of unique_ptrs from MemoryBuffer::getMemBuffer to move initialization now that it returns by unique_ptr instead of raw pointer.
Cleanup/improvements following r216583.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216605 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 20:14:18 +00:00
Rafael Espindola
1a7f705fba Return a std::unique_ptr when creating a new MemoryBuffer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216583 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 20:03:13 +00:00
Rafael Espindola
34806d20dd yaml::Stream doesn't need to take ownership of the buffer.
In fact, most users were already using the StringRef version.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216575 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 19:03:22 +00:00
Craig Topper
3512034554 Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or just letting them be implicitly created.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216525 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-27 05:25:25 +00:00
Rafael Espindola
fb1af0a48a Pass a std::unique_ptr<MemoryBuffer>& to getLazyBitcodeModule.
By taking a reference we can do the ownership transfer in one place instead of
expecting every caller to do it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216492 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 22:00:09 +00:00
Reid Kleckner
64bb4a64e7 Fix Path unittests on Windows after raw_fd_ostream changes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216422 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-26 00:24:23 +00:00
Rafael Espindola
8c96862847 Modernize raw_fd_ostream's constructor a bit.
Take a StringRef instead of a "const char *".
Take a "std::error_code &" instead of a "std::string &" for error.

A create static method would be even better, but this patch is already a bit too
big.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216393 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-25 18:16:47 +00:00
Dylan Noblesmith
d930a30833 Support: make LLVM Mutexes STL-compatible
Use lock/unlock() convention instead of acquire/release().

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216336 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-23 22:49:22 +00:00
Reid Kleckner
2e1bf78ad6 Fix PR17239 by changing the semantics of the RemainingArgsClass Option kind
This patch contains the LLVM side of the fix of PR17239.

This bug that happens because the /link (clang-cl.exe argument) is
marked as "consume all remaining arguments". However, when inside a
response file, /link should only consume all remaining arguments inside
the response file where it is located, not the entire command line after
expansion.

My patch will change the semantics of the RemainingArgsClass kind to
always consume only until the end of the response file when the option
originally came from a response file. There are only two options in this
class: dash dash (--) and /link.

Reviewed By: rnk

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

Patch by Rafael Auler!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216280 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 19:29:17 +00:00
Alex Lorenz
4ef54c3f85 [Support] Fix the overflow bug in ULEB128 decoding.
Differential Revision: http://reviews.llvm.org/D5029


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216268 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-22 16:29:45 +00:00
David Blaikie
95ca0fb247 Explicitly pass ownership of the MemoryBuffer to AddNewSourceBuffer using std::unique_ptr
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216223 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-21 20:44:56 +00:00
Elena Demikhovsky
6623af7892 IntelJITEventListener updates to fix breaks by recent changes to EngineBuilder and DIContext.
By Arch Robison.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216159 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-21 07:01:55 +00:00
Hans Wennborg
06de8a10d2 BumpPtrAllocator: don't accept 0 for the alignment parameter
It seems unnecessary to have to use an extra branch to check for this special case.

http://reviews.llvm.org/D4945

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216036 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 23:35:33 +00:00
Duncan P. N. Exon Smith
8db4ddb14a IR: Fix a missed case when threading OnlyIfReduced through ConstantExpr
In r216015 I missed propagating `OnlyIfReduced` through the inline
versions of `getGetElementPtr()` (I was relying on compile failures on
mismatches between the header and source signatures to get them all).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216023 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 21:18:21 +00:00
Duncan P. N. Exon Smith
b03916a88b IR: Fix ConstantExpr::replaceUsesOfWithOnConstant()
Change `ConstantExpr` to follow the model the other constants are using:
only malloc a replacement if it's going to be used.  This fixes a subtle
bug where if an API user had used `ConstantExpr::get()` already to
create the replacement but hadn't given it any users, we'd delete the
replacement.

This relies on r216015 to thread `OnlyIfReduced` through
`ConstantExpr::getWithOperands()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216016 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 20:03:35 +00:00
Duncan P. N. Exon Smith
7d84c8ec54 ADT: Unit test for ArrayRef::equals change in r215986
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216008 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 19:18:46 +00:00
Rafael Espindola
548f2b6e8f Don't own the buffer in object::Binary.
Owning the buffer is somewhat inflexible. Some Binaries have sub Binaries
(like Archive) and we had to create dummy buffers just to handle that. It is
also a bad fit for IRObjectFile where the Module wants to own the buffer too.

Keeping this ownership would make supporting IR inside native objects
particularly painful.

This patch focuses in lib/Object. If something elsewhere used to own an Binary,
now it also owns a MemoryBuffer.

This patch introduces a few new types.

* MemoryBufferRef. This is just a pair of StringRefs for the data and name.
  This is to MemoryBuffer as StringRef is to std::string.
* OwningBinary. A combination of Binary and a MemoryBuffer. This is needed
  for convenience functions that take a filename and return both the
  buffer and the Binary using that buffer.

The C api now uses OwningBinary to avoid any change in semantics. I will start
a new thread to see if we want to change it and how.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216002 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 18:44:46 +00:00
Rafael Espindola
9b29ff99c0 Modernize the .ll parsing interface.
* Use StringRef instead of std::string&
* Return a std::unique_ptr<Module> instead of taking an optional module to write
  to (was not really used).
* Use current comment style.
* Use current naming convention.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215989 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 16:58:54 +00:00
Duncan P. N. Exon Smith
7116af637c Reapply r215966, r215965, r215964, r215963, r215960, r215959, r215958, and r215957
This reverts commit r215981, which reverted the above commits because
MSVC std::equal asserts on nullptr iterators, and thes commits
introduced an `ArrayRef::equals()` on empty ArrayRefs.

ArrayRef was changed not to use std::equal in r215986.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215987 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 16:39:58 +00:00
Aaron Ballman
93710f07f0 Reverting r215966, r215965, r215964, r215963, r215960, r215959, r215958, and r215957 (these commits all rely on previous commits) due to build breakage. These commits cause failed assertions when testing Clang using MSVC 2013. The asserts are triggered from the std::equal call within ArrayRef::equals due to being passed invalid input (ArrayRef.begin() is returning a nullptr which is problematic).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215981 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 14:59:02 +00:00
Rafael Espindola
3f4ed32b43 Make it explicit that ExecutionEngine takes ownership of the modules.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215967 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 04:04:25 +00:00
Duncan P. N. Exon Smith
3b666f3b59 IR: Fix ConstantArray::replaceUsesOfWithOnConstant()
Previously, `ConstantArray::replaceUsesOfWithOnConstant()` neglected to
check whether it becomes a `ConstantDataArray`.  Call
`ConstantArray::getImpl()` to check for that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215965 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-19 02:21:00 +00:00
Rafael Espindola
b5a6adc30a Convert an ownership comment with std::uinque_ptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215855 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-17 22:20:33 +00:00
Hans Wennborg
61760cece0 BumpPtrAllocator: remove 'no slabs allocated yet' check
We already handle the no-slabs case when checking whether the current slab
is large enough: if no slabs have been allocated, CurPtr and End are both 0.
alignPtr(0), will still be 0, and so "if (Ptr + Size <= End)" fails.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215841 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-17 18:31:18 +00:00
Sean Silva
855d60236a Revert "[Support] Promote cl::StringSaver to a separate utility"
This reverts commit r215784 / 3f8a26f6fe.

LLD has 3 StringSaver's, one of which takes a lock when saving the
string... Need to investigate more closely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 23:39:01 +00:00
Sean Silva
3f8a26f6fe [Support] Promote cl::StringSaver to a separate utility
This class is generally useful.

In breaking it out, the primary change is that it has been made
non-virtual. It seems like being abstract led to there being 3 different
(2 in llvm + 1 in clang) concrete implementations which disagreed about
the ownership of the saved strings (see the manual call to free() in the
unittest StrDupSaver; yes this is different from the CommandLine.cpp
StrDupSaver which owns the stored strings; which is different from
Clang's StringSetSaver which just holds a reference to a
std::set<std::string> which owns the strings).

I've identified 2 other places in the
codebase that are open-coding this pattern:

  memcpy(Alloc.Allocate<char>(strlen(S)+1), S, strlen(S)+1)

I'll be switching them over. They are
* llvm::sys::Process::GetArgumentVector
* The StringAllocator member of YAMLIO's Input class
This also will allow simplifying Clang's driver.cpp quite a bit.

Let me know if there are any other places that could benefit from
StringSaver. I'm also thinking of adding a saveStringRef member for
getting a stable StringRef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215784 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 23:18:33 +00:00
Rafael Espindola
c73a086233 Simplify memory ownership with std::unique_ptr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215567 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 18:59:01 +00:00
Rafael Espindola
d6448b21bf Simplify ownership with std::unique_ptr. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215566 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 18:49:01 +00:00
Benjamin Kramer
00e08fcaa0 Canonicalize header guards into a common format.
Add header guards to files that were missing guards. Remove #endif comments
as they don't seem common in LLVM (we can easily add them back if we decide
they're useful)

Changes made by clang-tidy with minor tweaks.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:26:38 +00:00
Benjamin Foster
f58eecfbbb Test commit, remove trailing whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215556 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 16:11:50 +00:00
Aaron Ballman
3c02eb1b96 Asserting that the call to chdir succeeds in this test. Fixes some -Wunused-result warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215539 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-13 11:17:41 +00:00
David Blaikie
8ebea0132d Fix -Wsign-compare warnings
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215483 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12 23:23:05 +00:00
Reid Kleckner
151f8cef74 APInt: Make self-move-assignment a no-op to fix stage3 clang-cl
It's not clear what the semantics of a self-move should be.  The
consensus appears to be that a self-move should leave the object in a
moved-from state, which is what our existing move assignment operator
does.

However, the MSVC 2013 STL will perform self-moves in some cases.  In
particular, when doing a std::stable_sort of an already sorted APSInt
vector of an appropriate size, one of the merge steps will self-move
half of the elements.

We don't notice this when building with MSVC, because MSVC will not
synthesize the move assignment operator for APSInt.  Presumably MSVC
does this because APInt, the base class, has user-declared special
members that implicitly delete move special members.  Instead, MSVC
selects the copy-assign operator, which defends against self-assignment.
Clang, on the other hand, selects the move-assign operator, and we get
garbage APInts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215478 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12 22:01:39 +00:00
Saleem Abdulrasool
f96cd1aeb5 ADT: remove MinGW32 and Cygwin OSType enum
Remove the MinGW32 and Cygwin types from the OSType enumeration.  These values
are represented via environments of Windows.  It is a source of confusion and
needlessly clutters the code.  The cost of doing this is that we must sink the
check for them into the normalization code path along with the spelling.

Addresses PR20592.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215303 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-09 23:12:20 +00:00
Rafael Espindola
93c1316b70 Fix expected windows result.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215267 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-09 00:37:05 +00:00
Rafael Espindola
d6039e045f Remove dead code. Fixes pr20544.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215243 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 21:35:52 +00:00
Rafael Espindola
82acfbfe86 Fix bug 20125 - clang-format segfaults on bad config.
The problem was in unchecked dyn_cast inside of Input::createHNodes.
Patch by Roman Kashitsyn!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215205 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-08 13:58:00 +00:00
Eric Christopher
aa5b9c0f6f Temporarily Revert "Nuke the old JIT." as it's not quite ready to
be deleted. This will be reapplied as soon as possible and before
the 3.6 branch date at any rate.

Approved by Jim Grosbach, Lang Hames, Rafael Espindola.

This reverts commits r215111, 215115, 215116, 215117, 215136.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215154 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 22:02:54 +00:00
Rafael Espindola
7b232e2bb6 fix configure+make build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215116 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 14:38:49 +00:00
Rafael Espindola
875710a2fd Nuke the old JIT.
I am sure we will be finding bits and pieces of dead code for years to
come, but this is a good start.

Thanks to Lang Hames for making MCJIT a good replacement!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215111 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-07 14:21:18 +00:00
Andrew Trick
e85047ea0a Fix SmallDenseMap assignment operator.
Self assignment would lead to buckets of garbage, causing quadratic probing to hang.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214790 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 22:18:25 +00:00
Justin Bogner
981eb59138 Path: Stop claiming path::const_iterator is bidirectional
path::const_iterator claims that it's a bidirectional iterator, but it
doesn't satisfy all of the contracts for a bidirectional iterator.
For example, n3376 24.2.5 p6 says "If a and b are both dereferenceable,
then a == b if and only if *a and *b are bound to the same object",
but this doesn't work with how we stash and recreate Components.

This means that our use of reverse_iterator on this type is invalid
and leads to many of the valgrind errors we're hitting, as explained
by Tilmann Scheller here:

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

Instead, we admit that path::const_iterator is only an input_iterator,
and implement a second input_iterator for path::reverse_iterator (by
changing const_iterator::operator-- to reverse_iterator::operator++).
All of the uses of this just traverse once over the path in one
direction or the other anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214737 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-04 17:36:41 +00:00
NAKAMURA Takumi
1b23e26921 BitcodeTests: Fix LINK_COMPONENTS.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214598 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-02 00:12:54 +00:00
Duncan P. N. Exon Smith
99a43c2c42 IR: Add Value::reverseUseList()
I'm going to use this to improve `verify-uselistorder`.  Part of PR5680.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214594 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 23:28:49 +00:00
Duncan P. N. Exon Smith
cf8b959e8d BitcodeReader: Fix some BlockAddress forward reference corner cases
`BlockAddress`es are interesting in that they can reference basic blocks
from *outside* the block's function.  Since basic blocks are not global
values, this presents particular challenges for lazy parsing.

One corner case was found in PR11677 and fixed in r147425.  In that
case, a global variable references a block address.  It's necessary to
load the relevant function to resolve the forward reference before doing
anything with the module.

By inspection, I found (and have fixed here) two other cases:

  - An instruction from one function references a block address from
    another function, and only the first function is lazily loaded.

    I fixed this the same way as PR11677: by eagerly loading the
    referenced function.

  - A function whose block address is taken is dematerialized, leaving
    invalid references to it.

    I fixed this by refusing to dematerialize functions whose block
    addresses are taken (if you have to load it, you can't unload it).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214559 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 21:11:34 +00:00
Duncan P. N. Exon Smith
fc15e8a60f Try to fix configure+make after r214556
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214558 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 21:06:59 +00:00
Duncan P. N. Exon Smith
2e9b60aea8 Rewrite BitReaderTest, NFC
Rewrite the single unit test in `BitReaderTest` so that it's easier to
add more tests.

  - Parse from an assembly string rather than using API.
  - Use more helper functions.
  - Use a separate context for the module on the other side.

Aside from relying on the assembly parser, there's no functionality
change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214556 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-01 21:01:04 +00:00
Manman Ren
807538b567 [Debug Info] add DISubroutineType and its creation takes DITypeArray.
DITypeArray is an array of DITypeRef, at its creation, we will create
DITypeRef (i.e use the identifier if the type node has an identifier).

This is the last patch to unique the type array of a subroutine type.

rdar://17628609


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214132 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 22:24:06 +00:00
Chandler Carruth
8e704b16f1 [ADT] Add a remarkbly useful little helper routine to ArrayRef for
checking whether the ArrayRef is equal to an explicit list of arguments.

This is particularly easy to implement even without variadic templates
because ArrayRef happens to be homogeneously typed. As a consequence we
can use a "clever" wrapper type and default arguments to capture in
a single method many arguments as well as *how many* arguments the user
specified.

Thanks to Dave Blaikie for helping me pull together this little helper.
Suggestions for how to improve or generalize it are of course welcome.
I'll be using it immediately in my follow-up patch. =D

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214041 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-27 01:11:19 +00:00
NAKAMURA Takumi
e0b5c10bf6 IR/UseTest.cpp: Avoid std::to_string() to appease mingw32 bot.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213994 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-26 00:45:30 +00:00
Duncan P. N. Exon Smith
cf3794498e Fix r213824 on windows
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213866 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 15:16:23 +00:00
Hal Finkel
2c7c54c86c AA metadata refactoring (introduce AAMDNodes)
In order to enable the preservation of noalias function parameter information
after inlining, and the representation of block-level __restrict__ pointer
information (etc.), additional kinds of aliasing metadata will be introduced.
This metadata needs to be carried around in AliasAnalysis::Location objects
(and MMOs at the SDAG level), and so we need to generalize the current scheme
(which is hard-coded to just one TBAA MDNode*).

This commit introduces only the necessary refactoring to allow for the
introduction of other aliasing metadata types, but does not actually introduce
any (that will come in a follow-up commit). What it does introduce is a new
AAMDNodes structure to hold all of the aliasing metadata nodes associated with
a particular memory-accessing instruction, and uses that structure instead of
the raw MDNode* in AliasAnalysis::Location, etc.

No functionality change intended.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213859 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 12:16:19 +00:00
NAKAMURA Takumi
0fe305de89 [CMake] LineEditorTests: Add Support to link_components.
Even if LLVMSupport is added in add_unittests, LLVMSupport may be here as consistency.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213854 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 11:44:33 +00:00
Duncan P. N. Exon Smith
5092384bd3 IR: Add Value::sortUseList()
Add `Value::sortUseList()`, templated on the comparison function to use.

The sort is an iterative merge sort that uses a binomial vector of
already-merged lists to limit the size overhead to `O(1)`.

This is part of PR5680.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213824 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-24 00:53:19 +00:00
Justin Bogner
8fa83afb83 unittests: Actually test reverse iterators in Path tests
This re-enables some #if 0'd code (since 2010) in the Path unittests
and makes at least a weak effort at testing sys::path's rbegin/rend.

This change was inspired by some test failures near uses of rbegin and
rend here:

    http://lab.llvm.org:8011/builders/clang-x86_64-linux-vg/builds/3209

The "valgrind was whining" comment looked promising in terms of a
simpler to debug case of the same errors. However, it appears that the
valgrind complaints the comment was referring to are distinct from the
ones in the frontend, since this updated test isn't complaining for me
under valgrind.

In any case, the disabled tests weren't helping anybody.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213125 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-16 08:18:58 +00:00
Duncan P. N. Exon Smith
c12ce2b661 ADT: Add MapVector::remove_if
Add a `MapVector::remove_if()` that erases items in bulk in linear time,
as opposed to quadratic time for repeated calls to `MapVector::erase()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213090 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 20:24:56 +00:00
Duncan P. N. Exon Smith
d9ebc5991b ADT: Fix MapVector::erase()
Actually update the changed indexes in the map portion of `MapVector`
when erasing from the middle.  Add a unit test that checks for this.

Note that `MapVector::erase()` is a linear time operation (it was and
still is).  I'll commit a new method in a moment called
`MapVector::remove_if()` that deletes multiple entries in linear time,
which should be slightly less painful.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213084 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-15 18:32:30 +00:00
Justin Bogner
f66fc53bc7 Support: Fix option handling when using cl::Required with aliasopt
Until now, attempting to create an alias of a required option would
complain if the user supplied the alias, because the required option
didn't have a value. Similarly, if you said the alias was required,
then using the base option would complain that the alias wasn't
supplied. Lastly, if you put required on both, *neither* option would
work.

By changning alias to overload addOccurrence and setting cl::Required
on the original option, we can get this to behave in a more useful
way. I've also added a test and updated a user that was getting this
wrong.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212986 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 20:53:57 +00:00
NAKAMURA Takumi
a84c1fb652 [CMake] Update libdeps.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212920 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-14 05:01:53 +00:00
Argyrios Kyrtzidis
41a6ddb277 Move the API and implementation of clang::driver::getARMCPUForMArch() to llvm::Triple::getARMCPUForArch().
Suggested by Eric Christopher.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212846 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-11 21:44:54 +00:00
Alexey Samsonov
3e51f754ad Decouple llvm::SpecialCaseList text representation and its LLVM IR semantics.
Turn llvm::SpecialCaseList into a simple class that parses text files in
a specified format and knows nothing about LLVM IR. Move this class into
LLVMSupport library. Implement two users of this class:
  * DFSanABIList in DFSan instrumentation pass.
  * SanitizerBlacklist in Clang CodeGen library.
The latter will be modified to use actual source-level information from frontend
(source file names) instead of unstable LLVM IR things (LLVM Module identifier).

Remove dependency edge from ClangCodeGen/ClangDriver to LLVMTransformUtils.

No functionality change.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212643 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-09 19:40:08 +00:00
Aaron Ballman
c789ae2345 These should be EXPECT_TRUE, not EXPECT_FALSE. Amends r212415.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212419 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 20:20:02 +00:00
Aaron Ballman
d08df5a1c5 Fixing compile errors related to changes with MemoryBuffer::getFile.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212415 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 19:34:52 +00:00
Rafael Espindola
7cba2a973f Update the MemoryBuffer API to use ErrorOr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212405 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-06 17:43:13 +00:00
David Majnemer
38dbb0292d ADT: Add a drop_back() helper to ArrayRef
The slice(N, M) interface is powerful but not concise when wanting to
drop a few elements off of an ArrayRef, fix this by adding a drop_back
method.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212370 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-05 06:12:30 +00:00
Rafael Espindola
7413fefb8b Invert the MC -> Object dependency.
Now that we have a lib/MC/MCAnalysis, the dependency was there just because
of two helper classes. Move the two over to MC.

This will allow IRObjectFile to parse inline assembly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212248 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-03 02:01:39 +00:00
Rafael Espindola
cca08872b0 Move CFG building code to a new lib/MC/MCAnalysis library.
The new library is 150KB on a Release+Asserts build, so it is quiet a bit of
code that regular users of MC don't need to link with now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212209 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-02 19:49:34 +00:00
Benjamin Kramer
58d452b75a Remove unused typedef. GCC warns about this.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@212105 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-01 15:39:32 +00:00
Aaron Ballman
fbab8b6758 Reverting r211950 -- it did not help resolve the -Wcomment warnings triggered in GCC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211953 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 19:52:34 +00:00
Aaron Ballman
704fa86de5 Adding some trailing whitespace after a comment previously ending with \ to ensure that it isn't lexed as a multiline comment. This silences some -Wcomment warnings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211950 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 19:05:17 +00:00
Chandler Carruth
39ea80cc56 Re-apply r211287: Remove support for LLVM runtime multi-threading.
I'll fix the problems in libclang and other projects in ways that don't
require <mutex> until we sort out the cygwin situation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211900 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 15:13:01 +00:00
Alp Toker
8dd8d5c2b2 Revert "Introduce a string_ostream string builder facilty"
Temporarily back out commits r211749, r211752 and r211754.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211814 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 22:52:05 +00:00
Alp Toker
2559070422 Introduce a string_ostream string builder facilty
string_ostream is a safe and efficient string builder that combines opaque
stack storage with a built-in ostream interface.

small_string_ostream<bytes> additionally permits an explicit stack storage size
other than the default 128 bytes to be provided. Beyond that, storage is
transferred to the heap.

This convenient class can be used in most places an
std::string+raw_string_ostream pair or SmallString<>+raw_svector_ostream pair
would previously have been used, in order to guarantee consistent access
without byte truncation.

The patch also converts much of LLVM to use the new facility. These changes
include several probable bug fixes for truncated output, a programming error
that's no longer possible with the new interface.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-26 00:00:48 +00:00
NAKAMURA Takumi
cdde33ebaa Revert r211287, "Remove support for LLVM runtime multi-threading."
libclang still requires it on cygming, lack of incomplete <mutex>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211592 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 13:36:31 +00:00
Duncan P. N. Exon Smith
8e52bcc591 Support: Return ScaledNumbers::MaxScale from getQuotient()
Return MaxScale now that it's available.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211559 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-24 00:26:08 +00:00
Duncan P. N. Exon Smith
558b7725b7 Support: Extract ScaledNumbers::getSum() and getDifference()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211553 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 23:15:25 +00:00
Duncan P. N. Exon Smith
465f06cfa6 Support: Return scale from ScaledNumbers::matchScales()
This will be convenient when extracting `ScaledNumbers::getSum()`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211552 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 23:14:51 +00:00
Duncan P. N. Exon Smith
0da818cdbb Support: Extract ScaledNumbers::matchScale()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211531 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 20:40:45 +00:00
David Blaikie
9dd6fee485 Recommit 211309 (StringMap::insert), reverted in 211328 due to issues with private, but non-deleted, move members.
Certain versions of GCC (~4.7) couldn't handle the SFINAE on access
control, but with "= delete" (hidden behind a macro for portability)
this issue is worked around/addressed.

Patch by Agustín Bergé

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211525 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 18:28:53 +00:00
Duncan P. N. Exon Smith
dd15ed8a83 Cleanup r211507
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211521 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 18:08:58 +00:00
Duncan P. N. Exon Smith
18a301e578 Support: Extract ScaledNumbers::compare()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211507 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-23 17:47:40 +00:00
Duncan P. N. Exon Smith
fb7b9a7522 Support: ScaledNumber: Fix inconsistent test names
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211414 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 22:36:09 +00:00
Duncan P. N. Exon Smith
6f5fa4a363 Support: Write ScaledNumbers::getLg{,Floor,Ceiling}()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211413 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 22:33:40 +00:00
Duncan P. N. Exon Smith
67291098a6 Support: Write ScaledNumber::getQuotient() and getProduct()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211409 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 21:47:47 +00:00
Duncan P. N. Exon Smith
2d3fb0a171 Support: Mark end of namespaces
This convinces clang-format to leave a newline.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211406 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 21:43:20 +00:00
Zachary Turner
91e18f7639 Revert "Replace Execution Engine's mutex with std::recursive_mutex."
This reverts commit 1f502bd9d7, due to
GCC / MinGW's lack of support for C++11 threading.

It's possible this will go back in after we come up with a
reasonable solution.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211401 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 21:07:14 +00:00
David Blaikie
20dead8d0c Fix some -Wsign-compare fallout from changing container count member functions to return unsigned instead of bool.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211393 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 19:54:13 +00:00
Duncan P. N. Exon Smith
af08b8b820 Support: Clean up getRounded() tests
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211337 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 02:31:07 +00:00
Duncan P. N. Exon Smith
5cf39383da Support: Write ScaledNumbers::getAdjusted()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211336 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 02:31:03 +00:00
Duncan P. N. Exon Smith
16e592a6fe Support: Write ScaledNumbers::getRounded()
Start extracting helper functions out of -block-freq's `UnsignedFloat`
into `Support/ScaledNumber.h` with the eventual goal of moving and
renaming the class to `ScaledNumber`.

The bike shed about names is still being painted, but I'm going with
this for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211333 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 01:30:43 +00:00
Rafael Espindola
6fda71e05e Revert "Add StringMap::insert(pair) consistent with the standard associative container concept."
This reverts commit r211309.

It looks like it broke some bots:

http://lab.llvm.org:8011/builders/clang-x86_64-ubuntu-gdb-75/builds/15563/steps/compile/logs/stdio

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211328 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-20 00:23:03 +00:00
David Blaikie
4110a7ac7a Add StringMap::insert(pair) consistent with the standard associative container concept.
Patch by Agustín Bergé.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211309 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 20:08:56 +00:00
Zachary Turner
a4d0ff9cd1 Remove support for LLVM runtime multi-threading.
After a number of previous small iterations, the functions
llvm_start_multithreaded() and llvm_stop_multithreaded() have
been reduced essentially to no-ops.  This change removes them
entirely.

Reviewed by: rnk, dblaikie

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211287 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 18:18:23 +00:00
Alp Toker
ba928e254e Remove OwningPtr.h and associated tests
llvm::OwningPtr is superseded by std::unique_ptr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211259 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 07:25:18 +00:00
Nikola Smiljanic
1260b844fd PR10140 - StringPool's PooledStringPtr has non-const operator== causing bad OR-result.
Mark conversion operator explicit and const qualify comparison operators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211244 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-19 00:26:49 +00:00
Zachary Turner
1f502bd9d7 Replace Execution Engine's mutex with std::recursive_mutex.
This change has a bit of a trickle down effect due to the fact that
there are a number of derived implementations of ExecutionEngine,
and that the mutex is not tightly encapsulated so is used by other
classes directly.

Reviewed by: rnk

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211214 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-18 20:17:35 +00:00
Dmitri Gribenko
9f27b050b0 ConvertUTF tests: remove uses of initializer lists to restore compatibility
with MSVC


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211093 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-17 09:33:24 +00:00
Zachary Turner
4072aa3649 Fix build breakage caused by change to ValueMapTest.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211083 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-17 00:38:40 +00:00
Zachary Turner
84fea7720c Expose ValueMap's mutex type as a typedef instead of a sys::Mutex.
This enables static polymorphism of the mutex type, which is
necessary in order to replace the standard mutex implementation
with a different type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211080 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-17 00:17:38 +00:00
Zachary Turner
5ea46694d0 Revert r211066, 211067, 211068, 211069, 211070.
These were committed accidentally from the wrong branch before having
a review sign-off.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211072 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-16 22:49:41 +00:00
Zachary Turner
aedb5523d2 Remove some more code out into a separate CL.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211067 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-16 22:40:17 +00:00
Dmitri Gribenko
9becc6c2af Support/ConvertUTF: implement U+FFFD insertion according to the recommendation
given in the Unicode spec

That is, replace every maximal subpart of an ill-formed subsequence with one
U+FFFD.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211015 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-16 11:09:46 +00:00
Artyom Skrobov
25e659b6ff Adding llvm::sys::swapByteOrder() for the common use-case of byte-swapping a value in place
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210976 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-14 12:52:55 +00:00
Artyom Skrobov
9bb92cb537 Renaming SwapByteOrder() to getSwappedBytes()
The next commit will add swapByteOrder(), acting in-place



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210973 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-14 11:36:01 +00:00
Rafael Espindola
d8b23109b2 Finishing touch for the std::error_code transition.
While std::error_code itself seems to work OK in all platforms, there
are few annoying differences with regards to the std::errc enumeration.

This patch adds a simple llvm enumeration, which will hopefully avoid build
breakages in other platforms and surprises as we get more uses of
std::error_code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210920 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 17:20:48 +00:00
Rafael Espindola
250305156a Remove the last uses of 'using std::error_code'
This finishes the transition to std::error_code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210877 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-13 03:20:08 +00:00
Rafael Espindola
5c792faa0e Don't use 'using std::error_code' in include/llvm.
This should make sure that most new uses use the std prefix.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210835 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 21:46:39 +00:00
Rafael Espindola
15aa07b2e8 Replace llvm::error_code with std::error_code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210783 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-12 14:11:22 +00:00
Rafael Espindola
c6d63a3b0d Remove unused has_magic.
This will allow inlining get_magic, which should in turn fix one of the mingw
build problems after the switch to std::error_code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210712 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 21:53:22 +00:00
Rafael Espindola
7acd886ecf Use std::error_code instead of llvm::error_code.
The idea of this patch is to turn llvm/Support/system_error.h into a
transitional header that just brings in the erorr_code api to the llvm
namespace. I will remove it shortly afterwards.

The cases where the general idea needed some tweaking:

* std::errc is a namespace in msvc, so we cannot use "using std::errc". I could
add an #ifdef, but there were not that many uses, so I just added std:: to
them in this patch.

* Template specialization had to be moved to the std namespace in this
patch set already.

* The msvc implementation of default_error_condition doesn't seem to
provide the same transformations as we need. Not too surprising since
the standard doesn't actually say what "equivalent" means. I fixed the
problem by keeping our old mapping and using it at error_code
construction time.

Despite these shortcomings I think this is still a good thing. Some reasons:

* The different implementations of system_error might improve over time.
* It removes 925 lines of code from llvm already.
* It removes 6313 bytes from the text segment of the clang binary when
it is built with gcc and 2816 bytes when building with clang and
libstdc++.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210687 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 19:05:50 +00:00
David Blaikie
e23e227a5c SmallVectorTest: Make the deleted member functions private to help MSVC users.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210665 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 17:50:14 +00:00
Craig Topper
27be15cd36 Convert StringMapEntry::Create to use StringRef instead of start/end pointers. Simpliies all in tree call sites. No functional change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210638 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 05:35:56 +00:00
Rafael Espindola
e5e77d1cd8 Remove windows_error.
MSVC doesn't seem to provide any is_error_code_enum enumeration for the
windows errors.

Fortunately very few places in llvm have to handle raw windows errors, so
we can just construct the corresponding error_code directly.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210631 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-11 03:58:34 +00:00
NAKAMURA Takumi
6e02efd130 SmallVectorTest.cpp: Use LLVM_DELETED_FUNCTION.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210507 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-10 04:06:56 +00:00
David Blaikie
78b4fd3a4b SmallVector: support resize(N) with move-only types
Unfortunately there's no way to elegantly do this with pre-canned
algorithms. Using a generating iterator doesn't work because you default
construct for each element, then move construct into the actual slot
(bad for copy but non-movable types, and a little unneeded overhead even
in the move-only case), so just write it out manually.

This solution isn't exception safe (if one of the element's ctors calls
we don't fall back, destroy the constructed elements, and throw on -
which std::uninitialized_fill does do) but SmallVector (and LLVM) isn't
exception safe anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210495 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-09 22:26:20 +00:00
Craig Topper
b177041dfa [C++11] Use 'nullptr'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210442 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 22:29:17 +00:00
David Blaikie
cab673f638 SmallVector: Improve test coverage for insert with repetition
To test cases that involve actual repetition (> 1 elements), at least
one element before the insertion point, and some elements of the
original range that still fit in that range space after insertion.

Actually we need coverage for the inverse case too (where no elements
after the insertion point fit into the previously allocated space), but
this'll do for now, and I might end up rewriting bits of SmallVector to
avoid that special case anyway.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210436 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 19:33:40 +00:00
David Blaikie
62dd118135 SmallVector: More movable improvements - don't copy elements to make space when inserting repeated elements.
Also split and improve tests a bit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210433 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 19:12:31 +00:00
David Blaikie
aa72ac7dad SmallVector: Move, don't copy, elements to make space for an insertion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210432 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 19:12:28 +00:00
David Blaikie
16aac741f6 SmallVectorTest: Remove some more robust checks added in r210429 since they caught some bugs I haven't fixed yet.
Specifically this caused inserting an element from a SmallVector into
itself when such an insertion would cause a reallocation. We have code
to handle this for non-reallocating cases, but it's not robust against
reallocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210430 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 17:33:47 +00:00
David Blaikie
9262e52075 Fix some more moving-from-moved-from objects issues in SmallVector
(& because it makes it easier to test, this also improves
correctness/performance slightly by moving the last element in an insert
operation, rather than copying it)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210429 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 16:55:13 +00:00
Stephen Canon
bef256f49b APFloat: x - NaN needs to flip the signbit of NaN when x is a number.
Because we don't have a separate negate( ) function, 0 - NaN does double-duty as the IEEE-754 negate( ) operation, which (unlike most FP ops) *does* attach semantic meaning to the signbit of NaN.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210428 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 16:53:31 +00:00
David Blaikie
e570687bd8 Ensure SmallVector::insert doesn't overwrite the last element in the range with the already-moved-from value
This would cause the last element in a range to be in a moved-from state
after an insert at a non-end position, losing that value entirely in the
process.

Side note: move_backward is subtle. It copies [A, B) to C-1 and down.
(the fact that it decrements both the second and third iterators before
the first movement is the subtle part... kind of surprising, anyway)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210426 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 16:00:02 +00:00
Alp Toker
11e082eb54 Fix build when no native target is enabled
The JITTests and MCJITTests unit test targets require a native arch with JIT
support, otherwise fail to link.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210411 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-08 02:45:56 +00:00
Rafael Espindola
6fd1b8ee48 Allow aliases to be unnamed_addr.
Alias with unnamed_addr were in a strange state. It is stored in GlobalValue,
the language reference talks about "unnamed_addr aliases" but the verifier
was rejecting them.

It seems natural to allow unnamed_addr in aliases:

* It is a property of how it is accessed, not of the data itself.
* It is perfectly possible to write code that depends on the address
of an alias.

This patch then makes unname_addr legal for aliases. One side effect is that
the syntax changes for a corner case: In globals, unnamed_addr is now printed
before the address space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210302 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06 01:20:28 +00:00
Rafael Espindola
08e66be96d Make this operator bool() explicit to match the standard library.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210072 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-03 04:42:24 +00:00
Rafael Espindola
2d21b25393 Allow alias to point to an arbitrary ConstantExpr.
This  patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is
up to MC (or the system assembler) to decide if that expression is valid or not.

This reduces our ability to diagnose invalid uses and how early we can spot
them, but it also lets us do things like

@test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32),
                                 i32 ptrtoint (i32* @bar to i32)) to i32*)

An important implication of this patch is that the notion of aliased global
doesn't exist any more. The alias has to encode the information needed to
access it in its metadata (linkage, visibility, type, etc).

Another consequence to notice is that getSection has to return a "const char *".
It could return a NullTerminatedStringRef if there was such a thing, but when
that was proposed the decision was to just uses "const char*" for that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210062 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-03 02:41:57 +00:00
Rafael Espindola
1bab2d5399 Use error_code() instead of error_code::succes()
There is no std::error_code::success, so this removes much of the noise
in transitioning to std::error_code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209952 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-31 01:37:45 +00:00
Peter Collingbourne
bfe17408a9 Fix the behavior of ExecuteAndWait with a non-zero timeout.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209951 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-31 01:36:02 +00:00
Craig Topper
677564fe72 Use std::unique_ptr instead of OwningPtr in the MemoryBuffer unittests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209102 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-18 21:01:46 +00:00
Rafael Espindola
c86235f4eb Use create methods since msvc doesn't handle delegating constructors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209076 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-17 21:29:57 +00:00
Rafael Espindola
fbd8cc0926 Reduce abuse of default values in the GlobalAlias constructor.
This is in preparation for adding an optional offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209073 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-17 19:57:46 +00:00
Rafael Espindola
27c076ae40 Fix most of PR10367.
This patch changes the design of GlobalAlias so that it doesn't take a
ConstantExpr anymore. It now points directly to a GlobalObject, but its type is
independent of the aliasee type.

To avoid changing all alias related tests in this patches, I kept the common
syntax

@foo = alias i32* @bar

to mean the same as now. The cases that used to use cast now use the more
general syntax

@foo = alias i16, i32* @bar.

Note that GlobalAlias now behaves a bit more like GlobalVariable. We
know that its type is always a pointer, so we omit the '*'.

For the bitcode, a nice surprise is that we were writing both identical types
already, so the format change is minimal. Auto upgrade is handled by looking
through the casts and no new fields are needed for now. New bitcode will
simply have different types for Alias and Aliasee.

One last interesting point in the patch is that replaceAllUsesWith becomes
smart enough to avoid putting a ConstantExpr in the aliasee. This seems better
than checking and updating every caller.

A followup patch will delete getAliasedGlobal now that it is redundant. Another
patch will add support for an explicit offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209007 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 19:35:39 +00:00
Rafael Espindola
ab67b30df6 Change the GlobalAlias constructor to look a bit more like GlobalVariable.
This is part of the fix for pr10367. A GlobalAlias always has a pointer type,
so just have the constructor build the type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208983 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 13:34:04 +00:00
Juergen Ributzka
9bc1b73c9e Add C API for thread yielding callback.
Sometimes a LLVM compilation may take more time then a client would like to
wait for. The problem is that it is not possible to safely suspend the LLVM
thread from the outside. When the timing is bad it might be possible that the
LLVM thread holds a global mutex and this would block any progress in any other
thread.

This commit adds a new yield callback function that can be registered with a
context. LLVM will try to yield by calling this callback function, but there is
no guaranteed frequency. LLVM will only do so if it can guarantee that
suspending the thread won't block any forward progress in other LLVM contexts
in the same process.

Once the client receives the call back it can suspend the thread safely and
resume it at another time.

Related to <rdar://problem/16728690>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208945 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 02:33:15 +00:00
Juergen Ributzka
218bad2bc5 Revert "[PM] Add pass run listeners to the pass manager."
Revert the current implementation and C API. New implementation and C APIs are
in the works.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208904 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-15 17:49:20 +00:00
Rafael Espindola
e2b37447b7 Assert that we don't RAUW a Constant with a ConstantExpr that contains it.
We already had an assert for foo->RAUW(foo), but not for something like
foo->RAUW(GEP(foo)) and would go in an infinite loop trying to apply
the replacement.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208663 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-13 01:23:21 +00:00
David Blaikie
3fb66ae739 Remove use of = default/= delete as they're unsupported on MSVC2012
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208388 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-09 02:26:36 +00:00
David Blaikie
50f8a53856 Missed formatting
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208362 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08 21:53:33 +00:00
David Blaikie
2b94fa799b StringMap: Move assignment and move construction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208361 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08 21:52:29 +00:00
David Blaikie
b0439e6d6a StringMap support for move-only values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208359 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-08 21:52:23 +00:00
Rafael Espindola
b507e6601d Replace a virtual with an override.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208242 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-07 19:52:32 +00:00
Reid Kleckner
3949749701 Copy the full TailCallKind in CallInst::clone_impl
Split from the musttail inliner change.  This will be covered by an opt
test when the inliner change lands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208126 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06 20:08:20 +00:00
Evgeniy Stepanov
0e8c40d643 Disable -Wcomment when building with GCC.
GCC version of -Wcomment is not compatible with ascii art graph diagrams.

Reverts r207629.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208073 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-06 09:46:06 +00:00
Chandler Carruth
febf86d7e3 [LCG] Add the last (and most complex) of the edge insertion mutation
operations on the call graph. This one forms a cycle, and while not as
complex as removing an internal edge from an SCC, it involves
a reasonable amount of work to find all of the nodes newly connected in
a cycle.

Also somewhat alarming is the worst case complexity here: it might have
to walk roughly the entire SCC inverse DAG to insert a single edge. This
is carefully documented in the API (I hope).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207935 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-04 09:38:32 +00:00
Chandler Carruth
57a38b856e [LCG] Reorder the tests to be a bit more logical: inter-SCC mutation
before intra-SCC mutation, insertion before removal.

No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207934 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-04 09:38:23 +00:00
Juergen Ributzka
b2bd7e89e6 [TBAA] Fix handling of mixed TBAA (path-aware and non-path-aware TBAA).
This fix simply ensures that both metadata nodes are path-aware before
performing path-aware alias analysis.

This issue isn't normally triggered in LLVM, because we perform an autoupgrade
of the TBAA metadata to the new format when reading in LL or BC files. This
issue only appears when a client creates the IR manually and mixes old and new
TBAA metadata format.

This fixes <rdar://problem/16760860>.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207923 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-03 22:32:52 +00:00
Chandler Carruth
3ce8291da3 [LCG] Add the other simple edge insertion API to the call graph. This
just connects an SCC to one of its descendants directly. Not much of an
impact. The last one is the hard one -- connecting an SCC to one of its
ancestors, and thereby forming a cycle such that we have to merge all
the SCCs participating in the cycle.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207751 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-01 12:18:20 +00:00
Chandler Carruth
b8f462501b [LCG] Add some basic methods for querying the parent/child relationships
of SCCs in the SCC DAG. Exercise them in the big graph test case. These
will be especially useful for establishing invariants in insertion
logic.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207749 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-01 12:12:42 +00:00
Hans Wennborg
a8febf2283 ELFObjectWriter: deduplicate suffices in strtab
We already do this for shstrtab, so might as well do it for strtab. This
extracts the string table building code into a separate class. The idea
is to use it for other object formats too.

I mostly wanted to do this for the general principle, but it does save a
little bit on object file size. I tried this on a clang bootstrap and
saved 0.54% on the sum of object file sizes (1.14 MB out of 212 MB for
a release build).

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207670 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 16:25:02 +00:00
Douglas Gregor
3bdb9015b1 Fix a use of uninitialized memory in SmallVector's move-assignment operator.
When we were moving from a larger vector to a smaller one but didn't
need to re-allocate, we would move-assign over uninitialized memory in
the target, then move-construct that same data again.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207663 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 15:49:06 +00:00
Chandler Carruth
491f476b8b [LCG] Add the really, *really* boring edge insertion case: adding an
edge entirely within an existing SCC. Shockingly, making the connected
component more connected is ... a total snooze fest. =]

Anyways, its wired up, and I even added a test case to make sure it
pretty much sorta works. =D

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207631 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 10:48:36 +00:00
Evgeniy Stepanov
0a78097774 Fix multiline comment warning.
../unittests/Analysis/LazyCallGraphTest.cpp:45:1: warning: multi-line comment [-Wcomment]
 //        /  \
 ^


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207629 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 10:29:06 +00:00
Chandler Carruth
6253c04fc9 [LCG] Actually test the *basic* edge removal bits (IE, the non-SCC
bits), and discover that it's totally broken. Yay tests. Boo bug. Fix
the basic edge removal so that it works by nulling out the removed edges
rather than actually removing them. This leaves the indices valid in the
map from callee to index, and preserves some of the locality for
iterating over edges. The iterator is made bidirectional to reflect that
it now has to skip over null entries, and the skipping logic is layered
onto it.

As future work, I would like to track essentially the "load factor" of
the edge list, and when it falls below a threshold do a compaction.

An alternative I considered (and continue to consider) is storing the
callees in a doubly linked list where each element of the list is in
a set (which is essentially the classical linked-hash-table
datastructure). The problem with that approach is that either you need
to heap allocate the linked list nodes and use pointers to them, or use
a bucket hash table (with even *more* linked list pointer overhead!),
etc. It's pretty easy to get 5x overhead for values that are just
pointers. So far, I think punching holes in the vector, and periodic
compaction is likely to be much more efficient overall in the space/time
tradeoff.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207619 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-30 07:45:27 +00:00
Benjamin Kramer
7259f14839 raw_ostream: Forward declare OpenFlags and include FileSystem.h only where necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207593 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 23:26:49 +00:00
Duncan P. N. Exon Smith
f38f17c463 SupportTest: Fix test names harder
r207552, r207553 and r207554 all had bad test names.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207560 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 17:07:45 +00:00
Duncan P. N. Exon Smith
31413d8f1d Support: More BlockFrequencyTest => BranchProbabilityTest
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207554 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:44:59 +00:00
Duncan P. N. Exon Smith
3dbfacec2e Support: Fix test name
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207553 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:44:56 +00:00
Duncan P. N. Exon Smith
2c252dd576 Support: BlockFrequencyTest => BranchProbabilityTest
Move a detailed test of `BranchProbability::scale()` from
`BlockFrequencyTest` over to `BranchProbabilityTest`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207552 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:40:17 +00:00
Duncan P. N. Exon Smith
07f96126af blockfreq: Defer to BranchProbability::scale() (again)
Change `BlockFrequency` to defer to `BranchProbability::scale()` and
`BranchProbability::scaleByInverse()`.

This removes `BlockFrequency::scale()` from its API (and drops the
ability to see the remainder), but the only user was the unit tests.  If
some code in the future needs an API that exposes the remainder, we can
add something to `BranchProbability`, but I find that unlikely.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207550 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:31:29 +00:00
Duncan P. N. Exon Smith
048f520b91 Support: Add BranchProbability::scale() and ::scaleByInverse()
Add API to `BranchProbability` for scaling big integers.  Next job is to
rip the logic out of `BlockMass` and `BlockFrequency`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207544 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:15:35 +00:00
Duncan P. N. Exon Smith
4afab2afa8 Support: Add unit tests for BranchProbability
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207540 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 16:12:13 +00:00
NAKAMURA Takumi
ec96ef30c9 LinkModulesTest.cpp: Reformat.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207537 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 15:52:46 +00:00
NAKAMURA Takumi
d294b68e28 [CMake] Enable llvm/unittests/LinkerTests. It had not been enabled since r199354.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207536 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 15:52:36 +00:00
NAKAMURA Takumi
13085edf46 LinkModulesTest.cpp: Use test-specific Ctx instead of getGlobalContext(). The global context might not be free'd. [vg_leak]
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207535 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 15:52:27 +00:00
Chandler Carruth
4ef6c0908b [ADT] Teach PointerUnion to support assignment directly from nullptr to
clear it out.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207471 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-29 00:14:27 +00:00
Chandler Carruth
b86c32fe38 [cleanup] Add some actual positive tests for equality. This unittest
never actually compared for equality two pointer unions that were equal.
Fortunately, things seem to work. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207468 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 23:44:14 +00:00
Chandler Carruth
e3976b241c [cleanup] Make this test use a proper fixture rather than globals.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207466 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 23:42:22 +00:00
Chandler Carruth
e753df3566 [cleanup] Fix the whitespace in this test. Notably, correct spacing
around pointer types.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207465 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 23:37:53 +00:00
Juergen Ributzka
4e0cc51d79 [PM] Add pass run listeners to the pass manager.
This commit provides the necessary C/C++ APIs and infastructure to enable fine-
grain progress report and safe suspension points after each pass in the pass
manager.

Clients can provide a callback function to the pass manager to call after each
pass. This can be used in a variety of ways (progress report, dumping of IR
between passes, safe suspension of threads, etc).

The run listener list is maintained in the LLVMContext, which allows a multi-
threaded client to be only informed for it's own thread. This of course assumes
that the client created a LLVMContext for each thread.

This fixes <rdar://problem/16728690>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207430 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 18:19:25 +00:00
Chandler Carruth
db0b52c8e0 [LCG] Add the most basic of edge insertion to the lazy call graph. This
just handles the pre-DFS case. Also add some test cases for this case to
make sure it works.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207411 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 11:10:23 +00:00
Chandler Carruth
e52aad4202 [LCG] Make the return of the IntraSCC removal method actually match its
contract (and be much more useful). It now provides exactly the
post-order traversal a caller might need to perform on newly formed
SCCs.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207410 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-28 10:49:06 +00:00
Chandler Carruth
e3a8e534e1 [LCG] Re-organize the methods for mutating a call graph to make their
API requirements much more obvious.

The key here is that there are two totally different use cases for
mutating the graph. Prior to doing any SCC formation, it is very easy to
mutate the graph. There may be users that want to do small tweaks here,
and then use the already-built graph for their SCC-based operations.
This method remains on the graph itself and is documented carefully as
being cheap but unavailable once SCCs are formed.

Once SCCs are formed, and there is some in-flight DFS building them, we
have to be much more careful in how we mutate the graph. These mutation
operations are sunk onto the SCCs themselves, which both simplifies
things (the code was already there!) and helps make it obvious that
these interfaces are only applicable within that context. The other
primary constraint is that the edge being mutated is actually related to
the SCC on which we call the method. This helps make it obvious that you
cannot arbitrarily mutate some other SCC.

I've tried to write much more complete documentation for the interesting
mutation API -- intra-SCC edge removal. Currently one aspect of this
documentation is a lie (the result list of SCCs) but we also don't even
have tests for that API. =[ I'm going to add tests and fix it to match
the documentation next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207339 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-27 01:59:50 +00:00
David Blaikie
12d5224df6 DIE: Pass ownership of children via std::unique_ptr rather than raw pointer.
This should reduce the chance of memory leaks like those fixed in
r207240.

There's still some unclear ownership of DIEs happening in DwarfDebug.
Pushing unique_ptr and references through more APIs should help expose
the cases where ownership is a bit fuzzy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207263 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 20:00:34 +00:00
David Blaikie
172515f0be DIEEntry: Refer to the specified DIE via reference rather than pointer.
Makes some more cases (the unit tests, specifically), lexically
compatible with a change to unique_ptr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207261 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 19:33:43 +00:00
Duncan P. N. Exon Smith
db8c1ae04e SCC: Change clients to use const, NFC
It's fishy to be changing the `std::vector<>` owned by the iterator, and
no one actual does it, so I'm going to remove the ability in a
subsequent commit.  First, update the users.

<rdar://problem/14292693>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207252 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 18:24:50 +00:00
David Blaikie
5d71d87bff PR19554: Fix some memory leaks in DIEHashTest.cpp
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207240 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-25 17:07:55 +00:00
Chandler Carruth
01f21349f2 [ADT] Generalize pointee_iterator to smart pointers by using decltype.
Based on review feedback from Dave on the original patch.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207146 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-24 21:10:35 +00:00
Chandler Carruth
9e9ec34760 [LCG] Re-order expectations to provide more useful output when debugging
an issue. This way you see that the number of nodes was wrong before
a crash due to accessing too many nodes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207094 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-24 09:59:56 +00:00
Chandler Carruth
63ed439ab5 [LCG] Switch the SCC's parent iterators to be value iterators rather
than pointer iterators.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207086 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-24 07:48:18 +00:00
Chandler Carruth
beee61d3e6 [ADT] Add a generic iterator utility for adapting iterators much like
Boost's iterator_adaptor, and a specific adaptor which iterates over
pointees when wrapped around an iterator over pointers.

This is the result of a long discussion on IRC with Duncan Smith, Dave
Blaikie, Richard Smith, and myself. Essentially, I could use some subset
of the iterator facade facilities often used from Boost, and everyone
seemed interested in having the functionality in a reasonably generic
form. I've tried to strike a balance between the pragmatism and the
established Boost design. The primary differences are:

1) Delegating to the standard iterator interface names rather than
   special names that then make up a second iterator-like API.
2) Using the name 'pointee_iterator' which seems more clear than
   'indirect_iterator'. The whole business of calling the '*p' operation
   'pointer indirection' in the standard is ... quite confusing. And
   'dereference' is no better of a term for moving from a pointer to
   a reference.

Hoping Duncan, and others continue to provide comments on this until
we've got a nice, minimal abstraction.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207069 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-24 03:31:23 +00:00
Chandler Carruth
9f2150c046 [LCG] Normalize the post-order SCC iterator to just iterate over the SCC
values rather than having pointers in weird places.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207053 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 23:51:07 +00:00
Chandler Carruth
306d5ba092 [LCG] Switch the primary node iterator to be a *much* more normal C++
iterator, returning a Node by reference on dereference.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207048 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 23:34:48 +00:00
Chandler Carruth
31d2477c68 [LCG] Switch the SCC lookup to be in terms of call graph nodes rather
than functions. So far, this access pattern is *much* more common. It
seems likely that any user of this interface is going to have nodes at
the point that they are querying the SCCs.

No functionality changed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207045 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 23:12:06 +00:00
Chandler Carruth
e42618b4bc [LCG] Add the first round of mutation support to the lazy call graph.
This implements the core functionality necessary to remove an edge from
the call graph and correctly update both the basic graph and the SCC
structure. As part of that it has to run a tiny (in number of nodes)
Tarjan-style DFS walk of an SCC being mutated to compute newly formed
SCCs, etc.

This is *very rough* and a WIP. I have a bunch of FIXMEs for code
cleanup that will reduce the boilerplate in this change substantially.
I also have a bunch of simplifications to various parts of both
algorithms that I want to make, but first I'd like to have a more
holistic picture. Ideally, I'd also like more testing. I'll probably add
quite a few more unit tests as I go here to cover the various different
aspects and corner cases of removing edges from the graph.

Still, this is, so far, successfully updating the SCC graph in-place
without disrupting the identity established for the existing SCCs even
when we do challenging things like delete the critical edge that made an
SCC cycle at all and have to reform things as a tree of smaller SCCs.
Getting this to work is really critical for the new pass manager as it
is going to associate significant state with the SCC instance and needs
it to be stable. That is also the motivation behind the return of the
newly formed SCCs. Eventually, I'll wire this all the way up to the
public API so that the pass manager can use it to correctly re-enqueue
newly formed SCCs into a fresh postorder traversal.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206968 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 11:03:03 +00:00
Chandler Carruth
b9619110af [LCG] Implement Tarjan's algorithm correctly this time. We have to walk
up the stack finishing the exploration of each entries children before
we're finished in addition to accounting for their low-links. Added
a unittest that really hammers home the need for this with interlocking
cycles that would each appear distinct otherwise and crash or compute
the wrong result. As part of this, nuke a stale fixme and bring the rest
of the implementation still more closely in line with the original
algorithm.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206966 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 10:31:17 +00:00
Chandler Carruth
07c2241e45 [LCG] Add a unittest for the LazyCallGraph. I had a weak moment and
resisted this for too long. Just with the basic testing here I was able
to exercise the analysis in more detail and sift out both type signature
bugs in the API and a bug in the DFS numbering. All of these are fixed
here as well.

The unittests will be much more important for the mutation support where
it is necessary to craft minimal mutations and then inspect the state of
the graph. There is just no way to do that with a standard FileCheck
test. However, unittesting these kinds of analyses is really quite easy,
especially as they're designed with the new pass manager where there is
essentially no infrastructure required to rig up the core logic and
exercise it at an API level.

As a minor aside about the DFS numbering bug, the DFS numbering used in
LCG is a bit unusual. Rather than numbering from 0, we number from 1,
and use 0 as the sentinel "unvisited" state. Other implementations often
use '-1' for this, but I find it easier to deal with 0 and it shouldn't
make any real difference provided someone doesn't write silly bugs like
forgetting to actually initialize the DFS numbering. Oops. ;]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206954 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-23 08:08:49 +00:00
Quentin Colombet
43285b394e This reverts r206828 until David has time to figure out that is going on.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206839 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 02:17:11 +00:00
David Blaikie
6d73b8016e Use unique_ptr to handle ownership of Value*s in Cloning unit tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206828 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-21 23:47:47 +00:00
Chandler Carruth
c95ce87c23 Make the User::value_op_iterator a random access iterator. I had written
this code ages ago and lost track of it. Seems worth doing though --
this thing can get called from places that would benefit from knowing
that std::distance is O(1). Also add a very fledgeling unittest for
Users and make sure various aspects of this seem to work reasonably.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206453 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-17 09:07:50 +00:00
Chandler Carruth
d66a3fe106 [Allocator] Make BumpPtrAllocator movable and move assignable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206372 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-16 10:48:27 +00:00
Duncan P. N. Exon Smith
32791b02fa verify-di: Implement DebugInfoVerifier
Implement DebugInfoVerifier, which steals verification relying on
DebugInfoFinder from Verifier.

  - Adds LegacyDebugInfoVerifierPassPass, a ModulePass which wraps
    DebugInfoVerifier.  Uses -verify-di command-line flag.

  - Change verifyModule() to invoke DebugInfoVerifier as well as
    Verifier.

  - Add a call to createDebugInfoVerifierPass() wherever there was a
    call to createVerifierPass().

This implementation as a module pass should sidestep efficiency issues,
allowing us to turn debug info verification back on.

<rdar://problem/15500563>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206300 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15 16:27:38 +00:00
Chandler Carruth
b9a99d4593 [Allocator] Finally, finish nuking the redundant code that led me here
by removing the MallocSlabAllocator entirely and just using
MallocAllocator directly. This makes all off these allocators expose and
utilize the same core interface.

The only ugly part of this is that it exposes the fact that the JIT
allocator has no real handling of alignment, any more than the malloc
allocator does. =/ It would be nice to fix both of these to support
alignments, and then to leverage that in the BumpPtrAllocator to do less
over allocation in order to manually align pointers. But, that's another
patch for another day. This patch has no functional impact, it just
removes the somewhat meaningless wrapper around MallocAllocator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206267 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-15 09:44:09 +00:00
Chandler Carruth
17f9c2e35b [Allocator] Make the underlying allocator a template instead of an
abstract interface. The only user of this functionality is the JIT
memory manager and it is quite happy to have a custom type here. This
removes a virtual function call and a lot of unnecessary abstraction
from the common case where this is just a *very* thin vaneer around
a call to malloc.

Hopefully still no functionality changed here. =]

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206149 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14 05:11:27 +00:00
Chandler Carruth
cb7ead25c2 [Allocator] Switch the BumpPtrAllocator to use a vector of pointers to
slabs rather than embedding a singly linked list in the slabs
themselves. This has a few advantages:

- Better utilization of the slab's memory by not wasting 16-bytes at the
  front.
- Simpler allocation strategy by not having a struct packed at the
  front.
- Avoids paging every allocated slab in just to traverse them for
  deallocating or dumping stats.

The latter is the really nice part. Folks have complained from time to
time bitterly that tearing down a BumpPtrAllocator, even if it doesn't
run any destructors, pages in all of the memory allocated. Now it won't.
=]

Also resolves a FIXME with the scaling of the slab sizes. The scaling
now disregards specially sized slabs for allocations larger than the
threshold.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206147 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-14 03:55:11 +00:00
Benjamin Kramer
15c435a367 Retire llvm::array_endof in favor of non-member std::end.
While there make array_lengthof constexpr if we have support for it.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206112 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-12 16:15:53 +00:00
Benjamin Kramer
479151ab7f Move MDBuilder's methods out of line.
Making them inline was a historical accident, they're neither hot nor
templated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206109 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-12 14:26:59 +00:00