|
17 | 17 | #include "llvm/ADT/StringSwitch.h" |
18 | 18 | #include "llvm/BinaryFormat/Dwarf.h" |
19 | 19 | #include "llvm/IR/AttributeMask.h" |
20 | | -#include "llvm/IR/CallingConv.h" |
21 | 20 | #include "llvm/IR/Constants.h" |
22 | 21 | #include "llvm/IR/DebugInfo.h" |
23 | 22 | #include "llvm/IR/DebugInfoMetadata.h" |
@@ -5022,72 +5021,6 @@ bool llvm::UpgradeDebugInfo(Module &M) { |
5022 | 5021 | return Modified; |
5023 | 5022 | } |
5024 | 5023 |
|
5025 | | -bool static upgradeSingleNVVMAnnotation(GlobalValue *GV, StringRef K, |
5026 | | - const Metadata *V) { |
5027 | | - if (K == "kernel") { |
5028 | | - if (!mdconst::extract<ConstantInt>(V)->isZero()) |
5029 | | - cast<Function>(GV)->setCallingConv(CallingConv::PTX_Kernel); |
5030 | | - return true; |
5031 | | - } |
5032 | | - if (K == "align") { |
5033 | | - // V is a bitfeild specifying two 16-bit values. The alignment value is |
5034 | | - // specfied in low 16-bits, The index is specified in the high bits. For the |
5035 | | - // index, 0 indicates the return value while higher values correspond to |
5036 | | - // each parameter (idx = param + 1). |
5037 | | - const uint64_t AlignIdxValuePair = |
5038 | | - mdconst::extract<ConstantInt>(V)->getZExtValue(); |
5039 | | - const unsigned Idx = (AlignIdxValuePair >> 16); |
5040 | | - const Align StackAlign = Align(AlignIdxValuePair & 0xFFFF); |
5041 | | - // TODO: Skip adding the stackalign attribute for returns, for now. |
5042 | | - if (!Idx) |
5043 | | - return false; |
5044 | | - cast<Function>(GV)->addAttributeAtIndex( |
5045 | | - Idx, Attribute::getWithStackAlignment(GV->getContext(), StackAlign)); |
5046 | | - return true; |
5047 | | - } |
5048 | | - |
5049 | | - return false; |
5050 | | -} |
5051 | | - |
5052 | | -void llvm::UpgradeNVVMAnnotations(Module &M) { |
5053 | | - NamedMDNode *NamedMD = M.getNamedMetadata("nvvm.annotations"); |
5054 | | - if (!NamedMD) |
5055 | | - return; |
5056 | | - |
5057 | | - SmallVector<MDNode *, 8> NewNodes; |
5058 | | - SmallSet<const MDNode *, 8> SeenNodes; |
5059 | | - for (MDNode *MD : NamedMD->operands()) { |
5060 | | - if (!SeenNodes.insert(MD).second) |
5061 | | - continue; |
5062 | | - |
5063 | | - auto *GV = mdconst::dyn_extract_or_null<GlobalValue>(MD->getOperand(0)); |
5064 | | - if (!GV) |
5065 | | - continue; |
5066 | | - |
5067 | | - assert((MD->getNumOperands() % 2) == 1 && "Invalid number of operands"); |
5068 | | - |
5069 | | - SmallVector<Metadata *, 8> NewOperands{MD->getOperand(0)}; |
5070 | | - // Each nvvm.annotations metadata entry will be of the following form: |
5071 | | - // !{ ptr @gv, !"key1", value1, !"key2", value2, ... } |
5072 | | - // start index = 1, to skip the global variable key |
5073 | | - // increment = 2, to skip the value for each property-value pairs |
5074 | | - for (unsigned j = 1, je = MD->getNumOperands(); j < je; j += 2) { |
5075 | | - MDString *K = cast<MDString>(MD->getOperand(j)); |
5076 | | - const MDOperand &V = MD->getOperand(j + 1); |
5077 | | - bool Upgraded = upgradeSingleNVVMAnnotation(GV, K->getString(), V); |
5078 | | - if (!Upgraded) |
5079 | | - NewOperands.append({K, V}); |
5080 | | - } |
5081 | | - |
5082 | | - if (NewOperands.size() > 1) |
5083 | | - NewNodes.push_back(MDNode::get(M.getContext(), NewOperands)); |
5084 | | - } |
5085 | | - |
5086 | | - NamedMD->clearOperands(); |
5087 | | - for (MDNode *N : NewNodes) |
5088 | | - NamedMD->addOperand(N); |
5089 | | -} |
5090 | | - |
5091 | 5024 | /// This checks for objc retain release marker which should be upgraded. It |
5092 | 5025 | /// returns true if module is modified. |
5093 | 5026 | static bool upgradeRetainReleaseMarker(Module &M) { |
|
0 commit comments