Alias Analysis - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Alias Analysis

Description:

Alias Analysis. Team 6. Rakhi Anand. Phanindra Kanakamedala. Raj Kumar Jagiripu. Quinn Lewis ... Determination of storage locations that may be accessed in two ... – PowerPoint PPT presentation

Number of Views:190
Avg rating:3.0/5.0
Slides: 23
Provided by: changrakhi
Category:
Tags: alias | analysis | rakhi

less

Transcript and Presenter's Notes

Title: Alias Analysis


1
Alias Analysis
  • Team 6
  • Rakhi Anand
  • Phanindra Kanakamedala
  • Raj Kumar Jagiripu
  • Quinn Lewis
  • Chang Yun

2
Alias Analysis Basics
  • What?
  • Determination of storage locations that may be
    accessed in two or more ways
  • Why?
  • Essential to performing most optimizations
    correctly
  • When?
  • Applied before other analyses
  • Where?
  • Generated in WOPT/IPA and used in IPA, LNO, CG

3
Project Objectives
  • Understand alias analysis in the compiler
  • Export alias analysis information from Open64
  • Alias classification, flow-free and
    flow-sensitive pointer analysis
  • WOPT and IPA
  • Create tool that displays the alias analysis
    results using the compiler on a given program
  • Test tool with different applications

4
Static Single Assignment (SSA) form
  • SSA form - Only one definition allowed per
    variable over entire program
  • Each definition of a variable is given a unique
    version
  • Different versions of the same variable can be
    regarded as different program variables
  • Original Representation
    SSA Representation

a0 3 a1 a0 2 b0 a1 3
a 3 a a 2 b a 3
5
Aliasing Conditions
  • Aliasing of a scalar variable occurs in one of
    four conditions
  • When its storage location partially overlaps
    another variable
  • When it is pointed to by a pointer used in
    indirect memory operations
  • When its address is passed in a procedure call
  • When its a non-local variable that can be
    accessed from another procedure in a call or
    return

6
SSA with Aliasing
  • Factoring Operator ( ) - All edges pass through
    it, when multiple edges cross a join point
  • Two types of definitions of a variable that
    characterize the effects of aliasing
  • MustDef - operator
  • MustDef must redefine the variable
  • MayUse - µ operator
  • MayUse only potentially redefines the variable

7
SSA and Aliasing
  • Aliases in real programs can be modeled
  • completely and concisely in SSA form
  • Both direct and indirect memory accesses can be
    represented uniformly in SSA form using global
    value numbering
  • SSA-based optimizations on scalar variables can
    be extended to indirect variables
  • Any construct representing data storage can be
    represented in SSA form and benefits from SSA
    based optimizations

8
Alias Analysis in IPA
  • One of Interprocedural Analysis phases
  • Performs on the High WHIRL
  • Computes all possible aliases in a program using
    information passed across procedure boundaries
  • Objective
  • Propagate alias information into procedures
  • Propagate aliasing effects of the procedure out
    to the caller

9
Dataflow Relationship Between Modules
10
Five Phases of IPA
Phase 1 Inliner Phase (INL)
Phase 2 IPA Local Summary Phase (IPL)
Phase 3 IPA Analysis Phase (IPA)
Phase 4 IPA Optimization Phase (IPO)
Phase 5 IPA Miscellaneous Phase (IPM)
11
IPA Modular Hierarchy
ipa_driver (ipc_main.cxx)
Perform_Interprocedural_Optimization
(ipo_main.cxx)
Perform_Interprocedural_Analysis (ipa_main.cxx)
Padding Analysis (ipa_pda.cxx)
Optimize_Global_Variables (ipc_pic.cxx)
IPAA Simple IPAA
Eliminate_Dead_Function (ipc_cg.cxx)
IPAA Direct References Analysis
Do_Simple_IPAA (ipaa.cxx)
IPAA Indirect References Analysis
Clone_df (ipa_main.cxx)
IPAA Global Mod/Ref Listing
Ipa_Cprop (ipa_cprop.cxx)
IPAA Formal Points-To Mapping
Array_df (ipa_main.cxx)
Perform_Inline_analysis (ipa_inline.cxx)
12
Flow insensitive and sensitive
  • Flow-free analysis (Compute_FFA)
  • Creates the initial MU and CHI lists
  • Initializes the POINTS_TO data
  • Generates the occurrence table and virtual
    symbols
  • Flow-sensitive analysis (Compute_FSA)
  • Updates the POINTS_TO values already determined
    during flow free analysis
  • Requires SSA representation
  • Uses def-use (DU) chains to improve the
    information obtained during FFA

13
ALIAS_MANAGER Data Structure
  • ALIAS_CONTEXT
  • Determines rules from compiler options
  • And dynamically from context (e.g. multi-language
    inlining)
  • ALIAS_RULE
  • 6 main language independent rules
  • A few special rules for C and FORTRAN (no C)
  • Exposed via Aliased() function in
    ALIAS_MANAGER
  • ALIAS_RESULT
  • NOT_ALIASED two memops are not aliased
  • POSSIBLY_ALIASED cant prove memops are not
    aliased
  • SAME_LOCATION memops are aliased and have the
    same memory locations
  • POINTS_TO
  • Summarizes the alias information about memory
    operations
  • Each memory operation has its own POINTS_TO
    information

14
ALIAS_CLASSIFICATION
  • Actually two C classes
  • ALIAS_CLASSIFICATION
  • IP_ALIAS_CLASSIFICATION
  • Same alias class if
  • Two expressions or variables may be aliased
  • Two variables or expressions may be pointed to by
    the same pointer
  • This is the biggest conservatism inherent in the
    algorithm

15
Points-to versus Alias Analysis
  • Points-to analysis gathers the information
  • Flow free
  • Flow sensitive
  • Alias analysis uses the information
  • Symbol to symbol
  • Memop to symbol
  • Memop to memop
  • Call to symbol
  • Call to memop

16
Test Cases
  • Purpose
  • Generate data for the alias analysis tool
  • Study the effects of the different compiler
    options
  • Problems
  • Very little change in the generated WHIRL code
    with small test cases
  • Optimizer too good making it difficult to
    identify aliasing
  • Dead code elimination
  • Subexpression elimination

17
Compiler Options
  • uhcc -O2 OPTaliasany,typed,unnamed,restrict,di
    sjoint
  • any any pair of memory references may be
    aliased (the default)
  • typed pointers to distinct data types are not
    aliased
  • unnamed assume pointers never point to global
    variables
  • restrict different pointers never point to same
    memory location
  • disjoint assume multiple pointer indirection
    never overlap

18
Example of aliasing (C code)
  • test.c
  • include ltstdio.hgt
  • int main()
  • float arand()
  • float b, c
  • if (a1)
  • b a
  • else
  • c b
  • printf("\n u u u", a, b, c)
  • return 0

19
Example of aliasing (WHIRL code)
  • LOC 1 6 float b, c
  • LOC 1 7 if (a1)
  • LOC 1 8 b a
  • U8LDA 0 lt2,1,agt Tlt39,anon_ptr.,8gt
  • LOC 1 9 else
  • LOC 1 10 c b
  • U8U8LDID 0 lt2,2,bgt Tlt39,anon_ptr.,8gt alias_id
    12,fixed
  • U8STID 267 lt1,5,.preg_U8gt Tlt9,.predef_U8,8gt b
    alias_id 1,fixed freq 0, ln 10, col 0
  • U8U8LDID 267 lt1,5,.preg_U8gt Tlt9,.predef_U8,8gt
    b alias_id 1,fixed
  • U8STID 266 lt1,5,.preg_U8gt Tlt9,.predef_U8,8gt c
    alias_id 1,fixed freq 0, ln 10, col 0
  • LABEL L5 0 freq 0, ln 0, col 0
  • LOC 1 11 printf("\n u u u", a, b, c)
  • U8LDA 0 lt1,32,(11_bytes)_"\n_u_u_u\000"gt
    Tlt43,anon_ptr.,8gt
  • U8PARM 2 Tlt37,anon_ptr.,8gt by_value
    alias_id 0
  • U8LDA 0 lt2,1,agt Tlt39,anon_ptr.,8gt
  • U8PARM 2 Tlt39,anon_ptr.,8gt by_value
    alias_id 0
  • U8U8LDID 267 lt1,5,.preg_U8gt Tlt9,.predef_U8,8gt
    b alias_id 1,fixed
  • U8PARM 2 Tlt39,anon_ptr.,8gt by_value
    alias_id 0
  • U8U8LDID 266 lt1,5,.preg_U8gt Tlt9,.predef_U8,8gt
    c alias_id 1,fixed

Aliasing
20
Alias Analysis in Dragon tool
  • Helps to understand and improve complier codes
  • Prints essential program structures and obtain
    runtime information on their applications
  • Consistent with other analysis options in Dragon,
    including Callgraph, Flowgraph, Array Data
    Dependence, Array Regions

21
Dragon File Import Internals
  • All files are binary and generated with dragon
    compiler option

22
Aliasing
Write a Comment
User Comments (0)
About PowerShow.com