Author: chandlerc Date: Wed Mar 22 05:38:07 2017 New Revision: 298494 URL: http://llvm.org/viewvc/llvm-project?rev=298494&view=rev Log: 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. Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/test/CodeGen/function-attributes.c Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=298494&r1=298493&r2=298494&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Mar 22 05:38:07 2017 @@ -1813,7 +1813,11 @@ void CodeGenModule::ConstructAttributeLi 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; Modified: cfe/trunk/test/CodeGen/function-attributes.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-attributes.c?rev=298494&r1=298493&r2=298494&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/function-attributes.c (original) +++ cfe/trunk/test/CodeGen/function-attributes.c Wed Mar 22 05:38:07 2017 @@ -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{{.*}} } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits