aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/gcc-plugins/latent_entropy_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/gcc-plugins/latent_entropy_plugin.c')
-rw-r--r--scripts/gcc-plugins/latent_entropy_plugin.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/scripts/gcc-plugins/latent_entropy_plugin.c b/scripts/gcc-plugins/latent_entropy_plugin.c
index ff1939b804ae..8160f1c1b56e 100644
--- a/scripts/gcc-plugins/latent_entropy_plugin.c
+++ b/scripts/gcc-plugins/latent_entropy_plugin.c
@@ -77,7 +77,7 @@
77 77
78#include "gcc-common.h" 78#include "gcc-common.h"
79 79
80int plugin_is_GPL_compatible; 80__visible int plugin_is_GPL_compatible;
81 81
82static GTY(()) tree latent_entropy_decl; 82static GTY(()) tree latent_entropy_decl;
83 83
@@ -340,7 +340,7 @@ static enum tree_code get_op(tree *rhs)
340 break; 340 break;
341 } 341 }
342 if (rhs) 342 if (rhs)
343 *rhs = build_int_cstu(unsigned_intDI_type_node, random_const); 343 *rhs = build_int_cstu(long_unsigned_type_node, random_const);
344 return op; 344 return op;
345} 345}
346 346
@@ -372,7 +372,7 @@ static void __perturb_latent_entropy(gimple_stmt_iterator *gsi,
372 enum tree_code op; 372 enum tree_code op;
373 373
374 /* 1. create temporary copy of latent_entropy */ 374 /* 1. create temporary copy of latent_entropy */
375 temp = create_var(unsigned_intDI_type_node, "tmp_latent_entropy"); 375 temp = create_var(long_unsigned_type_node, "temp_latent_entropy");
376 376
377 /* 2. read... */ 377 /* 2. read... */
378 add_referenced_var(latent_entropy_decl); 378 add_referenced_var(latent_entropy_decl);
@@ -459,13 +459,13 @@ static void init_local_entropy(basic_block bb, tree local_entropy)
459 gsi_insert_before(&gsi, call, GSI_NEW_STMT); 459 gsi_insert_before(&gsi, call, GSI_NEW_STMT);
460 update_stmt(call); 460 update_stmt(call);
461 461
462 udi_frame_addr = fold_convert(unsigned_intDI_type_node, frame_addr); 462 udi_frame_addr = fold_convert(long_unsigned_type_node, frame_addr);
463 assign = gimple_build_assign(local_entropy, udi_frame_addr); 463 assign = gimple_build_assign(local_entropy, udi_frame_addr);
464 gsi_insert_after(&gsi, assign, GSI_NEW_STMT); 464 gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
465 update_stmt(assign); 465 update_stmt(assign);
466 466
467 /* 3. create temporary copy of latent_entropy */ 467 /* 3. create temporary copy of latent_entropy */
468 tmp = create_var(unsigned_intDI_type_node, "tmp_latent_entropy"); 468 tmp = create_var(long_unsigned_type_node, "temp_latent_entropy");
469 469
470 /* 4. read the global entropy variable into local entropy */ 470 /* 4. read the global entropy variable into local entropy */
471 add_referenced_var(latent_entropy_decl); 471 add_referenced_var(latent_entropy_decl);
@@ -480,7 +480,7 @@ static void init_local_entropy(basic_block bb, tree local_entropy)
480 update_stmt(assign); 480 update_stmt(assign);
481 481
482 rand_cst = get_random_const(); 482 rand_cst = get_random_const();
483 rand_const = build_int_cstu(unsigned_intDI_type_node, rand_cst); 483 rand_const = build_int_cstu(long_unsigned_type_node, rand_cst);
484 op = get_op(NULL); 484 op = get_op(NULL);
485 assign = create_assign(op, local_entropy, local_entropy, rand_const); 485 assign = create_assign(op, local_entropy, local_entropy, rand_const);
486 gsi_insert_after(&gsi, assign, GSI_NEW_STMT); 486 gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
@@ -529,7 +529,7 @@ static unsigned int latent_entropy_execute(void)
529 } 529 }
530 530
531 /* 1. create the local entropy variable */ 531 /* 1. create the local entropy variable */
532 local_entropy = create_var(unsigned_intDI_type_node, "local_entropy"); 532 local_entropy = create_var(long_unsigned_type_node, "local_entropy");
533 533
534 /* 2. initialize the local entropy variable */ 534 /* 2. initialize the local entropy variable */
535 init_local_entropy(bb, local_entropy); 535 init_local_entropy(bb, local_entropy);
@@ -561,10 +561,9 @@ static void latent_entropy_start_unit(void *gcc_data __unused,
561 if (in_lto_p) 561 if (in_lto_p)
562 return; 562 return;
563 563
564 /* extern volatile u64 latent_entropy */ 564 /* extern volatile unsigned long latent_entropy */
565 gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64); 565 quals = TYPE_QUALS(long_unsigned_type_node) | TYPE_QUAL_VOLATILE;
566 quals = TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE; 566 type = build_qualified_type(long_unsigned_type_node, quals);
567 type = build_qualified_type(long_long_unsigned_type_node, quals);
568 id = get_identifier("latent_entropy"); 567 id = get_identifier("latent_entropy");
569 latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, id, type); 568 latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, id, type);
570 569
@@ -584,8 +583,8 @@ static void latent_entropy_start_unit(void *gcc_data __unused,
584 | TODO_update_ssa 583 | TODO_update_ssa
585#include "gcc-generate-gimple-pass.h" 584#include "gcc-generate-gimple-pass.h"
586 585
587int plugin_init(struct plugin_name_args *plugin_info, 586__visible int plugin_init(struct plugin_name_args *plugin_info,
588 struct plugin_gcc_version *version) 587 struct plugin_gcc_version *version)
589{ 588{
590 bool enabled = true; 589 bool enabled = true;
591 const char * const plugin_name = plugin_info->base_name; 590 const char * const plugin_name = plugin_info->base_name;