[llvm] [llubi] Add support for undef values (PR #205602)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 27 08:56:52 PDT 2026
================
@@ -310,30 +342,43 @@ std::optional<AnyValue> Context::evaluateConstantExpression(ConstantExpr *CE) {
}
};
+ bool Cacheable = LHS->isCacheable() && RHS->isCacheable();
+
if (CE->getType()->isVectorTy()) {
auto &LHSVec = LHS->asAggregate();
auto &RHSVec = RHS->asAggregate();
std::vector<AnyValue> ResVec;
ResVec.reserve(LHSVec.size());
for (const auto &[ScalarLHS, ScalarRHS] : zip(LHSVec, RHSVec))
ResVec.push_back(ScalarEval(ScalarLHS, ScalarRHS));
- return std::move(ResVec);
+ return MaterializedConstant(std::move(ResVec), Cacheable);
}
- return ScalarEval(*LHS, *RHS);
+ return MaterializedConstant(ScalarEval(*LHS, *RHS), Cacheable);
}
}
-const AnyValue *Context::getConstantValue(Constant *C) {
+const MaterializedConstant *Context::getConstantValue(Constant *C) {
auto It = ConstCache.find(C);
if (It != ConstCache.end())
return &It->second;
- std::optional<AnyValue> Val = getConstantValueImpl(C);
- if (!Val)
+ MaterializedConstant Val = getConstantValueImpl(C);
+ if (Val.isNone())
return nullptr;
+ if (!Val.isCacheable()) {
+ assert(NoncacheableConstBuffer.getBytesAllocated() <=
+ 1024 * sizeof(MaterializedConstant) &&
+ "");
----------------
nikic wrote:
Empty message?
https://github.com/llvm/llvm-project/pull/205602
More information about the llvm-commits
mailing list