[PATCH] When generating llvm.used, we may need an addrspacecast instead of a bitcast.

Justin Holewinski justin.holewinski at gmail.com
Mon Feb 2 11:37:03 PST 2015


Comments inline.


================
Comment at: lib/CodeGen/CodeGenModule.cpp:939
@@ +938,3 @@
+      llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+                                                cast<llvm::Constant>(&*List[i]),
+                                                CGM.Int8PtrTy);
----------------
jingyue wrote:
> The indentation can be improved :)
What would you suggest?  I lowered the indentation to keep it in 80 columns.

================
Comment at: test/CodeGenCUDA/llvm-used.cu:8
@@ +7,2 @@
+// CHECK: @llvm.used = appending global [1 x i8*] [i8* addrspacecast (i8 addrspace(1)* bitcast ([0 x i32] addrspace(1)* @a to i8 addrspace(1)*) to i8*)], section "llvm.metadata"
+__attribute__((device)) __attribute__((__used__)) int a[] = {};
----------------
jingyue wrote:
> Is __attribute__((__used__)) necessary for this test? 
That is the test case attached to the bug report.  The attribute may not be strictly required in the input .cu file, but without it the test won't add the variable to the llvm.used list which is the point of the bug.

http://reviews.llvm.org/D7345

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list