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

Invalid transform: gep p, (q-p) -> q #44789

Closed
nunoplopes opened this issue Apr 6, 2020 · 1 comment
Closed

Invalid transform: gep p, (q-p) -> q #44789

nunoplopes opened this issue Apr 6, 2020 · 1 comment
Labels
bugzilla Issues migrated from bugzilla duplicate Resolved as duplicate miscompilation

Comments

@nunoplopes
Copy link
Member

Bugzilla Link 45444
Resolution DUPLICATE
Resolved on Apr 06, 2020 08:30
Version trunk
OS All
CC @efriedma-quic,@aqjune,@LebedevRI,@regehr,@rotateright

Extended Description

Unit test: Transforms/InstCombine/getelementptr.ll
Summary: just because 2 pointers have the same integer value it doesn't mean they are the same pointer. While %gep is in bounds, %c2 may refer to another object with an OOB pointer.

define * @​test45(* %c1, * %c2) {
%0:
%ptrtoint1 = ptrtoint * %c1 to i64
%ptrtoint2 = ptrtoint * %c2 to i64
%sub = sub i64 %ptrtoint2, %ptrtoint1
%shr = sdiv i64 %sub, 7
%gep = gep inbounds * %c1, 7 x i64 %shr
ret * %gep
}
=>
define * @​test45(* %c1, * %c2) {
%0:
%gep = bitcast * %c2 to *
ret * %gep
}
Transformation doesn't verify!
ERROR: Value mismatch

Example:

  • %c1 = pointer(non-local, block_id=1, offset=7790792235569643584)
  • %c2 = pointer(non-local, block_id=0, offset=8251192938491543615)

Source:
i64 %ptrtoint1 = #x72907442c8000040 (8255225947142225984)
i64 %ptrtoint2 = #x72822042c800003f (8251192938491543615)
i64 %sub = #xfff1abffffffffff (18442711065058869247, -4033008650682369)
i64 %shr = #xfffdf40000000000 (18446167929616596992, -576144092954624)

  • %gep = pointer(non-local, block_id=1, offset=7786759226918961216)

Target:

  • %gep = pointer(non-local, block_id=0, offset=8251192938491543615)
    Source value: pointer(non-local, block_id=1, offset=7786759226918961216)
    Target value: pointer(non-local, block_id=0, offset=8251192938491543615)

https://web.ist.utl.pt/nuno.lopes/alive2/index.php?hash=2009353267698970&test=Transforms%2FInstCombine%2Fgetelementptr.ll

@nunoplopes
Copy link
Member Author

Sorry, this is a dup.

*** This bug has been marked as a duplicate of bug #43748 ***

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla duplicate Resolved as duplicate miscompilation
Projects
None yet
Development

No branches or pull requests

1 participant