opendylan icon indicating copy to clipboard operation
opendylan copied to clipboard

Duplicated tagging in literal byte characters (C backend, x86_64 linux)

Open abeaumont opened this issue 12 years ago • 8 comments

When running apple-dylan-test-suite some character comparing tests give rare failures:

failed ['\216' ~= 'c']

Looking at C code, the problem seems to be a duplicated tagging:

T1 = primitive_raw_as_byte_character(C('c'));

abeaumont avatar Mar 28 '13 20:03 abeaumont

It seems that the problem already appears at the DFM:

t13 := [PRIMOP raw-as-byte-character(^'c')]

abeaumont avatar Mar 28 '13 21:03 abeaumont

I'm lazy. Can I have a couple of lines of Dylan that I can copy-paste into a hello world that demonstrate the issue?

waywardmonkeys avatar Mar 30 '13 15:03 waywardmonkeys

I have failed to reproduce it with a minimal test case so far, since it seems to be optimization dependent.

abeaumont avatar Apr 01 '13 09:04 abeaumont

Code to reproduce it:

module: string-aref-test

define function main ()
  let t = "abcdefg";
  let (a, b) = method() values(t[2], 'c') end();
  format-out("%= %=\n", a, b);
  let (c, d) = values(t[2], 'c');
  format-out("%= %=\n", c, d);
  let x = #[1, 2, 3, 4];
  let (e, f) = method() values(x[2], 'c') end();
  format-out("%= %=\n", e, f);
end function main;

main()

abeaumont avatar Mar 21 '16 17:03 abeaumont

Generated DFM:

METHOD main () => (#rest results)
  t26 := [PRIMOP raw-as-byte-character(^'c')]
  Vt20 := [STACK-VECTOR (t26, ^'c')]
  [CONGRUENT-CALLi ^{<&method> format-out (<string>)}(^"%= %=\n", Vt20)]
  Vt16 := [STACK-VECTOR (^'c', ^'c')]
  [CONGRUENT-CALLi ^{<&method> format-out (<string>)}(^"%= %=\n", Vt16)]
  t17 := [METHOD-CALLi ^{<&method> element (<simple-object-vector>, <integer>)}(^#[1, 2, 3, 4], ^2, ^#[], ^{<&generic> unsupplied-object})]
  Vt13 := [STACK-VECTOR (t17, ^'c')]
  *t18(0,#rest) := [CONGRUENT-CALLi ^{<&method> format-out (<string>)}(^"%= %=\n", Vt13)] // tail call
  return *t18(0,#rest)
END

METHOD top-level-initializer () => ()
  *t1(0) := [CONGRUENT-CALLi ^{<&method> main ()}()] // tail call
  return *t1(0)
END

abeaumont avatar Mar 21 '16 17:03 abeaumont

Error with LLVM back-end:

Generating code for library string-aref-test
computation t42 := [PRIMOP raw-as-byte-character(^'c')]: Error:
  No applicable method, applying {generic function llvm-integer-type-width (<object>) => (#rest)} to
  #[{<llvm-pointer-type> #x01C4CD60 i8*}].

emit KmainVstring_aref_testI: Error:
  No applicable method, applying {generic function llvm-integer-type-width (<object>) => (#rest)} to
  #[{<llvm-pointer-type> #x01C4CD60 i8*}].

waywardmonkeys avatar Mar 21 '16 17:03 waywardmonkeys

This may be in similar code to what is discussed in #289.

waywardmonkeys avatar Mar 22 '16 13:03 waywardmonkeys

Effectively it's the same code as discussed in #289. The problem is that the following code:

t14 := REPEATED-SLOT-VALUE(^"abcdefg", string-element, ^%9)
t15 := [PRIMOP raw-as-byte-character(t14)]

which works properly, is being replaced in that constant-fold optimization method by:

t15 := [PRIMOP raw-as-byte-character(^'c')]

which doesn't.

So I guess that REPEATED_SLOT_VALUE returns a raw value which is being replaced by an inmediate value. What I don't understand yet is why this only seems to affect strings/characters and not integer vectors, for example

abeaumont avatar Mar 22 '16 19:03 abeaumont