This is an archive of the discontinued LLVM Phabricator instance.

[hip] Allow the declaration of functions with variadic arguments in HIP.
ClosedPublic

Authored by hliao on Oct 24 2019, 8:56 AM.

Details

Summary
  • As variadic parameters have the lowest rank in overload resolution, without real usage of va_arg, they are commonly used as the catch-all fallbacks in SFINAE. As the front-end still reports errors on calls to va_arg, the declaration of functions with variadic arguments should be allowed in general.

Diff Detail

Event Timeline

hliao created this revision.Oct 24 2019, 8:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2019, 8:56 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
hliao updated this revision to Diff 226301.Oct 24 2019, 10:50 AM

revise commit message

hliao retitled this revision from [hip] Relax an allow the declaration of functions with variadic arguments in HIP. to [hip] Allow the declaration of functions with variadic arguments in HIP..Oct 24 2019, 10:51 AM
tra added inline comments.Oct 24 2019, 12:31 PM
clang/lib/CodeGen/TargetInfo.cpp
7764

llvm_unreachable() should be used to indicate an error in compiler's own code, not in the user code that we're compiling.

I think what you need to do is to issue a postponed diagnostics in Sema where we're currently checking for varargs functions and materialize them if we attempt to codegen such function.

hliao marked an inline comment as done.Oct 24 2019, 12:42 PM
hliao added inline comments.
clang/lib/CodeGen/TargetInfo.cpp
7764

this is just a stub to assert that there won't be codegen for va_arg. the real diagnosing is @ lib/Sema/SemaExpr.cpp around L14438. I just want to add an assertion to capture them if anything goes wrong. Error on va_arg use is already there for a while.

tra accepted this revision.Oct 24 2019, 2:39 PM

Perhaps we should rename -fcuda-allow-variadic-functions to -fgpu-allow-variadic-functions after this patch.

This revision is now accepted and ready to land.Oct 24 2019, 2:39 PM
This revision was automatically updated to reflect the committed changes.