[LLVMbugs] [Bug 12060] New: globalopt miscompilation
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Feb 21 12:58:34 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=12060
Bug #: 12060
Summary: globalopt miscompilation
Product: libraries
Version: trunk
Platform: PC
OS/Version: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: Transformation Utilities
AssignedTo: unassignedbugs at nondot.org
ReportedBy: richard-llvm at metafoo.co.uk
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
The following code, compiled by clang, produces a correct result (m=13) at -O0
and incorrect result (m=9) at -O1:
auto s = [](int a) { return [=](int b) { return a + b; }; };
auto f = s(4);
auto m = f(9);
Reduced IR:
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-S128"
target triple = "x86_64-unknown-linux-gnu"
%closure = type { i32 }
@f = internal global %closure zeroinitializer, align 4
@m = global i32 0, align 4
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()*
} { i32 65535, void ()* @_GLOBAL__I_a }]
define internal i32 @lambda(%closure* %this, i32 %b) nounwind uwtable
inlinehint align 2 {
entry:
%0 = getelementptr inbounds %closure* %this, i32 0, i32 0
%1 = load i32* %0, align 4
%add = add nsw i32 %1, %b
ret i32 %add
}
define internal void @_GLOBAL__I_a() section ".text.startup" {
entry:
store i32 4, i32* getelementptr inbounds (%closure* @f, i32 0, i32 0)
%call = call i32 @lambda(%closure* @f, i32 9)
store i32 %call, i32* @m, align 4
ret void
}
Manually inlining the call to @lambda removes the miscompile. I'm not sure if
this is related to PR11352, but it appears to be reasonably similar.
--
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