This is an archive of the discontinued LLVM Phabricator instance.

[FuzzMutate] New InsertCFGStrategy
ClosedPublic

Authored by Peter on Nov 30 2022, 5:27 PM.

Details

Summary

Mutating CFG is hard as we have to maintain dominator relations.
We avoid this problem by inserting a CFG into a splitted block.

switch, ret, and br instructions are generated.

Diff Detail

Event Timeline

Peter created this revision.Nov 30 2022, 5:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2022, 5:27 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
Peter requested review of this revision.Nov 30 2022, 5:27 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 30 2022, 5:27 PM
Peter updated this revision to Diff 479125.Nov 30 2022, 5:33 PM

add more complicate test.

Peter edited the summary of this revision. (Show Details)Nov 30 2022, 5:35 PM
arsenm added inline comments.Dec 5 2022, 11:34 AM
llvm/lib/FuzzMutate/IRMutator.cpp
341

Don't name the lambda?

344

cast<>? I don't see what RS really is

Peter added inline comments.Dec 5 2022, 12:12 PM
llvm/lib/FuzzMutate/IRMutator.cpp
344

RS returns a Type*, but because we used a filter isIntegerType, we can be sure that the result must be an IntegerType.

We can add a dynamic cast and check for the sake of readability, but it seems to me its un-necessary runtime overhead.

Peter marked 2 inline comments as done.Dec 7 2022, 2:52 PM
arsenm requested changes to this revision.Dec 9 2022, 2:32 PM
arsenm added inline comments.
llvm/lib/FuzzMutate/IRMutator.cpp
343–344

assert string is a bit weird

346–347

cast<> instead of dyn_cast and assert

365–374

Why is this a lambda here?

406

RetTy->isVoidTy()

llvm/lib/FuzzMutate/RandomIRBuilder.cpp
81

Should query the datalayout address space for new allocas

This revision now requires changes to proceed.Dec 9 2022, 2:32 PM
Peter updated this revision to Diff 481873.Dec 10 2022, 11:43 AM
Peter marked 3 inline comments as done.

Query Datalayout before alloca.

Peter marked an inline comment as done.Dec 12 2022, 11:02 AM
Peter added inline comments.
llvm/lib/FuzzMutate/IRMutator.cpp
343–344

This is to make sure that when things went wrong, we give some hint to tell the user what's wrong. Is there a recommended way of doing it?

365–374

Just to enclose unnecessary variables(tmp required to make CaseVal unique. I can write the loop outside the lambda if you want to.

arsenm added inline comments.Dec 12 2022, 11:04 AM
llvm/lib/FuzzMutate/IRMutator.cpp
343–344

I mean the phrasing with the question, and saying "I"

arsenm added inline comments.Dec 12 2022, 11:07 AM
llvm/lib/FuzzMutate/IRMutator.cpp
365–374

A lambda with no arguments is weird, especially with the placement. Could just be a separate function

Peter updated this revision to Diff 482267.Dec 12 2022, 2:20 PM

update assert string, move lambda as a stand alone function

arsenm accepted this revision.Dec 12 2022, 2:33 PM

lgtm with nits

llvm/lib/FuzzMutate/IRMutator.cpp
311

line after while

317

Can do this in the constructor Insts(BB.getFirstInsertionPt(), BB.end())

355–356

Assert string still weirdly phased

This revision is now accepted and ready to land.Dec 12 2022, 2:33 PM
Peter marked 6 inline comments as done.Dec 12 2022, 3:17 PM
Peter added inline comments.
llvm/lib/FuzzMutate/IRMutator.cpp
317

Unfortunately no, BB.getFirstInsertionPt returns an iterator, which can't be implicitly converted to Instruction*

Peter updated this revision to Diff 482287.Dec 12 2022, 3:17 PM
Peter marked an inline comment as done.

nit fix

Peter updated this revision to Diff 482290.Dec 12 2022, 3:19 PM

nit fix

This revision was landed with ongoing or failed builds.Dec 12 2022, 3:21 PM
This revision was automatically updated to reflect the committed changes.