This is an archive of the discontinued LLVM Phabricator instance.

IR: Replace the "Linker Options" module flag with "llvm.linker.options" named metadata.
ClosedPublic

Authored by pcc on Mar 24 2017, 12:59 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

pcc created this revision.Mar 24 2017, 12:59 PM
rnk added inline comments.Mar 24 2017, 1:37 PM
clang/lib/CodeGen/CodeGenModule.cpp
1304 ↗(On Diff #92992)

This is a minor behavior change, right? Now we don't deduplicate linker options for "free"? We unique the flags anyway, so we get this behavior, which seems fine:

$ cat a.ll
!0 = !{!"asdf"}
!my_named_md = !{!0}

$ cat b.ll
!0 = !{!"asdf"}
!my_named_md = !{!0}

$ llvm-link a.ll b.ll -S -o -
; ModuleID = 'llvm-link'
source_filename = "llvm-link"
!my_named_md = !{!0, !0}
!0 = !{!"asdf"}
pcc added inline comments.
clang/lib/CodeGen/CodeGenModule.cpp
1304 ↗(On Diff #92992)

Correct.

rjmccall edited edge metadata.Mar 24 2017, 3:26 PM

Clang side of this is fine.

Conceptually, I guess this is an uncommonly-enough-used extension that we can just change it without breaking too many frontends. I feel like you should probably check for the old module flag in the verifier, though; this is not something we should be silently ignoring.

rnk accepted this revision.Mar 24 2017, 3:29 PM

After briefly attempting to rework D31352 to work without this patch, I now see why you want to do this. Working with module flags is hard and working with named md nodes is easier. Module flags still seem appropriate for integer settings that need to match during LTO, but I don't think there are many appending module flags that wouldn't be better served by named md nodes.

This revision is now accepted and ready to land.Mar 24 2017, 3:29 PM
pcc updated this revision to Diff 101667.Jun 6 2017, 9:35 PM

Refresh and add verifier check

This revision now requires review to proceed.Jun 6 2017, 9:35 PM
pcc added a comment.Jun 6 2017, 9:39 PM

Clang side of this is fine.

Conceptually, I guess this is an uncommonly-enough-used extension that we can just change it without breaking too many frontends. I feel like you should probably check for the old module flag in the verifier, though; this is not something we should be silently ignoring.

Done.

(I'm refreshing this patch because I want to add another named metadata kind that is lowered to object files, and this patch contained the refactoring that allowed me to do that without being forced to go through module flags. I still think this is worth doing regardless of whether we do D31352 because this representation is simpler.)

mehdi_amini added inline comments.Jun 6 2017, 10:31 PM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
2619 ↗(On Diff #101667)

Is there a test covering this? I see many (most?) have been updated to the new metadata.

pcc added inline comments.Jun 6 2017, 10:32 PM
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
2619 ↗(On Diff #101667)

Yes, see llvm/test/Bitcode/upgrade-linker-options.ll

This revision is now accepted and ready to land.Jun 9 2017, 10:37 AM
rnk accepted this revision.Jun 12 2017, 11:46 AM

+1, still looks good. This will be much easier to work with.

This revision was automatically updated to reflect the committed changes.