Author: rjmccall Date: Mon Sep 28 23:37:40 2015 New Revision: 248775 URL: http://llvm.org/viewvc/llvm-project?rev=248775&view=rev Log: Honor the casted-to alignment of an explicit cast even when Sema thinks the cast is a no-op, as it does when (e.g.) the only thing that changes is an alignment attribute.
Fixed PR24944. Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp cfe/trunk/test/CodeGen/alignment.c Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=248775&r1=248774&r2=248775&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGExpr.cpp (original) +++ cfe/trunk/lib/CodeGen/CGExpr.cpp Mon Sep 28 23:37:40 2015 @@ -814,7 +814,6 @@ Address CodeGenFunction::EmitPointerWith // If this is an explicit bitcast, and the source l-value is // opaque, honor the alignment of the casted-to type. if (isa<ExplicitCastExpr>(CE) && - CE->getCastKind() == CK_BitCast && InnerSource != AlignmentSource::Decl) { Addr = Address(Addr.getPointer(), getNaturalPointeeTypeAlignment(E->getType(), Source)); Modified: cfe/trunk/test/CodeGen/alignment.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/alignment.c?rev=248775&r1=248774&r2=248775&view=diff ============================================================================== --- cfe/trunk/test/CodeGen/alignment.c (original) +++ cfe/trunk/test/CodeGen/alignment.c Mon Sep 28 23:37:40 2015 @@ -59,3 +59,11 @@ void test4(float4align64 *p) { // CHECK: @test4( // CHECK: store <4 x float> {{.*}}, <4 x float>* {{.*}}, align 64 +// PR24944 - Typedef alignment not honored on no-op cast. +typedef float __attribute__((vector_size(16), aligned(16))) float4align16; +typedef float __attribute__((vector_size(16), aligned(2))) float4align2; +void test6(float4align64 *p) { + float4align64 vec = *(float4align2*) p; +} +// CHECK-LABEL: @test6 +// CHECK: load <4 x float>, <4 x float>* {{.*}}, align 2 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits