Calculating pointer alignment in program code through code pattern analysis

A flow-insensitive, field-sensitive pointer analysis method efficiently calculates pointer alignment, optimizing compiler optimizations and improving program performance by reducing redundant checks and enhancing efficiency in large programs.

JP7721245B2Active Publication Date: 2025-08-12INTERNATIONAL BUSINESS MACHINE CORPORATION
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
JP2023565167
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2021-06-16
Filing Date
2022-06-10
Publication Date
2025-08-12
Estimated Expiration
2042-06-10

AI Technical Summary

Technical Problem

Existing methods for calculating pointer alignment in programming are inefficient and resource-intensive, particularly for large programs, and do not effectively utilize alignment information to optimize compiler optimizations.

Method used

A flow-insensitive, field-sensitive pointer analysis is used to collect equivalence classes of pointers, identify candidate pointers based on code patterns, and perform alignment calculations bottom-up to provide alignment information to compilers, optimizing pointer references and eliminating redundant checks.

Benefits of technology

This approach significantly reduces computation time and resource usage while improving program performance by up to 2-4% and reducing code size by approximately 8% in benchmark tests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007721245000001
    Figure 0007721245000001
  • Figure 0007721245000002
    Figure 0007721245000002
  • Figure 0007721245000003
    Figure 0007721245000003
Patent Text Reader

Abstract

Pointer alignment in computer programming to obtain information that enables a compiler to optimize the program code. Pointer equivalence classes are collected in a program using a flow-insensitive but field-sensitive pointer analysis operation that iterates through the entire program code of the program. Once the pointer equivalence classes are collected, the pointer equivalence classes are mapped to an Equivalence Class Mapping Table (ECTable) and recorded in the ECTable. A portion of the collected pointer equivalence classes are identified from the ECTable as pointer candidates for pointer alignment calculation according to a code pattern analysis of each pointer candidate. The code pattern analysis is based on the available alignment information and whether the alignment information enables the compiler to optimize pointer references of the candidate pointers. Then, a pointer alignment calculation is performed for each identified pointer candidate to obtain alignment information that is used to optimize the execution of the program.
Need to check novelty before this filing date? Find Prior Art

Description

[Technical Field]

[0001] The present invention relates generally to computing systems, and more particularly to various embodiments for calculating pointer alignment using a computing processor. Summary of the Invention

[0002] According to a preferred embodiment of the present invention, a computer-implemented method for calculating pointer alignment during programming is disclosed. The computer-implemented method includes recording equivalence classes of pointers in an equivalence class mapping table (ECTable) in response to collecting equivalence classes of pointers in a program using flow-insensitive and field-sensitive unification-based pointer analysis. The computer-implemented method performs a code pattern analysis of pointer references in the program to identify a set of pointer candidates from the ECTable for alignment calculation according to predefined criteria. The computer-implemented method further performs alignment calculation for each of the set of pointer candidates by iterating through the use-define chain of each identified candidate pointer starting at a respective reference point of each identified candidate pointer. The computer-implemented method further receives alignment information as a result of the alignment calculation and provides the alignment information to a compiler.

[0003] According to another preferred embodiment, the present invention comprises a computer system including a processor, a memory, a storage device, and program instructions stored on the storage device for execution by the processor via the memory, the program instructions, when executed by the processor, cause the processor to perform functions similar to those summarized above.

[0004] According to another preferred embodiment, the present invention comprises a computer usable program product, the computer usable program product including a computer readable storage device and program instructions stored on the storage device, which when executed by a processor, cause the processor to perform functions similar to those summarized above.

[0005] Preferred embodiments of the present invention will now be described, by way of example only, with reference to the following drawings, in which: [Brief explanation of the drawings]

[0006] [Figure 1] FIG. 2 is a block diagram illustrating an exemplary cloud computing node according to one embodiment of the present invention. [Figure 2] FIG. 1 illustrates a cloud computing environment according to one embodiment of the present invention. [Figure 3] FIG. 2 illustrates abstraction model layers according to one embodiment of the present invention. [Figure 4] FIG. 10 is a flowchart diagram illustrating a computer-implemented method for calculating pointer alignment during programming, in accordance with an aspect of the present invention. [Figure 5] FIG. 10 is an additional flowchart diagram illustrating a computer-implemented method for calculating pointer alignment during programming, in accordance with an aspect of the present invention. [Figure 6] FIG. 10 illustrates exemplary programming code for an algorithm for calculating pointer alignment, according to an aspect of the present invention. DETAILED DESCRIPTION OF THE INVENTION

[0007] Data processing systems provide mechanisms for dynamically checking memory access alignment. Memory accesses can be unrestricted, such that any individual byte in memory can be addressed by a memory access of any size, or memory accesses can be restricted, such that only memory accesses aligned with half-word, word, double-word, and other boundaries can occur. Thus, enforcing the alignment of data in memory (or calculating / determining the alignment of data) generally refers to various techniques related to the way data is stored across memory banks, which may depend on the boundary size and / or data type of the data to comply with mandatory data alignment requirements of a programming language or mandated by the processor architecture, or both.

[0008] In programming, pointers are widely used in pointer-rich programming languages such as C and C++, and these pointers are also aligned, generally with reference to ensuring that the addresses they point to are evenly divisible by some factor (i.e., constrained to word boundaries for access, for example). This alignment information for pointers is useful in various compiler-controlled optimizations, leading to performance improvements for programs. For example, if alignment analysis can indicate that a program pointer is aligned for access through a loop where a single instruction, multiple data (SIMD) instruction is appropriate, code duplication to address otherwise unknown pointer alignment (such as the inclusion of loop versioning with dynamic alignment checking) can be avoided. Users can also add code within their programs to check pointer alignment in order to perform similar tasks differently for different data types. For example, the spec_qsort routine used in the SPEC CPU® 2017 benchmarks, which include mfc, gcc, cam4, and povray, checks alignment every time a pair of elements of the data to be sorted is swapped. If valid alignment information is available for such data pointers, these dynamic alignment checks can be eliminated in a benchmark, which of course significantly improves benchmark performance. Eliminating these dynamic alignment checks also facilitates the efficient use of other optimization mechanisms and data-related analysis, since resources can be diverted to more desirable operations rather than being forced to repeatedly check alignment.

[0009] Although pointer alignment analysis methods are very similar to pointer analysis methods, it should be noted that techniques known in the art of pointer analysis are distinct from (i.e., precursors to) computing pointer alignment analysis. Intra- and inter-procedural pointer analysis have been studied for many years, with several proposed methods. As is known in the art, various methods of analysis achieve different tradeoffs between accuracy and efficiency (e.g., flow-sensitive analyses such as sparse analysis compared to flow-insensitive analyses such as Steensgaard or Anderson). In flow-sensitive analyses, separate points-to information is computed for each program point, whereas in flow-insensitive analyses, points-to information is merged across all program points. Of course, flow-sensitive analyses are more accurate but less scalable (i.e., they require more resources to operate and are therefore more resource "expensive") than flow-insensitive analyses. Inter-procedural flow-sensitive pointer analysis computes information about pointers at every point in the program, propagates the information through each procedure, and then performs iterative closure on the collected information for all procedures. However, such analysis is extremely resource-intensive, especially for compilers dealing with relatively large programs.

[0010] When considering alternative intraprocedural methods, granularity or precision may be considered rather than efficiency of the method. For example, in containment-based analysis (e.g., Anderson), a pointer may point to a set of abstract locations, and two pointers may be aliases if they can both point to some abstract location. In unification-based analysis (e.g., Steensgaard), pointers are placed in equivalence classes. That is, if pointer p can point to anything that pointer q can point to, they are considered to be in the same equivalence class.

[0011] To date, the most efficient interprocedural pointer analysis is the flow-insensitive context-insensitive unification-based Steensgaard-style method, which, as mentioned above, can be used to compute equivalence classes of pointers within an entire program. Converting this type of analysis into a pointer alignment analysis is generally less precise than the more complex and more expensive flow-sensitive analysis, but can provide more accurate alignment information for pointers at multiple levels of indirection.

[0012] Therefore, in this invention, a technique is proposed for computing pointer alignment based on pointer equivalence classes gathered from a flow-insensitive, but field-sensitive pointer analysis. The flow-insensitive aspects of the disclosed invention make computing pointer alignment significantly simpler and cheaper in terms of computation time than existing techniques, especially for large programs. Furthermore, techniques for performing these types of analysis have been extended to be field-sensitive and implemented as a basis for data reorganization in future compilers.

[0013] It should be noted that, in general, the term "optimize," as used herein, may refer to or be defined as "maximizing," "minimizing," "best," or achieving one or more specific targets, objectives, goals, or intentions, or both. The term optimize may also refer to maximizing benefit to a user, making the most effective or functional use of a situation, opportunity, or resource, or improving the efficiency of a resource or program in an empirically observable manner.

[0014] Furthermore, the term optimizing need not refer to the best solution or result, but may refer, for example, to a solution or result that is "good enough" for a particular application, or simply "better" than before. In additional aspects, the term optimizing or optimizing, or both, may refer to actions taken to achieve improved results, such as reduced execution costs or improved resource utilization, regardless of whether the optimal result is actually achieved. Similarly, the term optimizing may refer to components for performing such improvement actions, and the term optimized may be used to describe the results of such improvement actions.

[0015] Although this disclosure includes detailed descriptions of cloud computing, it should be understood that implementation of the teachings described herein is not limited to cloud computing environments. Rather, embodiments of the present invention may be implemented in conjunction with any other type of computing environment now known or later developed.

