The pass is needed to remove __nvvm_reflect calls after we link in libdevice bitcode that comes with CUDA.
http://llvm.org/docs/NVPTXUsage.html#linking-with-libdevice
Details
Diff Detail
Event Timeline
NVVMReflect pass functionality is already tested in test/CodeGen/NVPTX/nvvm-reflect.ll
In addition, tests in D11664 (clang-side counterpart of this patch) verify end-to-end functionality which ensures that __nvvm_reflect() is eliminated when -nvptx-enable-reflect option is passed.
Seems this could be unified with with the nvvm-reflect-enable option in the pass itself? Actually, is there any reason this shouldn't be on by default for the backend? (i.e. am I missing something here?)
-eric
Your point makes sense as linking with libdevice will be the common case for compiling real CUDA apps.
Adding NVVMReflect pass unconditionally would break whoever may want to compile their own libdevice variant.
It can be easily fixed with -nvvm-reflect-enable=0, so it should not be too big of a deal.
On second thought, adding NVVMReflect pass with *default* settings unconditionally may make is hard to replace it with the one that takes optional StringMap. I don't think we need that now, but if/when that happens we can make NVVMReflect pass conditional then.
Added NVVMReflect pass unconditionally.
Removed command-line option.
If NVVMReflect has to be disabled, it can be done with -nvvm-reflect-enable=0 option.