Page MenuHomePhabricator

Expose target-specific pre-linking passes in TargetMachine
AbandonedPublic

Authored by yaxunl on May 26 2016, 7:43 AM.

Details

Summary

Sometimes a backend needs to apply certain target-specific passes before linking. These passes sit in target directory and Clang needs a way to access them.

This patch attempts to expose target-specific pre-linking passes by adding a virtual member function addPreLinkPasses to TargetMachine.

The link to the discussion in cfe-dev about pre-linking passes is here:

http://lists.llvm.org/pipermail/cfe-dev/2016-May/048822.html

The related Clang change is here:

http://reviews.llvm.org/D20681

Diff Detail

Event Timeline

yaxunl updated this revision to Diff 58610.May 26 2016, 7:43 AM
yaxunl retitled this revision from to Expose target-specific pre-linking passes in TargetMachine.
yaxunl updated this object.
yaxunl added a reviewer: chandlerc.
yaxunl added a comment.Jun 6 2016, 8:56 AM

Ping

Chandler, could you please take a look? Thanks.

yaxunl updated this revision to Diff 60106.Jun 8 2016, 2:43 PM

Remove unnecessary argument.

yaxunl updated this object.Jun 13 2016, 8:44 AM
yaxunl added reviewers: dsanders, echristo, mehdi_amini.

Daniel, Christopher, Mehdi,

Sorry to add you as my reviewers without asking first. Would you please review my patch if you get time? Thanks.

mehdi_amini edited edge metadata.Jun 13 2016, 8:53 AM

(general comment: upload patches with full context please)

include/llvm/Target/TargetMachine.h
259

The comment is not very useful, it basically repeats the function name and would still let me puzzled.

I read the thread on cfe-dev, but I'm still don't really sure to understand where it would be called, do you have the clang patch ready?

mehdi_amini added inline comments.Jun 13 2016, 10:09 AM
include/llvm/Target/TargetMachine.h
259

Just saw the link to the clang patch in the description....

chandlerc requested changes to this revision.Jun 13 2016, 7:11 PM
chandlerc edited edge metadata.

I fundamentally do not believe that the TargetMachine should be involved in fixing language semantics issues with a "pre linking" pass at the LLVM level. Why? Because there is nothing "target" about this.

There needs to be a fundamentally more principled way of handling this at the language and frontend level IMO.

This revision now requires changes to proceed.Jun 13 2016, 7:11 PM

I fundamentally do not believe that the TargetMachine should be involved in fixing language semantics issues with a "pre linking" pass at the LLVM level. Why? Because there is nothing "target" about this.

There needs to be a fundamentally more principled way of handling this at the language and frontend level IMO.

I personally don't think adding more target specific details to frontend is a good idea from the point of view of modular design.

It would be nice to understand why you think that this is not target enough for this purpose.

echristo edited edge metadata.Jun 14 2016, 1:44 PM

I've read the cfe-dev summary and I'm still not sure why you need this - what's going on here?

-eric

I've read the cfe-dev summary and I'm still not sure why you need this - what's going on here?

-eric

Basically some OpenCL builtin functions are not easily implemented by library only. Instead, they need to be transformed by some pre-linking passes then linked with the library. These passes are target specific, so they need to stay in the specific target directory. Then we need a way to tell Clang that we want these passes before linking with libraries for this target.

How is it "target specific" (in the backend sense) and not "toolchains" or "platform" specific?

Also "PreLinking" is really not a great choice (and the two patches could benefit from a lot more documentation) as linking is usually what happens when the compiler is done.

yaxunl abandoned this revision.Aug 9 2016, 8:33 AM