summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp4
-rw-r--r--clang/test/CodeGen/unwind-attr.c7
2 files changed, 11 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 58d56ef0df9..e5cfa624b2c 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -315,6 +315,10 @@ void CodeGenFunction::EmitFunctionBody(FunctionArgList &Args) {
/// non-existence of any throwing calls within it. We believe this is
/// lightweight enough to do at -O0.
static void TryMarkNoThrow(llvm::Function *F) {
+ // LLVM treats 'nounwind' on a function as part of the type, so we
+ // can't do this on functions that can be overwritten.
+ if (F->mayBeOverridden()) return;
+
for (llvm::Function::iterator FI = F->begin(), FE = F->end(); FI != FE; ++FI)
for (llvm::BasicBlock::iterator
BI = FI->begin(), BE = FI->end(); BI != BE; ++BI)
diff --git a/clang/test/CodeGen/unwind-attr.c b/clang/test/CodeGen/unwind-attr.c
index 459176cdf77..c588ca8e1b6 100644
--- a/clang/test/CodeGen/unwind-attr.c
+++ b/clang/test/CodeGen/unwind-attr.c
@@ -15,3 +15,10 @@ int test0(void) {
int test1(void) {
return 0;
}
+
+// <rdar://problem/8283071>: not for weak functions
+// CHECK: define weak [[INT:i.*]] @test2() {
+// CHECK-NOEXC: define weak [[INT:i.*]] @test2() nounwind {
+__attribute__((weak)) int test2(void) {
+ return 0;
+}
OpenPOWER on IntegriCloud