[llvm] 18ab892 - [Bitcode] Avoid setting invalid comdat pointer (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 17 11:27:47 PST 2021
Author: Nikita Popov
Date: 2021-12-17T20:27:37+01:00
New Revision: 18ab892ff7e9032914ff7fdb07685d5945c84fef
URL: https://github.com/llvm/llvm-project/commit/18ab892ff7e9032914ff7fdb07685d5945c84fef
DIFF: https://github.com/llvm/llvm-project/commit/18ab892ff7e9032914ff7fdb07685d5945c84fef.diff
LOG: [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.
Added:
Modified:
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 909af126cd9a..d914152c9ea0 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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)
More information about the llvm-commits
mailing list