[PATCH] D153907: [AIX] [TOC] Add -mtocdata/-mno-tocdata options on AIX
syzaara added inline comments. Comment at: clang/include/clang/Driver/Options.td:2955 + MarshallingInfoFlag>; +def mno_tocdata_EQ : CommaJoined<["-"], "mno-tocdata=">, + Flags<[CC1Option,TargetSpecific]>, MaskRay wrote: > If `-mtocdata=` is opt-in, the convention is to make just `-mtocdata=` > CC1Option, but clear the flag for `-mno-tocdata=`. Our situation with these options is a bit more complicated because -mno-tocdata= is not just removing the entries that were specified by -mtocdata= For example if we have: ``` -mtocdata=X -mno-tocdata=X -mtocdata=Y,Z,S ``` Then we could potentially just forward to CC1: ``` -mtocdata=Y,Z,S ``` Rather than what we currently forward: ``` -mno-tocdata -mtocdata=Y,Z,S ``` However, if we have ``` -mtocdata -mno-tocdata=Y,Z,S ``` This means all suitable variables by default will become toc-data aside from the exceptions in -mno-tocdata=Y,Z,S and we would need to forward both these options. So the way we handle it is by passing to CC1 either ``` -mtocdata -mno-tocdata= ``` or ``` -mno-tocdata -mtocdata= ``` which is the current default setting along with the exceptions that need to be applied to that default setting. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153907/new/ https://reviews.llvm.org/D153907 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D153907: [AIX] [TOC] Add -mtocdata/-mno-tocdata options on AIX
syzaara updated this revision to Diff 554461. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D153907/new/ https://reviews.llvm.org/D153907 Files: clang/docs/UsersManual.rst clang/include/clang/Basic/CodeGenOptions.h clang/include/clang/Basic/DiagnosticDriverKinds.td clang/include/clang/Driver/Options.td clang/lib/CodeGen/CGDecl.cpp clang/lib/CodeGen/Targets/PPC.cpp clang/lib/Driver/ToolChains/AIX.cpp clang/lib/Frontend/CompilerInstance.cpp clang/test/CodeGen/PowerPC/toc-data-attribute.c clang/test/CodeGen/PowerPC/toc-data-attribute.cpp clang/test/CodeGen/PowerPC/toc-data-diagnostics.c clang/test/CodeGen/PowerPC/toc-data-structs-arrays.cpp clang/test/CodeGen/toc-data.c clang/test/Driver/toc-conf.c clang/test/Driver/tocdata-cc1.c llvm/include/llvm/ADT/STLExtras.h llvm/lib/MC/MCSectionXCOFF.cpp llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp llvm/test/CodeGen/PowerPC/toc-data-large-array.ll llvm/test/CodeGen/PowerPC/toc-data-struct-array.ll Index: llvm/test/CodeGen/PowerPC/toc-data-struct-array.ll === --- /dev/null +++ llvm/test/CodeGen/PowerPC/toc-data-struct-array.ll @@ -0,0 +1,29 @@ +; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefix CHECK +; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefix CHECK + +%struct.small_struct = type { i16 } + +@a = global %struct.small_struct zeroinitializer, align 2 #0 +@b = global [2 x i16] zeroinitializer, align 2 #0 + +; Function Attrs: noinline +define i16 @foo() #1 { +entry: + %0 = load i16, ptr @a, align 2 + %1 = load i16, ptr @b, align 2 + %add = add nsw i16 %0, %1 + ret i16 %add +} + +attributes #0 = { "toc-data" } +attributes #1 = { noinline } + +; CHECK: .toc +; CHECK-NEXT: .csect a[TD],2 +; CHECK-NEXT: .globla[TD] # @a +; CHECK-NEXT: .align1 +; CHECK-NEXT: .space2 +; CHECK-NEXT: .csect b[TD],2 +; CHECK-NEXT: .globlb[TD] # @b +; CHECK-NEXT: .align1 +; CHECK-NEXT: .space4 Index: llvm/test/CodeGen/PowerPC/toc-data-large-array.ll === --- /dev/null +++ llvm/test/CodeGen/PowerPC/toc-data-large-array.ll @@ -0,0 +1,16 @@ +; RUN: not --crash llc -mtriple powerpc-ibm-aix-xcoff < %s 2>&1 | FileCheck %s --check-prefix CHECK-ERROR +; RUN: not --crash llc -mtriple powerpc64-ibm-aix-xcoff < %s 2>&1 | FileCheck %s --check-prefix CHECK-ERROR + +@a = global [5 x i16] zeroinitializer, align 2 #0 + +; Function Attrs: noinline +define i16 @foo() #1 { +entry: + %0 = load i16, ptr @a, align 2 + ret i16 %0 +} + +attributes #0 = { "toc-data" } +attributes #1 = { noinline } + +; CHECK-ERROR: LLVM ERROR: A GlobalVariable with size larger than a TOC entry is not currently supported by the toc data transformation. Index: llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp === --- llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -533,21 +533,11 @@ assert(GVType->isSized() && "A GlobalVariable's size must be known to be " "supported by the toc data transformation."); - if (GVType->isVectorTy()) -report_fatal_error("A GlobalVariable of Vector type is not currently " - "supported by the toc data transformation."); - - if (GVType->isArrayTy()) -report_fatal_error("A GlobalVariable of Array type is not currently " - "supported by the toc data transformation."); - - if (GVType->isStructTy()) -report_fatal_error("A GlobalVariable of Struct type is not currently " - "supported by the toc data transformation."); - - assert(GVType->getPrimitiveSizeInBits() <= PointerSize * 8 && - "A GlobalVariable with size larger than a TOC entry is not currently " - "supported by the toc data transformation."); + if (GV->getParent()->getDataLayout().getTypeSizeInBits(GVType) > + PointerSize * 8) +report_fatal_error( +"A GlobalVariable with size larger than a TOC entry is not currently " +"supported by the toc data transformation."); if (GV->hasLocalLinkage() || GV->hasPrivateLinkage()) report_fatal_error("A GlobalVariable with private or local linkage is not " Index: llvm/lib/MC/MCSectionXCOFF.cpp === --- llvm/lib/MC/MCSectionXCOFF.cpp +++ llvm/lib/MC/MCSectionXCOFF.cpp @@ -82,8 +82,7 @@ } if (isCsect() && getMappingClass() == XCOFF::XMC_TD) { -assert((getKind().isBSSExtern() || getKind().isBSSLocal()) && - "Unexepected section kind for toc-data"); +assert(getKind().isBSS() && "Unexepected section kind for toc-data"); printCsectDirective(OS); return; } Index: llvm/include/llvm/ADT/STLExtras.h
[PATCH] D39376: [PowerPC] Add implementation for -msave-toc-indirect option - clang portion
syzaara created this revision. Add clang option -msave-toc-indirect for PowerPC. https://reviews.llvm.org/D39376 Files: include/clang/Driver/Options.td test/Driver/ppc-features.cpp Index: test/Driver/ppc-features.cpp === --- test/Driver/ppc-features.cpp +++ test/Driver/ppc-features.cpp @@ -134,6 +134,9 @@ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-vsx -mvsx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-VSX %s // CHECK-VSX: "-target-feature" "+vsx" +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -msave-toc-indirect -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-TOC %s +// CHECK-TOC: "-target-feature" "+save-toc-indirect" + // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-htm -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOHTM %s // CHECK-NOHTM: "-target-feature" "-htm" Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1904,6 +1904,7 @@ def maltivec : Flag<["-"], "maltivec">, Group; def mno_altivec : Flag<["-"], "mno-altivec">, Group; def mvsx : Flag<["-"], "mvsx">, Group; +def msave_toc_indirect : Flag<["-"], "msave-toc-indirect">, Group; def mno_vsx : Flag<["-"], "mno-vsx">, Group; def mpower8_vector : Flag<["-"], "mpower8-vector">, Group; Index: test/Driver/ppc-features.cpp === --- test/Driver/ppc-features.cpp +++ test/Driver/ppc-features.cpp @@ -134,6 +134,9 @@ // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-vsx -mvsx -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-VSX %s // CHECK-VSX: "-target-feature" "+vsx" +// RUN: %clang -target powerpc64-unknown-linux-gnu %s -msave-toc-indirect -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-TOC %s +// CHECK-TOC: "-target-feature" "+save-toc-indirect" + // RUN: %clang -target powerpc64-unknown-linux-gnu %s -mno-htm -### -o %t.o 2>&1 | FileCheck -check-prefix=CHECK-NOHTM %s // CHECK-NOHTM: "-target-feature" "-htm" Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1904,6 +1904,7 @@ def maltivec : Flag<["-"], "maltivec">, Group; def mno_altivec : Flag<["-"], "mno-altivec">, Group; def mvsx : Flag<["-"], "mvsx">, Group; +def msave_toc_indirect : Flag<["-"], "msave-toc-indirect">, Group; def mno_vsx : Flag<["-"], "mno-vsx">, Group; def mpower8_vector : Flag<["-"], "mpower8-vector">, Group; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits