mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-05-13 09:26:43 +00:00
Make dropTriviallyDeadConstantArrays not quadratic
Only look at the operands of dead constant arrays instead of all constant arrays again.
This commit is contained in:
parent
d7032bc3c0
commit
81f385b0c6
@ -11,6 +11,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "LLVMContextImpl.h"
|
#include "LLVMContextImpl.h"
|
||||||
|
#include "llvm/ADT/SetVector.h"
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
#include "llvm/IR/OptBisect.h"
|
#include "llvm/IR/OptBisect.h"
|
||||||
#include "llvm/IR/Type.h"
|
#include "llvm/IR/Type.h"
|
||||||
@ -142,18 +143,19 @@ LLVMContextImpl::~LLVMContextImpl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LLVMContextImpl::dropTriviallyDeadConstantArrays() {
|
void LLVMContextImpl::dropTriviallyDeadConstantArrays() {
|
||||||
bool Changed;
|
SmallSetVector<ConstantArray *, 4> WorkList(ArrayConstants.begin(),
|
||||||
do {
|
ArrayConstants.end());
|
||||||
Changed = false;
|
|
||||||
|
|
||||||
for (auto I = ArrayConstants.begin(), E = ArrayConstants.end(); I != E;) {
|
while (!WorkList.empty()) {
|
||||||
auto *C = *I++;
|
ConstantArray *C = WorkList.pop_back_val();
|
||||||
if (C->use_empty()) {
|
if (C->use_empty()) {
|
||||||
Changed = true;
|
for (const Use &Op : C->operands()) {
|
||||||
C->destroyConstant();
|
if (auto *COp = dyn_cast<ConstantArray>(Op))
|
||||||
|
WorkList.insert(COp);
|
||||||
}
|
}
|
||||||
|
C->destroyConstant();
|
||||||
}
|
}
|
||||||
} while (Changed);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Module::dropTriviallyDeadConstantArrays() {
|
void Module::dropTriviallyDeadConstantArrays() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user