[clang] [clang-repl][CodeGen] Add setOptLevel, #pragma clang repl optimize(N) (PR #214793)

Tom Stellard via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 24 07:31:06 PDT 2026


tstellar wrote:

Hi, I'm seeing test failures from the test added in this PR:

You can reproduce with `cmake -G Ninja -B build -S llvm -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=OFF -DLLVM_ENABLE_PROJECTS=clang -DLLVM_TARGETS_TO_BUILD=Native`

```
******************** TEST 'Clang :: Interpreter/pragma-optimize.cpp' FAILED ********************
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 6
cat /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/clang/test/Interpreter/pragma-optimize.cpp | /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/llvm/redhat-linux-build/bin/clang-repl -Xcc -Xclang -Xcc -emit-llvm | /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/llvm/redhat-linux-build/bin/FileCheck /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/clang/test/Interpreter/pragma-optimize.cpp
# executed command: cat /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/clang/test/Interpreter/pragma-optimize.cpp
# note: command had no output on stdout or stderr
# executed command: /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/llvm/redhat-linux-build/bin/clang-repl -Xcc -Xclang -Xcc -emit-llvm
# note: command had no output on stdout or stderr
# executed command: /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/llvm/redhat-linux-build/bin/FileCheck /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/clang/test/Interpreter/pragma-optimize.cpp
# .---command stderr------------
# | /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/clang/test/Interpreter/pragma-optimize.cpp:11:16: error: CHECK-NEXT: expected string not found in input
# | // CHECK-NEXT: entry:
# |                ^
# | <stdin>:91:18: note: scanning from here
# | define i32 @f_o0(i32 noundef %0) #0 {
# |                  ^
# | <stdin>:98:270: note: possible intended match here
# | attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
# |                                                                                                                                                                                                                                                                              ^
# | 
# | Input file: <stdin>
# | Check file: /builddir/build/BUILD/llvm-24.0.0_pre20261024.g16dde0db3ce0b9-build/llvm-project-16dde0db3ce0b9c5eae14178780cc6db1eec7ac8/clang/test/Interpreter/pragma-optimize.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |            .
# |            .
# |            .
# |           86: source_filename = "incr_module_8" 
# |           87: target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128" 
# |           88: target triple = "x86_64-unknown-linux-gnu" 
# |           89:  
# |           90: ; Function Attrs: mustprogress noinline nounwind optnone uwtable 
# |           91: define i32 @f_o0(i32 noundef %0) #0 { 
# | next:11'0                     {                       search range start (exclusive)
# | next:11'1                                             error: no match found in search range
# |           92:  %2 = alloca i32, align 4 
# |           93:  store i32 %0, ptr %2, align 4 
# |           94:  %3 = load i32, ptr %2, align 4 
# |           95:  ret i32 %3 
# |           96: } 
# |           97:  
# |           98: attributes #0 = { mustprogress noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" } 
# | next:11'2                                                                                                                                                                                                                                                                                  ?           possible intended match
# |           99:  
# |          100: !llvm.module.flags = !{!0, !1, !2} 
# |          101: !llvm.ident = !{!3} 
# |          102:  
# |          103: !0 = !{i32 8, !"PIC Level", i32 2} 
# |            .
# |            .
# |            .
# |          793:  
# |          794: !0 = !{i32 8, !"PIC Level", i32 2} 
# |          795: !1 = !{i32 7, !"uwtable", i32 2} 
# |          796: !2 = !{i32 7, !"frame-pointer", i32 2} 
# |          797: !3 = !{!"clang version 24.0.0pre20261024.g16dde0db3ce0b9 (Fedora 24.0.0~pre20261024.g16dde0db3ce0b9-1.fc46)"} 
# |          798:  
# | next:11'3      } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

********************
```

https://github.com/llvm/llvm-project/pull/214793


More information about the cfe-commits mailing list