[go: up one dir, main page]

JP2002099425A - How to convert global variables to local variables - Google Patents

How to convert global variables to local variables

Info

Publication number
JP2002099425A
JP2002099425A JP2000295438A JP2000295438A JP2002099425A JP 2002099425 A JP2002099425 A JP 2002099425A JP 2000295438 A JP2000295438 A JP 2000295438A JP 2000295438 A JP2000295438 A JP 2000295438A JP 2002099425 A JP2002099425 A JP 2002099425A
Authority
JP
Japan
Prior art keywords
function
variable
global
global variable
conversion
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
JP2000295438A
Other languages
Japanese (ja)
Inventor
Eiichiro Sendai
英一郎 千代
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hitachi Ltd
Original Assignee
Hitachi Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hitachi Ltd filed Critical Hitachi Ltd
Priority to JP2000295438A priority Critical patent/JP2002099425A/en
Publication of JP2002099425A publication Critical patent/JP2002099425A/en
Pending legal-status Critical Current

Links

Landscapes

  • Devices For Executing Special Programs (AREA)

Abstract

(57)【要約】 【課題】関数呼び出しをまたがって存在するグローバル
変数の使用における冗長なメモリ参照を削除する。 【解決手段】グローバル変数のローカル変数変換を行う
コンパイラにおいて、変換対象領域内に関数呼び出しが
存在し、呼び出し先の関数内でグローバル変数が使用さ
れている場合に、呼び出し先の関数に対して、該グロー
バル変数に対応する引数を追加し、該関数内の該グロー
バル変数の使用を、追加した引数の使用に置き換えた関
数を新たに作成し、呼び出し元では新たに作成した関数
を呼び出すようにする。
(57) [Summary] [PROBLEMS] To eliminate redundant memory references in use of global variables existing across function calls. In a compiler that performs local variable conversion of a global variable, if a function call exists in a conversion target area and a global variable is used in a callee function, the compiler calls the function of the callee. An argument corresponding to the global variable is added, and a function in which the use of the global variable in the function is replaced by the use of the added argument is newly created, and the caller calls the newly created function. .

Description

【発明の詳細な説明】DETAILED DESCRIPTION OF THE INVENTION

【0001】[0001]

【発明の属する技術分野】本発明は、計算機の利用技術
において、オブジェクトプログラムの実行時間を削減す
るコンパイル方法に関する。特に、グローバル変数の参
照をローカル変数の参照に置き換えることにより、実行
されるメモリ参照命令数を削減するプログラム変換方法
に関する。
[0001] 1. Field of the Invention [0002] The present invention relates to a compiling method for reducing the execution time of an object program in a computer utilization technique. In particular, the present invention relates to a program conversion method for reducing the number of executed memory reference instructions by replacing global variable references with local variable references.

【0002】[0002]

【従来の技術】命令レベルの並列度や動作周波数の向上
によってマイクロプロセッサの性能は飛躍的に向上して
いる。これに対して計算機の主記憶を構成するDRAM
(Dynamic RAM)の性能向上はプロセッサ性
能向上に比べて低いレベルにとどまっており、メモリ参
照に要するサイクル数は増加を続ける傾向にある。コン
パイラはメモリ参照の回数を減らすため、レジスタ割付
け手法を用いて、プログラム中で複数回参照(定義もし
くは使用)される変数は可能な限りレジスタに置くよう
にする。だが、複数の参照の間に関数呼び出しがある
と、グローバル変数のように呼び出し先で参照される可
能性のある変数は、値が定義されていれば呼び出し前に
メモリへのストアが必要となり、呼び出し後に使用する
場合には再びロードが必要となる。
2. Description of the Related Art The performance of microprocessors has been dramatically improved by improving the parallelism at the instruction level and the operating frequency. On the other hand, DRAM which constitutes the main memory of the computer
(Dynamic RAM) performance improvement is at a lower level than processor performance improvement, and the number of cycles required for memory reference tends to continue to increase. To reduce the number of memory references, the compiler uses register allocation techniques to place variables that are referenced (defined or used) multiple times in a program in registers whenever possible. However, if there is a function call between multiple references, variables that may be referred to by the callee, such as global variables, need to be stored in memory before the call if their values are defined, If it is used after the call, it must be loaded again.

