Go to the previous, next section.

The Global Symbol Table

The global symbol table is at the top of the symbol table hierarchy and corresponds to the outermost global scope. It contains objects that are visible across source files (i.e. shared types and global symbols with external linkage). For this reason, it is associated with the file_set object. See section The File Set.

The advantage of using a shared global symbol table appears when performing interprocedural analyses and transformations. Without a common symbol table, it can be quite a burden to deal with references to symbols that are defined in some files but not in others. Even trying to determine which symbols from different files correspond to the same objects is difficult. In essence, each interprocedural pass would need to do the work of a linker! The shared global symbol table avoids all of these problems and makes interprocedural optimization relatively easy.

Along with the benefits of the global symbol table come a few difficulties. Sharing the global symbol table across files makes it difficult to support separate compilation. Each file must contain a copy of the global symbol table, and if these files are manipulated individually, their copies of the global symbol table will not be consistent. Thus, before a group of files can be combined in a SUIF file set, their global symbol tables must be "linked" together using the SUIF linker pass. Whether this is preferable to just combining all of the source files into one big SUIF file is debatable.

The global_symtab class is used to represent the global symbol table. It is also used as the base class for file symbol tables. Because procedure symbols may only be entered in global and file symbol tables, this class contains the methods to deal with them. The new_proc method creates a new procedure symbol and enters it in the table (see section Creating New Entries), and the lookup_proc method searches for an existing procedure symbol (see section Lookup Methods). The number_globals method in this class handles the task of assigning ID numbers to the symbols and types in global and file symbol tables (see section Numbering Types and Symbols).

Go to the previous, next section.