Introduce debug info flag that indicates that a parameter has unchanged value through the course of a function.
This info will be used for emitting DW_OP_entry_value expressions for the parameter.
Authors: @asowda, @NikolaPrica, @djtodoro, @ivanbaev
Differential D58034
[IR/DIVar] Add flag for params that have unchanged values Authored by djtodoro on Feb 11 2019, 3:19 AM.
Details Introduce debug info flag that indicates that a parameter has unchanged value through the course of a function. This info will be used for emitting DW_OP_entry_value expressions for the parameter. Authors: @asowda, @NikolaPrica, @djtodoro, @ivanbaev
Diff Detail Event TimelineComment Actions Thanks! I'm assuming the idea is that this is analyzed by the language frontend? To make sure that we're getting the design right: Could you make an argument for why it is not sufficient to deduce this information at the MIR level by looking at the DBG_VALUEs of each variable? About the semantics: Does !isNotChanged() imply that the variable may be modified and should a MIR function with a *single* DBG_VALUE for a variable the !isNotChanged() throw a verifier error because we must have dropped another DBG_VALUE? Similarly, should or could the IR Verifier check for this? Lastly, I've been meaning to add an isConstant flag to DIFlags to support programming languages with immutable variables (such as Swift let bindings) better. An isConstant would be emitted as a DW_TAG_constant instead of DW_TAG_variable. I'm wondering if isNotChanged and isConstant are close enough that they could be merged. What do you think? Comment Actions @aprantl Thanks for your comments!
You got the idea right! :)
Actually, here is the example. bb.0.entry: ... DBG_VALUE $edi, $noreg, !"a",… $ebp = MOV32rr $edi DBG_VALUE $ebp, $noreg, !"a"… CALL64pcrel32 … ... If we have a function with parameter a and it is located in a callee-clobbered register at the beginning of the function. If there is a use of the parameter in the rest of the function (after a call), there will be such move instruction (such in the example shown above) that changes the location of the parameter into some callee-saved register, even the parameter did not change its value. It will imply generating a new DBG_VALUE for variable a. By using some heuristics, this could be handled I guess and figure it out that a parameter is only moved to another location.
In general, every isConstant should be IsNotChanged. Those are very similar, but I would say not exactly the same. We mark parameters as isNotChanged when its value did not changed through the course of a function (that implies its value was constant in that function, but it is not necessary declared as const). But, for example in Swift by using let keyword you declare a constant. For such cases, it makes sense to generate DW_TAG_constant. Comment Actions Yeah, that makes sense. It would be very hard to analyze this without either false positives or a ton of false negatives. I also see that while every constant is trivially not changed, the opposite is not true. Could you please add a round-trip test (like or perhaps even in test/Assembler/debug-info.ll )?
Comment Actions @aprantl I agree. Thanks for the comment!
Sure. Besides this, there is a test case in clang's part for generating the flag. For now, we restricted generating it only in the case of '-femit-param-entry-values' option.
Comment Actions
Comment Actions LGTM. One last request: Could you please add (either to the doxygen comment of isArgNotModified or to LangRef.rst or SourceLevelDebugging.rst) an explanation of the semantics of the flag. Ie.: What it is used for and under what conditions a frontend should generate it? Comment Actions
@aprantl Sure. Thanks a lot! Comment Actions @aprantl I just updated the diff with documentation. Please let me know what do you think. I didn't put explicitly how we generate this at the moment in front end, because (for now) it is restricted under the option for the whole new feature (-femit-param-entry-values).
| ||||||||||||||||||||||||||||||
These flags encode various properties of DINodes.