[llvm] r207713 - Patch for function cloning to inline all blocks whose address is taken

Joerg Sonnenberger joerg at britannica.bec.de
Sat May 17 09:04:41 PDT 2014


On Thu, May 15, 2014 at 01:06:31PM -0700, Eric Christopher wrote:
> On Wed, May 14, 2014 at 7:03 PM, Joerg Sonnenberger
> <joerg at britannica.bec.de> wrote:
> > On Wed, Apr 30, 2014 at 10:05:03PM -0000, Gerolf Hoflehner wrote:
> >> Author: ghoflehner
> >> Date: Wed Apr 30 17:05:02 2014
> >> New Revision: 207713
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=207713&view=rev
> >> Log:
> >> Patch for function cloning to inline all blocks whose address is taken
> >
> > This breaks the build of Ruby 1.9.3. Can't give you more details yet
> > except that the initial version crashes.
> >
> 
> Do you have any more data on this Joerg? Since this is currently not
> being used we can revert it - it was a patch to fix some possibly bad
> behavior when we got smarter about inlining and proving safety.
> 
> Gerolf: any other thoughts?

Attached are two source files that exhibit the problem on Linux/AMD64
when compiled with -O2.

Joerg
-------------- next part --------------
struct rb_iseq_struct {
  int *iseq_encoded
} rb_iseq_compile_node(p1) {
  rb_iseq_translate_threaded_code(p1);
}

rb_iseq_translate_threaded_code(struct rb_iseq_struct *p1) {
  void **a = rb_vm_get_insns_address_table();
  p1->iseq_encoded = ruby_xmalloc2();
  p1->iseq_encoded[0] = a[0];
}

main() {
  ruby_init();
  ruby_options();
}

b;
ruby_process_options() {
  rb_usascii_str_new(0, 0);
  b = rb_data_typed_object_alloc();
  rb_iseq_compile_node(b);
}
-------------- next part --------------
typedef struct {
  int *objspace
} rb_vm_t;
rb_vm_t ruby_current_vm;
typedef struct {
  struct {
    int freelist
  } heap
} rb_objspace_t;
*vm_xmalloc_mem, *stderr;
rb_newobj_obj, finish_insn_seq_0;
struct {
  struct {
    void *sa_sigaction
  } __sigaction_handler
} a;
ruby_xmalloc2() { vm_xmalloc_mem = malloc(0); }

rb_data_typed_object_alloc() {
  rb_objspace_t *objspace = &*ruby_current_vm.objspace;
  rb_newobj_obj = &objspace->heap.freelist;
}

vm_exec_core() {
  finish_insn_seq_0 = &&INSN_LABEL_finish;
INSN_LABEL_finish:
  ;
}

*rb_vm_get_insns_address_table() { vm_exec_core(); }

sigsegv() {
  fputs("[BUG] ", stderr);
  vfprintf();
}

rb_usascii_str_new() {}

ruby_init() {
  rb_vm_t *vm = malloc(0);
  rb_objspace_t *objspace = malloc(0);
  vm->objspace = objspace;
  ruby_current_vm = *vm;
  a.__sigaction_handler.sa_sigaction = sigsegv;
  sigaction(11, &a);
}

ruby_options() { ruby_process_options(); }


More information about the llvm-commits mailing list