Page MenuHomePhabricator

When generating llvm.used, we may need an addrspacecast instead of a bitcast.
ClosedPublic

Authored by jholewinski on Feb 2 2015, 6:59 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

jholewinski updated this revision to Diff 19152.Feb 2 2015, 6:59 AM
jholewinski retitled this revision from to When generating llvm.used, we may need an addrspacecast instead of a bitcast..
jholewinski updated this object.
jholewinski edited the test plan for this revision. (Show Details)
jholewinski added a reviewer: jingyue.
jholewinski added a subscriber: Unknown Object (MLST).
arsenm accepted this revision.Feb 2 2015, 8:17 AM
arsenm added a reviewer: arsenm.
arsenm added a subscriber: arsenm.

LGTM

This revision is now accepted and ready to land.Feb 2 2015, 8:17 AM
jingyue accepted this revision.Feb 2 2015, 9:55 AM
jingyue edited edge metadata.

Only two minor comments. Thanks!

lib/CodeGen/CodeGenModule.cpp
939 ↗(On Diff #19152)

The indentation can be improved :)

test/CodeGenCUDA/llvm-used.cu
8 ↗(On Diff #19152)

Is attribute((used)) necessary for this test?

Comments inline.

lib/CodeGen/CodeGenModule.cpp
939 ↗(On Diff #19152)

What would you suggest? I lowered the indentation to keep it in 80 columns.

test/CodeGenCUDA/llvm-used.cu
8 ↗(On Diff #19152)

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.

jingyue added inline comments.Feb 2 2015, 12:27 PM
lib/CodeGen/CodeGenModule.cpp
939 ↗(On Diff #19152)

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]),
test/CodeGenCUDA/llvm-used.cu
8 ↗(On Diff #19152)

I see. I was confused.

This revision was automatically updated to reflect the committed changes.