This is an archive of the discontinued LLVM Phabricator instance.

llvm-reduce: Add broken testcase that shows uselistorder problem
ClosedPublic

Authored by arsenm on Jun 30 2023, 4:49 AM.

Details

Summary

I've been trying to track down this problem for a while and finally
found a small enough reproducer for a test. Reductions sometimes
produce text IR which does not parse, with errors such as

"error: wrong number of indexes, expected 9"

This appears to not happen with bitcode reduction, as the bitcode
reader seems to silently discard uselistorder when the sizes don't
match. I believe this is caused by dangling constants in the
LLVMContext, which is currently recycled between different reductions.

Diff Detail

Event Timeline

arsenm created this revision.Jun 30 2023, 4:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 4:49 AM
arsenm requested review of this revision.Jun 30 2023, 4:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 30 2023, 4:49 AM
Herald added a subscriber: wdng. · View Herald Transcript

I think I ran into this once and just disabled uselistorder printing

the proper fix is to disallow inspecting uses of constants so we can stop printing the uselistorder for constants. I looked into this before but there were some passes doing weird things (func-spec I think?) and I never got around to fixing things

separately we could use different LLVMContexts?

separately we could use different LLVMContexts?

That's what I was looking into. There's also the related problem tracked by reduce-functions-blockaddress-wrong-function.ll (that one at least seems to be fixed by just always using the parallel reduction path)

I think I ran into this once and just disabled uselistorder printing

the proper fix is to disallow inspecting uses of constants so we can stop printing the uselistorder for constants. I looked into this before but there were some passes doing weird things (func-spec I think?) and I never got around to fixing things

I've also seen this happen with global addresses, where the use list order more obviously matters

arsenm added a comment.Jul 7 2023, 4:45 AM

ping, I don't know when I'm going to get back to looking at this and want to ensure the test isn't lost

regehr accepted this revision.Jul 7 2023, 8:02 AM

yes, please add this, thanks!

This revision is now accepted and ready to land.Jul 7 2023, 8:02 AM

seems fine to check in especially to verify if we ever fix it, one nit

llvm/test/tools/llvm-reduce/uselistorder-invalid-ir-output.ll
51

this CHECK line seems fragile, perhaps just uselistorder i32 0, {, and rely on the not llvm-as line check that it's invalid

arsenm added inline comments.Jul 7 2023, 1:10 PM
llvm/test/tools/llvm-reduce/uselistorder-invalid-ir-output.ll
51

Given the point is to express that this is broken, I think this is OK. Anything that perturbs this should require attention