Chapter Contents

Previous

Next
Using the Global Optimizer and the Object Module Disassembler

The Global Optimizer

The global optimization phase optimizes the flow of control and data through an entire function. A wide variety of optimizations are performed, including the following:

Each of these topics is treated in detail in the SAS/C Compiler and Library User's Guide.


Global Optimization Compiler Options

The -O compiler option is used to enable global optimization. The following options alter the behavior of the global optimizer.

Global Optimizer Options
Option Description
-Gf n or -Kfreg= n
specifies the maximum number of floating-point registers (n= 0 through 2).
-Gv n or -Kgreg= n
specifies the maximum number of registers the optimizer can assign to register variables (n= 0 through 6).
-Oa or -Kalias
specifies that the global optimizer should assume worst-case aliasing.
-Oic= n or -Kcomplexity= n
specifies the maximum complexity that a function can have and remain eligible for default inlining.
-Oid= n or -Kdepth= n
specifies the maximum depth of functions to be inlined.
-Oil or -Kinlocal
inlines single-call, static functions.
-Oin or -Kinline
enables inlining during the optimization phase.
-Oir= n or -Krdepth= n
specifies the maximum level of recursion to be inlined.
-Ol or -Kloop
specifies that loop optimizations should be performed.

Each of these options is described in Compiling C and C++ Programs.


Global Optimization and the Debugger

The cross-platform compiler does not optimize programs when the -g option is used. To use all the capabilities of the SAS/C Debugger, there must be an accurate correspondence between object code and source line numbers, and optimizations can alter this correspondence. Also, the -g option causes the compiler to suppress allocation of variables to registers, so the resulting code is not completely optimal.

You can, however, use the -Kdbhook option along with the -O option to generate optimized object code that can be used with the debugger. The -Kdbhook option generates hooks in the object code that enable the debugger to gain control of an executing program.

When using the debugger with optimized object code that has been compiled with the -Kdbhook option, the source code is not displayed in the debugger's Source window and you cannot access variables. Therefore, the debugger's print command, and other commands, which are normally used with variables, are not used when debugging optimized code. However, source code line numbers are displayed in the Source window, providing an indication of your location in the code. You also have the capability of viewing register values in the debugger's Register window, and you can use commands such as step , goto , and runto to control the execution of your program. However, due to optimizations that affect register contents, the goto command may fail when debugging optimized code.

See Cross-Debugging for more information about using the SAS/C Debugger with the SAS/C Cross-Platform Compiler.


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.