Commit Graph

4157 Commits

Author SHA1 Message Date
Eli Friedman
c66330504c Refactor code from inlining and globalopt that checks whether a function definition is unused, and enhance it so it can tell that functions which are only used by a blockaddress are in fact dead. This probably doesn't happen much on most code, but the Linux kernel's _THIS_IP_ can trigger this issue with blockaddress. (GlobalDCE can also handle the given tescase, but we only run that at -O3.) Found while looking at PR11180.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142572 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-20 05:23:42 +00:00
Benjamin Kramer
d2c6ff1ac6 Use a SmallVector for intrinsic argument types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142259 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 21:33:26 +00:00
Bill Wendling
3c5e60994f Correct over-zealous removal of hack.
Some code want to check that *any* call within a function has the 'returns
twice' attribute, not just that the current function has one.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142221 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 18:43:40 +00:00
Bill Wendling
728662f9e8 Now that we have the ReturnsTwice function attribute, this method is
obsolete. Check the attribute instead.
<rdar://problem/8031714>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142212 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 18:22:52 +00:00
Chandler Carruth
602650c988 Add a routine to swap branch instruction operands, and update any
profile metadata at the same time. Use it to preserve metadata attached
to a branch when re-writing it in InstCombine.

Add metadata to the canonicalize_branch InstCombine test, and check that
it is tranformed correctly.

Reviewed by Nick Lewycky!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142168 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-17 01:11:57 +00:00
Benjamin Kramer
962bad70f4 Let printf do the formatting instead aligning strings ourselves.
While at it, merge some format strings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142140 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16 16:30:34 +00:00
Chris Lattner
3f2d5f60b3 Make SMDiagnostic a little more sane. Instead of passing around note/warning/error as a
string, pass it around as an enum.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142107 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-16 05:43:57 +00:00
Chris Lattner
aeee2d3a29 constify array itself, don't iterate multiple times.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142013 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 22:50:21 +00:00
Torok Edwin
6563c87996 ocaml bindings: add getopcode for constant and instruction, and int64_of_const.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141990 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:37:49 +00:00
Torok Edwin
31116410de bindings: tab and indentation fixes of my previous commits
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141989 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-14 20:37:42 +00:00
Eric Christopher
0f691977d7 Spacing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141727 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-11 22:58:58 +00:00
Matt Beaumont-Gay
7761948761 Move default to top of switch
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141366 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-07 16:27:01 +00:00
Eli Friedman
8540101252 Remove the old atomic instrinsics. autoupgrade functionality is included with this patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141333 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 23:20:49 +00:00
Matt Beaumont-Gay
3ef12348d7 Fix -asserts build
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141313 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 20:59:09 +00:00
Torok Edwin
4df1557f40 Don't require C bindings opcode numbers to be kept in sync.
They are not in sync now, for example Bitcast would show up as LLVMCall.
So instead introduce 2 functions that map to and from the opcodes in the C
bindings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141290 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:39:34 +00:00
Torok Edwin
ff12c99d13 ocaml/C bindings: type->isSized()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141288 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:28 +00:00
Torok Edwin
4917ec9ec7 add binding to read icmp predicate
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141287 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:20 +00:00
Torok Edwin
4f661ab0fb ocaml/C bindings: getmdstring, add num_op, get_op should work on metadata too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141286 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:13:11 +00:00
Torok Edwin
c44943ed4f C/OCaml API to retrieve struct name.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141285 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 12:12:50 +00:00
Peter Collingbourne
de8f33c199 Build system infrastructure for multiple tblgens.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141266 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-06 01:51:51 +00:00
Rafael Espindola
11f1a8335e Check for the returns_twice attribute in callsFunctionThatReturnsTwice. This
fixes PR11038, but there are still some cleanups to be done.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141204 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-05 20:05:13 +00:00
Ted Kremenek
a589b1fa2b Unbreak CMake build.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141097 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 18:22:24 +00:00
Devang Patel
58c620024a Put GCOVFile and other related interface in a common header so that llvm-cov tool can share it with GCOV writer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141095 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-04 17:24:48 +00:00
Devang Patel
0e6a24d92a Add C api for Instruction->eraseFromParent().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141023 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-03 20:59:18 +00:00
Rafael Espindola
25456ef74c Add the returns_twice attribute to LLVM.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141001 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-03 14:45:37 +00:00
Andrew Trick
62e0590c0e Tracing or debug-printing a newly formed instruction should not crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140874 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-30 19:50:40 +00:00
Andrew Trick
18801ecd48 whitespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140873 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-30 19:48:58 +00:00
Eli Friedman
bb5a7442e3 Clean up uses of switch instructions so they are not dependent on the operand ordering. Patch by Stepan Dyatkovskiy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140803 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 20:21:17 +00:00
Devang Patel
7a50202be5 Cosmetic changes, as per Nick's review.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140785 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-29 16:46:47 +00:00
Duncan Sands
040bff0bc2 Check that catch clauses have pointer type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140625 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 19:34:22 +00:00
Duncan Sands
00418ea91c Have the verifier check that all landingpad operands are constants.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140606 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-27 16:43:19 +00:00
Bill Wendling
cccfd194ec The last verification check for the new EH model.
This makes sure that the unwind destination of an invoke is a landing pad.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140280 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-21 22:57:02 +00:00
Richard Trieu
23946fcaae Change:
assert(!"error message");

To:

  assert(0 && "error message");

which is more consistant across the code base.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140234 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-21 03:09:09 +00:00
Devang Patel
c67d184a2b Add a check to make sure schedulePass() has not deleted stale RequiredPass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139642 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-13 21:13:29 +00:00
Duncan Sands
28b77e968d Add codegen support for vector select (in the IR this means a select
with a vector condition); such selects become VSELECT codegen nodes.
This patch also removes VSETCC codegen nodes, unifying them with SETCC
nodes (codegen was actually often using SETCC for vector SETCC already).
This ensures that various DAG combiner optimizations kick in for vector
comparisons.  Passes dragonegg bootstrap with no testsuite regressions
(nightly testsuite as well as "make check-all").  Patch mostly by
Nadav Rotem.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139159 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 19:07:46 +00:00
Duncan Sands
4a544a79bd Split the init.trampoline intrinsic, which currently combines GCC's
init.trampoline and adjust.trampoline intrinsics, into two intrinsics
like in GCC.  While having one combined intrinsic is tempting, it is
not natural because typically the trampoline initialization needs to
be done in one function, and the result of adjust trampoline is needed
in a different (nested) function.  To get around this llvm-gcc hacks the
nested function lowering code to insert an additional parent variable
holding the adjust.trampoline result that can be accessed from the child
function.  Dragonegg doesn't have the luxury of tweaking GCC code, so it
stored the result of adjust.trampoline in the memory GCC set aside for
the trampoline itself (this is always available in the child function),
and set up some new memory (using an alloca) to hold the trampoline.
Unfortunately this breaks Go which allocates trampoline memory on the
heap and wants to use it even after the parent has exited (!).  Rather
than doing even more hacks to get Go working, it seemed best to just use
two intrinsics like in GCC.  Patch mostly by Sanjoy Das.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139140 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-06 13:37:06 +00:00
Bill Wendling
66d1836380 The insertion point for the loads is right before the llvm.eh.exception
call. The call may be in the same BB as the landingpad instruction. If that's
the case, then inserting the loads after the landingpad inst, but before the
extractvalues, causes undefined behavior.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139088 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-04 09:02:18 +00:00
Bill Wendling
17fe6c48ff Don't reload the values that are already there. The llvm.eh.resume uses the same
values that the resume instruction uses.
PR10850


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139076 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-03 01:38:17 +00:00
Bill Wendling
271439053d No need to get fancy inserting a PHI node when the values are stored in stack
slots. This fixes a bug where the number of nodes coming into the PHI node may
not equal the number of predecessors. E.g., two or more landingpad instructions
may require a PHI before reaching the eh.exception and eh.selector instructions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139035 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 21:17:08 +00:00
Jakub Staszak
8370d91f1e Return undef value (instead of arbitrary) for wrong or undef index in
ConstantVector.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139007 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 17:01:40 +00:00
Jakub Staszak
4c6b8bee2a ConstantVector returns arbitrary value for the wrong index.
This fixes PR10813.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139006 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 15:43:43 +00:00
Bill Wendling
24fbb5875c Perform the upgrading of the old EH to the new EH in a more sane manner.
Perform the upgrading in steps.

* First, create a map of the invokes to the EH intrinsics.

* Next, take that mapping and determine if the invoke's unwind destination has a
  single predecessor. If not, then create a new empty block to hold the new
  landingpad instruction.

* Create a landingpad instruction into the uwnind destination. Fill it with the
  values from the old selector. Map the old intrinsic calls to the new
  landingpad values (there may be multiple landingpad instructions per instrinic
  call pairs).

* Go through the old intrinsic calls, create a PHI node when necessary, and then
  replace their values with the new values from the landingpad instructions.

