Revert 49006 for the moment.
authorDale Johannesen <dalej@apple.com>
Tue, 1 Apr 2008 20:00:57 +0000 (20:00 +0000)
committerDale Johannesen <dalej@apple.com>
Tue, 1 Apr 2008 20:00:57 +0000 (20:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@49046 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/DwarfWriter.cpp
lib/CodeGen/LLVMTargetMachine.cpp
lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
lib/Target/PowerPC/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCRegisterInfo.cpp
lib/Target/X86/X86AsmPrinter.cpp
lib/Target/X86/X86RegisterInfo.cpp
lib/Transforms/Utils/LowerInvoke.cpp

index 3296e114df0dc9378f255be4f14b294aba618cc8..e72ff07a9d704299b36a67d4e0afc11ac0b3cf44 100644 (file)
@@ -2778,13 +2778,9 @@ private:
 
   std::vector<FunctionEHFrameInfo> EHFrames;
     
-  /// shouldEmit - Per-function flag to indicate if EH information should
-  /// be emitted.
+  /// shouldEmit - Flag to indicate if debug information should be emitted.
+  ///
   bool shouldEmit;
-
-  /// shouldEmitModule - Per-module flag to indicate if EH information should
-  /// be emitted.
-  bool shouldEmitModule;
   
   /// EmitCommonEHFrame - Emit the common eh unwind frame.
   ///
@@ -3372,7 +3368,6 @@ public:
   DwarfException(std::ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
   : Dwarf(OS, A, T, "eh")
   , shouldEmit(false)
-  , shouldEmitModule(false)
   {}
   
   virtual ~DwarfException() {}
@@ -3392,7 +3387,7 @@ public:
   /// EndModule - Emit all exception information that should come after the
   /// content.
   void EndModule() {
-    if (!shouldEmitModule) return;
+    if (!shouldEmit) return;
 
     const std::vector<Function *> Personalities = MMI->getPersonalities();
     for (unsigned i =0; i < Personalities.size(); ++i)
@@ -3408,14 +3403,13 @@ public:
   void BeginFunction(MachineFunction *MF) {
     this->MF = MF;
     
-    shouldEmit = false;
-    if ((ExceptionHandling || !MF->getFunction()->doesNotThrow()) &&
+    if (MMI &&
+        ExceptionHandling &&
         TAI->doesSupportExceptionHandling()) {
       shouldEmit = true;
       // Assumes in correct section after the entry point.
       EmitLabel("eh_func_begin", ++SubprogramCount);
     }
-    shouldEmitModule |= shouldEmit;
   }
 
   /// EndFunction - Gather and emit post-function exception information.
index 67c0e4772a87dd779d5ada0aa0095e2b196d1cd0..bae7140bfb17b5f6e7b7c603025ee764d9620abb 100644 (file)
@@ -66,7 +66,8 @@ LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM,
   
   PM.add(createGCLoweringPass());
 
-  PM.add(createLowerInvokePass(getTargetLowering()));
+  if (!ExceptionHandling)
+    PM.add(createLowerInvokePass(getTargetLowering()));
 
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
@@ -191,7 +192,8 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(PassManagerBase &PM,
   
   PM.add(createGCLoweringPass());
   
-  PM.add(createLowerInvokePass(getTargetLowering()));
+  if (!ExceptionHandling)
+    PM.add(createLowerInvokePass(getTargetLowering()));
   
   // Make sure that no unreachable blocks are instruction selected.
   PM.add(createUnreachableBlockEliminationPass());
index ae2b41899abc308348a9e7059da54c3cc6736425..80b5c046a7141abf83cf40339878e1893bf9ec9b 100644 (file)
@@ -169,7 +169,6 @@ namespace llvm {
     Function &Fn;
     MachineFunction &MF;
     MachineRegisterInfo &RegInfo;
-    bool needsExceptionHandling;
 
     FunctionLoweringInfo(TargetLowering &TLI, Function &Fn,MachineFunction &MF);
 
@@ -305,10 +304,6 @@ FunctionLoweringInfo::FunctionLoweringInfo(TargetLowering &tli,
         BuildMI(MBB, TII->get(TargetInstrInfo::PHI), PHIReg+i);
     }
   }
-
-  // Figure out whether we need to generate EH info.  Currently we do this for
-  // all functions not marked no-unwind, or if requested via -enable-eh.
-  needsExceptionHandling = ExceptionHandling || !Fn.doesNotThrow();
 }
 
 /// CreateRegForValue - Allocate the appropriate number of virtual registers of
@@ -2832,7 +2827,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
   }
     
   case Intrinsic::eh_exception: {
-    if (FuncInfo.needsExceptionHandling) {
+    if (ExceptionHandling) {
       if (!CurMBB->isLandingPad()) {
         // FIXME: Mark exception register as live in.  Hack for PR1508.
         unsigned Reg = TLI.getExceptionAddressRegister();
@@ -2857,7 +2852,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
     MVT::ValueType VT = (Intrinsic == Intrinsic::eh_selector_i32 ?
                          MVT::i32 : MVT::i64);
     
-    if (FuncInfo.needsExceptionHandling && MMI) {
+    if (ExceptionHandling && MMI) {
       if (CurMBB->isLandingPad())
         addCatchInfo(I, MMI, CurMBB);
       else {
@@ -2907,7 +2902,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
   case Intrinsic::eh_return: {
     MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
 
-    if (MMI && FuncInfo.needsExceptionHandling) {
+    if (MMI && ExceptionHandling) {
       MMI->setCallsEHReturn(true);
       DAG.setRoot(DAG.getNode(ISD::EH_RETURN,
                               MVT::Other,
@@ -2930,7 +2925,7 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
    }
 
    case Intrinsic::eh_dwarf_cfa: {
-     if (FuncInfo.needsExceptionHandling) {
+     if (ExceptionHandling) {
        MVT::ValueType VT = getValue(I.getOperand(1)).getValueType();
        SDOperand CfaArg;
        if (MVT::getSizeInBits(VT) > MVT::getSizeInBits(TLI.getPointerTy()))
@@ -3181,7 +3176,7 @@ void SelectionDAGLowering::LowerCallTo(CallSite CS, SDOperand Callee,
     Args.push_back(Entry);
   }
 
-  if (LandingPad && FuncInfo.needsExceptionHandling && MMI) {
+  if (LandingPad && ExceptionHandling && MMI) {
     // Insert a label before the invoke call to mark the try range.  This can be
     // used to detect deletion of the invoke via the MachineModuleInfo.
     BeginLabel = MMI->NextLabelID();
@@ -3200,7 +3195,7 @@ void SelectionDAGLowering::LowerCallTo(CallSite CS, SDOperand Callee,
     setValue(CS.getInstruction(), Result.first);
   DAG.setRoot(Result.second);
 
-  if (LandingPad && FuncInfo.needsExceptionHandling && MMI) {
+  if (LandingPad && ExceptionHandling && MMI) {
     // Insert a label at the end of the invoke call to mark the try range.  This
     // can be used to detect deletion of the invoke via the MachineModuleInfo.
     EndLabel = MMI->NextLabelID();
@@ -4619,7 +4614,7 @@ bool SelectionDAGISel::runOnFunction(Function &Fn) {
 
   FunctionLoweringInfo FuncInfo(TLI, Fn, MF);
 
-  if (FuncInfo.needsExceptionHandling)
+  if (ExceptionHandling)
     for (Function::iterator I = Fn.begin(), E = Fn.end(); I != E; ++I)
       if (InvokeInst *Invoke = dyn_cast<InvokeInst>(I->getTerminator()))
         // Mark landing pad.
@@ -4762,7 +4757,7 @@ void SelectionDAGISel::BuildSelectionDAG(SelectionDAG &DAG, BasicBlock *LLVMBB,
 
   MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
 
-  if (FuncInfo.needsExceptionHandling && MMI && BB->isLandingPad()) {
+  if (ExceptionHandling && MMI && BB->isLandingPad()) {
     // Add a label to mark the beginning of the landing pad.  Deletion of the
     // landing pad can thus be detected via the MachineModuleInfo.
     unsigned LabelID = MMI->addLandingPad(BB);
index 4cc9d2a9bd58a85ca9bf2c305bfc2fe53a60a5b7..2537d67ddaadf82858daa5bb3a1d8e819d7b401e 100644 (file)
@@ -1086,9 +1086,8 @@ bool DarwinAsmPrinter::doFinalization(Module &M) {
 
   O << "\n";
 
-  if (TAI->doesSupportExceptionHandling() && MMI) {
+  if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI) {
     // Add the (possibly multiple) personalities to the set of global values.
-    // Only referenced functions get into the Personalities list.
     const std::vector<Function *>& Personalities = MMI->getPersonalities();
 
     for (std::vector<Function *>::const_iterator I = Personalities.begin(),
index cc3b583cc2776360cc6cb6917e2a0b5db60b4aa4..0e6bc69023def8ddd299baa7d47f6c0bddaade54 100644 (file)
@@ -20,7 +20,6 @@
 #include "PPCFrameInfo.h"
 #include "PPCSubtarget.h"
 #include "llvm/Constants.h"
-#include "llvm/Function.h"
 #include "llvm/Type.h"
 #include "llvm/CodeGen/ValueTypes.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -947,8 +946,6 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
   MachineBasicBlock::iterator MBBI = MBB.begin();
   MachineFrameInfo *MFI = MF.getFrameInfo();
   MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
-  bool needsFrameInfo = (MMI && MMI->hasDebugInfo()) ||
-       ExceptionHandling || !MF.getFunction()->doesNotThrow();
   
   // Prepare for frame info.
   unsigned FrameLabelId = 0;
@@ -1022,7 +1019,7 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
   unsigned TargetAlign = MF.getTarget().getFrameInfo()->getStackAlignment();
   unsigned MaxAlign = MFI->getMaxAlignment();
 
-  if (needsFrameInfo) {
+  if (MMI && MMI->needsFrameInfo()) {
     // Mark effective beginning of when frame pointer becomes valid.
     FrameLabelId = MMI->NextLabelID();
     BuildMI(MBB, MBBI, TII.get(PPC::LABEL)).addImm(FrameLabelId).addImm(0);
@@ -1098,7 +1095,7 @@ PPCRegisterInfo::emitPrologue(MachineFunction &MF) const {
     }
   }
   
-  if (needsFrameInfo) {
+  if (MMI && MMI->needsFrameInfo()) {
     std::vector<MachineMove> &Moves = MMI->getFrameMoves();
     
     if (NegFrameSize) {
index e1bc65fc5d64e365e18c1eed37dce5eef4089488..98e7d9c1e819943de53eced9a5819162666f9057 100644 (file)
@@ -381,9 +381,9 @@ bool X86SharedAsmPrinter::doFinalization(Module &M) {
 
     O << "\n";
 
-    if (TAI->doesSupportExceptionHandling() && MMI && !Subtarget->is64Bit()) {
+    if (ExceptionHandling && TAI->doesSupportExceptionHandling() && MMI &&
+        !Subtarget->is64Bit()) {
       // Add the (possibly multiple) personalities to the set of global values.
-      // Only referenced functions get into the Personalities list.
       const std::vector<Function *>& Personalities = MMI->getPersonalities();
 
       for (std::vector<Function *>::const_iterator I = Personalities.begin(),
index 95026f281ab48e22ca3f630d86eafa14d60840c0..5cd2fbe35e6618f1a3bdc67f39591402a88a8642 100644 (file)
@@ -504,8 +504,6 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
   MachineModuleInfo *MMI = MFI->getMachineModuleInfo();
   X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
   MachineBasicBlock::iterator MBBI = MBB.begin();
-  bool needsFrameInfo = (MMI && MMI->hasDebugInfo()) ||
-      ExceptionHandling || !Fn->doesNotThrow();
   
   // Prepare for frame info.
   unsigned FrameLabelId = 0;
@@ -538,7 +536,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
       .addReg(FramePtr);
     NumBytes -= SlotSize;
 
-    if (needsFrameInfo) {
+    if (MMI && MMI->needsFrameInfo()) {
       // Mark effective beginning of when frame pointer becomes valid.
       FrameLabelId = MMI->NextLabelID();
       BuildMI(MBB, MBBI, TII.get(X86::LABEL)).addImm(FrameLabelId).addImm(0);
@@ -550,7 +548,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
   }
   
   unsigned ReadyLabelId = 0;
-  if (needsFrameInfo) {
+  if (MMI && MMI->needsFrameInfo()) {
     // Mark effective beginning of when frame pointer is ready.
     ReadyLabelId = MMI->NextLabelID();
     BuildMI(MBB, MBBI, TII.get(X86::LABEL)).addImm(ReadyLabelId).addImm(0);
@@ -609,7 +607,7 @@ void X86RegisterInfo::emitPrologue(MachineFunction &MF) const {
     }
   }
 
-  if (needsFrameInfo) {
+  if (MMI && MMI->needsFrameInfo()) {
     std::vector<MachineMove> &Moves = MMI->getFrameMoves();
     const TargetData *TD = MF.getTarget().getTargetData();
 
index f546c332729a487b8eae686aa90a894f51d33591..7f0ef85d75ffcabca44bc258846cea4bf58c2145 100644 (file)
@@ -47,9 +47,6 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Target/TargetLowering.h"
-#include "llvm/Target/TargetOptions.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetAsmInfo.h"
 #include <csetjmp>
 #include <set>
 using namespace llvm;
@@ -595,12 +592,6 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
 }
 
 bool LowerInvoke::runOnFunction(Function &F) {
-  // If we will be generating exception info, don't do anything here.
-  if ((ExceptionHandling || !F.doesNotThrow()) &&
-      TLI &&
-      TLI->getTargetMachine().getTargetAsmInfo()->
-                              doesSupportExceptionHandling())
-    return false;
   if (ExpensiveEHSupport)
     return insertExpensiveEHSupport(F);
   else