Skip to content

[GVN] Should be able to PRE a load from memset #25933

@llvmbot

Description

@llvmbot
Bugzilla Link 25559
Version trunk
OS Windows NT
Reporter LLVM Bugzilla Contributor
CC @hfinkel

Extended Description

Currently, GVN can pre loads from calloc like functions. For example, in the below test case the store to 'res' will be converted from a load into a constant zero.

#include <strings.h>
#include <stdlib.h>

int *test_calloc(int n, int *res)
{
if (n == 0)
return 0;

int *ptr = (int *)calloc(n, sizeof(int));
*res = ptr[n-1];
return ptr;
}

However, PRE falls apart with this example:

int *test_malloc_memset_zero(int n, int *res)
{
if (n == 0)
return 0;

int *ptr = (int *)malloc(n * sizeof(int));
bzero(ptr, n * sizeof(int));
*res = ptr[n-1];
return ptr;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm:GVNGVN and NewGVN stages (Global value numbering)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions