[llvm-dev] Print emory for constant address

Craig Topper via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 7 11:51:03 PDT 2018


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>


More information about the llvm-dev mailing list