diff options
author | Greg Roth <grroth@microsoft.com> | 2024-08-29 11:01:52 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-29 10:01:52 -0700 |
commit | 2dc3b509879518340b991733bfde5c7a4becd559 (patch) | |
tree | 381b21de5ba6cc80d8205b2b4d9942848d6c6e93 /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 178392454e076624674b4a7ddf3fc8bda2e94f0e (diff) | |
download | llvm-2dc3b509879518340b991733bfde5c7a4becd559.zip llvm-2dc3b509879518340b991733bfde5c7a4becd559.tar.gz llvm-2dc3b509879518340b991733bfde5c7a4becd559.tar.bz2 |
[HLSL] Apply NoRecurse attrib to all HLSL functions (#105907)
Previously, functions named "main" got the NoRecurse attribute
consistent with the behavior of C++, which HLSL largely follows.
However, standard recursion is not allowed in HLSL, so all functions
should really have this attribute. This doesn't prevent recursion, but
rather signals that these functions aren't expected to recurse.
Practically, this was done so that entry point functions named "main"
would have all have the same attributes as otherwise identical entry
points with other names.
This required small changes to the this assignment tests because they no
longer generate so many attribute sets since more of them match.
related to #105244
but done to simplify testing for #89806
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index c89eaa0..a574728 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1064,13 +1064,17 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, // OpenCL C 2.0 v2.2-11 s6.9.i: // Recursion is not supported. // + // HLSL + // Recursion is not supported. + // // SYCL v1.2.1 s3.10: // kernels cannot include RTTI information, exception classes, // recursive code, virtual functions or make use of C++ libraries that // are not compiled for the device. - if (FD && ((getLangOpts().CPlusPlus && FD->isMain()) || - getLangOpts().OpenCL || getLangOpts().SYCLIsDevice || - (getLangOpts().CUDA && FD->hasAttr<CUDAGlobalAttr>()))) + if (FD && + ((getLangOpts().CPlusPlus && FD->isMain()) || getLangOpts().OpenCL || + getLangOpts().HLSL || getLangOpts().SYCLIsDevice || + (getLangOpts().CUDA && FD->hasAttr<CUDAGlobalAttr>()))) Fn->addFnAttr(llvm::Attribute::NoRecurse); llvm::RoundingMode RM = getLangOpts().getDefaultRoundingMode(); |