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

Fix debug locations for Proc pointers #11243

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add llvm-ir spec
  • Loading branch information
HertzDevil committed Sep 24, 2021
commit 3e5551aa1933aaaff84f76d6392e14ab63a5dbce
11 changes: 11 additions & 0 deletions spec/llvm-ir/proc-pointer-debug-loc.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def foo
end

(->foo).call

# CHECK: define internal void @"~procProc(Nil)
# CHECK-SAME: !dbg [[LOC1:![0-9]+]]
# CHECK-NEXT: entry:
# CHECK-NEXT: ret void, !dbg [[LOC2:![0-9]+]]
# CHECK-NEXT: }
# CHECK: [[LOC2]] = !DILocation(line: 4, column: 2, scope: [[LOC1]])
28 changes: 16 additions & 12 deletions spec/llvm-ir/test.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#!/bin/sh
#!/bin/bash

set -euo pipefail

SCRIPT_PATH="$(realpath "$0")"
SCRIPT_ROOT="$(dirname "$SCRIPT_PATH")"

BUILD_DIR=$SCRIPT_ROOT/../../.build
LLVM_CONFIG="$(basename $($SCRIPT_ROOT/../../src/llvm/ext/find-llvm-config))"
FILE_CHECK=FileCheck-"${LLVM_CONFIG#llvm-config-}"
crystal=$SCRIPT_ROOT/../../bin/crystal

mkdir -p $BUILD_DIR
Expand All @@ -16,30 +18,32 @@ function test() {
input_cr="$SCRIPT_ROOT/$1"
output_ll="$BUILD_DIR/${1%.cr}.ll"
compiler_options="$2"
check_prefix="$3"
check_prefix="${3+--check-prefix $3}"

# $BUILD_DIR/test-ir is never used
# pushd $BUILD_DIR + $output_ll is a workaround due to the fact that we can't control
# the filename generated by --emit=llvm-ir
$crystal build --single-module --no-debug --no-color --emit=llvm-ir $2 -o $BUILD_DIR/test-ir $input_cr
FileCheck $input_cr --input-file $output_ll --check-prefix $check_prefix
$crystal build --single-module --no-color --emit=llvm-ir $2 -o $BUILD_DIR/test-ir $input_cr
$FILE_CHECK $input_cr --input-file $output_ll $check_prefix

rm $BUILD_DIR/test-ir.o
rm $output_ll
}

pushd $BUILD_DIR >/dev/null

test memset.cr "--cross-compile --target i386-apple-darwin --prelude=empty" X32
test memset.cr "--cross-compile --target i386-unknown-linux-gnu --prelude=empty" X32
test memset.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty" X64
test memset.cr "--cross-compile --target x86_64-unknown-linux-gnu --prelude=empty" X64
test proc-pointer-debug-loc.cr "--cross-compile --target x86_64-unknown-linux-gnu --prelude=empty"

test memcpy.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty" X64
test memcpy.cr "--cross-compile --target x86_64-unknown-linux-gnu --prelude=empty" X64
test memset.cr "--cross-compile --target i386-apple-darwin --prelude=empty --no-debug" X32
test memset.cr "--cross-compile --target i386-unknown-linux-gnu --prelude=empty --no-debug" X32
test memset.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty --no-debug" X64
test memset.cr "--cross-compile --target x86_64-unknown-linux-gnu --prelude=empty --no-debug" X64

test cast-unions.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty" X64
test assign-unions.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty" X64
test memcpy.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty --no-debug" X64
test memcpy.cr "--cross-compile --target x86_64-unknown-linux-gnu --prelude=empty --no-debug" X64

test cast-unions.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty --no-debug" X64
test assign-unions.cr "--cross-compile --target x86_64-apple-darwin --prelude=empty --no-debug" X64

popd >/dev/null