We want to incorporate some of the optimization passes in bind opcodes from ld64.
This revision makes no functional changes but to start storing opcodes in intermediate
containers in preparation for implementing the optimization passes in a follow-up revision.
Details
- Reviewers
int3 gkm - Group Reviewers
Restricted Project - Commits
- rGf2b1264141b0: [lld-macho] Use intermediate arrays to store opcodes
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
395 | nope, it's leftover code from before I added sortBindings. good catch :) |
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
280 | how about BindIR? | |
282 | how about renaming it to data so that there's less confusion about why we're using delta to refer to an offset or an addend? (alternatively we could use a union here) | |
299–300 | cast shouldn't be necessary any more I think. I used it for writing to the stream because we would otherwise call the integer overload of the stream operator. But here there's no overload to worry about | |
303 | ||
319 | I don't think there's anything to mask here, since we are explicitly setting op.opcode to one of the opcode values minus any extra data. But we could do an assert to be on the safe side :) |
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
319 | Doesn't this operation BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | seg->index mean it's possible that extra data could be embedded in an opcode value? Otherwise, why perform seg->index in the first place? |
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
281–282 | Probably not, since we always construct these values explicitly. But, the reason for having it as default is 1/ follow the convention of Binding struct and 2/ in the event that something goes awry, 0xF0 is not valid opcode and should make the program scream instead of accidentally writing "valid" values. Plus, I think it'll debugging easier if we see these specific values when debugging. | |
298–299 | Fwiw, the tests did pass. I'll revert to the old implementation. |
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
281–282 |
Can you add that as a comment? Otherwise it looks a bit like a magic number :) |
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
298–299 | I get why we added the cast back, but the temporary seems unnecessary... we can construct it inline as part of the push_back statement. Also, the cast is only needed for BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB | seg->index as | returns an int (regardless of the size of its operands). We don't need the cast for the other opcodes below (I thought you meant 'revert' as in 'partial revert', didn't realize you were going to do a full one) |
how about BindIR?