GCC Middle and Back End API Reference
|
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "rtl.h"
#include "tree.h"
#include "hard-reg-set.h"
#include "regs.h"
#include "insn-config.h"
#include "flags.h"
#include "recog.h"
#include "diagnostic-core.h"
#include "cselib.h"
#include "params.h"
#include "tm_p.h"
#include "target.h"
#include "function.h"
#include "emit-rtl.h"
#include "tree-pass.h"
#include "cfgloop.h"
#include "expr.h"
#include "df.h"
#include "dce.h"
#include "dbgcnt.h"
Macros | |
#define | FORWARDER_BLOCK_P(BB) ((BB)->flags & BB_FORWARDER_BLOCK) |
#define | SWAP(T, X, Y) do { T tmp = (X); (X) = (Y); (Y) = tmp; } while (0) |
Variables | |
static bool | first_pass |
static bool | crossjumps_occured |
static bool | block_was_dirty |
#define FORWARDER_BLOCK_P | ( | BB | ) | ((BB)->flags & BB_FORWARDER_BLOCK) |
Control flow optimization code for GNU compiler. Copyright (C) 1987-2013 Free Software Foundation, Inc.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. This file contains optimizer of the control flow. The main entry point is cleanup_cfg. Following optimizations are performed:
Referenced by merge_blocks_move_successor_nojumps().
|
static |
Returns true if BB basic block has a preserve label.
References BB_END, for_each_rtx(), and replace_label().
|
static |
Examine register notes on I1 and I2 and return:
Check for 2 sets.
Check that the 2 sets set the same dest.
Find identical req_equiv or reg_equal note, which implies that the 2 sets set dest to the same value.
Although the 2 sets set dest to the same value, we cannot replace (set (dest) (const_int)) by (set (dest) (reg)) because we don't know if the reg is live and has the same value at the location of replacement.
bool cleanup_cfg | ( | ) |
Tidy the CFG by deleting unreachable code and whatnot.
Set the cfglayout mode flag here. We could update all the callers but that is just inconvenient, especially given that we eventually want to have cfglayout mode as the default.
We've possibly created trivially dead code. Cleanup it right now to introduce more opportunities for try_optimize_cfg.
To tail-merge blocks ending in the same noreturn function (e.g. a call to abort) we have to insert fake edges to exit. Do this here once. The fake edges do not interfere with any other CFG cleanups.
Try to remove some trivially dead insns when doing an expensive cleanup. But delete_trivially_dead_insns doesn't work after reload (it only handles pseudos) and run_fast_dce is too costly to run in every iteration. For effective cross jumping, we really want to run a fast DCE to clean up any dead conditions, or they get in the way of performing useful tail merges. Other transformations in cleanup_cfg are not so sensitive to dead code, so delete_trivially_dead_insns or even doing nothing at all is good enough.
Don't call delete_dead_jumptables in cfglayout mode, because that function assumes that jump tables are in the insns stream. But we also don't _have_ to delete dead jumptables in cfglayout mode because we shouldn't even be looking at things that are not in a basic block. Dead jumptables are cleaned up when going out of cfglayout mode.
??? We probably do this way too often.
The above doesn't preserve dominance info if available.
void delete_dead_jumptables | ( | void | ) |
Delete any jump tables never referenced. We can't delete them at the time of removing tablejump insn as they are referenced by the preceding insns computing the destination, so we delay deleting and garbagecollect them once life information is computed.
A dead jump table does not belong to any basic block. Scan insns between two adjacent basic blocks.
bool delete_unreachable_blocks | ( | void | ) |
Delete all unreachable basic blocks.
When we're in GIMPLE mode and there may be debug insns, we should delete blocks in reverse dominator order, so as to get a chance to substitute all released DEFs into debug stmts. If we don't have dominators information, walking blocks backward gets us a better chance of retaining most debug information than otherwise.
Speed up the removal of blocks that don't dominate others. Walking backwards, this should be the common case.
Referenced by cleanup_empty_eh_unsplit(), cleanup_tree_cfg_1(), and split_live_ranges_for_shrink_wrap().
|
static |
Checks if patterns P1 and P2 are equivalent, apart from the possibly different single sets S1 and S2.
|
static |
|
static |
int flow_find_cross_jump | ( | basic_block | bb1, |
basic_block | bb2, | ||
rtx * | f1, | ||
rtx * | f2, | ||
enum replace_direction * | dir_p | ||
) |
Look through the insns at the end of BB1 and BB2 and find the longest sequence that are either equivalent, or allow forward or backward replacement. Store the first insns for that sequence in *F1 and *F2 and return the sequence length.
DIR_P indicates the allowed replacement direction on function entry, and the actual replacement direction on function exit. If NULL, only equivalent sequences are allowed.
To simplify callers of this function, if the blocks match exactly, store the head of the blocks in *F1 and *F2.
Skip simple jumps at the end of the blocks. Complex jumps still need to be compared for equivalence, which we'll do below.
Count everything except for unconditional jump as insn.
In the following example, we can replace all jumps to C by jumps to A. This removes 4 duplicate insns. [bb A] insn1 [bb C] insn1 insn2 insn2 [bb B] insn3 insn3 insn4 insn4 jump_insn jump_insn We could also replace all jumps to A by jumps to C, but that leaves B alive, and removes only 2 duplicate insns. In a subsequent crossjump step, all jumps to B would be replaced with jumps to the middle of C, achieving the same result with more effort. So we allow only the first possibility, which means that we don't allow fallthru in the block that's being replaced.
Don't begin a cross-jump with a NOTE insn.
Include preceding notes and labels in the cross-jump. One, this may bring us to the head of the blocks as requested above. Two, it keeps line number notes as matched as may be.
int flow_find_head_matching_sequence | ( | basic_block | bb1, |
basic_block | bb2, | ||
rtx * | f1, | ||
rtx * | f2, | ||
int | stop_after | ||
) |
Like flow_find_cross_jump, except start looking for a matching sequence from the head of the two blocks. Do not include jumps at the end. If STOP_AFTER is nonzero, stop after finding that many matching instructions.
Ignore notes, except NOTE_INSN_EPILOGUE_BEG.
A sanity check to make sure we're not merging insns with different effects on EH. If only one of them ends a basic block, it shouldn't have an EH edge; if both end a basic block, there should be the same number of EH edges.
Don't begin a cross-jump with a NOTE insn.
rtl_opt_pass* make_pass_jump | ( | ) |
rtl_opt_pass* make_pass_jump2 | ( | ) |
|
static |
Attempt to prove that operation is NOOP using CSElib or mark the effect on register. Used by jump threading.
In case we do clobber the register, mark it as equal, as we know the value is dead so it don't have to match.
|
static |
|
static |
Return nonzero if X is a register set in regset DATA. Called via for_each_rtx.
|
static |
Attempt to merge basic blocks that are potentially non-adjacent. Return NULL iff the attempt failed, otherwise return basic block where cleanup_cfg should continue. Because the merging commonly moves basic block away or introduces another optimization possibility, return basic block just before B so cleanup_cfg don't need to iterate.
It may be good idea to return basic block before C in the case C has been moved after B and originally appeared earlier in the insn sequence, but we have no information available about the relative ordering of these two. Hopefully it is not too common.
If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot and cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
If B has a fallthru edge to C, no need to move anything.
Protect the loop latches.
Otherwise we will need to move code around. Do that only if expensive transformations are allowed.
Avoid overactive code motion, as the forwarder blocks should be eliminated by edge redirection instead. One exception might have been if B is a forwarder block and C has no fallthru edge, but that should be cleaned up by bb-reorder instead.
We must make sure to not munge nesting of lexical blocks, and loop notes. This is done by squeezing out all the notes and leaving them there to lie. Not ideal, but functional.
Otherwise, we're going to try to move C after B. If C does not have an outgoing fallthru, then it can be moved immediately after B without introducing or modifying jumps.
If B does not have an incoming fallthru, then it can be moved immediately before C without introducing or modifying jumps. C cannot be the first block, so we do not have to worry about accessing a non-existent block.
|
static |
|
static |
Blocks A and B are to be merged into a single block. A has no incoming fallthru edge, so it can be moved before B without adding or modifying any jumps (aside from the jump from A to B).
If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot and cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
Scramble the insn chain.
Swap the records for the two blocks around.
Now blocks A and B are contiguous. Merge them.
References BARRIER_P, BB_END, BB_HEAD, BB_PARTITION, delete_insn(), dump_file, basic_block_def::index, merge_blocks(), NEXT_INSN, prev_active_insn(), reorder_insns_nobb(), table, and tablejump_p().
|
static |
|
static |
Blocks A and B are to be merged into a single block. B has no outgoing fallthru edge, so it can be moved after A without adding or modifying any jumps (aside from the jump from A to B).
If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot and cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
If there is a jump table following block B temporarily add the jump table to block B so that it will also be moved to the correct location.
There had better have been a barrier there. Delete it.
Scramble the insn chain.
Restore the real end of b.
Now blocks A and B are contiguous. Merge them.
References BB_PARTITION, CLEANUP_EXPENSIVE, current_loops, dump_file, ENTRY_BLOCK_PTR, edge_def::flags, FORWARDER_BLOCK_P, basic_block_def::index, loop::latch, basic_block_def::loop_father, merge_blocks(), NULL, basic_block_def::prev_bb, and update_forwarder_flag().
|
static |
Merges directions A and B.
Implements the following table: |bo fw bw no —+———– bo |bo fw bw no fw |– fw no no bw |– – bw no no |– – – no.
References CALL_INSN_FUNCTION_USAGE, dir_none, find_reg_note(), get_call_rtx_from(), GET_CODE, rtx_equal_p(), SANITIZE_ADDRESS, SIBLING_CALL_P, and XEXP.
void merge_memattrs | ( | ) |
Removes the memory attributes of MEM expression if they are not equal.
Two vectors must have the same length.
|
static |
When comparing insns I1 and I2 in flow_find_cross_jump or flow_find_head_matching_sequence, ensure the notes match.
If the merged insns have different REG_EQUAL notes, then remove them.
|
static |
|
static |
Set flags for newly created block.
|
static |
|
static |
Examine I1 and I2 and return:
Verify that I1 and I2 are equivalent.
__builtin_unreachable() may lead to empty blocks (ending with NOTE_INSN_BASIC_BLOCK). They may be crossjumped.
??? Do not allow cross-jumping between different stack levels.
??? Worse, this adjustment had better be constant lest we have differing incoming stack levels.
If this is a CALL_INSN, compare register usage information. If we don't check this on stack register machines, the two CALL_INSNs might be merged leaving reg-stack.c with mismatching numbers of stack registers in the same basic block. If we don't check this on machines with delay slots, a delay slot may be filled that clobbers a parameter expected by the subroutine. ??? We take the simple route for now and assume that if they're equal, they were constructed identically. Also check for identical exception regions.
Ensure the same EH region.
For address sanitizer, never crossjump __asan_report_* builtins, otherwise errors might be reported on incorrect lines.
References BUILT_IN_NORMAL, DECL_BUILT_IN_CLASS, DECL_FUNCTION_CODE, dir_none, SYMBOL_REF_DECL, TREE_CODE, and XEXP.
|
static |
|
static |
Return true iff outgoing edges of BB1 and BB2 match, together with the branch instruction. This means that if we commonize the control flow before end of the basic block, the semantic remains unchanged.
We may assume that there exists one edge with a common destination.
If we performed shrink-wrapping, edges to the EXIT_BLOCK_PTR can only be distinguished for JUMP_INSNs. The two paths may differ in whether they went through the prologue. Sibcalls are fine, we know that we either didn't need or inserted an epilogue before them.
If BB1 has only one successor, we may be looking at either an unconditional jump, or a fake edge to exit.
Match conditional jumps - this may get tricky when fallthru and branch edges are crossed.
Get around possible forwarders on fallthru edges. Other cases should be optimized out already.
To simplify use of this function, return false if there are unneeded forwarder blocks. These will get eliminated later during cleanup_cfg.
Verify codes and operands match.
If we return true, we will join the blocks. Which means that we will only have one branch prediction bit to work with. Thus we require the existing branches to have probabilities that are roughly similar.
Do not use f2 probability as f2 may be forwarded.
Fail if the difference in probabilities is greater than 50%. This rules out two well-predicted branches with opposite outcomes.
Generic case - we are seeing a computed jump, table jump or trapping instruction.
Check whether there are tablejumps in the end of BB1 and BB2. Return true if they are identical.
The labels should never be the same rtx. If they really are same the jump tables are same too. So disable crossjumping of blocks BB1 and BB2 because when deleting the common insns in the end of BB1 by delete_basic_block () the jump table would be deleted too.
If LABEL2 is referenced in BB1->END do not do anything because we would loose information when replacing LABEL1 by LABEL2 and then LABEL2 by LABEL1 in BB1->END.
Set IDENTICAL to true when the tables are identical.
Temporarily replace references to LABEL1 with LABEL2 in BB1->END so that we could compare the instructions.
Set the original label in BB1->END because when deleting a block whose end is a tablejump, the tablejump referenced from the instruction is deleted too.
First ensure that the instructions match. There may be many outgoing edges so this test is generally cheaper.
Search the outgoing edges, ensure that the counts do match, find possible fallthru and exception handling edges since these needs more validation.
If number of edges of various types does not match, fail.
If !ACCUMULATE_OUTGOING_ARGS, bb1 (and bb2) have no successors and the last real insn doesn't have REG_ARGS_SIZE note, don't attempt to optimize, as the two basic blocks might have different REG_ARGS_SIZE depths. For noreturn calls and unconditional traps there should be REG_ARG_SIZE notes, they could be missing for __builtin_unreachable () uses though.
fallthru edges must be forwarded to the same destination.
Ensure the same EH region.
The same checks as in try_crossjump_to_edge. It is required for RTL version of sequence abstraction.
References edge_def::dest, dump_file, basic_block_def::index, edge_def::probability, and REG_BR_PROB_BASE.
|
static |
|
static |
Attempt to prove that the basic block B will have no side effects and always continues in the same edge if reached via E. Return the edge if exist, NULL otherwise.
At the moment, we do handle only conditional jumps, but later we may want to extend this code to tablejumps and others.
Second branch must end with onlyjump, as we will eliminate the jump.
Ensure that the comparison operators are equivalent. ??? This is far too pessimistic. We should allow swapped operands, different CCmodes, or for example comparisons for interval, that dominate even when operands are not equivalent.
Short circuit cases where block B contains some side effects, as we can't safely bypass it.
First process all values computed in the source basic block.
Now assume that we've continued by the edge E to B and continue processing as if it were same basic block. Our goal is to prove that whole block is an NOOP.
Later we should clear nonequal of dead registers. So far we don't have life information in cfg_cleanup.
cond2 must not mention any register that is not equal to the former block.
|
static |
Return true if BB contains just bb note, or bb note followed by only DEBUG_INSNs.
References merge_blocks(), and update_forwarder_flag().
|
static |
|
static |
Search the predecessors of BB for common insn sequences. When found, share code between them by redirecting control flow. Return true if any changes made.
Nothing to do if there is not at least two incoming edges.
Don't crossjump if this block ends in a computed jump, unless we are optimizing for size.
If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot and cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
It is always cheapest to redirect a block that ends in a branch to a block that falls through into BB, as that adds no branches to the program. We'll try that combination first.
As noted above, first try with the fallthru predecessor (or, a fallthru predecessor if we are in cfglayout mode).
Don't combine the fallthru edge into anything else. If there is a match, we'll do it the other way around.
If nothing changed since the last attempt, there is nothing we can do.
Non-obvious work limiting check: Recognize that we're going to call try_crossjump_bb on every basic block. So if we have two blocks with lots of outgoing edges (a switch) and they share lots of common destinations, then we would do the cross-jump check once for each common destination. Now, if the blocks actually are cross-jump candidates, then all of their destinations will be shared. Which means that we only need check them for cross-jump candidacy once. We can eliminate redundant checks of crossjump(A,B) by arbitrarily choosing to do the check from the block for which the edge in question is the first successor of A.
We've already checked the fallthru edge above.
The "first successor" check above only prevents multiple checks of crossjump(A,B). In order to prevent redundant checks of crossjump(B,A), require that A be the block with the lowest index.
If nothing changed since the last attempt, there is nothing we can do.
Both e and e2 are not fallthru edges, so we can crossjump in either direction.
|
static |
E1 and E2 are edges with the same destination block. Search their predecessors for common code. If found, redirect control flow from (maybe the middle of) E1->SRC to (maybe the middle of) E2->SRC (dir_forward), or the other way around (dir_backward). DIR specifies the allowed replacement direction.
If we have partitioned hot/cold basic blocks, it is a bad idea to try this optimization. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
Search backward through forwarder blocks. We don't need to worry about multiple entry or chained forwarders, as they will be optimized away. We do this to look past the unconditional jump following a conditional jump that is required due to the current CFG shape.
Nothing to do if we reach ENTRY, or a common source block.
Seeing more than 1 forwarder blocks would confuse us later...
Likewise with dead code (possibly newly created by the other optimizations of cfg_cleanup).
Look for the common insn sequence, part the first ...
... and part the second.
Don't proceed with the crossjump unless we found a sufficient number of matching instructions or the 'from' block was totally matched (such that its predecessors will hopefully be redirected and the block removed).
Avoid deleting preserve label when redirecting ABNORMAL edges.
Here we know that the insns in the end of SRC1 which are common with SRC2 will be deleted. If we have tablejumps in the end of SRC1 and SRC2 they have been already compared for equivalence in outgoing_edges_match () so replace the references to TABLE1 by references to TABLE2.
Replace references to LABEL1 with LABEL2.
Do not replace the label in SRC1->END because when deleting a block whose end is a tablejump, the tablejump referenced from the instruction is deleted too.
Avoid splitting if possible. We must always split when SRC2 has EH predecessor edges, or we may end up with basic blocks with both normal and EH predecessor edges.
Skip possible basic block header.
We may have some registers visible through the block.
Recompute the frequencies and counts of outgoing edges.
Take care to update possible forwarder blocks. We verified that there is no more than one in the chain, so we can't run into infinite loop.
Adjust count and frequency for the block. An earlier jump threading pass may have left the profile in an inconsistent state (see update_bb_profile_for_threading) so we must be prepared for overflows.
Edit SRC1 to go to REDIRECT_TO at NEWPOS1.
Skip possible basic block header.
References BB_HEAD, DEBUG_INSN_P, edge_def::dest, dump_file, LABEL_P, NEXT_INSN, NOTE_P, PREV_INSN, and split_block().
|
static |
|
static |
Attempt to forward edges leaving basic block B. Return true if successful.
If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot and cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
Skip complex edges because we don't know how to update them. Still handle fallthru edges, as we can succeed to forward fallthru edge to the same place as the branch edge of conditional branch and turn conditional branch to an unconditional branch.
If we are partitioning hot/cold basic_blocks, we don't want to mess up jumps that cross between hot/cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
Bypass trivial infinite loops.
When not optimizing, ensure that edges or forwarder blocks with different locus are not optimized out.
Allow to thread only over one edge at time to simplify updating of probabilities.
Detect an infinite loop across blocks not including the start block.
Detect an infinite loop across the start block.
Save the values now, as the edge may get removed.
Don't force if target is exit block.
We successfully forwarded the edge. Now update profile data: for each edge we traversed in the chain, remove the original edge's execution count.
It is possible that as the result of threading we've removed edge as it is threaded to the fallthru edge. Avoid getting out of sync.
References ei_next().
|
static |
Search the successors of BB for common insn sequences. When found, share code between them by moving it across the basic block boundary. Return true if any changes made.
Nothing to do if there is not at least two outgoing edges.
Don't crossjump if this block ends in a computed jump, unless we are optimizing for size.
Normally, all destination blocks must only be reachable from this block, i.e. they must have one incoming edge. There is one special case we can handle, that of multiple consecutive jumps where the first jumps to one of the targets of the second jump. This happens frequently in switch statements for default labels. The structure is as follows: FINAL_DEST_BB .... if (cond) jump A; fall through BB jump with targets A, B, C, D... A has two incoming edges, from FINAL_DEST_BB and BB In this case, we can try to move the insns through BB and into FINAL_DEST_BB.
We must be able to move the insns across the whole block.
If we matched an entire block, we probably have to avoid moving the last insn.
We must find a union of the live registers at each of the end points.
Compute the end point and live information
If we're moving across two blocks, verify the validity of the first move, then adjust the target and let the loop below deal with the final move.
Try again, using a different insertion point.
We haven't checked whether a partial move would be OK for the first move, so we have to fail this case.
If we can't currently move all of the identical insns, remember each insn after the range that we'll merge.
For the unmerged insns, try a different insertion point.
|
static |
|
static |
Do simple CFG optimizations - basic block merging, simplifying of jump instructions etc. Return nonzero if changes were made.
Attempt to merge blocks as made possible by edge removal. If a block has only one successor, and the successor has only one predecessor, they may be combined.
Delete trivially dead basic blocks. This is either blocks with no predecessors, or empty blocks with no successors. However if the empty block with no successors is the successor of the ENTRY_BLOCK, it is kept. This ensures that the ENTRY_BLOCK will have a successor which is a precondition for many RTL passes. Empty blocks may result from expanding __builtin_unreachable ().
Avoid trying to remove ENTRY_BLOCK_PTR.
Remove code labels no longer used.
If the previous block ends with a branch to this block, we can't delete the label. Normally this is a condjump that is yet to be simplified, but if CASE_DROPS_THRU, this can be a tablejump with some element going to the same place as the default (fallthru).
If we fall through an empty block, we can remove it.
Note that forwarder_block_p true ensures that there is a successor for this block.
Merge B with its single successor, if any.
When not in cfg_layout mode use code aware of reordering INSN. This code possibly creates new basic blocks so it does not fit merge_blocks interface and is kept here in hope that it will become useless once more of compiler is transformed to use cfg_layout mode.
If the jump insn has side effects, we can't kill the edge.
Simplify branch over branch.
If B has a single outgoing edge, but uses a non-trivial jump instruction without side-effects, we can either delete the jump entirely, or replace it with a simple unconditional jump.
Simplify branch to branch.
Look for shared code between blocks.
This can lengthen register lifetimes. Do it only after reload.
Don't get confused by the index shift caused by deleting blocks.
This should only be set by head-merging.
Edge forwarding in particular can cause hot blocks previously reached by both hot and cold blocks to become dominated only by cold blocks. This will cause the verification below to fail, and lead to now cold code in the hot section. This is not easy to detect and fix during edge forwarding, and in some cases is only visible after newly unreachable blocks are deleted, which will be done in fixup_partitions.
|
static |
|
static |
Simplify a conditional jump around an unconditional jump. Return true if something changed.
Verify that there are exactly two successors.
Verify that we've got a normal conditional branch at the end of the block.
The next block must not have multiple predecessors, must not be the last block in the function, and must contain just the unconditional jump.
If we are partitioning hot/cold basic blocks, we don't want to mess up unconditional or indirect jumps that cross between hot and cold sections. Basic block partitioning may result in some jumps that appear to be optimizable (or blocks that appear to be mergeable), but which really must be left untouched (they are required to make it safely across partition boundaries). See the comments at the top of bb-reorder.c:partition_hot_cold_basic_blocks for complete details.
The conditional branch must target the block after the unconditional branch.
Invert the conditional branch.
Success. Update the CFG to match. Note that after this point the edge variable names appear backwards; the redirection is done this way to preserve edge profile data.
Delete the block with the unconditional jump, and clean up the mess.
|
static |
Referenced by merge_blocks_move_successor_nojumps(), and trivially_empty_bb_p().
|
static |
Recompute forwarder flag after block has been modified.
References EDGE_COUNT, and basic_block_def::succs.
|
static |
Walks from I1 in BB1 backward till the next non-debug insn, and returns the resulting insn in I1, and the corresponding bb in BB1. At the head of a bb, if there is a predecessor bb that reaches this bb via fallthru, and FOLLOW_FALLTHRU, walks further in the predecessor bb and registers this in DID_FALLTHRU. Otherwise, stops at the head of the bb.
Ignore notes.
|
static |
Set to true if we couldn't run an optimization due to stale liveness information; we should run df_analyze to enable more opportunities.
|
static |
Set to true if crossjumps occurred in the latest run of try_optimize_cfg.
|
static |
Set to true when we are running first pass of try_optimize_cfg loop.