[clang] [clang][DebugInfo] Add inlined subprogram metadata for compiler built-ins (PR #189969)
Shivam Kunwar via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 2 07:28:30 PDT 2026
================
@@ -2648,6 +2648,11 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
assert(!getContext().BuiltinInfo.isImmediate(BuiltinID) &&
"Should not codegen for consteval builtins");
+ // Treat built-in as call to artificial inlined function in debug info.
+ // This enables e.g. profiling tools to annotate time spent in user-called
+ // built-ins with the built-in function name.
+ ApplyBuiltinDebugLocation DebugScope(*this, GD);
----------------
phyBrackets wrote:
for example `__builtin_expect(x, 1)` emits no instructions at all, it just passes through the value. And `__builtin_unreachable()` emits a single `unreachable`. In both cases a synthetic subprogram gets created with nothing meaningful to profile against.
And a short exclusion list of known zero-codegen built-ins like these might be a simple middle ground, their behavior is well defined at the clang level so there's no ambiguity about what to skip.
https://github.com/llvm/llvm-project/pull/189969
More information about the cfe-commits
mailing list