* Delete all dead instructions.

* ???

* Profit!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138990 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-02 01:30:08 +00:00
Eli Friedman
81b4e434d9 Make isSafeToSpeculativelyExecute() return the right answer for some new instructions. Found by inspection; not sure what practical impact, if any, this has.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138962 91177308-0d34-0410-b5e6-96231b3b80d8
2011-09-01 21:03:03 +00:00
Nadav Rotem
89879ec76b Fixes following the CR by Chris and Duncan:
Optimize chained bitcasts of the form A->B->A.
Undo r138722 and change isEliminableCastPair to allow this case.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138756 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29 19:58:36 +00:00
Benjamin Kramer
3dedf7e2c8 Dump with dbgs() instead of printf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138749 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29 18:14:17 +00:00
Benjamin Kramer
4a3d0a56eb Make GCC happy by adding parens.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138748 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29 18:14:15 +00:00
Andrew Trick
0e122d1c24 Reapply r138695. Fix PassManager stack depths.
Patch by Xiaoyi Guo!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138737 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-29 17:07:00 +00:00
Andrew Trick
8592a0cda4 Reverting r138695 to see if it fixes clang self host.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138701 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-27 06:10:16 +00:00
Bill Wendling
884fb72f15 Only delete instructions once.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138700 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-27 06:10:02 +00:00
Andrew Trick
b846192230 Fix PassManager stack depths.
Patch by Xiaoyi Guo!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138695 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-27 02:11:03 +00:00
Bill Wendling
c82a61c6c6 Initial check in that will auto-upgrade the old EH scheme to the new EH scheme.
This upgrade suffers from the problems of the old EH scheme - i.e., that the
calls to llvm.eh.exception() and llvm.eh.selector() can wander off and get
lost. It makes a valiant effort to reclaim these little lost lambs.

This is a first draft, so it hasn't yet been hooked up to the parser.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138602 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-25 23:22:40 +00:00
Nadav Rotem
4c7c0f2353 Implement Constant::isAllOnesValue(). Fix ConstantFolding to use the new api.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138469 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-24 20:18:38 +00:00
Nate Begeman
7ced7763ca Add some useful accessors to c++ api that appear to be missing from the c api
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138371 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 20:27:46 +00:00
Eric Christopher
acc8f2d938 Revert "Address Duncan's CR request:"
This reverts commit 20a05be15e. (svn rev 138340)

Conflicts:

	test/Transforms/InstCombine/bitcast.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138366 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 20:11:10 +00:00
Nadav Rotem
20a05be15e Address Duncan's CR request:
1. Cleanup the tests in ConstantFolding.cpp
2. Implement isAllOnes for Constant, ConstantFP, ConstantVector





git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138340 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-23 17:48:43 +00:00
Chris Lattner
489fee1b64 Rip out the old StructType APIs as warned about on llvmdev last week.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137953 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 17:39:28 +00:00
Bill Wendling
c9b2a987a2 Revert r137655. There is some question about whether the 'landingpad'
instruction should be marked as potentially reading and/or writing memory.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137863 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-17 20:36:44 +00:00
Bill Wendling
55fdb4eec0 The resume instruction may throw. Return 'true' in this case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137757 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 21:15:50 +00:00
Bill Wendling
d2e103daf8 Add getFirstInsertionPt() method.
getFirstInsertionPt() returns an iterator to the first insertion point in a
basic block. This is after all PHIs and any other instruction which is required
to be at the top of the basic block (like LandingPadInst).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137744 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-16 20:42:52 +00:00
Bill Wendling
9d6070f161 Duncan pointed out that the LandingPadInst might read memory. (It might also
write to memory.) Marking it as such makes some checks for immobility go away.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137655 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 21:14:31 +00:00
Eli Friedman
e5e771263a Fix predicates methods on Instruction to handle atomic load/store correctly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137652 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-15 21:00:18 +00:00
Nick Lewycky
53b2b73643 Remove the last improper use of getGlobalContext() from LLVM.
This caused a race condition where a thread calls ~LLVMContextImpl which calls
Module::dropAllReferences which calls begin() on an empty ilist that would
create the sentinel, which racily accesses the global context.

This can not be fixed by locking inside createSentinel because the lock would
need to be shared with all users of the global context, including those that
reside outside LLVM's own code.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137546 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-13 01:04:44 +00:00
Eli Friedman
f03bb260c9 Move "atomic" and "volatile" designations on instructions after the opcode
of the instruction.

Note that this change affects the existing non-atomic load and store
instructions; the parser now accepts both forms, and the change is noted
in the release notes.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137527 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 22:50:01 +00:00
Bill Wendling
e6e8826870 Initial commit of the 'landingpad' instruction.
This implements the 'landingpad' instruction. It's used to indicate that a basic
block is a landing pad. There are several restrictions on its use (see
LangRef.html for more detail). These restrictions allow the exception handling
code to gather the information it needs in a much more sane way.

This patch has the definition, implementation, C interface, parsing, and bitcode
support in it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137501 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 20:24:12 +00:00
Chris Lattner
d95f8f6ada add ifdef's to let people easily remove these dead api for testing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137483 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 18:08:19 +00:00
Chris Lattner
c4d0e9fbdd switch to the new struct apis.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137481 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 18:07:07 +00:00
Chris Lattner
8dcfc74af4 forward to the correct constructor.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137479 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 18:03:30 +00:00
Chris Lattner
f4bbcaabeb add two missing function impls
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137470 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 17:43:05 +00:00
Chris Lattner
2c38d65fd9 add new accessors to reflect new terminology in struct types.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137468 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-12 17:31:02 +00:00
Eli Friedman
1cc5e38830 Whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137226 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-10 17:39:11 +00:00
NAKAMURA Takumi
77c714027c VMCore/BasicBlock.cpp: Don't assume BasicBlock::iterator might end with a non-PHInode Instruction in successors.
Frontends(eg. clang) might pass incomplete form of IR, to step off the way beyond iterator end. In the case I had met, it took infinite loop due to meeting bogus PHInode.

Thanks to Jay Foad and John McCall.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137175 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 23:13:05 +00:00
NAKAMURA Takumi
8fc9b3db53 Fix whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137174 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 23:12:56 +00:00
Eli Friedman
21006d40ac Representation of 'atomic load' and 'atomic store' in IR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137170 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-09 23:02:53 +00:00
Bill Wendling
7df4f963ea Indicate that there are changes if runOfFunction returns saying that there are.
Patch by Jingyue!


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137072 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 23:01:10 +00:00
Bill Wendling
63012206c9 Remove unnecessary space.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137041 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-08 08:02:48 +00:00
Chris Lattner
f4ef8db7cd strengthen up an assertion: you can't create a constant struct
with an opaque struct type, it doesn't make sense.  This should
resolve PR10473.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137028 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-07 04:18:48 +00:00
Chris Lattner
fb5179a2fa fix PR10286, a problem with the .ll printer handling block addresses that are out-of-scope.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136768 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-03 06:15:41 +00:00
Bill Wendling
1600525385 Remove the LLVMBuildUnwind C API function.
The 'unwind' function is going away with the new EH rewrite. This is step 0 in
keeping front-ends from using it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136683 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-02 06:20:17 +00:00
Jay Foad
5cd8ea2fd3 Add braces.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136612 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 12:48:54 +00:00
Jay Foad
8d948652f2 Simplify printAlias.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136611 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 12:29:14 +00:00
Jay Foad
4255274cf8 Micro-optimisation in getAliasedGlobal.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136610 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-01 12:28:01 +00:00
Bill Wendling
dccc03b242 Add the 'resume' instruction for the new EH rewrite.
This adds the 'resume' instruction class, IR parsing, and bitcode reading and
writing. The 'resume' instruction resumes propagation of an existing (in-flight)
exception whose unwinding was interrupted with a 'landingpad' instruction (to be
added later).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136589 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-31 06:30:59 +00:00
Bill Wendling
10c6d12a9f Revert r136253, r136263, r136269, r136313, r136325, r136326, r136329, r136338,
r136339, r136341, r136369, r136387, r136392, r136396, r136429, r136430, r136444,
r136445, r136446, r136253 pending review.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136556 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-30 05:42:50 +00:00
Chris Lattner
4cea5bae82 have the verifier catch gep's into opaque struct types. PR10473
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136510 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 20:32:28 +00:00
Eli Friedman
55ba816883 Misc optimizer+codegen work for 'cmpxchg' and 'atomicrmw'. They appear to be
working on x86 (at least for trivial testcases); other architectures will
need more work so that they actually emit the appropriate instructions for
orderings stricter than 'monotonic'. (As far as I can tell, the ARM, PPC,
Mips, and Alpha backends need such changes.)



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136457 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 03:05:32 +00:00
Chandler Carruth
ac03e736c7 Rewrite the CMake build to use explicit dependencies between libraries,
specified in the same file that the library itself is created. This is
more idiomatic for CMake builds, and also allows us to correctly specify
dependencies that are missed due to bugs in the GenLibDeps perl script,
or change from compiler to compiler. On Linux, this returns CMake to
a place where it can relably rebuild several targets of LLVM.

