Remove getDataLayout() from Instruction/GlobalValue/BasicBlock/Function
Summary:
This does not conceptually belongs here. Instead provide a shortcut
getModule() that provides access to the DataLayout.
Reviewers: chandlerc, echristo
Reviewed By: echristo
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D8027
From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 231147
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index eac7d3a..fe38385 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -29,10 +29,6 @@
return nullptr;
}
-const DataLayout *BasicBlock::getDataLayout() const {
- return getParent()->getDataLayout();
-}
-
LLVMContext &BasicBlock::getContext() const {
return getType()->getContext();
}
@@ -117,6 +113,9 @@
getParent()->getBasicBlockList(), this);
}
+const Module *BasicBlock::getModule() const {
+ return getParent()->getParent();
+}
TerminatorInst *BasicBlock::getTerminator() {
if (InstList.empty()) return nullptr;
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 54197d9..5a6adb3 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -42,10 +42,6 @@
getParent()->Dematerialize(this);
}
-const DataLayout *GlobalValue::getDataLayout() const {
- return getParent()->getDataLayout();
-}
-
/// Override destroyConstant to make sure it doesn't get called on
/// GlobalValue's because they shouldn't be treated like other constants.
void GlobalValue::destroyConstant() {
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index 92c6e9f..7d9bd7e 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -32,10 +32,6 @@
}
}
-const DataLayout *Instruction::getDataLayout() const {
- return getParent()->getDataLayout();
-}
-
Instruction::Instruction(Type *ty, unsigned it, Use *Ops, unsigned NumOps,
BasicBlock *InsertAtEnd)
: User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(nullptr) {
@@ -58,6 +54,10 @@
Parent = P;
}
+const Module *Instruction::getModule() const {
+ return getParent()->getModule();
+}
+
void Instruction::removeFromParent() {
getParent()->getInstList().remove(this);
}