llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.25k stars 12.07k forks source link

`target_clone` attribute blocks function inlining #94949

Open dtcxzyw opened 5 months ago

dtcxzyw commented 5 months ago

See the following case: https://godbolt.org/z/TqnvKcKWK

__attribute__((target_clones("default,sse4.2,avx2")))
int callee(void) { return 1; }

__attribute__((target_clones("default,sse4.2,avx2")))
int caller(void) {
    return callee();
}

callee should be inlined into caller because they share the same target_clone attribute.

llvmbot commented 5 months ago

@llvm/issue-subscribers-clang-codegen

Author: Yingwei Zheng (dtcxzyw)

See the following case: https://godbolt.org/z/TqnvKcKWK ``` __attribute__((target_clones("default,sse4.2,avx2"))) int callee(void) { return 1; } __attribute__((target_clones("default,sse4.2,avx2"))) int caller(void) { return callee(); } ``` `callee` should be inlined into caller because they share the same target_clone attribute.
antoniofrighetto commented 5 months ago

I think it should be OK here as they share the same attributes, though if you combine it with always_inline attribute it explicitly fails with «error attribute 'target_clones' multiversioning cannot be combined with attribute 'always_inline'».