I have tried not to change the dependencies from the ones in the current
auto-generated file. The only places I've really diverged are in places
where I was seeing link failures, and added a dependency. The goal of
this patch is not to start changing the dependencies, merely to move
them into the correct location, and an explicit form that we can control
and change when necessary.

This also removes a serialization point in the build because we don't
have to scan all the libraries before we begin building various tools.
We no longer have a step of the build that regenerates a file inside the
source tree. A few other associated cleanups fall out of this.

This isn't really finished yet though. After talking to dgregor he urged
switching to a single CMake macro to construct libraries with both
sources and dependencies in the arguments. Migrating from the two macros
to that style will be a follow-up patch.

Also, llvm-config is still generated with GenLibDeps.pl, which means it
still has slightly buggy dependencies. The internal CMake
'llvm-config-like' macro uses the correct explicitly specified
dependencies however. A future patch will switch llvm-config generation
(when using CMake) to be based on these deps as well.

This may well break Windows. I'm getting a machine set up now to dig
into any failures there. If anyone can chime in with problems they see
or ideas of how to solve them for Windows, much appreciated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136433 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-29 00:14:25 +00:00
Eli Friedman
ff03048c13 LangRef and basic memory-representation/reading/writing for 'cmpxchg' and
'atomicrmw' instructions, which allow representing all the current atomic
rmw intrinsics.

The allowed operands for these instructions are heavily restricted at the
moment; we can probably loosen it a bit, but supporting general
first-class types (where it makes sense) might get a bit complicated,
given how SelectionDAG works.

As an initial cut, these operations do not support specifying an alignment,
but it would be possible to add if we think it's useful. Specifying an
alignment lower than the natural alignment would be essentially
impossible to support on anything other than x86, but specifying a greater
alignment would be possible.  I can't think of any useful optimizations which
would use that information, but maybe someone else has ideas.

Optimizer/codegen support coming soon.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136404 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 21:48:00 +00:00
Bill Wendling
7379b66500 The personality function should be a Function* and not just a Value*.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136392 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 21:14:13 +00:00
Bill Wendling
7196184610 Don't add in the asked for size so that we don't copy too much from the old to new vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136338 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 07:26:41 +00:00
Bill Wendling
28d735230f Make sure that the landingpad instruction takes a Constant* as the clause's value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136326 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 02:27:12 +00:00
Bill Wendling
7f66c45f35 Add a couple of convenience functions:
* InvokeInst: Get the landingpad instruction associated with this invoke.
* LandingPadInst: A method to reserve extra space for clauses.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136325 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-28 02:15:52 +00:00
Bill Wendling
772fe17a6d Merge the contents from exception-handling-rewrite to the mainline.
This adds the new instructions 'landingpad' and 'resume'.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136253 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 20:18:04 +00:00
Eli Friedman
8a552bb85a Misc mid-level changes for new 'fence' instruction.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136205 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-27 01:08:30 +00:00
Eli Friedman
47f3513dd5 Initial implementation of 'fence' instruction, the new C++0x-style replacement for llvm.memory.barrier.
This is just a LangRef entry and reading/writing/memory representation; optimizer+codegen support coming soon.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136009 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 23:16:38 +00:00
Jay Foad
166579e287 Use ArrayRef in the (protected) constructors of ConstantArray, ConstantStruct and ConstantVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135905 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 10:14:44 +00:00
Jay Foad
a9203109f4 Convert GetElementPtrInst to use ArrayRef.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135904 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-25 09:48:08 +00:00
Jay Foad
0a2a60ace9 Convert IRBuilder::CreateGEP and IRBuilder::CreateInBoundsGEP to use
ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135761 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-22 08:16:57 +00:00
Jay Foad
4b5e207bf2 Make better use of ConstantExpr::getGetElementPtr's InBounds parameter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135676 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 15:15:37 +00:00
Jay Foad
dab3d29605 Convert ConstantExpr::getGetElementPtr and
ConstantExpr::getInBoundsGetElementPtr to use ArrayRef.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135673 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 14:31:17 +00:00
Chris Lattner
c30a38f34b move tier out of an anonymous namespace, it doesn't make sense
to for it to be an an anon namespace and be in a header.

Eliminate some extraenous uses of tie.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135669 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-21 06:21:31 +00:00