[llvm-bugs] [Bug 48174] New: compile-time crash with target enter data on a global struct

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Nov 13 10:33:00 PST 2020


https://bugs.llvm.org/show_bug.cgi?id=48174

            Bug ID: 48174
           Summary: compile-time crash with target enter data on a global
                    struct
           Product: OpenMP
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Clang Compiler Support
          Assignee: unassignedclangbugs at nondot.org
          Reporter: bertoni at anl.gov
                CC: llvm-bugs at lists.llvm.org

We see a compile-time error with the code below. It looks like it’s an issue
with `target enter data` on part of a global struct. If we make “objects” a
local variable in main instead of a global one, then this compiles without any
problems. This is from John Tramm at Argonne National Lab.


```
> cat main.cpp 
#include <stdio.h>
#include <stdlib.h>

#pragma omp declare target
typedef struct{
  int * arr;
} MyObject;

MyObject * objects;
#pragma omp end declare target

int main(void)
{
  // if objects is declared here instead, this code compiles
  // MyObject * objects;

  // Allocate and initialize host array
  objects = (MyObject *) malloc(sizeof(MyObject));
  objects[0].arr = (int *) malloc(sizeof(int));
  objects[0].arr[0] = 1024;

#pragma omp target enter data map(to: objects[0:1])
#pragma omp target enter data map(to: objects[0].arr[0:1])

  return 0;
}

> clang++ -fopenmp -fopenmp-targets=nvptx64 main.cpp
PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash
backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /soft/compilers/llvm/master-20201029/bin/clang-12
-cc1 -triple x86_64-unknown-linux-gnu -emit-llvm-bc -emit-llvm-uselists
-disable-free -main-file-name main.cpp -mrelocation-model static
-mframe-pointer=all -fmath-errno -fno-\
rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64
-tune-cpu generic -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir
/soft/compilers/llvm/master-20201029/lib/clang/12.0.0 -c-isystem
/soft/compilers/cuda/cuda-10.0.130/in\
...
...
> clang++ --version
clang version 12.0.0
(/gpfs/jlse-fs0/users/yeluo/opt/llvm-clang/llvm-project/clang
15a68fed111f67293f56e47904dc82d661c9e4d8)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /soft/compilers/llvm/master-latest/bin
```

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20201113/2a6375ca/attachment.html>


More information about the llvm-bugs mailing list