I'm trying to use a plugin to generate a label with the following code:
tree lab = build_decl (gimple_location (gsi_stmt (gsi)),
LABEL_DECL, NULL_TREE, void_type_node);
DECL_ARTIFICIAL (lab) = 0;
DECL_IGNORED_P (lab) = 1;
DECL_CONTEXT (lab) = current_function_decl;
DECL_NAME(lab) = get_identifier("test_text");
location_t loc = gimple_location (gsi_stmt (gsi));
tree label = create_artificial_label (loc);
gsi_insert_before (&gsi, gimple_build_label (lab), GSI_SAME_STMT);
While this works when I try to generate code for my intel processor, if I run this plugin in a cross-compiler for arm the labels' names are changed to a local symbol with a random name. For example, instead of obtaining "test_text:" I get ".L4:". Also, an additional instruction is added.
Below is an example of the code generated without the label generation code enabled.
ldrb r3, [fp, #-5] @ zero_extendqisi2
add r2, r2, r3
movw r3, #:lower16:b1
movt r3, #:upper16:b1
str r2, [r3, #4]
And now, it follows the code generated using the first shown code (generating a label in the tree and gimple representations). You can see that the test_text label was subsituted by .L5 and that an add instruction was added below the label. How is this possible?
ldrb r3, [fp, #-5] @ zero_extendqisi2
add r2, r2, r3
.L5:
add fp, fp, #4
movw r3, #:lower16:b1
movt r3, #:upper16:b1
str r2, [r3, #4]
I'm running my plugin after the CFG pass. Also, I'm using Linaro cross-compiler arm-eabi-gcc version 6.3.1.
Best Regards
Edit 1: Also found, by using -fdump-tree-optimized, that until this stage everything is fine. Partial output of the *.optmized file:
<bb 4>:
_8 = i_2 % 3;
_9 = _8 == 0;
test_text:
div_3 = _9;
_11 = i_2 % 5;