hameeza ahmed via llvm-dev
2019-Apr-23 19:40 UTC
[llvm-dev] StringRef Iterator Variable Display
Hello, I want to display the variable names in stringref iterator. But it is not displayed using following code. for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) { errs() << *sit << " "; } How to do this? Please help.. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190424/d9f34186/attachment.html>
David Blaikie via llvm-dev
2019-Apr-23 20:15 UTC
[llvm-dev] StringRef Iterator Variable Display
Does the code compile and execute? If so, I guess the strings in your set are empty/zero-length. On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev <llvm-dev at lists.llvm.org> wrote:> > Hello, > I want to display the variable names in stringref iterator. But it is not displayed using following code. > > > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) { > errs() << *sit << " "; > } > > How to do this? > Please help.. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
David Blaikie via llvm-dev
2019-Apr-23 20:31 UTC
[llvm-dev] StringRef Iterator Variable Display
Oh, sorry, adding the mailing list back (since I don't know if/how to get the numbers) - perhaps someone else can suggest how to do that. I'd go and look at how the IR AsmPrinter does this, if I were trying to figure it out. On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <hahmed2305 at gmail.com> wrote:> > How to display these %num stored in stringref? > > On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <dblaikie at gmail.com> wrote: >> >> Ah, this is a function of where you're getting the names from, not >> where/how you're printing them out. >> >> %num named values in LLVM IR aren actually nameless - the numbering is >> only used for textual rendering, not as an actual name. These %num >> values will return false from "hasName". >> >> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <hahmed2305 at gmail.com> wrote: >> > >> > the code is compiled and executed. >> > When the strings are name they are displayed... >> > when strings are %number they are not dispalyed >> > >> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <dblaikie at gmail.com> wrote: >> >> >> >> Does the code compile and execute? If so, I guess the strings in your >> >> set are empty/zero-length. >> >> >> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev >> >> <llvm-dev at lists.llvm.org> wrote: >> >> > >> >> > Hello, >> >> > I want to display the variable names in stringref iterator. But it is not displayed using following code. >> >> > >> >> > >> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) { >> >> > errs() << *sit << " "; >> >> > } >> >> > >> >> > How to do this? >> >> > Please help.. >> >> > _______________________________________________ >> >> > LLVM Developers mailing list >> >> > llvm-dev at lists.llvm.org >> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Justin Bogner via llvm-dev
2019-Apr-23 21:15 UTC
[llvm-dev] StringRef Iterator Variable Display
Assuming you have an `Instruction *` or a `Value *`, you probably want `X->printAsOperand(errs(), /*PrintType=*/false)` or so. David Blaikie via llvm-dev <llvm-dev at lists.llvm.org> writes:> Oh, sorry, adding the mailing list back (since I don't know if/how to > get the numbers) - perhaps someone else can suggest how to do that. > > I'd go and look at how the IR AsmPrinter does this, if I were trying > to figure it out. > > On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <hahmed2305 at gmail.com> wrote: >> >> How to display these %num stored in stringref? >> >> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <dblaikie at gmail.com> wrote: >>> >>> Ah, this is a function of where you're getting the names from, not >>> where/how you're printing them out. >>> >>> %num named values in LLVM IR aren actually nameless - the numbering is >>> only used for textual rendering, not as an actual name. These %num >>> values will return false from "hasName". >>> >>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <hahmed2305 at gmail.com> wrote: >>> > >>> > the code is compiled and executed. >>> > When the strings are name they are displayed... >>> > when strings are %number they are not dispalyed >>> > >>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <dblaikie at gmail.com> wrote: >>> >> >>> >> Does the code compile and execute? If so, I guess the strings in your >>> >> set are empty/zero-length. >>> >> >>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev >>> >> <llvm-dev at lists.llvm.org> wrote: >>> >> > >>> >> > Hello, >>> >> > I want to display the variable names in stringref >>> >> > iterator. But it is not displayed using following code. >>> >> > >>> >> > >>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) { >>> >> > errs() << *sit << " "; >>> >> > } >>> >> > >>> >> > How to do this? >>> >> > Please help.. >>> >> > _______________________________________________ >>> >> > LLVM Developers mailing list >>> >> > llvm-dev at lists.llvm.org >>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
hameeza ahmed via llvm-dev
2019-Apr-24 20:42 UTC
[llvm-dev] StringRef Iterator Variable Display
it is working fine for alphabetic labels....but numeric labels are not displayed by stringref. what is the issue? please help.. On Wed, Apr 24, 2019 at 2:27 AM hameeza ahmed <hahmed2305 at gmail.com> wrote:> for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) { > std::string spr; > raw_string_ostream string_stream(spr); > sit->printAsOperand(string_stream, false);} > > this is giving error of *printasoperand *not member of sit > > On Wed, Apr 24, 2019 at 2:16 AM hameeza ahmed <hahmed2305 at gmail.com> > wrote: > >> Yes..agree I tried it...But this doesnot work with stringref.. >> >> On Wed, Apr 24, 2019 at 2:15 AM Justin Bogner <mail at justinbogner.com> >> wrote: >> >>> Assuming you have an `Instruction *` or a `Value *`, you probably want >>> `X->printAsOperand(errs(), /*PrintType=*/false)` or so. >>> >>> David Blaikie via llvm-dev <llvm-dev at lists.llvm.org> writes: >>> > Oh, sorry, adding the mailing list back (since I don't know if/how to >>> > get the numbers) - perhaps someone else can suggest how to do that. >>> > >>> > I'd go and look at how the IR AsmPrinter does this, if I were trying >>> > to figure it out. >>> > >>> > On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <hahmed2305 at gmail.com> >>> wrote: >>> >> >>> >> How to display these %num stored in stringref? >>> >> >>> >> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <dblaikie at gmail.com> >>> wrote: >>> >>> >>> >>> Ah, this is a function of where you're getting the names from, not >>> >>> where/how you're printing them out. >>> >>> >>> >>> %num named values in LLVM IR aren actually nameless - the numbering >>> is >>> >>> only used for textual rendering, not as an actual name. These %num >>> >>> values will return false from "hasName". >>> >>> >>> >>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <hahmed2305 at gmail.com> >>> wrote: >>> >>> > >>> >>> > the code is compiled and executed. >>> >>> > When the strings are name they are displayed... >>> >>> > when strings are %number they are not dispalyed >>> >>> > >>> >>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <dblaikie at gmail.com> >>> wrote: >>> >>> >> >>> >>> >> Does the code compile and execute? If so, I guess the strings in >>> your >>> >>> >> set are empty/zero-length. >>> >>> >> >>> >>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev >>> >>> >> <llvm-dev at lists.llvm.org> wrote: >>> >>> >> > >>> >>> >> > Hello, >>> >>> >> > I want to display the variable names in stringref >>> >>> >> > iterator. But it is not displayed using following code. >>> >>> >> > >>> >>> >> > >>> >>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); >>> sit++) { >>> >>> >> > errs() << *sit << " "; >>> >>> >> > } >>> >>> >> > >>> >>> >> > How to do this? >>> >>> >> > Please help.. >>> >>> >> > _______________________________________________ >>> >>> >> > LLVM Developers mailing list >>> >>> >> > llvm-dev at lists.llvm.org >>> >>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>> > _______________________________________________ >>> > LLVM Developers mailing list >>> > llvm-dev at lists.llvm.org >>> > https://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/20190425/d2658b05/attachment.html>
Craig Topper via llvm-dev
2019-Apr-24 21:08 UTC
[llvm-dev] StringRef Iterator Variable Display
PrintAsOperand works on a Value object. You tried to call it on a StringRef. You need to change the set to use std::string instead of StringRef and call printAsOperand when you put data into the set. On Wed, Apr 24, 2019 at 1:43 PM hameeza ahmed via llvm-dev < llvm-dev at lists.llvm.org> wrote:> it is working fine for alphabetic labels....but numeric labels are not > displayed by stringref. > > what is the issue? > please help.. > > On Wed, Apr 24, 2019 at 2:27 AM hameeza ahmed <hahmed2305 at gmail.com> > wrote: > >> for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); sit++) { >> std::string spr; >> raw_string_ostream string_stream(spr); >> sit->printAsOperand(string_stream, false);} >> >> this is giving error of *printasoperand *not member of sit >> >> On Wed, Apr 24, 2019 at 2:16 AM hameeza ahmed <hahmed2305 at gmail.com> >> wrote: >> >>> Yes..agree I tried it...But this doesnot work with stringref.. >>> >> >>> On Wed, Apr 24, 2019 at 2:15 AM Justin Bogner <mail at justinbogner.com> >>> wrote: >>> >>>> Assuming you have an `Instruction *` or a `Value *`, you probably want >>>> `X->printAsOperand(errs(), /*PrintType=*/false)` or so. >>>> >>>> David Blaikie via llvm-dev <llvm-dev at lists.llvm.org> writes: >>>> > Oh, sorry, adding the mailing list back (since I don't know if/how to >>>> > get the numbers) - perhaps someone else can suggest how to do that. >>>> > >>>> > I'd go and look at how the IR AsmPrinter does this, if I were trying >>>> > to figure it out. >>>> > >>>> > On Tue, Apr 23, 2019 at 1:26 PM hameeza ahmed <hahmed2305 at gmail.com> >>>> wrote: >>>> >> >>>> >> How to display these %num stored in stringref? >>>> >> >>>> >> On Wed, Apr 24, 2019 at 1:25 AM David Blaikie <dblaikie at gmail.com> >>>> wrote: >>>> >>> >>>> >>> Ah, this is a function of where you're getting the names from, not >>>> >>> where/how you're printing them out. >>>> >>> >>>> >>> %num named values in LLVM IR aren actually nameless - the numbering >>>> is >>>> >>> only used for textual rendering, not as an actual name. These %num >>>> >>> values will return false from "hasName". >>>> >>> >>>> >>> On Tue, Apr 23, 2019 at 1:18 PM hameeza ahmed <hahmed2305 at gmail.com> >>>> wrote: >>>> >>> > >>>> >>> > the code is compiled and executed. >>>> >>> > When the strings are name they are displayed... >>>> >>> > when strings are %number they are not dispalyed >>>> >>> > >>>> >>> > On Wed, Apr 24, 2019 at 1:15 AM David Blaikie <dblaikie at gmail.com> >>>> wrote: >>>> >>> >> >>>> >>> >> Does the code compile and execute? If so, I guess the strings in >>>> your >>>> >>> >> set are empty/zero-length. >>>> >>> >> >>>> >>> >> On Tue, Apr 23, 2019 at 12:41 PM hameeza ahmed via llvm-dev >>>> >>> >> <llvm-dev at lists.llvm.org> wrote: >>>> >>> >> > >>>> >>> >> > Hello, >>>> >>> >> > I want to display the variable names in stringref >>>> >>> >> > iterator. But it is not displayed using following code. >>>> >>> >> > >>>> >>> >> > >>>> >>> >> > for (set<StringRef>::iterator sit = L.begin(); sit != L.end(); >>>> sit++) { >>>> >>> >> > errs() << *sit << " "; >>>> >>> >> > } >>>> >>> >> > >>>> >>> >> > How to do this? >>>> >>> >> > Please help.. >>>> >>> >> > _______________________________________________ >>>> >>> >> > LLVM Developers mailing list >>>> >>> >> > llvm-dev at lists.llvm.org >>>> >>> >> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>> > _______________________________________________ >>>> > LLVM Developers mailing list >>>> > llvm-dev at lists.llvm.org >>>> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >>>> >>> _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-- ~Craig -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190424/39bc3d81/attachment.html>