diff options
| author | Justin Lebar <jlebar@google.com> | 2016-10-04 23:41:49 +0000 |
|---|---|---|
| committer | Justin Lebar <jlebar@google.com> | 2016-10-04 23:41:49 +0000 |
| commit | 3e6449b4f423c9c4e13974ee5ad909a1475bce63 (patch) | |
| tree | 63f6e094fbdbae54a2c2025646fbf44101794336 /clang/lib/CodeGen | |
| parent | 49e7614efb5bad5de8d7bcab0fcd59808db5495d (diff) | |
| download | bcm5719-llvm-3e6449b4f423c9c4e13974ee5ad909a1475bce63.tar.gz bcm5719-llvm-3e6449b4f423c9c4e13974ee5ad909a1475bce63.zip | |
[CUDA] Mark device functions as nounwind.
Summary:
This prevents clang from emitting 'invoke's and catch statements.
Things previously mostly worked thanks to TryToMarkNoThrow() in
CodeGenFunction. But this is not a proper IPO, and it doesn't properly
handle cases like mutual recursion.
Fixes bug 30593.
Reviewers: tra
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D25166
llvm-svn: 283272
Diffstat (limited to 'clang/lib/CodeGen')
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGException.cpp | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index f441bf4eda1..955b86a38b2 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1814,6 +1814,9 @@ void CodeGenModule::ConstructAttributeList( // them). LLVM will remove this attribute where it safely can. FuncAttrs.addAttribute(llvm::Attribute::Convergent); + // Exceptions aren't supported in CUDA device code. + FuncAttrs.addAttribute(llvm::Attribute::NoUnwind); + // Respect -fcuda-flush-denormals-to-zero. if (getLangOpts().CUDADeviceFlushDenormalsToZero) FuncAttrs.addAttribute("nvptx-f32ftz", "true"); diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp index 4a7dc4205e0..57ac44e6b17 100644 --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -698,6 +698,10 @@ llvm::BasicBlock *CodeGenFunction::getInvokeDestImpl() { return nullptr; } + // CUDA device code doesn't have exceptions. + if (LO.CUDA && LO.CUDAIsDevice) + return nullptr; + // Check the innermost scope for a cached landing pad. If this is // a non-EH cleanup, we'll check enclosing scopes in EmitLandingPad. llvm::BasicBlock *LP = EHStack.begin()->getCachedLandingPad(); |

