diff options
author | David Sherwood <david.sherwood@arm.com> | 2021-09-21 12:11:04 +0100 |
---|---|---|
committer | David Sherwood <david.sherwood@arm.com> | 2021-09-24 09:58:10 +0100 |
commit | c2634fc6abe73acf0d9c4421071948e43d96d7eb (patch) | |
tree | 2d78cfa450b294803f69fd19dc919e3426c54246 /llvm/lib/Analysis/ValueTracking.cpp | |
parent | 3bad9616aa52aa467e4f1fb5c00abac6acba8471 (diff) | |
download | llvm-c2634fc6abe73acf0d9c4421071948e43d96d7eb.zip llvm-c2634fc6abe73acf0d9c4421071948e43d96d7eb.tar.gz llvm-c2634fc6abe73acf0d9c4421071948e43d96d7eb.tar.bz2 |
[Analysis] Fix issues when querying vscale attributes on functions
There are several places in the code that are currently broken as
they assume an Instruction always has a parent Function when
attempting to get the vscale_range attribute. This patch adds checks
that an Instruction has a parent.
I've added a test for a parentless @llvm.vscale intrinsic call here:
unittests/Analysis/ValueTrackingTest.cpp
Differential Revision: https://reviews.llvm.org/D110158
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 174ee97..ab5c388 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -1685,7 +1685,8 @@ static void computeKnownBitsFromOperator(const Operator *I, Known.Zero.setBitsFrom(31); break; case Intrinsic::vscale: { - if (!II->getFunction()->hasFnAttribute(Attribute::VScaleRange)) + if (!II->getParent() || + !II->getFunction()->hasFnAttribute(Attribute::VScaleRange)) break; auto VScaleRange = II->getFunction() |