diff options
author | Keno Fischer <keno@alumni.harvard.edu> | 2017-05-09 21:07:20 +0000 |
---|---|---|
committer | Keno Fischer <keno@alumni.harvard.edu> | 2017-05-09 21:07:20 +0000 |
commit | 06f962c1e8c84aac3bac31ceeeeda22a58a1fb7b (patch) | |
tree | f796c5e0fd8dcc780b9dbd9b981335c57a0e6f12 /llvm/lib/Transforms | |
parent | 7e3794d5c3f02b74e87e58bdce5a2e95b3334f72 (diff) | |
download | bcm5719-llvm-06f962c1e8c84aac3bac31ceeeeda22a58a1fb7b.tar.gz bcm5719-llvm-06f962c1e8c84aac3bac31ceeeeda22a58a1fb7b.zip |
[GVN] Fix a crash on encountering non-integral pointers
Summary:
This fixes the immediate crash caused by introducing an incorrect inttoptr
before attempting the conversion. There may still be a legality
check missing somewhere earlier for non-integral pointers, but this change
seems necessary in any case.
Reviewers: sanjoy, dberlin
Reviewed By: dberlin
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D32623
llvm-svn: 302587
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/Utils/VNCoercion.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp index 83bd29dbca6..60d9ede2c48 100644 --- a/llvm/lib/Transforms/Utils/VNCoercion.cpp +++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp @@ -303,6 +303,15 @@ static T *getStoreValueForLoadHelper(T *SrcVal, unsigned Offset, Type *LoadTy, const DataLayout &DL) { LLVMContext &Ctx = SrcVal->getType()->getContext(); + // If two pointers are in the same address space, they have the same size, + // so we don't need to do any truncation, etc. This avoids introducing + // ptrtoint instructions for pointers that may be non-integral. + if (SrcVal->getType()->isPointerTy() && LoadTy->isPointerTy() && + cast<PointerType>(SrcVal->getType())->getAddressSpace() == + cast<PointerType>(LoadTy)->getAddressSpace()) { + return SrcVal; + } + uint64_t StoreSize = (DL.getTypeSizeInBits(SrcVal->getType()) + 7) / 8; uint64_t LoadSize = (DL.getTypeSizeInBits(LoadTy) + 7) / 8; // Compute which bits of the stored value are being used by the load. Convert |