All Structured Programs have Small Tree-Width and Good Register Allocation
نویسنده
چکیده
The register allocation problem for an imperative program is often modelled as the coloring problem of the interference graph of the control-ow graph of the program. The interference graph of a ow graph G is the intersection graph of some connected subgraphs of G. These connected subgraphs represent the lives, or life times, of variables, so the coloring problem models that two variables with overlapping life times should be in diierent registers. For general programs with unrestricted gotos, the interference graph can be any graph, and hence we cannot in general color within a factor O(n ") from optimality unless NP=P. It is shown that if a graph has tree-width k, we can eeciently color any intersection graph of connected subgraphs within a factor (bk=2c + 1) from optimality. Moreover, it is shown that structured (goto-free) programs, including, for example, short circuit evaluations and multiple exits from loops, have tree-width at most 6. Thus, for every structured program, we can do register allocation eeciently within a factor 4 from optimality, regardless of how many registers are needed. The bounded tree-width of control-ow graphs of structured programs implies that the many techniques for bounded tree-width may now be applied in control-ow analysis, solving problems in linear time that are NP-hard, or even P-space hard, for general graphs.
منابع مشابه
Structured Programs have Small Tree-Width and Good Register Allocation (Extended Abstract)
The register allocation problem for an imperative program is often modelled as the coloring problem of the interference graph of the control-ow graph of the program. The interference graph of a ow graph G is the intersection graph of some connected subgraphs of G. These connected subgraphs represent the lives, or life times, of variables, so the coloring problem models that two variables with o...
متن کاملThe complexity of register allocation
In compilers, register allocation is one of the most important stages with respect to optimization for typical goals, such as code size, code speed, or energy efficiency. Graph theoretically, optimal register allocation is the problem of finding a maximum weight r-colorable induced subgraph in the conflict graph of a given program. The parameter r is the number of registers. Large classes of pr...
متن کاملThe Treewidth of Java Programs
Intuitively, the treewidth of a graph G measures how close G is to being a tree. The lower the treewidth, the faster we can solve various optimization problems on G, by dynamic programming along the tree structure. In the paper M.Thorup, All Structured Programs have Small Tree-Width and Good Register Allocation [8] it is shown that the control-flow graph of any goto-free C program is at most 6....
متن کاملCode Generation Techniques
Optimal instruction scheduling and register allocation are NP-complete problems that require heuristic solutions. By restricting the problem of register allocation and instruction scheduling for delayed-load architectures to expression trees we are able to nd optimal schedules quickly. This thesis presents a fast, optimal code scheduling algorithm for processors with a delayed load of 1 instruc...
متن کاملRegister assignment in tree-structured programs
Much complex decision-making is performed routinely by the software of a computer system. It is appropriate to study more thoroughly the performance of this built-in decisionmaking, because it can strongly influence the efficiency of the entire system. One objective of compilers is to produce a reasonably efficient machine-language version of a user’s program. Traditionally, one of the best opp...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید
ثبت ناماگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید
ورودعنوان ژورنال:
- Inf. Comput.
دوره 142 شماره
صفحات -
تاریخ انتشار 1998