Skip to content

Commit a6aa81e

Browse files
paigealegfxbot
authored andcommitted
In elfpackager we want to ensure the output is always the same when the same file gets passed in. Currently it would give different outputs because we were using std::sets with pointer values. These pointer values are inconsistent run to run. The fix was to add StringRef which remain constant
Change-Id: I80d908cdc6e7120ca98d76a0315c1cc90ce21f60
1 parent ae8afb8 commit a6aa81e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

IGC/ElfPackager/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void CreateElfSection(CLElfLib::CElfWriter* pWriter, CLElfLib::SSectionNode sect
105105
std::unique_ptr<Module> LocalCloneModule(
106106
const Module *M, ValueToValueMapTy &VMap,
107107
std::vector<GlobalValue*> &ExtractValues,
108-
std::map<const llvm::Function*, std::set<const llvm::GlobalVariable*>> &FuncMap) {
108+
std::map<const llvm::Function*, std::set<StringRef>> &FuncMap) {
109109
// First off, we need to create the new module.
110110
std::unique_ptr<Module> New =
111111
llvm::make_unique<Module>(M->getModuleIdentifier(), M->getContext());
@@ -177,7 +177,7 @@ std::unique_ptr<Module> LocalCloneModule(
177177
auto funcGlobalSet = FuncMap[&*I];
178178
for (auto &global_Iterator : funcGlobalSet)
179179
{
180-
mapGlobal(global_Iterator);
180+
mapGlobal(M->getNamedGlobal(global_Iterator));
181181
}
182182

183183

@@ -301,15 +301,15 @@ int main(int argc, char *argv[])
301301
}
302302
}
303303

304-
std::map<const llvm::Function*, std::set<const llvm::GlobalVariable*>> FuncToGlobalsMap;
304+
std::map<const llvm::Function*, std::set<StringRef>> FuncToGlobalsMap;
305305

306306
for (auto &iterator3 : GlobalList)
307307
{
308308
std::function<void(User*)> findUsers = [&](User* U)
309309
{
310310
if (auto inst = dyn_cast<Instruction>(U))
311311
{
312-
FuncToGlobalsMap[inst->getParent()->getParent()].insert(&iterator3);
312+
FuncToGlobalsMap[inst->getParent()->getParent()].insert(iterator3.getName());
313313
return;
314314
}
315315
else if (auto inst = dyn_cast<GlobalValue>(U))

0 commit comments

Comments
 (0)