summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-10-16 18:28:50 +0000
committerChris Lattner <sabre@nondot.org>2003-10-16 18:28:50 +0000
commit2d05c60bac33d65c9f47b3de66534eeccab787e1 (patch)
tree51701c56f9280a1370f2906e68eb071b7aec5a31 /llvm/lib/Bytecode/Reader/Reader.cpp
parent06bd29b53b32c7e3497115ef0f2e11868c2ad154 (diff)
downloadbcm5719-llvm-2d05c60bac33d65c9f47b3de66534eeccab787e1.tar.gz
bcm5719-llvm-2d05c60bac33d65c9f47b3de66534eeccab787e1.zip
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. llvm-svn: 9170
Diffstat (limited to 'llvm/lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/Reader.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index e8e1afd52e8..29d0a71b589 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/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#
OpenPOWER on IntegriCloud