[llvm] r304199 - [MC] Fix constant pools with DenseMap sentinel values
Oliver Stannard via llvm-commits
llvm-commits at lists.llvm.org
Tue May 30 02:37:12 PDT 2017
Author: olista01
Date: Tue May 30 04:37:11 2017
New Revision: 304199
URL: http://llvm.org/viewvc/llvm-project?rev=304199&view=rev
Log:
[MC] Fix constant pools with DenseMap sentinel values
The MC ConstantPool class uses a DenseMap to track generated constants, with
the int64_t value of the constant as the key. This fails when values of
0x7fffffffffffffff or 0x7ffffffffffffffe are inserted into the constant pool, as
these are sentinel values for DenseMap.
The fix is to use std::map instead, which doesn't use sentinel values.
Differential revision: https://reviews.llvm.org/D33667
Modified:
llvm/trunk/include/llvm/MC/ConstantPools.h
llvm/trunk/test/MC/AArch64/ldr-pseudo.s
Modified: llvm/trunk/include/llvm/MC/ConstantPools.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/ConstantPools.h?rev=304199&r1=304198&r2=304199&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/ConstantPools.h (original)
+++ llvm/trunk/include/llvm/MC/ConstantPools.h Tue May 30 04:37:11 2017
@@ -19,6 +19,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/SMLoc.h"
#include <cstdint>
+#include <map>
namespace llvm {
@@ -44,7 +45,7 @@ struct ConstantPoolEntry {
class ConstantPool {
using EntryVecTy = SmallVector<ConstantPoolEntry, 4>;
EntryVecTy Entries;
- DenseMap<int64_t, const MCSymbolRefExpr *> CachedEntries;
+ std::map<int64_t, const MCSymbolRefExpr *> CachedEntries;
public:
// Initialize a new empty constant pool
Modified: llvm/trunk/test/MC/AArch64/ldr-pseudo.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/AArch64/ldr-pseudo.s?rev=304199&r1=304198&r2=304199&view=diff
==============================================================================
--- llvm/trunk/test/MC/AArch64/ldr-pseudo.s (original)
+++ llvm/trunk/test/MC/AArch64/ldr-pseudo.s Tue May 30 04:37:11 2017
@@ -205,6 +205,13 @@ f18:
ldr x1, =0x320064
// CHECK: ldr x1, .Ltmp[[TMP26:[0-9]+]]
+// We previously used a DenseMap with constant values as keys, check that
+// sentinel values can be used.
+ ldr x0, =0x7ffffffffffffffe
+// CHECK: ldr x0, .Ltmp[[TMP27:[0-9]+]]
+ ldr x1, =0x7fffffffffffffff
+// CHECK: ldr x1, .Ltmp[[TMP28:[0-9]+]]
+
//
// Constant Pools
//
@@ -311,3 +318,8 @@ f18:
// CHECK: .p2align 2
// CHECK: .Ltmp[[TMP25]]
// CHECK: .word 3276900
+
+// CHECK: .Ltmp[[TMP27]]
+// CHECK: .xword 9223372036854775806
+// CHECK: .Ltmp[[TMP28]]
+// CHECK: .xword 9223372036854775807
More information about the llvm-commits
mailing list