Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken variable length array #2

Open
Codetector1374 opened this issue Dec 12, 2019 · 0 comments
Open

Broken variable length array #2

Codetector1374 opened this issue Dec 12, 2019 · 0 comments

Comments

@Codetector1374
Copy link
Member

__attribute__((noinline))
int simple(unsigned n) {
  volatile int shit[n];
  volatile int a;
  shit[n-1] = n;
  return a;
}
; ModuleID = 'simple.c'
source_filename = "simple.c"
target datalayout = "E-m:e-S32-p:32:32:32-i32:32:32-a:32:32-n32"
target triple = "tl45-unknown-unknown-elf"

; Function Attrs: noinline nounwind
define dso_local i32 @simple(i32 %n) local_unnamed_addr #0 {
entry:
  %a = alloca i32, align 4
  %vla = alloca i32, i32 %n, align 4
  %a.0.a.0..sroa_cast = bitcast i32* %a to i8*
  call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %a.0.a.0..sroa_cast)
  %sub = add i32 %n, -1
  %arrayidx = getelementptr inbounds i32, i32* %vla, i32 %sub
  store volatile i32 %n, i32* %arrayidx, align 4, !tbaa !2
  %a.0.a.0. = load volatile i32, i32* %a, align 4, !tbaa !2
  call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %a.0.a.0..sroa_cast)
  ret i32 %a.0.a.0.
}
; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1

; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1

attributes #0 = { noinline nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { argmemonly nounwind willreturn }
attributes #2 = { nounwind "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="none" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }

!llvm.module.flags = !{!0}
!llvm.ident = !{!1}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 10.0.0 ([email protected]:transfer-learning/llvm-tl45.git 9c609f55e093b10737f8006ade652e06a6a1d976)"}
!2 = !{!3, !3, i64 0}
!3 = !{!"int", !4, i64 0}
!4 = !{!"omnipotent char", !5, i64 0}
!5 = !{!"Simple C/C++ TBAA"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant