r287025 - [OPENMP] Fix stack use after delete, NFC.

Vitaly Buka via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 15 15:40:29 PST 2016


With this patch it's "after-scope" instead of return but still there:
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/650/steps/check-clang%20asan/logs/stdio

On Tue, Nov 15, 2016 at 1:07 PM Alexey Bataev via cfe-commits <
cfe-commits at lists.llvm.org> wrote:

> Author: abataev
> Date: Tue Nov 15 14:57:18 2016
> New Revision: 287025
>
> URL: http://llvm.org/viewvc/llvm-project?rev=287025&view=rev
> Log:
> [OPENMP] Fix stack use after delete, NFC.
>
> Fixed possible use of stack variable after deletion.
>
> Modified:
>     cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
>
> Modified: cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp?rev=287025&r1=287024&r2=287025&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGStmtOpenMP.cpp Tue Nov 15 14:57:18 2016
> @@ -2237,6 +2237,7 @@ void CodeGenFunction::EmitSections(const
>    bool HasLastprivates = false;
>    auto &&CodeGen = [&S, Stmt, CS, &HasLastprivates](CodeGenFunction &CGF,
>                                                      PrePostActionTy &) {
> +    OMPCancelStackRAII CancelRegion(CGF);
>      auto &C = CGF.CGM.getContext();
>      auto KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32,
> /*Signed=*/1);
>      // Emit helper vars inits.
> @@ -2332,11 +2333,11 @@ void CodeGenFunction::EmitSections(const
>                           [](CodeGenFunction &) {});
>      // Tell the runtime we are done.
>      SourceLocation ELoc = S.getLocEnd();
> -    auto &&CodeGen = [ELoc](CodeGenFunction &CGF) {
> +    auto &&FinalCodeGen = [ELoc](CodeGenFunction &CGF) {
>        CGF.CGM.getOpenMPRuntime().emitForStaticFinish(CGF, ELoc);
>      };
> -    CodeGen(CGF);
> -    CGF.OMPCancelStack.back().CodeGen = CodeGen;
> +    FinalCodeGen(CGF);
> +    CGF.OMPCancelStack.back().CodeGen = FinalCodeGen;
>      CGF.EmitOMPReductionClauseFinal(S);
>      // Emit post-update of the reduction variables if IsLastIter != 0.
>      emitPostUpdateForReductionClause(
> @@ -2374,7 +2375,6 @@ void CodeGenFunction::EmitSections(const
>  void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective
> &S) {
>    {
>      OMPLexicalScope Scope(*this, S, /*AsInlined=*/true);
> -    OMPCancelStackRAII CancelRegion(*this);
>      EmitSections(S);
>    }
>    // Emit an implicit barrier at the end.
> @@ -2483,7 +2483,6 @@ void CodeGenFunction::EmitOMPParallelSec
>    // Emit directive as a combined directive that consists of two implicit
>    // directives: 'parallel' with 'sections' directive.
>    auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &) {
> -    OMPCancelStackRAII CancelRegion(CGF);
>      CGF.EmitSections(S);
>    };
>    emitCommonOMPParallelDirective(*this, S, OMPD_sections, CodeGen);
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161115/b188d1a4/attachment.html>


More information about the cfe-commits mailing list