[llvm] r285975 - X86: Move a non-null assert to before the pointer is dereferenced

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 3 16:55:36 PDT 2016


Author: bogner
Date: Thu Nov  3 18:55:36 2016
New Revision: 285975

URL: http://llvm.org/viewvc/llvm-project?rev=285975&view=rev
Log:
X86: Move a non-null assert to before the pointer is dereferenced

Modified:
    llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp

Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=285975&r1=285974&r2=285975&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Thu Nov  3 18:55:36 2016
@@ -264,13 +264,14 @@ X86RegisterInfo::getRegPressureLimit(con
 
 const MCPhysReg *
 X86RegisterInfo::getCalleeSavedRegs(const MachineFunction *MF) const {
+  assert(MF && "MachineFunction required");
+
   const X86Subtarget &Subtarget = MF->getSubtarget<X86Subtarget>();
   bool HasSSE = Subtarget.hasSSE1();
   bool HasAVX = Subtarget.hasAVX();
   bool HasAVX512 = Subtarget.hasAVX512();
   bool CallsEHReturn = MF->getMMI().callsEHReturn();
 
-  assert(MF && "MachineFunction required");
   switch (MF->getFunction()->getCallingConv()) {
   case CallingConv::GHC:
   case CallingConv::HiPE:




More information about the llvm-commits mailing list