This is an archive of the discontinued LLVM Phabricator instance.

[FuzzMutate] InstModificationStrategy, add FastMath flags and exact flags to instructions.
ClosedPublic

Authored by Peter on Dec 7 2022, 5:27 PM.

Details

Summary

I think there are more attributes, flags we can add to call, functions declarations and global variables. Let's start with these two flags.

Diff Detail

Event Timeline

Peter created this revision.Dec 7 2022, 5:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2022, 5:27 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Peter requested review of this revision.Dec 7 2022, 5:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 7 2022, 5:27 PM
Peter edited the summary of this revision. (Show Details)Dec 7 2022, 5:28 PM
Peter added a reviewer: arsenm.
arsenm added inline comments.Dec 7 2022, 6:03 PM
llvm/lib/FuzzMutate/IRMutator.cpp
221–223

I don't know exactly how the fuzz argument works, but won't these interfere? Setting all is superfluous with setting every individual flag

llvm/unittests/FuzzMutate/StrategiesTest.cpp
330

Separate ASSERT_TRUE for each

354

Do we even allow fmf on arrays of vectors?

368–374

Missing paces. Can you also reduce the indentation level by factoring out the innermost loop or something?

Peter updated this revision to Diff 481139.Dec 7 2022, 7:08 PM
Peter marked 4 inline comments as done.
  1. fix indentation
  2. remove the probability where we repeatedly setting the same thing.
llvm/lib/FuzzMutate/IRMutator.cpp
221–223

Yes, setting all is superfluous. I removed the repeated part, now we are only flipping the setting. (So we don't set true to ture).

It takes a lot of mutations to set(or unset) every flag, so I think its a good idea that we keep an option to set everything at once.

llvm/unittests/FuzzMutate/StrategiesTest.cpp
354

https://godbolt.org/z/nGarYT6Ef

I think we do. The documentation (for call, phi, and select) says "that return a floating-point scalar or vector type, or an array (nested to any depth) of floating-point scalar or vector types", and llc is not complaining about this.

arsenm added inline comments.Dec 9 2022, 2:20 PM
llvm/lib/FuzzMutate/IRMutator.cpp
276–277

Why don't these do the set the opposite value like the fmf? Same for the existing GEP case (if you want to change the GEP case, do it in a separate change)

290–301

You can dyn_cast to FPMathOperator to get all fast math flag compatible operations without maintaining the instruction list

arsenm requested changes to this revision.Dec 9 2022, 2:20 PM
This revision now requires changes to proceed.Dec 9 2022, 2:20 PM
Peter updated this revision to Diff 481869.Dec 10 2022, 11:04 AM

fliping isExact as well. Using isa<FPMathOperator>(&Inst) to do test if FastMath is compatable.

Peter marked 2 inline comments as done.Dec 10 2022, 11:05 AM
Peter added inline comments.
llvm/lib/FuzzMutate/IRMutator.cpp
290–301

I didn't know FPMathOperator can work on call inst. Thanks for pointing out.

arsenm accepted this revision.Dec 12 2022, 3:12 PM
This revision is now accepted and ready to land.Dec 12 2022, 3:12 PM
This revision was automatically updated to reflect the committed changes.
Peter marked an inline comment as done.