How get IR value from llvm.dbg.declare

2019-07-28 04:10发布

Given a llvm.dbg.declare, how can I get its llvm value?

e.g.

call void @llvm.dbg.declare(metadata !{i32** %r}, metadata !23), !dbg !24

I want get the Value i32** %r, not the metadata !{i32** %r}.

Please give me the code!

Thanks!

1条回答
疯言疯语
2楼-- · 2019-07-28 04:18

metadata !{i32** %r} is the 1st operand of the call instruction, and i32** %r is the 1st operand of the metadata. So something like this should work:

CallInst I = ... // get the @llvm.dbg.declare call
Value* referredValue = cast<MDNode>(I->getOperand(0))->getOperand(0);
查看更多
登录 后发表回答