[PATCH] D62381: Use SymbolTable::insert() to implement --trace.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 27 18:34:13 PDT 2019

MaskRay added inline comments.

Comment at: lld/ELF/SymbolTable.h:38
-  ArrayRef<Symbol *> getSymbols() const { return SymVector; }
+  void forEachSymbol(std::function<void(Symbol *)> Fn) {
+    for (Symbol *Sym : SymVector)
grimar wrote:
> ruiu wrote:
> > grimar wrote:
> > > `llvm::function_ref` should probably be a bit better, btw.
> > I didn't take a look at the assembly, but isn't this something that a compiler can optimize and erases std::function? Since this is an inline function, a compiler knows exactly how a given lambda is used.
> I do not know the answer.
`function_ref` should be better, but I don't know if compilers can optimize out the heap allocation used for the lambda.

I still want to understand how complicated the signature of `llvm::make_filter_range` is. Let me check

  rG LLVM Github Monorepo



More information about the llvm-commits mailing list