[llvm-commits] [lld] optimize WriterELF findOutputSection

Michael Spencer bigcheesegs at gmail.com
Fri Jan 11 01:07:52 PST 2013


On Thu, Jan 10, 2013 at 10:17 PM,  <shankare at codeaurora.org> wrote:
> Hi,
>
> This is to optimize findOutputSection to use the MergedSectionMap.
>
> Diff below :-
>
> Index: WriterELF.cpp
> ===================================================================
> --- WriterELF.cpp       (revision 172176)
> +++ WriterELF.cpp       (working copy)
> @@ -1716,23 +1716,13 @@
>      return error_code::success();
>    }
>
> -  /// \biref Find an output Section given a section name.
> -  ///
> -  /// \todo Make this not O(n). We can't use _mergedSectionMap because it
> -  /// doesn't get virtual addresses set :(
> -  Chunk<target_endianness, max_align, is64Bits> *
> +  /// \brief Find an output Section given a section name.
> +  MergedSections<target_endianness, max_align, is64Bits> *
>    findOutputSection(StringRef name) {
> -    for (auto seg : _segments) {
> -      for (auto sliceI = seg->slices_begin(),
> -                sliceE = seg->slices_end(); sliceI != sliceE; ++sliceI) {
> -        for (auto secI = (*sliceI)->sections_begin(),
> -                  secE = (*sliceI)->sections_end(); secI != secE; ++secI) {
> -          if ((*secI)->name() == name)
> -            return *secI;
> -        }
> -      }
> -    }
> -    return nullptr;
> +    auto iter = _mergedSectionMap.find(name);
> +    if (iter == _mergedSectionMap.end())
> +      return nullptr;
> +    return iter->second;
>    }
>
>    /// \brief find a absolute atom given a name
>
> Thanks
>
> Shankar Easwaran
>

As per the previous comment, this doesn't work. The virtual address of
the MergedSections is never set.

- Michael Spencer



More information about the llvm-commits mailing list