Do not externalize unnamed GlobalValues

It doesn't make sense and the JIT crashes, see upstream bug report
https://github.com/llvm/llvm-project/issues/54813
This commit is contained in:
Jonas Hahnfeld 2022-04-08 15:52:08 +02:00 committed by jenkins
parent b20a403638
commit 1cba6d415c

View File

@ -43,9 +43,15 @@ namespace {
if (GV.isDeclaration())
return false; // no change.
// GV is a definition.
// It doesn't make sense to keep unnamed constants, we wouldn't know how
// to reference them anyway.
if (!GV.hasName())
return false;
if (GV.getName().startswith(".str"))
return false;
// GV is a definition.
llvm::GlobalValue::LinkageTypes LT = GV.getLinkage();
if (!GV.isDiscardableIfUnused(LT))