Don't suppress the emission of available_externally functions marked

with always_inline attribute. Thanks to Howard for the tip.

llvm-svn: 108469
This commit is contained in:
Douglas Gregor 2010-07-15 22:58:18 +00:00
parent b3026df9fa
commit 8997690ff1
2 changed files with 16 additions and 1 deletions

View File

@ -816,7 +816,8 @@ void CodeGenModule::EmitGlobalDefinition(GlobalDecl GD) {
if (const FunctionDecl *Function = dyn_cast<FunctionDecl>(D)) {
// At -O0, don't generate IR for functions with available_externally
// linkage.
if (CodeGenOpts.OptimizationLevel == 0 &&
if (CodeGenOpts.OptimizationLevel == 0 &&
!Function->hasAttr<AlwaysInlineAttr>() &&
getFunctionLinkage(Function)
== llvm::Function::AvailableExternallyLinkage)
return;

View File

@ -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);
}