0

In this commit, getDataLayout has been removed after deprecation. What's the current way of obtaining the DataLayout?

Bartek Banachewicz
  • 38,596
  • 7
  • 91
  • 135

2 Answers2

1

I suppose TargetMachine::createDataLayout() can be used.

TargetMachine.h:

const DataLayout createDataLayout() const { return DL; }

This returns a copy of the data layout rather than a const reference.

If anything this can be used more safely because the copy of the data layout remains valid after the TargetMachine object is destroyed.

If I remember correctly DataLyaout is not a particularly large class, so the copying overhead should be acceptable. Should it turn out to be a problem I recommend keeping a copy for very frequent accesses.

PaulR
  • 3,587
  • 14
  • 24
  • Wow if that's really so simple... I have to partially blame *entire* llvm.org going down where I needed it the most. I'd appreciate some more confirmation that this is indeed a drop-in replacement, otherwise you'll need to be patient until I can verify. Thanks anyway! – Bartek Banachewicz Oct 10 '17 at 18:34
1

The DataLayout should be in the module as well which is why getting it off of the TargetMachine isn't allowed anymore. I.e. basically whatever is constructing the module should know enough to construct the DataLayout.

echristo
  • 1,687
  • 10
  • 8