]> granicus.if.org Git - clang/commitdiff
Don't suppress the emission of available_externally functions marked
authorDouglas Gregor <dgregor@apple.com>
Thu, 15 Jul 2010 22:58:18 +0000 (22:58 +0000)
committerDouglas Gregor <dgregor@apple.com>
Thu, 15 Jul 2010 22:58:18 +0000 (22:58 +0000)
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
test/CodeGen/available-externally-suppress.c

index bf606a616582232ba8c1eee848c5fd94d3acf6c8..834f981a528c9218f6e8f1f63e6180d4ee6ca3a8 100644 (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;
index c3b7a213baf6e58ee8fff5df67764843a81207f4..fb8c9c61d9b8fae2b09e3b0047ccf13440b67a2e 100644 (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); 
+}