[llvm-dev] Access to undefined local variables in IR

Thomas Ströder via llvm-dev llvm-dev at lists.llvm.org
Sun Aug 16 04:26:28 PDT 2015


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


More information about the llvm-dev mailing list