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

            Bug ID: 41801
           Summary: [ISel] Unused instructions referenced in debug data
                    removed at O0
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedb...@nondot.org
          Reporter: stephen.to...@sony.com
                CC: llvm-bugs@lists.llvm.org

Using LLVM/clang r360138 and the command line "-c -O0 -x ir" on the IR file
produced by the commands below, the debug data corresponding to "nose.b" and
"boot" is not present in the output object file. The issue appears to occur
during instruction selection, where the following register (which is only used
in debug expressions)is not present in the first pass to output MIR, either
"X86 DAG->DAG Instruction Selection" or "Expand ISel Pseudo-instructions"
depending on platform. This causes debug information to be lost due to an
optimization when -O0 is enabled.

To reproduce:

$ clang -v
clang version 9.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\dev\llvm-project\build\Debug\bin

$ cat reproduce.cpp
struct chin {
        int a;
        int b;
};

int foo(struct chin nose, int more) {
        int shoe = nose.a;
        int boot = nose.b;
        return more;
}

$ clang reproduce.cpp -o - -S -emit-llvm -g -O0 -Xclang -disable-O0-optnone |
opt -sroa -early-cse -S > reproduce.ll


The point at which the debug information for "boot" is lost can then be seen in
the output of the command:

$ clang reproduce.ll -o - -c -g -O0 -x ir -mllvm -print-after-all 2>&1
>/dev/null

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to