Skip to content

Cfi update - #138

Draft
woodard wants to merge 9 commits into
ccoutant:mainfrom
woodard:cfi-update
Draft

Cfi update#138
woodard wants to merge 9 commits into
ccoutant:mainfrom
woodard:cfi-update

Conversation

@woodard

@woodard woodard commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Heavy editing of CFI updates

Merged all the proposals which deal with CFI back into one bigger proposal.

woodard added 3 commits March 20, 2026 18:44
Converted the clarification updates from 003-clarification-cfi.txt
into markdown. Then merged them with the parts from
013-generalize-address-spaces.md that were left out of the address
space proposal. Then merged inHeavy editing of CFI updates
 the new operator from
017-call-frame-entry-registers.txt into one pro
posal that handles alConverted the clarification updates from 003-clarification-cfi.txt
l
the CFI loosinto markdown. Then merged them with the parts from
e ends.

Began addi013-generalize-address-spaces.md that were left out of the address
ng something like the operation headers tspace proposal. Then merged in the new operator from
o the CFA Instru017-call-frame-entry-registers.txt into one proposal that handles all
ctions.
the CFI loose ends.

Began adding something like the operation headers to the CFA Instructions.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Ben Woodard <woodard@redhat.com>
@woodard
woodard marked this pull request as draft March 21, 2026 01:52
woodard added 3 commits April 2, 2026 11:53
More work on the CFI proposal. Still WIP.

Signed-off-by: Ben Woodard <woodard@redhat.com>
New intro -- much better. Kind of brings the whole topic together.
Begin adding prototype like headers to rules.

Signed-off-by: Ben Woodard <woodard@redhat.com>

@markus-metzger markus-metzger left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I stopped reviewing at some point. I think this needs the high-level design described in the introduction.

Going through the changes, I suspect that the intent is to turn CFA into a location and make all CFI rules yield locations. I'm not convinced that this is strictly necessary. It seems to add complications and turns simple and clear rules into something rather complicated.

Defining CFA as an integral offset in some ABI-defined address-space (which could be some generic address-space covering multiple address-spaces) would leave most of CFI intact. I would like to see an example where this simpler approach would not work.

Comment thread 003-cfi-update.md Outdated
> *Previously, the Call Frame Location, CFL, was known as the Call
> Frame Address, CFA. However, GPUs do not necessarily store
> previous frames on the stack, they may pushed to some local
> storage in the GPU. So it is not quite to appropriate to assume

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that 'local storage in the GPU' also behave like a stack? Are we just talking about different address-spaces or something more exotic?

Comment thread 003-cfi-update.md

With:

> An area of memory that is allocated on a stack called a “call

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not convinced that CFA needs to be a location and cannot be an integral offset in an ABI-defined address-space that contains the stack.

Comment thread 003-cfi-update.md
with "Call Frame Location" in the paragraph that describes what the
CFL is.

> The previous value of this register is the undefined location

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not clear where this is to be added. Looks like it is replacing the 'undefined' rule. I think it is fine as it is unless we want to change all CFI register rules to produce a location. The introduction did not say anything like that (or I didn't find or understand it).

Comment thread 003-cfi-update.md
requirements that are different than CPUs. In particular, they have
multiple address spaces and and can spill registers to them. Some
architectures of GPUs can even spill registers to other registers
which are farther away in their memory hierarchy. The fact that GPUs

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 'farther away in their memory hierarchy' mean in the context of registers?

Comment thread 003-cfi-update.md
multiple address spaces and and can spill registers to them. Some
architectures of GPUs can even spill registers to other registers
which are farther away in their memory hierarchy. The fact that GPUs
use various locations to store previous frames which cannot be

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does 'use various locations to store previous frames' mean? Can we give a concrete real-world example?

Comment thread 003-cfi-update.md
Comment thread 003-cfi-update.md Outdated
Comment thread 003-cfi-update.md
following:

> The previous value of this register is located either in a generic
> value or in implicit storage produced by evaluating the DWARF

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the producer wanted to use implicit storage, why did it not use the 'expression(E)' rule?

I see no issue with restricting 'val_expression(E)' to values that can be pushed onto the stack and leave the rule to define the value of the register as the top stack element after evaluating E.

woodard added 2 commits May 4, 2026 11:54
Another big chunk of edits as I pound this into shape. Several of the
edits needed discussion by the group and needed to be resolved there.

Thanks to Markus Metzger for his review comments. Several of them have
been taken care of but several still need to be worked through and
resolved.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Comment thread 003-cfi-update.md
which are farther away in their memory hierarchy. The fact that GPUs
use various locations to store previous frames which cannot be
expressed as a simple address requires the generalization of Call
Frame Addresses or Cononical Frame Addresses CFA (it is used

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Cononical

Comment thread 003-cfi-update.md
section and the .debug_frames section for the target GPU in its
embedded ELF file. If there were an architecture where the host's ELF
file's .debug_frames section mixed addresses between host code and
device code, then additional Row Creation Instructions would be need

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "would be need" -> "would need"

Comment thread 003-cfi-update.md
In bullet point 3 Current Compilation Unit add the following paragraph
between the normative text and the non-normative text.

> DWARF exppressions used in CFI (see Section 7.4.2 on page 198) do

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: exppressions

Comment thread 003-cfi-update.md
Comment on lines +160 to +161
> DWARF exppressions used for variable's location or value do not
> have a curret register in their context.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: exppressions, curret

Comment thread 003-cfi-update.md
To:

> *A DWARF expression may be able to be evaluated without a thread,
> call frame, lane, program counter, current object, registeer, or

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: registeer

Comment thread 003-cfi-update.md
> the current state of the register. However, if the current frame
> is not the top most frame, then operators such as DW_OP_reg<N>,
> DW_OP_regx, DW_OP_breg<N> and DW_OP_bregx will access the
> previous contents of the register by applying the CFI rules which

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comma before "which".

Comment thread 003-cfi-update.md
Comment on lines +207 to +223
In the description of DW_OP_breg0...DW_OP_breg32 after "register
(0-31)" add the following qualifier: "at the time of the Current Frame
(See 3.1 page 47) are virtually restored by CFI (see 7.4 page 193)"

In section 3.8 replace:

> The following DWARF operations can be used to specify a register
> location.

With:

> The following DWARF operations can be used to specify a register
> location. When the Current Frame (See 3.1 page 47) in the
> Expression Evaluation Context is not the top most frame, then the
> state of these registers is first virtually restored using CFI
> (See section 7.4 page 193) and that value is referenced when
> evaluating these operations.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Below, there is a new paragraph that starts with "When a consumer is evaluating a DWARF expression in the context...". If that paragraph is added, do we still need these changes?

Comment thread 003-cfi-update.md
Comment on lines +296 to +302
For the "val_offset(N)" register rule, replace the description with
the following:

> N is a signed byte offset. The previous value of this register is
> saved at the memory address pointed to by the location description
> L, where L is the location description of the current CFL offset by
> N bytes.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the "offset" rule, not "val_offset'.

Comment thread 003-cfi-update.md
For the "val_offset(N)" register rule, replace the description with
the following:

> N is a signed byte offset. The previous value of this register is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about this rewording?
The previous value of this register is saved at CFL, offset by N bytes.

Comment thread 003-cfi-update.md
> *For example, if a register R1 has a `DW_CFA_def_cfa_expression`
> instruction that evaluates a `DW_OP_call_frame_entry_reg`
> operation that specifies register R2, and register R2 has a
> `DW_CFA_def_cfa_expression` instruction that that evaluates a

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"that that" -> "that"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants