]> granicus.if.org Git - clang/commitdiff
Revise r110163: don't mark weak functions nounwind, because the optimizer
authorJohn McCall <rjmccall@apple.com>
Wed, 11 Aug 2010 22:38:33 +0000 (22:38 +0000)
committerJohn McCall <rjmccall@apple.com>
Wed, 11 Aug 2010 22:38:33 +0000 (22:38 +0000)
treats that as a contract to be fulfilled by any replacements.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110864 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CodeGenFunction.cpp
test/CodeGen/unwind-attr.c

index 58d56ef0df94c6da2b081173b35a1eae7d268c15..e5cfa624b2cc2e5c6fe836b23b682ca69a6e7ed1 100644 (file)
@@ -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)
index 459176cdf77337c5ceaa522eee3359ac18d63d85..c588ca8e1b60e50b456dcef37c17427380452b3e 100644 (file)
@@ -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;
+}