[0016] Cloud computing is a service delivery model for enabling convenient, on-demand network access to a shared pool of configurable computing resources (e.g., networks, network bandwidth, servers, processing, memory, storage, applications, virtual machines, and services) that can be rapidly provisioned and released with minimal administrative effort or interaction with the service provider. This cloud model can include at least five characteristics, at least three service models, and at least four deployment models.

[0017] The features are as follows: On-Demand Self-Service: Cloud consumers can unilaterally provision computing capabilities, such as server time or network storage, automatically as needed, without the need for human interaction with the provider of the service. Wide network access: Functionality is available over the network and accessed through standard mechanisms that facilitate use by heterogeneous thin or thick client platforms (e.g., cell phones, laptops, and PDAs). Resource Pooling: A provider's computing resources are pooled to serve multiple consumers using a multi-tenant model, with various physical and virtual resources dynamically allocated and reallocated according to demand. Consumers generally have no control or knowledge of the exact location of the resources provided, but there is some location independence in that they may be able to specify location at a higher level of abstraction (e.g., country, state, or data center). Rapid scalability: Capabilities can be quickly and elastically, in some cases automatically, provisioned and quickly scaled out, and quickly released and quickly scaled in. To the consumer, the capabilities available for provisioning often appear unlimited, and any amount can be purchased at any time. Metered Services: Cloud systems automatically control and optimize resource usage by leveraging metering capabilities at some level of abstraction appropriate to the type of service (e.g., storage, processing, bandwidth, and active user accounts). Resource usage can be monitored, controlled, and reported, providing transparency to both providers and consumers of utilized services.

[0018] The service model is as follows: Software as a Service (SaaS): The functionality offered to the consumer is the use of the provider's applications running on a cloud infrastructure. The applications are accessible from a variety of client devices through thin-client interfaces such as web browsers (e.g., web-based email). The consumer does not manage or control the underlying cloud infrastructure, including the network, servers, operating systems, storage, or even individual application functions, with the possible exception of limited user-specific application configuration settings. Platform as a Service (PaaS): The functionality offered to the consumer is the deployment of applications they create or acquire, written using programming languages and tools supported by the provider, onto a cloud infrastructure. The consumer does not manage or control the underlying cloud infrastructure, including the network, servers, operating systems, or storage, but does have control over the applications deployed and, in some cases, the application hosting environment configuration. Infrastructure as a Service (IaaS): The capability offered to consumers is to provision processing, storage, network, and other basic computing resources onto which they can deploy and run any software, which may include operating systems and applications. Consumers do not manage or control the underlying cloud infrastructure, but do have control over the operating system, storage, deployed applications, and possibly limited control over selected networking components (e.g., host firewalls).

[0019] The deployment model is as follows: Private Cloud: The cloud infrastructure is operated solely for the organization. The cloud infrastructure can be managed by the organization or a third party and can exist on-premise or off-premise. Community Cloud: Cloud infrastructure is shared by several organizations to support a specific community with shared interests (e.g., mission, security requirements, policy, and compliance considerations). The cloud infrastructure may be managed by the organization or a third party and may exist on-premises or off-premises. Public cloud: Cloud infrastructure is made available to the general public or large industry groups and is owned by an organization that sells cloud services. Hybrid Cloud: A cloud infrastructure is a composition of two or more clouds (private, community, or public) that remain unique entities but are tied together by standardized or proprietary technologies that enable data and application portability (e.g., cloud bursting for load balancing between clouds).

[0020] A cloud computing environment is a service-oriented environment with an emphasis on statelessness, low coupling, modularity, and semantic interoperability. At the heart of cloud computing is an infrastructure that includes a network of interconnected nodes.

[0021] Referring now to Figure 1, a schematic diagram of an example cloud computing node is shown. Cloud computing node 10 is merely one example of a suitable cloud computing node and is not intended to suggest any limitation as to the scope of use or functionality of the inventive embodiments described herein. Nevertheless, cloud computing node 10 may implement and / or perform any of the aforementioned functions.

[0022] Cloud computing node 10 includes computer system / server 12, which is operable with numerous other general-purpose or special-purpose computing system environments or configurations. Examples of well-known computing systems, environments, or configurations, or combinations thereof, that may be suitable for use with computer system / server 12 include, but are not limited to, personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments that include any of the above systems or devices.

[0023] Computer system / server 12 may be described in the general context of computer system-executable instructions, such as program modules, being executed by a computer system. Generally, program modules may include routines, programs, objects, components, logic, data structures, etc. that perform particular tasks or implement particular abstract data types. Computer system / server 12 may also be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed cloud computing environment, program modules may be located in both local and remote computer system storage media, including memory storage devices.

[0024] 1, computer system / server 12 within cloud computing node 10 is shown in the form of a general-purpose computing device. Components of computer system / server 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 coupling various system components, including system memory 28, to processor 16.

[0025] Bus 18 represents any one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus, using any of a variety of bus architectures. By way of example and not limitation, such architectures include an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MCA) bus, an Enhanced ISA (EISA) bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.

[0026] Computer system / server 12 typically includes a variety of computer system-readable media, which may be any available media that can be accessed by computer system / server 12 and includes both volatile and nonvolatile media, removable and non-removable media.

[0027] System memory 28 may include computer-system-readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. Computer system / server 12 may further include other removable / non-removable, volatile / non-volatile computer-system storage media. By way of example only, a storage system 34 may be provided for reading from and writing to non-removable, non-volatile magnetic media (not shown, typically referred to as a "hard drive"). Although not shown, a magnetic disk drive may be provided for reading from and writing to removable, non-volatile magnetic disks (e.g., "floppy disks"), and an optical disk drive may be provided for reading from and writing to removable, non-volatile optical disks, such as CD-ROMs, DVD-ROMs, or other optical media. In such cases, each may be connected to bus 18 by one or more data media interfaces. As further illustrated and described below, system memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to implement the functionality of embodiments of the present invention.

[0028] By way of example and not limitation, a program / utility 40 having a set (at least one) of program modules 42, as well as an operating system, one or more application programs, other program modules, and program data, may be stored in system memory 28. Each of the operating system, one or more application programs, other program modules, and program data, or some combination thereof, may include an implementation of a networking environment. Program modules 42 generally implement the functions and / or methods of embodiments of the present invention as described herein.

[0029] Computer system / server 12 may also communicate with one or more external devices 14, such as a keyboard, pointing device, display 24, one or more devices that allow a user to interact with computer system / server 12, or any device that allows computer system / server 12 to communicate with one or more other computing devices (e.g., a network card, modem, etc.), or combinations thereof. Such communication may occur via input / output (I / O) interface 22. Furthermore, computer system / server 12 may communicate with one or more networks, such as a local area network (LAN), a general wide area network (WAN), or a public network (e.g., the Internet), or combinations thereof, via network adapter 20. As shown, network adapter 20 communicates with other components of computer system / server 12 via bus 18. It should be understood that other hardware and / or software components, not shown, may be used with computer system / server 12. Examples include, but are not limited to, microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data archive storage systems, and the like.

[0030] Referring now to FIG. 2, an exemplary cloud computing environment 50 is shown. As shown, the cloud computing environment 50 includes one or more cloud computing nodes 10 with which local computing devices used by cloud consumers, such as, for example, a personal digital assistant (PDA) or cellular phone 54A, a desktop computer 54B, a laptop computer 54C, or an automobile computer system 54N, or combinations thereof, may communicate. The nodes 10 may communicate with each other. The nodes 10 may be physically or virtually grouped into one or more networks, such as a private cloud, a community cloud, a public cloud, or a hybrid cloud, or combinations thereof, as previously described (not shown). This enables the cloud computing environment 50 to provide infrastructure, platform, or software, or combinations thereof, as a service without the cloud consumer having to maintain resources therefor on their local computing devices. It should be understood that the types of computing devices 54A-N shown in FIG. 2 are exemplary only, and that computing node 10 and cloud computing environment 50 may communicate with any type of computerized device over any type of network and / or network-addressable connection (e.g., using a web browser).

[0031] Referring now to Figure 3, a set of functional abstraction layers provided by cloud computing environment 50 (Figure 2) is shown. It should be understood in advance that the components, layers, and functions shown in Figure 3 are merely exemplary, and embodiments of the present invention are not limited thereto. As shown, the following layers and corresponding functions are provided:

[0032] The device layer 55 includes physical and / or virtual devices that incorporate and / or are stand-alone electronics, sensors, actuators, and other objects for performing various tasks in the cloud computing environment 50. Each of the devices in the device layer 55 incorporates networking functionality with respect to other functional abstraction layers, such that information obtained from the device may be provided to other functional abstraction layers, information from other abstraction layers may be provided to the device, or both. In one embodiment, the various devices comprising the device layer 55 may incorporate a network of entities collectively referred to as the "Internet of Things" (IoT). As one skilled in the art will appreciate, such a network of entities enables data to be communicated with, collected, and distributed to accomplish a wide variety of purposes.

[0033] The illustrated device layer 55, as shown, includes sensors 52, actuators 53, a "learning" thermostat with integrated processing 56, sensor and networking electronics, cameras 57, controllable home outlets / receptacles 58, and controllable electrical switches 59. Other possible devices may include, but are not limited to, various additional sensor devices, networking devices, electronics devices (such as remote control devices), additional actuator devices, so-called "smart" applications such as refrigerators and washer / dryers, and a wide variety of other possible interconnected objects.

