From: Jakob Stoklund Olesen Date: Sat, 15 Aug 2009 13:10:46 +0000 (+0000) Subject: Don't setCalleeSavedInfoValid() until spills are interted. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d62c9a697b53f9e754926a89126fd121220ed09b;p=oota-llvm.git Don't setCalleeSavedInfoValid() until spills are interted. In a naked function, the flag is never set and getPristineRegs() returns an empty list. That means naked functions are able to clobber callee saved registers, but that is the whole point of naked functions. This fixes PR4716. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79096 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index 8b05f4c4a3e..608e4c5763a 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -214,8 +214,6 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) { } } - FFI->setCalleeSavedInfoValid(true); - if (CSI.empty()) return; // Early exit if no callee saved registers are modified! @@ -274,6 +272,8 @@ void PEI::insertCSRSpillsAndRestores(MachineFunction &Fn) { MachineFrameInfo *FFI = Fn.getFrameInfo(); const std::vector &CSI = FFI->getCalleeSavedInfo(); + FFI->setCalleeSavedInfoValid(true); + // Early exit if no callee saved registers are modified! if (CSI.empty()) return; diff --git a/test/CodeGen/ARM/2009-08-15-RegScavengerAssert.ll b/test/CodeGen/ARM/2009-08-15-RegScavengerAssert.ll new file mode 100644 index 00000000000..54196dcb919 --- /dev/null +++ b/test/CodeGen/ARM/2009-08-15-RegScavengerAssert.ll @@ -0,0 +1,10 @@ +; RUN: llvm-as < %s | llc -march=arm +; PR4716 + +define arm_aapcscc void @_start() nounwind naked { +entry: + tail call arm_aapcscc void @exit(i32 undef) noreturn nounwind + unreachable +} + +declare arm_aapcscc void @exit(i32) noreturn nounwind