This is an archive of the discontinued LLVM Phabricator instance.

[NFC][StackSafety] Test that StackLifetime looks through stripPointerCasts
ClosedPublic

Authored by ChuanqiXu on Aug 5 2020, 11:45 PM.

Details

Summary

StackLifetime class collects lifetime marker of an alloca by collect
the user of BitCast who is the user of the alloca. However, either
the alloca itself could be used with the lifetime marker or the BitCast
of the alloca could be transformed to other instructions. (e.g.,
it may be transformed to all zero reps in InstCombine pass).
This patch tries to fix this process in collectMarkers functions.

Diff Detail

Event Timeline

ChuanqiXu created this revision.Aug 5 2020, 11:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2020, 11:45 PM
ChuanqiXu requested review of this revision.Aug 5 2020, 11:45 PM
ChuanqiXu edited the summary of this revision. (Show Details)Aug 5 2020, 11:56 PM
ChuanqiXu updated this revision to Diff 283796.Aug 6 2020, 7:38 PM
ChuanqiXu edited the summary of this revision. (Show Details)
This comment was removed by ChuanqiXu.
ChuanqiXu updated this revision to Diff 283797.Aug 6 2020, 7:41 PM

Update test case

test case?

Sorry, it's my fault to forget to update the test case. I update it now. The IR in the test file is generated by command clang -O2 -S -emit-llvm for the following code:

typedef struct  {
    char a[500];
} char_array;

void consume(char_array);

void simple(int cond) {
    if (cond) {
        char_array a;
        consume(a);
    } else {
        char_array b;
        consume(b);
    }
}

This function was changed
Is this issue still relevant?
If this is still needed, could you please make this a regular lit test?

This function was changed
Is this issue still relevant?
If this is still needed, could you please make this a regular lit test?

Thanks for your comment. This issue is fixed by the new commit. I don't know how to add this a regular lit test because StackLifetime module won't provide a pass interface, which means I can call it from opt.

The test is still could be useful
Maybe something like this llvm/test/Analysis/StackSafetyAnalysis/lifetime.ll ?

ChuanqiXu updated this revision to Diff 286242.Aug 18 2020, 4:02 AM

The test is still could be useful
Maybe something like this llvm/test/Analysis/StackSafetyAnalysis/lifetime.ll ?

Oh, I find here is StackLifetimePrinterPass which I can use for tests. I updated the diff about test case to lifetime.ll for now.

vitalybuka retitled this revision from [StackSafety] Use `Value::stripPointerCasts` to collect lifetime marker in StackLifetime to [NFC][StackSafety] Test that StackLifetime looks through stripPointerCasts.Aug 18 2020, 4:13 PM
vitalybuka edited the summary of this revision. (Show Details)
vitalybuka edited the summary of this revision. (Show Details)

cleanup

vitalybuka accepted this revision.Aug 18 2020, 4:19 PM

LGTM with some updates

This revision is now accepted and ready to land.Aug 18 2020, 4:19 PM
This revision was landed with ongoing or failed builds.Aug 18 2020, 4:21 PM
This revision was automatically updated to reflect the committed changes.

LGTM with some updates

Thank you very much !!!