[cfe-commits] r108230 - in /cfe/trunk: lib/CodeGen/CodeGenModule.cpp test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp test/CodeGen/available-externally-suppress.c test/CodeGen/inline.c test/CodeGen/inline2.c test/CodeGenCXX/template-instantiation.cpp test/CodeGenCXX/visibility-hidden-extern-templates.cpp

Douglas Gregor dgregor at apple.com
Mon Jul 12 23:02:28 PDT 2010


Author: dgregor
Date: Tue Jul 13 01:02:28 2010
New Revision: 108230

URL: http://llvm.org/viewvc/llvm-project?rev=108230&view=rev
Log:
Reinstate the optimization suppressing available_externally functions
at -O0. The only change from the previous patch is that we don't try
to generate virtual method thunks for an available_externally
function.

Added:
    cfe/trunk/test/CodeGen/available-externally-suppress.c
      - copied unchanged from r108193, cfe/trunk/test/CodeGen/available-externally-suppress.c
Modified:
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp
    cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
    cfe/trunk/test/CodeGen/inline.c
    cfe/trunk/test/CodeGen/inline2.c
    cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
    cfe/trunk/test/CodeGenCXX/visibility-hidden-extern-templates.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=108230&r1=108229&r2=108230&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue Jul 13 01:02:28 2010
@@ -813,18 +813,27 @@
                                  Context.getSourceManager(),
                                  "Generating code for declaration");
   
-  if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
-    if (Method->isVirtual())
-      getVTables().EmitThunks(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 &&
+        getFunctionLinkage(Function) 
+                                  == llvm::Function::AvailableExternallyLinkage)
+      return;
+
+    if (const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D)) {
+      if (Method->isVirtual())
+        getVTables().EmitThunks(GD);
 
-  if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(D))
-    return EmitCXXConstructor(CD, GD.getCtorType());
+      if (const CXXConstructorDecl *CD = dyn_cast<CXXConstructorDecl>(Method))
+        return EmitCXXConstructor(CD, GD.getCtorType());
   
-  if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(D))
-    return EmitCXXDestructor(DD, GD.getDtorType());
+      if (const CXXDestructorDecl *DD = dyn_cast<CXXDestructorDecl>(Method))
+        return EmitCXXDestructor(DD, GD.getDtorType());
+    }
 
-  if (isa<FunctionDecl>(D))
     return EmitGlobalFunctionDefinition(GD);
+  }
   
   if (const VarDecl *VD = dyn_cast<VarDecl>(D))
     return EmitGlobalVarDefinition(VD);

Modified: cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp?rev=108230&r1=108229&r2=108230&view=diff
==============================================================================
--- cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p9-linkage.cpp Tue Jul 13 01:02:28 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -std=c++0x -o - %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -emit-llvm -std=c++0x -o - %s | FileCheck %s
 
 template<typename T>
 struct X0 {

Modified: cfe/trunk/test/CodeGen/inline.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline.c?rev=108230&r1=108229&r2=108230&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/inline.c (original)
+++ cfe/trunk/test/CodeGen/inline.c Tue Jul 13 01:02:28 2010
@@ -1,5 +1,5 @@
 // RUN: echo "GNU89 tests:"
-// RUN: %clang %s -emit-llvm -S -o %t -std=gnu89
+// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=gnu89
 // RUN: grep "define available_externally i32 @ei()" %t
 // RUN: grep "define i32 @foo()" %t
 // RUN: grep "define i32 @bar()" %t
@@ -14,7 +14,7 @@
 // RUN: grep "define available_externally i32 @test5" %t
 
 // RUN: echo "\nC99 tests:"
-// RUN: %clang %s -emit-llvm -S -o %t -std=c99
+// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=c99
 // RUN: grep "define i32 @ei()" %t
 // RUN: grep "define available_externally i32 @foo()" %t
 // RUN: grep "define i32 @bar()" %t
@@ -29,7 +29,7 @@
 // RUN: grep "define available_externally i32 @test5" %t
 
 // RUN: echo "\nC++ tests:"
-// RUN: %clang %s -emit-llvm -S -o %t -std=c++98
+// RUN: %clang %s -O1 -emit-llvm -S -o %t -std=c++98
 // RUN: grep "define linkonce_odr i32 @_Z2eiv()" %t
 // RUN: grep "define linkonce_odr i32 @_Z3foov()" %t
 // RUN: grep "define i32 @_Z3barv()" %t

Modified: cfe/trunk/test/CodeGen/inline2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/inline2.c?rev=108230&r1=108229&r2=108230&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/inline2.c (original)
+++ cfe/trunk/test/CodeGen/inline2.c Tue Jul 13 01:02:28 2010
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -std=gnu89 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix GNU89 %s
-// RUN: %clang_cc1 -std=c99 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix C99 %s
+// RUN: %clang_cc1 -O1 -std=gnu89 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix GNU89 %s
+// RUN: %clang_cc1 -O1 -std=c99 -triple i386-apple-darwin9 -emit-llvm %s -o - | FileCheck -check-prefix C99 %s
 
 // CHECK-GNU89: define i32 @f0()
 // CHECK-C99: define i32 @f0()

Modified: cfe/trunk/test/CodeGenCXX/template-instantiation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/template-instantiation.cpp?rev=108230&r1=108229&r2=108230&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/template-instantiation.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/template-instantiation.cpp Tue Jul 13 01:02:28 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O1 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
 
 // CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant
 // CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE

Modified: cfe/trunk/test/CodeGenCXX/visibility-hidden-extern-templates.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/visibility-hidden-extern-templates.cpp?rev=108230&r1=108229&r2=108230&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/visibility-hidden-extern-templates.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/visibility-hidden-extern-templates.cpp Tue Jul 13 01:02:28 2010
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm -o - -fvisibility hidden %s | FileCheck %s
+// RUN: %clang_cc1 -O1 -emit-llvm -o - -fvisibility hidden %s | FileCheck %s
 
 template<typename T>
 struct X {





More information about the cfe-commits mailing list