summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Stannard <oliver.stannard@arm.com>2017-05-30 09:37:11 +0000
committerOliver Stannard <oliver.stannard@arm.com>2017-05-30 09:37:11 +0000
commit3d0f9507d5e3d86d51632f4de6e80155c956ee47 (patch)
tree5bba3ef9bb5eb3dcc2c6d3d0e9866cf5886e772d
parent375b60de744bfe15160ddac28f078d945807118b (diff)
downloadbcm5719-llvm-3d0f9507d5e3d86d51632f4de6e80155c956ee47.tar.gz
bcm5719-llvm-3d0f9507d5e3d86d51632f4de6e80155c956ee47.zip
[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 llvm-svn: 304199
-rw-r--r--llvm/include/llvm/MC/ConstantPools.h3
-rw-r--r--llvm/test/MC/AArch64/ldr-pseudo.s12
2 files changed, 14 insertions, 1 deletions
diff --git a/llvm/include/llvm/MC/ConstantPools.h b/llvm/include/llvm/MC/ConstantPools.h
index 5d4e32a672d..ef33250204e 100644
--- a/llvm/include/llvm/MC/ConstantPools.h
+++ b/llvm/include/llvm/MC/ConstantPools.h
@@ -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
diff --git a/llvm/test/MC/AArch64/ldr-pseudo.s b/llvm/test/MC/AArch64/ldr-pseudo.s
index e132f7cf651..1d99d140180 100644
--- a/llvm/test/MC/AArch64/ldr-pseudo.s
+++ b/llvm/test/MC/AArch64/ldr-pseudo.s
@@ -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
OpenPOWER on IntegriCloud