





















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A lecture note from the university of michigan's eecs 483 course, focusing on control flow analysis and optimization in compiler backends. The note covers memory alignment, structure alignment, class problem, compiler backend introduction, and compiler backend structure. It also includes an example of calculating basic blocks and dominators in a code sequence.
Typology: Study notes
1 / 29
This page cannot be seen from the preview
Don't miss anything!






















size = 200, halfword aligned, maps to addrs 1000 - 1199
char b;
size = 1, byte aligned, maps to addr 1200
int c;^
size = 4, word aligned, maps to addrs 1204-
double d;
size = 8, double aligned, maps to addrs, 1208-
short e;
size = 2, halfword aligned, maps to addrs, 1216-
struct {
max field = int, thus must be word aligned, start at addr 1220
char f;
size = 1, byte aligned, maps to addr, 1220
int g[1];
size = 4, word aligned, maps to addrs, 1224-
char h[2];
size = 2, byte aligned, maps to addrs 1228-
} i;^
overall size of struct must be multiple of 4, thus pad out to Total size = 232 bytes
Machine independent opti y Machine dependent opti y Analyze program, understand its behavior, thentransform it to a more efficient form
Deal with limitations of processor y Virtual to physical binding (resource binding)
Instruction set for abstract machine
Opcode y Operands^ X^ Virtual registers – infinite number of these^ X^ Special registers – stack pointer, pc, etc.^ X^ Literals – compile-time constants (no limit onsize of these)^ X^ Symbolic names – start of array, branch targets
Essentially skipping Low IR
L1: r7 = load(r8) L2: r1 = r2 + r3 L3: beq r1, 0, L10 L4: r4 = r5 * r6 L5: r1 = r1 + 1 L6: beq r1 100 L2 L7: beq r2 100 L10 L8: r5 = r9 + 1 L9: r7 = r7 & 3 L10: r9 = load (r3) L11: store(r9, r1)
Remember: 2 main rules: * Rule 1: Each branch ends a basic block * Rule 2: Each branch target starts a basic block
B1^ x = z – 2;^ y = 2 * z;^ if (c) B2 else B
x = z – 2; y = 2 * z; if (c) {^ x = x + 1;^ y = y + 1; } else {^ x = x – 1;^ y = y – 1; } z = x + y
then(fallthrough)
else(taken)
x = x + 1; y = y + 1; goto B
x = x – 1; y = y – 1;
B4^ z = z + y
L1: r7 = load(r8)L2: r1 = r2 + r3L3: beq r1, 0, L10L4: r4 = r5 * r6L5: r1 = r1 + 1L6: beq r1 100 L2L7: beq r2 100 L10L8: r5 = r9 + 1L9: r7 = r7 & 3L10: r9 = load (r3)L11: store(r9, r1) 1 2 3 4 5 6
» Static properties
Æ^ Not executing the code
»^ Dom(entry) = entry »^ Dom(everything else) = all nodes Y Iterative computation »^ while change, do^ y^
change = false y for each BB (except the entry BB)^ X^ tmp(BB) = BB + {intersect of Domof all predecessor BB’s}^ X^ if (tmp(BB) != dom(BB))^ ±
dom(BB) = tmp(BB) ± change = true
Entry^ BB1 BB2^ BB
BB BB^
BB6 BB7 Exit
Entry^ BB1 BB2^ BB
BB BB^
BB6 BB7 Exit