[llvm] [llvm][ARM]Add widen global arrays pass (PR #107120)
Nashe Mncube via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 7 04:12:59 PDT 2024
nasherm wrote:
> With the now updated pass I get the following output on the below (truncated) IR
>
> **IR**
>
> ```
> @.str = private unnamed_addr constant [10 x i8] c"123456789\00", align 1
>
> ; Function Attrs: nounwind
> define hidden void @foo() #0 {
> entry:
> %something = alloca [10 x i8], align 1
> call void @llvm.memcpy.p0.p0.i32(ptr noundef nonnull align 1 dereferenceable(10) %something, ptr noundef nonnull align 1 dereferenceable(10) @.str, i32 10, i1 false)
> %call2 = call i32 @bar(ptr nonnull %something)
> ret void
> }
>
>
> declare i32 @bar(...)
> ```
***ARM***
```
**ARM (No pass)**
```
$ opt -mtriple=arm-none-eabi -S | llc -o -
foo:
.fnstart
@ %bb.0: @ %entry
.save {r11, lr}
push {r11, lr}
.pad #16
sub sp, sp, #16
mov r0, #57
strh r0, [sp, #12]
ldr r0, .LCPI0_0
str r0, [sp, #8]
ldr r0, .LCPI0_1
str r0, [sp, #4]
add r0, sp, #4
bl bar
add sp, sp, #16
pop {r11, lr}
mov pc, lr
.p2align 2
@ %bb.1:
.LCPI0_0:
.long 943142453 @ 0x38373635
.LCPI0_1:
.long 875770417 @ 0x34333231
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.fnend
@ -- End function
.type .L.str,%object @ @.str
.section .rodata.str1.4,"aMS",%progbits,1
.p2align 2, 0x0
.L.str:
.asciz "123456789"
.size .L.str, 10
.section ".note.GNU-stack","",%progbits
.eabi_attribute 30, 1 @ Tag_ABI_optimization_goals
```
**ARM (with pass)**
```
$ opt -passes=globalopt -mtriple=arm-none-eabi -S | llc -o -
foo:
.fnstart
@ %bb.0: @ %entry
.save {r11, lr}
push {r11, lr}
.pad #16
sub sp, sp, #16
mov r0, #57
str r0, [sp, #12]
ldr r0, .LCPI0_0
str r0, [sp, #8]
ldr r0, .LCPI0_1
str r0, [sp, #4]
add r0, sp, #4
bl bar
add sp, sp, #16
pop {r11, lr}
mov pc, lr
.p2align 2
@ %bb.1:
.LCPI0_0:
.long 943142453 @ 0x38373635
.LCPI0_1:
.long 875770417 @ 0x34333231
.Lfunc_end0:
.size foo, .Lfunc_end0-foo
.fnend
@ -- End function
.type .L.str,%object @ @.str
.section .rodata,"a",%progbits
.p2align 2, 0x0
.L.str:
.asciz "123456789\000\000"
.size .L.str, 12
.section ".note.GNU-stack","",%progbits
.eabi_attribute 30, 1 @ Tag_ABI_optimization_goals
```
https://github.com/llvm/llvm-project/pull/107120
More information about the llvm-commits
mailing list