From 45d8a7843253ec68367c26114a2aa6bff2a7a4bb Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Wed, 2 Dec 2020 14:45:49 +0100 Subject: [PATCH] Simplify append to module inline asm string in IRLinker::run() This also removes the empty extra "module asm" that would be created, and updates the test to reflect that while making it more explicit. Broken out from https://reviews.llvm.org/D92335 --- llvm/lib/Linker/IRMover.cpp | 9 ++------- .../test/Linker/link-arm-and-thumb-module-inline-asm.ll | 17 ++++++++--------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp index d55c53e..5a67266 100644 --- a/llvm/lib/Linker/IRMover.cpp +++ b/llvm/lib/Linker/IRMover.cpp @@ -1440,13 +1440,8 @@ Error IRLinker::run() { // Append the module inline asm string. if (!IsPerformingImport && !SrcM->getModuleInlineAsm().empty()) { - std::string SrcModuleInlineAsm = adjustInlineAsm(SrcM->getModuleInlineAsm(), - SrcTriple); - if (DstM.getModuleInlineAsm().empty()) - DstM.setModuleInlineAsm(SrcModuleInlineAsm); - else - DstM.setModuleInlineAsm(DstM.getModuleInlineAsm() + "\n" + - SrcModuleInlineAsm); + DstM.appendModuleInlineAsm(adjustInlineAsm(SrcM->getModuleInlineAsm(), + SrcTriple)); } // Loop over all of the linked values to compute type mappings. diff --git a/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll b/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll index 13779f3..5e12a8c 100644 --- a/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll +++ b/llvm/test/Linker/link-arm-and-thumb-module-inline-asm.ll @@ -9,12 +9,11 @@ target triple = "armv7-linux-gnueabihf" module asm "add r1, r2, r2" -; CHECK: .text -; CHECK-NEXT: .balign 4 -; CHECK-NEXT: .arm -; CHECK-NEXT: add r1, r2, r2 -; CHECK-NEXT: module asm -; CHECK-NEXT: .text -; CHECK-NEXT: .balign 2 -; CHECK-NEXT: .thumb -; CHECK-NEXT: orn r1, r2, r2 +; CHECK: module asm ".text" +; CHECK-NEXT: module asm ".balign 4" +; CHECK-NEXT: module asm ".arm" +; CHECK-NEXT: module asm "add r1, r2, r2" +; CHECK-NEXT: module asm ".text" +; CHECK-NEXT: module asm ".balign 2" +; CHECK-NEXT: module asm ".thumb" +; CHECK-NEXT: module asm "orn r1, r2, r2" -- 2.7.4