Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix large literals #323

Merged
merged 3 commits into from
Apr 29, 2024
Merged

Fix large literals #323

merged 3 commits into from
Apr 29, 2024

Conversation

frabert
Copy link
Collaborator

@frabert frabert commented May 12, 2023

No description provided.

@github-actions
Copy link

See the diff generated by this PR for the tests here: https://github.com/lifting-bits/rellic/actions/runs/4957976082

fizzbuzz.bc

typedefs_of_typedefs.bc

switch_loop.bc

func_cond_zero_arg.bc

fcmp.bc

conflicting_names.bc

struct.bc

issue_183_literal_structs.bc

zeroinit.bc

issue_127_uint128_t_lit.bc

--- /dev/fd/63	2023-05-12 10:50:16.907968319 +0000
+++ /dev/fd/62	2023-05-12 10:50:16.907968319 +0000
@@ -1,9 +1,9 @@
 int main(void);
-unsigned __int128 x = (unsigned __int128)3735928559ULL;
+unsigned __int128 x = (unsigned __int128)(unsigned __int128)(unsigned __int128)3735928559UL;
 int main(void) {
     unsigned int var0;
     unsigned char val1;
     var0 = 0U;
-    val1 = (x & (unsigned __int128)65535ULL) == (unsigned __int128)48879ULL;
+    val1 = (x & (unsigned __int128)(unsigned __int128)65535UL) == (unsigned __int128)(unsigned __int128)48879UL;
     return val1 ? 0U : 1U;
 }

global_using_function_decl.bc

init_list.bc

reg_test_structure_fields.bc

ret0.bc

goto_loop.bc

--- /dev/fd/63	2023-05-12 10:50:17.251968524 +0000
+++ /dev/fd/62	2023-05-12 10:50:17.251968524 +0000
@@ -6,7 +6,7 @@
     unsigned int var1;
     var0 = 0U;
     var1 = 0U;
-    while (1U)
+    while (1Ui8)
         {
             var1 = var1 + 1U;
             if (var1 == 1U) {

trunc.bc

bitops.bc

cast.bc

nullptr.bc

nested_struct.bc

--- /dev/fd/63	2023-05-12 10:50:18.031968988 +0000
+++ /dev/fd/62	2023-05-12 10:50:18.031968988 +0000
@@ -14,7 +14,7 @@
     struct struct__pair field1;
     struct struct__person field2;
 };
-struct struct__record r1 = {14U, {33U, 42U}, {"Bob", (unsigned char)66U}};
+struct struct__record r1 = {14U, {33U, 42U}, {"Bob", 66Ui8}};
 char _str_1[9] = "Name: %s\000";
 int main(void) {
     unsigned int var0;

array_swap.bc

binops.bc

bitmask.bc

loop.bc

float.bc

nested_while.bc

vectors.bc

funcptr.bc

struct_swap.bc

short.bc

--- /dev/fd/63	2023-05-12 10:50:19.879970070 +0000
+++ /dev/fd/62	2023-05-12 10:50:19.879970070 +0000
@@ -1,10 +1,10 @@
 int main(void);
-unsigned short a = (unsigned short)0U;
+unsigned short a = (unsigned short)0Ui16;
 int main(void) {
     unsigned int var0;
     unsigned short var1;
     var0 = 0U;
-    a = 13U;
+    a = 13Ui16;
     var1 = a;
     return (unsigned int)var1;
 }

inttoptr.bc

issue_4.bc

issue_123_uint128_t.bc

fizzbuzz_stateful.bc

issue_94_strncmp.bc

bool.bc

zext.bc

--- /dev/fd/63	2023-05-12 10:50:21.195970822 +0000
+++ /dev/fd/62	2023-05-12 10:50:21.195970822 +0000
@@ -1,5 +1,5 @@
 int main(void);
-char a = (unsigned char)1U;
+char a = (unsigned char)1Ui8;
 int main(void) {
     unsigned int var0;
     var0 = 0U;

byval_struct.bc

func_cond_two_arg.bc

conflicting_global.bc

assert.bc

switch.bc

branch.bc

template_parameter_pack.bc

byval_tail_nogep.ll

byval_tail_gep.ll

@github-actions
Copy link

See the diff generated by this PR for the tests here: https://github.com/lifting-bits/rellic/actions/runs/4959022548

fizzbuzz.bc

typedefs_of_typedefs.bc

switch_loop.bc

func_cond_zero_arg.bc

fcmp.bc

conflicting_names.bc

struct.bc

issue_183_literal_structs.bc

zeroinit.bc

issue_127_uint128_t_lit.bc

--- /dev/fd/63	2023-05-12 12:53:50.918157142 +0000
+++ /dev/fd/62	2023-05-12 12:53:50.918157142 +0000
@@ -1,9 +1,9 @@
 int main(void);
-unsigned __int128 x = (unsigned __int128)3735928559ULL;
+unsigned __int128 x = (unsigned __int128)3735928559UL;
 int main(void) {
     unsigned int var0;
     unsigned char val1;
     var0 = 0U;
-    val1 = (x & (unsigned __int128)65535ULL) == (unsigned __int128)48879ULL;
+    val1 = (x & (unsigned __int128)(unsigned long long)65535UL) == (unsigned __int128)(unsigned long long)48879UL;
     return val1 ? 0U : 1U;
 }

global_using_function_decl.bc

init_list.bc

reg_test_structure_fields.bc

ret0.bc

goto_loop.bc

trunc.bc

bitops.bc

cast.bc

nullptr.bc

nested_struct.bc

array_swap.bc

binops.bc

bitmask.bc

loop.bc

float.bc

nested_while.bc

--- /dev/fd/63	2023-05-12 12:53:53.098225556 +0000
+++ /dev/fd/62	2023-05-12 12:53:53.098225556 +0000
@@ -25,7 +25,7 @@
                 printf("loop2 x: %d\n", var1);
             }
     }
-    if (((int)var1 >= 20 || (int)var1 <= 10) && (int)var1 >= 20) {
+    if ((int)var1 >= 20 && ((int)var1 >= 20 || (int)var1 <= 10)) {
         return var0;
     }
 }

vectors.bc

funcptr.bc

struct_swap.bc

short.bc

inttoptr.bc

issue_4.bc

issue_123_uint128_t.bc

fizzbuzz_stateful.bc

issue_94_strncmp.bc

bool.bc

zext.bc

byval_struct.bc

func_cond_two_arg.bc

conflicting_global.bc

assert.bc

switch.bc

branch.bc

template_parameter_pack.bc

byval_tail_nogep.ll

byval_tail_gep.ll

@frabert frabert force-pushed the fix-large-literals branch 2 times, most recently from 86a933f to 9873893 Compare May 18, 2023 13:18
@github-actions
Copy link

See the diff generated by this PR for the tests here: https://github.com/lifting-bits/rellic/actions/runs/5014381562

fizzbuzz.bc

typedefs_of_typedefs.bc

switch_loop.bc

func_cond_zero_arg.bc

fcmp.bc

conflicting_names.bc

struct.bc

issue_183_literal_structs.bc

zeroinit.bc

issue_127_uint128_t_lit.bc

--- /dev/fd/63	2023-05-18 13:29:15.928137986 +0000
+++ /dev/fd/62	2023-05-18 13:29:15.928137986 +0000
@@ -1,9 +1,9 @@
 int main(void);
-unsigned __int128 x = (unsigned __int128)3735928559ULL;
+unsigned __int128 x = 3735928559;
 int main(void) {
     unsigned int var0;
     unsigned char val1;
     var0 = 0U;
-    val1 = (x & (unsigned __int128)65535ULL) == (unsigned __int128)48879ULL;
+    val1 = (x & 65535) == 48879;
     return val1 ? 0U : 1U;
 }

global_using_function_decl.bc

init_list.bc

reg_test_structure_fields.bc

ret0.bc

goto_loop.bc

trunc.bc

bitops.bc

cast.bc

nullptr.bc

nested_struct.bc

--- /dev/fd/63	2023-05-18 13:29:17.052170352 +0000
+++ /dev/fd/62	2023-05-18 13:29:17.052170352 +0000
@@ -14,7 +14,7 @@
     struct struct__pair field1;
     struct struct__person field2;
 };
-struct struct__record r1 = {14U, {33U, 42U}, {"Bob", (unsigned char)66U}};
+struct struct__record r1 = {14U, {33U, 42U}, {"Bob", 66U}};
 char _str_1[9] = "Name: %s\000";
 int main(void) {
     unsigned int var0;

array_swap.bc

binops.bc

bitmask.bc

loop.bc

float.bc

nested_while.bc

--- /dev/fd/63	2023-05-18 13:29:18.096200414 +0000
+++ /dev/fd/62	2023-05-18 13:29:18.096200414 +0000
@@ -25,7 +25,7 @@
                 printf("loop2 x: %d\n", var1);
             }
     }
-    if (((int)var1 >= 20 || (int)var1 <= 10) && (int)var1 >= 20) {
+    if ((int)var1 >= 20 && ((int)var1 >= 20 || (int)var1 <= 10)) {
         return var0;
     }
 }

vectors.bc

funcptr.bc

struct_swap.bc

short.bc

--- /dev/fd/63	2023-05-18 13:29:18.844221952 +0000
+++ /dev/fd/62	2023-05-18 13:29:18.844221952 +0000
@@ -1,5 +1,5 @@
 int main(void);
-unsigned short a = (unsigned short)0U;
+unsigned short a = 0U;
 int main(void) {
     unsigned int var0;
     unsigned short var1;

inttoptr.bc

issue_4.bc

issue_123_uint128_t.bc

fizzbuzz_stateful.bc

issue_94_strncmp.bc

bool.bc

zext.bc

--- /dev/fd/63	2023-05-18 13:29:20.112258464 +0000
+++ /dev/fd/62	2023-05-18 13:29:20.112258464 +0000
@@ -1,5 +1,5 @@
 int main(void);
-char a = (unsigned char)1U;
+char a = 1U;
 int main(void) {
     unsigned int var0;
     var0 = 0U;

byval_struct.bc

func_cond_two_arg.bc

conflicting_global.bc

assert.bc

switch.bc

branch.bc

template_parameter_pack.bc

byval_tail_nogep.ll

byval_tail_gep.ll

@frabert
Copy link
Collaborator Author

frabert commented May 19, 2023

Since LLVM16 supports (u)int128 literals, there is no more need to emit adjusted literals

Copy link

See the diff generated by this PR for the tests here: https://github.com/lifting-bits/rellic/actions/runs/8881669823

fizzbuzz.bc

typedefs_of_typedefs.bc

switch_loop.bc

func_cond_zero_arg.bc

fcmp.bc

conflicting_names.bc

struct.bc

issue_183_literal_structs.bc

zeroinit.bc

issue_127_uint128_t_lit.bc

--- /dev/fd/63	2024-04-29 16:15:17.026959824 +0000
+++ /dev/fd/62	2024-04-29 16:15:17.026959824 +0000
@@ -1,9 +1,9 @@
 int main(void);
-unsigned __int128 x = (unsigned __int128)3735928559ULL;
+unsigned __int128 x = 3735928559;
 int main(void) {
     unsigned int var0;
     unsigned char val1;
     var0 = 0U;
-    val1 = (x & (unsigned __int128)65535ULL) == (unsigned __int128)48879ULL;
+    val1 = (x & 65535) == 48879;
     return val1 ? 0U : 1U;
 }

struct_swap.bc

global_using_function_decl.bc

init_list.bc

ret0.bc

goto_loop.bc

trunc.bc

bitops.bc

cast.bc

nullptr.bc

nested_struct.bc

--- /dev/fd/63	2024-04-29 16:15:17.854970339 +0000
+++ /dev/fd/62	2024-04-29 16:15:17.854970339 +0000
@@ -14,7 +14,7 @@
     struct struct__pair field1;
     struct struct__person field2;
 };
-struct struct__record r1 = {14U, {33U, 42U}, {"Bob", (unsigned char)66U}};
+struct struct__record r1 = {14U, {33U, 42U}, {"Bob", 66U}};
 char _str_1[9] = "Name: %s\000";
 int main(void) {
     unsigned int var0;

array_swap.bc

binops.bc

bitmask.bc

loop.bc

float.bc

reg_test_structure_fields.bc

vectors.bc

funcptr.bc

inttoptr.bc

short.bc

--- /dev/fd/63	2024-04-29 16:15:18.850982987 +0000
+++ /dev/fd/62	2024-04-29 16:15:18.850982987 +0000
@@ -1,5 +1,5 @@
 int main(void);
-unsigned short a = (unsigned short)0U;
+unsigned short a = 0U;
 int main(void) {
     unsigned int var0;
     unsigned short var1;

issue_4.bc

conflicting_global.bc

issue_123_uint128_t.bc

fizzbuzz_stateful.bc

issue_94_strncmp.bc

bool.bc

zext.bc

--- /dev/fd/63	2024-04-29 16:15:19.642993045 +0000
+++ /dev/fd/62	2024-04-29 16:15:19.642993045 +0000
@@ -1,5 +1,5 @@
 int main(void);
-char a = (unsigned char)1U;
+char a = 1U;
 int main(void) {
     unsigned int var0;
     var0 = 0U;

byval_struct.bc

nested_while.bc

--- /dev/fd/63	2024-04-29 16:15:19.778994772 +0000
+++ /dev/fd/62	2024-04-29 16:15:19.778994772 +0000
@@ -25,7 +25,7 @@
                 printf("loop2 x: %d\n", var1);
             }
     }
-    if (((int)var1 >= 20 || (int)var1 <= 10) && (int)var1 >= 20) {
+    if ((int)var1 >= 20 && ((int)var1 >= 20 || (int)var1 <= 10)) {
         return var0;
     }
 }

func_cond_two_arg.bc

assert.bc

switch.bc

branch.bc

template_parameter_pack.bc

byval_tail_nogep.ll

byval_tail_gep.ll

issue_335_z3_ite.ll

@frabert frabert requested a review from surovic April 29, 2024 16:18
@surovic surovic merged commit a2d5ea7 into master Apr 29, 2024
6 checks passed
@surovic surovic deleted the fix-large-literals branch April 29, 2024 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants