This is an archive of the discontinued LLVM Phabricator instance.

[AIX] Support init priority
ClosedPublic

Authored by Xiangling_L on Nov 11 2020, 9:00 AM.

Details

Summary

Support reserved [0-100] and non-reserved[101-65535] Clang/GNU init priority values on AIX.

This patch maps Clang/GNU values into priority values used in sinit/sterm functions. User can play with values and be able to get init to occur before or after XL init and vice versa.

The conversion strategies are: For [0-100] reserved and [101-65535] non-reserved Clang/GNU values, we use linear interpolation to map Clang to sinit/sterm priority values. But 21/20 on reserved range ends and 1024 on both non-reserved range ends will be used with a factor of 1.

Diff Detail

Event Timeline

Xiangling_L created this revision.Nov 11 2020, 9:00 AM
Xiangling_L requested review of this revision.Nov 11 2020, 9:00 AM
Xiangling_L edited the summary of this revision. (Show Details)

Fix wrong sinit/sterm function formatting issue;

sfertile added inline comments.Nov 19 2020, 7:54 AM
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
2003

The comment and table do a good job explains the mapping you want to do, but could we condense it without loosing too much if we reworded it? Something along the lines of:

We map the reserved clang/gnu priority range [0-100] into the sterm/sinit reserved priority range [0,1023] by 
- directly mapping the first 20 elements of the ranges
- directly mapping the last 20 elements of the ranges
- linear interpolating the intermediate values with a step size of 16.

We map the non reserved clang/gnu priority range of [101, 65535] into the sterm/sinit priority range [1024,2147483648] by:
- directly mapping the first 1023 elements of the ranges
- directly mapping the last 1023 elements of the ranges.
- linear interpolating the intermediate values with a step size of 33878.
2037

Suggestion: Having the actual mapping done in a separate helper cleans up the initialization:

unsigned MapedPriority = mapPriorityToSinit(Priority);
llvm/test/CodeGen/PowerPC/aix-static-init-non-default-priority.ll
1–2

missing -verify-machineinstrs

Xiangling_L marked 2 inline comments as done.

Addressed the comments;

A couple of really minor comments, but otherwise LGTM.

llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
2000

Its simpler if we use returns:

if (P <=20)
  return P;

if (P < 81)
  return 20 + (P - 20) * 16;

etc ...
2028

Real minor nit: Move this inside the helper function.

Xiangling_L marked 3 inline comments as done.

Addressed comments;

This revision is now accepted and ready to land.Nov 23 2020, 10:17 AM
This revision was automatically updated to reflect the committed changes.