r186219 - Changes so that a few tests do not fail when running under guarded malloc.

Gao, Yunzhong yunzhong_gao at playstation.sony.com
Thu Jan 23 14:06:53 PST 2014


Hi Argyrios,
No, it is not a big problem for me. I was confused by the error message "LLVM ERROR: IO failure on output stream"
so I thought I would report this. I debugged the issue a little bit, and it seems that when combining "-o -" and
"-fdump-record-layouts", there will be two copies of raw_fd_ostream to stdout, created in
CompilerInstance::addOutputFile() and llvm::outs() respectively, so when clang exits, stdout will be closed twice. I did
not find very good solution from googling about how to detect already closed file descriptors on Linux other than
checking the return value and errno of ::close().
- Gao.

________________________________________
From: Argyrios Kyrtzidis [akyrtzi at gmail.com]
Sent: Thursday, January 23, 2014 1:29 PM
To: Gao, Yunzhong
Cc: Reid Kleckner; cfe-commits at cs.uiuc.edu cfe
Subject: Re: r186219 - Changes so that a few tests do not fail when running under guarded malloc.

On Jan 23, 2014, at 12:37 PM, Gao, Yunzhong <yunzhong_gao at playstation.sony.com> wrote:

> It seems that if I combine "-o -" and "-fdump-record-layouts" I get an error saying "LLVM ERROR: IO failure on output stream."
>
> $ clang -cc1 -emit-llvm -fdump-record-layouts -o - test.c
> $ cat test.c
> struct foo {
>  int x;
> } foo_var;
>
> int main()
> {
>  return 0;
> }
>
> I am not sure what would be the right fix. Maybe it makes sense to teach ~raw_fd_ostream() to ignore EBADF when closing a file descriptor?

Do you really need to combine  "-o -" and "-fdump-record-layouts", can't you just do:

$ clang -cc1 -emit-llvm-only -fdump-record-layouts test.c

to dump the records and

$ clang -cc1 -emit-llvm -o - test.c

to get the IR ?

or

$ clang -cc1 -emit-llvm -fdump-record-layouts -o t.ll test.c


> - Gao.
>
> ________________________________________
> From: cfe-commits-bounces at cs.uiuc.edu [cfe-commits-bounces at cs.uiuc.edu] on behalf of Reid Kleckner [rnk at google.com]
> Sent: Friday, July 12, 2013 5:49 PM
> To: Argyrios Kyrtzidis
> Cc: cfe-commits at cs.uiuc.edu cfe
> Subject: Re: r186219 - Changes so that a few tests do not fail when running     under guarded malloc.
>
> This seems problematic if someone combines -o - and -fdump-record-layouts, but that's not that big of a deal.
>
>
> On Fri, Jul 12, 2013 at 6:30 PM, Argyrios Kyrtzidis <akyrtzi at gmail.com<mailto:akyrtzi at gmail.com>> wrote:
> Author: akirtzidis
> Date: Fri Jul 12 17:30:03 2013
> New Revision: 186219
>
> URL: http://llvm.org/viewvc/llvm-project?rev=186219&view=rev
> Log:
> Changes so that a few tests do not fail when running under guarded malloc.
>
> Guarded malloc emits some messages at the beginning in stderr when enabled.
> These messages caused a few tests to fail.
>
> Modified:
>    cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
>    cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
>    cfe/trunk/test/ASTMerge/class.cpp
>    cfe/trunk/test/CodeGen/bitfield-2.c
>    cfe/trunk/test/CodeGen/override-layout.c
>    cfe/trunk/test/CodeGenCXX/override-layout.cpp
>
> Modified: cfe/trunk/lib/AST/RecordLayoutBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/RecordLayoutBuilder.cpp?rev=186219&r1=186218&r2=186219&view=diff
> ==============================================================================
> --- cfe/trunk/lib/AST/RecordLayoutBuilder.cpp (original)
> +++ cfe/trunk/lib/AST/RecordLayoutBuilder.cpp Fri Jul 12 17:30:03 2013
> @@ -2423,8 +2423,8 @@ ASTContext::getASTRecordLayout(const Rec
>   ASTRecordLayouts[D] = NewEntry;
>
>   if (getLangOpts().DumpRecordLayouts) {
> -    llvm::errs() << "\n*** Dumping AST Record Layout\n";
> -    DumpRecordLayout(D, llvm::errs(), getLangOpts().DumpRecordLayoutsSimple);
> +    llvm::outs() << "\n*** Dumping AST Record Layout\n";
> +    DumpRecordLayout(D, llvm::outs(), getLangOpts().DumpRecordLayoutsSimple);
>   }
>
>   return *NewEntry;
>
> Modified: cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp?rev=186219&r1=186218&r2=186219&view=diff
> ==============================================================================
> --- cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGRecordLayoutBuilder.cpp Fri Jul 12 17:30:03 2013
> @@ -976,11 +976,11 @@ CGRecordLayout *CodeGenTypes::ComputeRec
>
>   // Dump the layout, if requested.
>   if (getContext().getLangOpts().DumpRecordLayouts) {
> -    llvm::errs() << "\n*** Dumping IRgen Record Layout\n";
> -    llvm::errs() << "Record: ";
> -    D->dump();
> -    llvm::errs() << "\nLayout: ";
> -    RL->dump();
> +    llvm::outs() << "\n*** Dumping IRgen Record Layout\n";
> +    llvm::outs() << "Record: ";
> +    D->dump(llvm::outs());
> +    llvm::outs() << "\nLayout: ";
> +    RL->print(llvm::outs());
>   }
>
> #ifndef NDEBUG
>
> Modified: cfe/trunk/test/ASTMerge/class.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ASTMerge/class.cpp?rev=186219&r1=186218&r2=186219&view=diff
> ==============================================================================
> --- cfe/trunk/test/ASTMerge/class.cpp (original)
> +++ cfe/trunk/test/ASTMerge/class.cpp Fri Jul 12 17:30:03 2013
> @@ -1,7 +1,7 @@
> // RUN: %clang_cc1 -emit-pch -o %t.1.ast %S/Inputs/class1.cpp
> // RUN: %clang_cc1 -emit-pch -o %t.2.ast %S/Inputs/class2.cpp
> // RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 | FileCheck %s
> -// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 -Wno-odr | count 0
> +// RUN: %clang_cc1 -ast-merge %t.1.ast -ast-merge %t.2.ast -fsyntax-only %s 2>&1 -Wno-odr -Werror
>
> // CHECK: class1.cpp:5:8: warning: type 'B' has incompatible definitions in different translation units
> // CHECK: class1.cpp:6:9: note: field 'y' has type 'float' here
>
> Modified: cfe/trunk/test/CodeGen/bitfield-2.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bitfield-2.c?rev=186219&r1=186218&r2=186219&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/bitfield-2.c (original)
> +++ cfe/trunk/test/CodeGen/bitfield-2.c Fri Jul 12 17:30:03 2013
> @@ -1,5 +1,5 @@
> // RUN: %clang_cc1 -emit-llvm -triple x86_64 -O3 -o %t.opt.ll %s \
> -// RUN:   -fdump-record-layouts 2> %t.dump.txt
> +// RUN:   -fdump-record-layouts > %t.dump.txt
> // RUN: FileCheck -check-prefix=CHECK-RECORD < %t.dump.txt %s
> // RUN: FileCheck -check-prefix=CHECK-OPT < %t.opt.ll %s
>
>
> Modified: cfe/trunk/test/CodeGen/override-layout.c
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/override-layout.c?rev=186219&r1=186218&r2=186219&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGen/override-layout.c (original)
> +++ cfe/trunk/test/CodeGen/override-layout.c Fri Jul 12 17:30:03 2013
> @@ -1,6 +1,6 @@
> -// RUN: %clang_cc1 -w -fdump-record-layouts %s 2> %t.layouts
> -// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.before 2>&1
> -// RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
> +// RUN: %clang_cc1 -w -fdump-record-layouts %s > %t.layouts
> +// RUN: %clang_cc1 -w -fdump-record-layouts-simple %s > %t.before
> +// RUN: %clang_cc1 -w -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
> // RUN: diff %t.before %t.after
> // RUN: FileCheck %s < %t.after
>
>
> Modified: cfe/trunk/test/CodeGenCXX/override-layout.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/override-layout.cpp?rev=186219&r1=186218&r2=186219&view=diff
> ==============================================================================
> --- cfe/trunk/test/CodeGenCXX/override-layout.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/override-layout.cpp Fri Jul 12 17:30:03 2013
> @@ -1,6 +1,6 @@
> -// RUN: %clang_cc1 -fdump-record-layouts-simple %s 2> %t.layouts
> -// RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.before 2>&1
> -// RUN: %clang_cc1 -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after 2>&1
> +// RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.layouts
> +// RUN: %clang_cc1 -fdump-record-layouts-simple %s > %t.before
> +// RUN: %clang_cc1 -DPACKED= -DALIGNED16= -fdump-record-layouts-simple -foverride-record-layout=%t.layouts %s > %t.after
> // RUN: diff -u %t.before %t.after
> // RUN: FileCheck %s < %t.after
>
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu<mailto:cfe-commits at cs.uiuc.edu>
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>







More information about the cfe-commits mailing list