summaryrefslogtreecommitdiffstats
path: root/mlir/lib/Analysis/NestedMatcher.cpp
diff options
context:
space:
mode:
authorNicolas Vasilache <ntv@google.com>2019-01-31 08:05:11 -0800
committerjpienaar <jpienaar@google.com>2019-03-29 16:04:23 -0700
commitea963d7e288133ae307e82f401c9f3eb957f13e7 (patch)
treeff2be507b89456481d2b040f78427912b24d2f9d /mlir/lib/Analysis/NestedMatcher.cpp
parentd4921f4a96a46e24c2fb76ca7feb66e6894395d2 (diff)
downloadbcm5719-llvm-ea963d7e288133ae307e82f401c9f3eb957f13e7.tar.gz
bcm5719-llvm-ea963d7e288133ae307e82f401c9f3eb957f13e7.zip
Post commit fixes
This CL introduces a hotfix post refactoring of NestedMatchers: - fix uninitialized read to skip - avoid bumpptr allocating with 0 elements Interestingly the latter issue only surfaced in fastbuild mode with no-san and manifested itself by a SIGILL. All other combinations that were tried failed to reproduce the issue (dbg, opt, fastbuild with asan) PiperOrigin-RevId: 231787642
Diffstat (limited to 'mlir/lib/Analysis/NestedMatcher.cpp')
-rw-r--r--mlir/lib/Analysis/NestedMatcher.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/mlir/lib/Analysis/NestedMatcher.cpp b/mlir/lib/Analysis/NestedMatcher.cpp
index 43e3b332a58..46bf5ad0b97 100644
--- a/mlir/lib/Analysis/NestedMatcher.cpp
+++ b/mlir/lib/Analysis/NestedMatcher.cpp
@@ -51,10 +51,12 @@ llvm::BumpPtrAllocator *&NestedPattern::allocator() {
NestedPattern::NestedPattern(Instruction::Kind k,
ArrayRef<NestedPattern> nested,
FilterFunctionType filter)
- : kind(k), nestedPatterns(ArrayRef<NestedPattern>(nested)), filter(filter) {
- auto *newNested = allocator()->Allocate<NestedPattern>(nested.size());
- std::uninitialized_copy(nested.begin(), nested.end(), newNested);
- nestedPatterns = ArrayRef<NestedPattern>(newNested, nested.size());
+ : kind(k), nestedPatterns(), filter(filter), skip(nullptr) {
+ if (!nested.empty()) {
+ auto *newNested = allocator()->Allocate<NestedPattern>(nested.size());
+ std::uninitialized_copy(nested.begin(), nested.end(), newNested);
+ nestedPatterns = ArrayRef<NestedPattern>(newNested, nested.size());
+ }
}
unsigned NestedPattern::getDepth() const {
OpenPOWER on IntegriCloud