Thomas Ströder via llvm-dev
2015-Aug-16 11:26 UTC
[llvm-dev] Access to undefined local variables in IR
Dear all, I have a question regarding access to undefined (or out of scope) local variables in LLVM IR. If I have a program like: define i32 @f(i32 %i) nounwind { %1 = add i32 %i, 1 ret i32 %1 } define i32 @g() nounwind { %1 = add i32 %i, 1 ret i32 %1 } define i32 @main() nounwind { %1 = call i32 @g() ret i32 %1 } Would that be a valid LLVM IR program (note the access to %i outside of f)? If so, what happens when accessing an undefined local variable? Is there a reference that I could cite in a scientific paper where this is described? Thank you very much, Thomas -- Thomas Ströder mailto:stroeder at informatik.rwth-aachen.de LuFG Informatik 2 http://verify.rwth-aachen.de/stroeder RWTH Aachen phone: +49 241 80-21241
Tobias Grosser via llvm-dev
2015-Aug-16 11:33 UTC
[llvm-dev] Access to undefined local variables in IR
On 08/16/2015 01:26 PM, Thomas Ströder via llvm-dev wrote:> define i32 @f(i32 %i) nounwind { > %1 = add i32 %i, 1 > ret i32 %1 > } > > define i32 @g() nounwind { > %1 = add i32 %i, 1 > ret i32 %1 > } > > define i32 @main() nounwind { > %1 = call i32 @g() > ret i32 %1 > }No, this is not valid. $opt /tmp/test.ll opt: /tmp/test.ll:8:16: error: use of undefined value '%i' %1 = add i32 %i, 1 Tobias