@@ -75,7 +75,7 @@ const char *ir_op_name[IR_LAST_OP] = {
75
75
#endif
76
76
};
77
77
78
- static void ir_print_escaped_str (const char * s , size_t len , FILE * f )
78
+ void ir_print_escaped_str (const char * s , size_t len , FILE * f )
79
79
{
80
80
char ch ;
81
81
@@ -95,10 +95,14 @@ static void ir_print_escaped_str(const char *s, size_t len, FILE *f)
95
95
case '\v' : fputs ("\\v" , f ); break ;
96
96
case '\?' : fputs ("\\?" , f ); break ;
97
97
default :
98
+ #ifdef __aarch64__
98
99
if (ch < 32 ) {
100
+ #else
101
+ if (ch >= 0 && ch < 32 ) {
102
+ #endif
99
103
fprintf (f , "\\%c%c%c" ,
100
- '0' + ((ch >> 3 ) % 8 ),
101
104
'0' + ((ch >> 6 ) % 8 ),
105
+ '0' + ((ch >> 3 ) % 8 ),
102
106
'0' + (ch % 8 ));
103
107
break ;
104
108
} else {
@@ -1784,48 +1788,64 @@ static ir_alias ir_check_aliasing(ir_ctx *ctx, ir_ref addr1, ir_ref addr2)
1784
1788
static ir_alias ir_check_partial_aliasing (const ir_ctx * ctx , ir_ref addr1 , ir_ref addr2 , ir_type type1 , ir_type type2 )
1785
1789
{
1786
1790
ir_insn * insn1 , * insn2 ;
1791
+ ir_ref base1 , base2 , off1 , off2 ;
1787
1792
1788
1793
/* this must be already check */
1789
1794
IR_ASSERT (addr1 != addr2 );
1790
1795
1791
1796
insn1 = & ctx -> ir_base [addr1 ];
1792
1797
insn2 = & ctx -> ir_base [addr2 ];
1793
- if (insn1 -> op == IR_ADD && IR_IS_CONST_REF (insn1 -> op2 )) {
1794
- if (insn1 -> op1 == addr2 ) {
1795
- uintptr_t offset1 = ctx -> ir_base [insn1 -> op2 ].val .addr ;
1796
- uintptr_t size2 = ir_type_size [type2 ];
1797
-
1798
- return (offset1 < size2 ) ? IR_MUST_ALIAS : IR_NO_ALIAS ;
1799
- } else if (insn2 -> op == IR_ADD && IR_IS_CONST_REF (insn1 -> op2 ) && insn1 -> op1 == insn2 -> op1 ) {
1800
- if (insn1 -> op2 == insn2 -> op2 ) {
1801
- return IR_MUST_ALIAS ;
1802
- } else if (IR_IS_CONST_REF (insn1 -> op2 ) && IR_IS_CONST_REF (insn2 -> op2 )) {
1803
- uintptr_t offset1 = ctx -> ir_base [insn1 -> op2 ].val .addr ;
1804
- uintptr_t offset2 = ctx -> ir_base [insn2 -> op2 ].val .addr ;
1805
-
1806
- if (offset1 == offset2 ) {
1807
- return IR_MUST_ALIAS ;
1808
- } else if (type1 == type2 ) {
1809
- return IR_NO_ALIAS ;
1810
- } else {
1811
- /* check for partail intersection */
1812
- uintptr_t size1 = ir_type_size [type1 ];
1813
- uintptr_t size2 = ir_type_size [type2 ];
1798
+ if (insn1 -> op != IR_ADD ) {
1799
+ base1 = addr1 ;
1800
+ off1 = IR_UNUSED ;
1801
+ } else if (ctx -> ir_base [insn1 -> op2 ].op == IR_SYM ) {
1802
+ base1 = insn1 -> op2 ;
1803
+ off1 = insn1 -> op1 ;
1804
+ } else {
1805
+ base1 = insn1 -> op1 ;
1806
+ off1 = insn1 -> op2 ;
1807
+ }
1808
+ if (insn2 -> op != IR_ADD ) {
1809
+ base2 = addr2 ;
1810
+ off2 = IR_UNUSED ;
1811
+ } else if (ctx -> ir_base [insn2 -> op2 ].op == IR_SYM ) {
1812
+ base2 = insn2 -> op2 ;
1813
+ off2 = insn2 -> op1 ;
1814
+ } else {
1815
+ base2 = insn2 -> op1 ;
1816
+ off2 = insn2 -> op2 ;
1817
+ }
1818
+ if (base1 == base2 ) {
1819
+ uintptr_t offset1 , offset2 ;
1814
1820
1815
- if (offset1 > offset2 ) {
1816
- return offset1 < offset2 + size2 ? IR_MUST_ALIAS : IR_NO_ALIAS ;
1817
- } else {
1818
- return offset2 < offset1 + size1 ? IR_MUST_ALIAS : IR_NO_ALIAS ;
1819
- }
1820
- }
1821
- }
1821
+ if (!off1 ) {
1822
+ offset1 = 0 ;
1823
+ } else if (IR_IS_CONST_REF (off1 ) && !IR_IS_SYM_CONST (ctx -> ir_base [off1 ].op )) {
1824
+ offset1 = ctx -> ir_base [off1 ].val .addr ;
1825
+ } else {
1826
+ return IR_MAY_ALIAS ;
1822
1827
}
1823
- } else if (insn2 -> op == IR_ADD && IR_IS_CONST_REF (insn2 -> op2 )) {
1824
- if (insn2 -> op1 == addr1 ) {
1825
- uintptr_t offset2 = ctx -> ir_base [insn2 -> op2 ].val .addr ;
1826
- uintptr_t size1 = ir_type_size [type1 ];
1827
-
1828
- return (offset2 < size1 ) ? IR_MUST_ALIAS : IR_NO_ALIAS ;
1828
+ if (!off2 ) {
1829
+ offset2 = 0 ;
1830
+ } else if (IR_IS_CONST_REF (off2 ) && !IR_IS_SYM_CONST (ctx -> ir_base [off2 ].op )) {
1831
+ offset2 = ctx -> ir_base [off2 ].val .addr ;
1832
+ } else {
1833
+ return IR_MAY_ALIAS ;
1834
+ }
1835
+ if (offset1 == offset2 ) {
1836
+ return IR_MUST_ALIAS ;
1837
+ } else if (offset1 < offset2 ) {
1838
+ return offset1 + ir_type_size [type1 ] <= offset2 ? IR_NO_ALIAS : IR_MUST_ALIAS ;
1839
+ } else {
1840
+ return offset2 + ir_type_size [type2 ] <= offset1 ? IR_NO_ALIAS : IR_MUST_ALIAS ;
1841
+ }
1842
+ } else {
1843
+ insn1 = & ctx -> ir_base [base1 ];
1844
+ insn2 = & ctx -> ir_base [base2 ];
1845
+ if ((insn1 -> op == IR_ALLOCA && (insn2 -> op == IR_ALLOCA || insn2 -> op == IR_SYM || insn2 -> op == IR_PARAM ))
1846
+ || (insn1 -> op == IR_SYM && (insn2 -> op == IR_ALLOCA || insn2 -> op == IR_SYM ))
1847
+ || (insn1 -> op == IR_PARAM && insn2 -> op == IR_ALLOCA )) {
1848
+ return IR_NO_ALIAS ;
1829
1849
}
1830
1850
}
1831
1851
return IR_MAY_ALIAS ;
0 commit comments