summaryrefslogtreecommitdiff
path: root/llvm/lib/FuzzMutate/IRMutator.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2022-03-16 16:10:24 +0100
committerNikita Popov <npopov@redhat.com>2022-03-16 16:58:33 +0100
commit6a23d2764467bd45c2e02828f6175a0b9f9a1005 (patch)
tree8018f3b845325c4d3abffd01dc8fec8442cfe399 /llvm/lib/FuzzMutate/IRMutator.cpp
parent3251ba2d0fcf5223fce3e270b91c54f548664b4e (diff)
[FuzzMutate] Don't insert instructions after musttail call
Diffstat (limited to 'llvm/lib/FuzzMutate/IRMutator.cpp')
-rw-r--r--llvm/lib/FuzzMutate/IRMutator.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/FuzzMutate/IRMutator.cpp b/llvm/lib/FuzzMutate/IRMutator.cpp
index 105f8bc6c522..0f93bf9ee9c8 100644
--- a/llvm/lib/FuzzMutate/IRMutator.cpp
+++ b/llvm/lib/FuzzMutate/IRMutator.cpp
@@ -116,6 +116,16 @@ void InjectorIRStrategy::mutate(BasicBlock &BB, RandomIRBuilder &IB) {
auto InstsBefore = makeArrayRef(Insts).slice(0, IP);
auto InstsAfter = makeArrayRef(Insts).slice(IP);
+ if (!InstsBefore.empty()) {
+ // Don't insert instructions after a musttail call.
+ Instruction *InstBefore = InstsBefore.back();
+ if (isa<BitCastInst>(InstBefore))
+ InstBefore = InstBefore->getPrevNode();
+ CallBase *CallBefore = dyn_cast_or_null<CallBase>(InstBefore);
+ if (CallBefore && CallBefore->isMustTailCall())
+ return;
+ }
+
// Choose a source, which will be used to constrain the operation selection.
SmallVector<Value *, 2> Srcs;
Srcs.push_back(IB.findOrCreateSource(BB, InstsBefore));