summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2015-12-08 00:13:12 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2015-12-08 00:13:12 +0000
commit411fdcd460312b4b441bda60c138d9877f2d426e (patch)
tree7760dd5e4c46256bf52e0d89183c5e6c9064f596
parent5ae3418ffecc754a72d5b71bf9d5c8bc95cde70a (diff)
downloadbcm5719-llvm-411fdcd460312b4b441bda60c138d9877f2d426e.tar.gz
bcm5719-llvm-411fdcd460312b4b441bda60c138d9877f2d426e.zip
Add Instruction::getFunction; NFC
Will be used in a upcoming patch. llvm-svn: 254975
-rw-r--r--llvm/include/llvm/IR/Instruction.h7
-rw-r--r--llvm/lib/IR/Instruction.cpp5
2 files changed, 12 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index c7ba8721fe0..77ba87c6b66 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -66,6 +66,13 @@ public:
const Module *getModule() const;
Module *getModule();
+ /// \brief Return the function this instruction belongs to.
+ ///
+ /// Note: it is undefined behavior to call this on an instruction not
+ /// currently inserted into a function.
+ const Function *getFunction() const;
+ Function *getFunction();
+
/// removeFromParent - This method unlinks 'this' from the containing basic
/// block, but does not delete it.
///
diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp
index b5a30a4969b..7bd50328b12 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -62,6 +62,11 @@ Module *Instruction::getModule() {
return getParent()->getModule();
}
+Function *Instruction::getFunction() { return getParent()->getParent(); }
+
+const Function *Instruction::getFunction() const {
+ return getParent()->getParent();
+}
void Instruction::removeFromParent() {
getParent()->getInstList().remove(getIterator());
OpenPOWER on IntegriCloud