Skip to content

[AMDGPU] Alloca is not properly promoted #66669

@shiltian

Description

@shiltian

To reproduce this issue, both LLVM and OpenMP (with target offloading at least for AMDGPU) need to be built.

The reproducer is in LLVM repo.

$ clang -fopenmp --offload-arch=gfx90a llvm-project/openmp/libomptarget/test/offloading/bug51982.c -O1 -fopenmp-target-jit -o bug51982
$ ./bug51982

At this moment the test should not fail. Extract the attachment (as-puzzle.tar.gz) and there are four files: good.ll, good.s, bad.ll, and bad.s. As their names suggest, "good" means the IR can pass the test, while "bad" means the IR causes the test failure. The only difference between the two IRs is, the bad version has an extra AS cast, and then the corresponding store to the original generic pointer is replaced with a store with the right AS. The two .s files correspond to the IRs.

In order to reproduce the runtime memory access fault, we don't need to rebuilt the reproducer.

$ llc -O1 -march=amdgcn -mcpu=gfx90a --filetype=obj good.ll -o good.o
$ export LIBOMPTARGET_JIT_REPLACEMENT_OBJECT="good.o"
$ ./bug51982

The test should pass as well. Now we compile the bad version.

$ llc -O1 -march=amdgcn -mcpu=gfx90a --filetype=obj bad.ll -o bad.o
$ export LIBOMPTARGET_JIT_REPLACEMENT_OBJECT="bad.o"
$ ./bug51982

Now you are supposed to see the memory access fault error that crashes the program.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions