Kaynağa Gözat

* simplify all type conversions for formal constants even for LLVM and JVM
(since these happen at compile time and don't result in generated code,
they never need extra type conversions in the code)

git-svn-id: trunk@40629 -

Jonas Maebe 6 yıl önce
ebeveyn
işleme
dd29088430
2 değiştirilmiş dosya ile 5 ekleme ve 3 silme
  1. 1 1
      compiler/llvm/nllvmcnv.pas
  2. 4 2
      compiler/ncnv.pas

+ 1 - 1
compiler/llvm/nllvmcnv.pas

@@ -80,7 +80,7 @@ class function tllvmtypeconvnode.target_specific_need_equal_typeconv(fromdef, to
     result:=
     result:=
       (fromdef<>todef) and
       (fromdef<>todef) and
       { two procdefs that are structurally the same but semantically different
       { two procdefs that are structurally the same but semantically different
-        still need a convertion }
+        still need a conversion }
       (
       (
        ((fromdef.typ=procvardef) and
        ((fromdef.typ=procvardef) and
         (todef.typ=procvardef))
         (todef.typ=procvardef))

+ 4 - 2
compiler/ncnv.pas

@@ -350,7 +350,8 @@ implementation
         if equal_defs(p.resultdef,def) and
         if equal_defs(p.resultdef,def) and
            (p.resultdef.typ=def.typ) and
            (p.resultdef.typ=def.typ) and
            not is_bitpacked_access(p) and
            not is_bitpacked_access(p) and
-           not ctypeconvnode.target_specific_need_equal_typeconv(p.resultdef,def) then
+           ((p.blocktype=bt_const) or
+            not ctypeconvnode.target_specific_need_equal_typeconv(p.resultdef,def)) then
           begin
           begin
             { don't replace encoded string constants to rawbytestring encoding.
             { don't replace encoded string constants to rawbytestring encoding.
               preserve the codepage }
               preserve the codepage }
@@ -2434,7 +2435,8 @@ implementation
 {$ifdef llvm}
 {$ifdef llvm}
                      { we still may have to insert a type conversion at the
                      { we still may have to insert a type conversion at the
                        llvm level }
                        llvm level }
-                     if (left.resultdef<>resultdef) and
+                     if (blocktype<>bt_const) and
+                        (left.resultdef<>resultdef) and
                         { if unspecialised generic -> we won't generate any code
                         { if unspecialised generic -> we won't generate any code
                           for this, and keeping the type conversion node will
                           for this, and keeping the type conversion node will
                           cause valid_for_assign to fail because the typecast will be from/to something of 0
                           cause valid_for_assign to fail because the typecast will be from/to something of 0