diff options
author | Artem Belevich <tra@google.com> | 2015-08-19 20:48:20 +0000 |
---|---|---|
committer | Artem Belevich <tra@google.com> | 2015-08-19 20:48:20 +0000 |
commit | 39259ffc65556b2e848ff691f6611f896c0ed6aa (patch) | |
tree | 2d1499fac723f833c6a5af56ee1d0a1be90e750d /clang/lib | |
parent | 61ede1519cdfb3d390bb268dc0e9ce8dcb277c30 (diff) | |
download | bcm5719-llvm-39259ffc65556b2e848ff691f6611f896c0ed6aa.tar.gz bcm5719-llvm-39259ffc65556b2e848ff691f6611f896c0ed6aa.zip |
[CUDA] Add appropriate host/device attribute to builtins.
Differential Revision: http://reviews.llvm.org/D12122
llvm-svn: 245496
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 11 |
2 files changed, 12 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp index a8a7009ccf5..e2940c7f57e 100644 --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -525,7 +525,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, // Since the target specific builtins for each arch overlap, only check those // of the arch we are compiling for. - if (BuiltinID >= Builtin::FirstTSBuiltin) { + if (Context.BuiltinInfo.isTSBuiltin(BuiltinID)) { switch (Context.getTargetInfo().getTriple().getArch()) { case llvm::Triple::arm: case llvm::Triple::armeb: diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a8d1e1203e4..d79d60c9773 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -11187,6 +11187,17 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) { FD->addAttr(NoThrowAttr::CreateImplicit(Context, FD->getLocation())); if (Context.BuiltinInfo.isConst(BuiltinID) && !FD->hasAttr<ConstAttr>()) FD->addAttr(ConstAttr::CreateImplicit(Context, FD->getLocation())); + if (getLangOpts().CUDA && Context.BuiltinInfo.isTSBuiltin(BuiltinID) && + !FD->hasAttr<CUDADeviceAttr>() && !FD->hasAttr<CUDAHostAttr>()) { + // Target-specific builtins are assumed to be intended for use + // in this particular CUDA compilation mode and should have + // appropriate attribute set so we can enforce CUDA function + // call restrictions. + if (getLangOpts().CUDAIsDevice) + FD->addAttr(CUDADeviceAttr::CreateImplicit(Context, FD->getLocation())); + else + FD->addAttr(CUDAHostAttr::CreateImplicit(Context, FD->getLocation())); + } } IdentifierInfo *Name = FD->getIdentifier(); |