[PATCH] D51968: [deadargelim] Update dbg.value of 'unused' parameters

Vedant Kumar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 12 11:26:29 PDT 2018


vsk added a comment.

In https://reviews.llvm.org/D51968#1232061, @aprantl wrote:

> Thanks, this looks mostly good, minor comments for the testcase inline.
>
> Why doesn't this do the right thing automatically though? What does the dbg.value point to after %k is dropped?


Because %k isn't deleted (I have an explanation in an inline comment). This part of DAE just edits calls to 'f2' s.t they pass in undef wherever they would have passed in a "real" value for %k.



================
Comment at: lib/Transforms/IPO/DeadArgumentElimination.cpp:295
+      if(Arg.isUsedByMetadata())
+        Arg.replaceAllUsesWith(UndefValue::get(Arg.getType()));
       UnusedArgs.push_back(Arg.getArgNo());
----------------
I think you need `Changed = true` here. Otherwise, this will return false if Fn has no uses.


================
Comment at: test/Transforms/DeadArgElim/dbginfo-update-dbgval.ll:27
+entry:
+; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !16
+  call void @llvm.dbg.value(metadata i32 %k, metadata !15, metadata !DIExpression()), !dbg !16
----------------
aprantl wrote:
> can you also add a check that f2 no longer has an argument?
DAE doesn't remove the argument here, see the comment from SurveyFunction:
```
// We consider arguments of non-internal functions to be intrinsically alive as
// well as arguments to functions which have their "address taken".
```


Repository:
  rL LLVM

https://reviews.llvm.org/D51968





More information about the llvm-commits mailing list