Index: llvm/lib/CodeGen/CallingConvLower.cpp =================================================================== --- llvm/lib/CodeGen/CallingConvLower.cpp +++ llvm/lib/CodeGen/CallingConvLower.cpp @@ -276,18 +276,23 @@ for (unsigned I = 0, E = RVLocs1.size(); I != E; ++I) { const CCValAssign &Loc1 = RVLocs1[I]; const CCValAssign &Loc2 = RVLocs2[I]; + // Must fill the same part of their locations if (Loc1.getLocInfo() != Loc2.getLocInfo()) return false; - bool RegLoc1 = Loc1.isRegLoc(); - if (RegLoc1 != Loc2.isRegLoc()) - return false; - if (RegLoc1) { - if (Loc1.getLocReg() != Loc2.getLocReg()) + + if (Loc1.isRegLoc() && Loc2.isRegLoc()) { + if (Loc1.getLocReg() != Loc2.getLocReg()) { return false; - } else { - if (Loc1.getLocMemOffset() != Loc2.getLocMemOffset()) + } + } else if (Loc1.isMemLoc() && Loc2.isMemLoc()) { + if (Loc1.getLocMemOffset() != Loc2.getLocMemOffset()) { return false; + } + } else { + // Mix of register/memory is not compatible + return false; } } + return true; }