This reuses the approach (and some code) from LLD-ELF.
It's a decent win when linking chromium_framework on a Mac Pro (3.2 GHz 16-Core Intel Xeon W):
N Min Max Median Avg Stddev
x 20 4.58 4.83 4.66 4.6685 0.066591844
+ 20 4.42 4.61 4.5 4.505 0.04751731
Difference at 95.0% confidence
-0.1635 +/- 0.0370242
-3.5022% +/- 0.793064%
(Student's t, pooled s = 0.0578462)
The output binary is 381MB.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D99279
33 lines
942 B
C++
33 lines
942 B
C++
//===- Arrays.h ------------------------------------------------*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLD_ARRAYS_H
|
|
#define LLD_ARRAYS_H
|
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
#include <vector>
|
|
|
|
namespace lld {
|
|
// Split one uint8 array into small pieces of uint8 arrays.
|
|
inline std::vector<llvm::ArrayRef<uint8_t>> split(llvm::ArrayRef<uint8_t> arr,
|
|
size_t chunkSize) {
|
|
std::vector<llvm::ArrayRef<uint8_t>> ret;
|
|
while (arr.size() > chunkSize) {
|
|
ret.push_back(arr.take_front(chunkSize));
|
|
arr = arr.drop_front(chunkSize);
|
|
}
|
|
if (!arr.empty())
|
|
ret.push_back(arr);
|
|
return ret;
|
|
}
|
|
|
|
} // namespace lld
|
|
|
|
#endif
|