This is an archive of the discontinued LLVM Phabricator instance.

Make "@name =" mandatory for globals in .ll files
Needs RevisionPublic

Authored by espindola on May 10 2016, 11:16 AM.

Details

Reviewers
dexonsmith
Summary

An oddity of the .ll syntax is that the "@var = " in

@var = global i32 42

is optional. Writing just

global i32 42

is equivalent to

@0 = global i32 42

This means that there is a pretty big First set at the top level. The current implementation maintains it manually. I was trying to refactor it, but then started wondering why keep it a all. I personally find the above syntax confusing. It looks like something is missing.

The attached patch removes the feature and simplifies the parser.

Diff Detail

Event Timeline

rafael retitled this revision from to Make "@name =" mandatory for globals in .ll files.
rafael updated this object.
rafael added a reviewer: dexonsmith.
rafael added a subscriber: llvm-commits.
pete added a subscriber: pete.May 10 2016, 11:21 AM

Yeah, that doesn’t seem to be particularly useful. The small number of tests you had to update shows just how few people probably even knew it existed.

LGTM to remove it.

Cheers,
Pete

dexonsmith edited edge metadata.May 10 2016, 11:31 PM
dexonsmith added a subscriber: dexonsmith.

I'm not sure this goes far enough.

While it's inconvenient for parsing and not particularly readable, it makes .ll files with unnamed globals easier to modify. E.g., if you have this file:

global i32 42
global i32 43

global i32 44

you can delete the second line to create:

global i32 42

global i32 44

However, IIRC, skipping a slot would be illegal:

@0 = global i32 42

@2 = global i32 44

If you make the above (skipping a slot) legal (or if I'm wrong and it's already legal), then I'm fine with this.

espindola commandeered this revision.Mar 15 2018, 8:58 AM
espindola added a reviewer: rafael.
dexonsmith requested changes to this revision.Oct 17 2020, 6:09 AM
This revision now requires changes to proceed.Oct 17 2020, 6:09 AM