Skip to content

Commit

Permalink
Fix compiler crash in HeapToStack optimization pass
Browse files Browse the repository at this point in the history
This is a good one. One the March 22, 2022 development sync,
we collectively debugged issue #4059. We finally arrived at
the conclusion that our call graph usage was incorrect.

Originally during the call, Joe realized that while we were
using, we weren't doing it correctly. The initial assumption
was that the incorrect usage was innocous, however, it was
determined shortly thereafter that something about the incorrect
usage was in fact causing issue 4059.

This commit removes the offending code.

Gordon reported during the call that when the call graph code
was added as part the (now years ago) addition of LLVM 4 support
that the code was cribbed from the Dlang compiler and he posited,
probably not correctly.

Fixes #4059
  • Loading branch information
SeanTAllen committed Mar 23, 2022
1 parent 65e2cfc commit c0ccd62
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .release-notes/4059.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Fixed bug that caused the compiler to crash

We've fixed a [bug](https://github.com/ponylang/ponyc/issues/4059) that caused a compiler crash.
11 changes: 1 addition & 10 deletions src/libponyc/codegen/genopt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ class HeapToStack : public FunctionPass
invoke->getUnwindDest()->removePredecessor(call.getParent());
}

CallGraphWrapperPass* cg_pass =
getAnalysisIfAvailable<CallGraphWrapperPass>();
CallGraph* cg = cg_pass ? &cg_pass->getCallGraph() : nullptr;
CallGraphNode* cg_node = cg ? (*cg)[&f] : nullptr;
if (cg_node)
{
cg_node->removeCallEdgeFor(call);
}

inst->eraseFromParent();

for(auto new_call: new_calls)
Expand Down Expand Up @@ -1378,7 +1369,7 @@ static void optimise(compile_t* c, bool pony_specific)
fprintf(stderr, "Optimising\n");

pmb.OptLevel = 3;
pmb.Inliner = createFunctionInliningPass(275);
//pmb.Inliner = createFunctionInliningPass(275);
pmb.MergeFunctions = true;
} else {
pmb.OptLevel = 0;
Expand Down

0 comments on commit c0ccd62

Please sign in to comment.