[PATCH] D110158: [Analysis] Fix issues when querying vscale attributes on functions
David Sherwood via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 21 05:19:43 PDT 2021
david-arm created this revision.
david-arm added reviewers: sdesmalen, georges, DylanFleming-arm.
Herald added a subscriber: hiraditya.
david-arm requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D110158
Files:
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
Index: llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
===================================================================
--- llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCasts.cpp
@@ -963,7 +963,8 @@
}
if (match(Src, m_VScale(DL))) {
- if (Trunc.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
+ if (Trunc.getFunction() &&
+ Trunc.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
unsigned MaxVScale = Trunc.getFunction()
->getFnAttribute(Attribute::VScaleRange)
.getVScaleRangeArgs()
@@ -1334,7 +1335,8 @@
}
if (match(Src, m_VScale(DL))) {
- if (CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
+ if (CI.getFunction() &&
+ CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
unsigned MaxVScale = CI.getFunction()
->getFnAttribute(Attribute::VScaleRange)
.getVScaleRangeArgs()
@@ -1604,7 +1606,8 @@
}
if (match(Src, m_VScale(DL))) {
- if (CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
+ if (CI.getFunction() &&
+ CI.getFunction()->hasFnAttribute(Attribute::VScaleRange)) {
unsigned MaxVScale = CI.getFunction()
->getFnAttribute(Attribute::VScaleRange)
.getVScaleRangeArgs()
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -1690,7 +1690,8 @@
Known.Zero.setBitsFrom(31);
break;
case Intrinsic::vscale: {
- if (!II->getFunction()->hasFnAttribute(Attribute::VScaleRange))
+ if (!II->getFunction() ||
+ !II->getFunction()->hasFnAttribute(Attribute::VScaleRange))
break;
auto VScaleRange = II->getFunction()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D110158.373870.patch
Type: text/x-patch
Size: 2009 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210921/c72639d8/attachment.bin>
More information about the llvm-commits
mailing list