summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuentin Colombet <qcolombet@apple.com>2013-11-08 18:14:17 +0000
committerQuentin Colombet <qcolombet@apple.com>2013-11-08 18:14:17 +0000
commitb06a0ed4b09754501fddd164ba6125ee8ae9bcd5 (patch)
treea7ede50e6803620163fe220ce6487803a3190106
parent5f54c655c140305abbb71546b88b4324f273a105 (diff)
downloadbcm5719-llvm-b06a0ed4b09754501fddd164ba6125ee8ae9bcd5.tar.gz
bcm5719-llvm-b06a0ed4b09754501fddd164ba6125ee8ae9bcd5.zip
[VirtRegMap] Fix for PR17825. Do not ignore noreturn definitions when setting
isPhysRegUsed if the unwind information is required. Indeed, the runtime may need a correct stack to be able to unwind the call. llvm-svn: 194271
-rw-r--r--llvm/lib/CodeGen/VirtRegMap.cpp6
-rw-r--r--llvm/test/CodeGen/ARM/noreturn.ll20
2 files changed, 21 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp
index 0a08608ecfc..e0aa4053987 100644
--- a/llvm/lib/CodeGen/VirtRegMap.cpp
+++ b/llvm/lib/CodeGen/VirtRegMap.cpp
@@ -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;
diff --git a/llvm/test/CodeGen/ARM/noreturn.ll b/llvm/test/CodeGen/ARM/noreturn.ll
index 3a5c39e9a8d..4c876cec9c1 100644
--- a/llvm/test/CodeGen/ARM/noreturn.ll
+++ b/llvm/test/CodeGen/ARM/noreturn.ll
@@ -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 }
OpenPOWER on IntegriCloud