It looks like it was possible to attach it to both for a long time, however
since llvm r217548 attaching it to just the pass manager is no longer
sufficient and causes bugs (see http://llvm.org/bugs/show_bug.cgi?id=20903).
Tested-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
static boolean
create_pass_manager(struct gallivm_state *gallivm)
{
+ char *td_str;
assert(!gallivm->passmgr);
assert(gallivm->target);
if (!gallivm->passmgr)
return FALSE;
+ // Old versions of LLVM get the DataLayout from the pass manager.
LLVMAddTargetData(gallivm->target, gallivm->passmgr);
+ // New ones from the Module.
+ td_str = LLVMCopyStringRepOfTargetData(gallivm->target);
+ LLVMSetDataLayout(gallivm->module, td_str);
+ free(td_str);
+
if ((gallivm_debug & GALLIVM_DEBUG_NO_OPT) == 0) {
/* These are the passes currently listed in llvm-c/Transforms/Scalar.h,
* but there are more on SVN.