Store command in LLVM-IR

Viewed 18

The following LLVM-IR cannot be compiled by clang to an executable file ("clang test2.ll") and give this error in store commands (Even IR generated by clang using "-S -emit-llvm -O0 -g0" does not compile correctly):

 test2.ll:8:18: error: expected type
 store i32 0, ptr %1, align 4

IR in test2.ll:

; ModuleID = 'Module'
source_filename = "Module"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

define i32 @main() {
  %1 = alloca i32, align 4
  %2 = alloca i32, align 4
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  store i32 0, ptr %1, align 4
  store i32 100, ptr %2, align 4
  store i32 10, ptr %3, align 4
  store i32 2, ptr %4, align 4
  %6 = load i32, ptr %2, align 4
  %7 = load i32, ptr %3, align 4
  %8 = add nsw i32 %6, %7
  %9 = load i32, ptr %4, align 4
  %10 = sub nsw i32 %9, 2
  %11 = sub nsw i32 %8, %10
  store i32 %11, ptr %5, align 4
  ret i32 0
}
0 Answers
Related