# US 12,182,553 B2 · User customizable compiler attributes for code optimization

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 12,182,553 B2
- Document ID: US12182553B2
- Status: Granted
- Kind: B2
- Application number: 17/665,830
- Filed: 2022-02-07
- Published: 2023-08-10
- Granted: 2024-12-31
- Earliest claimed: 2022-02-07
- Assignees: Red Hat, Inc.
- Applicants: Red Hat, Inc.
- Inventors: Ulrich Drepper
- Web page: https://patentgrep.com/patent/US12182553B2

## CPC

- G06F 8/443: {Optimisation}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Disclosed herein is technology to use customized compiler attributes to enhance code optimizations. An example method may include: accessing, by a processing device executing a compiler, a source code comprising a compiler attribute, wherein the compiler attribute is defined by text in the source code; detecting, by the processing device, a call in the source code to a compiler function that processes the compiler attribute, wherein the source code includes logic to process the compiler attribute; executing, by the processing device, the compiler function at compile time, wherein the compiler function uses the logic to process the compiler attribute and generates attribute data; and using, by the compiler, the attribute data to optimize object code generated from the source code.

## Claims

### Claim 1

A method comprising:
accessing, by a processing device executing a compiler, a source code comprising a compiler attribute, wherein the compiler attribute is defined by text in the source code;
detecting, by the processing device, a call in the source code to a first compiler function identified by function name in the source code that assigns a value to the compiler attribute in association with a variable declared in the source code, wherein the source code includes logic to process the compiler attribute;
executing, by the processing device, a second compiler function identified by function name in the source code at compile time to return a function result based on the value of the compiler attribute associated with the variable, wherein the compiler uses the logic to process the compiler attribute and, based on the function result generates an executable code segment that is a different executable code segment than would be generated based on a different value of the compiler attribute.

### Claim 2 (depends on 1)

The method of claim 1, wherein the text in the source code that defines the compiler attribute is provided by an author of the source code and comprises a call to a predefined compiler function and one or more user defined attribute values created by the author, wherein the user defined attribute values comprise at least one of a user defined attribute name or a user defined attribute type.

### Claim 3 (depends on 1)

The method of claim 1, wherein the logic is not included in object code and not evaluated at runtime, and wherein the logic comprises an if statement, a while loop, or a for loop.

### Claim 4 (depends on 1)

The method of claim 1, wherein the logic to process the compiler attribute is provided by an author of the source code and comprises attribute combining logic and attribute testing logic.

### Claim 5 (depends on 1)

The method of claim 1, further comprising:
generating, by the compiler, an intermediate representation that comprises multiple control flows that converge, wherein the multiple control flows each comprise the compiler attribute; and
using, by the compiler, attribute combining logic provided by the author to combine the compiler attributes of the multiple control flows into a combined attribute.

### Claim 6 (depends on 1)

The method of claim 1, further comprising:
detecting, by the compiler, that the compiler attribute defined in the source code is assigned to each of a plurality of descriptor variables;
evaluating, by the compiler, the compiler attributes at a location in the source code, wherein the compiler attributes indicate each of the descriptor variables comprise a target type that is a network socket; and
optimizing, by the compiler, the object code to include a call to a specific function that handles network sockets and to be absent a call to a generic function that handles multiple target types.

### Claim 7

A system comprising:
a memory; and
a processing device communicably coupled to the memory, the processing device to:
access a source code comprising a compiler attribute, wherein the compiler attribute is defined by text in the source code;
detect a call in the source code to a first compiler function identified by function name in the source code that assigns a value to the compiler attribute in association with a variable declared in the source code, wherein the source code includes logic to process the compiler attribute;
execute a second compiler function identified by function name in the source code at compile time to return a function result based on the value of the compiler attribute associated with the variable, wherein the compiler uses the logic to process the compiler attribute and, based on the function result generates an executable code segment that is a different executable code segment than would be generated based on a different value of the compiler attribute.

### Claim 8 (depends on 7)

The system of claim 7, wherein the text in the source code that defines the compiler attribute is provided by an author of the source code and comprises a call to a predefined compiler function and one or more user defined attribute values created by the author, wherein the user defined attribute values comprise at least one of a user defined attribute name or a user defined attribute type.

### Claim 9 (depends on 7)

The system of claim 7, wherein the logic is not included in object code and not evaluated at runtime, and wherein the logic comprises an if statement, a while loop, or a for loop.

### Claim 10 (depends on 7)

The system of claim 7, wherein the logic to process the compiler attribute is provided by an author of the source code and comprises attribute combining logic and attribute testing logic.

### Claim 11 (depends on 7)

The system of claim 7, wherein the processing device is further to:
generate an intermediate representation that comprises multiple control flows that converge, wherein the multiple control flows each comprise the compiler attribute; and
use attribute combining logic provided by the author to combine the compiler attributes of the multiple control flows into a combined attribute.

### Claim 12 (depends on 7)

The system of claim 7, wherein the processing device is further to:
detect that the compiler attribute defined in the source code is assigned to each of a plurality of descriptor variables;
evaluate the compiler attributes at a location in the source code, wherein the compiler attributes indicate each of the descriptor variables comprise a target type that is a network socket; and
optimize the object code to include a call to a specific function that handles network sockets and to be absent a call to a generic function that handles multiple target types.

### Claim 13

A non-transitory machine-readable storage medium storing instructions which, when executed, cause a processing device to perform operations comprising:
accessing a source code comprising a compiler attribute, wherein the compiler attribute is defined by text in the source code;
detecting a call in the source code to a first compiler function identified by function name in the source code that assigns a value to the compiler attribute in association with a variable declared in the source code, wherein the source code includes logic to process the compiler attribute;
executing a second compiler function identified by function name in the source code at compile time to return a function result based on the value of the compiler attribute associated with the variable, wherein the compiler uses the logic to process the compiler attribute and, based on the function result generates an executable code segment that is a different executable code segment than would be generated based on a different value of the compiler attribute.

### Claim 14 (depends on 13)

The non-transitory machine-readable storage medium of claim 13, wherein the text in the source code that defines the compiler attribute is provided by an author of the source code and comprises a call to a predefined compiler function and one or more user defined attribute values created by the author, wherein the user defined attribute values comprise at least one of a user defined attribute name or a user defined attribute type.

### Claim 15 (depends on 13)

The non-transitory machine-readable storage medium of claim 13, wherein the logic statement is not included in object code and not evaluated at runtime, and wherein the logic comprises an if statement, a while loop, or a for loop.

### Claim 16 (depends on 13)

The non-transitory machine-readable storage medium of claim 13, wherein the logic to process the compiler attribute is provided by an author of the source code and comprises attribute combining logic and attribute testing logic.

### Claim 17 (depends on 13)

The non-transitory machine-readable storage medium of claim 13, wherein the operations further comprise:
generating an intermediate representation that comprises multiple control flows that converge, wherein the multiple control flows each comprise the compiler attribute; and
using attribute combining logic provided by the author to combine the compiler attributes of the multiple control flows into a combined attribute.
