SolverConfig Parametrization#430
Conversation
| if constexpr (has_setIFDSIDESolverConfig_v<ProblemDescription>) { | ||
| ProblemDesc.setIFDSIDESolverConfig(SolverConfig); | ||
| } |
There was a problem hiding this comment.
This function is always defined on IFDS and IDE problems. We can remove this check.
There was a problem hiding this comment.
The WholeProgramAnalysis is used for the Mono-analyses as well. They do not define that function
| template <typename T, typename = void> | ||
| struct has_setIFDSIDESolverConfig : std::false_type {}; | ||
| template <typename T> | ||
| struct has_setIFDSIDESolverConfig< | ||
| T, decltype(std::declval<T>().setIFDSIDESolverConfig( | ||
| std::declval<IFDSIDESolverConfig>()))> : std::true_type {}; | ||
|
|
There was a problem hiding this comment.
I don't think we need that (cf. comment in the above).
|
|
||
| if (Successors.empty()) { | ||
| if (const auto *Branch = llvm::dyn_cast<llvm::BranchInst>(I); | ||
| Branch && isStaticVariableLazyInitializationBranch(Branch)) { | ||
| // Skip the "already initialized" case, such that the analysis is always | ||
| // aware of the initialized value. | ||
| const auto *NextInst = &Branch->getSuccessor(0)->front(); | ||
| if (IgnoreDbgInstructions && | ||
| llvm::isa<llvm::DbgInfoIntrinsic>(NextInst)) { | ||
| NextInst = NextInst->getNextNonDebugInstruction(false); | ||
| } | ||
| Successors.push_back(NextInst); | ||
|
|
||
| } else { | ||
| Successors.reserve(I->getNumSuccessors() + Successors.size()); | ||
| std::transform(llvm::succ_begin(I), llvm::succ_end(I), | ||
| std::back_inserter(Successors), | ||
| [](const llvm::BasicBlock *BB) { | ||
| const llvm::Instruction *Succ = &BB->front(); | ||
| if (llvm::isa<llvm::DbgInfoIntrinsic>(Succ)) { | ||
| Succ = Succ->getNextNonDebugInstruction( | ||
| false /*Only debug instructions*/); | ||
| } | ||
| return Succ; | ||
| }); | ||
| } |
There was a problem hiding this comment.
Could you explain the change to me, I don't quite get it. Thanks.
There was a problem hiding this comment.
A static local variable is lazily initialized (i.e. the first time it is used). This results in a branch in the IR that skips the initialization. So, from the analysis' point of view, the initialization may be skipped all times the variable is used (we cannot analyze the branch condition). However, in reality, we know that (by specification) the variable must definitely be initialized before it is used.
This piece of code removes the "skip lazy initialization" branch from the CFG, such that the analysis knows, it already happened when the rest of the code uses that variable.
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Add CLI parameters to the phasar-llvm tool in order to enable parametrization of the
IFDSIDESolverConfigoptions