Abstract
Structured programs are believed to be easier to understand, and compiler friendly [5, 10, 45]. However, compilers do not process the source programs directly; they instead work on control flow graphs (CFGs) of the programs. Unfortunately, there is little formalization of structured CFGs. This paper shows how the lack of formalization has led to varying interpretations of structured CFGs. The paper next presents new formalization of structured CFGs which eliminates the ambiguity. Structured CFGs gain importance as they ease compiler optimizations, decompilation, and help reduce the performance degradation caused by thread divergence on SIMD units. The paper elaborates on these benefits. It also shows that compilers, both front-ends and back-ends, may generate unstructured CFGs from structured program sources, which necessitates mechanisms to obtain structured CFGs from unstructured ones.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
References
Control flow structuring without code explosion [Under Submission]
Omni OpenMP benchmarks (2016). http://www.hpcs.cs.tsukuba.ac.jp/omni-compiler/download/download-benchmarks.html. Accessed 11 Mar 2016
Aho, A.V., Sethi, R., Ullman, J.D.: Compilers: Principles, Techniques, and Tools. Addison-Wesley Longman Publishing Co., Inc., Boston (1986)
Allen, F.E., Cocke, J.: A program data flow analysis procedure. Commun. ACM 19(3), 137 (1976). http://doi.acm.org/10.1145/360018.360025
Allen, F.E.: Control flow analysis. In: Proceedings of a Symposium on Compiler Optimization, pp. 1–19. ACM, New York (1970). http://doi.acm.org/10.1145/800028.808479
Allen, J.R., Kennedy, K., Porterfield, C., Warren, J.: Conversion of control dependence to data dependence. In: Proceedings of the 10th ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL 1983, pp. 177–189. ACM, New York (1983). http://doi.acm.org/10.1145/567067.567085
Ammarguellat, Z.: A control-flow normalization algorithm and its complexity. IEEE Trans. Softw. Eng. 18(3), 237–251 (1992). http://dx.doi.org/10.1109/32.126773
Anantpur, J., R., G.: Taming control divergence in GPUs through control flow linearization. In: Cohen, A. (ed.) CC 2014. LNCS, vol. 8409, pp. 133–153. Springer, Heidelberg (2014). doi:10.1007/978-3-642-54807-9_8
Ashcroft, E.A., Manna, Z.: The translation of ‘go to’ programs to ‘while’ programs. In: IFIP Congress, no. 1, pp. 250–255 (1971)
Baker, B.S.: An algorithm for structuring flowgraphs. J. ACM 24(1), 98–120 (1977). http://doi.acm.org/10.1145/321992.321999
Blackham, B., Heiser, G.: Sequoll: A framework for model checking binaries. In: 2013 IEEE 19th Real-Time and Embedded Technology and Applications Symposium (RTAS), pp. 97–106, April 2013
Böhm, C., Jacopini, G.: Flow diagrams, turing machines and languages with only two formation rules. Commun. ACM 9(5), 366–371 (1966). http://doi.acm.org/10.1145/355592.365646
Carter, L., Ferrante, J., Thomborson, C.D.: Folklore confirmed: reducible flow graphs are exponentially larger. In: Conference Record of POPL 2003: The 30th SIGPLAN-SIGACT Symposium on Principles of Programming Languages, New Orleans, Louisisana, USA, 15-17 January 2003, pp. 106–114 (2003). http://doi.acm.org/10.1145/640128.604141
Chapin, N., Denniston, S.P.: Characteristics of a structured program. SIGPLAN Not. 13(5), 36–45 (1978). http://doi.acm.org/10.1145/953395.953398
Collberg, C., Nagra, J.: Surreptitious Software: Obfuscation, Watermarking, and Tamperproofing for Software Protection, 1st edn. Addison-Wesley Professional, Boston (2009)
Collberg, C., Thomborson, C., Low, D.: A taxonomy of obfuscating transformations (1997)
Collberg, C., Thomborson, C., Low, D.: Manufacturing cheap, resilient, and stealthy opaque constructs. In: Proceedings of the 25th ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages, POPL 1998. ACM, New York (1998). http://doi.acm.org/10.1145/268946.268962
Division, N.A.S.: NAS Parallel Benchmarks (2016). https://www.nas.nasa.gov/publications/npb.html/. Accessed 11 March 2016
Erosa, A., Hendren, L.: Taming control flow: a structured approach to eliminating goto statements. In: Proceedings of the 1994 International Conference on Computer Languages, pp. 229–240, May 1994
Hecht, M.S., Ullman, J.D.: Characterizations of reducible flow graphs. J. ACM 21(3), 367–375 (1974). http://doi.acm.org/10.1145/321832.321835
Hecht, M.S.: Flow Analysis of Computer Programs. Elsevier Science Inc., New York (1977)
Hecht, M.S., Ullman, J.D.: Analysis of a simple algorithm for global data flow problems. In: Proceedings of the 1st Annual ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages, POPL 1973, pp. 207–217., ACM, New York (1973). http://doi.acm.org/10.1145/512927.512946
Hepp, S., Brandner, F.: Splitting functions into single-entry regions. In: Proceedings of the 2014 International Conference on Compilers, Architecture and Synthesis for Embedded Systems, CASES 2014, pp. 17:1–17:10. ACM, New York (2014). http://doi.acm.org/10.1145/2656106.2656128
Hundt, R., Raman, E., Thuresson, M., Vachharajani, N.: Mao – an extensible micro-architectural optimizer. In: Proceedings of the 9th Annual IEEE/ACM International Symposium on Code Generation and Optimization, CGO 2011, pp. 1–10. IEEE Computer Society, Washington, D.C. (2011). http://dl.acm.org/citation.cfm?id=2190025.2190077
Kalvala, S., Warburton, R., Lacey, D.: Program transformations using temporal logic side conditions. ACM Trans. Program. Lang. Syst. 31(4), 14:1–14:48 (2009). http://doi.acm.org/10.1145/1516507.1516509
Kandemir, M., Banerjee, P., Choudhary, A., Ramanujam, J., Shenoy, N.: A global communication optimization technique based on data-flow analysis and linear algebra. ACM Trans. Program. Lang. Syst. 21(6), 1251–1297 (1999). http://doi.acm.org/10.1145/330643.330647
Kleinsorge, J.C., Falk, H., Marwedel, P.: Simple analysis of partial worst-case execution paths on general control flow graphs. In: Proceedings of the Eleventh ACM International Conference on Embedded Software, EMSOFT 2013, pp. 16:1–16:10. IEEE Press, Piscataway (2013). http://dl.acm.org/citation.cfm?id=2555754.2555770
Knuth, D.E.: Structured programming with go to statements. ACM Comput. Surv. 6(4), 261–301 (1974). http://doi.acm.org/10.1145/356635.356640
Lattner, C., Adve, V.: LLVM: a compilation framework for lifelong program analysis & transformation. In: Proceedings of the International Symposium on Code Generation and Optimization: Feedback-Directed and Runtime Optimization, CGO 2004, p. 75. IEEE Computer Society, Washington, D.C. (2004). http://dl.acm.org/citation.cfm?id=977395.977673
Matosevic, I., Abdelrahman, T.S.: Efficient bottom-up heap analysis for symbolic path-based data access summaries. In: Proceedings of the Tenth International Symposium on Code Generation and Optimization, CGO 2012, pp. 252–263. ACM, New York (2012). http://doi.acm.org/10.1145/2259016.2259049
Moretti, E., Chanteperdrix, G., Osorio, A.: New algorithms for control-flow graph structuring. In: Fifth Conference on Software Maintenance and Reengineering, CSMR 2001, Lisbon, Portugal, 14–16 March 2001, pp. 184–187 (2001). http://dx.doi.org/10.1109/.2001.914984
Oulsnam, G.: Unravelling unstructured programs. Comput. J. 25(3), 379–387 (1982). http://dx.doi.org/10.1093/comjnl/25.3.379
Oulsnam, G.: The algorithmic transformation of schemas to structured form. Comput. J. 30(1), 43–51 (1987). http://dx.doi.org/10.1093/comjnl/30.1.43
Ramshaw, L.: Eliminating go to’s while preserving program structure. J. ACM 35(4), 893–920 (1988). http://doi.acm.org/10.1145/48014.48021
Sabne, A.J., Lin, Y., Grover, V.: Confluence analysis and loop fast-forwarding for improving SIMD execution efficiency, 21 January 2014, uS Patent Ap. 14/160,426
Shankar, A., Sastry, S.S., Bodík, R., Smith, J.E.: Runtime specialization with optimistic heap analysis. SIGPLAN Not. 40(10), 327–343 (2005). http://doi.acm.org/10.1145/1103845.1094837
Stanier, J., Watson, D.: A study of irreducibility in C programs. Softw. Pract. Experience 42(1), 117–130 (2012). http://dx.doi.org/10.1002/spe.1059
Unger, S., Mueller, F.: Handling irreducible loops: optimized node splitting versus DJ-graphs. ACM Trans. Program. Lang. Syst. 24(4), 299–333 (2002). http://doi.acm.org/10.1145/567097.567098
Williams, M.H.: Generating structured flow diagrams: the nature of unstructuredness. Comput. J. 20(1), 45–50 (1977). http://dx.doi.org/10.1093/comjnl/20.1.45
Williams, M.H., Ossher, H.L.: Conversion of unstructured flow diagrams to structured form. Comput. J. 21(2), 161–167 (1978)
Wimmer, C., Franz, M.: Linear scan register allocation on SSA form. In: Proceedings of the 8th Annual IEEE/ACM International Symposium on Code Generation and Optimization, CGO 2010, pp. 170–179. ACM, New York (2010). http://doi.acm.org/10.1145/1772954.1772979
Woodward, M., Hennell, M., Hedley, D.: A measure of control flow complexity in program text. IEEE Trans. Softw. Eng. 5(1), 45–50 (1979)
Wu, H., Diamos, G., Wang, J., Li, S., Yalamanchili, S.: Characterization and transformation of unstructured control flow in bulk synchronous GPU applications. Int. J. High Perform. Comput. Appl. 26(2), 170–185 (2012). http://dx.doi.org/10.1177/1094342011434814
Xie, Y., Aiken, A.: Saturn: a scalable framework for error detection using Boolean satisfiability. ACM Trans. Program. Lang. Syst. 29(3), Article No. 16 (2007). http://doi.acm.org/10.1145/1232420.1232423
Zhang, F., D’Hollander, E.H.: Using hammock graphs to structure programs. IEEE Trans. Softw. Eng. 30(4), 231–245 (2004). http://dx.doi.org/10.1109/TSE.2004.1274043
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2017 Springer International Publishing AG
About this paper
Cite this paper
Sabne, A., Sakdhnagool, P., Eigenmann, R. (2017). Formalizing Structured Control Flow Graphs. In: Ding, C., Criswell, J., Wu, P. (eds) Languages and Compilers for Parallel Computing. LCPC 2016. Lecture Notes in Computer Science(), vol 10136. Springer, Cham. https://doi.org/10.1007/978-3-319-52709-3_13
Download citation
DOI: https://doi.org/10.1007/978-3-319-52709-3_13
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-52708-6
Online ISBN: 978-3-319-52709-3
eBook Packages: Computer ScienceComputer Science (R0)