diff options
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index b3df3a7..349d40e 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -41,7 +41,6 @@ #include "llvm/IR/GVMaterializer.h" #include "llvm/IR/GlobalAlias.h" #include "llvm/IR/GlobalIFunc.h" -#include "llvm/IR/GlobalIndirectSymbol.h" #include "llvm/IR/GlobalObject.h" #include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalVariable.h" @@ -500,7 +499,7 @@ class BitcodeReader : public BitcodeReaderBase, public GVMaterializer { SmallVector<Instruction *, 64> InstructionList; std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInits; - std::vector<std::pair<GlobalIndirectSymbol *, unsigned>> IndirectSymbolInits; + std::vector<std::pair<GlobalValue *, unsigned>> IndirectSymbolInits; struct FunctionOperandInfo { Function *F; @@ -2253,8 +2252,7 @@ uint64_t BitcodeReader::decodeSignRotatedValue(uint64_t V) { /// Resolve all of the initializers for global values and aliases that we can. Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() { std::vector<std::pair<GlobalVariable *, unsigned>> GlobalInitWorklist; - std::vector<std::pair<GlobalIndirectSymbol *, unsigned>> - IndirectSymbolInitWorklist; + std::vector<std::pair<GlobalValue *, unsigned>> IndirectSymbolInitWorklist; std::vector<FunctionOperandInfo> FunctionOperandWorklist; GlobalInitWorklist.swap(GlobalInits); @@ -2283,10 +2281,16 @@ Error BitcodeReader::resolveGlobalAndIndirectSymbolInits() { Constant *C = dyn_cast_or_null<Constant>(ValueList[ValID]); if (!C) return error("Expected a constant"); - GlobalIndirectSymbol *GIS = IndirectSymbolInitWorklist.back().first; - if (isa<GlobalAlias>(GIS) && C->getType() != GIS->getType()) - return error("Alias and aliasee types don't match"); - GIS->setIndirectSymbol(C); + GlobalValue *GV = IndirectSymbolInitWorklist.back().first; + if (auto *GA = dyn_cast<GlobalAlias>(GV)) { + if (C->getType() != GV->getType()) + return error("Alias and aliasee types don't match"); + GA->setAliasee(C); + } else if (auto *GI = dyn_cast<GlobalIFunc>(GV)) { + GI->setResolver(C); + } else { + return error("Expected an alias or an ifunc"); + } } IndirectSymbolInitWorklist.pop_back(); } @@ -3118,8 +3122,7 @@ Error BitcodeReader::globalCleanup() { // Force deallocation of memory for these vectors to favor the client that // want lazy deserialization. std::vector<std::pair<GlobalVariable *, unsigned>>().swap(GlobalInits); - std::vector<std::pair<GlobalIndirectSymbol *, unsigned>>().swap( - IndirectSymbolInits); + std::vector<std::pair<GlobalValue *, unsigned>>().swap(IndirectSymbolInits); return Error::success(); } @@ -3499,7 +3502,7 @@ Error BitcodeReader::parseGlobalIndirectSymbolRecord( auto Val = Record[OpNum++]; auto Linkage = Record[OpNum++]; - GlobalIndirectSymbol *NewGA; + GlobalValue *NewGA; if (BitCode == bitc::MODULE_CODE_ALIAS || BitCode == bitc::MODULE_CODE_ALIAS_OLD) NewGA = GlobalAlias::create(Ty, AddrSpace, getDecodedLinkage(Linkage), Name, |