[llvm-bugs] [Bug 34242] New: inlining a function into itself can result in references to version of variable from wrong frame
via llvm-bugs
llvm-bugs at lists.llvm.org
Fri Aug 18 17:45:32 PDT 2017
https://bugs.llvm.org/show_bug.cgi?id=34242
Bug ID: 34242
Summary: inlining a function into itself can result in
references to version of variable from wrong frame
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: richard-llvm at metafoo.co.uk
CC: llvm-bugs at lists.llvm.org,
sanjoy at playingwithpointers.com
Reduced miscompiled testcase: (reduced from libaf's af_pan.c)
define i32 @test(i1 %init, i8* %addr) {
bb:
%n = alloca i32
br i1 %init, label %store, label %load
store:
store i32 0, i32* %n
%cast = bitcast i32* %n to i8*
%v = call i32 @test(i1 0, i8* %cast)
ret i32 %v
load:
%castback = bitcast i8* %addr to i32*
%n.load = load i32, i32* %castback
ret i32 %n.load
}
After inlining, we get this:
define i32 @test(i1 %init, i8* %addr) {
bb:
%n.i = alloca i32
%n = alloca i32
br i1 %init, label %store, label %load
store: ; preds = %bb
store i32 0, i32* %n
%cast = bitcast i32* %n to i8*
%0 = bitcast i32* %n.i to i8*
call void @llvm.lifetime.start.p0i8(i64 4, i8* %0)
%n.load.i = load i32, i32* %n.i
%1 = bitcast i32* %n.i to i8*
call void @llvm.lifetime.end.p0i8(i64 4, i8* %1)
ret i32 %n.load.i
load: ; preds = %bb
%castback = bitcast i8* %addr to i32*
%n.load = load i32, i32* %castback
ret i32 %n.load
}
This is wrong: %n.load.i is a load of the *wrong variable*. We should be
loading %n, not %n.i.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20170819/08758b31/attachment.html>
More information about the llvm-bugs
mailing list