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

fix Issue 15745 - Inline Assembly stomped on by Profiling #11608

Merged
merged 1 commit into from Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/dmd/glue.d
Expand Up @@ -924,7 +924,7 @@ void FuncDeclaration_toObjFile(FuncDeclaration fd, bool multiobj)
* 2. impact on function inlining
* 3. what to do when writing out .di files, or other pretty printing
*/
if (global.params.trace && !fd.isCMain() && !fd.naked)
if (global.params.trace && !fd.isCMain() && !fd.naked && !(fd.hasReturnExp & 8))
Copy link
Member

Choose a reason for hiding this comment

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

hasReturnExp & 8
needs a comment, I know what it means but others might not

Copy link
Member Author

Choose a reason for hiding this comment

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

What it really needs is a refactoring of hasReturnExp into an enumeration of named flags, but refactoring that is beyond the scope of this fix. A grep of hasReturnExp will show where the bits are documented.

{
/* The profiler requires TLS, and TLS may not be set up yet when C main()
* gets control (i.e. OSX), leading to a crash.
Expand Down
27 changes: 26 additions & 1 deletion test/runnable/testprofile.d
Expand Up @@ -67,9 +67,34 @@ void test13331() {asm {naked; ret;}}

// ------------------

void main()
// https://issues.dlang.org/show_bug.cgi?id=15745

ubyte LS1B(uint board)
{
asm
{
bsf EAX, board;
}
}

void test15754()
{

for (int i = 0; i < 31; ++i)
{
auto slide = (1U << i);
auto ls1b = slide.LS1B;
assert(ls1b == i);
}
}

// ------------------

int main()
{
test1();
test5689();
test13331();
test15754();
return 0;
}