diff options
author | Dan Gohman <sunfish@mozilla.com> | 2014-03-05 19:40:14 -0800 |
---|---|---|
committer | Dan Gohman <sunfish@mozilla.com> | 2014-03-05 19:42:53 -0800 |
commit | 805f34e607fadc603eefa3120ff514a2f3432392 (patch) | |
tree | 7bb1987b9b697e6d00af0b7feb5f1e09509aac29 | |
parent | d47d2f44889791561b29646a087e3836a5965942 (diff) |
Disable the ResolveAliases and GlobalCleanup passes.
Also add a test for handling of global aliases.
-rw-r--r-- | lib/Target/JSBackend/JSBackend.cpp | 5 | ||||
-rw-r--r-- | lib/Transforms/NaCl/PNaClABISimplify.cpp | 4 | ||||
-rw-r--r-- | test/CodeGen/JS/global-alias.ll | 56 |
3 files changed, 65 insertions, 0 deletions
diff --git a/lib/Target/JSBackend/JSBackend.cpp b/lib/Target/JSBackend/JSBackend.cpp index 65504326b0..856a051fe9 100644 --- a/lib/Target/JSBackend/JSBackend.cpp +++ b/lib/Target/JSBackend/JSBackend.cpp @@ -950,6 +950,11 @@ std::string JSWriter::getConstant(const Constant* CV, AsmCast sign) { Externals.insert(Name); return Name; } + if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(CV)) { + // Since we don't currently support linking of our output, we don't need + // to worry about weak or other kinds of aliases. + return getConstant(GA->getAliasee(), sign); + } return utostr(getGlobalAddress(GV->getName().str())); } diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp index 5678ffaa7f..886e0cc4cc 100644 --- a/lib/Transforms/NaCl/PNaClABISimplify.cpp +++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp @@ -77,13 +77,17 @@ void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) { PM.add(createExpandVarArgsPass()); PM.add(createExpandCtorsPass()); +#if 0 // XXX EMSCRIPTEN: We handle aliases. PM.add(createResolveAliasesPass()); +#endif #if 0 // EMSCRIPTEN: no need for tls PM.add(createExpandTlsPass()); #endif // GlobalCleanup needs to run after ExpandTls because // __tls_template_start etc. are extern_weak before expansion +#if 0 // XXX EMSCRIPTEN: We don't currently have tls, and we don't have the same complications with extern_weak PM.add(createGlobalCleanupPass()); +#endif } void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) { diff --git a/test/CodeGen/JS/global-alias.ll b/test/CodeGen/JS/global-alias.ll new file mode 100644 index 0000000000..b6efc0e7e7 --- /dev/null +++ b/test/CodeGen/JS/global-alias.ll @@ -0,0 +1,56 @@ +; RUN: llc -march=js < %s | FileCheck %s + +; Handle global aliases of various kinds. + +@pri = internal global [60 x i8] zeroinitializer +@pub = global [60 x i8] zeroinitializer + +@pri_int = alias internal [60 x i8]* @pri +@pri_wea = alias weak [60 x i8]* @pri +@pri_nor = alias [60 x i8]* @pri + +@pub_int = alias internal [60 x i8]* @pub +@pub_wea = alias weak [60 x i8]* @pub +@pub_nor = alias [60 x i8]* @pub + +; CHECK: test0( +; CHECK: return ([[PRI:[0-9]+]]|0); +define [60 x i8]* @test0() { + ret [60 x i8]* @pri +} +; CHECK: test1( +; CHECK: return ([[PRI]]|0); +define [60 x i8]* @test1() { + ret [60 x i8]* @pri_int +} +; CHECK: test2( +; CHECK: return ([[PRI]]|0); +define [60 x i8]* @test2() { + ret [60 x i8]* @pri_wea +} +; CHECK: test3( +; CHECK: return ([[PRI]]|0); +define [60 x i8]* @test3() { + ret [60 x i8]* @pri_nor +} + +; CHECK: test4( +; CHECK: return ([[PUB:[0-9]+]]|0); +define [60 x i8]* @test4() { + ret [60 x i8]* @pub +} +; CHECK: test5( +; CHECK: return ([[PUB]]|0); +define [60 x i8]* @test5() { + ret [60 x i8]* @pub_int +} +; CHECK: test6( +; CHECK: return ([[PUB]]|0); +define [60 x i8]* @test6() { + ret [60 x i8]* @pub_wea +} +; CHECK: test7( +; CHECK: return ([[PUB]]|0); +define [60 x i8]* @test7() { + ret [60 x i8]* @pub_nor +} |