Duplicated tagging in literal byte characters (C backend, x86_64 linux)
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'));
It seems that the problem already appears at the DFM:
t13 := [PRIMOP raw-as-byte-character(^'c')]
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?
I have failed to reproduce it with a minimal test case so far, since it seems to be optimization dependent.
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()
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
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*}].
This may be in similar code to what is discussed in #289.
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