Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Analysis/CaptureTracking.cpp
Show First 20 Lines • Show All 418 Lines • ▼ Show 20 Lines | if (auto *CPN = dyn_cast<ConstantPointerNull>(I->getOperand(OtherIdx))) { | ||||
} | } | ||||
} | } | ||||
// Comparison against value stored in global variable. Given the pointer | // Comparison against value stored in global variable. Given the pointer | ||||
// does not escape, its value cannot be guessed and stored separately in a | // does not escape, its value cannot be guessed and stored separately in a | ||||
// global variable. | // global variable. | ||||
auto *LI = dyn_cast<LoadInst>(I->getOperand(OtherIdx)); | auto *LI = dyn_cast<LoadInst>(I->getOperand(OtherIdx)); | ||||
if (LI && isa<GlobalVariable>(LI->getPointerOperand())) | if (LI && isa<GlobalVariable>(LI->getPointerOperand())) | ||||
return UseCaptureKind::NO_CAPTURE; | return UseCaptureKind::NO_CAPTURE; | ||||
if (auto *CE = dyn_cast<ConstantExpr>(I->getOperand(OtherIdx))) { | |||||
if (CE->getOpcode() == Instruction::GetElementPtr && | |||||
isa<GlobalVariable>(CE->getOperand(0))) | |||||
return UseCaptureKind::NO_CAPTURE; | |||||
} | |||||
// Otherwise, be conservative. There are crazy ways to capture pointers | // Otherwise, be conservative. There are crazy ways to capture pointers | ||||
// using comparisons. | // using comparisons. | ||||
return UseCaptureKind::MAY_CAPTURE; | return UseCaptureKind::MAY_CAPTURE; | ||||
} | } | ||||
default: | default: | ||||
// Something else - be conservative and say it is captured. | // Something else - be conservative and say it is captured. | ||||
return UseCaptureKind::MAY_CAPTURE; | return UseCaptureKind::MAY_CAPTURE; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |