diff --git a/llvm/include/llvm/CodeGen/MachineInstr.h b/llvm/include/llvm/CodeGen/MachineInstr.h --- a/llvm/include/llvm/CodeGen/MachineInstr.h +++ b/llvm/include/llvm/CodeGen/MachineInstr.h @@ -923,6 +923,8 @@ /// For example, if the instruction has a unique labels attached /// to it, duplicating it would cause multiple definition errors. bool isNotDuplicable(QueryType Type = AnyInBundle) const { + if (getPreInstrSymbol() || getPostInstrSymbol()) + return true; return hasProperty(MCID::NotDuplicable, Type); } diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -630,6 +630,11 @@ if (getDebugLoc() && Other.getDebugLoc() && getDebugLoc() != Other.getDebugLoc()) return false; + // If pre- or post-instruction symbols do not match then the two instructions + // are not identical. + if (getPreInstrSymbol() != Other.getPreInstrSymbol() || + getPostInstrSymbol() != Other.getPostInstrSymbol()) + return false; return true; } diff --git a/llvm/lib/Target/RISCV/RISCV.h b/llvm/lib/Target/RISCV/RISCV.h --- a/llvm/lib/Target/RISCV/RISCV.h +++ b/llvm/lib/Target/RISCV/RISCV.h @@ -56,6 +56,9 @@ FunctionPass *createRISCVExpandPseudoPass(); void initializeRISCVExpandPseudoPass(PassRegistry &); +FunctionPass *createRISCVPreRAExpandPseudoPass(); +void initializeRISCVPreRAExpandPseudoPass(PassRegistry &); + FunctionPass *createRISCVExpandAtomicPseudoPass(); void initializeRISCVExpandAtomicPseudoPass(PassRegistry &); diff --git a/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp b/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp --- a/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp +++ b/llvm/lib/Target/RISCV/RISCVExpandPseudoInsts.cpp @@ -19,10 +19,12 @@ #include "llvm/CodeGen/LivePhysRegs.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +#include "llvm/MC/MCContext.h" using namespace llvm; #define RISCV_EXPAND_PSEUDO_NAME "RISCV pseudo instruction expansion pass" +#define RISCV_PRERA_EXPAND_PSEUDO_NAME "RISCV Pre-RA pseudo instruction expansion pass" namespace { @@ -47,18 +49,6 @@ MachineBasicBlock::iterator MBBI, MachineBasicBlock::iterator &NextMBBI, unsigned FlagsHi, unsigned SecondOpcode); - bool expandLoadLocalAddress(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI); - bool expandLoadAddress(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI); - bool expandLoadTLSIEAddress(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI); - bool expandLoadTLSGDAddress(MachineBasicBlock &MBB, - MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI); bool expandVSetVL(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI); bool expandVMSET_VMCLR(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned Opcode); @@ -96,14 +86,6 @@ // expanded instructions for each pseudo is correct in the Size field of the // tablegen definition for the pseudo. switch (MBBI->getOpcode()) { - case RISCV::PseudoLLA: - return expandLoadLocalAddress(MBB, MBBI, NextMBBI); - case RISCV::PseudoLA: - return expandLoadAddress(MBB, MBBI, NextMBBI); - case RISCV::PseudoLA_TLS_IE: - return expandLoadTLSIEAddress(MBB, MBBI, NextMBBI); - case RISCV::PseudoLA_TLS_GD: - return expandLoadTLSGDAddress(MBB, MBBI, NextMBBI); case RISCV::PseudoVSETVLI: case RISCV::PseudoVSETVLIX0: case RISCV::PseudoVSETIVLI: @@ -196,49 +178,6 @@ return true; } -bool RISCVExpandPseudo::expandLoadLocalAddress( - MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI) { - return expandAuipcInstPair(MBB, MBBI, NextMBBI, RISCVII::MO_PCREL_HI, - RISCV::ADDI); -} - -bool RISCVExpandPseudo::expandLoadAddress( - MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI) { - MachineFunction *MF = MBB.getParent(); - - unsigned SecondOpcode; - unsigned FlagsHi; - if (MF->getTarget().isPositionIndependent()) { - const auto &STI = MF->getSubtarget(); - SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW; - FlagsHi = RISCVII::MO_GOT_HI; - } else { - SecondOpcode = RISCV::ADDI; - FlagsHi = RISCVII::MO_PCREL_HI; - } - return expandAuipcInstPair(MBB, MBBI, NextMBBI, FlagsHi, SecondOpcode); -} - -bool RISCVExpandPseudo::expandLoadTLSIEAddress( - MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI) { - MachineFunction *MF = MBB.getParent(); - - const auto &STI = MF->getSubtarget(); - unsigned SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW; - return expandAuipcInstPair(MBB, MBBI, NextMBBI, RISCVII::MO_TLS_GOT_HI, - SecondOpcode); -} - -bool RISCVExpandPseudo::expandLoadTLSGDAddress( - MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, - MachineBasicBlock::iterator &NextMBBI) { - return expandAuipcInstPair(MBB, MBBI, NextMBBI, RISCVII::MO_TLS_GD_HI, - RISCV::ADDI); -} - bool RISCVExpandPseudo::expandVSetVL(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) { assert(MBBI->getNumExplicitOperands() == 3 && MBBI->getNumOperands() >= 5 && @@ -377,12 +316,169 @@ return true; } +class RISCVPreRAExpandPseudo : public MachineFunctionPass { +public: + const RISCVInstrInfo *TII; + static char ID; + + RISCVPreRAExpandPseudo() : MachineFunctionPass(ID) { + initializeRISCVPreRAExpandPseudoPass(*PassRegistry::getPassRegistry()); + } + + bool runOnMachineFunction(MachineFunction &MF) override; + + void getAnalysisUsage(AnalysisUsage &AU) const override { + AU.setPreservesCFG(); + MachineFunctionPass::getAnalysisUsage(AU); + } + StringRef getPassName() const override { + return RISCV_PRERA_EXPAND_PSEUDO_NAME; + } + +private: + bool expandMBB(MachineBasicBlock &MBB); + bool expandMI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI); + bool expandAuipcInstPair(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI, + unsigned FlagsHi, unsigned SecondOpcode); + bool expandLoadLocalAddress(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI); + bool expandLoadAddress(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI); + bool expandLoadTLSIEAddress(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI); + bool expandLoadTLSGDAddress(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI); +}; + +char RISCVPreRAExpandPseudo::ID = 0; + +bool RISCVPreRAExpandPseudo::runOnMachineFunction(MachineFunction &MF) { + TII = static_cast(MF.getSubtarget().getInstrInfo()); + bool Modified = false; + for (auto &MBB : MF) + Modified |= expandMBB(MBB); + return Modified; +} + +bool RISCVPreRAExpandPseudo::expandMBB(MachineBasicBlock &MBB) { + bool Modified = false; + + MachineBasicBlock::iterator MBBI = MBB.begin(), E = MBB.end(); + while (MBBI != E) { + MachineBasicBlock::iterator NMBBI = std::next(MBBI); + Modified |= expandMI(MBB, MBBI, NMBBI); + MBBI = NMBBI; + } + + return Modified; +} + +bool RISCVPreRAExpandPseudo::expandMI(MachineBasicBlock &MBB, + MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI) { + + switch (MBBI->getOpcode()) { + case RISCV::PseudoLLA: + return expandLoadLocalAddress(MBB, MBBI, NextMBBI); + case RISCV::PseudoLA: + return expandLoadAddress(MBB, MBBI, NextMBBI); + case RISCV::PseudoLA_TLS_IE: + return expandLoadTLSIEAddress(MBB, MBBI, NextMBBI); + case RISCV::PseudoLA_TLS_GD: + return expandLoadTLSGDAddress(MBB, MBBI, NextMBBI); + } + return false; +} + +bool RISCVPreRAExpandPseudo::expandAuipcInstPair( + MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI, unsigned FlagsHi, + unsigned SecondOpcode) { + MachineFunction *MF = MBB.getParent(); + MachineInstr &MI = *MBBI; + DebugLoc DL = MI.getDebugLoc(); + + Register DestReg = MI.getOperand(0).getReg(); + Register ScratchReg = + MF->getRegInfo().createVirtualRegister(&RISCV::GPRRegClass); + + MachineOperand &Symbol = MI.getOperand(1); + Symbol.setTargetFlags(FlagsHi); + MCSymbol *AUIPCSymbol = MF->getContext().createNamedTempSymbol("pcrel_hi"); + + MachineInstr *MIAUIPC = + BuildMI(MBB, MBBI, DL, TII->get(RISCV::AUIPC), ScratchReg).add(Symbol); + MIAUIPC->setPreInstrSymbol(*MF, AUIPCSymbol); + + BuildMI(MBB, MBBI, DL, TII->get(SecondOpcode), DestReg) + .addReg(ScratchReg) + .addSym(AUIPCSymbol, RISCVII::MO_PCREL_LO); + + MI.eraseFromParent(); + return true; +} + +bool RISCVPreRAExpandPseudo::expandLoadLocalAddress( + MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI) { + return expandAuipcInstPair(MBB, MBBI, NextMBBI, RISCVII::MO_PCREL_HI, + RISCV::ADDI); +} + +bool RISCVPreRAExpandPseudo::expandLoadAddress( + MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI) { + MachineFunction *MF = MBB.getParent(); + + unsigned SecondOpcode; + unsigned FlagsHi; + if (MF->getTarget().isPositionIndependent()) { + const auto &STI = MF->getSubtarget(); + SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW; + FlagsHi = RISCVII::MO_GOT_HI; + } else { + SecondOpcode = RISCV::ADDI; + FlagsHi = RISCVII::MO_PCREL_HI; + } + return expandAuipcInstPair(MBB, MBBI, NextMBBI, FlagsHi, SecondOpcode); +} + +bool RISCVPreRAExpandPseudo::expandLoadTLSIEAddress( + MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI) { + MachineFunction *MF = MBB.getParent(); + + const auto &STI = MF->getSubtarget(); + unsigned SecondOpcode = STI.is64Bit() ? RISCV::LD : RISCV::LW; + return expandAuipcInstPair(MBB, MBBI, NextMBBI, RISCVII::MO_TLS_GOT_HI, + SecondOpcode); +} + +bool RISCVPreRAExpandPseudo::expandLoadTLSGDAddress( + MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, + MachineBasicBlock::iterator &NextMBBI) { + return expandAuipcInstPair(MBB, MBBI, NextMBBI, RISCVII::MO_TLS_GD_HI, + RISCV::ADDI); +} + } // end of anonymous namespace INITIALIZE_PASS(RISCVExpandPseudo, "riscv-expand-pseudo", RISCV_EXPAND_PSEUDO_NAME, false, false) + +INITIALIZE_PASS(RISCVPreRAExpandPseudo, "riscv-prera-expand-pseudo", + RISCV_PRERA_EXPAND_PSEUDO_NAME, false, false) + namespace llvm { FunctionPass *createRISCVExpandPseudoPass() { return new RISCVExpandPseudo(); } +FunctionPass *createRISCVPreRAExpandPseudoPass() { return new RISCVPreRAExpandPseudo(); } } // end of namespace llvm diff --git a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp --- a/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp +++ b/llvm/lib/Target/RISCV/RISCVMCInstLower.cpp @@ -125,6 +125,9 @@ case MachineOperand::MO_JumpTableIndex: MCOp = lowerSymbolOperand(MO, AP.GetJTISymbol(MO.getIndex()), AP); break; + case MachineOperand::MO_MCSymbol: + MCOp = lowerSymbolOperand(MO, MO.getMCSymbol(), AP); + break; } return true; } diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -253,6 +253,7 @@ if (TM->getTargetTriple().getArch() == Triple::riscv64) addPass(createRISCVSExtWRemovalPass()); + addPass(createRISCVPreRAExpandPseudoPass()); } void RISCVPassConfig::addPreRegAlloc() { diff --git a/llvm/test/CodeGen/RISCV/O3-pipeline.ll b/llvm/test/CodeGen/RISCV/O3-pipeline.ll --- a/llvm/test/CodeGen/RISCV/O3-pipeline.ll +++ b/llvm/test/CodeGen/RISCV/O3-pipeline.ll @@ -96,6 +96,7 @@ ; CHECK-NEXT: Peephole Optimizations ; CHECK-NEXT: Remove dead machine instructions ; RV64-NEXT: RISCV sext.w Removal +; CHECK-NEXT: RISCV Pre-RA pseudo instruction expansion pass ; CHECK-NEXT: RISCV Merge Base Offset ; CHECK-NEXT: RISCV Insert VSETVLI pass ; CHECK-NEXT: Detect Dead Lanes diff --git a/llvm/test/CodeGen/RISCV/codemodel-lowering.ll b/llvm/test/CodeGen/RISCV/codemodel-lowering.ll --- a/llvm/test/CodeGen/RISCV/codemodel-lowering.ll +++ b/llvm/test/CodeGen/RISCV/codemodel-lowering.ll @@ -16,9 +16,9 @@ ; ; RV32I-MEDIUM-LABEL: lower_global: ; RV32I-MEDIUM: # %bb.0: -; RV32I-MEDIUM-NEXT: .LBB0_1: # Label of block must be emitted +; RV32I-MEDIUM-NEXT: .Lpcrel_hi0: ; RV32I-MEDIUM-NEXT: auipc a0, %pcrel_hi(G) -; RV32I-MEDIUM-NEXT: addi a0, a0, %pcrel_lo(.LBB0_1) +; RV32I-MEDIUM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0) ; RV32I-MEDIUM-NEXT: lw a0, 0(a0) ; RV32I-MEDIUM-NEXT: ret %1 = load volatile i32, i32* @G @@ -39,9 +39,9 @@ ; ; RV32I-MEDIUM-LABEL: lower_blockaddress: ; RV32I-MEDIUM: # %bb.0: -; RV32I-MEDIUM-NEXT: .LBB1_1: # Label of block must be emitted +; RV32I-MEDIUM-NEXT: .Lpcrel_hi1: ; RV32I-MEDIUM-NEXT: auipc a0, %pcrel_hi(addr) -; RV32I-MEDIUM-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV32I-MEDIUM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV32I-MEDIUM-NEXT: li a1, 1 ; RV32I-MEDIUM-NEXT: sw a1, 0(a0) ; RV32I-MEDIUM-NEXT: ret @@ -79,10 +79,9 @@ ; RV32I-MEDIUM-LABEL: lower_blockaddress_displ: ; RV32I-MEDIUM: # %bb.0: # %entry ; RV32I-MEDIUM-NEXT: addi sp, sp, -16 -; RV32I-MEDIUM-NEXT: .LBB2_4: # %entry -; RV32I-MEDIUM-NEXT: # Label of block must be emitted +; RV32I-MEDIUM-NEXT: .Lpcrel_hi2: ; RV32I-MEDIUM-NEXT: auipc a1, %pcrel_hi(.Ltmp0) -; RV32I-MEDIUM-NEXT: addi a1, a1, %pcrel_lo(.LBB2_4) +; RV32I-MEDIUM-NEXT: addi a1, a1, %pcrel_lo(.Lpcrel_hi2) ; RV32I-MEDIUM-NEXT: li a2, 101 ; RV32I-MEDIUM-NEXT: sw a1, 8(sp) ; RV32I-MEDIUM-NEXT: blt a0, a2, .LBB2_3 @@ -134,9 +133,9 @@ ; ; RV32I-MEDIUM-LABEL: lower_constantpool: ; RV32I-MEDIUM: # %bb.0: -; RV32I-MEDIUM-NEXT: .LBB3_1: # Label of block must be emitted +; RV32I-MEDIUM-NEXT: .Lpcrel_hi3: ; RV32I-MEDIUM-NEXT: auipc a0, %pcrel_hi(.LCPI3_0) -; RV32I-MEDIUM-NEXT: addi a0, a0, %pcrel_lo(.LBB3_1) +; RV32I-MEDIUM-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi3) ; RV32I-MEDIUM-NEXT: flw ft0, 0(a0) ; RV32I-MEDIUM-NEXT: fadd.s fa0, fa0, ft0 ; RV32I-MEDIUM-NEXT: ret diff --git a/llvm/test/CodeGen/RISCV/elf-preemption.ll b/llvm/test/CodeGen/RISCV/elf-preemption.ll --- a/llvm/test/CodeGen/RISCV/elf-preemption.ll +++ b/llvm/test/CodeGen/RISCV/elf-preemption.ll @@ -18,9 +18,9 @@ ; ; RV32-PIC-LABEL: get_preemptable_var: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB0_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi0: ; RV32-PIC-NEXT: auipc a0, %got_pcrel_hi(preemptable_var) -; RV32-PIC-NEXT: lw a0, %pcrel_lo(.LBB0_1)(a0) +; RV32-PIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: get_preemptable_var: @@ -31,9 +31,9 @@ ; ; RV64-PIC-LABEL: get_preemptable_var: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB0_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi0: ; RV64-PIC-NEXT: auipc a0, %got_pcrel_hi(preemptable_var) -; RV64-PIC-NEXT: ld a0, %pcrel_lo(.LBB0_1)(a0) +; RV64-PIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0) ; RV64-PIC-NEXT: ret ret i32* @preemptable_var } @@ -48,9 +48,9 @@ ; ; RV32-PIC-LABEL: get_dsolocal_var: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB1_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi1: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(.Ldsolocal_var$local) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: get_dsolocal_var: @@ -61,9 +61,9 @@ ; ; RV64-PIC-LABEL: get_dsolocal_var: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB1_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi1: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(.Ldsolocal_var$local) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV64-PIC-NEXT: ret ret i32* @dsolocal_var } @@ -78,9 +78,9 @@ ; ; RV32-PIC-LABEL: get_weak_dsolocal_var: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB2_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi2: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(weak_dsolocal_var) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB2_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi2) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: get_weak_dsolocal_var: @@ -91,9 +91,9 @@ ; ; RV64-PIC-LABEL: get_weak_dsolocal_var: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB2_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi2: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(weak_dsolocal_var) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB2_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi2) ; RV64-PIC-NEXT: ret ret i32* @weak_dsolocal_var } @@ -108,9 +108,9 @@ ; ; RV32-PIC-LABEL: get_hidden_var: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB3_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi3: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(hidden_var) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB3_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi3) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: get_hidden_var: @@ -121,9 +121,9 @@ ; ; RV64-PIC-LABEL: get_hidden_var: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB3_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi3: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(hidden_var) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB3_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi3) ; RV64-PIC-NEXT: ret ret i32* @hidden_var } @@ -138,9 +138,9 @@ ; ; RV32-PIC-LABEL: get_protected_var: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB4_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi4: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(protected_var) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB4_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi4) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: get_protected_var: @@ -151,9 +151,9 @@ ; ; RV64-PIC-LABEL: get_protected_var: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB4_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi4: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(protected_var) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB4_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi4) ; RV64-PIC-NEXT: ret ret i32* @protected_var } @@ -167,9 +167,9 @@ ; ; RV32-PIC-LABEL: preemptable_func: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB5_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi5: ; RV32-PIC-NEXT: auipc a0, %got_pcrel_hi(preemptable_func) -; RV32-PIC-NEXT: lw a0, %pcrel_lo(.LBB5_1)(a0) +; RV32-PIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi5)(a0) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: preemptable_func: @@ -180,9 +180,9 @@ ; ; RV64-PIC-LABEL: preemptable_func: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB5_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi5: ; RV64-PIC-NEXT: auipc a0, %got_pcrel_hi(preemptable_func) -; RV64-PIC-NEXT: ld a0, %pcrel_lo(.LBB5_1)(a0) +; RV64-PIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi5)(a0) ; RV64-PIC-NEXT: ret ret void()* bitcast(void()*()* @preemptable_func to void()*) } @@ -196,9 +196,9 @@ ; ; RV32-PIC-LABEL: dsolocal_func: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB6_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi6: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(.Ldsolocal_func$local) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB6_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi6) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: dsolocal_func: @@ -209,9 +209,9 @@ ; ; RV64-PIC-LABEL: dsolocal_func: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB6_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi6: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(.Ldsolocal_func$local) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB6_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi6) ; RV64-PIC-NEXT: ret ret void()* bitcast(void()*()* @dsolocal_func to void()*) } @@ -225,9 +225,9 @@ ; ; RV32-PIC-LABEL: weak_dsolocal_func: ; RV32-PIC: # %bb.0: -; RV32-PIC-NEXT: .LBB7_1: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi7: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(weak_dsolocal_func) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB7_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi7) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: weak_dsolocal_func: @@ -238,9 +238,9 @@ ; ; RV64-PIC-LABEL: weak_dsolocal_func: ; RV64-PIC: # %bb.0: -; RV64-PIC-NEXT: .LBB7_1: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi7: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(weak_dsolocal_func) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB7_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi7) ; RV64-PIC-NEXT: ret ret void()* bitcast(void()*()* @weak_dsolocal_func to void()*) } diff --git a/llvm/test/CodeGen/RISCV/jumptable.ll b/llvm/test/CodeGen/RISCV/jumptable.ll --- a/llvm/test/CodeGen/RISCV/jumptable.ll +++ b/llvm/test/CodeGen/RISCV/jumptable.ll @@ -203,10 +203,9 @@ ; RV32I-MEDIUM-NEXT: bltu a2, a0, .LBB1_9 ; RV32I-MEDIUM-NEXT: # %bb.1: # %entry ; RV32I-MEDIUM-NEXT: slli a0, a0, 2 -; RV32I-MEDIUM-NEXT: .LBB1_10: # %entry -; RV32I-MEDIUM-NEXT: # Label of block must be emitted +; RV32I-MEDIUM-NEXT: .Lpcrel_hi0: ; RV32I-MEDIUM-NEXT: auipc a2, %pcrel_hi(.LJTI1_0) -; RV32I-MEDIUM-NEXT: addi a2, a2, %pcrel_lo(.LBB1_10) +; RV32I-MEDIUM-NEXT: addi a2, a2, %pcrel_lo(.Lpcrel_hi0) ; RV32I-MEDIUM-NEXT: add a0, a0, a2 ; RV32I-MEDIUM-NEXT: lw a0, 0(a0) ; RV32I-MEDIUM-NEXT: jr a0 @@ -275,10 +274,9 @@ ; RV64I-MEDIUM-NEXT: bltu a2, a0, .LBB1_9 ; RV64I-MEDIUM-NEXT: # %bb.1: # %entry ; RV64I-MEDIUM-NEXT: slli a0, a0, 3 -; RV64I-MEDIUM-NEXT: .LBB1_10: # %entry -; RV64I-MEDIUM-NEXT: # Label of block must be emitted +; RV64I-MEDIUM-NEXT: .Lpcrel_hi0: ; RV64I-MEDIUM-NEXT: auipc a2, %pcrel_hi(.LJTI1_0) -; RV64I-MEDIUM-NEXT: addi a2, a2, %pcrel_lo(.LBB1_10) +; RV64I-MEDIUM-NEXT: addi a2, a2, %pcrel_lo(.Lpcrel_hi0) ; RV64I-MEDIUM-NEXT: add a0, a0, a2 ; RV64I-MEDIUM-NEXT: ld a0, 0(a0) ; RV64I-MEDIUM-NEXT: jr a0 diff --git a/llvm/test/CodeGen/RISCV/machinelicm-address-pseudos.ll b/llvm/test/CodeGen/RISCV/machinelicm-address-pseudos.ll --- a/llvm/test/CodeGen/RISCV/machinelicm-address-pseudos.ll +++ b/llvm/test/CodeGen/RISCV/machinelicm-address-pseudos.ll @@ -12,10 +12,9 @@ ; RV32I-LABEL: test_lla: ; RV32I: # %bb.0: # %entry ; RV32I-NEXT: li a1, 0 -; RV32I-NEXT: .LBB0_3: # %entry -; RV32I-NEXT: # Label of block must be emitted +; RV32I-NEXT: .Lpcrel_hi0: ; RV32I-NEXT: auipc a2, %pcrel_hi(l) -; RV32I-NEXT: addi a2, a2, %pcrel_lo(.LBB0_3) +; RV32I-NEXT: addi a2, a2, %pcrel_lo(.Lpcrel_hi0) ; RV32I-NEXT: .LBB0_1: # %loop ; RV32I-NEXT: # =>This Inner Loop Header: Depth=1 ; RV32I-NEXT: lw a3, 0(a2) @@ -27,10 +26,9 @@ ; RV64I-LABEL: test_lla: ; RV64I: # %bb.0: # %entry ; RV64I-NEXT: li a1, 0 -; RV64I-NEXT: .LBB0_3: # %entry -; RV64I-NEXT: # Label of block must be emitted +; RV64I-NEXT: .Lpcrel_hi0: ; RV64I-NEXT: auipc a2, %pcrel_hi(l) -; RV64I-NEXT: addi a2, a2, %pcrel_lo(.LBB0_3) +; RV64I-NEXT: addi a2, a2, %pcrel_lo(.Lpcrel_hi0) ; RV64I-NEXT: .LBB0_1: # %loop ; RV64I-NEXT: # =>This Inner Loop Header: Depth=1 ; RV64I-NEXT: lw a3, 0(a2) @@ -57,10 +55,9 @@ define void @test_la(i32 signext %n) { ; RV32I-LABEL: test_la: ; RV32I: # %bb.0: # %entry -; RV32I-NEXT: .LBB1_3: # %entry -; RV32I-NEXT: # Label of block must be emitted +; RV32I-NEXT: .Lpcrel_hi1: ; RV32I-NEXT: auipc a1, %got_pcrel_hi(g) -; RV32I-NEXT: lw a1, %pcrel_lo(.LBB1_3)(a1) +; RV32I-NEXT: lw a1, %pcrel_lo(.Lpcrel_hi1)(a1) ; RV32I-NEXT: li a2, 0 ; RV32I-NEXT: .LBB1_1: # %loop ; RV32I-NEXT: # =>This Inner Loop Header: Depth=1 @@ -72,10 +69,9 @@ ; ; RV64I-LABEL: test_la: ; RV64I: # %bb.0: # %entry -; RV64I-NEXT: .LBB1_3: # %entry -; RV64I-NEXT: # Label of block must be emitted +; RV64I-NEXT: .Lpcrel_hi1: ; RV64I-NEXT: auipc a1, %got_pcrel_hi(g) -; RV64I-NEXT: ld a1, %pcrel_lo(.LBB1_3)(a1) +; RV64I-NEXT: ld a1, %pcrel_lo(.Lpcrel_hi1)(a1) ; RV64I-NEXT: li a2, 0 ; RV64I-NEXT: .LBB1_1: # %loop ; RV64I-NEXT: # =>This Inner Loop Header: Depth=1 @@ -103,10 +99,9 @@ define void @test_la_tls_ie(i32 signext %n) { ; RV32I-LABEL: test_la_tls_ie: ; RV32I: # %bb.0: # %entry -; RV32I-NEXT: .LBB2_3: # %entry -; RV32I-NEXT: # Label of block must be emitted -; RV32I-NEXT: auipc a2, %tls_ie_pcrel_hi(ie) -; RV32I-NEXT: lw a2, %pcrel_lo(.LBB2_3)(a2) +; RV32I-NEXT: .Lpcrel_hi2: +; RV32I-NEXT: auipc a1, %tls_ie_pcrel_hi(ie) +; RV32I-NEXT: lw a2, %pcrel_lo(.Lpcrel_hi2)(a1) ; RV32I-NEXT: li a1, 0 ; RV32I-NEXT: add a2, a2, tp ; RV32I-NEXT: .LBB2_1: # %loop @@ -119,10 +114,9 @@ ; ; RV64I-LABEL: test_la_tls_ie: ; RV64I: # %bb.0: # %entry -; RV64I-NEXT: .LBB2_3: # %entry -; RV64I-NEXT: # Label of block must be emitted -; RV64I-NEXT: auipc a2, %tls_ie_pcrel_hi(ie) -; RV64I-NEXT: ld a2, %pcrel_lo(.LBB2_3)(a2) +; RV64I-NEXT: .Lpcrel_hi2: +; RV64I-NEXT: auipc a1, %tls_ie_pcrel_hi(ie) +; RV64I-NEXT: ld a2, %pcrel_lo(.Lpcrel_hi2)(a1) ; RV64I-NEXT: li a1, 0 ; RV64I-NEXT: add a2, a2, tp ; RV64I-NEXT: .LBB2_1: # %loop @@ -158,10 +152,9 @@ ; RV32I-NEXT: sw s2, 0(sp) # 4-byte Folded Spill ; RV32I-NEXT: mv s0, a0 ; RV32I-NEXT: li s2, 0 -; RV32I-NEXT: .LBB3_3: # %entry -; RV32I-NEXT: # Label of block must be emitted -; RV32I-NEXT: auipc s1, %tls_gd_pcrel_hi(gd) -; RV32I-NEXT: addi s1, s1, %pcrel_lo(.LBB3_3) +; RV32I-NEXT: .Lpcrel_hi3: +; RV32I-NEXT: auipc a0, %tls_gd_pcrel_hi(gd) +; RV32I-NEXT: addi s1, a0, %pcrel_lo(.Lpcrel_hi3) ; RV32I-NEXT: .LBB3_1: # %loop ; RV32I-NEXT: # =>This Inner Loop Header: Depth=1 ; RV32I-NEXT: mv a0, s1 @@ -186,10 +179,9 @@ ; RV64I-NEXT: sd s2, 0(sp) # 8-byte Folded Spill ; RV64I-NEXT: mv s0, a0 ; RV64I-NEXT: li s2, 0 -; RV64I-NEXT: .LBB3_3: # %entry -; RV64I-NEXT: # Label of block must be emitted -; RV64I-NEXT: auipc s1, %tls_gd_pcrel_hi(gd) -; RV64I-NEXT: addi s1, s1, %pcrel_lo(.LBB3_3) +; RV64I-NEXT: .Lpcrel_hi3: +; RV64I-NEXT: auipc a0, %tls_gd_pcrel_hi(gd) +; RV64I-NEXT: addi s1, a0, %pcrel_lo(.Lpcrel_hi3) ; RV64I-NEXT: .LBB3_1: # %loop ; RV64I-NEXT: # =>This Inner Loop Header: Depth=1 ; RV64I-NEXT: mv a0, s1 diff --git a/llvm/test/CodeGen/RISCV/mir-target-flags.ll b/llvm/test/CodeGen/RISCV/mir-target-flags.ll --- a/llvm/test/CodeGen/RISCV/mir-target-flags.ll +++ b/llvm/test/CodeGen/RISCV/mir-target-flags.ll @@ -24,14 +24,14 @@ ; RV32-SMALL-LABEL: name: caller ; RV32-SMALL: target-flags(riscv-hi) @g_e ; RV32-SMALL-NEXT: target-flags(riscv-lo) @g_e -; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_un -; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) %bb.1 ; RV32-SMALL: target-flags(riscv-hi) @g_i ; RV32-SMALL-NEXT: target-flags(riscv-lo) @g_i +; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_un +; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) ; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_ld -; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) %bb.2 +; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) ; RV32-SMALL: target-flags(riscv-tls-got-hi) @t_ie -; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) %bb.3 +; RV32-SMALL-NEXT: target-flags(riscv-pcrel-lo) ; RV32-SMALL: target-flags(riscv-tprel-hi) @t_le ; RV32-SMALL-NEXT: target-flags(riscv-tprel-add) @t_le ; RV32-SMALL-NEXT: target-flags(riscv-tprel-lo) @t_le @@ -39,17 +39,17 @@ ; ; RV32-MED-LABEL: name: caller ; RV32-MED: target-flags(riscv-got-hi) @g_e -; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) %bb.1 +; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) ; RV32-MED: target-flags(riscv-pcrel-hi) @g_i -; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) %bb.2 +; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) ; RV32-MED: target-flags(riscv-tls-gd-hi) @t_un -; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) %bb.3 +; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) ; RV32-MED-NEXT: target-flags(riscv-plt) &__tls_get_addr ; RV32-MED: target-flags(riscv-tls-gd-hi) @t_ld -; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) %bb.4 +; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) ; RV32-MED-NEXT: target-flags(riscv-plt) &__tls_get_addr ; RV32-MED: target-flags(riscv-tls-got-hi) @t_ie -; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) %bb.5 +; RV32-MED-NEXT: target-flags(riscv-pcrel-lo) ; RV32-MED: target-flags(riscv-tprel-hi) @t_le ; RV32-MED-NEXT: target-flags(riscv-tprel-add) @t_le ; RV32-MED-NEXT: target-flags(riscv-tprel-lo) @t_le diff --git a/llvm/test/CodeGen/RISCV/pic-models.ll b/llvm/test/CodeGen/RISCV/pic-models.ll --- a/llvm/test/CodeGen/RISCV/pic-models.ll +++ b/llvm/test/CodeGen/RISCV/pic-models.ll @@ -26,10 +26,9 @@ ; ; RV32-PIC-LABEL: f1: ; RV32-PIC: # %bb.0: # %entry -; RV32-PIC-NEXT: .LBB0_1: # %entry -; RV32-PIC-NEXT: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi0: ; RV32-PIC-NEXT: auipc a0, %got_pcrel_hi(external_var) -; RV32-PIC-NEXT: lw a0, %pcrel_lo(.LBB0_1)(a0) +; RV32-PIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: f1: @@ -40,10 +39,9 @@ ; ; RV64-PIC-LABEL: f1: ; RV64-PIC: # %bb.0: # %entry -; RV64-PIC-NEXT: .LBB0_1: # %entry -; RV64-PIC-NEXT: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi0: ; RV64-PIC-NEXT: auipc a0, %got_pcrel_hi(external_var) -; RV64-PIC-NEXT: ld a0, %pcrel_lo(.LBB0_1)(a0) +; RV64-PIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0) ; RV64-PIC-NEXT: ret entry: ret i32* @external_var @@ -61,10 +59,9 @@ ; ; RV32-PIC-LABEL: f2: ; RV32-PIC: # %bb.0: # %entry -; RV32-PIC-NEXT: .LBB1_1: # %entry -; RV32-PIC-NEXT: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi1: ; RV32-PIC-NEXT: auipc a0, %pcrel_hi(internal_var) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV32-PIC-NEXT: ret ; ; RV64-STATIC-LABEL: f2: @@ -75,10 +72,9 @@ ; ; RV64-PIC-LABEL: f2: ; RV64-PIC: # %bb.0: # %entry -; RV64-PIC-NEXT: .LBB1_1: # %entry -; RV64-PIC-NEXT: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi1: ; RV64-PIC-NEXT: auipc a0, %pcrel_hi(internal_var) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV64-PIC-NEXT: ret entry: ret i32* @internal_var diff --git a/llvm/test/CodeGen/RISCV/tls-models.ll b/llvm/test/CodeGen/RISCV/tls-models.ll --- a/llvm/test/CodeGen/RISCV/tls-models.ll +++ b/llvm/test/CodeGen/RISCV/tls-models.ll @@ -23,10 +23,9 @@ ; RV32-PIC: # %bb.0: # %entry ; RV32-PIC-NEXT: addi sp, sp, -16 ; RV32-PIC-NEXT: sw ra, 12(sp) # 4-byte Folded Spill -; RV32-PIC-NEXT: .LBB0_1: # %entry -; RV32-PIC-NEXT: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi0: ; RV32-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(unspecified) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB0_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0) ; RV32-PIC-NEXT: call __tls_get_addr@plt ; RV32-PIC-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32-PIC-NEXT: addi sp, sp, 16 @@ -36,10 +35,9 @@ ; RV64-PIC: # %bb.0: # %entry ; RV64-PIC-NEXT: addi sp, sp, -16 ; RV64-PIC-NEXT: sd ra, 8(sp) # 8-byte Folded Spill -; RV64-PIC-NEXT: .LBB0_1: # %entry -; RV64-PIC-NEXT: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi0: ; RV64-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(unspecified) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB0_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi0) ; RV64-PIC-NEXT: call __tls_get_addr@plt ; RV64-PIC-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64-PIC-NEXT: addi sp, sp, 16 @@ -47,19 +45,17 @@ ; ; RV32-NOPIC-LABEL: f1: ; RV32-NOPIC: # %bb.0: # %entry -; RV32-NOPIC-NEXT: .LBB0_1: # %entry -; RV32-NOPIC-NEXT: # Label of block must be emitted +; RV32-NOPIC-NEXT: .Lpcrel_hi0: ; RV32-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(unspecified) -; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.LBB0_1)(a0) +; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi0)(a0) ; RV32-NOPIC-NEXT: add a0, a0, tp ; RV32-NOPIC-NEXT: ret ; ; RV64-NOPIC-LABEL: f1: ; RV64-NOPIC: # %bb.0: # %entry -; RV64-NOPIC-NEXT: .LBB0_1: # %entry -; RV64-NOPIC-NEXT: # Label of block must be emitted +; RV64-NOPIC-NEXT: .Lpcrel_hi0: ; RV64-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(unspecified) -; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.LBB0_1)(a0) +; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi0)(a0) ; RV64-NOPIC-NEXT: add a0, a0, tp ; RV64-NOPIC-NEXT: ret entry: @@ -74,10 +70,9 @@ ; RV32-PIC: # %bb.0: # %entry ; RV32-PIC-NEXT: addi sp, sp, -16 ; RV32-PIC-NEXT: sw ra, 12(sp) # 4-byte Folded Spill -; RV32-PIC-NEXT: .LBB1_1: # %entry -; RV32-PIC-NEXT: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi1: ; RV32-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(ld) -; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV32-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV32-PIC-NEXT: call __tls_get_addr@plt ; RV32-PIC-NEXT: lw ra, 12(sp) # 4-byte Folded Reload ; RV32-PIC-NEXT: addi sp, sp, 16 @@ -87,10 +82,9 @@ ; RV64-PIC: # %bb.0: # %entry ; RV64-PIC-NEXT: addi sp, sp, -16 ; RV64-PIC-NEXT: sd ra, 8(sp) # 8-byte Folded Spill -; RV64-PIC-NEXT: .LBB1_1: # %entry -; RV64-PIC-NEXT: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi1: ; RV64-PIC-NEXT: auipc a0, %tls_gd_pcrel_hi(ld) -; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.LBB1_1) +; RV64-PIC-NEXT: addi a0, a0, %pcrel_lo(.Lpcrel_hi1) ; RV64-PIC-NEXT: call __tls_get_addr@plt ; RV64-PIC-NEXT: ld ra, 8(sp) # 8-byte Folded Reload ; RV64-PIC-NEXT: addi sp, sp, 16 @@ -98,19 +92,17 @@ ; ; RV32-NOPIC-LABEL: f2: ; RV32-NOPIC: # %bb.0: # %entry -; RV32-NOPIC-NEXT: .LBB1_1: # %entry -; RV32-NOPIC-NEXT: # Label of block must be emitted +; RV32-NOPIC-NEXT: .Lpcrel_hi1: ; RV32-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ld) -; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.LBB1_1)(a0) +; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi1)(a0) ; RV32-NOPIC-NEXT: add a0, a0, tp ; RV32-NOPIC-NEXT: ret ; ; RV64-NOPIC-LABEL: f2: ; RV64-NOPIC: # %bb.0: # %entry -; RV64-NOPIC-NEXT: .LBB1_1: # %entry -; RV64-NOPIC-NEXT: # Label of block must be emitted +; RV64-NOPIC-NEXT: .Lpcrel_hi1: ; RV64-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ld) -; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.LBB1_1)(a0) +; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi1)(a0) ; RV64-NOPIC-NEXT: add a0, a0, tp ; RV64-NOPIC-NEXT: ret entry: @@ -123,37 +115,33 @@ define i32* @f3() nounwind { ; RV32-PIC-LABEL: f3: ; RV32-PIC: # %bb.0: # %entry -; RV32-PIC-NEXT: .LBB2_1: # %entry -; RV32-PIC-NEXT: # Label of block must be emitted +; RV32-PIC-NEXT: .Lpcrel_hi2: ; RV32-PIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie) -; RV32-PIC-NEXT: lw a0, %pcrel_lo(.LBB2_1)(a0) +; RV32-PIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi2)(a0) ; RV32-PIC-NEXT: add a0, a0, tp ; RV32-PIC-NEXT: ret ; ; RV64-PIC-LABEL: f3: ; RV64-PIC: # %bb.0: # %entry -; RV64-PIC-NEXT: .LBB2_1: # %entry -; RV64-PIC-NEXT: # Label of block must be emitted +; RV64-PIC-NEXT: .Lpcrel_hi2: ; RV64-PIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie) -; RV64-PIC-NEXT: ld a0, %pcrel_lo(.LBB2_1)(a0) +; RV64-PIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0) ; RV64-PIC-NEXT: add a0, a0, tp ; RV64-PIC-NEXT: ret ; ; RV32-NOPIC-LABEL: f3: ; RV32-NOPIC: # %bb.0: # %entry -; RV32-NOPIC-NEXT: .LBB2_1: # %entry -; RV32-NOPIC-NEXT: # Label of block must be emitted +; RV32-NOPIC-NEXT: .Lpcrel_hi2: ; RV32-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie) -; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.LBB2_1)(a0) +; RV32-NOPIC-NEXT: lw a0, %pcrel_lo(.Lpcrel_hi2)(a0) ; RV32-NOPIC-NEXT: add a0, a0, tp ; RV32-NOPIC-NEXT: ret ; ; RV64-NOPIC-LABEL: f3: ; RV64-NOPIC: # %bb.0: # %entry -; RV64-NOPIC-NEXT: .LBB2_1: # %entry -; RV64-NOPIC-NEXT: # Label of block must be emitted +; RV64-NOPIC-NEXT: .Lpcrel_hi2: ; RV64-NOPIC-NEXT: auipc a0, %tls_ie_pcrel_hi(ie) -; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.LBB2_1)(a0) +; RV64-NOPIC-NEXT: ld a0, %pcrel_lo(.Lpcrel_hi2)(a0) ; RV64-NOPIC-NEXT: add a0, a0, tp ; RV64-NOPIC-NEXT: ret entry: