File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
test/Transforms/InstCombine Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -475,6 +475,12 @@ bool llvm::wouldInstructionBeTriviallyDead(const Instruction *I,
475
475
II->getIntrinsicID () == Intrinsic::launder_invariant_group)
476
476
return true ;
477
477
478
+ // Intrinsics declare sideeffects to prevent them from moving, but they are
479
+ // nops without users.
480
+ if (II->getIntrinsicID () == Intrinsic::allow_runtime_check ||
481
+ II->getIntrinsicID () == Intrinsic::allow_ubsan_check)
482
+ return true ;
483
+
478
484
if (II->isLifetimeStartOrEnd ()) {
479
485
auto *Arg = II->getArgOperand (1 );
480
486
// Lifetime intrinsics are dead when their right-hand is undef.
Original file line number Diff line number Diff line change
1
+ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2
+ ; RUN: opt < %s -passes=instcombine -S | FileCheck %s --implicit-check-not="call i1 @llvm.allow"
3
+
4
+ define i1 @test_runtime () {
5
+ ; CHECK-LABEL: @test_runtime(
6
+ ; CHECK-NEXT: entry:
7
+ ; CHECK-NEXT: [[HOT:%.*]] = call i1 @llvm.allow.runtime.check(metadata !"test")
8
+ ; CHECK-NEXT: ret i1 [[HOT]]
9
+ ;
10
+ entry:
11
+ %allow = call i1 @llvm.allow.runtime.check (metadata !"test" )
12
+ ret i1 %allow
13
+ }
14
+
15
+ define void @test_runtime_void () {
16
+ ; CHECK-LABEL: @test_runtime_void(
17
+ ; CHECK-NEXT: entry:
18
+ ; CHECK-NEXT: ret void
19
+ ;
20
+ entry:
21
+ %allow = call i1 @llvm.allow.runtime.check (metadata !"test" )
22
+ ret void
23
+ }
24
+
25
+ define i1 @test_ubsan () {
26
+ ; CHECK-LABEL: @test_ubsan(
27
+ ; CHECK-NEXT: entry:
28
+ ; CHECK-NEXT: [[HOT:%.*]] = call i1 @llvm.allow.ubsan.check(i8 11)
29
+ ; CHECK-NEXT: ret i1 [[HOT]]
30
+ ;
31
+ entry:
32
+ %allow = call i1 @llvm.allow.ubsan.check (i8 11 )
33
+ ret i1 %allow
34
+ }
35
+
36
+ define void @test_ubsan_void () {
37
+ ; CHECK-LABEL: @test_ubsan_void(
38
+ ; CHECK-NEXT: entry:
39
+ ; CHECK-NEXT: ret void
40
+ ;
41
+ entry:
42
+ %allow = call i1 @llvm.allow.ubsan.check (i8 11 )
43
+ ret void
44
+ }
You can’t perform that action at this time.
0 commit comments