Stream: t-compiler/wg-mir-opt

Topic: VarDebugInfo using constants instead of locals


eddyb (Feb 07 2020 at 07:58, on Zulip):

@oli @Wesley Wiser hey, do you think it would be cheap to check in the constant folder if a local always has a constant value whenever initialized?

eddyb (Feb 07 2020 at 07:59, on Zulip):

I guess it could be its own pass post-constant-folding, that checks for one initialization and no mutation

eddyb (Feb 07 2020 at 08:01, on Zulip):

I want to have debug x => _123; replaced with e.g. debug x => const 42usize; wherever possible

eddyb (Feb 07 2020 at 08:03, on Zulip):

the other thing we could do is debug a => &b.c; (value of debug var a is always the address of a place with no runtime indexing or derefs)

eddyb (Feb 07 2020 at 08:05, on Zulip):

the latter wouldn't count as a borrow because only the debugger would see it, and also both it and the constant form could use llvm.dbg.value

eddyb (Feb 07 2020 at 08:07, on Zulip):

the goal is to reduce the impact of debuginfo on optimizations and codegen

eddyb (Feb 07 2020 at 08:08, on Zulip):

but maybe I should do some statistics on the kinds of things that are e.g. unnecessarily on the stack in debug mode

Wesley Wiser (Feb 07 2020 at 10:46, on Zulip):

@eddyb By "constant folder" do you mean const-prop or something else?

eddyb (Feb 07 2020 at 21:18, on Zulip):

yeah I guess it's called const-prop

eddyb (Feb 07 2020 at 21:19, on Zulip):

I'd argue propagation is just replacing uses with the value at the definition, whereas folding is e.g. _5 = 1 + 2 => _5 = 3 (there's no propagation there)

eddyb (Feb 07 2020 at 21:19, on Zulip):

the current pass is a combination of propagation and folding

Wesley Wiser (Feb 07 2020 at 21:23, on Zulip):

Sure yeah

Wesley Wiser (Feb 07 2020 at 21:23, on Zulip):

I can't imagine it would be expensive

Wesley Wiser (Feb 07 2020 at 21:24, on Zulip):

We've already done that check and know what locals satisfy that constraint

eddyb (Feb 07 2020 at 21:26, on Zulip):

oh right you're not relying on dataflow?

eddyb (Feb 07 2020 at 21:26, on Zulip):

I guess you couldn't have, @ecstatic-morse's stuff is pretty recent

Wesley Wiser (Feb 07 2020 at 21:30, on Zulip):

Nah, not yet

Last update: Feb 25 2020 at 04:15UTC