Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 78fa56c

Browse files
committed
Revert a couple of InstCombine/Guard checkins
This change reverts: r293061: "[InstCombine] Canonicalize guards for NOT OR condition" r293058: "[InstCombine] Canonicalize guards for AND condition" They miscompile cases like: ``` declare void @llvm.experimental.guard(i1, ...) define void @test_guard_not_or(i1 %A, i1 %B) { %C = or i1 %A, %B %D = xor i1 %C, true call void(i1, ...) @llvm.experimental.guard(i1 %D, i32 20, i32 30)[ "deopt"() ] ret void } ``` because they do transfer the `i32 20, i32 30` parameters to newly created guard instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293227 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent e6f10d3 commit 78fa56c

File tree

2 files changed

+0
-75
lines changed

2 files changed

+0
-75
lines changed

lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,35 +3010,6 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
30103010
if (match(II->getNextNode(),
30113011
m_Intrinsic<Intrinsic::experimental_guard>(m_Specific(IIOperand))))
30123012
return eraseInstFromFunction(*II);
3013-
3014-
// Canonicalize guard(a && b) -> guard(a); guard(b);
3015-
// Note: New guard intrinsics created here are registered by
3016-
// the InstCombineIRInserter object.
3017-
Function *GuardIntrinsic = II->getCalledFunction();
3018-
Value *A, *B;
3019-
OperandBundleDef DeoptOB(*II->getOperandBundle(LLVMContext::OB_deopt));
3020-
if (match(IIOperand, m_And(m_Value(A), m_Value(B)))) {
3021-
CallInst *GuardA =
3022-
Builder->CreateCall(GuardIntrinsic, A, {DeoptOB}, II->getName());
3023-
CallInst *GuardB =
3024-
Builder->CreateCall(GuardIntrinsic, B, {DeoptOB}, II->getName());
3025-
auto CC = II->getCallingConv();
3026-
GuardA->setCallingConv(CC);
3027-
GuardB->setCallingConv(CC);
3028-
return eraseInstFromFunction(*II);
3029-
}
3030-
3031-
// guard(!(a || b)) -> guard(!a); guard(!b);
3032-
if (match(IIOperand, m_Not(m_Or(m_Value(A), m_Value(B))))) {
3033-
CallInst *GuardA = Builder->CreateCall(
3034-
GuardIntrinsic, Builder->CreateNot(A), {DeoptOB}, II->getName());
3035-
CallInst *GuardB = Builder->CreateCall(
3036-
GuardIntrinsic, Builder->CreateNot(B), {DeoptOB}, II->getName());
3037-
auto CC = II->getCallingConv();
3038-
GuardA->setCallingConv(CC);
3039-
GuardB->setCallingConv(CC);
3040-
return eraseInstFromFunction(*II);
3041-
}
30423013
break;
30433014
}
30443015
}

test/Transforms/InstCombine/call-guard.ll

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -28,49 +28,3 @@ define void @test_guard_adjacent_neg(i1 %A, i1 %B) {
2828
call void(i1, ...) @llvm.experimental.guard( i1 %B )[ "deopt"() ]
2929
ret void
3030
}
31-
32-
define void @test_guard_and(i1 %A, i1 %B) {
33-
; CHECK-LABEL: @test_guard_and(
34-
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ]
35-
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ]
36-
; CHECK-NEXT: ret void
37-
%C = and i1 %A, %B
38-
call void(i1, ...) @llvm.experimental.guard( i1 %C )[ "deopt"() ]
39-
ret void
40-
}
41-
42-
define void @test_guard_and_non_default_cc(i1 %A, i1 %B) {
43-
; CHECK-LABEL: @test_guard_and_non_default_cc(
44-
; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ]
45-
; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ]
46-
; CHECK-NEXT: ret void
47-
%C = and i1 %A, %B
48-
call cc99 void(i1, ...) @llvm.experimental.guard( i1 %C )[ "deopt"() ]
49-
ret void
50-
}
51-
52-
define void @test_guard_not_or(i1 %A, i1 %B) {
53-
; CHECK-LABEL: @test_guard_not_or(
54-
; CHECK-NEXT: %1 = xor i1 %A, true
55-
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %1) [ "deopt"() ]
56-
; CHECK-NEXT: %2 = xor i1 %B, true
57-
; CHECK-NEXT: call void (i1, ...) @llvm.experimental.guard(i1 %2) [ "deopt"() ]
58-
; CHECK-NEXT: ret void
59-
%C = or i1 %A, %B
60-
%D = xor i1 %C, true
61-
call void(i1, ...) @llvm.experimental.guard( i1 %D )[ "deopt"() ]
62-
ret void
63-
}
64-
65-
define void @test_guard_not_or_non_default_cc(i1 %A, i1 %B) {
66-
; CHECK-LABEL: @test_guard_not_or_non_default_cc(
67-
; CHECK-NEXT: %1 = xor i1 %A, true
68-
; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %1) [ "deopt"() ]
69-
; CHECK-NEXT: %2 = xor i1 %B, true
70-
; CHECK-NEXT: call cc99 void (i1, ...) @llvm.experimental.guard(i1 %2) [ "deopt"() ]
71-
; CHECK-NEXT: ret void
72-
%C = or i1 %A, %B
73-
%D = xor i1 %C, true
74-
call cc99 void(i1, ...) @llvm.experimental.guard( i1 %D )[ "deopt"() ]
75-
ret void
76-
}

0 commit comments

Comments
 (0)