remove #include of Function.h from IRBuilder

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92231 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2009-12-28 21:50:56 +00:00
parent 43469b6957
commit 2ad32752b9
2 changed files with 14 additions and 5 deletions

View File

@@ -17,7 +17,7 @@
#include "llvm/Constants.h" #include "llvm/Constants.h"
#include "llvm/Instructions.h" #include "llvm/Instructions.h"
#include "llvm/Function.h" #include "llvm/BasicBlock.h"
#include "llvm/ADT/Twine.h" #include "llvm/ADT/Twine.h"
#include "llvm/Support/ConstantFolder.h" #include "llvm/Support/ConstantFolder.h"
@@ -143,6 +143,10 @@ public:
const Type *getVoidTy() { const Type *getVoidTy() {
return Type::getVoidTy(Context); 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 /// IRBuilder - This provides a uniform API for creating instructions and
@@ -230,8 +234,7 @@ public:
/// multiple return values. /// multiple return values.
/// ///
ReturnInst *CreateAggregateRet(Value *const *retVals, unsigned N) { ReturnInst *CreateAggregateRet(Value *const *retVals, unsigned N) {
const Type *RetType = BB->getParent()->getReturnType(); Value *V = UndefValue::get(getCurrentFunctionReturnType());
Value *V = UndefValue::get(RetType);
for (unsigned i = 0; i != N; ++i) for (unsigned i = 0; i != N; ++i)
V = CreateInsertValue(V, retVals[i], i, "mrv"); V = CreateInsertValue(V, retVals[i], i, "mrv");
return Insert(ReturnInst::Create(Context, V)); return Insert(ReturnInst::Create(Context, V));

View File

@@ -14,6 +14,7 @@
#include "llvm/Support/IRBuilder.h" #include "llvm/Support/IRBuilder.h"
#include "llvm/GlobalVariable.h" #include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
#include "llvm/Metadata.h" #include "llvm/Metadata.h"
#include "llvm/LLVMContext.h" #include "llvm/LLVMContext.h"
using namespace llvm; using namespace llvm;
@@ -44,3 +45,8 @@ void IRBuilderBase::SetInstDebugLocation(Instruction *I) const {
if (CurDbgLocation) if (CurDbgLocation)
Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I); Context.getMetadata().addMD(DbgMDKind, CurDbgLocation, I);
} }
const Type *IRBuilderBase::getCurrentFunctionReturnType() const {
assert(BB && BB->getParent() && "No current function!");
return BB->getParent()->getReturnType();
}