New issue
Advanced search Search tips

Issue 831158 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Apr 2018
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 1
Type: Bug

Blocking:
issue 828582



Sign in to add a comment

tip-of-tree clang windows builds failing with "Invalid register passed in"

Project Member Reported by h...@chromium.org, Apr 10 2018

Issue description

Comment 1 by h...@chromium.org, Apr 10 2018

Attaching the repro.
cpu_x86-0f1122.c
6.5 MB View Download
cpu_x86-0f1122.sh
10.1 KB View Download

Comment 2 by h...@chromium.org, Apr 10 2018

Bisection points to r329673

Comment 3 by h...@chromium.org, Apr 10 2018

Somewhat reduced:

$ cat /tmp/a.c

int asm_HasCPUID(void) {
  volatile int before, after, result;
  __asm {
    pushfd
    pop eax
    mov before, eax
    xor eax, 0x00200000
    push eax
    popfd
    pushfd
    pop after
  }
  result = (before ^ after) & 0x0200000;
  return result;
}

$ build.release/bin/clang -target i686-pc-win32 -c /tmp/a.c
clang-7.0: /work/llvm.combined/llvm/tools/clang/lib/Basic/TargetInfo.cpp:450: llvm::StringRef clang::TargetInfo::getNormalizedGCCRegisterName(llvm::StringRef, bool) const: Assertion `isValidGCCRegisterName(Name) && "Invalid register passed in"' failed.
/work/llvm.combined/build.release/bin/clang-7.0(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x1a)[0x558ef09c948a]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN4llvm3sys17RunSignalHandlersEv+0x56)[0x558ef09c71c6]
/work/llvm.combined/build.release/bin/clang-7.0(+0x246c535)[0x558ef09c7535]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x110c0)[0x7fadb91420c0]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xcf)[0x7fadb7cd3fcf]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7fadb7cd53fa]
/lib/x86_64-linux-gnu/libc.so.6(+0x2be37)[0x7fadb7ccce37]
/lib/x86_64-linux-gnu/libc.so.6(+0x2bee2)[0x7fadb7cccee2]
/work/llvm.combined/build.release/bin/clang-7.0(+0x407bd95)[0x558ef25d6d95]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen15CodeGenFunction11EmitAsmStmtERKNS_7AsmStmtE+0x22fe)[0x558ef0be38ae]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen15CodeGenFunction8EmitStmtEPKNS_4StmtEN4llvm8ArrayRefIPKNS_4AttrEEE+0x229)[0x558ef0be8b09]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen15CodeGenFunction28EmitCompoundStmtWithoutScopeERKNS_12CompoundStmtEbNS0_12AggValueSlotE+0x53)[0x558ef0be9053]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen15CodeGenFunction16EmitFunctionBodyERNS0_15FunctionArgListEPKNS_4StmtE+0x8d)[0x558ef0c2263d]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen15CodeGenFunction12GenerateCodeENS_10GlobalDeclEPN4llvm8FunctionERKNS0_14CGFunctionInfoE+0x246)[0x558ef0c2eea6]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen13CodeGenModule28EmitGlobalFunctionDefinitionENS_10GlobalDeclEPN4llvm11GlobalValueE+0x16a)[0x558ef0c5649a]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen13CodeGenModule20EmitGlobalDefinitionENS_10GlobalDeclEPN4llvm11GlobalValueE+0x1c1)[0x558ef0c68701]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang7CodeGen13CodeGenModule10EmitGlobalENS_10GlobalDeclE+0x478)[0x558ef0c69758]
/work/llvm.combined/build.release/bin/clang-7.0(+0x270f405)[0x558ef0c6a405]
/work/llvm.combined/build.release/bin/clang-7.0(+0x2dbac6d)[0x558ef1315c6d]
/work/llvm.combined/build.release/bin/clang-7.0(+0x2db02ad)[0x558ef130b2ad]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang8ParseASTERNS_4SemaEbb+0x1a3)[0x558ef1ae7cc3]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang13CodeGenAction13ExecuteActionEv+0x80)[0x558ef1313190]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang14FrontendAction7ExecuteEv+0x8e)[0x558ef0fb763e]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang16CompilerInstance13ExecuteActionERNS_14FrontendActionE+0x17e)[0x558ef0f7f91e]
/work/llvm.combined/build.release/bin/clang-7.0(_ZN5clang25ExecuteCompilerInvocationEPNS_16CompilerInstanceE+0x86b)[0x558ef105443b]
/work/llvm.combined/build.release/bin/clang-7.0(_Z8cc1_mainN4llvm8ArrayRefIPKcEES2_Pv+0xa08)[0x558eef196e28]
/work/llvm.combined/build.release/bin/clang-7.0(main+0x1964)[0x558eef117b74]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf1)[0x7fadb7cc12b1]
/work/llvm.combined/build.release/bin/clang-7.0(_start+0x2a)[0x558eef192d0a]
Stack dump:
0.      Program arguments: /work/llvm.combined/build.release/bin/clang-7.0 -cc1 -triple i686-pc-windows-msvc19.11.0 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -main-file-name a.c -mrelocation-model static -mthread-model posix -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -target-cpu pentium4 -dwarf-column-info -debugger-tuning=gdb -coverage-notes-file /work/llvm.combined/a.gcno -resource-dir /work/llvm.combined/build.release/lib/clang/7.0.0 -internal-isystem /work/llvm.combined/build.release/lib/clang/7.0.0/include -fdebug-compilation-dir /work/llvm.combined -ferror-limit 19 -fmessage-length 207 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.11 -fdelayed-template-parsing -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o a.o -x c /tmp/a.c 
1.      <eof> parser at end of file
2.      /tmp/a.c:2:5: LLVM IR generation of declaration 'asm_HasCPUID'
3.      /tmp/a.c:2:5: Generating code for declaration 'asm_HasCPUID'
clang-7.0: error: unable to execute command: Aborted
clang-7.0: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 7.0.0 
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: /work/llvm.combined/build.release/bin
clang-7.0: note: diagnostic msg: PLEASE submit a bug report to https://bugs.llvm.org/ and include the crash backtrace, preprocessed source, and associated run script.
clang-7.0: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-7.0: note: diagnostic msg: /tmp/a-fe8be0.c
clang-7.0: note: diagnostic msg: /tmp/a-fe8be0.sh
clang-7.0: note: diagnostic msg: 

********************

Comment 4 by h...@chromium.org, Apr 10 2018

More reduced:

$ cat /tmp/a.c
void f(void) {
  __asm {
    popfd
  }
}


popfd doesn't any operands, so not sure why it's complaining..

Comment 5 by h...@chromium.org, Apr 10 2018

clang::TargetInfo::getNormalizedGCCRegisterName is getting called with "DF" as register name.

isValidGCCRegisterName() is based on a list of registers in lib/Basic/Targets/X86.cpp

DF isn't there, but neither is EFLAGS. What's going on...

Comment 6 by h...@chromium.org, Apr 10 2018

Oh wait, EFLAGS is listed in GCCRegNames, but just as "flags".

The reason DF shows up is that it's now a clobbered register for popf.

So, maybe just adding it to GCCRegNames is the thing? But actually, "dirflag" is already listed there. Hmm.

Comment 7 by thakis@chromium.org, Apr 10 2018

list says "fixed in r329734"

Comment 8 by h...@chromium.org, Apr 11 2018

Status: Fixed (was: Assigned)

Sign in to add a comment