Handle ctor/init_array initialization.
authorSid Manning <sidneym@codeaurora.org>
Mon, 3 Nov 2014 14:56:05 +0000 (14:56 +0000)
committerSid Manning <sidneym@codeaurora.org>
Mon, 3 Nov 2014 14:56:05 +0000 (14:56 +0000)
Hexagon was not calling InitializeELF and could not select between
ctors and init_array.

Phabricator revision: http://reviews.llvm.org/D6061

llvm-svn: 221156

llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp
llvm/test/CodeGen/Hexagon/ctor.ll [new file with mode: 0644]

index e61507f..f4ab5e2 100644 (file)
@@ -31,7 +31,7 @@ static cl::opt<int> SmallDataThreshold("hexagon-small-data-threshold",
 void HexagonTargetObjectFile::Initialize(MCContext &Ctx,
                                          const TargetMachine &TM) {
   TargetLoweringObjectFileELF::Initialize(Ctx, TM);
-
+  InitializeELF(TM.Options.UseInitArray);
 
   SmallDataSection =
     getContext().getELFSection(".sdata", ELF::SHT_PROGBITS,
diff --git a/llvm/test/CodeGen/Hexagon/ctor.ll b/llvm/test/CodeGen/Hexagon/ctor.ll
new file mode 100644 (file)
index 0000000..2e2fc51
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llc -march=hexagon < %s  | FileCheck -check-prefix=INITARRAY %s
+; RUN: llc -march=hexagon < %s  -use-ctors | FileCheck -check-prefix=CTOR %s
+
+@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_P10066.ii, i8* null }]
+define internal void @_GLOBAL__sub_I_P10066.ii() {
+entry:
+  ret void
+}
+
+;CTOR: .section        .ctors
+;CTOR-NOT:  section    .init_array
+
+;INITARRAY: section    .init_array
+;INITARRAY-NOT: .section       .ctors