[PATCH] D69411: [MC] Calculate difference of symbols in two fragments when possible

Jian Cai via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 1 16:53:33 PDT 2019


jcai19 added inline comments.


================
Comment at: llvm/test/MC/AsmParser/directive_if_offset.s:1
+@ RUN: clang -target arm-linux-gnueabihf %s -c -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-ARM %s
+@ RUN: clang -target thumb-linux-gnueabihf %s -c -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-THUMB %s
----------------
peter.smith wrote:
> peter.smith wrote:
> > Be careful with module dependencies and targets.
> > - An llvm test cannot depend on clang, only tools that are in the llvm repository such as llvm-mc.
> > - All backends like ARM are optional so tests need to be guarded either by directory or by REQUIRES to prevent failures when backends aren't available. Looking at the directories lit.local.cfg:
> > ```
> > if not 'X86' in config.root.targets:
> >     config.unsupported = True
> > ```
> > Which is backed up by all of the tests in the directory using X86 backend triples. I think that this test if it remains in this location will need to be rewritten in x86. If the test needs Arm I think it ought to go in the MC/ARM directory.
> The test fails when there is asm output from llvm-mc.
> 
> ```
> llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf directive_if_offset.s -o /dev/null
> echo $?
> 0
> ```
> However when using the assembler output, this fails:
> ```
> llvm-mc --triple armv7a-linux-gnueabihf directive_if_offset.s -filetype=asm -o /dev/null
> directive_if_offset.s:7:5: error: expected absolute expression
> .if . - 9997b == 4 ;
> ```
> It may be that there is no way to resolve this in the asm output as the data structures might not exist. It will be worth a check to see though. I think that differences between the asm and obj outputs of llvm-mv are frowned on, but I don't think that they are necessarily fatal if coming from a assembler file and not something generated by clang. This might be a problem if the .if exists in inline assembler, not that I'd recommend anyone do that.
I have moved the tests to MC/ARM directory.


================
Comment at: llvm/test/MC/AsmParser/directive_if_offset.s:10
+// CHECK-THUMB-NOT: :[[@LINE-2]]:5: error: expected absolute expression
+orr r1, r1, #1 ;
+.else ; orr r1, r1, #2;
----------------
peter.smith wrote:
> You could use llvm-objdump -d on the ELF output to test that the correct instruction had been generated. Normally we'd use llvm-mc -filetype=asm and use FileCheck on that but that isn't working in this case.
I did verify myself with -filetype=obj and llvm-objdump -disassemble, although I can't seem to trigger 

    if (Asm->isThumbFunc(&SA))
      Addend |= 1;
and therefore cannot the else branch here. Any thoughts on this? Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D69411/new/

https://reviews.llvm.org/D69411





More information about the llvm-commits mailing list