[PATCH] D104919: [lld-macho] Preserve alignment for non-deduplicated cstrings

Leonard Grey via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 25 10:58:38 PDT 2021


lgrey marked an inline comment as done.
lgrey added inline comments.


================
Comment at: lld/MachO/SyntheticSections.cpp:1191
+      // TODO: Is it worth introducing another code path to not bother with the
+      // hash?
+      CachedHashStringRef string = isec->getCachedHashStringRef(i);
----------------
thakis wrote:
> thakis wrote:
> > I think that'd be nice. You just need
> > 
> > ```
> > % git diff
> > diff --git a/lld/MachO/InputSection.h b/lld/MachO/InputSection.h
> > index 3dd31d27be91..413b7aed70e7 100644
> > --- a/lld/MachO/InputSection.h
> > +++ b/lld/MachO/InputSection.h
> > @@ -183,11 +183,15 @@ public:
> >    // Returns i'th piece as a CachedHashStringRef. This function is very hot when
> >    // string merging is enabled, so we want to inline.
> >    LLVM_ATTRIBUTE_ALWAYS_INLINE
> > -  llvm::CachedHashStringRef getCachedHashStringRef(size_t i) const {
> > +  StringRef getStringRef(size_t i) const {
> >      size_t begin = pieces[i].inSecOff;
> >      size_t end =
> >          (pieces.size() - 1 == i) ? data.size() : pieces[i + 1].inSecOff;
> > -    return {toStringRef(data.slice(begin, end - begin)), pieces[i].hash};
> > +    return toStringRef(data.slice(begin, end - begin));
> > +  }
> > +  LLVM_ATTRIBUTE_ALWAYS_INLINE
> > +  llvm::CachedHashStringRef getCachedHashStringRef(size_t i) const {
> > +    return {getStringRef(i), pieces[i].hash};
> >    }
> > 
> >    static bool classof(const InputSection *isec) {
> > ```
> > 
> > and then you could call `getStringRef()` here, right?
> (and give `splitIntoPieces()` a toggle to control if it computes a hash or not.)
Baked it into the implementation


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

https://reviews.llvm.org/D104919



More information about the llvm-commits mailing list