[llvm-commits] [PATCH] -fno-strict-overflow/-fwrapv: allow pointer arithmetic to be defined as wrapping instead of undefined on overflow

Török Edwin edwintorok at gmail.com
Mon Feb 2 13:02:53 PST 2009


On 2009-02-02 22:33, Chris Lattner wrote:
> On Feb 1, 2009, at 12:32 PM, Török Edwin wrote:
>
>   
>> Hi,
>>
>> gcc provides -fwrapv and -fno-strict-overflow that allows pointer +
>> unsigned to be treated as possibly wrapping, instead of undefined ->
>> can't happen (the default with -fstrict-overflow, -O2, -O3 or -Os).
>>     
>
> I think the right way to handle this is to add a "overflow  
> characteristic" field to the integer operations.  Each integer  
> operation could be "2's complement on overflow" "undefined on  
> overflow" "trapping on overflow" or "saturating on overflow".  I think  
> it makes sense to capture this directly in the IR on a per-operation  
> basis instead of trying to disable optimizations based on a global flag.
>
> If you're interested in tackling this, the first place to start would  
> be to split up add into add/fadd and any other operations that work on  
> both int/fp that do arithmetic.

Added to my TODOlist, we'll see if I have time to implement it.

FYI here's my TODO for 2.6:
1. IRBuilder constantfolding patch (2.5/2.6)
2. assert/abort error handling
 starting point: unsupported inline asm shouldn't abort(), set "error
occured" flag
 notes: make sure we don't generate any code (e.g. output .fail)

3. RangeSet to reduce O(M*N) memory usage of Codegen/LiveVariables
4.  overflow behaviour
5.  LLVM passes that are able to emit warnings optionally (for e.g. when
encountering undefined behaviour instead of silently outputting code
that might break
allow it to print a warning message) <-- this'll need some discussion

Best regards,
--Edwin



More information about the llvm-commits mailing list