llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

InstructionCombine error when monolithic LTO used

Open markschimmel opened this issue 3 years ago • 3 comments

Monolithic LTO bug results in call to f() being erased by InstCombinerImpl::visitUnreachableInst

// File f.c
extern void __attribute__((noreturn))f();
extern volatile int b,c,d,e;
int main() {
  if (b) {
    c = 1;
  } else {
    d = 2;
  }
  e = 1;
  e = 2;
  e = 3;
  f(); // CALL IS DELETED
  e = 5;
  return 0;
}

// file g.c
volatile int b=1,c,d,e;
void __attribute__((noreturn))f() {
  while(1) {
    c++;
  }
}

markschimmel avatar Aug 04 '22 00:08 markschimmel

Sorry, saved lto somehow erroneously deleted llvm:instcombine label - will fix

markschimmel avatar Aug 04 '22 00:08 markschimmel

Could you clarify what the issue is? The fact that the call to f() is removed?

fhahn avatar Aug 04 '22 16:08 fhahn

@markschimmel would it be possible to extract the LLVM IR module before instcombine removes the call, e.g. using -mllvm -print-before=instcombine -mllvm -print-module-scope? Depending on what linker you use you may have to thread them through to the LTO plugin using -Wl or something like that.

fhahn avatar Aug 15 '22 07:08 fhahn