Skip to content

Commit f6b2556

Browse files
author
anoopkg6
committed
Incorporate code review feedback
1 parent 2f7a610 commit f6b2556

File tree

3 files changed

+127
-171
lines changed

3 files changed

+127
-171
lines changed

llvm/include/llvm/ExecutionEngine/JITLink/systemz.h

Lines changed: 82 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ enum EdgeKind_systemz : Edge::Kind {
203203
/// an out-of-range error will be returned.
204204
NegDelta32,
205205

206-
/// A GOT entry getter/constructor, transformed to DeltaPLT64FromGOT pointing
206+
/// A GOT entry getter/constructor, transformed to Delta64FromGOT pointing
207207
/// at the GOT entry for the original target.
208208
///
209-
/// Indicates that this edge should be transformed into a DeltaPLT64FromGOT
209+
/// Indicates that this edge should be transformed into a Delta64FromGOT
210210
/// targeting the GOT entry for the edge's current target, maintaining the
211211
/// same addend. A GOT entry for the target should be created if one does
212212
/// not already exist.
@@ -220,12 +220,12 @@ enum EdgeKind_systemz : Edge::Kind {
220220
/// Errors:
221221
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
222222
///
223-
RequestGOTAndTransformToDeltaPLT64FromGOT,
223+
RequestGOTAndTransformToDelta64FromGOT,
224224

225-
/// A GOT entry getter/constructor, transformed to DeltaPLT32FromGOT pointing
225+
/// A GOT entry getter/constructor, transformed to Delta32FromGOT pointing
226226
/// at the GOT entry for the original target.
227227
///
228-
/// Indicates that this edge should be transformed into a DeltaPLT32FromGOT
228+
/// Indicates that this edge should be transformed into a Delta32FromGOT
229229
/// targeting the GOT entry for the edge's current target, maintaining the
230230
/// same addend. A GOT entry for the target should be created if one does
231231
/// not already exist.
@@ -239,12 +239,12 @@ enum EdgeKind_systemz : Edge::Kind {
239239
/// Errors:
240240
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
241241
///
242-
RequestGOTAndTransformToDeltaPLT32FromGOT,
242+
RequestGOTAndTransformToDelta32FromGOT,
243243

244-
/// A GOT entry getter/constructor, transformed to DeltaPLT16FromGOT pointing
244+
/// A GOT entry getter/constructor, transformed to Delta16FromGOT pointing
245245
/// at the GOT entry for the original target.
246246
///
247-
/// Indicates that this edge should be transformed into a DeltaPLT16FromGOT
247+
/// Indicates that this edge should be transformed into a Delta16FromGOT
248248
/// targeting the GOT entry for the edge's current target, maintaining the
249249
/// same addend. A GOT entry for the target should be created if one does
250250
/// not already exist.
@@ -258,7 +258,7 @@ enum EdgeKind_systemz : Edge::Kind {
258258
/// Errors:
259259
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
260260
///
261-
RequestGOTAndTransformToDeltaPLT16FromGOT,
261+
RequestGOTAndTransformToDelta16FromGOT,
262262

263263
/// A 32-bit Delta shifted by 1.
264264
///
@@ -350,17 +350,14 @@ enum EdgeKind_systemz : Edge::Kind {
350350

351351
/// A 64-bit offset from GOT to PLT.
352352
///
353-
/// Delta from the fixup to the target. This will lead to creation of a
354-
/// PLT stub.
355-
///
356353
/// Fixup expression:
357354
/// Fixup <- Target - GOTBase + Addend : int64
358355
///
359356
/// Errors:
360357
/// - *ASSERTION* Failure to a null pointer GOTSymbol, which the GOT section
361358
/// symbol was not been defined.
362359
///
363-
DeltaPLT64FromGOT,
360+
Delta64PLTFromGOT,
364361

365362
/// A 32-bit offset from GOT to PLT.
366363
///
@@ -373,22 +370,46 @@ enum EdgeKind_systemz : Edge::Kind {
373370
/// - The result of the fixup expression must fit into an int32, otherwise
374371
/// an out-of-range error will be returned.
375372
///
376-
DeltaPLT32FromGOT,
373+
Delta32PLTFromGOT,
377374

378-
/// A 20-bit offset from GOT to PLT.
375+
/// A 16-bit offset from GOT to PLT.
379376
///
380377
/// Fixup expression:
381-
/// Fixup <- Target - GOTBase + Addend : int20
378+
/// Fixup <- Target - GOTBase + Addend : int16
382379
///
383380
/// Errors:
384381
/// - *ASSERTION* Failure to a null pointer GOTSymbol, which the GOT section
385382
/// symbol was not been defined.
386383
/// - The result of the fixup expression must fit into an int16, otherwise
387384
/// an out-of-range error will be returned.
388385
///
389-
DeltaPLT20FromGOT,
386+
Delta16PLTFromGOT,
390387

391-
/// A 16-bit offset from GOT to PLT.
388+
/// A 64-bit offset from GOT.
389+
///
390+
/// Fixup expression:
391+
/// Fixup <- Target - GOTBase + Addend : int64
392+
///
393+
/// Errors:
394+
/// - *ASSERTION* Failure to a null pointer GOTSymbol, which the GOT section
395+
/// symbol was not been defined.
396+
///
397+
Delta64FromGOT,
398+
399+
/// A 32-bit offset from GOT.
400+
///
401+
/// Fixup expression:
402+
/// Fixup <- Target - GOTBase + Addend : int32
403+
///
404+
/// Errors:
405+
/// - *ASSERTION* Failure to a null pointer GOTSymbol, which the GOT section
406+
/// symbol was not been defined.
407+
/// - The result of the fixup expression must fit into an int32, otherwise
408+
/// an out-of-range error will be returned.
409+
///
410+
Delta32FromGOT,
411+
412+
/// A 16-bit offset from GOT.
392413
///
393414
/// Fixup expression:
394415
/// Fixup <- Target - GOTBase + Addend : int16
@@ -399,9 +420,22 @@ enum EdgeKind_systemz : Edge::Kind {
399420
/// - The result of the fixup expression must fit into an int16, otherwise
400421
/// an out-of-range error will be returned.
401422
///
402-
DeltaPLT16FromGOT,
423+
Delta16FromGOT,
424+
425+
/// A 20-bit offset from GOT.
426+
///
427+
/// Fixup expression:
428+
/// Fixup <- Target - GOTBase + Addend : int20
429+
///
430+
/// Errors:
431+
/// - *ASSERTION* Failure to a null pointer GOTSymbol, which the GOT section
432+
/// symbol was not been defined.
433+
/// - The result of the fixup expression must fit into an int16, otherwise
434+
/// an out-of-range error will be returned.
435+
///
436+
Delta20FromGOT,
403437

404-
/// A 12-bit offset from GOT to PLT.
438+
/// A 12-bit offset from GOT.
405439
///
406440
/// Fixup expression:
407441
/// Fixup <- Target - GOTBase + Addend : int12
@@ -412,12 +446,12 @@ enum EdgeKind_systemz : Edge::Kind {
412446
/// - The result of the fixup expression must fit into an int16, otherwise
413447
/// an out-of-range error will be returned.
414448
///
415-
DeltaPLT12FromGOT,
449+
Delta12FromGOT,
416450

417-
/// A GOT entry getter/constructor, transformed to DeltaPLT20FromGOT pointing
451+
/// A GOT entry getter/constructor, transformed to Delta20FromGOT pointing
418452
/// at the GOT entry for the original target.
419453
///
420-
/// Indicates that this edge should be transformed into a DeltaPLT20FromGOT
454+
/// Indicates that this edge should be transformed into a Delta20FromGOT
421455
/// targeting the GOT entry for the edge's current target, maintaining the
422456
/// same addend. A GOT entry for the target should be created if one does
423457
/// not already exist.
@@ -431,12 +465,12 @@ enum EdgeKind_systemz : Edge::Kind {
431465
/// Errors:
432466
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
433467
///
434-
RequestGOTAndTransformToDeltaPLT20FromGOT,
468+
RequestGOTAndTransformToDelta20FromGOT,
435469

436-
/// A GOT entry getter/constructor, transformed to DeltaPLT12FromGOT pointing
470+
/// A GOT entry getter/constructor, transformed to Delta12FromGOT pointing
437471
/// at the GOT entry for the original target.
438472
///
439-
/// Indicates that this edge should be transformed into a DeltaPLT12FromGOT
473+
/// Indicates that this edge should be transformed into a Delta12FromGOT
440474
/// targeting the GOT entry for the edge's current target, maintaining the
441475
/// same addend. A GOT entry for the target should be created if one does
442476
/// not already exist.
@@ -451,7 +485,7 @@ enum EdgeKind_systemz : Edge::Kind {
451485
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
452486
/// phase will result in an assert/unreachable during the fixup phase.
453487
///
454-
RequestGOTAndTransformToDeltaPLT12FromGOT,
488+
RequestGOTAndTransformToDelta12FromGOT,
455489

456490
/// A GOT entry getter/constructor, transformed to Delta32dbl pointing at
457491
/// the GOT entry for the original target.
@@ -473,44 +507,6 @@ enum EdgeKind_systemz : Edge::Kind {
473507
///
474508
RequestGOTAndTransformToDelta32dbl,
475509

476-
/// A GOTPC entry getter/constructor, transformed to Delta32GOTBase
477-
/// delta to GOT base.
478-
///
479-
/// Indicates that this edge should be transformed into a Delta32GOTBase
480-
/// targeting the GOTPC entry for the edge's current target, maintaining
481-
/// the same addend. A GOTPC entry for the target should be created if
482-
/// one does not already exist.
483-
///
484-
/// Edges of this kind are usually handled by a GOTPC builder pass inserted
485-
/// by default.
486-
///
487-
/// Fixup expression:
488-
/// NONE
489-
///
490-
/// Errors:
491-
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
492-
/// phase will result in an assert/unreachable during the fixup phase.
493-
RequestGOTPCAndTransformToDelta32GOTBase,
494-
495-
/// A GOTPC entry getter/constructor, transformed to Delta32dblGOTBase
496-
/// delta to GOT base.
497-
///
498-
/// Indicates that this edge should be transformed into a Delta32dblGOTBase
499-
/// targeting the GOTPC entry for the edge's current target, maintaining
500-
/// the same addend. A GOTPC entry for the target should be created if
501-
/// one does not already exist.
502-
///
503-
/// Edges of this kind are usually handled by a GOTPC builder pass inserted
504-
/// by default.
505-
///
506-
/// Fixup expression:
507-
/// NONE
508-
///
509-
/// Errors:
510-
/// - *ASSERTION* Failure to handle edges of this kind prior to the fixup
511-
/// phase will result in an assert/unreachable during the fixup phase.
512-
RequestGOTPCAndTransformToDelta32dblGOTBase,
513-
514510
/// A 32-bit Delta to GOT base.
515511
///
516512
/// Fixup expression:
@@ -701,29 +697,32 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
701697
write32be(FixupPtr, Value >> 1);
702698
break;
703699
}
704-
case DeltaPLT64FromGOT: {
700+
case Delta64PLTFromGOT:
701+
case Delta64FromGOT: {
705702
assert(GOTSymbol && "No GOT section symbol");
706703
int64_t Value = (S + A - GOTBase);
707704
write64be(FixupPtr, Value);
708705
break;
709706
}
710-
case DeltaPLT32FromGOT: {
707+
case Delta32PLTFromGOT:
708+
case Delta32FromGOT: {
711709
assert(GOTSymbol && "No GOT section symbol");
712710
int64_t Value = (S + A - GOTBase);
713711
if (!LLVM_UNLIKELY(isInt<32>(Value)))
714712
return makeTargetOutOfRangeError(G, B, E);
715713
write32be(FixupPtr, Value);
716714
break;
717715
}
718-
case DeltaPLT16FromGOT: {
716+
case Delta16PLTFromGOT:
717+
case Delta16FromGOT: {
719718
assert(GOTSymbol && "No GOT section symbol");
720719
int64_t Value = (S + A - GOTBase);
721720
if (!LLVM_UNLIKELY(isInt<16>(Value)))
722721
return makeTargetOutOfRangeError(G, B, E);
723722
write16be(FixupPtr, Value);
724723
break;
725724
}
726-
case DeltaPLT20FromGOT: {
725+
case Delta20FromGOT: {
727726
assert(GOTSymbol && "No GOT section symbol");
728727
uint64_t Value = S - GOTBase + A;
729728
if (!LLVM_UNLIKELY(isInt<20>(Value)))
@@ -732,7 +731,7 @@ inline Error applyFixup(LinkGraph &G, Block &B, const Edge &E,
732731
((Value & 0xFFF) << 16) | ((Value & 0xFF000) >> 4));
733732
break;
734733
}
735-
case DeltaPLT12FromGOT: {
734+
case Delta12FromGOT: {
736735
assert(GOTSymbol && "No GOT section symbol");
737736
uint64_t Value = S - GOTBase + A;
738737
if (!LLVM_UNLIKELY(isUInt<12>(Value)))
@@ -819,20 +818,20 @@ class GOTTableManager : public TableManager<GOTTableManager> {
819818
return false;
820819
Edge::Kind KindToSet = Edge::Invalid;
821820
switch (E.getKind()) {
822-
case systemz::RequestGOTAndTransformToDeltaPLT12FromGOT:
823-
KindToSet = systemz::DeltaPLT12FromGOT;
821+
case systemz::RequestGOTAndTransformToDelta12FromGOT:
822+
KindToSet = systemz::Delta12FromGOT;
824823
break;
825-
case systemz::RequestGOTAndTransformToDeltaPLT16FromGOT:
826-
KindToSet = systemz::DeltaPLT16FromGOT;
824+
case systemz::RequestGOTAndTransformToDelta16FromGOT:
825+
KindToSet = systemz::Delta16FromGOT;
827826
break;
828-
case systemz::RequestGOTAndTransformToDeltaPLT20FromGOT:
829-
KindToSet = systemz::DeltaPLT20FromGOT;
827+
case systemz::RequestGOTAndTransformToDelta20FromGOT:
828+
KindToSet = systemz::Delta20FromGOT;
830829
break;
831-
case systemz::RequestGOTAndTransformToDeltaPLT32FromGOT:
832-
KindToSet = systemz::DeltaPLT32FromGOT;
830+
case systemz::RequestGOTAndTransformToDelta32FromGOT:
831+
KindToSet = systemz::Delta32FromGOT;
833832
break;
834-
case systemz::RequestGOTAndTransformToDeltaPLT64FromGOT:
835-
KindToSet = systemz::DeltaPLT64FromGOT;
833+
case systemz::RequestGOTAndTransformToDelta64FromGOT:
834+
KindToSet = systemz::Delta64FromGOT;
836835
break;
837836
case systemz::RequestGOTAndTransformToDelta32dbl:
838837
KindToSet = systemz::DeltaPLT32dbl;
@@ -885,9 +884,9 @@ class PLTTableManager : public TableManager<PLTTableManager> {
885884
case systemz::DeltaPLT16dbl:
886885
case systemz::DeltaPLT24dbl:
887886
case systemz::DeltaPLT32dbl:
888-
case systemz::DeltaPLT16FromGOT:
889-
case systemz::DeltaPLT32FromGOT:
890-
case systemz::DeltaPLT64FromGOT:
887+
case systemz::Delta16PLTFromGOT:
888+
case systemz::Delta32PLTFromGOT:
889+
case systemz::Delta64PLTFromGOT:
891890
break;
892891
default:
893892
return false;
@@ -918,53 +917,6 @@ class PLTTableManager : public TableManager<PLTTableManager> {
918917
Section *StubsSection = nullptr;
919918
};
920919

921-
/// GOTPC Table Builder.
922-
class GOTPCTableManager : public TableManager<GOTPCTableManager> {
923-
public:
924-
GOTPCTableManager(GOTTableManager &GOT) : GOT(GOT) {}
925-
926-
static StringRef getSectionName() { return "$__GOTPC"; }
927-
928-
bool visitEdge(LinkGraph &G, Block *B, Edge &E) {
929-
Edge::Kind KindToSet = Edge::Invalid;
930-
switch (E.getKind()) {
931-
case systemz::RequestGOTPCAndTransformToDelta32GOTBase:
932-
KindToSet = systemz::Delta32GOTBase;
933-
break;
934-
case systemz::RequestGOTPCAndTransformToDelta32dblGOTBase:
935-
KindToSet = systemz::Delta32dblGOTBase;
936-
break;
937-
default:
938-
return false;
939-
}
940-
assert(KindToSet != Edge::Invalid &&
941-
"Fell through switch, but no new kind to set");
942-
DEBUG_WITH_TYPE("jitlink", {
943-
dbgs() << " Fixing " << G.getEdgeKindName(E.getKind()) << " edge at "
944-
<< B->getFixupAddress(E) << " (" << B->getAddress() << " + "
945-
<< formatv("{0:x}", E.getOffset()) << ")\n";
946-
});
947-
E.setKind(KindToSet);
948-
E.setTarget(getEntryForTarget(G, E.getTarget()));
949-
return true;
950-
}
951-
952-
Symbol &createEntry(LinkGraph &G, Symbol &Target) {
953-
return createAnonymousPointer(G, getGOTPCSection(G), &Target);
954-
}
955-
956-
private:
957-
Section &getGOTPCSection(LinkGraph &G) {
958-
if (!GOTPCSection)
959-
GOTPCSection = &G.createSection(getSectionName(),
960-
orc::MemProt::Read | orc::MemProt::Exec);
961-
return *GOTPCSection;
962-
}
963-
964-
GOTTableManager &GOT;
965-
Section *GOTPCSection = nullptr;
966-
};
967-
968920
} // namespace systemz
969921
} // namespace jitlink
970922
} // namespace llvm

0 commit comments

Comments
 (0)