[PATCH] D24193: Allow variables with asm labels in naked functions

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 2 09:57:51 PDT 2016


rnk added a comment.

Won't the mid-level optimizer turn these register variables into undefs, and we'll end up with this kind of IR?

  void f() {
    int register var asm ("eax") ;
    asm volatile ("add %%eax, %0\n\tret" : : "r"(var));
  }
  ->
  define void @"\01?f@@YAXXZ"() local_unnamed_addr #0 {
  entry:
    tail call void asm sideeffect "add %eax, $0\0A\09ret", "{eax},~{dirflag},~{fpsr},~{flags}"(i32 undef) #1, !srcloc !2
    ret void
  }

I guess it's OK so long as we don't codegen undef to anything, but it could go badly.


https://reviews.llvm.org/D24193





More information about the cfe-commits mailing list