https://llvm.org/bugs/show_bug.cgi?id=24325

            Bug ID: 24325
           Summary: Compiler generating an unnecessary volatile load
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
          Assignee: unassignedclangb...@nondot.org
          Reporter: douglas_y...@playstation.sony.com
                CC: llvmbugs@cs.uiuc.edu
    Classification: Unclassified

This bug was found when trying to modify the clang lit test
CodeGenCXX\volatile.cpp to work when the compiler is in c++11 mode.

The repro is as follows:

volatile int *x;

void test() {
  *x;
}

If you compile the code with trunk (I am using r242449) and give the option "-S
-emit-llvm", you get the following:

@x = global i32* null, align 8

; Function Attrs: nounwind uwtable
define void @_Z4testv() #0 {
entry:
  %0 = load i32*, i32** @x, align 8
  ret void
}

However if you also add the switch "-std=c++11", the code generated is the
following:

@x = global i32* null, align 8

; Function Attrs: nounwind uwtable
define void @_Z4testv() #0 {
entry:
  %0 = load i32*, i32** @x, align 8
  %1 = load volatile i32, i32* %0, align 4
  ret void
}

Note that there is an extra load volatile that is generated in this case.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
LLVMbugs@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to