[all-commits] [llvm/llvm-project] 494884: [MC] MCDwarfLineAddr::Encode: use SmallVectorImpl ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Sun May 7 16:27:05 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 49488490d195591bfc90daef111cd7293f8c80aa
      https://github.com/llvm/llvm-project/commit/49488490d195591bfc90daef111cd7293f8c80aa
  Author: Fangrui Song <i at maskray.me>
  Date:   2023-05-07 (Sun, 07 May 2023)

  Changed paths:
    M llvm/include/llvm/MC/MCDwarf.h
    M llvm/lib/DWARFLinker/DWARFStreamer.cpp
    M llvm/lib/MC/MCAssembler.cpp
    M llvm/lib/MC/MCDwarf.cpp
    M llvm/unittests/MC/DwarfLineTables.cpp

  Log Message:
  -----------
  [MC] MCDwarfLineAddr::Encode: use SmallVectorImpl instead of raw_ostream. NFC

Similar to D145791: most call sites need a SmallString, but have to provide a
raw_svector_ostream wrapper with unneeded abstraction and overhead:

raw_ostream::write =(inlinable)=> flush_tied_then_write (unneeded TiedStream check) =(virtual function call)=> raw_svector_ostream::write_impl ==> SmallVector append(ItTy in_start, ItTy in_end) (range; less efficient then push_back).

Just use SmallVectorImpl to simplify and optimize code. Unfortunately most call
sites use SmallString, so we have to use SmallVectorImpl<char> instead of
<uint8_t> to avoid large refactoring.




More information about the All-commits mailing list