diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2023-12-14 13:59:15 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-14 13:59:15 -0800 |
commit | 23ccb02c59d2ad6c1e8c79b7bf0e98c2afc36fb9 (patch) | |
tree | 4646faf4eb921f73b42853944969d6ba04b8afb6 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | |
parent | f34325307eb36d6032ccea3773e3e0c1746b7f98 (diff) | |
download | llvm-23ccb02c59d2ad6c1e8c79b7bf0e98c2afc36fb9.zip llvm-23ccb02c59d2ad6c1e8c79b7bf0e98c2afc36fb9.tar.gz llvm-23ccb02c59d2ad6c1e8c79b7bf0e98c2afc36fb9.tar.bz2 |
CodeGen: add a missing check for bit-slice overlap in CV (#75504)
Type dereferenced fragments are specified by offset and length in bits.
The representation in CodeView is defined in terms of byte offsets. If
the bit slice overlaps at a byte that is included, we would create
invalid definition ranges.
Consider the following scenario:
~~~
01234567 01234567
---------+---------
==== ======
~~~
Here bits 1-4 are marked as defined as well as bits 7-9. The byte range
for the second portion overlaps and so we would say that bytes 1 and 2
are valid though there is potentially a hole. There is no way to
represent this in the defined range for the local variable in CodeView.
We simply can drop the fragment definition in such a scenario with the
variables are "optimized out".
Thanks to @rnk and @hjyamauchi for the discussion around this.
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index 3a9d5fa..dddc08b 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1397,6 +1397,12 @@ void CodeViewDebug::calculateRanges( if (Location->Register == 0 || Location->LoadChain.size() > 1) continue; + // Codeview can only express byte-aligned offsets, ensure that we have a + // byte-boundaried location. + if (Location->FragmentInfo) + if (Location->FragmentInfo->OffsetInBits % 8) + continue; + LocalVarDef DR; DR.CVRegister = TRI->getCodeViewRegNum(Location->Register); DR.InMemory = !Location->LoadChain.empty(); |