Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class GlobalCtorsDtorsModel {
static constexpr llvm::StringLiteral NonDetValuePrefix =
"__psrCRuntimeNonDetValue";

static constexpr llvm::StringLiteral QuickExitCallerName =
"__psrQuickExitCaller";

/// A global that a registration (on_exit, __cxa_atexit) fills with the
/// non-constant argument its exit handler gets
static constexpr llvm::StringLiteral ExitHandlerArgName =
"__psrExitHandlerArg";

/// @brief Function that creates a new global model and inserts it into the
/// IRDB. The returned function is the global model that was inserted.
/// @param[in, out] IRDB IR database that will have the global model
Expand Down
5 changes: 5 additions & 0 deletions include/phasar/PhasarLLVM/DB/LLVMProjectIRDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ class LLVMProjectIRDB {
/// called twice for the same function. Use with care!
void insertFunction(llvm::Function *F, bool DoPreprocessing = true);

/// Re-synchronizes the ids with the managed module after a transformation
/// added or removed instructions.
void updateInstructionIds();

/// Returns the function that contains the given instruction Inst.
///
/// \remark This function should eventually replace
Expand Down Expand Up @@ -218,6 +222,7 @@ class LLVMProjectIRDB {
std::unique_ptr<llvm::LLVMContext> Ctx;
MaybeUniquePtr<llvm::Module> Mod = nullptr;
size_t IdOffset = 0;
bool IsPreprocessed = false;
llvm::SmallVector<const llvm::Value *, 0> IdToInst;
llvm::DenseMap<const llvm::Value *, size_t> InstToId;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,26 +289,6 @@ struct IFDSProblemConfig : LLVMIFDSAnalysisDomainDefault {
// XXX: more
};

/// Utility to strip off potential pointer-arithmetic from V and accumulating
/// the byte-offset.
[[nodiscard]] inline std::pair<const llvm::Value *, int32_t>
getBaseAndOffset(const llvm::Value *V, const llvm::DataLayout &DL) {
llvm::APInt Offset(64, 0);
int32_t OffsVal = AccessPath::TopOffset;
const auto *Base = V->stripAndAccumulateConstantOffsets(DL, Offset, true);

if (llvm::isa<llvm::GEPOperator>(Base)) {
return {Base->stripPointerCastsAndAliases(), AccessPath::TopOffset};
}

auto RawOffsVal = Offset.getSExtValue();
if (RawOffsVal <= INT32_MAX && RawOffsVal >= INT32_MIN) {
OffsVal = int32_t(RawOffsVal);
}

return {Base->stripPointerCastsAndAliases(), OffsVal};
}

/// Checks whether Fact holds at Inst in a field-sensitive way
template <bool AllowDeepTaints = true, typename ResultsT>
[[nodiscard]] inline bool holdsFactAt(const ResultsT &Results,
Expand Down
5 changes: 5 additions & 0 deletions include/phasar/PhasarLLVM/Utils/LLVMShorthands.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class LLVMProjectIRDB;
isAllocaInstOrHeapAllocaFunction(const llvm::Value *V) noexcept;
[[nodiscard]] bool isHeapAllocatingFunction(const llvm::Function *F) noexcept;

/// Strips potential pointer-arithmetic from V, accumulating the byte-offset.
/// Offset is INT32_MIN if not constant.
[[nodiscard]] std::pair<const llvm::Value *, int32_t>
getBaseAndOffset(const llvm::Value *V, const llvm::DataLayout &DL);

/// Returns true if the provided function and the function type are both not
/// null and have the same number of parameters and the same return type. If the
/// argument ExactMatch is set to true, which it is by default, the two provided
Expand Down
Loading
Loading