mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-13 17:37:00 +00:00

Another buildbot failure http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/20402 clang-9: /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/llvm/include/llvm/ADT/DenseMap.h:1228: llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type* llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::operator->() const [with KeyT = const llvm::Instruction*; ValueT = unsigned int; KeyInfoT = llvm::DenseMapInfo<const llvm::Instruction*>; Bucket = llvm::detail::DenseMapPair<const llvm::Instruction*, unsigned int>; bool IsConst = false; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::pointer = llvm::detail::DenseMapPair<const llvm::Instruction*, unsigned int>*; llvm::DenseMapIterator<KeyT, ValueT, KeyInfoT, Bucket, IsConst>::value_type = llvm::detail::DenseMapPair<const llvm::Instruction*, unsigned int>]: Assertion `isHandleInSync() && "invalid iterator access!"' failed. 0. Program arguments: /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/stage1.install/bin/clang-9 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -disable-free -main-file-name ArchiveCommandLine.cpp -mrelocation-model static -mthread-model posix -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu skylake-avx512 -dwarf-column-info -debugger-tuning=gdb -momit-leaf-frame-pointer -coverage-notes-file /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/sandbox/build/MultiSource/Benchmarks/7zip/Output/ArchiveCommandLine.llvm.gcno -resource-dir /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/stage1.install/lib/clang/9.0.0 -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/sandbox/build/MultiSource/Benchmarks/7zip -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/MultiSource/Benchmarks/7zip -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/include -I ../../../include -D _GNU_SOURCE -D __STDC_LIMIT_MACROS -D NDEBUG -D BREAK_HANDLER -D UNICODE -D _UNICODE -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/MultiSource/Benchmarks/7zip/C -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/MultiSource/Benchmarks/7zip/CPP/myWindows -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/MultiSource/Benchmarks/7zip/CPP/include_windows -I /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/MultiSource/Benchmarks/7zip/CPP -I . -D _FILE_OFFSET_BITS=64 -D _LARGEFILE_SOURCE -D NDEBUG -D _REENTRANT -D ENV_UNIX -D _7ZIP_LARGE_PAGES -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/x86_64-linux-gnu/c++/5.4.0 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c++/5.4.0/backward -internal-isystem /usr/local/include -internal-isystem /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/stage1.install/lib/clang/9.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O3 -std=gnu++98 -fdeprecated-macro -fdebug-compilation-dir /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/sandbox/build/MultiSource/Benchmarks/7zip -ferror-limit 19 -fmessage-length 0 -pthread -fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option -vectorize-loops -vectorize-slp -o Output/ArchiveCommandLine.llvm.o -x c++ /home/ssglocal/clang-cmake-x86_64-sde-avx512-linux/clang-cmake-x86_64-sde-avx512-linux/test/test-suite/MultiSource/Benchmarks/7zip/CPP/7zip/UI/Common/ArchiveCommandLine.cpp -faddrsig This reverts r357222 (git commit 64cccfcc72c44ea62f441b782d2177a90912769a) llvm-svn: 357227
88 lines
3.7 KiB
C++
88 lines
3.7 KiB
C++
//===- OrderedBasicBlock.cpp --------------------------------- -*- C++ -*-===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file implements the OrderedBasicBlock class. OrderedBasicBlock
|
|
// maintains an interface where clients can query if one instruction comes
|
|
// before another in a BasicBlock. Since BasicBlock currently lacks a reliable
|
|
// way to query relative position between instructions one can use
|
|
// OrderedBasicBlock to do such queries. OrderedBasicBlock is lazily built on a
|
|
// source BasicBlock and maintains an internal Instruction -> Position map. A
|
|
// OrderedBasicBlock instance should be discarded whenever the source
|
|
// BasicBlock changes.
|
|
//
|
|
// It's currently used by the CaptureTracker in order to find relative
|
|
// positions of a pair of instructions inside a BasicBlock.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/Analysis/OrderedBasicBlock.h"
|
|
#include "llvm/IR/Instruction.h"
|
|
using namespace llvm;
|
|
|
|
OrderedBasicBlock::OrderedBasicBlock(const BasicBlock *BasicB)
|
|
: NextInstPos(0), BB(BasicB) {
|
|
LastInstFound = BB->end();
|
|
}
|
|
|
|
/// Given no cached results, find if \p A comes before \p B in \p BB.
|
|
/// Cache and number out instruction while walking \p BB.
|
|
bool OrderedBasicBlock::comesBefore(const Instruction *A,
|
|
const Instruction *B) {
|
|
const Instruction *Inst = nullptr;
|
|
assert(!(LastInstFound == BB->end() && NextInstPos != 0) &&
|
|
"Instruction supposed to be in NumberedInsts");
|
|
assert(A->getParent() == BB && "Instruction supposed to be in the block!");
|
|
assert(B->getParent() == BB && "Instruction supposed to be in the block!");
|
|
|
|
// Start the search with the instruction found in the last lookup round.
|
|
auto II = BB->begin();
|
|
auto IE = BB->end();
|
|
if (LastInstFound != IE)
|
|
II = std::next(LastInstFound);
|
|
|
|
// Number all instructions up to the point where we find 'A' or 'B'.
|
|
for (; II != IE; ++II) {
|
|
Inst = cast<Instruction>(II);
|
|
NumberedInsts[Inst] = NextInstPos++;
|
|
if (Inst == A || Inst == B)
|
|
break;
|
|
}
|
|
|
|
assert(II != IE && "Instruction not found?");
|
|
assert((Inst == A || Inst == B) && "Should find A or B");
|
|
LastInstFound = II;
|
|
return Inst != B;
|
|
}
|
|
|
|
/// Find out whether \p A dominates \p B, meaning whether \p A
|
|
/// comes before \p B in \p BB. This is a simplification that considers
|
|
/// cached instruction positions and ignores other basic blocks, being
|
|
/// only relevant to compare relative instructions positions inside \p BB.
|
|
bool OrderedBasicBlock::dominates(const Instruction *A, const Instruction *B) {
|
|
assert(A->getParent() == B->getParent() &&
|
|
"Instructions must be in the same basic block!");
|
|
assert(A->getParent() == BB && "Instructions must be in the tracked block!");
|
|
|
|
// First we lookup the instructions. If they don't exist, lookup will give us
|
|
// back ::end(). If they both exist, we compare the numbers. Otherwise, if NA
|
|
// exists and NB doesn't, it means NA must come before NB because we would
|
|
// have numbered NB as well if it didn't. The same is true for NB. If it
|
|
// exists, but NA does not, NA must come after it. If neither exist, we need
|
|
// to number the block and cache the results (by calling comesBefore).
|
|
auto NAI = NumberedInsts.find(A);
|
|
auto NBI = NumberedInsts.find(B);
|
|
if (NAI != NumberedInsts.end() && NBI != NumberedInsts.end())
|
|
return NAI->second < NBI->second;
|
|
if (NAI != NumberedInsts.end())
|
|
return true;
|
|
if (NBI != NumberedInsts.end())
|
|
return false;
|
|
|
|
return comesBefore(A, B);
|
|
}
|