[llvm-commits] [llvm] r75571 - in /llvm/trunk: lib/Transforms/Scalar/SimplifyCFGPass.cpp test/Transforms/SimplifyCFG/2009-07-13-no-delete-asm.ll

Chris Lattner clattner at apple.com
Tue Jul 14 10:20:38 PDT 2009


On Jul 14, 2009, at 10:09 AM, Dale Johannesen wrote:

>
> On Jul 13, 2009, at 9:03 PMPDT, Chris Lattner wrote:
>
>>
>> On Jul 13, 2009, at 5:53 PM, Eli Friedman wrote:
>>
>>> On Mon, Jul 13, 2009 at 5:45 PM, Dale Johannesen<dalej at apple.com>  
>>> wrote:
>>>> --- llvm/trunk/test/Transforms/SimplifyCFG/2009-07-13-no-delete- 
>>>> asm.ll (added)
>>>> +++ llvm/trunk/test/Transforms/SimplifyCFG/2009-07-13-no-delete- 
>>>> asm.ll Mon Jul 13 19:45:38 2009
>>>> @@ -0,0 +1,11 @@
>>>> +; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | grep xor
>>>> +; ModuleID = '<stdin>'
>>>> +target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16- 
>>>> i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128- 
>>>> a0:0:64-f80:128:128"
>>>> +target triple = "i386-apple-darwin9.6"
>>>> +
>>>> +define void @bar() nounwind {
>>>> +entry:
>>>> +       store i16 undef, i16* null
>>>> +       %asmtmp = call i32 asm sideeffect "xor $0, $0",  
>>>> "=={bx},rm,~{dirflag},~{fpsr},~{flags},~{memory}"(i16 undef)  
>>>> nounwind           ; <i32> [#uses=0]
>>>> +       ret void
>>>> +}
>>>
>>> Umm, this testcase quite clearly has undefined behavior; what is  
>>> this
>>> patch trying to fix?
>>
>> Beyond that, what does the store have to do with the undef.  The  
>> store being undefined means the asm is not reachable, so it should  
>> be deleted.
>
> No, the gcc doc is (for once) quite clear that volatile asm's should  
> never be deleted.

This isn't true Dale, they are deleted and duplicated at will.

void foo(){
   return;
   asm volatile("foo");
}

-Chris




More information about the llvm-commits mailing list