瀏覽代碼

llvmdbg: fix overflows for aggregates > 2^61 bytes

LLVM does not support aggregates larger than that at all, because internally
it stores all sizes in bits in an uint64. Their rationale for not having
special support for that is that there is no hardware with full 64 bit VM
address space anyway. So truncate our size emissions in debug info also to
that.
Jonas Maebe 3 年之前
父節點
當前提交
a19deace45
共有 1 個文件被更改,包括 14 次插入2 次删除
  1. 14 2
      compiler/llvm/dbgllvm.pas

+ 14 - 2
compiler/llvm/dbgllvm.pas

@@ -945,7 +945,13 @@ implementation
         if is_vector(def) then
         if is_vector(def) then
           dinode.addenum('flags','DIFlagVector');
           dinode.addenum('flags','DIFlagVector');
         if not is_dynamic_array(def) then
         if not is_dynamic_array(def) then
-          dinode.addqword('size',def.size*8)
+          if def.size<(qword(1) shl 61) then
+            dinode.addqword('size',def.size*8)
+          else
+            { LLVM internally "only" supports sizes up to 1 shl 61, because they
+              store all sizes in bits in a qword; the rationale is that there
+              is no hardware supporting a full 64 bit address space either }
+            dinode.addqword('size',qword(1) shl 61)
         else
         else
           begin
           begin
             exprnode:=tai_llvmspecialisedmetadatanode.create(tspecialisedmetadatanodekind.DIExpression);
             exprnode:=tai_llvmspecialisedmetadatanode.create(tspecialisedmetadatanodekind.DIExpression);
@@ -974,7 +980,13 @@ implementation
         dinode.addint64('tag',ord(DW_TAG_structure_type));
         dinode.addint64('tag',ord(DW_TAG_structure_type));
         if (name<>'') then
         if (name<>'') then
           dinode.addstring('name',name);
           dinode.addstring('name',name);
-        dinode.addqword('size',def.size*8);
+        if def.size<(qword(1) shl 61) then
+          dinode.addqword('size',def.size*8)
+        else
+          { LLVM internally "only" supports sizes up to 1 shl 61, because they
+            store all sizes in bits in a qword; the rationale is that there
+            is no hardware supporting a full 64 bit address space either }
+          dinode.addqword('size',qword(1) shl 61);
 
 
         list.concat(dinode);
         list.concat(dinode);