Skip to content

Commit 581c2b9

Browse files
committedJan 28, 2016
Check for frontend errors after releasing the Builder.
Frontend can emit errors when releaseing the Builder. If there are errors before or when releasing the Builder, we reset the module to stop here before invoking the backend. Before this commit, clang will continue to invoke the backend and backend can crash. Differential Revision: http://reviews.llvm.org/D16564 llvm-svn: 259116
1 parent 243d024 commit 581c2b9

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed
 

‎clang/lib/CodeGen/ModuleBuilder.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,18 @@ namespace {
199199
}
200200

201201
void HandleTranslationUnit(ASTContext &Ctx) override {
202+
// Release the Builder when there is no error.
203+
if (!Diags.hasErrorOccurred() && Builder)
204+
Builder->Release();
205+
206+
// If there are errors before or when releasing the Builder, reset
207+
// the module to stop here before invoking the backend.
202208
if (Diags.hasErrorOccurred()) {
203209
if (Builder)
204210
Builder->clear();
205211
M.reset();
206212
return;
207213
}
208-
209-
if (Builder)
210-
Builder->Release();
211214
}
212215

213216
void AssignInheritanceModel(CXXRecordDecl *RD) override {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin -S -verify -o - -target-feature +avx
2+
3+
// RUN: not %clang_cc1 %s -triple=x86_64-apple-darwin -emit-obj -target-feature +avx 2> %t.err
4+
// RUN: FileCheck < %t.err %s
5+
// CHECK: 1 error generated
6+
7+
typedef unsigned short uint16_t;
8+
typedef long long __m128i __attribute__((__vector_size__(16)));
9+
typedef float __v8sf __attribute__ ((__vector_size__ (32)));
10+
typedef float __m256 __attribute__ ((__vector_size__ (32)));
11+
typedef uint16_t half;
12+
typedef __attribute__ ((ext_vector_type( 8),__aligned__( 16))) half half8;
13+
typedef __attribute__ ((ext_vector_type(16),__aligned__( 32))) half half16;
14+
typedef __attribute__ ((ext_vector_type(16),__aligned__( 2))) half half16U;
15+
typedef __attribute__ ((ext_vector_type( 8),__aligned__( 32))) float float8;
16+
typedef __attribute__ ((ext_vector_type(16),__aligned__( 64))) float float16;
17+
static inline half8 __attribute__((__overloadable__)) convert_half( float8 a ) {
18+
return __extension__ ({ __m256 __a = (a); (__m128i)__builtin_ia32_vcvtps2ph256((__v8sf)__a, (0x00)); }); // expected-error {{'__builtin_ia32_vcvtps2ph256' needs target feature f16c}}
19+
}
20+
static inline half16 __attribute__((__overloadable__)) convert_half( float16 a ) {
21+
half16 r;
22+
r.lo = convert_half( a.lo);
23+
return r;
24+
}
25+
void avx_test( uint16_t *destData, float16 argbF)
26+
{
27+
((half16U*)destData)[0] = convert_half(argbF);
28+
}

0 commit comments

Comments
 (0)
Please sign in to comment.