【0003】たとえば図8(a)に示すような、条件付
きで行われる関数呼び出しの前後にグローバル変数Gの
参照が存在するプログラムがあった場合、そのままでは
文806でGの値のメモリへのストアを行い、文811
でGの値のロードを行うオブジェクトコードが生成され
る。だが文807における条件判定の結果、関数fの呼
び出しが発生しなかった場合にはこれらのストア、ロー
ドは不要である。こういう場合に、たとえば文献「A.
V.S.Sastry他,A New Algorith
m for Scalar Register Promo
tion Based on SSA Form,Proc
eedings of the ACMSIGPLAN ’
98 Conference on Programmi
ngLanguage Design and Impl
ementation, pp.15−25,199
8」に示されているように、グローバル変数と同じ型の
ローカル変数を用意し、グローバル変数の参照をローカ
ル変数の参照に置き換え、必要な個所でのみグローバル
変数とローカル変数の間の値の一貫性を取る処理を行う
ようにプログラムを変換することで、冗長なメモリ参照
を削除する手法が検討されている。
For example, if there is a program in which a reference to a global variable G exists before and after a function call performed conditionally as shown in FIG. 8A, a statement 806 stores the value of G in a memory as it is. Perform store, sentence 811
Generates an object code for loading the value of G. However, if the result of the condition determination in the statement 807 indicates that no call to the function f has occurred, these stores and loads are unnecessary. In such a case, for example, the document “A.
V. S. Sastry et al., A New Algorithm
m for Scalar Register Promo
Tion Based on SSA Form, Proc
eatings of the ACMSGPLAN ''
98 Conference on Programmi
ngLanguage Design and Impl
emmentation, pp. 15-25, 199
8), prepare a local variable of the same type as the global variable, replace the reference of the global variable with the reference of the local variable, and make the value consistent between the global variable and the local variable only where necessary. A method of removing a redundant memory reference by converting a program so as to perform a process that takes responsiveness is being studied.

【0004】この手法を適用すると図8(a)のプログ
ラムは図8(b)のように変換され、文820の条件判
定が不成立のため関数呼び出しが起こらなかった場合に
はGの値の再ロードは行われなくなるため、プログラム
実行が高速化される。
When this method is applied, the program in FIG. 8A is converted as shown in FIG. 8B, and if the function call does not occur because the condition determination of the statement 820 is not satisfied, the value of G is reset. Since the loading is not performed, the program execution speeds up.

【0005】[0005]

【発明が解決しようとする課題】上記論文に示されてい
るグローバル変数のローカル変数変換手法によって、呼
び出し元関数内に含まれるグローバル変数の冗長なメモ
リ参照は削除されるが、呼び出し先関数内で該グローバ
ル変数の参照がある場合は考慮されておらず、冗長なメ
モリ参照が削除できなかった。たとえば図6(a)では
文607から610にまたがるループ内で、グローバル
変数Gの使用を含む関数trimを複数回に渡って呼び
出している。ループ実行の際には、trimの呼び出し
毎に文616におけるGの使用に対するメモリ参照(ロ
ード)が生じることになるが、従来の手法ではこのよう
な関数呼び出しにまたがって存在する冗長なメモリ参照
を取り扱うことはできなかった。
According to the local variable conversion method of global variables shown in the above-mentioned paper, redundant memory references of global variables included in a caller function are deleted, but in a callee function, The case where there is a reference to the global variable is not considered, and the redundant memory reference could not be deleted. For example, in FIG. 6A, the function trim including the use of the global variable G is called a plurality of times in a loop extending from the statements 607 to 610. At the time of loop execution, a memory reference (load) to the use of G in the statement 616 occurs every time the trim is called. In the conventional method, a redundant memory reference existing over such a function call is used. I couldn't handle it.

