diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4910,8 +4910,9 @@ } } + bool HasDefaultDataSections = Triple.isOSBinFormatXCOFF(); if (Args.hasFlag(options::OPT_fdata_sections, options::OPT_fno_data_sections, - UseSeparateSections)) { + UseSeparateSections || HasDefaultDataSections)) { CmdArgs.push_back("-fdata-sections"); } diff --git a/clang/test/Driver/aix-data-sections.c b/clang/test/Driver/aix-data-sections.c new file mode 100644 --- /dev/null +++ b/clang/test/Driver/aix-data-sections.c @@ -0,0 +1,7 @@ +// Verify -fdata-sections is the default for AIX + +// RUN: %clang -### -target powerpc-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \ +// RUN: | FileCheck %s +// RUN: %clang -### -target powerpc64-ibm-aix7.1.0.0 %s -c -o %t.o 2>&1 \ +// RUN: | FileCheck %s +// CHECK: "-fdata-sections" diff --git a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp --- a/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp +++ b/clang/tools/clang-fuzzer/handle-llvm/handle_llvm.cpp @@ -102,7 +102,8 @@ ErrorAndExit("Could not parse IR"); Triple ModuleTriple(M->getTargetTriple()); - const TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + const TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(ModuleTriple); std::string E; const Target *TheTarget = TargetRegistry::lookupTarget(codegen::getMArch(), ModuleTriple, E); @@ -165,7 +166,10 @@ builder.setEngineKind(EngineKind::JIT); builder.setMCJITMemoryManager(std::make_unique()); builder.setOptLevel(OLvl); - builder.setTargetOptions(codegen::InitTargetOptionsFromCodeGenFlags()); + + Triple ModuleTriple(M->getTargetTriple()); + builder.setTargetOptions( + codegen::InitTargetOptionsFromCodeGenFlags(ModuleTriple)); std::unique_ptr EE(builder.create()); if (!EE) diff --git a/lld/Common/TargetOptionsCommandFlags.cpp b/lld/Common/TargetOptionsCommandFlags.cpp --- a/lld/Common/TargetOptionsCommandFlags.cpp +++ b/lld/Common/TargetOptionsCommandFlags.cpp @@ -14,7 +14,7 @@ static llvm::codegen::RegisterCodeGenFlags CGF; llvm::TargetOptions lld::initTargetOptionsFromCodeGenFlags() { - return llvm::codegen::InitTargetOptionsFromCodeGenFlags(); + return llvm::codegen::InitTargetOptionsFromCodeGenFlags(llvm::Triple()); } llvm::Optional lld::getRelocModelFromCMModel() { diff --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h --- a/llvm/include/llvm/ADT/Triple.h +++ b/llvm/include/llvm/ADT/Triple.h @@ -771,6 +771,11 @@ return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment(); } + /// Tests whether the target uses -data-sections as default. + bool hasDefaultDataSections() const { + return isOSBinFormatXCOFF() || isWasm(); + } + /// @} /// @name Mutators /// @{ diff --git a/llvm/include/llvm/CodeGen/CommandFlags.h b/llvm/include/llvm/CodeGen/CommandFlags.h --- a/llvm/include/llvm/CodeGen/CommandFlags.h +++ b/llvm/include/llvm/CodeGen/CommandFlags.h @@ -14,6 +14,7 @@ #include "llvm/ADT/FloatingPointMode.h" #include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/Triple.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Intrinsics.h" #include "llvm/MC/MCTargetOptionsCommandFlags.h" @@ -134,9 +135,13 @@ llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options); -// Common utility function tightly tied to the options listed here. Initializes -// a TargetOptions object with CodeGen flags and returns it. -TargetOptions InitTargetOptionsFromCodeGenFlags(); +/// Common utility function tightly tied to the options listed here. Initializes +/// a TargetOptions object with CodeGen flags and returns it. +/// \p TheTriple is used to determine the default value for options if +/// options are not explicitly specified. If those triple dependant options +/// value do not have effect for your component, a default Triple() could be +/// passed in. +TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple); std::string getCPUStr(); diff --git a/llvm/lib/CodeGen/CommandFlags.cpp b/llvm/lib/CodeGen/CommandFlags.cpp --- a/llvm/lib/CodeGen/CommandFlags.cpp +++ b/llvm/lib/CodeGen/CommandFlags.cpp @@ -461,7 +461,8 @@ // Common utility function tightly tied to the options listed here. Initializes // a TargetOptions object with CodeGen flags and returns it. -TargetOptions codegen::InitTargetOptionsFromCodeGenFlags() { +TargetOptions +codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) { TargetOptions Options; Options.AllowFPOpFusion = getFuseFPOps(); Options.UnsafeFPMath = getEnableUnsafeFPMath(); @@ -485,7 +486,8 @@ Options.StackSymbolOrdering = getStackSymbolOrdering(); Options.UseInitArray = !getUseCtors(); Options.RelaxELFRelocations = getRelaxELFRelocations(); - Options.DataSections = getDataSections(); + Options.DataSections = + getExplicitDataSections().getValueOr(TheTriple.hasDefaultDataSections()); Options.FunctionSections = getFunctionSections(); Options.IgnoreXCOFFVisibility = getIgnoreXCOFFVisibility(); Options.BBSections = getBBSectionsMode(Options); diff --git a/llvm/test/CodeGen/PowerPC/aix-alias.ll b/llvm/test/CodeGen/PowerPC/aix-alias.ll --- a/llvm/test/CodeGen/PowerPC/aix-alias.ll +++ b/llvm/test/CodeGen/PowerPC/aix-alias.ll @@ -2,10 +2,10 @@ ; is implemnted. ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | \ +; RUN: -mattr=-altivec -data-sections=false < %s | \ ; RUN: FileCheck --check-prefix=ASM %s ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | \ +; RUN: -mattr=-altivec -data-sections=false < %s | \ ; RUN: FileCheck --check-prefix=ASM %s @var = global i32 42 diff --git a/llvm/test/CodeGen/PowerPC/aix-bytestring.ll b/llvm/test/CodeGen/PowerPC/aix-bytestring.ll --- a/llvm/test/CodeGen/PowerPC/aix-bytestring.ll +++ b/llvm/test/CodeGen/PowerPC/aix-bytestring.ll @@ -1,5 +1,5 @@ -; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s -; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | FileCheck %s @str = constant [256 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10\11\12\13\14\15\16\17\18\19\1A\1B\1C\1D\1E\1F !\22#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\7F\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F\90\91\92\93\94\95\96\97\98\99\9A\9B\9C\9D\9E\9F\A0\A1\A2\A3\A4\A5\A6\A7\A8\A9\AA\AB\AC\AD\AE\AF\B0\B1\B2\B3\B4\B5\B6\B7\B8\B9\BA\BB\BC\BD\BE\BF\C0\C1\C2\C3\C4\C5\C6\C7\C8\C9\CA\CB\CC\CD\CE\CF\D0\D1\D2\D3\D4\D5\D6\D7\D8\D9\DA\DB\DC\DD\DE\DF\E0\E1\E2\E3\E4\E5\E6\E7\E8\E9\EA\EB\EC\ED\EE\EF\F0\F1\F2\F3\F4\F5\F6\F7\F8\F9\FA\FB\FC\FD\FE\FF\00", align 1 diff --git a/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll b/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll --- a/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll +++ b/llvm/test/CodeGen/PowerPC/aix-extern-weak.ll @@ -1,15 +1,16 @@ ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s +; RUN: -mattr=-altivec -data-sections=false < %s | FileCheck --check-prefixes=COMMON,BIT32 %s ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s +; RUN: -mattr=-altivec -data-sections=false < %s | FileCheck --check-prefixes=COMMON,BIT64 %s ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s ; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o 2>&1 < %s | \ +; RUN: FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. diff --git a/llvm/test/CodeGen/PowerPC/aix-extern.ll b/llvm/test/CodeGen/PowerPC/aix-extern.ll --- a/llvm/test/CodeGen/PowerPC/aix-extern.ll +++ b/llvm/test/CodeGen/PowerPC/aix-extern.ll @@ -1,15 +1,15 @@ ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s +; RUN: -mattr=-altivec -data-sections=false < %s | FileCheck --check-prefixes=COMMON,BIT32 %s ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s +; RUN: -mattr=-altivec -data-sections=false < %s | FileCheck --check-prefixes=COMMON,BIT64 %s ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s ; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. @bar_p = global i32 (...)* @bar_ref, align 4 diff --git a/llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll b/llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll --- a/llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll +++ b/llvm/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll @@ -1,14 +1,14 @@ ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | \ +; RUN: -mattr=-altivec -data-sections=false < %s | \ ; RUN: FileCheck --check-prefix=VISIBILITY-ASM %s ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec -ignore-xcoff-visibility < %s | \ +; RUN: -mattr=-altivec -data-sections=false -ignore-xcoff-visibility < %s | \ ; RUN: FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | \ +; RUN: -mattr=-altivec -data-sections=false < %s | \ ; RUN: FileCheck --check-prefix=VISIBILITY-ASM %s ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec -ignore-xcoff-visibility < %s | \ +; RUN: -mattr=-altivec -data-sections=false -ignore-xcoff-visibility < %s | \ ; RUN: FileCheck --check-prefix=IGNOREVISIBILITY-ASM %s @foo_p = global void ()* @zoo_extern_h, align 4 diff --git a/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py b/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py --- a/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py +++ b/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py @@ -1,17 +1,17 @@ # UNSUPPORTED: expensive_checks, debug # RUN: %python %s > %t.ll -# RUN: llc -mtriple powerpc-ibm-aix-xcoff -code-model=small -mcpu=pwr4 -mattr=-altivec -O0 < %t.ll | \ +# RUN: llc -mtriple powerpc-ibm-aix-xcoff -code-model=small -data-sections=false -mcpu=pwr4 -mattr=-altivec -O0 < %t.ll | \ # RUN: FileCheck --check-prefix=ASM32 %s -# RUN: llc -mtriple powerpc64-ibm-aix-xcoff -code-model=small -mcpu=pwr4 -mattr=-altivec -O0 < %t.ll | \ +# RUN: llc -mtriple powerpc64-ibm-aix-xcoff -code-model=small -data-sections=false -mcpu=pwr4 -mattr=-altivec -O0 < %t.ll | \ # RUN: FileCheck --check-prefix=ASM64 %s -# RUN: llc -mtriple powerpc-ibm-aix-xcoff -code-model=small -mcpu=pwr4 -mattr=-altivec -O0 \ +# RUN: llc -mtriple powerpc-ibm-aix-xcoff -code-model=small -data-sections=false -mcpu=pwr4 -mattr=-altivec -O0 \ # RUN: -filetype=obj -o %t.o < %t.ll # RUN: llvm-objdump -D -r --symbol-description %t.o | FileCheck --check-prefix=DIS32 %s -# RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff \ +# RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff -data-sections=false \ # RUN: -mcpu=pwr4 -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %t.ll | \ # RUN: FileCheck --check-prefix=XCOFF64 %s # XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. diff --git a/llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll b/llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll --- a/llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll +++ b/llvm/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll @@ -1,5 +1,7 @@ -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff --relocation-model=pic < %s | FileCheck %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff --relocation-model=pic < %s | FileCheck --check-prefix=CHECK64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff \ +; RUN: --relocation-model=pic -data-sections=false < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ +; RUN: --relocation-model=pic -data-sections=false < %s | FileCheck --check-prefix=CHECK64 %s @a = common global i32 0 @b = constant i32* @a diff --git a/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll b/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll --- a/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll +++ b/llvm/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll @@ -1,5 +1,7 @@ -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefix=CHECK64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff \ +; RUN: -data-sections=false < %s | FileCheck %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ +; RUN: -data-sections=false < %s | FileCheck --check-prefix=CHECK64 %s @foo_ptr = global void (...)* @foo declare void @foo(...) diff --git a/llvm/test/CodeGen/PowerPC/aix-return55.ll b/llvm/test/CodeGen/PowerPC/aix-return55.ll --- a/llvm/test/CodeGen/PowerPC/aix-return55.ll +++ b/llvm/test/CodeGen/PowerPC/aix-return55.ll @@ -1,5 +1,5 @@ -; RUN: llc -mcpu=pwr4 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs < %s | FileCheck %s -; RUN: llc -mcpu=pwr4 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs -filetype=obj -o %t.o < %s +; RUN: llc -mcpu=pwr4 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs -data-sections=false < %s | FileCheck %s +; RUN: llc -mcpu=pwr4 -mtriple=powerpc-ibm-aix-xcoff -verify-machineinstrs -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=CHECKOBJ %s ; RUN: llvm-readobj -sections %t.o | FileCheck --check-prefix=CHECKSECT %s diff --git a/llvm/test/CodeGen/PowerPC/aix-weak.ll b/llvm/test/CodeGen/PowerPC/aix-weak.ll --- a/llvm/test/CodeGen/PowerPC/aix-weak.ll +++ b/llvm/test/CodeGen/PowerPC/aix-weak.ll @@ -1,15 +1,16 @@ ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT32 %s +; RUN: -mattr=-altivec -data-sections=false < %s | FileCheck --check-prefixes=COMMON,BIT32 %s ; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | FileCheck --check-prefixes=COMMON,BIT64 %s +; RUN: -mattr=-altivec -data-sections=false < %s | FileCheck --check-prefixes=COMMON,BIT64 %s ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj --symbols %t.o | FileCheck --check-prefix=CHECKSYM %s ; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o 2>&1 < %s | FileCheck --check-prefix=XCOFF64 %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o 2>&1 < %s | \ +; RUN: FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. @foo_weak_p = global void (...)* bitcast (void ()* @foo_ref_weak to void (...)*), align 4 diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll @@ -6,6 +6,24 @@ ; RUN: llvm-objdump -D --symbol-description %t.o | FileCheck --check-prefix=CHECKOBJ %s ; RUN: llvm-readobj -syms %t.o | FileCheck --check-prefix=CHECKSYM %s +;; Test to see if the default is correct for -data-sections on AIX. +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llvm-objdump -D --symbol-description %t.o | FileCheck --check-prefix=CHECKOBJ %s +; RUN: llvm-readobj -syms %t.o | FileCheck --check-prefix=CHECKSYM %s + +;; Test to see if the default is correct for -data-sections on AIX. +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llvm-objdump -D --symbol-description %t.o | FileCheck --check-prefix=CHECKOBJ %s +; RUN: llvm-readobj -syms %t.o | FileCheck --check-prefix=CHECKSYM %s + @ivar = local_unnamed_addr global i32 35, align 4 @const_ivar = constant i32 35, align 4 diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll @@ -1,15 +1,15 @@ ; This file tests the codegen of initialized and common variables in AIX ; assembly and XCOFF object files. -; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,CHECK32 %s -; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,CHECK64 %s +; RUN: llc -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | FileCheck --check-prefixes=CHECK,CHECK32 %s +; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | FileCheck --check-prefixes=CHECK,CHECK64 %s -; RUN: llc -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llc -mtriple powerpc-ibm-aix-xcoff -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj --section-headers --file-header %t.o | \ ; RUN: FileCheck --check-prefix=OBJ %s ; RUN: llvm-readobj --syms %t.o | FileCheck --check-prefix=SYMS %s -; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj < %s 2>&1 | \ +; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff -data-sections=false -filetype=obj < %s 2>&1 | \ ; RUN: FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll @@ -1,11 +1,14 @@ -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,ASM32 %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,ASM64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,ASM32 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,ASM64 %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj -r --expand-relocs -t %t.o | FileCheck --check-prefixes=RELOC,SYM %s -; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff -filetype=obj < %s 2>&1 | \ -; RUN: FileCheck --check-prefix=XCOFF64 %s +; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff \ +; RUN: -data-sections=false -filetype=obj < %s 2>&1 | \ +; RUN: FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. @common = common global i32 0, align 4 diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll @@ -1,8 +1,10 @@ ; This file tests the codegen of mergeable const in AIX assembly. ; This file also tests mergeable const in XCOFF object file generation. -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,CHECK32 %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,CHECK64 %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=CHECKOBJ %s ; RUN: llvm-readobj -syms %t.o | FileCheck --check-prefix=CHECKSYM %s diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll @@ -4,11 +4,11 @@ ; tests for XCOFF object files. ; RUN: llc -verify-machineinstrs -mcpu=pwr4 \ -; RUN: -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s +; RUN: -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | FileCheck %s ; RUN: llc -verify-machineinstrs -mcpu=pwr4 \ -; RUN: -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s +; RUN: -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | FileCheck %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=CHECKOBJ %s @magic16 = private unnamed_addr constant [4 x i16] [i16 264, i16 272, i16 213, i16 0], align 2 diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-reloc.ll @@ -1,4 +1,4 @@ -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -mattr=-altivec -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj --section-headers --file-header %t.o | \ ; RUN: FileCheck --check-prefix=OBJ %s ; RUN: llvm-readobj --relocs --expand-relocs %t.o | FileCheck --check-prefix=RELOC %s @@ -6,7 +6,7 @@ ; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=DIS %s ; RUN: llvm-objdump -r %t.o | FileCheck --check-prefix=DIS_REL %s -; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff -mattr=-altivec -filetype=obj < %s 2>&1 | \ +; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff -mattr=-altivec -data-sections=false -filetype=obj < %s 2>&1 | \ ; RUN: FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-rodata.ll @@ -1,13 +1,15 @@ -; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,CHECK32 %s -; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck --check-prefixes=CHECK,CHECK64 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK32 %s +; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | \ +; RUN: FileCheck --check-prefixes=CHECK,CHECK64 %s -; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff -filetype=obj -o %t.o < %s +; RUN: llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc-ibm-aix-xcoff -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-readobj --section-headers --file-header %t.o | \ ; RUN: FileCheck --check-prefix=OBJ %s ; RUN: llvm-readobj --syms %t.o | FileCheck --check-prefix=SYMS %s ; RUN: llvm-objdump -D %t.o | FileCheck --check-prefix=DIS %s -; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff -filetype=obj < %s 2>&1 | \ +; RUN: not --crash llc -verify-machineinstrs -mcpu=pwr7 -mtriple powerpc64-ibm-aix-xcoff -data-sections=false -filetype=obj < %s 2>&1 | \ ; RUN: FileCheck --check-prefix=XCOFF64 %s ; XCOFF64: LLVM ERROR: 64-bit XCOFF object files are not supported yet. diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll @@ -4,11 +4,11 @@ ;; tests for 64-bit mode are omitted. ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec < %s | \ +; RUN: -mattr=-altivec -data-sections=false < %s | \ ; RUN: FileCheck --check-prefix=ASM %s ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \ -; RUN: -mattr=-altivec -filetype=obj -o %t.o < %s +; RUN: -mattr=-altivec -data-sections=false -filetype=obj -o %t.o < %s ; RUN: llvm-objdump -D -r --symbol-description %t.o | \ ; RUN: FileCheck --check-prefix=OBJ %s diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-used.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-used.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-used.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-used.ll @@ -1,10 +1,10 @@ ;; This test verifies llc on AIX would not crash when llvm.used and ;; llvm.compiler.used is presented in the IR. -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff < %s | \ +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc-ibm-aix-xcoff -data-sections=false < %s | \ ; RUN: FileCheck %s -; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff < %s | \ +; RUN: llc -verify-machineinstrs -mcpu=pwr4 -mtriple powerpc64-ibm-aix-xcoff -data-sections=false < %s | \ ; RUN: FileCheck %s @keep_this = internal global i32 2, align 4 diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-visibility.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-visibility.ll --- a/llvm/test/CodeGen/PowerPC/aix-xcoff-visibility.ll +++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-visibility.ll @@ -1,6 +1,6 @@ -; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 -mattr=-altivec < %s | \ +; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 -mattr=-altivec -data-sections=false < %s | \ ; RUN: FileCheck %s -; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 -mattr=-altivec < %s |\ +; RUN: llc -verify-machineinstrs -mtriple powerpc64-ibm-aix-xcoff -mcpu=pwr4 -mattr=-altivec -data-sections=false < %s |\ ; RUN: FileCheck %s @b = global i32 0, align 4 diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -852,7 +852,7 @@ ThinBackend Backend; Conf.CPU = options::mcpu; - Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(); + Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); // Disable the new X86 relax relocations since gold might not support them. // FIXME: Check the gold version or add a new option to enable them. diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -426,7 +426,7 @@ TargetOptions Options; auto InitializeOptions = [&](const Triple &TheTriple) { - Options = codegen::InitTargetOptionsFromCodeGenFlags(); + Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple); Options.DisableIntegratedAS = NoIntegratedAssembler; Options.MCOptions.ShowMCEncoding = ShowMCEncoding; Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory; diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -476,7 +476,8 @@ builder.setOptLevel(getOptLevel()); - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple(TargetTriple)); if (codegen::getFloatABIForCalls() != FloatABI::Default) Options.FloatABIType = codegen::getFloatABIForCalls(); diff --git a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp --- a/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp +++ b/llvm/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp @@ -158,7 +158,7 @@ case '3': OLvl = CodeGenOpt::Aggressive; break; } - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(TheTriple); TM.reset(TheTarget->createTargetMachine( TheTriple.getTriple(), CPUStr, FeaturesStr, Options, codegen::getExplicitRelocModel(), codegen::getExplicitCodeModel(), OLvl)); diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -418,7 +418,7 @@ LLVMContext Context; Context.setDiagnosticHandler(std::make_unique(), true); - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); for (auto &Filename : InputFilenames) { ErrorOr> ModuleOrErr = LTOModule::createFromFile(Context, Filename, Options); @@ -907,7 +907,7 @@ InitializeAllAsmParsers(); // set up the TargetOptions for the machine - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); if (ListSymbolsOnly) { listSymbols(Options); diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp --- a/llvm/tools/llvm-lto2/llvm-lto2.cpp +++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp @@ -230,7 +230,7 @@ }; Conf.CPU = codegen::getMCPU(); - Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(); + Conf.Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); Conf.MAttrs = codegen::getMAttrs(); if (auto RM = codegen::getExplicitRelocModel()) Conf.RelocModel = RM.getValue(); diff --git a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp --- a/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/llvm/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -224,7 +224,8 @@ exit(1); } - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(TargetTriple); TM.reset(TheTarget->createTargetMachine( TargetTriple.getTriple(), codegen::getCPUStr(), codegen::getFeaturesStr(), Options, codegen::getExplicitRelocModel(), diff --git a/llvm/tools/lto/lto.cpp b/llvm/tools/lto/lto.cpp --- a/llvm/tools/lto/lto.cpp +++ b/llvm/tools/lto/lto.cpp @@ -218,7 +218,8 @@ lto_module_t lto_module_create(const char* path) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); ErrorOr> M = LTOModule::createFromFile(*LTOContext, StringRef(path), Options); if (!M) @@ -228,7 +229,8 @@ lto_module_t lto_module_create_from_fd(int fd, const char *path, size_t size) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); ErrorOr> M = LTOModule::createFromOpenFile( *LTOContext, fd, StringRef(path), size, Options); if (!M) @@ -241,7 +243,8 @@ size_t map_size, off_t offset) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); ErrorOr> M = LTOModule::createFromOpenFileSlice( *LTOContext, fd, StringRef(path), map_size, offset, Options); if (!M) @@ -251,7 +254,8 @@ lto_module_t lto_module_create_from_memory(const void* mem, size_t length) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); ErrorOr> M = LTOModule::createFromBuffer(*LTOContext, mem, length, Options); if (!M) @@ -263,7 +267,8 @@ size_t length, const char *path) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); ErrorOr> M = LTOModule::createFromBuffer( *LTOContext, mem, length, Options, StringRef(path)); if (!M) @@ -274,7 +279,8 @@ lto_module_t lto_module_create_in_local_context(const void *mem, size_t length, const char *path) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); // Create a local context. Ownership will be transferred to LTOModule. std::unique_ptr Context = std::make_unique(); @@ -293,7 +299,8 @@ const char *path, lto_code_gen_t cg) { lto_initialize(); - llvm::TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + llvm::TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(Triple()); ErrorOr> M = LTOModule::createFromBuffer( unwrap(cg)->getContext(), mem, length, Options, StringRef(path)); return wrap(M->release()); @@ -356,7 +363,7 @@ static lto_code_gen_t createCodeGen(bool InLocalContext) { lto_initialize(); - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); LibLTOCodeGenerator *CodeGen = InLocalContext ? new LibLTOCodeGenerator(std::make_unique()) @@ -507,7 +514,8 @@ thinlto_code_gen_t thinlto_create_codegen(void) { lto_initialize(); ThinLTOCodeGenerator *CodeGen = new ThinLTOCodeGenerator(); - CodeGen->setTargetOptions(codegen::InitTargetOptionsFromCodeGenFlags()); + CodeGen->setTargetOptions( + codegen::InitTargetOptionsFromCodeGenFlags(Triple())); CodeGen->setFreestanding(EnableFreestanding); if (OptLevel.getNumOccurrences()) { diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -698,7 +698,8 @@ Triple ModuleTriple(M->getTargetTriple()); std::string CPUStr, FeaturesStr; TargetMachine *Machine = nullptr; - const TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + const TargetOptions Options = + codegen::InitTargetOptionsFromCodeGenFlags(ModuleTriple); if (ModuleTriple.getArch()) { CPUStr = codegen::getCPUStr();