FuncToLLVM uses the data layout string attribute in 3 different ways:
- LowerToLLVMOptions options(&getContext(), getAnalysis<DataLayoutAnalysis>().getAtOrAbove(m));
- options.dataLayout = llvm::DataLayout(this->dataLayout);
- m->setAttr(..., this->dataLayout));
The 3rd way is unrelated to the other 2 and occurs after conversion, making it confusing.
This revision separates this post-hoc module annotation functionality into its own pass.
The convert-func-to-llvm pass loses its data-layout option and instead recovers it from
the llvm.data_layout attribute attached to the module, when present.
In the future, LowerToLLVMOptions options(&getContext(), getAnalysis<DataLayoutAnalysis>().getAtOrAbove(m)) and
options.dataLayout = llvm::DataLayout(dataLayout); should be unified.
Nit: I'd prefer explicitly mentioning llvm in the name here, e.g., set-module-llvm-datalayout.