From 867e91468baf1eac9c04a64c72107a8ac65bb8f6 Mon Sep 17 00:00:00 2001 From: Mehdi Amini Date: Thu, 14 Apr 2016 04:36:40 +0000 Subject: [PATCH] Do not use getGlobalContext()... ever. This code was creating a new type in the global context, regardless of which context the user is sitting in, what can possibly go wrong? From: Mehdi Amini llvm-svn: 266275 --- llvm/lib/Target/X86/X86TargetTransformInfo.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp index 1bd1372..9508539 100644 --- a/llvm/lib/Target/X86/X86TargetTransformInfo.cpp +++ b/llvm/lib/Target/X86/X86TargetTransformInfo.cpp @@ -1001,14 +1001,14 @@ int X86TTIImpl::getMaskedMemoryOpCost(unsigned Opcode, Type *SrcTy, unsigned NumElem = SrcVTy->getVectorNumElements(); VectorType *MaskTy = - VectorType::get(Type::getInt8Ty(getGlobalContext()), NumElem); + VectorType::get(Type::getInt8Ty(SrcVTy->getContext()), NumElem); if ((Opcode == Instruction::Load && !isLegalMaskedLoad(SrcVTy)) || (Opcode == Instruction::Store && !isLegalMaskedStore(SrcVTy)) || !isPowerOf2_32(NumElem)) { // Scalarization int MaskSplitCost = getScalarizationOverhead(MaskTy, false, true); int ScalarCompareCost = getCmpSelInstrCost( - Instruction::ICmp, Type::getInt8Ty(getGlobalContext()), nullptr); + Instruction::ICmp, Type::getInt8Ty(SrcVTy->getContext()), nullptr); int BranchCost = getCFInstrCost(Instruction::Br); int MaskCmpCost = NumElem * (BranchCost + ScalarCompareCost); @@ -1339,7 +1339,7 @@ int X86TTIImpl::getGSVectorCost(unsigned Opcode, Type *SrcVTy, Value *Ptr, unsigned IndexSize = (VF >= 16) ? getIndexSizeInBits(Ptr, DL) : DL.getPointerSizeInBits(); - Type *IndexVTy = VectorType::get(IntegerType::get(getGlobalContext(), + Type *IndexVTy = VectorType::get(IntegerType::get(SrcVTy->getContext(), IndexSize), VF); std::pair IdxsLT = TLI->getTypeLegalizationCost(DL, IndexVTy); std::pair SrcLT = TLI->getTypeLegalizationCost(DL, SrcVTy); @@ -1374,10 +1374,10 @@ int X86TTIImpl::getGSScalarCost(unsigned Opcode, Type *SrcVTy, int MaskUnpackCost = 0; if (VariableMask) { VectorType *MaskTy = - VectorType::get(Type::getInt1Ty(getGlobalContext()), VF); + VectorType::get(Type::getInt1Ty(SrcVTy->getContext()), VF); MaskUnpackCost = getScalarizationOverhead(MaskTy, false, true); int ScalarCompareCost = - getCmpSelInstrCost(Instruction::ICmp, Type::getInt1Ty(getGlobalContext()), + getCmpSelInstrCost(Instruction::ICmp, Type::getInt1Ty(SrcVTy->getContext()), nullptr); int BranchCost = getCFInstrCost(Instruction::Br); MaskUnpackCost += VF * (BranchCost + ScalarCompareCost); -- 2.7.4