[PATCH] D20121: Make "@name =" mandatory for globals in .ll files

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Tue May 10 23:31:26 PDT 2016


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.

> On 2016-May-10, at 11:16, Rafael Ávila de Espíndola <rafael.espindola at gmail.com> wrote:
> 
> rafael created this revision.
> rafael added a reviewer: dexonsmith.
> rafael added a subscriber: llvm-commits.
> Herald added a subscriber: qcolombet.
> 
> 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.
> 
> http://reviews.llvm.org/D20121
> 
> Files:
>  docs/LangRef.rst
>  lib/AsmParser/LLParser.cpp
>  test/Assembler/2003-04-15-ConstantInitAssertion.ll
>  test/Assembler/2003-05-21-ConstantShiftExpr.ll
>  test/Assembler/2003-05-21-MalformedShiftCrash.ll
>  test/Assembler/2003-05-21-MalformedStructCrash.ll
>  test/Assembler/2003-08-21-ConstantExprCast-Fold.ll
>  test/Assembler/2004-01-20-MaxLongLong.ll
>  test/Assembler/2004-02-01-NegativeZero.ll
>  test/Assembler/2009-02-01-UnnamedForwardRef.ll
>  test/Assembler/ConstantExprFold.ll
>  test/Assembler/getelementptr_vec_idx4.ll
>  test/Assembler/invalid-hexint.ll
>  test/Assembler/invalid_cast4.ll
>  test/Assembler/vector-cmp.ll
>  test/CodeGen/PowerPC/2008-03-24-CoalescerBug.ll
>  test/CodeGen/X86/2008-07-19-movups-spills.ll
>  test/CodeGen/X86/2008-07-22-CombinerCrash.ll
>  test/CodeGen/X86/2008-09-29-ReMatBug.ll
>  test/CodeGen/X86/2009-03-05-burr-list-crash.ll
>  test/CodeGen/X86/extractps.ll
>  test/CodeGen/X86/pr2585.ll
>  test/Feature/constexpr.ll
>  test/Feature/constpointer.ll
>  test/Feature/globalvars.ll
>  test/Feature/testconstants.ll
>  test/Integer/constexpr_bt.ll
>  test/Integer/constpointer_bt.ll
>  test/Linker/2003-08-28-TypeResolvesGlobal3.ll
>  test/Transforms/GlobalOpt/2007-05-13-Crash.ll
>  test/Transforms/GlobalOpt/2009-03-06-Anonymous.ll
> 
> <D20121.56764.patch>



More information about the llvm-commits mailing list