@@ -714,12 +714,6 @@ enum class LLVMSafetyContractCoverage {
714714static constexpr llvm::StringLiteral kLythonSafetyMetadataName {" ly.safety" };
715715static constexpr llvm::StringLiteral kLythonSafetyMetadataVersion {
716716 " ly.safety.v1" };
717- // Atomics inside the pre-lowered runtime cache were verified by the full
718- // pipeline when the cache was generated at build time. Their metadata is
719- // sealed to this version so the per-compile verifier can recognize them
720- // without confusing their stale contract ids with the current profile.
721- static constexpr llvm::StringLiteral kLythonRuntimeSafetyMetadataVersion {
722- " ly.safety.runtime.v1" };
723717static constexpr llvm::StringLiteral kPySafetyContractIdAttr {
724718 " py.safety_contract_id" };
725719
@@ -982,21 +976,12 @@ std::optional<int64_t> getLythonSafetyMetadataId(llvm::Instruction &inst) {
982976 return intConstant->getSExtValue ();
983977}
984978
985- bool hasRuntimeVerifiedSafetyMetadata (llvm::Instruction &inst) {
986- llvm::MDNode *node = inst.getMetadata (kLythonSafetyMetadataName );
987- if (!node || node->getNumOperands () < 1 )
988- return false ;
989- auto *version = llvm::dyn_cast<llvm::MDString>(node->getOperand (0 ));
990- return version && version->getString () == kLythonRuntimeSafetyMetadataVersion ;
991- }
992-
993979void collectLinkedLLVMSafetyContracts (llvm::Module &llvmModule,
994980 LLVMSafetyProfile &profile) {
995981 for (llvm::Function &function : llvmModule) {
996982 for (llvm::BasicBlock &block : function) {
997983 for (llvm::Instruction &inst : block) {
998- if (hasRuntimeVerifiedSafetyMetadata (inst) ||
999- getLythonSafetyMetadataId (inst))
984+ if (getLythonSafetyMetadataId (inst))
1000985 continue ;
1001986
1002987 LLVMSafetyContract contract;
@@ -1031,21 +1016,6 @@ void collectLinkedLLVMSafetyContracts(llvm::Module &llvmModule,
10311016 }
10321017}
10331018
1034- // Rewrites the safety metadata of every contracted instruction to the
1035- // runtime-verified version. Called only by the prelower generation run after
1036- // all verifications have passed; the resulting IR is the build-time cache.
1037- void sealRuntimeSafetyMetadata (llvm::Module &llvmModule) {
1038- llvm::LLVMContext &ctx = llvmModule.getContext ();
1039- llvm::Metadata *operands[] = {
1040- llvm::MDString::get (ctx, kLythonRuntimeSafetyMetadataVersion )};
1041- llvm::MDNode *sealed = llvm::MDNode::get (ctx, operands);
1042- for (llvm::Function &function : llvmModule)
1043- for (llvm::BasicBlock &block : function)
1044- for (llvm::Instruction &inst : block)
1045- if (getLythonSafetyMetadataId (inst))
1046- inst.setMetadata (kLythonSafetyMetadataName , sealed);
1047- }
1048-
10491019class PySafetyLLVMIRTranslationInterface final
10501020 : public LLVMTranslationDialectInterface {
10511021public:
@@ -1095,10 +1065,6 @@ LogicalResult verifyLLVMIRSafetyMetadataPreserved(
10951065 for (llvm::Function &function : llvmModule) {
10961066 for (llvm::BasicBlock &block : function) {
10971067 for (llvm::Instruction &inst : block) {
1098- // Instructions from the pre-lowered runtime cache carry sealed
1099- // metadata: their contracts were verified when the cache was built.
1100- if (hasRuntimeVerifiedSafetyMetadata (inst))
1101- continue ;
11021068 auto id = getLythonSafetyMetadataId (inst);
11031069 if (!id) {
11041070 if (auto recovered =
@@ -1679,8 +1645,6 @@ LogicalResult runJIT(ModuleOp module, const py::IRDumpConfig &irDump,
16791645
16801646 llvmModule->setDataLayout (jit->getDataLayout ());
16811647 llvmModule->setTargetTriple (jit->getTargetTriple ().getTriple ());
1682- if (failed (py::runtime_library::linkPrelinkedRuntime (*llvmModule)))
1683- return failure ();
16841648 if (failed (py::runtime_library::linkEmbeddedNativeRuntime (*llvmModule)))
16851649 return failure ();
16861650 collectLinkedLLVMSafetyContracts (*llvmModule, safetyProfile);
@@ -1964,22 +1928,14 @@ int main(int argc, char **argv) {
19641928 if (failed (configureLLVMModuleCodeGenTarget (*llvmModule, tensorTarget)))
19651929 return 1 ;
19661930
1967- if (py::runtime_library::prelowerGenerationMode ()) {
1968- sealRuntimeSafetyMetadata (*llvmModule);
1969- } else {
1970- if (failed (py::runtime_library::linkPrelinkedRuntime (*llvmModule)))
1971- return 1 ;
1972- if (failed (py::runtime_library::linkEmbeddedNativeRuntime (*llvmModule)))
1973- return 1 ;
1974- }
1931+ if (failed (py::runtime_library::linkEmbeddedNativeRuntime (*llvmModule)))
1932+ return 1 ;
19751933 rewriteExceptionPersonalityForTarget (*llvmModule);
19761934
1977- if (!py::runtime_library::prelowerGenerationMode () &&
1978- failed (installAOTEntryPoint (*llvmModule)))
1935+ if (failed (installAOTEntryPoint (*llvmModule)))
19791936 return 1 ;
19801937
1981- if (!py::runtime_library::prelowerGenerationMode ())
1982- collectLinkedLLVMSafetyContracts (*llvmModule, safetyProfile);
1938+ collectLinkedLLVMSafetyContracts (*llvmModule, safetyProfile);
19831939
19841940 if (EmitLLVMOnly)
19851941 return failed (writeLLVMIR (*llvmModule, outputPath)) ? 1 : 0 ;
0 commit comments