[VirtRegMap] Fix for PR17825. Do not ignore noreturn definitions when setting
[oota-llvm.git] / lib / CodeGen / VirtRegMap.cpp
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;