[PATCH] D26199: [ELF] - Implemented threaded --build-id computation

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 11:48:44 PDT 2016


ruiu added inline comments.


================
Comment at: ELF/SyntheticSections.cpp:74-82
+  while (!Arr.empty()) {
+    if (Arr.size() <= ChunkSize) {
+      Ret.push_back(Arr);
+      break;
+    }
+    Ret.push_back(Arr.take_front(ChunkSize));
+    Arr = Arr.drop_front(ChunkSize);
----------------
This can be simplified.

  while (Arr.size() > ChunkSize) {
    Ret.push_back(...);
    Arr = Arr.drop_front...;
  }
  if (!Arr.empty())
    Ret.push_back(Arr);
  return Ret;


================
Comment at: ELF/SyntheticSections.cpp:88
+    llvm::ArrayRef<uint8_t> Data,
+    std::function<void(ArrayRef<uint8_t> Arr, uint8_t *Hash)> Cb) {
+  std::vector<ArrayRef<uint8_t>> Chunks = split(Data, 1024 * 1024);
----------------
Cb is not a good name. Let's name Hash.


================
Comment at: ELF/SyntheticSections.cpp:93
+  if (Config->Threads)
+    parallel_for_each(Chunks.begin(), Chunks.end(),
+                      [&](ArrayRef<uint8_t> &Chunk) {
----------------
You can always call parallel_for_each. If multi-threads are not available, it will fall back to std::for_each.


================
Comment at: ELF/SyntheticSections.cpp:109
+void BuildIdFastHash<ELFT>::writeBuildId(MutableArrayRef<uint8_t> Buf) {
+  computeHash(Buf, [&](ArrayRef<uint8_t> Arr, uint8_t *Dest) {
+    uint64_t Hash = xxHash64(toStringRef(Arr));
----------------
Replace [&] with [] because I think it doesn't capture anything. (And ditto for other functions.)


https://reviews.llvm.org/D26199





More information about the llvm-commits mailing list