[WebAssembly] Replace varargs debugPrint with standard log call

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

llvm-svn: 327507
This commit is contained in:
Nicholas Wilson 2018-03-14 13:50:20 +00:00
parent 8883af6892
commit a06a355095
1 changed files with 9 additions and 19 deletions

View File

@ -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,