DUMP=1 crystal build -Dhle_unions --prelude=empty --no-debug --no-color --emit=llvm-ir local_variable_hle_check.cr 2>local_variable_hle_check.ll
cat local_variable_hle_check.ll | FileCheck local_variable_hle_check.cr
Created
November 7, 2019 18:55
-
-
Save bcardiff/37c9528a54745e0217d9af28b590d8d8 to your computer and use it in GitHub Desktop.
Sample to use FileCheck with Crystal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The lock is at the end of the unions | |
# | |
# CHECK: %"(Bool | Int32)" = type { i32, [1 x i64], i32 } | |
local_var = uninitialized Int32 | Bool | |
# After the alloca the lock is initialized as free (1) | |
# | |
# CHECK: %local_var = alloca %"(Bool | Int32)" | |
# CHECK: %0 = getelementptr inbounds %"(Bool | Int32)", %"(Bool | Int32)"* %local_var, i32 0, i32 2 | |
# CHECK: store i32 1, i32* %0 | |
int32_type_id = 0.crystal_type_id | |
# CHECK: store i32 [[INT32_TID:[0-9]+]], i32* %int32_type_id | |
local_var = 2 | |
# CHECK: [[IR_LOCAL_VAR:%.*]] = getelementptr inbounds [[T:.*]], {{.*}}[[T]]* %local_var, i32 0, i32 1 | |
# CHECK: [[IR_LOCAL_VAR_BLOB_AS_INT32:%.*]] = bitcast {{.*}}* {{.*}}[[IR_LOCAL_VAR]] to i32* | |
# CHECK: [[IR_LOCAL_VAR_LOCK:%.*]] = getelementptr inbounds [[T:.*]], {{.*}}[[T]]* %local_var, i32 0, i32 2 | |
# CHECK: call void @spin_lock_hle(i32* {{.*}}[[IR_LOCAL_VAR_LOCK]]) | |
# CHECK: [[IR_LOCAL_VAR_TID:%.*]] = getelementptr inbounds [[T:.*]], {{.*}}[[T]]* %local_var, i32 0, i32 0 | |
# The assignment of type (11) and value (2) is performed around | |
# `@spin_lock_hle` / `@spin_unlock_hle` | |
# | |
# CHECK: store i32 {{.*}}[[INT32_TID]], i32* {{.*}}[[IR_LOCAL_VAR_TID]] | |
# CHECK: store i32 2, i32* {{.*}}[[IR_LOCAL_VAR_BLOB_AS_INT32]] | |
# CHECK: call void @spin_unlock_hle(i32* {{.*}}[[IR_LOCAL_VAR_LOCK]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment