Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Possible missing libm functions, ICE on reproducible #51474

Open Quuxplusone opened 3 years ago

Quuxplusone commented 3 years ago
Bugzilla Link PR52507
Status NEW
Importance P enhancement
Reported by Jon Chesterfield (jonathanchesterfield@gmail.com)
Reported on 2021-11-15 03:12:02 -0800
Last modified on 2021-11-16 08:46:12 -0800
Version unspecified
Hardware PC Linux
CC huberjn@ornl.gov, jdoerfert@anl.gov, llvm-bugs@lists.llvm.org
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Test case reported by Wael Elwasif,

#include <omp.h>
#include <math.h>
#include <cstdio>

int main(int argc, char **argv){
     float a = 1.5;

#pragma omp target map(tofrom: a)
     {
     a = floor(a);
     }
     printf("a = %lf\n", a);
}

Reported failure mode:
clang++ -std=c++17 -lm -O3 -fopenmp -target x86_64-pc-linux-gnu
-fopenmp-targets=amdgcn-amd-amdhsa -Xopenmp-target=amdgcn-amd-amdhsa
-march=gfx90a  ./test_cmath.cpp
lld: error: undefined symbol: floorf

where changing the call to floorf, or the type to double, links OK.

However, on attempting to reproduce this, I get a segv on trunk:

https://godbolt.org/z/azsvd84fn

#3 0x0000558c2e2f6ff6 (anonymous
namespace)::AAKernelInfoFunction::changeToSPMDMode(llvm::Attributor&,
llvm::ChangeStatus&) (.constprop.1276) OpenMPOpt.cpp:0:0
 #4 0x0000558c2e2f7de7 (anonymous namespace)::AAKernelInfoFunction::manifest(llvm::Attributor&) OpenMPOpt.cpp:0:0
 #5 0x0000558c2e22181c llvm::Attributor::manifestAttributes() (/opt/compiler-explorer/clang-trunk-20211115/bin/clang-14+0x2c2181c)
 #6 0x0000558c2e22d61b llvm::Attributor::run() (/opt/compiler-explorer/clang-trunk-20211115/bin/clang-14+0x2c2d61b)
 #7 0x0000558c2e300ec8 (anonymous namespace)::OpenMPOpt::runAttributor(bool) (.part.1214) OpenMPOpt.cpp:0:0
 #8 0x0000558c2e301531 (anonymous namespace)::OpenMPOpt::run(bool) OpenMPOpt.cpp:0:0
 #9 0x0000558c2e3044d7 llvm::OpenMPOptPass::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) (/opt/compiler-explorer/clang-trunk-20211115/bin/clang-14+0x2d044d7)

Bug was reported to me ~3 days ago.
Quuxplusone commented 3 years ago
I tried to reproduce this on Spock with upstream LLVM and didn't seem to get
the error. This is weird because it seems to cause issues on spock.

$ clang++ amd.cpp -std=c++17 -lm -O3 -fopenmp -target x86_64-pc-linux-gnu -
fopenmp-targets=amdgcn-amd-amdhsa -Rpass=openmp-opt
$ env LIBOMPTARGET_INFO=1 ./a.out
Libomptarget device 0 info: Entering OpenMP kernel at amd.cpp:8:1 with 1
arguments:
Libomptarget device 0 info: tofrom(a)[4]
a = 1.000000