This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Fix wrong lex result on 64-bit integer boundaries
ClosedPublic

Authored by zsrkmyn on Aug 4 2023, 2:13 AM.

Details

Summary

Binary and decimal values were reconginzed by strtoll, which returns
error when the msb is 1, and the error was ignored, resulting to wrong
results.

This patch fixes the issue.

Diff Detail

Event Timeline

zsrkmyn created this revision.Aug 4 2023, 2:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 2:13 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
zsrkmyn requested review of this revision.Aug 4 2023, 2:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 4 2023, 2:13 AM
MaskRay accepted this revision.Aug 14 2023, 12:48 PM

LGTM.

llvm/lib/TableGen/TGLexer.cpp
468
484–502

Add a period to a full sentence.

llvm/test/TableGen/64-bit-int.td
23

I think you swapped BinVal and HexVal?

I think it's useful to give the same suffix for Bin/Hex/Dec values with the same value.

BinVal0 = 0b.........;
HexVal0 = 0x8000000000000000;
bits<64> DecVal0 = 9223372036854775808;

HexVal1 = 0x8000000000000001;
bits<64> DecVal1 = 9223372036854775809;

This grouping makes it clear that 9223372036854775808 equals 0x8000000000000000....

This revision is now accepted and ready to land.Aug 14 2023, 12:48 PM
MaskRay added inline comments.Aug 14 2023, 12:49 PM
llvm/test/TableGen/64-bit-int.td
22

Positive tests don't need to be surrounded by #ifdef VALID ... #endif.

Only negative tests need a preprocessor guard.

zsrkmyn updated this revision to Diff 551877.Aug 20 2023, 7:03 PM

Update as per MaskRay's comment.

zsrkmyn marked 4 inline comments as done.Aug 20 2023, 7:04 PM
MaskRay accepted this revision.Aug 20 2023, 9:42 PM
This revision was landed with ongoing or failed builds.Aug 20 2023, 9:46 PM
This revision was automatically updated to reflect the committed changes.