版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
1、1Next Section: Pointer Analysis Outline: What is pointer analysis Intraprocedural pointer analysis Interprocedural pointer analysis (Wilson & Lam) Unification based interprocedural pointer analysis (Steensgaard)2Pointer and Alias Analysis Aliases: two expressions that denote the same memory loca
2、tion. Aliases are introduced by: pointers call-by-reference array indexing C unions3Useful for what? Improve the precision of analyses that require knowing what is modified or referenced (eg const prop, CSE ) Eliminate redundant loads/stores and dead stores. Parallelization of code can recursive cal
3、ls to quick_sort be run in parallel? Yes, provided that they reference distinct regions of the array. Identify objects to be tracked in error detection toolsx := *p;.y := *p; / replace with y := x?*x := .;/ is *x dead?x.lock();.y.unlock(); / same object as x?4Kinds of alias information Points-to inf
4、ormation (must or may versions) at program point, compute a set of pairs of the form p ! x, where p points to x. can represent this informationin a points-to graph Alias pairs at each program point, compute the set of of all pairs (e1,e2) where e1 and e2 must/may reference the same memory. Storage s
5、hape analysis at each program point, compute anabstract description of the pointer structure.pxyzp5Intraprocedural Points-to Analysis Want to compute may-points-to information Lattice:6Flow functionsx := a + binoutFx := a+b(in) =x := kinoutFx := k(in) =7Flow functionsx := &yinoutFx := &y(in)
6、 =x := yinoutFx := y(in) =8Flow functions*x := yinoutF*x := y(in) =x := *yinoutFx := *y(in) =9Intraprocedural Points-to Analysis Flow functions:10Example of using points-to information In constant propagation:11Example of using points-to information In constant propagation:12Pointers to dynamically-
7、allocated memory Handle statements of the form: x := new T One idea: generate a new variable each time the new statement is analyzed to stand for the new location:13Examplelst := new Consp := lstt := new Cons*p := tp := t14Example solvedl := new Consp := lt := new Cons*p := tp := tlpV1lpV1tV2lpV1tV2
8、ltV1pV2ltV1pV2ltV1pV2V3ltV1pV2V3ltV1pV2V315What went wrong? Lattice was infinitely tall! Instead, we need to summarize the infinitely many allocated objects in a finite way. introduce summary nodes, which will stand for a whole class of allocated objects. For example: For each new statement with lab
9、el L, introduce a summary node locL , which stands for the memory allocated by statement L. Summary nodes can use other criterion for merging.16Example revisitedS1: l := new Consp := lS2: t := new Cons*p := tp := t17Example revisited & solvedS1: l := new Consp := lS2: t := new Cons*p := tp := tl
10、pS1lpS1tS2lpS1tS2ltS1pS2ltS1pS2ltS1pL2ltS1pS2ltS1pS2ltS1pS2ltL1pL2ltS1pS2ltS1pS2Iter 1Iter 2Iter 318Array aliasing, and pointers to arrays Array indexing can cause aliasing: ai aliases bj if: a aliases b and i = j a and b overlap, and i = j + k, where k is the amount of overlap. Can have pointers to
11、 elements of an array p := &ai; .; p+; How can arrays be modeled? Could treat the whole array as one location. Could try to reason about the array index expressions: array dependence analysis.19Summary We just saw: intraprocedural points-to analysis handling dynamically allocated memory handling
12、 pointers to arrays But, intraprocedural pointer analysis is not enough. Sharing data structures across multiple procedures is one the big benefits of pointers: instead of passing the whole data structures around, just pass pointers to them (eg C pass by reference). So pointers end up pointing to st
13、ructures shared across procedures. If you dont do an interproc analysis, youll have to make conservative assumptions functions entries and function calls.20Conservative approximation on entry Say we dont have interprocedural pointer analysis. What should the information be at the input of the follow
14、ing procedure:global g;void p(x,y) .xyg21Conservative approximation on entry Here are a few solutions:xyglocationsfrom allocsites priorto thisinvocationglobal g;void p(x,y) . They are all very conservative! We can try to do better.x,y,g & locationsfrom allocsites priorto thisinvocation22Interpro
15、cedural pointer analysis for C Well look at Wilson & Lam PLDI 95, and focus on two problems solved by this paper: how to represent pointer information in the presence of casts, pointer arithmetic, unions, and all the rest of C. how to perform context-sensitive pointer analysis interprocedurally
16、in a way that provides good precision at reasonable costs.23Representing pointer information for C Problem: C types can be subverted by type casts: an int can in fact be a pointer. Pointer arithmetic can lead to subobject boundaries being crossed. So, ignore the type system and subobject boundaries. Instead use a
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 大學(xué)生畢業(yè)登記表自我鑒定(5篇)
- 石河子大學(xué)《歷史教學(xué)技能實訓(xùn)》2022-2023學(xué)年第一學(xué)期期末試卷
- 石河子大學(xué)《工業(yè)藥物分析綜合實驗》2022-2023學(xué)年第一學(xué)期期末試卷
- 石河子大學(xué)《教師語言與行為藝術(shù)》2022-2023學(xué)年第一學(xué)期期末試卷
- 沈陽理工大學(xué)《數(shù)字信號處理》2021-2022學(xué)年第一學(xué)期期末試卷
- 沈陽理工大學(xué)《美國文學(xué)史》2022-2023學(xué)年第一學(xué)期期末試卷
- 沈陽理工大學(xué)《機(jī)械工程材料》2021-2022學(xué)年第一學(xué)期期末試卷
- 沈陽理工大學(xué)《翻譯工作坊》2023-2024學(xué)年第一學(xué)期期末試卷
- 合同法81條對應(yīng)民法典
- 高空作業(yè)合同安全責(zé)任書模版
- 二十世紀(jì)中國文學(xué)經(jīng)典與電影-知到答案、智慧樹答案
- 應(yīng)收賬款收款進(jìn)度跟蹤管理報表模板
- 《詩經(jīng)》與楚辭導(dǎo)讀智慧樹知到答案2024年??诮?jīng)濟(jì)學(xué)院
- 育德育心育心養(yǎng)德
- 湘少版英語五年級下冊全冊教案(教學(xué)設(shè)計)
- XXXX無線維護(hù)崗位認(rèn)證教材故障處理思路及案例分析
- 缺血性心肌病
- 1960年文教群英會表彰名單
- 基于創(chuàng)業(yè)思維的軟件開發(fā)技術(shù)(JAVA)智慧樹知到期末考試答案2024年
- 體育教師生涯發(fā)展展示
- 老舊小區(qū)物業(yè)管理方案
評論
0/150
提交評論