Skip to content

Commit 0801efd

Browse files
authored
Merge pull request #1068 from reactorlabs/ciTimeoutCrash
trying to work around CI timeouts and crashes
2 parents 60adcb6 + b5685ba commit 0801efd

File tree

4 files changed

+84
-59
lines changed

4 files changed

+84
-59
lines changed

.gitlab-ci.yml

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ test_release_2:
9494
variables:
9595
GIT_STRATEGY: none
9696
PIR_INLINER_INLINE_UNLIKELY: 1
97-
PIR_MAX_INPUT_SIZE: 5000
98-
PIR_INLINER_MAX_SIZE: 5000
99-
PIR_LLVM_OPT_LEVEL: 1
97+
PIR_MAX_INPUT_SIZE: 4000
98+
PIR_INLINER_MAX_SIZE: 4000
99+
PIR_LLVM_OPT_LEVEL: 0
100+
# there is an impossible to reproduce memory corruption issue in survivals compete.Rnw
101+
retry: 1
100102
stage: Run tests
101103
needs:
102104
- rir_container
@@ -136,6 +138,7 @@ tests_debug2:
136138
image: registry.gitlab.com/rirvm/rir_mirror:$CI_COMMIT_SHA
137139
variables:
138140
GIT_STRATEGY: none
141+
PIR_LLVM_OPT_LEVEL: 0
139142
stage: Run tests
140143
needs:
141144
- rir_container
@@ -179,18 +182,14 @@ test_features_1:
179182
except:
180183
- schedules
181184
script:
182-
- cd /opt/rir/build/releaseassert
183-
# - PIR_ENABLE_PROFILER=1 ./bin/tests
184185
- cd /opt/rir/build/release
185-
- PIR_DEOPT_CHAOS=1000 PIR_INLINER_MAX_INLINEE_SIZE=800 bin/gnur-make-tests check || $SAVE_LOGS
186-
- PIR_WARMUP=2 PIR_DEOPT_CHAOS=400 ./bin/gnur-make-tests check || $SAVE_LOGS
187-
- RIR_SERIALIZE_CHAOS=1 FAST_TESTS=1 ./bin/tests
188-
- PIR_GLOBAL_SPECIALIZATION_LEVEL=0 ./bin/tests
189-
- PIR_GLOBAL_SPECIALIZATION_LEVEL=1 ./bin/tests
190-
- PIR_GLOBAL_SPECIALIZATION_LEVEL=2 ./bin/tests
191-
- PIR_GLOBAL_SPECIALIZATION_LEVEL=3 ./bin/tests
192-
- PIR_GLOBAL_SPECIALIZATION_LEVEL=4 ./bin/tests
193-
- PIR_GLOBAL_SPECIALIZATION_LEVEL=5 ./bin/tests
186+
- PIR_WARMUP=2 PIR_DEOPT_CHAOS=500 ./bin/gnur-make-tests check || $SAVE_LOGS
187+
- PIR_GLOBAL_SPECIALIZATION_LEVEL=0 FAST_TESTS=1 ./bin/tests
188+
- PIR_GLOBAL_SPECIALIZATION_LEVEL=1 FAST_TESTS=1 ./bin/tests
189+
- PIR_GLOBAL_SPECIALIZATION_LEVEL=2 FAST_TESTS=1 ./bin/tests
190+
- PIR_GLOBAL_SPECIALIZATION_LEVEL=3 FAST_TESTS=1 ./bin/tests
191+
- PIR_GLOBAL_SPECIALIZATION_LEVEL=4 FAST_TESTS=1 ./bin/tests
192+
- PIR_GLOBAL_SPECIALIZATION_LEVEL=5 FAST_TESTS=1 ./bin/tests
194193
artifacts:
195194
paths:
196195
- logs
@@ -216,6 +215,27 @@ test_features_2:
216215
when: on_failure
217216
expire_in: 1 week
218217

