aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorNikita Popov <npopov@redhat.com>2023-01-20 15:27:19 +0100
committerNikita Popov <npopov@redhat.com>2023-01-20 15:28:32 +0100
commita4898b437dbd76bf62c6fc2c5f015c327aa19190 (patch)
tree530959255c05ae56c8e560b7fed08676d43638dd /llvm/lib/Transforms/Utils/Local.cpp
parent4ece50737d5385fb80cfa23f5297d1111f8eed39 (diff)
downloadllvm-a4898b437dbd76bf62c6fc2c5f015c327aa19190.zip
llvm-a4898b437dbd76bf62c6fc2c5f015c327aa19190.tar.gz
llvm-a4898b437dbd76bf62c6fc2c5f015c327aa19190.tar.bz2
[Local] Preserve range metadata if the type did not change
In copyRangeMetadata() and by extension copyLoadMetadata(), handle the trivial case where the type did not change, in which case we can simply preserve the range metadata as is.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index a57035d..31cdd2e 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2916,6 +2916,11 @@ void llvm::copyNonnullMetadata(const LoadInst &OldLI, MDNode *N,
void llvm::copyRangeMetadata(const DataLayout &DL, const LoadInst &OldLI,
MDNode *N, LoadInst &NewLI) {
auto *NewTy = NewLI.getType();
+ // Simply copy the metadata if the type did not change.
+ if (NewTy == OldLI.getType()) {
+ NewLI.setMetadata(LLVMContext::MD_range, N);
+ return;
+ }
// Give up unless it is converted to a pointer where there is a single very
// valuable mapping we can do reliably.