Package: llvm-3.0
Version: 3.0-10
Severity: normal
Tags: patch

Hi,

clang 3.0 fails with -march=native on an Core i7 Ivy Bridge CPU on [amd64]:

# clang -c -v -march=native /tmp/x.c -m64
Debian clang version 3.0-6.1 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
 "/usr/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all
 -disable-free -disable-llvm-verifier -main-file-name x.c
 -mrelocation-model static -mdisable-fp-elim -masm-verbose
 -mconstructor-aliases -munwind-tables -target-cpu i686
 -target-linker-version 2.22 -momit-leaf-frame-pointer -v -coverage-file
 x.o -resource-dir /usr/bin/../lib/clang/3.0 -fmodule-cache-path
 /var/tmp/clang-module-cache -internal-isystem /usr/local/include
 -internal-isystem /usr/bin/../lib/clang/3.0/include
 -internal-externc-isystem /usr/include/x86_64-linux-gnu
 -internal-externc-isystem /usr/include -ferror-limit 19
 -fmessage-length 194 -fgnu-runtime -fobjc-runtime-has-arc
 -fobjc-runtime-has-weak -fobjc-fragile-abi -fdiagnostics-show-option
 -fcolor-diagnostics -o x.o -x c /tmp/x.c
error: unknown target CPU 'i686'

Hmm, well, that one only exists for -m32.

# cat /proc/cpuinfo
 processor       : 0
 vendor_id       : GenuineIntel
 cpu family      : 6
 model           : 58
 model name      : Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz
 stepping        : 9
 microcode       : 0x12
...

I cherry-picked a few patches from llvm-3.2 from their git-svn repository
that
* add detection for a few newer CPUs
* use a default for unknown CPUs that takes into account whether the CPU
  is 64-bit capable, so this would fall back to -march=x86-64 which
  would actually work.

After applying these patches to llvm-3.0 clang-3.0 started to behave
sane again. (But due to lack of AVX support I'll have to move to
llvm-3.2/clang-3.2 anyway.)

If help is needed, I could take care of a NMU and try to get this
unblocked for wheezy.

Andreas

--


------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
Forschungszentrum Juelich GmbH
52425 Juelich
Sitz der Gesellschaft: Juelich
Eingetragen im Handelsregister des Amtsgerichts Dueren Nr. HR B 3498
Vorsitzender des Aufsichtsrats: MinDir Dr. Karl Eugen Huthmacher
Geschaeftsfuehrung: Prof. Dr. Achim Bachem (Vorsitzender),
Karsten Beneke (stellv. Vorsitzender), Prof. Dr.-Ing. Harald Bolt,
Prof. Dr. Sebastian M. Schmidt
------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------
>From aff59685a9ff59edb525a1be2120e9d0206f3bb8 Mon Sep 17 00:00:00 2001
From: Evan Cheng <[email protected]>
Date: Mon, 23 Apr 2012 22:41:39 +0000
Subject: [PATCH] Add a missing cpu subtype.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155402 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Support/Host.cpp |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp
index 0f06964..a5e0cb0 100644
--- a/lib/Support/Host.cpp
+++ b/lib/Support/Host.cpp
@@ -230,6 +230,10 @@ std::string sys::getHostCPUName() {
       case 45:
         return "corei7-avx";
 
+      // Ivy Bridge:
+      case 58:
+        return "core-avx-i";
+
       case 28: // Intel Atom processor. All processors are manufactured using
                // the 45 nm process
         return "atom";
-- 
1.7.10.4

>From 0d38d3a0005c60f721899475902026a91ef65fad Mon Sep 17 00:00:00 2001
From: Bob Wilson <[email protected]>
Date: Wed, 9 May 2012 17:47:03 +0000
Subject: [PATCH] Use the cpuid 64 bit flag to pick the default CPU name for
 an unknown model.

For the Family 6 switch in sys::getHostCPUName, an unrecognized model was
reported as "i686".  That's a really bad default since it means that new
CPUs will be treated as if they can only use 32-bit code.  This just looks
at the cpuid extended feature flag for 64 bit support, and if that is set,
it uses a default x86-64 cpu.  Similar logic is already used for the Family
15 code.  <rdar://problem/11314502>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156486 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Support/Host.cpp |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/lib/Support/Host.cpp
+++ b/lib/Support/Host.cpp
@@ -231,7 +231,7 @@
                // the 45 nm process
         return "atom";
 
-      default: return "i686";
+      default: return (Em64T) ? "x86-64" : "i686";
       }
     case 15: {
       switch (Model) {
>From 4335e3495d5cd6784a99749879114caf22b9d398 Mon Sep 17 00:00:00 2001
From: Benjamin Kramer <[email protected]>
Date: Wed, 26 Sep 2012 18:21:47 +0000
Subject: [PATCH] Add support for detecting some corei7-class Xeons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164714 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lib/Support/Host.cpp |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/Support/Host.cpp b/lib/Support/Host.cpp
index a13b9e2..9ee3f2d 100644
--- a/lib/Support/Host.cpp
+++ b/lib/Support/Host.cpp
@@ -234,6 +234,8 @@ std::string sys::getHostCPUName() {
       case 37: // Intel Core i7, laptop version.
       case 44: // Intel Core i7 processor and Intel Xeon processor. All
                // processors are manufactured using the 32 nm process.
+      case 46: // Nehalem EX
+      case 47: // Westmere EX
         return "corei7";
 
       // SandyBridge:
-- 
1.7.10.4

Reply via email to