© 1998 IRISA / INRIA - University of Rennes 1 Version 1.194

Tempo Specializer - FAQ



MAIN  TUTOR  USER  REF  INSTALL  FAQ  LIMIT  BUGS  SUPPORT  SML  SUIF  DEMO  CONTRIB

Goal and conventions

The Tempo FAQ will keep track of the Frequently Asked Questions from Tempo developers and users.

We follow the convention that unless specified otherwise, all references below can be found in the User Manual, except references marked "Variable:" and "File:", which can be found in the Reference Manual.


The Tempo top level

What does the "=" prompt mean?

In the SML top level, every command has to be terminated with a semicolon. "=" indicates that the semicolon was not provided.

When I run the tempo command, nothing happens.

The tempo SML command requires three arguments, the name of the file (without the .c extension), the name of the starting phase, and the name of the ending phase. Because the tempo function is curried, if you leave off one of the arguments, a partially-applied function is returned.
See also: The SML Top Level, Using SML commands

What files are needed at minimum to specialize a program?

The C source file (file.c) and the SML file containing configuration information (file.config.sml). The specialization context file initializing the static parameters of the program (file.sctx.c) is needed for compile-time specialization. The SML file containing configuration information must at least define the entry_point variable.
See also: Specifying the Program to Specialize
Entry Point and Binding Times For Its Arguments
Variable: entry_point
File: .c
File: .config.sml
File: .sctx.c

Why doesn't ~ work to specify the path of a file or directory?

This is currently a feature of Tempo. Use the complete path name when changing directories. When you are in the directory of the program to specialize, just the file name is sufficient.
See also: Specifying the Program to Specialize

How can I specify an include path for the analysis phase and for the specialization phase?

Any flags can be provided to Suif (the parser used for the analyses) using the scc_flags variable. Any flags can be added to the compilation of the specializer using the ctcg_cflags variable.
See also: Variable: scc_cflags
Variable: porky_flags
Variable: ctcg_cflags

How can I set my preferences (e.g. viewer := html rather than emacs) once and for all rather than explicitly at each Tempo session?

Create a file named .tempo.sml in your home directory (that is the full name, not just an file extension); it will be loaded each time you run the the tempo top level.
See also: File: .tempo.sml

How do I get out of Tempo?

Type control-D (i.e. end-of-file character).

Properties of global variables

What are the initial binding times of global variables?

Uninitialized global variables are dynamic by default. Initialized global variables are static by default. Global variables can be declared static explicitly using the static_locations variable.
See also: Binding Time of Global Variables
Variable: static_locations

What are the initial alias properties of global variables?

By default, it is assumed that there are no alias relationships among global variables. Aliases can be specified using the set_analysis_context() function in the .actx.c file.
See also: Specifying Complex Analysis Contexts
File: .actx.c

Properties of parameters and local variables

Why does a local variable have bottom binding time?

A local variable has binding time bottom until it is assigned.
See also: Colored Files

When does a parameter become a local variable?

If a parameter value is static and its address is used at runtime, the parameter is suppressed and a local variable is allocated. Take for example the following program:
void proc2(int *p)
{
  show(p);
}

void proc1(int c)
{
  proc2(&c);
}

void entry()
{
  proc1(1);
}
Here, show() is an external function: it can not be called at specialization time. There is no .actx.c file, so by default this function does not access the value stored at its parameter address.

The value of c is static. So the parameter c could be suppressed. On the other hand, the address of c is dynamic. So the parameter c should be residualized. In order to reconcile both aspects, the parameter c is suppressed and a local variable c is introduced in proc1() (where its address is needed). The specialized code looks like:

static void proc2(int *p)
  {
    show(p);
  }

static void proc1()
  {
    int c;

    proc2(&c);
  }

extern void entry()
  {
    proc1();
  }
See also: Evaluation-time analysis (1)   (Reference Manual)
Evaluation-time analysis (2)   (Reference Manual)

Properties of array cells and structure and union fields

After the assignment a[3] = 0, why is a[3] still dynamic?

In Tempo, all array cells have the same binding time. Thus if any cell is dynamic, they are all dynamic, even after a static assignment to a particular cell.
See also: Array Monovariance
Binding Time of Arrays
Composite Locations and Binding Times

After the assignment s.x = 0, why is s.x still dynamic?

In Tempo, there is only one binding time description for all instances of a structure or union of a given type. Because just assigning the field of one instance to a static value does not ensure that the corresponding field of all instances has a static value, the binding time remains dynamic.
See also: Structure Monovariance
Binding Time of Structures and Unions
Composite Locations and Binding Times

Even though there is no assignment of an array cell (or structure or union field) to a dynamic value, why are all the array cells (or structure or union fields) dynamic?

In Tempo, all locations are considered dynamic, unless specified otherwise (except initialized scalar variables). This includes the content of arrays and the fields of structures and unions.
See also: Variable: static_locations
Binding Time of Global Variables
Binding Time of Arrays
Binding Time of Structures and Unions

Where does the __tmp_struct1 structure type come from?

SUIF introduces names of this form when an anonymous structure type is defined in the program. It is not safe to rely on Suif to choose a particular name for a particular structure.
See also: Anonymous Structures or Unions

If s is the name of a structure with field x , why isn't s.x a valid entry in the list static_locations ?

The entry in the static_locations list uses the type name rather than the name of a particular instance, because of structure monovariance.
See also: Structure Monovariance
Binding Time of Structures and Unions

If str is the name of a structure type declared using typedef, why isn't str.x a valid entry in the list static_locations ?

Typedefs are eliminated by Suif. The entry for a structure or union field in the static_locations list has to be the name of the structure or union type, followed by "dot", followed by the name of the desired field.
See also: Restrictions on Typedef
Binding Time of Structures and Unions
Variable: static_locations

If str is the type of a structure or union, and x is a field of str having structure or union type, why is it an error to include str.x in the list static_locations ?

Structures as a whole do not have a static binding time. Instead, the individual fields should be specified to be static.
See also: Locations
Nested Structures and Unions

Specialization of a module

Tempo may be applied to only part of a complete application. In this situation it may be necessary to specify extra information about the context in which the specialized code will be invoked, about functions called from the code to specialized, and about the context following the invocation of the specialized code. Furthermore, the specialized code needs to be reintegrated into the application.


Calling context

How can the binding times of values pointed to by global variables or entry-point parameters be specified?

By default, pointed values have the same binding time as the pointer. A different binding time can be specified using the set_analysis_context() function in the .actx.c file.
See also: Specifying Complex Analysis Contexts
Binding Times of Parameters Passed By Reference
File: .actx.c

How can alias relationships among global variables or entry-point parameters be specified?

Aliases can be specified using the set_analysis_context() function in the .actx.c file.
See also: Specifying Complex Analysis Contexts
Initial Alias Relation
File: .actx.c

Returning context

The code to be specialized contains a static assignment to a global variable. When the variable is used in the application after the specialized code is called, how can I force the assignment to be residualized?

The variable live_locations allows one to specify what locations are used in the application after the call to the specialized code. More complex relationships can be specified using the set_post_analysis_context() function in the .actx.c file.
See also: Live Locations After The Entry Point
Variable: live_locations
Specifying Complex Analysis Contexts
File: .actx.c

External functions

When are external function calls residualized?

An external function call is residualized when any of the arguments are dynamic. An external function call is also residualized when the external_functions variable is set to a RESIDUALIZE list including the name of the function, or when the external_functions variable is set to an EVALUATE list not including the name of the function. By default, all external functions are residualized.
See also: Variable: external_functions
Binding Time of External Function Calls
Variable: residualize_all_icalls
Binding Time of External Indirect Function Calls

When are external function calls evaluated?

An external function call is never evaluated when any of the arguments are dynamic. When all of the arguments are static, an external function call is evaluated if the external_functions variable is set to an EVALUATE list including the name of the function, or when the external_functions variable is set to a RESIDUALIZE list not including the name of the function. Note that the decision whether all the arguments are static depends on just the argument values, not on values the arguments may point to.
See also: Variable: external_functions
Binding Time of External Function Calls
Variable: residualize_all_icalls
Binding Time of External Indirect Function Calls

How is the definition of an evaluated external function obtained?

Evaluated external functions have to be linked in with the specializer. Libraries and files defining external functions can be specified using the ctcg_ldlibs variable.
See also: Variable: ctcg_ldlibs

How can the effect of an external function on binding times be specified?

By default, an external call is assumed to have no effect on binding times. Binding-time effects can be specified using an abstract definition of the function in the .actx.c file.
See also: Abstract Function
Behavior of External Functions

How can the effect of an external function on aliases be specified?

By default, an external call is assumed to have no effect on aliases. Alias effects can be specified using an abstract definition of the function in the .actx.c file.
See also: Abstract Function
Behavior of External Functions

How can a location be made static in the .actx.c file?

A location can be made static by just assigning it to a constant, or to a global variable declared in the .actx.c file and specified as static using the static_locations variable.
See also: Variable: static_locations
Dummy Static Location

How can a location be made dynamic in the .actx.c file?

A location can be made dynamic just assigning it to a global variable declared in the .actx.c file or by assigning it to the result of a residualized external function call.
See also: Dummy Dynamic Location

How can aliases be described in the .actx.c file?

Alias relationships between variables can be described using the addresses of variables declared in the .actx.c file. A collection of aliases for a single location can be specified using a sequence of if statements.
See also: Initial Alias Relation
Pointer to a Set of Locations

How can memory allocation by external functions be modeled?

Memory allocation can be modeled by defining an abstract function that returns a pointer to some data structure defined in the .actx.c file.
See also: Named Memory Cells
Modeling Dynamic Memory Allocation
Limitations concerning casts   (Limitations)

Global variables

During specialization, variables declared in the specialized program don't seem to communicate with variables declared in the rest of the application.

In the current implementation of the specializer, global names are renamed during specialization. This can cause problems if they are are referenced externally during specialization, because references in already-compiled code will not be renamed appropriately. A solution is to include the .sctx.h file in all of the files of the application, and recompile the entire application at specialization time, rather than using existing .o files.
See also: Identifier Naming In Compile-Time Specialization   (Limitations)
File: .sctx.h

The names of the specialized functions

Will the names of specialized functions conflict with the names of existing functions in the original application?

All specialized functions except the specialized entry point are declared as static, so they are not visible from any other file.
See also: Specifying Several Entry Points

What is the name of the specialized entry point?

A fresh name is chosen for the specialized entry point by default. The name can be specified using the variable specialized_entry_point_name.
See also: Specifying Several Entry Points
Variable: specialized_entry_point_name

Running the Analysis

My analysis takes a lot of time to compute? Do I have to always re-run it from scratch?

As long as your source files (".c" and ".actx.c") and configuration file (".config.sml") do not change, you can always restart from some already generated intermediate file (suffixed ".as") The an command runs the whole sequence of analysis phases, starting from the C files. But you may use the tempo top-level command to run only a fraction of thoses analyses.
See also: Command: tempo
Variable: output_mode

Compile-time specialization

How are the values of the static parameters and globals provided before specialization?

Static variables are initialized using the .sctx.c file
See also: Compile-Time Specialization
File: .sctx.c

Why are there unbound variables when compiling the .sctx.c file?

Tempo changes the names of some variables. Thus, the .sctx.c file must #include the .sctx.h to perform the renaming.
See also: Compile-Time Specialization
File: .sctx.h

What does it mean when the specializer just sits there, doing nothing?

Perhaps your program is in an infinite loop (see also Static Loops Containing Dynamic Exits in the Known Bugs collection), or perhaps there is too much specialization being performed. If a single static value varies a lot, you may end up creating many very similar specialized functions. In this case it may be useful to make some static values dynamic, to perform less specialization.
See also: Turn a Location Dynamic

What does it mean when there is a lot of garbage collection during specialization?

Once you see messages about garbage collection, specialization has successfully completed, and Tempo is performing postprocessing. Probably your specialized program is just very large. In this case it may be useful to make some static values dynamic, to perform less specialization.
See also: Turn a Location Dynamic

What does it mean if my static parameters are initialized to zero or to some strange random values?

Initialization of the static parameters is specified by a user-written function set_specialization_context() in a file suffixed .sctx.c . A common error is to set the local variables of this function, not their pointer values (i.e. not the static arguments of the entry point).
See also: Invocation of a Compile-Time Specializer
Common Errors in Setting Specialization Contexts

What does it mean if there is a bus error, segmentation fault, or illegal instruction error during specialization?

If the error does not come rapidly when specialization starts, it may mean that the specialized code has exceeded the allocated buffer size. A larger buffer can be requested using the explicit_cts_bufsize variable.

If the error comes rapidly when specialization starts, it is likely that some data structure is not properly initialized (see Common Errors in Setting Specialization Contexts). Alternatively, there may be an error in your program. You can use the debugger gdb by compiling the specializer files with the -g option (specified by adding -g to the value of ctcg_cflags). Errors are likely to occur in the .ev.c file. Each function in this file contains a comment indicating the name of the function in the source program that it comes from.

See also: Common Errors in Setting Specialization Contexts
Variable: explicit_cts_bufsize
Variable: ctcg_cflags
File: .ev.c

How can I see the result of the specialization before post-processing?

The result of raw specialization is dumped into the file.rawcts.as file. It is not turned into C text by default as it is post-processed right away. To view it as C text, type this command at the top level.
as2c "file.rawcts.as";

The corresponding file.rawcts.c will be generated in the working directory. Alternatively, you may also set variable output_mode.

See also: Command: as2c   (generation of C text from abstract syntax format)
Variable: output_mode   (control of the intermediate files to generate)

Is there any way to specify that a single function should always be inlined and no other function should ever be inlined, without saying do_not_inline and listing the names of all the functions?

The SML variable post_do_inline is bound to a list of functions that must be inlined. The SML variable post_do_not_inline is bound to a list of functions that must not be inlined. But setting post_do_inline to a list of function names does not does not mean that no other functions will be inlined. Similarly setting post_do_not_inline to a list of function names does not mean that all other functions will be inlined. Instead the inlining of functions is controlled by the variables post_inlining_max_nb_stmts and post_inlining_max_nb_calls . These integer variables are the thresholds at which to stop inlining functions not explicitly included in the post_do_inline list. Thus to inline the function "foo", but no other functions, set the flags as follows:
post_inlining := true;
post_do_inline := ["foo"];
post_inlining_max_nb_stmts := 0;
post_inlining_max_nb_calls := 0;
Note that no inlining happens, regardless of the value of post_do_inline if post_inlining is set to false.

If you want the calls within "foo" to be inlined as well, use the following settings:

post_inlining := true;
post_do_inline := ["foo"];
post_start_inlining_func := ["foo"];

Variable start_inlining_func specifies the function at which inlining begins. Function calls not directly or indirectly within these functions are not inlined. inlining, and stops any functions outside the branch of the function(s) specified from being inlined.
See also: Post-processing
Variable: post_do_inline
Variable: post_do_not_inline
Variable: post_inlining
Variable: post_inlining_max_nb_calls
Variable: post_inlining_max_nb_stmts
Variable: post_inlining_mode
Variable: post_inlining_renaming
Variable: post_start_inlining_func


