[cfe-commits] r134969 - in /cfe/trunk: lib/CodeGen/CodeGenTypes.cpp test/CodeGen/const-arithmetic.c test/CodeGen/const-init.c test/CodeGen/designated-initializers.c test/CodeGen/regparm.c test/CodeGen/transparent-union.c test/CodeGen/x86_64-arguments.c test/CodeGenCXX/pointers-to-data-members.cpp

Chris Lattner sabre at nondot.org
Mon Jul 11 22:53:08 PDT 2011


Author: lattner
Date: Tue Jul 12 00:53:08 2011
New Revision: 134969

URL: http://llvm.org/viewvc/llvm-project?rev=134969&view=rev
Log:
fix an unintended behavior change in the type system rewrite, which caused us to compile
stuff like this:

typedef struct {
 int x, y, z; 
} foo_t;

foo_t g;

into:
%"struct.<anonymous>" = type { i32, i32, i32 }
we now get:
%struct.foo_t = type { i32, i32, i32 }

This doesn't change the behavior of the compiler, but makes the IR much easier to read.



Modified:
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
    cfe/trunk/test/CodeGen/const-arithmetic.c
    cfe/trunk/test/CodeGen/const-init.c
    cfe/trunk/test/CodeGen/designated-initializers.c
    cfe/trunk/test/CodeGen/regparm.c
    cfe/trunk/test/CodeGen/transparent-union.c
    cfe/trunk/test/CodeGen/x86_64-arguments.c
    cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Tue Jul 12 00:53:08 2011
@@ -451,10 +451,10 @@
   llvm::StructType *&Entry = RecordDeclTypes[Key];
 
   // If we don't have a StructType at all yet, create the forward declaration.
-  if (Entry == 0)
-    Entry = llvm::StructType::createNamed(getLLVMContext(), 
-                                          std::string(RD->getKindName()) + "." +
-                                          RD->getQualifiedNameAsString());
+  if (Entry == 0) {
+    Entry = llvm::StructType::createNamed(getLLVMContext(), "");
+    addRecordTypeName(RD, Entry, "");
+  }
   llvm::StructType *Ty = Entry;
 
   // If this is still a forward declaration, or the LLVM type is already

Modified: cfe/trunk/test/CodeGen/const-arithmetic.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/const-arithmetic.c?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/const-arithmetic.c (original)
+++ cfe/trunk/test/CodeGen/const-arithmetic.c Tue Jul 12 00:53:08 2011
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
 
-// CHECK: @g1 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %"struct.<anonymous>"]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %"struct.<anonymous>"]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16
-// CHECK: @g2 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %"struct.<anonymous>"]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %"struct.<anonymous>"]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16
+// CHECK: @g1 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16
+// CHECK: @g2 = global [2 x i8*] [i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -2), i8* getelementptr (i8* getelementptr inbounds ([0 x %struct.anon]* @g0, i32 0, i32 0, i32 0), i64 -46)], align 16
 
 extern struct { unsigned char a, b; } g0[];
 void *g1[] = {g0 + -1, g0 + -23 };

Modified: cfe/trunk/test/CodeGen/const-init.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/const-init.c?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/const-init.c (original)
+++ cfe/trunk/test/CodeGen/const-init.c Tue Jul 12 00:53:08 2011
@@ -52,14 +52,14 @@
 int g10 = (2.0 + 3.0i) * (5.0 + 7.0i) != (-11.0 + 29.0i);
 
 // PR5108
-// CHECK: @gv1 = global %"struct.<anonymous>" <{ i32 0, i8 7 }>, align 1
+// CHECK: @gv1 = global %struct.anon <{ i32 0, i8 7 }>, align 1
 struct {
   unsigned long a;
   unsigned long b:3;
 } __attribute__((__packed__)) gv1  = { .a = 0x0, .b = 7,  };
 
 // PR5118
-// CHECK: @gv2 = global %"struct.<anonymous>.0" <{ i8 1, i8* null }>, align 1 
+// CHECK: @gv2 = global %struct.anon.0 <{ i8 1, i8* null }>, align 1 
 struct {
   unsigned char a;
   char *b;

Modified: cfe/trunk/test/CodeGen/designated-initializers.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/designated-initializers.c?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/designated-initializers.c (original)
+++ cfe/trunk/test/CodeGen/designated-initializers.c Tue Jul 12 00:53:08 2011
@@ -5,13 +5,13 @@
     int b;
 };
 
-// CHECK: @u = global %"union.<anonymous>" zeroinitializer
+// CHECK: @u = global %union.anon zeroinitializer
 union { int i; float f; } u = { };
 
 // CHECK: @u2 = global { i32, [4 x i8] } { i32 0, [4 x i8] undef }
 union { int i; double f; } u2 = { };
 
-// CHECK: @u3 = global %"union.<anonymous>.1" zeroinitializer
+// CHECK: @u3 = global  %union.anon.1 zeroinitializer
 union { double f; int i; } u3 = { };
 
 // CHECK: @b = global [2 x i32] [i32 0, i32 22]
