[llvm-bugs] [Bug 46060] New: InlineAsm loses srcloc metadata with -O0

via llvm-bugs llvm-bugs at lists.llvm.org
Sun May 24 13:42:10 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=46060

            Bug ID: 46060
           Summary: InlineAsm loses srcloc metadata with -O0
           Product: libraries
           Version: 10.0
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: Common Code Generator Code
          Assignee: unassignedbugs at nondot.org
          Reporter: amanieu at gmail.com
                CC: llvm-bugs at lists.llvm.org

This only seems to affect some targets: X86 is not affected but ARM and AArch64
are.

$ cat clang_asm.c 
void foo() {
    asm("nowayisthisavalidinstruction");
}

$ clang -target arm-unknown-linux-gnueabihf clang_asm.c -O0
<inline asm>:1:2: error: invalid instruction
        nowayisthisavalidinstruction
        ^
1 error generated.

$ clang -target arm-unknown-linux-gnueabihf clang_asm.c -O1
clang_asm.c:2:9: error: invalid instruction
    asm("nowayisthisavalidinstruction");
        ^
<inline asm>:1:2: note: instantiated into assembly here
        nowayisthisavalidinstruction
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.


The metadata seems to get lost in the instruction selection pass:

//// -O0

*** IR Dump After Safe Stack instrumentation pass ***
; Function Attrs: noinline nounwind optnone sspstrong
define dso_local void @foo() #0 {
  call void asm sideeffect "nowayisthisavalidinstruction", ""() #1, !srcloc !5
  ret void
}
# *** IR Dump After ARM Instruction Selection ***:
# Machine code for function foo: IsSSA, TracksLiveness

bb.0 (%ir-block.0):
  INLINEASM &nowayisthisavalidinstruction [sideeffect] [attdialect]
  BX_RET 14, $noreg

# End machine code for function foo.

//// -O1

*** IR Dump After Safe Stack instrumentation pass ***
; Function Attrs: nounwind sspstrong
define dso_local void @foo() local_unnamed_addr #0 {
  call void asm sideeffect "nowayisthisavalidinstruction", ""() #1, !srcloc !5
  ret void
}
# *** IR Dump After ARM Instruction Selection ***:
# Machine code for function foo: IsSSA, TracksLiveness

bb.0 (%ir-block.0):
  INLINEASM &nowayisthisavalidinstruction [sideeffect] [attdialect], !5
  BX_RET 14, $noreg

# End machine code for function foo.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200524/b90d2ddb/attachment-0001.html>


More information about the llvm-bugs mailing list