Alberto Barbaro via llvm-dev
2019-Dec-08 08:38 UTC
[llvm-dev] How to generate a .ll file with functions' parameter names
Hi all, I'm trying to obtain a .ll with parameters name for every function. My simple c C is the following: int sum(int a, int b) { return a+b; } int main() { sum(1,2); } I obtain the .ll with the following commands: clang -emit-llvm sum.c -c llvm-dis-7 sum.bc The obtained .ll is: cat sum.ll ; ModuleID = 'sum.bc' source_filename = "sum.c" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-linux-gnu" ; Function Attrs: noinline nounwind optnone uwtable define i32 @sum(i32, i32) #0 { %3 = alloca i32, align 4 %4 = alloca i32, align 4 store i32 %0, i32* %3, align 4 store i32 %1, i32* %4, align 4 %5 = load i32, i32* %3, align 4 %6 = load i32, i32* %4, align 4 %7 = add nsw i32 %5, %6 ret i32 %7 } ; Function Attrs: noinline nounwind optnone uwtable define i32 @main() #0 { %1 = call i32 @sum(i32 1, i32 2) ret i32 0 } attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } !llvm.module.flags = !{!0} !llvm.ident = !{!1} !0 = !{i32 1, !"wchar_size", i32 4} !1 = !{!"clang version 6.0.1-svn334776-1~exp1~20190309042703.125 (branches/release_60)"} Could you tell me why I don't see a and b parameters for the sum function? Thanks Alberto -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191208/0d499d24/attachment.html>
Hideto Ueno via llvm-dev
2019-Dec-08 08:50 UTC
[llvm-dev] How to generate a .ll file with functions' parameter names
Hi Alberto, Variable names in LLVM IR are meaningless and only used for debugging. However, if you want to preserve the variable name, you can use `-fno-discard-value-names` option. Regards, Hideto 2019年12月8日(日) 17:38 Alberto Barbaro via llvm-dev <llvm-dev at lists.llvm.org>:> Hi all, > I'm trying to obtain a .ll with parameters name for every function. My > simple c C is the following: > > int sum(int a, int b) { > return a+b; > } > > int main() { > sum(1,2); > } > > I obtain the .ll with the following commands: > > clang -emit-llvm sum.c -c > llvm-dis-7 sum.bc > > The obtained .ll is: > > cat sum.ll > ; ModuleID = 'sum.bc' > source_filename = "sum.c" > target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" > target triple = "x86_64-pc-linux-gnu" > > ; Function Attrs: noinline nounwind optnone uwtable > define i32 @sum(i32, i32) #0 { > %3 = alloca i32, align 4 > %4 = alloca i32, align 4 > store i32 %0, i32* %3, align 4 > store i32 %1, i32* %4, align 4 > %5 = load i32, i32* %3, align 4 > %6 = load i32, i32* %4, align 4 > %7 = add nsw i32 %5, %6 > ret i32 %7 > } > > ; Function Attrs: noinline nounwind optnone uwtable > define i32 @main() #0 { > %1 = call i32 @sum(i32 1, i32 2) > ret i32 0 > } > > attributes #0 = { noinline nounwind optnone uwtable > "correctly-rounded-divide-sqrt-fp-math"="false" > "disable-tail-calls"="false" "less-precise-fpmad"="false" > "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" > "no-infs-fp-math"="false" "no-jump-tables"="false" > "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" > "no-trapping-math"="false" "stack-protector-buffer-size"="8" > "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" > "unsafe-fp-math"="false" "use-soft-float"="false" } > > !llvm.module.flags = !{!0} > !llvm.ident = !{!1} > > !0 = !{i32 1, !"wchar_size", i32 4} > !1 = !{!"clang version 6.0.1-svn334776-1~exp1~20190309042703.125 > (branches/release_60)"} > > Could you tell me why I don't see a and b parameters for the sum function? > > Thanks > Alberto > _______________________________________________ > 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/20191208/aaa3f726/attachment.html>
Alberto Barbaro via llvm-dev
2019-Dec-08 09:54 UTC
[llvm-dev] How to generate a .ll file with functions' parameter names
Hi Hideto, thanks for your answer. Unfortunately I'm still using llvm 6.0 and in llvm-dis I don't see that option. I tried reading the full list of options but I didn't see an alternative. Do you have any suggestions? Thanks Alberto Il giorno dom 8 dic 2019 alle ore 08:50 Hideto Ueno < uenoku.tokotoko at gmail.com> ha scritto:> Hi Alberto, > > Variable names in LLVM IR are meaningless and only used for debugging. > However, if you want to preserve the variable name, you can use > `-fno-discard-value-names` option. > > Regards, > Hideto > > 2019年12月8日(日) 17:38 Alberto Barbaro via llvm-dev <llvm-dev at lists.llvm.org > >: > >> Hi all, >> I'm trying to obtain a .ll with parameters name for every function. My >> simple c C is the following: >> >> int sum(int a, int b) { >> return a+b; >> } >> >> int main() { >> sum(1,2); >> } >> >> I obtain the .ll with the following commands: >> >> clang -emit-llvm sum.c -c >> llvm-dis-7 sum.bc >> >> The obtained .ll is: >> >> cat sum.ll >> ; ModuleID = 'sum.bc' >> source_filename = "sum.c" >> target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" >> target triple = "x86_64-pc-linux-gnu" >> >> ; Function Attrs: noinline nounwind optnone uwtable >> define i32 @sum(i32, i32) #0 { >> %3 = alloca i32, align 4 >> %4 = alloca i32, align 4 >> store i32 %0, i32* %3, align 4 >> store i32 %1, i32* %4, align 4 >> %5 = load i32, i32* %3, align 4 >> %6 = load i32, i32* %4, align 4 >> %7 = add nsw i32 %5, %6 >> ret i32 %7 >> } >> >> ; Function Attrs: noinline nounwind optnone uwtable >> define i32 @main() #0 { >> %1 = call i32 @sum(i32 1, i32 2) >> ret i32 0 >> } >> >> attributes #0 = { noinline nounwind optnone uwtable >> "correctly-rounded-divide-sqrt-fp-math"="false" >> "disable-tail-calls"="false" "less-precise-fpmad"="false" >> "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" >> "no-infs-fp-math"="false" "no-jump-tables"="false" >> "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" >> "no-trapping-math"="false" "stack-protector-buffer-size"="8" >> "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" >> "unsafe-fp-math"="false" "use-soft-float"="false" } >> >> !llvm.module.flags = !{!0} >> !llvm.ident = !{!1} >> >> !0 = !{i32 1, !"wchar_size", i32 4} >> !1 = !{!"clang version 6.0.1-svn334776-1~exp1~20190309042703.125 >> (branches/release_60)"} >> >> Could you tell me why I don't see a and b parameters for the sum function? >> >> Thanks >> Alberto >> _______________________________________________ >> 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/20191208/f3dbcdac/attachment.html>
Maybe Matching Threads
- How to generate a .ll file with functions' parameter names
- GSoC2019 - Improve function attribute inference
- How to generate a .ll file with functions' parameter names
- Missing code depending on a #ifdef within the .ll file
- How to generate a .ll file with functions' parameter names