1 / 32

Ben-Chung Cheng and Wen-mei W. Hwu in proceedings of PLDI2000 発表者: gotoh

Modular Interprocedural Pointer Analysis Using Access Paths: Design, Implementation, and Evaluation. Ben-Chung Cheng and Wen-mei W. Hwu in proceedings of PLDI2000 発表者: gotoh. Pointer analysis とは?. プログラム中の各ポインタ変数がどのメモリ領域へのポインタを保持する可能性があるか. Pointer analysis の応用. 各種メモリまわりの最適化

ciaran-guy
Télécharger la présentation

Ben-Chung Cheng and Wen-mei W. Hwu in proceedings of PLDI2000 発表者: gotoh

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Modular Interprocedural Pointer Analysis Using Access Paths: Design, Implementation, and Evaluation Ben-Chung Cheng and Wen-mei W. Hwu in proceedings of PLDI2000 発表者:gotoh AMO 発表資料

  2. Pointer analysis とは? • プログラム中の各ポインタ変数がどのメモリ領域へのポインタを保持する可能性があるか AMO 発表資料

  3. Pointer analysis の応用 • 各種メモリまわりの最適化 • redundant load/store elimination • loop-invariant location promotion • load/store scheduling etc. 上記に限らず何らかの最適化を行なう際に同様の手法を用いることになる(ことが多い)ので、勉強することは非常に重要 AMO 発表資料

  4. 紹介論文の売り • Cの全ての feature を扱いつつ、大きなプログラム(200,000行)に対しても適用可能なアルゴリズム ※ flow-insensitive だが context-sensitive AMO 発表資料

  5. 今後の流れ • 解析方針 • 解析方法 • Intraprocedural analysis • Interprocedural analysis • 実験結果 AMO 発表資料

  6. 解析の方針 • Flow sensitive or flow insensitive • Context sensitive or context insensitive • Whole-program or modular analysis • Storage- or path-based representation • Partial or complete language features AMO 発表資料

  7. Flow sensitivity • ポインタ代入の文の順番を考慮するか • flow sensitive …する • より細かい解析が可能だが、重い • flow insensitive …しない • おおざっぱな解析だが、軽い ※ flow sensitive でもあまり効果ないという指摘 [M.Hind and A.Pioli 1998] flow insensitive を採用 AMO 発表資料

  8. Context sensitivity • 呼び出し先が一緒でも呼び出し元が異なる場合を区別するか • context sensitive …する • context insensitive …しない ※ 区別したところでいくつかのベンチマークでは効果は出ていない [E.Ruf 1995] context sensitive だが、コストが 低いように実装 AMO 発表資料

  9. Whole-program / modular analysis • プログラム全体が与えられたとして全部を一度に解析するか、関数単位など部分毎に解析するか • whole-program • リソースおよび時間のコストが大きい • modular • コストは低いが無駄な解析をさけるための処理必要 AMO 発表資料

  10. Storage- / path-based representation • メモリロケーションの表現方法 • storage-based …物理メモリアドレスに対応した変数名で表現 ※ 曖昧さをさけるために同じ場所に複数の名前をつけないようにする必要があることも…(大変) • path-based …最初にどの変数に指されていたかで表現 ※ 同じ場所に対する2つ以上の表現あり AMO 発表資料

  11. 解析の流れ Phase I' Analyze local statements (flow-insensitive) Phase O Build accurate call graph (context-insensitive) Phase I'' Propagete summary transfer functions (context-insensitive) Phase II' Propagete concrete function names Phase II'' Propagate concrete values intraprocedural interprocedural Phase III Determine parameter aliases AMO 発表資料

  12. Intraprocedural Analysis (図) typedef struct S { int *key; struct S *next; } S; fn3(S *r, S *s) { r->next = s; } access path r r* r*.4_7 s s* ソースプログラム summary transfer function (point-to relation グラフ) AMO 発表資料

  13. Intraprocedural Analysis (文) • 入力:関数のソース • グローバル変数、引数、関数呼び出しの返値は全て未初期化と仮定 • flow-insensitive → 命令の順番は関係ない • 出力:どの変数(ポインタ)がどの変数(領域)を指す(可能性がある)かを表すグラフ、ほか AMO 発表資料

  14. Access Path 配列は要素の区別なし • v( fd | d )*( f |ε) • v: 変数名 • f: フィールド名 .<開始オフセット>_<終了オフセット> の形 • d: dereference (Cの `*` オペレータ) (ex) フィールド名のかわりに開始・終了オフセットを用いることで、union にも対応 プログラム中の表現 access path r->next r*.4_7 r->next->key r*.4_7*.0_3 ※ 計算方法は別紙の図1 AMO 発表資料

  15. Interprocedural Analysis • 関数のコールグラフの作成 …以下の2ステップの反復 • main() からトップダウンに作成 • summary transfer function をボトムアップに伝播、コールグラフの更新 グローバル変数、戻り値、実・仮引数の対応 • (potential) aliasing の解析 ※ 本論文では詳細説明はない AMO 発表資料

  16. Strongly Connected Components-Directed Acyclic Graph 強連結成分有向非環状グラフ? コールグラフの作成 • main() から深さ優先でコールグラフ作成 • 生成したグラフを SCC-DAG に変換 • SCC-DAG において summary transfer function を topological 順序で伝播 • 関数名を今度は top-down で伝播 以上の手順をグラフが収束するまで反復 • 関数の間接呼び出しがない場合は1回で収束 AMO 発表資料

  17. summary transfer function 伝播 • 各 SCC 内に複数の関数が含まれている場合、SCC の中だけで収束するまで伝播 • SCC 間で伝播 2. SCC間での伝播 1. SCC内での伝播 SCC AMO 発表資料

  18. 動的に確保された領域の扱い ※ malloc() のみ扱う • 領域名…一時変数名のかわりに malloc_1(), malloc_2() ... のような名前 • 数字は関数内で unique • 動的領域が caller に返されたら? • 他の動的領域と名前が重ならないの? AMO 発表資料

  19. Extended Access Path • An EAP can be considered as a reverse-engineered access path obtrained from DFS and indicates a potential way for the object to be accessed from a parameter or a global variable. AMO 発表資料

  20. EAP=q1** EAP=q2** EAP の例(EAPを求めるアルゴリズムは別紙) fn5() { int *p1, *p2, *p3; my(&p1,&p2,&p3); *p1=1; *p2=2; *p3=3; } my(int**q1,int**q2,int**q3) { *q1=malloc(4); *q2=malloc(4); *q3=*q2; } &p1 p1 p1* &p2 p2 p2* &p3 p3 p3* q1 q1* malloc_1()* malloc_1() q2 q2* malloc_2()* malloc_2() q3 q3* AMO 発表資料

  21. transfer function 伝播例 caller &p1 p1 p1* &p2 p2 p2* &p3 p3 p3* &p1 p1 p1* callee q1 q1* q1** &p2 p2 p2* malloc_1() &p3 p3 q2 q2* q2** malloc_2() q1 → &p1 q2 → &p2 q3 q3* AMO 発表資料

  22. 実験 • PentiumII-450MHz, 256MB メモリ, Linux(RedHat6.0) • 実験内容 • Analysis cost • Accuracy Measurement • Performance Improvements AMO 発表資料

  23. Analysis Costs Benchmark Intra. Time (sec) Inter. Total Time (sec) Time(sec) Mem(MB) 008.espresso 5.66 20.20 14.26 25.86 023.eqntott 0.75 0.99 2.81 1.54 026.compress 0.12 0.48 1.93 0.60 072.sc 2.42 3.15 6.34 5.57 085.ccl 33.61 277.67 79.22 311.28 • プログラムサイズ • 複雑な構造体 • キャスト 099.go 2.82 0.21 8.13 3.03 124.m88ksim 2.36 3.54 8.09 5.90 126.gcc 76.68 520.85 238.00 597.53 129.compress 0.09 0.10 1.26 0.19 130.li 2.33 149.59 30.58 151.92 132.ijpeg 7.34 99.16 29.97 106.50 134.perl 14.43 468.33 51.14 482.76 147.vortex 15.08 166.90 74.80 181.98 AMO 発表資料

  24. Accuracy (1/3) • 2つの基準 • 各ポインタの指すターゲットがいくつか? • 1に近いほど良い • 各ターゲットはいくつのポインタから参照? • 1に近いほど良い ※ 片方だけだと正しい判定とはいえない • 全てのポインタが一つのターゲットを参照 AMO 発表資料

  25. Accuracy (2/3) target/pointer pointer/target Benchmark 1 2 3 ≧4 avg. 1 2 3 ≧4 avg. 008.espresso 3071 436 40 24 1.16 1341 329 253 282 1.76 023.eqntott 310 115 0 7 1.31 165 30 31 37 1.77 026.compress 34 1 1 0 1.08 21 6 2 2 1.52 072.sc 662 46 13 6 1.12 291 88 36 40 1.62 085.ccl 9231 1659 384 189 1.26 2527 617 607 980 2.01 099.go 312 0 0 0 1.00 159 24 5 21 1.46 124.m88ksim 622 49 3 15 1.15 562 88 35 16 1.29 126.gcc 16147 3679 705 451 1.31 4481 1092 795 1852 2.00 129.compress 37 2 0 0 1.05 36 9 0 0 1.20 130.li 1576 243 50 4 1.19 588 239 58 126 1.73 132.ijpeg 3897 766 135 23 1.23 3166 829 201 144 1.38 134.perl 2873 691 340 435 1.62 1205 477 206 543 2.04 147.vortex 6768 121 41 5 1.03 4848 671 214 347 1.35 AMO 発表資料

  26. Accuracy (3/3) flow-sensitive にすると解析精度が増す部分 → named_acyclic たかだか10%程度 AMO 発表資料

  27. Performance (1/2) • base ... 全てのメモリアクセス、関数の副作用は曖昧 • std ... 関数内解析のみ • adv ... 関数間解析も利用 AMO 発表資料

  28. Performance (2/2) AMO 発表資料

  29. 関連研究 (1/3) • [Landi et al.] • flow/context sensitive • 対象言語は C のサブセット • [Emami et al.] • flow sensitive • ヒープオブジェクトの扱いがクリアでない • C のサブセット、関数ポインタも含む AMO 発表資料

  30. 関連研究 (2/3) • [Choi et al.] • 実装・実験が明らかでない • [Andersen] • 最悪でO(n3)なアルゴリズム • [Fahndrich et al.]によって、大きいプログラムでも十分実用的になりうることが示された? • [Shapiro et al. ] • [Andersen] と [Steensgaard] の混在した方法 AMO 発表資料

  31. 関連研究 (3/3) • [Hasti et al.] • SSA-form により、解析精度を反復進化? • 実験結果なし • [Zhang et al.] [Stocks et al.] • さまざまなアルゴリズムを切り替えて使用 紹介論文… C の全性質に対応し 200000行以上のコードを解析できる最初の研究 AMO 発表資料

  32. まとめ • 効率的な C言語用の modular inter-procedural pointer analysis algorithm を提案、実装した • context-sensitive なため、間接的な関数呼び出しを多く含むプログラムに特に威力を発揮 • 実用的な効率 AMO 発表資料

More Related