[llvm-commits] [llvm] r103439 - in /llvm/trunk: lib/CodeGen/AsmPrinter/DwarfDebug.cpp lib/CodeGen/AsmPrinter/DwarfDebug.h test/DebugInfo/2010-05-10-MultipleCU.ll

Chris Lattner clattner at apple.com
Tue Sep 28 09:03:21 PDT 2010


On Sep 28, 2010, at 8:17 AM, Benjamin Kramer wrote:

>> void DwarfDebug::computeSizeAndOffsets() {
>> -  // Compute size of compile unit header.
>> -  static unsigned Offset =
>> -    sizeof(int32_t) + // Length of Compilation Unit Info
>> -    sizeof(int16_t) + // DWARF version number
>> -    sizeof(int32_t) + // Offset Into Abbrev. Section
>> -    sizeof(int8_t);   // Pointer Size (in bytes)
>> -
>> -  computeSizeAndOffset(ModuleCU->getCUDie(), Offset, true);
>> +  unsigned PrevOffset = 0;
>> +  for (DenseMap<const MDNode *, CompileUnit *>::iterator I = CUMap.begin(),
>> +         E = CUMap.end(); I != E; ++I) {
>> +    // Compute size of compile unit header.
>> +    static unsigned Offset = PrevOffset +
> 
> Why is this variable static? PrevOffset is 0 when the var is hit the first time so the
> offset will be constant (11). I tried to remove the static keyword but that seems to corrupt
> the dwarf output in 2010-05-10-MultipleCU.ll. Can you take a look?

Good catch.  mutable static variables like this break compiler multithreading.

-Chris



More information about the llvm-commits mailing list