summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-12-28 21:28:46 +0000
committerChris Lattner <sabre@nondot.org>2009-12-28 21:28:46 +0000
commita53cfd16f075f22655a8c965b122aea38e635aa3 (patch)
tree8de4419f79bed5908825ada0055c19cb4763657d /lib
parentaca8d54c4f9a81e46fc94425392203d414b83376 (diff)
downloadllvm-a53cfd16f075f22655a8c965b122aea38e635aa3.tar.gz
llvm-a53cfd16f075f22655a8c965b122aea38e635aa3.tar.bz2
llvm-a53cfd16f075f22655a8c965b122aea38e635aa3.tar.xz
split code that doesn't need to be templated out of IRBuilder into a new
non-templated IRBuilderBase class. Move that large CreateGlobalString out of line, eliminating the need to #include GlobalVariable.h in IRBuilder.h git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@92227 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Transforms/Scalar/GVN.cpp1
-rw-r--r--lib/VMCore/IRBuilder.cpp31
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 249194d036..612b41587e 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -20,6 +20,7 @@
#include "llvm/BasicBlock.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/GlobalVariable.h"
#include "llvm/Function.h"
#include "llvm/IntrinsicInst.h"
#include "llvm/LLVMContext.h"
diff --git a/lib/VMCore/IRBuilder.cpp b/lib/VMCore/IRBuilder.cpp
new file mode 100644
index 0000000000..850812cf66
--- /dev/null
+++ b/lib/VMCore/IRBuilder.cpp
@@ -0,0 +1,31 @@
+//===---- IRBuilder.cpp - Builder for LLVM Instrs -------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file implements the IRBuilder class, which is used as a convenient way
+// to create LLVM instructions with a consistent and simplified interface.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Support/IRBuilder.h"
+#include "llvm/GlobalVariable.h"
+using namespace llvm;
+
+/// CreateGlobalString - Make a new global variable with an initializer that
+/// has array of i8 type filled in the the nul terminated string value
+/// specified. If Name is specified, it is the name of the global variable
+/// created.
+Value *IRBuilderBase::CreateGlobalString(const char *Str, const Twine &Name) {
+ Constant *StrConstant = ConstantArray::get(Context, Str, true);
+ Module &M = *BB->getParent()->getParent();
+ GlobalVariable *GV = new GlobalVariable(M, StrConstant->getType(),
+ true, GlobalValue::InternalLinkage,
+ StrConstant, "", 0, false);
+ GV->setName(Name);
+ return GV;
+}