[PATCH] D53779: [CodeExtractor] Allow extracting allocas within simple stack{save, restore} pairs

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 26 15:15:08 PDT 2018


efriedma added a comment.

The approach seems fine.

It seems weird that this is relevant; VLAs with a fixed size should generally be rare... unless the error logging code is intentionally using a VLA to trick the compiler into dynamically allocating the space?



================
Comment at: llvm/lib/Transforms/Utils/CodeExtractor.cpp:189
+      if (IID == Intrinsic::stacksave) {
+        assert(CI->hasOneUse() && "Expected a stacksave to have one use");
+        auto *Restore = cast<CallInst>(*CI->user_begin());
----------------
There's no reason to expect a stacksave has exactly one use in general.  (For example, it could have two uses if jump threading cloned a stackrestore, or it could be dead if the use was optimized out.)


================
Comment at: llvm/lib/Transforms/Utils/CodeExtractor.cpp:197
+      } else if (IID == Intrinsic::stackrestore) {
+        --PendingStackRestores;
+      }
----------------
You need to check that the parameter of the stackrestore is the corresponding stacksave.


https://reviews.llvm.org/D53779





More information about the llvm-commits mailing list