aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-06 07:11:04 +0000
committerChris Lattner <sabre@nondot.org>2005-11-06 07:11:04 +0000
commit8eb52dd7341909b16e961371a48eb353150a45b1 (patch)
treee6f3b2a55d3b48fee17fc2ca68985c1b28123378 /lib/Bytecode/Reader/Reader.cpp
parentabdf0f5327010c880612ff5d74a298a330ccf8fd (diff)
Read/write global variable alignments if present
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24216 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 917727098e..26bd68c344 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -1903,6 +1903,17 @@ void BytecodeReader::ParseModuleGlobalInfo() {
bool isConstant = VarType & 1;
bool hasInitializer = VarType & 2;
GlobalValue::LinkageTypes Linkage;
+ unsigned Alignment = 0;
+
+ // An extension word is present when linkage = 3 (internal) and hasinit = 0.
+ if (LinkageID == 3 && !hasInitializer) {
+ unsigned ExtWord = read_vbr_uint();
+ // The extension word has this format: bit 0 = has initializer, bit 1-3 =
+ // linkage, bit 4-8 = alignment (log2), bits 10+ = future use.
+ hasInitializer = ExtWord & 1;
+ LinkageID = (ExtWord >> 1) & 7;
+ Alignment = (1 << ((ExtWord >> 4) & 31)) >> 1;
+ }
switch (LinkageID) {
case 0: Linkage = GlobalValue::ExternalLinkage; break;
@@ -1930,6 +1941,7 @@ void BytecodeReader::ParseModuleGlobalInfo() {
// Create the global variable...
GlobalVariable *GV = new GlobalVariable(ElTy, isConstant, Linkage,
0, "", TheModule);
+ GV->setAlignment(Alignment);
insertValue(GV, SlotNo, ModuleValues);
unsigned initSlot = 0;