[LLVMbugs] [Bug 11786] New: Fatal error generating code for atomic operations [x86-64]

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Jan 17 10:54:07 PST 2012


http://llvm.org/bugs/show_bug.cgi?id=11786

             Bug #: 11786
           Summary: Fatal error generating code for atomic operations
                    [x86-64]
           Product: new-bugs
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: csdavec at swan.ac.uk
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


With this IR, produced while attempting to find a reduced test case for a
libc++ miscompilation bug, I get a fatal error in the codegen:

; ModuleID = 'atom.c'
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-freebsd9.0"

@.str = private unnamed_addr constant [4 x i8] c"%p\0A\00", align 1

define i32 @main() nounwind uwtable {
  %1 = alloca i32, align 4
  %a = alloca i32*, align 8
  %b = alloca i32*, align 8
  %2 = alloca i32, align 4
  %3 = alloca i8, align 1
  store i32 0, i32* %1
  store i32* inttoptr (i64 3 to i32*), i32** %a, align 8
  store i32* inttoptr (i64 3 to i32*), i32** %b, align 8
  %4 = load atomic i32** %a seq_cst, align 8
  %5 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]*
@.str, i32 0, i32 0), i32* %4)
  store i32 5, i32* %2
  %6 = bitcast i32** %a to i64*
  %7 = bitcast i32** %b to i64*
  %8 = bitcast i32* %2 to i64*
  %9 = load i64* %7, align 8
  %10 = load i64* %8, align 8
  %11 = cmpxchg i64* %6, i64 %9, i64 %10 seq_cst
  store i64 %11, i64* %7, align 8
  %12 = icmp eq i64 %11, %9
  %13 = zext i1 %12 to i8
  store i8 %13, i8* %3
  %14 = load i8* %3
  %15 = trunc i8 %14 to i1
  %16 = load atomic i32** %a seq_cst, align 8
  %17 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([4 x i8]*
@.str, i32 0, i32 0), i32* %16)
  ret i32 0
}

declare i32 @printf(i8*, ...)




This is the error:

fatal error: error in backend: Cannot select: 0x802a47e10: i64 = any_extend
0x802a47d10 [ID=47]
  0x802a47d10: i1,ch = AtomicLoad 0x802a47a10, 0x802a44610<Volatile
LDST1[%a](align=8)> [ORD=22] [ID=46]
    0x802a44610: i64 = FrameIndex<1> [ORD=3] [ID=5]

Replacing the cmpxchg with a load gives me a different error, this time
complaining about being able to match the atomic load.

-- 
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