Index: lib/IR/MDBuilder.cpp =================================================================== --- lib/IR/MDBuilder.cpp +++ lib/IR/MDBuilder.cpp @@ -62,12 +62,19 @@ SmallVector Ops; Ops.push_back(createString("function_entry_count")); Ops.push_back(createConstant(ConstantInt::get(Int64Ty, Count))); - if (Imports) - for (auto ID : *Imports) + if (Imports) { + SmallVector OrderID(Imports->begin(), Imports->end()); + std::stable_sort(OrderID.begin(), OrderID.end(), + [] (GlobalValue::GUID A, GlobalValue::GUID B) { + return A < B;}); + for (auto ID : OrderID) { Ops.push_back(createConstant(ConstantInt::get(Int64Ty, ID))); + } + } return MDNode::get(Context, Ops); } + MDNode *MDBuilder::createFunctionSectionPrefix(StringRef Prefix) { return MDNode::get(Context, {createString("function_section_prefix"),