llvm.org GIT mirror llvm / ae8e83e
[PredicateInfo] Use custom mangling to support ssa_copy with unnamed types. This is a workaround and it would be better to fix this generally, but doing it generally is quite tricky. See D48541 and PR38117. Doing it in PredicateInfo directly allows us to use the type address to differentiate different unnamed types, because neither the created declarations nor the ssa_copy calls should be visible after PredicateInfo got destroyed. Reviewers: efriedma, davide Reviewed By: efriedma Differential Revision: https://reviews.llvm.org/D49126 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337828 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 1 year, 1 month ago
9 changed file(s) with 166 addition(s) and 76 deletion(s). Raw diff Collapse all Expand all
5353 #include "llvm/ADT/DenseMap.h"
5454 #include "llvm/ADT/DenseSet.h"
5555 #include "llvm/ADT/SmallPtrSet.h"
56 #include "llvm/ADT/SmallSet.h"
5657 #include "llvm/ADT/SmallVector.h"
5758 #include "llvm/ADT/ilist.h"
5859 #include "llvm/ADT/ilist_node.h"
6869 #include "llvm/IR/Use.h"
6970 #include "llvm/IR/User.h"
7071 #include "llvm/IR/Value.h"
72 #include "llvm/IR/ValueHandle.h"
7173 #include "llvm/Pass.h"
7274 #include "llvm/PassAnalysisSupport.h"
7375 #include "llvm/Support/Casting.h"
260262 // The set of edges along which we can only handle phi uses, due to critical
261263 // edges.
262264 DenseSet> EdgeUsesOnly;
265 // The set of ssa_copy declarations we created with our custom mangling.
266 SmallSet, 20> CreatedDeclarations;
263267 };
264268
265269 // This pass does eager building and then printing of PredicateInfo. It is used
1616 #include "llvm/ADT/STLExtras.h"
1717 #include "llvm/ADT/SmallPtrSet.h"
1818 #include "llvm/ADT/Statistic.h"
19 #include "llvm/ADT/StringExtras.h"
1920 #include "llvm/Analysis/AssumptionCache.h"
2021 #include "llvm/Analysis/CFG.h"
2122 #include "llvm/IR/AssemblyAnnotationWriter.h"
2324 #include "llvm/IR/Dominators.h"
2425 #include "llvm/IR/GlobalVariable.h"
2526 #include "llvm/IR/IRBuilder.h"
27 #include "llvm/IR/InstIterator.h"
2628 #include "llvm/IR/IntrinsicInst.h"
2729 #include "llvm/IR/LLVMContext.h"
2830 #include "llvm/IR/Metadata.h"
478480 renameUses(OpsToRename);
479481 }
480482
483 // Create a ssa_copy declaration with custom mangling, because
484 // Intrinsic::getDeclaration does not handle overloaded unnamed types properly:
485 // all unnamed types get mangled to the same string. We use the pointer
486 // to the type as name here, as it guarantees unique names for different
487 // types and we remove the declarations when destroying PredicateInfo.
488 // It is a workaround for PR38117, because solving it in a fully general way is
489 // tricky (FIXME).
490 static Function *getCopyDeclaration(Module *M, Type *Ty) {
491 std::string Name = "llvm.ssa.copy." + utostr((uintptr_t) Ty);
492 return cast(M->getOrInsertFunction(
493 Name, getType(M->getContext(), Intrinsic::ssa_copy, Ty)));
494 }
495
481496 // Given the renaming stack, make all the operands currently on the stack real
482497 // by inserting them into the IR. Return the last operation's value.
483498 Value *PredicateInfo::materializeStack(unsigned int &Counter,
506521 // order in the case of multiple predicateinfo in the same block.
507522 if (isa(ValInfo)) {
508523 IRBuilder<> B(getBranchTerminator(ValInfo));
509 Function *IF = Intrinsic::getDeclaration(
510 F.getParent(), Intrinsic::ssa_copy, Op->getType());
524 Function *IF = getCopyDeclaration(F.getParent(), Op->getType());
525 if (IF->user_begin() == IF->user_end())
526 CreatedDeclarations.insert(IF);
511527 CallInst *PIC =
512528 B.CreateCall(IF, Op, Op->getName() + "." + Twine(Counter++));
513529 PredicateMap.insert({PIC, ValInfo});
517533 assert(PAssume &&
518534 "Should not have gotten here without it being an assume");
519535 IRBuilder<> B(PAssume->AssumeInst);
520 Function *IF = Intrinsic::getDeclaration(
521 F.getParent(), Intrinsic::ssa_copy, Op->getType());
536 Function *IF = getCopyDeclaration(F.getParent(), Op->getType());
537 if (IF->user_begin() == IF->user_end())
538 CreatedDeclarations.insert(IF);
522539 CallInst *PIC = B.CreateCall(IF, Op);
523540 PredicateMap.insert({PIC, ValInfo});
524541 Result.Def = PIC;
703720 buildPredicateInfo();
704721 }
705722
706 PredicateInfo::~PredicateInfo() {}
723 // Remove all declarations we created . The PredicateInfo consumers are
724 // responsible for remove the ssa_copy calls created.
725 PredicateInfo::~PredicateInfo() {
726 // Collect function pointers in set first, as SmallSet uses a SmallVector
727 // internally and we have to remove the asserting value handles first.
728 SmallPtrSet FunctionPtrs;
729 for (auto &F : CreatedDeclarations)
730 FunctionPtrs.insert(&*F);
731 CreatedDeclarations.clear();
732
733 for (Function *F : FunctionPtrs) {
734 assert(F->user_begin() == F->user_end() &&
735 "PredicateInfo consumer did not remove all SSA copies.");
736 F->eraseFromParent();
737 }
738 }
707739
708740 void PredicateInfo::verifyPredicateInfo() const {}
709741
719751 AU.setPreservesAll();
720752 AU.addRequiredTransitive();
721753 AU.addRequired();
754 }
755
756 // Replace ssa_copy calls created by PredicateInfo with their operand.
757 static void replaceCreatedSSACopys(PredicateInfo &PredInfo, Function &F) {
758 for (auto I = inst_begin(F), E = inst_end(F); I != E;) {
759 Instruction *Inst = &*I++;
760 const auto *PI = PredInfo.getPredicateInfoFor(Inst);
761 auto *II = dyn_cast(Inst);
762 if (!PI || !II || II->getIntrinsicID() != Intrinsic::ssa_copy)
763 continue;
764
765 Inst->replaceAllUsesWith(II->getOperand(0));
766 Inst->eraseFromParent();
767 }
722768 }
723769
724770 bool PredicateInfoPrinterLegacyPass::runOnFunction(Function &F) {
728774 PredInfo->print(dbgs());
729775 if (VerifyPredicateInfo)
730776 PredInfo->verifyPredicateInfo();
777
778 replaceCreatedSSACopys(*PredInfo, F);
731779 return false;
732780 }
733781
736784 auto &DT = AM.getResult(F);
737785 auto &AC = AM.getResult(F);
738786 OS << "PredicateInfo for function: " << F.getName() << "\n";
739 make_unique(F, DT, AC)->print(OS);
740
787 auto PredInfo = make_unique(F, DT, AC);
788 PredInfo->print(OS);
789
790 replaceCreatedSSACopys(*PredInfo, F);
741791 return PreservedAnalyses::all();
742792 }
743793
77 ; CHECK-NEXT: br label [[BB22:%.*]]
88 ; CHECK: bb22:
99 ; CHECK-NEXT: [[TMP23:%.*]] = icmp eq i32 undef, 2
10 ; CHECK: [[TMP23_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP23]])
10 ; CHECK: [[TMP23_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP23]])
1111 ; CHECK-NEXT: br i1 [[TMP23]], label [[BB29:%.*]], label [[BB35:%.*]]
1212 ; CHECK: bb29:
13 ; CHECK: [[TMP23_0_1:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP23_0]])
13 ; CHECK: [[TMP23_0_1:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP23_0]])
1414 ; CHECK-NEXT: br i1 [[TMP23]], label [[BB33:%.*]], label [[BB35]]
1515 ; CHECK: bb33:
1616 ; CHECK-NEXT: br i1 [[TMP23_0_1]], label [[BB35]], label [[BB35]]
7575 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_END:%.*]], label [[IF_THEN:%.*]]
7676 ; CHECK: if.then:
7777 ; CHECK-NEXT: [[PUTS2:%.*]] = tail call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @str.2, i64 0, i64 0))
78 ; CHECK-NEXT: tail call void @abort() #4
78 ; CHECK-NEXT: tail call void @abort()
7979 ; CHECK-NEXT: unreachable
8080 ; CHECK: if.end:
8181 ; CHECK-NEXT: [[PUTS:%.*]] = tail call i32 @puts(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
9797 ; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
9898 ; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
9999 ; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
100 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
101 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
102 ; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[XZ]])
103 ; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[YZ]])
104 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[Z]])
100 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
101 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
102 ; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
103 ; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
104 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
105105 ; CHECK-NEXT: br i1 [[Z]], label [[BOTH_ZERO:%.*]], label [[NOPE:%.*]]
106106 ; CHECK: both_zero:
107107 ; CHECK-NEXT: call void @foo(i1 [[XZ_0]])
138138 ; CHECK-NEXT: i32 3, label [[CASE3]]
139139 ; CHECK-NEXT: i32 4, label [[DEFAULT:%.*]]
140140 ; CHECK-NEXT: ] Edge: [label [[SW]],label %case1] }
141 ; CHECK-NEXT: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X:%.*]])
141 ; CHECK-NEXT: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X:%.*]])
142142 ; CHECK-NEXT: switch i32 [[X]], label [[DEFAULT]] [
143143 ; CHECK-NEXT: i32 0, label [[CASE0]]
144144 ; CHECK-NEXT: i32 1, label [[CASE1]]
185185 define i1 @test5(i32 %x, i32 %y) {
186186 ; CHECK-LABEL: @test5(
187187 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], [[Y:%.*]]
188 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
189 ; CHECK: [[X_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
190 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
191 ; CHECK: [[Y_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
188 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
189 ; CHECK: [[X_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
190 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
191 ; CHECK: [[Y_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
192192 ; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
193193 ; CHECK: same:
194194 ; CHECK-NEXT: [[CMP2:%.*]] = icmp ne i32 [[X_0]], [[Y_0]]
258258 define i1 @test7(i32 %x, i32 %y) {
259259 ; CHECK-LABEL: @test7(
260260 ; CHECK-NEXT: [[CMP:%.*]] = icmp sgt i32 [[X:%.*]], [[Y:%.*]]
261 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
262 ; CHECK: [[X_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
263 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
264 ; CHECK: [[Y_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
261 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
262 ; CHECK: [[X_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
263 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
264 ; CHECK: [[Y_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
265265 ; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
266266 ; CHECK: same:
267267 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sle i32 [[X_0]], [[Y_0]]
285285 define i1 @test7_fp(float %x, float %y) {
286286 ; CHECK-LABEL: @test7_fp(
287287 ; CHECK-NEXT: [[CMP:%.*]] = fcmp ogt float [[X:%.*]], [[Y:%.*]]
288 ; CHECK: [[X_0:%.*]] = call float @llvm.ssa.copy.f32(float [[X]])
289 ; CHECK: [[X_1:%.*]] = call float @llvm.ssa.copy.f32(float [[X]])
290 ; CHECK: [[Y_0:%.*]] = call float @llvm.ssa.copy.f32(float [[Y]])
291 ; CHECK: [[Y_1:%.*]] = call float @llvm.ssa.copy.f32(float [[Y]])
288 ; CHECK: [[X_0:%.*]] = call float @llvm.ssa.copy.{{.+}}(float [[X]])
289 ; CHECK: [[X_1:%.*]] = call float @llvm.ssa.copy.{{.+}}(float [[X]])
290 ; CHECK: [[Y_0:%.*]] = call float @llvm.ssa.copy.{{.+}}(float [[Y]])
291 ; CHECK: [[Y_1:%.*]] = call float @llvm.ssa.copy.{{.+}}(float [[Y]])
292292 ; CHECK-NEXT: br i1 [[CMP]], label [[SAME:%.*]], label [[DIFFERENT:%.*]]
293293 ; CHECK: same:
294294 ; CHECK-NEXT: [[CMP2:%.*]] = fcmp ule float [[X_0]], [[Y_0]]
358358 define i32 @test9(i32 %i, i32 %j) {
359359 ; CHECK-LABEL: @test9(
360360 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], [[J:%.*]]
361 ; CHECK: [[I_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[I]])
362 ; CHECK: [[J_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[J]])
361 ; CHECK: [[I_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[I]])
362 ; CHECK: [[J_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[J]])
363363 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[RET:%.*]]
364364 ; CHECK: cond_true:
365365 ; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[I_0]], [[J_0]]
381381 define i32 @test10(i32 %j, i32 %i) {
382382 ; CHECK-LABEL: @test10(
383383 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[I:%.*]], [[J:%.*]]
384 ; CHECK: [[J_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[J]])
385 ; CHECK: [[I_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[I]])
384 ; CHECK: [[J_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[J]])
385 ; CHECK: [[I_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[I]])
386386 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[RET:%.*]]
387387 ; CHECK: cond_true:
388388 ; CHECK-NEXT: [[DIFF:%.*]] = sub i32 [[I_0]], [[J_0]]
408408 ; CHECK-NEXT: [[V0:%.*]] = call i32 @yogibar()
409409 ; CHECK-NEXT: [[V1:%.*]] = call i32 @yogibar()
410410 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[V0]], [[V1]]
411 ; CHECK: [[V0_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[V0]])
412 ; CHECK: [[V1_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[V1]])
411 ; CHECK: [[V0_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[V0]])
412 ; CHECK: [[V1_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[V1]])
413413 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[NEXT:%.*]]
414414 ; CHECK: cond_true:
415415 ; CHECK-NEXT: ret i32 [[V1_0]]
416416 ; CHECK: next:
417417 ; CHECK-NEXT: [[CMP2:%.*]] = icmp eq i32 [[X:%.*]], [[V0_0]]
418 ; CHECK: [[V0_0_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[V0_0]])
418 ; CHECK: [[V0_0_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[V0_0]])
419419 ; CHECK-NEXT: br i1 [[CMP2]], label [[COND_TRUE2:%.*]], label [[NEXT2:%.*]]
420420 ; CHECK: cond_true2:
421421 ; CHECK-NEXT: ret i32 [[V0_0_1]]
444444 define i32 @test12(i32 %x) {
445445 ; CHECK-LABEL: @test12(
446446 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0
447 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
448 ; CHECK: [[X_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
447 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
448 ; CHECK: [[X_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
449449 ; CHECK-NEXT: br i1 [[CMP]], label [[COND_TRUE:%.*]], label [[COND_FALSE:%.*]]
450450 ; CHECK: cond_true:
451451 ; CHECK-NEXT: br label [[RET:%.*]]
44 ; CHECK-NEXT: br i1 [[Y:%.*]], label [[BB0:%.*]], label [[BB1:%.*]]
55 ; CHECK: bb0:
66 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
7 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
7 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
88 ; CHECK-NEXT: br i1 [[CMP]], label [[BB2:%.*]], label [[BB3:%.*]]
99 ; CHECK: bb1:
1010 ; CHECK-NEXT: [[X2:%.*]] = add nuw nsw i32 [[X]], 1
1111 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i32 [[X2]], 2
12 ; CHECK: [[X2_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X2]])
12 ; CHECK: [[X2_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X2]])
1313 ; CHECK-NEXT: br i1 [[CMP2]], label [[BB2]], label [[BB3]]
1414 ; CHECK: bb2:
1515 ; CHECK-NEXT: [[X3:%.*]] = phi i32 [ [[X_0]], [[BB0]] ], [ [[X2_0]], [[BB1]] ]
3737 ; CHECK-NEXT: br i1 [[Y:%.*]], label [[BB0:%.*]], label [[BB1:%.*]]
3838 ; CHECK: bb0:
3939 ; CHECK-NEXT: [[CMP:%.*]] = icmp sge i32 [[X:%.*]], 0
40 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
40 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
4141 ; CHECK-NEXT: br i1 [[CMP]], label [[BB3:%.*]], label [[BB2:%.*]]
4242 ; CHECK: bb1:
4343 ; CHECK-NEXT: [[X2:%.*]] = add nuw nsw i32 [[X]], 1
4444 ; CHECK-NEXT: [[CMP2:%.*]] = icmp sge i32 [[X2]], 2
45 ; CHECK: [[X2_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X2]])
45 ; CHECK: [[X2_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X2]])
4646 ; CHECK-NEXT: br i1 [[CMP2]], label [[BB3]], label [[BB2]]
4747 ; CHECK: bb2:
4848 ; CHECK-NEXT: [[X3:%.*]] = phi i32 [ [[X_0]], [[BB0]] ], [ [[X2_0]], [[BB1]] ]
44 ; CHECK-LABEL: @f1(
55 ; CHECK-NEXT: bb0:
66 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0
7 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
7 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
88 ; CHECK-NEXT: br i1 [[CMP]], label [[BB2:%.*]], label [[BB1:%.*]]
99 ; CHECK: bb1:
1010 ; CHECK-NEXT: br label [[BB2]]
2828 ; CHECK-LABEL: @f2(
2929 ; CHECK-NEXT: bb0:
3030 ; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[X:%.*]], 0
31 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
31 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
3232 ; CHECK-NEXT: br i1 [[CMP]], label [[BB1:%.*]], label [[BB2:%.*]]
3333 ; CHECK: bb1:
3434 ; CHECK-NEXT: br label [[BB2]]
5151 define i32 @f3(i32 %x) {
5252 ; CHECK-LABEL: @f3(
5353 ; CHECK-NEXT: bb0:
54 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X:%.*]])
54 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X:%.*]])
5555 ; CHECK-NEXT: switch i32 [[X]], label [[BB1:%.*]] [
5656 ; CHECK-NEXT: i32 0, label [[BB2:%.*]]
5757 ; CHECK-NEXT: ]
7777 ; CHECK-LABEL: @fcmp_oeq_not_zero(
7878 ; CHECK-NEXT: entry:
7979 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[Y:%.*]], 2.000000e+00
80 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.f64(double [[Y]])
80 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
8181 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[RETURN:%.*]]
8282 ; CHECK: if:
8383 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
104104 ; CHECK-LABEL: @fcmp_une_not_zero(
105105 ; CHECK-NEXT: entry:
106106 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[Y:%.*]], 2.000000e+00
107 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.f64(double [[Y]])
107 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
108108 ; CHECK-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[ELSE:%.*]]
109109 ; CHECK: else:
110110 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
131131 ; CHECK-LABEL: @fcmp_oeq_zero(
132132 ; CHECK-NEXT: entry:
133133 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[Y:%.*]], 0.000000e+00
134 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.f64(double [[Y]])
134 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
135135 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[RETURN:%.*]]
136136 ; CHECK: if:
137137 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
158158 ; CHECK-LABEL: @fcmp_une_zero(
159159 ; CHECK-NEXT: entry:
160160 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[Y:%.*]], -0.000000e+00
161 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.f64(double [[Y]])
161 ; CHECK: [[Y_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Y]])
162162 ; CHECK-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[ELSE:%.*]]
163163 ; CHECK: else:
164164 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Y_0]]
187187 ; CHECK-NEXT: entry:
188188 ; CHECK-NEXT: [[Z:%.*]] = fadd double [[Z1:%.*]], [[Z2:%.*]]
189189 ; CHECK-NEXT: [[CMP:%.*]] = fcmp oeq double [[Y:%.*]], [[Z]]
190 ; CHECK: [[Z_0:%.*]] = call double @llvm.ssa.copy.f64(double [[Z]])
190 ; CHECK: [[Z_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Z]])
191191 ; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[RETURN:%.*]]
192192 ; CHECK: if:
193193 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Z_0]]
216216 ; CHECK-NEXT: entry:
217217 ; CHECK-NEXT: [[Z:%.*]] = fadd double [[Z1:%.*]], [[Z2:%.*]]
218218 ; CHECK-NEXT: [[CMP:%.*]] = fcmp une double [[Y:%.*]], [[Z]]
219 ; CHECK: [[Z_0:%.*]] = call double @llvm.ssa.copy.f64(double [[Z]])
219 ; CHECK: [[Z_0:%.*]] = call double @llvm.ssa.copy.{{.+}}(double [[Z]])
220220 ; CHECK-NEXT: br i1 [[CMP]], label [[RETURN:%.*]], label [[ELSE:%.*]]
221221 ; CHECK: else:
222222 ; CHECK-NEXT: [[DIV:%.*]] = fdiv double [[X:%.*]], [[Z_0]]
99 ; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
1010 ; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
1111 ; CHECK-NEXT: [[Z:%.*]] = or i1 [[XZ]], [[YZ]]
12 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
13 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
14 ; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[XZ]])
15 ; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[YZ]])
16 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[Z]])
12 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
13 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
14 ; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
15 ; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
16 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
1717 ; CHECK-NEXT: br i1 [[Z]], label [[ONEOF:%.*]], label [[NEITHER:%.*]]
1818 ; CHECK: oneof:
1919 ; CHECK-NEXT: call void @foo(i1 [[XZ]])
5353 ; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
5454 ; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
5555 ; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
56 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
57 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
58 ; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[XZ]])
59 ; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[YZ]])
60 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[Z]])
56 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
57 ; CHECK: [[Y_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
58 ; CHECK: [[XZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
59 ; CHECK: [[YZ_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
60 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
6161 ; CHECK-NEXT: br i1 [[Z]], label [[BOTH:%.*]], label [[NOPE:%.*]]
6262 ; CHECK: both:
6363 ; CHECK-NEXT: call void @foo(i1 [[XZ_0]])
9797 ; CHECK-NEXT: [[XGT:%.*]] = icmp sgt i32 [[X:%.*]], 0
9898 ; CHECK-NEXT: [[XLT:%.*]] = icmp slt i32 [[X]], 100
9999 ; CHECK-NEXT: [[Z:%.*]] = and i1 [[XGT]], [[XLT]]
100 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
101 ; CHECK: [[X_0_1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X_0]])
102 ; CHECK: [[XGT_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[XGT]])
103 ; CHECK: [[XLT_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[XLT]])
104 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[Z]])
100 ; CHECK: [[X_0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
101 ; CHECK: [[X_0_1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X_0]])
102 ; CHECK: [[XGT_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XGT]])
103 ; CHECK: [[XLT_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XLT]])
104 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
105105 ; CHECK-NEXT: br i1 [[Z]], label [[BOTH:%.*]], label [[NOPE:%.*]]
106106 ; CHECK: both:
107107 ; CHECK-NEXT: call void @foo(i1 [[XGT_0]])
135135 ; CHECK-NEXT: [[XZ:%.*]] = icmp eq i32 [[X:%.*]], 0
136136 ; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
137137 ; CHECK-NEXT: [[Z:%.*]] = and i1 [[XZ]], [[YZ]]
138 ; CHECK: [[TMP1:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[X]])
139 ; CHECK: [[TMP2:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[Y]])
140 ; CHECK: [[TMP3:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[XZ]])
141 ; CHECK: [[TMP4:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[YZ]])
142 ; CHECK: [[TMP5:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[Z]])
138 ; CHECK: [[TMP1:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[X]])
139 ; CHECK: [[TMP2:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[Y]])
140 ; CHECK: [[TMP3:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[XZ]])
141 ; CHECK: [[TMP4:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[YZ]])
142 ; CHECK: [[TMP5:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
143143 ; CHECK-NEXT: call void @llvm.assume(i1 [[TMP5]])
144 ; CHECK: [[DOT0:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[TMP1]])
145 ; CHECK: [[DOT01:%.*]] = call i32 @llvm.ssa.copy.i32(i32 [[TMP2]])
146 ; CHECK: [[DOT02:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP3]])
147 ; CHECK: [[DOT03:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP4]])
148 ; CHECK: [[DOT04:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[TMP5]])
144 ; CHECK: [[DOT0:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[TMP1]])
145 ; CHECK: [[DOT01:%.*]] = call i32 @llvm.ssa.copy.{{.+}}(i32 [[TMP2]])
146 ; CHECK: [[DOT02:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP3]])
147 ; CHECK: [[DOT03:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP4]])
148 ; CHECK: [[DOT04:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[TMP5]])
149149 ; CHECK-NEXT: br i1 [[TMP5]], label [[BOTH:%.*]], label [[NOPE:%.*]]
150150 ; CHECK: both:
151151 ; CHECK-NEXT: call void @foo(i1 [[DOT02]])
181181 ; CHECK-NEXT: [[YZ:%.*]] = icmp eq i32 [[Y:%.*]], 0
182182 ; CHECK-NEXT: [[Z:%.*]] = or i1 [[XZ]], [[YZ]]
183183 ; CHECK-NEXT: call void @llvm.assume(i1 [[Z]])
184 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.i1(i1 [[Z]])
184 ; CHECK: [[Z_0:%.*]] = call i1 @llvm.ssa.copy.{{.+}}(i1 [[Z]])
185185 ; CHECK-NEXT: br i1 [[Z]], label [[BOTH:%.*]], label [[NOPE:%.*]]
186186 ; CHECK: both:
187187 ; CHECK-NEXT: call void @foo(i1 [[XZ]])
0 ; RUN: opt < %s -print-predicateinfo 2>&1 | FileCheck %s
1
2 %1 = type opaque
3 %0 = type opaque
4
5 ; Check we can use ssa.copy with unnamed types.
6
7 ; CHECK-LABEL: bb:
8 ; CHECK: Has predicate info
9 ; CHECK: branch predicate info { TrueEdge: 1 Comparison: %cmp1 = icmp ne %0* %arg, null Edge: [label %bb,label %bb1] }
10 ; CHECK-NEXT: %arg.0 = call %0* @llvm.ssa.copy.{{.+}}(%0* %arg)
11
12 ; CHECK-LABEL: bb1:
13 ; CHECK: Has predicate info
14 ; CHECK-NEXT: branch predicate info { TrueEdge: 0 Comparison: %cmp2 = icmp ne %1* null, %tmp Edge: [label %bb1,label %bb3] }
15 ; CHECK-NEXT: %tmp.0 = call %1* @llvm.ssa.copy.{{.+}}(%1* %tmp)
16
17 define void @f0(%0* %arg, %1* %tmp) {
18 bb:
19 %cmp1 = icmp ne %0* %arg, null
20 br i1 %cmp1, label %bb1, label %bb2
21
22 bb1: ; preds = %bb
23 %cmp2 = icmp ne %1* null, %tmp
24 br i1 %cmp2, label %bb2, label %bb3
25
26 bb2: ; preds = %bb
27 ret void
28
29 bb3: ; preds = %bb
30 %u1 = call i8* @fun(%1* %tmp)
31 %tmp2 = bitcast %0* %arg to i8*
32 ret void
33 }
34
35 declare i8* @fun(%1*)