Function Outliner::Preprocess::transformNonLocalControlFlow#
Defined in File Preprocess.hh
Function Documentation#
-
SgBasicBlock *Outliner::Preprocess::transformNonLocalControlFlow(SgBasicBlock *b_orig)#
Preprocess non-local control flow for outlining.
Let ‘B’ be an input code block (i.e., an SgBasicBlock node). We define a non-local jump to be any break, continue, return, or goto statement that cedes control to some point outside ‘B’.
Given ‘B’, of the form,
// Start of input block, ‘B’ { … // bunch of code JUMP_1; // First non-local “jump” statement … JUMP_2; // Second non-local “jump” … JUMP_k; // k-th non-local “jump” … }
where each JUMP_i is a non-local jump statement, this routine transforms ‘B’ into
// Start of the transformed ‘B’ { int EXIT_TAKEN__ = 0; // A new block, ‘G’, transformed to use a local ‘goto’. { … { EXIT_TAKEN__ = 1; goto NON_LOCAL_EXIT__; } … { EXIT_TAKEN__ = 2; goto NON_LOCAL_EXIT__; } … { EXIT_TAKEN__ = k; goto NON_LOCAL_EXIT__; } … NON_LOCAL_EXIT__: ; } if (EXIT_TAKEN__ == 1) JUMP_1; else if (EXIT_TAKEN__ == 2) JUMP_2; … else if (EXIT_TAKEN__ == k) JUMP_k; }
and returns ‘T’.