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 "llvm/ADT/SetVector.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/OptBisect.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
@ -142,18 +143,19 @@ LLVMContextImpl::~LLVMContextImpl() {
|
||||
}
|
||||
|
||||
void LLVMContextImpl::dropTriviallyDeadConstantArrays() {
|
||||
bool Changed;
|
||||
do {
|
||||
Changed = false;
|
||||
SmallSetVector<ConstantArray *, 4> WorkList(ArrayConstants.begin(),
|
||||
ArrayConstants.end());
|
||||
|
||||
for (auto I = ArrayConstants.begin(), E = ArrayConstants.end(); I != E;) {
|
||||
auto *C = *I++;
|
||||
while (!WorkList.empty()) {
|
||||
ConstantArray *C = WorkList.pop_back_val();
|
||||
if (C->use_empty()) {
|
||||
Changed = true;
|
||||
for (const Use &Op : C->operands()) {
|
||||
if (auto *COp = dyn_cast<ConstantArray>(Op))
|
||||
WorkList.insert(COp);
|
||||
}
|
||||
C->destroyConstant();
|
||||
}
|
||||
}
|
||||
} while (Changed);
|
||||
}
|
||||
|
||||
void Module::dropTriviallyDeadConstantArrays() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user