[llvm] [IR] enable attaching metadata on ifuncs (PR #158732)

Wael Yehia via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 17 19:57:28 PDT 2025


w2yehia wrote:

I'm not very familiar with debug info. I tried the testcase from the [PR](https://reviews.llvm.org/D60714) that added `!dbg` on function declarations, with ifuncs and no debug info was generated. So I've added checks in the verifier for `!dbg` and `!prof`.
```
$ cat t.c
#if USE_IFUNC
void *res() { return 0; }
__attribute__((ifunc("res"))) int fn1(int a, int b);   
#else
extern int fn1(int a, int b);
#endif

int main() {
  int x = 4, y = 5;
  int res = fn1(x, y);

  return res;
}
$ ibm-clang -g  -target x86_64-none-linux-gnu -S -emit-llvm -O1 -o - -DUSE_IFUNC t2.c| grep "fn1.*ifunc"
@fn1 = dso_local ifunc i32 (i32, i32), ptr @res

$ ibm-clang -g  -target x86_64-none-linux-gnu -S -emit-llvm -O1 -o - t2.c| grep "declare.*fn1"
declare !dbg !21 i32 @fn1(i32 noundef, i32 noundef) local_unnamed_addr #1
```

https://github.com/llvm/llvm-project/pull/158732


More information about the llvm-commits mailing list