[PATCH] D38735: [ScheduleDAGInstrs] fix behavior of getUnderlyingObjectsForCodeGen when no identifiable object found
Hiroshi Inoue via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 10 08:06:01 PDT 2017
inouehrs created this revision.
This patch fixes the bug introduced in my previous patch https://reviews.llvm.org/D35907 reported by http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20171002/491452.html .
Before https://reviews.llvm.org/D35907, when `GetUnderlyingObjects` fails to find an identifiable object, `allMMOsOkay` lambda in `getUnderlyingObjectsForInstr` returns false and `Objects` vector is cleared. This behavior is unintentionally changed by https://reviews.llvm.org/D35907.
This patch makes the behavior for such case same as the previous behavior.
Since https://reviews.llvm.org/D35907 introduced a wrapper function `getUnderlyingObjectsForCodeGen` around `GetUnderlyingObjects`, `getUnderlyingObjectsForCodeGen` is modified to return a boolean value to ask the caller to clear the `Objects` vector.
https://reviews.llvm.org/D38735
Files:
include/llvm/Analysis/ValueTracking.h
lib/Analysis/ValueTracking.cpp
lib/CodeGen/ScheduleDAGInstrs.cpp
Index: lib/CodeGen/ScheduleDAGInstrs.cpp
===================================================================
--- lib/CodeGen/ScheduleDAGInstrs.cpp
+++ lib/CodeGen/ScheduleDAGInstrs.cpp
@@ -151,7 +151,8 @@
Objects.push_back(UnderlyingObjectsVector::value_type(PSV, MayAlias));
} else if (const Value *V = MMO->getValue()) {
SmallVector<Value *, 4> Objs;
- getUnderlyingObjectsForCodeGen(V, Objs, DL);
+ if (!getUnderlyingObjectsForCodeGen(V, Objs, DL))
+ return false;
for (Value *V : Objs) {
assert(isIdentifiedObject(V));
Index: lib/Analysis/ValueTracking.cpp
===================================================================
--- lib/Analysis/ValueTracking.cpp
+++ lib/Analysis/ValueTracking.cpp
@@ -3428,7 +3428,8 @@
/// This is a wrapper around GetUnderlyingObjects and adds support for basic
/// ptrtoint+arithmetic+inttoptr sequences.
-void llvm::getUnderlyingObjectsForCodeGen(const Value *V,
+/// It returns false if unidentified object is found in GetUnderlyingObjects.
+bool llvm::getUnderlyingObjectsForCodeGen(const Value *V,
SmallVectorImpl<Value *> &Objects,
const DataLayout &DL) {
SmallPtrSet<const Value *, 16> Visited;
@@ -3454,11 +3455,12 @@
// getUnderlyingObjectsForCodeGen also fails for safety.
if (!isIdentifiedObject(V)) {
Objects.clear();
- return;
+ return false;
}
Objects.push_back(const_cast<Value *>(V));
}
} while (!Working.empty());
+ return true;
}
/// Return true if the only users of this pointer are lifetime markers.
Index: include/llvm/Analysis/ValueTracking.h
===================================================================
--- include/llvm/Analysis/ValueTracking.h
+++ include/llvm/Analysis/ValueTracking.h
@@ -323,7 +323,7 @@
/// This is a wrapper around GetUnderlyingObjects and adds support for basic
/// ptrtoint+arithmetic+inttoptr sequences.
- void getUnderlyingObjectsForCodeGen(const Value *V,
+ bool getUnderlyingObjectsForCodeGen(const Value *V,
SmallVectorImpl<Value *> &Objects,
const DataLayout &DL);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38735.118387.patch
Type: text/x-patch
Size: 2225 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171010/c33f7cf6/attachment.bin>
More information about the llvm-commits
mailing list