SlideShare a Scribd company logo
2
Most read
5
Most read
6
Most read
BASIC
BLOCKS AND
FLOW
GRAPHS
JGALINO
Construction of
the
Representation
1. Partition the intermediate code
into basic blocks
2. The basic blocks become the
nodes of a flow graph and the
edges indicate the flow (which
blocks follow which)
Basic Blocks
*a piece of straight line code
i.e. there are no jumps in or out
of the middle of a block
1. the flow of control can only
enter the basic block through
the first instruction
2. control will leave the block
without halting or branching,
except possibly, at the last
instruction in the block
Constructing
Basic Blocks
1) Determine a set of leaders,
the first instruction of blocks
2) A basic block consists of a
leader and all the following
instructions until the next
leader
Constructing
Basic Blocks
Determine a set of leaders
1) The first instruction is a leader
2) Instruction L is a leader if there is
an instruction a
or a
3) Instruction L is a leader if it
immediately follows an
instruction a
or a
if … goto L
goto L
if … goto B
goto B
goto B
Flow Graph
Once an intermediate-code
program is partitioned into basic
blocks, we represent the flow of
control between them by a flow
graph.
Constructing
the Flow
Graph
There is an edge from block B to
block C iff it is possible for the first
instruction in block C to
immediately follow the last
instruction in block B
1. There is a conditional or unconditional jump from the
end of B to the beginning of C
Constructing
the Flow
Graph
There is an edge from block B to
block C iff it is possible for the first
instruction in block C to
immediately follow the last
instruction in block B
2. C immediately follows B in the original order of the
three-address instructions, and B does not end in an
unconditional jump
Constructing
the Flow
Graph
Often we add two nodes, called
the entry and exit.
1. There is an edge from the entry to the first
executable node.
Constructing
the Flow
Graph
Often we add two nodes, called
the entry and exit.
2. There is an edge to the exit from any basic block that
contains an instruction that could bet eh last
executed instruction of the program
goto B
goto B
Loops
We say that a set of nodes L in a
flow graph is a loop if
1. There is a node in L called the loop entry with the
property that no other node in L has a predecessor
outside L.That is , every path from the entry of the entire
flow graph to any node in L goes through the loop entry.
Loops
We say that a set of nodes L in a
flow graph is a loop if
2. Every node in L has a nonempty path, completely
within L, to the entry of L.
Fin

More Related Content

PPTX
Code Optimization
PDF
Syntax Directed Definition and its applications
PDF
COMPILER DESIGN- Syntax Directed Translation
PPTX
Lecture 14 run time environment
PDF
PPTX
Peephole Optimization
PPTX
Peephole optimization techniques in compiler design
PPTX
Phases of Compiler
Code Optimization
Syntax Directed Definition and its applications
COMPILER DESIGN- Syntax Directed Translation
Lecture 14 run time environment
Peephole Optimization
Peephole optimization techniques in compiler design
Phases of Compiler

What's hot (20)

PPTX
RECURSIVE DESCENT PARSING
PPTX
Unit iv(simple code generator)
PDF
Issues in the design of Code Generator
PPT
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
PPTX
Code Generation
PPT
Code Optimization
PPT
Chapter 5 Syntax Directed Translation
PDF
Lexical Analysis - Compiler design
PPTX
Input-Buffering
PPTX
Basic blocks and control flow graphs
PPTX
Error Detection & Recovery
PPTX
Symbol Table
PPT
1.Role lexical Analyzer
PPT
Lecture 1 - Lexical Analysis.ppt
PDF
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
PPTX
Segmentation in operating systems
PDF
Intermediate code generation in Compiler Design
PPTX
Syntax Analysis in Compiler Design
PPTX
contiguous memory allocation.pptx
PDF
Code optimization in compiler design
RECURSIVE DESCENT PARSING
Unit iv(simple code generator)
Issues in the design of Code Generator
12-Syntax Directed Definition – Evaluation Order-09-06-2023.ppt
Code Generation
Code Optimization
Chapter 5 Syntax Directed Translation
Lexical Analysis - Compiler design
Input-Buffering
Basic blocks and control flow graphs
Error Detection & Recovery
Symbol Table
1.Role lexical Analyzer
Lecture 1 - Lexical Analysis.ppt
14-Intermediate code generation - Variants of Syntax trees - Three Address Co...
Segmentation in operating systems
Intermediate code generation in Compiler Design
Syntax Analysis in Compiler Design
contiguous memory allocation.pptx
Code optimization in compiler design
Ad

Viewers also liked (7)

PDF
Dataflow Analysis
PPTX
Basic Block
PPTX
Code optimization
PPTX
Dag representation of basic blocks
PPT
Code generator
PPTX
Three address code In Compiler Design
PPTX
Code generation
Dataflow Analysis
Basic Block
Code optimization
Dag representation of basic blocks
Code generator
Three address code In Compiler Design
Code generation
Ad

Similar to Basic Blocks and Flow Graphs (6)

PPTX
PPT
unit-5.pptvshvshshhshsjjsjshhshshshhshsj
PDF
Code optimization lecture
PDF
Control engineering module 3 part-A
PPTX
Machine_Learning_JNTUH_R18_UNIT5_CONCEPTS.pptx
PPTX
Chapter 4: Combinational Logic
unit-5.pptvshvshshhshsjjsjshhshshshhshsj
Code optimization lecture
Control engineering module 3 part-A
Machine_Learning_JNTUH_R18_UNIT5_CONCEPTS.pptx
Chapter 4: Combinational Logic

More from Jenny Galino (8)

PPTX
Heap Management
PPTX
Semantic Networks
PPTX
Upper OSI Layers
PPTX
Main Memory
PPTX
Genetically Modified Food
PPTX
Geometry
PPTX
Hierarchical Memory System
PPTX
Knapsack Problem
Heap Management
Semantic Networks
Upper OSI Layers
Main Memory
Genetically Modified Food
Geometry
Hierarchical Memory System
Knapsack Problem

Recently uploaded (20)

PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Nekopoi APK 2025 free lastest update
PDF
AI in Product Development-omnex systems
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PPTX
history of c programming in notes for students .pptx
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
System and Network Administraation Chapter 3
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PDF
Digital Strategies for Manufacturing Companies
PDF
Softaken Excel to vCard Converter Software.pdf
PDF
System and Network Administration Chapter 2
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
Essential Infomation Tech presentation.pptx
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Nekopoi APK 2025 free lastest update
AI in Product Development-omnex systems
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Upgrade and Innovation Strategies for SAP ERP Customers
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
history of c programming in notes for students .pptx
VVF-Customer-Presentation2025-Ver1.9.pptx
CHAPTER 2 - PM Management and IT Context
System and Network Administraation Chapter 3
Navsoft: AI-Powered Business Solutions & Custom Software Development
Design an Analysis of Algorithms II-SECS-1021-03
Digital Strategies for Manufacturing Companies
Softaken Excel to vCard Converter Software.pdf
System and Network Administration Chapter 2
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Essential Infomation Tech presentation.pptx

Basic Blocks and Flow Graphs

  • 2. Construction of the Representation 1. Partition the intermediate code into basic blocks 2. The basic blocks become the nodes of a flow graph and the edges indicate the flow (which blocks follow which)
  • 3. Basic Blocks *a piece of straight line code i.e. there are no jumps in or out of the middle of a block 1. the flow of control can only enter the basic block through the first instruction 2. control will leave the block without halting or branching, except possibly, at the last instruction in the block
  • 4. Constructing Basic Blocks 1) Determine a set of leaders, the first instruction of blocks 2) A basic block consists of a leader and all the following instructions until the next leader
  • 5. Constructing Basic Blocks Determine a set of leaders 1) The first instruction is a leader 2) Instruction L is a leader if there is an instruction a or a 3) Instruction L is a leader if it immediately follows an instruction a or a if … goto L goto L if … goto B goto B goto B
  • 6. Flow Graph Once an intermediate-code program is partitioned into basic blocks, we represent the flow of control between them by a flow graph.
  • 7. Constructing the Flow Graph There is an edge from block B to block C iff it is possible for the first instruction in block C to immediately follow the last instruction in block B 1. There is a conditional or unconditional jump from the end of B to the beginning of C
  • 8. Constructing the Flow Graph There is an edge from block B to block C iff it is possible for the first instruction in block C to immediately follow the last instruction in block B 2. C immediately follows B in the original order of the three-address instructions, and B does not end in an unconditional jump
  • 9. Constructing the Flow Graph Often we add two nodes, called the entry and exit. 1. There is an edge from the entry to the first executable node.
  • 10. Constructing the Flow Graph Often we add two nodes, called the entry and exit. 2. There is an edge to the exit from any basic block that contains an instruction that could bet eh last executed instruction of the program
  • 13. Loops We say that a set of nodes L in a flow graph is a loop if 1. There is a node in L called the loop entry with the property that no other node in L has a predecessor outside L.That is , every path from the entry of the entire flow graph to any node in L goes through the loop entry.
  • 14. Loops We say that a set of nodes L in a flow graph is a loop if 2. Every node in L has a nonempty path, completely within L, to the entry of L.
  • 15. Fin

Editor's Notes

  • #2: This section introduces a graph presentation of intermediate code (although not constructed by a code-generation algo) which is is helpful for discussing code generation Better register allocation, if we know how values are defined and used
  • #7: The nodes of the flow graph are the basic blocks
  • #9: We say that B is a predecessor of C , and C is a successor of B .
  • #11: If the final instruction of the program is not an unconditional jump, then the block containing the final instruction of the program is one predecessor of the exit, but so is any basic block that has a jump to code that is not part of the program.
  • #13: Note from that in the flow graph, it is normal to replace the jumps to instruction numbers or labels by jumps to basic blocks
  • #14: If the final instruction of the program is not an unconditional jump, then the block containing the final instruction of the program is one predecessor of the exit, but so is any basic block that has a jump to code that is not part of the program.
  • #15: If the final instruction of the program is not an unconditional jump, then the block containing the final instruction of the program is one predecessor of the exit, but so is any basic block that has a jump to code that is not part of the program.