yaohuihan-iluvatar wrote: > Given that builtin IDs overlap, computing whether a builtin ID refers to a > particular target-specific builtin requires two checks: one, that the we're > compiling for the relevant target, and two, that the builtin has the relevant > ID. Given that, this patch is missing some checks?
You're right — the `constexpr` dispatch is pure ID matching (there are ~644 `case X86::BI...` labels in `ExprConstant.cpp` and no triple/arch checks at all), **so it only does check (2) "the ID matches" and never check (1) "we're actually compiling for X86".** **The patch can turn a missed fold into a wrong fold for non-x86 aux configs.** `CodeGen` avoids this because `EmitTargetBuiltinExpr` un-shifts and dispatches on the aux target's arch (`EmitTargetArchBuiltinExpr → EmitX86BuiltinExpr/EmitAArch64BuiltinExpr/…`), so a builtin can only ever reach its own target's handler. **The constexpr evaluator has no such routing**. I'll add the missing target check: only interpret a (normalized) target builtin as X86 when the owning target's arch is actually x86 (aux arch for aux IDs, primary arch otherwise); otherwise fall through to default. https://github.com/llvm/llvm-project/pull/201805 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
