Files
clamav/libclamav/c++/llvm/lib/CodeGen/MachineBasicBlock.cpp
Török Edvin de5bf27b3c Merge LLVM upstream r91428.
Squashed commit of the following:

commit 08c733e79dd6b65be6eab3060b47fe4d231098b9
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 09:05:13 2009 +0000

    add some other xforms that should be done as part of PR5783

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91428 91177308-0d34-0410-b5e6-96231b3b80d8

commit 39a7fa146ef728a10fce157d2efcecd806bf276b
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 08:34:01 2009 +0000

    a few improvements:
    1. Use std::equal instead of reinventing it.
    2. don't run dtors in destroy_range if element is pod-like.
    3. Use isPodLike to decide between memcpy/uninitialized_copy
       instead of is_class.  isPodLike is more generous in some cases.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91427 91177308-0d34-0410-b5e6-96231b3b80d8

commit 3a95c15ce022ba6cdeea981f9b7b0a7d4724e11a
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 08:29:22 2009 +0000

    hoist the begin/end/capacity members and a few trivial methods
    up into the non-templated SmallVectorBase class.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91426 91177308-0d34-0410-b5e6-96231b3b80d8

commit 142f4f4c9d8ab4a1d1eb5c2fde61a6383fed25c4
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 07:40:44 2009 +0000

    improve isPodLike to know that all non-class types are pod.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91425 91177308-0d34-0410-b5e6-96231b3b80d8

commit bc6f37b22aeb8f1ec5c7eb650ecbdea67f34a3de
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 07:27:58 2009 +0000

    Lang verified that SlotIndex is "pod like" even though it isn't a pod.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91423 91177308-0d34-0410-b5e6-96231b3b80d8

commit 169f3a233e90dcdd01e42829b396c823d016fe30
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 07:26:43 2009 +0000

    Remove isPod() from DenseMapInfo, splitting it out to its own
    isPodLike type trait.  This is a generally useful type trait for
    more than just DenseMap, and we really care about whether something
    acts like a pod, not whether it really is a pod.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91421 91177308-0d34-0410-b5e6-96231b3b80d8

commit e1d483dade6f1675d9c2279fb9ae503858b89844
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Tue Dec 15 07:21:14 2009 +0000

    Convert llvmc tests to FileCheck.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91420 91177308-0d34-0410-b5e6-96231b3b80d8

commit d016c18182f165c7a967f1c5a6a343971bcd2465
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Tue Dec 15 07:20:50 2009 +0000

    Support hook invocation from 'append_cmd'.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91419 91177308-0d34-0410-b5e6-96231b3b80d8

commit 4136d8daf27d7f04dea28a578b39e5a614fca81e
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 06:49:02 2009 +0000

    Fix an encoding bug.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91417 91177308-0d34-0410-b5e6-96231b3b80d8

commit 54fec492a4c81ee84265ad953f4212eda9aff5c1
Author: Chris Lattner <sabre@nondot.org>
Date:   Tue Dec 15 06:14:33 2009 +0000

    add an ALWAYS_INLINE macro, which does the obvious thing.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91416 91177308-0d34-0410-b5e6-96231b3b80d8

commit 428c804a753234ecaf6a6177107361a1312508f8
Author: Kenneth Uildriks <kennethuil@gmail.com>
Date:   Tue Dec 15 03:27:52 2009 +0000

    For fastcc on x86, let ECX be used as a return register after EAX and EDX

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91410 91177308-0d34-0410-b5e6-96231b3b80d8

commit 90468b7e484723a7ecfe7b4bf7a3264d2c6c6d06
Author: John McCall <rjmccall@apple.com>
Date:   Tue Dec 15 03:10:26 2009 +0000

    Names from dependent base classes are not found by unqualified lookup.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91407 91177308-0d34-0410-b5e6-96231b3b80d8

commit 87c0a2dffc5590dc2604754dbe12c9430a54b27b
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 03:07:11 2009 +0000

    Disable 91381 for now. It's miscompiling ARMISelDAG2DAG.cpp.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91405 91177308-0d34-0410-b5e6-96231b3b80d8

commit 5ca004428400555d08d43eebe7e91c7035793afb
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Tue Dec 15 03:04:52 2009 +0000

    Validate the generated C++ code in llvmc tests.

    Checks that the code generated by 'tblgen --emit-llvmc' can be actually
    compiled. Also fixes two bugs found in this way:

    - forward_transformed_value didn't work with non-list arguments
    - cl::ZeroOrOne is now called cl::Optional

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91404 91177308-0d34-0410-b5e6-96231b3b80d8

commit 0e4f60395f69857730808200642874b0ecd44896
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Tue Dec 15 03:04:14 2009 +0000

    Pipe 'grep' output to 'count'.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91403 91177308-0d34-0410-b5e6-96231b3b80d8

commit bc4f5408a6a0881c31e2a3165d022d74a6b2b9e5
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Tue Dec 15 03:04:02 2009 +0000

    Allow $CALL(Hook, '$INFILE') for non-join tools.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91402 91177308-0d34-0410-b5e6-96231b3b80d8

commit ff7c2e17fda5f570afff5eaf75f88460019d3f74
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Tue Dec 15 03:03:37 2009 +0000

    Small documentation update.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91401 91177308-0d34-0410-b5e6-96231b3b80d8

commit d629d80a80bfd6094563000bc82ed37b42acfffa
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 03:00:32 2009 +0000

    Make 91378 more conservative.
    1. Only perform (zext (shl (zext x), y)) -> (shl (zext x), y) when y is a constant. This makes sure it remove at least one zest.
    2. If the shift is a left shift, make sure the original shift cannot shift out bits.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91399 91177308-0d34-0410-b5e6-96231b3b80d8

commit 7caa1423082e873b0685e8d1fb4f7351bdabb103
Author: John McCall <rjmccall@apple.com>
Date:   Tue Dec 15 02:35:24 2009 +0000

    You can't use typedefs to declare template member specializations, and
    clang enforces it.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91397 91177308-0d34-0410-b5e6-96231b3b80d8

commit e8aa0b417ca5d0fc33b6079aa11b81cf86667956
Author: Bill Wendling <isanbard@gmail.com>
Date:   Tue Dec 15 01:54:51 2009 +0000

    Initial work on disabling the scheduler. This is a work in progress, and this
    stuff isn't used just yet.

    We want to model the GCC `-fno-schedule-insns' and `-fno-schedule-insns2'
    flags. The hypothesis is that the people who use these flags know what they are
    doing, and have hand-optimized the C code to reduce latencies and other
    conflicts.

    The idea behind our scheme to turn off scheduling is to create a map "on the
    side" during DAG generation. It will order the nodes by how they appeared in the
    code. This map is then used during scheduling to get the ordering.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91392 91177308-0d34-0410-b5e6-96231b3b80d8

commit 3f0f8885c7079d20930ca0336bb879adde51aaaf
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 01:44:10 2009 +0000

    Tail duplication should zap a copy it inserted for SSA update if the copy is the only use of its source.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91390 91177308-0d34-0410-b5e6-96231b3b80d8

commit 834ae6b04f4c3650b92182662aa8bb5b0fcf419f
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 00:53:42 2009 +0000

    Use sbb x, x to materialize carry bit in a GPR. The result is all one's or all zero's.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91381 91177308-0d34-0410-b5e6-96231b3b80d8

commit 5b6187226b44f590ce7f614b128480b9c2d823ef
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 00:52:11 2009 +0000

    Fold (zext (and x, cst)) -> (and (zext x), cst).

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91380 91177308-0d34-0410-b5e6-96231b3b80d8

commit d08dad66572d86df1826c3547cb824b43ae8e8be
Author: Daniel Dunbar <daniel@zuster.org>
Date:   Tue Dec 15 00:41:47 2009 +0000

    NNT: Make sure stderr for build commands goes to log file, as intended but misdirected.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91379 91177308-0d34-0410-b5e6-96231b3b80d8

commit 3ff63ae679cf08e69db6770e7965e4f3d04637b9
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Tue Dec 15 00:41:36 2009 +0000

    Propagate zest through logical shift.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91378 91177308-0d34-0410-b5e6-96231b3b80d8

commit 9f669d99f66d2ca120c85c4c379f2571d6dd947a
Author: Eric Christopher <echristo@apple.com>
Date:   Tue Dec 15 00:40:55 2009 +0000

    Formatting.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91377 91177308-0d34-0410-b5e6-96231b3b80d8

commit 87426f8cd21507e13f0256a6727a0c27f60705c3
Author: Bill Wendling <isanbard@gmail.com>
Date:   Tue Dec 15 00:39:24 2009 +0000

    Revert these. They may have been causing 483_xalancbmk to fail:

    $ svn merge -c -91161 https://llvm.org/svn/llvm-project/llvm/trunk
    --- Reverse-merging r91161 into '.':
    U    lib/CodeGen/BranchFolding.cpp
    U    lib/CodeGen/MachineBasicBlock.cpp
    $ svn merge -c -91113 https://llvm.org/svn/llvm-project/llvm/trunk
    --- Reverse-merging r91113 into '.':
    G    lib/CodeGen/MachineBasicBlock.cpp
    $ svn merge -c -91101 https://llvm.org/svn/llvm-project/llvm/trunk
    --- Reverse-merging r91101 into '.':
    U    include/llvm/CodeGen/MachineBasicBlock.h
    G    lib/CodeGen/MachineBasicBlock.cpp
    $ svn merge -c -91092 https://llvm.org/svn/llvm-project/llvm/trunk
    --- Reverse-merging r91092 into '.':
    G    include/llvm/CodeGen/MachineBasicBlock.h
    G    lib/CodeGen/MachineBasicBlock.cpp

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91376 91177308-0d34-0410-b5e6-96231b3b80d8

commit e6e14f2cfc4e8bd346bf3fa7a5ac87b6ebf422ff
Author: Jim Grosbach <grosbach@apple.com>
Date:   Tue Dec 15 00:12:35 2009 +0000

    nand atomic requires opposite operand ordering

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91371 91177308-0d34-0410-b5e6-96231b3b80d8

commit c6cfdd3f717bfa1b43351c354e39c066dbd167cd
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 23:40:38 2009 +0000

    Fix integer cast code to handle vector types.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91362 91177308-0d34-0410-b5e6-96231b3b80d8

commit 8b0d8db13172ed290285f0832e021b4ce3ef9aea
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 23:36:03 2009 +0000

    Move Flag and isVoid after the vector types, since bit arithmetic with
    those enum values is less common.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91361 91177308-0d34-0410-b5e6-96231b3b80d8

commit 81c5562ec2e59741258fc67824bbb64b91ece71e
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 23:34:36 2009 +0000

    Fix these asserts to check the invariant that the code actually
    depends on.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91360 91177308-0d34-0410-b5e6-96231b3b80d8

commit 612ae24984fcce968041a2f3f379505d8e007a83
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 23:13:31 2009 +0000

    Update this comment.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91356 91177308-0d34-0410-b5e6-96231b3b80d8

commit a34782d2b71b5fd6b3b32fa4943de1fc89d47115
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 23:08:09 2009 +0000

    Fix this to properly clear the FastISel debug location. Thanks to
    Bill for spotting this!

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91355 91177308-0d34-0410-b5e6-96231b3b80d8

commit becf334c8d194b1f6c21db915ba3c22c451ab42a
Author: Bob Wilson <bob.wilson@apple.com>
Date:   Mon Dec 14 22:44:22 2009 +0000

    Rearrange rules to add missing dependency and allow parallel makes.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91352 91177308-0d34-0410-b5e6-96231b3b80d8

commit 6fdbe657ebacf9e1bdb1e2cebfe82a9549d86d3e
Author: Johnny Chen <johnny.chen@apple.com>
Date:   Mon Dec 14 21:51:34 2009 +0000

    Add encoding bits "let Inst{11-4} = 0b00000000;" to BR_JTr to disambiguate
    between BR_JTr and STREXD.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91339 91177308-0d34-0410-b5e6-96231b3b80d8

commit 32b48e95922e730032f188c313cdd2e50c63cbc9
Author: Bill Wendling <isanbard@gmail.com>
Date:   Mon Dec 14 21:49:44 2009 +0000

    The CIE says that the LSDA point in the FDE section is an "sdata4". That's fine,
    but we need it to actually be 4-bytes in the FDE.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91337 91177308-0d34-0410-b5e6-96231b3b80d8

commit ba16e07fc539e23bb604defb021187e64c04702a
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 21:33:32 2009 +0000

    v6 sync insn copy/paste error

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91333 91177308-0d34-0410-b5e6-96231b3b80d8

commit 6eee903ab286e1a0093c5091bb30fc35e00cd86b
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 21:24:16 2009 +0000

    Add ARMv6 memory and sync barrier instructions

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91329 91177308-0d34-0410-b5e6-96231b3b80d8

commit 8ac1d378d72ad45806ab86d316bd50ca5e7f861c
Author: Johnny Chen <johnny.chen@apple.com>
Date:   Mon Dec 14 21:01:46 2009 +0000

    Fixed encoding bits typo of ldrexd/strexd.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91327 91177308-0d34-0410-b5e6-96231b3b80d8

commit 5b595cd6311d7b9670268b69096b55dd1a384d35
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 20:14:59 2009 +0000

    Thumb2 atomic operations

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91321 91177308-0d34-0410-b5e6-96231b3b80d8

commit 95218a2eb2163a644a1ff5d419ef0b581a60eb39
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 19:55:22 2009 +0000

    Add svn:ignore entries for the Disassembler files.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91320 91177308-0d34-0410-b5e6-96231b3b80d8

commit b6e3c7b1e4283ee072c8115244515c145ef6d072
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 19:43:09 2009 +0000

    Move several function bodies which are rarely inlined out of line.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91319 91177308-0d34-0410-b5e6-96231b3b80d8

commit a850594e8be4f3a3cb7c4d404b8434dfb3844ec8
Author: Chris Lattner <sabre@nondot.org>
Date:   Mon Dec 14 19:34:32 2009 +0000

    fix an obvious bug found by clang++ and collapse a redundant if.

    Here's the diagnostic from clang:

    /Volumes/Data/dgregor/Projects/llvm/lib/Target/CppBackend/CPPBackend.cpp:989:23: warning: 'gv' is always NULL in this context
            printConstant(gv);
                          ^
    1 diagnostic generated.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91318 91177308-0d34-0410-b5e6-96231b3b80d8

commit 5dbe26aa8326068823cb9481972426dca151c3cc
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 19:32:31 2009 +0000

    Micro-optimize these functions in the case where they are not inlined.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91316 91177308-0d34-0410-b5e6-96231b3b80d8

commit 2d6e24935ebc8902bd9b22f73ba02fa31d60f8bb
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 19:24:11 2009 +0000

    correct selection requirements for thumb2 vs. arm versions of the barrier intrinsics

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91313 91177308-0d34-0410-b5e6-96231b3b80d8

commit 4fc99a1a87b457f994c5e8e0d12206b9b2e02bb4
Author: Eric Christopher <echristo@apple.com>
Date:   Mon Dec 14 19:07:25 2009 +0000

    Add radar fixed in comment.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91312 91177308-0d34-0410-b5e6-96231b3b80d8

commit efbc1f057fd24bd540ab94dfcac298d6762aa3bd
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 18:56:47 2009 +0000

    add Thumb2 atomic and memory barrier instruction definitions

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91310 91177308-0d34-0410-b5e6-96231b3b80d8

commit 31b2740914c8fec8580a8dc1000e3b5295309dfb
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 18:36:32 2009 +0000

    whitespace

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91307 91177308-0d34-0410-b5e6-96231b3b80d8

commit 63437d96828f86ca3833c58964c4a5d4b142aa07
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 18:31:20 2009 +0000

    ARM memory barrier instructions are not predicable

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91305 91177308-0d34-0410-b5e6-96231b3b80d8

commit 49da09d50ecde9dcaacb4bc57807b9fe0fd31005
Author: Daniel Dunbar <daniel@zuster.org>
Date:   Mon Dec 14 17:58:33 2009 +0000

    NNT: Use [e]grep -a when scanning logs, its possibly they will have non-text
    characters in them, in which case the grep will just return 'Binary file
    matches' and the whole thing falls over.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91302 91177308-0d34-0410-b5e6-96231b3b80d8

commit 2cef3baf8abe8446367182510bb5410247c99a8e
Author: Daniel Dunbar <daniel@zuster.org>
Date:   Mon Dec 14 17:58:27 2009 +0000

    NNT: Always create the -sentdata.txt file.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91301 91177308-0d34-0410-b5e6-96231b3b80d8

commit 5d6c29ba56ae19b4d81f8a8f7abf04aa356403fb
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:35:17 2009 +0000

    Clear the Processed set when it is no longer used, and clear the
    IVUses list in releaseMemory().

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91296 91177308-0d34-0410-b5e6-96231b3b80d8

