[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-05-14 Thread Serge Pavlov via cfe-commits
spavloff wrote: PR https://github.com/llvm/llvm-project/pull/92146 does not solve the problem of serialization mentioned above, but it is simple and quick solution for the reported crash. https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commit

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-05-13 Thread Serge Pavlov via cfe-commits
spavloff wrote: Hi @SLTozer, Thank you for the report. There is an issue somewhere around the code that reads/wtites records FP_PRAGMA_OPTIONS and/or FLOAT_CONTROL_PRAGMA_OPTIONS, which sometimes manifest itseld in broken synchronization of FP options. I will prepare fix soon. https://github

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-05-10 Thread Stephen Tozer via cfe-commits
SLTozer wrote: It looks like this is causing crashes when including precompiled headers that contain optnone functions; this can be reproduced with a very short header file and any source file, even a completely empty one. Reproducer follows: ``` $ cat header.h __attribute__((optnone)) void foo

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-05-04 Thread Serge Pavlov via cfe-commits
spavloff wrote: Hi @wjristow, Thank you for your detailed analysis. Indeed, FPContract looks more like mandatory option rather than optional optimization. I prepared PR: https://github.com/llvm/llvm-project/pull/91061, which fixes this issue. https://github.com/llvm/llvm-project/pull/85605 __

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-05-03 Thread via cfe-commits
wjristow wrote: Hi @spavloff. Given my post above was fairly long, I want to make a short, clarifying comment. There was a sense in the earlier discussion that there is a problem in that the spec of `optnone` is imprecise (and that's causing the behavior difference). A lack of precision of

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-05-01 Thread via cfe-commits
wjristow wrote: Hi @spavloff. Regarding: > With that goal in mind, having `optnone` and `-O0` be deliberately different > here makes no sense. There's no need for them to behave differently here. And in fact, we _want_ them to behave the same. There's a subtle point about FP contraction, in

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-26 Thread Paul T Robinson via cfe-commits
pogo59 wrote: > `optnone` is a very strange attribute; it's a directive to the compiler with > no clear semantics. In an ideal world, an `optnone` function would be compiled as-if the entire compilation unit had `-O0`. At `-O0`, Clang attaches `optnone` to every function, implying that this e

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-25 Thread via cfe-commits
dyung wrote: > Hi @dyung. > > The observed difference is due to the FP contraction turned off if optnone is > specified. In O0 this optimization is still applied. As a result, the > function with optnone contains separate fadd and fmul, while without this > attribute the function contains com

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-25 Thread Serge Pavlov via cfe-commits
spavloff wrote: Hi @dyung. The observed difference is due to the FP contraction turned off if optnone is specified. In O0 this optimization is still applied. As a result, the function with optnone contains separate fadd and fmul, while without this attribute the function contains combined ope

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-25 Thread via cfe-commits
dyung wrote: Hi, we have an internal test that checks that compiling with and without optnone at O0 does not change the code generated by the compiler, and one of the tests we have did change which I bisected back to your change. The test consists of the following code: ```c++ #include exter

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-23 Thread Serge Pavlov via cfe-commits
spavloff wrote: Thanks! > Is there any existing bookkeeping we no longer need to do if we're going to > have this RAII object in scope during function parsing? It seems handling fast-math is the only case that prevented using this RAII object. https://github.com/llvm/llvm-project/pull/85605

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-23 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff closed https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-22 Thread John McCall via cfe-commits
https://github.com/rjmccall approved this pull request. This seems fine. Is there any existing bookkeeping we no longer need to do if we're going to have this RAII object in scope during function parsing? https://github.com/llvm/llvm-project/pull/85605 _

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-22 Thread Serge Pavlov via cfe-commits
spavloff wrote: A little about the significance of this fix. To implement pragma FENV_ROUND, we need to apply the FP options stored in the instance of CompoundStmt to the builder object, so that it uses the specified rounding mode. It can be done using the class CGFPOptionsRAII. However in thi

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-15 Thread Serge Pavlov via cfe-commits
spavloff wrote: Ping. https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-04-15 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/85605 >From 07e171e0566ab584299a57c210106bb8220c6261 Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 18 Mar 2024 13:20:15 +0700 Subject: [PATCH 1/4] [clang] Set correct FPOptions if attribute 'optnone' present

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-23 Thread via cfe-commits
github-actions[bot] wrote: :white_check_mark: With the latest revision this PR passed the Python code formatter. https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/m

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-23 Thread via cfe-commits
github-actions[bot] wrote: :white_check_mark: With the latest revision this PR passed the C/C++ code formatter. https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/ma

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-23 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/85605 >From 5049e0209e240f0f8a3ccb6e248d55d1480b7bad Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 18 Mar 2024 13:20:15 +0700 Subject: [PATCH 1/4] [clang] Set correct FPOptions if attribute 'optnone' present

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-23 Thread Vlad Serebrennikov via cfe-commits
https://github.com/Endilll commented: `Sema.h` changes look good to me. https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-20 Thread John McCall via cfe-commits
@@ -1495,6 +1495,10 @@ Decl *Parser::ParseFunctionDefinition(ParsingDeclarator &D, return Actions.ActOnFinishFunctionBody(Res, nullptr, false); } + // Some function attributes (like OptimizeNoneAttr) affect FP options. + Sema::FPFeaturesStateRAII SaveFPFeatures(Action

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-20 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/85605 >From 5049e0209e240f0f8a3ccb6e248d55d1480b7bad Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 18 Mar 2024 13:20:15 +0700 Subject: [PATCH 1/2] [clang] Set correct FPOptions if attribute 'optnone' present

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-20 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/85605 >From 5049e0209e240f0f8a3ccb6e248d55d1480b7bad Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 18 Mar 2024 13:20:15 +0700 Subject: [PATCH 1/2] [clang] Set correct FPOptions if attribute 'optnone' present

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-19 Thread John McCall via cfe-commits
@@ -2508,6 +2508,10 @@ Decl *Parser::ParseFunctionStatementBody(Decl *Decl, ParseScope &BodyScope) { Sema::PragmaStackSentinelRAII PragmaStackSentinel(Actions, "InternalPragmaState", IsCXXMethod); + // Some function attributes (like OptimizeNoneAttr) affect FP options.

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-19 Thread John McCall via cfe-commits
https://github.com/rjmccall commented: Alright. I don't really have a problem with doing this, and this seems like basically the right approach. You're applying the attributes in the wrong place, though. https://github.com/llvm/llvm-project/pull/85605

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-19 Thread John McCall via cfe-commits
https://github.com/rjmccall edited https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-19 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff ready_for_review https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-19 Thread Serge Pavlov via cfe-commits
spavloff wrote: > optnone is a very strange attribute; it's a directive to the compiler with no > clear semantics. `fast-math` also does not have clear semantics. It is however used to express user's expectations that some assumptions are valid. `optnone` could also be treated from similar vi

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread Zahira Ammarguellat via cfe-commits
zahiraam wrote: I have uploaded your patch and compared the attributes generated from your patch and the little test case from https://github.com/llvm/llvm-project/issues/62098. The attributes generated are different. Therefore, the expected optimizations from this patch are going to be diff

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread John McCall via cfe-commits
rjmccall wrote: > > Hmm. Is there some sort of optimization in IRGen that we need to suppress > > here, or is it something in LLVM code gen? Presumably normal LLVM > > optimization passes all just skip `optnone` functions. > > The issue #62098 demonstrates such case. Okay. So if I understand

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread Serge Pavlov via cfe-commits
spavloff wrote: > Hmm. Is there some sort of optimization in IRGen that we need to suppress > here, or is it something in LLVM code gen? Presumably normal LLVM > optimization passes all just skip `optnone` functions. The issue https://github.com/llvm/llvm-project/issues/62098 demonstrates such

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff updated https://github.com/llvm/llvm-project/pull/85605 >From 5049e0209e240f0f8a3ccb6e248d55d1480b7bad Mon Sep 17 00:00:00 2001 From: Serge Pavlov Date: Mon, 18 Mar 2024 13:20:15 +0700 Subject: [PATCH] [clang] Set correct FPOptions if attribute 'optnone' presents At

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff converted_to_draft https://github.com/llvm/llvm-project/pull/85605 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-18 Thread John McCall via cfe-commits
rjmccall wrote: Hmm. Is there some sort of optimization in IRGen that we need to suppress here, or is it something in LLVM code gen? Presumably normal LLVM optimization passes all just skip `optnone` functions. Mostly I'm wondering how far we're expected to go with `optnone`. https://github

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-17 Thread via cfe-commits
llvmbot wrote: @llvm/pr-subscribers-clang Author: Serge Pavlov (spavloff) Changes Attribute `optnone` must turn off all optimizations including fast-math ones. Actually AST nodes in the 'optnone' function still had fast-math flags. This change implements fixing FP options before function

[clang] [clang] Set correct FPOptions if attribute 'optnone' presents (PR #85605)

2024-03-17 Thread Serge Pavlov via cfe-commits
https://github.com/spavloff created https://github.com/llvm/llvm-project/pull/85605 Attribute `optnone` must turn off all optimizations including fast-math ones. Actually AST nodes in the 'optnone' function still had fast-math flags. This change implements fixing FP options before function bod