[cfe-dev] Fwd: Library calls for complex types and terminate scopes.
Samuel F Antao via cfe-dev
cfe-dev at lists.llvm.org
Tue Nov 17 17:58:24 PST 2015
Reid, John,
Thanks for the feedback!
John McCall <rjmccall at gmail.com> wrote on 11/17/2015 08:34:18 PM:
> From: John McCall <rjmccall at gmail.com>
> To: Reid Kleckner <rnk at google.com>
> Cc: Samuel F Antao/Watson/IBM at IBMUS, cfe-dev <cfe-
> dev at lists.llvm.org>, Alexey Bataev <a.bataev at hotmail.com>, Hal
> Finkel <hfinkel at anl.gov>
> Date: 11/17/2015 08:34 PM
> Subject: Re: [cfe-dev] Fwd: Library calls for complex types and
> terminate scopes.
>
> 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.
Just to make sure I get it right. You'd like me to add a new bit to ExtInfo
and use it instead of the check of the nounwind attribute in EmitCall,
right?
I'd probably keep the check of the attribute anyway as there may be other
places that are already relying on the attribute, do you agree?
Thanks again,
Samuel
>
> 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/75f9e52d/attachment.html>
More information about the cfe-dev
mailing list