aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGException.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2015-10-07 01:07:13 +0000
committerReid Kleckner <rnk@google.com>2015-10-07 01:07:13 +0000
commitf8d115338d1ec2ea14a072b65647816b02b9d30b (patch)
treea3cc258663cf122f2e5caa7bd18297213bdc491f /clang/lib/CodeGen/CGException.cpp
parent52dca345db0ded0d934a312b6a103a08c8ffc997 (diff)
downloadllvm-f8d115338d1ec2ea14a072b65647816b02b9d30b.zip
llvm-f8d115338d1ec2ea14a072b65647816b02b9d30b.tar.gz
llvm-f8d115338d1ec2ea14a072b65647816b02b9d30b.tar.bz2
[SEH] Fix x64 __exception_code in __except blocks
Use llvm.eh.exceptioncode to get the code out of EAX for x64. For 32-bit, the filter is responsible for storing it to memory for us. llvm-svn: 249497
Diffstat (limited to 'clang/lib/CodeGen/CGException.cpp')
-rw-r--r--clang/lib/CodeGen/CGException.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index ebeb727..2490098 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1898,14 +1898,21 @@ void CodeGenFunction::ExitSEHTryStmt(const SEHTryStmt &S) {
ExceptBB = createBasicBlock("__except");
Builder.CreateCatchRet(CPI, ExceptBB);
EmitBlock(ExceptBB);
- }
-
- // On Win64, the exception pointer is the exception code. Copy it to the slot.
- if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
- llvm::Value *Code =
- Builder.CreatePtrToInt(getExceptionFromSlot(), IntPtrTy);
- Code = Builder.CreateTrunc(Code, Int32Ty);
- Builder.CreateStore(Code, SEHCodeSlotStack.back());
+ // On Win64, the exception code is returned in EAX. Copy it into the slot.
+ if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
+ llvm::Function *SEHCodeIntrin =
+ CGM.getIntrinsic(llvm::Intrinsic::eh_exceptioncode);
+ llvm::Value *Code = Builder.CreateCall(SEHCodeIntrin, {CPI});
+ Builder.CreateStore(Code, SEHCodeSlotStack.back());
+ }
+ } else {
+ // On Win64, the exception pointer is the exception code. Copy it to the slot.
+ if (CGM.getTarget().getTriple().getArch() != llvm::Triple::x86) {
+ llvm::Value *Code =
+ Builder.CreatePtrToInt(getExceptionFromSlot(), IntPtrTy);
+ Code = Builder.CreateTrunc(Code, Int32Ty);
+ Builder.CreateStore(Code, SEHCodeSlotStack.back());
+ }
}
// Emit the __except body.