[cfe-users] Getting variable names in LLVM IR
Hi, I'm a newbie in LLVM environment. I'm trying to generate the LLVM IR of a c file using clang. The command line argument I'm passing is as : "clang -O0 -S -emit-llvm test.c -c -o test.ll" It is generating the LLVM IR properly but I'm not getting the variable names. e.g, for the c file : #include int main() { int x; int y; x = 2; y =4; int z = x*y; if(x==y) { z = x*y; return z; } else { z = x+y; } printf("z = %d", z); return 0; } the corresponding llvm IR is : ; Function Attrs: nounwind uwtable define i32 @main() #0 { %1 = alloca i32, align 4 %2 = alloca i32, align 4 %3 = alloca i32, align 4 %4 = alloca i32, align 4 store i32 0, i32* %1, align 4 store i32 2, i32* %2, align 4 store i32 4, i32* %3, align 4 %5 = load i32, i32* %2, align 4 %6 = load i32, i32* %3, align 4 %7 = mul nsw i32 %5, %6 store i32 %7, i32* %4, align 4 %8 = load i32, i32* %2, align 4 %9 = load i32, i32* %3, align 4 %10 = icmp eq i32 %8, %9 br i1 %10, label %11, label %16 ; :11: ; preds = %0 %12 = load i32, i32* %2, align 4 %13 = load i32, i32* %3, align 4 %14 = mul nsw i32 %12, %13 store i32 %14, i32* %4, align 4 %15 = load i32, i32* %4, align 4 store i32 %15, i32* %1, align 4 br label %21 ; :16: ; preds = %0 %17 = load i32, i32* %2, align 4 %18 = load i32, i32* %3, align 4 %19 = add nsw i32 %17, %18 store i32 %19, i32* %4, align 4 br label %20 ; :20: ; preds = %16 store i32 0, i32* %1, align 4 br label %21 ; :21: ; preds = %20, %11 %22 = load i32, i32* %1, align 4 ret i32 %22 } I wanted to get the variables in their original name i.e, x,y,z instead of %1,%2,%3, etc. Is it possible to do so? Thanks. ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] .deb package for LibC++
Eric, I'd be happy to do this work. However, I have no experience with developing LLVM / Clang / LibC++, so I'll need some mentoring. I do have some experience on creating Debian packages though, from a few years back. Let me know how we should proceed with this. For start, where shall I start looking at how Clang packages are created and deployed to apt.llvm.org ? Cheers, M. On Mon, Feb 13, 2017 at 3:18 PM Eric Fiselier wrote: > I don't know about any .deb packages for libc++, but I sure would > appreciate somebody working on it :-) > > /Eric > > On Mon, Feb 13, 2017 at 10:25 AM, Duncan P. N. Exon Smith < > dexonsm...@apple.com> wrote: > > +Eric > > Eric, do you know? > > On 2017-Feb-12, at 13:43, Michal Jaszczyk via cfe-users < > cfe-users@lists.llvm.org> wrote: > > Hey, > > I'm trying to set up my Ubuntu Yakkety dev environment to use Clang and > LibC++. > > I'm trying to use Clang 4.0. It is not available in Yakkety by default, > but http://apt.llvm.org/ conveniently offers an Apt repository to get the > right package. I was able to use that and get Clang 4.0 pretty smoothly. > > Similarly, I'd like to use LibC++ 4.0. Yakkety offers 3.7 by default, and > it is actually broken. However, it seems that apt.llvm.org does not > provide .deb packages for LibC++. Is there anywhere I could find them? > > If none exist, how hard would it be to add them? I'd be willing to spend > some time trying to make this happen. > > Cheers, > > M. > > ___ > cfe-users mailing list > cfe-users@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users > > > > ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] .deb package for LibC++
I don't know about any .deb packages for libc++, but I sure would appreciate somebody working on it :-) /Eric On Mon, Feb 13, 2017 at 10:25 AM, Duncan P. N. Exon Smith < dexonsm...@apple.com> wrote: > +Eric > > Eric, do you know? > > On 2017-Feb-12, at 13:43, Michal Jaszczyk via cfe-users < > cfe-users@lists.llvm.org> wrote: > > Hey, > > I'm trying to set up my Ubuntu Yakkety dev environment to use Clang and > LibC++. > > I'm trying to use Clang 4.0. It is not available in Yakkety by default, > but http://apt.llvm.org/ conveniently offers an Apt repository to get the > right package. I was able to use that and get Clang 4.0 pretty smoothly. > > Similarly, I'd like to use LibC++ 4.0. Yakkety offers 3.7 by default, and > it is actually broken. However, it seems that apt.llvm.org does not > provide .deb packages for LibC++. Is there anywhere I could find them? > > If none exist, how hard would it be to add them? I'd be willing to spend > some time trying to make this happen. > > Cheers, > > M. > > ___ > cfe-users mailing list > cfe-users@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users > > > ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
Re: [cfe-users] Getting variable names in LLVM IR
> On 2017-Feb-13, at 23:10, Subhendu Malakar via cfe-users > wrote: > > Hi, > I'm a newbie in LLVM environment. > > I'm trying to generate the LLVM IR of a c file using clang. The command line > argument I'm passing is as : > "clang -O0 -S -emit-llvm test.c -c -o test.ll" If you add "-###" to the end of the command-line you can see the raw -cc1 command for the compilation. Depending on your version of clang, you should see "-discard-value-names" in there. If you repeat the -cc1 command yourself, skipping that option, you'll get variable names. If you're compiling clang yourself (it doesn't sound like you are, but just in case), this -discard-value-names option is *not* passed by default in asserts builds. > > It is generating the LLVM IR properly but I'm not getting the variable names. > e.g, > > for the c file : > #include > > int main() > { >int x; >int y; >x = 2; >y =4; >int z = x*y; > >if(x==y) >{ >z = x*y; >return z; >} else >{ >z = x+y; >} >printf("z = %d", z); >return 0; > } > > > the corresponding llvm IR is : > > ; Function Attrs: nounwind uwtable > define i32 @main() #0 { > %1 = alloca i32, align 4 > %2 = alloca i32, align 4 > %3 = alloca i32, align 4 > %4 = alloca i32, align 4 > store i32 0, i32* %1, align 4 > store i32 2, i32* %2, align 4 > store i32 4, i32* %3, align 4 > %5 = load i32, i32* %2, align 4 > %6 = load i32, i32* %3, align 4 > %7 = mul nsw i32 %5, %6 > store i32 %7, i32* %4, align 4 > %8 = load i32, i32* %2, align 4 > %9 = load i32, i32* %3, align 4 > %10 = icmp eq i32 %8, %9 > br i1 %10, label %11, label %16 > > ; :11: ; preds = %0 > %12 = load i32, i32* %2, align 4 > %13 = load i32, i32* %3, align 4 > %14 = mul nsw i32 %12, %13 > store i32 %14, i32* %4, align 4 > %15 = load i32, i32* %4, align 4 > store i32 %15, i32* %1, align 4 > br label %21 > > ; :16: ; preds = %0 > %17 = load i32, i32* %2, align 4 > %18 = load i32, i32* %3, align 4 > %19 = add nsw i32 %17, %18 > store i32 %19, i32* %4, align 4 > br label %20 > > ; :20: ; preds = %16 > store i32 0, i32* %1, align 4 > br label %21 > > ; :21: ; preds = %20, %11 > %22 = load i32, i32* %1, align 4 > ret i32 %22 > } > > > I wanted to get the variables in their original name i.e, x,y,z instead of > %1,%2,%3, etc. > Is it possible to do so? > > Thanks. > ___ > cfe-users mailing list > cfe-users@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users ___ cfe-users mailing list cfe-users@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users