Yes, the crash may happen only on CodeGenFunction destruction Best regards, Alexey Bataev
21 ???. 2017 ?., ? 0:04, Reid Kleckner <r...@google.com<mailto:r...@google.com>> ???????(?): Thanks! Does this match the logic for starting a function in OpenMP? Also, the test shouldn't have REQUIRES: x86-registered-target. On Fri, Jan 20, 2017 at 12:57 AM, Alexey Bataev via cfe-commits <cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org>> wrote: Author: abataev Date: Fri Jan 20 02:57:28 2017 New Revision: 292590 URL: http://llvm.org/viewvc/llvm-project?rev=292590&view=rev Log: [OPENMP] Fix for PR31643: Clang crashes when compiling code on Windows with SEH and openmp In some cituations (during codegen for Windows SEH constructs) CodeGenFunction instance may have CurFn equal to nullptr. OpenMP related code does not expect such situation during cleanup. Added: cfe/trunk/test/OpenMP/openmp_seh.c Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=292590&r1=292589&r2=292590&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Jan 20 02:57:28 2017 @@ -112,9 +112,8 @@ CodeGenFunction::~CodeGenFunction() { if (FirstBlockInfo) destroyBlockInfos(FirstBlockInfo); - if (getLangOpts().OpenMP) { + if (getLangOpts().OpenMP && CurFn) CGM.getOpenMPRuntime().functionFinished(*this); - } } CharUnits CodeGenFunction::getNaturalPointeeTypeAlignment(QualType T, Added: cfe/trunk/test/OpenMP/openmp_seh.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/openmp_seh.c?rev=292590&view=auto ============================================================================== --- cfe/trunk/test/OpenMP/openmp_seh.c (added) +++ cfe/trunk/test/OpenMP/openmp_seh.c Fri Jan 20 02:57:28 2017 @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -verify -triple x86_64-pc-windows-msvc19.0.0 -fopenmp -fms-compatibility -x c++ -emit-llvm %s -o - | FileCheck %s +// expected-no-diagnostics +// REQUIRES: x86-registered-target +extern "C" { +void __cpuid(int[4], int); +} + +// CHECK-LABEL: @main +int main(void) { + __try { + int info[4]; + __cpuid(info, 1); + } __except (1) { + } + + return 0; +} + _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org<mailto:cfe-commits@lists.llvm.org> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits