diff options
| author | Chandler Carruth <chandlerc@gmail.com> | 2017-03-22 10:38:07 +0000 |
|---|---|---|
| committer | Chandler Carruth <chandlerc@gmail.com> | 2017-03-22 10:38:07 +0000 |
| commit | 421fa6c9e27adacdb52e2195da7f67292e5b18ac (patch) | |
| tree | 9ac992c3dba9a8bff54810ab599bf7060e196693 | |
| parent | 00aee43734e040de1d8d98722abfc78db7dc5c82 (diff) | |
| download | bcm5719-llvm-421fa6c9e27adacdb52e2195da7f67292e5b18ac.tar.gz bcm5719-llvm-421fa6c9e27adacdb52e2195da7f67292e5b18ac.zip | |
Remove an overly aggressive assert in r298491 and leave a comment
explaining why we have to ignore errors here even though in other parts
of codegen we can be more strict with builtins.
Also add a test case based on the code in a TSan test that found this
issue.
llvm-svn: 298494
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 6 | ||||
| -rw-r--r-- | clang/test/CodeGen/function-attributes.c | 14 |
2 files changed, 19 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index b9090b413c6..e56fe2c1c1d 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -1813,7 +1813,11 @@ void CodeGenModule::ConstructAttributeList( ASTContext::GetBuiltinTypeError Error; getContext().GetBuiltinType(BuiltinID, Error, nullptr, &OverrideNonnullReturn, &OverrideNonnullArgs); - assert(Error == ASTContext::GE_None && "Should not codegen an error"); + // Note that we can't check the 'Error' here as there may be errors that + // have been diagnosed and reported to the programmer as warnings but + // repaired in the AST such as for implicit declarations of builtin + // functions. None of those impact our usage of this to analyze attributes + // for the builtins. } bool HasOptnone = false; diff --git a/clang/test/CodeGen/function-attributes.c b/clang/test/CodeGen/function-attributes.c index 2139f6fe654..49f47bf74d4 100644 --- a/clang/test/CodeGen/function-attributes.c +++ b/clang/test/CodeGen/function-attributes.c @@ -108,6 +108,20 @@ void f20(void) { _setjmp(0); } +// Bogus declarations that will end up with bad types when detecting builtins, +// but that we will still process when considering whether to add attributes. +struct __jmp_buf_tag; +extern int __sigsetjmp(struct __jmp_buf_tag *__env, int __savemask); + +// CHECK-LABEL: define void @f21() +// CHECK: { +// CHECK: call i32 @__sigsetjmp(%{{.*}}* null, i32 0) +// CHECK: [[RT_CALL]] +// CHECK: ret void +void f21(void) { + __sigsetjmp(0, 0); +} + // CHECK: attributes [[NUW]] = { nounwind optsize{{.*}} } // CHECK: attributes [[AI]] = { alwaysinline nounwind optsize{{.*}} } // CHECK: attributes [[NUW_OS_RN]] = { nounwind optsize readnone{{.*}} } |

