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

            Bug ID: 50220
           Summary: Missing DSE for escaped local variable, affects
                    pattern init
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Scalar Optimizations
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]

Consider this input:

$ cat t.c
void escape(int*);
int getval(void);
int missed_dse() {
  int v1 = 0;
  escape(&v1);
  int v2 = 55555;
  v2 = getval();
  escape(&v2);
  return v2 + v1;
}

DSE cannot eliminate the dead store of 55555:

$ clang -O2 t.c -o - -S -emit-llvm | grep store
  store i32 0, i32* %v1, align 4, !tbaa !3
  store i32 55555, i32* %v2, align 4, !tbaa !3
  store i32 %call, i32* %v2, align 4, !tbaa !3

Our users noticed that the Chrome binary contains lots of stores of 0xAAAA
constants after enabling -fauto-var-init=pattern, and this pattern stood out.

I attempted to debug why this happens, and basically DSE thinks that the
`getval` call can read the 5555 store from v2, even though it has not been
escaped yet. It will be escaped later in the program, but that hasn't happened
at the point of the call.

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

Reply via email to