From d77cbcb13060ac41c851f583591c24c67fd59e6a Mon Sep 17 00:00:00 2001 From: jasonliu Date: Wed, 14 Oct 2020 15:55:55 +0000 Subject: [PATCH] [AIX] Turn -fdata-sections on by default in Clang Summary: This patch does the following: 1. Make InitTargetOptionsFromCodeGenFlags() accepts Triple as a parameter, because some options' default value is triple dependant. 2. DataSections is turned on by default on AIX for llc. 3. Test cases change accordingly because of the default behaviour change. 4. Clang Driver passes in -fdata-sections by default on AIX. Reviewed By: MaskRay, DiggerLin Differential Revision: https://reviews.llvm.org/D88737 --- include/llvm/ADT/Triple.h | 5 ++++ include/llvm/CodeGen/CommandFlags.h | 11 +++++--- lib/CodeGen/CommandFlags.cpp | 6 +++-- test/CodeGen/PowerPC/aix-alias.ll | 4 +-- test/CodeGen/PowerPC/aix-bytestring.ll | 4 +-- test/CodeGen/PowerPC/aix-extern-weak.ll | 9 ++++--- test/CodeGen/PowerPC/aix-extern.ll | 8 +++--- .../PowerPC/aix-ignore-xcoff-visibility.ll | 8 +++--- test/CodeGen/PowerPC/aix-overflow-toc.py | 8 +++--- .../PowerPC/aix-readonly-with-relocation.ll | 6 +++-- .../PowerPC/aix-reference-func-addr-const.ll | 6 +++-- test/CodeGen/PowerPC/aix-return55.ll | 4 +-- test/CodeGen/PowerPC/aix-weak.ll | 9 ++++--- .../PowerPC/aix-xcoff-data-sections.ll | 18 +++++++++++++ test/CodeGen/PowerPC/aix-xcoff-data.ll | 8 +++--- test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll | 13 ++++++---- .../PowerPC/aix-xcoff-mergeable-const.ll | 8 +++--- .../PowerPC/aix-xcoff-mergeable-str.ll | 6 ++--- test/CodeGen/PowerPC/aix-xcoff-reloc.ll | 4 +-- test/CodeGen/PowerPC/aix-xcoff-rodata.ll | 10 ++++--- .../PowerPC/aix-xcoff-symbol-rename.ll | 4 +-- test/CodeGen/PowerPC/aix-xcoff-used.ll | 4 +-- test/CodeGen/PowerPC/aix-xcoff-visibility.ll | 4 +-- tools/gold/gold-plugin.cpp | 2 +- tools/llc/llc.cpp | 2 +- tools/lli/lli.cpp | 3 ++- tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp | 2 +- tools/llvm-lto/llvm-lto.cpp | 4 +-- tools/llvm-lto2/llvm-lto2.cpp | 2 +- tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp | 3 ++- tools/lto/lto.cpp | 26 ++++++++++++------- tools/opt/opt.cpp | 3 ++- 32 files changed, 134 insertions(+), 80 deletions(-) diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index b67da41f30c..57b283c3c84 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -771,6 +771,11 @@ public: return isAndroid() || isOSOpenBSD() || isWindowsCygwinEnvironment(); } + /// Tests whether the target uses -data-sections as default. + bool hasDefaultDataSections() const { + return isOSBinFormatXCOFF() || isWasm(); + } + /// @} /// @name Mutators /// @{ diff --git a/include/llvm/CodeGen/CommandFlags.h b/include/llvm/CodeGen/CommandFlags.h index e724abafcb2..b58fe2d43cd 100644 --- a/include/llvm/CodeGen/CommandFlags.h +++ b/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 @@ struct RegisterCodeGenFlags { 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/lib/CodeGen/CommandFlags.cpp b/lib/CodeGen/CommandFlags.cpp index 078fee67365..a9093586d69 100644 --- a/lib/CodeGen/CommandFlags.cpp +++ b/lib/CodeGen/CommandFlags.cpp @@ -461,7 +461,8 @@ codegen::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 codegen::InitTargetOptionsFromCodeGenFlags() { +TargetOptions +codegen::InitTargetOptionsFromCodeGenFlags(const Triple &TheTriple) { TargetOptions Options; Options.AllowFPOpFusion = getFuseFPOps(); Options.UnsafeFPMath = getEnableUnsafeFPMath(); @@ -485,7 +486,8 @@ TargetOptions codegen::InitTargetOptionsFromCodeGenFlags() { 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/test/CodeGen/PowerPC/aix-alias.ll b/test/CodeGen/PowerPC/aix-alias.ll index 1fdd7c90f5a..eef6dbd75e1 100644 --- a/test/CodeGen/PowerPC/aix-alias.ll +++ b/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/test/CodeGen/PowerPC/aix-bytestring.ll b/test/CodeGen/PowerPC/aix-bytestring.ll index 443c019c9e3..f381335aad5 100644 --- a/test/CodeGen/PowerPC/aix-bytestring.ll +++ b/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/test/CodeGen/PowerPC/aix-extern-weak.ll b/test/CodeGen/PowerPC/aix-extern-weak.ll index 0b38ba8b23b..07f0e3d882b 100644 --- a/test/CodeGen/PowerPC/aix-extern-weak.ll +++ b/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/test/CodeGen/PowerPC/aix-extern.ll b/test/CodeGen/PowerPC/aix-extern.ll index 0146a4745ef..fbdd48351aa 100644 --- a/test/CodeGen/PowerPC/aix-extern.ll +++ b/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/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll b/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll index 54eafd39c79..c72cc2fc57d 100644 --- a/test/CodeGen/PowerPC/aix-ignore-xcoff-visibility.ll +++ b/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/test/CodeGen/PowerPC/aix-overflow-toc.py b/test/CodeGen/PowerPC/aix-overflow-toc.py index 85776b76094..174164b119d 100644 --- a/test/CodeGen/PowerPC/aix-overflow-toc.py +++ b/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/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll b/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll index 115938ad6b7..bfc1ca8a930 100644 --- a/test/CodeGen/PowerPC/aix-readonly-with-relocation.ll +++ b/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/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll b/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll index 50c08fc0b6a..72661bf5379 100644 --- a/test/CodeGen/PowerPC/aix-reference-func-addr-const.ll +++ b/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/test/CodeGen/PowerPC/aix-return55.ll b/test/CodeGen/PowerPC/aix-return55.ll index a18a211b46b..344437c66f9 100644 --- a/test/CodeGen/PowerPC/aix-return55.ll +++ b/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/test/CodeGen/PowerPC/aix-weak.ll b/test/CodeGen/PowerPC/aix-weak.ll index 4e73a838242..a056ccfdff0 100644 --- a/test/CodeGen/PowerPC/aix-weak.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll b/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll index 264c7b49786..3d72a4bcfcb 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-data-sections.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-data.ll b/test/CodeGen/PowerPC/aix-xcoff-data.ll index 88c8b08bdb5..59492f60a78 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-data.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll b/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll index a7db7f8fdf8..54b915d3ccf 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-lower-comm.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll b/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll index 312ddbf7393..0cf2022d2f2 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-mergeable-const.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll b/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll index 0d29857fd15..f4fe2744c9c 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-mergeable-str.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-reloc.ll b/test/CodeGen/PowerPC/aix-xcoff-reloc.ll index 3aa1f863685..f270219d0df 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-reloc.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-rodata.ll b/test/CodeGen/PowerPC/aix-xcoff-rodata.ll index a7bb0189664..5ad88445ac1 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-rodata.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll b/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll index f486fc9524c..93211addef5 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-symbol-rename.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-used.ll b/test/CodeGen/PowerPC/aix-xcoff-used.ll index dd0812f3d8c..258a382d71c 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-used.ll +++ b/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/test/CodeGen/PowerPC/aix-xcoff-visibility.ll b/test/CodeGen/PowerPC/aix-xcoff-visibility.ll index 04c2e0cfe22..1875170addc 100644 --- a/test/CodeGen/PowerPC/aix-xcoff-visibility.ll +++ b/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/tools/gold/gold-plugin.cpp b/tools/gold/gold-plugin.cpp index 0124e0a93e8..ebd08c4038c 100644 --- a/tools/gold/gold-plugin.cpp +++ b/tools/gold/gold-plugin.cpp @@ -852,7 +852,7 @@ static std::unique_ptr createLTO(IndexWriteCallback OnIndexWrite, 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/tools/llc/llc.cpp b/tools/llc/llc.cpp index b58e8486db8..80db55e5e78 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -426,7 +426,7 @@ static int compileModule(char **argv, LLVMContext &Context) { 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/tools/lli/lli.cpp b/tools/lli/lli.cpp index b93f77dae68..5e5e82e544a 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -476,7 +476,8 @@ int main(int argc, char **argv, char * const *envp) { 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/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp b/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp index a93a04f65aa..1d93299b9e8 100644 --- a/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp +++ b/tools/llvm-isel-fuzzer/llvm-isel-fuzzer.cpp @@ -158,7 +158,7 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize(int *argc, 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/tools/llvm-lto/llvm-lto.cpp b/tools/llvm-lto/llvm-lto.cpp index 164254756f4..b86c6573592 100644 --- a/tools/llvm-lto/llvm-lto.cpp +++ b/tools/llvm-lto/llvm-lto.cpp @@ -418,7 +418,7 @@ static void printMachOCPUOnly() { 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 @@ int main(int argc, char **argv) { InitializeAllAsmParsers(); // set up the TargetOptions for the machine - TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(); + TargetOptions Options = codegen::InitTargetOptionsFromCodeGenFlags(Triple()); if (ListSymbolsOnly) { listSymbols(Options); diff --git a/tools/llvm-lto2/llvm-lto2.cpp b/tools/llvm-lto2/llvm-lto2.cpp index 9dd1f13bd3c..473bc15eb5b 100644 --- a/tools/llvm-lto2/llvm-lto2.cpp +++ b/tools/llvm-lto2/llvm-lto2.cpp @@ -230,7 +230,7 @@ static int run(int argc, char **argv) { }; 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/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp b/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp index 40aac7c3a28..be60ce906eb 100644 --- a/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp +++ b/tools/llvm-opt-fuzzer/llvm-opt-fuzzer.cpp @@ -224,7 +224,8 @@ extern "C" LLVM_ATTRIBUTE_USED int LLVMFuzzerInitialize( 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/tools/lto/lto.cpp b/tools/lto/lto.cpp index ea44430f66a..0ea7b4942e3 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -218,7 +218,8 @@ lto_module_is_object_file_in_memory_for_target(const void* mem, 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(const char* path) { 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 @@ lto_module_t lto_module_create_from_fd_at_offset(int fd, const char *path, 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_fd_at_offset(int fd, const char *path, 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 @@ lto_module_t lto_module_create_from_memory_with_path(const void* mem, 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_from_memory_with_path(const void* mem, 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 @@ lto_module_t lto_module_create_in_codegen_context(const void *mem, 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 @@ void lto_codegen_set_diagnostic_handler(lto_code_gen_t cg, 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 @@ void lto_codegen_set_should_embed_uselists(lto_code_gen_t cg, 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/tools/opt/opt.cpp b/tools/opt/opt.cpp index 9f03606a738..3ba02dc8a5c 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -698,7 +698,8 @@ int main(int argc, char **argv) { 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();