File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 11
11
// ===----------------------------------------------------------------------===//
12
12
13
13
#include " LLVMContextImpl.h"
14
+ #include " llvm/ADT/SetVector.h"
14
15
#include " llvm/IR/Module.h"
15
16
#include " llvm/IR/OptBisect.h"
16
17
#include " llvm/IR/Type.h"
@@ -142,18 +143,19 @@ LLVMContextImpl::~LLVMContextImpl() {
142
143
}
143
144
144
145
void LLVMContextImpl::dropTriviallyDeadConstantArrays () {
145
- bool Changed;
146
- do {
147
- Changed = false ;
148
-
149
- for ( auto I = ArrayConstants. begin (), E = ArrayConstants. end (); I != E;) {
150
- auto *C = *I++;
151
- if ( C->use_empty ()) {
152
- Changed = true ;
153
- C-> destroyConstant ( );
146
+ SmallSetVector<ConstantArray *, 4 > WorkList (ArrayConstants. begin (),
147
+ ArrayConstants. end ());
148
+
149
+ while (!WorkList. empty ()) {
150
+ ConstantArray *C = WorkList. pop_back_val ();
151
+ if (C-> use_empty ()) {
152
+ for ( const Use &Op : C->operands ()) {
153
+ if ( auto *COp = dyn_cast<ConstantArray>(Op))
154
+ WorkList. insert (COp );
154
155
}
156
+ C->destroyConstant ();
155
157
}
156
- } while (Changed);
158
+ }
157
159
}
158
160
159
161
void Module::dropTriviallyDeadConstantArrays () {
You can’t perform that action at this time.
0 commit comments