[llvm] [SandboxIR] Implement PoisonValue (PR #107324)
Sriraman Tallam via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 11:16:18 PDT 2024
================
@@ -1018,6 +1020,49 @@ class ConstantPointerNull final : public Constant {
#endif
};
+// TODO: Inherit from UndefValue.
+class PoisonValue final : public Constant {
+ PoisonValue(llvm::PoisonValue *C, Context &Ctx)
+ : Constant(ClassID::PoisonValue, C, Ctx) {}
+ friend class Context; // For constructor.
+
+public:
+ /// Static factory methods - Return an 'poison' object of the specified type.
+ static PoisonValue *get(Type *T);
+
+ /// If this poison has array or vector type, return a poison with the right
+ /// element type.
+ PoisonValue *getSequentialElement() const;
+
+ /// If this poison has struct type, return a poison with the right element
+ /// type for the specified element.
+ PoisonValue *getStructElement(unsigned Elt) const;
+
+ /// Return an poison of the right value for the specified GEP index if we can,
+ /// otherwise return null (e.g. if C is a ConstantExpr).
+ PoisonValue *getElementValue(Constant *C) const;
+
+ /// Return an poison of the right value for the specified GEP index.
+ PoisonValue *getElementValue(unsigned Idx) const;
+
+ /// For isa/dyn_cast.
+ static bool classof(const sandboxir::Value *From) {
+ return From->getSubclassID() == ClassID::PoisonValue;
+ }
+ unsigned getUseOperandNo(const Use &Use) const final {
+ llvm_unreachable("ConstantAggregateZero has no operands!");
----------------
tmsri wrote:
"PoisonValue has no operands!"
https://github.com/llvm/llvm-project/pull/107324
More information about the llvm-commits
mailing list