A%20Multi-Technique%20C%20Inliner - PowerPoint PPT Presentation

About This Presentation
Title:

A%20Multi-Technique%20C%20Inliner

Description:

University of New Brunswick. July 7, 1998. MCS thesis. by. 2. Organization of presentation ... Remove expensive call-return instructions. Remove parameter loads ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 22
Provided by: chengy5
Category:

less

Transcript and Presenter's Notes

Title: A%20Multi-Technique%20C%20Inliner


1
A Multi-Technique C Inliner
MCS thesis
by
Chengyan Zhao
Supervisor Dr. Owen Kaser
Graduate Academic Unit of Computer Science
University of New Brunswick
July 7, 1998
2
Organization of presentation
1. Introduction 2. Parsing 3. Inlining
Technique 4. Decision-making algorithm 5.
Conclusion
3
1 Introduction
1. Introduction
? What is Inlining?


t strlen(Hello) /callsite / ... int
strlen(char s) register int n n 0
while (s) n return
int AA0000 0 char s Hello
register int n n 0 while ( s) n
AA0000 n t AA0000 int strlen(char
s) / body of strlen /
? Replacement of callsite
? Parameter Passing Simulation
? Return simulation
4
? Why Perform Inlining?
1. Introduction
  • Remove expensive call-return instructions
  • Remove parameter loads and stores
  • Increased opportunities for optimizations

t A(15) int A(int index) return 3
index 1
int temp_i 15 int AA0001 0 AA0001
3 temp_i 1 goto exit_01 exit_01
t AA0001 ...
Before Inlining
After inlining
5
? Inlining vs. Textual Replacement
1. Introduction
if ( f(x) lt 10) int f(int index) / body of
function f /
if( / duplicated body of function f(x) /
lt 10) int f(int index) / body of function f
/
Invalid Modification
Reason ANSI C standard does not allow curly
brackets and commands in expressions
Solution Callsite standardization
6
1. Introduction
??? Top View of Inlining
? 8 Major steps ? Action of each step
7
2 Parsing
2. Parsing
  • Build a parser
  • Parse-tree management -- message system
  • Overview ?

Parse-tree for j2
? Parse-tree introduction ? Tree composition
8
2. Parsing
? Message Broadcaster Tree TreeMsgBroadcaster(
Parameter) CMessage Msg Compose
Message BroadCastMessage(Msg) Return
Result
? Message broadcasting and receiving
? Message Connector void TreeBroadCastMessage(
CMessage Msg) node_-gtBroadCastMessage
(Msg)
? Message Processor void ParseNodeBroadCastMessa
ge(CMessage Msg) switch(Msg.Id)
case Type_of_message ProcMsg(Msg)
break
9
3 Inlining Technique
3 Inlining Technique
  • Standardized format
  • f(e1,e2,,en)
  • y f(e1,e2,,en)
  • Swapping for statements
  • Overview of swapping ?
  • Swapping process
  • Swap conditional controls
  • Swap return statement
  • Swap declaration
  • Splitting for expressions
  • Comma operator removal ?
  • Split short-cut operators (and, or)?
  • Split ? expression
  • Split expression
  • Split nested callsite
  • Limitation on splitting ?

10
Overview of Swapping
3. Inlining Technique
? General rule for if construct swapping
if(condition) then_statement else else_statement
int temp01 condition /
progressing / if(temp01) then_statement
else else_statement
? Parse-tree representation for swapping if
construct
? Parse-node message processing void
IfThenElseNodeBroadCastMessage(CMessage Msg)
Switch(Msg.Id) case
ck_SwapIfCond SwapIfCond(Msg)
break // end of switch
// end of message filter
11
Spliting
3. Inlining Technique
? Comma operator removal
Rule for removing comma operator
temp01 expr1, expr2,
,exprn
expr1 expr2 temp01 exprn
Comma operator removal
? Split short-cut operator ()
int temp01 0 int temp02 f1(x)
if(temp02) int temp03 f2(b) 10
if(temp03) temp01 1 t
temp01
t (f1(x) (f2(b)10))
12
3. Inlining Technique
Split expression (may not always work)
/assume t 10 / x (t)f(t) (t--)
type_of_f temp01 temp01 f(t) x(t)
temp01 (t--)
13
3 Inlining Technique
  • Inline a callsite
  • Body duplication
  • Parameter passing simulation
  • One-dimensional array passing ?
  • Renaming
  • Return simulation
  • Specialization opportunity
  • Callsite removal

One-dimensional array parameter passing Simulation
f(s) / callsite, s is an one-dimensional
array type / void f(int a ) a1 2
t a5
int temp01 s temp011 2 t
temp015 void f(int a ) a1 2 t
a5
14
4 algorithm
4 Decision algorithm
? Eliminate uninlineable callsites ? Profile
information collection Profiler limitation
? Dummy functions ? ? Algorithm ? Inliners
features ? Automatic, source-level ?
Profile-guided ? Multi-technique
(const-propagation, version issue, cache issue) ?
Testings ?
15
Profile Information Collection
4 algorithm
- Profiler Build-in limitation - Dummy function
creation
void Dummy01(void) void Dummy01(void) f(void)
f1( ) Dummy01( ) ... f1( )
Dummy02( ) void Dummy01(void) void
Dummy01(void)
f(void) f1( ) f2( )
f 15 f1 10 Dummy01 5
Dummy02 ...
16
4 algorithm
Inlining Decision Algorithm
for each callsite in the program Determine the
benefit for each type of inlining Adjust benefits
for constant propagation Adjust benefits
for hazardous situations Decide best
callsite and best type Do Inlining Update
parse tree and decision-making data structures
17
Experimental Results
4 algorithm
? Gcc 2.7.2.1 ? PentiumPro 266 machine
18
5. Conclusion
5. Conclusion and future work ? Conclusion ?
OO parser ? Inlining optimization (4 43) ?
Design patterns ? Future work ? Multi-file
support ? Pipeline interlock ? Database in
inlining
19
(No Transcript)
20
(No Transcript)
21
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com