diff options
| author | Vedant Kumar <vsk@apple.com> | 2019-01-25 18:30:22 +0000 |
|---|---|---|
| committer | Vedant Kumar <vsk@apple.com> | 2019-01-25 18:30:22 +0000 |
| commit | 13ef84fced995ad67942349e6814bfcb005e19ea (patch) | |
| tree | 3135702be53d50e4e0ff3e199847cae80ee0f6bf /llvm/lib/MC/MCParser/AsmParser.cpp | |
| parent | 414f9b305d8284e6eab6aac1bee814953f67358a (diff) | |
| download | bcm5719-llvm-13ef84fced995ad67942349e6814bfcb005e19ea.tar.gz bcm5719-llvm-13ef84fced995ad67942349e6814bfcb005e19ea.zip | |
[MC] Teach the MachO object writer about N_FUNC_COLD
N_FUNC_COLD is a new MachO symbol attribute. It's a hint to the linker
to order a symbol towards the end of its section, to improve locality.
Example:
```
void a1() {}
__attribute__((cold)) void a2() {}
void a3() {}
int main() {
a1();
a2();
a3();
return 0;
}
```
A linker that supports N_FUNC_COLD will order _a2 to the end of the text
section. From `nm -njU` output, we see:
```
_a1
_a3
_main
_a2
```
Differential Revision: https://reviews.llvm.org/D57190
llvm-svn: 352227
Diffstat (limited to 'llvm/lib/MC/MCParser/AsmParser.cpp')
| -rw-r--r-- | llvm/lib/MC/MCParser/AsmParser.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp index 6c311c13836..189422e2ad3 100644 --- a/llvm/lib/MC/MCParser/AsmParser.cpp +++ b/llvm/lib/MC/MCParser/AsmParser.cpp @@ -426,6 +426,7 @@ private: DK_WEAK_DEFINITION, DK_WEAK_REFERENCE, DK_WEAK_DEF_CAN_BE_HIDDEN, + DK_COLD, DK_COMM, DK_COMMON, DK_LCOMM, @@ -1983,6 +1984,8 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info, return parseDirectiveSymbolAttribute(MCSA_WeakReference); case DK_WEAK_DEF_CAN_BE_HIDDEN: return parseDirectiveSymbolAttribute(MCSA_WeakDefAutoPrivate); + case DK_COLD: + return parseDirectiveSymbolAttribute(MCSA_Cold); case DK_COMM: case DK_COMMON: return parseDirectiveComm(/*IsLocal=*/false); @@ -5223,6 +5226,7 @@ void AsmParser::initializeDirectiveKindMap() { DirectiveKindMap[".weak_definition"] = DK_WEAK_DEFINITION; DirectiveKindMap[".weak_reference"] = DK_WEAK_REFERENCE; DirectiveKindMap[".weak_def_can_be_hidden"] = DK_WEAK_DEF_CAN_BE_HIDDEN; + DirectiveKindMap[".cold"] = DK_COLD; DirectiveKindMap[".comm"] = DK_COMM; DirectiveKindMap[".common"] = DK_COMMON; DirectiveKindMap[".lcomm"] = DK_LCOMM; |

