[clang] [Clang][CodeGen] Respect FP pragma options for fneg and calls (PR #212141)
Shivam Gupta via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 4 01:03:34 PDT 2026
================
@@ -682,6 +682,12 @@ class ScalarExprEmitter
if (E->getCallReturnType(CGF.getContext())->isReferenceType())
return EmitLoadOfLValue(E);
+ std::optional<CodeGenFunction::CGFPOptionsRAII> FPOptsRAII;
+ const FunctionDecl *FD = E->getDirectCallee();
+ bool IsBuiltin = FD && FD->getBuiltinID() != 0;
----------------
xgupta wrote:
I see two builtins test case failed without excluding builtins -
```
/CodeGen/AArch64/v8.2a-neon-intrinsics-constrained.c
# executed command: /home/shivam/llvm-project/build/bin/opt -S -passes=mem2reg,sroa
# executed command: /home/shivam/llvm-project/build/bin/FileCheck --check-prefix=CONSTRAINED --implicit-check-not=fpexcept.maytrap /home/shivam/llvm-project/clang/test/CodeGen/AArch64/v8.2a-neon-intrinsics-constrained.c
# .---command stderr------------
# | /home/shivam/llvm-project/clang/test/CodeGen/AArch64/v8.2a-neon-intrinsics-constrained.c:455:22: error: CONSTRAINED-NEXT: expected string not found in input
# | // CONSTRAINED-NEXT: [[TMP0:%.*]] = call half @llvm.experimental.constrained.fma.f16(half [[B]], half [[EXTRACT]], half [[A]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2]]
# | ^
# | <stdin>:213:48: note: scanning from here
# | %extract = extractelement <4 x half> %c, i32 3
# | ^
# | <stdin>:213:48: note: with "B" equal to "%b"
# | %extract = extractelement <4 x half> %c, i32 3
# | ^
# | <stdin>:213:48: note: with "EXTRACT" equal to "%extract"
# | %extract = extractelement <4 x half> %c, i32 3
# | ^
# | <stdin>:213:48: note: with "A" equal to "%a"
# | %extract = extractelement <4 x half> %c, i32 3
# | ^
# | <stdin>:213:48: note: with "ATTR2" equal to "2"
# | %extract = extractelement <4 x half> %c, i32 3
# | ^
# | <stdin>:213:48: note: pattern attempts to capture variables: "TMP0"
# | %extract = extractelement <4 x half> %c, i32 3
# | ^
# | <stdin>:214:2: note: possible intended match here
# | %0 = call half @llvm.experimental.constrained.fma.f16(half %b, half %extract, half %a, metadata !"round.tonearest", metadata !"fpexcept.strict") #2
# | ^
```
and
```
/home/shivam/llvm-project/clang/test/CodeGen/constrained-math-builtins.c
# executed command: /home/shivam/llvm-project/build/bin/FileCheck /home/shivam/llvm-project/clang/test/CodeGen/constrained-math-builtins.c
# .---command stderr------------
# | /home/shivam/llvm-project/clang/test/CodeGen/constrained-math-builtins.c:126:11: error: CHECK: expected string not found in input
# | // CHECK: call double @llvm.experimental.constrained.maxnum.f64(double %{{.*}}, double %{{.*}}, metadata !"fpexcept.strict")
# | ^
# | <stdin>:261:157: note: scanning from here
# | %159 = call half @llvm.experimental.constrained.fma.f16(half %conv68, half %conv69, half %conv70, metadata !"round.tonearest", metadata !"fpexcept.strict") #3
# | ^
# | <stdin>:266:14: note: possible intended match here
# | %162 = call nsz double @llvm.experimental.constrained.maxnum.f64(double %conv71, double %conv72, metadata !"fpexcept.strict") #3
# | ^
# |
# | Input file: <stdin>
# | Check file: /home/shivam/llvm-project/clang/test/CodeGen/constrained-math-builtins.c
# |
# | -dump-input=help explains the following input dump.
```
https://github.com/llvm/llvm-project/pull/212141
More information about the cfe-commits
mailing list