[cfe-commits] r162862 - in /cfe/trunk: lib/CodeGen/CGBuiltin.cpp test/CodeGenObjC/builtin-memfns.m
Eli Friedman
eli.friedman at gmail.com
Wed Aug 29 14:21:11 PDT 2012
Author: efriedma
Date: Wed Aug 29 16:21:11 2012
New Revision: 162862
URL: http://llvm.org/viewvc/llvm-project?rev=162862&view=rev
Log:
Make alignment computation for pointer values for builtins handle
non-pointer types with a pointer representation correctly. PR13660.
Added:
cfe/trunk/test/CodeGenObjC/builtin-memfns.m
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=162862&r1=162861&r2=162862&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Aug 29 16:21:11 2012
@@ -1478,7 +1478,8 @@
assert(Addr->getType()->isPointerType());
Addr = Addr->IgnoreParens();
if (const ImplicitCastExpr *ICE = dyn_cast<ImplicitCastExpr>(Addr)) {
- if (ICE->getCastKind() == CK_BitCast || ICE->getCastKind() == CK_NoOp) {
+ if ((ICE->getCastKind() == CK_BitCast || ICE->getCastKind() == CK_NoOp) &&
+ ICE->getSubExpr()->getType()->isPointerType()) {
std::pair<llvm::Value*, unsigned> Ptr =
EmitPointerWithAlignment(ICE->getSubExpr());
Ptr.first = Builder.CreateBitCast(Ptr.first,
Added: cfe/trunk/test/CodeGenObjC/builtin-memfns.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/builtin-memfns.m?rev=162862&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/builtin-memfns.m (added)
+++ cfe/trunk/test/CodeGenObjC/builtin-memfns.m Wed Aug 29 16:21:11 2012
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.8.0 -emit-llvm < %s| FileCheck %s
+
+void *memcpy(void *restrict s1, const void *restrict s2, unsigned long n);
+
+// PR13660
+void test1(int *a, id b) {
+ // CHECK: @test1
+ // CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* {{.*}}, i8* {{.*}}, i64 8, i32 1, i1 false)
+ memcpy(a, b, 8);
+}
More information about the cfe-commits
mailing list