[llvm-branch-commits] [llvm-gcc-branch] r86257 - in /llvm-gcc-4.2/branches/Apple/Leela/gcc: llvm-convert.cpp llvm-internal.h

Bob Wilson bob.wilson at apple.com
Fri Nov 6 09:45:17 PST 2009


Author: bwilson
Date: Fri Nov  6 11:45:16 2009
New Revision: 86257

URL: http://llvm.org/viewvc/llvm-project?rev=86257&view=rev
Log:
$ svn merge -c 86255 https://bwilson@llvm.org/svn/llvm-project/llvm-gcc-4.2/trunk
--- Merging r86255 into '.':
U    gcc/llvm-convert.cpp
U    gcc/llvm-internal.h

Modified:
    llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp
    llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-internal.h

Modified: llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp?rev=86257&r1=86256&r2=86257&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp (original)
+++ llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-convert.cpp Fri Nov  6 11:45:16 2009
@@ -181,11 +181,6 @@
   FuncEHSelector = 0;
   FuncEHGetTypeID = 0;
 
-#ifndef USEINDIRECTBRANCH
-  NumAddressTakenBlocks = 0;
-  IndirectGotoBlock = 0;
-#endif
-
   assert(TheTreeToLLVM == 0 && "Reentering function creation?");
   TheTreeToLLVM = this;
 }
@@ -728,20 +723,6 @@
   EmitPostPads();
   EmitUnwindBlock();
 
-#ifndef USEINDIRECTBRANCH
-  // If this function takes the address of a label, emit the indirect goto
-  // block.
-  if (IndirectGotoBlock) {
-    EmitBlock(IndirectGotoBlock);
-
-    // Change the default destination to go to one of the other destinations, if
-    // there is any other dest.
-    SwitchInst *SI = cast<SwitchInst>(IndirectGotoBlock->getTerminator());
-    if (SI->getNumSuccessors() > 1)
-      SI->setSuccessor(0, SI->getSuccessor(1));
-  }
-#endif
-
   // Remove any cached LLVM values that are local to this function.  Such values
   // may be deleted when the optimizers run, so would be dangerous to keep.
   eraseLocalLLVMValues();
@@ -1059,12 +1040,7 @@
 
   // Constants.
   case LABEL_DECL: {
-#ifdef USEINDIRECTBRANCH
     LV = LValue(EmitLV_LABEL_DECL(exp), 1);
-#else
-    Value *Ptr = TreeConstantToLLVM::EmitLV_LABEL_DECL(exp);
-    LV = LValue(Ptr, 1);
-#endif
     break;
   }
   case COMPLEX_CST: {
@@ -1689,46 +1665,6 @@
   }
 }
 
-#ifndef USEINDIRECTBRANCH
-//===----------------------------------------------------------------------===//
-//                ... Address Of Labels Extension Support ...
-//===----------------------------------------------------------------------===//
-
-/// getIndirectGotoBlockNumber - Return the unique ID of the specified basic
-/// block for uses that take the address of it.
-Constant *TreeToLLVM::getIndirectGotoBlockNumber(BasicBlock *BB) {
-  ConstantInt *&Val = AddressTakenBBNumbers[BB];
-  if (Val) return Val;
-
-  // Assign the new ID, update AddressTakenBBNumbers to remember it.
-  uint64_t BlockNo = ++NumAddressTakenBlocks;
-  BlockNo &= ~0ULL >> (64-TD.getPointerSizeInBits());
-  Val = ConstantInt::get(TD.getIntPtrType(Context), BlockNo);
-
-  // Add it to the switch statement in the indirect goto block.
-  cast<SwitchInst>(getIndirectGotoBlock()->getTerminator())->addCase(Val, BB);
-  return Val;
-}
-
-/// getIndirectGotoBlock - Get (and potentially lazily create) the indirect
-/// goto block.
-BasicBlock *TreeToLLVM::getIndirectGotoBlock() {
-  if (IndirectGotoBlock) return IndirectGotoBlock;
-
-  // Create a temporary for the value to be switched on.
-  IndirectGotoValue = CreateTemporary(TD.getIntPtrType(Context));
-
-  // Create the block, emit a load, and emit the switch in the block.
-  IndirectGotoBlock = BasicBlock::Create(Context, "indirectgoto");
-  Value *Ld = new LoadInst(IndirectGotoValue, "gotodest", IndirectGotoBlock);
-  SwitchInst::Create(Ld, IndirectGotoBlock, 0, IndirectGotoBlock);
-
-  // Finally, return it.
-  return IndirectGotoBlock;
-}
-#endif
-
-
 //===----------------------------------------------------------------------===//
 //                           ... Control Flow ...
 //===----------------------------------------------------------------------===//
@@ -1746,8 +1682,6 @@
     // Direct branch.
     Builder.CreateBr(getLabelDeclBlock(dest));
   } else {
-
-#ifdef USEINDIRECTBRANCH
     // Indirect branch.
     basic_block bb = bb_for_stmt(exp);
     Value *V = Emit(dest, 0);
@@ -1758,21 +1692,6 @@
     edge_iterator ei;
     FOR_EACH_EDGE (e, ei, bb->succs)
       Br->addDestination(getLabelDeclBlock(tree_block_label(e->dest)));
-#else
-    // Otherwise we have an indirect goto.
-    BasicBlock *DestBB = getIndirectGotoBlock();
-
-    // Store the destination block to the GotoValue alloca.
-    Value *V = Emit(dest, 0);
-    V = CastToType(Instruction::PtrToInt, V, TD.getIntPtrType(Context));
-    Builder.CreateStore(V, IndirectGotoValue);
-
-    // NOTE: This is HORRIBLY INCORRECT in the presence of exception handlers.
-    // There should be one collector block per cleanup level!  Note that
-    // standard GCC gets this wrong as well.
-    //
-    Builder.CreateBr(DestBB);
-#endif
   }
   EmitBlock(BasicBlock::Create(Context, ""));
   return 0;
@@ -6939,11 +6858,9 @@
   return LValue(Builder.CreateStructGEP(Ptr.Ptr, Idx), Alignment);
 }
 
-#ifdef USEINDIRECTBRANCH
 Constant *TreeToLLVM::EmitLV_LABEL_DECL(tree exp) {
   return BlockAddress::get(Fn, getLabelDeclBlock(exp));
 }
-#endif
 
 //===----------------------------------------------------------------------===//
 //                       ... Constant Expressions ...
@@ -8022,13 +7939,7 @@
            "Taking the address of a label that isn't in the current fn!?");
   }
 
-#ifdef USEINDIRECTBRANCH
   return TheTreeToLLVM->EmitLV_LABEL_DECL(exp);
-#else
-  BasicBlock *BB = getLabelDeclBlock(exp);
-  Constant *C = TheTreeToLLVM->getIndirectGotoBlockNumber(BB);
-  return TheFolder->CreateIntToPtr(C, Type::getInt8PtrTy(Context));
-#endif
 }
 
 Constant *TreeConstantToLLVM::EmitLV_COMPLEX_CST(tree exp) {

Modified: llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-internal.h
URL: http://llvm.org/viewvc/llvm-project/llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-internal.h?rev=86257&r1=86256&r2=86257&view=diff

==============================================================================
--- llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-internal.h (original)
+++ llvm-gcc-4.2/branches/Apple/Leela/gcc/llvm-internal.h Fri Nov  6 11:45:16 2009
@@ -331,24 +331,6 @@
   /// FuncEHGetTypeID - Function used to return type id for give typeinfo.
   Function *FuncEHGetTypeID;
 
-#ifndef USEINDIRECTBRANCH
-  /// NumAddressTakenBlocks - Count the number of labels whose addresses are
-  /// taken.
-  uint64_t NumAddressTakenBlocks;
-
-  /// AddressTakenBBNumbers - For each label with its address taken, we keep 
-  /// track of its unique ID.
-  std::map<BasicBlock*, ConstantInt*> AddressTakenBBNumbers;
-  
-  /// IndirectGotoBlock - If non-null, the block that indirect goto's in this
-  /// function branch to.
-  BasicBlock *IndirectGotoBlock;
-  
-  /// IndirectGotoValue - This is set to be the alloca temporary that the
-  /// indirect goto block switches on.
-  Value *IndirectGotoValue;
-#endif
-  
 public:
   TreeToLLVM(tree_node *fndecl);
   ~TreeToLLVM();
@@ -364,12 +346,6 @@
   /// the address of the result.
   LValue EmitLV(tree_node *exp);
 
-#ifndef USEINDIRECTBRANCH
-  /// getIndirectGotoBlockNumber - Return the unique ID of the specified basic
-  /// block for uses that take the address of it.
-  Constant *getIndirectGotoBlockNumber(BasicBlock *BB);
-#endif
-  
   /// getIndirectGotoBlock - Get (and potentially lazily create) the indirect
   /// goto block.
   BasicBlock *getIndirectGotoBlock();
@@ -613,11 +589,9 @@
                             const Type *ResultType,
                             std::vector<Value*> &Ops);
 
-#ifdef USEINDIRECTBRANCH
 public:
   // Helper for taking the address of a label.
   Constant *EmitLV_LABEL_DECL(tree_node *exp);
-#endif
 };
 
 /// TreeConstantToLLVM - An instance of this class is created and used to 





More information about the llvm-branch-commits mailing list