[PATCH] D109749: Experimental Partial Mem2Reg
Johannes Doerfert via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 21 08:52:35 PDT 2021
jdoerfert added a comment.
Does this work for you:
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp
index 8955658cb9e7..41251d2676e6 100644
--- a/llvm/lib/Analysis/CaptureTracking.cpp
+++ b/llvm/lib/Analysis/CaptureTracking.cpp
@@ -373,9 +373,13 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker,
case Instruction::Store:
// Stored the pointer - conservatively assume it may be captured.
// Volatile stores make the address observable.
- if (U->getOperandNo() == 0 || cast<StoreInst>(I)->isVolatile())
+ if (U->getOperandNo() == 0 || cast<StoreInst>(I)->isVolatile()) {
+ if (auto *AI = dyn_cast<AllocaInst>(I->getOperand(1)->stripInBoundsOffsets()))
+ if (AI->hasMetadata("nocapture_storage"))
+ break;
if (Tracker->captured(U))
return;
+ }
break;
case Instruction::AtomicRMW: {
// atomicrmw conceptually includes both a load and store from
And then add `!nocapture_storage !0` after the alloca in your example as well as `!0 = !{!0}` in the end of that file
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109749/new/
https://reviews.llvm.org/D109749
More information about the llvm-commits
mailing list