Open
Description
$ cat arr.f90
program arr
integer :: a(5)
a(3) = 1
end program
$ fort -S -emit-llvm -o - arr.f90
; ModuleID = 'arr.f90'
source_filename = "arr.f90"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-freebsd11.1"
define i32 @main() {
program_entry:
call void @libfort_sys_init()
%a = alloca [5 x i32]
br label %body
body: ; preds = %program_entry
%0 = getelementptr inbounds [5 x i32], [5 x i32]* %a, i32 0, i32 0
%1 = getelementptr i32, i32* %0, i64 2
store i32 1, i32* %1
br label %program_exit
program_exit: ; preds = %body
ret i32 0
}
declare void @libfort_sys_init()
First getelementpointer
is redundant, at it returns the address of %a
. Optimizer is able to clean this up, but it does not make a lot of sense when dereferencing pointers that Fort uses for allocatable array support.