diff options
author | Philip Reames <listmail@philipreames.com> | 2019-02-19 23:49:38 +0000 |
---|---|---|
committer | Philip Reames <listmail@philipreames.com> | 2019-02-19 23:49:38 +0000 |
commit | 952d234d00b1e67a2d51e3d13ac734a9e2e99f3c (patch) | |
tree | ef51b66a4484eb238213c726e237fa4f310cb966 /llvm/lib/Transforms/Utils/VNCoercion.cpp | |
parent | bdbbfdc8c2f60947dd149c59879af2e1fb56cd75 (diff) | |
download | bcm5719-llvm-952d234d00b1e67a2d51e3d13ac734a9e2e99f3c.tar.gz bcm5719-llvm-952d234d00b1e67a2d51e3d13ac734a9e2e99f3c.zip |
[GVN] Fix a crash bug w/non-integral pointers and memtransfers
Problem is very similiar to the one fixed for memsets in r354399, we try to coerce a value to non-integral type, and then crash while try to do so. Since we shouldn't be doing such coercions to start with, easy fix. From inspection, I see two other cases which look to be similiar and will follow up with most test cases and fixes if confirmed.
llvm-svn: 354403
Diffstat (limited to 'llvm/lib/Transforms/Utils/VNCoercion.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/VNCoercion.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/VNCoercion.cpp b/llvm/lib/Transforms/Utils/VNCoercion.cpp index 8e21472f2c1..1aedce75ca6 100644 --- a/llvm/lib/Transforms/Utils/VNCoercion.cpp +++ b/llvm/lib/Transforms/Utils/VNCoercion.cpp @@ -300,6 +300,11 @@ int analyzeLoadFromClobberingMemInst(Type *LoadTy, Value *LoadPtr, if (Offset == -1) return Offset; + // Don't coerce non-integral pointers to integers or vice versa. + if (DL.isNonIntegralPointerType(LoadTy->getScalarType())) + // TODO: Can allow nullptrs from constant zeros + return -1; + unsigned AS = Src->getType()->getPointerAddressSpace(); // Otherwise, see if we can constant fold a load from the constant with the // offset applied as appropriate. |