Bug 65169 - [5 Regression] r210201 miscompiles LLVM's TableGen on ppc64
Summary: [5 Regression] r210201 miscompiles LLVM's TableGen on ppc64
Status: RESOLVED MOVED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 5.0
: P1 normal
Target Milestone: 5.0
Assignee: Not yet assigned to anyone
URL: https://sourceware.org/bugzilla/show_...
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2015-02-23 08:45 UTC by Markus Trippelsdorf
Modified: 2015-02-24 06:37 UTC (History)
3 users (show)

See Also:
Host: powerpc64-unknown-linux-gnu
Target: powerpc64-unknown-linux-gnu
Build: powerpc64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2015-02-23 08:45:07 UTC
Before r210201 vs after r210201:

trippels@gcc2-power8 llvm_build % ./bin/llvm-tblgen -gen-intrinsic -I /home/trippels/llvm/include/llvm/IR -I /home/trippels/llvm/lib/Target -I /home/trippels/llvm/include /home/trippels/llvm/include/llvm/IR/Intrinsics.td -o /home/trippels/llvm_build/include/llvm/IR/Intrinsics.gen.tmp

--- /home/trippels/Intrinsics.gen.tmp   2015-02-23 07:34:46.987705642 +0000
+++ /home/trippels/llvm_build/include/llvm/IR/Intrinsics.gen.tmp        2015-02-23 07:37:26.600608412 +0000
@@ -42034,7 +42034,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind,Attribute::ReadNone};
       AS[0] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 1;
-      break;
+        eak;
       }
     case 17: {
       const Attribute::AttrKind AttrParam1[]= {Attribute::NoCapture};
@@ -42042,13 +42042,13 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind,Attribute::ReadNone};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 3: {
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind,Attribute::ReadOnly};
       AS[0] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 1;
-      break;
+        eak;
       }
     case 16: {
       const Attribute::AttrKind AttrParam1[]= {Attribute::NoCapture};
@@ -42056,13 +42056,13 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind,Attribute::ReadOnly};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 2: {
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[0] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 1;
-      break;
+        eak;
       }
     case 13: {
       const Attribute::AttrKind AttrParam1[]= {Attribute::NoCapture};
@@ -42070,7 +42070,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 18: {
       const Attribute::AttrKind AttrParam1[]= {Attribute::NoCapture};
@@ -42080,7 +42080,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[2] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 3;
-      break;
+        eak;
       }
     case 15: {
       const Attribute::AttrKind AttrParam1[]= {Attribute::NoCapture};
@@ -42090,7 +42090,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[2] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 3;
-      break;
+        eak;
       }
     case 14: {
       const Attribute::AttrKind AttrParam2[]= {Attribute::NoCapture};
@@ -42098,7 +42098,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 11: {
       const Attribute::AttrKind AttrParam2[]= {Attribute::NoCapture};
@@ -42108,7 +42108,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[2] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 3;
-      break;
+        eak;
       }
     case 4: {
       const Attribute::AttrKind AttrParam3[]= {Attribute::NoCapture};
@@ -42116,7 +42116,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 5: {
       const Attribute::AttrKind AttrParam4[]= {Attribute::NoCapture};
@@ -42124,7 +42124,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 6: {
       const Attribute::AttrKind AttrParam5[]= {Attribute::NoCapture};
@@ -42132,7 +42132,7 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 7: {
       const Attribute::AttrKind AttrParam6[]= {Attribute::NoCapture};
@@ -42140,25 +42140,25 @@
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind};
       AS[1] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 2;
-      break;
+        eak;
       }
     case 9: {
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind,Attribute::NoReturn};
       AS[0] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 1;
-      break;
+        eak;
       }
     case 8: {
       const Attribute::AttrKind Atts[] = {Attribute::NoUnwind,Attribute::NoDuplicate};
       AS[0] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 1;
-      break;
+        eak;
       }
     case 12: {
       const Attribute::AttrKind Atts[] = {Attribute::ReadNone};
       AS[0] = AttributeSet::get(C, AttributeSet::FunctionIndex, Atts);
       NumAttrs = 1;
-      break;
+        eak;
       }
     case 10: {
       return AttributeSet();@@ -70125,7 +70125,7 @@
     return Intrinsic::xcore_bitrev;     // "__builtin_bitrev"
   }
   }
-  return Intrinsic::not_intrinsic;
+    retu Intrinsic::not_intrinsic;
 }
 #endif

@@ -70182,7 +70182,7 @@
       break;
     return Intrinsic::arm_mrc2;         // "_MoveFromCoprocessor2"
   }
-}  return Intrinsic::not_intrinsic;
+}    retu Intrinsic::not_intrinsic;
 }
 #endif

LLVM was configured with:
trippels@gcc2-power8 llvm_build % cmake -DCMAKE_INSTALL_PREFIX=~/llvm-installi -DCMAKE_BUILD_TYPE=release -DLLVM_ENABLE_ASSERTIONS=on -DLLVM_TARGETS_TO_BUILD="PowerPC" -DCMAKE_CXX_FLAGS_RELEASE:STRING="-O3 -mcpu=power8 -fno-strict-aliasing -DNDEBUG -pipe" -DCMAKE_EXE_LINKER_FLAGS="-Wl,-O1,--hash-style=gnu,--gc-sections" -DENABLE_PIC=1 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_SHARED_LIBS=on -DLLVM_BINUTILS_INCDIR=/home/trippels/include -DCMAKE_C_COMPILER=/home/trippels/gcc_bisect/usr/local/bin/gcc -DCMAKE_CXX_COMPILER="/home/trippels/gcc_bisect/usr/local/bin/g++" ~/llvm

Sorry, no simple testcase yet.
Comment 1 Alan Modra 2015-02-23 22:59:22 UTC
Preprocessed source for llvm-tblgen and gcc command line to compile same would be appreciated.
Comment 2 Alan Modra 2015-02-24 04:07:36 UTC
I couldn't reproduce this using svn llvm rev 230301, gcc-5 20150223, and binutils 2.25.51.20150223.  I was building on a power7 box (because that's where I happened to have my latest gcc build), so used -mcpu=power7 -mno-strict-align.  That ought to trigger the same block move code as -mcpu=power8, and a quick visual inspection showed that to be the case.

I'm guessing that the "s/break/  eak/" difference Markus sees comes from utils/TableGen/IntrinsicEmitter.cpp IntrinsicEmitter::EmitAttributes
    if (numAttrs) {
      OS << "      NumAttrs = " << numAttrs << ";\n";
      OS << "      break;\n";
      OS << "      }\n";

My generated code for the above looked good, and ran properly on power7.  -mcpu=power8 code didn't look much different.

Markus, are you using gold?  (I wasn't.)  The strings are in a string merge section, and I'm wondering if gold miscalculates some string offset.
Comment 3 Markus Trippelsdorf 2015-02-24 05:10:02 UTC
(In reply to Alan Modra from comment #2)
> I couldn't reproduce this using svn llvm rev 230301, gcc-5 20150223, and
> binutils 2.25.51.20150223.  I was building on a power7 box (because that's
> where I happened to have my latest gcc build), so used -mcpu=power7
> -mno-strict-align.  That ought to trigger the same block move code as
> -mcpu=power8, and a quick visual inspection showed that to be the case.
> 
> I'm guessing that the "s/break/  eak/" difference Markus sees comes from
> utils/TableGen/IntrinsicEmitter.cpp IntrinsicEmitter::EmitAttributes
>     if (numAttrs) {
>       OS << "      NumAttrs = " << numAttrs << ";\n";
>       OS << "      break;\n";
>       OS << "      }\n";
> 
> My generated code for the above looked good, and ran properly on power7. 
> -mcpu=power8 code didn't look much different.
> 
> Markus, are you using gold?  (I wasn't.)  The strings are in a string merge
> section, and I'm wondering if gold miscalculates some string offset.

Yes, I was using gold. 
And indeed using ld.bfd fixes the issue. 
I will open a binutils bug later. x86_64 gold is fine BTW.
Comment 4 Markus Trippelsdorf 2015-02-24 06:37:20 UTC
https://sourceware.org/bugzilla/show_bug.cgi?id=18010