This is an archive of the discontinued LLVM Phabricator instance.

[TargetMachine] Don't try to create COFFSTUB references on windows on non-COFF
ClosedPublic

Authored by mstorsjo on Aug 18 2019, 2:45 PM.

Details

Summary

This avoids spurious relocation types for windows/elf targets, as reported in D51590.

@hans, once settled, I think this is a bugfix important enough for 9.0 if it still can make it, as it currently is breaking Julia users.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Aug 18 2019, 2:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 18 2019, 2:45 PM
rnk added inline comments.Aug 19 2019, 2:20 PM
lib/Target/TargetMachine.cpp
148 ↗(On Diff #215800)

Maybe this should be relaxed to just isCOFF || isWindows, rather than enumerating other formats.

lib/Target/X86/X86Subtarget.cpp
149 ↗(On Diff #215800)

This seems like it's trivially dead (Windows must use COFF, right? Actually, no), so I think it's worth a comment.

mstorsjo marked an inline comment as done.Aug 19 2019, 9:14 PM
mstorsjo added inline comments.
lib/Target/TargetMachine.cpp
148 ↗(On Diff #215800)

Yes, that's probably best.

mstorsjo updated this revision to Diff 216053.Aug 19 2019, 9:16 PM
mstorsjo marked 2 inline comments as done.

Simplified condition to (coff || windows), added a comment

hans added a comment.Aug 20 2019, 2:18 AM

@hans, once settled, I think this is a bugfix important enough for 9.0 if it still can make it, as it currently is breaking Julia users.

Thanks, I've put it on my watchlist.

Thanks Martin for the quick response and fix. My minimal test-case works and I am in the progress of testing our full build.

rnk accepted this revision.Aug 20 2019, 11:21 AM

lgtm

This revision is now accepted and ready to land.Aug 20 2019, 11:21 AM
This revision was automatically updated to reflect the committed changes.

This apparently broke tests for a few other architectures, when the testsuite is run on windows: http://lab.llvm.org:8011/builders/clang-x64-windows-msvc/builds/9816/steps/stage%201%20check/logs/stdio

These tests use plain e.g. llc -march=amdgcn. When run on windows, that ends up implicitly using a triple with a windows os, even though the tests probably didn't ever intend that.

I guess it should be ok to just amend those tests and change -march into -mtriple with a suitable non-windows os?

This change should hopefully fix the errors in that log:

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

Does that sound sensible? I tried to pick triple values matching what's used elsewhere in similar tests.

I landed my tweak for the tests in rL369443, let's hope that fixes the buildbot.

hans added a comment.Aug 22 2019, 7:27 AM

@hans, once settled, I think this is a bugfix important enough for 9.0 if it still can make it, as it currently is breaking Julia users.

Thanks, I've put it on my watchlist.

Merged to release_90 together with r369443 in r369654.