1 //===-- llvm/CodeGen/AddressPool.cpp - Dwarf Debug Framework ---*- C++ -*--===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "AddressPool.h"
11 #include "llvm/CodeGen/AsmPrinter.h"
12 #include "llvm/MC/MCStreamer.h"
13 #include "llvm/Target/TargetLoweringObjectFile.h"
19 unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
22 Pool.insert(std::make_pair(Sym, AddressPoolEntry(Pool.size(), TLS)));
23 return IterBool.first->second.Number;
26 // Emit addresses into the section given.
27 void AddressPool::emit(AsmPrinter &Asm, const MCSection *AddrSection) {
31 // Start the dwarf addr section.
32 Asm.OutStreamer.SwitchSection(AddrSection);
34 // Order the address pool entries by ID
35 SmallVector<const MCExpr *, 64> Entries(Pool.size());
37 for (const auto &I : Pool)
38 Entries[I.second.Number] =
40 ? Asm.getObjFileLowering().getDebugThreadLocalSymbol(I.first)
41 : MCSymbolRefExpr::Create(I.first, Asm.OutContext);
43 for (const MCExpr *Entry : Entries)
44 Asm.OutStreamer.EmitValue(Entry, Asm.getDataLayout().getPointerSize());