This is an archive of the discontinued LLVM Phabricator instance.

[LLParser] Support symbolic address space numbers
ClosedPublic

Authored by arichardson on Nov 28 2022, 4:01 AM.

Details

Summary

This allows the LLParser to also accept "A", "G", and "P" in addrspace
usages. "A" will be replaced by the alloca address space defined in the
globals, "G" by the default globals address space and "P" by the program
address space. This makes it easier to write tests that use different
address space and only only vary the RUN: lines. Currently, the only
alternative is to pre-process the sources with a tool such as sed

Importantly, these new string values are only accepted in .ll files and
not stored in the bitcode format, so it does not round-trip via llvm-as
and llvm-dis (see newly added test).

Diff Detail

Event Timeline

arichardson created this revision.Nov 28 2022, 4:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 4:01 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
arichardson requested review of this revision.Nov 28 2022, 4:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2022, 4:01 AM
nikic added a comment.Dec 5 2022, 6:30 AM

I'm fine with this addition. Should probably get a mention in LangRef as well?

arsenm added a comment.Dec 5 2022, 6:38 AM

Seems mildly convenient for some lit tests

llvm/test/Assembler/symbolic-addrspace.ll
23

Can you also test some cases where the string doesn't match the expected address space (e.g. alloca("G"))

51

Can you also test the error if it's a number in a string, e.g. "0"

  • Add LangRef update
  • Add requested additional tests

drop accidental diff

arichardson marked 2 inline comments as done.Dec 7 2022, 6:00 AM
nikic accepted this revision.Dec 8 2022, 7:12 AM

LGTM

This revision is now accepted and ready to land.Dec 8 2022, 7:12 AM
This revision was landed with ongoing or failed builds.Dec 8 2022, 12:52 PM
This revision was automatically updated to reflect the committed changes.