diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2013-09-16 01:08:15 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2013-09-16 01:08:15 +0000 |
commit | 1e3037f0be430ef2339838bbdede11f45658bd82 (patch) | |
tree | 685847478f3c9e31c3e1fa7f63f5f605e5f43f80 /lib/Bitcode/Reader | |
parent | fabfb5d5880354983c89c6f475312dd359e5bb03 (diff) | |
download | external_llvm-1e3037f0be430ef2339838bbdede11f45658bd82.zip external_llvm-1e3037f0be430ef2339838bbdede11f45658bd82.tar.gz external_llvm-1e3037f0be430ef2339838bbdede11f45658bd82.tar.bz2 |
Implement function prefix data as an IR feature.
Previous discussion:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-July/063909.html
Differential Revision: http://llvm-reviews.chandlerc.com/D1191
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190773 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode/Reader')
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.cpp | 18 | ||||
-rw-r--r-- | lib/Bitcode/Reader/BitcodeReader.h | 1 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index ca432fd..0c20163 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -1106,9 +1106,11 @@ uint64_t BitcodeReader::decodeSignRotatedValue(uint64_t V) { bool BitcodeReader::ResolveGlobalAndAliasInits() { std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInitWorklist; std::vector<std::pair<GlobalAlias*, unsigned> > AliasInitWorklist; + std::vector<std::pair<Function*, unsigned> > FunctionPrefixWorklist; GlobalInitWorklist.swap(GlobalInits); AliasInitWorklist.swap(AliasInits); + FunctionPrefixWorklist.swap(FunctionPrefixes); while (!GlobalInitWorklist.empty()) { unsigned ValID = GlobalInitWorklist.back().second; @@ -1136,6 +1138,20 @@ bool BitcodeReader::ResolveGlobalAndAliasInits() { } AliasInitWorklist.pop_back(); } + + while (!FunctionPrefixWorklist.empty()) { + unsigned ValID = FunctionPrefixWorklist.back().second; + if (ValID >= ValueList.size()) { + FunctionPrefixes.push_back(FunctionPrefixWorklist.back()); + } else { + if (Constant *C = dyn_cast<Constant>(ValueList[ValID])) + FunctionPrefixWorklist.back().first->setPrefixData(C); + else + return Error("Function prefix is not a constant!"); + } + FunctionPrefixWorklist.pop_back(); + } + return false; } @@ -1881,6 +1897,8 @@ bool BitcodeReader::ParseModule(bool Resume) { if (Record.size() > 9) UnnamedAddr = Record[9]; Func->setUnnamedAddr(UnnamedAddr); + if (Record.size() > 10 && Record[10] != 0) + FunctionPrefixes.push_back(std::make_pair(Func, Record[10]-1)); ValueList.push_back(Func); // If this is a function with a body, remember the prototype we are diff --git a/lib/Bitcode/Reader/BitcodeReader.h b/lib/Bitcode/Reader/BitcodeReader.h index b095447..9533597 100644 --- a/lib/Bitcode/Reader/BitcodeReader.h +++ b/lib/Bitcode/Reader/BitcodeReader.h @@ -142,6 +142,7 @@ class BitcodeReader : public GVMaterializer { std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; std::vector<std::pair<GlobalAlias*, unsigned> > AliasInits; + std::vector<std::pair<Function*, unsigned> > FunctionPrefixes; /// MAttributes - The set of attributes by index. Index zero in the /// file is for null, and is thus not represented here. As such all indices |