[PATCH] D37054: Require address space to be specified when creating functions (2/3)

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 07:56:36 PST 2018


bjope added a comment.

In https://reviews.llvm.org/D37054#1016555, @arichardson wrote:

> @bjope does https://reviews.llvm.org/D43645 fix the LLParser issues for you?


Thanks for the feedback @arichardson.
The https://reviews.llvm.org/D43645 solves some problems. I will do some more analysis of the problems I see in our local test suite (and hopefully I can create similar patches).

One problem I've seen is related to globals with forward reference of a function pointer (although I've not tested it with a clean top-of-tree yet):

  %fun1 = type i16 (i16) addrspace(40)
  %funptr1 = type %fun1*
  
  @fun_ptr = global %funptr1 @fun
  
  define i16 @fun(i16 %arg) addrspace(40) {
    ret i16 %arg
  }

I think that we should replace

  PointerType *PFT = PointerType::getUnqual(FT);

by

  PointerType *PFT = PointerType::get(FT, AddrSpace);

in LLParser::ParseFunctionHeader. That seems to solve the above problem at least.

Another problem I have is related to the declare construct. The test case is doing something like this:

  define %int4 @fn1 () addrspace(40) {
  ...
  %_tmp13 = call %int4 (%ptr6, %int4) bitcast ( %int4 (...)addrspace(40)* @fn2 to %int4 (%ptr6, %int4)addrspace(40)*)(%ptr6 %_tmp9, %int4 %_tmp12)
  ...
  }
  
  declare %int4 @fn2 (...);

and I get

  error: constant expression type mismatch
  %_tmp13 = call %int4 (%ptr6, %int4) bitcast ( %int4 (...)addrspace(40)* @fn2 to %int4 (%ptr6, %int4)addrspace(40)*)(%ptr6 %_tmp9, %int4 %_tmp12)
                                      ^

Maybe there should be an addrspace attribute on the declare statement? At the moment it does not help, because LLParser does not parse it.


https://reviews.llvm.org/D37054





More information about the llvm-commits mailing list