[llvm] [VPlan] Add VPConstantInt for VPIRValues wrapping ConstantInts (NFC) (PR #175458)

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 12 04:08:49 PST 2026


================
@@ -4506,8 +4506,12 @@ class VPlan {
   VPIRValue *getOrAddLiveIn(Value *V) {
     assert(V && "Trying to get or add the VPIRValue of a null Value");
     auto [It, Inserted] = LiveIns.try_emplace(V);
-    if (Inserted)
-      It->second = new VPIRValue(V);
+    if (Inserted) {
+      if (auto *CI = dyn_cast<ConstantInt>(V))
+        It->second = new VPConstantInt(CI);
+      else
+        It->second = new VPIRValue(V);
+    }
----------------
fhahn wrote:

It might not cause issues in practice, but IIRC without this we would be casting to a class unrelated to the object which is UB, even though they currently have exactly the same layout

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


More information about the llvm-commits mailing list