@@ -367,6 +367,14 @@ llvm::Value *CodeGenFunction::getEHSelectorSlot() {
367
367
return EHSelectorSlot;
368
368
}
369
369
370
+ llvm::Value *CodeGenFunction::getExceptionFromSlot () {
371
+ return Builder.CreateLoad (getExceptionSlot (), " exn" );
372
+ }
373
+
374
+ llvm::Value *CodeGenFunction::getSelectorFromSlot () {
375
+ return Builder.CreateLoad (getEHSelectorSlot (), " sel" );
376
+ }
377
+
370
378
void CodeGenFunction::EmitCXXThrowExpr (const CXXThrowExpr *E) {
371
379
if (!E->getSubExpr ()) {
372
380
if (getInvokeDest ()) {
@@ -483,9 +491,7 @@ static void emitFilterDispatchBlock(CodeGenFunction &CGF,
483
491
// here because the filter triggered.
484
492
if (filterScope.getNumFilters ()) {
485
493
// Load the selector value.
486
- llvm::Value *selector =
487
- CGF.Builder .CreateLoad (CGF.getEHSelectorSlot (), " selector" );
488
-
494
+ llvm::Value *selector = CGF.getSelectorFromSlot ();
489
495
llvm::BasicBlock *unexpectedBB = CGF.createBasicBlock (" ehspec.unexpected" );
490
496
491
497
llvm::Value *zero = CGF.Builder .getInt32 (0 );
@@ -500,7 +506,7 @@ static void emitFilterDispatchBlock(CodeGenFunction &CGF,
500
506
// because __cxa_call_unexpected magically filters exceptions
501
507
// according to the last landing pad the exception was thrown
502
508
// into. Seriously.
503
- llvm::Value *exn = CGF.Builder . CreateLoad (CGF. getExceptionSlot () );
509
+ llvm::Value *exn = CGF.getExceptionFromSlot ( );
504
510
CGF.Builder .CreateCall (getUnexpectedFn (CGF), exn)
505
511
->setDoesNotReturn ();
506
512
CGF.Builder .CreateUnreachable ();
@@ -899,7 +905,7 @@ static void InitCatchParam(CodeGenFunction &CGF,
899
905
const VarDecl &CatchParam,
900
906
llvm::Value *ParamAddr) {
901
907
// Load the exception from where the landing pad saved it.
902
- llvm::Value *Exn = CGF.Builder . CreateLoad (CGF. getExceptionSlot (), " exn " );
908
+ llvm::Value *Exn = CGF.getExceptionFromSlot ( );
903
909
904
910
CanQualType CatchType =
905
911
CGF.CGM .getContext ().getCanonicalType (CatchParam.getType ());
@@ -1074,7 +1080,7 @@ static void BeginCatch(CodeGenFunction &CGF, const CXXCatchStmt *S) {
1074
1080
1075
1081
VarDecl *CatchParam = S->getExceptionDecl ();
1076
1082
if (!CatchParam) {
1077
- llvm::Value *Exn = CGF.Builder . CreateLoad (CGF. getExceptionSlot (), " exn " );
1083
+ llvm::Value *Exn = CGF.getExceptionFromSlot ( );
1078
1084
CallBeginCatch (CGF, Exn, true );
1079
1085
return ;
1080
1086
}
@@ -1116,8 +1122,7 @@ static void emitCatchDispatchBlock(CodeGenFunction &CGF,
1116
1122
CGF.CGM .getIntrinsic (llvm::Intrinsic::eh_typeid_for);
1117
1123
1118
1124
// Load the selector value.
1119
- llvm::Value *selector =
1120
- CGF.Builder .CreateLoad (CGF.getEHSelectorSlot (), " selector" );
1125
+ llvm::Value *selector = CGF.getSelectorFromSlot ();
1121
1126
1122
1127
// Test against each of the exception types we claim to catch.
1123
1128
for (unsigned i = 0 , e = catchScope.getNumHandlers (); ; ++i) {
@@ -1423,13 +1428,13 @@ void CodeGenFunction::FinallyInfo::exit(CodeGenFunction &CGF) {
1423
1428
1424
1429
// If there's a begin-catch function, call it.
1425
1430
if (BeginCatchFn) {
1426
- exn = CGF.Builder . CreateLoad (CGF. getExceptionSlot () );
1431
+ exn = CGF.getExceptionFromSlot ( );
1427
1432
CGF.Builder .CreateCall (BeginCatchFn, exn)->setDoesNotThrow ();
1428
1433
}
1429
1434
1430
1435
// If we need to remember the exception pointer to rethrow later, do so.
1431
1436
if (SavedExnVar) {
1432
- if (!exn) exn = CGF.Builder . CreateLoad (CGF. getExceptionSlot () );
1437
+ if (!exn) exn = CGF.getExceptionFromSlot ( );
1433
1438
CGF.Builder .CreateStore (exn, SavedExnVar);
1434
1439
}
1435
1440
@@ -1519,10 +1524,10 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock() {
1519
1524
StringRef RethrowName = Personality.getCatchallRethrowFnName ();
1520
1525
if (!RethrowName.empty ()) {
1521
1526
Builder.CreateCall (getCatchallRethrowFn (*this , RethrowName),
1522
- Builder. CreateLoad ( getExceptionSlot () ))
1527
+ getExceptionFromSlot ( ))
1523
1528
->setDoesNotReturn ();
1524
1529
} else {
1525
- llvm::Value *Exn = Builder. CreateLoad ( getExceptionSlot () );
1530
+ llvm::Value *Exn = getExceptionFromSlot ( );
1526
1531
1527
1532
switch (CleanupHackLevel) {
1528
1533
case CHL_MandatoryCatchall:
@@ -1534,7 +1539,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock() {
1534
1539
break ;
1535
1540
case CHL_MandatoryCleanup: {
1536
1541
// In mandatory-cleanup mode, we should use llvm.eh.resume.
1537
- llvm::Value *Selector = Builder. CreateLoad ( getEHSelectorSlot () );
1542
+ llvm::Value *Selector = getSelectorFromSlot ( );
1538
1543
Builder.CreateCall2 (CGM.getIntrinsic (llvm::Intrinsic::eh_resume),
1539
1544
Exn, Selector)
1540
1545
->setDoesNotReturn ();
0 commit comments