Skip to content
This repository was archived by the owner on Nov 1, 2021. It is now read-only.

Commit 37dfcdc

Browse files
committed
warn on large amounts of variables, when not running full optimizations that could reduce them
1 parent eecc048 commit 37dfcdc

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Target/JSBackend/JSBackend.cpp

+8
Original file line numberDiff line numberDiff line change
@@ -2331,6 +2331,14 @@ void JSWriter::printFunctionBody(const Function *F) {
23312331
nl(Out);
23322332
}
23332333

2334+
{
2335+
static bool Warned = false;
2336+
if (!Warned && OptLevel < 2 && UsedVars.size() > 2000) {
2337+
prettyWarning() << "emitted code will contain very large numbers of local variables, which is bad for performance (build to JS with -O2 or above to avoid this - make sure to do so both on source files, and during 'linking')\n";
2338+
Warned = true;
2339+
}
2340+
}
2341+
23342342
// Emit stack entry
23352343
Out << " " << getAdHocAssign("sp", Type::getInt32Ty(F->getContext())) << "STACKTOP;";
23362344
if (uint64_t FrameSize = Allocas.getFrameSize()) {

0 commit comments

Comments
 (0)