diff options
| author | Eric Christopher <echristo@apple.com> | 2011-08-15 22:38:22 +0000 |
|---|---|---|
| committer | Eric Christopher <echristo@apple.com> | 2011-08-15 22:38:22 +0000 |
| commit | bf005ecd9c4d791b8fd2595bd970644dff951a9f (patch) | |
| tree | 195607747c734bde956ff66ad15c7e4560c37b5a | |
| parent | d2dfc5ec02d90d28147c583decb5417a4c37d07e (diff) | |
| download | bcm5719-llvm-bf005ecd9c4d791b8fd2595bd970644dff951a9f.tar.gz bcm5719-llvm-bf005ecd9c4d791b8fd2595bd970644dff951a9f.zip | |
'pure' and 'const' functions should also be marked nounwind. Migrate
test over from llvm/test/FrontendC++ and update others to account for
the change.
llvm-svn: 137669
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 9 | ||||
| -rw-r--r-- | clang/test/CodeGen/libcalls.c | 6 | ||||
| -rw-r--r-- | clang/test/CodeGen/struct-passing.c | 4 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp | 8 |
4 files changed, 20 insertions, 7 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 023dd2267cc..dc3e702d6a3 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -739,10 +739,15 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, 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; } diff --git a/clang/test/CodeGen/libcalls.c b/clang/test/CodeGen/libcalls.c index 5ff684fd5b6..458c591837f 100644 --- a/clang/test/CodeGen/libcalls.c +++ b/clang/test/CodeGen/libcalls.c @@ -24,9 +24,9 @@ void test_sqrt(float a0, double a1, long double a2) { // 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 diff --git a/clang/test/CodeGen/struct-passing.c b/clang/test/CodeGen/struct-passing.c index 8e5c0adcfc1..efb00efd53a 100644 --- a/clang/test/CodeGen/struct-passing.c +++ b/clang/test/CodeGen/struct-passing.c @@ -16,8 +16,8 @@ void __attribute__((pure)) f5(T1 a); 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) diff --git a/clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp b/clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp new file mode 100644 index 00000000000..708920792bf --- /dev/null +++ b/clang/test/CodeGenCXX/2009-05-04-PureConstNounwind.cpp @@ -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(); +} |

