[llvm-commits] [llvm] r92231 - in /llvm/trunk: include/llvm/Support/IRBuilder.h lib/VMCore/IRBuilder.cpp

Chris Lattner sabre at nondot.org
Mon Dec 28 13:50:56 PST 2009


Author: lattner
Date: Mon Dec 28 15:50:56 2009
New Revision: 92231

URL: http://llvm.org/viewvc/llvm-project?rev=92231&view=rev
Log:
remove #include of Function.h from IRBuilder

Modified:
    llvm/trunk/include/llvm/Support/IRBuilder.h
    llvm/trunk/lib/VMCore/IRBuilder.cpp

Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=92231&r1=92230&r2=92231&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Mon Dec 28 15:50:56 2009
@@ -17,7 +17,7 @@
 
 #include "llvm/Constants.h"
 #include "llvm/Instructions.h"
-#include "llvm/Function.h"
+#include "llvm/BasicBlock.h"
 #include "llvm/ADT/Twine.h"
 #include "llvm/Support/ConstantFolder.h"
 
@@ -143,6 +143,10 @@
   const Type *getVoidTy() {
     return Type::getVoidTy(Context);
   }
+  
+  /// getCurrentFunctionReturnType - Get the return type of the current function
+  /// that we're emitting into.
+  const Type *getCurrentFunctionReturnType() const;
 };
   
 /// IRBuilder - This provides a uniform API for creating instructions and
@@ -221,7 +225,7 @@
   ReturnInst *CreateRet(Value *V) {
     return Insert(ReturnInst::Create(Context, V));
   }
-
+  
   /// CreateAggregateRet - Create a sequence of N insertvalue instructions,
   /// with one Value from the retVals array each, that build a aggregate
   /// return value one value at a time, and a ret instruction to return
@@ -229,9 +233,8 @@
   /// code that uses aggregate return values as a vehicle for having
   /// multiple return values.
   ///
-  ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) {
-    const Type *RetType = BB->getParent()->getReturnType();
-    Value *V = UndefValue::get(RetType);
+  ReturnInst *CreateAggregateRet(Value *const *retVals, unsigned N) {
+    Value *V = UndefValue::get(getCurrentFunctionReturnType());
     for (unsigned i = 0; i != N; ++i)
       V = CreateInsertValue(V, retVals[i], i, "mrv");
     return Insert(ReturnInst::Create(Context, V));

Modified: llvm/trunk/lib/VMCore/IRBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/IRBuilder.cpp?rev=92231&r1=92230&r2=92231&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/IRBuilder.cpp (original)
+++ llvm/trunk/lib/VMCore/IRBuilder.cpp Mon Dec 28 15:50:56 2009
@@ -14,6 +14,7 @@
 
 #include "llvm/Support/IRBuilder.h"
 #include "llvm/GlobalVariable.h"
+#include "llvm/Function.h"
 #include "llvm/Metadata.h"
 #include "llvm/LLVMContext.h"
 using namespace llvm;
@@ -44,3 +45,8 @@
   if (CurDbgLocation)
     Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I);
 }
+
+const Type *IRBuilderBase::getCurrentFunctionReturnType() const {
+  assert(BB && BB->getParent() && "No current function!");
+  return BB->getParent()->getReturnType();
+}





More information about the llvm-commits mailing list