[LLVMbugs] [Bug 13656] New: Optimizers wrongly think a GEP of global without inbounds can't point into a different global
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Aug 21 13:52:50 PDT 2012
http://llvm.org/bugs/show_bug.cgi?id=13656
Bug #: 13656
Summary: Optimizers wrongly think a GEP of global without
inbounds can't point into a different global
Product: new-bugs
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
AssignedTo: unassignedbugs at nondot.org
ReportedBy: baldrick at free.fr
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
This testcase was inspired by the fact that pointsToConstantGlobal in
InstCombineLoadStoreAlloca.cpp forgets to check "inbounds" on the GEP.
However my attempts to get a testcase failed because all kinds of other
parts of instcombine and constant folding also forget to check inbounds,
and would do wrong transforms before pointsToConstantGlobal could get
anywhere near the IR! So here is a simple testcase showing the issue:
it loads the value of a non-constant global @B, but instcombine is fooled
into thinking it is loading from another, constant, global @A thanks to a
tricky GEP.
; RUN: opt < %s -instcombine -S | FileCheck %s
target datalayout =
"e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
@A = constant i8 0
@B = global i8 0
define i8 @foo() {
; CHECK: @foo
; Load @B while sneakily giving the appearance of loading part of @A.
%val = load i8* getelementptr (i8* @A, i64 sub (i64 ptrtoint (i8* @B to i64),
i64 ptrtoint (i8* @A to i64)))
ret i8 %val
; CHECK-NOT: ret i8 0
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list