[PATCH] D46147: [NVPTX] Added a feature to use short pointers for const/local/shared AS.

Artem Belevich via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 27 15:08:18 PDT 2018


tra added a comment.

In https://reviews.llvm.org/D46147#1081662, @arsenm wrote:

> The subtarget is a function level property. The pointer size / datalayout is a module property and can't be different between functions. If you have multiple functions with different pointer sizes in a module (or no functions at all), then what pointer size ends up used for a global? The global itself has a size, and any ConstantExpr pointers in its initializer will also need to have a size.


I think I see. So, someone could add "target-attributes" to a function and that may potentially override the features. It does not harm us in this case as we only set datalayout once when it's called during creation NVPTXTargetMachine so only the features supplied on command line will be affected. That said, I do see your point that subtarget is not the right place for this option. After a bit of digging I've found a curious comment in LLVMTargetMachine, so this approach is both used in other places and considered problemetic.

  // FIXME: Having an MCSubtargetInfo on the target machine is a hack due
  // to some backends having subtarget feature dependent module level
  // code generation. This is similar to the hack in the AsmPrinter for
  // module level assembly etc.
  STI = TheTarget.createMCSubtargetInfo(getTargetTriple().str(), getTargetCPU(),
                                        getTargetFeatureString());

One way out of this is to add a separate command-line option to control this. Is there a better way to do it?


https://reviews.llvm.org/D46147





More information about the llvm-commits mailing list