The argument reduction pass shouldn't remove arguments of
intrinsics, because the resulting module is ill-formed, and so
inherently uninteresting.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
should we be skipping all intrinsics? intrinsic signatures should never change right?
and there are a couple comments that seem to indicate that we are only touching definitions, but it looks like we're also touching declarations
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp | ||
---|---|---|
10 | drive by, this looks wrong | |
111–112 | drive by, this looks wrong |
should we be skipping all intrinsics? intrinsic signatures should never change right?
Good call, I've generalized this patch.
and there are a couple comments that seem to indicate that we are only touching definitions, but it looks like we're also touching declarations
Agreed.
I'm not okay with blankedly ignoring intrinsics.
Please can you show the malformed IR after dbginfo arg removal?
why wouldn't we always ignore intrinsics? their signature is always the same, it should be invalid to remove a parameter of an intrinsic
Please can you show the malformed IR after dbginfo arg removal?
Here's the output of the testcase I added before this patch:
******************** TEST 'LLVM :: tools/llvm-reduce/remove-args-dbg-intrinsics.ll' FAILED ******************** Script: -- : 'RUN: at line 3'; llvm-reduce --abort-on-invalid-reduction --delta-passes=arguments --test=/home/langston/code/llvm-project/build/bin/opt --test-arg=-verify --test-arg=-disable-output --output=/home/langston/code/llvm-project/build/test/tools/llvm-reduce/Output/remove-args-dbg-intrinsics.ll.tmp /home/langston/code/llvm-project/llvm/test/tools/llvm-reduce/remove-args-dbg-intrinsics.ll : 'RUN: at line 4'; cat /home/langston/code/llvm-project/build/test/tools/llvm-reduce/Output/remove-args-dbg-intrinsics.ll.tmp | /home/langston/code/llvm-project/build/bin/FileCheck /home/langston/code/llvm-project/llvm/test/tools/llvm-reduce/remove-args-dbg-intrinsics.ll -- Exit Code: 1 Command Output (stdout): -- *** Reducing Arguments... ---------------------------- Param Index Reference: llvm.dbg.addr 1: 2: 3: ---------------------------- llvm.dbg.declare 4: 5: 6: ---------------------------- llvm.dbg.value 7: 8: 9: ---------------------------- -- Command Output (stderr): -- Invalid user of intrinsic instruction! void (metadata, metadata, metadata)* bitcast (void ()* @llvm.dbg.addr to void (metadata, metadata, metadata)*) Invalid user of intrinsic instruction! void (metadata, metadata, metadata)* bitcast (void ()* @llvm.dbg.declare to void (metadata, metadata, metadata)*) Invalid user of intrinsic instruction! void (metadata, metadata, metadata)* bitcast (void ()* @llvm.dbg.value to void (metadata, metadata, metadata)*) Invalid reduction -- ******************** ******************** Failed Tests (1): LLVM :: tools/llvm-reduce/remove-args-dbg-intrinsics.ll
If I run that same command without --abort-on-invalid-reduction, I just see many more WARNINGs, and the final module is identical to the input module. So IIUC, this patch doesn't result in different output from llvm-reduce, just fewer unnecessary *attempts* at reduction.
the title/summary needs to be updated
llvm/test/tools/llvm-reduce/remove-args-dbg-intrinsics.ll | ||
---|---|---|
4 | I don't think this is the right test, llvm-reduce already checks that something is verified. The test should be checking that each of the three intrinsics is declared (ignoring the arguments). Look at the other tests in the file for more examples. | |
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp | ||
47 | F.isIntrinsic() |
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp | ||
---|---|---|
47 | While i could be okay with ignoring actual intriniscs, |
llvm/tools/llvm-reduce/deltas/ReduceArguments.cpp | ||
---|---|---|
47 | https://llvm.org/docs/LangRef.html#intrinsic-functions |
could you also update the various comments to say that all functions, not just definitions, are touched?
llvm/test/tools/llvm-reduce/remove-args-dbg-intrinsics.ll | ||
---|---|---|
4 | I think this is still not quite right. so something like CHECK-INTERESTINGNESS: declare void @llvm.dbg.addr CHECK-INTERESTINGNESS: declare void @llvm.dbg.declare CHECK-INTERESTINGNESS: declare void @llvm.dbg.value CHECK-FINAL: declare void @llvm.dbg.addr(metadata, metadata, metadata) CHECK-FINAL: declare void @llvm.dbg.declare(metadata, metadata, metadata) CHECK-FINAL: declare void @llvm.dbg.value(metadata, metadata, metadata) |
lgtm, thanks!
Thanks for your patience and comments in the review! I don't have commit access, so I'll need some help merging this.
I don't think this is the right test, llvm-reduce already checks that something is verified. The test should be checking that each of the three intrinsics is declared (ignoring the arguments). Look at the other tests in the file for more examples.