commit 6f4122b67d3bd31a6d3544f319527949f2d1cf4e
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:31:01 2009 +0000

    Fix a thinko; isNotAlreadyContainedIn had a built-in negative, so the
    condition was inverted when the code was converted to contains().

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91295 91177308-0d34-0410-b5e6-96231b3b80d8

commit b937cf58556a1fea130dae4d42e49489b308edc5
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:19:06 2009 +0000

    Remove unnecessary #includes.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91293 91177308-0d34-0410-b5e6-96231b3b80d8

commit 34b9035f2aa2e072afa2da175e47a86de9c723ce
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:14:32 2009 +0000

    Make the IVUses member private.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91291 91177308-0d34-0410-b5e6-96231b3b80d8

commit 8c5b238c82b464d9993971757204b347a18ed86e
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:12:51 2009 +0000

    Instead of having a ScalarEvolution pointer member in BasedUser, just pass
    the ScalarEvolution pointer into the functions which need it.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91289 91177308-0d34-0410-b5e6-96231b3b80d8

commit e48b5a49457a7976192930b8503e889383e7c0e7
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:10:44 2009 +0000

    Don't bother cleaning up if there's nothing to clean up.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91288 91177308-0d34-0410-b5e6-96231b3b80d8

commit a7366d992d0c8f3d840085a41c04be370a3cfe95
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:08:09 2009 +0000

    Delete an unused variable.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91287 91177308-0d34-0410-b5e6-96231b3b80d8

commit f1e30e458078b78f37abe8ca738d50df8b3cfae8
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:06:50 2009 +0000

    Drop Loop::isNotAlreadyContainedIn in favor of Loop::contains. The
    former was just exposing a LoopInfoBase implementation detail.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91286 91177308-0d34-0410-b5e6-96231b3b80d8

commit c83030d61279ac68b9532896fea512ae408387de
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 17:02:55 2009 +0000

    add ldrexd/strexd instructions

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91284 91177308-0d34-0410-b5e6-96231b3b80d8

commit d1d6f3708a558575396f8c066b9d9575889f8642
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 17:02:34 2009 +0000

    LSR itself doesn't need LoopInfo.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91283 91177308-0d34-0410-b5e6-96231b3b80d8

commit 01c63bf35c8b7ff7775bc83a02a39fc2efcfe3f8
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 16:57:08 2009 +0000

    LSR itself doesn't need DominatorTree.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91282 91177308-0d34-0410-b5e6-96231b3b80d8

commit 7ad7ae23378a83d55d836338cf33935a4a6829b9
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 16:52:55 2009 +0000

    Remove the code in LSR that manually hoists expansions out of loops;
    SCEVExpander does this automatically.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91281 91177308-0d34-0410-b5e6-96231b3b80d8

commit c476702d130b84050a146b9e8a602709bbdc3e2e
Author: Dan Gohman <gohman@apple.com>
Date:   Mon Dec 14 16:37:29 2009 +0000

    Minor code cleanups.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91280 91177308-0d34-0410-b5e6-96231b3b80d8

commit 814a12c5353afed59395f62dc082aca10b93c3dd
Author: Devang Patel <dpatel@apple.com>
Date:   Mon Dec 14 16:18:45 2009 +0000

    Use DW_AT_specification to point to DIE describing function declaration.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91278 91177308-0d34-0410-b5e6-96231b3b80d8

commit 99e265ce64bf952da29d01da65438a96984819fe
Author: Shantonu Sen <ssen@apple.com>
Date:   Mon Dec 14 14:15:15 2009 +0000

    Remove empty file completely

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91277 91177308-0d34-0410-b5e6-96231b3b80d8

commit c8da34e01191c9d3819aa1b52fdbc6fe1d544095
Author: Edwin Török <edwintorok@gmail.com>
Date:   Mon Dec 14 12:38:18 2009 +0000

    Add "generic" fallback.

    gcc warned that the function may not have a return value, indeed
    for non-intel and non-amd X86 CPUs it is right (VIA, etc.).

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91276 91177308-0d34-0410-b5e6-96231b3b80d8

commit 76d8399d2044c4af7ef6b723f2905e4ad6cbbbf3
Author: Lang Hames <lhames@gmail.com>
Date:   Mon Dec 14 07:43:25 2009 +0000

    Added CalcSpillWeights to CMakeLists.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91275 91177308-0d34-0410-b5e6-96231b3b80d8

commit 8233240e96cc3df533f37641d17df9ae2d15af12
Author: Bill Wendling <isanbard@gmail.com>
Date:   Mon Dec 14 06:51:19 2009 +0000

    Whitespace changes, comment clarification. No functional changes.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91274 91177308-0d34-0410-b5e6-96231b3b80d8

commit 4f49e0f7a619ff4a98eae831896636e8fa9051a4
Author: Lang Hames <lhames@gmail.com>
Date:   Mon Dec 14 06:49:42 2009 +0000

    Moved spill weight calculation out of SimpleRegisterCoalescing and into its own pass: CalculateSpillWeights.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91273 91177308-0d34-0410-b5e6-96231b3b80d8

commit edf3f1eff2ea650086482a564fe3a649801a17fe
Author: Chris Lattner <sabre@nondot.org>
Date:   Mon Dec 14 05:11:02 2009 +0000

    revert r91184, because it causes a crash on a .bc file I just
    sent to Bob.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91268 91177308-0d34-0410-b5e6-96231b3b80d8

commit c7e4ddcbcad547e5513dfd7eefe8c1ae97e84485
Author: Jim Grosbach <grosbach@apple.com>
Date:   Mon Dec 14 04:22:04 2009 +0000

    atomic binary operations up to 32-bits wide.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91260 91177308-0d34-0410-b5e6-96231b3b80d8

commit 15874c1fc1d911bfe2ff73e4a66d500d2c07e6f6
Author: Mikhail Glushenkov <foldr@codedgers.com>
Date:   Mon Dec 14 04:06:38 2009 +0000

    Add a test for the 'init' option property.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91259 91177308-0d34-0410-b5e6-96231b3b80d8

commit 7fe6f87162f412660039e41bc96d1ac96d107176
Author: Jeffrey Yasskin <jyasskin@google.com>
Date:   Sun Dec 13 20:30:32 2009 +0000

    Reinstate r91208 to fix available_externally linkage for globals, with
    nlewycky's fix to add -rdynamic so the JIT can look symbols up in Linux builds
    of the JITTests binary.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91250 91177308-0d34-0410-b5e6-96231b3b80d8

commit eae8d0465c69874badfcb83312d374d1ba668962
Author: Edwin Török <edwintorok@gmail.com>
Date:   Sun Dec 13 08:59:40 2009 +0000

    Using _MSC_VER there was wrong, better just use the already existing ifdefs for
    x86 CPU detection for the X86 getHostCPUName too, and create a simple
    getHostCPUName that returns "generic" for all else.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91240 91177308-0d34-0410-b5e6-96231b3b80d8

commit 87a4e6c0cb18756f3d55ec0f1b5cb86c4c88e068
Author: Chandler Carruth <chandlerc@gmail.com>
Date:   Sun Dec 13 07:04:45 2009 +0000

    Don't leave pointers uninitialized in the default constructor. GCC complains
    about the potential use of these uninitialized members under certain conditions.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91239 91177308-0d34-0410-b5e6-96231b3b80d8

commit 7c29ae320a827facfbcc32b91d6d98c6b06e44ea
Author: Anton Korobeynikov <asl@math.spbu.ru>
Date:   Sun Dec 13 01:00:59 2009 +0000

    Fix weird typo which leads to unallocated memory access for nodes with 4 results.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91233 91177308-0d34-0410-b5e6-96231b3b80d8

commit efb9350360fe13284f9162fec884d16590da206a
Author: Anton Korobeynikov <asl@math.spbu.ru>
Date:   Sun Dec 13 01:00:32 2009 +0000

    Do not allow uninitialize access during debug printing

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91232 91177308-0d34-0410-b5e6-96231b3b80d8

commit 993eb83df375e2fa7d3fb2c1519690402c27b460
Author: Eli Friedman <eli.friedman@gmail.com>
Date:   Sat Dec 12 23:23:43 2009 +0000

    More info on this transformation.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91230 91177308-0d34-0410-b5e6-96231b3b80d8

commit a3a131a8c63dc9768694c87d74109afefb021cfb
Author: Eli Friedman <eli.friedman@gmail.com>
Date:   Sat Dec 12 21:41:48 2009 +0000

    Remove some stuff that's already implemented.  Also, remove the note about
    merging x >u 5 and x <s 20 because it's impossible to implement.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91228 91177308-0d34-0410-b5e6-96231b3b80d8

commit ee30369f778aaece9f0f70dc482331c6ed8cb326
Author: Daniel Dunbar <daniel@zuster.org>
Date:   Sat Dec 12 21:17:54 2009 +0000

    Update install-clang target for clang-cc removal.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91226 91177308-0d34-0410-b5e6-96231b3b80d8

commit 8597901e12c0caa1cf841472e12df422c1d2c02b
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Sat Dec 12 20:03:14 2009 +0000

    Disable r91104 for x86. It causes partial register stall which pessimize code in 32-bit.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91223 91177308-0d34-0410-b5e6-96231b3b80d8

commit 36d987ea7542f0face7c2a3e98cfa4d8f31ab5e9
Author: Anton Korobeynikov <asl@math.spbu.ru>
Date:   Sat Dec 12 18:55:37 2009 +0000

    Implement variable-width shifts.
    No testcase yet - it seems we're exposing generic codegen bugs.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91221 91177308-0d34-0410-b5e6-96231b3b80d8

commit 9357ab4ddb97c2a6606ba0ee9f859b9c93b364b7
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Sat Dec 12 18:55:26 2009 +0000

    Add comment about potential partial register stall.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91220 91177308-0d34-0410-b5e6-96231b3b80d8

commit ca348204499380bc590165f8467f8dccdc3f414a
Author: Evan Cheng <evan.cheng@apple.com>
Date:   Sat Dec 12 18:51:56 2009 +0000

    Fix an obvious bug. No test case since LEA16r is not being used.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91219 91177308-0d34-0410-b5e6-96231b3b80d8

commit d50b1dd026feed23280c98d75ec3465627424725
Author: Edwin Török <edwintorok@gmail.com>
Date:   Sat Dec 12 12:42:31 2009 +0000

    Enable CPU detection when using MS VS 2k8 too.
    MSVS2k8 doesn't define __i386__, hence all the CPU detection code was disabled.
    Enable it by looking for _MSC_VER.

    git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@91217 91177308-0d34-0410-b5e6-96231b3b80d8
2009-12-15 14:28:14 +02:00

514 lines
17 KiB
C++

