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

False precondition for refinement of global variable alignment #1108

Open
can-leh-emmtrix opened this issue Nov 6, 2024 · 0 comments
Open

Comments

@can-leh-emmtrix
Copy link
Contributor

can-leh-emmtrix commented Nov 6, 2024

Increasing the alignment of a global variable should be a refinement. Alive2 already proves this is in fact a refinement when the size of the global variable is a multiple of the new alignment. However, when the size of the global is not a multiple of the new alignment, the precondition is false:

****************************************
WARNING: Source function is always UB.
It can be refined by any target function.
Please make sure this is what you wanted.
****************************************

ERROR: Precondition is always false

Source:

@global = external global [100 x i8], align 4

define i32 @test() {
entry:
  %0 = load i32, ptr @global, align 4
  ret i32 %0
}

Target:

@global = external global [100 x i8], align 8

define i32 @test() {
entry:
  %0 = load i32, ptr @global, align 4
  ret i32 %0
}

Note that the only difference between the source and target is changing the align of @global from 4 to 8.

The size of the global variable is rounded up to the next multiple of its alignment here.
As the resulting size is different for source and target, the precondition now contains the axioms (= (_ bv100 8) (blk_size (_ bv0 1))) and (= (blk_size (_ bv0 1)) (_ bv104 8)) making it always false.

Related: #1028

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