Skip to content

Instantly share code, notes, and snippets.

View raviqqe's full-sized avatar
🐈‍⬛
Not eating lunch

Yota Toyama raviqqe

🐈‍⬛
Not eating lunch
View GitHub Profile

Keybase proof

I hereby claim:

  • I am raviqqe on github.
  • I am raviqqe (https://keybase.io/raviqqe) on keybase.
  • I have a public key whose fingerprint is B8ED 2942 7E9F 1DB3 A6A7 BB7D FDC7 028D 7AAE D55F

To claim this, I am signing this object:

@raviqqe
raviqqe / cps.lisp
Last active January 27, 2022 16:07
This file has been truncated, but you can view the full file.
(module
(function variant_clone_None _payload
(block
(deconstruct-union (union 0 _payload) 1 _fmm_0)
(deconstruct-union (union 0 _fmm_0) 1 _fmm_1)
(return _fmm_1)))
(function variant_drop_None _payload
(block
(deconstruct-union (union 0 _payload) 1 _fmm_2)
(return (record))))
This file has been truncated, but you can view the full file.
(module
(function variant_clone_None _payload
(block
(deconstruct-union (union 0 _payload) 1 _fmm_0)
(deconstruct-union (union 0 _fmm_0) 1 _fmm_1)
(return _fmm_1)))
(function variant_drop_None _payload
(block
(deconstruct-union (union 0 _payload) 1 _fmm_2)
(return (record))))
xs = [1, 2, 3]
ys = [4, 5, 6]
print([[x, y] for x in xs for y in ys])
==1210358== Memcheck, a memory error detector
==1210358== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1210358== Using Valgrind-3.18.1 and LibVEX; rerun with -h for copyright info
==1210358== Command: ./app
==1210358== Parent PID: 476735
==1210358==
==1210358==
==1210358== Process terminating with default action of signal 2 (SIGINT)
==1210358== at 0x487EE68: __pthread_initialize_minimal (in /usr/lib/libpthread-2.33.so)
==1210358== by 0x487E00C: ??? (in /usr/lib/libpthread-2.33.so)

Stack pointer offset calculation bug for spilled arguments on llc -tailcallopt

Description

llc seems to calculate wrong stack pointer offsets for spilled arguments on tail calls with its -tailcallopt option.

Example

The code below is the bug where a stack pointer offset is miscalculated.

; ModuleID = '840c8f9e80eb3a7b.bc'
target triple = "x86_64-unknown-linux-gnu"
@"/.pen/default/packages/cc2ed307d895f924/Print.pen:Line" = external global { {} ({ i8*, i64, i64 }*, {} ({ i8*, i64, i64 }*, { { {} (i64)*, {} (i64)* }*, i64 })*, {}*, {}*, { i64, i8 }*)*, {} (i64)*, {} }
@"/.pen/default/packages/cc2ed307d895f924/Print.pen:Lines" = external global { {} ({ i8*, i64, i64 }*, {} ({ i8*, i64, i64 }*, { { {} (i64)*, {} (i64)* }*, i64 })*, {}*, {}*, {}*)*, {} (i64)*, {} }
@"/.pen/default/packages/fb4346304f4058b6/Context.pen:New" = external global { {} ({ i8*, i64, i64 }*, {} ({ i8*, i64, i64 }*, {}*)*, {}*)*, {} (i64)*, {} }
@"/.pen/default/packages/fb4346304f4058b6/Context.pen:Inner" = external global { {} ({ i8*, i64, i64 }*, {} ({ i8*, i64, i64 }*, {}*)*, {}*, {}*)*, {} (i64)*, {} }
@"/.pen/default/packages/fb4346304f4058b6/Environment.pen:Arguments" = external global { {} ({ i8*, i64, i64 }*, {} ({ i8*, i64, i64 }*, {}*)*, {}*, {}*)*, {} (i64)*, {} }
@"/.pen/default/packages/fb4346304f4058b6/Enviro

Union ABI in the C calling convention

#include <stdio.h>

union u {
  struct s {
    int x;
    int y;
  } x;

uint64_t vs double in C

Codes

uint64_t

#include <stdint.h>

int main() {
/*
* object.h - SML# heap object format
* @copyright (c) 2007, Tohoku University.
* @author UENO Katsuhiro
*/
#ifndef SMLSHARP__OBJECT_H__
#define SMLSHARP__OBJECT_H__
#include <limits.h>