[clang] [CIR] Upstream handling for __builtin_prefetch (PR #164387)
Sirui Mu via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 21 09:19:21 PDT 2025
================
@@ -454,6 +454,27 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
assert(!cir::MissingFeatures::coroSizeBuiltinCall());
return getUndefRValue(e->getType());
}
+ case Builtin::BI__builtin_prefetch: {
+ auto evaluateOperandAsInt = [&](const Expr *arg) {
+ Expr::EvalResult res;
+ [[maybe_unused]] bool evalSucceed =
+ arg->EvaluateAsInt(res, cgm.getASTContext());
+ assert(evalSucceed && "expression should be able to evaluate as int");
+ return res.Val.getInt().getZExtValue();
+ };
+
+ bool isWrite = false;
+ if (e->getNumArgs() > 1)
+ isWrite = evaluateOperandAsInt(e->getArg(1));
----------------
Lancern wrote:
Could you include a negative test for this branch? (i.e. test the case when the if condition does not hold.)
https://github.com/llvm/llvm-project/pull/164387
More information about the cfe-commits
mailing list