-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Kernel compilation failure when doing bitwise comparisons with sparse data structures #704
Labels
bug
We've confirmed that this is an BUG
Comments
KLozes
added
the
potential bug
Something that looks like a bug but not yet confirmed
label
Apr 3, 2020
You may also want to try |
@yuanming-hu I think we can have better error message (potentially indicating line number in IR) for assertion failures like this? So that CHI (#689) could become more mature. |
Thanks for reporting! Final IR of
LLVM complains
LLVM IR: define internal void @loop_body(%struct.Context*, %struct.Element*, i32, i32) {
allocs:
%4 = alloca i32
%5 = alloca %struct.PhysicalCoordinates
%6 = alloca %struct.PointerMeta
%7 = alloca %struct.DenseMeta
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.PointerMeta
%11 = alloca %struct.DenseMeta
br label %entry
entry: ; preds = %allocs
br label %loop_body
loop_body: ; preds = %entry
store i32 %2, i32* %4
br label %test
test: ; preds = %loop_body_tail, %loop_body
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, %3
br i1 %13, label %loop_body1, label %after_loop
loop_body1: ; preds = %test
%14 = call %struct.PhysicalCoordinates* @Element_get_ptr_pcoord(%struct.Element* %1)
%15 = load i32, i32* %4
call void @S2_refine_coordinates(%struct.PhysicalCoordinates* %14, %struct.PhysicalCoordinates* %5, i32 %15)
br i1 true, label %bound_guarded_loop_body, label %loop_body_tail
after_loop: ; preds = %test
ret void
ret void
loop_body_tail: ; preds = %after_if, %loop_body1
%16 = load i32, i32* %4
%17 = add i32 %16, 1
store i32 %17, i32* %4
br label %test
bound_guarded_loop_body: ; preds = %loop_body1
%18 = getelementptr %struct.PhysicalCoordinates, %struct.PhysicalCoordinates* %5, i32 0, i32 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr %struct.PhysicalCoordinates, %struct.PhysicalCoordinates* %5, i32 0, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call %struct.LLVMRuntime* @Context_get_runtime(%struct.Context* %0)
%23 = call i8* @LLVMRuntime_get_root(%struct.LLVMRuntime* %22)
%24 = bitcast i8* %23 to %S0_ch*
%25 = getelementptr %S0_ch, %S0_ch* %24, i32 0
%26 = bitcast %S0_ch* %25 to i8*
%27 = call i8* @get_ch_S0_to_S1(i8* %26)
%28 = bitcast i8* %27 to %0*
%29 = add i32 %19, 0
%30 = lshr i32 %29, 2
%31 = and i32 %30, 31
%32 = add i32 %21, 0
%33 = lshr i32 %32, 2
%34 = and i32 %33, 31
%35 = mul i32 %31, 32
%36 = add i32 %34, %35
%37 = bitcast %struct.PointerMeta* %6 to %struct.StructMeta*
call void @StructMeta_set_snode_id(%struct.StructMeta* %37, i32 1)
call void @StructMeta_set_element_size(%struct.StructMeta* %37, i64 128)
call void @StructMeta_set_max_num_elements(%struct.StructMeta* %37, i32 1024)
call void @StructMeta_set_context(%struct.StructMeta* %37, %struct.Context* %0)
call void @StructMeta_set_lookup_element(%struct.StructMeta* %37, i8* (i8*, i8*, i32)* @Pointer_lookup_element)
call void @StructMeta_set_is_active(%struct.StructMeta* %37, i32 (i8*, i8*, i32)* @Pointer_is_active)
call void @StructMeta_set_get_num_elements(%struct.StructMeta* %37, i32 (i8*, i8*)* @Pointer_get_num_elements)
call void @StructMeta_set_from_parent_element(%struct.StructMeta* %37, i8* (i8*)* @get_ch_S0_to_S1)
call void @StructMeta_set_refine_coordinates(%struct.StructMeta* %37, void (%struct.PhysicalCoordinates*, %struct.PhysicalCoordinates*, i32)* @S1_refine_coordinates)
%38 = bitcast %struct.PointerMeta* %6 to i8*
%39 = bitcast %0* %28 to i8*
%40 = call i8* @Pointer_lookup_element(i8* %38, i8* %39, i32 %36)
%41 = call i8* @get_ch_S1_to_S2(i8* %40)
%42 = bitcast i8* %41 to [16 x %S2_ch]*
%43 = add i32 %19, 0
%44 = lshr i32 %43, 0
%45 = and i32 %44, 3
%46 = add i32 %21, 0
%47 = lshr i32 %46, 0
%48 = and i32 %47, 3
%49 = mul i32 %45, 4
%50 = add i32 %48, %49
%51 = bitcast %struct.DenseMeta* %7 to %struct.StructMeta*
call void @StructMeta_set_snode_id(%struct.StructMeta* %51, i32 2)
call void @StructMeta_set_element_size(%struct.StructMeta* %51, i64 8)
call void @StructMeta_set_max_num_elements(%struct.StructMeta* %51, i32 16)
call void @StructMeta_set_context(%struct.StructMeta* %51, %struct.Context* %0)
call void @StructMeta_set_lookup_element(%struct.StructMeta* %51, i8* (i8*, i8*, i32)* @Dense_lookup_element)
call void @StructMeta_set_is_active(%struct.StructMeta* %51, i32 (i8*, i8*, i32)* @Dense_is_active)
call void @StructMeta_set_get_num_elements(%struct.StructMeta* %51, i32 (i8*, i8*)* @Dense_get_num_elements)
call void @StructMeta_set_from_parent_element(%struct.StructMeta* %51, i8* (i8*)* @get_ch_S1_to_S2)
call void @StructMeta_set_refine_coordinates(%struct.StructMeta* %51, void (%struct.PhysicalCoordinates*, %struct.PhysicalCoordinates*, i32)* @S2_refine_coordinates)
call void @DenseMeta_set_morton_dim(%struct.DenseMeta* %7, i32 0)
%52 = bitcast %struct.DenseMeta* %7 to i8*
%53 = bitcast [16 x %S2_ch]* %42 to i8*
%54 = call i8* @Dense_lookup_element(i8* %52, i8* %53, i32 %50)
%55 = call i8* @get_ch_S2_to_S3(i8* %54)
%56 = bitcast i8* %55 to i32*
%57 = load i32, i32* %56
%58 = and i32 %57, 2
%59 = icmp eq i32 %58, 2
%60 = sext i1 %59 to i32
%61 = and i32 1, %60
store i32 0, i32* %8
store i32 0, i32* %9
%62 = icmp ne i32 %61, 0
br i1 %62, label %true_block, label %false_block
true_block: ; preds = %bound_guarded_loop_body
%63 = getelementptr %struct.PhysicalCoordinates, %struct.PhysicalCoordinates* %5, i32 0, i32 0, i32 0
%64 = load i32, i32* %63
%65 = getelementptr %struct.PhysicalCoordinates, %struct.PhysicalCoordinates* %5, i32 0, i32 0, i32 1
%66 = load i32, i32* %65
%67 = call %struct.LLVMRuntime* @Context_get_runtime(%struct.Context* %0)
%68 = call i8* @LLVMRuntime_get_root(%struct.LLVMRuntime* %67)
%69 = bitcast i8* %68 to %S0_ch*
%70 = getelementptr %S0_ch, %S0_ch* %69, i32 0
%71 = bitcast %S0_ch* %70 to i8*
%72 = call i8* @get_ch_S0_to_S1(i8* %71)
%73 = bitcast i8* %72 to %0*
%74 = add i32 %64, 0
%75 = lshr i32 %74, 2
%76 = and i32 %75, 31
%77 = add i32 %66, 0
%78 = lshr i32 %77, 2
%79 = and i32 %78, 31
%80 = mul i32 %76, 32
%81 = add i32 %79, %80
%82 = bitcast %struct.PointerMeta* %10 to %struct.StructMeta*
call void @StructMeta_set_snode_id(%struct.StructMeta* %82, i32 1)
call void @StructMeta_set_element_size(%struct.StructMeta* %82, i64 128)
call void @StructMeta_set_max_num_elements(%struct.StructMeta* %82, i32 1024)
call void @StructMeta_set_context(%struct.StructMeta* %82, %struct.Context* %0)
call void @StructMeta_set_lookup_element(%struct.StructMeta* %82, i8* (i8*, i8*, i32)* @Pointer_lookup_element)
call void @StructMeta_set_is_active(%struct.StructMeta* %82, i32 (i8*, i8*, i32)* @Pointer_is_active)
call void @StructMeta_set_get_num_elements(%struct.StructMeta* %82, i32 (i8*, i8*)* @Pointer_get_num_elements)
call void @StructMeta_set_from_parent_element(%struct.StructMeta* %82, i8* (i8*)* @get_ch_S0_to_S1)
call void @StructMeta_set_refine_coordinates(%struct.StructMeta* %82, void (%struct.PhysicalCoordinates*, %struct.PhysicalCoordinates*, i32)* @S1_refine_coordinates)
%83 = bitcast %struct.PointerMeta* %10 to i8*
%84 = bitcast %0* %73 to i8*
%85 = call i8* @Pointer_lookup_element(i8* %83, i8* %84, i32 %81)
%86 = call i8* @get_ch_S1_to_S2(i8* %85)
%87 = bitcast i8* %86 to [16 x %S2_ch]*
%88 = add i32 %64, 0
%89 = lshr i32 %88, 0
%90 = and i32 %89, 3
%91 = add i32 %66, 0
%92 = lshr i32 %91, 0
%93 = and i32 %92, 3
%94 = mul i32 %90, 4
%95 = add i32 %93, %94
%96 = bitcast %struct.DenseMeta* %11 to %struct.StructMeta*
call void @StructMeta_set_snode_id(%struct.StructMeta* %96, i32 2)
call void @StructMeta_set_element_size(%struct.StructMeta* %96, i64 8)
call void @StructMeta_set_max_num_elements(%struct.StructMeta* %96, i32 16)
call void @StructMeta_set_context(%struct.StructMeta* %96, %struct.Context* %0)
call void @StructMeta_set_lookup_element(%struct.StructMeta* %96, i8* (i8*, i8*, i32)* @Dense_lookup_element)
call void @StructMeta_set_is_active(%struct.StructMeta* %96, i32 (i8*, i8*, i32)* @Dense_is_active)
call void @StructMeta_set_get_num_elements(%struct.StructMeta* %96, i32 (i8*, i8*)* @Dense_get_num_elements)
call void @StructMeta_set_from_parent_element(%struct.StructMeta* %96, i8* (i8*)* @get_ch_S1_to_S2)
call void @StructMeta_set_refine_coordinates(%struct.StructMeta* %96, void (%struct.PhysicalCoordinates*, %struct.PhysicalCoordinates*, i32)* @S2_refine_coordinates)
call void @DenseMeta_set_morton_dim(%struct.DenseMeta* %11, i32 0)
%97 = bitcast %struct.DenseMeta* %11 to i8*
%98 = bitcast [16 x %S2_ch]* %87 to i8*
%99 = call i8* @Dense_lookup_element(i8* %97, i8* %98, i32 %95)
%100 = call i8* @get_ch_S2_to_S4(i8* %99)
%101 = bitcast i8* %100 to i32*
store i32 1, i32* %101
br label %after_if
false_block: ; preds = %bound_guarded_loop_body
br label %after_if
after_if: ; preds = %false_block, %true_block
br label %loop_body_tail
}
Note after_loop: ; preds = %test
ret void
ret void |
yuanming-hu
added a commit
to yuanming-hu/taichi
that referenced
this issue
Apr 5, 2020
yuanming-hu
added
bug
We've confirmed that this is an BUG
and removed
potential bug
Something that looks like a bug but not yet confirmed
labels
Apr 5, 2020
yuanming-hu
added a commit
that referenced
this issue
Apr 5, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
Kernels fail to compile when using sparse data structures and doing more than 1 bitwise comparison in an if statement. Things seem to work fine with dense data structures and other comparisons. I believe this bug is very recent.
Log/Screenshots
To Reproduce
The text was updated successfully, but these errors were encountered: