summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorReid Kleckner <reid@kleckner.net>2015-02-11 21:40:48 +0000
committerReid Kleckner <reid@kleckner.net>2015-02-11 21:40:48 +0000
commita593000f0133bccfeabb5f89b8c9d9533d2106bd (patch)
tree9a0e4939e3655257631c64903b577682e3ed207c /clang/lib
parent59c8aa92b8933fdf1cfefdaadc877c7ad640d4cb (diff)
downloadbcm5719-llvm-a593000f0133bccfeabb5f89b8c9d9533d2106bd.tar.gz
bcm5719-llvm-a593000f0133bccfeabb5f89b8c9d9533d2106bd.zip
Add the 'noinline' attribute to call sites within __try bodies
LLVM doesn't support non-call exceptions, so inlining makes it harder to catch such asynchronous exceptions. llvm-svn: 228876
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/CodeGen/CGCall.cpp6
-rw-r--r--clang/lib/CodeGen/CGException.cpp7
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp2
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h3
4 files changed, 16 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 0574a1a34dc..60ab2effbeb 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3325,6 +3325,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
Attrs.addAttribute(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
llvm::Attribute::AlwaysInline);
+ // Disable inlining inside SEH __try blocks.
+ if (IsSEHTryScope)
+ Attrs =
+ Attrs.addAttribute(getLLVMContext(), llvm::AttributeSet::FunctionIndex,
+ llvm::Attribute::NoInline);
+
CS.setAttributes(Attrs);
CS.setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 9df4f977318..b8ce205ff1b 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -21,6 +21,7 @@
#include "clang/AST/StmtObjC.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Intrinsics.h"
+#include "llvm/Support/SaveAndRestore.h"
using namespace clang;
using namespace CodeGen;
@@ -1703,7 +1704,11 @@ void CodeGenFunction::EmitSEHTryStmt(const SEHTryStmt &S) {
SEHFinallyInfo FI;
EnterSEHTryStmt(S, FI);
- EmitStmt(S.getTryBlock());
+ {
+ // Disable inlining inside SEH __try scopes.
+ SaveAndRestore<bool> Saver(IsSEHTryScope, true);
+ EmitStmt(S.getTryBlock());
+ }
ExitSEHTryStmt(S, FI);
}
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index 79425d4c21e..43dd7a05de1 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -40,7 +40,7 @@ CodeGenFunction::CodeGenFunction(CodeGenModule &cgm, bool suppressNewContext)
CurFn(nullptr), CapturedStmtInfo(nullptr),
SanOpts(CGM.getLangOpts().Sanitize), IsSanitizerScope(false),
CurFuncIsThunk(false), AutoreleaseResult(false), SawAsmBlock(false),
- BlockInfo(nullptr), BlockPointer(nullptr),
+ IsSEHTryScope(false), BlockInfo(nullptr), BlockPointer(nullptr),
LambdaThisCaptureField(nullptr), NormalCleanupDest(nullptr),
NextCleanupDestIndex(1), FirstBlockInfo(nullptr), EHResumeBlock(nullptr),
ExceptionSlot(nullptr), EHSelectorSlot(nullptr),
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 998e0676cd2..6011333c9dd 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -263,6 +263,9 @@ public:
/// potentially set the return value.
bool SawAsmBlock;
+ /// Codegen is currently inside an SEH try block.
+ bool IsSEHTryScope;
+
const CodeGen::CGBlockInfo *BlockInfo;
llvm::Value *BlockPointer;
OpenPOWER on IntegriCloud