[all-commits] [llvm/llvm-project] bcbbb2: [clang] Fix clang debug info generation for unprto...

Georgiy Samoylov via All-commits all-commits at lists.llvm.org
Fri Aug 1 02:05:01 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: bcbbb2c986e001e9c357df70ed43c9d998ecd6d2
      https://github.com/llvm/llvm-project/commit/bcbbb2c986e001e9c357df70ed43c9d998ecd6d2
  Author: Georgiy Samoylov <g.samoylov at syntacore.com>
  Date:   2025-08-01 (Fri, 01 Aug 2025)

  Changed paths:
    M clang/lib/CodeGen/CGDebugInfo.cpp
    A clang/test/CodeGen/dbg-info-all-calls-described.c

  Log Message:
  -----------
  [clang] Fix clang debug info generation for unprtototyped function (#150022)

Consider this declaration:

`int foo();`

This function is described in LLVM with `clang::FunctionNoProtoType`
class. ([See
description](https://clang.llvm.org/doxygen/classclang_1_1FunctionNoProtoType.html))

Judging by [this
comment](https://github.com/llvm/llvm-project/blob/a1bf0d1394e48894be05d274d3942ff77c35ce87/clang/lib/CodeGen/CGCall.cpp#L159C11-L159C12)
all such functions are treated like functions with variadic number of
parameters.

When we want to [emit debug
info](https://github.com/llvm/llvm-project/blob/0a8ddd396546bec7eaa4c3b7ef2f495e52bca0b8/clang/lib/CodeGen/CGDebugInfo.cpp#L4808)
we have to know function that we calling.

In method
[getCalledFunction()](https://github.com/llvm/llvm-project/blob/0a8ddd396546bec7eaa4c3b7ef2f495e52bca0b8/llvm/include/llvm/IR/InstrTypes.h#L1348)
we compare two types of function:

1. Function that we deduce from calling operand, and
2. Function that we store locally

If they differ we get `nullptr` and can't emit appropriate debug info.

The only thing they differ is: lhs function is variadic, but rhs
function isn't

Reason of this difference is that under RISC-V there is no overridden
function that tells us about treating functions with no parameters.
[Default
function](https://github.com/llvm/llvm-project/blob/0a8ddd396546bec7eaa4c3b7ef2f495e52bca0b8/clang/lib/CodeGen/TargetInfo.cpp#L87)
always return `false`.

This patch overrides this function for RISC-V



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list