Skip to content

Commit bef6034

Browse files
committed
[AliasAnalysis] CatchPad and CatchRet can modify escaped memory
CatchPad and CatchRet behave a lot like function calls: they can potentially modify any memory which has been escaped. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@253323 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent a56e1d6 commit bef6034

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

include/llvm/Analysis/AliasAnalysis.h

+24
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,26 @@ class AAResults {
421421
return getModRefInfo(I, MemoryLocation(P, Size));
422422
}
423423

424+
/// getModRefInfo (for catchpads) - Return information about whether
425+
/// a particular catchpad modifies or reads the specified memory location.
426+
ModRefInfo getModRefInfo(const CatchPadInst *I, const MemoryLocation &Loc);
427+
428+
/// getModRefInfo (for catchpads) - A convenience wrapper.
429+
ModRefInfo getModRefInfo(const CatchPadInst *I, const Value *P,
430+
uint64_t Size) {
431+
return getModRefInfo(I, MemoryLocation(P, Size));
432+
}
433+
434+
/// getModRefInfo (for catchrets) - Return information about whether
435+
/// a particular catchret modifies or reads the specified memory location.
436+
ModRefInfo getModRefInfo(const CatchReturnInst *I, const MemoryLocation &Loc);
437+
438+
/// getModRefInfo (for catchrets) - A convenience wrapper.
439+
ModRefInfo getModRefInfo(const CatchReturnInst *I, const Value *P,
440+
uint64_t Size) {
441+
return getModRefInfo(I, MemoryLocation(P, Size));
442+
}
443+
424444
/// Check whether or not an instruction may read or write memory (without
425445
/// regard to a specific location).
426446
///
@@ -461,6 +481,10 @@ class AAResults {
461481
return getModRefInfo((const AtomicRMWInst*)I, Loc);
462482
case Instruction::Call: return getModRefInfo((const CallInst*)I, Loc);
463483
case Instruction::Invoke: return getModRefInfo((const InvokeInst*)I,Loc);
484+
case Instruction::CatchPad:
485+
return getModRefInfo((const CatchPadInst *)I, Loc);
486+
case Instruction::CatchRet:
487+
return getModRefInfo((const CatchReturnInst *)I, Loc);
464488
default:
465489
return MRI_NoModRef;
466490
}

lib/Analysis/AliasAnalysis.cpp

+26
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,32 @@ ModRefInfo AAResults::getModRefInfo(const VAArgInst *V,
247247
return MRI_ModRef;
248248
}
249249

250+
ModRefInfo AAResults::getModRefInfo(const CatchPadInst *CatchPad,
251+
const MemoryLocation &Loc) {
252+
if (Loc.Ptr) {
253+
// If the pointer is a pointer to constant memory,
254+
// then it could not have been modified by this catchpad.
255+
if (pointsToConstantMemory(Loc))
256+
return MRI_NoModRef;
257+
}
258+
259+
// Otherwise, a catchpad reads and writes.
260+
return MRI_ModRef;
261+
}
262+
263+
ModRefInfo AAResults::getModRefInfo(const CatchReturnInst *CatchRet,
264+
const MemoryLocation &Loc) {
265+
if (Loc.Ptr) {
266+
// If the pointer is a pointer to constant memory,
267+
// then it could not have been modified by this catchpad.
268+
if (pointsToConstantMemory(Loc))
269+
return MRI_NoModRef;
270+
}
271+
272+
// Otherwise, a catchret reads and writes.
273+
return MRI_ModRef;
274+
}
275+
250276
ModRefInfo AAResults::getModRefInfo(const AtomicCmpXchgInst *CX,
251277
const MemoryLocation &Loc) {
252278
// Acquire/Release cmpxchg has properties that matter for arbitrary addresses.

0 commit comments

Comments
 (0)