llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Program with too many columns causes parse error

Open cmtice opened this issue 11 years ago • 11 comments

Bugzilla Link 24621
Resolution FIXED
Resolved on Aug 28, 2015 18:00
Version trunk
OS Linux
CC @adrian-prantl,@dwblaikie,@dexonsmith,@echristo

Extended Description

Using the same test case as in llvm/llvm-project#24992 we run out of columns.

time /usr/local/google2/cmtice/llvm-work/llvm-install.opt/bin/opt interpreter_goto_table_impl.ll -O3 -S -o /dev/null /usr/local/google2/cmtice/llvm-work/llvm-install.opt/bin/opt: interpreter_goto_table_impl.ll:361932:84: error: value for 'column' too large, limit is 65535 !​86192 = distinct !DILexicalBlock(scope: !​46092, file: !​46093, line: 2533, column: 65740) ^

cmtice avatar Aug 28 '15 23:08 cmtice

Fixed in r246349.

(Well, it'll still cause a parse error, but the assembly won't be generated anymore.)

dexonsmith avatar Aug 29 '15 01:08 dexonsmith

After an IRC conversation, we've decided to go with column of 0 here (and no frontend change necessary). DILocation already has this behaviour, and in DWARF this means "unknown column", which seems fairly appropriate. Running tests now, so if I don't get distracted should be committed soon.

(BTW, when I was talking about backend crashes, I was somehow conflating this with the # of subprogram arguments, which also used to be limited to 255.)

dexonsmith avatar Aug 29 '15 00:08 dexonsmith

Works for me.

echristo avatar Aug 29 '15 00:08 echristo

(My bugzilla skills seem weak.)

dexonsmith avatar Aug 29 '15 00:08 dexonsmith

Hmm, could do. Should we do the same for DILocation?

Saturate at 16-bits?

Could do. Same for DILocation?

dexonsmith avatar Aug 29 '15 00:08 dexonsmith

Saturate at 16-bits?

echristo avatar Aug 29 '15 00:08 echristo

DILocation is the only other thing with column-info, and it's restricted to 16-bits.

In the parser, I also restricted DILexicalBlock to 16-bits, but forgot to add an assertion (it's an arbitrary restriction for consistency with DILocation).

IMO, we should be consistent, and DILexicalBlock should only accept 16-bits:

diff --git a/include/llvm/IR/DebugInfoMetadata.h b/include/llvm/IR/DebugInfoMetadata.h index eeacbdb..6fba3b5 100644 --- a/include/llvm/IR/DebugInfoMetadata.h +++ b/include/llvm/IR/DebugInfoMetadata.h @@ -1430,12 +1430,14 @@ class DILexicalBlock : public DILexicalBlockBase { friend class MDNode;

unsigned Line;

  • unsigned Column;
  • uint16_t Column;

    DILexicalBlock(LLVMContext &C, StorageType Storage, unsigned Line, unsigned Column, ArrayRef<Metadata *> Ops) : DILexicalBlockBase(C, DILexicalBlockKind, Storage, Ops), Line(Line),

  •    Column(Column) {}
    
  •    Column(Column) {
    
  • assert(Column < (1u << 16) && "Expected 16-bit column");
  • } ~DILexicalBlock() = default;
    static DILexicalBlock *getImpl(LLVMContext &Context, DILocalScope *Scope,

Still not sure what the right frontend fix is though.

dexonsmith avatar Aug 29 '15 00:08 dexonsmith

Sorry, my fault :)

echristo avatar Aug 29 '15 00:08 echristo

Hold on, this isn't even a verifier failure. This is a parse error:

/usr/local/google2/cmtice/llvm-work/llvm-install.opt/bin/opt: interpreter_goto_table_impl.ll:361932:84: error: value for 'column' too large, limit is 65535 !​86192 = distinct !DILexicalBlock(scope: !​46092, file: !​46093, line: 2533, column: 65740)

Maybe I'm confused here.

dexonsmith avatar Aug 29 '15 00:08 dexonsmith

Until recently 255 was the limit. I added the verifier check since that's better than a backend crash (or wrapping around), but I'm not really sure of the right actual fix.

Should the frontend drop the column info? Should all the IR classes (DILocalVariable/DILexicalBlock/DILocation) drop it silently on construction?

dexonsmith avatar Aug 29 '15 00:08 dexonsmith

assigned to @dexonsmith

cmtice avatar Aug 28 '15 23:08 cmtice