diff options
| author | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-03-29 14:50:00 +0000 |
|---|---|---|
| committer | Yaxun Liu <Yaxun.Liu@amd.com> | 2018-03-29 14:50:00 +0000 |
| commit | b0eee29c7415dfa1599e4a02018a7e99465d4253 (patch) | |
| tree | 7dab613ca6655ba0661bf2db0454256955b45023 /clang/lib | |
| parent | 20c5e14ae168edcb397b2a24ba1cf13416cd470d (diff) | |
| download | bcm5719-llvm-b0eee29c7415dfa1599e4a02018a7e99465d4253.tar.gz bcm5719-llvm-b0eee29c7415dfa1599e4a02018a7e99465d4253.zip | |
Disable emitting static extern C aliases for amdgcn target for CUDA
Patch by Greg Rodgers.
Revised and lit test added by Yaxun Liu.
Differential Revision: https://reviews.llvm.org/D44987
llvm-svn: 328793
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 | ||||
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/CodeGen/TargetInfo.h | 5 |
3 files changed, 16 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index e1cb3242021..bc7ba9011ae 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -4677,9 +4677,7 @@ static void EmitGlobalDeclMetadata(CodeGenModule &CGM, /// to such functions with an unmangled name from inline assembly within the /// same translation unit. void CodeGenModule::EmitStaticExternCAliases() { - // Don't do anything if we're generating CUDA device code -- the NVPTX - // assembly target doesn't support aliases. - if (Context.getTargetInfo().getTriple().isNVPTX()) + if (!getTargetCodeGenInfo().shouldEmitStaticExternCAliases()) return; for (auto &I : StaticExternCValues) { IdentifierInfo *Name = I.first; diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 8f3676e7d2e..b6f265a3579 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -6154,6 +6154,7 @@ public: void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV, CodeGen::CodeGenModule &M) const override; + bool shouldEmitStaticExternCAliases() const override; private: // Adds a NamedMDNode with F, Name, and Operand as operands, and adds the @@ -6275,6 +6276,10 @@ void NVPTXTargetCodeGenInfo::addNVVMMetadata(llvm::Function *F, StringRef Name, // Append metadata to nvvm.annotations MD->addOperand(llvm::MDNode::get(Ctx, MDVals)); } + +bool NVPTXTargetCodeGenInfo::shouldEmitStaticExternCAliases() const { + return false; +} } //===----------------------------------------------------------------------===// @@ -7646,6 +7651,7 @@ public: createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; + bool shouldEmitStaticExternCAliases() const override; }; } @@ -7777,6 +7783,10 @@ AMDGPUTargetCodeGenInfo::getLLVMSyncScopeID(SyncScope S, return C.getOrInsertSyncScopeID(Name); } +bool AMDGPUTargetCodeGenInfo::shouldEmitStaticExternCAliases() const { + return false; +} + //===----------------------------------------------------------------------===// // SPARC v8 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1. diff --git a/clang/lib/CodeGen/TargetInfo.h b/clang/lib/CodeGen/TargetInfo.h index f7a813ef675..533e14514ff 100644 --- a/clang/lib/CodeGen/TargetInfo.h +++ b/clang/lib/CodeGen/TargetInfo.h @@ -296,6 +296,11 @@ public: createEnqueuedBlockKernel(CodeGenFunction &CGF, llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const; + + /// \return true if the target supports alias from the unmangled name to the + /// mangled name of functions declared within an extern "C" region and marked + /// as 'used', and having internal linkage. + virtual bool shouldEmitStaticExternCAliases() const { return true; } }; } // namespace CodeGen |

