[llvm-dev] Corresponding register of stack variables after mem2reg pass

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 6 11:40:27 PDT 2015


On 6 October 2015 at 11:23, Riyad Parvez via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Here %sub is the corresponding register for variable "x". My question is
> after "mem2reg" pass is it possible to know these corresponding registers?

Only really as a best-effort via debug info, I think. In this case,
the sub is followed by an @llvm.dbg.value call which specifies which
source variable it came from:

  call void @llvm.dbg.value(metadata i32 %sub, i64 0, metadata !18,
metadata !13), !dbg !19

on my build, where the metadata !18 refers to "!DILocalVariable(name:
"x", scope: !4, file: !1, line: 2, type: !7)"

Of course, that information is likely to get fuzzier and fuzzier as
more optimisations happen.

Cheers.

Tim.


More information about the llvm-dev mailing list