The AMDGPU backend uses a pass to transform calls to the printf
function to a built-in verision for either HIP or OpenCL. Currently this
does not respect -fno-builtin and is always emitted. This allows the
user to turn off this functionality as is standard for these types of
built-in transformations. The motivation behind this change is to allow
the libc project to provide a linkable version of the printf
function in the future.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Time | Test | |
---|---|---|
60,030 ms | x64 debian > MLIR.Examples/standalone::test.toy |
Event Timeline
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp | ||
---|---|---|
441 | Attribute::Builtin is documented as "only valid on a callsite", so there shouldn't be any need to check it here? | |
llvm/test/CodeGen/AMDGPU/printf_nobuiltin.ll | ||
18 | There should be another test where "-fno-builtin" is passed or equivalently, printf is declared with nobuiltin, but then an over-riding "builtin" is specified on a call to printf. |
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp | ||
---|---|---|
447–449 | But doesn't (!CI->isNoBuiltin()) cover all of this? It calls hasFnAttrImpl(), which in turn checks both attributes in the positive and negative sense, including on the called function. The overall effect is as the function comment says: "check whether this call should not be treated as a builtin". |
llvm/lib/Target/AMDGPU/AMDGPUPrintfRuntimeBinding.cpp | ||
---|---|---|
447–449 | You're right, totally forgot that it checks the callee attributes as well. |
Attribute::Builtin is documented as "only valid on a callsite", so there shouldn't be any need to check it here?