Closed CaviarChen closed 3 years ago
https://github.com/pschachte/wybe/commit/76cb705388277edcd7aab733692309eba568833c introduces an new bug. Compiling the code above gives:
Internal error: arguments in call list.reverse_helper<0>(~tmp$14#0:list.int_list, ~tmp$15#0:wybe.int, ~step#0:wybe.int, ~stop#0:wybe.int, ~tmp$0#0:list.int_list, ?result#1:list.int_list) #3 don't match params [lst#0:list.int_list,acc#0:list.int_list,?$#0:list.int_list]
CallStack (from HasCallStack):
error, called at src/AST.hs:3161:17 in main:AST
I'm trying to track this down, but I don't understand why it happens. It looks like some code is incorrectly transformed. Here's the last part of the log of Transform and BodyBuilder:
Transform: --- prim: reverse.gen$1<0>(~tmp$14#0:reverse.int_list, ~tmp$15#0:wybe.int, ~step#0:wybe.int, ~stop#0:wybe.int, ~tmp$0#0:reverse.int_list, ?result#1:reverse.int_list) #3 @reverse:5:5
Transform: --- transformed to: reverse.reverse_helper<0>(~tmp$14#0:reverse.int_list, ~tmp$15#0:wybe.int, ~step#0:wybe.int, ~stop#0:wybe.int, ~tmp$0#0:reverse.int_list, ?result#1:reverse.int_list) #3 @reverse:5:5
BodyBuilder: Expanded tmp$14#0 to Nothing
BodyBuilder: Expanded tmp$15#0 to Nothing
BodyBuilder: Expanded step#0 to Nothing
BodyBuilder: Expanded stop#0 to Nothing
BodyBuilder: Expanded tmp$0#0 to Nothing
Internal error: arguments in call reverse.reverse_helper<0>(~tmp$14#0:reverse.int_list, ~tmp$15#0:wybe.int, ~step#0:wybe.int, ~stop#0:wybe.int, ~tmp$0#0:reverse.int_list, ?result#1:reverse.int_list) #3 don't match params [lst#0:reverse.int_list,acc#0:reverse.int_list,?$#0:reverse.int_list]
So it looks to me like a call to reverse.gen$1<0>
is being transformed into a call to reverse.reverse_helper<0>
with the same arguments, which is where it goes off the rails.
I was trying to fix #87 but encountered this.
For example, the following code will have two generated procedure for
range
.Note that
gen$2
has the inline flag but it is not inlined ingen$1
. This is a problem because we skip procedures with the inline flag during alias analysis. In this case, we will miss the optimization opportunities ingen$2
. Even worse, the compiler may be misleaded by the emptyAliasPairs
of a procedure with the inline flag.