Skip to content

Commit a9d84cb

Browse files
committedJul 12, 2018
[IRInterpreter] Fix misevaluation of interpretation expressions with urem.
Scalar::MakeUnsigned was implemented incorrectly so it didn't really change the sign of the type (leaving signed types signed). This showed up as a misevaluation when IR-interpreting urem but it's likely to arise in other contexts. This commit fixes the definition, and adds a test to make sure this won't regress in future (hopefully). Fixes rdar://problem/42038760 and LLVM PR38076 Differential Revision: https://reviews.llvm.org/D49155 llvm-svn: 336872
1 parent 034adf2 commit a9d84cb

File tree

4 files changed

+31
-5
lines changed

4 files changed

+31
-5
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
LEVEL = ../../make
2+
C_SOURCES := main.c
3+
include $(LEVEL)/Makefile.rules
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from lldbsuite.test import lldbinline
2+
from lldbsuite.test import decorators
3+
4+
lldbinline.MakeInlineTest(__file__, globals(), None)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Make sure we IR-interpret the expression correctly.
2+
3+
typedef unsigned int uint32_t;
4+
struct S0 {
5+
signed f2;
6+
};
7+
static g_463 = 0x1561983AL;
8+
void func_1(void)
9+
{
10+
struct S0 l_19;
11+
l_19.f2 = 419;
12+
uint32_t l_4037 = 4294967295UL;
13+
l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
14+
}
15+
int main()
16+
{
17+
func_1();
18+
return 0;
19+
}

‎lldb/source/Core/Scalar.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1184,38 +1184,38 @@ bool Scalar::MakeUnsigned() {
11841184
case e_void:
11851185
break;
11861186
case e_sint:
1187+
m_type = e_uint;
11871188
success = true;
11881189
break;
11891190
case e_uint:
1190-
m_type = e_uint;
11911191
success = true;
11921192
break;
11931193
case e_slong:
1194+
m_type = e_ulong;
11941195
success = true;
11951196
break;
11961197
case e_ulong:
1197-
m_type = e_ulong;
11981198
success = true;
11991199
break;
12001200
case e_slonglong:
1201+
m_type = e_ulonglong;
12011202
success = true;
12021203
break;
12031204
case e_ulonglong:
1204-
m_type = e_ulonglong;
12051205
success = true;
12061206
break;
12071207
case e_sint128:
1208+
m_type = e_uint128;
12081209
success = true;
12091210
break;
12101211
case e_uint128:
1211-
m_type = e_uint128;
12121212
success = true;
12131213
break;
12141214
case e_sint256:
1215+
m_type = e_uint256;
12151216
success = true;
12161217
break;
12171218
case e_uint256:
1218-
m_type = e_uint256;
12191219
success = true;
12201220
break;
12211221
case e_float:

0 commit comments

Comments
 (0)
Please sign in to comment.