【0006】本発明の目的は、関数呼び出しをまたがっ
て存在するグローバル変数の使用における冗長なメモリ
参照を削除する方法を与えることにある。
[0006] It is an object of the present invention to provide a method for eliminating redundant memory references in the use of global variables that exist across function calls.

【0007】[0007]

【課題を解決するための手段】前記目的を達成するた
め、本発明では、グローバル変数のローカル変数変換を
適用しようとする領域内に関数呼び出しが存在し、かつ
ローカル変数変換しようとしているグローバル変数が呼
び出し先で使用されている場合に、呼び出し先における
そのグローバル変数の使用を新たに引数を追加すること
で除去(これを引数変換と称する)した後にローカル変
数変換を行う。
In order to achieve the above object, according to the present invention, a function call exists in an area where a local variable conversion of a global variable is to be applied, and the global variable to be converted into a local variable is If used by the callee, local variable conversion is performed after the use of the global variable at the callee is removed by adding a new argument (this is referred to as argument conversion).

【0008】引数変換では、変換対象の関数およびグロ
ーバル変数に対して、グローバル変数と同じ型の引数を
関数に追加し、関数内にあるグローバル変数の使用をそ
の引数の使用に置き換えた関数を新たに作成する処理を
行う。それに合わせて、呼び出し元のコールサイトの方
は、対応するグローバル変数を引数に追加し、新たに作
成した関数を呼び出すように変更する。
In the argument conversion, for a function and a global variable to be converted, an argument of the same type as the global variable is added to the function, and a function in which the use of the global variable in the function is replaced with the use of the argument is newly added. Perform the process of creating. At the same time, the call site of the caller adds a corresponding global variable to the argument and changes the call site to call the newly created function.

【0009】この変換を行うことで、呼び出し先の関数
内に存在するグローバル変数の使用は呼び出し元の方に
引数として移動することになる。これにより、関数呼び
出しにまたがって存在するグローバル変数の使用は、従
来の関数内におけるグローバル変数のローカル変数変換
の対象となり、冗長なメモリ参照は削除することが可能
となる。
By performing this conversion, the use of the global variable existing in the callee function is moved to the caller as an argument. As a result, the use of a global variable existing over a function call becomes a target of local variable conversion of the global variable in the conventional function, and redundant memory reference can be deleted.

【0010】[0010]

【発明の実施の形態】以下、本発明の一実施例を説明す
る。
DESCRIPTION OF THE PREFERRED EMBODIMENTS One embodiment of the present invention will be described below.

【0011】図1は本発明によるコンパイラが稼動する
計算機システムの構成図である。図示するように、計算
機システムはCPU101、主記憶装置104、外部記
憶装置105、ディスプレイ装置102、キーボード1
03より構成されている。外部記憶装置105にはソー
スプログラム106、オブジェクトプログラム107が
格納される。主記憶装置104には、コンパイラ108
と、コンパイル処理過程で必要となる中間コード10
9、変数参照表110および引数変換表111が保持さ
れる。コンパイル処理はCPU101がコンパイラプロ
グラム108を実行することにより行われる。キーボー
ド103はユーザからのコマンドをコンパイラ108に
与えるのに用いる。ディスプレイ装置102はコンパイ
ルの終了またはエラーをユーザに知らせる。
FIG. 1 is a configuration diagram of a computer system on which a compiler according to the present invention operates. As shown, the computer system includes a CPU 101, a main storage device 104, an external storage device 105, a display device 102, a keyboard 1
03. The external storage device 105 stores a source program 106 and an object program 107. The main storage device 104 includes a compiler 108
And the intermediate code 10 required in the compilation process
9. The variable reference table 110 and the argument conversion table 111 are held. The compiling process is performed by the CPU 101 executing the compiler program 108. The keyboard 103 is used to give commands from the user to the compiler 108. The display device 102 informs the user of the end of compilation or an error.

【0012】図2はコンパイル処理の流れを示したフロ
ーチャートである。コンパイラの処理は、まずステップ
201で、構文解析を行う。構文解析はソースプログラ
ム106を読み出し、コンパイラ内部で処理可能な中間
コード109を作成する。構文解析処理については、た
とえば「エイホ、セシィ、ウルマン著:コンパイラI
(サイエンス社、1990年)30頁〜74頁」に記載
されている。次にステップ202で、変数参照解析を行
う。変数参照解析についても「エイホ、セシィ、ウルマ
ン著:コンパイラII(サイエンス社、1990年)74
1頁〜 772頁」に記載がある。変数参照解析によ
り、プログラムに含まれる各文において参照される変数
の集合および参照の種類(定義、使用)が求められ、こ
れが変数参照表110に記録される。次にステップ20
3で、未処理の関数があるか調べる。なければステップ
206へ進み、オブジェクトコードを生成して終了す
る。オブジェクトコード生成については、同じく「エイ
ホ、セシィ、ウルマン著:コンパイラII(サイエンス
社、1990年)624頁〜707頁」に記載がある。
未処理の関数があればステップ204で関数を1つ取り
出す(nとする)。そしてステップ205で、n中のグ
ローバル変数に対してグローバル変数のローカル変数変
換処理を行う。この処理については図3〜5を用いてさ
らに詳しく説明する。この処理の後はステップ203か
ら繰り返す。
FIG. 2 is a flowchart showing the flow of the compiling process. In the processing of the compiler, first, in step 201, syntax analysis is performed. The syntax analysis reads the source program 106 and creates an intermediate code 109 that can be processed inside the compiler. For the syntax analysis processing, see, for example, "Eiho, Seshi, Ullman: Compiler I
(Science, 1990) pages 30-74 ". Next, in step 202, a variable reference analysis is performed. Regarding variable reference analysis, see “Aho, Seshi and Ullman: Compiler II (Science, 1990) 74
Pages 1 to 772 ". By the variable reference analysis, a set of variables referred to in each statement included in the program and a type of reference (definition, use) are obtained, and these are recorded in the variable reference table 110. Then step 20
At 3, check whether there is any unprocessed function. If not, proceed to step 206, generate an object code, and end. The object code generation is also described in “Eiho, Seshii and Ullman: Compiler II (Science Inc., 1990), pp. 624-707”.
If there is an unprocessed function, one function is extracted in step 204 (assumed to be n). Then, in step 205, a global variable local variable conversion process is performed on the global variables in n. This processing will be described in more detail with reference to FIGS. After this processing, the processing is repeated from step 203.

【0013】図3はステップ205の処理の流れを詳し
く示した図である。ここでは与えられた関数nから呼び
出される関数のうち必要なものについてはグローバル変
数の引数変換を行った後、n内のグローバル変数に対し
てローカル変数変換処理を行う。
FIG. 3 is a diagram showing the flow of the processing of step 205 in detail. Here, among the functions called from the given function n, necessary variables are subjected to global variable argument conversion, and then local variable conversion processing is performed on the global variables in n.

【0014】まずステップ301で関数nが呼び出す関
数のうち、引数変換が必要な関数と変換するグローバル
変数を求める。結果は引数変換表111に記録する。こ
の処理については図4を用いて後で詳しく説明する。ス
テップ302では引数変換表111に登録された関数の
うち未処理のものがあるか調べ、なければステップ30
6へ進む。あればステップ303でその関数を1つ取り
出す(それをfとする)。ステップ304ではfに対し
て引数変換を行い、新しく関数を作成する(それをf2
とする)。この処理については図5を用いて後で詳しく
説明する。ステップ305では引数変換表111に登録
されているfのコールサイトを、f2を呼び出すように
修正し、引数変換を行ったグローバル変数を引数として
追加する。最後にステップ306でグローバル変数のロ
ーカル変数変換を行う。ステップ306は従来技術であ
る。
First, in step 301, among the functions called by the function n, a function requiring argument conversion and a global variable to be converted are obtained. The result is recorded in the argument conversion table 111. This processing will be described later in detail with reference to FIG. In step 302, it is checked whether there is an unprocessed function among the functions registered in the argument conversion table 111.
Proceed to 6. If there is, at step 303, one of the functions is taken out (this is taken as f). In step 304, argument conversion is performed on f, and a new function is created (this is referred to as f2
And). This processing will be described later in detail with reference to FIG. In step 305, the call site of f registered in the argument conversion table 111 is modified so as to call f2, and the converted global variable is added as an argument. Finally, in step 306, local variables are converted from global variables. Step 306 is conventional.

