[VirtRegMap] Fix for PR17825. Do not ignore noreturn definitions when setting
authorQuentin Colombet <qcolombet@apple.com>
Fri, 8 Nov 2013 18:14:17 +0000 (18:14 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Fri, 8 Nov 2013 18:14:17 +0000 (18:14 +0000)
isPhysRegUsed if the unwind information is required.
Indeed, the runtime may need a correct stack to be able to unwind the call.

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

lib/CodeGen/VirtRegMap.cpp
test/CodeGen/ARM/noreturn.ll

index 0a08608ecfc53406feeb16afc28f7470f0c0d0e9..e0aa4053987c225a3545dbdea6f45daf1542e80b 100644 (file)
@@ -285,7 +285,11 @@ void VirtRegRewriter::rewrite() {
           if (!MO.isGlobal())
             continue;
           const Function *Func = dyn_cast<Function>(MO.getGlobal());
-          if (!Func || !Func->hasFnAttribute(Attribute::NoReturn))
+          if (!Func || !Func->hasFnAttribute(Attribute::NoReturn) ||
+              // We need to keep correct unwind information
+              // even if the function will not return, since the
+              // runtime may need it.
+              !Func->hasFnAttribute(Attribute::NoUnwind))
             continue;
           NoReturnInsts.insert(MI);
           break;
index 3a5c39e9a8dca9fc2658dab142e4c5bed4b8bb45..4c876cec9c106376486929f6460d2ccbd4d12b36 100644 (file)
@@ -2,8 +2,7 @@
 ; Test case from PR16882.
 target triple = "thumbv7s-apple-ios"
 
-; Function Attrs: noreturn
-define i32 @test1() #0 {
+define i32 @test1() {
 ; CHECK-LABEL: @test1
 ; CHECK-NOT: push
 entry:
@@ -11,7 +10,7 @@ entry:
   unreachable
 }
 
-; Function Attrs: noreturn
+; Function Attrs: noreturn nounwind
 declare void @overflow() #0
 
 define i32 @test2(i32 %x, i32 %y) {
@@ -35,4 +34,17 @@ if.end:                                           ; preds = %entry
   ret i32 %conv2
 }
 
-attributes #0 = { noreturn }
+; Test case for PR17825.
+define i32 @test3() {
+; CHECK-LABEL: @test3
+; CHECK: push
+entry:
+  tail call void @overflow_with_unwind() #1
+  unreachable
+}
+
+; Function Attrs: noreturn
+declare void @overflow_with_unwind() #1
+
+attributes #0 = { noreturn nounwind }
+attributes #1 = { noreturn }