Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Analysis/CaptureTracking.cpp
Show All 19 Lines | |||||
#include "llvm/ADT/SmallVector.h" | #include "llvm/ADT/SmallVector.h" | ||||
#include "llvm/Analysis/AliasAnalysis.h" | #include "llvm/Analysis/AliasAnalysis.h" | ||||
#include "llvm/Analysis/CFG.h" | #include "llvm/Analysis/CFG.h" | ||||
#include "llvm/Analysis/ValueTracking.h" | #include "llvm/Analysis/ValueTracking.h" | ||||
#include "llvm/IR/Constants.h" | #include "llvm/IR/Constants.h" | ||||
#include "llvm/IR/Dominators.h" | #include "llvm/IR/Dominators.h" | ||||
#include "llvm/IR/Instructions.h" | #include "llvm/IR/Instructions.h" | ||||
#include "llvm/IR/IntrinsicInst.h" | #include "llvm/IR/IntrinsicInst.h" | ||||
#include "llvm/IR/Intrinsics.h" | |||||
#include "llvm/Support/CommandLine.h" | #include "llvm/Support/CommandLine.h" | ||||
using namespace llvm; | using namespace llvm; | ||||
/// The default value for MaxUsesToExplore argument. It's relatively small to | /// The default value for MaxUsesToExplore argument. It's relatively small to | ||||
/// keep the cost of analysis reasonable for clients like BasicAliasAnalysis, | /// keep the cost of analysis reasonable for clients like BasicAliasAnalysis, | ||||
/// where the results can't be cached. | /// where the results can't be cached. | ||||
/// TODO: we should probably introduce a caching CaptureTracking analysis and | /// TODO: we should probably introduce a caching CaptureTracking analysis and | ||||
▲ Show 20 Lines • Show All 221 Lines • ▼ Show 20 Lines | void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker, | ||||
while (!Worklist.empty()) { | while (!Worklist.empty()) { | ||||
const Use *U = Worklist.pop_back_val(); | const Use *U = Worklist.pop_back_val(); | ||||
Instruction *I = cast<Instruction>(U->getUser()); | Instruction *I = cast<Instruction>(U->getUser()); | ||||
V = U->get(); | V = U->get(); | ||||
switch (I->getOpcode()) { | switch (I->getOpcode()) { | ||||
case Instruction::Call: | case Instruction::Call: | ||||
case Instruction::Invoke: { | case Instruction::Invoke: { | ||||
if (auto *II = dyn_cast<IntrinsicInst>(I)) | |||||
if (II->getIntrinsicID() == Intrinsic::noalias || | |||||
II->getIntrinsicID() == Intrinsic::provenance_noalias || | |||||
II->getIntrinsicID() == Intrinsic::noalias_arg_guard || | |||||
II->getIntrinsicID() == Intrinsic::noalias_copy_guard) { | |||||
AddUses(I); | |||||
break; | |||||
} | |||||
auto *Call = cast<CallBase>(I); | auto *Call = cast<CallBase>(I); | ||||
// Not captured if the callee is readonly, doesn't return a copy through | // Not captured if the callee is readonly, doesn't return a copy through | ||||
// its return value and doesn't unwind (a readonly function can leak bits | // its return value and doesn't unwind (a readonly function can leak bits | ||||
// by throwing an exception or not depending on the input value). | // by throwing an exception or not depending on the input value). | ||||
if (Call->onlyReadsMemory() && Call->doesNotThrow() && | if (Call->onlyReadsMemory() && Call->doesNotThrow() && | ||||
Call->getType()->isVoidTy()) | Call->getType()->isVoidTy()) | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 125 Lines • Show Last 20 Lines |