mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-21 18:29:46 +00:00
Add some command line options for twiddling the default data layout
used by opt when a module doesn't specify one. Patch from Kenneth Uildriks! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84814 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
8000c6c535
commit
d331cb3fde
@ -127,6 +127,15 @@ QuietA("quiet", cl::desc("Alias for -q"), cl::aliasopt(Quiet));
|
||||
static cl::opt<bool>
|
||||
AnalyzeOnly("analyze", cl::desc("Only perform analysis, no optimization"));
|
||||
|
||||
static cl::opt<std::string>
|
||||
DefaultDataLayout("default-data-layout",
|
||||
cl::desc("data layout string to use if not specified by module"),
|
||||
cl::value_desc("layout-string"), cl::init(""));
|
||||
|
||||
static cl::opt<bool>
|
||||
NoDefaultDataLayout("no-default-data-layout",
|
||||
cl::desc("no data layout assumptions unless module specifies data layout"));
|
||||
|
||||
// ---------- Define Printers for module and function passes ------------
|
||||
namespace {
|
||||
|
||||
@ -388,12 +397,21 @@ int main(int argc, char **argv) {
|
||||
PassManager Passes;
|
||||
|
||||
// Add an appropriate TargetData instance for this module...
|
||||
Passes.add(new TargetData(M.get()));
|
||||
TargetData *TD = 0;
|
||||
const std::string &ModuleDataLayout = M.get()->getDataLayout();
|
||||
if (!ModuleDataLayout.empty())
|
||||
TD = new TargetData(ModuleDataLayout);
|
||||
else if (!NoDefaultDataLayout)
|
||||
TD = new TargetData(DefaultDataLayout);
|
||||
|
||||
if (TD)
|
||||
Passes.add(TD);
|
||||
|
||||
FunctionPassManager *FPasses = NULL;
|
||||
if (OptLevelO1 || OptLevelO2 || OptLevelO3) {
|
||||
FPasses = new FunctionPassManager(new ExistingModuleProvider(M.get()));
|
||||
FPasses->add(new TargetData(M.get()));
|
||||
if (TD)
|
||||
FPasses->add(new TargetData(*TD));
|
||||
}
|
||||
|
||||
// If the -strip-debug command line option was specified, add it. If
|
||||
|
Loading…
Reference in New Issue
Block a user