Run-time specialization

Once the run-time specializer is created, how is it used in the application?

The run-time specializer is invoked with the list of values for the static arguments. The result is a pointer to a specialized function that takes as inputs the values of the rest of the arguments.
See also: Invocation of a Run-Time Specializer

The run-time specializer is generated in an architecture-dependent directory; how do I know its name, how can I change it?

All architecture-dependent files are generated, starting from in the working directory, in a sub-directory given by variable arch_dep_dir. If you want it to be written in the working directory instead, you may assign arch_dep_dir to ".".
See also: Variable: arch_dep_dir

How can multiple specializations of a single function be created?

By default, the run-time specializer allocate new buffer space each time the specializer is called and for each function. Other buffer manipulation strategies can be implemented by the user. The reentrant flag can be set to false to instruct the specializer to use a single buffer to store the specialized code. Subsequent specializations overwrite previous specializations.
See also: Recursive and Multiple Run-Time Specializations
Variable: reentrant_rts

What does a segmentation fault during run-time specialization mean?

If the segmentation fault occurs during specialization, as opposed to when running the specialized program, the problem might be that the program is recursive. If the program is recursive, the reentrant_rts flag must be set to true.
See also: Recursive and Multiple Run-Time Specializations
Variable: reentrant_rts

Visualization

Why does emacs give an error when loading color files?

There is a problem with the enriched mode of emacs version 19.34. A patch is available, as described in the installation manual.
See also: Emacs installation issues   (Installation Manual)

Why are some of the color annotations missing when viewing the color files under emacs?

There is a problem with the enriched mode of emacs version 19.34. A patch is available, as described in the installation manual.
See also: Emacs installation issues   (Installation Manual)

Why are lines being wrapped when viewing color files under emacs?

The enriched mode of emacs will sometimes automatically perform filling at a specific width. The solution is to turn off filling, as described in the installation manual.
See also: Emacs installation issues   (Installation Manual)

Why does my color file have lots of strange annotation when I view it under emacs?

The enriched mode of emacs will sometimes fail to display the file. Reloading the file normally solves the problem.

Why don't the color files look like the source program?

Several transformations are performed on the source program by Suif and by Tempo. For example, Suif breaks up complex conditions, rewrites all pointer dereferences to apply to a single variable, and rewrites all loops as do-while loops. Early phases of Tempo eliminate gotos and indirect function calls.
See also: Parsing   (Reference Manual)
Indirect call elimination   (Reference Manual)
Goto elimination   (Reference Manual)
Anonymous Structures or Unions
Display of Alias information
Pointers to Strings and Arrays

How can I get rid of all the comments in the color files?

Alias comments can be eliminated by setting verbose_aliases variable to false. Function-header comments can be eliminated by setting verbose_headers variable to false.
See also: Variable: verbose_aliases
Variable: verbose_headers
Variable: verbose_callsig
Variable: verbose_aliases_in_specializations

What do the colors mean?

There is a legend at the top that describes the meaning of each color.
See also: Visualization of Colored Files

What happened to the variable declarations?

If there are more global variable declarations than the threshold specified by the variable max_decls_size, the variable declarations are put in a .decl.h file.
See also: Variable: max_decls_size
File: .decl.h

How do I print a color file in emacs?

M-x ps-print-buffer-with-faces

Prints the current buffer on the current printer.

M-1 M-x ps-print-buffer-with-faces

Prompts for the name of a file where to save a postscript version (with colors) of the current buffer.

M-x eval-expression
(ps-print-buffer-with-faces "file.ps")

Saves a postscript version (with colors) of the current buffer into file.ps.


MAIN  TUTOR  USER  REF  INSTALL  FAQ  LIMIT  BUGS  SUPPORT  SML  SUIF  DEMO  CONTRIB


Last modified: Wed Jun 24 17:38:45 MET DST 1998