2 #include "AddressPool.h"
3 #include "llvm/CodeGen/AsmPrinter.h"
4 #include "llvm/MC/MCStreamer.h"
5 #include "llvm/Target/TargetLoweringObjectFile.h"
11 unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
13 Pool.insert(std::make_pair(Sym, AddressPoolEntry(Pool.size(), TLS)));
14 return IterBool.first->second.Number;
17 // Emit addresses into the section given.
18 void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) {
22 // Start the dwarf addr section.
23 Asm.OutStreamer.SwitchSection(AddrSection);
25 // Order the address pool entries by ID
26 SmallVector<const MCExpr *, 64> Entries(Pool.size());
28 for (const auto &I : Pool)
29 Entries[I.second.Number] =
31 ? Asm.getObjFileLowering().getDebugThreadLocalSymbol(I.first)
32 : MCSymbolRefExpr::Create(I.first, Asm.OutContext);
34 for (const MCExpr *Entry : Entries)
35 Asm.OutStreamer.EmitValue(Entry, Asm.getDataLayout().getPointerSize());