[cfe-commits] r139826 - in /cfe/trunk/lib/CodeGen: CGException.cpp CGObjCRuntime.cpp CodeGenFunction.h
Bill Wendling
isanbard at gmail.com
Thu Sep 15 11:57:19 PDT 2011
Author: void
Date: Thu Sep 15 13:57:19 2011
New Revision: 139826
URL: http://llvm.org/viewvc/llvm-project?rev=139826&view=rev
Log:
Refactor the load of the exception pointer and the exception selector from their
storage slot into helper functions.
Modified:
cfe/trunk/lib/CodeGen/CGException.cpp
cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGException.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGException.cpp?rev=139826&r1=139825&r2=139826&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGException.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGException.cpp Thu Sep 15 13:57:19 2011
@@ -367,6 +367,14 @@
return EHSelectorSlot;
}
+llvm::Value *CodeGenFunction::getExceptionFromSlot() {
+ return Builder.CreateLoad(getExceptionSlot(), "exn");
+}
+
+llvm::Value *CodeGenFunction::getSelectorFromSlot() {
+ return Builder.CreateLoad(getEHSelectorSlot(), "sel");
+}
+
void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) {
if (!E->getSubExpr()) {
if (getInvokeDest()) {
@@ -483,9 +491,7 @@
// here because the filter triggered.
if (filterScope.getNumFilters()) {
// Load the selector value.
- llvm::Value *selector =
- CGF.Builder.CreateLoad(CGF.getEHSelectorSlot(), "selector");
-
+ llvm::Value *selector = CGF.getSelectorFromSlot();
llvm::BasicBlock *unexpectedBB = CGF.createBasicBlock("ehspec.unexpected");
llvm::Value *zero = CGF.Builder.getInt32(0);
@@ -500,7 +506,7 @@
// because __cxa_call_unexpected magically filters exceptions
// according to the last landing pad the exception was thrown
// into. Seriously.
- llvm::Value *exn = CGF.Builder.CreateLoad(CGF.getExceptionSlot());
+ llvm::Value *exn = CGF.getExceptionFromSlot();
CGF.Builder.CreateCall(getUnexpectedFn(CGF), exn)
->setDoesNotReturn();
CGF.Builder.CreateUnreachable();
@@ -899,7 +905,7 @@
const VarDecl &CatchParam,
llvm::Value *ParamAddr) {
// Load the exception from where the landing pad saved it.
- llvm::Value *Exn = CGF.Builder.CreateLoad(CGF.getExceptionSlot(), "exn");
+ llvm::Value *Exn = CGF.getExceptionFromSlot();
CanQualType CatchType =
CGF.CGM.getContext().getCanonicalType(CatchParam.getType());
@@ -1074,7 +1080,7 @@
VarDecl *CatchParam = S->getExceptionDecl();
if (!CatchParam) {
- llvm::Value *Exn = CGF.Builder.CreateLoad(CGF.getExceptionSlot(), "exn");
+ llvm::Value *Exn = CGF.getExceptionFromSlot();
CallBeginCatch(CGF, Exn, true);
return;
}
@@ -1116,8 +1122,7 @@
CGF.CGM.getIntrinsic(llvm::Intrinsic::eh_typeid_for);
// Load the selector value.
- llvm::Value *selector =
- CGF.Builder.CreateLoad(CGF.getEHSelectorSlot(), "selector");
+ llvm::Value *selector = CGF.getSelectorFromSlot();
// Test against each of the exception types we claim to catch.
for (unsigned i = 0, e = catchScope.getNumHandlers(); ; ++i) {
@@ -1423,13 +1428,13 @@
// If there's a begin-catch function, call it.
if (BeginCatchFn) {
- exn = CGF.Builder.CreateLoad(CGF.getExceptionSlot());
+ exn = CGF.getExceptionFromSlot();
CGF.Builder.CreateCall(BeginCatchFn, exn)->setDoesNotThrow();
}
// If we need to remember the exception pointer to rethrow later, do so.
if (SavedExnVar) {
- if (!exn) exn = CGF.Builder.CreateLoad(CGF.getExceptionSlot());
+ if (!exn) exn = CGF.getExceptionFromSlot();
CGF.Builder.CreateStore(exn, SavedExnVar);
}
@@ -1519,10 +1524,10 @@
StringRef RethrowName = Personality.getCatchallRethrowFnName();
if (!RethrowName.empty()) {
Builder.CreateCall(getCatchallRethrowFn(*this, RethrowName),
- Builder.CreateLoad(getExceptionSlot()))
+ getExceptionFromSlot())
->setDoesNotReturn();
} else {
- llvm::Value *Exn = Builder.CreateLoad(getExceptionSlot());
+ llvm::Value *Exn = getExceptionFromSlot();
switch (CleanupHackLevel) {
case CHL_MandatoryCatchall:
@@ -1534,7 +1539,7 @@
break;
case CHL_MandatoryCleanup: {
// In mandatory-cleanup mode, we should use llvm.eh.resume.
- llvm::Value *Selector = Builder.CreateLoad(getEHSelectorSlot());
+ llvm::Value *Selector = getSelectorFromSlot();
Builder.CreateCall2(CGM.getIntrinsic(llvm::Intrinsic::eh_resume),
Exn, Selector)
->setDoesNotReturn();
Modified: cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp?rev=139826&r1=139825&r2=139826&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjCRuntime.cpp Thu Sep 15 13:57:19 2011
@@ -221,7 +221,7 @@
CatchHandler &Handler = Handlers[I];
CGF.EmitBlock(Handler.Block);
- llvm::Value *RawExn = CGF.Builder.CreateLoad(CGF.getExceptionSlot());
+ llvm::Value *RawExn = CGF.getExceptionFromSlot();
// Enter the catch.
llvm::Value *Exn = RawExn;
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=139826&r1=139825&r2=139826&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Thu Sep 15 13:57:19 2011
@@ -1121,6 +1121,11 @@
llvm::Value *getExceptionSlot();
llvm::Value *getEHSelectorSlot();
+ /// Returns the contents of the function's exception object and selector
+ /// slots.
+ llvm::Value *getExceptionFromSlot();
+ llvm::Value *getSelectorFromSlot();
+
llvm::Value *getNormalCleanupDestSlot();
llvm::BasicBlock *getUnreachableBlock() {
More information about the cfe-commits
mailing list