Index: lib/CodeGen/TargetInfo.cpp
===================================================================
--- lib/CodeGen/TargetInfo.cpp	(revision 161655)
+++ lib/CodeGen/TargetInfo.cpp	(working copy)
@@ -322,6 +322,15 @@
   return true;
 }
 
+/// getFirstFieldInTransparentUnion - In case Ty is a transparent union
+/// return the type of the first field in the union, otherwise return Ty.
+static QualType getFirstFieldInTransparentUnion(QualType Ty) {
+  const RecordType *UT = Ty->getAsUnionType();
+  if (UT && UT->getDecl()->hasAttr<TransparentUnionAttr>())
+    return UT->getDecl()->field_begin()->getType();
+  return Ty;
+}
+
 namespace {
 /// DefaultABIInfo - The default implementation for ABI specific
 /// details. This implementation provides information which results in
@@ -357,6 +366,7 @@
 }
 
 ABIArgInfo DefaultABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   if (isAggregateTypeForABI(Ty)) {
     // Records with non trivial destructors/constructors should not be passed
     // by value.
@@ -753,6 +763,7 @@
 }
 
 ABIArgInfo X86_32ABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   // FIXME: Set alignment on indirect arguments.
   if (isAggregateTypeForABI(Ty)) {
     // Structures with flexible arrays are always indirect.
@@ -2006,6 +2017,7 @@
   const
 {
   X86_64ABIInfo::Class Lo, Hi;
+  Ty = getFirstFieldInTransparentUnion(Ty);
   classify(Ty, 0, Lo, Hi);
 
   // Check some invariants.
@@ -2220,6 +2232,7 @@
   // };
   unsigned neededInt, neededSSE;
 
+  Ty = getFirstFieldInTransparentUnion(Ty);
   Ty = CGF.getContext().getCanonicalType(Ty);
   ABIArgInfo AI = classifyArgumentType(Ty, 0, neededInt, neededSSE);
 
@@ -2730,6 +2743,7 @@
 }
 
 ABIArgInfo ARMABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   if (!isAggregateTypeForABI(Ty)) {
     // Treat an enum type as its underlying type.
     if (const EnumType *EnumTy = Ty->getAs<EnumType>())
@@ -3017,6 +3031,7 @@
 }
 
 ABIArgInfo NVPTXABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   if (isAggregateTypeForABI(Ty))
     return ABIArgInfo::getIndirect(0);
 
@@ -3163,6 +3178,7 @@
 }
 
 ABIArgInfo MBlazeABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   if (isAggregateTypeForABI(Ty))
     return ABIArgInfo::getIndirect(0);
 
@@ -3371,6 +3387,7 @@
 
 ABIArgInfo
 MipsABIInfo::classifyArgumentType(QualType Ty, uint64_t &Offset) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   uint64_t OrigOffset = Offset;
   uint64_t TySize = getContext().getTypeSize(Ty);
   uint64_t Align = getContext().getTypeAlign(Ty) / 8;
@@ -3663,6 +3680,7 @@
 }
 
 ABIArgInfo HexagonABIInfo::classifyArgumentType(QualType Ty) const {
+  Ty = getFirstFieldInTransparentUnion(Ty);
   if (!isAggregateTypeForABI(Ty)) {
     // Treat an enum type as its underlying type.
     if (const EnumType *EnumTy = Ty->getAs<EnumType>())
Index: test/CodeGen/transparent-union.c
===================================================================
--- test/CodeGen/transparent-union.c	(revision 161655)
+++ test/CodeGen/transparent-union.c	(working copy)
@@ -1,8 +1,5 @@
 // RUN: %clang_cc1 -Werror -triple i386-unknown-unknown -emit-llvm -o %t %s
 // RUN: FileCheck < %t %s
-//
-// FIXME: Note that we don't currently get the ABI right here. f0() should be
-// f0(i8*).
 
 typedef union {
   void *f0;
@@ -11,7 +8,7 @@
 void f0(transp_t0 obj);
 
 // CHECK: define void @f1_0(i32* %a0) 
-// CHECK:  call void @f0(%union.transp_t0* byval align 4 %{{.*}})
+// CHECK:  call void @f0(i8* %{{.*}})
 // CHECK:  call void %{{.*}}(i8* %{{[a-z0-9]*}})
 // CHECK: }
 void f1_0(int *a0) {
