
Much to my surprise, '-disable-llvm-optzns' which I thought was the magical flag I wanted to get at the raw LLVM IR coming out of Clang deosn't do that. It still runs some passes over the IR. I don't want that, I really want the *raw* IR coming out of Clang and I strongly suspect everyone else using it is in the same camp. There is actually a flag that does what I want that I didn't know about called '-disable-llvm-passes'. I suspect many others don't know about it either. It both does what I want and is much simpler. This removes the confusing version and makes that spelling of the flag an alias for '-disable-llvm-passes'. I've also moved everything in Clang to use the 'passes' spelling as it seems both more accurate (*all* LLVM passes are disabled, not just optimizations) and much easier to remember and spell correctly. This is part of simplifying how Clang drives LLVM to make it cleaner to wire up to the new pass manager. Differential Revision: https://reviews.llvm.org/D28047 llvm-svn: 290392
41 lines
1.3 KiB
C++
41 lines
1.3 KiB
C++
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-passes %s -o - | FileCheck %s -check-prefix=CHECKA -check-prefix=CHECK
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-passes -fcxx-exceptions %s -o - | FileCheck %s -check-prefix=CHECKB -check-prefix=CHECK
|
|
// expected-no-diagnostics
|
|
|
|
// The variable template specialization x<Foo> generated in each file
|
|
// should be 'internal global' and not 'linkonce_odr global'.
|
|
|
|
template <typename T> int x = 42;
|
|
|
|
// CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global
|
|
|
|
// CHECK-DAG: define internal dereferenceable(4) i32* @_ZL3foov(
|
|
static int &foo() {
|
|
struct Foo { };
|
|
|
|
// CHECK-DAG: ret i32* @_Z1xIZL3foovE3FooE
|
|
return x<Foo>;
|
|
}
|
|
|
|
|
|
#if !__has_feature(cxx_exceptions) // File A
|
|
// CHECKA-DAG: define dereferenceable(4) i32* @_Z3barv(
|
|
int &bar() {
|
|
// CHECKA-DAG: call dereferenceable(4) i32* @_ZL3foov()
|
|
return foo();
|
|
}
|
|
|
|
#else // File B
|
|
|
|
// CHECKB-DAG: declare dereferenceable(4) i32* @_Z3barv(
|
|
int &bar();
|
|
|
|
int main() {
|
|
// CHECKB-DAG: call dereferenceable(4) i32* @_Z3barv()
|
|
// CHECKB-DAG: call dereferenceable(4) i32* @_ZL3foov()
|
|
&bar() == &foo() ? throw 0 : (void)0; // Should not throw exception at runtime.
|
|
}
|
|
|
|
#endif // end of Files A and B
|
|
|