This is an archive of the discontinued LLVM Phabricator instance.

[clang-offload-wrapper] Add data layout to the wrapper bitcode
AbandonedPublic

Authored by sdmitriev on Nov 21 2019, 10:37 AM.

Details

Reviewers
ABataev

Diff Detail

Event Timeline

sdmitriev created this revision.Nov 21 2019, 10:37 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 21 2019, 10:37 AM

Why do we need this?

Why do we need this?

To pass wrapper bitcode directly to the linker when LTO is enabled. LTO plugin does not accept bc if there is no data layout.

Why do we need this?

To pass wrapper bitcode directly to the linker when LTO is enabled. LTO plugin does not accept bc if there is no data layout.

Maybe it would better to pass it a parameter just like for opt?

Why do we need this?

To pass wrapper bitcode directly to the linker when LTO is enabled. LTO plugin does not accept bc if there is no data layout.

Maybe it would better to pass it a parameter just like for opt?

In this case clang driver would need to get it from somewhere in order to pass it to the wrapper tool. I do not know where it can get it from.

Why do we need this?

To pass wrapper bitcode directly to the linker when LTO is enabled. LTO plugin does not accept bc if there is no data layout.

Maybe it would better to pass it a parameter just like for opt?

In this case clang driver would need to get it from somewhere in order to pass it to the wrapper tool. I do not know where it can get it from.

TargetInfo class is not accessible in the driver?

Why do we need this?

To pass wrapper bitcode directly to the linker when LTO is enabled. LTO plugin does not accept bc if there is no data layout.

Maybe it would better to pass it a parameter just like for opt?

In this case clang driver would need to get it from somewhere in order to pass it to the wrapper tool. I do not know where it can get it from.

TargetInfo class is not accessible in the driver?

Ah, I see, you mean clang's TargetInfo. Let me check if/how it will work.

Ok, it is possible to do it like you suggested, but I think that teaching wrapper tool to set data layout without external help is more preferable. There is a certain difference between opt and wrapper tool – opt works on the existing .bc that is provided in command line and data-layout option just gives user an optional way to override input’s data layout while wrapper tool creates output .bc from scratch. With your proposal, data-layout would become sort of mandatory option for the wrapper tool which is not very convenient. I believe wrapper tool should be able to set it without external help, and we can always add an option to override data layout (similar to opt) if there would be a need for that.

Ok, it is possible to do it like you suggested, but I think that teaching wrapper tool to set data layout without external help is more preferable. There is a certain difference between opt and wrapper tool – opt works on the existing .bc that is provided in command line and data-layout option just gives user an optional way to override input’s data layout while wrapper tool creates output .bc from scratch. With your proposal, data-layout would become sort of mandatory option for the wrapper tool which is not very convenient. I believe wrapper tool should be able to set it without external help, and we can always add an option to override data layout (similar to opt) if there would be a need for that.

Why it is not convenient? Plus, when you're trying to build the data layout yourself, you end up with the default one for the given target rather than rely on the one specified by the user when the driver was invoked. So, I think, it would be better to get the data layout from the driver rather than use the default one.

I would agree with you if data layout was indeed available in the driver, but unfortunately driver does not have access to any existing TargetInfo instance (or maybe I just have not found it). So, I have to create TargetInfo and build data layout even for the case when driver passes it to the wrapper tool. I guess that would also be a default data layout, so it would not differ much from what I have already done in this patch. BTW, I will probably upload an alternative patch where I have implemented your suggestion, just to compare))

I would agree with you if data layout was indeed available in the driver, but unfortunately driver does not have access to any existing TargetInfo instance (or maybe I just have not found it). So, I have to create TargetInfo and build data layout even for the case when driver passes it to the wrapper tool. I guess that would also be a default data layout, so it would not differ much from what I have already done in this patch. BTW, I will probably upload an alternative patch where I have implemented your suggestion, just to compare))

Of course, this is not a good solution. I was hoping that TargetInfo is available in driver. Otherwise, it would be good somehow to read the target data from the .bc file.

Wrapper tool is invoked at link phase, therefore there just could be no .bc files available to read data layout from. Ok, looks like there is no good solution for the data layout problem, so I will drop the idea of passing wrapper .bc directly to the linker when LTO is enabled (at least for now:). I will abandon this patch.

sdmitriev abandoned this revision.Nov 22 2019, 1:54 PM