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

Jingyue Wu jingyue at google.com
Mon Feb 2 12:27:50 PST 2015


================
Comment at: lib/CodeGen/CodeGenModule.cpp:939
@@ +938,3 @@
+      llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
+                                                cast<llvm::Constant>(&*List[i]),
+                                                CGM.Int8PtrTy);
----------------
jholewinski wrote:
> jingyue wrote:
> > The indentation can be improved :)
> What would you suggest?  I lowered the indentation to keep it in 80 columns.
e.g., four spaces from the last line. I'm following clang-format. 
```
for (unsigned i = 0, e = List.size(); i != e; ++i) {
  UsedArray[i] =
      llvm::ConstantExpr::getPointerBitCastOrAddrSpaceCast(
          cast<llvm::Constant>(&*List[i]),
```

================
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[] = {};
----------------
jholewinski wrote:
> 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.
I see. I was confused.

http://reviews.llvm.org/D7345

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






More information about the llvm-commits mailing list