This is an archive of the discontinued LLVM Phabricator instance.

[IR/AsmWriter] Output escape sequences if the first character isdigit()
ClosedPublic

Authored by filcab on May 27 2015, 6:00 PM.

Details

Summary

If the first character in a metadata attachment's name is a digit, it has
to be output using an escape sequence, otherwise it's not valid text IR.

Removed an over-zealous assert from LLVMContext which didn't allow this.
The rule should only apply to text IR. Actual names can have any sequence
of non-NUL bytes.

Also added some documentation on accepted names.

Bug found with AFL fuzz.

Diff Detail

Event Timeline

filcab updated this revision to Diff 26655.May 27 2015, 6:00 PM
filcab retitled this revision from to [IR/AsmWriter] Output escape sequences if the first character isdigit().
filcab updated this object.
filcab edited the test plan for this revision. (Show Details)
filcab added reviewers: dexonsmith, rafael.
filcab added a subscriber: Unknown Object (MLST).

I could add some more stuff to FileCheck in that test, but am not 100% sure on what the best way to do it.

If it's safe to assume the output it currently has (!{} becomes !2, and some other "abbreviations" appear), I can do a verbatim check, but it would basically be checking copy+paste.
Comments on this?

rafael added inline comments.May 28 2015, 8:00 AM
docs/LangRef.rst
840

Maybe mention that you can still use escapes, so in the end we support any name but have a different syntax in the .ll

lib/IR/AsmWriter.cpp
2218–2219

Start with a lowercase letter.

2223–2224

This is just clang-format, right? Please commit it first.

lib/IR/LLVMContext.cpp
246–248

Commit the clang-format bits first.

filcab updated this revision to Diff 26706.May 28 2015, 11:21 AM
  • clang-format a few functions. NFC
  • [IR/AsmWriter] Output escape sequences if the first character isdigit()

Split the patch in two and addressed comments.

filcab updated this revision to Diff 26707.May 28 2015, 11:23 AM
  • [IR/AsmWriter] Output escape sequences if the first character isdigit()

printMetadataIdentifier now actually starts with a lowercase letter

filcab updated this revision to Diff 26743.May 28 2015, 2:57 PM
  • CHECK-LABEL-ize test. NFC

Move test to test/Assembler/metadata.ll

filcab accepted this revision.Jun 3 2015, 6:08 PM
filcab added a reviewer: filcab.

This got committed as r238865, r238866, and r238867.
Phab didn't pick it up, though. Closing.

This revision is now accepted and ready to land.Jun 3 2015, 6:08 PM
filcab closed this revision.Jun 3 2015, 6:08 PM