SideEffectAnalysis: don't assume that arguments with trivial type cannot be pointers.

Even values of trivial type can contain a Builtin.RawPointer, which can be used to read/write from/to.

To compensate for the removed check, enable the escape-analysis check in MemBehavior (as it was before).

This fixes a recently introduced miscompile.
rdar://problem/70220876
This commit is contained in:
Erik Eckstein
2020-10-13 09:51:31 +02:00
parent 45127174fb
commit b0c9e69b6f
4 changed files with 46 additions and 11 deletions

View File

@@ -215,11 +215,7 @@ public:
SIMPLE_MEMBEHAVIOR_INST(CondFailInst, None)
#undef SIMPLE_MEMBEHAVIOR_INST
// If we are asked to treat ref count increments as being inert, return None
// for these.
//
// FIXME: Once we separate the notion of ref counts from reading/writing
// memory this will be unnecessary.
// Incrementing reference counts doesn't have an observable memory effect.
#define REFCOUNTINC_MEMBEHAVIOR_INST(Name) \
MemBehavior visit##Name(Name *I) { \
return MemBehavior::None; \
@@ -455,7 +451,7 @@ MemBehavior MemoryBehaviorVisitor::getApplyBehavior(FullApplySite AS) {
behavior = MemBehavior::MayRead;
// Ask escape analysis.
if (!nonEscapingAddress && !EA->canEscapeTo(V, AS))
if (!EA->canEscapeTo(V, AS))
behavior = MemBehavior::None;
}
LLVM_DEBUG(llvm::dbgs() << " Found apply, returning " << behavior << '\n');