[lld] Update uses of DEBUG macro to LLVM_DEBUG.

The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM

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

llvm-svn: 332351
This commit is contained in:
Nicola Zaghen 2018-05-15 13:36:20 +00:00
parent 3538b39ed5
commit e7245b429b
11 changed files with 102 additions and 94 deletions

View File

@ -1068,7 +1068,7 @@ bool parse(llvm::ArrayRef<const char *> args, MachOLinkingContext &ctx,
} }
// Parse the LLVM options before we process files in case the file handling // Parse the LLVM options before we process files in case the file handling
// makes use of things like DEBUG(). // makes use of things like LLVM_DEBUG().
parseLLVMOptions(ctx); parseLLVMOptions(ctx);
// Handle input files and sectcreate. // Handle input files and sectcreate.

View File

@ -282,7 +282,7 @@ public:
private: private:
llvm::Error perform(SimpleFile &mergedFile) override { llvm::Error perform(SimpleFile &mergedFile) override {
DEBUG(llvm::dbgs() << "MachO Compact Unwind pass\n"); LLVM_DEBUG(llvm::dbgs() << "MachO Compact Unwind pass\n");
std::map<const Atom *, CompactUnwindEntry> unwindLocs; std::map<const Atom *, CompactUnwindEntry> unwindLocs;
std::map<const Atom *, const Atom *> dwarfFrames; std::map<const Atom *, const Atom *> dwarfFrames;
@ -319,7 +319,7 @@ private:
// Finally, we can start creating pages based on these entries. // Finally, we can start creating pages based on these entries.
DEBUG(llvm::dbgs() << " Splitting entries into pages\n"); LLVM_DEBUG(llvm::dbgs() << " Splitting entries into pages\n");
// FIXME: we split the entries into pages naively: lots of 4k pages followed // FIXME: we split the entries into pages naively: lots of 4k pages followed
// by a small one. ld64 tried to minimize space and align them to real 4k // by a small one. ld64 tried to minimize space and align them to real 4k
// boundaries. That might be worth doing, or perhaps we could perform some // boundaries. That might be worth doing, or perhaps we could perform some
@ -336,11 +336,13 @@ private:
pages.back().entries = remainingInfos.slice(0, entriesInPage); pages.back().entries = remainingInfos.slice(0, entriesInPage);
remainingInfos = remainingInfos.slice(entriesInPage); remainingInfos = remainingInfos.slice(entriesInPage);
DEBUG(llvm::dbgs() LLVM_DEBUG(llvm::dbgs()
<< " Page from " << pages.back().entries[0].rangeStart->name() << " Page from "
<< " to " << pages.back().entries.back().rangeStart->name() << " + " << pages.back().entries[0].rangeStart->name() << " to "
<< llvm::format("0x%x", pages.back().entries.back().rangeLength) << pages.back().entries.back().rangeStart->name() << " + "
<< " has " << entriesInPage << " entries\n"); << llvm::format("0x%x",
pages.back().entries.back().rangeLength)
<< " has " << entriesInPage << " entries\n");
} while (!remainingInfos.empty()); } while (!remainingInfos.empty());
auto *unwind = new (_file.allocator()) auto *unwind = new (_file.allocator())
@ -360,7 +362,7 @@ private:
const SimpleFile &mergedFile, const SimpleFile &mergedFile,
std::map<const Atom *, CompactUnwindEntry> &unwindLocs, std::map<const Atom *, CompactUnwindEntry> &unwindLocs,
std::vector<const Atom *> &personalities, uint32_t &numLSDAs) { std::vector<const Atom *> &personalities, uint32_t &numLSDAs) {
DEBUG(llvm::dbgs() << " Collecting __compact_unwind entries\n"); LLVM_DEBUG(llvm::dbgs() << " Collecting __compact_unwind entries\n");
for (const DefinedAtom *atom : mergedFile.defined()) { for (const DefinedAtom *atom : mergedFile.defined()) {
if (atom->contentType() != DefinedAtom::typeCompactUnwindInfo) if (atom->contentType() != DefinedAtom::typeCompactUnwindInfo)
@ -369,14 +371,15 @@ private:
auto unwindEntry = extractCompactUnwindEntry(atom); auto unwindEntry = extractCompactUnwindEntry(atom);
unwindLocs.insert(std::make_pair(unwindEntry.rangeStart, unwindEntry)); unwindLocs.insert(std::make_pair(unwindEntry.rangeStart, unwindEntry));
DEBUG(llvm::dbgs() << " Entry for " << unwindEntry.rangeStart->name() LLVM_DEBUG(llvm::dbgs() << " Entry for "
<< ", encoding=" << unwindEntry.rangeStart->name() << ", encoding="
<< llvm::format("0x%08x", unwindEntry.encoding)); << llvm::format("0x%08x", unwindEntry.encoding));
if (unwindEntry.personalityFunction) if (unwindEntry.personalityFunction)
DEBUG(llvm::dbgs() << ", personality=" LLVM_DEBUG(llvm::dbgs()
<< unwindEntry.personalityFunction->name() << ", personality="
<< ", lsdaLoc=" << unwindEntry.lsdaLocation->name()); << unwindEntry.personalityFunction->name()
DEBUG(llvm::dbgs() << '\n'); << ", lsdaLoc=" << unwindEntry.lsdaLocation->name());
LLVM_DEBUG(llvm::dbgs() << '\n');
// Count number of LSDAs we see, since we need to know how big the index // Count number of LSDAs we see, since we need to know how big the index
// will be while laying out the section. // will be while laying out the section.
@ -454,7 +457,7 @@ private:
const std::map<const Atom *, const Atom *> &dwarfFrames) { const std::map<const Atom *, const Atom *> &dwarfFrames) {
std::vector<CompactUnwindEntry> unwindInfos; std::vector<CompactUnwindEntry> unwindInfos;
DEBUG(llvm::dbgs() << " Creating __unwind_info entries\n"); LLVM_DEBUG(llvm::dbgs() << " Creating __unwind_info entries\n");
// The final order in the __unwind_info section must be derived from the // The final order in the __unwind_info section must be derived from the
// order of typeCode atoms, since that's how they'll be put into the object // order of typeCode atoms, since that's how they'll be put into the object
// file eventually (yuck!). // file eventually (yuck!).
@ -465,10 +468,10 @@ private:
unwindInfos.push_back(finalizeUnwindInfoEntryForAtom( unwindInfos.push_back(finalizeUnwindInfoEntryForAtom(
atom, unwindLocs, personalities, dwarfFrames)); atom, unwindLocs, personalities, dwarfFrames));
DEBUG(llvm::dbgs() << " Entry for " << atom->name() LLVM_DEBUG(llvm::dbgs()
<< ", final encoding=" << " Entry for " << atom->name() << ", final encoding="
<< llvm::format("0x%08x", unwindInfos.back().encoding) << llvm::format("0x%08x", unwindInfos.back().encoding)
<< '\n'); << '\n');
} }
return unwindInfos; return unwindInfos;

View File

@ -191,7 +191,7 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc,
// Sort atoms by their ordinal overrides only if they fall in the same // Sort atoms by their ordinal overrides only if they fall in the same
// chain. // chain.
if (leftRoot == rightRoot) { if (leftRoot == rightRoot) {
DEBUG(reason = formatReason("override", lc._override, rc._override)); LLVM_DEBUG(reason = formatReason("override", lc._override, rc._override));
return lc._override < rc._override; return lc._override < rc._override;
} }
@ -200,8 +200,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc,
DefinedAtom::ContentPermissions rightPerms = rightRoot->permissions(); DefinedAtom::ContentPermissions rightPerms = rightRoot->permissions();
if (leftPerms != rightPerms) { if (leftPerms != rightPerms) {
DEBUG(reason = LLVM_DEBUG(
formatReason("contentPerms", (int)leftPerms, (int)rightPerms)); reason = formatReason("contentPerms", (int)leftPerms, (int)rightPerms));
return leftPerms < rightPerms; return leftPerms < rightPerms;
} }
@ -210,7 +210,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc,
DefinedAtom::ContentType rightType = rightRoot->contentType(); DefinedAtom::ContentType rightType = rightRoot->contentType();
if (leftType != rightType) { if (leftType != rightType) {
DEBUG(reason = formatReason("contentType", (int)leftType, (int)rightType)); LLVM_DEBUG(reason =
formatReason("contentType", (int)leftType, (int)rightType));
return leftType < rightType; return leftType < rightType;
} }
@ -226,8 +227,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc,
const File *rightFile = &rightRoot->file(); const File *rightFile = &rightRoot->file();
if (leftFile != rightFile) { if (leftFile != rightFile) {
DEBUG(reason = formatReason(".o order", (int)leftFile->ordinal(), LLVM_DEBUG(reason = formatReason(".o order", (int)leftFile->ordinal(),
(int)rightFile->ordinal())); (int)rightFile->ordinal()));
return leftFile->ordinal() < rightFile->ordinal(); return leftFile->ordinal() < rightFile->ordinal();
} }
@ -236,8 +237,8 @@ static bool compareAtomsSub(const LayoutPass::SortKey &lc,
uint64_t rightOrdinal = rightRoot->ordinal(); uint64_t rightOrdinal = rightRoot->ordinal();
if (leftOrdinal != rightOrdinal) { if (leftOrdinal != rightOrdinal) {
DEBUG(reason = formatReason("ordinal", (int)leftRoot->ordinal(), LLVM_DEBUG(reason = formatReason("ordinal", (int)leftRoot->ordinal(),
(int)rightRoot->ordinal())); (int)rightRoot->ordinal()));
return leftOrdinal < rightOrdinal; return leftOrdinal < rightOrdinal;
} }
@ -251,7 +252,7 @@ static bool compareAtoms(const LayoutPass::SortKey &lc,
LayoutPass::SortOverride customSorter) { LayoutPass::SortOverride customSorter) {
std::string reason; std::string reason;
bool result = compareAtomsSub(lc, rc, customSorter, reason); bool result = compareAtomsSub(lc, rc, customSorter, reason);
DEBUG({ LLVM_DEBUG({
StringRef comp = result ? "<" : ">="; StringRef comp = result ? "<" : ">=";
llvm::dbgs() << "Layout: '" << lc._atom.get()->name() llvm::dbgs() << "Layout: '" << lc._atom.get()->name()
<< "' " << comp << " '" << "' " << comp << " '"
@ -441,7 +442,7 @@ void LayoutPass::undecorate(File::AtomRange<DefinedAtom> &atomRange,
/// Perform the actual pass /// Perform the actual pass
llvm::Error LayoutPass::perform(SimpleFile &mergedFile) { llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
DEBUG(llvm::dbgs() << "******** Laying out atoms:\n"); LLVM_DEBUG(llvm::dbgs() << "******** Laying out atoms:\n");
// sort the atoms // sort the atoms
ScopedTask task(getDefaultDomain(), "LayoutPass"); ScopedTask task(getDefaultDomain(), "LayoutPass");
File::AtomRange<DefinedAtom> atomRange = mergedFile.defined(); File::AtomRange<DefinedAtom> atomRange = mergedFile.defined();
@ -450,12 +451,12 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
buildFollowOnTable(atomRange); buildFollowOnTable(atomRange);
// Check the structure of followon graph if running in debug mode. // Check the structure of followon graph if running in debug mode.
DEBUG(checkFollowonChain(atomRange)); LLVM_DEBUG(checkFollowonChain(atomRange));
// Build override maps // Build override maps
buildOrdinalOverrideMap(atomRange); buildOrdinalOverrideMap(atomRange);
DEBUG({ LLVM_DEBUG({
llvm::dbgs() << "unsorted atoms:\n"; llvm::dbgs() << "unsorted atoms:\n";
printDefinedAtoms(atomRange); printDefinedAtoms(atomRange);
}); });
@ -465,15 +466,15 @@ llvm::Error LayoutPass::perform(SimpleFile &mergedFile) {
[&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool { [&](const LayoutPass::SortKey &l, const LayoutPass::SortKey &r) -> bool {
return compareAtoms(l, r, _customSorter); return compareAtoms(l, r, _customSorter);
}); });
DEBUG(checkTransitivity(vec, _customSorter)); LLVM_DEBUG(checkTransitivity(vec, _customSorter));
undecorate(atomRange, vec); undecorate(atomRange, vec);
DEBUG({ LLVM_DEBUG({
llvm::dbgs() << "sorted atoms:\n"; llvm::dbgs() << "sorted atoms:\n";
printDefinedAtoms(atomRange); printDefinedAtoms(atomRange);
}); });
DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n"); LLVM_DEBUG(llvm::dbgs() << "******** Finished laying out atoms\n");
return llvm::Error::success(); return llvm::Error::success();
} }

View File

@ -1431,8 +1431,8 @@ llvm::Error
normalizedObjectToAtoms(MachOFile *file, normalizedObjectToAtoms(MachOFile *file,
const NormalizedFile &normalizedFile, const NormalizedFile &normalizedFile,
bool copyRefs) { bool copyRefs) {
DEBUG(llvm::dbgs() << "******** Normalizing file to atoms: " LLVM_DEBUG(llvm::dbgs() << "******** Normalizing file to atoms: "
<< file->path() << "\n"); << file->path() << "\n");
bool scatterable = ((normalizedFile.flags & MH_SUBSECTIONS_VIA_SYMBOLS) != 0); bool scatterable = ((normalizedFile.flags & MH_SUBSECTIONS_VIA_SYMBOLS) != 0);
// Create atoms from each section. // Create atoms from each section.

View File

@ -103,16 +103,17 @@ void InputChunk::writeTo(uint8_t *Buf) const {
verifyRelocTargets(); verifyRelocTargets();
#endif #endif
DEBUG(dbgs() << "applying relocations: " << getName() LLVM_DEBUG(dbgs() << "applying relocations: " << getName()
<< " count=" << Relocations.size() << "\n"); << " count=" << Relocations.size() << "\n");
int32_t Off = OutputOffset - getInputSectionOffset(); int32_t Off = OutputOffset - getInputSectionOffset();
for (const WasmRelocation &Rel : Relocations) { for (const WasmRelocation &Rel : Relocations) {
uint8_t *Loc = Buf + Rel.Offset + Off; uint8_t *Loc = Buf + Rel.Offset + Off;
uint32_t Value = File->calcNewValue(Rel); uint32_t Value = File->calcNewValue(Rel);
DEBUG(dbgs() << "apply reloc: type=" << ReloctTypeToString(Rel.Type) LLVM_DEBUG(dbgs() << "apply reloc: type=" << ReloctTypeToString(Rel.Type)
<< " addend=" << Rel.Addend << " index=" << Rel.Index << " addend=" << Rel.Addend << " index=" << Rel.Index
<< " value=" << Value << " offset=" << Rel.Offset << "\n"); << " value=" << Value << " offset=" << Rel.Offset
<< "\n");
switch (Rel.Type) { switch (Rel.Type) {
case R_WEBASSEMBLY_TYPE_INDEX_LEB: case R_WEBASSEMBLY_TYPE_INDEX_LEB:
@ -145,8 +146,8 @@ void InputChunk::writeRelocations(raw_ostream &OS) const {
return; return;
int32_t Off = OutputOffset - getInputSectionOffset(); int32_t Off = OutputOffset - getInputSectionOffset();
DEBUG(dbgs() << "writeRelocations: " << File->getName() LLVM_DEBUG(dbgs() << "writeRelocations: " << File->getName()
<< " offset=" << Twine(Off) << "\n"); << " offset=" << Twine(Off) << "\n");
for (const WasmRelocation &Rel : Relocations) { for (const WasmRelocation &Rel : Relocations) {
writeUleb128(OS, Rel.Type, "reloc type"); writeUleb128(OS, Rel.Type, "reloc type");
@ -166,15 +167,15 @@ void InputChunk::writeRelocations(raw_ostream &OS) const {
} }
void InputFunction::setFunctionIndex(uint32_t Index) { void InputFunction::setFunctionIndex(uint32_t Index) {
DEBUG(dbgs() << "InputFunction::setFunctionIndex: " << getName() << " -> " LLVM_DEBUG(dbgs() << "InputFunction::setFunctionIndex: " << getName()
<< Index << "\n"); << " -> " << Index << "\n");
assert(!hasFunctionIndex()); assert(!hasFunctionIndex());
FunctionIndex = Index; FunctionIndex = Index;
} }
void InputFunction::setTableIndex(uint32_t Index) { void InputFunction::setTableIndex(uint32_t Index) {
DEBUG(dbgs() << "InputFunction::setTableIndex: " << getName() << " -> " LLVM_DEBUG(dbgs() << "InputFunction::setTableIndex: " << getName() << " -> "
<< Index << "\n"); << Index << "\n");
assert(!hasTableIndex()); assert(!hasTableIndex());
TableIndex = Index; TableIndex = Index;
} }

View File

@ -159,7 +159,7 @@ uint32_t ObjFile::calcNewValue(const WasmRelocation &Reloc) const {
void ObjFile::parse() { void ObjFile::parse() {
// Parse a memory buffer as a wasm file. // Parse a memory buffer as a wasm file.
DEBUG(dbgs() << "Parsing object: " << toString(this) << "\n"); LLVM_DEBUG(dbgs() << "Parsing object: " << toString(this) << "\n");
std::unique_ptr<Binary> Bin = CHECK(createBinary(MB), toString(this)); std::unique_ptr<Binary> Bin = CHECK(createBinary(MB), toString(this));
auto *Obj = dyn_cast<WasmObjectFile>(Bin.get()); auto *Obj = dyn_cast<WasmObjectFile>(Bin.get());
@ -339,7 +339,7 @@ Symbol *ObjFile::createUndefined(const WasmSymbol &Sym) {
void ArchiveFile::parse() { void ArchiveFile::parse() {
// Parse a MemoryBufferRef as an archive file. // Parse a MemoryBufferRef as an archive file.
DEBUG(dbgs() << "Parsing library: " << toString(this) << "\n"); LLVM_DEBUG(dbgs() << "Parsing library: " << toString(this) << "\n");
File = CHECK(Archive::create(MB), toString(this)); File = CHECK(Archive::create(MB), toString(this));
// Read the symbol table to construct Lazy symbols. // Read the symbol table to construct Lazy symbols.
@ -348,7 +348,7 @@ void ArchiveFile::parse() {
Symtab->addLazy(this, &Sym); Symtab->addLazy(this, &Sym);
++Count; ++Count;
} }
DEBUG(dbgs() << "Read " << Count << " symbols\n"); LLVM_DEBUG(dbgs() << "Read " << Count << " symbols\n");
} }
void ArchiveFile::addMember(const Archive::Symbol *Sym) { void ArchiveFile::addMember(const Archive::Symbol *Sym) {
@ -361,8 +361,8 @@ void ArchiveFile::addMember(const Archive::Symbol *Sym) {
if (!Seen.insert(C.getChildOffset()).second) if (!Seen.insert(C.getChildOffset()).second)
return; return;
DEBUG(dbgs() << "loading lazy: " << Sym->getName() << "\n"); LLVM_DEBUG(dbgs() << "loading lazy: " << Sym->getName() << "\n");
DEBUG(dbgs() << "from archive: " << toString(this) << "\n"); LLVM_DEBUG(dbgs() << "from archive: " << toString(this) << "\n");
MemoryBufferRef MB = MemoryBufferRef MB =
CHECK(C.getMemoryBufferRef(), CHECK(C.getMemoryBufferRef(),

View File

@ -37,7 +37,7 @@ void lld::wasm::markLive() {
if (!Config->GcSections) if (!Config->GcSections)
return; return;
DEBUG(dbgs() << "markLive\n"); LLVM_DEBUG(dbgs() << "markLive\n");
SmallVector<InputChunk *, 256> Q; SmallVector<InputChunk *, 256> Q;
auto Enqueue = [&](Symbol *Sym) { auto Enqueue = [&](Symbol *Sym) {

View File

@ -118,7 +118,7 @@ static void checkDataType(const Symbol *Existing, const InputFile *File) {
DefinedFunction *SymbolTable::addSyntheticFunction(StringRef Name, DefinedFunction *SymbolTable::addSyntheticFunction(StringRef Name,
uint32_t Flags, uint32_t Flags,
InputFunction *Function) { InputFunction *Function) {
DEBUG(dbgs() << "addSyntheticFunction: " << Name << "\n"); LLVM_DEBUG(dbgs() << "addSyntheticFunction: " << Name << "\n");
assert(!find(Name)); assert(!find(Name));
SyntheticFunctions.emplace_back(Function); SyntheticFunctions.emplace_back(Function);
return replaceSymbol<DefinedFunction>(insert(Name).first, Name, Flags, return replaceSymbol<DefinedFunction>(insert(Name).first, Name, Flags,
@ -127,14 +127,15 @@ DefinedFunction *SymbolTable::addSyntheticFunction(StringRef Name,
DefinedData *SymbolTable::addSyntheticDataSymbol(StringRef Name, DefinedData *SymbolTable::addSyntheticDataSymbol(StringRef Name,
uint32_t Flags) { uint32_t Flags) {
DEBUG(dbgs() << "addSyntheticDataSymbol: " << Name << "\n"); LLVM_DEBUG(dbgs() << "addSyntheticDataSymbol: " << Name << "\n");
assert(!find(Name)); assert(!find(Name));
return replaceSymbol<DefinedData>(insert(Name).first, Name, Flags); return replaceSymbol<DefinedData>(insert(Name).first, Name, Flags);
} }
DefinedGlobal *SymbolTable::addSyntheticGlobal(StringRef Name, uint32_t Flags, DefinedGlobal *SymbolTable::addSyntheticGlobal(StringRef Name, uint32_t Flags,
InputGlobal *Global) { InputGlobal *Global) {
DEBUG(dbgs() << "addSyntheticGlobal: " << Name << " -> " << Global << "\n"); LLVM_DEBUG(dbgs() << "addSyntheticGlobal: " << Name << " -> " << Global
<< "\n");
assert(!find(Name)); assert(!find(Name));
SyntheticGlobals.emplace_back(Global); SyntheticGlobals.emplace_back(Global);
return replaceSymbol<DefinedGlobal>(insert(Name).first, Name, Flags, nullptr, return replaceSymbol<DefinedGlobal>(insert(Name).first, Name, Flags, nullptr,
@ -145,20 +146,20 @@ static bool shouldReplace(const Symbol *Existing, InputFile *NewFile,
uint32_t NewFlags) { uint32_t NewFlags) {
// If existing symbol is undefined, replace it. // If existing symbol is undefined, replace it.
if (!Existing->isDefined()) { if (!Existing->isDefined()) {
DEBUG(dbgs() << "resolving existing undefined symbol: " LLVM_DEBUG(dbgs() << "resolving existing undefined symbol: "
<< Existing->getName() << "\n"); << Existing->getName() << "\n");
return true; return true;
} }
// Now we have two defined symbols. If the new one is weak, we can ignore it. // Now we have two defined symbols. If the new one is weak, we can ignore it.
if ((NewFlags & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) { if ((NewFlags & WASM_SYMBOL_BINDING_MASK) == WASM_SYMBOL_BINDING_WEAK) {
DEBUG(dbgs() << "existing symbol takes precedence\n"); LLVM_DEBUG(dbgs() << "existing symbol takes precedence\n");
return false; return false;
} }
// If the existing symbol is weak, we should replace it. // If the existing symbol is weak, we should replace it.
if (Existing->isWeak()) { if (Existing->isWeak()) {
DEBUG(dbgs() << "replacing existing weak symbol\n"); LLVM_DEBUG(dbgs() << "replacing existing weak symbol\n");
return true; return true;
} }
@ -172,7 +173,7 @@ static bool shouldReplace(const Symbol *Existing, InputFile *NewFile,
Symbol *SymbolTable::addDefinedFunction(StringRef Name, uint32_t Flags, Symbol *SymbolTable::addDefinedFunction(StringRef Name, uint32_t Flags,
InputFile *File, InputFile *File,
InputFunction *Function) { InputFunction *Function) {
DEBUG(dbgs() << "addDefinedFunction: " << Name << "\n"); LLVM_DEBUG(dbgs() << "addDefinedFunction: " << Name << "\n");
Symbol *S; Symbol *S;
bool WasInserted; bool WasInserted;
std::tie(S, WasInserted) = insert(Name); std::tie(S, WasInserted) = insert(Name);
@ -192,7 +193,8 @@ Symbol *SymbolTable::addDefinedFunction(StringRef Name, uint32_t Flags,
Symbol *SymbolTable::addDefinedData(StringRef Name, uint32_t Flags, Symbol *SymbolTable::addDefinedData(StringRef Name, uint32_t Flags,
InputFile *File, InputSegment *Segment, InputFile *File, InputSegment *Segment,
uint32_t Address, uint32_t Size) { uint32_t Address, uint32_t Size) {
DEBUG(dbgs() << "addDefinedData:" << Name << " addr:" << Address << "\n"); LLVM_DEBUG(dbgs() << "addDefinedData:" << Name << " addr:" << Address
<< "\n");
Symbol *S; Symbol *S;
bool WasInserted; bool WasInserted;
std::tie(S, WasInserted) = insert(Name); std::tie(S, WasInserted) = insert(Name);
@ -211,7 +213,7 @@ Symbol *SymbolTable::addDefinedData(StringRef Name, uint32_t Flags,
Symbol *SymbolTable::addDefinedGlobal(StringRef Name, uint32_t Flags, Symbol *SymbolTable::addDefinedGlobal(StringRef Name, uint32_t Flags,
InputFile *File, InputGlobal *Global) { InputFile *File, InputGlobal *Global) {
DEBUG(dbgs() << "addDefinedGlobal:" << Name << "\n"); LLVM_DEBUG(dbgs() << "addDefinedGlobal:" << Name << "\n");
Symbol *S; Symbol *S;
bool WasInserted; bool WasInserted;
std::tie(S, WasInserted) = insert(Name); std::tie(S, WasInserted) = insert(Name);
@ -231,7 +233,7 @@ Symbol *SymbolTable::addDefinedGlobal(StringRef Name, uint32_t Flags,
Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags, Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,
InputFile *File, InputFile *File,
const WasmSignature *Sig) { const WasmSignature *Sig) {
DEBUG(dbgs() << "addUndefinedFunction: " << Name << "\n"); LLVM_DEBUG(dbgs() << "addUndefinedFunction: " << Name << "\n");
Symbol *S; Symbol *S;
bool WasInserted; bool WasInserted;
@ -248,7 +250,7 @@ Symbol *SymbolTable::addUndefinedFunction(StringRef Name, uint32_t Flags,
Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags, Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags,
InputFile *File) { InputFile *File) {
DEBUG(dbgs() << "addUndefinedData: " << Name << "\n"); LLVM_DEBUG(dbgs() << "addUndefinedData: " << Name << "\n");
Symbol *S; Symbol *S;
bool WasInserted; bool WasInserted;
@ -266,7 +268,7 @@ Symbol *SymbolTable::addUndefinedData(StringRef Name, uint32_t Flags,
Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags, Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags,
InputFile *File, InputFile *File,
const WasmGlobalType *Type) { const WasmGlobalType *Type) {
DEBUG(dbgs() << "addUndefinedGlobal: " << Name << "\n"); LLVM_DEBUG(dbgs() << "addUndefinedGlobal: " << Name << "\n");
Symbol *S; Symbol *S;
bool WasInserted; bool WasInserted;
@ -282,7 +284,7 @@ Symbol *SymbolTable::addUndefinedGlobal(StringRef Name, uint32_t Flags,
} }
void SymbolTable::addLazy(ArchiveFile *File, const Archive::Symbol *Sym) { void SymbolTable::addLazy(ArchiveFile *File, const Archive::Symbol *Sym) {
DEBUG(dbgs() << "addLazy: " << Sym->getName() << "\n"); LLVM_DEBUG(dbgs() << "addLazy: " << Sym->getName() << "\n");
StringRef Name = Sym->getName(); StringRef Name = Sym->getName();
Symbol *S; Symbol *S;
@ -296,7 +298,7 @@ void SymbolTable::addLazy(ArchiveFile *File, const Archive::Symbol *Sym) {
// If there is an existing undefined symbol, load a new one from the archive. // If there is an existing undefined symbol, load a new one from the archive.
if (S->isUndefined()) { if (S->isUndefined()) {
DEBUG(dbgs() << "replacing existing undefined\n"); LLVM_DEBUG(dbgs() << "replacing existing undefined\n");
File->addMember(Sym); File->addMember(Sym);
} }
} }

View File

@ -71,7 +71,8 @@ uint32_t Symbol::getOutputSymbolIndex() const {
} }
void Symbol::setOutputSymbolIndex(uint32_t Index) { void Symbol::setOutputSymbolIndex(uint32_t Index) {
DEBUG(dbgs() << "setOutputSymbolIndex " << Name << " -> " << Index << "\n"); LLVM_DEBUG(dbgs() << "setOutputSymbolIndex " << Name << " -> " << Index
<< "\n");
assert(OutputSymbolIndex == INVALID_INDEX); assert(OutputSymbolIndex == INVALID_INDEX);
OutputSymbolIndex = Index; OutputSymbolIndex = Index;
} }
@ -89,7 +90,7 @@ bool Symbol::isHidden() const {
} }
void Symbol::setHidden(bool IsHidden) { void Symbol::setHidden(bool IsHidden) {
DEBUG(dbgs() << "setHidden: " << Name << " -> " << IsHidden << "\n"); LLVM_DEBUG(dbgs() << "setHidden: " << Name << " -> " << IsHidden << "\n");
Flags &= ~WASM_SYMBOL_VISIBILITY_MASK; Flags &= ~WASM_SYMBOL_VISIBILITY_MASK;
if (IsHidden) if (IsHidden)
Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN; Flags |= WASM_SYMBOL_VISIBILITY_HIDDEN;
@ -105,7 +106,7 @@ uint32_t FunctionSymbol::getFunctionIndex() const {
} }
void FunctionSymbol::setFunctionIndex(uint32_t Index) { void FunctionSymbol::setFunctionIndex(uint32_t Index) {
DEBUG(dbgs() << "setFunctionIndex " << Name << " -> " << Index << "\n"); LLVM_DEBUG(dbgs() << "setFunctionIndex " << Name << " -> " << Index << "\n");
assert(FunctionIndex == INVALID_INDEX); assert(FunctionIndex == INVALID_INDEX);
FunctionIndex = Index; FunctionIndex = Index;
} }
@ -137,7 +138,7 @@ void FunctionSymbol::setTableIndex(uint32_t Index) {
F->Function->setTableIndex(Index); F->Function->setTableIndex(Index);
return; return;
} }
DEBUG(dbgs() << "setTableIndex " << Name << " -> " << Index << "\n"); LLVM_DEBUG(dbgs() << "setTableIndex " << Name << " -> " << Index << "\n");
assert(TableIndex == INVALID_INDEX); assert(TableIndex == INVALID_INDEX);
TableIndex = Index; TableIndex = Index;
} }
@ -149,25 +150,25 @@ DefinedFunction::DefinedFunction(StringRef Name, uint32_t Flags, InputFile *F,
Function(Function) {} Function(Function) {}
uint32_t DefinedData::getVirtualAddress() const { uint32_t DefinedData::getVirtualAddress() const {
DEBUG(dbgs() << "getVirtualAddress: " << getName() << "\n"); LLVM_DEBUG(dbgs() << "getVirtualAddress: " << getName() << "\n");
if (Segment) if (Segment)
return Segment->OutputSeg->StartVA + Segment->OutputSegmentOffset + Offset; return Segment->OutputSeg->StartVA + Segment->OutputSegmentOffset + Offset;
return Offset; return Offset;
} }
void DefinedData::setVirtualAddress(uint32_t Value) { void DefinedData::setVirtualAddress(uint32_t Value) {
DEBUG(dbgs() << "setVirtualAddress " << Name << " -> " << Value << "\n"); LLVM_DEBUG(dbgs() << "setVirtualAddress " << Name << " -> " << Value << "\n");
assert(!Segment); assert(!Segment);
Offset = Value; Offset = Value;
} }
uint32_t DefinedData::getOutputSegmentOffset() const { uint32_t DefinedData::getOutputSegmentOffset() const {
DEBUG(dbgs() << "getOutputSegmentOffset: " << getName() << "\n"); LLVM_DEBUG(dbgs() << "getOutputSegmentOffset: " << getName() << "\n");
return Segment->OutputSegmentOffset + Offset; return Segment->OutputSegmentOffset + Offset;
} }
uint32_t DefinedData::getOutputSegmentIndex() const { uint32_t DefinedData::getOutputSegmentIndex() const {
DEBUG(dbgs() << "getOutputSegmentIndex: " << getName() << "\n"); LLVM_DEBUG(dbgs() << "getOutputSegmentIndex: " << getName() << "\n");
return Segment->OutputSeg->Index; return Segment->OutputSeg->Index;
} }
@ -179,7 +180,7 @@ uint32_t GlobalSymbol::getGlobalIndex() const {
} }
void GlobalSymbol::setGlobalIndex(uint32_t Index) { void GlobalSymbol::setGlobalIndex(uint32_t Index) {
DEBUG(dbgs() << "setGlobalIndex " << Name << " -> " << Index << "\n"); LLVM_DEBUG(dbgs() << "setGlobalIndex " << Name << " -> " << Index << "\n");
assert(GlobalIndex == INVALID_INDEX); assert(GlobalIndex == INVALID_INDEX);
GlobalIndex = Index; GlobalIndex = Index;
} }
@ -197,14 +198,14 @@ DefinedGlobal::DefinedGlobal(StringRef Name, uint32_t Flags, InputFile *File,
Global(Global) {} Global(Global) {}
uint32_t SectionSymbol::getOutputSectionIndex() const { uint32_t SectionSymbol::getOutputSectionIndex() const {
DEBUG(dbgs() << "getOutputSectionIndex: " << getName() << "\n"); LLVM_DEBUG(dbgs() << "getOutputSectionIndex: " << getName() << "\n");
assert(OutputSectionIndex != INVALID_INDEX); assert(OutputSectionIndex != INVALID_INDEX);
return OutputSectionIndex; return OutputSectionIndex;
} }
void SectionSymbol::setOutputSectionIndex(uint32_t Index) { void SectionSymbol::setOutputSectionIndex(uint32_t Index) {
DEBUG(dbgs() << "setOutputSectionIndex: " << getName() << " -> " << Index LLVM_DEBUG(dbgs() << "setOutputSectionIndex: " << getName() << " -> " << Index
<< "\n"); << "\n");
assert(Index != INVALID_INDEX); assert(Index != INVALID_INDEX);
OutputSectionIndex = Index; OutputSectionIndex = Index;
} }

View File

@ -304,7 +304,7 @@ void Writer::createCustomSections() {
P->second->setOutputSectionIndex(SectionIndex); P->second->setOutputSectionIndex(SectionIndex);
} }
DEBUG(dbgs() << "createCustomSection: " << Name << "\n"); LLVM_DEBUG(dbgs() << "createCustomSection: " << Name << "\n");
OutputSections.push_back(make<CustomSection>(Name, Pair.second)); OutputSections.push_back(make<CustomSection>(Name, Pair.second));
} }
} }
@ -716,7 +716,7 @@ void Writer::calculateImports() {
if (!Sym->isLive()) if (!Sym->isLive())
continue; continue;
DEBUG(dbgs() << "import: " << Sym->getName() << "\n"); LLVM_DEBUG(dbgs() << "import: " << Sym->getName() << "\n");
ImportedSymbols.emplace_back(Sym); ImportedSymbols.emplace_back(Sym);
if (auto *F = dyn_cast<FunctionSymbol>(Sym)) if (auto *F = dyn_cast<FunctionSymbol>(Sym))
F->setFunctionIndex(NumImportedFunctions++); F->setFunctionIndex(NumImportedFunctions++);
@ -757,7 +757,7 @@ void Writer::calculateExports() {
Export = {Name, WASM_EXTERNAL_GLOBAL, FakeGlobalIndex++}; Export = {Name, WASM_EXTERNAL_GLOBAL, FakeGlobalIndex++};
} }
DEBUG(dbgs() << "Export: " << Name << "\n"); LLVM_DEBUG(dbgs() << "Export: " << Name << "\n");
Exports.push_back(Export); Exports.push_back(Export);
} }
} }
@ -770,7 +770,7 @@ void Writer::assignSymtab() {
unsigned SymbolIndex = SymtabEntries.size(); unsigned SymbolIndex = SymtabEntries.size();
for (ObjFile *File : Symtab->ObjectFiles) { for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "Symtab entries: " << File->getName() << "\n"); LLVM_DEBUG(dbgs() << "Symtab entries: " << File->getName() << "\n");
for (Symbol *Sym : File->getSymbols()) { for (Symbol *Sym : File->getSymbols()) {
if (Sym->getFile() != File) if (Sym->getFile() != File)
continue; continue;
@ -817,7 +817,7 @@ uint32_t Writer::lookupType(const WasmSignature &Sig) {
uint32_t Writer::registerType(const WasmSignature &Sig) { uint32_t Writer::registerType(const WasmSignature &Sig) {
auto Pair = TypeIndices.insert(std::make_pair(Sig, Types.size())); auto Pair = TypeIndices.insert(std::make_pair(Sig, Types.size()));
if (Pair.second) { if (Pair.second) {
DEBUG(dbgs() << "type " << toString(Sig) << "\n"); LLVM_DEBUG(dbgs() << "type " << toString(Sig) << "\n");
Types.push_back(&Sig); Types.push_back(&Sig);
} }
return Pair.first->second; return Pair.first->second;
@ -857,7 +857,7 @@ void Writer::assignIndexes() {
AddDefinedFunction(Func); AddDefinedFunction(Func);
for (ObjFile *File : Symtab->ObjectFiles) { for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "Functions: " << File->getName() << "\n"); LLVM_DEBUG(dbgs() << "Functions: " << File->getName() << "\n");
for (InputFunction *Func : File->Functions) for (InputFunction *Func : File->Functions)
AddDefinedFunction(Func); AddDefinedFunction(Func);
} }
@ -885,7 +885,7 @@ void Writer::assignIndexes() {
}; };
for (ObjFile *File : Symtab->ObjectFiles) { for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "Handle relocs: " << File->getName() << "\n"); LLVM_DEBUG(dbgs() << "Handle relocs: " << File->getName() << "\n");
for (InputChunk *Chunk : File->Functions) for (InputChunk *Chunk : File->Functions)
HandleRelocs(Chunk); HandleRelocs(Chunk);
for (InputChunk *Chunk : File->Segments) for (InputChunk *Chunk : File->Segments)
@ -897,7 +897,7 @@ void Writer::assignIndexes() {
uint32_t GlobalIndex = NumImportedGlobals + InputGlobals.size(); uint32_t GlobalIndex = NumImportedGlobals + InputGlobals.size();
auto AddDefinedGlobal = [&](InputGlobal *Global) { auto AddDefinedGlobal = [&](InputGlobal *Global) {
if (Global->Live) { if (Global->Live) {
DEBUG(dbgs() << "AddDefinedGlobal: " << GlobalIndex << "\n"); LLVM_DEBUG(dbgs() << "AddDefinedGlobal: " << GlobalIndex << "\n");
Global->setGlobalIndex(GlobalIndex++); Global->setGlobalIndex(GlobalIndex++);
InputGlobals.push_back(Global); InputGlobals.push_back(Global);
} }
@ -907,7 +907,7 @@ void Writer::assignIndexes() {
AddDefinedGlobal(Global); AddDefinedGlobal(Global);
for (ObjFile *File : Symtab->ObjectFiles) { for (ObjFile *File : Symtab->ObjectFiles) {
DEBUG(dbgs() << "Globals: " << File->getName() << "\n"); LLVM_DEBUG(dbgs() << "Globals: " << File->getName() << "\n");
for (InputGlobal *Global : File->Globals) for (InputGlobal *Global : File->Globals)
AddDefinedGlobal(Global); AddDefinedGlobal(Global);
} }
@ -933,12 +933,12 @@ void Writer::createOutputSegments() {
StringRef Name = getOutputDataSegmentName(Segment->getName()); StringRef Name = getOutputDataSegmentName(Segment->getName());
OutputSegment *&S = SegmentMap[Name]; OutputSegment *&S = SegmentMap[Name];
if (S == nullptr) { if (S == nullptr) {
DEBUG(dbgs() << "new segment: " << Name << "\n"); LLVM_DEBUG(dbgs() << "new segment: " << Name << "\n");
S = make<OutputSegment>(Name, Segments.size()); S = make<OutputSegment>(Name, Segments.size());
Segments.push_back(S); Segments.push_back(S);
} }
S->addInputSegment(Segment); S->addInputSegment(Segment);
DEBUG(dbgs() << "added data: " << Name << ": " << S->Size << "\n"); LLVM_DEBUG(dbgs() << "added data: " << Name << ": " << S->Size << "\n");
} }
} }
} }

View File

@ -37,7 +37,7 @@ static const char *valueTypeToString(uint8_t Type) {
namespace lld { namespace lld {
void wasm::debugWrite(uint64_t Offset, const Twine &Msg) { void wasm::debugWrite(uint64_t Offset, const Twine &Msg) {
DEBUG(dbgs() << format(" | %08lld: ", Offset) << Msg << "\n"); LLVM_DEBUG(dbgs() << format(" | %08lld: ", Offset) << Msg << "\n");
} }
void wasm::writeUleb128(raw_ostream &OS, uint32_t Number, const Twine &Msg) { void wasm::writeUleb128(raw_ostream &OS, uint32_t Number, const Twine &Msg) {