218+
test_features_3:
219+
image: registry.gitlab.com/rirvm/rir_mirror:$CI_COMMIT_SHA
220+
variables:
221+
GIT_STRATEGY: none
222+
PIR_LLVM_OPT_LEVEL: 0
223+
stage: Run tests
224+
needs:
225+
- rir_container
226+
except:
227+
- schedules
228+
script:
229+
- cd /opt/rir/build/release
230+
- PIR_DEOPT_CHAOS=1000 PIR_INLINER_MAX_INLINEE_SIZE=800 bin/gnur-make-tests check || $SAVE_LOGS
231+
- RIR_SERIALIZE_CHAOS=1 FAST_TESTS=1 ./bin/tests
232+
artifacts:
233+
paths:
234+
- logs
235+
when: on_failure
236+
expire_in: 1 week
237+
238+
219239
# Run ubsan and gc torture
220240
test_sanitize1:
221241
image: registry.gitlab.com/rirvm/rir_mirror:$CI_COMMIT_SHA
@@ -246,8 +266,11 @@ test_sanitize2:
246266
except:
247267
- schedules
248268
script:
269+
- cd /opt/rir/build/release
270+
- PIR_INLINER_MAX_INLINEE_SIZE=2000 ./bin/tests
271+
- PIR_INLINER_MAX_INLINEE_SIZE=1500 PIR_DEOPT_CHAOS=100 ./bin/tests
249272
- cd /opt/rir/build/releaseassert
250-
- PIR_TEST_CLEAR_TEMPS=1 R_GCTORTURE=50 bin/tests
273+
- PIR_TEST_CLEAR_TEMPS=1 R_GCTORTURE=60 bin/tests
251274

252275
# Test with inlining big functions
253276
test_big_inline:
@@ -264,8 +287,6 @@ test_big_inline:
264287
- schedules
265288
script:
266289
- cd /opt/rir/build/release
267-
- PIR_INLINER_MAX_INLINEE_SIZE=2000 ./bin/tests
268-
- PIR_INLINER_MAX_INLINEE_SIZE=1500 PIR_DEOPT_CHAOS=100 ./bin/tests
269290
- PIR_INLINER_MAX_INLINEE_SIZE=400 PIR_INLINER_INLINE_UNLIKELY=1 ./bin/gnur-make-tests check || $SAVE_LOGS
270291
artifacts:
271292
paths:
@@ -342,7 +363,7 @@ benchmark_llvm:
342363
paths:
343364
- benchmarks.data
344365
expire_in: 24 month
345-
retry: 2
366+
retry: 1
346367

347368
benchmark_gnur:
348369
image: registry.gitlab.com/rirvm/rir_mirror/benchmark-baseline

rir/src/R/symbol_list.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
V(seq, "seq") \
6060
V(lapply, "lapply") \
6161
V(aslist, "as.list") \
62+
V(ascharacter, "as.character") \
6263
V(isvector, "is.vector") \
6364
V(substr, "substr") \
6465
V(Class, "class") \

rir/src/compiler/native/lower_function_llvm.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,13 +1393,6 @@ llvm::Value* LowerFunctionLLVM::container(llvm::Value* v) {
13931393

13941394
llvm::CallInst* LowerFunctionLLVM::call(const NativeBuiltin& builtin,
13951395
const std::vector<llvm::Value*>& args) {
1396-
#ifdef ENABLE_SLOWASSERT
1397-
// abuse BB label as comment
1398-
auto callBB =
1399-
BasicBlock::Create(PirJitLLVM::getContext(), builtin.name, fun);
1400-
builder.CreateBr(callBB);
1401-
builder.SetInsertPoint(callBB);
1402-
#endif
14031396
return builder.CreateCall(getBuiltin(builtin), args);
14041397
}
14051398

rir/src/compiler/opt/constantfold.cpp

Lines changed: 44 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,39 @@
1919
namespace rir {
2020
namespace pir {
2121

22-
static SEXP isConst(Value* instr) {
22+
static SEXP isConst(Value* instr, Preserve& p) {
2323
instr = instr->followCastsAndForce();
2424

25+
if (auto cst = LdConst::Cast(instr))
26+
return cst->c();
27+
2528
if (instr->asRValue() && instr != MissingArg::instance())
2629
return instr->asRValue();
2730

28-
if (auto cst = LdConst::Cast(instr)) {
29-
return cst->c();
30-
}
3131
return nullptr;
3232
}
33+
34+
SEXP qt(SEXP c, Preserve& p) {
35+
if (TYPEOF(c) == SYMSXP)
36+
return p.operator()(Rf_lang2(symbol::quote, c));
37+
return c;
38+
}
39+
3340
#define FOLD_BINARY_NATIVE(Instruction, Operation) \
3441
do { \
3542
if (auto instr = Instruction::Cast(i)) { \
36-
if (auto lhs = isConst(instr->arg<0>().val())) { \
37-
if (auto rhs = isConst(instr->arg<1>().val())) { \
38-
auto res = \
39-
Rf_eval(Rf_lang3(Operation, lhs, rhs), R_BaseEnv); \
43+
if (auto lhs = isConst(instr->arg<0>().val(), p)) { \
44+
if (auto rhs = isConst(instr->arg<1>().val(), p)) { \
45+
auto res = Rf_eval( \
46+
p(Rf_lang3(Operation, qt(lhs, p), qt(rhs, p))), \
47+
R_BaseEnv); \
4048
if (res == R_TrueValue || res == R_FalseValue) { \
4149
instr->replaceUsesWith( \
4250
res == R_TrueValue ? (Value*)True::instance() \
4351
: (Value*)False::instance()); \
4452
next = bb->remove(ip); \
4553
} else { \
46-
cmp.preserve(res); \
54+
p(res); \
4755
auto resi = new LdConst(res); \
4856
anyChange = true; \
4957
instr->replaceUsesWith(resi); \
@@ -56,15 +64,15 @@ static SEXP isConst(Value* instr) {
5664
#define FOLD_UNARY(Instruction, Operation) \
5765
do { \
5866
if (auto instr = Instruction::Cast(i)) { \
59-
if (auto arg = isConst(instr->arg<0>().val())) \
67+
if (auto arg = isConst(instr->arg<0>().val(), p)) \
6068
Operation(arg); \
6169
} \
6270
} while (false)
6371
#define FOLD_BINARY(Instruction, Operation) \
6472
do { \
6573
if (auto instr = Instruction::Cast(i)) { \
66-
if (auto lhs = isConst(instr->arg<0>().val())) { \
67-
if (auto rhs = isConst(instr->arg<1>().val())) { \
74+
if (auto lhs = isConst(instr->arg<0>().val(), p)) { \
75+
if (auto rhs = isConst(instr->arg<1>().val(), p)) { \
6876
Operation(lhs, rhs); \
6977
} \
7078
} \
@@ -73,11 +81,11 @@ static SEXP isConst(Value* instr) {
7381
#define FOLD_BINARY_EITHER(Instruction, Operation) \
7482
do { \
7583
if (auto instr = Instruction::Cast(i)) { \
76-
if (auto lhs = isConst(instr->arg<0>().val())) { \
84+
if (auto lhs = isConst(instr->arg<0>().val(), p)) { \
7785
if (Operation(lhs, instr->arg<1>().val())) \
7886
break; \
7987
} \
80-
if (auto rhs = isConst(instr->arg<1>().val())) { \
88+
if (auto rhs = isConst(instr->arg<1>().val(), p)) { \
8189
Operation(rhs, instr->arg<0>().val()); \
8290
} \
8391
} \
@@ -158,6 +166,7 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
158166

159167
bool anyChange = false;
160168

169+
Preserve p;
161170
std::unordered_map<BB*, bool> branchRemoval;
162171

163172
DominanceGraph dom(code);
@@ -317,7 +326,7 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
317326
};
318327

319328
auto foldLglCmp = [&](SEXP carg, Value* varg, bool isEq) {
320-
if (!isConst(varg) && // If this is true, was already folded
329+
if (!isConst(varg, p) && // was already folded
321330
IS_SIMPLE_SCALAR(carg, LGLSXP) &&
322331
varg->type.isA(PirType::simpleScalarLogical())) {
323332
int larg = *LOGICAL(carg);
@@ -375,9 +384,9 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
375384
: (Value*)False::instance();
376385
i->replaceUsesWith(replace);
377386
next = bb->remove(ip);
378-
} else if (isConst(a) &&
379-
convertsToLogicalWithoutWarning(isConst(a))) {
380-
auto replace = Rf_asLogical(isConst(a)) == TRUE
387+
} else if (isConst(a, p) &&
388+
convertsToLogicalWithoutWarning(isConst(a, p))) {
389+
auto replace = Rf_asLogical(isConst(a, p)) == TRUE
381390
? (Value*)True::instance()
382391
: (Value*)False::instance();
383392
i->replaceUsesWith(replace);
@@ -484,28 +493,28 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
484493
i->replaceUsesWith(False::instance());
485494
next = bb->remove(ip);
486495
}
487-
} else if (isConst(i->arg(0).val()) &&
488-
isConst(i->arg(0).val()) == R_TrueValue &&
496+
} else if (isConst(i->arg(0).val(), p) &&
497+
isConst(i->arg(0).val(), p) == R_TrueValue &&
489498
i->arg(1).val()->type.isA(PirType::test())) {
490499
iterAnyChange = true;
491500
i->replaceUsesWith(i->arg(1).val());
492501
next = bb->remove(ip);
493-
} else if (isConst(i->arg(1).val()) &&
494-
isConst(i->arg(1).val()) == R_TrueValue &&
502+
} else if (isConst(i->arg(1).val(), p) &&
503+
isConst(i->arg(1).val(), p) == R_TrueValue &&
495504
i->arg(0).val()->type.isA(PirType::test())) {
496505
iterAnyChange = true;
497506
i->replaceUsesWith(i->arg(0).val());
498507
next = bb->remove(ip);
499-
} else if (isConst(i->arg(0).val()) &&
500-
isConst(i->arg(0).val()) == R_FalseValue &&
508+
} else if (isConst(i->arg(0).val(), p) &&
509+
isConst(i->arg(0).val(), p) == R_FalseValue &&
501510
i->arg(1).val()->type.isA(PirType::test())) {
502511
iterAnyChange = true;
503512
auto neg =
504513
new Not(i->arg(1).val(), Env::elided(), i->srcIdx);
505514
neg->type = PirType::test();
506515
i->replaceUsesAndSwapWith(neg, ip);
507-
} else if (isConst(i->arg(1).val()) &&
508-
isConst(i->arg(1).val()) == R_FalseValue &&
516+
} else if (isConst(i->arg(1).val(), p) &&
517+
isConst(i->arg(1).val(), p) == R_FalseValue &&
509518
i->arg(0).val()->type.isA(PirType::test())) {
510519
iterAnyChange = true;
511520
auto neg =
@@ -570,7 +579,7 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
570579
}
571580
}
572581
if (auto cl = Colon::Cast(i)) {
573-
if (auto a = isConst(cl->arg(0).val())) {
582+
if (auto a = isConst(cl->arg(0).val(), p)) {
574583
if (TYPEOF(a) == REALSXP && Rf_length(a) == 1 &&
575584
REAL(a)[0] == (double)(int)REAL(a)[0]) {
576585
iterAnyChange = true;
@@ -579,7 +588,7 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
579588
ip++;
580589
}
581590
}
582-
if (auto a = isConst(cl->arg(1).val())) {
591+
if (auto a = isConst(cl->arg(1).val(), p)) {
583592
if (TYPEOF(a) == REALSXP && Rf_length(a) == 1 &&
584593
REAL(a)[0] == (double)(int)REAL(a)[0]) {
585594
iterAnyChange = true;
@@ -665,12 +674,13 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
665674
iterAnyChange = true;
666675
i->replaceUsesWith(i->arg(0).val());
667676
next = bb->remove(ip);
668-
} else if (auto con = isConst(i->arg(0).val())) {
677+
} else if (auto con = isConst(i->arg(0).val(), p)) {
669678
auto t = TYPEOF(con);
670679
if (t == REALSXP || t == INTSXP || t == LGLSXP) {
671-
auto res = Rf_eval(
672-
Rf_lang2(Rf_install("as.character"), con),
673-
R_BaseEnv);
680+
auto res =
681+
p(Rf_eval(p(Rf_lang2(symbol::ascharacter,
682+
qt(con, p))),
683+
R_BaseEnv));
674684
iterAnyChange = true;
675685
i->replaceUsesAndSwapWith(new LdConst(res), ip);
676686
}
@@ -683,7 +693,7 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
683693
iterAnyChange = true;
684694
i->replaceUsesWith(i->arg(0).val());
685695
next = bb->remove(ip);
686-
} else if (auto con = isConst(i->arg(0).val())) {
696+
} else if (auto con = isConst(i->arg(0).val(), p)) {
687697
if (IS_SIMPLE_SCALAR(con, REALSXP)) {
688698
if (REAL(con)[0] == REAL(con)[0]) {
689699
iterAnyChange = true;
@@ -880,7 +890,7 @@ bool Constantfold::apply(Compiler& cmp, ClosureVersion* cls, Code* code,
880890
}
881891
if (auto not_ = Not::Cast(i)) {
882892
Value* arg = not_->arg<0>().val();
883-
if (auto carg = isConst(arg)) {
893+
if (auto carg = isConst(arg, p)) {
884894
if (IS_SIMPLE_SCALAR(carg, LGLSXP) ||
885895
IS_SIMPLE_SCALAR(carg, INTSXP) ||
886896
IS_SIMPLE_SCALAR(carg, REALSXP)) {

0 commit comments

Comments
 (0)