Skip to content

[for information only] LDC diff with DMD: 2.077.1#7506

Closed
JohanEngelen wants to merge 1 commit intodlang:masterfrom
JohanEngelen:dmd-ldc-diff
Closed

[for information only] LDC diff with DMD: 2.077.1#7506
JohanEngelen wants to merge 1 commit intodlang:masterfrom
JohanEngelen:dmd-ldc-diff

Conversation

@JohanEngelen
Copy link
Contributor

@JohanEngelen JohanEngelen commented Dec 24, 2017

Copy-paste of LDC master 24 Dec (8c0abd5220e4993d66336b57742c1988dfd73d3f) onto DMD 2.077.1

Continuation of #4688

Note: parts of the diff have already been applied to DMD master.

@dlang-bot
Copy link
Contributor

Thanks for your pull request, @JohanEngelen! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.

Some tips to help speed things up:

  • smaller, focused PRs are easier to review than big ones

  • try not to mix up refactoring or style changes with bug fixes or feature enhancements

  • provide helpful commit messages explaining the rationale behind each change

Bear in mind that large or tricky changes may require multiple rounds of review and revision.

Please see CONTRIBUTING.md for more information.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@JohanEngelen JohanEngelen changed the title LDC diff with DMD LDC diff with DMD: 2.077.1 Dec 24, 2017
Copy link
Member

@ibuclaw ibuclaw left a comment

Choose a reason for hiding this comment

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

There's an awful lot here, and I gave up looking at it. :-)

void semanticTypeInfoMembers();
Dsymbol *search(Loc, Identifier *ident, int flags = SearchLocalsOnly);
const char *kind();
const char *kind() const;
Copy link
Member

Choose a reason for hiding this comment

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

Why?

}
return createNewScope(sc, sc.stc, sc.linkage, sc.cppmangle, sc.protection, sc.explicitProtection, sc.aligndecl, inlining);
}
else if (IN_LLVM && ident == Id.LDC_profile_instr) {
Copy link
Member

Choose a reason for hiding this comment

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

Propose a way to add pragmas to the frontend via a hook. (Maybe #7457 might be the place to put it).

void addMember(Scope *sc, ScopeDsymbol *sds);
void setScope(Scope *sc);
void importAll(Scope *sc);
void semantic(Scope *sc);
Copy link
Member

Choose a reason for hiding this comment

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

Why? Semantic passes should have been removed and visitor()-ized.

Copy link
Contributor

Choose a reason for hiding this comment

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

It's just a merge artefact – benign, as the function is not virtual, but fixed in master nevertheless.

Dsymbols *include(Scope *sc, ScopeDsymbol *sds);
void addMember(Scope *sc, ScopeDsymbol *sds);
void addComment(const char *comment);
void addComment(const utf8_t *comment);
Copy link
Member

Choose a reason for hiding this comment

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

Wasn't this committed recently?

version(IN_LLVM)
{

private Type getTypeOfOverloadedIntrinsic(FuncDeclaration fd)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe same as per comment on pragmas. Need a way to extend front-end built-ins for each compiler (although gdc just ignores this module).

// if there is no offset. With an offset, we can at least say that it is
// non-zero.
SymOffExp soe = cast(SymOffExp) e;
if (soe.var.llvmInternal == LDCPragma.LLVMextern_weak && !soe.offset)
Copy link
Member

Choose a reason for hiding this comment

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

Bug / test for this? Seems innocuous.

Copy link
Contributor

@dnadlinger dnadlinger Dec 25, 2017

Choose a reason for hiding this comment

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

This is related to an LDC-only pragma, LDC_extern_weak, which can be used to implement ELF-style weak symbols (on targets that support them). The frontend would constant-fold away the null checks to see whether they are present, since it assumed that symbol addresses are always non-zero (the 2 below). There is a regression test for it in our lit test suite.

(In fact, the pragma was never publicly documented, as I wanted to have something portable across the compilers instead, but I needed it to implement shared libraries in a way that is compatible with --gc-sections due to a certain ld.bfd bug. If the pragma was added upstream, this hunk would also apply.)

{
// Cast the CommaExp instead of the inner rhs; this fixes
// https://github.com/ldc-developers/ldc/issues/2415.
result = new CastExp(e.loc, e, e2c.type);
Copy link
Member

Choose a reason for hiding this comment

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

Can't you handle this properly in code-gen?


// Whether to emit instrumentation code if -fprofile-instr-generate is specified,
// the value is set with pragma(LDC_profile_instr, true|false)
bool emitInstrumentation;
Copy link
Member

Choose a reason for hiding this comment

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

Can't you do heuristics at code-gen level?

errorSupplemental(loc, "ldc2 might not be correctly installed.");
errorSupplemental(loc, "Please check your ldc2.conf configuration file.");
errorSupplemental(loc, "Installation instructions can be found at http://wiki.dlang.org/LDC.");
}
Copy link
Member

Choose a reason for hiding this comment

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

We need a way to have a per-compiler message here, again with Compiler hook.

// Coverage analysis
void* d_cover_valid; // llvm::GlobalVariable* --> private immutable size_t[] _d_cover_valid;
void* d_cover_data; // llvm::GlobalVariable* --> private uint[] _d_cover_data;
Array!size_t d_cover_valid_init; // initializer for _d_cover_valid
Copy link
Member

Choose a reason for hiding this comment

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

Can't you attach this data to LLVM AST?

@skl131313
Copy link
Contributor

Why is this being merged into dmd? Unless tests get added for it, it'll constantly be broken and just adds bloat otherwise.

@JinShil
Copy link
Contributor

JinShil commented Dec 24, 2017

@skl131313 It's just informational. It is not intended to be merged.

@JinShil JinShil added the Compiler:LDC LLVM based D Compiler label Dec 24, 2017
@WalterBright
Copy link
Member

@ibuclaw @JohanEngelen Since dmd doesn't use the C++ .h files anymore, I'll defer the merging of them to you guys.

@ibuclaw
Copy link
Member

ibuclaw commented Dec 24, 2017

Since dmd doesn't use the C++ .h files anymore, I'll defer the merging of them to you guys.

Well, any changes to struct/class layout must also be reflected on the D side too. Otherwise there'd be linker problems, or worse, runtime corruption.

@andralex
Copy link
Member

So what's the story here? There seems to be a lot of good stuff here but it's in a form that's difficult to review.

@JohanEngelen JohanEngelen changed the title LDC diff with DMD: 2.077.1 [for information only] LDC diff with DMD: 2.077.1 Jan 20, 2018
@JinShil
Copy link
Contributor

JinShil commented Mar 23, 2018

@JohanEngelen Has this PR served its purpose? Can you update it, or can we close it?

@WalterBright WalterBright added the Review:Phantom Zone Has value/information for future work, but closed for now label Mar 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compiler:LDC LLVM based D Compiler Review:Needs Rebase Review:Needs Work Review:Phantom Zone Has value/information for future work, but closed for now Review:WIP Work In Progress - not ready for review or pulling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants