Skip to content

[wasm] Blazor template AOT failures on windows. #49588

Closed
@lewing

Description

@lewing

We're getting a runtime exception after an Windows AOT build of the template app. It looks like we're generating incorrect bitcode when emitting direct icalls to ves_icall_System_Environment_get_TickCount and ves_icall_System_Environment_get_TickCount64 methods. It looks like a possible collision happening in the native symbol resolution.

It presents as
image

The relevant section of llvm-dis output: diff is from windows (-failing) -> osx (+working)

-  %4 = notail call i32 @ves_icall_System_Environment_get_TickCount64()
+  %4 = notail call i32 @ves_icall_System_Environment_get_TickCount()
   %5 = load i32*, i32** @aotconst_interruption_request_flag, align 4, !invariant.load !0
   %t6 = load i32, i32* %5, align 4
   %6 = icmp eq i32 %t6, 0
   %7 = call i1 @llvm.expect.i1(i1 %6, i1 true)
   br i1 %7, label %BB4, label %BB5
 
+BB4:                                              ; preds = %BB6, %BB2
+  br label %BB1
+
 BB5:                                              ; preds = %BB2
   %8 = load i32*, i32** getelementptr inbounds ([16 x i32*], [16 x i32*]* @dummy_got, i32 0, i32 0), align 4
   %9 = bitcast i32* %8 to i32* ()*
@@ -63229,22 +63238,19 @@ BB5:                                              ; preds = %BB2
   %13 = call i1 @llvm.expect.i1(i1 %12, i1 true)
   br i1 %13, label %BB6, label %BB7
 
-BB4:                                              ; preds = %BB6, %BB2
-  br label %BB1
-
 BB1:                                              ; preds = %BB4
   %14 = phi i32 [ %4, %BB4 ]
   ret i32 %14
 
+BB6:                                              ; preds = %BB5
+  br label %BB4
+
 BB7:                                              ; preds = %BB5
   %15 = load volatile i32*, i32** %entry, align 4
   %16 = ptrtoint i32* %15 to i32
   %t21 = add i32 %16, 68
   %17 = icmp eq i32 %t21, 0
-  br i1 %17, label %EX_BB3, label %NOEX_BB5, !make.implicit !2
-
-BB6:                                              ; preds = %BB5
-  br label %BB4
+  br i1 %17, label %EX_BB3, label %NOEX_BB5, !make.implicit !3
 
 EX_BB3:                                           ; preds = %BB7
   br label %EX2_BB4
@@ -63264,11 +63270,11 @@ NOEX_BB5:                                         ; preds = %BB7
 
 NOTINITED_BB7:                                    ; No predecessors!
   call coldcc void @mono_aot_corlib_init_method(i32* bitcast ([6 x i8]* @info_aot_wrapper_corlib_System_System_dot_Environment__get_TickCount_pinvoke_i4_i4_ to i32*))
-  store i8 1, i8* getelementptr inbounds ([13021 x i8], [13021 x i8]* @mono_inited, i32 0, i32 281), align 1
+  store i8 1, i8* getelementptr inbounds ([13027 x i8], [13027 x i8]* @mono_inited, i32 0, i32 281), align 1
   br label %INITED_BB2
 }
 
-declare hidden i32 @ves_icall_System_Environment_get_TickCount64()
+declare hidden i32 @ves_icall_System_Environment_get_TickCount()
 
 ; Function Attrs: noinline uwtable
 define dso_local i64 @aot_wrapper_corlib_System_System_dot_Environment__get_TickCount64_pinvoke_i8_i8_(i32* %dummy_arg) #8 {
@@ -63278,7 +63284,7 @@ BB0:
   br label %INIT_BB1
 
 INIT_BB1:                                         ; preds = %BB0
-  %is_inited = load i8, i8* getelementptr inbounds ([13021 x i8], [13021 x i8]* @mono_inited, i32 0, i32 282), align 1
+  %is_inited = load i8, i8* getelementptr inbounds ([13027 x i8], [13027 x i8]* @mono_inited, i32 0, i32 282), align 1
   %0 = call i8 @llvm.expect.i8(i8 %is_inited, i8 1)
   %1 = icmp eq i8 %0, 0
   br i1 %1, label %INITED_BB2, label %INITED_BB2
@@ -63293,40 +63299,40 @@ BB3:                                              ; preds = %INITED_BB2
   br label %BB2
 
 BB2:                                              ; preds = %BB3
-  %4 = notail call i64 bitcast (i32 ()* @ves_icall_System_Environment_get_TickCount64 to i64 ()*)()
+  %4 = notail call i64 @ves_icall_System_Environment_get_TickCount64()
   %5 = load i32*, i32** @aotconst_interruption_request_flag, align 4, !invariant.load !0
   %t10 = load i32, i32* %5, align 4
   %6 = icmp eq i32 %t10, 0
   %7 = call i1 @llvm.expect.i1(i1 %6, i1 true)
   br i1 %7, label %BB4, label %BB5
 
-BB5:                                              ; preds = %BB2
-  %8 = load i32*, i32** getelementptr inbounds ([16 x i32*], [16 x i32*]* @dummy_got, i32 0, i32 0), align 4
-  %9 = bitcast i32* %8 to i32* ()*
-  %10 = notail call i32* @aot_wrapper_icall_mono_thread_interruption_checkpoint()
-  store i32* %10, i32** %entry, align 4
-  %11 = ptrtoint i32* %10 to i32
-  %12 = icmp eq i32 %11, 0
-  %13 = call i1 @llvm.expect.i1(i1 %12, i1 true)
-  br i1 %13, label %BB6, label %BB7
-
 BB4:                                              ; preds = %BB6, %BB2
-  %14 = phi i64 [ %4, %BB2 ], [ %4, %BB6 ]
+  %8 = phi i64 [ %4, %BB2 ], [ %4, %BB6 ]
   br label %BB1
 
+BB5:                                              ; preds = %BB2
+  %9 = load i32*, i32** getelementptr inbounds ([16 x i32*], [16 x i32*]* @dummy_got, i32 0, i32 0), align 4
+  %10 = bitcast i32* %9 to i32* ()*
+  %11 = notail call i32* @aot_wrapper_icall_mono_thread_interruption_checkpoint()
+  store i32* %11, i32** %entry, align 4
+  %12 = ptrtoint i32* %11 to i32
+  %13 = icmp eq i32 %12, 0
+  %14 = call i1 @llvm.expect.i1(i1 %13, i1 true)
+  br i1 %14, label %BB6, label %BB7
+
 BB1:                                              ; preds = %BB4
-  %15 = phi i64 [ %14, %BB4 ]
+  %15 = phi i64 [ %8, %BB4 ]
   ret i64 %15
 
+BB6:                                              ; preds = %BB5
+  br label %BB4
+
 BB7:                                              ; preds = %BB5
   %16 = load volatile i32*, i32** %entry, align 4
   %17 = ptrtoint i32* %16 to i32
   %t31 = add i32 %17, 68
   %18 = icmp eq i32 %t31, 0
-  br i1 %18, label %EX_BB3, label %NOEX_BB5, !make.implicit !2
-
-BB6:                                              ; preds = %BB5
-  br label %BB4
+  br i1 %18, label %EX_BB3, label %NOEX_BB5, !make.implicit !3
 
 EX_BB3:                                           ; preds = %BB7
   br label %EX2_BB4
@@ -63346,10 +63352,12 @@ NOEX_BB5:                                         ; preds = %BB7
 
 NOTINITED_BB7:                                    ; No predecessors!
   call coldcc void @mono_aot_corlib_init_method(i32* bitcast ([6 x i8]* @info_aot_wrapper_corlib_System_System_dot_Environment__get_TickCount64_pinvoke_i8_i8_ to i32*))
-  store i8 1, i8* getelementptr inbounds ([13021 x i8], [13021 x i8]* @mono_inited, i32 0, i32 282), align 1
+  store i8 1, i8* getelementptr inbounds ([13027 x i8], [13027 x i8]* @mono_inited, i32 0, i32 282), align 1
   br label %INITED_BB2
 }
 
+declare hidden i64 @ves_icall_System_Environment_get_TickCount64()
+
 ; Function Attrs: noinline uwtable
 define internal void @corlib_System_Environment_FailFast_string(i32* %arg_message, i32* %dummy_arg) #8 {

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions