for (auto &MBB : MF) { for (auto &MI : MBB) { int opcode = MI.getOpcode(); // do something with opcode } }
for (auto &BB : F) { for (auto &I : BB) { if (auto *MI = dyn_castThis code snippet is another example of using the getOpcode function to traverse blocks and retrieve the opcode of a machine instruction. This code is likely from the machine code generation package in the LLVM library.(&I)) { int opcode = MI->getOpcode(); // do something with opcode } } }