From 8c202cdbda686500ff56e5f4a5184c03d78f38f6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 15 Jan 2004 18:47:15 +0000 Subject: [PATCH] The bcwriter does not want ConstantPointerRef's to be indexed, and the asmwriter never did! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10885 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Writer/SlotCalculator.cpp | 19 ++++++++++++++----- lib/VMCore/SlotCalculator.cpp | 19 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 283ca96bd26..6ce2f35ffb1 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -321,11 +321,16 @@ void SlotCalculator::purgeFunction() { SC_DEBUG("end purgeFunction!\n"); } -int SlotCalculator::getSlot(const Value *D) const { - std::map::const_iterator I = NodeMap.find(D); - if (I == NodeMap.end()) return -1; - - return (int)I->second; +int SlotCalculator::getSlot(const Value *V) const { + std::map::const_iterator I = NodeMap.find(V); + if (I != NodeMap.end()) + return (int)I->second; + + // Do not number ConstantPointerRef's at all. They are an abomination. + if (const ConstantPointerRef *CPR = dyn_cast(V)) + return getSlot(CPR->getValue()); + + return -1; } @@ -333,6 +338,10 @@ int SlotCalculator::getOrCreateSlot(const Value *V) { int SlotNo = getSlot(V); // Check to see if it's already in! if (SlotNo != -1) return SlotNo; + // Do not number ConstantPointerRef's at all. They are an abomination. + if (const ConstantPointerRef *CPR = dyn_cast(V)) + return getOrCreateSlot(CPR->getValue()); + if (!isa(V)) if (const Constant *C = dyn_cast(V)) { // If we are emitting a bytecode file, do not index the characters that diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index 283ca96bd26..6ce2f35ffb1 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -321,11 +321,16 @@ void SlotCalculator::purgeFunction() { SC_DEBUG("end purgeFunction!\n"); } -int SlotCalculator::getSlot(const Value *D) const { - std::map::const_iterator I = NodeMap.find(D); - if (I == NodeMap.end()) return -1; - - return (int)I->second; +int SlotCalculator::getSlot(const Value *V) const { + std::map::const_iterator I = NodeMap.find(V); + if (I != NodeMap.end()) + return (int)I->second; + + // Do not number ConstantPointerRef's at all. They are an abomination. + if (const ConstantPointerRef *CPR = dyn_cast(V)) + return getSlot(CPR->getValue()); + + return -1; } @@ -333,6 +338,10 @@ int SlotCalculator::getOrCreateSlot(const Value *V) { int SlotNo = getSlot(V); // Check to see if it's already in! if (SlotNo != -1) return SlotNo; + // Do not number ConstantPointerRef's at all. They are an abomination. + if (const ConstantPointerRef *CPR = dyn_cast(V)) + return getOrCreateSlot(CPR->getValue()); + if (!isa(V)) if (const Constant *C = dyn_cast(V)) { // If we are emitting a bytecode file, do not index the characters that