diff options
author | Nikita Popov <npopov@redhat.com> | 2021-12-17 20:25:32 +0100 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2021-12-17 20:27:37 +0100 |
commit | 18ab892ff7e9032914ff7fdb07685d5945c84fef (patch) | |
tree | 8c83f372bfd0345093ab2c4f2746d9a33cc2aa3b /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 7de813e14cb072251d4995cfdd871388ecd93f61 (diff) | |
download | llvm-18ab892ff7e9032914ff7fdb07685d5945c84fef.zip llvm-18ab892ff7e9032914ff7fdb07685d5945c84fef.tar.gz llvm-18ab892ff7e9032914ff7fdb07685d5945c84fef.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 909af12..d914152 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) |