summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2014-02-25 23:25:17 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2014-02-25 23:25:17 +0000
commit356deb5ecde78fdef706e325325c23c828666b9f (patch)
tree21aa8a0fb4fed7044dc5449561035d3d8e26a825 /include
parent7e2bf3c6f908cc79dd48c69f86920a3826141e72 (diff)
downloadllvm-356deb5ecde78fdef706e325325c23c828666b9f.tar.gz
llvm-356deb5ecde78fdef706e325325c23c828666b9f.tar.bz2
llvm-356deb5ecde78fdef706e325325c23c828666b9f.tar.xz
Use DataLayout from the module when easily available.
Eventually DataLayoutPass should go away, but for now that is the only easy way to get a DataLayout in some APIs. This patch only changes the ones that have easy access to a Module. One interesting issue with sometimes using DataLayoutPass and sometimes fetching it from the Module is that we have to make sure they are equivalent. We can get most of the way there by always constructing the pass with a Module. In fact, the pass could be changed to point to an external DataLayout instead of owning one to make this stricter. Unfortunately, the C api passes a DataLayout, so it has to be up to the caller to make sure the pass and the module are in sync. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202204 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Analysis/InlineCost.h1
-rw-r--r--include/llvm/IR/BasicBlock.h2
-rw-r--r--include/llvm/IR/DataLayout.h4
-rw-r--r--include/llvm/IR/GlobalValue.h2
-rw-r--r--include/llvm/IR/Instruction.h2
5 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/Analysis/InlineCost.h b/include/llvm/Analysis/InlineCost.h
index ab1d500b73..a9d8d313e4 100644
--- a/include/llvm/Analysis/InlineCost.h
+++ b/include/llvm/Analysis/InlineCost.h
@@ -99,7 +99,6 @@ public:
/// \brief Cost analyzer used by inliner.
class InlineCostAnalysis : public CallGraphSCCPass {
- const DataLayout *DL;
const TargetTransformInfo *TTI;
public:
diff --git a/include/llvm/IR/BasicBlock.h b/include/llvm/IR/BasicBlock.h
index 3bdc95d556..1adc254a61 100644
--- a/include/llvm/IR/BasicBlock.h
+++ b/include/llvm/IR/BasicBlock.h
@@ -116,6 +116,8 @@ public:
const Function *getParent() const { return Parent; }
Function *getParent() { return Parent; }
+ const DataLayout *getDataLayout() const;
+
/// \brief Returns the terminator instruction if the block is well formed or
/// null if the block is not well formed.
TerminatorInst *getTerminator();
diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h
index 046553dc1a..5bdfc49875 100644
--- a/include/llvm/IR/DataLayout.h
+++ b/include/llvm/IR/DataLayout.h
@@ -460,10 +460,10 @@ public:
const DataLayout &getDataLayout() const { return DL; }
+ // For use with the C API. C++ code should always use the constructor that
+ // takes a module.
explicit DataLayoutPass(const DataLayout &DL);
- explicit DataLayoutPass(StringRef LayoutDescription);
-
explicit DataLayoutPass(const Module *M);
static char ID; // Pass identification, replacement for typeid
diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h
index f0c80673be..32108b153c 100644
--- a/include/llvm/IR/GlobalValue.h
+++ b/include/llvm/IR/GlobalValue.h
@@ -300,6 +300,8 @@ public:
inline Module *getParent() { return Parent; }
inline const Module *getParent() const { return Parent; }
+ const DataLayout *getDataLayout() const;
+
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const Value *V) {
return V->getValueID() == Value::FunctionVal ||
diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h
index 0a245483ff..8ba8b9c4f1 100644
--- a/include/llvm/IR/Instruction.h
+++ b/include/llvm/IR/Instruction.h
@@ -53,6 +53,8 @@ public:
inline const BasicBlock *getParent() const { return Parent; }
inline BasicBlock *getParent() { return Parent; }
+ const DataLayout *getDataLayout() const;
+
/// removeFromParent - This method unlinks 'this' from the containing basic
/// block, but does not delete it.
///