Skip to content

Commit bdb3107

Browse files
authored
null / nonnull check (#2443)
* null / nonnull check * fix
1 parent a92bc18 commit bdb3107

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

enzyme/Enzyme/Utils.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3985,6 +3985,17 @@ arePointersGuaranteedNoAlias(TargetLibraryInfo &TLI, llvm::AAResults &AA,
39853985
if (lhs == rhs) {
39863986
return false;
39873987
}
3988+
if (auto i1 = dyn_cast<Instruction>(op1))
3989+
if (isa<ConstantPointerNull>(op0) &&
3990+
hasMetadata(i1, LLVMContext::MD_nonnull)) {
3991+
return true;
3992+
}
3993+
if (auto i0 = dyn_cast<Instruction>(op0))
3994+
if (isa<ConstantPointerNull>(op1) &&
3995+
hasMetadata(i0, LLVMContext::MD_nonnull)) {
3996+
return true;
3997+
}
3998+
39883999
if (!lhs->getType()->isPointerTy() && !rhs->getType()->isPointerTy())
39894000
return {};
39904001

0 commit comments

Comments
 (0)