Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tslang/include/TypeScript/LowerToLLVM/LLVMCodeHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class LLVMCodeHelper : public LLVMCodeHelperBase
// keyed by the concrete type rather than by the name: every class reports the name
// "class", but each needs its own record, which is the point of having one at all
std::stringstream varName;
varName << "td_" << (size_t)hash_value(type) << variant.str() << "_" << name;
varName << "td_" << MLIRHelper::hashOfType(type) << variant.str() << "_" << name;

TypeConverterHelper tch(typeConverter);
auto blockWordType = getHeapBlockWordType();
Expand Down
14 changes: 7 additions & 7 deletions tslang/include/TypeScript/LowerToLLVM/OwnershipRoutineLogic.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class OwnershipRoutineLogic
}

std::stringstream nameStream;
nameStream << "tsrelrec_" << (size_t)hash_value(type);
nameStream << "tsrelrec_" << MLIRHelper::hashOfType(type);
for (auto index : borrowed)
{
nameStream << "_" << index;
Expand Down Expand Up @@ -586,7 +586,7 @@ class OwnershipRoutineLogic
}

std::stringstream nameStream;
nameStream << "tsshr_" << (size_t)hash_value(type);
nameStream << "tsshr_" << MLIRHelper::hashOfType(type);
auto name = nameStream.str();

auto parentModule = op->getParentOfType<ModuleOp>();
Expand Down Expand Up @@ -627,7 +627,7 @@ class OwnershipRoutineLogic
}

std::stringstream nameStream;
nameStream << "tsshrbox_" << (size_t)hash_value(captureRefType);
nameStream << "tsshrbox_" << MLIRHelper::hashOfType(captureRefType);
auto name = nameStream.str();

auto parentModule = op->getParentOfType<ModuleOp>();
Expand Down Expand Up @@ -720,7 +720,7 @@ class OwnershipRoutineLogic
std::string getRoutineName(mlir::Type type)
{
std::stringstream ss;
ss << "tsrel_" << (size_t)hash_value(type);
ss << "tsrel_" << MLIRHelper::hashOfType(type);
return ss.str();
}

Expand All @@ -745,7 +745,7 @@ class OwnershipRoutineLogic
}

std::stringstream ss;
ss << "tsret_" << (size_t)hash_value(type);
ss << "tsret_" << MLIRHelper::hashOfType(type);
return ss.str();
}

Expand All @@ -766,7 +766,7 @@ class OwnershipRoutineLogic
}

std::stringstream nameStream;
nameStream << prefix.str() << (size_t)hash_value(type);
nameStream << prefix.str() << MLIRHelper::hashOfType(type);
auto name = nameStream.str();

auto parentModule = op->getParentOfType<ModuleOp>();
Expand Down Expand Up @@ -1518,7 +1518,7 @@ class OwnershipRoutineLogic
bool holdsNothing = false, bool borrowsContents = false)
{
std::stringstream nameStream;
nameStream << prefix.str() << (size_t)hash_value(captureRefType);
nameStream << prefix.str() << MLIRHelper::hashOfType(captureRefType);
auto name = nameStream.str();

auto parentModule = op->getParentOfType<ModuleOp>();
Expand Down
11 changes: 11 additions & 0 deletions tslang/include/TypeScript/MLIRLogic/MLIRHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,17 @@ class MLIRHelper
return getCallSiteLocation(callee.getDefiningOp()->getLoc(), caller, enable);
}

// A hash of a type for a symbol's name: of its text, as MLIR prints it. hash_value(type) hashes
// the type's storage address, weakly mixed: names made from it were different in every run, and
// two types could meet in one name - and so share a type descriptor or a release routine.
static uint64_t hashOfType(mlir::Type type)
{
std::string text;
llvm::raw_string_ostream os(text);
os << type;
return llvm::xxh3_64bits(text);
}

static void getAnonymousNameStep(std::stringstream &ssName, mlir::Location loc)
{
mlir::TypeSwitch<mlir::LocationAttr>(loc)
Expand Down
2 changes: 1 addition & 1 deletion tslang/lib/TypeScript/MLIRGenImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -14050,7 +14050,7 @@ class MLIRGenImpl
StringRef interfaceVTableNameForObject(mlir_ts::ObjectType objectType, InterfaceInfo::TypePtr newInterfacePtr)
{
std::stringstream ss;
ss << hash_value(objectType);
ss << MLIRHelper::hashOfType(objectType);

return concat(newInterfacePtr->fullName, ss.str().c_str(), VTABLE_NAME);
}
Expand Down
Loading