llvm.org GIT mirror llvm / 647c66e
[msan] Mostly disable msan-handle-icmp-exact. It is way too slow. Change the default option value to 0. Always do exact shadow propagation for unsigned ICmp with constants, it is cheap (under 1% cpu time) and required for correctness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173682 91177308-0d34-0410-b5e6-96231b3b80d8 Evgeniy Stepanov 6 years ago
2 changed file(s) with 39 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
128128
129129 static cl::opt ClHandleICmpExact("msan-handle-icmp-exact",
130130 cl::desc("exact handling of relational integer ICmp"),
131 cl::Hidden, cl::init(true));
131 cl::Hidden, cl::init(false));
132132
133133 static cl::opt ClStoreCleanOrigin("msan-store-clean-origin",
134134 cl::desc("store origin for clean (fully initialized) values"),
12541254 }
12551255
12561256 void visitICmpInst(ICmpInst &I) {
1257 if (ClHandleICmp && I.isEquality())
1257 if (!ClHandleICmp) {
1258 handleShadowOr(I);
1259 return;
1260 }
1261 if (I.isEquality()) {
12581262 handleEqualityComparison(I);
1259 else if (ClHandleICmp && ClHandleICmpExact && I.isRelational())
1263 return;
1264 }
1265
1266 assert(I.isRelational());
1267 if (ClHandleICmpExact) {
12601268 handleRelationalComparisonExact(I);
1261 else if (ClHandleICmp && I.isSigned() && I.isRelational())
1269 return;
1270 }
1271 if (I.isSigned()) {
12621272 handleSignedRelationalComparison(I);
1263 else
1264 handleShadowOr(I);
1273 return;
1274 }
1275
1276 assert(I.isUnsigned());
1277 if ((isa(I.getOperand(0)) || isa(I.getOperand(1)))) {
1278 handleRelationalComparisonExact(I);
1279 return;
1280 }
1281
1282 handleShadowOr(I);
12651283 }
12661284
12671285 void visitFCmpInst(FCmpInst &I) {
322322 ; CHECK-NOT: call void @__msan_warning
323323 ; CHECK: icmp slt
324324 ; CHECK-NOT: call void @__msan_warning
325 ; CHECK: icmp slt
326 ; CHECK-NOT: call void @__msan_warning
327325 ; CHECK: ret i1
328326
329327 define zeroext i1 @ICmpSGE(i32 %x) nounwind uwtable readnone {
332330 }
333331
334332 ; CHECK: @ICmpSGE
335 ; CHECK: icmp sge
336 ; CHECK-NOT: call void @__msan_warning
337 ; CHECK: icmp sge
333 ; CHECK: icmp slt
338334 ; CHECK-NOT: call void @__msan_warning
339335 ; CHECK: icmp sge
340336 ; CHECK-NOT: call void @__msan_warning
346342 }
347343
348344 ; CHECK: @ICmpSGT
349 ; CHECK: icmp sgt
350 ; CHECK-NOT: call void @__msan_warning
351 ; CHECK: icmp sgt
345 ; CHECK: icmp slt
352346 ; CHECK-NOT: call void @__msan_warning
353347 ; CHECK: icmp sgt
354348 ; CHECK-NOT: call void @__msan_warning
360354 }
361355
362356 ; CHECK: @ICmpSLE
363 ; CHECK: icmp sle
364 ; CHECK-NOT: call void @__msan_warning
365 ; CHECK: icmp sle
357 ; CHECK: icmp slt
366358 ; CHECK-NOT: call void @__msan_warning
367359 ; CHECK: icmp sle
368360 ; CHECK-NOT: call void @__msan_warning
380372 ; CHECK: @ICmpSLT_vector
381373 ; CHECK: icmp slt <2 x i64>
382374 ; CHECK-NOT: call void @__msan_warning
383 ; CHECK: icmp slt <2 x i64>
384 ; CHECK-NOT: call void @__msan_warning
385375 ; CHECK: icmp slt <2 x i32*>
386376 ; CHECK-NOT: call void @__msan_warning
387377 ; CHECK: ret <2 x i1>
388378
389379
390 ; Check that we propagate shadow for arbitrary relational comparisons
391
392 define zeroext i1 @ICmpSLENonZero(i32 %x, i32 %y) nounwind uwtable readnone {
393 entry:
394 %cmp = icmp sle i32 %x, %y
380 ; Check that we propagate shadow for unsigned relational comparisons with
381 ; constants
382
383 define zeroext i1 @ICmpUGTConst(i32 %x) nounwind uwtable readnone {
384 entry:
385 %cmp = icmp ugt i32 %x, 7
395386 ret i1 %cmp
396387 }
397388
398 ; CHECK: @ICmpSLENonZero
399 ; CHECK: icmp sle i32
400 ; CHECK-NOT: call void @__msan_warning
401 ; CHECK: icmp sle i32
402 ; CHECK-NOT: call void @__msan_warning
403 ; CHECK: icmp sle i32
389 ; CHECK: @ICmpUGTConst
390 ; CHECK: icmp ugt i32
391 ; CHECK-NOT: call void @__msan_warning
392 ; CHECK: icmp ugt i32
393 ; CHECK-NOT: call void @__msan_warning
394 ; CHECK: icmp ugt i32
404395 ; CHECK-NOT: call void @__msan_warning
405396 ; CHECK: ret i1
406397