Index: llvm/trunk/lib/MC/MCAsmStreamer.cpp =================================================================== --- llvm/trunk/lib/MC/MCAsmStreamer.cpp +++ llvm/trunk/lib/MC/MCAsmStreamer.cpp @@ -1106,10 +1106,8 @@ OS << ' '; } PrintQuotedString(Filename, OS); - if (Checksum) { - OS << " md5 "; - PrintQuotedString(Checksum->digest(), OS); - } + if (Checksum) + OS << " md5 0x" << Checksum->digest(); if (Source) { OS << " source "; PrintQuotedString(*Source, OS); Index: llvm/trunk/lib/MC/MCParser/AsmParser.cpp =================================================================== --- llvm/trunk/lib/MC/MCParser/AsmParser.cpp +++ llvm/trunk/lib/MC/MCParser/AsmParser.cpp @@ -2969,6 +2969,25 @@ return false; } +static bool parseHexOcta(AsmParser &Asm, uint64_t &hi, uint64_t &lo) { + if (Asm.getTok().isNot(AsmToken::Integer) && + Asm.getTok().isNot(AsmToken::BigNum)) + return Asm.TokError("unknown token in expression"); + SMLoc ExprLoc = Asm.getTok().getLoc(); + APInt IntValue = Asm.getTok().getAPIntVal(); + Asm.Lex(); + if (!IntValue.isIntN(128)) + return Asm.Error(ExprLoc, "out of range literal value"); + if (!IntValue.isIntN(64)) { + hi = IntValue.getHiBits(IntValue.getBitWidth() - 64).getZExtValue(); + lo = IntValue.getLoBits(64).getZExtValue(); + } else { + hi = 0; + lo = IntValue.getZExtValue(); + } + return false; +} + /// ParseDirectiveOctaValue /// ::= .octa [ hexconstant (, hexconstant)* ] @@ -2976,21 +2995,9 @@ auto parseOp = [&]() -> bool { if (checkForValidSection()) return true; - if (getTok().isNot(AsmToken::Integer) && getTok().isNot(AsmToken::BigNum)) - return TokError("unknown token in expression"); - SMLoc ExprLoc = getTok().getLoc(); - APInt IntValue = getTok().getAPIntVal(); uint64_t hi, lo; - Lex(); - if (!IntValue.isIntN(128)) - return Error(ExprLoc, "out of range literal value"); - if (!IntValue.isIntN(64)) { - hi = IntValue.getHiBits(IntValue.getBitWidth() - 64).getZExtValue(); - lo = IntValue.getLoBits(64).getZExtValue(); - } else { - hi = 0; - lo = IntValue.getZExtValue(); - } + if (parseHexOcta(*this, hi, lo)) + return true; if (MAI.isLittleEndian()) { getStreamer().EmitIntValue(lo, 8); getStreamer().EmitIntValue(hi, 8); @@ -3283,7 +3290,8 @@ Filename = Path; } - std::string Checksum; + uint64_t MD5Hi, MD5Lo; + bool HasMD5 = false; Optional Source; bool HasSource = false; @@ -3296,12 +3304,10 @@ parseIdentifier(Keyword)) return true; if (Keyword == "md5") { + HasMD5 = true; if (check(FileNumber == -1, "MD5 checksum specified, but no file number") || - check(getTok().isNot(AsmToken::String), - "unexpected token in '.file' directive") || - parseEscapedString(Checksum) || - check(Checksum.size() != 32, "invalid MD5 checksum specified")) + parseHexOcta(*this, MD5Hi, MD5Lo)) return true; } else if (Keyword == "source") { HasSource = true; @@ -3324,12 +3330,12 @@ getStreamer().EmitFileDirective(Filename); else { MD5::MD5Result *CKMem = nullptr; - if (!Checksum.empty()) { - Checksum = fromHex(Checksum); - if (check(Checksum.size() != 16, "invalid MD5 checksum specified")) - return true; + if (HasMD5) { CKMem = (MD5::MD5Result *)Ctx.allocate(sizeof(MD5::MD5Result), 1); - memcpy(&CKMem->Bytes, Checksum.data(), 16); + for (unsigned i = 0; i != 8; ++i) { + CKMem->Bytes[i] = uint8_t(MD5Hi >> ((7 - i) * 8)); + CKMem->Bytes[i + 8] = uint8_t(MD5Lo >> ((7 - i) * 8)); + } } if (HasSource) { char *SourceBuf = static_cast(Ctx.allocate(SourceString.size())); Index: llvm/trunk/test/CodeGen/Generic/dwarf-md5.ll =================================================================== --- llvm/trunk/test/CodeGen/Generic/dwarf-md5.ll +++ llvm/trunk/test/CodeGen/Generic/dwarf-md5.ll @@ -13,13 +13,13 @@ ; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefixes=OBJ,OBJ-5 ; ASM-4-NOT: .file 0 -; ASM-5: .file 0 "/scratch{{.*[/\\]}}t.c" md5 "00000000000000000000000000000000" +; ASM-5: .file 0 "/scratch{{.*[/\\]}}t.c" md5 0x00000000000000000000000000000000 ; ASM: .file 1 "/scratch{{.*[/\\]}}t1.h" ; ASM-4-NOT: md5 -; ASM-5-SAME: md5 "11111111111111111111111111111111" +; ASM-5-SAME: md5 0x11111111111111111111111111111111 ; ASM: .file 2 "/scratch{{.*[/\\]}}t2.h" ; ASM-4-NOT: md5 -; ASM-5-SAME: md5 "22222222222222222222222222222222" +; ASM-5-SAME: md5 0x22222222222222222222222222222222 ; OBJ-5: file_names[ 0]: ; OBJ-5-NEXT: name: "t.c" Index: llvm/trunk/test/MC/ELF/debug-file-options.s =================================================================== --- llvm/trunk/test/MC/ELF/debug-file-options.s +++ llvm/trunk/test/MC/ELF/debug-file-options.s @@ -2,8 +2,8 @@ // Test combinations of options to the .file directive. - .file 1 "dir1/foo" md5 "ee87e05688663173cd6043a3a15bba6e" source "void foo() {}" - .file 2 "dir2/bar" source "void bar() {}" md5 "816225a0c90ca8948b70eb58be4d522f" + .file 1 "dir1/foo" md5 0xee87e05688663173cd6043a3a15bba6e source "void foo() {}" + .file 2 "dir2/bar" source "void bar() {}" md5 0x816225a0c90ca8948b70eb58be4d522f .loc 1 1 0 nop .loc 2 1 0 Index: llvm/trunk/test/MC/ELF/debug-md5-err.s =================================================================== --- llvm/trunk/test/MC/ELF/debug-md5-err.s +++ llvm/trunk/test/MC/ELF/debug-md5-err.s @@ -7,20 +7,20 @@ # Missing md5 keyword. # CHECK: [[@LINE+1]]:{{[0-9]+}}: error: unexpected token in '.file' directive - .file 2 "dir1" "foo" "00112233445566778899aabbccddeeff" + .file 2 "dir1" "foo" 0x00112233445566778899aabbccddeeff -# Bad length. -# CHECK: [[@LINE+1]]:{{[0-9]+}}: error: invalid MD5 checksum specified +# Bad syntax. +# CHECK: [[@LINE+1]]:{{[0-9]+}}: error: unknown token in expression .file 3 "dir2" "bar" md5 "ff" -# Not a string. -# CHECK: [[@LINE+1]]:{{[0-9]+}}: error: unexpected token in '.file' directive +# No hex prefix. +# CHECK: [[@LINE+1]]:{{[0-9]+}}: error: unknown token in expression .file 4 "dir3" "foo" md5 ffeeddccbbaa99887766554433221100 # Non-DWARF .file syntax with checksum. # CHECK: [[@LINE+1]]:{{[0-9]+}}: error: MD5 checksum specified, but no file number - .file "baz" md5 "ffeeddccbbaa998877665544332211gg" + .file "baz" md5 0xffeeddccbbaa99887766554433221100 # Inconsistent use of MD5 option. Note: .file 1 did not supply one. # CHECK: [[@LINE+1]]:{{[0-9]+}}: error: inconsistent use of MD5 checksums - .file 5 "bax" md5 "ffeeddccbbaa99887766554433221100" + .file 5 "bax" md5 0xffeeddccbbaa99887766554433221100 Index: llvm/trunk/test/MC/ELF/debug-md5.s =================================================================== --- llvm/trunk/test/MC/ELF/debug-md5.s +++ llvm/trunk/test/MC/ELF/debug-md5.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -triple x86_64-unknown-unknown -dwarf-version 5 -fdebug-compilation-dir=/tmp -filetype=obj %s -o - | llvm-dwarfdump --debug-line --debug-line-str -v - | FileCheck %s - .file 1 "dir1/foo" md5 "00112233445566778899aabbccddeeff" - .file 2 "dir2" "bar" md5 "ffeeddccbbaa99887766554433221100" + .file 1 "dir1/foo" md5 0x00112233445566778899aabbccddeeff + .file 2 "dir2" "bar" md5 0xffeeddccbbaa99887766554433221100 .loc 1 1 0 nop .loc 2 1 0