From 852bad0a95358e5ff2b487be1c0abb0a9b25d9a8 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sun, 27 Jul 2014 23:11:06 +0000 Subject: [PATCH] Start adding some tests for the gold plugin. 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. llvm-svn: 214058 --- llvm/test/lit.cfg | 22 +++++++++++++++++++++- llvm/test/tools/gold/lit.local.cfg | 3 +++ llvm/test/tools/gold/option.ll | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 llvm/test/tools/gold/lit.local.cfg create mode 100644 llvm/test/tools/gold/option.ll diff --git a/llvm/test/lit.cfg b/llvm/test/lit.cfg index 2b9b2d9..6f2632c 100644 --- a/llvm/test/lit.cfg +++ b/llvm/test/lit.cfg @@ -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/llvm/test/tools/gold/lit.local.cfg b/llvm/test/tools/gold/lit.local.cfg new file mode 100644 index 0000000..ddcd48c --- /dev/null +++ b/llvm/test/tools/gold/lit.local.cfg @@ -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/llvm/test/tools/gold/option.ll b/llvm/test/tools/gold/option.ll new file mode 100644 index 0000000..af24d83 --- /dev/null +++ b/llvm/test/tools/gold/option.ll @@ -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 -- 2.7.4