This is an archive of the discontinued LLVM Phabricator instance.

[OpenCL] Fix generation of constant address space sampler in function scope
Needs ReviewPublic

Authored by Anastasia on Oct 20 2017, 10:55 AM.

Details

Reviewers
yaxunl
Summary

After the change of constant address space function scope variable in 6e34f0e ("[OpenCL] Emit function-scope variable in constant address space as static variable", 2017-05-15) a bug has been introduced that triggered unreachable during generation of samplers.

This is because sampler in global scope has not to be generated. The initialization function has to be used instead of a variable everywhere the sampler variable is being referenced.

This patch fixes the bug and adds missing test case.

Diff Detail

Event Timeline

Anastasia created this revision.Oct 20 2017, 10:55 AM
bader added a subscriber: bader.Oct 21 2017, 6:03 AM

@Anastasia, during the discussion of similar fix (https://reviews.llvm.org/D34342).

I found another bug in the CodeGen library. Do you have time to fix it too?
Here is the reproducer from the old review request:

int get_sampler_initializer(void);
kernel void foo() {
  const sampler_t const_smp_func_init = get_sampler_initializer();
}

@Anastasia, during the discussion of similar fix (https://reviews.llvm.org/D34342).

I found another bug in the CodeGen library. Do you have time to fix it too?
Here is the reproducer from the old review request:

int get_sampler_initializer(void);
kernel void foo() {
  const sampler_t const_smp_func_init = get_sampler_initializer();
}

I am getting an error currently: error: internal error: could not emit constant value "abstractly". It seems very weird and also doesn't seem to be related to constant AS change. I think this should be allowed to compile though? I can try to investigate but since I don't know the time frame yet and it doesn't seem to be related to constant AS I would prefer to do it as a separate change.

bader added a comment.Nov 14 2017, 3:16 AM

@Anastasia, during the discussion of similar fix (https://reviews.llvm.org/D34342).

I found another bug in the CodeGen library. Do you have time to fix it too?
Here is the reproducer from the old review request:

int get_sampler_initializer(void);
kernel void foo() {
  const sampler_t const_smp_func_init = get_sampler_initializer();
}

I am getting an error currently: error: internal error: could not emit constant value "abstractly". It seems very weird and also doesn't seem to be related to constant AS change. I think this should be allowed to compile though? I can try to investigate but since I don't know the time frame yet and it doesn't seem to be related to constant AS I would prefer to do it as a separate change.

I'm fine with fixing this test case later, but I assume that patch posted https://reviews.llvm.org/D34342 covers more cases. Is this version able to handle samples declared as const sampler_t const_smp?
Are you okay if I commit https://reviews.llvm.org/D34342 instead?

@Anastasia, during the discussion of similar fix (https://reviews.llvm.org/D34342).

I found another bug in the CodeGen library. Do you have time to fix it too?
Here is the reproducer from the old review request:

int get_sampler_initializer(void);
kernel void foo() {
  const sampler_t const_smp_func_init = get_sampler_initializer();
}

I am getting an error currently: error: internal error: could not emit constant value "abstractly". It seems very weird and also doesn't seem to be related to constant AS change. I think this should be allowed to compile though? I can try to investigate but since I don't know the time frame yet and it doesn't seem to be related to constant AS I would prefer to do it as a separate change.

I'm fine with fixing this test case later, but I assume that patch posted https://reviews.llvm.org/D34342 covers more cases. Is this version able to handle samples declared as const sampler_t const_smp?
Are you okay if I commit https://reviews.llvm.org/D34342 instead?

Sure. Sorry I overlooked it somehow.