Commit 076226f
authored
[ELF] Separate relative and non-relative dynamic relocations (llvm#187959)
Previously, the flow was:
1. Parallel scan adds relative relocs to per-thread `relocsVec`
2. `mergeRels()` copies all into `relocs`
3. `partitionRels()` uses `stable_partition` to separate
Now, relative relocs are routed at `addReloc` time by checking
`reloc.type == relativeRel`. In `mergeRels`, sharded entries are
classified through the same `addReloc` path rather than blindly
appended. `relocsVec` may contain non-relative entries like
`R_AARCH64_AUTH_RELATIVE`.
This eliminates the `stable_partition` on the full relocation vector
(543K entries for clang) and avoids copying relative relocations into
`relocs` only to move them out again.
Linking an x86_64 release+assertions build of clang is 1.04x as fast.
`numRelativeRelocs` caches `relativeRelocs.size()` at `finalizeContents`
time for `DT_RELACOUNT`. Using a live `relativeRelocs.size()` would
cause `DynamicSection::writeTo` to emit an extra entry when thunks add
relocs after `.dynamic` is sized, overflowing into adjacent sections.
Tested by ppc64-long-branch-rel14.s.1 parent 5567572 commit 076226f
2 files changed
+35
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1483 | 1483 | | |
1484 | 1484 | | |
1485 | 1485 | | |
1486 | | - | |
| 1486 | + | |
| 1487 | + | |
1487 | 1488 | | |
1488 | 1489 | | |
1489 | 1490 | | |
| |||
1503 | 1504 | | |
1504 | 1505 | | |
1505 | 1506 | | |
1506 | | - | |
| 1507 | + | |
1507 | 1508 | | |
1508 | 1509 | | |
1509 | | - | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
1510 | 1514 | | |
1511 | | - | |
| 1515 | + | |
| 1516 | + | |
1512 | 1517 | | |
1513 | 1518 | | |
1514 | 1519 | | |
1515 | | - | |
1516 | | - | |
1517 | | - | |
1518 | | - | |
1519 | | - | |
1520 | | - | |
1521 | | - | |
1522 | | - | |
1523 | | - | |
1524 | | - | |
1525 | 1520 | | |
1526 | 1521 | | |
1527 | | - | |
1528 | | - | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
1529 | 1525 | | |
1530 | 1526 | | |
1531 | 1527 | | |
| |||
1551 | 1547 | | |
1552 | 1548 | | |
1553 | 1549 | | |
| 1550 | + | |
| 1551 | + | |
| 1552 | + | |
1554 | 1553 | | |
1555 | 1554 | | |
1556 | 1555 | | |
1557 | 1556 | | |
| 1557 | + | |
| 1558 | + | |
1558 | 1559 | | |
1559 | | - | |
| 1560 | + | |
1560 | 1561 | | |
1561 | 1562 | | |
1562 | 1563 | | |
1563 | 1564 | | |
1564 | 1565 | | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
1571 | 1571 | | |
1572 | 1572 | | |
1573 | | - | |
1574 | 1573 | | |
1575 | 1574 | | |
1576 | 1575 | | |
| |||
1585 | 1584 | | |
1586 | 1585 | | |
1587 | 1586 | | |
1588 | | - | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
1589 | 1590 | | |
1590 | 1591 | | |
1591 | 1592 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
495 | 495 | | |
496 | 496 | | |
497 | 497 | | |
498 | | - | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
499 | 502 | | |
500 | 503 | | |
501 | 504 | | |
| |||
532 | 535 | | |
533 | 536 | | |
534 | 537 | | |
535 | | - | |
| 538 | + | |
536 | 539 | | |
537 | 540 | | |
538 | 541 | | |
539 | | - | |
| 542 | + | |
540 | 543 | | |
541 | 544 | | |
542 | 545 | | |
| |||
545 | 548 | | |
546 | 549 | | |
547 | 550 | | |
548 | | - | |
| 551 | + | |
549 | 552 | | |
550 | 553 | | |
551 | 554 | | |
552 | | - | |
553 | 555 | | |
554 | 556 | | |
555 | | - | |
| 557 | + | |
556 | 558 | | |
557 | 559 | | |
| 560 | + | |
558 | 561 | | |
559 | 562 | | |
560 | 563 | | |
| |||
0 commit comments