Главная » Все файлы » Просмотр файлов из архивов » PDF-файлы » 2004. Precise Interprocedural Analysis through Linear Algebra

2004. Precise Interprocedural Analysis through Linear Algebra, страница 2

PDF-файл 2004. Precise Interprocedural Analysis through Linear Algebra, страница 2 Конструирование компиляторов (52977): Статья - 7 семестр2004. Precise Interprocedural Analysis through Linear Algebra: Конструирование компиляторов - PDF, страница 2 (52977) - СтудИзба2019-09-18СтудИзба

Описание файла

PDF-файл из архива "2004. Precise Interprocedural Analysis through Linear Algebra", который расположен в категории "". Всё это находится в предмете "конструирование компиляторов" из 7 семестр, которые можно найти в файловом архиве МГУ им. Ломоносова. Не смотря на прямую связь этого архива с МГУ им. Ломоносова, его также можно найти и в других разделах. .

Просмотр PDF-файла онлайн

Текст 2 страницы из PDF

Another example program.A generalization of Karr’s algorithm in another direction is the useof polyhedra instead of affine spaces for approximately representing sets of program states; the classic reference is Cousot’s andHalbwachs’ paper [6]. Polyhedra allow to determinebesides affineequalities also affine inequalities like 3x1 5x2 7x3 . Since thelattice of polyhedra has infinite height, widenings must be used toensure termination of the analysis (see [2] for a recent discussion)—making it unsuitable for precise analyses. Sets of affine inequalities, however, allow to relate the values of variables before andafter a procedure call (a relational analysis in the terminology ofCousot)—thus naturally allowing for an interprocedural generalization. A relational analysis, however, that uses affine spaces orpolyhedra for approximating the relational semantics of proceduresis not precise enough to detect all valid affine relations in a program with procedures.

For a simple example see Figure 2. Thetrue relational semantics of procedure P is described by the formulax x0 x 2 x0 2 where x0 represents the initial and x the final value of the variable. The best approximation of this relationby an affine space or polyhedron is described by the formula true.It is obvious that this approximation of P’s semantics is too weakto detect that the affine relation x 2 is valid at program point 2 inprocedure Main.The paper is organized as follows. In Section 2, we formally introduce the programs to be analyzed together with their semantics.In Section 3, we introduce affine relations, their weakest preconditions along a program run and explain our algorithm for this specialcase.

In Section 4, we generalize our approach to deal with arbitrarypolynomial relations of bounded degree. In Section 5, we extendour approach to procedures with local variables and in Section 6 weshow how to take into account affine preconditions completely.2 Affine ProgramsWe model programs by systems of non-deterministic flow graphsthatcan recursively call each other as in Figure 1.

Let X x1 xk be the set of (global) variables the program operates on.We use x to denote the column vector1 of variables x x1 xk t .We assume that the variables take values in a fixed field . In practice, is the field of rational numbers. Then a state assigning values to the variables is conveniently modeled by a k-dimensional(column) vector x x1 xk t k ; xi is the value assigned tovariable xi . Note that we distinguish variables and their values byusing a different font.

For a state x, a variable xi and a value c ,we write x xi c for the state x1 xi 1 c xi 1 xk t .We assume that the basic statements in the program are either affine1 The superscript “t” denotes the transpose operation which mirrors a matrix at the main diagonal and changes a row vector into acolumn vector (and vice versa).assignments of the form x j : t0 ∑ki 1 ti xi (with ti for i 0 k and x j X) or non-deterministic assignments of the formx j : ? (with x j X). Assignments x j : x j have no effect ontothe program state. They are also called statements and omittedin pictures. Non-deterministic assignments x j : ? represent a safeabstraction of statements in a source program our analysis cannothandle precisely, for example of assignments x j : t with non-affineexpressions t or of read statements x j .

Let  be the set ofbasic statements.A program comprises a finite set !"$#% of procedure names that contains a distinguished procedure Main. Execution starts with a callto Main. Each procedure name p !"$#% is associated with a control flow graph G p Np E p A p e p r p that consists of:&a set Np of program points;&a set of edges E p ' Np ( Np ;a mapping A p : E p  *)+!"$#% that annotates each edgewith a basic statement of the form described above or a procedure call;&&&a special entry (or start) point e p Np ; anda special return point r p Np .We assume that the program points of different procedures are disjoint: Np , Nq 0/ for p - q. This can always be enforced by renaming program points.We write N for .

p /1012 354 Np , E for . p /6012 34 E p , and A for. p /1012 354 A p . We agree that 789  is the sete : A e ;5<of base edges and =8?> > p e : A e A@ p is the set of edges thatcall procedure p.The core part of our algorithm can be understood as a precise abstract interpretation of a constraint system characterizing the program executions that reach program points. We represent programexecutions or runs by sequences of affine assignments. Formally, arun r is a finite sequencer @ s1 ; ; smof assignments si of the form x j : t where x j X and t @t0 ∑ki 1 ti xi for some t0 tk . We write BAC?D for the setof runs. The set of runs reaching program point u N can be characterized as the least solution of a system of subset constraints onrun sets (see, e.g., [19] for a similar approach for explicitly parallel programs).

We start by defining the program executions of baseedges e in isolation. If e is annotated by an affine assignment,i.e.,A e E@ x j : t, it gives rise to a single execution: S e x j : t .The effect of base edges e annotated by a non-deterministic assignment x j : ? is captured by all runs that assign some value from to x j :S ex j : c : c Thus, we capture the effect of non-deterministic assignments bycollecting all constant assignments.

Next, we characterize samelevel runs. Same-level runs of procedures capture complete runs ofprocedures in isolation. As auxiliary sets we consider same-levelruns of program nodes, i.e., those runs that reach a program point uin a procedure p from a call to p on same-level, i.e., after all procedures called by p have terminated. The same-level runs of procedures and program nodes are the smallest solution of the constraintsystem S: S1S qS eq S vS v S2 S3 S4S rq εS u ; S e if e S u ; S p if e u v 7 9 u v 8= ?> > pwhere “ε” denotes the empty run, and the operator “;” denotes concatenation of run sets.

By S1 , the set of same-level runs of a procedure q comprises all same-level runs reaching the return point ofq. By S2 , the set of same-level runs of the entry point of a procedure contains the empty run. By S3 and S4 , a same-level runfor a program point v is obtained by considering an ingoing edgee u v . In both cases, we concatenate a same-level run reachingu with a run corresponding to the edge. If e is a base edge, we concatenate with an edge from S e . If e is a call to a procedure p, wetake a same-level run of p.Next, we characterize the runs that reach program points.

They arethe smallest solution of the constraint system R: R1 R2R Main R pR u R3hyper-plane in the k-dimensional vector space k . Such a relationcan be represented as a polynomial of degree at most 1 (namely, theleft-hand side) or, equivalently, as a column vector a a0 ak t .In particular, the set of all affine relations forms an -vector spacewhich is isomorphic to k 1 .

The vector y k satisfies the affinerelation a iff a0 a y 0 where a a1 ak t and “ ” denotesscalar product. We write y : a to denote this fact. Geometrically,this means that the point y is an element of the hyper-plane described by a.εR uif u =8?> > pR p ; S u if u N pThe affine relation a is valid after a single run r iff r x : a forall x k , i.e., iff a0 a6 r x 0 for all x k ; x representsthe unknown initial state.

Thus, a0 a r x 0 is the weakestprecondition for validity of the affine relation a after run r. Wehave Choice of Ar and br a0 a A r x b r t xx x j t x where t x is the value of term t in state x. This definition is inductively extended to runs: ε , where is the identical mappingand ra a r .The state transformation of an affine assignment x j : t0 ∑ki 1 ti xiis an affine transformation. Hence, it can be written in the form x j : t x Ax b with a matrix A k k and a (column) vectorb k .

More specifically, A and b have the form indicated below:AI j 10t1 tk0Ik jb0t00(1)Here, Ii is the unit matrix with i rows and columns and 0 denoteszero matrices and vectors of appropriate dimension. In b, t0 appearsas j-th component.As a composition of affine transformations, the state transformer ofa run is an affine transformation as well.

For any run r, let Ar k kand br k be such that r x Ar x br .a0 a br a Ar x 0At x y from linear algebra Law x Ay iff x j :0 Linearity, rearrangementSo far, we have furnished procedural flow graphs with a symbolicoperational semantics only by describing the sets of sequencesof assignments possibly reaching program points.

Each of theseruns gives rise to a transformation of the underlying program statex k . Every assignment statement xi : t induces a state transformation x j : t : k k given bya0 a 5 r x 0iffiffBy R1 , the procedure Main is reachable by the empty path.

By R2 , every procedure p is reachable by a path reaching a call ofp. By R3 , we obtain a run reaching a program point u in someprocedure p, by composing a run reaching p with a same-level runreaching u.a0 a br Atr a x 0From this characterization we see that the weakest precondition isagain an affine relation. Even better: The mapping that assignsto each affine relation its weakest precondition before run r is thelinear map described by the following k 1 ( k 1 matrix Wr :Wr1btr0Atr(2)In particular, we have proved that for every x r x :aiffx : Wr ak:(3)Thus, the matrix Wr provides us with a finite description of theweakest precondition transformer for affine relations of a singleprogram execution r.Note that the only affine relation which is true for all program statesis the relation 0 0 0 t .

Thus, the affine relation a is valid afterrun r iff Wr a 0, because the initial state is arbitrary. Accordingly,the affine relation a is valid at a program point u, iff it is valid afterall runs r R u . Summarizing, we have:L EMMA 1. The affine relation a u iff Wr a 0 for all r R u .k 1is valid at program pointThus, the set W Wr : r R u gives us a handle to solve thevalidity problem for affine relations. The problem is that we donot know how to represent W in a finitary way—let alone how tocompute it. In this place, we recall from linear algebra that the setof k 1 A( k 1 matrices again forms an -vector space.

Свежие статьи
Популярно сейчас
Зачем заказывать выполнение своего задания, если оно уже было выполнено много много раз? Его можно просто купить или даже скачать бесплатно на СтудИзбе. Найдите нужный учебный материал у нас!
Ответы на популярные вопросы
Да! Наши авторы собирают и выкладывают те работы, которые сдаются в Вашем учебном заведении ежегодно и уже проверены преподавателями.
Да! У нас любой человек может выложить любую учебную работу и зарабатывать на её продажах! Но каждый учебный материал публикуется только после тщательной проверки администрацией.
Вернём деньги! А если быть более точными, то автору даётся немного времени на исправление, а если не исправит или выйдет время, то вернём деньги в полном объёме!
Да! На равне с готовыми студенческими работами у нас продаются услуги. Цены на услуги видны сразу, то есть Вам нужно только указать параметры и сразу можно оплачивать.
Отзывы студентов
Ставлю 10/10
Все нравится, очень удобный сайт, помогает в учебе. Кроме этого, можно заработать самому, выставляя готовые учебные материалы на продажу здесь. Рейтинги и отзывы на преподавателей очень помогают сориентироваться в начале нового семестра. Спасибо за такую функцию. Ставлю максимальную оценку.
Лучшая платформа для успешной сдачи сессии
Познакомился со СтудИзбой благодаря своему другу, очень нравится интерфейс, количество доступных файлов, цена, в общем, все прекрасно. Даже сам продаю какие-то свои работы.
Студизба ван лав ❤
Очень офигенный сайт для студентов. Много полезных учебных материалов. Пользуюсь студизбой с октября 2021 года. Серьёзных нареканий нет. Хотелось бы, что бы ввели подписочную модель и сделали материалы дешевле 300 рублей в рамках подписки бесплатными.
Отличный сайт
Лично меня всё устраивает - и покупка, и продажа; и цены, и возможность предпросмотра куска файла, и обилие бесплатных файлов (в подборках по авторам, читай, ВУЗам и факультетам). Есть определённые баги, но всё решаемо, да и администраторы реагируют в течение суток.
Маленький отзыв о большом помощнике!
Студизба спасает в те моменты, когда сроки горят, а работ накопилось достаточно. Довольно удобный сайт с простой навигацией и огромным количеством материалов.
Студ. Изба как крупнейший сборник работ для студентов
Тут дофига бывает всего полезного. Печально, что бывают предметы по которым даже одного бесплатного решения нет, но это скорее вопрос к студентам. В остальном всё здорово.
Спасательный островок
Если уже не успеваешь разобраться или застрял на каком-то задание поможет тебе быстро и недорого решить твою проблему.
Всё и так отлично
Всё очень удобно. Особенно круто, что есть система бонусов и можно выводить остатки денег. Очень много качественных бесплатных файлов.
Отзыв о системе "Студизба"
Отличная платформа для распространения работ, востребованных студентами. Хорошо налаженная и качественная работа сайта, огромная база заданий и аудитория.
Отличный помощник
Отличный сайт с кучей полезных файлов, позволяющий найти много методичек / учебников / отзывов о вузах и преподователях.
Отлично помогает студентам в любой момент для решения трудных и незамедлительных задач
Хотелось бы больше конкретной информации о преподавателях. А так в принципе хороший сайт, всегда им пользуюсь и ни разу не было желания прекратить. Хороший сайт для помощи студентам, удобный и приятный интерфейс. Из недостатков можно выделить только отсутствия небольшого количества файлов.
Спасибо за шикарный сайт
Великолепный сайт на котором студент за не большие деньги может найти помощь с дз, проектами курсовыми, лабораторными, а также узнать отзывы на преподавателей и бесплатно скачать пособия.
Популярные преподаватели
Нашёл ошибку?
Или хочешь предложить что-то улучшить на этой странице? Напиши об этом и получи бонус!
Бонус рассчитывается индивидуально в каждом случае и может быть в виде баллов или бесплатной услуги от студизбы.
Предложить исправление
Добавляйте материалы
и зарабатывайте!
Продажи идут автоматически
5140
Авторов
на СтудИзбе
441
Средний доход
с одного платного файла
Обучение Подробнее