summaryrefslogtreecommitdiffstats
path: root/llvm/include
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-29 18:56:03 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2016-03-29 18:56:03 +0000
commit40b44e1d0a2beafb86d402bbed521423d473aa81 (patch)
tree3380f76cf52ca5654c93b27da6b4e20bd2d9a218 /llvm/include
parent89daa29fa610db912fbcef8c283ae8c40702a7dd (diff)
downloadbcm5719-llvm-40b44e1d0a2beafb86d402bbed521423d473aa81.tar.gz
bcm5719-llvm-40b44e1d0a2beafb86d402bbed521423d473aa81.zip
IR: Add DbgInfoIntrinsic::getVariableLocation
Create a common accessor, DbgInfoIntrinsic::getVariableLocation, which doesn't care about the type of debug info intrinsic. Use this to further unify the implementations of DbgDeclareInst::getAddress and DbgValueInst::getValue. Besides being a cleanup, I'm planning to use this to prepare DEBUG output without having to branch on the concrete type. llvm-svn: 264767
Diffstat (limited to 'llvm/include')
-rw-r--r--llvm/include/llvm/IR/IntrinsicInst.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/include/llvm/IR/IntrinsicInst.h b/llvm/include/llvm/IR/IntrinsicInst.h
index af61c8fac08..50e16ce7126 100644
--- a/llvm/include/llvm/IR/IntrinsicInst.h
+++ b/llvm/include/llvm/IR/IntrinsicInst.h
@@ -58,6 +58,10 @@ namespace llvm {
/// This is the common base class for debug info intrinsics.
class DbgInfoIntrinsic : public IntrinsicInst {
public:
+ /// Get the location corresponding to the variable referenced by the debug
+ /// info intrinsic. Depending on the intrinsic, this could be the
+ /// variable's value or its address.
+ Value *getVariableLocation(bool AllowNullOp = true) const;
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const IntrinsicInst *I) {
@@ -78,7 +82,7 @@ namespace llvm {
/// This represents the llvm.dbg.declare instruction.
class DbgDeclareInst : public DbgInfoIntrinsic {
public:
- Value *getAddress() const;
+ Value *getAddress() const { return getVariableLocation(); }
DILocalVariable *getVariable() const {
return cast<DILocalVariable>(getRawVariable());
}
@@ -105,8 +109,9 @@ namespace llvm {
/// This represents the llvm.dbg.value instruction.
class DbgValueInst : public DbgInfoIntrinsic {
public:
- const Value *getValue() const;
- Value *getValue();
+ Value *getValue() const {
+ return getVariableLocation(/* AllowNullOp = */ false);
+ }
uint64_t getOffset() const {
return cast<ConstantInt>(
const_cast<Value*>(getArgOperand(1)))->getZExtValue();
OpenPOWER on IntegriCloud