diff options
author | Nikita Popov <npopov@redhat.com> | 2022-05-24 15:20:01 +0200 |
---|---|---|
committer | Nikita Popov <npopov@redhat.com> | 2022-05-25 09:54:04 +0200 |
commit | 8a6698b5238228876e7e5eb20ed82167ab1b04db (patch) | |
tree | 0b59fe87857247a63541a79626d494d78fe9411c /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 643df8fa8ef58d883cbb554c7e71910dc8a8673c (diff) | |
download | llvm-8a6698b5238228876e7e5eb20ed82167ab1b04db.zip llvm-8a6698b5238228876e7e5eb20ed82167ab1b04db.tar.gz llvm-8a6698b5238228876e7e5eb20ed82167ab1b04db.tar.bz2 |
[ValueTracking] Loads with !dereferenceable metadata cannot be undef/poison
A load with !dereferenceable or !dereferenceable_or_null metadata
must return a well-defined (non-undef/poison) value. Effectively
they imply !noundef. This is the same as we do for the
dereferenceable(N) attribute.
This should fix https://github.com/llvm/llvm-project/issues/55672,
or at least the specific case discussed there.
Differential Revision: https://reviews.llvm.org/D126296
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index a326335..c7586f2 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -5191,7 +5191,9 @@ static bool isGuaranteedNotToBeUndefOrPoison(const Value *V, } if (auto *I = dyn_cast<LoadInst>(V)) - if (I->getMetadata(LLVMContext::MD_noundef)) + if (I->hasMetadata(LLVMContext::MD_noundef) || + I->hasMetadata(LLVMContext::MD_dereferenceable) || + I->hasMetadata(LLVMContext::MD_dereferenceable_or_null)) return true; if (programUndefinedIfUndefOrPoison(V, PoisonOnly)) |