[lld] r327507 - [WebAssembly] Replace varargs debugPrint with standard log call
Nicholas Wilson via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 14 06:50:20 PDT 2018
Author: ncw
Date: Wed Mar 14 06:50:20 2018
New Revision: 327507
URL: http://llvm.org/viewvc/llvm-project?rev=327507&view=rev
Log:
[WebAssembly] Replace varargs debugPrint with standard log call
Differential Revision: https://reviews.llvm.org/D44441
Modified:
lld/trunk/wasm/Writer.cpp
Modified: lld/trunk/wasm/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/wasm/Writer.cpp?rev=327507&r1=327506&r2=327507&view=diff
==============================================================================
--- lld/trunk/wasm/Writer.cpp (original)
+++ lld/trunk/wasm/Writer.cpp Wed Mar 14 06:50:20 2018
@@ -143,16 +143,6 @@ private:
} // anonymous namespace
-static void debugPrint(const char *fmt, ...) {
- if (!errorHandler().Verbose)
- return;
- fprintf(stderr, "lld: ");
- va_list ap;
- va_start(ap, fmt);
- vfprintf(stderr, fmt, ap);
- va_end(ap);
-}
-
void Writer::createImportSection() {
uint32_t NumImports = ImportedSymbols.size();
if (Config->ImportMemory)
@@ -568,7 +558,7 @@ void Writer::writeSections() {
void Writer::layoutMemory() {
uint32_t MemoryPtr = 0;
MemoryPtr = Config->GlobalBase;
- debugPrint("mem: global base = %d\n", Config->GlobalBase);
+ log("mem: global base = " + Twine(Config->GlobalBase));
createOutputSegments();
@@ -580,8 +570,8 @@ void Writer::layoutMemory() {
for (OutputSegment *Seg : Segments) {
MemoryPtr = alignTo(MemoryPtr, Seg->Alignment);
Seg->StartVA = MemoryPtr;
- debugPrint("mem: %-15s offset=%-8d size=%-8d align=%d\n",
- Seg->Name.str().c_str(), MemoryPtr, Seg->Size, Seg->Alignment);
+ log(formatv("mem: {0,-15} offset={1,-8} size={2,-8} align={3}", Seg->Name,
+ MemoryPtr, Seg->Size, Seg->Alignment));
MemoryPtr += Seg->Size;
}
@@ -589,29 +579,29 @@ void Writer::layoutMemory() {
if (WasmSym::DataEnd)
WasmSym::DataEnd->setVirtualAddress(MemoryPtr);
- debugPrint("mem: static data = %d\n", MemoryPtr - Config->GlobalBase);
+ log("mem: static data = " + Twine(MemoryPtr - Config->GlobalBase));
// Stack comes after static data and bss
if (!Config->Relocatable) {
MemoryPtr = alignTo(MemoryPtr, kStackAlignment);
if (Config->ZStackSize != alignTo(Config->ZStackSize, kStackAlignment))
error("stack size must be " + Twine(kStackAlignment) + "-byte aligned");
- debugPrint("mem: stack size = %d\n", Config->ZStackSize);
- debugPrint("mem: stack base = %d\n", MemoryPtr);
+ log("mem: stack size = " + Twine(Config->ZStackSize));
+ log("mem: stack base = " + Twine(MemoryPtr));
MemoryPtr += Config->ZStackSize;
WasmSym::StackPointer->Global->Global.InitExpr.Value.Int32 = MemoryPtr;
- debugPrint("mem: stack top = %d\n", MemoryPtr);
+ log("mem: stack top = " + Twine(MemoryPtr));
// Set `__heap_base` to directly follow the end of the stack. We don't
// allocate any heap memory up front, but instead really on the malloc/brk
// implementation growing the memory at runtime.
WasmSym::HeapBase->setVirtualAddress(MemoryPtr);
- debugPrint("mem: heap base = %d\n", MemoryPtr);
+ log("mem: heap base = " + Twine(MemoryPtr));
}
uint32_t MemSize = alignTo(MemoryPtr, WasmPageSize);
NumMemoryPages = MemSize / WasmPageSize;
- debugPrint("mem: total pages = %d\n", NumMemoryPages);
+ log("mem: total pages = " + Twine(NumMemoryPages));
}
SyntheticSection *Writer::createSyntheticSection(uint32_t Type,
More information about the llvm-commits
mailing list