diff options
author | Chris Lattner <sabre@nondot.org> | 2003-10-16 18:28:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-10-16 18:28:50 +0000 |
commit | 6b25242a4ba80e8c3a8a2664eefeba9c69814012 (patch) | |
tree | 468303cb62487b68d1fc360524994071fd1f5722 /lib/Bytecode/Reader/Reader.cpp | |
parent | 9eb52a5c2913ebb105463e2fe7500664902a4468 (diff) |
Add support for 'weak' linkage.
For now, we translate linkonce into weak linkage in the bytecode format because
we don't have enough bits to represent it. We will rev the bytecode version
soon anyways, so this will be fixed in the near future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9170 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index e8e1afd52e..29d0a71b58 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -318,7 +318,12 @@ void BytecodeParser::materializeFunction(Function* F) { throw std::string("ParseFunction: Error reading from buffer."); if (LinkageType & ~0x3) throw std::string("Invalid linkage type for Function."); - Linkage = (GlobalValue::LinkageTypes)LinkageType; + switch (LinkageType) { + case 0: Linkage = GlobalValue::ExternalLinkage; break; + case 1: Linkage = GlobalValue::WeakLinkage; break; + case 2: Linkage = GlobalValue::AppendingLinkage; break; + case 3: Linkage = GlobalValue::InternalLinkage; break; + } } else { // We used to only support two linkage models: internal and external unsigned isInternal; @@ -436,7 +441,12 @@ void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf, // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, // bit2,3 = Linkage, bit4+ = slot# SlotNo = VarType >> 4; - Linkage = (GlobalValue::LinkageTypes)((VarType >> 2) & 3); + switch ((VarType >> 2) & 3) { + case 0: Linkage = GlobalValue::ExternalLinkage; break; + case 1: Linkage = GlobalValue::WeakLinkage; break; + case 2: Linkage = GlobalValue::AppendingLinkage; break; + case 3: Linkage = GlobalValue::InternalLinkage; break; + } } else { // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, // bit2 = isInternal, bit3+ = slot# |