DwarfDebug: Reduce duplication in addAccel*** methods
authorPavel Labath <labath@google.com>
Fri, 20 Jul 2018 15:24:13 +0000 (15:24 +0000)
committerPavel Labath <labath@google.com>
Fri, 20 Jul 2018 15:24:13 +0000 (15:24 +0000)
commit7f7e60694e37cef81423bf626950c59081c96b42
tree5024dc2f082562c2d67a7069f108e411c023f5d5
parent7c56bce996ff74a57e6536f2bb3c23612fd606fb
DwarfDebug: Reduce duplication in addAccel*** methods

Summary:
Each of the four methods had a dozen lines and was doing almost exactly
the same thing: get the appropriate accelerator table kind and insert an
entry into it. I move this common logic to a helper function and make
these methods delegate to it.

This came up in the context of D49493, where I've needed to make adding
a string to a string pool slightly more complicated, and it seemed to
make sense to do it in one place instead of five.

To make this work I've needed to unify the interface of the AccelTable
data types, as some used to store DIE& and others DIE*. I chose to unify
to a reference as that's what the caller uses.

This technically isn't NFC, because it changes the StringPool used for
apple tables in the DWO case (now it uses the main file like DWARF v5
instead of the DWO file). However, that shouldn't matter, as DWO is not
a thing on apple targets (clang frontend simply ignores -gsplit-dwarf).

Reviewers: JDevlieghere, aprantl, probinson

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D49542

llvm-svn: 337562
llvm/include/llvm/CodeGen/AccelTable.h
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h