Start adding some tests for the gold plugin.
authorRafael Espindola <rafael.espindola@gmail.com>
Sun, 27 Jul 2014 23:11:06 +0000 (23:11 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Sun, 27 Jul 2014 23:11:06 +0000 (23:11 +0000)
These are only used when the 'ld' in the path is gold and the plugin has
been built, but it is already a start to make sure we don't regress features
that cannot be tested with llvm-lto.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214058 91177308-0d34-0410-b5e6-96231b3b80d8

test/lit.cfg
test/tools/gold/lit.local.cfg [new file with mode: 0644]
test/tools/gold/option.ll [new file with mode: 0644]

index 2b9b2d9a7d05b2f137892aa02f2ddbc5114f8087..6f2632cba5dd2b6837587b7b8267a200892ef560 100644 (file)
@@ -301,8 +301,28 @@ else:
 if config.host_triple == config.target_triple:
     config.available_features.add("native")
 
-# Ask llvm-config about assertion mode.
 import subprocess
+
+def have_ld_plugin_support():
+    if not os.path.exists(os.path.join(config.llvm_shlib_dir, 'LLVMgold.so')):
+        return False
+
+    ld_cmd = subprocess.Popen(['ld', '--help'], stdout = subprocess.PIPE)
+    if not '-plugin' in ld_cmd.stdout.read():
+        return False
+    ld_cmd.wait()
+
+    ld_version = subprocess.Popen(['ld', '--version'], stdout = subprocess.PIPE)
+    if not 'GNU gold' in ld_version.stdout.read():
+        return False
+    ld_version.wait()
+
+    return True
+
+if have_ld_plugin_support():
+    config.available_features.add('ld_plugin')
+
+# Ask llvm-config about assertion mode.
 try:
     llvm_config_cmd = subprocess.Popen(
         [os.path.join(llvm_tools_dir, 'llvm-config'), '--assertion-mode'],
diff --git a/test/tools/gold/lit.local.cfg b/test/tools/gold/lit.local.cfg
new file mode 100644 (file)
index 0000000..ddcd48c
--- /dev/null
@@ -0,0 +1,3 @@
+if (not 'ld_plugin' in  config.available_features or
+    not 'X86' in config.root.targets):
+   config.unsupported = True
diff --git a/test/tools/gold/option.ll b/test/tools/gold/option.ll
new file mode 100644 (file)
index 0000000..af24d83
--- /dev/null
@@ -0,0 +1,24 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: ld -plugin %llvmshlibdir/LLVMgold.so -m elf_x86_64 \
+; RUN:    --plugin-opt=-jump-table-type=arity \
+; RUN:    --plugin-opt=-mattr=+aes \
+; RUN:    -shared %t.o -o %t2.o
+; RUN: llvm-nm %t2.o | FileCheck %s
+
+; CHECK: T __llvm_jump_instr_table_0_1
+; CHECK: T __llvm_jump_instr_table_1_1
+
+target triple = "x86_64-unknown-linux-gnu"
+define i32 @g(i32 %a) unnamed_addr jumptable {
+  ret i32 %a
+}
+
+define i32 @f() unnamed_addr jumptable {
+  ret i32 0
+}
+
+define <2 x i64> @test_avx(<2 x i64> %a0, <2 x i64> %a1) {
+  %res = call <2 x i64> @llvm.x86.aesni.aesenc(<2 x i64> %a0, <2 x i64> %a1)
+  ret <2 x i64> %res
+}
+declare <2 x i64> @llvm.x86.aesni.aesenc(<2 x i64>, <2 x i64>) nounwind readnone