diff options
author | Akira Hatanaka <ahatanaka@apple.com> | 2017-10-06 07:12:46 +0000 |
---|---|---|
committer | Akira Hatanaka <ahatanaka@apple.com> | 2017-10-06 07:12:46 +0000 |
commit | 6b103bc18c4069098f59394cc6b39a645c1bfe1e (patch) | |
tree | be77044162e4a8e0de096ba4ec13458981f553cc /clang/lib/CodeGen/CodeGenFunction.h | |
parent | bcd36f7c5a1187169b0c804dcb86eb4a7655be0f (diff) | |
download | llvm-6b103bc18c4069098f59394cc6b39a645c1bfe1e.zip llvm-6b103bc18c4069098f59394cc6b39a645c1bfe1e.tar.gz llvm-6b103bc18c4069098f59394cc6b39a645c1bfe1e.tar.bz2 |
[CodeGen] Emit a helper function for __builtin_os_log_format to reduce
code size.
Currently clang expands a call to __builtin_os_log_format into a long
sequence of instructions at the call site, causing code size to
increase in some cases.
This commit attempts to reduce code size by emitting a helper function
that can be shared by calls to __builtin_os_log_format with similar
formats and arguments. The helper function has linkonce_odr linkage to
enable the linker to merge identical functions across translation units.
Attribute 'noinline' is attached to the helper function at -Oz so that
the inliner doesn't inline functions that can potentially be merged.
This commit also fixes a bug where the generated IR writes past the end
of the buffer when "%m" is the last specifier appearing in the format
string passed to __builtin_os_log_format.
Original patch by Duncan Exon Smith.
rdar://problem/34065973
rdar://problem/34196543
Differential Revision: https://reviews.llvm.org/D38606
llvm-svn: 315045
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 50c8ebf..8cee6b6 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -76,6 +76,10 @@ class ObjCAtThrowStmt; class ObjCAtSynchronizedStmt; class ObjCAutoreleasePoolStmt; +namespace analyze_os_log { +class OSLogBufferLayout; +} + namespace CodeGen { class CodeGenTypes; class CGCallee; @@ -3304,6 +3308,13 @@ public: unsigned BuiltinID, const CallExpr *E, ReturnValueSlot ReturnValue); + /// Emit IR for __builtin_os_log_format. + RValue emitBuiltinOSLogFormat(const CallExpr &E); + + llvm::Function *generateBuiltinOSLogHelperFunction( + const analyze_os_log::OSLogBufferLayout &Layout, + CharUnits BufferAlignment); + RValue EmitBlockCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue); /// EmitTargetBuiltinExpr - Emit the given builtin call. Returns 0 if the call |