From 2fcd2ae8a82e222d31e37bac540eb0a40854c334 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 22 Aug 2019 14:28:05 +0000 Subject: [PATCH 1/1] Merging r369426 and r369443: ------------------------------------------------------------------------ r369426 | mstorsjo | 2019-08-20 20:58:05 +0200 (Tue, 20 Aug 2019) | 5 lines [TargetMachine] Don't try to create COFFSTUB references on windows on non-COFF This avoids spurious relocation types for windows/elf targets. Differential Revision: https://reviews.llvm.org/D66401 ------------------------------------------------------------------------ ------------------------------------------------------------------------ r369443 | mstorsjo | 2019-08-20 22:58:02 +0200 (Tue, 20 Aug 2019) | 11 lines [test] Fix tests when run on windows after SVN r369426. NFC. When running tests on windows, invoking "llc -march=" will implicitly use windows as the target os, making these tests misbehave after this change. Fix the issue by using more specific -mtriple values instead of plain -march in these tests. This should hopefully fix buildbot failures like http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9816. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_90@369654 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/TargetMachine.cpp | 8 +++++--- lib/Target/X86/X86Subtarget.cpp | 3 +++ .../AMDGPU/propagate-attributes-bitcast-function.ll | 2 +- test/CodeGen/AMDGPU/propagate-attributes-clone.ll | 2 +- test/CodeGen/AMDGPU/propagate-attributes-single-set.ll | 2 +- test/CodeGen/Hexagon/pic-jt-big.ll | 2 +- test/CodeGen/Hexagon/pic-sdata.ll | 4 ++-- test/CodeGen/SPARC/tls.ll | 18 +++++++++--------- test/CodeGen/X86/mingw-refptr.ll | 7 +++++++ 9 files changed, 30 insertions(+), 18 deletions(-) diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 634866d9357..28d783afe56 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -140,8 +140,8 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, // don't assume the variables to be DSO local unless we actually know // that for sure. This only has to be done for variables; for functions // the linker can insert thunks for calling functions from another DLL. - if (TT.isWindowsGNUEnvironment() && GV && GV->isDeclarationForLinker() && - isa(GV)) + if (TT.isWindowsGNUEnvironment() && TT.isOSBinFormatCOFF() && GV && + GV->isDeclarationForLinker() && isa(GV)) return false; // On COFF, don't mark 'extern_weak' symbols as DSO local. If these symbols @@ -154,7 +154,9 @@ bool TargetMachine::shouldAssumeDSOLocal(const Module &M, // Make an exception for windows OS in the triple: Some firmware builds use // *-win32-macho triples. This (accidentally?) produced windows relocations // without GOT tables in older clang versions; Keep this behaviour. - if (TT.isOSBinFormatCOFF() || (TT.isOSWindows() && TT.isOSBinFormatMachO())) + // Some JIT users use *-win32-elf triples; these shouldn't use GOT tables + // either. + if (TT.isOSBinFormatCOFF() || TT.isOSWindows()) return true; // Most PIC code sequences that assume that a symbol is local cannot diff --git a/lib/Target/X86/X86Subtarget.cpp b/lib/Target/X86/X86Subtarget.cpp index d5bb56603df..61fc3d05b8b 100644 --- a/lib/Target/X86/X86Subtarget.cpp +++ b/lib/Target/X86/X86Subtarget.cpp @@ -146,6 +146,9 @@ unsigned char X86Subtarget::classifyGlobalReference(const GlobalValue *GV, return X86II::MO_DLLIMPORT; return X86II::MO_COFFSTUB; } + // Some JIT users use *-win32-elf triples; these shouldn't use GOT tables. + if (isOSWindows()) + return X86II::MO_NO_FLAG; if (is64Bit()) { // ELF supports a large, truly PIC code model with non-PC relative GOT diff --git a/test/CodeGen/AMDGPU/propagate-attributes-bitcast-function.ll b/test/CodeGen/AMDGPU/propagate-attributes-bitcast-function.ll index c1d8009d08b..173bc72db85 100644 --- a/test/CodeGen/AMDGPU/propagate-attributes-bitcast-function.ll +++ b/test/CodeGen/AMDGPU/propagate-attributes-bitcast-function.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=GCN %s ; GCN: foo1: ; v_cndmask_b32_e64 v0, 0, 1, vcc_lo{{$}} diff --git a/test/CodeGen/AMDGPU/propagate-attributes-clone.ll b/test/CodeGen/AMDGPU/propagate-attributes-clone.ll index b9c36217aaa..cb0406c5b1f 100644 --- a/test/CodeGen/AMDGPU/propagate-attributes-clone.ll +++ b/test/CodeGen/AMDGPU/propagate-attributes-clone.ll @@ -1,5 +1,5 @@ ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck -check-prefix=OPT %s -; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s ; OPT: declare void @foo4() local_unnamed_addr #0 ; OPT: define internal fastcc void @foo3.2() unnamed_addr #1 diff --git a/test/CodeGen/AMDGPU/propagate-attributes-single-set.ll b/test/CodeGen/AMDGPU/propagate-attributes-single-set.ll index 34882586533..cb4283c8c67 100644 --- a/test/CodeGen/AMDGPU/propagate-attributes-single-set.ll +++ b/test/CodeGen/AMDGPU/propagate-attributes-single-set.ll @@ -1,5 +1,5 @@ ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -O1 < %s | FileCheck -check-prefix=OPT %s -; RUN: llc -march=amdgcn -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s +; RUN: llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < %s | FileCheck -check-prefix=LLC %s ; OPT: declare void @foo4() local_unnamed_addr #0 ; OPT: define void @foo3() local_unnamed_addr #1 diff --git a/test/CodeGen/Hexagon/pic-jt-big.ll b/test/CodeGen/Hexagon/pic-jt-big.ll index f5b4c2df52c..25ee04521b6 100644 --- a/test/CodeGen/Hexagon/pic-jt-big.ll +++ b/test/CodeGen/Hexagon/pic-jt-big.ll @@ -1,4 +1,4 @@ -; RUN: llc -march=hexagon -relocation-model=pic < %s | FileCheck %s +; RUN: llc -mtriple=hexagon-unknown-elf -relocation-model=pic < %s | FileCheck %s ; CHECK: r{{[0-9]+}} = add({{pc|PC}},##.LJTI{{[0-9_]+}}@PCREL) ; CHECK: r{{[0-9]+}} = memw(r{{[0-9]}}+##g0@GOT diff --git a/test/CodeGen/Hexagon/pic-sdata.ll b/test/CodeGen/Hexagon/pic-sdata.ll index 3e4dc2dc93e..446734b9ca0 100644 --- a/test/CodeGen/Hexagon/pic-sdata.ll +++ b/test/CodeGen/Hexagon/pic-sdata.ll @@ -1,5 +1,5 @@ -; RUN: llc -march=hexagon -hexagon-small-data-threshold=8 -relocation-model=static < %s | FileCheck --check-prefixes=CHECK,STATIC %s -; RUN: llc -march=hexagon -hexagon-small-data-threshold=8 -relocation-model=pic < %s | FileCheck --check-prefixes=CHECK,PIC %s +; RUN: llc -mtriple=hexagon-unknown-elf -hexagon-small-data-threshold=8 -relocation-model=static < %s | FileCheck --check-prefixes=CHECK,STATIC %s +; RUN: llc -mtriple=hexagon-unknown-elf -hexagon-small-data-threshold=8 -relocation-model=pic < %s | FileCheck --check-prefixes=CHECK,PIC %s ; If a global has a specified section, it should probably be placed in that ; section, but with PIC any accesses to globals in small data should still diff --git a/test/CodeGen/SPARC/tls.ll b/test/CodeGen/SPARC/tls.ll index 1b1af2e99c3..843769df8d9 100644 --- a/test/CodeGen/SPARC/tls.ll +++ b/test/CodeGen/SPARC/tls.ll @@ -1,12 +1,12 @@ -; RUN: llc <%s -march=sparc -relocation-model=static | FileCheck %s --check-prefix=v8abs -; RUN: llc <%s -march=sparcv9 -relocation-model=static | FileCheck %s --check-prefix=v9abs -; RUN: llc <%s -march=sparc -relocation-model=pic | FileCheck %s --check-prefix=pic -; RUN: llc <%s -march=sparcv9 -relocation-model=pic | FileCheck %s --check-prefix=pic - -; RUN: llc <%s -march=sparc -relocation-model=static -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=v8abs-obj -; RUN: llc <%s -march=sparcv9 -relocation-model=static -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=v9abs-obj -; RUN: llc <%s -march=sparc -relocation-model=pic -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=pic-obj -; RUN: llc <%s -march=sparcv9 -relocation-model=pic -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=pic-obj +; RUN: llc <%s -mtriple=sparc-unknown-linux -relocation-model=static | FileCheck %s --check-prefix=v8abs +; RUN: llc <%s -mtriple=sparcv9-unknown-linux -relocation-model=static | FileCheck %s --check-prefix=v9abs +; RUN: llc <%s -mtriple=sparc-unknown-linux -relocation-model=pic | FileCheck %s --check-prefix=pic +; RUN: llc <%s -mtriple=sparcv9-unknown-linux -relocation-model=pic | FileCheck %s --check-prefix=pic + +; RUN: llc <%s -mtriple=sparc-unknown-linux -relocation-model=static -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=v8abs-obj +; RUN: llc <%s -mtriple=sparcv9-unknown-linux -relocation-model=static -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=v9abs-obj +; RUN: llc <%s -mtriple=sparc-unknown-linux -relocation-model=pic -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=pic-obj +; RUN: llc <%s -mtriple=sparcv9-unknown-linux -relocation-model=pic -filetype=obj | llvm-readobj -r --symbols | FileCheck %s --check-prefix=pic-obj @local_symbol = internal thread_local global i32 0 @extern_symbol = external thread_local global i32 diff --git a/test/CodeGen/X86/mingw-refptr.ll b/test/CodeGen/X86/mingw-refptr.ll index 158462dd283..8d5712b2a7e 100644 --- a/test/CodeGen/X86/mingw-refptr.ll +++ b/test/CodeGen/X86/mingw-refptr.ll @@ -1,5 +1,6 @@ ; RUN: llc < %s -mtriple=x86_64-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X64 ; RUN: llc < %s -mtriple=i686-w64-mingw32 | FileCheck %s -check-prefix=CHECK-X86 +; RUN: llc < %s -mtriple=i686-w64-mingw32-none-elf | FileCheck %s -check-prefix=CHECK-X86-ELF @var = external local_unnamed_addr global i32, align 4 @dsolocalvar = external dso_local local_unnamed_addr global i32, align 4 @@ -16,6 +17,9 @@ define dso_local i32 @getVar() { ; CHECK-X86: movl .refptr._var, %eax ; CHECK-X86: movl (%eax), %eax ; CHECK-X86: retl +; CHECK-X86-ELF-LABEL: getVar: +; CHECK-X86-ELF: movl var, %eax +; CHECK-X86-ELF: retl entry: %0 = load i32, i32* @var, align 4 ret i32 %0 @@ -66,6 +70,9 @@ define dso_local i32 @getExtVar() { ; CHECK-X86: movl __imp__extvar, %eax ; CHECK-X86: movl (%eax), %eax ; CHECK-X86: retl +; CHECK-X86-ELF-LABEL: getExtVar: +; CHECK-X86-ELF: movl extvar, %eax +; CHECK-X86-ELF: retl entry: %0 = load i32, i32* @extvar, align 4 ret i32 %0 -- 2.11.0