x86: getCalleeSavedRegs() would crash on 0 (so don't default to it)
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 14 Mar 2014 15:38:12 +0000 (15:38 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 14 Mar 2014 15:38:12 +0000 (15:38 +0000)
The current logic assumes that MF is not 0.  Assert that it isn't, and
remove the default of 0 from the header.

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

lib/Target/X86/X86RegisterInfo.cpp
lib/Target/X86/X86RegisterInfo.h

index 43057c0fdf650202fd423af9796f5daa61f650db..ccbe579a468e949e4b046a44cb632fba2fa878a0 100644 (file)
@@ -237,6 +237,7 @@ X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
   bool HasAVX = TM.getSubtarget<X86Subtarget>().hasAVX();
   bool HasAVX512 = TM.getSubtarget<X86Subtarget>().hasAVX512();
 
+  assert(MF && "MachineFunction required");
   switch (MF->getFunction()->getCallingConv()) {
   case CallingConv::GHC:
   case CallingConv::HiPE:
index 3ee328f2e59e3f140d917dbc841a67593d7b9b6b..447ff953da83b44461d6019134d43df6725bd170 100644 (file)
@@ -101,7 +101,7 @@ public:
   /// getCalleeSavedRegs - Return a null-terminated list of all of the
   /// callee-save registers on this target.
   const uint16_t *
-  getCalleeSavedRegs(const MachineFunction* MF = 0) const override;
+  getCalleeSavedRegs(const MachineFunction* MF) const override;
   const uint32_t *getCallPreservedMask(CallingConv::ID) const override;
   const uint32_t *getNoPreservedMask() const;