From cdb7c31f0adaa9fb338ec1a226cfd44cd9d31c5d Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Tue, 12 Mar 2019 09:28:19 +0000 Subject: [PATCH] [TableGen] Allow 2^63-1 and 2^63-2 as int literals. These two values correspond to the 'Empty' and 'Tombstone' special keys defined by DenseMapInfo, which means that neither one can be used as a key in DenseMap. Hence, if you try to use either of those values as an int literal, IntInit::get() fails an assertion when it tries to insert them into its static cache of int-literal objects. Fixed by replacing the DenseMap with a std::map, which doesn't intrude on the space of legal values of the key type. Reviewers: nhaehnle, hfinkel, javedabsar, efriedma Reviewed By: efriedma Subscribers: fhahn, efriedma, hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D59016 llvm-svn: 355900 --- llvm/lib/TableGen/Record.cpp | 3 ++- llvm/test/TableGen/IntSpecialValues.td | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 llvm/test/TableGen/IntSpecialValues.td diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp index 4222a0b57fb8..7577f0b85716 100644 --- a/llvm/lib/TableGen/Record.cpp +++ b/llvm/lib/TableGen/Record.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -457,7 +458,7 @@ Init *BitsInit::resolveReferences(Resolver &R) const { } IntInit *IntInit::get(int64_t V) { - static DenseMap ThePool; + static std::map ThePool; IntInit *&I = ThePool[V]; if (!I) I = new(Allocator) IntInit(V); diff --git a/llvm/test/TableGen/IntSpecialValues.td b/llvm/test/TableGen/IntSpecialValues.td new file mode 100644 index 000000000000..be91282366fa --- /dev/null +++ b/llvm/test/TableGen/IntSpecialValues.td @@ -0,0 +1,8 @@ +// RUN: llvm-tblgen %s | FileCheck %s + +def TestRecord { + // CHECK: int X = 9223372036854775807; + int X = 0x7FFFFFFFFFFFFFFF; + // CHECK: int Y = 9223372036854775806; + int Y = 0x7FFFFFFFFFFFFFFE; +}