-
Notifications
You must be signed in to change notification settings - Fork 139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[flang2] Full support for opaque pointers #1322
[flang2] Full support for opaque pointers #1322
Conversation
5fa8b7e
to
5d99839
Compare
@xinliu-hnc Please rebase the branch. |
5d99839
to
6d83bdc
Compare
Rebased. |
rewrite typed pointer with 'ptr'. 1. In the function 'make_bitcast()', a copy of the source with the type of the dest is returned when both the data types of source and dest are LL_PTR. 2. Due to the above modification, in function 'make_load()', flang should always get the load type from ll_type in the operand. 3. Remove the bitcast instruction used to store different types of results to the address of the return variable when processing ENTRY statements. 4. For some hard-coded typed pointers in code blocks controlled by conditional compilation macros, rewrite them with 'ptr'.
6d83bdc
to
2368c87
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
@xinliu-hnc Are any additional changes required? Have you tested the opaque pointer support on workloads outside of the Classic Flang regression tests? |
I don't have any additional changes. I've tested |
I compiled a simple test case: function cdexp (in1)
complex(kind=8) :: in1, cdexp
cdexp = exp(in1)
end function cdexp This emits the following IR: define void @cdexp_(ptr %cdexp, ptr %in1) !dbg !15 {
L.entry:
%.ka0000_338 = alloca <{double, double}>, align 16
br label %L.LB1_336
L.LB1_336:
%0 = bitcast ptr %.ka0000_338 to ptr, !dbg !18
%1 = bitcast ptr %in1 to ptr, !dbg !18
%2 = load <{double, double}>, ptr %1, align 1, !dbg !18
%3 = extractvalue <{double, double}> %2, 0, !dbg !18
%4 = bitcast ptr %in1 to ptr, !dbg !18
%5 = load <{double, double}>, ptr %4, align 1, !dbg !18
%6 = extractvalue <{double, double}> %5, 1, !dbg !18
%7 = bitcast ptr @__mth_i_cdexp to ptr, !dbg !18
%8 = call i32 (ptr, double, double, ...) %7 (ptr %0, double %3, double %6), !dbg !18
%9 = load <{double, double}>, ptr %.ka0000_338, align 1, !dbg !18
%10 = bitcast ptr %cdexp to ptr, !dbg !18
store <{double, double}> %9, ptr %10, align 8, !dbg !18
ret void, !dbg !19
} As you can see, there is a lot of unnecessary |
Apologies, this was a mistake on our part. The |
I think we have sufficient approvals to merge this. |
Could you please double check why the alignment of load instructions in generated IR ? Let's see the example above:
Why this pointer is loaded with |
Hi @inclyc, could you type-in some minimal reproducer for the observed problem? |
Hi @pawosm-arm , thanks for your quick reply! Just see the example above: #1322 (comment) |
LLVM IR verifier will add |
#1449 should fix this. |
This PR depends on PR #1321, rebase this branch after merging PR #1321 into the master branch.
This PR removes the redundant bitcast instructions generated by functions as well as the redundant bitcast instructions in some hard-coded strings, and for some hard-coded typed pointers in code blocks controlled by conditional compilation macros, we rewrite them. We also modify some test cases that use redundant bitcast instructions.