From c47dec2b27317a49b62a2e1e46c06ba915691d87 Mon Sep 17 00:00:00 2001 From: Sebastian Neubauer Date: Fri, 21 Jul 2023 20:45:39 +0200 Subject: [PATCH] Remove typed pointers from example Upstream llvm now asserts when trying to enable typed pointers. llvm-dialects needs to keep support for typed pointers for some time, but it also needs to compile with upstream llvm. We could add a CMake flag or make the test code dependent on the llvm version, but in practice, llvm-dialects examples are only tested here. --- example/ExampleMain.cpp | 24 +----------------------- test/example/test-builder.test | 12 ------------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/example/ExampleMain.cpp b/example/ExampleMain.cpp index 1382fcc..3238129 100644 --- a/example/ExampleMain.cpp +++ b/example/ExampleMain.cpp @@ -57,9 +57,6 @@ cl::opt g_action( cl::list g_inputs(cl::Positional, cl::ZeroOrMore, cl::desc("Input file(s) (\"-\" for stdin)")); -cl::opt g_typedPointers("typed-pointers", cl::init(false), - cl::desc("Disable opaque pointers")); - cl::opt g_rpot("rpot", cl::init(false), cl::desc("Visit functions in reverse post-order")); @@ -135,23 +132,6 @@ std::unique_ptr createModuleExample(LLVMContext &context) { return module; } -/// A smaller example that does not need pointers and works with typed pointers. -std::unique_ptr createModuleExampleTypedPtrs(LLVMContext &context) { - auto module = std::make_unique("example", context); - Builder b{context}; - - Function *fn = Function::Create(FunctionType::get(b.getVoidTy(), false), - GlobalValue::ExternalLinkage, "example-typed", *module); - - BasicBlock *bb = BasicBlock::Create(context, "entry", fn); - b.SetInsertPoint(bb); - - useUnnamedStructTypes(b); - - b.CreateRetVoid(); - return module; -} - struct VisitorInnermost { int counter = 0; }; @@ -241,12 +221,10 @@ int main(int argc, char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv); LLVMContext context; - if (g_typedPointers) - context.setOpaquePointers(false); auto dialectContext = DialectContext::make(context); if (g_action == Action::Build) { - auto module = g_typedPointers ? createModuleExampleTypedPtrs(context) : createModuleExample(context); + auto module = createModuleExample(context); module->print(llvm::outs(), nullptr, false); } else { if (g_inputs.size() != 1) { diff --git a/test/example/test-builder.test b/test/example/test-builder.test index 77df8c9..05a6fe8 100644 --- a/test/example/test-builder.test +++ b/test/example/test-builder.test @@ -1,7 +1,6 @@ ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --tool llvm-dialects-example --include-generated-funcs ; NOTE: stdin isn't used by the example program, but the redirect makes the UTC tool happy. ; RUN: llvm-dialects-example - | FileCheck --check-prefixes=CHECK %s -; RUN: llvm-dialects-example -typed-pointers | FileCheck --check-prefixes=TYPED %s ; CHECK-LABEL: @example( ; CHECK-NEXT: entry: @@ -34,14 +33,3 @@ ; CHECK-NEXT: call void (...) @xd.write([[TMP2]] [[TMP17]]) ; CHECK-NEXT: ret void ; -; -; TYPED-LABEL: @example-typed( -; TYPED-NEXT: entry: -; TYPED-NEXT: [[TMP0:%.*]] = call [[TMP0]] @xd.read.s_s() -; TYPED-NEXT: [[TMP1:%.*]] = call [[TMP1]] @xd.read.s_s_0() -; TYPED-NEXT: [[TMP2:%.*]] = call [[TMP2]] @xd.read.s_s_1() -; TYPED-NEXT: call void (...) @xd.write([[TMP0]] [[TMP0]]) -; TYPED-NEXT: call void (...) @xd.write([[TMP1]] [[TMP1]]) -; TYPED-NEXT: call void (...) @xd.write([[TMP2]] [[TMP2]]) -; TYPED-NEXT: ret void -;