[llvm] 69365ae - [RandomIRBuilder] Remove use of getNonOpaquePointerElementType() (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 14 01:57:12 PDT 2023
Author: Nikita Popov
Date: 2023-07-14T10:54:38+02:00
New Revision: 69365ae56f67affb4bfc3e467d4fbb73b03355e5
URL: https://github.com/llvm/llvm-project/commit/69365ae56f67affb4bfc3e467d4fbb73b03355e5
DIFF: https://github.com/llvm/llvm-project/commit/69365ae56f67affb4bfc3e467d4fbb73b03355e5.diff
LOG: [RandomIRBuilder] Remove use of getNonOpaquePointerElementType() (NFC)
Added:
Modified:
llvm/include/llvm/FuzzMutate/RandomIRBuilder.h
llvm/lib/FuzzMutate/RandomIRBuilder.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h b/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h
index 8560f2ca2066e4..1a422fcc0be6ed 100644
--- a/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h
+++ b/llvm/include/llvm/FuzzMutate/RandomIRBuilder.h
@@ -96,8 +96,7 @@ struct RandomIRBuilder {
Value *V);
/// Create a user for \c V in \c BB.
Instruction *newSink(BasicBlock &BB, ArrayRef<Instruction *> Insts, Value *V);
- Value *findPointer(BasicBlock &BB, ArrayRef<Instruction *> Insts,
- ArrayRef<Value *> Srcs, fuzzerop::SourcePred Pred);
+ Value *findPointer(BasicBlock &BB, ArrayRef<Instruction *> Insts);
/// Return a uniformly choosen type from \c AllowedTypes
Type *randomType();
Function *createFunctionDeclaration(Module &M, uint64_t ArgNum);
diff --git a/llvm/lib/FuzzMutate/RandomIRBuilder.cpp b/llvm/lib/FuzzMutate/RandomIRBuilder.cpp
index 548ba7956fd5a1..5569888e5b28e8 100644
--- a/llvm/lib/FuzzMutate/RandomIRBuilder.cpp
+++ b/llvm/lib/FuzzMutate/RandomIRBuilder.cpp
@@ -203,7 +203,7 @@ Value *RandomIRBuilder::newSource(BasicBlock &BB, ArrayRef<Instruction *> Insts,
RS.sample(Pred.generate(Srcs, KnownTypes));
// If we can find a pointer to load from, use it half the time.
- Value *Ptr = findPointer(BB, Insts, Srcs, Pred);
+ Value *Ptr = findPointer(BB, Insts);
if (Ptr) {
// Create load from the chosen pointer
auto IP = BB.getFirstInsertionPt();
@@ -363,7 +363,7 @@ Instruction *RandomIRBuilder::connectToSink(BasicBlock &BB,
Instruction *RandomIRBuilder::newSink(BasicBlock &BB,
ArrayRef<Instruction *> Insts, Value *V) {
- Value *Ptr = findPointer(BB, Insts, {V}, matchFirstType());
+ Value *Ptr = findPointer(BB, Insts);
if (!Ptr) {
if (uniform(Rand, 0, 1)) {
Type *Ty = V->getType();
@@ -377,27 +377,14 @@ Instruction *RandomIRBuilder::newSink(BasicBlock &BB,
}
Value *RandomIRBuilder::findPointer(BasicBlock &BB,
- ArrayRef<Instruction *> Insts,
- ArrayRef<Value *> Srcs, SourcePred Pred) {
- auto IsMatchingPtr = [&Srcs, &Pred](Instruction *Inst) {
+ ArrayRef<Instruction *> Insts) {
+ auto IsMatchingPtr = [](Instruction *Inst) {
// Invoke instructions sometimes produce valid pointers but currently
// we can't insert loads or stores from them
if (Inst->isTerminator())
return false;
- if (auto *PtrTy = dyn_cast<PointerType>(Inst->getType())) {
- if (PtrTy->isOpaque())
- return true;
-
- // We can never generate loads from non first class or non sized types
- Type *ElemTy = PtrTy->getNonOpaquePointerElementType();
- if (!ElemTy->isSized() || !ElemTy->isFirstClassType())
- return false;
-
- // TODO: Check if this is horribly expensive.
- return Pred.matches(Srcs, UndefValue::get(ElemTy));
- }
- return false;
+ return Inst->getType()->isPointerTy();
};
if (auto RS = makeSampler(Rand, make_filter_range(Insts, IsMatchingPtr)))
return RS.getSelection();
More information about the llvm-commits
mailing list