@@ -39,11 +39,11 @@
 struct ds ds1 = { { .a = 1 } };
 struct ds ds2 = { { .b = 1 } };
 struct ds ds3 = { .a = 0 };
-// CHECK: @ds4 = global %struct.ds { %"struct.ds::<anonymous>" { %"struct.ds::<anonymous struct>::<anonymous>" zeroinitializer, i16 0, %"struct.ds::<anonymous struct>::<anonymous>.2" { i16 1 } } }
+// CHECK: @ds4 = global %struct.ds { %struct.anon.3 { %struct.anon zeroinitializer, i16 0, %struct.anon.2 { i16 1 } } }
 struct ds ds4 = { .c = 1 };
 struct ds ds5 = { { { .a = 0 } }, .b = 1 };
 struct ds ds6 = { { .a = 0, .b = 1 } };
-// CHECK: @ds7 = global %struct.ds { %"struct.ds::<anonymous>" { %"struct.ds::<anonymous struct>::<anonymous>" { i16 2 }, i16 3, %"struct.ds::<anonymous struct>::<anonymous>.2" zeroinitializer } }
+// CHECK: @ds7 = global %struct.ds { %struct.anon.3 { %struct.anon { i16 2 }, i16 3, %struct.anon.2 zeroinitializer } }
 struct ds ds7 = {
   { {
       .a = 1
@@ -59,7 +59,7 @@
     .b = 1024,
   };
 
-  // CHECK: bitcast %union.* %u2
+  // CHECK: bitcast %union.anon.4* %u2
   // CHECK: call void @llvm.memset
    union { int i; float f; } u2 = { };
 

Modified: cfe/trunk/test/CodeGen/regparm.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/regparm.c?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/regparm.c (original)
+++ cfe/trunk/test/CodeGen/regparm.c Tue Jul 12 00:53:08 2011
@@ -20,7 +20,7 @@
 
 int
 main(void) {
-  // CHECK: call void @reduced(i8 signext inreg 0, {{.*}} %"struct.<anonymous>"* inreg null
+  // CHECK: call void @reduced(i8 signext inreg 0, {{.*}} %struct.foo* inreg null
   reduced(0, 0.0, 0, 0.0, 0);
   // CHECK: call x86_stdcallcc void {{.*}}(i32 inreg 1, i32 inreg 2)
   bar(1,2);

Modified: cfe/trunk/test/CodeGen/transparent-union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/transparent-union.c?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/transparent-union.c (original)
+++ cfe/trunk/test/CodeGen/transparent-union.c Tue Jul 12 00:53:08 2011
@@ -11,7 +11,7 @@
 void f0(transp_t0 obj);
 
 // CHECK: define void @f1_0(i32* %a0) 
-// CHECK:  call void @f0(%"union.<anonymous>"* byval align 4 %{{.*}})
+// CHECK:  call void @f0(%union.transp_t0* byval align 4 %{{.*}})
 // CHECK:  call void %{{.*}}(i8* %{{[a-z0-9]*}})
 // CHECK: }
 void f1_0(int *a0) {

Modified: cfe/trunk/test/CodeGen/x86_64-arguments.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/x86_64-arguments.c?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/x86_64-arguments.c (original)
+++ cfe/trunk/test/CodeGen/x86_64-arguments.c Tue Jul 12 00:53:08 2011
@@ -58,7 +58,7 @@
 struct s10 { int a; int b; int : 0; };
 void f10(struct s10 a0) {}
 
-// CHECK: define void @f11(%"union.<anonymous>"* sret %agg.result)
+// CHECK: define void @f11(%union.anon* sret %agg.result)
 union { long double a; float b; } f11() { while (1) {} }
 
 // CHECK: define i32 @f12_0()

Modified: cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp?rev=134969&r1=134968&r2=134969&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp Tue Jul 12 00:53:08 2011
@@ -22,7 +22,7 @@
   // CHECK-GLOBAL: @_ZN8ZeroInit1bE = global i64 -1,
   int A::* b = 0;
 
-  // CHECK-GLOBAL: @_ZN8ZeroInit2saE = internal global %"struct.ZeroInit::<anonymous>" { i64 -1 }
+  // CHECK-GLOBAL: @_ZN8ZeroInit2saE = internal global %struct.anon { i64 -1 }
   struct {
     int A::*a;
   } sa;
@@ -35,7 +35,7 @@
   } ssa[2];
   void test_ssa() { (void) ssa; }
   
-  // CHECK-GLOBAL: @_ZN8ZeroInit2ssE = internal global %"struct.ZeroInit::<anonymous>.1" { %"struct.ZeroInit::<anonymous struct>::<anonymous>" { i64 -1 } }
+  // CHECK-GLOBAL: @_ZN8ZeroInit2ssE = internal global %struct.anon.1 { %struct.anon.2 { i64 -1 } }
   struct {
     struct {
       int A::*pa;





More information about the cfe-commits mailing list