10000 Hunk cherry-pick from 8a2198773e: fix InterceptorEnabled visibility. by MorthimerMcMare · Pull Request #50 · focs-lab/llvm-project · GitHub
[go: up one dir, main page]

Skip to content

Hunk cherry-pick from 8a2198773e: fix InterceptorEnabled visibility. #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
f7fe4ca
Migration to getUnderlyingMayEscObjectsNew
apaznikov Nov 8, 2024
2f95b0b
Added inttoptr/ptrtoint tests
apaznikov Nov 11, 2024
348eeb0
Minor refactoring (mostly compOutEscapeState)
apaznikov Nov 12, 2024
1945512
Added GlobalEscapeAnalysis pass infrastructure
apaznikov Nov 13, 2024
9ac70ee
Updated escape/no-escape with passing to calls or aliasing to ptr arg…
apaznikov Nov 15, 2024
4c86254
Starting work on propagation of argument escape info: add argument to…
apaznikov Nov 26, 2024
cefcd9e
Finished IPA EA, refactoring, tests
apaznikov Nov 27, 2024
020af62
Added recursive call conservative algorithm
apaznikov Nov 28, 2024
b155fe5
Fix std::optional<std::reference_wrapper<ArgumentEscapesMap>> ArgsEsc…
apaznikov Nov 29, 2024
bc3186e
Added recursive call conservative algorithm
apaznikov Nov 28, 2024
fbbe19e
Fix std::optional<std::reference_wrapper<ArgumentEscapesMap>> ArgsEsc…
apaznikov Nov 29, 2024
b342f09
Efforts on TSan and IPA EA integration
apaznikov Nov 29, 2024
178fd58
Add Global EA usage to TSan
apaznikov Dec 3, 2024
d0c40d7
Finished support of IPA EA & TSan, fixed bugs
apaznikov Dec 3, 2024
f862a25
Add support of function returning escaped value -- draft
apaznikov Dec 4, 2024
56855b2
Minor fixes for argument escape logic (DBG)
apaznikov Dec 5, 2024
2efb371
Add support of function returning escaped value -- draft 2
apaznikov Dec 5, 2024
2aa25f7
Add EscapeReasonTy
apaznikov Dec 5, 2024
6fbd3bd
Fix addEscapingObject logic for EscReason support
apaznikov Dec 5, 2024
dbc01a3
Fix logic with EscReasons, isEscapeForFunc, etc
apaznikov Dec 6, 2024
24ded0c
Fixed merging escape states, fixed printing, minor fixes, add tests w…
apaznikov Dec 9, 2024
de71362
Support of SCC in IPA - in progress
apaznikov Dec 9, 2024
a03d550
Many fixes for recursive functions, argument, aliasing processing and…
apaznikov Dec 11, 2024
460e60e
Refactoring and debug
apaznikov Dec 12, 2024
ce24c31
Fixed logic mainly with EscapeReason/Argument checks. Add support for…
apaznikov Dec 13, 2024
142270d
Merge branch 'tsan-with-ea-IPA-DBG-rec-calls-TMP' into tsan-with-ea-IPA
apaznikov Dec 13, 2024
781082f
Refactor to simplify and unify logic
apaznikov Dec 13, 2024
2772c1e
Refactor EscapeAnalysis API to improve readability and maintainability
apaznikov Dec 15, 2024
7962dcd
Add support of calls returning pointers (should lead escape)
apaznikov Dec 16, 2024
ed91d09
Use CaptureTracker first, and then EscapeAnalysis
apaznikov Dec 17, 2024
83ca510
Added EscapeReason statistics to TSan. Refactor escape analysis to tr…
apaznikov Dec 18, 2024
01b846c
Add support IPA return info
apaznikov Dec 19, 2024
3f11e06
Try traverse -- DEBUG
apaznikov Dec 19, 2024
87eef69
Argument escape tracking - DEBUG.
apaznikov Dec 20, 2024
408ec0d
Add top-down argument escape analysis (DEBUG)
apaznikov Dec 23, 2024
a69e19e
Add support for detecting functions passed to ObjC selectors
apaznikov Dec 26, 2024
3c7af95
Remove debug logs and enhance escape analysis logic, add test for top…
apaznikov Dec 26, 2024
1d44daa
Fix incorrect assertion in escape analysis.
apaznikov Dec 29, 2024
675f201
Efforts for new pointer escape logic: add UnderlObjInfo, updates in a…
apaznikov Jan 3, 2025
d2329e4
Refactor logic for treating escaping pointers: now pointers (if they …
apaznikov Jan 10, 2025
8eaf60e
Make isEscapedForBBInFuncTSan more optimistic
apaznikov Jan 10, 2025
e6ff26f
Use IPA version `isEscapedForBBIPA` in isEscapedForBBInFuncTSan
apaznikov Jan 10, 2025
b3a7a9a
Fixed IPA escape analysis logic
apaznikov Jan 13, 2025
d9a48f9
Added support of SCCs for TopDownIPA, fixed evalTopDownArgEscStatus (…
apaznikov Jan 14, 2025
006c2d3
Large update for memcpy/memset/memmove
apaznikov Jan 17, 2025
2690475
Enable interceptor toggling via `InterceptorEnabled` global variable …
apaznikov Jan 27, 2025
c946299
Introduce global InterceptorEnabled for interceptor control
apaznikov Feb 4, 2025
f7cfec5
Add intercepted call handling (strlen, strcmp, memchr)
apaznikov Feb 5, 2025
22a26b0
Fixed bug and cleanup debug output
apaznikov Feb 5, 2025
d76f5b0
Enable/disable in sanitizer_common_interceptors.inc
apaznikov Feb 6, 2025
ef66b29
Add __tsan_enable/__tsan_disalbe intrinsics
apaznikov Feb 24, 2025
16216da
Minor fixes
apaznikov Mar 24, 2025
10d6ed8
hunk cherry-pick from 8a2198773e: fix InterceptorEnabled visibility.
MorthimerMcMare Apr 27, 2025
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
Prev Previous commit
Next Next commit
Add support for detecting functions passed to ObjC selectors
Introduce the `isFuncPassedToObjCSelector` function to identify functions used in Objective-C selectors. Enhance debugging output in escape analysis for better traceability. Modify loop processing in `getFullEscapedForBBReason` to skip empty predecessors.
  • Loading branch information
apaznikov committed Dec 26, 2024
commit a69e19ebe832d8734932d8cd566a78c3b138fb86
3 changes: 3 additions & 0 deletions llvm/include/llvm/Analysis/EscapeAnalysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,9 @@ class EscapeAnalysisGlobalInfo {
DenseMap<const Function *, SmallVector<const CallBase *>>
getFuncToCallSitesMap();

/// Check weather function passed to the Objective C selector
bool isFuncPassedToObjCSelector(const Function *F);

/// Compute escape status for the function argument based on call instructions
void analyzeCallGraphTopBottom(
const SmallVectorImpl<std::vector<CallGraphNode *>> &SCCList,
Expand Down
38 changes: 32 additions & 6 deletions llvm/lib/Analysis/EscapeAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ EscapeAnalysisInfo::getExtObjStatusWithArgLookup(const Value *V) const {
const auto EscReason = getExtObjStatus(V);
if (IPAFuncEscInfo && (EscReason == EscReasonBits::PTR_ARG_ALIASING)) {
const auto *Arg = cast<Argument>(V);
LLVM_DEBUG(dbgs() << "\t\t\t\tEscReason for Arg: ";
LLVM_DEBUG(dbgs() << "\t\t\t\tEscReason for Arg " << *Arg << ": ";
printEscReason(
getArgEscStatus(Arg->getArgNo(), Arg->getParent())));
return getArgEscStatus(Arg->getArgNo(), Arg->getParent());
Expand Down Expand Up @@ -923,6 +923,7 @@ SmallVector<Value *, 8> EscapeAnalysisInfo::getUnderlyingMayEscObjects(
EscapeAnalysisInfo::EscReasonTy
EscapeAnalysisInfo::findObjInBBEscapeState(const BasicBlock *BB,
const Value *V) const {
dbgs() << "findObjInBBEscapeState for BB " << BB->getName() << "\n";
const auto It = BBEscapeStates.find(BB);
assert((It != BBEscapeStates.end()) && "Cannot find BBEscapeState for BB\n");
return It->second.getEscReason(V);
Expand Down Expand Up @@ -961,8 +962,11 @@ bool EscapeAnalysisInfo::isEscapedForFunc(
const Value *V,
std::optional<std::reference_wrapper<EscReasonTy>> EscReason) const {
EscReasonTy CombinedEscReason;
for (const auto &BB : AnalyzedFunc)
for (const auto &BB : AnalyzedFunc) {
if (pred_empty(&BB))
continue;
CombinedEscReason |= getFullEscapedForBBReason(&BB, V);
}

if (EscReason.has_value())
EscReason->get() = CombinedEscReason;
Expand Down Expand Up @@ -1172,13 +1176,10 @@ bool EscapeAnalysisGlobalInfo::analyzeCallGraphBottomTop(
Converged = true;
for (const CallGraphNode *CGN : SCC) {
const auto *F = CGN->getFunction();
if (F)
dbgs() << "Analyzing function: " << F->getName() << "\n";
// if (!isLocalFunc(F))
// continue;
if (!F || F->isDeclaration())
continue;
dbgs() << "LOCAL\n";

// Build escape summary for a function
FuncEscapeInfo.erase(F);
Expand Down Expand Up @@ -1211,6 +1212,27 @@ bool EscapeAnalysisGlobalInfo::analyzeCallGraphBottomTop(
return false;
}

bool EscapeAnalysisGlobalInfo::isFuncPassedToObjCSelector(const Function *F) {
for (const GlobalVariable &GV : M.globals()) {
if (GV.getName().starts_with("OBJC_SELECTOR_REFERENCES_") && GV.
hasInitializer()) {
const auto *Initializer = GV.getInitializer();

if (Initializer->getName() == "OBJC_METH_VAR_NAME_") {
if (const auto *InitStr = dyn_cast<ConstantDataArray>(
Initializer->getOperand(0))) {
if (InitStr->isString() &&
// Drop last \00 symbol in the func name in selector
F->getName().contains(InitStr->getAsString().drop_back(1))) {
return true;
}
}
}
}
}
return false;
}

void EscapeAnalysisGlobalInfo::analyzeCallGraphTopBottom(
const SmallVectorImpl<std::vector<CallGraphNode *>> &SCCList,
const DenseMap<const Function *, SmallVector<const CallBase *>>
Expand All @@ -1224,15 +1246,19 @@ void EscapeAnalysisGlobalInfo::analyzeCallGraphTopBottom(

for (CallGraphNode *CGN : SCC) {
const Function *F = CGN->getFunction();

if (!isLocalFunc(F))
continue;

// We consider only static functions
if (!F->hasLocalLinkage())
continue;

// For 541E now, conservatively skip all ObjC methods
if (isFuncPassedToObjCSelector(F))
continue;

LLVM_DEBUG(dbgs() << "\nFunc: " << F->getName() << "\n");
dbgs() << "\nFunc: " << F->getName() << "\n";
evalFuncArgEscStatus(FuncCallSites, F);

// Build escape summary for a function
Expand Down
0