1 //===- bolt/Passes/ADRRelaxationPass.h --------------------------*- C++ -*-===// 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 // This file declares the ADRRelaxationPass class, which replaces AArch64 10 // non-local ADR instructions with ADRP + ADD due to small offset range of ADR 11 // instruction (+- 1MB) which could be easily overflowed after BOLT 12 // optimizations. Such problems are usually connected with errata 843419 13 // https://developer.arm.com/documentation/epm048406/2100/ 14 // The linker could replace ADRP instruction with ADR in some cases. 15 // 16 //===----------------------------------------------------------------------===// 17 18 #ifndef BOLT_PASSES_ADRRELAXATIONPASS_H 19 #define BOLT_PASSES_ADRRELAXATIONPASS_H 20 21 #include "bolt/Passes/BinaryPasses.h" 22 23 namespace llvm { 24 namespace bolt { 25 26 class ADRRelaxationPass : public BinaryFunctionPass { 27 public: ADRRelaxationPass()28 explicit ADRRelaxationPass() : BinaryFunctionPass(false) {} 29 getName()30 const char *getName() const override { return "adr-relaxation"; } 31 32 /// Pass entry point 33 void runOnFunctions(BinaryContext &BC) override; 34 void runOnFunction(BinaryFunction &BF); 35 }; 36 37 } // namespace bolt 38 } // namespace llvm 39 40 #endif 41