[cfe-commits] r85504 - in /cfe/trunk: lib/CodeGen/CGExprConstant.cpp test/CodeGen/cast-to-union.c test/CodeGen/union-init2.c
Nuno Lopes
nunoplopes at sapo.pt
Thu Oct 29 04:27:07 PDT 2009
Author: nlopes
Date: Thu Oct 29 06:27:06 2009
New Revision: 85504
URL: http://llvm.org/viewvc/llvm-project?rev=85504&view=rev
Log:
make clang emit undefs for padding of structs and unions instead of zeros. this enables constant compaction optimizations.
Modified:
cfe/trunk/lib/CodeGen/CGExprConstant.cpp
cfe/trunk/test/CodeGen/cast-to-union.c
cfe/trunk/test/CodeGen/union-init2.c
Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=85504&r1=85503&r2=85504&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Thu Oct 29 06:27:06 2009
@@ -228,7 +228,7 @@
if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
- llvm::Constant *C = llvm::Constant::getNullValue(Ty);
+ llvm::Constant *C = llvm::UndefValue::get(Ty);
Elements.push_back(C);
assert(getAlignment(C) == 1 && "Padding must have 1 byte alignment!");
@@ -266,7 +266,7 @@
if (NumBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumBytes);
- llvm::Constant *Padding = llvm::Constant::getNullValue(Ty);
+ llvm::Constant *Padding = llvm::UndefValue::get(Ty);
PackedElements.push_back(Padding);
ElementOffsetInBytes += getSizeInBytes(Padding);
}
@@ -496,7 +496,7 @@
if (NumPadBytes > 1)
Ty = llvm::ArrayType::get(Ty, NumPadBytes);
- Elts.push_back(llvm::Constant::getNullValue(Ty));
+ Elts.push_back(llvm::UndefValue::get(Ty));
Types.push_back(Ty);
}
Modified: cfe/trunk/test/CodeGen/cast-to-union.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cast-to-union.c?rev=85504&r1=85503&r2=85504&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/cast-to-union.c (original)
+++ cfe/trunk/test/CodeGen/cast-to-union.c Thu Oct 29 06:27:06 2009
@@ -1,5 +1,5 @@
// RUN: clang-cc -emit-llvm %s -o - | FileCheck %s
-// CHECK: w = global %0 { i32 2, [4 x i8] zeroinitializer }
+// CHECK: w = global %0 { i32 2, [4 x i8] undef }
// CHECK: y = global %union.u { double 7.300000e+0{{[0]*}}1 }
// CHECK: store i32 351, i32
Modified: cfe/trunk/test/CodeGen/union-init2.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/union-init2.c?rev=85504&r1=85503&r2=85504&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/union-init2.c (original)
+++ cfe/trunk/test/CodeGen/union-init2.c Thu Oct 29 06:27:06 2009
@@ -1,4 +1,4 @@
-// RUN: clang-cc -emit-llvm %s -o - -triple i686-pc-linux-gnu | grep "bitcast (%0\* @r to %union.x\*), \[4 x i8\] zeroinitializer"
+// RUN: clang-cc -emit-llvm %s -o - -triple i686-pc-linux-gnu | grep "bitcast (%0\* @r to %union.x\*), \[4 x i8\] undef"
// Make sure we generate something sane instead of a ptrtoint
union x {long long b;union x* a;} r = {.a = &r};
More information about the cfe-commits
mailing list