#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Type.h"
+#include "llvm/Support/Compiler.h"
using namespace llvm;
namespace {
/// LowerSelect - Turn select instructions into conditional branches.
///
- class LowerSelect : public FunctionPass {
+ class VISIBILITY_HIDDEN LowerSelect : public FunctionPass {
bool OnlyFP; // Only lower FP select instructions?
public:
- LowerSelect(bool onlyfp = false) : OnlyFP(onlyfp) {}
+ static char ID; // Pass identification, replacement for typeid
+ explicit LowerSelect(bool onlyfp = false) : FunctionPass((intptr_t)&ID),
+ OnlyFP(onlyfp) {}
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
// This certainly destroys the CFG.
- // This is a cluster of orthogonal Transforms:
+ // This is a cluster of orthogonal Transforms:
AU.addPreserved<UnifyFunctionExitNodes>();
AU.addPreservedID(PromoteMemoryToRegisterID);
AU.addPreservedID(LowerSwitchID);
bool runOnFunction(Function &F);
};
+ char LowerSelect::ID = 0;
RegisterPass<LowerSelect>
X("lowerselect", "Lower select instructions to branches");
}
new BranchInst(NewTrue, NewCont, SI->getCondition(), BB);
// Create a new PHI node in the cont block with the entries we need.
- std::string Name = SI->getName(); SI->setName("");
- PHINode *PN = new PHINode(SI->getType(), Name, NewCont->begin());
+ PHINode *PN = new PHINode(SI->getType(), "", NewCont->begin());
+ PN->takeName(SI);
PN->addIncoming(SI->getTrueValue(), NewTrue);
PN->addIncoming(SI->getFalseValue(), BB);