【0015】図4はステップ301の処理の流れを詳し
く示した図である。ステップ401では関数nから呼び
出されているすべての関数について、使用されているグ
ローバル変数の集合を変数参照表110から調べ、その
和集合を求める(それをuとする)。uは引数変換の候
補となるグローバル変数の集合である。ステップ402
ではu内のグローバル変数のうち未処理のものがあるか
調べ、なければ終了する。あればステップ403でその
グローバル変数を1つ取り出す(それをgとする)。ス
テップ404では関数n内のgの参照領域を求める(そ
れをrとする)。ここでgの参照領域とは、gを定義も
しくは使用する文の集合である。ただしコールサイトに
関しては、呼び出し先でgが定義もしくは使用される文
も参照領域に含める。ステップ405ではrに含まれる
文のうち未処理の文があるか調べ、なければステップ4
02に戻る。あればステップ406でその文を1つ取り
出す(それをsとする)。ステップ407ではsからの
実行パスのうち、rに含まれるコールサイトに到達する
ものが存在するかどうかを調べ、なければステップ40
5に戻る。あれば、sにおけるgの参照とそのコールサ
イトから呼び出す関数内におけるgの参照との間に冗長
なメモリ参照が生じ得る。そこでステップ408へ進
み、sから到達可能なr内のコールサイトのうち、呼び
出し先でgを使用し、かつ定義しないものについて、呼
び出し関数(f)、使用しているグローバル変数
(g)、コールサイトの組を引数変換表111へ登録
し、ステップ405に戻る。
FIG. 4 is a diagram showing the flow of the process of step 301 in detail. In step 401, for all functions called from the function n, a set of used global variables is checked from the variable reference table 110, and the union thereof is obtained (let it be u). u is a set of global variables that are candidates for argument conversion. Step 402
Then, it checks whether there is any unprocessed global variable in u, and terminates if not. If there is, at step 403, one of the global variables is taken out (it is set as g). In step 404, a reference area of g in the function n is obtained (let it be r). Here, the reference region of g is a set of sentences that define or use g. However, for the call site, the statement in which g is defined or used in the callee is also included in the reference area. In step 405, it is checked whether there is an unprocessed sentence among the sentences included in r.
Return to 02. If there is, at step 406, one sentence is extracted (let it be s). In step 407, it is checked whether or not any of the execution paths from s reaches the call site included in r.
Return to 5. If so, a redundant memory reference may occur between the reference to g in s and the reference to g in the function called from that call site. Then, the process proceeds to step 408. Among call sites in r that can be reached from s, those that use and do not define g at the call destination, call function (f), used global variable (g), call The set of sites is registered in the argument conversion table 111, and the process returns to step 405.

【0016】図5はステップ304の処理の流れを詳し
く示した図である。まずステップ501では関数fをク
ローニングし、新しく関数f2を作成する。ステップ5
02では引数変換表111に登録されている関数f内の
グローバル変数のうち未処理のものがあるか調べ、なけ
れば終了する。あればステップ503でそのグローバル
変数を1つ取り出す(それをgとする)。ステップ50
4では関数f2の引数としてgと同じ型を持つ変数を追
加する(それをg2とする)。ステップ505では関数
f2内のgの参照をg2の参照に置き換える。
FIG. 5 is a diagram showing in detail the flow of the process of step 304. First, in step 501, the function f is cloned, and a new function f2 is created. Step 5
In 02, it is checked whether there is any unprocessed global variable in the function f registered in the argument conversion table 111, and if not, the process ends. If there is, at step 503, one of the global variables is extracted (let it be g). Step 50
In step 4, a variable having the same type as g is added as an argument of the function f2 (this is referred to as g2). In step 505, the reference of g in the function f2 is replaced with the reference of g2.

【0017】続いて、本実施例の適用例を示す。入力と
して図6(a)のようなプログラムを考える。
Next, an application example of the present embodiment will be described. Consider a program as shown in FIG. 6A as an input.

【0018】図2のステップ202の変数参照解析によ
り、図6(b)のような変数参照表が作成される。グロ
ーバル変数に関しては、Gが関数trim中の文616
および617で使用されている。
A variable reference table as shown in FIG. 6B is created by the variable reference analysis in step 202 in FIG. For global variables, G is the statement 616 in the function trim.
And 617.

【0019】次にステップ204で未処理関数としてm
ainを取り出し、ステップ205でグローバル変数の
ローカル変数変換を行う。ステップ205を詳しくした
図3では、最初にステップ301で、main内から呼
び出されている関数のうち引数変換の対象となる関数お
よびグローバル変数を選択する。
Next, at step 204, m as an unprocessed function
ain is extracted, and in step 205, local variables are converted into global variables. In FIG. 3 showing step 205 in detail, first, in step 301, a function and a global variable to be subjected to argument conversion are selected from functions called from the main.

【0020】ステップ301を詳しくした図4では、最
初にステップ401で、呼び出し先関数で使用されてい
るグローバル変数の和集合を求める。mainから呼び
出されている関数はtrimだけであり、変数参照表よ
り使用されているグローバル変数の集合は{G}である
ことがわかる。ステップ402で未処理グローバル変数
としてGを選択する(ステップ403)。ステップ40
4でGの参照領域を求めると{608}となり、ステッ
プ405で未処理文として文608を選択しsとする
(ステップ406)。ステップ407でsから到達可能
なr内のコールサイトがあるか調べると、文607から
文610までのループをたどる実行パスによって自分自
身(文608)に到達可能であることがわかり、ステッ
プ408に進む。ステップ408では変換対象の関数t
rim、変換対象のグローバル変数G、コールサイト6
08を引数変換表に登録する。
In FIG. 4 showing step 301 in detail, first, in step 401, a union of global variables used in the called function is obtained. The function called from main is only trim, and it can be seen from the variable reference table that the set of global variables used is {G}. In step 402, G is selected as an unprocessed global variable (step 403). Step 40
When the reference region of G is obtained in step 4, it becomes {608}, and in step 405, the sentence 608 is selected as an unprocessed sentence and is set as s (step 406). When it is checked in step 407 whether there is a call site in r that can be reached from s, it is found that the call site can reach itself (statement 608) by an execution path that follows a loop from statement 607 to statement 610. move on. In step 408, the function t to be converted
rim, global variable G to be converted, call site 6
08 is registered in the argument conversion table.

【0021】図3に戻り、次にステップ302で引数変
換表をみて未処理の関数を1つ取り出す。ここではtr
imしか登録されていないので、これを選択する(ステ
ップ303)。ステップ304でtrimに対して引数
変換を適用する。まずステップ501でtrimをクロ
ーニングした関数trim2を作成する。ステップ50
2では引数変換表を見て、trimに対して登録されて
いるグローバル変数のうち未処理のものがあるかを調
べ、Gを選択する(ステップ503)。ステップ504
でGと同じ型の引数gをtrim2に追加する(図7の
文713参照)。ステップ505でtrim2内の文6
16、617におけるGの使用をgに置き換える。図7
(a)のtrim2は置き換えを行った結果である。
Returning to FIG. 3, next, at step 302, one unprocessed function is extracted by referring to the argument conversion table. Where tr
Since only im is registered, this is selected (step 303). In step 304, argument conversion is applied to trim. First, in step 501, a function trim2 obtained by cloning trim is created. Step 50
In step 2, the parameter conversion table is checked to see if any of the global variables registered for trim is unprocessed, and G is selected (step 503). Step 504
To add an argument g of the same type as G to trim2 (see statement 713 in FIG. 7). At step 505, sentence 6 in trim2
Replace the use of G in 16, 617 with g. FIG.
Trim2 in (a) is the result of the replacement.

【0022】次にステップ305で引数変換表をもとに
引数変換を行った関数に対応するコールサイトを引数変
換後の関数呼び出しに置き換える(文716、71
7)。文608におけるtrimの呼び出しはtrim
2への呼び出しに置き換えられ、引数として新しくGが
追加される(文708)。図7(a)のmainは変換
した結果である。
Next, in step 305, the call site corresponding to the function whose argument has been converted based on the argument conversion table is replaced with the function call after the argument conversion (statements 716 and 71).
7). The call of trim in statement 608 is trim
2 and a new G is added as an argument (statement 708). Main in FIG. 7A is the result of the conversion.

【0023】最後にステップ306で従来のグローバル
変数のローカル変数変換を行う。変換結果は図7(b)
のようになる。trim内のグローバル変数Gの使用が
main内に移動した後、グローバル変数のローカル変
数変換によってループの外に出されている。これによ
り、trimの呼び出し毎に生じていたGの使用におけ
る冗長なメモリ参照が削除され、ループ入口で一度だけ
生じることになる。
Finally, at step 306, a conventional local variable conversion of a global variable is performed. The conversion result is shown in FIG.
become that way. After the use of the global variable G in trim has moved into main, it has been moved out of the loop by local variable conversion of the global variable. This eliminates redundant memory references in the use of G that occurred with each call of trim, and occurs only once at the loop entry.

【0024】[0024]

【発明の効果】本発明によれば、関数呼び出しにまたが
ったグローバル変数の使用における冗長なメモリ参照を
削除する方法を与えられる。これによって、プログラム
の実行時のメモリ参照量を減少させ、プログラム実行の
高速化に効果がある。
In accordance with the present invention, a method is provided for eliminating redundant memory references in the use of global variables across function calls. As a result, the amount of memory reference at the time of program execution is reduced, which is effective in speeding up program execution.

【図面の簡単な説明】[Brief description of the drawings]

【図1】本発明のコンパイラが稼動する計算機システム
の構成図。
FIG. 1 is a configuration diagram of a computer system on which a compiler of the present invention operates.

【図2】コンパイラの処理の流れを示す図。FIG. 2 is a diagram showing a processing flow of a compiler.

【図3】グローバル変数のローカル変数変換処理の流れ
を示す図。
FIG. 3 is a diagram showing a flow of a local variable conversion process of a global variable.

【図4】引数変換の適用対象決定処理の流れを示す図。FIG. 4 is a view showing a flow of an argument conversion application target determination process.

【図5】引数変換の処理の流れを示す図。FIG. 5 is a diagram showing a flow of an argument conversion process.

【図6】本発明のグローバル変数のローカル変数変換の
例を示す図。
FIG. 6 is a diagram showing an example of local variable conversion of a global variable according to the present invention.

【図7】本発明のグローバル変数のローカル変数変換の
例(結果)を示す図。
FIG. 7 is a view showing an example (result) of local variable conversion of a global variable according to the present invention.

【図8】従来技術のグローバル変数のローカル変数変換
の例を示す図。
FIG. 8 is a diagram showing an example of a local variable conversion of a global variable according to the related art.

Claims (3)

【特許請求の範囲】[Claims] 【請求項1】 グローバル変数のローカル変数変換を行
うコンパイラにおいて、変換対象領域内に関数呼び出し
が存在し、呼び出し先の関数内でグローバル変数が使用
されている場合に、呼び出し先の関数に対して、該グロ
ーバル変数に対応する引数を追加し、該関数内の該グロ
ーバル変数の使用を、追加した引数の使用に置き換えた
関数を新たに作成し、呼び出し元では新たに作成した関
数を呼び出すようにすることを特徴とするプログラム変
換方法。
In a compiler for performing local variable conversion of a global variable, when a function call exists in a conversion target area and a global variable is used in a callee function, the compiler calls the function of the callee. Add a function corresponding to the global variable, replace the use of the global variable in the function with the use of the added argument, and newly create a function, and call the newly created function. A program conversion method.
【請求項2】 請求項1のプログラム変換方法を用いた
コンパイラ。
2. A compiler using the program conversion method according to claim 1.
【請求項3】 請求項2のコンパイラを格納した記憶媒
体。
3. A storage medium storing the compiler according to claim 2.
JP2000295438A 2000-09-25 2000-09-25 How to convert global variables to local variables Pending JP2002099425A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
JP2000295438A JP2002099425A (en) 2000-09-25 2000-09-25 How to convert global variables to local variables

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
JP2000295438A JP2002099425A (en) 2000-09-25 2000-09-25 How to convert global variables to local variables

