From a9455ec9f8dd8bd87b0950467b8d6391076959e2 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Thu, 6 Oct 2011 18:29:46 +0000 Subject: CUDA: add -fcuda-is-device flag This frontend-only flag is used by the IR generator to determine whether to filter CUDA declarations for the host or for the device. llvm-svn: 141301 --- clang/lib/CodeGen/CodeGenModule.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenModule.cpp') diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f5e3789..d8b9c9d 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -785,6 +785,23 @@ void CodeGenModule::EmitGlobal(GlobalDecl GD) { if (Global->hasAttr()) return EmitAliasDefinition(GD); + // If this is CUDA, be selective about which declarations we emit. + if (Features.CUDA) { + if (CodeGenOpts.CUDAIsDevice) { + if (!Global->hasAttr() && + !Global->hasAttr() && + !Global->hasAttr() && + !Global->hasAttr()) + return; + } else { + if (!Global->hasAttr() && ( + Global->hasAttr() || + Global->hasAttr() || + Global->hasAttr())) + return; + } + } + // Ignore declarations, they will be emitted on their first use. if (const FunctionDecl *FD = dyn_cast(Global)) { // Forward declarations are emitted lazily on first use. -- cgit v1.1