From 7feaeeed1789fbf357fc81072966fe8f62fb4a81 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Thu, 15 Jul 2010 22:58:18 +0000 Subject: [PATCH] Don't suppress the emission of available_externally functions marked with always_inline attribute. Thanks to Howard for the tip. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108469 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 3 ++- test/CodeGen/available-externally-suppress.c | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index bf606a6165..834f981a52 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -816,7 +816,8 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) { if (const FunctionDecl *Function = dyn_cast(D)) { // At -O0, don't generate IR for functions with available_externally // linkage. - if (CodeGenOpts.OptimizationLevel == 0 && + if (CodeGenOpts.OptimizationLevel == 0 && + !Function->hasAttr() && getFunctionLinkage(Function) == llvm::Function::AvailableExternallyLinkage) return; diff --git a/test/CodeGen/available-externally-suppress.c b/test/CodeGen/available-externally-suppress.c index c3b7a213ba..fb8c9c61d9 100644 --- a/test/CodeGen/available-externally-suppress.c +++ b/test/CodeGen/available-externally-suppress.c @@ -10,3 +10,17 @@ inline void f0(int y) { x = y; } void test() { f0(17); } + +inline int __attribute__((always_inline)) f1(int x) { + int blarg = 0; + for (int i = 0; i < x; ++i) + blarg = blarg + x * i; + return blarg; +} + +int test1(int x) { + // CHECK: br i1 + // CHECK-NOT: call + // CHECK: ret i32 + return f1(x); +} -- 2.40.0