Skip to content
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: An attempt to introduce opaque pointers to flang #1306

Closed
wants to merge 1 commit into from

Conversation

pawosm-arm
Copy link
Collaborator

@pawosm-arm pawosm-arm commented Oct 13, 2022

This is my naïve approach, it's not perfect, uses ptr to ptr bitcasts, but may work as well.

Won't be of any use until we shift to LLVM15.

Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>
@bryanpkc
Copy link
Collaborator

@pawosm-arm @kiranchandramohan @shivaramaarao Is it important to keep the master branch backward-compatible with LLVM 14 and older releases, perhaps with liberal uses of macros or by duplicating files? IMHO it's probably better to create a new master branch that uses opaque pointers only, and dual-maintain both branches until nobody needs the old master branch any more. What do you think?

@@ -272,7 +272,7 @@ write_prototypes(FILE *out, LLVMModuleRef module)

if (text_calls) {
fprintf(out, "declare i64 @llvm.nvvm.texsurf.handle.p1i64(metadata, i64 "
"addrspace(1)*) nounwind readnone\n");
"ptr addrspace(1)) nounwind readnone\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete i64 in the previous line:
i64 addrspace(1)* -> ptr addrspace(1)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, good cacth. Seems this is something that wouldn't ever be executed in our ecosystem.

elem_type, AG_TYPENAME(gblsym), AG_NAME(gblsym));
"ptr bitcast(ptr getelementptr("
"%sptr @%s, i32 0) to ptr)",
elem_type, AG_NAME(gblsym));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the bitcast instruction:

            "ptr getelementptr(%sptr @%s, i32 0)",
            elem_type, AG_NAME(gblsym));

elem_type, n_elts, name, suffix ? suffix : "");
"ptr bitcast(ptr getelementptr("
"%sptr @%s%s, i32 0) to ptr)",
elem_type, name, suffix ? suffix : "");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the bitcast instruction:

            "ptr getelementptr(%sptr @%s%s, i32 0)",
            elem_type, name, suffix ? suffix : "");

initname, initname, ADDRESSG(TYPDEF_INITG(tag)));
" ptr bitcast(ptr getelementptr(i8, ptr "
"@%s, i32 %ld) to ptr),\n",
initname, ADDRESSG(TYPDEF_INITG(tag)));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the bitcast instruction:

              "     ptr getelementptr(i8, ptr @%s, i32 %ld),\n",
              initname, ADDRESSG(TYPDEF_INITG(tag)));

",\n", name, name);
" ptr bitcast(ptr getelementptr(i8, ptr "
"@%s$parents, i32 0) to ptr)"
",\n", name);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the bitcast instruction:

              "     ptr getelementptr(i8, ptr @%s$parents, i32 0),\n", name);

@@ -153,7 +153,7 @@ write_proc_pointer(SPTR sptr)
if (abi) {
fntype = ll_abi_function_type(abi)->str;
}
fprintf(ASMFIL, "i8* bitcast(%s* @%s to i8*)", fntype, getsname(sptr));
fprintf(ASMFIL, "ptr bitcast(ptr @%s to ptr)", getsname(sptr));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable fntype is no longer used. Please delete the related code and the bitcast instruction.

fprintf(ASMFIL, " }>\n@%s = alias %s%sbitcast (<{%s}>* @%s.%d to %s*)",
getsname(sptr), alTy, alSep, bare, getsname(sptr), sptr, typed);
fprintf(ASMFIL, " }>\n@%s = alias %s%sbitcast (ptr @%s.%d to ptr)",
getsname(sptr), alTy, alSep, getsname(sptr), sptr);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the bitcast instruction:

      fprintf(ASMFIL, " }>\n@%s = alias %s%sptr @%s.%d",
              getsname(sptr), alTy, alSep, getsname(sptr), sptr);

"\t%%prof.thisfn = bitcast %s* @%s to i8*\n"
"\t%%prof.callsite = call i8*(i32) @" PROF_CALLSITE "(i32 0)\n",
currFnTy->str, currFn);
"\t%%prof.thisfn = bitcast ptr @%s to ptr\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The no-op bitcasts are redundant in the IR, please delete the bitcast instruction:

"\t%%prof.thisfn = ptr @%s\n"

@@ -4100,7 +4100,7 @@ lldbg_function_end(LL_DebugInfo *db, int func)
sname = getsname(i); // temporary pointer
buff = (char *)getitem(LLVM_LONGTERM_AREA, strlen(name) + strlen(sname) +
strlen(type->str) + 25);
sprintf(buff, "bitcast (%%struct%s* @%s to %s)", sname, name, type->str);
sprintf(buff, "bitcast (ptr @%s to %s)", name, type->str);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable sname is no longer used. Please delete the related code and the bitcast instruction for the pointer type.

@bryanpkc
Copy link
Collaborator

@pawosm-arm Would you have time to work on this PR?

@pawosm-arm
Copy link
Collaborator Author

@pawosm-arm Would you have time to work on this PR?

Good question. Sadly, time management is the reason I may need to abandon this patch. As I said, I'm taking no credits on this one, so feel free to build on it if you need it.

@bryanpkc
Copy link
Collaborator

Superceded by #1321.

@bryanpkc bryanpkc closed this Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants