[PATCH] D113818: [MachO] Shrink reloc from 32 bytes to 24 bytes

Shoaib Meenai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 16 17:04:31 PST 2021


smeenai added a subscriber: oontvoo.
smeenai added inline comments.


================
Comment at: lld/MachO/InputFiles.cpp:355
+template <class T>
+static InputSection *findContainingSubsection(SubsectionMap &map, T *offset) {
   auto it = std::prev(llvm::upper_bound(
----------------
int3 wrote:
> smeenai wrote:
> > int3 wrote:
> > > hm, can't we leave it as uint64_t and have the uint32_t be automatically promoted?
> > Promotion doesn't happen for pointer arguments (you wouldn't wanna write 8 bytes into a 4 byte storage slot).
> OH right. I knew that, I just couldn't read :P
> 
> > If reviewers prefer, I could instead make findContainingSubsection take the InputSection * as the output argument and return the adjusted offset, so that the return value can just be downcast instead of needing a template.
> 
> Nah this seems ugly in a different way, `findFoo` functions should generally return `Foo`s...
> 
> Maybe add a comment here that we expect `T` to be either uint32_t or uint64_t?
I was gonna add a type assert but screwed up my push; whoops. @oontvoo fixed that in D114044; thank you!


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D113818/new/

https://reviews.llvm.org/D113818



More information about the llvm-commits mailing list