diff options
| author | Gor Nishanov <GorNishanov@gmail.com> | 2017-11-11 17:00:43 +0000 |
|---|---|---|
| committer | Gor Nishanov <GorNishanov@gmail.com> | 2017-11-11 17:00:43 +0000 |
| commit | 04491bd8f324bce9d2adbc9cc6e45f0d1659ac41 (patch) | |
| tree | 3fe744167112646b34709aad1180d71b90eab244 /clang/lib/CodeGen/CodeGenFunction.h | |
| parent | d0ef19ef9b2c4c61ecd10b133632c795c3bc2d31 (diff) | |
| download | bcm5719-llvm-04491bd8f324bce9d2adbc9cc6e45f0d1659ac41.tar.gz bcm5719-llvm-04491bd8f324bce9d2adbc9cc6e45f0d1659ac41.zip | |
[coroutines] Promote cleanup.dest.slot allocas to registers to avoid storing it in the coroutine frame
Summary:
We don't want to store cleanup dest slot saved into the coroutine frame (as some of the cleanup code may
access them after coroutine frame destroyed).
This is an alternative to https://reviews.llvm.org/D37093
It is possible to do this for all functions, but, cursory check showed that in -O0, we get slightly longer function (by 1-3 instructions), thus, we are only limiting cleanup.dest.slot elimination to coroutines.
Reviewers: rjmccall, hfinkel, eric_niebler
Reviewed By: eric_niebler
Subscribers: EricWF, cfe-commits
Differential Revision: https://reviews.llvm.org/D39768
llvm-svn: 317981
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
| -rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index ba8d8b5e60e..0165e5f45df 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -225,6 +225,10 @@ public: }; CGCoroInfo CurCoro; + bool isCoroutine() const { + return CurCoro.Data != nullptr; + } + /// CurGD - The GlobalDecl for the current function being compiled. GlobalDecl CurGD; @@ -764,7 +768,7 @@ public: ForceCleanup(); } - /// Checks if the global variable is captured in current function. + /// Checks if the global variable is captured in current function. bool isGlobalVarCaptured(const VarDecl *VD) const { VD = VD->getCanonicalDecl(); return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0; @@ -826,7 +830,7 @@ public: /// block through the normal cleanup handling code (if any) and then /// on to \arg Dest. void EmitBranchThroughCleanup(JumpDest Dest); - + /// isObviouslyBranchWithoutCleanups - Return true if a branch to the /// specified destination obviously has no cleanups to run. 'false' is always /// a conservatively correct answer for this method. @@ -1045,7 +1049,7 @@ public: if (Data.isValid()) Data.unbind(CGF); } }; - + private: CGDebugInfo *DebugInfo; bool DisableDebugInfo; @@ -1434,7 +1438,7 @@ private: /// Add OpenCL kernel arg metadata and the kernel attribute meatadata to /// the function metadata. - void EmitOpenCLKernelMetadata(const FunctionDecl *FD, + void EmitOpenCLKernelMetadata(const FunctionDecl *FD, llvm::Function *Fn); public: @@ -1443,10 +1447,10 @@ public: CodeGenTypes &getTypes() const { return CGM.getTypes(); } ASTContext &getContext() const { return CGM.getContext(); } - CGDebugInfo *getDebugInfo() { - if (DisableDebugInfo) + CGDebugInfo *getDebugInfo() { + if (DisableDebugInfo) return nullptr; - return DebugInfo; + return DebugInfo; } void disableDebugInfo() { DisableDebugInfo = true; } void enableDebugInfo() { DisableDebugInfo = false; } @@ -2509,7 +2513,7 @@ public: }; AutoVarEmission EmitAutoVarAlloca(const VarDecl &var); void EmitAutoVarInit(const AutoVarEmission &emission); - void EmitAutoVarCleanups(const AutoVarEmission &emission); + void EmitAutoVarCleanups(const AutoVarEmission &emission); void emitAutoVarTypeCleanup(const AutoVarEmission &emission, QualType::DestructionKind dtorKind); @@ -2531,7 +2535,7 @@ public: bool isIndirect() const { return Alignment != 0; } llvm::Value *getAnyValue() const { return Value; } - + llvm::Value *getDirectValue() const { assert(!isIndirect()); return Value; @@ -3188,7 +3192,7 @@ public: LValue EmitCastLValue(const CastExpr *E); LValue EmitMaterializeTemporaryExpr(const MaterializeTemporaryExpr *E); LValue EmitOpaqueValueLValue(const OpaqueValueExpr *e); - + Address EmitExtVectorElementLValue(LValue V); RValue EmitRValueForField(LValue LV, const FieldDecl *FD, SourceLocation Loc); @@ -3305,12 +3309,12 @@ public: void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef<llvm::Value*> args); - CGCallee BuildAppleKextVirtualCall(const CXXMethodDecl *MD, + CGCallee BuildAppleKextVirtualCall(const CXXMethodDecl *MD, NestedNameSpecifier *Qual, llvm::Type *Ty); - + CGCallee BuildAppleKextVirtualDestructorCall(const CXXDestructorDecl *DD, - CXXDtorType Type, + CXXDtorType Type, const CXXRecordDecl *RD); RValue @@ -3484,11 +3488,11 @@ public: static Destroyer destroyARCWeak; static Destroyer emitARCIntrinsicUse; - void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr); + void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr); llvm::Value *EmitObjCAutoreleasePoolPush(); llvm::Value *EmitObjCMRRAutoreleasePoolPush(); void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr); - void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr); + void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr); /// \brief Emits a reference binding to the passed in expression. RValue EmitReferenceBindingToExpr(const Expr *E); @@ -3603,7 +3607,7 @@ public: bool PerformInit); void EmitCXXConstructExpr(const CXXConstructExpr *E, AggValueSlot Dest); - + void EmitSynthesizedCXXCopyCtor(Address Dest, Address Src, const Expr *Exp); void enterFullExpression(const ExprWithCleanups *E) { @@ -3652,7 +3656,7 @@ public: /// Determine if the given statement might introduce a declaration into the /// current scope, by being a (possibly-labelled) DeclStmt. static bool mightAddDeclToScope(const Stmt *S); - + /// ConstantFoldsToSimpleInteger - If the specified expression does not fold /// to a constant, or if it does but contains a label, return false. If it /// constant folds return true and set the boolean result in Result. |

