UP | HOME

Special Topics: Compiler Optimization
Lecture 21-22

Table of Contents

Compiler Optimization

Provably Correct Peephole Optimizations with Alive

Basics of program analysis

What is soundness (in static analysis)?

Local optimizations

Global optimizations: 1 2 3

Resources on register allocation: LLVM blog LLVM reference Survey paper Linear scan algorithm

LLVM passes

LLVM talks: 1 2

Undefined behavior in LLVM: 1 2

while(x > 0) { x = x - 1; }
LABEL _l0_main  # head label

# generated code for x > 0
CONST _t2 0
GOTOLE _l2_main x _t2
CONST _t3 1
GOTO _l3_main
LABEL _l2_main
CONST _t3 0
LABEL _l3_main

GOTOZE _l1_main _t3   # branch for false

# generated code for the body
CONST _t4 1
SUB _t5 x _t4
ASSIGN x _t5

GOTO _l0_main  # branch to head
LABEL _l1_main  # end label

CONST _t3 0 # only need to do this once CONST _t4 1 # duplicate of _t3 ASSIGN x _t5 # can avoid assign by making x destination of subtraction

Author: Paul Gazzillo

Created: 2022-04-04 Mon 14:02