[LLVMbugs] [Bug 2548] New: wide strings versus endianness
bugzilla-daemon at cs.uiuc.edu
bugzilla-daemon at cs.uiuc.edu
Mon Jul 14 04:50:30 PDT 2008
http://llvm.org/bugs/show_bug.cgi?id=2548
Summary: wide strings versus endianness
Product: tools
Version: 2.3
Platform: PC
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P2
Component: llvm-gcc
AssignedTo: unassignedbugs at nondot.org
ReportedBy: jay.foad at antixlabs.com
CC: llvmbugs at cs.uiuc.edu
I built llvm-gcc as a cross compiler, running on x86 linux but targetting
sparc.
When I compile this source:
$ cat wide.c
int f() { return L'a'; }
int g() { return L"a"[0]; }
I get:
$ cc1 -quiet -emit-llvm wide.c
$ cat wide.s
; ModuleID = 'wide.c'
target datalayout =
"E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-f128:128:128"
target triple = "sparc-linux"
@.str = internal constant [2 x i32] [ i32 1627389952, i32 0 ] ; <[2 x
i32]*> [#uses=1]
define i32 @f() nounwind {
entry:
%retval = alloca i32 ; <i32*> [#uses=2]
%tmp = alloca i32 ; <i32*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
store i32 97, i32* %tmp, align 4
%tmp1 = load i32* %tmp, align 4 ; <i32> [#uses=1]
store i32 %tmp1, i32* %retval, align 4
br label %return
return: ; preds = %entry
%retval2 = load i32* %retval ; <i32> [#uses=1]
ret i32 %retval2
}
define i32 @g() nounwind {
entry:
%retval = alloca i32 ; <i32*> [#uses=2]
%tmp = alloca i32 ; <i32*> [#uses=2]
%"alloca point" = bitcast i32 0 to i32 ; <i32> [#uses=0]
%tmp1 = load i32* getelementptr ([2 x i32]* @.str, i32 0, i32 0), align
4 ; <i32> [#uses=1]
store i32 %tmp1, i32* %tmp, align 4
%tmp2 = load i32* %tmp, align 4 ; <i32> [#uses=1]
store i32 %tmp2, i32* %retval, align 4
br label %return
return: ; preds = %entry
%retval3 = load i32* %retval ; <i32> [#uses=1]
ret i32 %retval3
}
So f() will return 97 (0x61) but g() will return 1627389952 (0x61000000). This
looks like an endianness problem.
--
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