Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Đây là cách chúng tôi sử dụng một giải pháp cho vấn đề đạt-định nghĩa để phát hiện sử dụng trước khi định nghĩa. Bí quyết là để giới thiệu một định nghĩa giả cho mỗi biến x trong mục đồ thị dòng chảy. Nếu định nghĩa giả của x đạt đến một p điểm trong đó x có thể được sử dụng, | Simpo PDF Merge and Split Unregistered Version - http www.simpopdf.com Detecting Possible Uses Before Definition Here is how we use a solution to the reaching-definitions problem to detect uses before definition. The trick is to introduce a dummy definition for each variable X in the entry to the flow graph. If the dummy definition of X reaches a point p where X might be used then there might be an opportunity to use X before definition. Note that we can never be absolutely certain that the program has a bug since there may be some reason possibly involving a complex logical argument why the path along which p is reached without a real definition of X can never be taken. know whether a statement s is assigning a value to X. we must assume that it may assign to it that is variable X after statement s may have either its original value before s or the new value created by s. For the sake of simplicity the rest of the chapter assumes that we are dealing only with variables that have no aliases. This class of variables includes all local scalar variables in most languages in the case of c and C local variables whose addresses have been computed at some point are excluded. Example 9.9 Shown in Fig. 9.13 is a flow graph with seven definitions. Let US focus on the definitions reaching block B2 All the definitions in block Bl reach the beginning of block B2. The definition d- . j j-1 in block B2 also reaches the beginning of block B2 because no other definitions of j can be found in the loop leading back to B2. This definition however kills the definition d2 . j n preventing it from reaching B3 or B4. The statement CỈ4 ỉ Ỉ 1 in B2 does not reach the beginning of B2 though because the variable i is always redefined by d7 i u3. Finally the definition d6 a u2 also reaches the beginning of block B2- By defining reaching definitions as we have we sometimes allow inaccuracies. However they are all in the safe or conservative direction. For example notice our assumption that all