[PATCH] D106191: [clang] Option control afn flag
Bardia Mahjour via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 30 14:32:17 PDT 2021
bmahjour added inline comments.
================
Comment at: clang/include/clang/Driver/Options.td:1732-1733
NegFlag<SetFalse>>;
-def fapprox_func : Flag<["-"], "fapprox-func">, Group<f_Group>, Flags<[CC1Option, NoDriverOption]>,
- MarshallingInfoFlag<LangOpts<"ApproxFunc">>, ImpliedByAnyOf<[menable_unsafe_fp_math.KeyPath]>;
defm finite_math_only : BoolFOption<"finite-math-only",
----------------
So this option already exists and seems to behave the way we want it to. Does anyone know why it was made `NoDriverOption`?
```
> cat fp.c
#include <math.h>
void foo(float *f1, float *f2)
{
*f1 = sin(*f2) + *f1;
}
> clang -c fp.c -S -emit-llvm -mllvm -disable-llvm-optzns -O3 -Xclang -fapprox-func && grep afn fp.ll
%call = call afn double @sin(double %conv) #2
%add = fadd afn double %call, %conv1
```
Could we just expose it as a supported option and call it done. ie make it more like `fhonor_nans` below but without introducing a new function attribute:
```def fapprox_func : Flag<["-"], "fapprox-func">, Group<f_Group>;```
so that instead of having `-Xclang -fapprox-func ` in the command above we could just have `-fapprox-func `?
================
Comment at: clang/test/CodeGen/afn-flag-test.c:10
+ // CHECK-AFN: %{{.*}} = call afn double @{{.*}}exp{{.*}}(double %{{.*}})
+ // CHECK-AFN: attributes #0 ={{.*}} "approx-func-fp-math"="true" {{.*}}
+
----------------
can we avoid these attributes?
================
Comment at: clang/test/CodeGen/afn-flag-test.c:13
+ // CHECK-NO-AFN: %{{.*}} = call double @{{.*}}exp{{.*}}(double %{{.*}})
+ // CHECK-NO-AFN-NOT: attributes #0 ={{.*}} "approx-func-fp-math"="true" {{.*}}
+}
----------------
avoid attributes.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D106191/new/
https://reviews.llvm.org/D106191
More information about the cfe-commits
mailing list