Page MenuHomePhabricator

Debug Info: Represent local anonymous unions as anonymous unions.
Needs ReviewPublic

Authored by aprantl on Apr 28 2015, 3:45 PM.

Details

Reviewers
dblaikie
echristo
Summary

Debug Info: Represent local anonymous unions as anonymous unions in the debug info.
This patch deletes a hack that emits the members of local anonymous unions as local variables.

Why? Besides being morally wrong, the existing representation using local variables breaks internal assumptions about the local variables' storage size.

Compiling

void fn1() {
  union {
    int i;
    char c;
  };
  i = c;
}

with -g -O3 -verify will cause the verifier to fail after SROA splits the 32-bit storage for the "local variable" c into two pieces because the second piece is clearly outside the 8-bit range that is expected for a variable of type char. Given the choice I'd rather fix the debug representation than weaken the verifier.

Debuggers generally already know how to deal with anonymous unions when they are members of C++ record types, but they may have problems finding the local anonymous struct members in the expression evaluator.

Eric, do you know whether the local variable trick is necessary for GDB compatibility?

Diff Detail

Repository
rL LLVM

Event Timeline

aprantl updated this revision to Diff 24581.Apr 28 2015, 3:45 PM
aprantl retitled this revision from to Debug Info: Represent local anonymous unions as anonymous unions..
aprantl updated this object.
aprantl edited the test plan for this revision. (Show Details)
aprantl added reviewers: echristo, dblaikie.
aprantl set the repository for this revision to rL LLVM.
aprantl added a subscriber: Unknown Object (MLST).