Hi all, Consider a simple ll code: %2 = load i32* %y, align 4 I intend to get the memory address of %2. if(isa<loadInst>(I)){ // variable name:y value v = I.getOperand(0); // ? I shows the entire instruction, not %2, then I.getName() would print an empty space which is %2, but I can’t get the memory when dereferencing it errs()<< *&(I.getName())<<"\n”; } error: taking the address of an temporary object of type llvm::stringRef. Please suggest what should I use to get the actual address of the register name %2. Thanks, Ethan -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180408/7abbeeb4/attachment.html>
Craig Topper via llvm-dev
2018-Apr-07 18:51 UTC
[llvm-dev] Print emory for constant address
If you just want to print %2 and not the whole instruction, I think you can use I.printAsOperand(errs()) ~Craig On Sat, Apr 7, 2018 at 11:43 AM, Zhizhong via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi all, > > Consider a simple ll code: > %2 = load i32* %y, align 4 > > I intend to get the memory address of %2. > if(isa<loadInst>(I)){ > // variable name:y > value v = I.getOperand(0); > // ? I shows the entire instruction, not %2, then I.getName() would print > an empty space which is %2, but I can’t get the memory when dereferencing it > errs()<< *&(I.getName())<<"\n”; > } > > error: taking the address of an temporary object of type llvm::stringRef. > > Please suggest what should I use to get the actual address of the register > name %2. > > Thanks, > Ethan > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180407/34dd74c4/attachment.html>