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"
17 unsigned AddressPool::getIndex(const MCSymbol *Sym, bool TLS) {
20 Pool.insert(std::make_pair(Sym, AddressPoolEntry(Pool.size(), TLS)));
21 return IterBool.first->second.Number;
24 // Emit addresses into the section given.
25 void AddressPool::emit(AsmPrinter &Asm, MCSection *AddrSection) {
29 // Start the dwarf addr section.
30 Asm.OutStreamer->SwitchSection(AddrSection);
32 // Order the address pool entries by ID
33 SmallVector<const MCExpr *, 64> Entries(Pool.size());
35 for (const auto &I : Pool)
36 Entries[I.second.Number] =
38 ? Asm.getObjFileLowering().getDebugThreadLocalSymbol(I.first)
39 : MCSymbolRefExpr::create(I.first, Asm.OutContext);
41 for (const MCExpr *Entry : Entries)
42 Asm.OutStreamer->EmitValue(Entry, Asm.getDataLayout().getPointerSize());