diff options
author | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2015-09-11 20:29:07 +0000 |
---|---|---|
committer | Evgeniy Stepanov <eugeni.stepanov@gmail.com> | 2015-09-11 20:29:07 +0000 |
commit | 072e83500e1f4291692753fa19840b17c694244e (patch) | |
tree | 864a12a926b5836534b23521e0bc6e45e10879ac /clang/test/CodeGen/function-attributes.c | |
parent | 69c3ddc44a1b4b15cbfa1d447da0cc68eeb75579 (diff) | |
download | bcm5719-llvm-072e83500e1f4291692753fa19840b17c694244e.tar.gz bcm5719-llvm-072e83500e1f4291692753fa19840b17c694244e.zip |
Always_inline codegen rewrite.
Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.
Libc++ relies on the compiler never emitting such undefined reference.
With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
-- or, depending on the linkage --
2b. A declaration of F.
The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).
This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.
This patch is based on ideas by Chandler Carruth and Richard Smith.
llvm-svn: 247465
Diffstat (limited to 'clang/test/CodeGen/function-attributes.c')
-rw-r--r-- | clang/test/CodeGen/function-attributes.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/test/CodeGen/function-attributes.c b/clang/test/CodeGen/function-attributes.c index 177ad848f74..4a7d4fc0edb 100644 --- a/clang/test/CodeGen/function-attributes.c +++ b/clang/test/CodeGen/function-attributes.c @@ -25,8 +25,8 @@ void f6(signed short x) { } void f7(unsigned short x) { } -// CHECK-LABEL: define void @f8() -// CHECK: [[AI:#[0-9]+]] +// CHECK: define void @f8() +// CHECK: [[NUW:#[0-9]+]] // CHECK: { void __attribute__((always_inline)) f8(void) { } @@ -129,7 +129,6 @@ void f20(void) { } // CHECK: attributes [[NUW]] = { nounwind optsize readnone{{.*}} } -// CHECK: attributes [[AI]] = { alwaysinline nounwind optsize readnone{{.*}} } // CHECK: attributes [[ALIGN]] = { nounwind optsize readnone alignstack=16{{.*}} } // CHECK: attributes [[RT]] = { nounwind optsize returns_twice{{.*}} } // CHECK: attributes [[NR]] = { noreturn nounwind optsize } |