[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

Juan Manuel Martinez CaamaƱo via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 27 06:29:52 PST 2023


jmmartinez created this revision.
jmmartinez added reviewers: dblaikie, probinson.
Herald added subscribers: kosarev, tpr.
Herald added a project: All.
jmmartinez requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I'm looking for some feedback, this is definitively not the final solution.
I was wondering if there was an alternative to pass this information in the dwarf debug-info.

Consider the following sturctures when targetting:

  struct foo {
    int space[4];
    char a : 8;
    char b : 8;
    char x : 8;
    char y : 8;
  };
  
  struct bar {
    int space[4];
    char a : 8;
    char b : 8;
    char : 0;
    char x : 8;
    char y : 8;
  };

Even if both structs have the same layout in memory, they are handled
differenlty by the AMDGPU ABI.

With the following code:

// clang --target=amdgcn-amd-amdhsa -g -O1 example.c -S
char use_foo(struct foo f) { return f.y; }
char use_bar(struct bar b) { return b.y; }

For use_foo, the 'y' field is passed in v4
; v_ashrrev_i32_e32 v0, 24, v4
; s_setpc_b64 s[30:31]

For use_bar, the 'y' field is passed in v5
; v_bfe_i32 v0, v5, 8, 8
; s_setpc_b64 s[30:31]

To make this distinction, we record a single 0-size bitfield for every member that is preceded
by it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144870

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGRecordLayout.h
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/test/CodeGen/debug-info-bitfield-0-struct.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144870.500764.patch
Type: text/x-patch
Size: 14840 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230227/bf0f5bd5/attachment.bin>


More information about the cfe-commits mailing list