1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
/*========================== begin_copyright_notice ============================
Copyright (C) 2022 Intel Corporation
SPDX-License-Identifier: MIT
============================= end_copyright_notice ===========================*/
#include "Compiler/RemoveCodeAssumptions.hpp"
#include "Compiler/IGCPassSupport.h"
using namespace llvm;
using namespace IGC;
// Register pass to igc-opt
#define PASS_FLAG "igc-remove-code-assumptions"
#define PASS_DESCRIPTION "Remove code assumptions from the module"
#define PASS_CFG_ONLY false
#define PASS_ANALYSIS false
IGC_INITIALIZE_PASS_BEGIN(RemoveCodeAssumptions, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG_ONLY, PASS_ANALYSIS)
IGC_INITIALIZE_PASS_END(RemoveCodeAssumptions, PASS_FLAG, PASS_DESCRIPTION, PASS_CFG_ONLY, PASS_ANALYSIS)
char RemoveCodeAssumptions::ID = 0;
RemoveCodeAssumptions::RemoveCodeAssumptions()
: FunctionPass(ID)
{
initializeRemoveCodeAssumptionsPass(*PassRegistry::getPassRegistry());
}
bool RemoveCodeAssumptions::runOnFunction(Function& F)
{
visit(F);
bool changed = m_instructionsToRemove.size() > 0;
for (auto I : m_instructionsToRemove)
{
I->eraseFromParent();
}
m_instructionsToRemove.clear();
return changed;
}
void RemoveCodeAssumptions::visitIntrinsicInst(llvm::IntrinsicInst& I)
{
auto intrinsicID = I.getIntrinsicID();
switch (intrinsicID)
{
case Intrinsic::assume:
m_instructionsToRemove.push_back(&I);
break;
default:
break;
}
}
|