[LLVMbugs] [Bug 16263] New: Incorrect code gen for global const ref
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Fri Jun 7 04:09:21 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=16263
Bug ID: 16263
Summary: Incorrect code gen for global const ref
Product: clang
Version: trunk
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: a.bataev at gmx.com
CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
Classification: Unclassified
clang incorrectly translates the next code:
const unsigned ii = 0xdeadbeaf;
const int& dd = (const int&) ii;
int main(void) {
return (ii == dd) ? 0: 1;
}
clang produces the following llvm-code:
; ModuleID = 'test.cpp'
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-apple-macosx10.8.0"
@dd = global i32* null, align 8
@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()*
} { i32 65535, void ()* @_GLOBAL__I_a }]
define internal void @__cxx_global_var_init() section
"__TEXT,__StaticInit,regular,pure_instructions" {
entry:
%ref.tmp = alloca i32, align 4
store i32 -559038801, i32* %ref.tmp, align 4
store i32* %ref.tmp, i32** @dd, align 8
ret void
}
define i32 @main() nounwind uwtable ssp {
entry:
%retval = alloca i32, align 4
store i32 0, i32* %retval
%0 = load i32** @dd, align 8
%1 = load i32* %0, align 4
%cmp = icmp eq i32 -559038801, %1
%cond = select i1 %cmp, i32 0, i32 1
ret i32 %cond
}
define internal void @_GLOBAL__I_a() section
"__TEXT,__StaticInit,regular,pure_instructions" {
entry:
call void @__cxx_global_var_init()
ret void
}
The cope for @dd initialization in @__cxx_global_var_init is incorrect.
Alexey Bataev
Software Engineer
Intel Compiler Team
Intel Corp.
--
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/20130607/5b5b55e6/attachment.html>
More information about the llvm-bugs
mailing list