[cfe-dev] Fwd: Library calls for complex types and terminate scopes.
John McCall via cfe-dev
cfe-dev at lists.llvm.org
Tue Nov 17 17:34:18 PST 2015
On Tue, Nov 17, 2015 at 4:54 PM, Reid Kleckner <rnk at google.com> wrote:
> Maybe you could mark the runtime function nounwind when you get its
> declaration here:
> llvm::Constant *Func = CGF.CGM.CreateBuiltinFunction(FTy, LibCallName
> /*pass an AttributeSet here*/);
>
> Then you won't have to call setDoesNotThrow() later.
>
The by-design way to do this is to add a noexcept specification to the
ExtInfo being passed to arrangeFreeFunctionCall.
John.
> On Tue, Nov 17, 2015 at 4:43 PM, Samuel F Antao via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
>
>> Hi all,
>>
>> I came across an issue that happens to trigger an assertion in clang if
>> an operation with type type is implemented in a scope that happens to
>> install a terminate scope in the exceptions stack. I see the issue while
>> using complex arithmetic in OpenMP regions, but I believe that could also
>> be a problem for non-openMP codes.
>>
>> The problem happens in `ComplexExprEmitter::EmitComplexBinOpLibCall` and
>> is caused by an assertion in:
>>
>> ```
>> RValue Res = CGF.EmitCall(FuncInfo, Func, ReturnValueSlot(), Args,
>> nullptr, &Call);
>> cast<llvm::CallInst>(Call)->setCallingConv(CGF.CGM.getBuiltinCC());
>> cast<llvm::CallInst>(Call)->setDoesNotThrow();
>> ```
>>
>> `EHStack.requiresLandingPad()` is used by `EmitCall` and is true if we
>> have a scope installed in the exceptions stack. This causes `EmitCall` to
>> produce an invoke instruction instead of a call instruction.
>>
>> One of the ways to tackle the issue is use the proper attributes for the
>> library function (e.g. no unwind). Is this the right thing to do? Or can
>> these library calls throw in some cases?
>>
>> Any thoughts?
>>
>> Here is a simple code that replicates the problem:
>> ```
>> int main (int argc, char *argv[]){
>> double _Complex dc = (double)argc + 3*I;
>>
>> dc *= dc;
>> #pragma omp parallel
>> {
>> dc *= dc;
>> }
>> printf("%lf %lf\n",creal(dc),cimag(dc));
>> return 0;
>> }
>> ```
>>
>> Thanks!
>> Samuel
>>
>>
>> _______________________________________________
>> cfe-dev mailing list
>> cfe-dev at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>
>>
>
--
I suppose you'd like my real thoughts as well.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151117/8d3c5526/attachment.html>
More information about the cfe-dev
mailing list