llvm.org GIT mirror llvm / 83e4df0
Invalidate assumption cache before outlining. Subscribers: llvm-commits Tags: #llvm Reviewers: compnerd, vsk, sebpop, fhahn, tejohnson Reviewed by: vsk Differential Revision: https://reviews.llvm.org/D68478 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373807 91177308-0d34-0410-b5e6-96231b3b80d8 Aditya Kumar 1 year, 1 month ago
4 changed file(s) with 38 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
105105 /// returns false.
106106 Function *extractCodeRegion();
107107
108 /// Verify that assumption cache isn't stale after a region is extracted.
109 /// Returns false when verifier finds errors. AssumptionCache is passed as
110 /// parameter to make this function stateless.
111 static bool verifyAssumptionCache(const Function& F, AssumptionCache *AC);
112
108113 /// Test whether this code extractor is eligible.
109114 ///
110115 /// Based on the blocks used when constructing the code extractor,
627627 } while (!Region.empty());
628628 }
629629
630 // We need to explicitly clear the assumption cache since the value tracking
631 // may now be invalid as part of the function has changed.
632 if (Changed)
633 if (AssumptionCache *AC = LookupAC(F))
634 AC->clear();
635630 return Changed;
636631 }
637632
13001300
13011301 // Insert this basic block into the new function
13021302 newBlocks.push_back(Block);
1303
1304 // Remove @llvm.assume calls that were moved to the new function from the
1305 // old function's assumption cache.
1306 if (AC)
1307 for (auto &I : *Block)
1308 if (match(&I, m_Intrinsic()))
1309 AC->unregisterAssumption(cast(&I));
13101303 }
13111304 }
13121305
13751368 EntryFreq +=
13761369 BFI->getBlockFreq(Pred) * BPI->getEdgeProbability(Pred, header);
13771370 }
1371 }
1372
1373 if (AC) {
1374 // Remove @llvm.assume calls that were moved to the new function from the
1375 // old function's assumption cache.
1376 for (BasicBlock *Block : Blocks)
1377 for (auto &I : *Block)
1378 if (match(&I, m_Intrinsic()))
1379 AC->unregisterAssumption(cast(&I));
13781380 }
13791381
13801382 // If we have any return instructions in the region, split those blocks so
15671569 });
15681570 LLVM_DEBUG(if (verifyFunction(*oldFunction))
15691571 report_fatal_error("verification of oldFunction failed!"));
1572 LLVM_DEBUG(if (AC && verifyAssumptionCache(*oldFunction, AC))
1573 report_fatal_error("Stale Asumption cache for old Function!"));
15701574 return newFunction;
15711575 }
1576
1577 bool CodeExtractor::verifyAssumptionCache(const Function& F,
1578 AssumptionCache *AC) {
1579 for (auto AssumeVH : AC->assumptions()) {
1580 CallInst *I = cast(AssumeVH);
1581 if (I->getFunction() != &F)
1582 return true;
1583 }
1584 return false;
1585 }
0 ; REQUIRES: asserts
1 ; RUN: opt -S -instsimplify -hotcoldsplit -debug < %s 2>&1 | FileCheck %s
2 ; RUN: opt -instcombine -hotcoldsplit -instsimplify %s -o /dev/null
13
24 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
46
57 %a = type { i64, i64 }
68 %b = type { i64 }
9
10 ; CHECK: @f
11 ; CHECK-LABEL: codeRepl:
12 ; CHECK-NOT: @llvm.assume
13 ; CHECK: }
14 ; CHECK: declare {{.*}}@llvm.assume
15 ; CHECK: define {{.*}}@f.cold.1(i64 %0)
16 ; CHECK-LABEL: newFuncRoot:
17 ; CHECK: %1 = icmp eq i64 %0, 0
18 ; CHECK: call void @llvm.assume(i1 %1)
719
820 define void @f() {
921 entry: