'$ &#! ".,, -# + -&4 &$ #.$2 -.3 ".-3 (-... ".-#(3(.- +2

advertisement
'$ &#! ".,, -# + -&4 &$ #.$2 -.3 ".-3 (- +../2 .1
".-#(3(.- +2
$5$1 + $5$-3:! 2$# #$!4&&$12 ' 5$ !$$- #$5$+./$# 2 1$:
2$ 1"' /1.3.38/$2 -+(*$ 3'$8 1$ -.3 5 (+ !+$ 2
".,,$1"( + /1.#4"32 +$* (2 2$04$-3( + $5$-3:! 2$#
#$!4&&$1 6'("' (2 - $73$-2(.- .% &#! +$* ++.62 '(&':
+$5$+ $5$-32 3. !$ #$%(-$# %1., ".,!(- 3(.-2 .% +.6$1:+$5$+
$5$-32 +$* (2 24/$1(.1 3. (- /1.5(#(-& 3'$ !(+(38
3. #$%(-$ '(&':+$5$+ $5$-32 .6$5$1 (2 /1.! !+8
$ 2($1 3. 42$ !$" 42$ .41 &. + ' 2 !$$- 3. /1.5(#$ 3'$ 42$1
6(3' /.6$1%4+ $5$-3:! 2$# #$!4&&(-& %$ 341$2 6'("' " - !$
42$# 6(3' +(33+$ $%%.13 -4,!$1 .% $5$-3:! 2$# #$!4&&$12
' 5$ !$$- #$5$+./$# %.1 / 1 ++$+ -# #(231(!43$# 2823$,2
$5$1 + /$./+$ ' 5$ +..*$# 3 3'$ /1.!+$, .% #$!4&&(-&
./3(,(9$# ".#$ $--$228 /1$2$-32 +&.1(3',2 %.1 #$3$1:
,(-(-& 3'$ 5 +4$ .% 5 1( !+$2 (- - ./3(,(9$# /1.&1 ,
'$- 3'$ #$!4&&$1 (2 23.//$# 3 !1$ */.(-3 -# 3'$ 42$1
31($2 3. /1(-3 5 1( !+$ x 3'$ #$!4&&$1 2'.4+# .43/43 3'$
5 +4$ .% x 3' 3 (2 ".-2(23$-3 6(3' 3'$ .1#$1 .% $7$"43(.- .%
23 3$,$-32 (- 3'$ 4-./3(,(9$# /1.&1 , (-"$ 3'$ ./3(,(9$1
" - 1$.1#$1 23 3$,$-32 3'$ 5 +4$ 23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' 3 .""41 (- 3'$ ./3(,(9$# 5$12(.- .%
/1.&1 , !43 -.3 (- 3'$ 4-./3(,(9$# 5$12(.-
2 "+ 22 .% 3..+2 #$!4&&$12 /$1%.1, 6(#$ 1 -&$ .%
./$1 3(.-2 %1., 5$18 +.6:+$5$+ 3 1&$3:2/$"(%(" ./$1 3(.-2 3.
,(##+$:+$5$+ + -&4 &$:2/$"(%(" ./$1 3(.-2 3. '(&':+$5$+ 42$1
(-3$1% "$ ./$1 3(.-2 $" 42$ .% 3'$ - 341$ .% 3'$2$ ./$1 :
3(.-2 #$!4&&$1 " - !$ #(%%("4+3 3. /.13 -# 1$3 1&$3
' 2 !$$- #$2(&-$# (- ,.#4+ 1 % 2'(.- 6(3' 3'$
&. + .% (2.+ 3(-& .!)$"3 ".#$ #$/$-#$-3 + -&4 &$ #$/$-#$-3
3 1&$3 #$/$-#$-3 -# 42$1 (-3$1% "$ #$/$-#$-3 %4-"3(.-2
%1., &$-$1(" #$!4&&(-& %4-"3(.-2 '$ 1"'(3$"341$
".-2(232 .% , (- #$!4&&$1 -# 2$5$1 + , - &$12 6'("'
1$ " 3$&.1(9$# "".1#(-& 3. + -&4 &$ 3 1&$3 .!)$"3 ".#$
-# 42$1 (-3$1% "$ 38/$ 2$$ (& '$ , (- #$!4&&$1 (2 #$2(&-$# 3. /1.5(#$ 2 , -8 &$-$1("
#$!4&&$1 ./$1 3(.-2 2 (3 " - 6(3'.43 ".,/1.,(2(-& 3'$
&$-$1 +(38 .% 7 ,/+$2 .% 3'$2$ ./$1 3(.-2 (-"+4#$
 Hewlett-Packard Company 1994
The object code produced by a compiler using straightforward compiling techniques
is often not very efficient. In many cases, the object code can be made to run faster
or take up less space through program transformations known as optimizations.
Compilers that improve performance through code transformations are known as
optimizing compilers.
In an unoptimized program, there is generally a one-to-one correspondence between
a source statement and a group of one or more machine instructions. Optimizing
compilers must preserve the correctness of a program, but after optimization, this
one-to-one correspondence no longer exists in many cases, and the program may
no longer execute in the order implied by the source code. This complicates debugging. Programmers must often resort to debugging assembly code to figure out
how an optimized program is behaving.
In general, users should debug the unoptimized version of a program before using
the optimizer. However, there are a number reasons why the ability to debug
optimized code is desirable:
• A program may run correctly when compiled without optimization and fail when
compiled with optimization. This can happen even if the optimizer is working correctly. For example, reordering statements may result in arithmetic overflow or
underflow. An uninitialized variable or an out-of-bounds memory reference might
cause a problem in the optimized version but not in the unoptimized version.
• The time or space requirements of an unoptimized program might be too big to
allow adequate testing.
• Production code is often optimized. A customer may submit a bug report with a
core file produced from an optimized program. It would be desirable to have the
ability to analyze the core file.
• Optimizing compilers can be written more easily with good tools for debugging
optimized code.
• The compiler may not have the ability to generate unoptimized code.
• The programmer may have mistakenly supplied explicit assertions, directives, or
options that caused the optimizing compiler to generate incorrect code.
• Optimizing compilers may have bugs.
28,!.+ 3 !+$ -# /1.&1 , ,.-(3.1 , - &$,$-3 '$ , - &:
$12 /$1%.1, ./$1 3(.-2 3' 3 1$ 2/$"(%(" 3. &(5$- , "'(-$
+ -&4 &$ ".,/(+$1 .1 42$1 (-3$1% "$ "' , - &$1 ' 2 (-3$1% "$ 2/$"(%(" 3(.- 3' 3 #$%(-$2 3'$ ./$1 3(.-2 / 13("4+ 1
, - &$1 2'.4+# /1.5(#$ , - &$1 (2 %.1, ++8 #$%(-$# 2
-8 /($"$ .% 2.%36 1$ 3' 3 ".11$"3+8 (,/+$,$-32 3'$ %4-"3(.-2
#$%(-$# (- 3'$ (-3$1% "$ 2/$"(%(" 3(.-
'$ , (- #$!4&&$1 +2. ' 2 2$3 .% %4-"3(.-2 " ++$# 3' 3 , - &$12 " - (-5.*$ 3. .!3 (- (-%.1, 3(.%1., 3'$ , (- #$!4&&$1 2 3'$ , (- #$!4&&$1 2 3(2%($2
42$1 ".,, -# (3 " - " ++ .- 3'$ 5 1(.42 , - &$12 3. /$1:
%.1, ./$1 3(.-2 /1.5(#$# !8 / 13("4+ 1 , - &$1 -# 6'(+$
, - &$1 (2 2 3(2%8(-& 1$04$23 %1., 3'$ , (- #$!4&&$1 (3
" - 1$04$23 (-%.1, 3(.- %1., 3'$ , (- #$!4&&$1 3'1.4&'
" ++! "* %4-"3(.-
- &$12 #. -.3 ".,,4-(" 3$ 6(3' .-$ -.3'$1 !$" 42$ (2 2314"341$# 2. 3' 3 (3 2'.4+# -.3 !$ -$"$22 18 '(2
231("3 / 13(3(.-(-& ++.62 #$5$+./$1 3. /.13 -# 1$3 1&$3
, - &$1 .1 #$5$+./ -$6 , - &$1 2 -$"$22 18 6(3'.43
,.#(%8(-& .3'$1 , - &$12 .1 3'$ , (- #$!4&&$1
- 3'$ , (- #$!4&&$1 -# , - &$12 /+ 3%.1,:2/$"(%(" 2823$,
" ++2 1$ 5.(#$# $7"$/3 (- 3'$ +.6$23:+$5$+ / 132 .% 3'$ , -:
&$12 .6$5$1 2823$,:2/$"(%(" " ++2 1$ &$-$1 ++8 -$$#$#
2. 6$ ' 5$ (,/+$,$-3$# 2$3 .% &$-$1 +:/41/.2$ 43(+(3($2
/ 13 .% 6'("' " - !$ "423.,(9$# %.1 3'$ 3 1&$3 /+ 3%.1,
$"$,!$1 $6+$33: "* 1# .41- +
Download