[llvm] [NewGVN] Check intrinsic ID before accessing operands (PR #141571)

via llvm-commits llvm-commits at lists.llvm.org
Tue May 27 02:19:51 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Mariusz Sikora (mariusz-sikora-at-amd)

<details>
<summary>Changes</summary>

This patch is fixing assertions in downstream tests

---
Full diff: https://github.com/llvm/llvm-project/pull/141571.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/NewGVN.cpp (+6-5) 


``````````diff
diff --git a/llvm/lib/Transforms/Scalar/NewGVN.cpp b/llvm/lib/Transforms/Scalar/NewGVN.cpp
index 85bd8ef1f09a8..584cb0e89ef66 100644
--- a/llvm/lib/Transforms/Scalar/NewGVN.cpp
+++ b/llvm/lib/Transforms/Scalar/NewGVN.cpp
@@ -1530,11 +1530,12 @@ NewGVN::performSymbolicLoadCoercion(Type *LoadType, Value *LoadPtr,
   }
 
   if (auto *II = dyn_cast<IntrinsicInst>(DepInst)) {
-    auto *LifetimePtr = II->getOperand(1);
-    if (II->getIntrinsicID() == Intrinsic::lifetime_start &&
-        (LoadPtr == lookupOperandLeader(LifetimePtr) ||
-         AA->isMustAlias(LoadPtr, LifetimePtr)))
-      return createConstantExpression(UndefValue::get(LoadType));
+    if (II->getIntrinsicID() == Intrinsic::lifetime_start) {
+      auto *LifetimePtr = II->getOperand(1);
+      if (LoadPtr == lookupOperandLeader(LifetimePtr) ||
+          AA->isMustAlias(LoadPtr, LifetimePtr))
+        return createConstantExpression(UndefValue::get(LoadType));
+    }
   }
 
   // All of the below are only true if the loaded pointer is produced

``````````

</details>


https://github.com/llvm/llvm-project/pull/141571


More information about the llvm-commits mailing list