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

Windows: Problem with passing arguments by value #12

Closed
SigmundVik opened this issue May 6, 2011 · 2 comments
Closed

Windows: Problem with passing arguments by value #12

SigmundVik opened this issue May 6, 2011 · 2 comments
Assignees

Comments

@SigmundVik
Copy link
Contributor

Running Emscripten with llvm 2.9 on my Windows system, test_raytrace fails with this output in src.cpp.o.js:

analyzer.js:285: TypeError: Cannot read property 'derivedTypes' of undefined
              if (!func.variables[item.value.ident].derivedTypes) {
                                                   ^

The problem seems to be related to Emscripten not understanding this llvm function signature:

define internal %struct.node_t* @_Z6createP6node_tii3v_tS1_d(%struct.node_t* %n, i32 %lvl, i32 %dist, %struct.v_t* byval align 4, %struct.v_t* byval align 4, double %r)

The complete llvm output can be found here (please note that I had to change iostream usage with printfs to make it compile):
http://pastebin.com/7s7vV5xJ

If I pass the v_t structs by const reference instead of by value in the create() function the test passes. In this case the llvm function signature looks like this:

define internal %struct.node_t* @_Z6createP6node_tiiRK3v_tS3_d(%struct.node_t* %n, i32 %lvl, i32 %dist, %struct.v_t* %c, %struct.v_t* %d, double %r)

If I insert these lines before line 285 in analyzer.js:

print(JSON.stringify(item.value.ident));
print(JSON.stringify(func.variables));

I get that item.value.ident is "$0", and then there is this oddly looking entry in func.variables:

"4":{"ident":"4","type":"%struct.v_t*byvalalign","origin":"funcparam","lineNum":216,"uses":null}

I'm guessing the "4" here comes from the parameter declaration:

%struct.v_t* byval align 4
@ghost ghost assigned kripken May 10, 2011
@kripken
Copy link
Member

kripken commented May 10, 2011

This should be fixed by commit 123385f. SiggyBar, can you please verify?

@SigmundVik
Copy link
Contributor Author

Yes, commit 123385f fixed this, thanks! Closing. (Urk, hit "Comment" instead of "Comment & Close", trying again!)

tlively pushed a commit to tlively/emscripten that referenced this issue Mar 23, 2022
…-quota-checks

Add safeguards against QuotaExceededErrors in SFA
steveisok pushed a commit to steveisok/emscripten that referenced this issue Sep 18, 2023
…721.1 (emscripten-core#12)

[dotnet/main] Update dependencies from dotnet/arcade
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

No branches or pull requests

2 participants