[LLVMdev] opt and llc use datalayout differently - bug?

JP corniceresearch.com-jpbonn-keyword-llvm.7c175e at corniceresearch.com
Mon Oct 3 18:25:13 PDT 2011


It appears llc gives preference to the default target datalayout whereas 
opt gives preference to the module datalayout.  Is there a reason they 
behave differently?

 From llc.cpp:
   // Add the target data from the target machine, if it exists, or the 
module.
   if (const TargetData *TD = Target.getTargetData())
     PM.add(new TargetData(*TD));
   else
     PM.add(new TargetData(&mod));

 From opt.cpp:
   // Add an appropriate TargetData instance for this module.
   TargetData *TD = 0;
   const std::string &ModuleDataLayout = M.get()->getDataLayout();
   if (!ModuleDataLayout.empty())
     TD = new TargetData(ModuleDataLayout);
   else if (!DefaultDataLayout.empty())
     TD = new TargetData(DefaultDataLayout);

   if (TD)
     Passes.add(TD);



More information about the llvm-dev mailing list