Static Value-Flow Analysis
Loading...
Searching...
No Matches
Functions
SVFIRBuilder.cpp File Reference
#include "SVF-LLVM/SVFIRBuilder.h"
#include "SVF-LLVM/BasicTypes.h"
#include "SVF-LLVM/CHGBuilder.h"
#include "SVF-LLVM/CppUtil.h"
#include "SVF-LLVM/LLVMLoopAnalysis.h"
#include "SVF-LLVM/LLVMUtil.h"
#include "SVF-LLVM/ObjTypeInference.h"
#include "SVF-LLVM/SymbolTableBuilder.h"
#include "SVFIR/PAGBuilderFromFile.h"
#include "Util/CallGraphBuilder.h"
#include "Graphs/CallGraph.h"
#include "Util/Options.h"
#include "Util/SVFUtil.h"

Go to the source code of this file.

Functions

static const Type * getAggregateFieldType (const Type *type, const std::vector< unsigned > &indices)
 Return the type at a constant aggregate path, including fixed vector lanes.
 
static std::optional< unsigned > getFixedVectorLane (const Type *type, const Value *index)
 
static bool canModelAggregateReturn (const Function *fun)
 

Function Documentation

◆ canModelAggregateReturn()

static bool canModelAggregateReturn ( const Function *  fun)
static

Require a returning, nonvariadic definition whose uses are all ordinary direct calls with matching types, so each call can pass the output pointers.

Definition at line 1558 of file SVFIRBuilder.cpp.

1559{
1560 if (!fun || LLVMUtil::isExtCall(fun) || fun->isVarArg() ||
1561 fun->doesNotReturn() || !fun->getReturnType()->isAggregateType() ||
1562 fun->hasAddressTaken())
1563 return false;
1564 for (const User* user : fun->users())
1565 {
1566 const auto* call = SVFUtil::dyn_cast<CallInst>(user);
1567 if (!call || call->getCalledFunction() != fun ||
1568 call->getFunctionType() != fun->getFunctionType())
1569 return false;
1570 }
1571 return true;
1572}
bool isExtCall(const Function *fun)
Definition LLVMUtil.cpp:385
llvm::IRBuilder IRBuilder
Definition BasicTypes.h:76
llvm::User User
Definition BasicTypes.h:149

◆ getAggregateFieldType()

static const Type * getAggregateFieldType ( const Type *  type,
const std::vector< unsigned > &  indices 
)
static

Return the type at a constant aggregate path, including fixed vector lanes.

Definition at line 1335 of file SVFIRBuilder.cpp.

1337{
1338 for (unsigned index : indices)
1339 {
1340 if (const auto* structure = SVFUtil::dyn_cast<StructType>(type))
1341 {
1342 if (index >= structure->getNumElements())
1343 return nullptr;
1344 type = structure->getElementType(index);
1345 }
1346 else if (const auto* array = SVFUtil::dyn_cast<ArrayType>(type))
1347 {
1348 if (index >= array->getNumElements())
1349 return nullptr;
1350 type = array->getElementType();
1351 }
1352 else if (const auto* vector = SVFUtil::dyn_cast<llvm::FixedVectorType>(type))
1353 {
1354 if (index >= vector->getNumElements())
1355 return nullptr;
1356 type = vector->getElementType();
1357 }
1358 else
1359 return nullptr;
1360 }
1361 return type;
1362}
newitem type
Definition cJSON.cpp:2739
int index
Definition cJSON.h:170

◆ getFixedVectorLane()

static std::optional< unsigned > getFixedVectorLane ( const Type *  type,
const Value *  index 
)
static

Return the selected fixed-vector lane, or no lane for other vector types, variable indices and out-of-range indices.

Definition at line 1366 of file SVFIRBuilder.cpp.

1368{
1369 const auto* vector = SVFUtil::dyn_cast<llvm::FixedVectorType>(type);
1370 const auto* constant = SVFUtil::dyn_cast<ConstantInt>(index);
1371 if (!vector || !constant ||
1372 constant->getValue().uge(vector->getNumElements()))
1373 return std::nullopt;
1374 return static_cast<unsigned>(constant->getZExtValue());
1375}