Publications (1)

Publication Number Publication Date
JP2002099425A true JP2002099425A (en) 2002-04-05

Family

ID=18777862

Family Applications (1)

Application Number Title Priority Date Filing Date
JP2000295438A Pending JP2002099425A (en) 2000-09-25 2000-09-25 How to convert global variables to local variables

Country Status (1)

Country Link
JP (1) JP2002099425A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007511817A (en) * 2003-11-05 2007-05-10 ローベルト ボッシュ ゲゼルシャフト ミット ベシュレンクテル ハフツング Method and apparatus for adapting functions for controlling drive sequences
JP2007531946A (en) * 2004-04-07 2007-11-08 ローベルト ボッシュ ゲゼルシャフト ミット ベシュレンクテル ハフツング Data integrity in data processing equipment
KR101588027B1 (en) * 2014-10-10 2016-01-25 (주)씽크포비엘 Method and apparatus for generating test case to support localization of software

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2007511817A (en) * 2003-11-05 2007-05-10 ローベルト ボッシュ ゲゼルシャフト ミット ベシュレンクテル ハフツング Method and apparatus for adapting functions for controlling drive sequences
JP2007531946A (en) * 2004-04-07 2007-11-08 ローベルト ボッシュ ゲゼルシャフト ミット ベシュレンクテル ハフツング Data integrity in data processing equipment
KR101588027B1 (en) * 2014-10-10 2016-01-25 (주)씽크포비엘 Method and apparatus for generating test case to support localization of software

Similar Documents

Publication Publication Date Title
US6973644B2 (en) Program interpreter
US6553565B2 (en) Method and apparatus for debugging optimized code
US6363522B1 (en) Method and apparatus for handling exceptions as normal control flow
JPH07234792A (en) Compile processor
JP3280332B2 (en) Method and apparatus for performing versioning on loop, method and apparatus for collecting information on array range check in basic block, method for changing information on array range check, method for optimizing array range check, array range Method of generating code for checking, unnecessary array range check removal method and apparatus, method of selecting array range check, method of changing array range check, collection method of array range check, and handling judgment of array range check Method
JP2001166949A (en) Method and device for compiling source code by using symbolic execution
JP3813087B2 (en) Program conversion method, computer apparatus and program
JP2004062830A (en) Program conversion method, data processing device and program using the same
US7458071B2 (en) Compilation method, compiler apparatus and compiler
US10013244B2 (en) Apparatus and method to compile a variadic template function
JP2001166946A (en) Method and device for compiling source code by flattening hierarchy
JP2002116917A (en) Compiler for compiling source program by object-oriented programming language
US7624390B2 (en) Optimizing compiling of object oriented source code
US7747991B2 (en) Program converting method
JP2002099425A (en) How to convert global variables to local variables
US20030140336A1 (en) Program conversion method, computer using it and program
JP2016224724A (en) Information processing apparatus, compiling method, and compiler program
US20170344351A1 (en) Information processing apparatus, compiling management method, and recording medium
US20050097532A1 (en) Resolving operators with user defined operands
US20060107258A1 (en) Program, program code optimization method, program code compile method, program code, and information processing system
US20090199166A1 (en) Program converting device
JP2011180814A (en) Compiler apparatus, compiling method and program
JP2002140198A (en) Inline expansion method
Saito et al. Controlling Computation Granularity through Fusion in Improving Floating-Point Numbers
JP4788902B2 (en) Compilation optimization method and compiler