Page MenuHomePhabricator

[clang][patch][FPEnv} Initialization of C++ globals not strictfp aware
Needs ReviewPublic

Authored by mibintc on May 12 2021, 11:08 AM.

Details

Summary

In the proposed patch https://reviews.llvm.org/D81178 @kpn pointed out that the global variable initialization functions didn't have the "strictfp" metadata set correctly, and @rjmccall said that there was buggy code in SetFPModel and StartFunction, this patch is to solve those problems. When Sema creates a FunctionDecl, it sets the FunctionDeclBits.UsesFPIntrin to "true" if the lexical FP settings (i.e. a combination of command line options and #pragma float_control settings) correspond to ConstrainedFP mode. That bit is used when CodeGen starts codegen for a llvm function, and it translates into the "strictfp" function attribute.

Diff Detail

Unit TestsFailed

TimeTest
930 msx64 debian > libomp.lock::omp_init_lock.c
Script: -- : 'RUN: at line 1'; /mnt/disks/ssd0/agent/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -I /mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test -I /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/src -L /mnt/disks/ssd0/agent/llvm-project/build/lib -I /mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/ompt /mnt/disks/ssd0/agent/llvm-project/openmp/runtime/test/lock/omp_init_lock.c -o /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/test/lock/Output/omp_init_lock.c.tmp -lm -latomic && /mnt/disks/ssd0/agent/llvm-project/build/projects/openmp/runtime/test/lock/Output/omp_init_lock.c.tmp

Event Timeline

mibintc created this revision.May 12 2021, 11:08 AM
mibintc requested review of this revision.May 12 2021, 11:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 12 2021, 11:08 AM
mibintc added inline comments.May 12 2021, 11:13 AM
clang/lib/CodeGen/CodeGenFunction.cpp
700

there's a whole bunch of places in this func that creates FD, I changed them into a single place. hope that's OK, or i could pull it out as a pre-patch if you prefer

aaron.ballman added inline comments.
clang/include/clang/AST/DeclCXX.h
2685

Formatting looks off here.

2729

If ctors and cxxmethods get the parameter, why not conversion operators?

clang/lib/Sema/SemaLambda.cpp
395

Should lambdas pick up the same fp constraints as the function defining the lambda?