This is an archive of the discontinued LLVM Phabricator instance.

[memtag] Plug in stack safety analysis.
ClosedPublic

Authored by eugenis on Jan 27 2020, 5:20 PM.

Details

Summary

Run StackSafetyAnalysis at the end of the IR pipeline and annotate
proven safe allocas with !stack-safe metadata. Do not instrument such
allocas in the AArch64StackTagging pass.

Diff Detail

Event Timeline

eugenis created this revision.Jan 27 2020, 5:20 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptJan 27 2020, 5:20 PM

To explain some design decisions:

The analysis is added to the IR pipeline and not to the AArch64 codegen pipeline mainly because we plan to extend it with ThinLTO support in the future. To do that, module summary builder will need to depend on the (function-)local stack safety analysis pass, and the global analysis result will be provided by the combined summary reader, and all of that must happen in the target-independent IR pipeline.

Another reason is that the legacy pass manager, which is still used for codegen, is not good at mixing function and module analyses. AFAIK a module pass that depends on function analysis will always produce an on-the-fly pass manager which can not reuse earlier analysis results; and a function pass can not depend on a module analysis at all (at least I could not make it work).

For these two reasons I opted not to use analysis manager framework to pass the safety information to AArch64StackTaggingPass, and chose to use alloca metadata instead.

Unit tests: pass. 62250 tests passed, 0 failed and 816 were skipped.

clang-tidy: fail. clang-tidy found 0 errors and 1 warnings. 0 of them are added as review comments below (why?).

clang-format: fail. Please format your changes with clang-format by running git-clang-format HEAD^ or applying this patch.

Build artifacts: diff.json, clang-tidy.txt, clang-format.patch, CMakeCache.txt, console-log.txt, test-results.xml

Pre-merge checks is in beta. Report issue. Please join beta or enable it for your project.

vitalybuka accepted this revision.Feb 3 2020, 6:21 PM
vitalybuka added inline comments.
llvm/lib/Analysis/StackSafetyAnalysis.cpp
670

Could you please add basic test in StackSafetyAnalysis to checks "stack-safe" in IR?

This revision is now accepted and ready to land.Feb 3 2020, 6:21 PM
This revision was automatically updated to reflect the committed changes.