[PATCH] D28538: [CodeGen] [CUDA] Add the ability set default attrs on functions in linked modules.
Justin Lebar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 10 15:52:17 PST 2017
jlebar created this revision.
jlebar added a reviewer: echristo.
jlebar added subscribers: llvm-commits, hfinkel.
Herald added a subscriber: mehdi_amini.
Now when you ask clang to link in a bitcode module, you can tell it to
set attributes on that module's functions to match what we would have
set if we'd emitted those functions ourselves.
This is particularly important for fast-math attributes in CUDA
compilations.
Each CUDA compilation links in libdevice, a bitcode library provided by
nvidia as part of the CUDA distribution. Without this patch, if we have
a user-function F that is compiled with -ffast-math that calls a
function G from libdevice, F will have the unsafe-fp-math=true (etc.)
attributes, but G will have no attributes.
Since F calls G, the inliner will merge G's attributes into F's. It
considers the lack of an unsafe-fp-math=true attribute on G to be
tantamount to unsafe-fp-math=false, so it "merges" these by setting
unsafe-fp-math=false on F.
This then continues up the call graph, until every function that
(transitively) calls something in libdevice gets unsafe-fp-math=false
set, thus disabling fastmath in almost all CUDA code.
https://reviews.llvm.org/D28538
Files:
clang/include/clang/CodeGen/CodeGenAction.h
clang/include/clang/Frontend/CodeGenOptions.h
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CodeGenAction.cpp
clang/lib/CodeGen/CodeGenModule.h
clang/lib/Frontend/CompilerInvocation.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D28538.83887.patch
Type: text/x-patch
Size: 23901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170110/ae8ac734/attachment.bin>
More information about the llvm-commits
mailing list