Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit beeb70a

Browse files
committed
fix relocation in getPtrUse
1 parent be87c2f commit beeb70a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/Target/JSBackend/JSBackend.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -1053,21 +1053,23 @@ std::string JSWriter::getPtrUse(const Value* Ptr) {
10531053
Type *t = cast<PointerType>(Ptr->getType())->getElementType();
10541054
unsigned Bytes = DL->getTypeAllocSize(t);
10551055
if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Ptr)) {
1056-
std::string text = "";
10571056
unsigned Addr = getGlobalAddress(GV->getName().str());
1057+
if (Relocatable) {
1058+
return getHeapAccess(relocateGlobal(utostr(Addr)), Bytes, t->isIntegerTy() || t->isPointerTy());
1059+
}
10581060
switch (Bytes) {
10591061
default: llvm_unreachable("Unsupported type");
1060-
case 8: return "HEAPF64[" + relocateGlobal(utostr(Addr >> 3)) + "]";
1062+
case 8: return "HEAPF64[" + utostr(Addr >> 3) + "]";
10611063
case 4: {
10621064
if (t->isIntegerTy() || t->isPointerTy()) {
1063-
return "HEAP32[" + relocateGlobal(utostr(Addr >> 2)) + "]";
1065+
return "HEAP32[" + utostr(Addr >> 2) + "]";
10641066
} else {
10651067
assert(t->isFloatingPointTy());
1066-
return "HEAPF32[" + relocateGlobal(utostr(Addr >> 2)) + "]";
1068+
return "HEAPF32[" + utostr(Addr >> 2) + "]";
10671069
}
10681070
}
1069-
case 2: return "HEAP16[" + relocateGlobal(utostr(Addr >> 1)) + "]";
1070-
case 1: return "HEAP8[" + relocateGlobal(utostr(Addr)) + "]";
1071+
case 2: return "HEAP16[" + utostr(Addr >> 1) + "]";
1072+
case 1: return "HEAP8[" + utostr(Addr) + "]";
10711073
}
10721074
}
10731075
return getHeapAccess(getValueAsStr(Ptr), Bytes, t->isIntegerTy() || t->isPointerTy());

0 commit comments

Comments
 (0)