Re: [ubsan] Add libcall arguments

2013-07-22 Thread Marek Polacek
On Mon, Jul 22, 2013 at 10:09:00AM -0400, Jason Merrill wrote: > On 07/19/2013 02:45 PM, Marek Polacek wrote: > > /* This type represents an entry in the hash table. */ > > struct ubsan_typedesc > > { > >+ /* This represents the type of a variable. */ > > tree type; > >+ > >+ /* This is the V

Re: [ubsan] Add libcall arguments

2013-07-22 Thread Jason Merrill
On 07/19/2013 02:45 PM, Marek Polacek wrote: /* This type represents an entry in the hash table. */ struct ubsan_typedesc { + /* This represents the type of a variable. */ tree type; + + /* This is the VAR_DECL of the type. */ tree decl; }; What I was looking for was something al

Re: [ubsan] Add libcall arguments

2013-07-22 Thread Marek Polacek
On Sun, Jul 21, 2013 at 10:41:15PM -0400, Jason Merrill wrote: > On 07/21/2013 02:26 PM, Marek Polacek wrote: > > (pointer_sized_type_node): Define. > > Let's call it pointer_sized_int_node. Sure. Here it is. 2013-07-21 Marek Polacek * tree.h (enum tree_index): Add TI_POINTER_SI

Re: [ubsan] Add libcall arguments

2013-07-21 Thread Jason Merrill
On 07/21/2013 02:26 PM, Marek Polacek wrote: (pointer_sized_type_node): Define. Let's call it pointer_sized_int_node. Jason

Re: [ubsan] Add libcall arguments

2013-07-21 Thread Marek Polacek
On Sat, Jul 20, 2013 at 08:17:34PM -0400, Jason Merrill wrote: > On 07/20/2013 10:27 AM, Jakub Jelinek wrote: > >So, the middle-end can only use > >some other type, say build_nonstandard_integer_type (POINTER_SIZE, 1); > >which often will be the same type as uintptr_type_node, but perhaps not on >

Re: [ubsan] Add libcall arguments

2013-07-20 Thread Jason Merrill
On 07/20/2013 10:27 AM, Jakub Jelinek wrote: So, the middle-end can only use some other type, say build_nonstandard_integer_type (POINTER_SIZE, 1); which often will be the same type as uintptr_type_node, but perhaps not on all targets. It could be worth to create such a type in tree.c and stick

Re: [ubsan] Add libcall arguments

2013-07-20 Thread Jakub Jelinek
On Sat, Jul 20, 2013 at 10:19:55AM +0200, Marek Polacek wrote: > On Sat, Jul 20, 2013 at 02:04:24AM -0400, Jason Merrill wrote: > > On 07/19/2013 03:01 PM, Marek Polacek wrote: > > >On Fri, Jul 19, 2013 at 08:50:42PM +0200, Jakub Jelinek wrote: > > >>uintptr_type_node is a C/C++/ObjC/ObjC++ FE tree

Re: [ubsan] Add libcall arguments

2013-07-20 Thread Marek Polacek
On Sat, Jul 20, 2013 at 02:04:24AM -0400, Jason Merrill wrote: > On 07/19/2013 03:01 PM, Marek Polacek wrote: > >On Fri, Jul 19, 2013 at 08:50:42PM +0200, Jakub Jelinek wrote: > >>uintptr_type_node is a C/C++/ObjC/ObjC++ FE tree. So, if you use it just > >>in c-family/c-ubsan.c, that is just fine,

Re: [ubsan] Add libcall arguments

2013-07-19 Thread Jason Merrill
On 07/19/2013 03:01 PM, Marek Polacek wrote: On Fri, Jul 19, 2013 at 08:50:42PM +0200, Jakub Jelinek wrote: uintptr_type_node is a C/C++/ObjC/ObjC++ FE tree. So, if you use it just in c-family/c-ubsan.c, that is just fine, but you can't use it in ubsan.c. Any reason not to move it into the mi

Re: [ubsan] Add libcall arguments

2013-07-19 Thread Jakub Jelinek
On Fri, Jul 19, 2013 at 08:45:30PM +0200, Marek Polacek wrote: > > >+uptr_type (void) > > >+{ > > >+ return build_nonstandard_integer_type (POINTER_SIZE, 1); > > > > Why not use uintptr_type_node? > > I suppose I could. I just followed suit what asan.c does. I didn't > address this in this pat

Re: [ubsan] Add libcall arguments

2013-07-19 Thread Marek Polacek
On Thu, Jul 18, 2013 at 03:47:28PM -0400, Jason Merrill wrote: > On 07/05/2013 10:04 AM, Marek Polacek wrote: > >+/* This type represents an entry in the hash table. */ > > Please describe the hash table more up here. What are you tracking? Ok, I've added two more comments. > >+ hashval_t h =

Re: [ubsan] Add libcall arguments

2013-07-19 Thread Marek Polacek
On Fri, Jul 19, 2013 at 08:50:42PM +0200, Jakub Jelinek wrote: > On Fri, Jul 19, 2013 at 08:45:30PM +0200, Marek Polacek wrote: > > > >+uptr_type (void) > > > >+{ > > > >+ return build_nonstandard_integer_type (POINTER_SIZE, 1); > > > > > > Why not use uintptr_type_node? > > > > I suppose I coul

Re: [ubsan] Add libcall arguments

2013-07-19 Thread Marek Polacek
On Fri, Jul 19, 2013 at 05:20:39PM +0200, Jakub Jelinek wrote: > > >I have yet to handle > > >freeing the hash table, but I think I'll need the GTY machinery for > > >this (ubsan is not a pass, so I can't just call it at the end of the > > >pas). Or maybe just create a destructor and use append_to

Re: [ubsan] Add libcall arguments

2013-07-19 Thread Jakub Jelinek
On Thu, Jul 18, 2013 at 03:47:28PM -0400, Jason Merrill wrote: > Please describe the hash table more up here. What are you tracking? > > >+ hashval_t h = iterative_hash_object (data->type, 0); > >+ h = iterative_hash_object (data->decl, h); > > If you hash the decl as well as the type, the fin

Re: [ubsan] Add libcall arguments

2013-07-18 Thread Jason Merrill
On 07/05/2013 10:04 AM, Marek Polacek wrote: +/* This type represents an entry in the hash table. */ Please describe the hash table more up here. What are you tracking? + hashval_t h = iterative_hash_object (data->type, 0); + h = iterative_hash_object (data->decl, h); If you hash the de

[ubsan] Add libcall arguments

2013-07-05 Thread Marek Polacek
This patch adds creating and passing the arguments for the ubsan library. So, we can finally make use of the ubsan library. We currently sanitize only divisions by zero and shifts. What it can do now is e.g. for: int main (void) { long int a = 4; int b = 113; return a << b; } it at runtime says: