This is an archive of the discontinued LLVM Phabricator instance.

[CUDA] Make printf work.
ClosedPublic

Authored by jlebar on Jan 20 2016, 1:41 PM.

Details

Summary

The code in CGCUDACall is largely based on a patch written by Eli
Bendersky:
http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140324/210218.html

That patch implemented an LLVM pass lowering printf to vprintf; this
one does something similar, but in Clang codegen.

Diff Detail

Event Timeline

jlebar updated this revision to Diff 45439.Jan 20 2016, 1:41 PM
jlebar retitled this revision from to [CUDA] Make printf work..
jlebar updated this object.
jlebar added a reviewer: tra.
jlebar added subscribers: jhen, echristo, cfe-commits.
jlebar updated this revision to Diff 45446.Jan 20 2016, 2:06 PM

Remove {} around an if statement.

tra added inline comments.Jan 20 2016, 2:30 PM
lib/CodeGen/CGCUDACall.cpp
1

We'll need to handle other builtins soon. Perhaps we can keep them in this file and rename it CGCUDABuiltins.cpp

test/CodeGenCUDA/Inputs/cuda.h
11–12

These are not needed to test anything relevant to this patch, IMO.

test/CodeGenCUDA/printf.cu
12

You may want to add a test case for printf("constant string w/o format args").
It would check no-arguments case and would also verify that we don't get optimized into puts().

jlebar updated this revision to Diff 45456.Jan 20 2016, 3:24 PM
jlebar marked 3 inline comments as done.

Address tra's review comments.

test/CodeGenCUDA/printf.cu
12

Good idea, done.

echristo accepted this revision.Jan 20 2016, 3:28 PM
echristo added a reviewer: echristo.

Looks reasonable to me.

-eric

This revision is now accepted and ready to land.Jan 20 2016, 3:28 PM
This revision was automatically updated to reflect the committed changes.