Handle selects and memsets in alloca tracking

Handle selects and memsets in alloca tracking
This commit is contained in:
Jakacki, Jakub
2025-08-27 21:40:20 +00:00
committed by igcbot
parent cca2a9fe60
commit 3275c8a2a4

View File

@ -401,6 +401,12 @@ static bool tryFindPointerOrigin(GetElementPtrInst *Ptr, SmallVectorImpl<Instruc
return tryFindPointerOriginImpl(Ptr->getPointerOperand(), origins, cache); return tryFindPointerOriginImpl(Ptr->getPointerOperand(), origins, cache);
} }
static bool tryFindPointerOrigin(SelectInst *Ptr, SmallVectorImpl<Instruction *> &origins,
DenseSet<Value *> &cache) {
return tryFindPointerOriginImpl(Ptr->getTrueValue(), origins, cache) &&
tryFindPointerOriginImpl(Ptr->getFalseValue(), origins, cache);
}
static bool tryFindPointerOriginImpl(Value *ptr, SmallVectorImpl<Instruction *> &origins, DenseSet<Value *> &cache) { static bool tryFindPointerOriginImpl(Value *ptr, SmallVectorImpl<Instruction *> &origins, DenseSet<Value *> &cache) {
if (!cache.insert(ptr).second) if (!cache.insert(ptr).second)
return true; return true;
@ -409,6 +415,10 @@ static bool tryFindPointerOriginImpl(Value *ptr, SmallVectorImpl<Instruction *>
return tryFindPointerOrigin(GEP, origins, cache); return tryFindPointerOrigin(GEP, origins, cache);
} }
if (auto *select = dyn_cast<SelectInst>(ptr)) {
return tryFindPointerOrigin(select, origins, cache);
}
if (auto *allocaI = dyn_cast<AllocaInst>(ptr)) { if (auto *allocaI = dyn_cast<AllocaInst>(ptr)) {
origins.push_back(allocaI); origins.push_back(allocaI);
return true; return true;