aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Bitcode
diff options
context:
space:
mode:
authorDuncan Sands <baldrick@free.fr>2009-03-07 15:45:40 +0000
committerDuncan Sands <baldrick@free.fr>2009-03-07 15:45:40 +0000
commit667d4b8de6dea70195ff12ef39a4deebffa2f5c7 (patch)
tree7c3eab01e7683698c4818410c678d6af0ebfa56b /lib/Bitcode
parent0dd2a6a89f49438b239638ab147ac5746d6c32c3 (diff)
downloadexternal_llvm-667d4b8de6dea70195ff12ef39a4deebffa2f5c7.zip
external_llvm-667d4b8de6dea70195ff12ef39a4deebffa2f5c7.tar.gz
external_llvm-667d4b8de6dea70195ff12ef39a4deebffa2f5c7.tar.bz2
Introduce new linkage types linkonce_odr, weak_odr, common_odr
and extern_weak_odr. These are the same as the non-odr versions, except that they indicate that the global will only be overridden by an *equivalent* global. In C, a function with weak linkage can be overridden by a function which behaves completely differently. This means that IP passes have to skip weak functions, since any deductions made from the function definition might be wrong, since the definition could be replaced by something completely different at link time. This is not allowed in C++, thanks to the ODR (One-Definition-Rule): if a function is replaced by another at link-time, then the new function must be the same as the original function. If a language knows that a function or other global can only be overridden by an equivalent global, it can give it the weak_odr linkage type, and the optimizers will understand that it is alright to make deductions based on the function body. The code generators on the other hand map weak and weak_odr linkage to the same thing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66339 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bitcode')
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp12
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp12
2 files changed, 16 insertions, 8 deletions
diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp
index 2ddfbe3..0fe6fc6 100644
--- a/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -59,15 +59,19 @@ static GlobalValue::LinkageTypes GetDecodedLinkage(unsigned Val) {
switch (Val) {
default: // Map unknown/new linkages to external
case 0: return GlobalValue::ExternalLinkage;
- case 1: return GlobalValue::WeakLinkage;
+ case 1: return GlobalValue::WeakAnyLinkage;
case 2: return GlobalValue::AppendingLinkage;
case 3: return GlobalValue::InternalLinkage;
- case 4: return GlobalValue::LinkOnceLinkage;
+ case 4: return GlobalValue::LinkOnceAnyLinkage;
case 5: return GlobalValue::DLLImportLinkage;
case 6: return GlobalValue::DLLExportLinkage;
- case 7: return GlobalValue::ExternalWeakLinkage;
- case 8: return GlobalValue::CommonLinkage;
+ case 7: return GlobalValue::ExternalWeakAnyLinkage;
+ case 8: return GlobalValue::CommonAnyLinkage;
case 9: return GlobalValue::PrivateLinkage;
+ case 10: return GlobalValue::WeakODRLinkage;
+ case 11: return GlobalValue::LinkOnceODRLinkage;
+ case 12: return GlobalValue::ExternalWeakODRLinkage;
+ case 13: return GlobalValue::CommonODRLinkage;
}
}
diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp
index 5633f0f..fefffbe 100644
--- a/lib/Bitcode/Writer/BitcodeWriter.cpp
+++ b/lib/Bitcode/Writer/BitcodeWriter.cpp
@@ -276,15 +276,19 @@ static unsigned getEncodedLinkage(const GlobalValue *GV) {
default: assert(0 && "Invalid linkage!");
case GlobalValue::GhostLinkage: // Map ghost linkage onto external.
case GlobalValue::ExternalLinkage: return 0;
- case GlobalValue::WeakLinkage: return 1;
+ case GlobalValue::WeakAnyLinkage: return 1;
case GlobalValue::AppendingLinkage: return 2;
case GlobalValue::InternalLinkage: return 3;
- case GlobalValue::LinkOnceLinkage: return 4;
+ case GlobalValue::LinkOnceAnyLinkage: return 4;
case GlobalValue::DLLImportLinkage: return 5;
case GlobalValue::DLLExportLinkage: return 6;
- case GlobalValue::ExternalWeakLinkage: return 7;
- case GlobalValue::CommonLinkage: return 8;
+ case GlobalValue::ExternalWeakAnyLinkage: return 7;
+ case GlobalValue::CommonAnyLinkage: return 8;
case GlobalValue::PrivateLinkage: return 9;
+ case GlobalValue::WeakODRLinkage: return 10;
+ case GlobalValue::LinkOnceODRLinkage: return 11;
+ case GlobalValue::ExternalWeakODRLinkage: return 12;
+ case GlobalValue::CommonODRLinkage: return 13;
}
}