[llvm] r355900 - [TableGen] Allow 2^63-1 and 2^63-2 as int literals.
Simon Tatham via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 02:28:19 PDT 2019
Author: statham
Date: Tue Mar 12 02:28:19 2019
New Revision: 355900
URL: http://llvm.org/viewvc/llvm-project?rev=355900&view=rev
Log:
[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<int64_t>, which means that neither one
can be used as a key in DenseMap<int64_t, anything>. 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
Added:
llvm/trunk/test/TableGen/IntSpecialValues.td
Modified:
llvm/trunk/lib/TableGen/Record.cpp
Modified: llvm/trunk/lib/TableGen/Record.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=355900&r1=355899&r2=355900&view=diff
==============================================================================
--- llvm/trunk/lib/TableGen/Record.cpp (original)
+++ llvm/trunk/lib/TableGen/Record.cpp Tue Mar 12 02:28:19 2019
@@ -32,6 +32,7 @@
#include <cassert>
#include <cstdint>
#include <memory>
+#include <map>
#include <string>
#include <utility>
#include <vector>
@@ -457,7 +458,7 @@ Init *BitsInit::resolveReferences(Resolv
}
IntInit *IntInit::get(int64_t V) {
- static DenseMap<int64_t, IntInit*> ThePool;
+ static std::map<int64_t, IntInit*> ThePool;
IntInit *&I = ThePool[V];
if (!I) I = new(Allocator) IntInit(V);
Added: llvm/trunk/test/TableGen/IntSpecialValues.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/TableGen/IntSpecialValues.td?rev=355900&view=auto
==============================================================================
--- llvm/trunk/test/TableGen/IntSpecialValues.td (added)
+++ llvm/trunk/test/TableGen/IntSpecialValues.td Tue Mar 12 02:28:19 2019
@@ -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;
+}
More information about the llvm-commits
mailing list