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