]> granicus.if.org Git - llvm/commitdiff
Revert a couple of InstCombine/Guard checkins
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 26 Jan 2017 23:38:11 +0000 (23:38 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 26 Jan 2017 23:38:11 +0000 (23:38 +0000)
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

lib/Transforms/InstCombine/InstCombineCalls.cpp
test/Transforms/InstCombine/call-guard.ll

index b92ea76d13676ad33cc59d8bf22c64a70f95bcba..18161de418aea6c31b2c931f923eb648953cf4dd 100644 (file)
@@ -3010,35 +3010,6 @@ Instruction *InstCombiner::visitCallInst(CallInst &CI) {
     if (match(II->getNextNode(),
               m_Intrinsic<Intrinsic::experimental_guard>(m_Specific(IIOperand))))
       return eraseInstFromFunction(*II);
-
-    // Canonicalize guard(a && b) -> guard(a); guard(b);
-    // Note: New guard intrinsics created here are registered by
-    // the InstCombineIRInserter object.
-    Function *GuardIntrinsic = II->getCalledFunction();
-    Value *A, *B;
-    OperandBundleDef DeoptOB(*II->getOperandBundle(LLVMContext::OB_deopt));
-    if (match(IIOperand, m_And(m_Value(A), m_Value(B)))) {
-      CallInst *GuardA =
-          Builder->CreateCall(GuardIntrinsic, A, {DeoptOB}, II->getName());
-      CallInst *GuardB =
-          Builder->CreateCall(GuardIntrinsic, B, {DeoptOB}, II->getName());
-      auto CC = II->getCallingConv();
-      GuardA->setCallingConv(CC);
-      GuardB->setCallingConv(CC);
-      return eraseInstFromFunction(*II);
-    }
-
-    // guard(!(a || b)) -> guard(!a); guard(!b);
-    if (match(IIOperand, m_Not(m_Or(m_Value(A), m_Value(B))))) {
-      CallInst *GuardA = Builder->CreateCall(
-          GuardIntrinsic, Builder->CreateNot(A), {DeoptOB}, II->getName());
-      CallInst *GuardB = Builder->CreateCall(
-          GuardIntrinsic, Builder->CreateNot(B), {DeoptOB}, II->getName());
-      auto CC = II->getCallingConv();
-      GuardA->setCallingConv(CC);
-      GuardB->setCallingConv(CC);
-      return eraseInstFromFunction(*II);
-    }
     break;
   }
   }
index 1b59878f25c832fdf8747b3439cd188e849cbf5c..18da465e606c593f9cd5b14b80a8a0a1f8fb8f90 100644 (file)
@@ -28,49 +28,3 @@ define void @test_guard_adjacent_neg(i1 %A, i1 %B) {
   call void(i1, ...) @llvm.experimental.guard( i1 %B )[ "deopt"() ]
   ret void
 }
-
-define void @test_guard_and(i1 %A, i1 %B) {
-; CHECK-LABEL: @test_guard_and(
-; CHECK-NEXT:    call void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ]
-; CHECK-NEXT:    call void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ]
-; CHECK-NEXT:    ret void
-  %C = and i1 %A, %B
-  call void(i1, ...) @llvm.experimental.guard( i1 %C )[ "deopt"() ]
-  ret void
-}
-
-define void @test_guard_and_non_default_cc(i1 %A, i1 %B) {
-; CHECK-LABEL: @test_guard_and_non_default_cc(
-; CHECK-NEXT:    call cc99 void (i1, ...) @llvm.experimental.guard(i1 %A) [ "deopt"() ]
-; CHECK-NEXT:    call cc99 void (i1, ...) @llvm.experimental.guard(i1 %B) [ "deopt"() ]
-; CHECK-NEXT:    ret void
-  %C = and i1 %A, %B
-  call cc99 void(i1, ...) @llvm.experimental.guard( i1 %C )[ "deopt"() ]
-  ret void
-}
-
-define void @test_guard_not_or(i1 %A, i1 %B) {
-; CHECK-LABEL: @test_guard_not_or(
-; CHECK-NEXT:    %1 = xor i1 %A, true
-; CHECK-NEXT:    call void (i1, ...) @llvm.experimental.guard(i1 %1) [ "deopt"() ]
-; CHECK-NEXT:    %2 = xor i1 %B, true
-; CHECK-NEXT:    call void (i1, ...) @llvm.experimental.guard(i1 %2) [ "deopt"() ]
-; CHECK-NEXT:    ret void
-  %C = or i1 %A, %B
-  %D = xor i1 %C, true
-  call void(i1, ...) @llvm.experimental.guard( i1 %D )[ "deopt"() ]
-  ret void
-}
-
-define void @test_guard_not_or_non_default_cc(i1 %A, i1 %B) {
-; CHECK-LABEL: @test_guard_not_or_non_default_cc(
-; CHECK-NEXT:    %1 = xor i1 %A, true
-; CHECK-NEXT:    call cc99 void (i1, ...) @llvm.experimental.guard(i1 %1) [ "deopt"() ]
-; CHECK-NEXT:    %2 = xor i1 %B, true
-; CHECK-NEXT:    call cc99 void (i1, ...) @llvm.experimental.guard(i1 %2) [ "deopt"() ]
-; CHECK-NEXT:    ret void
-  %C = or i1 %A, %B
-  %D = xor i1 %C, true
-  call cc99 void(i1, ...) @llvm.experimental.guard( i1 %D )[ "deopt"() ]
-  ret void
-}