Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • sac2c sac2c
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 394
    • Issues 394
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 17
    • Merge requests 17
  • Deployments
    • Deployments
    • Releases
  • Wiki
    • Wiki
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • sac-group
  • sac2csac2c
  • Issues
  • #2330
Closed
Open
Created Apr 07, 2023 by Michiel Verloop@MVerloopMaintainer

Memory leak in polyhedral_reuse_analysis.c due to node to constant to int conversion

In polyhedral_reuse_analysis.c, the pattern COconst2Int (COaST2Constant (node)) occurs 13 times, leaking the constant every single time.

The code guards the conversion as in a way similar to this:

if (COisConstant (some_node)
    && COisConstant (more_nodes)) {
  some_int = COconst2Int (COaST2Constant (some_node);
  more_ints = COconst2Int (COaST2Constant (more_ints));
 // code using the integers here
}

This format is also what I need for an optimization I'm writing.

Should we add this function to constants_basic.c?

int
COaST2IntUnchecked (node *a) {
    constant *tmp_const;
    int res;

    DBUG_ENTER ();
  
    tmp_const = COaST2Constant (a);
    DBUG_ASSERT (tmp_const != NULL, 
                 "COaST2IntUnchecked was used without checking"
                 " whether the node is indeed a constant.");
    res = COconst2Int (tmp_const);
    COfreeConstant (tmp_const);

    DBUG_RETURN (res);
}

It would allow the code in polyhedral_reuse_analysis.c to be refactorable with simply a find + replace, fixing the memory leak, as well as making the code for my optimization a lot simpler.

Edited Apr 07, 2023 by Michiel Verloop
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking