@@ -564,11 +564,11 @@ namespace {
564
564
// / @return The index to the heap HeapName for the memory access.
565
565
std::string getHeapNameAndIndex (const Value *Ptr , const char **HeapName);
566
566
567
- // Like getHeapNameAndIndex(), but uses the given memory operation size instead of the one from Ptr.
568
- std::string getHeapNameAndIndex (const Value *Ptr , const char **HeapName, unsigned Bytes);
567
+ // Like getHeapNameAndIndex(), but uses the given memory operation size and whether it is an Integer instead of the type of Ptr.
568
+ std::string getHeapNameAndIndex (const Value *Ptr , const char **HeapName, unsigned Bytes, bool Integer );
569
569
570
570
// / Like getHeapNameAndIndex(), but for global variables only.
571
- std::string getHeapNameAndIndexToGlobal (const GlobalVariable *GV, const Type *T , const char **HeapName);
571
+ std::string getHeapNameAndIndexToGlobal (const GlobalVariable *GV, unsigned Bytes, bool Integer , const char **HeapName);
572
572
573
573
// / Like getHeapNameAndIndex(), but for pointers represented in string expression form.
574
574
static std::string getHeapNameAndIndexToPtr (const std::string& Ptr , unsigned Bytes, bool Integer, const char **HeapName);
@@ -982,12 +982,10 @@ static inline const char *getHeapShiftStr(int Bytes)
982
982
}
983
983
}
984
984
985
- std::string JSWriter::getHeapNameAndIndexToGlobal (const GlobalVariable *GV, const Type *T , const char **HeapName)
985
+ std::string JSWriter::getHeapNameAndIndexToGlobal (const GlobalVariable *GV, unsigned Bytes, bool Integer , const char **HeapName)
986
986
{
987
- Type *t = cast<PointerType>(T)->getElementType ();
988
- unsigned Bytes = DL->getTypeAllocSize (t);
989
987
unsigned Addr = getGlobalAddress (GV->getName ().str ());
990
- *HeapName = getHeapName (Bytes, t-> isIntegerTy () || t-> isPointerTy () );
988
+ *HeapName = getHeapName (Bytes, Integer );
991
989
if (!Relocatable) {
992
990
return utostr (Addr >> getHeapShift (Bytes));
993
991
} else {
@@ -1001,24 +999,21 @@ std::string JSWriter::getHeapNameAndIndexToPtr(const std::string& Ptr, unsigned
1001
999
return Ptr + getHeapShiftStr (Bytes);
1002
1000
}
1003
1001
1004
- std::string JSWriter::getHeapNameAndIndex (const Value *Ptr , const char **HeapName, unsigned Bytes)
1002
+ std::string JSWriter::getHeapNameAndIndex (const Value *Ptr , const char **HeapName, unsigned Bytes, bool Integer )
1005
1003
{
1006
- Type *t = cast<PointerType>(Ptr ->getType ())->getElementType ();
1007
-
1008
1004
const GlobalVariable *GV;
1009
1005
if ((GV = dyn_cast<GlobalVariable>(Ptr ->stripPointerCasts ())) && GV->hasInitializer ()) {
1010
1006
// Note that we use the type of the pointer, as it might be a bitcast of the underlying global. We need the right type.
1011
- return getHeapNameAndIndexToGlobal (GV, Ptr -> getType () , HeapName);
1007
+ return getHeapNameAndIndexToGlobal (GV, Bytes, Integer , HeapName);
1012
1008
} else {
1013
- return getHeapNameAndIndexToPtr (getValueAsStr (Ptr ), Bytes, t-> isIntegerTy () || t-> isPointerTy () , HeapName);
1009
+ return getHeapNameAndIndexToPtr (getValueAsStr (Ptr ), Bytes, Integer , HeapName);
1014
1010
}
1015
1011
}
1016
1012
1017
1013
std::string JSWriter::getHeapNameAndIndex (const Value *Ptr , const char **HeapName)
1018
1014
{
1019
1015
Type *t = cast<PointerType>(Ptr ->getType ())->getElementType ();
1020
- unsigned Bytes = DL->getTypeAllocSize (t);
1021
- return getHeapNameAndIndex (Ptr , HeapName, Bytes);
1016
+ return getHeapNameAndIndex (Ptr , HeapName, DL->getTypeAllocSize (t), t->isIntegerTy () || t->isPointerTy ());
1022
1017
}
1023
1018
1024
1019
static const char *heapNameToAtomicTypeName (const char *HeapName)
@@ -1293,7 +1288,7 @@ std::string JSWriter::getHeapAccess(const std::string& Name, unsigned Bytes, boo
1293
1288
1294
1289
std::string JSWriter::getShiftedPtr (const Value *Ptr , unsigned Bytes) {
1295
1290
const char *HeapName = 0 ; // unused
1296
- return getHeapNameAndIndex (Ptr , &HeapName, Bytes);
1291
+ return getHeapNameAndIndex (Ptr , &HeapName, Bytes, true /* Integer; doesn't matter */ );
1297
1292
}
1298
1293
1299
1294
std::string JSWriter::getPtrUse (const Value* Ptr ) {
0 commit comments