aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2017-11-28 01:25:38 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2017-11-28 01:25:38 +0000
commitc06f55e1e8c09c779d6dedae84490f25cdc9f4ac (patch)
tree15f08a1649594cbdff69f190401d66a3d0db3486 /llvm/lib/Transforms/Utils/Local.cpp
parent5d01e708e1ae895c64a5ccc8f525a9b5d3bfad8a (diff)
downloadllvm-c06f55e1e8c09c779d6dedae84490f25cdc9f4ac.zip
llvm-c06f55e1e8c09c779d6dedae84490f25cdc9f4ac.tar.gz
llvm-c06f55e1e8c09c779d6dedae84490f25cdc9f4ac.tar.bz2
This reverts commit r319096 and r319097.
Revert "[SROA] Propagate !range metadata when moving loads." Revert "[Mem2Reg] Clang-format unformatted parts of this file. NFCI." Davide says they broke a bot. llvm-svn: 319131
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index fa42902..3f76295 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1947,24 +1947,18 @@ 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();
- auto *OldTy = OldLI.getType();
- if (DL.getTypeStoreSizeInBits(NewTy) == DL.getTypeSizeInBits(OldTy) &&
- NewTy->isIntegerTy()) {
- // An integer with the same number of bits - give it the range
- // metadata!.
- NewLI.setMetadata(LLVMContext::MD_range, N);
+ // Give up unless it is converted to a pointer where there is a single very
+ // valuable mapping we can do reliably.
+ // FIXME: It would be nice to propagate this in more ways, but the type
+ // conversions make it hard.
+ if (!NewTy->isPointerTy())
return;
- }
- if (NewTy->isPointerTy()) {
- // Try to convert the !range metadata to !nonnull metadata on the
- // new pointer.
- unsigned BitWidth = DL.getTypeSizeInBits(NewTy);
- if (!getConstantRangeFromMetadata(*N).contains(APInt(BitWidth, 0))) {
- MDNode *NN = MDNode::get(OldLI.getContext(), None);
- NewLI.setMetadata(LLVMContext::MD_nonnull, NN);
- }
+ unsigned BitWidth = DL.getTypeSizeInBits(NewTy);
+ if (!getConstantRangeFromMetadata(*N).contains(APInt(BitWidth, 0))) {
+ MDNode *NN = MDNode::get(OldLI.getContext(), None);
+ NewLI.setMetadata(LLVMContext::MD_nonnull, NN);
}
}