[llvm] r331220 - [WebAssembly] MC: Improve debug output

Sam Clegg via llvm-commits llvm-commits at lists.llvm.org
Tue May 1 17:04:22 PDT 2018


Sorry about that. Looking into it.

On Tue, May 1, 2018 at 3:24 PM, Galina Kistanova <gkistanova at gmail.com> wrote:
> Hello Sam,
>
> This commit broke at least two builders:
> http://lab.llvm.org:8011/builders/lld-x86_64-darwin13/builds/20828
> and
> http://lab.llvm.org:8011/builders/clang-lld-x86_64-2stage
>
> . . .
> /Users/buildslave/as-bldslv9/lld-x86_64-darwin13/llvm.src/lib/MC/WasmObjectWriter.cpp:40:20:
> error: unused function 'toString' [-Werror,-Wunused-function]
> static std::string toString(wasm::WasmSymbolType type) {
>                    ^
> 1 error generated.
> make[2]: *** [lib/MC/CMakeFiles/LLVMMC.dir/WasmObjectWriter.cpp.o] Error 1
> make[1]: *** [lib/MC/CMakeFiles/LLVMMC.dir/all] Error 2
> make[1]: *** Waiting for unfinished jobs....
>
> Please have a look ASAP?
>
> Thanks
>
> Galina
>
> On Mon, Apr 30, 2018 at 12:40 PM, Sam Clegg via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: sbc
>> Date: Mon Apr 30 12:40:57 2018
>> New Revision: 331220
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=331220&view=rev
>> Log:
>> [WebAssembly] MC: Improve debug output
>>
>> Modified:
>>     llvm/trunk/include/llvm/MC/MCSymbolWasm.h
>>     llvm/trunk/lib/MC/WasmObjectWriter.cpp
>>
>> Modified: llvm/trunk/include/llvm/MC/MCSymbolWasm.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbolWasm.h?rev=331220&r1=331219&r2=331220&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/MC/MCSymbolWasm.h (original)
>> +++ llvm/trunk/include/llvm/MC/MCSymbolWasm.h Mon Apr 30 12:40:57 2018
>> @@ -45,6 +45,7 @@ public:
>>    bool isFunction() const { return Type ==
>> wasm::WASM_SYMBOL_TYPE_FUNCTION; }
>>    bool isData() const { return Type == wasm::WASM_SYMBOL_TYPE_DATA; }
>>    bool isGlobal() const { return Type == wasm::WASM_SYMBOL_TYPE_GLOBAL; }
>> +  bool isSection() const { return Type == wasm::WASM_SYMBOL_TYPE_SECTION;
>> }
>>    wasm::WasmSymbolType getType() const { return Type; }
>>    void setType(wasm::WasmSymbolType type) { Type = type; }
>>
>>
>> Modified: llvm/trunk/lib/MC/WasmObjectWriter.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/WasmObjectWriter.cpp?rev=331220&r1=331219&r2=331220&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/lib/MC/WasmObjectWriter.cpp (original)
>> +++ llvm/trunk/lib/MC/WasmObjectWriter.cpp Mon Apr 30 12:40:57 2018
>> @@ -37,6 +37,29 @@ using namespace llvm;
>>
>>  #define DEBUG_TYPE "mc"
>>
>> +static std::string toString(wasm::WasmSymbolType type) {
>> +  switch (type) {
>> +  case wasm::WASM_SYMBOL_TYPE_FUNCTION:
>> +    return "WASM_SYMBOL_TYPE_FUNCTION";
>> +  case wasm::WASM_SYMBOL_TYPE_GLOBAL:
>> +    return "WASM_SYMBOL_TYPE_GLOBAL";
>> +  case wasm::WASM_SYMBOL_TYPE_DATA:
>> +    return "WASM_SYMBOL_TYPE_DATA";
>> +  case wasm::WASM_SYMBOL_TYPE_SECTION:
>> +    return "WASM_SYMBOL_TYPE_SECTION";
>> +  }
>> +}
>> +
>> +static std::string relocTypetoString(uint32_t type) {
>> +  switch (type) {
>> +#define WASM_RELOC(NAME, VALUE) case VALUE: return #NAME;
>> +#include "llvm/BinaryFormat/WasmRelocs.def"
>> +#undef WASM_RELOC
>> +  default:
>> +    llvm_unreachable("uknown reloc type");
>> +  }
>> +}
>> +
>>  namespace {
>>
>>  // Went we ceate the indirect function table we start at 1, so that there
>> is
>> @@ -163,8 +186,8 @@ struct WasmRelocationEntry {
>>    }
>>
>>    void print(raw_ostream &Out) const {
>> -    Out << "Off=" << Offset << ", Sym=" << *Symbol << ", Addend=" <<
>> Addend
>> -        << ", Type=" << Type
>> +    Out << relocTypetoString(Type)
>> +        << " Off=" << Offset << ", Sym=" << *Symbol << ", Addend=" <<
>> Addend
>>          << ", FixupSection=" << FixupSection->getSectionName();
>>    }
>>
>> @@ -214,7 +237,7 @@ class WasmObjectWriter : public MCObject
>>    DenseMap<const MCSymbolWasm *, uint32_t> TableIndices;
>>    // Maps function/global symbols to the (shared) Symbol index space.
>>    DenseMap<const MCSymbolWasm *, uint32_t> SymbolIndices;
>> -  // Maps function/global symbols to the function/global Wasm index
>> space.
>> +  // Maps function/global symbols to the function/global/section index
>> space.
>>    DenseMap<const MCSymbolWasm *, uint32_t> WasmIndices;
>>    // Maps data symbols to the Wasm segment and offset/size with the
>> segment.
>>    DenseMap<const MCSymbolWasm *, wasm::WasmDataReference> DataLocations;
>> @@ -1235,11 +1258,11 @@ void WasmObjectWriter::writeObject(MCAss
>>        continue;
>>
>>      const auto &WS = static_cast<const MCSymbolWasm &>(S);
>> -    DEBUG(dbgs() << "MCSymbol: '" << S << "'"
>> +    DEBUG(dbgs() << "MCSymbol: " << toString(WS.getType())
>> +                 << " '" << S << "'"
>>                   << " isDefined=" << S.isDefined()
>>                   << " isExternal=" << S.isExternal()
>>                   << " isTemporary=" << S.isTemporary()
>> -                 << " isFunction=" << WS.isFunction()
>>                   << " isWeak=" << WS.isWeak()
>>                   << " isHidden=" << WS.isHidden()
>>                   << " isVariable=" << WS.isVariable() << "\n");
>> @@ -1284,7 +1307,7 @@ void WasmObjectWriter::writeObject(MCAss
>>          continue;
>>
>>        if (!WS.isDefined()) {
>> -        DEBUG(dbgs() << "  -> segment index: -1");
>> +        DEBUG(dbgs() << "  -> segment index: -1" << "\n");
>>          continue;
>>        }
>>
>> @@ -1306,8 +1329,8 @@ void WasmObjectWriter::writeObject(MCAss
>>            static_cast<uint32_t>(Layout.getSymbolOffset(WS)),
>>            static_cast<uint32_t>(Size)};
>>        DataLocations[&WS] = Ref;
>> -      DEBUG(dbgs() << "  -> segment index: " << Ref.Segment);
>> -    } else {
>> +      DEBUG(dbgs() << "  -> segment index: " << Ref.Segment << "\n");
>> +    } else if (WS.isGlobal()) {
>>        // A "true" Wasm global (currently just __stack_pointer)
>>        if (WS.isDefined())
>>          report_fatal_error("don't yet support defined globals");
>> @@ -1315,6 +1338,8 @@ void WasmObjectWriter::writeObject(MCAss
>>        // An import; the index was assigned above
>>        DEBUG(dbgs() << "  -> global index: " <<
>> WasmIndices.find(&WS)->second
>>                     << "\n");
>> +    } else {
>> +      assert(WS.isSection());
>>      }
>>    }
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
>


More information about the llvm-commits mailing list