[PATCH] D42541: [DeadArgumentElimination] Preserve llvm.dbg.values's first argument

Djordje Todorovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 25 09:51:58 PST 2018


djtodoro added a comment.

@aprantl Thanks for your comment!
Dead argument elimination pass removes dead return values or dead function arguments. It is detected that when it removing a return value from a function, when it supposed to do 'replaceAllUsesWith()' (line:968) for live function arguments it generates llvm.dbg.value as following:
...
call void @llvm.dbg.value(metadata !2, metadata !39, metadata !DIExpression()), !dbg !42
...
!2 = !{}
...
So, that llvm.dbg.value is not useful and in the next optimization pass it is going to be recognized as dead and it will be deleted.

After applying the patch the llvm.dbg.value would look:
...
call void @llvm.dbg.value(metadata i1 %is_y, metadata !39, metadata !DIExpression()), !dbg !42
...
and it will be propagated to 'debug_loc' properly.

I am aware of llvm::salvageDebugInfo(), but I think that we can not use it in this situation.
Maybe some additional condition when calling 'replaceMetadataUsesWithPDBG()' would be enough to avoid potential differences in generated code. Any suggestion?


https://reviews.llvm.org/D42541





More information about the llvm-commits mailing list