[PATCH] D103556: [Attributor] Allow lookupAAFor to return null on invalid state
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 2 14:35:53 PDT 2021
jhuber6 updated this revision to Diff 349383.
jhuber6 added a comment.
Forgot to format
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D103556/new/
https://reviews.llvm.org/D103556
Files:
llvm/include/llvm/Transforms/IPO/Attributor.h
Index: llvm/include/llvm/Transforms/IPO/Attributor.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/Attributor.h
+++ llvm/include/llvm/Transforms/IPO/Attributor.h
@@ -1218,12 +1218,13 @@
DepClassTy::NONE);
}
- /// Return the attribute of \p AAType for \p IRP if existing. This also allows
- /// non-AA users lookup.
+ /// Return the attribute of \p AAType for \p IRP if existing and valid. This
+ /// also allows non-AA users lookup.
template <typename AAType>
AAType *lookupAAFor(const IRPosition &IRP,
const AbstractAttribute *QueryingAA = nullptr,
- DepClassTy DepClass = DepClassTy::OPTIONAL) {
+ DepClassTy DepClass = DepClassTy::OPTIONAL,
+ bool AllowInvalidState = true) {
static_assert(std::is_base_of<AbstractAttribute, AAType>::value,
"Cannot query an attribute with a type not derived from "
"'AbstractAttribute'!");
@@ -1240,6 +1241,10 @@
AA->getState().isValidState())
recordDependence(*AA, const_cast<AbstractAttribute &>(*QueryingAA),
DepClass);
+
+ // Return nullptr if this attribute has an invalid state.
+ if (!AllowInvalidState && !AA->getState().isValidState())
+ return nullptr;
return AA;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103556.349383.patch
Type: text/x-patch
Size: 1414 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210602/d1420178/attachment.bin>
More information about the llvm-commits
mailing list