[PATCH] D36916: Associate functions with address spaces

Dylan McKay via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 21 11:57:18 PDT 2017


dylanmckay added inline comments.


================
Comment at: include/llvm/IR/DerivedTypes.h:106
+  FunctionType(Type *Result, ArrayRef<Type*> Params, bool IsVarArgs,
+               unsigned AddrSpace);
 
----------------
theraven wrote:
> pcc wrote:
> > I don't understand why this needs to be part of the function type. It seems to me that this ought to work in the same way as for global variables, i.e. function takes an address space at construction time which is used to create its pointer type; address space is queried by querying address space on the pointer type.
> Indeed.  One of the big differences between the C and LLVM models is that C address spaces are properties of objects whereas LLVM address spaces are properties of pointers.  The LLVM model is cleaner, but associating an address space with a function would be inconsistent.  
I originally implemented this in the way you all are mentioning, but I had to backtrack when I saw these two lines

```
FunctionType *FT =
    FunctionType::get(RetType, ParamTypeList, isVarArg, AddrSpace);
  PointerType *PFT = PointerType::getUnqual(FT);
```

I just read up and realised that `getUnqual` will always use the generic address space, and so this is not relevant.

I will move the field to `Function`, similar to the way it is done for global variables.


https://reviews.llvm.org/D36916





More information about the llvm-commits mailing list