[PATCH] D85399: [StackSafety] Use `Value::stripPointerCasts` to collect lifetime marker in StackLifetime

Chuanqi Xu via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 5 23:45:53 PDT 2020


ChuanqiXu created this revision.
ChuanqiXu added reviewers: vitalybuka, RKSimon.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
ChuanqiXu requested review of this revision.

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.


https://reviews.llvm.org/D85399

Files:
  llvm/lib/Analysis/StackLifetime.cpp


Index: llvm/lib/Analysis/StackLifetime.cpp
===================================================================
--- llvm/lib/Analysis/StackLifetime.cpp
+++ llvm/lib/Analysis/StackLifetime.cpp
@@ -85,8 +85,8 @@
     while (!WorkList.empty()) {
       const Instruction *I = WorkList.pop_back_val();
       for (const User *U : I->users()) {
-        if (auto *BI = dyn_cast<BitCastInst>(U)) {
-          WorkList.push_back(BI);
+        if (U->stripPointerCasts() == AI) {
+          WorkList.push_back(cast<Instruction>(U));
           continue;
         }
         auto *UI = dyn_cast<IntrinsicInst>(U);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85399.283493.patch
Type: text/x-patch
Size: 604 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200806/dd126459/attachment.bin>


More information about the llvm-commits mailing list