[clang] [llvm] [OpenMP][CodeGen] Preserve libcalls for declare simd redecls (PR #193881)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 27 02:48:56 PST 2026
wpcwzy wrote:
Hi Alexey,
All five fixed, and I rebased the series on top of main so the cached getFunctionFeatureMap(GlobalDecl) API is available.
The mapping now uses getFunctionFeatureMap(CurCodeDecl == CurGD.getDecl() ? CurGD : GlobalDecl()). That keeps the MultiVersionIndex for cpu_specific/cpu_dispatch/target_clones, and blocks, outlined regions, global initializers and Objective-C methods get the TU features. Blocks were taking the features of the enclosing function before, which was the AVX2 mismatch; the lookup is cached in ASTContext now, so the per-call rebuild is gone.
hasLibraryDeclareSimdVariants() now looks at the whole redeclaration chain, so a trailing plain redeclaration does not drop the _ZGV* attributes or the mapping anymore. It also rejects asm-labeled declarations, and CGBuiltin only keeps the libcall when the mapping will actually be emitted. The call is not annotated when the call site or the caller has nobuiltin / no-builtins / no-builtin-<name>.
The getOrInsertFunction cast is replaced with getNamedValue plus a type check, and the created variant declarations copy nounwind/willreturn/nofree/nosync/nocallback and, where that is safe, the memory attribute from the scalar function.
Running the full test suite turned up one more crash in the no-builtin check: FD->getName() asserts for declarations without a simple identifier, e.g. a C++ constructor, so hasLibraryDeclareSimdVariants() has to come before the "no-builtin-<name>" attribute name is built.
Tests added for the trailing redeclaration, ObjC method, block, no_builtin, asm label and variant declaration attribute cases.
check-all and llvm-test-suite pass.
https://github.com/llvm/llvm-project/pull/193881
More information about the cfe-commits
mailing list