Compiler optimisation of intermediate representation via analysis of variable assignement and scope

EP4720841A1Pending Publication Date: 2026-04-08HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
EP · EP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-08-07
Publication Date
2026-04-08

AI Technical Summary

Technical Problem

Existing escape analysis techniques lack specificity and precision, failing to indicate exactly where an object escapes to, which limits optimization possibilities such as hoisting memory allocations out of loops.

Method used

A computing apparatus and method that performs static analysis of source code by generating a connection graph, determining the escaping scope of nodes, and propagating escapement through the graph to generate an optimized connection graph, enabling more precise optimizations like stack allocation and loop invariant code motion.

Benefits of technology

The approach provides precise information on where objects escape, enabling optimizations like hoisting allocations out of loops, which were not possible with existing escape analyses, thereby improving compiler efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure EP2023071788_13022025_PF_FP_ABST
    Figure EP2023071788_13022025_PF_FP_ABST
Patent Text Reader

Abstract

Described is a computing apparatus (900) for static analysis (301) of source code (402), the computing apparatus being configured to: obtain an abstract code representation (204a) of the source code; generate a connection graph (701) from the abstract code representation, the connection graph (701) representing the connectivity between constructs in the source code (402); determine an escaping scope (602, 603) of one or more nodes (601) in the connection graph (701), the nodes (601) in the connection graph (701) corresponding to the constructs in the source code (402); and propagate an escapement of the one or more nodes (601) through the connection graph (701), the escapement being based on the escaping scope of the one or more nodes (601), to generate an optimised connection graph (205a, 705). In this way, the optimised connection graph, based on the escaping scope of the nodes, may be used to optimise a compiler (404).
Need to check novelty before this filing date? Find Prior Art

Description

[0001] COMPILER OPTIMISATION OF INTERMEDIATE REPRESENTATION VIA ANALYSIS OF VARIABLE ASSIGNEMENT AND SCOPE

[0002] TECHNUICAL FIELD

[0003] The present disclosure relates to an apparatus and method for static analysis of source code.

[0004] BACKGROUND

[0005] Escape Analysis (EA) is a well-known compiler analysis technique for determining whether an object or reference escapes a scope. In other words, that object is read from or written to outside that scope. This escape information can be used to determine whether it is safe to allocate an, usually heap-allocated, object on the stack.

[0006] EA can also be used for scalar replacement - replacing an object or structure with its scalar fields - and lock elision - in which locks are removed in concurrent programs when escape analysis shows an object does not escape a thread.

[0007] Fig. 1 A shows a function in which the object does not escape the scope of the function. In this example function, the object of interest, o, does not escape the scope of the function.

[0008] Fig. IB shows a function in which the object does not escape the scope of the function. In this example function, the object of interest, o, does escape the scope of the function. In this case, the object is assigned to a global variable, GlobalVar.

[0009] The state of the art in EA can be considered to be the approach described in Escape analysis for Java Choi et al. (OOPSLA 1999). The approach described in this paper is to build a connection graph of variables within a function, showing how they are connected to each other. A set of rules is applied to variables to determine whether and how they escape the scope of the function, and this escapement of a node in the connection graph is propagated to its neighbours. This propagation continues until a fixed point is reached i.e., no further changes in the graph are noted with a new propagation step. The resulting escapement of the node is used to inform optimisations such as stack allocation of formerly heap objects. Partial Escape Analysis and Scalar Replacement for Java Stadler et al. (CGO 2014) attempts to extend escape analysis by including branching behaviour in the calculation e.g., if a condition is true, this object escapes, but does not escape otherwise.

[0010] The prior art can indicate whether or not an object escapes a scope, but may not provide any more information. The prior art may not indicate specifically where and object escapes to i.e., which scope it is accessible. This may limit the optimizations that this technique enables e.g., it may not be possible to hoist memory allocations from a loop using the escape information produced from the prior art, and it may not be possible to know whether an object escapes a loop - existing escape analyses may be limited to function and thread scopes.

[0011] It is desirable to develop an apparatus and method that overcomes the above problems.

[0012] SUMMARY

[0013] According to a first aspect, there is provided a computing apparatus for static analysis of source code, the computing apparatus comprising one or more processors and a memory storing in non-transient form data defining program code executable by the one or more processors, wherein the program code is executable by the one or more processors so that the computing apparatus is configured to: obtain an abstract code representation of the source code; generate a connection graph from the abstract code representation, the connection graph representing the connectivity between constructs in the source code; determine an escaping scope of one or more nodes in the connection graph, the nodes in the connection graph corresponding to the constructs in the source code; and propagate an escapement of the one or more nodes through the connection graph, the escapement being based on the escaping scope of the one or more nodes, to generate an optimised connection graph. In this way, the optimised connection graph, based on the escaping scope of the nodes, may be used to optimise a compiler.

[0014] In some implementations, the computing apparatus may be configured to obtain the source code and generate the abstract code representation of the source code. In this way, the apparatus may be able to carry out the optimised compiling directly from the source code.

[0015] In some implementations, the abstract code representation comprises one of: a graph-based intermediate generalisation, optionally the graph-based intermediate generalisation being a hypergraph; an abstract syntax tree (AST); or a static single assignment (SSA). In this way, the apparatus may be applied to different types of abstract code representations.

[0016] In some implementations, the computing apparatus may be configured to generate the connection graph from the abstract code representation by removing one or more transient nodes. In this way, transient nodes may be removed from the static analysis, a result of may provide an improved optimisation.

[0017] In some implementations, the escaping scope represents a block of unevaluated code comprising one of: a function; a loop; and an unevaluated argument. In this way, the apparatus may be implemented for a thunk.

[0018] In some implementations, the computing apparatus may be configured to inline the connection graph. In this way, the called function may be inlined into its caller.

[0019] In some implementations, the computing apparatus may be configured to propagate the escapement of the one or more nodes through the connection graph by means of a fixed-point algorithm. In this way, the propagation may be applied across the entire connection graph automatically.

[0020] In some implementations, the computing apparatus may be configured to propagate the escapement of the one or more nodes through the connection graph until the connection graph reaches a steady state. In this way, the propagation may termination when no further propagation with required.

[0021] In some implementations, the computing may be further configured to annotate the optimised connection graph to indicate a type of optimisation to be performed on a node of the one or more nodes. In this way, the static analysis may be utilised in manual initiation and control of a compiler.

[0022] In some implementations, the type of optimisation to be performed on a node comprises: allocating the node to a stack, and / or hoisting the node to an escaping scope of the node. In this way, the static analysis may be utilised in manual initiation and control of a compiler.

[0023] In some implementations, the computing apparatus may be further configured to allocate a node of the one or more nodes to a stack, and / or wherein the computing apparatus is further configured to hoist a node of the one or more nodes to the escaping scope of the node. In this way, the static analysis may be utilised in automatic initiation and control of a compiler.

[0024] In some implementations, the computing apparatus may be configured to compile the source code into an executable code based on the optimised connection graph. In this way, the compiling of the source code by the apparatus itself may be optimised.

[0025] In some implementations, the computing apparatus may be configured to execute the executable code. In this way, the execution of the executable code by the apparatus itself may be optimised.

[0026] According to a second aspect, there is provided a computer-readable storage medium for static analysis of source code configured to: obtain an abstract code representation of the source code; generate a connection graph from the abstract code representation, the connection graph representing the connectivity between constructs in the source code; determine an escaping scope of one or more nodes in the connection graph, the nodes in the connection graph corresponding to the constructs in the source code; and propagate an escapement of the one or more nodes through the connection graph, the escapement being based on the escaping scope of the one or more nodes, to generate an optimised connection graph.

[0027] According to a third aspect, there is provided a computer program product for static analysis of source code configured to: obtain an abstract code representation of the source code; generate a connection graph from the abstract code representation, the connection graph representing the connectivity between constructs in the source code; determine an escaping scope of one or more nodes in the connection graph, the nodes in the connection graph corresponding to the constructs in the source code; and propagate an escapement of the one or more nodes through the connection graph, the escapement being based on the escaping scope of the one or more nodes, to generate an optimised connection graph.

[0028] According to a second aspect, there is provided a method for compiler static analysis of source code, the method comprising steps of: obtaining an abstract code representation of the source code; generating a connection graph from the abstract code representation, the connection graph representing the connectivity between constructs in the source code; determining an escaping scope of one or more nodes in the connection graph, the nodes in the connection graph corresponding to the constructs in the source code; and propagating an escapement of the one or more nodes through the connection graph, the escapement being based on the escaping scope of the one or more nodes, to generate an optimised connection graph.

[0029] BRIEF DESCRIPTION OF THE FIGURES

[0030] The present disclosure will now be described by way of example with reference to the accompanying drawings. In the drawings:

[0031] Fig. 1 A shows a function in which the object does not escape the scope of the function.

[0032] Fig. IB shows a function in which the object does not escape the scope of the function.

[0033] Fig. 2 schematically illustrates a pipeline of the present application.

[0034] Fig. 3 schematically illustrates a compiler architecture of the present application.

[0035] Fig. 4 schematically illustrates a further compiler architecture of the present application.

[0036] Fig. 5 schematically illustrates an escape analysis architecture of the present application.

[0037] Fig. 6 shows a function of the present application.

[0038] Fig. 7 schematically illustrates a graph intermediate representation of the present application.

[0039] Fig. 8 shows an example of a computer implemented method for static analysis of source code.

[0040] Fig. 9 shows an example of an apparatus configured to perform the methods described herein.

[0041] DETAILED DESCRIPTION

[0042] The apparatuses and methods described herein concern static analysis of source code.

[0043] Embodiments of the present disclosure may tackle one or more of the problems previously mentioned by determining an escaping scope of one or more nodes in the connection graph and using the escaping scopes to generate an optimised connection graph. In this way, the optimised connection graph, based on the escaping scope of the nodes, may be used to optimise a compiler.

[0044] The present application may solve the problem of the lack of specificity and precision in existing escape analysis by showing exactly where an object escapes to, rather than just providing a binary escape / no escape answer. The present disclosure may also enable a Loop Invariant Code Motion (LICM) optimization - specifically, the hoisting of allocations out of a loop. This may not have been possible with existing escape analyses.

[0045] The present application may be applicable as an analysis or optimization pass in a compiler for computer program code, known as source code. The present application may be applied to an abstract representation of the source code during compilation e.g. an using an intermediate representation (IR).

[0046] The compiler may comprise a multi-pass architecture: including several individual analyses or translations applied in sequence as a pipeline. The present application may be used for a typical general purpose computer programming language, compiled by an ahead-of-time static compiler into native machine code.

[0047] The present application may be used for graph-based high-level intermediate representations. The present application may also be applied to Abstract Syntax Trees (ASTs). The present application may also be applied to a low-level Static Single Assignment (SSA) IR e.g. a low level virtual machine (LLVM). Rather than determining the escaping thunk, the system may determine which basic block the node would escape to. Intraprocedural analysis may be omitted from the system in this case.

[0048] Fig. 2 schematically illustrates a pipeline 200 of the present application. The pipeline 200 may receive inputs from a user 201. The user 201 may be a programmer. The pipeline 201 may comprise a compiler module 204. The pipeline 205 may comprise an executable module 205. The user 201 may input a source code 202 to the pipeline 200. The user 201 may input a source code 202 to the compiler 204. The source code 202 may be inputted into the compiler 204 to be compiled. The source code 202 may comprise a text file. The source code 202 may invoke the compiler 204 executable program. The compiler 204 may compile the source code 202 into an executable code. The compiler 204 may receive optimisation flags 203. The user 201 may input the optimisation flags 203. The user 201 may control the optimization level of the compiler 204, or enable / disable specific optimisation, by passing command line flags or options to the compiler executable (e.g. -01 -02 -03 etc.). The compiler 204 may compile the source code 202 using the optimisation flags 203. The optimisation flags 203 may guide the compiler 204 to generate an optimised executable code. The compiler 204 may output the executable code into the executable module 205. The executable code may be executed by the executable module 205. The executable model 205 may output the outputs of the executable code. Alternatively, the user 201 may be outputted the executable code as a result.

[0049] Fig. 3 schematically illustrates a compiler architecture 300 of the present application. The compiler module 204 may comprise the compiler architecture 300. The compiler architecture 300 may obtain the source code 202 from the user 201. The compiler architecture 300 may generate the executable code.

[0050] The compiler pipeline 300 may comprise a lexical analysis module 301. The lexical analysis module 301 may receive the source code 202. The lexical analysis module 301 may generate a token stream 301a. The lexical analysis module 301 may generate the token stream 301a by means of Lexing, also known as tokenisation.

[0051] The compiler pipeline 300 may comprise a syntactic analysis module 302. The syntactic analysis module 302 may receive the token stream 301a. The syntactic analysis module 302 may generate an abstract syntax tree (AST) 302a. The syntactic analysis module 302 may generate the AST 302a by means of syntactic analysis, or by means of parsing, of the token stream 301a. The AST may be replaced by any other suitable syntax.

[0052] The compiler pipeline 300 may comprise a semantic analysis module 303. The semantic analysis module 303 may receive the AST 302a. The semantic analysis module 303 may generate an annotated abstract syntax tree (AST) 303a. The semantic analysis module 303 may generate the annotated AST 303a by means of semantic analysis of the AST 302a. The semantic analysis may comprise type checking, and / or soundness checking.

[0053] The compiler pipeline 300 may comprise a transformation module 304. The transformation module 304 may receive the annotated AST 303a. The transformation module 304 may generate an abstract code representation 304a. The transformation module 304 may generate the abstract code representation 304a by means of intermediate representation transformation. The abstract code representation 304a may comprise graph-based intermediate generalisation. The graph-based intermediate generalisation may comprise a hypergraph (such as a hypergraph of nodes), a transformed abstract syntax tree, or a static single assignment (SSA). The abstract code representation 304a may be a high-level intermediate generalisation.

[0054] The combination of the lexical analysis module 301, the syntactic analysis module 302, the semantic analysis module 303 and the transformation module 304 may generate the abstract code representation 304a of the source code 202. It will be appreciated that more or less than the modules 301 to 304, and the processes carried out by such modules 301 to 304, may be used to generate abstract code representation 304a of the source code 202. The abstract code representation 304a of the source code 202 may be generated in a single step.

[0055] The compiler pipeline 300 may comprise an optimisation module 305. The optimisation module 305 may receive the abstract code representation 304a. The optimisation module 305 may generate an optimised abstract code representation 305a. The optimisation module 305 may generate the optimised abstract code representation 305a by optimising the abstract code representation 304a. The optimisation may improve the abstract code representation’s 305a suitability for the compiling. The optimised abstract code representation 305a may be a high- level intermediate generalisation.

[0056] The compiler pipeline 300 may comprise a low-end compiler module 306. The low-end compiler module 306 may receive the optimised abstract code representation 305a. The low- end compiler module 306 may generate a low-end abstract code representation 306a. The low-end compiler module 306 may generate the low-end abstract code representation 306a by compiling the optimised abstract code representation 305a to a lower-level representation.

[0057] The compiler pipeline 300 may comprise a back-end compiler module 307. The back-end compiler module 307 may receive the low-end abstract code representation 306a. The back- end compiler module 307 may generate executable code 307a. The low-end compiler module 306 may generate the executable code 307 by compiling the low-end abstract code representation 306a to a target back-level representation. The compilation may form a code suitable for execution.

[0058] Fig. 4 schematically illustrates a further compiler architecture 400 of the present application. The further compiler architecture 400 may include all the modules of the compiler architecture 300. The compiler architecture 400 may further comprise a static analysis module 401. The statis analysis module 401 may used for the optimisation of the abstract code representation 304a used by the optimisation module 305. The statis analysis module 401 may be used for the static analysis of the abstract code representation 304a used by the optimisation module 305. The static analysis module 401 may output static analysis to the optimisation module 305. The optimisation module 305 may use the static analysis to optimise the abstract code representation 304a. The use of the static analysis module 401 may be controlled with a command line option, and / or may can be enabled with a -02 option.

[0059] Fig. 5 schematically illustrates an escape analysis architecture 500 of the present application. The static analysis module 401 may comprise the escape analysis architecture 500. The escape analysis architecture 500 may generate an optimised connection graph 505. The optimised connection graph 505 may be used by the optimisation module 305 to generate the optimised abstract code representation 305a.

[0060] The escape analysis architecture 500 may comprise a connection graph builder 501. The connection graph builder 501 may generate a connection graph 501. The connection graph builder 501 may generate the connection graph 501 from the abstract code representation 304a. The connection graph 501 may represent the connectivity between any constructs in the source code 202. The connection graph 501 may comprise one or more nodes. The constructs in the source code 202 may be represented by nodes in the connection graph 501. Each node in the connection graph 501 may correspond to a construct in the source code 202. The connection graph 501 may represent the connectivity between nodes in individual functions. The connection graph 501 may only represent the connectivity between nodes in individual functions. The connection graph builder 501 may generate the connection graph 501 from the abstract code representation 304a by removing one or more transient nodes. In particular, the connection graph builder 501 may generate the connection graph 501 from the abstract code representation 304a by removing any transient nodes.

[0061] The escape analysis architecture 500 may comprise a connection graph inliner 502. The connection graph inliner 502 may generate an inlined connection graph 502. The connection graph inliner 502 may generate the inlined connection graph 502 by inlining the connection graph 501. Inlining the connection graph 501 may comprise replacing the function call site with the body of the called function. Inlining the connection graph 501 may comprise inlining the called function into its caller. The intraprocedural case may be handled by the inlining of the connection graph.

[0062] The escape analysis architecture 500 may comprise a connection graph traverser 503. The connection graph traverser 503 may generate a traversed connection graph 503. The connection graph traverser 503 may generate the traversed connection graph 503 by traversal of the inlined connection graph 502. Traversal of the inlined connection graph 502 may comprise visiting each of the nodes in the connection graph 501.

[0063] The escape analysis architecture 500 may comprise an escapement setting module 504. The escapement setting module 504 may determine the escaping scope of each of the nodes in the connection graph 501. The escapement setting module 504 may determine which scope each of the nodes escapes to. An escaping scope may also be known as a binding. In the case of graph-based IRs, the escaping scope may be known as a thunk. Thunks may be nested and correspond closely to source code scopes, but may comprise a finer grain. The escaping scope, or the thunk, may represent a block of unevaluated code. The block of unevaluated code may comprise one of a function, a loop and an unevaluated argument. Rather than detect which thunk a node escapes to, the escapement setting module 504 may track which function, loop, block node etc. the node escapes to. The escapement setting module 504 may be manually encoded for different ASTs for different languages.

[0064] The escape analysis architecture 500 may comprise a fixed-point escapement propagation module 505. The fixed-point escapement propagation module 505 may propagate the escapement of the one or more nodes through the connection graph 501. The escapement may be based on the escaping scope of the one or more nodes. The escapement may comprise a combination of the escaping scope of each of the nodes. In other words, the escapement may incorporate the escaping scope of each of the nodes. Propagating the escapement through the connection graph 501 may generate an optimised connection graph 505. The fixed-point escapement propagation module 505 may propagate the escapement of the one or more nodes through the connection graph 501 by means of a fixed-point algorithm. The fixed-point escapement propagation module 505 may propagate the escapement of the one or more nodes through the connection graph 501 until the connection graph 501 reaches a steady state. In other words, the escapement is propagated until there are no further changes in the connection graph. The escapement analysis architecture 500 may comprise an annotation engine 506. The annotation engine 506 may annotate the optimised connection graph 505 to generate an annotated optimised connection graph 506. The annotations may be applied to the connection graph 506 itself. Alternatively, the annotations may be associated with aspects of the connection graph 506. The annotations may indicate a type of optimisation to be performed on a node. The type of optimisation to be performed may be annotated to each of the nodes respectively. Where an optimisation is not required, an annotation may not be included on the node. The type of optimisation to be performed on the node may include allocating the node to a stack, and / or hoisting the node to an escaping scope of the node. The escaping scope of the node may be the escaping scope determined by the escapement setting module 504. In the case of the optimisation being stacking, the annotation may comprise “stackable”. IN the case of the optimisation being hoisting, the annotation may comprise “hoistable”.

[0065] The escapement analysis architecture 500 may comprise a loop hoisting transformation module 507. The loop hoisting module 507 may hoist a node to the escaping scope of the node. The escaping scope of the node may be the escaping scope determined by the escapement setting module 504. The loop hoisting module 507 may hoist one or more of the nodes to their respective escaping scope, should an escaping scope have been determined for the respective node. Based on the hoisted nodes, the loop hoisting transformation module 507 may generate a node hoisted optimised connection graph. The hoisting may be carried by means of a loop invariant code motion (LICM). The loop expressions may be based on the escaping scope determined by the escapement setting module 504. Hoisting the node may comprise hoisting the node to some thunk if the node’s escaping thunk is within that thunk. The hoisting may be done combination with the use of use-def chains analysis for determining whether the size of an array is invariant and thus its allocation may be hoisted.

[0066] The escapement analysis architecture 500 may also comprise a stack allocation module (not shown in Fig. 5). The stack allocation module may allocate a node to the stack. The stack allocation module may allocate one or more of the nodes to the stack. Based on the stacked nodes, the stack allocation module may generate a node stacked optimised connection graph. Allocating the node on the stack may comprise the node not escaping a function-thunk.

[0067] In the case of automatic compiling, the compiler 204 may compile the source code 202 based on the optimised connection graph 505. Alternatively, the automatic compiling may be based on the annotated optimised connection graph 502, the node hoisted optimised connection graph, or the node stacked optimised connection graph. In the case of manual compiling, a compiler, which may or may not be the compiler 204, may be instructed to the compile the source code based on the annotated optimised connection graph 506. Alternatively, the manual compiling may be based on the node hoisted optimised connection graph, or the node stacked optimised connection graph.

[0068] Fig. 6 shows a function 600 of the present application. The function 600 shows how an object, or a node, may escape. Fig. 7 schematically illustrates a graph intermediate representation 700 of the present application. The graph intermediate representation 700 corresponding to the function 600. The graph intermediate representation 700 comprises an object 701, also known as a node 701. The node 701 may escape to one of a plurality of scopes. In the example shown in Fig. 7, the node 701 may escape to an inner loop scope 702, an outer loop scope 703, or outside of the function scope 704. In the examiner shown in Fig. 7 the node 701 escapes to the outer loop scope 703 to the reference position 705.

[0069] Fig. 8 summarises an example of a method 800 for compiler static analysis of source code. At step 801, the method 800 comprises obtaining an abstract code representation of the source code. At step 802, the method 800 comprises generating a connection graph from the abstract code representation, the connection graph representing the connectivity between constructs in the source code. At step 803, the method 800 comprises determining an escaping scope of one or more nodes in the connection graph, the nodes in the connection graph corresponding to the constructs in the source code. At step 804, the method 800 comprises propagating an escapement of the one or more nodes through the connection graph, the escapement being based on the escaping scope of the one or more nodes, to generate an optimised connection graph.

[0070] An example of an apparatus 900 configured to implement the method 800 is schematically illustrated in Fig. 9. The computing apparatus 900 may comprise the pipeline 200. The apparatus 900 may be implemented on an electronic device, such as a computer, laptop, tablet, or smart phone.

[0071] The apparatus 900 comprises a processor 901 configured to process the datasets in the manner described herein. For example, the processor 901 may be implemented as a computer program running on a programmable device such as a Central Processing Unit (CPU). The apparatus 900 comprises a memory 902 which is arranged to communicate with the processor 901. Memory 902 may be a non-volatile memory. The processor 901 may also comprise a cache (not shown in Fig. 9), which may be used to temporarily store data from memory 902. The apparatus may comprise more than one processor and more than one memory. The memory may store data that is executable by the processor. The processor may be configured to operate in accordance with a computer program stored in non-transitory form on a machine- readable storage medium. The computer program may store instructions for causing the processor to perform its methods in the manner described herein. The method steps described herein may be carried out by a computer-readable storage medium. The method steps described herein may be carried out by a computer program product. The applicant hereby discloses in isolation each individual feature described herein and any combination of two or more such features, to the extent that such features or combinations are capable of being carried out based on the present specification as a whole in the light of the common general knowledge of a person skilled in the art, irrespective of whether such features or combinations of features solve any problems disclosed herein, and without limitation to the scope of the claims. The applicant indicates that aspects of the present disclosure may consist of any such individual feature or combination of features. In view of the foregoing description, it will be evident to a person skilled in the art that various modifications may be made within the scope of the disclosure.

Claims

CLAIMS1. A computing apparatus (900) for static analysis (401) of source code (202), the computing apparatus (900) comprising one or more processors (901) and a memory (902) storing in non-transient form data defining program code executable by the one or more processors (901), wherein the program code is executable by the one or more processors (901) so that the computing apparatus (900) is configured to: obtain an abstract code representation (304a) of the source code (202); generate a connection graph (501) from the abstract code representation (304a), the connection graph (501) representing the connectivity between constructs in the source code (202); determine an escaping scope (702, 703) of one or more nodes (101) in the connection graph (501), the nodes (701) in the connection graph (501) corresponding to the constructs in the source code (202); and propagate an escapement of the one or more nodes (701) through the connection graph (501), the escapement being based on the escaping scope of the one or more nodes (701), to generate an optimised connection graph (505).

2. The computing apparatus (900) according to claim 1, wherein the apparatus (900) is configured to obtain the source code (202) and generate the abstract code representation (304a) of the source code (202).

3. The computing apparatus (900) according to claim 1 or 2, wherein the abstract code representation (304a) comprises one of: a graph-based intermediate generalisation, optionally the graph-based intermediate generalisation being a hypergraph; an abstract syntax tree (AST); or a static single assignment (SSA).

4. The computing apparatus (900) according to any preceding claim, wherein the apparatus (900) is configured to generate the connection graph (501) from the abstract code representation (304a) by removing one or more transient nodes.

5. The computing apparatus (900) according to any preceding claim, wherein the escaping scope (702, 703) represents a block of unevaluated code comprising one of: a function; a loop; and an unevaluated argument.

6. The computing apparatus (900) according to any preceding claim, wherein the apparatus (900) is configured to inline (502) the connection graph (501).

7. The computing apparatus (900) according to any preceding claim, wherein the apparatus (900) is configured to propagate the escapement of the one or more nodes (701) through the connection graph (501) by means of a fixed-point algorithm.

8. The computing apparatus (900) according to any preceding claim, wherein the apparatus (900) is configured to propagate the escapement of the one or more nodes (701) through the connection graph (501) until the connection graph (501) reaches a steady state.

9. The computing apparatus (900) according to any preceding claim, wherein the apparatus (900) is further configured to annotate (506) the optimised connection graph (505) to indicate a type of optimisation to be performed on a node (701) of the one or more nodes (701), and optionally wherein the type of optimisation to be performed on a node (701) comprises: allocating the node (701) to a stack, and / or hoisting the node (701) to an escaping scope of the node.

10. The computing apparatus (900) according to any preceding claim, wherein the computing apparatus (900) is further configured to allocate a node (701) of the one or more nodes (701) to a stack, and / or wherein the computing apparatus (900) is further configured to hoist a node (701) of the one or more nodes (701) to the escaping scope (702, 703) of the node (701).

11. The computing apparatus (900) according to any preceding claim, wherein the apparatus (900) is configured to compile (306, 204) the source code (202) into an executable code (307a, 205) based on the optimised connection graph (505).

12. The computing apparatus (900) according to claim 13, wherein the apparatus (900) is configured to execute the executable code (307a, 205).

13. A computer-readable storage medium for static analysis (401) of source code (402) configured to: obtain an abstract code representation (304a) of the source code (202);generate a connection graph (501) from the abstract code representation (304a), the connection graph (501) representing the connectivity between constructs in the source code (202); determine an escaping scope (702, 703) of one or more nodes (701) in the connection graph (501), the nodes (701) in the connection graph (501) corresponding to the constructs in the source code (202); and propagate an escapement of the one or more nodes (701) through the connection graph (501), the escapement being based on the escaping scope of the one or more nodes (701), to generate an optimised connection graph (505).

14. A computer program product for static analysis (401) of source code (202) configured to: obtain an abstract code representation (304a) of the source code (202); generate a connection graph (501) from the abstract code representation (304a), the connection graph (501) representing the connectivity between constructs in the source code (202); determine an escaping scope (702, 703) of one or more nodes (701) in the connection graph (501), the nodes (701) in the connection graph (501) corresponding to the constructs in the source code (302); and propagate an escapement of the one or more nodes (701) through the connection graph (501), the escapement being based on the escaping scope of the one or more nodes (501), to generate an optimised connection graph (505).

15. A method (800) for compiler static analysis of source code, the method (800) comprising steps of: obtaining an abstract code representation of the source code (801); generating a connection graph from the abstract code representation, the connection graph representing the connectivity between constructs in the source code(802); determining an escaping scope of one or more nodes in the connection graph, the nodes in the connection graph corresponding to the constructs in the source code(803); andpropagating an escapement of the one or more nodes through the connection graph, the escapement being based on the escaping scope of the one or more nodes, to generate an optimised connection graph (804).