Advanced Compilers CMPSCI 710 Spring 2003 Interprocedural AnalysisTopicsAliasingAliasing Examples, IAliasing Examples, IIAlias Examples, IIIInterprocedural AnalysisProblems with Interprocedural AnalysisAnalysis SensitivityContext SensitivitySummary InformationTwo Types of InformationPropagation Summaries: ExamplesSide-Effect Summaries: ExamplesComputing SummariesImplementing IPA: The Call GraphCall Graph ExampleSide-Effect SummarizationSide-Effect Summary ExampleAlternatives to IPA: InliningAlternatives to IPA: CloningCloningConclusionUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer ScienceEmery BergerUniversity of Massachusetts, AmherstAdvanced CompilersCMPSCI 710Spring 2003Interprocedural AnalysisUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science2TopicsUp to nowIntraprocedural analysesDataflow analysesDefUse, SSARegister AllocationSchedulingJust for individual proceduresToday: Interprocedural analysisacross/between proceduresWhy?UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science3AliasingFormals and/or globals may be aliasedTwo names point to same locationOnly form of aliasing for Java, FortranAt procedure callGlobals may be modified or usedActual args may be modified or usedUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science4Aliasing Examples, INeed alias analysis to do:Instruction schedulingRegister allocationUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science5Aliasing Examples, IINeed alias analysis to do:Dead code eliminationCode motionUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science6Alias Examples, IIINeed alias analysis to do:Constant propagationTo perform alias analysis, we need…UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science7Interprocedural AnalysisGoalsEnable standard optimizations even with procedure callsReduce call overhead for proceduresEnable optimizations not possible for single proceduresOptimizationsRegister allocationLoop transformationsCSE, etc.UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science8Problems withInterprocedural AnalysisNot without drawbacksWhole-program analysisWhat about libraries?Separate compilation requires recompilation analysis [Burke & Torczon 93]ExpensiveDoesn’t scale well, or worseSome problems intractablee.g., Flow-sensitive killUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science9Analysis SensitivityFlow-insensitiveWhat may happen (on at least one path)Linear-timeFlow-sensitiveConsider control flow (what must happen)Iterative data-flow: possibly exponentialContext-insensitiveCall treated the same regardless of caller“Monovariant” analysisContext-sensitiveReanalyze callee for each caller“Polyvariant” analysisMore sensitivity ) more accuracy, but more expenseUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science10Context SensitivityReanalyze callee as if procedure was inlinedToo expensive in space & timeRecursion?Approximate context sensitivity:Reanalyze callee for k levels of calling contextUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science11Summary InformationAnother approach: summarize each procedureEffect/result of called procedure for callersEffect/input of callers for called procedureStore in database for use by later optimization passPros:+Concise+Fast+Practical: separate compilationCons:-ImpreciseUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science12Two Types of InformationTrack info that flows into procedures“Propagation problems”, e.g.:which formals are constant?which formals are aliased to globals?Track info that flows out of procedures“Side effect problems”, e.g.:which globals defined/used by procedure?which locals defined/used by procedure?Which actual parameters defined by procedure?UUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science13Propagation Summaries: ExamplesMAY-ALIASFormals that may be aliased to globalsMUST-ALIASFormals definitely aliased to globalsCONSTANTFormals that are defi n itely constantUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science14Side-Effect Summaries: ExamplesMODVariables poss ibly modified (defined) by procedure callREFVariables poss ibly referenced (used) by procedureKILLVariables that are definit ely killed in procedureUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science15Computing SummariesBottom-up (MOD, REF, KILL)Summarizes effect of callTop-down (MAY-ALIAS)Summarizes information about callerBi-directional (AVAIL, CONSTANT)Info to/from caller & calleeUUNIVERSITY OF NIVERSITY OF MMASSACHUSETTSASSACHUSETTS, A, AMHERST • MHERST • Department of Computer Science Department of Computer Science16Implementing IPA: The Call GraphRepresent procedure call relationshipby call graphG = (V,E,start)Each procedure is unique vertexCall site = edge between caller & callee(u,v) = call from u to vCan label with source lineCycles represent recursionUUNIVERSITY OF NIVERSITY OF
View Full Document