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

performance problem with indirection #968

Open
regehr opened this issue Nov 18, 2023 · 0 comments
Open

performance problem with indirection #968

regehr opened this issue Nov 18, 2023 · 0 comments
Labels
memory Memory Model performance Opportunities for improving performance

Comments

@regehr
Copy link
Contributor

regehr commented Nov 18, 2023

here's an example where the asm memory model isn't yet making verification fast; this one exits with SMT Error: unclassified exception after about 2.5 minutes

source_filename = "M2"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-linux-gnu"


define dso_local i32 @two_stars(ptr noundef %0) #0 {
  %2 = alloca ptr, align 8
  store ptr %0, ptr %2, align 8
  %3 = load ptr, ptr %2, align 8
  %4 = load ptr, ptr %3, align 8
  %5 = load i32, ptr %4, align 4
  ret i32 %5
}

attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+outline-atomics,+v8a,-fmv" }
; ModuleID = 'M2'
source_filename = "M2"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-linux-gnu"

define i32 @two_stars(ptr %0) local_unnamed_addr {
arm_tv_entry:
  %stack = tail call dereferenceable(640) ptr @myalloc(i32 640)
  %1 = getelementptr inbounds i8, ptr %stack, i64 512
  %2 = ptrtoint ptr %1 to i64
  %3 = ptrtoint ptr %0 to i64
  %a2_1 = add i64 %2, -16
  %4 = inttoptr i64 %a2_1 to ptr
  %5 = getelementptr i8, ptr %4, i64 8
  store i64 %3, ptr %5, align 1
  %a5_1 = load i64, ptr %0, align 1
  %6 = inttoptr i64 %a5_1 to ptr
  %a6_1 = load i32, ptr %6, align 1
  ret i32 %a6_1
}

; Function Attrs: allockind("alloc") allocsize(0)
declare nonnull ptr @myalloc(i32) local_unnamed_addr #0

attributes #0 = { allockind("alloc") allocsize(0) }
regehr@john-home:~/alive2-regehr/tests/arm-tv/pointers$ time ~/alive2-regehr/build/alive-tv double-indirect-1a.ll ~/tgt.ll --tgt-is-asm --smt-to=600000

----------------------------------------
define i32 @two_stars(ptr noundef %#0) {
#1:
  %#2 = alloca i64 8, align 8
  store ptr noundef %#0, ptr %#2, align 8
  %#3 = load ptr, ptr %#2, align 8
  %#4 = load ptr, ptr %#3, align 8
  %#5 = load i32, ptr %#4, align 4
  ret i32 %#5
}
=>
declare ptr @myalloc(i32)

define i32 @two_stars(ptr %#0) asm {
arm_tv_entry:
  %stack = call ptr @myalloc(i32 640) dereferenceable(640) nonnull allockind(alloc) allocsize(0)
  %#1 = gep inbounds ptr %stack, 1 x i64 512
  %#2 = ptrtoint ptr %#1 to i64
  %#3 = ptrtoint ptr %#0 to i64
  %a2_1 = add i64 %#2, -16
  %#4 = int2ptr i64 %a2_1 to ptr
  %#5 = gep ptr %#4, 1 x i64 8
  store i64 %#3, ptr %#5, align 1
  %a5_1 = load i64, ptr %#0, align 1
  %#6 = int2ptr i64 %a5_1 to ptr
  %a6_1 = load i32, ptr %#6, align 1
  ret i32 %a6_1
}
ERROR: SMT Error: unclassified exception

Summary:
  0 correct transformations
  0 incorrect transformations
  1 failed-to-prove transformations
  0 Alive2 errors

real	2m19.009s
user	2m17.265s
sys	0m1.700s
regehr@john-home:~/alive2-regehr/tests/arm-tv/pointers$ 
@nunoplopes nunoplopes added performance Opportunities for improving performance memory Memory Model labels Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory Memory Model performance Opportunities for improving performance
Projects
None yet
Development

No branches or pull requests

2 participants