This is an archive of the discontinued LLVM Phabricator instance.

[JITLink] Introduce virtual offsets for Symbol definitions in LinkGraph
AbandonedPublic

Authored by sgraenitz on Feb 24 2023, 3:19 AM.

Details

Reviewers
lhames
Summary

On AArch32 branch offsets explicitly encode the target instruction subset (Arm/Thumb) in their least significant bit. We want to store Thumb symbol definitions with the extra bit set, so that branch offset calculations account for instruction subset changes automatically.

However, we don't want to adjust the physical size of the symbol or the containing block, since this bit is not part of the symbol's physical location. Instead, we could consider it a virtual offset: Virtual offsets do affect branch offsets, but not physical memory size.

Diff Detail

Event Timeline

sgraenitz created this revision.Feb 24 2023, 3:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 3:19 AM
sgraenitz requested review of this revision.Feb 24 2023, 3:19 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2023, 3:19 AM

This implementation is one option. Symbols don't know their target triple, but the link-graph does. My main concern is that splitArchVirtualOffset() would introduce target-specific behavior to LinkGraph. Not sure how we could avoid it without changing the interface.

The alternative I see would be to extend the LinkGraph::add<...>Symbol() interface and:
(1) either add VirtualOffset as another parameter -- currently affects around 80 individual calls
(2) or add respective overloads where necessary -- affects no-one but adds extra overall complexity to the interface

What do you think?

lhames added a comment.Mar 5 2023, 6:28 PM

My gut reaction is to want to introduce a new "target flags" concept into Symbol, rather than using/abusing the address. On the other hand I think that using/abusing the address is the standard for thumb, and people might get thrown if this bit _isn't_ where they expect it to be.

If I'm right about that then the question is whether we want to privilege the generic LinkGraph assumptions over the thumb ones, or vice versa.

sgraenitz abandoned this revision.Mar 22 2023, 9:56 AM

Dropping this in favor of D146641