r349506 - [NFC] Fix usage of Builder.insert(new Bitcast...)in CodeGenFunction

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 18 08:22:22 PST 2018


Author: erichkeane
Date: Tue Dec 18 08:22:21 2018
New Revision: 349506

URL: http://llvm.org/viewvc/llvm-project?rev=349506&view=rev
Log:
[NFC] Fix usage of Builder.insert(new Bitcast...)in CodeGenFunction

This is exactly a "CreateBitCast", so refactor this to get rid of a
'new'.

Note that this slightly changes the test, as the Builder is now
seemingly smart enough to fold one of the bitcasts into the annotation
call.

Change-Id: I1733fb1fdf91f5c9d88651067130b9a4e7b5ab67

Modified:
    cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
    cfe/trunk/test/CodeGen/annotations-field.c

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=349506&r1=349505&r2=349506&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Tue Dec 18 08:22:21 2018
@@ -2243,7 +2243,7 @@ Address CodeGenFunction::EmitFieldAnnota
     // annotation on the first field of a struct and annotation on the struct
     // itself.
     if (VTy != CGM.Int8PtrTy)
-      V = Builder.Insert(new llvm::BitCastInst(V, CGM.Int8PtrTy));
+      V = Builder.CreateBitCast(V, CGM.Int8PtrTy);
     V = EmitAnnotationCall(F, V, I->getAnnotation(), D->getLocation());
     V = Builder.CreateBitCast(V, VTy);
   }

Modified: cfe/trunk/test/CodeGen/annotations-field.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/annotations-field.c?rev=349506&r1=349505&r2=349506&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/annotations-field.c (original)
+++ cfe/trunk/test/CodeGen/annotations-field.c Tue Dec 18 08:22:21 2018
@@ -21,7 +21,6 @@ int main(int argc, char **argv) {
 // CHECK-NEXT: call i8* @llvm.ptr.annotation.p0i8({{.*}}str{{.*}}str{{.*}}i32 8)
 // CHECK-NEXT: bitcast i8* {{.*}} to i32*
     gf.v = argc;
-// CHECK: bitcast i32* getelementptr inbounds (%struct.foo, %struct.foo* @gf, i32 0, i32 0) to i8*
-// CHECK-NEXT: call i8* @llvm.ptr.annotation.p0i8({{.*}}str{{.*}}str{{.*}}i32 8)
+// CHECK: call i8* @llvm.ptr.annotation.p0i8(i8* bitcast (%struct.foo* @gf to i8*), {{.*}}str{{.*}}str{{.*}}i32 8)
     return 0;
 }




More information about the cfe-commits mailing list