summaryrefslogtreecommitdiff
path: root/include/llvm/Object/IRSymtab.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/llvm/Object/IRSymtab.h')
-rw-r--r--include/llvm/Object/IRSymtab.h49
1 files changed, 26 insertions, 23 deletions
diff --git a/include/llvm/Object/IRSymtab.h b/include/llvm/Object/IRSymtab.h
index cde6f3b0f651..be0f02aa7f17 100644
--- a/include/llvm/Object/IRSymtab.h
+++ b/include/llvm/Object/IRSymtab.h
@@ -41,9 +41,9 @@ typedef support::ulittle32_t Word;
/// A reference to a string in the string table.
struct Str {
- Word Offset;
+ Word Offset, Size;
StringRef get(StringRef Strtab) const {
- return Strtab.data() + Offset;
+ return {Strtab.data() + Offset, Size};
}
};
@@ -59,6 +59,9 @@ template <typename T> struct Range {
/// table.
struct Module {
Word Begin, End;
+
+ /// The index of the first Uncommon for this Module.
+ Word UncBegin;
};
/// This is equivalent to an IR comdat.
@@ -82,7 +85,8 @@ struct Symbol {
Word Flags;
enum FlagBits {
FB_visibility, // 2 bits
- FB_undefined = FB_visibility + 2,
+ FB_has_uncommon = FB_visibility + 2,
+ FB_undefined,
FB_weak,
FB_common,
FB_indirect,
@@ -94,10 +98,6 @@ struct Symbol {
FB_unnamed_addr,
FB_executable,
};
-
- /// The index into the Uncommon table, or -1 if this symbol does not have an
- /// Uncommon.
- Word UncommonIndex;
};
/// This data structure contains rarely used symbol fields and is optionally
@@ -249,15 +249,9 @@ public:
/// Reader::module_symbols().
class Reader::SymbolRef : public Symbol {
const storage::Symbol *SymI, *SymE;
+ const storage::Uncommon *UncI;
const Reader *R;
-public:
- SymbolRef(const storage::Symbol *SymI, const storage::Symbol *SymE,
- const Reader *R)
- : SymI(SymI), SymE(SymE), R(R) {
- read();
- }
-
void read() {
if (SymI == SymE)
return;
@@ -267,16 +261,24 @@ public:
ComdatIndex = SymI->ComdatIndex;
Flags = SymI->Flags;
- uint32_t UncI = SymI->UncommonIndex;
- if (UncI != -1u) {
- const storage::Uncommon &Unc = R->Uncommons[UncI];
- CommonSize = Unc.CommonSize;
- CommonAlign = Unc.CommonAlign;
- COFFWeakExternFallbackName = R->str(Unc.COFFWeakExternFallbackName);
+ if (Flags & (1 << storage::Symbol::FB_has_uncommon)) {
+ CommonSize = UncI->CommonSize;
+ CommonAlign = UncI->CommonAlign;
+ COFFWeakExternFallbackName = R->str(UncI->COFFWeakExternFallbackName);
}
}
+
+public:
+ SymbolRef(const storage::Symbol *SymI, const storage::Symbol *SymE,
+ const storage::Uncommon *UncI, const Reader *R)
+ : SymI(SymI), SymE(SymE), UncI(UncI), R(R) {
+ read();
+ }
+
void moveNext() {
++SymI;
+ if (Flags & (1 << storage::Symbol::FB_has_uncommon))
+ ++UncI;
read();
}
@@ -284,15 +286,16 @@ public:
};
inline Reader::symbol_range Reader::symbols() const {
- return {SymbolRef(Symbols.begin(), Symbols.end(), this),
- SymbolRef(Symbols.end(), Symbols.end(), this)};
+ return {SymbolRef(Symbols.begin(), Symbols.end(), Uncommons.begin(), this),
+ SymbolRef(Symbols.end(), Symbols.end(), nullptr, this)};
}
inline Reader::symbol_range Reader::module_symbols(unsigned I) const {
const storage::Module &M = Modules[I];
const storage::Symbol *MBegin = Symbols.begin() + M.Begin,
*MEnd = Symbols.begin() + M.End;
- return {SymbolRef(MBegin, MEnd, this), SymbolRef(MEnd, MEnd, this)};
+ return {SymbolRef(MBegin, MEnd, Uncommons.begin() + M.UncBegin, this),
+ SymbolRef(MEnd, MEnd, nullptr, this)};
}
}