LLVM 20.0.0git
Functions | Variables
AutoUpgrade.cpp File Reference
#include "llvm/IR/AutoUpgrade.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/AttributeMask.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/IntrinsicsAArch64.h"
#include "llvm/IR/IntrinsicsARM.h"
#include "llvm/IR/IntrinsicsNVPTX.h"
#include "llvm/IR/IntrinsicsRISCV.h"
#include "llvm/IR/IntrinsicsWebAssembly.h"
#include "llvm/IR/IntrinsicsX86.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Value.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/AMDGPUAddrSpace.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Regex.h"
#include "llvm/TargetParser/Triple.h"
#include <cstring>

Go to the source code of this file.

Functions

static void rename (GlobalValue *GV)
 
static bool upgradePTESTIntrinsic (Function *F, Intrinsic::ID IID, Function *&NewFn)
 
static bool upgradeX86IntrinsicsWith8BitMask (Function *F, Intrinsic::ID IID, Function *&NewFn)
 
static bool upgradeX86MaskedFPCompare (Function *F, Intrinsic::ID IID, Function *&NewFn)
 
static bool upgradeX86BF16Intrinsic (Function *F, Intrinsic::ID IID, Function *&NewFn)
 
static bool upgradeX86BF16DPIntrinsic (Function *F, Intrinsic::ID IID, Function *&NewFn)
 
static bool shouldUpgradeX86Intrinsic (Function *F, StringRef Name)
 
static bool upgradeX86IntrinsicFunction (Function *F, StringRef Name, Function *&NewFn)
 
static bool upgradeArmOrAarch64IntrinsicFunction (bool IsArm, Function *F, StringRef Name, Function *&NewFn)
 
static Intrinsic::ID shouldUpgradeNVPTXBF16Intrinsic (StringRef Name)
 
static bool upgradeIntrinsicFunction1 (Function *F, Function *&NewFn, bool CanUpgradeDebugIntrinsicsToRecords)
 
static ValueupgradeX86PSLLDQIntrinsics (IRBuilder<> &Builder, Value *Op, unsigned Shift)
 
static ValueupgradeX86PSRLDQIntrinsics (IRBuilder<> &Builder, Value *Op, unsigned Shift)
 
static ValuegetX86MaskVec (IRBuilder<> &Builder, Value *Mask, unsigned NumElts)
 
static ValueemitX86Select (IRBuilder<> &Builder, Value *Mask, Value *Op0, Value *Op1)
 
static ValueemitX86ScalarSelect (IRBuilder<> &Builder, Value *Mask, Value *Op0, Value *Op1)
 
static ValueupgradeX86ALIGNIntrinsics (IRBuilder<> &Builder, Value *Op0, Value *Op1, Value *Shift, Value *Passthru, Value *Mask, bool IsVALIGN)
 
static ValueupgradeX86VPERMT2Intrinsics (IRBuilder<> &Builder, CallBase &CI, bool ZeroMask, bool IndexForm)
 
static ValueupgradeX86BinaryIntrinsics (IRBuilder<> &Builder, CallBase &CI, Intrinsic::ID IID)
 
static ValueupgradeX86Rotate (IRBuilder<> &Builder, CallBase &CI, bool IsRotateRight)
 
static ValueupgradeX86vpcom (IRBuilder<> &Builder, CallBase &CI, unsigned Imm, bool IsSigned)
 
static ValueupgradeX86ConcatShift (IRBuilder<> &Builder, CallBase &CI, bool IsShiftRight, bool ZeroMask)
 
static ValueupgradeMaskedStore (IRBuilder<> &Builder, Value *Ptr, Value *Data, Value *Mask, bool Aligned)
 
static ValueupgradeMaskedLoad (IRBuilder<> &Builder, Value *Ptr, Value *Passthru, Value *Mask, bool Aligned)
 
static ValueupgradeAbs (IRBuilder<> &Builder, CallBase &CI)
 
static ValueupgradePMULDQ (IRBuilder<> &Builder, CallBase &CI, bool IsSigned)
 
static ValueapplyX86MaskOn1BitsVec (IRBuilder<> &Builder, Value *Vec, Value *Mask)
 
static ValueupgradeMaskedCompare (IRBuilder<> &Builder, CallBase &CI, unsigned CC, bool Signed)
 
static ValueupgradeX86MaskedShift (IRBuilder<> &Builder, CallBase &CI, Intrinsic::ID IID)
 
static ValueupgradeMaskedMove (IRBuilder<> &Builder, CallBase &CI)
 
static ValueupgradeMaskToInt (IRBuilder<> &Builder, CallBase &CI)
 
static bool upgradeAVX512MaskToSelect (StringRef Name, IRBuilder<> &Builder, CallBase &CI, Value *&Rep)
 
static ValueupgradeNVVMIntrinsicCall (StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
 
static ValueupgradeX86IntrinsicCall (StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
 
static ValueupgradeAArch64IntrinsicCall (StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
 
static ValueupgradeARMIntrinsicCall (StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
 
static ValueupgradeAMDGCNIntrinsicCall (StringRef Name, CallBase *CI, Function *F, IRBuilder<> &Builder)
 
template<typename MDType >
static MDType * unwrapMAVOp (CallBase *CI, unsigned Op)
 Helper to unwrap intrinsic call MetadataAsValue operands.
 
static void upgradeDbgIntrinsicToDbgRecord (StringRef Name, CallBase *CI)
 Convert debug intrinsic calls to non-instruction debug records.
 
static bool upgradeRetainReleaseMarker (Module &M)
 This checks for objc retain release marker which should be upgraded.
 
static bool isOldLoopArgument (Metadata *MD)
 
static MDStringupgradeLoopTag (LLVMContext &C, StringRef OldTag)
 
static MetadataupgradeLoopArgument (Metadata *MD)
 

Variables

static cl::opt< boolDisableAutoUpgradeDebugInfo ("disable-auto-upgrade-debug-info", cl::desc("Disable autoupgrade of debug info"))
 

Function Documentation

◆ applyX86MaskOn1BitsVec()

static Value * applyX86MaskOn1BitsVec ( IRBuilder<> &  Builder,
Value Vec,
Value Mask 
)
static

◆ emitX86ScalarSelect()

static Value * emitX86ScalarSelect ( IRBuilder<> &  Builder,
Value Mask,
Value Op0,
Value Op1 
)
static

◆ emitX86Select()

static Value * emitX86Select ( IRBuilder<> &  Builder,
Value Mask,
Value Op0,
Value Op1 
)
static

◆ getX86MaskVec()

static Value * getX86MaskVec ( IRBuilder<> &  Builder,
Value Mask,
unsigned  NumElts 
)
static

◆ isOldLoopArgument()

static bool isOldLoopArgument ( Metadata MD)
static

Definition at line 5431 of file AutoUpgrade.cpp.

Referenced by llvm::upgradeInstructionLoopAttachment().

◆ rename()

static void rename ( GlobalValue GV)
static

◆ shouldUpgradeNVPTXBF16Intrinsic()

static Intrinsic::ID shouldUpgradeNVPTXBF16Intrinsic ( StringRef  Name)
static

◆ shouldUpgradeX86Intrinsic()

static bool shouldUpgradeX86Intrinsic ( Function F,
StringRef  Name 
)
static

Definition at line 122 of file AutoUpgrade.cpp.

References Name.

Referenced by upgradeX86IntrinsicFunction().

◆ unwrapMAVOp()

template<typename MDType >
static MDType * unwrapMAVOp ( CallBase CI,
unsigned  Op 
)
static

Helper to unwrap intrinsic call MetadataAsValue operands.

Definition at line 4276 of file AutoUpgrade.cpp.

References llvm::CallBase::getArgOperand().

◆ upgradeAArch64IntrinsicCall()

static Value * upgradeAArch64IntrinsicCall ( StringRef  Name,
CallBase CI,
Function F,
IRBuilder<> &  Builder 
)
static

◆ upgradeAbs()

static Value * upgradeAbs ( IRBuilder<> &  Builder,
CallBase CI 
)
static

◆ upgradeAMDGCNIntrinsicCall()

static Value * upgradeAMDGCNIntrinsicCall ( StringRef  Name,
CallBase CI,
Function F,
IRBuilder<> &  Builder 
)
static

◆ upgradeARMIntrinsicCall()

static Value * upgradeARMIntrinsicCall ( StringRef  Name,
CallBase CI,
Function F,
IRBuilder<> &  Builder 
)
static

◆ upgradeArmOrAarch64IntrinsicFunction()

static bool upgradeArmOrAarch64IntrinsicFunction ( bool  IsArm,
Function F,
StringRef  Name,
Function *&  NewFn 
)
static

◆ upgradeAVX512MaskToSelect()

static bool upgradeAVX512MaskToSelect ( StringRef  Name,
IRBuilder<> &  Builder,
CallBase CI,
Value *&  Rep 
)
static

◆ upgradeDbgIntrinsicToDbgRecord()

static void upgradeDbgIntrinsicToDbgRecord ( StringRef  Name,
CallBase CI 
)
static

Convert debug intrinsic calls to non-instruction debug records.

Name - Final part of the intrinsic name, e.g. 'value' in llvm.dbg.value. CI - The debug intrinsic call.

Definition at line 4285 of file AutoUpgrade.cpp.

References llvm::DIExpression::append(), llvm::CallBase::arg_size(), assert(), llvm::CallBase::getArgOperand(), llvm::Instruction::getDebugLoc(), llvm::ilist_node_impl< OptionsT >::getIterator(), llvm::ilist_detail::node_parent_access< NodeTy, ParentTy >::getParent(), Name, and llvm::Offset.

Referenced by llvm::UpgradeIntrinsicCall().

◆ upgradeIntrinsicFunction1()

static bool upgradeIntrinsicFunction1 ( Function F,
Function *&  NewFn,
bool  CanUpgradeDebugIntrinsicsToRecords 
)
static

◆ upgradeLoopArgument()

static Metadata * upgradeLoopArgument ( Metadata MD)
static

◆ upgradeLoopTag()

static MDString * upgradeLoopTag ( LLVMContext C,
StringRef  OldTag 
)
static

◆ upgradeMaskedCompare()

static Value * upgradeMaskedCompare ( IRBuilder<> &  Builder,
CallBase CI,
unsigned  CC,
bool  Signed 
)
static

◆ upgradeMaskedLoad()

static Value * upgradeMaskedLoad ( IRBuilder<> &  Builder,
Value Ptr,
Value Passthru,
Value Mask,
bool  Aligned 
)
static

◆ upgradeMaskedMove()

static Value * upgradeMaskedMove ( IRBuilder<> &  Builder,
CallBase CI 
)
static

◆ upgradeMaskedStore()

static Value * upgradeMaskedStore ( IRBuilder<> &  Builder,
Value Ptr,
Value Data,
Value Mask,
bool  Aligned 
)
static

◆ upgradeMaskToInt()

static Value * upgradeMaskToInt ( IRBuilder<> &  Builder,
CallBase CI 
)
static

◆ upgradeNVVMIntrinsicCall()

static Value * upgradeNVVMIntrinsicCall ( StringRef  Name,
CallBase CI,
Function F,
IRBuilder<> &  Builder 
)
static

◆ upgradePMULDQ()

static Value * upgradePMULDQ ( IRBuilder<> &  Builder,
CallBase CI,
bool  IsSigned 
)
static

◆ upgradePTESTIntrinsic()

static bool upgradePTESTIntrinsic ( Function F,
Intrinsic::ID  IID,
Function *&  NewFn 
)
static

◆ upgradeRetainReleaseMarker()

static bool upgradeRetainReleaseMarker ( Module M)
static

This checks for objc retain release marker which should be upgraded.

It returns true if module is modified.

Definition at line 5027 of file AutoUpgrade.cpp.

References llvm::Module::Error, llvm::MDString::get(), llvm::NamedMDNode::getOperand(), and llvm::SmallVectorBase< Size_T >::size().

Referenced by llvm::UpgradeARCRuntime().

◆ upgradeX86ALIGNIntrinsics()

static Value * upgradeX86ALIGNIntrinsics ( IRBuilder<> &  Builder,
Value Op0,
Value Op1,
Value Shift,
Value Passthru,
Value Mask,
bool  IsVALIGN 
)
static

◆ upgradeX86BF16DPIntrinsic()

static bool upgradeX86BF16DPIntrinsic ( Function F,
Intrinsic::ID  IID,
Function *&  NewFn 
)
static

Definition at line 112 of file AutoUpgrade.cpp.

References F, llvm::Intrinsic::getOrInsertDeclaration(), and rename().

Referenced by upgradeX86IntrinsicFunction().

◆ upgradeX86BF16Intrinsic()

static bool upgradeX86BF16Intrinsic ( Function F,
Intrinsic::ID  IID,
Function *&  NewFn 
)
static

Definition at line 102 of file AutoUpgrade.cpp.

References F, llvm::Intrinsic::getOrInsertDeclaration(), and rename().

Referenced by upgradeX86IntrinsicFunction().

◆ upgradeX86BinaryIntrinsics()

static Value * upgradeX86BinaryIntrinsics ( IRBuilder<> &  Builder,
CallBase CI,
Intrinsic::ID  IID 
)
static

◆ upgradeX86ConcatShift()

static Value * upgradeX86ConcatShift ( IRBuilder<> &  Builder,
CallBase CI,
bool  IsShiftRight,
bool  ZeroMask 
)
static

◆ upgradeX86IntrinsicCall()

static Value * upgradeX86IntrinsicCall ( StringRef  Name,
CallBase CI,
Function F,
IRBuilder<> &  Builder 
)
static

Definition at line 2408 of file AutoUpgrade.cpp.

References A, Addr, llvm::Aligned, applyX86MaskOn1BitsVec(), llvm::CallBase::arg_size(), llvm::CallBase::args(), assert(), B, llvm::CallingConv::C, llvm::IRBuilderBase::CreateAdd(), llvm::IRBuilderBase::CreateAlignedLoad(), llvm::IRBuilderBase::CreateAlignedStore(), llvm::IRBuilderBase::CreateAnd(), llvm::IRBuilderBase::CreateBitCast(), llvm::IRBuilderBase::CreateCall(), llvm::IRBuilderBase::CreateExtractElement(), llvm::IRBuilderBase::CreateExtractValue(), llvm::IRBuilderBase::CreateFAdd(), llvm::IRBuilderBase::CreateFDiv(), llvm::IRBuilderBase::CreateFMul(), llvm::IRBuilderBase::CreateFNeg(), llvm::IRBuilderBase::CreateFPExt(), llvm::IRBuilderBase::CreateFSub(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateICmpEQ(), llvm::IRBuilderBase::CreateInsertElement(), llvm::IRBuilderBase::CreateIntrinsic(), llvm::IRBuilderBase::CreateLoad(), llvm::IRBuilderBase::CreateMul(), llvm::IRBuilderBase::CreateNot(), llvm::IRBuilderBase::CreateOr(), llvm::IRBuilderBase::CreatePointerCast(), llvm::IRBuilderBase::CreateSExt(), llvm::IRBuilderBase::CreateShuffleVector(), llvm::IRBuilderBase::CreateSIToFP(), llvm::IRBuilderBase::CreateSub(), llvm::IRBuilderBase::CreateTrunc(), llvm::IRBuilderBase::CreateUIToFP(), llvm::IRBuilderBase::CreateVectorSplat(), llvm::IRBuilderBase::CreateXor(), llvm::IRBuilderBase::CreateZExt(), emitX86ScalarSelect(), emitX86Select(), F, llvm::ConstantAsMetadata::get(), llvm::MDNode::get(), llvm::FixedVectorType::get(), llvm::PoisonValue::get(), llvm::ConstantAggregateZero::get(), llvm::Constant::getAllOnesValue(), llvm::CallBase::getArgOperand(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::getFixedValue(), llvm::Type::getHalfTy(), llvm::IRBuilderBase::getInt16Ty(), llvm::IRBuilderBase::getInt32Ty(), llvm::Type::getInt32Ty(), llvm::Type::getInt64Ty(), llvm::IRBuilderBase::getInt8(), llvm::Instruction::getModule(), llvm::Constant::getNullValue(), getNumElements(), llvm::User::getOperand(), llvm::Intrinsic::getOrInsertDeclaration(), llvm::Type::getPrimitiveSizeInBits(), llvm::Type::getScalarSizeInBits(), llvm::ShuffleVectorInst::getShuffleMask(), llvm::Value::getType(), getType(), llvm::PointerType::getUnqual(), getX86MaskVec(), High, I, llvm::Type::isIntegerTy(), LHS, llvm_unreachable, Name, llvm::Offset, Ptr, llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::Value::replaceAllUsesWith(), RHS, llvm::Instruction::setMetadata(), Size, std::swap(), upgradeAbs(), upgradeAVX512MaskToSelect(), upgradeMaskedCompare(), upgradeMaskedLoad(), upgradeMaskedMove(), upgradeMaskedStore(), upgradeMaskToInt(), upgradePMULDQ(), upgradeX86ALIGNIntrinsics(), upgradeX86BinaryIntrinsics(), upgradeX86ConcatShift(), upgradeX86MaskedShift(), upgradeX86PSLLDQIntrinsics(), upgradeX86PSRLDQIntrinsics(), upgradeX86Rotate(), upgradeX86vpcom(), and upgradeX86VPERMT2Intrinsics().

Referenced by llvm::UpgradeIntrinsicCall().

◆ upgradeX86IntrinsicFunction()

static bool upgradeX86IntrinsicFunction ( Function F,
StringRef  Name,
Function *&  NewFn 
)
static

◆ upgradeX86IntrinsicsWith8BitMask()

static bool upgradeX86IntrinsicsWith8BitMask ( Function F,
Intrinsic::ID  IID,
Function *&  NewFn 
)
static

◆ upgradeX86MaskedFPCompare()

static bool upgradeX86MaskedFPCompare ( Function F,
Intrinsic::ID  IID,
Function *&  NewFn 
)
static

Definition at line 91 of file AutoUpgrade.cpp.

References F, llvm::Intrinsic::getOrInsertDeclaration(), and rename().

Referenced by upgradeX86IntrinsicFunction().

◆ upgradeX86MaskedShift()

static Value * upgradeX86MaskedShift ( IRBuilder<> &  Builder,
CallBase CI,
Intrinsic::ID  IID 
)
static

◆ upgradeX86PSLLDQIntrinsics()

static Value * upgradeX86PSLLDQIntrinsics ( IRBuilder<> &  Builder,
Value Op,
unsigned  Shift 
)
static

◆ upgradeX86PSRLDQIntrinsics()

static Value * upgradeX86PSRLDQIntrinsics ( IRBuilder<> &  Builder,
Value Op,
unsigned  Shift 
)
static

◆ upgradeX86Rotate()

static Value * upgradeX86Rotate ( IRBuilder<> &  Builder,
CallBase CI,
bool  IsRotateRight 
)
static

◆ upgradeX86vpcom()

static Value * upgradeX86vpcom ( IRBuilder<> &  Builder,
CallBase CI,
unsigned  Imm,
bool  IsSigned 
)
static

◆ upgradeX86VPERMT2Intrinsics()

static Value * upgradeX86VPERMT2Intrinsics ( IRBuilder<> &  Builder,
CallBase CI,
bool  ZeroMask,
bool  IndexForm 
)
static

Variable Documentation

◆ DisableAutoUpgradeDebugInfo

cl::opt< bool > DisableAutoUpgradeDebugInfo("disable-auto-upgrade-debug-info", cl::desc("Disable autoupgrade of debug info")) ( "disable-auto-upgrade-debug-info"  ,
cl::desc("Disable autoupgrade of debug info")   
)
static

Referenced by llvm::UpgradeDebugInfo().