+static Constant *
+getFunctionData(const Function *F,
+ const LLVMContextImpl::FunctionDataMapTy &Map) {
+ const auto &Entry = Map.find(F);
+ assert(Entry != Map.end());
+ return cast<Constant>(Entry->second->getReturnValue());
+}
+
+/// setFunctionData - Set "Map[F] = Data". Return an updated SubclassData value
+/// in which Bit is low iff Data is null.
+static unsigned setFunctionData(Function *F,
+ LLVMContextImpl::FunctionDataMapTy &Map,
+ Constant *Data, unsigned SCData, unsigned Bit) {
+ ReturnInst *&Holder = Map[F];
+ if (Data) {
+ if (Holder)
+ Holder->setOperand(0, Data);
+ else
+ Holder = ReturnInst::Create(F->getContext(), Data);
+ return SCData | (1 << Bit);
+ } else {
+ delete Holder;
+ Map.erase(F);
+ return SCData & ~(1 << Bit);
+ }
+}
+