[Bitcode] Avoid setting invalid comdat pointer (NFC)
Instead track global objects with implicit comdat in a separate set. The current approach of temporarily assigning an invalid comdat pointer is incompatible with D115864.
This commit is contained in:
@@ -488,6 +488,7 @@ class BitcodeReader : public BitcodeReaderBase, public GVMaterializer {
|
||||
BitcodeReaderValueList ValueList;
|
||||
Optional<MetadataLoader> MDLoader;
|
||||
std::vector<Comdat *> ComdatList;
|
||||
DenseSet<GlobalObject *> ImplicitComdatObjects;
|
||||
SmallVector<Instruction *, 64> InstructionList;
|
||||
|
||||
std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInits;
|
||||
@@ -2038,14 +2039,8 @@ Expected<Value *> BitcodeReader::recordValue(SmallVectorImpl<uint64_t> &Record,
|
||||
return error("Invalid value name");
|
||||
V->setName(NameStr);
|
||||
auto *GO = dyn_cast<GlobalObject>(V);
|
||||
if (GO) {
|
||||
if (GO->getComdat() == reinterpret_cast<Comdat *>(1)) {
|
||||
if (TT.supportsCOMDAT())
|
||||
GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
|
||||
else
|
||||
GO->setComdat(nullptr);
|
||||
}
|
||||
}
|
||||
if (GO && ImplicitComdatObjects.contains(GO) && TT.supportsCOMDAT())
|
||||
GO->setComdat(TheModule->getOrInsertComdat(V->getName()));
|
||||
return V;
|
||||
}
|
||||
|
||||
@@ -3293,7 +3288,7 @@ Error BitcodeReader::parseGlobalVarRecord(ArrayRef<uint64_t> Record) {
|
||||
NewGV->setComdat(ComdatList[ComdatID - 1]);
|
||||
}
|
||||
} else if (hasImplicitComdat(RawLinkage)) {
|
||||
NewGV->setComdat(reinterpret_cast<Comdat *>(1));
|
||||
ImplicitComdatObjects.insert(NewGV);
|
||||
}
|
||||
|
||||
if (Record.size() > 12) {
|
||||
@@ -3427,7 +3422,7 @@ Error BitcodeReader::parseFunctionRecord(ArrayRef<uint64_t> Record) {
|
||||
Func->setComdat(ComdatList[ComdatID - 1]);
|
||||
}
|
||||
} else if (hasImplicitComdat(RawLinkage)) {
|
||||
Func->setComdat(reinterpret_cast<Comdat *>(1));
|
||||
ImplicitComdatObjects.insert(Func);
|
||||
}
|
||||
|
||||
if (Record.size() > 13)
|
||||
|
||||
Reference in New Issue
Block a user