1 //===- StripDebugInfo.cpp - Pass to strip debug information ---------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #include "PassDetail.h" 10 #include "mlir/IR/Function.h" 11 #include "mlir/IR/Operation.h" 12 #include "mlir/Pass/Pass.h" 13 #include "mlir/Transforms/Passes.h" 14 15 using namespace mlir; 16 17 namespace { 18 struct StripDebugInfo : public StripDebugInfoBase<StripDebugInfo> { 19 void runOnOperation() override; 20 }; 21 } // end anonymous namespace 22 runOnOperation()23void StripDebugInfo::runOnOperation() { 24 // Strip the debug info from all operations. 25 auto unknownLoc = UnknownLoc::get(&getContext()); 26 getOperation()->walk([&](Operation *op) { op->setLoc(unknownLoc); }); 27 } 28 29 /// Creates a pass to strip debug information from a function. createStripDebugInfoPass()30std::unique_ptr<Pass> mlir::createStripDebugInfoPass() { 31 return std::make_unique<StripDebugInfo>(); 32 } 33