[cfe-commits] r137669 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/libcalls.c test/CodeGen/struct-passing.c test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp

Eric Christopher echristo at apple.com
Mon Aug 15 15:38:22 PDT 2011


Author: echristo
Date: Mon Aug 15 17:38:22 2011
New Revision: 137669

URL: http://llvm.org/viewvc/llvm-project?rev=137669&view=rev
Log:
'pure' and 'const' functions should also be marked nounwind. Migrate
test over from llvm/test/FrontendC++ and update others to account for
the change.

Added:
    cfe/trunk/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGCall.cpp
    cfe/trunk/test/CodeGen/libcalls.c
    cfe/trunk/test/CodeGen/struct-passing.c

Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=137669&r1=137668&r2=137669&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Mon Aug 15 17:38:22 2011
@@ -739,10 +739,15 @@
 
     if (TargetDecl->hasAttr<NoReturnAttr>())
       FuncAttrs |= llvm::Attribute::NoReturn;
-    if (TargetDecl->hasAttr<ConstAttr>())
+
+    // 'const' and 'pure' attribute functions are also nounwind.
+    if (TargetDecl->hasAttr<ConstAttr>()) {
       FuncAttrs |= llvm::Attribute::ReadNone;
-    else if (TargetDecl->hasAttr<PureAttr>())
+      FuncAttrs |= llvm::Attribute::NoUnwind;
+    } else if (TargetDecl->hasAttr<PureAttr>()) {
       FuncAttrs |= llvm::Attribute::ReadOnly;
+      FuncAttrs |= llvm::Attribute::NoUnwind;
+    }
     if (TargetDecl->hasAttr<MallocAttr>())
       RetAttrs |= llvm::Attribute::NoAlias;
   }

Modified: cfe/trunk/test/CodeGen/libcalls.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcalls.c?rev=137669&r1=137668&r2=137669&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/libcalls.c (original)
+++ cfe/trunk/test/CodeGen/libcalls.c Mon Aug 15 17:38:22 2011
@@ -24,9 +24,9 @@
 // CHECK-YES: declare float @sqrtf(float)
 // CHECK-YES: declare double @sqrt(double)
 // CHECK-YES: declare x86_fp80 @sqrtl(x86_fp80)
-// CHECK-NO: declare float @sqrtf(float) readnone
-// CHECK-NO: declare double @sqrt(double) readnone
-// CHECK-NO: declare x86_fp80 @sqrtl(x86_fp80) readnone
+// CHECK-NO: declare float @sqrtf(float) nounwind readnone
+// CHECK-NO: declare double @sqrt(double) nounwind readnone
+// CHECK-NO: declare x86_fp80 @sqrtl(x86_fp80) nounwind readnone
 
 // CHECK-YES: define void @test_pow
 // CHECK-NO: define void @test_pow

Modified: cfe/trunk/test/CodeGen/struct-passing.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/struct-passing.c?rev=137669&r1=137668&r2=137669&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/struct-passing.c (original)
+++ cfe/trunk/test/CodeGen/struct-passing.c Mon Aug 15 17:38:22 2011
@@ -16,8 +16,8 @@
 
 void *ps[] = { f0, f1, f2, f3, f4, f5 };
 
-// CHECK: declare i32 @f0() readnone
-// CHECK: declare i32 @f1() readonly
+// CHECK: declare i32 @f0() nounwind readnone
+// CHECK: declare i32 @f1() nounwind readonly
 // CHECK: declare void @f2({{.*}} sret)
 // CHECK: declare void @f3({{.*}} sret)
 // CHECK: declare void @f4({{.*}} byval align 4)

Added: cfe/trunk/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp?rev=137669&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp Mon Aug 15 17:38:22 2011
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fexceptions -emit-llvm %s -o - | grep nounwind | count 4
+int c(void) __attribute__((const));
+int p(void) __attribute__((pure));
+int t(void);
+
+int f(void) {
+  return c() + p() + t();
+}





More information about the cfe-commits mailing list