//===-- llvm/CodeGen/MachineBasicBlock.cpp ----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Collect the sequence of machine instructions for a basic block.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/BasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetInstrDesc.h"
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/LeakDetector.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Assembly/Writer.h"
#include <algorithm>
using namespace llvm;
MachineBasicBlock::MachineBasicBlock(MachineFunction &mf, const BasicBlock *bb)
: BB(bb), Number(-1), xParent(&mf), Alignment(0), IsLandingPad(false),
AddressTaken(false) {
Insts.Parent = this;
}
MachineBasicBlock::~MachineBasicBlock() {
LeakDetector::removeGarbageObject(this);
}
raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineBasicBlock &MBB) {
MBB.print(OS);
return OS;
}
/// addNodeToList (MBB) - When an MBB is added to an MF, we need to update the
/// parent pointer of the MBB, the MBB numbering, and any instructions in the
/// MBB to be on the right operand list for registers.
///
/// MBBs start out as #-1. When a MBB is added to a MachineFunction, it
/// gets the next available unique MBB number. If it is removed from a
/// MachineFunction, it goes back to being #-1.
void ilist_traits<MachineBasicBlock>::addNodeToList(MachineBasicBlock *N) {
MachineFunction &MF = *N->getParent();
N->Number = MF.addToMBBNumbering(N);
// Make sure the instructions have their operands in the reginfo lists.
MachineRegisterInfo &RegInfo = MF.getRegInfo();
for (MachineBasicBlock::iterator I = N->begin(), E = N->end(); I != E; ++I)
I->AddRegOperandsToUseLists(RegInfo);
LeakDetector::removeGarbageObject(N);
}
void ilist_traits<MachineBasicBlock>::removeNodeFromList(MachineBasicBlock *N) {
N->getParent()->removeFromMBBNumbering(N->Number);
N->Number = -1;
LeakDetector::addGarbageObject(N);
}
/// addNodeToList (MI) - When we add an instruction to a basic block
/// list, we update its parent pointer and add its operands from reg use/def
/// lists if appropriate.
void ilist_traits<MachineInstr>::addNodeToList(MachineInstr *N) {
assert(N->getParent() == 0 && "machine instruction already in a basic block");
N->setParent(Parent);
// Add the instruction's register operands to their corresponding
// use/def lists.
MachineFunction *MF = Parent->getParent();
N->AddRegOperandsToUseLists(MF->getRegInfo());
LeakDetector::removeGarbageObject(N);
}
/// removeNodeFromList (MI) - When we remove an instruction from a basic block
/// list, we update its parent pointer and remove its operands from reg use/def
/// lists if appropriate.
void ilist_traits<MachineInstr>::removeNodeFromList(MachineInstr *N) {
assert(N->getParent() != 0 && "machine instruction not in a basic block");
// Remove from the use/def lists.
N->RemoveRegOperandsFromUseLists();
N->setParent(0);
LeakDetector::addGarbageObject(N);
}
/// transferNodesFromList (MI) - When moving a range of instructions from one
/// MBB list to another, we need to update the parent pointers and the use/def
/// lists.
void ilist_traits<MachineInstr>::
transferNodesFromList(ilist_traits<MachineInstr> &fromList,
MachineBasicBlock::iterator first,
MachineBasicBlock::iterator last) {
assert(Parent->getParent() == fromList.Parent->getParent() &&
"MachineInstr parent mismatch!");
// Splice within the same MBB -> no change.
if (Parent == fromList.Parent) return;
// If splicing between two blocks within the same function, just update the
// parent pointers.
for (; first != last; ++first)
first->setParent(Parent);
}
void ilist_traits<MachineInstr>::deleteNode(MachineInstr* MI) {
assert(!MI->getParent() && "MI is still in a block!");
Parent->getParent()->DeleteMachineInstr(MI);
}
MachineBasicBlock::iterator MachineBasicBlock::getFirstTerminator() {
iterator I = end();
while (I != begin() && (--I)->getDesc().isTerminator())
; /*noop */
if (I != end() && !I->getDesc().isTerminator()) ++I;
return I;
}
/// isOnlyReachableViaFallthough - Return true if this basic block has
/// exactly one predecessor and the control transfer mechanism between
/// the predecessor and this block is a fall-through.
bool MachineBasicBlock::isOnlyReachableByFallthrough() const {
// If this is a landing pad, it isn't a fall through. If it has no preds,
// then nothing falls through to it.
if (isLandingPad() || pred_empty())
return false;
// If there isn't exactly one predecessor, it can't be a fall through.
const_pred_iterator PI = pred_begin(), PI2 = PI;
++PI2;
if (PI2 != pred_end())
return false;
// The predecessor has to be immediately before this block.
const MachineBasicBlock *Pred = *PI;
if (!Pred->isLayoutSuccessor(this))
return false;
// If the block is completely empty, then it definitely does fall through.
if (Pred->empty())
return true;
// Otherwise, check the last instruction.
const MachineInstr &LastInst = Pred->back();
return !LastInst.getDesc().isBarrier();
}
void MachineBasicBlock::dump() const {
print(errs());
}
static inline void OutputReg(raw_ostream &os, unsigned RegNo,
const TargetRegisterInfo *TRI = 0) {
if (RegNo != 0 && TargetRegisterInfo::isPhysicalRegister(RegNo)) {
if (TRI)
os << " %" << TRI->get(RegNo).Name;
else
os << " %physreg" << RegNo;
} else
os << " %reg" << RegNo;
}
StringRef MachineBasicBlock::getName() const {
if (const BasicBlock *LBB = getBasicBlock())
return LBB->getName();
else
return "(null)";
}
void MachineBasicBlock::print(raw_ostream &OS) const {
const MachineFunction *MF = getParent();
if (!MF) {
OS << "Can't print out MachineBasicBlock because parent MachineFunction"
<< " is null\n";
return;
}
if (Alignment) { OS << "Alignment " << Alignment << "\n"; }
OS << "BB#" << getNumber() << ": ";
const char *Comma = "";
if (const BasicBlock *LBB = getBasicBlock()) {
OS << Comma << "derived from LLVM BB ";
WriteAsOperand(OS, LBB, /*PrintType=*/false);
Comma = ", ";
}
if (isLandingPad()) { OS << Comma << "EH LANDING PAD"; Comma = ", "; }
if (hasAddressTaken()) { OS << Comma << "ADDRESS TAKEN"; Comma = ", "; }
OS << '\n';
const TargetRegisterInfo *TRI = MF->getTarget().getRegisterInfo();
if (!livein_empty()) {
OS << " Live Ins:";
for (const_livein_iterator I = livein_begin(),E = livein_end(); I != E; ++I)
OutputReg(OS, *I, TRI);
OS << '\n';
}
// Print the preds of this block according to the CFG.
if (!pred_empty()) {
OS << " Predecessors according to CFG:";
for (const_pred_iterator PI = pred_begin(), E = pred_end(); PI != E; ++PI)
OS << " BB#" << (*PI)->getNumber();
OS << '\n';
}
for (const_iterator I = begin(); I != end(); ++I) {
OS << '\t';
I->print(OS, &getParent()->getTarget());
}
// Print the successors of this block according to the CFG.
if (!succ_empty()) {
OS << " Successors according to CFG:";
for (const_succ_iterator SI = succ_begin(), E = succ_end(); SI != E; ++SI)
OS << " BB#" << (*SI)->getNumber();
OS << '\n';
}
}
void MachineBasicBlock::removeLiveIn(unsigned Reg) {
livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
assert(I != livein_end() && "Not a live in!");
LiveIns.erase(I);
}
bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
const_livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
return I != livein_end();
}
void MachineBasicBlock::moveBefore(MachineBasicBlock *NewAfter) {
getParent()->splice(NewAfter, this);
}
void MachineBasicBlock::moveAfter(MachineBasicBlock *NewBefore) {
MachineFunction::iterator BBI = NewBefore;
getParent()->splice(++BBI, this);
}
void MachineBasicBlock::updateTerminator() {
const TargetInstrInfo *TII = getParent()->getTarget().getInstrInfo();
// A block with no successors has no concerns with fall-through edges.
if (this->succ_empty()) return;
MachineBasicBlock *TBB = 0, *FBB = 0;
SmallVector<MachineOperand, 4> Cond;
bool B = TII->AnalyzeBranch(*this, TBB, FBB, Cond);
(void) B;
assert(!B && "UpdateTerminators requires analyzable predecessors!");
if (Cond.empty()) {
if (TBB) {
// The block has an unconditional branch. If its successor is now
// its layout successor, delete the branch.
if (isLayoutSuccessor(TBB))
TII->RemoveBranch(*this);
} else {
// The block has an unconditional fallthrough. If its successor is not
// its layout successor, insert a branch.
TBB = *succ_begin();
if (!isLayoutSuccessor(TBB))
TII->InsertBranch(*this, TBB, 0, Cond);
}
} else {
if (FBB) {
// The block has a non-fallthrough conditional branch. If one of its
// successors is its layout successor, rewrite it to a fallthrough
// conditional branch.
if (isLayoutSuccessor(TBB)) {
if (TII->ReverseBranchCondition(Cond))
return;
TII->RemoveBranch(*this);
TII->InsertBranch(*this, FBB, 0, Cond);
} else if (isLayoutSuccessor(FBB)) {
TII->RemoveBranch(*this);
TII->InsertBranch(*this, TBB, 0, Cond);
}
} else {
// The block has a fallthrough conditional branch.
MachineBasicBlock *MBBA = *succ_begin();
MachineBasicBlock *MBBB = *llvm::next(succ_begin());
if (MBBA == TBB) std::swap(MBBB, MBBA);
if (isLayoutSuccessor(TBB)) {
if (TII->ReverseBranchCondition(Cond)) {
// We can't reverse the condition, add an unconditional branch.
Cond.clear();
TII->InsertBranch(*this, MBBA, 0, Cond);
return;
}
TII->RemoveBranch(*this);
TII->InsertBranch(*this, MBBA, 0, Cond);
} else if (!isLayoutSuccessor(MBBA)) {
TII->RemoveBranch(*this);
TII->InsertBranch(*this, TBB, MBBA, Cond);
}
}
}
}
void MachineBasicBlock::addSuccessor(MachineBasicBlock *succ) {
Successors.push_back(succ);
succ->addPredecessor(this);
}
void MachineBasicBlock::removeSuccessor(MachineBasicBlock *succ) {
succ->removePredecessor(this);
succ_iterator I = std::find(Successors.begin(), Successors.end(), succ);
assert(I != Successors.end() && "Not a current successor!");
Successors.erase(I);
}
MachineBasicBlock::succ_iterator
MachineBasicBlock::removeSuccessor(succ_iterator I) {
assert(I != Successors.end() && "Not a current successor!");
(*I)->removePredecessor(this);
return Successors.erase(I);
}
void MachineBasicBlock::addPredecessor(MachineBasicBlock *pred) {
Predecessors.push_back(pred);
}
void MachineBasicBlock::removePredecessor(MachineBasicBlock *pred) {
std::vector<MachineBasicBlock *>::iterator I =
std::find(Predecessors.begin(), Predecessors.end(), pred);
assert(I != Predecessors.end() && "Pred is not a predecessor of this block!");
Predecessors.erase(I);
}
void MachineBasicBlock::transferSuccessors(MachineBasicBlock *fromMBB) {
if (this == fromMBB)
return;
for (MachineBasicBlock::succ_iterator I = fromMBB->succ_begin(),
E = fromMBB->succ_end(); I != E; ++I)
addSuccessor(*I);
while (!fromMBB->succ_empty())
fromMBB->removeSuccessor(fromMBB->succ_begin());
}
bool MachineBasicBlock::isSuccessor(const MachineBasicBlock *MBB) const {
std::vector<MachineBasicBlock *>::const_iterator I =
std::find(Successors.begin(), Successors.end(), MBB);
return I != Successors.end();
}
bool MachineBasicBlock::isLayoutSuccessor(const MachineBasicBlock *MBB) const {
MachineFunction::const_iterator I(this);
return llvm::next(I) == MachineFunction::const_iterator(MBB);
}
bool MachineBasicBlock::canFallThrough() {
MachineFunction::iterator Fallthrough = this;
++Fallthrough;
// If FallthroughBlock is off the end of the function, it can't fall through.
if (Fallthrough == getParent()->end())
return false;
// If FallthroughBlock isn't a successor, no fallthrough is possible.
if (!isSuccessor(Fallthrough))
return false;
// Analyze the branches, if any, at the end of the block.
MachineBasicBlock *TBB = 0, *FBB = 0;
SmallVector<MachineOperand, 4> Cond;
const TargetInstrInfo *TII = getParent()->getTarget().getInstrInfo();
if (TII->AnalyzeBranch(*this, TBB, FBB, Cond, true)) {
// If we couldn't analyze the branch, examine the last instruction.
// If the block doesn't end in a known control barrier, assume fallthrough
// is possible. The isPredicable check is needed because this code can be
// called during IfConversion, where an instruction which is normally a
// Barrier is predicated and thus no longer an actual control barrier. This
// is over-conservative though, because if an instruction isn't actually
// predicated we could still treat it like a barrier.
return empty() || !back().getDesc().isBarrier() ||
back().getDesc().isPredicable();
}
// If there is no branch, control always falls through.
if (TBB == 0) return true;
// If there is some explicit branch to the fallthrough block, it can obviously
// reach, even though the branch should get folded to fall through implicitly.
if (MachineFunction::iterator(TBB) == Fallthrough ||
MachineFunction::iterator(FBB) == Fallthrough)
return true;
// If it's an unconditional branch to some block not the fall through, it
// doesn't fall through.
if (Cond.empty()) return false;
// Otherwise, if it is conditional and has no explicit false block, it falls
// through.
return FBB == 0;
}
/// removeFromParent - This method unlinks 'this' from the containing function,
/// and returns it, but does not delete it.
MachineBasicBlock *MachineBasicBlock::removeFromParent() {
assert(getParent() && "Not embedded in a function!");
getParent()->remove(this);
return this;
}
/// eraseFromParent - This method unlinks 'this' from the containing function,
/// and deletes it.
void MachineBasicBlock::eraseFromParent() {
assert(getParent() && "Not embedded in a function!");
getParent()->erase(this);
}
/// ReplaceUsesOfBlockWith - Given a machine basic block that branched to
/// 'Old', change the code and CFG so that it branches to 'New' instead.
void MachineBasicBlock::ReplaceUsesOfBlockWith(MachineBasicBlock *Old,
MachineBasicBlock *New) {
assert(Old != New && "Cannot replace self with self!");
MachineBasicBlock::iterator I = end();
while (I != begin()) {
--I;
if (!I->getDesc().isTerminator()) break;
// Scan the operands of this machine instruction, replacing any uses of Old
// with New.
for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
if (I->getOperand(i).isMBB() &&
I->getOperand(i).getMBB() == Old)
I->getOperand(i).setMBB(New);
}
// Update the successor information.
removeSuccessor(Old);
addSuccessor(New);
}
/// CorrectExtraCFGEdges - Various pieces of code can cause excess edges in the
/// CFG to be inserted. If we have proven that MBB can only branch to DestA and
/// DestB, remove any other MBB successors from the CFG. DestA and DestB can
/// be null.
/// Besides DestA and DestB, retain other edges leading to LandingPads
/// (currently there can be only one; we don't check or require that here).
/// Note it is possible that DestA and/or DestB are LandingPads.
bool MachineBasicBlock::CorrectExtraCFGEdges(MachineBasicBlock *DestA,
MachineBasicBlock *DestB,
bool isCond) {
bool MadeChange = false;
bool AddedFallThrough = false;
MachineFunction::iterator FallThru =
llvm::next(MachineFunction::iterator(this));
if (isCond) {
// If this block ends with a conditional branch that falls through to its
// successor, set DestB as the successor.
if (DestB == 0 && FallThru != getParent()->end()) {
DestB = FallThru;
AddedFallThrough = true;
}
} else {
// If this is an unconditional branch with no explicit dest, it must just be
// a fallthrough into DestA.
if (DestA == 0 && FallThru != getParent()->end()) {
DestA = FallThru;
AddedFallThrough = true;
}
}
MachineBasicBlock::succ_iterator SI = succ_begin();
MachineBasicBlock *OrigDestA = DestA, *OrigDestB = DestB;
while (SI != succ_end()) {
if (*SI == DestA) {
DestA = 0;
++SI;
} else if (*SI == DestB) {
DestB = 0;
++SI;
} else if ((*SI)->isLandingPad() &&
*SI!=OrigDestA && *SI!=OrigDestB) {
++SI;
} else {
// Otherwise, this is a superfluous edge, remove it.
SI = removeSuccessor(SI);
MadeChange = true;
}
}
if (!AddedFallThrough) {
assert(DestA == 0 && DestB == 0 &&
"MachineCFG is missing edges!");
} else if (isCond) {
assert(DestA == 0 && "MachineCFG is missing edges!");
}
return MadeChange;
}
void llvm::WriteAsOperand(raw_ostream &OS, const MachineBasicBlock *MBB,
bool t) {
OS << "BB#" << MBB->getNumber();
}