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

Commit efe8231

Browse files
committed
Merge branch 'relooper-build-warnings' of https://github.com/jfbastien/emscripten-fastcomp into incoming
2 parents 930535d + 876e422 commit efe8231

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

lib/Target/JSBackend/Relooper.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ Branch::Branch(const char *ConditionInit, const char *CodeInit) : Ancestor(NULL)
129129
}
130130

131131
Branch::~Branch() {
132-
if (Condition) free((void*)Condition);
133-
if (Code) free((void*)Code);
132+
free(static_cast<void *>(const_cast<char *>(Condition)));
133+
free(static_cast<void *>(const_cast<char *>(Code)));
134134
}
135135

136136
void Branch::Render(Block *Target, bool SetLabel) {
@@ -155,8 +155,8 @@ Block::Block(const char *CodeInit, const char *BranchVarInit) : Parent(NULL), Id
155155
}
156156

157157
Block::~Block() {
158-
if (Code) free((void*)Code);
159-
if (BranchVar) free((void*)BranchVar);
158+
free(static_cast<void *>(const_cast<char *>(Code)));
159+
free(static_cast<void *>(const_cast<char *>(BranchVar)));
160160
for (BlockBranchMap::iterator iter = ProcessedBranchesOut.begin(); iter != ProcessedBranchesOut.end(); iter++) {
161161
delete iter->second;
162162
}
@@ -215,7 +215,7 @@ void Block::Render(bool InLoop) {
215215
// into the Simple's branches.
216216
MultipleShape *Fused = Shape::IsMultiple(Parent->Next);
217217
if (Fused) {
218-
PrintDebug("Fusing Multiple to Simple\n");
218+
PrintDebug("Fusing Multiple to Simple\n", 0);
219219
Parent->Next = Parent->Next->Next;
220220
Fused->UseSwitch = false; // TODO: emit switches here
221221
Fused->RenderLoopPrefix();
@@ -710,7 +710,7 @@ void Relooper::Calculate(Block *Entry) {
710710
}
711711
#endif
712712

713-
PrintDebug("creating loop block:\n");
713+
PrintDebug("creating loop block:\n", 0);
714714
DebugDump(InnerBlocks, " inner blocks:");
715715
DebugDump(Entries, " inner entries:");
716716
DebugDump(Blocks, " outer blocks:");
@@ -912,7 +912,7 @@ void Relooper::Calculate(Block *Entry) {
912912
// ->Next block on them, and the blocks are what remains in Blocks (which Make* modify). In this way
913913
// we avoid recursing on Next (imagine a long chain of Simples, if we recursed we could blow the stack).
914914
Shape *Process(BlockSet &Blocks, BlockSet& InitialEntries, Shape *Prev) {
915-
PrintDebug("Process() called\n");
915+
PrintDebug("Process() called\n", 0);
916916
BlockSet *Entries = &InitialEntries;
917917
BlockSet TempEntries[2];
918918
int CurrTempIndex = 0;
@@ -922,12 +922,12 @@ void Relooper::Calculate(Block *Entry) {
922922
Shape *Temp = call; \
923923
if (Prev) Prev->Next = Temp; \
924924
if (!Ret) Ret = Temp; \
925-
if (!NextEntries->size()) { PrintDebug("Process() returning\n"); return Ret; } \
925+
if (!NextEntries->size()) { PrintDebug("Process() returning\n", 0); return Ret; } \
926926
Prev = Temp; \
927927
Entries = NextEntries; \
928928
continue;
929929
while (1) {
930-
PrintDebug("Process() running\n");
930+
PrintDebug("Process() running\n", 0);
931931
DebugDump(Blocks, " blocks : ");
932932
DebugDump(*Entries, " entries: ");
933933

@@ -1013,7 +1013,7 @@ void Relooper::Calculate(Block *Entry) {
10131013
if (!DeadEnd) break;
10141014
}
10151015
if (DeadEnd) {
1016-
PrintDebug("Removing nesting by not handling large group because small group is dead end\n");
1016+
PrintDebug("Removing nesting by not handling large group because small group is dead end\n", 0);
10171017
IndependentGroups.erase(LargeEntry);
10181018
}
10191019
}
@@ -1052,7 +1052,7 @@ void Relooper::Calculate(Block *Entry) {
10521052

10531053
struct PostOptimizer {
10541054
Relooper *Parent;
1055-
void *Closure;
1055+
std::stack<Shape*> *Closure;
10561056

10571057
PostOptimizer(Relooper *ParentInit) : Parent(ParentInit), Closure(NULL) {}
10581058

@@ -1066,10 +1066,13 @@ void Relooper::Calculate(Block *Entry) {
10661066

10671067
#define SHAPE_SWITCH(var, simple, multiple, loop) \
10681068
if (SimpleShape *Simple = Shape::IsSimple(var)) { \
1069+
(void)Simple; \
10691070
simple; \
10701071
} else if (MultipleShape *Multiple = Shape::IsMultiple(var)) { \
1072+
(void)Multiple; \
10711073
multiple; \
10721074
} else if (LoopShape *Loop = Shape::IsLoop(var)) { \
1075+
(void)Loop; \
10731076
loop; \
10741077
}
10751078

@@ -1142,7 +1145,6 @@ void Relooper::Calculate(Block *Entry) {
11421145
}
11431146
if (Found && !Abort) {
11441147
for (BlockBranchMap::iterator iter = Simple->Inner->ProcessedBranchesOut.begin(); iter != Simple->Inner->ProcessedBranchesOut.end(); iter++) {
1145-
Block *Target = iter->first;
11461148
Branch *Details = iter->second;
11471149
if (Details->Type == Branch::Break) {
11481150
Details->Type = Branch::Direct;
@@ -1194,9 +1196,9 @@ void Relooper::Calculate(Block *Entry) {
11941196
void FindLabeledLoops(Shape *Root) {
11951197
bool First = Closure == NULL;
11961198
if (First) {
1197-
Closure = (void*)(new std::stack<Shape*>);
1199+
Closure = new std::stack<Shape*>;
11981200
}
1199-
std::stack<Shape*> &LoopStack = *((std::stack<Shape*>*)Closure);
1201+
std::stack<Shape*> &LoopStack = *Closure;
12001202

12011203
Shape *Next = Root;
12021204
while (Next) {
@@ -1219,7 +1221,6 @@ void Relooper::Calculate(Block *Entry) {
12191221
RECURSE_Multiple(Fused, FindLabeledLoops);
12201222
}
12211223
for (BlockBranchMap::iterator iter = Simple->Inner->ProcessedBranchesOut.begin(); iter != Simple->Inner->ProcessedBranchesOut.end(); iter++) {
1222-
Block *Target = iter->first;
12231224
Branch *Details = iter->second;
12241225
if (Details->Type == Branch::Break || Details->Type == Branch::Continue) {
12251226
assert(LoopStack.size() > 0);
@@ -1263,7 +1264,7 @@ void Relooper::Calculate(Block *Entry) {
12631264
}
12641265

12651266
if (First) {
1266-
delete (std::stack<Shape*>*)Closure;
1267+
delete Closure;
12671268
}
12681269
}
12691270

@@ -1274,7 +1275,7 @@ void Relooper::Calculate(Block *Entry) {
12741275
}
12751276
};
12761277

1277-
PrintDebug("=== Optimizing shapes ===\n");
1278+
PrintDebug("=== Optimizing shapes ===\n", 0);
12781279

12791280
PostOptimizer(this).Process(Root);
12801281
}
@@ -1435,4 +1436,3 @@ RELOOPERDLL_API void rl_relooper_render(void *relooper) {
14351436
}
14361437

14371438
}
1438-

0 commit comments

Comments
 (0)