mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
Revert "[IRBuilder] Virtualize IRBuilder"
This reverts commit 0765d3824d069f37596bc5a890399099b776c2a0. This reverts commit 1b04866a3db9f816a559860f941da067fe1eccf1. Relevant looking crashes observed on: http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win
This commit is contained in:
parent
ace163be2a
commit
163465c064
@ -22,14 +22,13 @@
|
||||
#include "llvm/Analysis/ConstantFolding.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/InstrTypes.h"
|
||||
#include "llvm/IR/IRBuilderFolder.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class DataLayout;
|
||||
|
||||
/// TargetFolder - Create constants with target dependent folding.
|
||||
class TargetFolder final : public IRBuilderFolder {
|
||||
class TargetFolder {
|
||||
const DataLayout &DL;
|
||||
|
||||
/// Fold - Fold the constant using target specific information.
|
||||
@ -39,8 +38,6 @@ class TargetFolder final : public IRBuilderFolder {
|
||||
return C;
|
||||
}
|
||||
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
explicit TargetFolder(const DataLayout &DL) : DL(DL) {}
|
||||
|
||||
@ -49,70 +46,66 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateAdd(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return Fold(ConstantExpr::getAdd(LHS, RHS, HasNUW, HasNSW));
|
||||
}
|
||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getFAdd(LHS, RHS));
|
||||
}
|
||||
Constant *CreateSub(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return Fold(ConstantExpr::getSub(LHS, RHS, HasNUW, HasNSW));
|
||||
}
|
||||
Constant *CreateFSub(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getFSub(LHS, RHS));
|
||||
}
|
||||
Constant *CreateMul(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return Fold(ConstantExpr::getMul(LHS, RHS, HasNUW, HasNSW));
|
||||
}
|
||||
Constant *CreateFMul(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getFMul(LHS, RHS));
|
||||
}
|
||||
Constant *CreateUDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
Constant *CreateUDiv(Constant *LHS, Constant *RHS, bool isExact = false)const{
|
||||
return Fold(ConstantExpr::getUDiv(LHS, RHS, isExact));
|
||||
}
|
||||
Constant *CreateSDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
Constant *CreateSDiv(Constant *LHS, Constant *RHS, bool isExact = false)const{
|
||||
return Fold(ConstantExpr::getSDiv(LHS, RHS, isExact));
|
||||
}
|
||||
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getFDiv(LHS, RHS));
|
||||
}
|
||||
Constant *CreateURem(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateURem(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getURem(LHS, RHS));
|
||||
}
|
||||
Constant *CreateSRem(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getSRem(LHS, RHS));
|
||||
}
|
||||
Constant *CreateFRem(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getFRem(LHS, RHS));
|
||||
}
|
||||
Constant *CreateShl(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return Fold(ConstantExpr::getShl(LHS, RHS, HasNUW, HasNSW));
|
||||
}
|
||||
Constant *CreateLShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
Constant *CreateLShr(Constant *LHS, Constant *RHS, bool isExact = false)const{
|
||||
return Fold(ConstantExpr::getLShr(LHS, RHS, isExact));
|
||||
}
|
||||
Constant *CreateAShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
Constant *CreateAShr(Constant *LHS, Constant *RHS, bool isExact = false)const{
|
||||
return Fold(ConstantExpr::getAShr(LHS, RHS, isExact));
|
||||
}
|
||||
Constant *CreateAnd(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getAnd(LHS, RHS));
|
||||
}
|
||||
Constant *CreateOr(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateOr(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getOr(LHS, RHS));
|
||||
}
|
||||
Constant *CreateXor(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateXor(Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getXor(LHS, RHS));
|
||||
}
|
||||
|
||||
Constant *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Constant *LHS, Constant *RHS) const override {
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return Fold(ConstantExpr::get(Opc, LHS, RHS));
|
||||
}
|
||||
|
||||
@ -121,17 +114,17 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateNeg(Constant *C,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return Fold(ConstantExpr::getNeg(C, HasNUW, HasNSW));
|
||||
}
|
||||
Constant *CreateFNeg(Constant *C) const override {
|
||||
Constant *CreateFNeg(Constant *C) const {
|
||||
return Fold(ConstantExpr::getFNeg(C));
|
||||
}
|
||||
Constant *CreateNot(Constant *C) const override {
|
||||
Constant *CreateNot(Constant *C) const {
|
||||
return Fold(ConstantExpr::getNot(C));
|
||||
}
|
||||
|
||||
Constant *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const override {
|
||||
Constant *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const {
|
||||
return Fold(ConstantExpr::get(Opc, C));
|
||||
}
|
||||
|
||||
@ -140,34 +133,33 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const override {
|
||||
ArrayRef<Constant *> IdxList) const {
|
||||
return Fold(ConstantExpr::getGetElementPtr(Ty, C, IdxList));
|
||||
}
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const override {
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C, Constant *Idx) const {
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
return Fold(ConstantExpr::getGetElementPtr(Ty, C, Idx));
|
||||
}
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const override {
|
||||
ArrayRef<Value *> IdxList) const {
|
||||
return Fold(ConstantExpr::getGetElementPtr(Ty, C, IdxList));
|
||||
}
|
||||
|
||||
Constant *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Constant *> IdxList) const override {
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const {
|
||||
return Fold(ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList));
|
||||
}
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const override {
|
||||
Constant *Idx) const {
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
return Fold(ConstantExpr::getInBoundsGetElementPtr(Ty, C, Idx));
|
||||
}
|
||||
Constant *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Value *> IdxList) const override {
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const {
|
||||
return Fold(ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList));
|
||||
}
|
||||
|
||||
@ -176,54 +168,54 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateCast(Instruction::CastOps Op, Constant *C,
|
||||
Type *DestTy) const override {
|
||||
Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getCast(Op, C, DestTy));
|
||||
}
|
||||
Constant *CreateIntCast(Constant *C, Type *DestTy,
|
||||
bool isSigned) const override {
|
||||
bool isSigned) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned));
|
||||
}
|
||||
Constant *CreatePointerCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreatePointerCast(Constant *C, Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getPointerCast(C, DestTy));
|
||||
}
|
||||
Constant *CreateFPCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateFPCast(Constant *C, Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getFPCast(C, DestTy));
|
||||
}
|
||||
Constant *CreateBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateBitCast(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::BitCast, C, DestTy);
|
||||
}
|
||||
Constant *CreateIntToPtr(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateIntToPtr(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::IntToPtr, C, DestTy);
|
||||
}
|
||||
Constant *CreatePtrToInt(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreatePtrToInt(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::PtrToInt, C, DestTy);
|
||||
}
|
||||
Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getZExtOrBitCast(C, DestTy));
|
||||
}
|
||||
Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getSExtOrBitCast(C, DestTy));
|
||||
}
|
||||
Constant *CreateTruncOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateTruncOrBitCast(Constant *C, Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getTruncOrBitCast(C, DestTy));
|
||||
}
|
||||
|
||||
Constant *CreatePointerBitCastOrAddrSpaceCast(Constant *C,
|
||||
Type *DestTy) const override {
|
||||
Type *DestTy) const {
|
||||
if (C->getType() == DestTy)
|
||||
return C; // avoid calling Fold
|
||||
return Fold(ConstantExpr::getPointerBitCastOrAddrSpaceCast(C, DestTy));
|
||||
@ -234,11 +226,11 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const override {
|
||||
Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getCompare(P, LHS, RHS));
|
||||
}
|
||||
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const override {
|
||||
Constant *RHS) const {
|
||||
return Fold(ConstantExpr::getCompare(P, LHS, RHS));
|
||||
}
|
||||
|
||||
@ -246,32 +238,31 @@ public:
|
||||
// Other Instructions
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateSelect(Constant *C, Constant *True,
|
||||
Constant *False) const override {
|
||||
Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
|
||||
return Fold(ConstantExpr::getSelect(C, True, False));
|
||||
}
|
||||
|
||||
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const override {
|
||||
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
|
||||
return Fold(ConstantExpr::getExtractElement(Vec, Idx));
|
||||
}
|
||||
|
||||
Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
|
||||
Constant *Idx) const override {
|
||||
Constant *Idx) const {
|
||||
return Fold(ConstantExpr::getInsertElement(Vec, NewElt, Idx));
|
||||
}
|
||||
|
||||
Constant *CreateShuffleVector(Constant *V1, Constant *V2,
|
||||
Constant *Mask) const override {
|
||||
Constant *Mask) const {
|
||||
return Fold(ConstantExpr::getShuffleVector(V1, V2, Mask));
|
||||
}
|
||||
|
||||
Constant *CreateExtractValue(Constant *Agg,
|
||||
ArrayRef<unsigned> IdxList) const override {
|
||||
ArrayRef<unsigned> IdxList) const {
|
||||
return Fold(ConstantExpr::getExtractValue(Agg, IdxList));
|
||||
}
|
||||
|
||||
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
|
||||
ArrayRef<unsigned> IdxList) const override {
|
||||
ArrayRef<unsigned> IdxList) const {
|
||||
return Fold(ConstantExpr::getInsertValue(Agg, Val, IdxList));
|
||||
}
|
||||
};
|
||||
|
@ -20,14 +20,11 @@
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/InstrTypes.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/IRBuilderFolder.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// ConstantFolder - Create constants with minimum, target independent, folding.
|
||||
class ConstantFolder final : public IRBuilderFolder {
|
||||
virtual void anchor();
|
||||
|
||||
class ConstantFolder {
|
||||
public:
|
||||
explicit ConstantFolder() = default;
|
||||
|
||||
@ -36,87 +33,87 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateAdd(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return ConstantExpr::getAdd(LHS, RHS, HasNUW, HasNSW);
|
||||
}
|
||||
|
||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getFAdd(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateSub(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return ConstantExpr::getSub(LHS, RHS, HasNUW, HasNSW);
|
||||
}
|
||||
|
||||
Constant *CreateFSub(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFSub(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getFSub(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateMul(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return ConstantExpr::getMul(LHS, RHS, HasNUW, HasNSW);
|
||||
}
|
||||
|
||||
Constant *CreateFMul(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFMul(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getFMul(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateUDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
return ConstantExpr::getUDiv(LHS, RHS, isExact);
|
||||
}
|
||||
|
||||
Constant *CreateSDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
return ConstantExpr::getSDiv(LHS, RHS, isExact);
|
||||
}
|
||||
|
||||
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFDiv(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getFDiv(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateURem(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateURem(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getURem(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateSRem(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateSRem(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getSRem(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateFRem(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateFRem(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getFRem(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateShl(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return ConstantExpr::getShl(LHS, RHS, HasNUW, HasNSW);
|
||||
}
|
||||
|
||||
Constant *CreateLShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
return ConstantExpr::getLShr(LHS, RHS, isExact);
|
||||
}
|
||||
|
||||
Constant *CreateAShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
return ConstantExpr::getAShr(LHS, RHS, isExact);
|
||||
}
|
||||
|
||||
Constant *CreateAnd(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateAnd(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getAnd(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateOr(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateOr(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getOr(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateXor(Constant *LHS, Constant *RHS) const override {
|
||||
Constant *CreateXor(Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::getXor(LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Constant *LHS, Constant *RHS) const override {
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return ConstantExpr::get(Opc, LHS, RHS);
|
||||
}
|
||||
|
||||
@ -125,19 +122,19 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateNeg(Constant *C,
|
||||
bool HasNUW = false, bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
return ConstantExpr::getNeg(C, HasNUW, HasNSW);
|
||||
}
|
||||
|
||||
Constant *CreateFNeg(Constant *C) const override {
|
||||
Constant *CreateFNeg(Constant *C) const {
|
||||
return ConstantExpr::getFNeg(C);
|
||||
}
|
||||
|
||||
Constant *CreateNot(Constant *C) const override {
|
||||
Constant *CreateNot(Constant *C) const {
|
||||
return ConstantExpr::getNot(C);
|
||||
}
|
||||
|
||||
Constant *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const override {
|
||||
Constant *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const {
|
||||
return ConstantExpr::get(Opc, C);
|
||||
}
|
||||
|
||||
@ -146,12 +143,11 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const override {
|
||||
ArrayRef<Constant *> IdxList) const {
|
||||
return ConstantExpr::getGetElementPtr(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const override {
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C, Constant *Idx) const {
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
@ -159,25 +155,25 @@ public:
|
||||
}
|
||||
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const override {
|
||||
ArrayRef<Value *> IdxList) const {
|
||||
return ConstantExpr::getGetElementPtr(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Constant *> IdxList) const override {
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const {
|
||||
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const override {
|
||||
Constant *Idx) const {
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, Idx);
|
||||
}
|
||||
|
||||
Constant *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Value *> IdxList) const override {
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const {
|
||||
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
@ -186,49 +182,49 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateCast(Instruction::CastOps Op, Constant *C,
|
||||
Type *DestTy) const override {
|
||||
Type *DestTy) const {
|
||||
return ConstantExpr::getCast(Op, C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreatePointerCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreatePointerCast(Constant *C, Type *DestTy) const {
|
||||
return ConstantExpr::getPointerCast(C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreatePointerBitCastOrAddrSpaceCast(Constant *C,
|
||||
Type *DestTy) const override {
|
||||
Type *DestTy) const {
|
||||
return ConstantExpr::getPointerBitCastOrAddrSpaceCast(C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreateIntCast(Constant *C, Type *DestTy,
|
||||
bool isSigned) const override {
|
||||
bool isSigned) const {
|
||||
return ConstantExpr::getIntegerCast(C, DestTy, isSigned);
|
||||
}
|
||||
|
||||
Constant *CreateFPCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateFPCast(Constant *C, Type *DestTy) const {
|
||||
return ConstantExpr::getFPCast(C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreateBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateBitCast(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::BitCast, C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreateIntToPtr(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateIntToPtr(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::IntToPtr, C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreatePtrToInt(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreatePtrToInt(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::PtrToInt, C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateZExtOrBitCast(Constant *C, Type *DestTy) const {
|
||||
return ConstantExpr::getZExtOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateSExtOrBitCast(Constant *C, Type *DestTy) const {
|
||||
return ConstantExpr::getSExtOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
Constant *CreateTruncOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Constant *CreateTruncOrBitCast(Constant *C, Type *DestTy) const {
|
||||
return ConstantExpr::getTruncOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
@ -237,12 +233,12 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateICmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const override {
|
||||
Constant *RHS) const {
|
||||
return ConstantExpr::getCompare(P, LHS, RHS);
|
||||
}
|
||||
|
||||
Constant *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const override {
|
||||
Constant *RHS) const {
|
||||
return ConstantExpr::getCompare(P, LHS, RHS);
|
||||
}
|
||||
|
||||
@ -250,32 +246,31 @@ public:
|
||||
// Other Instructions
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateSelect(Constant *C, Constant *True,
|
||||
Constant *False) const override {
|
||||
Constant *CreateSelect(Constant *C, Constant *True, Constant *False) const {
|
||||
return ConstantExpr::getSelect(C, True, False);
|
||||
}
|
||||
|
||||
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const override {
|
||||
Constant *CreateExtractElement(Constant *Vec, Constant *Idx) const {
|
||||
return ConstantExpr::getExtractElement(Vec, Idx);
|
||||
}
|
||||
|
||||
Constant *CreateInsertElement(Constant *Vec, Constant *NewElt,
|
||||
Constant *Idx) const override {
|
||||
Constant *Idx) const {
|
||||
return ConstantExpr::getInsertElement(Vec, NewElt, Idx);
|
||||
}
|
||||
|
||||
Constant *CreateShuffleVector(Constant *V1, Constant *V2,
|
||||
Constant *Mask) const override {
|
||||
Constant *Mask) const {
|
||||
return ConstantExpr::getShuffleVector(V1, V2, Mask);
|
||||
}
|
||||
|
||||
Constant *CreateExtractValue(Constant *Agg,
|
||||
ArrayRef<unsigned> IdxList) const override {
|
||||
ArrayRef<unsigned> IdxList) const {
|
||||
return ConstantExpr::getExtractValue(Agg, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateInsertValue(Constant *Agg, Constant *Val,
|
||||
ArrayRef<unsigned> IdxList) const override {
|
||||
ArrayRef<unsigned> IdxList) const {
|
||||
return ConstantExpr::getInsertValue(Agg, Val, IdxList);
|
||||
}
|
||||
};
|
||||
|
@ -59,12 +59,9 @@ class Use;
|
||||
///
|
||||
/// By default, this inserts the instruction at the insertion point.
|
||||
class IRBuilderDefaultInserter {
|
||||
public:
|
||||
virtual ~IRBuilderDefaultInserter();
|
||||
|
||||
virtual void InsertHelper(Instruction *I, const Twine &Name,
|
||||
BasicBlock *BB,
|
||||
BasicBlock::iterator InsertPt) const {
|
||||
protected:
|
||||
void InsertHelper(Instruction *I, const Twine &Name,
|
||||
BasicBlock *BB, BasicBlock::iterator InsertPt) const {
|
||||
if (BB) BB->getInstList().insert(InsertPt, I);
|
||||
I->setName(Name);
|
||||
}
|
||||
@ -72,18 +69,16 @@ public:
|
||||
|
||||
/// Provides an 'InsertHelper' that calls a user-provided callback after
|
||||
/// performing the default insertion.
|
||||
class IRBuilderCallbackInserter : public IRBuilderDefaultInserter {
|
||||
class IRBuilderCallbackInserter : IRBuilderDefaultInserter {
|
||||
std::function<void(Instruction *)> Callback;
|
||||
|
||||
public:
|
||||
virtual ~IRBuilderCallbackInserter();
|
||||
|
||||
IRBuilderCallbackInserter(std::function<void(Instruction *)> Callback)
|
||||
: Callback(std::move(Callback)) {}
|
||||
|
||||
protected:
|
||||
void InsertHelper(Instruction *I, const Twine &Name,
|
||||
BasicBlock *BB,
|
||||
BasicBlock::iterator InsertPt) const override {
|
||||
BasicBlock *BB, BasicBlock::iterator InsertPt) const {
|
||||
IRBuilderDefaultInserter::InsertHelper(I, Name, BB, InsertPt);
|
||||
Callback(I);
|
||||
}
|
||||
@ -97,8 +92,6 @@ protected:
|
||||
BasicBlock *BB;
|
||||
BasicBlock::iterator InsertPt;
|
||||
LLVMContext &Context;
|
||||
const IRBuilderFolder &Folder;
|
||||
const IRBuilderDefaultInserter &Inserter;
|
||||
|
||||
MDNode *DefaultFPMathTag;
|
||||
FastMathFlags FMF;
|
||||
@ -110,37 +103,15 @@ protected:
|
||||
ArrayRef<OperandBundleDef> DefaultOperandBundles;
|
||||
|
||||
public:
|
||||
IRBuilderBase(LLVMContext &context, const IRBuilderFolder &Folder,
|
||||
const IRBuilderDefaultInserter &Inserter,
|
||||
MDNode *FPMathTag, ArrayRef<OperandBundleDef> OpBundles)
|
||||
: Context(context), Folder(Folder), Inserter(Inserter),
|
||||
DefaultFPMathTag(FPMathTag), IsFPConstrained(false),
|
||||
IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: Context(context), DefaultFPMathTag(FPMathTag), IsFPConstrained(false),
|
||||
DefaultConstrainedExcept(fp::ebStrict),
|
||||
DefaultConstrainedRounding(fp::rmDynamic),
|
||||
DefaultOperandBundles(OpBundles) {
|
||||
ClearInsertionPoint();
|
||||
}
|
||||
|
||||
/// Insert and return the specified instruction.
|
||||
template<typename InstTy>
|
||||
InstTy *Insert(InstTy *I, const Twine &Name = "") const {
|
||||
Inserter.InsertHelper(I, Name, BB, InsertPt);
|
||||
SetInstDebugLocation(I);
|
||||
return I;
|
||||
}
|
||||
|
||||
/// No-op overload to handle constants.
|
||||
Constant *Insert(Constant *C, const Twine& = "") const {
|
||||
return C;
|
||||
}
|
||||
|
||||
Value *Insert(Value *V, const Twine& = "") const {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
return Insert(I);
|
||||
assert(isa<Constant>(V));
|
||||
return V;
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Builder configuration methods
|
||||
//===--------------------------------------------------------------------===//
|
||||
@ -949,7 +920,85 @@ private:
|
||||
const Twine &Name = "");
|
||||
|
||||
Value *getCastedInt8PtrValue(Value *Ptr);
|
||||
};
|
||||
|
||||
/// This provides a uniform API for creating instructions and inserting
|
||||
/// them into a basic block: either at the end of a BasicBlock, or at a specific
|
||||
/// iterator location in a block.
|
||||
///
|
||||
/// Note that the builder does not expose the full generality of LLVM
|
||||
/// instructions. For access to extra instruction properties, use the mutators
|
||||
/// (e.g. setVolatile) on the instructions after they have been
|
||||
/// created. Convenience state exists to specify fast-math flags and fp-math
|
||||
/// tags.
|
||||
///
|
||||
/// The first template argument specifies a class to use for creating constants.
|
||||
/// This defaults to creating minimally folded constants. The second template
|
||||
/// argument allows clients to specify custom insertion hooks that are called on
|
||||
/// every newly created insertion.
|
||||
template <typename T = ConstantFolder,
|
||||
typename Inserter = IRBuilderDefaultInserter>
|
||||
class IRBuilder : public IRBuilderBase, public Inserter {
|
||||
T Folder;
|
||||
|
||||
public:
|
||||
IRBuilder(LLVMContext &C, const T &F, Inserter I = Inserter(),
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(C, FPMathTag, OpBundles), Inserter(std::move(I)),
|
||||
Folder(F) {}
|
||||
|
||||
explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(C, FPMathTag, OpBundles) {}
|
||||
|
||||
explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
|
||||
SetInsertPoint(TheBB);
|
||||
}
|
||||
|
||||
explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles) {
|
||||
SetInsertPoint(TheBB);
|
||||
}
|
||||
|
||||
explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(IP->getContext(), FPMathTag, OpBundles) {
|
||||
SetInsertPoint(IP);
|
||||
}
|
||||
|
||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T &F,
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles), Folder(F) {
|
||||
SetInsertPoint(TheBB, IP);
|
||||
}
|
||||
|
||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP,
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), FPMathTag, OpBundles) {
|
||||
SetInsertPoint(TheBB, IP);
|
||||
}
|
||||
|
||||
/// Get the constant folder being used.
|
||||
const T &getFolder() { return Folder; }
|
||||
|
||||
/// Insert and return the specified instruction.
|
||||
template<typename InstTy>
|
||||
InstTy *Insert(InstTy *I, const Twine &Name = "") const {
|
||||
this->InsertHelper(I, Name, BB, InsertPt);
|
||||
this->SetInstDebugLocation(I);
|
||||
return I;
|
||||
}
|
||||
|
||||
/// No-op overload to handle constants.
|
||||
Constant *Insert(Constant *C, const Twine& = "") const {
|
||||
return C;
|
||||
}
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Instruction creation methods: Terminators
|
||||
@ -2927,79 +2976,6 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/// This provides a uniform API for creating instructions and inserting
|
||||
/// them into a basic block: either at the end of a BasicBlock, or at a specific
|
||||
/// iterator location in a block.
|
||||
///
|
||||
/// Note that the builder does not expose the full generality of LLVM
|
||||
/// instructions. For access to extra instruction properties, use the mutators
|
||||
/// (e.g. setVolatile) on the instructions after they have been
|
||||
/// created. Convenience state exists to specify fast-math flags and fp-math
|
||||
/// tags.
|
||||
///
|
||||
/// The first template argument specifies a class to use for creating constants.
|
||||
/// This defaults to creating minimally folded constants. The second template
|
||||
/// argument allows clients to specify custom insertion hooks that are called on
|
||||
/// every newly created insertion.
|
||||
template <typename FolderTy = ConstantFolder,
|
||||
typename InserterTy = IRBuilderDefaultInserter>
|
||||
class IRBuilder : public IRBuilderBase {
|
||||
private:
|
||||
FolderTy Folder;
|
||||
InserterTy Inserter;
|
||||
|
||||
public:
|
||||
IRBuilder(LLVMContext &C, FolderTy Folder, InserterTy Inserter = InserterTy(),
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles),
|
||||
Folder(Folder), Inserter(Inserter) {}
|
||||
|
||||
explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(C, this->Folder, this->Inserter, FPMathTag, OpBundles) {}
|
||||
|
||||
explicit IRBuilder(BasicBlock *TheBB, FolderTy Folder,
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
|
||||
FPMathTag, OpBundles), Folder(Folder) {
|
||||
SetInsertPoint(TheBB);
|
||||
}
|
||||
|
||||
explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
|
||||
FPMathTag, OpBundles) {
|
||||
SetInsertPoint(TheBB);
|
||||
}
|
||||
|
||||
explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(IP->getContext(), this->Folder, this->Inserter,
|
||||
FPMathTag, OpBundles) {
|
||||
SetInsertPoint(IP);
|
||||
}
|
||||
|
||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, FolderTy Folder,
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
|
||||
FPMathTag, OpBundles), Folder(Folder) {
|
||||
SetInsertPoint(TheBB, IP);
|
||||
}
|
||||
|
||||
IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP,
|
||||
MDNode *FPMathTag = nullptr,
|
||||
ArrayRef<OperandBundleDef> OpBundles = None)
|
||||
: IRBuilderBase(TheBB->getContext(), this->Folder, this->Inserter,
|
||||
FPMathTag, OpBundles) {
|
||||
SetInsertPoint(TheBB, IP);
|
||||
}
|
||||
|
||||
InserterTy &getInserter() { return Inserter; }
|
||||
};
|
||||
|
||||
// Create wrappers for C Binding types (see CBindingWrapping.h).
|
||||
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(IRBuilder<>, LLVMBuilderRef)
|
||||
|
||||
|
@ -1,141 +0,0 @@
|
||||
//===- IRBuilderFolder.h - Const folder interface for IRBuilder -*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines for constant folding interface used by IRBuilder.
|
||||
// It is implemented by ConstantFolder (default), TargetFolder and NoFoler.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_IR_IRBUILDERFOLDER_H
|
||||
#define LLVM_IR_IRBUILDERFOLDER_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/IR/InstrTypes.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// IRBuilderFolder - Interface for constant folding in IRBuilder.
|
||||
class IRBuilderFolder {
|
||||
public:
|
||||
virtual ~IRBuilderFolder();
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Binary Operators
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
virtual Value *CreateAdd(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const = 0;
|
||||
virtual Value *CreateFAdd(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateSub(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const = 0;
|
||||
virtual Value *CreateFSub(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateMul(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const = 0;
|
||||
virtual Value *CreateFMul(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateUDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const = 0;
|
||||
virtual Value *CreateSDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const = 0;
|
||||
virtual Value *CreateFDiv(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateURem(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateSRem(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateFRem(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateShl(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false, bool HasNSW = false) const = 0;
|
||||
virtual Value *CreateLShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const = 0;
|
||||
virtual Value *CreateAShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const = 0;
|
||||
virtual Value *CreateAnd(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateOr(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateXor(Constant *LHS, Constant *RHS) const = 0;
|
||||
virtual Value *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Constant *LHS, Constant *RHS) const = 0;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Unary Operators
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
virtual Value *CreateNeg(Constant *C,
|
||||
bool HasNUW = false, bool HasNSW = false) const = 0;
|
||||
virtual Value *CreateFNeg(Constant *C) const = 0;
|
||||
virtual Value *CreateNot(Constant *C) const = 0;
|
||||
virtual Value *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const = 0;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Memory Instructions
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
virtual Value *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const = 0;
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
virtual Value *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const = 0;
|
||||
virtual Value *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const = 0;
|
||||
virtual Value *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Constant *> IdxList) const = 0;
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
virtual Value *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const = 0;
|
||||
virtual Value *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Value *> IdxList) const = 0;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Cast/Conversion Operators
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
virtual Value *CreateCast(Instruction::CastOps Op, Constant *C,
|
||||
Type *DestTy) const = 0;
|
||||
virtual Value *CreatePointerCast(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreatePointerBitCastOrAddrSpaceCast(Constant *C,
|
||||
Type *DestTy) const = 0;
|
||||
virtual Value *CreateIntCast(Constant *C, Type *DestTy,
|
||||
bool isSigned) const = 0;
|
||||
virtual Value *CreateFPCast(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreateBitCast(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreateIntToPtr(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreatePtrToInt(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreateZExtOrBitCast(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreateSExtOrBitCast(Constant *C, Type *DestTy) const = 0;
|
||||
virtual Value *CreateTruncOrBitCast(Constant *C, Type *DestTy) const = 0;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Compare Instructions
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
virtual Value *CreateICmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const = 0;
|
||||
virtual Value *CreateFCmp(CmpInst::Predicate P, Constant *LHS,
|
||||
Constant *RHS) const = 0;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Other Instructions
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
virtual Value *CreateSelect(Constant *C, Constant *True,
|
||||
Constant *False) const = 0;
|
||||
virtual Value *CreateExtractElement(Constant *Vec, Constant *Idx) const = 0;
|
||||
virtual Value *CreateInsertElement(Constant *Vec, Constant *NewElt,
|
||||
Constant *Idx) const = 0;
|
||||
virtual Value *CreateShuffleVector(Constant *V1, Constant *V2,
|
||||
Constant *Mask) const = 0;
|
||||
virtual Value *CreateExtractValue(Constant *Agg,
|
||||
ArrayRef<unsigned> IdxList) const = 0;
|
||||
virtual Value *CreateInsertValue(Constant *Agg, Constant *Val,
|
||||
ArrayRef<unsigned> IdxList) const = 0;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_IR_IRBUILDERFOLDER_H
|
@ -26,14 +26,11 @@
|
||||
#include "llvm/IR/InstrTypes.h"
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/IRBuilderFolder.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// NoFolder - Create "constants" (actually, instructions) with no folding.
|
||||
class NoFolder final : public IRBuilderFolder {
|
||||
virtual void anchor();
|
||||
|
||||
class NoFolder {
|
||||
public:
|
||||
explicit NoFolder() = default;
|
||||
|
||||
@ -42,76 +39,73 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Instruction *CreateAdd(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false,
|
||||
bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
BinaryOperator *BO = BinaryOperator::CreateAdd(LHS, RHS);
|
||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
||||
if (HasNSW) BO->setHasNoSignedWrap();
|
||||
return BO;
|
||||
}
|
||||
|
||||
Instruction *CreateFAdd(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateFAdd(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateFAdd(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateSub(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false,
|
||||
bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
BinaryOperator *BO = BinaryOperator::CreateSub(LHS, RHS);
|
||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
||||
if (HasNSW) BO->setHasNoSignedWrap();
|
||||
return BO;
|
||||
}
|
||||
|
||||
Instruction *CreateFSub(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateFSub(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateFSub(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateMul(Constant *LHS, Constant *RHS,
|
||||
bool HasNUW = false,
|
||||
bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
BinaryOperator *BO = BinaryOperator::CreateMul(LHS, RHS);
|
||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
||||
if (HasNSW) BO->setHasNoSignedWrap();
|
||||
return BO;
|
||||
}
|
||||
|
||||
Instruction *CreateFMul(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateFMul(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateFMul(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateUDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
if (!isExact)
|
||||
return BinaryOperator::CreateUDiv(LHS, RHS);
|
||||
return BinaryOperator::CreateExactUDiv(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateSDiv(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
if (!isExact)
|
||||
return BinaryOperator::CreateSDiv(LHS, RHS);
|
||||
return BinaryOperator::CreateExactSDiv(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateFDiv(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateFDiv(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateFDiv(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateURem(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateURem(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateURem(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateSRem(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateSRem(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateSRem(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateFRem(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateFRem(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateFRem(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateShl(Constant *LHS, Constant *RHS, bool HasNUW = false,
|
||||
bool HasNSW = false) const override {
|
||||
bool HasNSW = false) const {
|
||||
BinaryOperator *BO = BinaryOperator::CreateShl(LHS, RHS);
|
||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
||||
if (HasNSW) BO->setHasNoSignedWrap();
|
||||
@ -119,33 +113,33 @@ public:
|
||||
}
|
||||
|
||||
Instruction *CreateLShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
if (!isExact)
|
||||
return BinaryOperator::CreateLShr(LHS, RHS);
|
||||
return BinaryOperator::CreateExactLShr(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateAShr(Constant *LHS, Constant *RHS,
|
||||
bool isExact = false) const override {
|
||||
bool isExact = false) const {
|
||||
if (!isExact)
|
||||
return BinaryOperator::CreateAShr(LHS, RHS);
|
||||
return BinaryOperator::CreateExactAShr(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateAnd(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateAnd(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateAnd(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateOr(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateOr(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateOr(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateXor(Constant *LHS, Constant *RHS) const override {
|
||||
Instruction *CreateXor(Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::CreateXor(LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateBinOp(Instruction::BinaryOps Opc,
|
||||
Constant *LHS, Constant *RHS) const override {
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return BinaryOperator::Create(Opc, LHS, RHS);
|
||||
}
|
||||
|
||||
@ -154,24 +148,22 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Instruction *CreateNeg(Constant *C,
|
||||
bool HasNUW = false,
|
||||
bool HasNSW = false) const override {
|
||||
bool HasNUW = false, bool HasNSW = false) const {
|
||||
BinaryOperator *BO = BinaryOperator::CreateNeg(C);
|
||||
if (HasNUW) BO->setHasNoUnsignedWrap();
|
||||
if (HasNSW) BO->setHasNoSignedWrap();
|
||||
return BO;
|
||||
}
|
||||
|
||||
Instruction *CreateFNeg(Constant *C) const override {
|
||||
Instruction *CreateFNeg(Constant *C) const {
|
||||
return UnaryOperator::CreateFNeg(C);
|
||||
}
|
||||
|
||||
Instruction *CreateNot(Constant *C) const override {
|
||||
Instruction *CreateNot(Constant *C) const {
|
||||
return BinaryOperator::CreateNot(C);
|
||||
}
|
||||
|
||||
Instruction *CreateUnOp(Instruction::UnaryOps Opc,
|
||||
Constant *C) const override {
|
||||
Instruction *CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const {
|
||||
return UnaryOperator::Create(Opc, C);
|
||||
}
|
||||
|
||||
@ -180,12 +172,11 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const override {
|
||||
ArrayRef<Constant *> IdxList) const {
|
||||
return ConstantExpr::getGetElementPtr(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const override {
|
||||
Constant *CreateGetElementPtr(Type *Ty, Constant *C, Constant *Idx) const {
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
@ -193,25 +184,25 @@ public:
|
||||
}
|
||||
|
||||
Instruction *CreateGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const override {
|
||||
ArrayRef<Value *> IdxList) const {
|
||||
return GetElementPtrInst::Create(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Constant *> IdxList) const override {
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Constant *> IdxList) const {
|
||||
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
Constant *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
Constant *Idx) const override {
|
||||
Constant *Idx) const {
|
||||
// This form of the function only exists to avoid ambiguous overload
|
||||
// warnings about whether to convert Idx to ArrayRef<Constant *> or
|
||||
// ArrayRef<Value *>.
|
||||
return ConstantExpr::getInBoundsGetElementPtr(Ty, C, Idx);
|
||||
}
|
||||
|
||||
Instruction *CreateInBoundsGetElementPtr(
|
||||
Type *Ty, Constant *C, ArrayRef<Value *> IdxList) const override {
|
||||
Instruction *CreateInBoundsGetElementPtr(Type *Ty, Constant *C,
|
||||
ArrayRef<Value *> IdxList) const {
|
||||
return GetElementPtrInst::CreateInBounds(Ty, C, IdxList);
|
||||
}
|
||||
|
||||
@ -220,49 +211,49 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Instruction *CreateCast(Instruction::CastOps Op, Constant *C,
|
||||
Type *DestTy) const override {
|
||||
Type *DestTy) const {
|
||||
return CastInst::Create(Op, C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreatePointerCast(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreatePointerCast(Constant *C, Type *DestTy) const {
|
||||
return CastInst::CreatePointerCast(C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreatePointerBitCastOrAddrSpaceCast(
|
||||
Constant *C, Type *DestTy) const override {
|
||||
Constant *C, Type *DestTy) const {
|
||||
return CastInst::CreatePointerBitCastOrAddrSpaceCast(C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreateIntCast(Constant *C, Type *DestTy,
|
||||
bool isSigned) const override {
|
||||
bool isSigned) const {
|
||||
return CastInst::CreateIntegerCast(C, DestTy, isSigned);
|
||||
}
|
||||
|
||||
Instruction *CreateFPCast(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreateFPCast(Constant *C, Type *DestTy) const {
|
||||
return CastInst::CreateFPCast(C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreateBitCast(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreateBitCast(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::BitCast, C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreateIntToPtr(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreateIntToPtr(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::IntToPtr, C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreatePtrToInt(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreatePtrToInt(Constant *C, Type *DestTy) const {
|
||||
return CreateCast(Instruction::PtrToInt, C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreateZExtOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreateZExtOrBitCast(Constant *C, Type *DestTy) const {
|
||||
return CastInst::CreateZExtOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreateSExtOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreateSExtOrBitCast(Constant *C, Type *DestTy) const {
|
||||
return CastInst::CreateSExtOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
Instruction *CreateTruncOrBitCast(Constant *C, Type *DestTy) const override {
|
||||
Instruction *CreateTruncOrBitCast(Constant *C, Type *DestTy) const {
|
||||
return CastInst::CreateTruncOrBitCast(C, DestTy);
|
||||
}
|
||||
|
||||
@ -271,12 +262,12 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Instruction *CreateICmp(CmpInst::Predicate P,
|
||||
Constant *LHS, Constant *RHS) const override {
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return new ICmpInst(P, LHS, RHS);
|
||||
}
|
||||
|
||||
Instruction *CreateFCmp(CmpInst::Predicate P,
|
||||
Constant *LHS, Constant *RHS) const override {
|
||||
Constant *LHS, Constant *RHS) const {
|
||||
return new FCmpInst(P, LHS, RHS);
|
||||
}
|
||||
|
||||
@ -285,32 +276,31 @@ public:
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
Instruction *CreateSelect(Constant *C,
|
||||
Constant *True, Constant *False) const override {
|
||||
Constant *True, Constant *False) const {
|
||||
return SelectInst::Create(C, True, False);
|
||||
}
|
||||
|
||||
Instruction *CreateExtractElement(Constant *Vec,
|
||||
Constant *Idx) const override {
|
||||
Instruction *CreateExtractElement(Constant *Vec, Constant *Idx) const {
|
||||
return ExtractElementInst::Create(Vec, Idx);
|
||||
}
|
||||
|
||||
Instruction *CreateInsertElement(Constant *Vec, Constant *NewElt,
|
||||
Constant *Idx) const override {
|
||||
Constant *Idx) const {
|
||||
return InsertElementInst::Create(Vec, NewElt, Idx);
|
||||
}
|
||||
|
||||
Instruction *CreateShuffleVector(Constant *V1, Constant *V2,
|
||||
Constant *Mask) const override {
|
||||
Constant *Mask) const {
|
||||
return new ShuffleVectorInst(V1, V2, Mask);
|
||||
}
|
||||
|
||||
Instruction *CreateExtractValue(Constant *Agg,
|
||||
ArrayRef<unsigned> IdxList) const override {
|
||||
ArrayRef<unsigned> IdxList) const {
|
||||
return ExtractValueInst::Create(Agg, IdxList);
|
||||
}
|
||||
|
||||
Instruction *CreateInsertValue(Constant *Agg, Constant *Val,
|
||||
ArrayRef<unsigned> IdxList) const override {
|
||||
ArrayRef<unsigned> IdxList) const {
|
||||
return InsertValueInst::Create(Agg, Val, IdxList);
|
||||
}
|
||||
};
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Analysis/TargetFolder.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/Analysis/ValueTracking.h"
|
||||
#include "llvm/Analysis/VectorUtils.h"
|
||||
@ -2661,5 +2660,3 @@ bool llvm::isMathLibCallNoop(const CallBase *Call,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void TargetFolder::anchor() {}
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include "llvm/IR/Intrinsics.h"
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Operator.h"
|
||||
#include "llvm/IR/NoFolder.h"
|
||||
#include "llvm/IR/Statepoint.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Value.h"
|
||||
@ -785,9 +784,3 @@ CallInst *IRBuilderBase::CreateIntrinsic(Intrinsic::ID ID,
|
||||
Function *Fn = Intrinsic::getDeclaration(M, ID, Types);
|
||||
return createCallHelper(Fn, Args, this, Name, FMFSource);
|
||||
}
|
||||
|
||||
IRBuilderDefaultInserter::~IRBuilderDefaultInserter() {}
|
||||
IRBuilderCallbackInserter::~IRBuilderCallbackInserter() {}
|
||||
IRBuilderFolder::~IRBuilderFolder() {}
|
||||
void ConstantFolder::anchor() {}
|
||||
void NoFolder::anchor() {}
|
||||
|
@ -129,7 +129,7 @@ namespace {
|
||||
|
||||
/// A custom IRBuilder inserter which prefixes all names, but only in
|
||||
/// Assert builds.
|
||||
class IRBuilderPrefixedInserter final : public IRBuilderDefaultInserter {
|
||||
class IRBuilderPrefixedInserter : public IRBuilderDefaultInserter {
|
||||
std::string Prefix;
|
||||
|
||||
const Twine getNameWithPrefix(const Twine &Name) const {
|
||||
@ -139,8 +139,9 @@ class IRBuilderPrefixedInserter final : public IRBuilderDefaultInserter {
|
||||
public:
|
||||
void SetNamePrefix(const Twine &P) { Prefix = P.str(); }
|
||||
|
||||
protected:
|
||||
void InsertHelper(Instruction *I, const Twine &Name, BasicBlock *BB,
|
||||
BasicBlock::iterator InsertPt) const override {
|
||||
BasicBlock::iterator InsertPt) const {
|
||||
IRBuilderDefaultInserter::InsertHelper(I, getNameWithPrefix(Name), BB,
|
||||
InsertPt);
|
||||
}
|
||||
@ -2367,8 +2368,7 @@ public:
|
||||
Instruction *OldUserI = cast<Instruction>(OldUse->getUser());
|
||||
IRB.SetInsertPoint(OldUserI);
|
||||
IRB.SetCurrentDebugLocation(OldUserI->getDebugLoc());
|
||||
IRB.getInserter().SetNamePrefix(
|
||||
Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
|
||||
IRB.SetNamePrefix(Twine(NewAI.getName()) + "." + Twine(BeginOffset) + ".");
|
||||
|
||||
CanSROA &= visit(cast<Instruction>(OldUse->getUser()));
|
||||
if (VecTy || IntTy)
|
||||
|
Loading…
Reference in New Issue
Block a user