From d51e43af0b3a6897b971f316c4de2035ec82d1f2 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@141301 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'lib/CodeGen/CodeGenModule.cpp') diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index f5e37897bc..d8b9c9d853 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/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.2.3-70-g09d2