summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/StackMaps.cpp
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2014-11-04 00:59:21 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2014-11-04 00:59:21 +0000
commite839965faa22d6ed5dd41402c80bd806eb8f6c26 (patch)
tree54d209276bc456db3a37314dbd8c9c006667e43b /llvm/lib/CodeGen/StackMaps.cpp
parent8691dc5b754f32c4262236481ca29770c3219353 (diff)
downloadbcm5719-llvm-e839965faa22d6ed5dd41402c80bd806eb8f6c26.tar.gz
bcm5719-llvm-e839965faa22d6ed5dd41402c80bd806eb8f6c26.zip
The patchpoint lowering logic would crash with live constants equal to
the tombstone or empty keys of a DenseMap<int64_t, T>. This patch fixes the issue (and adds a tests case). llvm-svn: 221214
Diffstat (limited to 'llvm/lib/CodeGen/StackMaps.cpp')
-rw-r--r--llvm/lib/CodeGen/StackMaps.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/StackMaps.cpp b/llvm/lib/CodeGen/StackMaps.cpp
index 967cf751f36..d3791c3feb5 100644
--- a/llvm/lib/CodeGen/StackMaps.cpp
+++ b/llvm/lib/CodeGen/StackMaps.cpp
@@ -222,6 +222,16 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID,
// -1 is directly encoded as .long 0xFFFFFFFF with no constant pool.
if (I->LocType == Location::Constant && !isInt<32>(I->Offset)) {
I->LocType = Location::ConstantIndex;
+ // ConstPool is intentionally a MapVector of 'uint64_t's (as
+ // opposed to 'int64_t's). We should never be in a situation
+ // where we have to insert either the tombstone or the empty
+ // keys into a map, and for a DenseMap<uint64_t, T> these are
+ // (uint64_t)0 and (uint64_t)-1. They can be and are
+ // represented using 32 bit integers.
+
+ assert((uint64_t)I->Offset != DenseMapInfo<uint64_t>::getEmptyKey() &&
+ (uint64_t)I->Offset != DenseMapInfo<uint64_t>::getTombstoneKey() &&
+ "empty and tombstone keys should fit in 32 bits!");
auto Result = ConstPool.insert(std::make_pair(I->Offset, I->Offset));
I->Offset = Result.first - ConstPool.begin();
}
OpenPOWER on IntegriCloud