diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-14 16:58:26 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-14 16:58:26 -0700 |
commit | 263d9c76d6975df0a864396919c326063380f75e (patch) | |
tree | 2833f0f249ec438391f1d0e282470e8e9f16e5fc /lib/Transforms/NaCl/StripAttributes.cpp | |
parent | c31b941a4fc4c995cbc40d5f4be6705d61eda011 (diff) |
PNaCl ABI: Convert "private" linkage to "internal"
This simplifies the ABI by reducing the number of linkage types we
have to check for and represent in the wire format.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3495
TEST=*.ll tests + PNaCl toolchain trybots
Review URL: https://codereview.chromium.org/17084003
Diffstat (limited to 'lib/Transforms/NaCl/StripAttributes.cpp')
-rw-r--r-- | lib/Transforms/NaCl/StripAttributes.cpp | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/lib/Transforms/NaCl/StripAttributes.cpp b/lib/Transforms/NaCl/StripAttributes.cpp index a28aee3ad1..5c2ff72daa 100644 --- a/lib/Transforms/NaCl/StripAttributes.cpp +++ b/lib/Transforms/NaCl/StripAttributes.cpp @@ -135,12 +135,25 @@ static void CheckAttributes(AttributeSet Attrs) { } } +void stripGlobalValueAttrs(GlobalValue *GV) { + GV->setUnnamedAddr(false); + + // Convert "private" linkage to "internal" to reduce the number of + // linkage types that need to be represented in PNaCl's wire format. + // + // We convert "private" to "internal" rather than vice versa because + // "private" symbols are omitted from the nexe's symbol table, which + // would get in the way of debugging when an unstripped pexe is + // translated offline. + if (GV->getLinkage() == GlobalValue::PrivateLinkage) + GV->setLinkage(GlobalValue::InternalLinkage); +} + void stripFunctionAttrs(Function *Func) { CheckAttributes(Func->getAttributes()); Func->setAttributes(AttributeSet()); Func->setCallingConv(CallingConv::C); Func->setAlignment(0); - Func->setUnnamedAddr(false); for (Function::iterator BB = Func->begin(), E = Func->end(); BB != E; ++BB) { @@ -169,12 +182,14 @@ bool StripAttributes::runOnModule(Module &M) { // constructor for Functions just adds them back again. It would // be confusing if the attributes were sometimes present on // intrinsics and sometimes not. - if (!Func->isIntrinsic()) + if (!Func->isIntrinsic()) { + stripGlobalValueAttrs(Func); stripFunctionAttrs(Func); + } } for (Module::global_iterator GV = M.global_begin(), E = M.global_end(); GV != E; ++GV) { - GV->setUnnamedAddr(false); + stripGlobalValueAttrs(GV); } return true; } |