[0034] Hardware and software layer 60 includes hardware and software components. Examples of hardware components include mainframes 61, RISC (reduced instruction set computer) architecture-based servers 62, servers 63, blade servers 64, storage devices 65, and networks and networking components 66. In some embodiments, software components include network application server software 67 and database software 68.

[0035] The virtualization layer 70 provides an abstraction layer from which the following examples of virtual entities may be provided: virtual servers 71, virtual storage 72, virtual networks including virtual private networks 73, virtual applications and operating systems 74, and virtual clients 75.

[0036] As an example, management layer 80 may provide the functions described below. Resource provisioning 81 enables dynamic procurement of computing and other resources utilized to perform tasks within the cloud computing environment. Metering and pricing 82 enables cost tracking as resources are utilized within the cloud computing environment and billing or invoicing for the consumption of these resources. As an example, these resources may include application software licenses. Security provides identity verification for cloud consumers and tasks, as well as protection for data and other resources. User portal 83 provides access to the cloud computing environment for consumers and system administrators. Service level management 84 enables cloud computing resource allocation and management so that required service levels are met. Service level agreement (SLA) planning and fulfillment 85 enables proactive coordination and procurement of cloud computing resources in anticipation of future needs in accordance with SLAs.

[0037] The workload layer 90 provides examples of functionality for which a cloud computing environment may be utilized. Examples of workloads and functionality that may be provided from this layer include mapping and navigation 91, software development and lifecycle management 92, virtual classroom instruction delivery 93, data analytics processing 94, transaction processing 95, and, in the context of the illustrated embodiment of the present invention, various workloads and functionality 96 for facilitating pointer alignment in computer programming applications. Additionally, the workloads and functionality 96 may include operations such as performing various analyses (e.g., pointer analysis) to identify data and data parameters and characteristics used to directly or indirectly facilitate pointer alignment computation. Those skilled in the art will appreciate that the workloads and functionality 96 for computing pointer alignment in computer programming applications may also work with other portions of various abstraction layers, such as hardware and software 60, virtualization 70, management 80, and other workloads 90 (e.g., data analytics processing 94) to achieve various objectives of the illustrated embodiment of the present invention.

[0038] Referring now to the body of functionality achieved by aspects of the present invention, embodiments of the present invention again introduce a novel interprocedural compilation method to efficiently calculate pointer alignment to optimize or improve performance during execution of compiled program code. Embodiments of the present invention comprise aspects of performing flow-insensitive but field-sensitive pointer analysis to collect pointer equivalence classes for the entire program. An additional aspect includes identifying candidate pointers from the pointer equivalence classes for which alignment is calculated based on code patterns of their references (i.e., references to the candidate pointers) within the program. An additional aspect includes calculating an alignment bottom-up (i.e., flow-insensitive) for each identified candidate pointer, starting from its reference point within the program. The resulting alignment information may then be provided to a compiler, enabling the compiler to optimize references to these candidate pointers for which alignment has been calculated.

[0039] Note that, certainly not by way of limitation, the disclosed techniques are particularly efficient for relatively large programs where alignment information is needed for only a few pointers. These techniques have been prototyped and found to be able to remove all redundant two versions of non-8-byte alignment code for data swapping in spec_qsort, resulting in approximately a 2-4% performance improvement in the compiled code at runtime and an approximately 8% code size reduction for the SPEC CPU® 2017 mcf_r code.

[0040] Referring now to FIG. 4 , a computer-implemented method 400 for calculating pointer alignment when programming an application is illustrated, in accordance with an aspect of the present invention. The functions of method 400 may be executed as instructions by processing unit 16 on computer system / server 12, for example, with the instructions embodied on a tangible, non-transitory, machine-readable storage medium, such as storage system 34. Method 400 begins at step 402. In some embodiments, at step 404, in response to collecting equivalence classes of pointers in a program using a flow-insensitive, field-sensitive, unified-based pointer analysis, these equivalence classes of pointers are recorded in an equivalence class mapping table (ECTable). At step 406, a code pattern analysis of pointer references in the program is performed, and a set of candidate pointers is identified from the ECTable for alignment calculation according to predefined criteria. As will now be described, the code pattern analysis utilizes predefined criteria to determine whether references to those analyzed pointers can be optimized in the code.

[0041] At step 408, an alignment calculation for each of the set of candidate pointers is performed by iterating through each identified candidate pointer's use-define chain starting at each identified candidate pointer's respective reference point in the program. At step 410, alignment information is received as a result of the alignment calculation, and this alignment information is provided to a compiler to optimize program execution. Method 400 ends at step 412.

[0042] 5, a computer-implemented method 500 for calculating pointer alignment when programming an application is shown, in accordance with an aspect of the present invention. The functions of method 500 may be performed as instructions by, for example, processing unit 16 on computer system / server 12, with the instructions embodied on a tangible, non-transitory, machine-readable storage medium, such as storage system 34. Method 500 begins at step 502 and can be viewed as component stages as follows:

[0043] Pointer Analysis In step 502, pointer analysis is performed on the program code of the program to identify equivalence classes of all pointers in the program. In some embodiments, the pointer analysis may include a unified-based pointer analysis that is flow-insensitive, context-insensitive, but field-sensitive (e.g., using Steensgaard's method). In some embodiments, the pointer analysis to identify equivalence classes of pointers may be completed by iterating through and identifying all equivalence classes of pointers in a single pass. In step 504, all identified equivalence classes of pointers determined from the pointer analysis are recorded in an equivalence class mapping table (ECTable) stored or maintained in system memory 28, including, but not limited to, cache memory 32, RAM 30, or storage system 34, or a combination thereof. Each pointer stored in the ECTable includes a mapping to an ECTable; therefore, when iterating through the program code with pointer analysis, whenever a pointer assignment is satisfied in the analysis, the two corresponding pointers are considered equivalent, and this equivalence is recorded in the ECTable in step 506.

[0044] When performing pointer analysis and iterating through the program code to identify equivalence classes of pointers, predefined flags may be marked for applicable equivalence classes of pointers based on the pointer behavior and / or characteristics of each pointer. In step 508, these applicable flags are marked for each applicable equivalence class of pointer according to such pointer behavior and / or characteristics. In some embodiments, these flags may include, for example, a flag "incomplete" to indicate that the pointer escapes the program and a flag "unknown" to indicate that the pointer originates from unknown allocated memory. In step 510, for each equivalence class of pointers recorded in the ECTable, a subset of these pointers whose values are stored using store instructions in the program is additionally recorded in an equivalent store mapping table (ESTable).

[0045] Candidate Identification Continuing with method 500, and now referring to step 512, a set of candidate pointers for the pointer equivalence class recorded in the ECTable is identified for alignment calculation. In some embodiments, each identified pointer is considered a candidate if the respective pointer is of an equivalence class that is not marked with flags including an incomplete flag, an unknown flag, or both. Furthermore, an identified pointer is considered a candidate for alignment calculation only if the alignment of each pointer in the set of candidate pointer equivalence classes is associated with alignment information that enables a compiler to optimize its corresponding references, if available. The analysis to identify candidate pointers is based on code patterns of pointer references within the program.

[0046] For example, in one aspect, a code pattern of pointer references may indicate that alignment checks in program code can be reduced or eliminated. Consider the following code sequence: if(p & 7 == 0) code_sequence_for_alignment_8; else if(code & 3 == 0) code_sequence_for_alignment_4; else code_sequence_for_non_aligment;

[0047] Using this example sequence, if the alignment of pointer p is determined to be 8 or greater, all branches from pointer p can be removed and the remaining code after simplification consists of code_sequence_for_alignment_8.

[0048] As another example, a code pattern of pointer dereferences may indicate that code versioning can be avoided based on pointer alignment. Consider the following loop: while(*p++ !='s'); Here, the pointer p points to a one-byte integer. If the alignment of p is determined to be different from 1, then SIMDization's aggressive load speculation can be safely implemented (i.e., with reduced risk of error) for the loop without loop versioning through alignment checks. This is because, in general, if all memory accesses can be shown to be contained within a single page in memory, then loads can be safely inferred without alignment checks. Typically, this is done through loop versioning, where the first load is aligned with a page boundary and the total loop iteration count is checked to see if it is less than the page size; however, using this alignment information, loop versioning can be eliminated. Furthermore, if information about data alignment and size is available at compile time, then run-time checks are not necessary.

[0049] In some embodiments, as described above, when performing pointer analysis, candidate pointers for alignment calculation may be identified by iterating through all references of pointers that are of the equivalence class and are not marked with either the incomplete or unknown flags, calculating the alignment of the pointers, recording it in an ESTable, and providing this information to a compiler's optimizer to optimize the program code using the recorded alignment information. In some embodiments, candidate pointers may be identified and their alignment calculation may be required when performing certain optimization analyses such as branch elimination, loop versioning, etc.

[0050] Alignment Calculation Continuing with method 500, and now referring to step 514, an alignment calculation is performed for each identified candidate pointer. It should also be noted that this alignment calculation is not simply pointer analysis (as is known in the art), but rather the resulting candidate pointers identified through pointer analysis are used to obtain their associated memory alignment information (i.e., alignment information for each pointer). In some embodiments, alignment may be performed by iterating through the pointer's use-define chain starting at the reference point of the identified pointer. When iterating through the pointer's use-define chain, the definition of each pointer variable is analyzed. In some embodiments, the alignment calculation may be performed "bottom-up" or "backward" (i.e., flow-insensitive) through its branches starting at this reference point.

[0051] When performing the alignment calculation, referring next to step 516, a determination is made as to whether the pointer value is from a load instruction or an address calculation. If, at step 516, the pointer value originates from a load instruction, method 500 proceeds to step 518, where all associated mapped pointers (for the currently analyzed pointer) recorded in the ESTable are further analyzed. If, at step 516, it is determined that the pointer value originates from an address calculation, including a pointer assignment, a pointer parameter passed from a call site, and a pointer value returned from a function call, method 500 proceeds to step 520. At step 520, the base pointer of the currently analyzed pointer undergoing alignment calculation is extracted for further analysis. In conjunction with this analysis, the integer value of the greatest common denominator (gcd) coefficient of the remaining address calculations is calculated and used to derive pointer alignment information up to this (current) stage of the calculation.

[0052] In either case (i.e., whether the pointer value is determined to be from a load instruction or an address calculation), the alignment of the candidate pointer is calculated using a prescribed method. After the alignment calculation is performed, in step 522, alignment information is received, and in step 524, the alignment information is provided to the compiler. The compiler may then use this alignment information to optimize the referencing of the candidate pointer, as described above, simplify the program code, or eliminate dynamic alignment checks, or a combination thereof, e.g., so that resources that would otherwise be performing these checks can be diverted for use in other optimization techniques or for other purposes. In step 526, method 500 ends.

[0053] Referring now to Figure 6, Figure 6 shows exemplary programming code 600 for calculating pointer alignment, illustrating an implementation of method 500 based on an LLVM Compiler Infrastructure Intermediate Representation (IR) code representation. Programming code 600 illustrates an implementation based on LLVM IR, in which each pointer variable is assigned exactly once. It should be noted that exemplary programming code 600 illustrates only one of many different ways of implementing the techniques described herein, and thus, one skilled in the art would understand that many variations and modifications may be made thereto without departing from the intended scope of the present disclosure.

[0054] The present invention may be a system, a method, or a computer program product, or a combination thereof. The computer program product may include a computer-readable storage medium having computer-readable program instructions for causing a processor to implement aspects of the present invention.

[0055] A computer-readable storage medium may be a tangible device that can retain and store instructions for use by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the above. A non-exhaustive list of more specific examples of computer-readable storage media includes portable computer diskettes, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disk read-only memory (CD-ROM), digital versatile disk (DVD), memory stick, floppy disk, mechanically encoded devices such as punch cards or ridge-in-groove structures with instructions recorded on them, and any suitable combination of the above. As used herein, computer-readable storage media should not be construed as signals that are transitory in nature, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission medium (e.g., light pulses passing through fiber optic cable), or electrical signals transmitted through wires.

[0056] The computer-readable program instructions described herein may be downloaded from a computer-readable storage medium to each computing / processing device or to an external computer or storage device via a network, such as the Internet, a local area network, a wide area network, or a wireless network, or a combination thereof. The network may include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, or edge servers, or a combination thereof. A network adapter card or network interface within each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in a computer-readable storage medium within the respective computing / processing device.

[0057] Computer-readable program instructions for carrying out operations of the present invention may be source or object code written in any combination of one or more programming languages, including assembler instructions, instruction set architecture (ISA) instructions, machine language instructions, machine-dependent instructions, microcode, firmware instructions, state-setting data, or object code written in any combination of one or more programming languages, including object-oriented programming languages such as Smalltalk®, C++, and traditional procedural programming languages such as the “C” programming language and similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be to an external computer (e.g., through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA) may execute computer readable program instructions by utilizing state information of the computer readable program instructions to individualize the electronic circuitry to implement aspects of the present invention.

[0058] Aspects of the present invention are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0059] These computer-readable program instructions may be provided to a processor of a general-purpose computer, special-purpose computer, or other programmable data processing apparatus, such that the instructions, executed by the processor of the computer or other programmable data processing apparatus, produce means for implementing the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams, to create a machine. These computer-readable program instructions may also be stored in a computer-readable storage medium that can direct a computer, programmable data processing apparatus, or other device, or combination thereof, to function in a particular way, such that the computer-readable storage medium storing the instructions comprises an article of manufacture containing instructions that implement aspects of the functions / acts specified in one or more blocks of the flowcharts and / or block diagrams.

[0060] The computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device, causing the computer, other programmable apparatus, or other device to perform a series of operational steps to create a computer-implemented process, such that the instructions, which execute on the computer, other programmable apparatus, or other device, implement the functions / operations specified in one or more blocks of the flowcharts and / or block diagrams.

[0061] The flowcharts and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowcharts or block diagrams may represent a module, segment, or portion of instructions, including one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions described in the blocks may occur in an order other than that described in the figures. For example, two blocks shown in succession may in fact be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending on the functionality involved. It should also be noted that each block of the block diagrams and / or flowchart diagrams, and combinations of blocks in the block diagrams and / or flowchart diagrams, may be implemented by a dedicated hardware-based system that performs the specified function or operation or a combination of dedicated hardware and computer instructions.

[0062] Descriptions of embodiments of the present invention are presented for illustrative purposes, but are not intended to be exhaustive or limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope of the described embodiments. The terms used herein are chosen to best explain the principles of the embodiments, practical applications or technical improvements over technology found in the market, or to enable those skilled in the art to understand the embodiments disclosed herein.

Claims

1. A method for calculating pointer alignment during programming by computer information processing, comprising: responsive to collecting equivalence classes of pointers in the program using flow-insensitive, field-sensitive unification-based pointer analysis, recording the equivalence classes of pointers in an equivalence class mapping table (ECTable); performing a code pattern analysis of pointer references in the program to identify a set of pointer candidates from the ECTable for alignment calculation according to predefined criteria; performing said alignment calculation for each of said set of candidate pointers by iterating through a use-define chain of each identified candidate pointer beginning at a respective reference point of each identified candidate pointer; receiving alignment information as a result of said alignment calculation and providing said alignment information to a compiler; 10. A computer-implemented method comprising:

2. 2. The method of claim 1, further comprising: for each of the collected equivalence classes of pointers, recording in an equivalent store mapping table (ESTable) a subset of the pointers whose values are stored using a store instruction in the program.

3. 2. The method of claim 1, wherein each candidate pointer is identified as an unflagged equivalence class mapped within the ECTable having available alignment information to enable the compiler to optimize pointer references for each of the candidate pointers.

4. 4. The method of claim 3, wherein the code pattern analysis further comprises determining that the respective pointer references of the candidate pointers in the program indicate that alignment checks of the respective pointer references can be reduced or eliminated by branch elimination to simplify program code of the program.

5. 4. The method of claim 3, wherein the code pattern analysis further comprises determining that the respective pointer references of the candidate pointers in the program indicate that code versioning can be reduced based on pointer alignment, where the pointer alignment performs load speculation or data parallelism at reduced risk for loops without the use of loop versioning.

6. 3. The method of claim 2, wherein performing the alignment calculation further comprises, in response to determining that the identified candidate pointer value is from a load instruction, analyzing all associated mapped pointers recorded in the ESTable.

7. 7. The method of claim 6, wherein performing the alignment calculation further comprises, in response to determining that the value of the identified candidate pointer is from an address calculation, extracting a base pointer of the identified candidate pointer for analysis.

8. 8. The method of claim 7, wherein extracting the base pointer for analysis further comprises: calculating a greatest common divisor (GCD) integer value for coefficients of the remaining portion of the address calculation; and obtaining alignment information according to said calculation up to a current stage of the address calculation.

9. 1. A system for calculating pointer alignment in a computing environment, comprising: a processor; and a memory storing executable instructions, the executable instructions, when executed by the processor, causing the processor to: responsive to collecting equivalence classes of pointers in the program using flow-insensitive and field-sensitive unification-based pointer analysis, recording said equivalence classes of pointers in an equivalence class mapping table (ECTable); performing a code pattern analysis of pointer references in the program to identify a set of pointer candidates from the ECTable for alignment calculation according to predefined criteria; performing said alignment calculation for each of said set of candidate pointers by iterating through a use-define chain of each identified candidate pointer beginning at a respective reference point of each identified candidate pointer; and receiving alignment information as a result of said alignment calculation and providing said alignment information to a compiler; the memory; A system comprising:

10. 1. A computer program product for calculating pointer alignment during programming, comprising: program instructions for recording equivalence classes of pointers in an equivalence class mapping table (ECTable) in response to collecting equivalence classes of pointers in a program using flow-insensitive, field-sensitive unification-based pointer analysis; program instructions for performing a code pattern analysis of pointer references within the program to identify a set of pointer candidates from the ECTable for alignment calculation according to predefined criteria; program instructions for performing the alignment calculation for each of the set of candidate pointers by iterating through a use-define chain of each identified candidate pointer beginning at a respective reference point of each identified candidate pointer; program instructions for receiving alignment information as a result of said alignment calculation and providing said alignment information to a compiler; the program instructions including:

1. A computer program product comprising:

11. A computer-readable storage medium having the computer program of claim 10 recorded thereon.

12. A method for calculating pointer alignment during programming by computer processing, comprising: using a pointer analysis operation to collect equivalence classes of pointers in the program; identifying only a portion of the collected pointer equivalence classes as pointer candidates for pointer alignment calculation according to predefined pointer reference patterns; performing the pointer alignment calculation for each identified pointer candidate to obtain alignment information used to optimize execution of the program; A method comprising:

Citation Information

Patent Citations

  • Program processor

    JP2006107339A

  • Method of analyzing pointer, computer therefor and computer program

    JP2012128584A

  • A user-oriented and profile-driven optimization framework.

    JP2016517109A

  • Optimizing compiler for improving application performance on many-core coprocessors

    US20130055224A1