What is the difference between Interprocedural and Intraprocedural analysis?
Asked Answered
T

2

5

I have searched a lot to find the difference between the Interprocedural and Intraprocedural analysis. As far as I could understand, the Intraprocedural analysis is applied on a single procedure whereas the Interprocedural analysis is applied on all procedures. This is still not clear to me, more specficialy how this Interprocedural analysis is applied on all procedures?

Can someone please give me an explanation for that?

Theretofore answered 27/5, 2020 at 21:36 Comment(2)
by gathering info from several procedures, the compiler can emit some optimizations like caching some immutable states used by several procedures in a call chainCralg
This may help ibm.com/docs/en/zos/…Vendue
M
6

Interprocedural (think Internet, a network of networks, vs. Intranet, a single network) analysis is analysis that operates on multiple functions, for example the following Interproducedural optimization:

function main() {
   return getConstant() * rand()
}

function getConstant() {
   return 42
}

Could be inlined to:

function main() {
   return 42 * rand()
}

And the following Intraprocedural optimization:

function getNrOfSecondsInWeek() {
  secondsAMinute := 60
  minutesAnHour := 60
  hoursADay := 24
  daysAWeek := 7
  return secondsAMinute * minutesAnHour * hoursADay * daysAWeek;
}

Could be inlined to:

function getNrOfSecondsInWeek() {
  return 604800;
}
Mungovan answered 6/5, 2021 at 13:21 Comment(0)
V
1

Intraprocedural analysis is a mechanism for performing optimization (or other analysis) for each function in a compilation unit, using only the information available for that function and compilation unit.

Interprocedural analysis is a mechanism for performing optimization (or other analysis) across function and compilation unit boundaries.

More information here: https://www.ibm.com/docs/en/zos/2.3.0?topic=option-types-procedural-analysis

Vendue answered 5/6, 2022 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.