[llvm-commits] [llvm] r57437 - /llvm/trunk/lib/CodeGen/MachineFunction.cpp

Matthijs Kooijman matthijs at stdin.nl
Mon Oct 13 05:37:16 PDT 2008


Author: matthijs
Date: Mon Oct 13 07:37:16 2008
New Revision: 57437

URL: http://llvm.org/viewvc/llvm-project?rev=57437&view=rev
Log:
Make MachineFunction not crash when TargetMachine::getRegisterInfo() returns
NULL, but just hide some debug output then.

Modified:
    llvm/trunk/lib/CodeGen/MachineFunction.cpp

Modified: llvm/trunk/lib/CodeGen/MachineFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineFunction.cpp?rev=57437&r1=57436&r2=57437&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineFunction.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineFunction.cpp Mon Oct 13 07:37:16 2008
@@ -110,8 +110,11 @@
 MachineFunction::MachineFunction(const Function *F,
                                  const TargetMachine &TM)
   : Annotation(MF_AID), Fn(F), Target(TM) {
-  RegInfo = new (Allocator.Allocate<MachineRegisterInfo>())
-                MachineRegisterInfo(*TM.getRegisterInfo());
+  if (TM.getRegisterInfo())
+    RegInfo = new (Allocator.Allocate<MachineRegisterInfo>())
+                  MachineRegisterInfo(*TM.getRegisterInfo());
+  else
+    RegInfo = 0;
   MFInfo = 0;
   FrameInfo = new (Allocator.Allocate<MachineFrameInfo>())
                   MachineFrameInfo(*TM.getFrameInfo());
@@ -132,7 +135,8 @@
   BasicBlocks.clear();
   InstructionRecycler.clear(Allocator);
   BasicBlockRecycler.clear(Allocator);
-  RegInfo->~MachineRegisterInfo();        Allocator.Deallocate(RegInfo);
+  if (RegInfo)
+    RegInfo->~MachineRegisterInfo();        Allocator.Deallocate(RegInfo);
   if (MFInfo) {
     MFInfo->~MachineFunctionInfo();       Allocator.Deallocate(MFInfo);
   }
@@ -255,7 +259,7 @@
   
   const TargetRegisterInfo *TRI = getTarget().getRegisterInfo();
   
-  if (!RegInfo->livein_empty()) {
+  if (RegInfo && !RegInfo->livein_empty()) {
     OS << "Live Ins:";
     for (MachineRegisterInfo::livein_iterator
          I = RegInfo->livein_begin(), E = RegInfo->livein_end(); I != E; ++I) {
@@ -269,7 +273,7 @@
     }
     OS << "\n";
   }
-  if (!RegInfo->liveout_empty()) {
+  if (RegInfo && !RegInfo->liveout_empty()) {
     OS << "Live Outs:";
     for (MachineRegisterInfo::liveout_iterator
          I = RegInfo->liveout_begin(), E = RegInfo->liveout_end(); I != E; ++I)





More information about the llvm-commits mailing list