'if' is defined to complex code when CONFIG_PROFILE_ALL_BRANCHES is
selected, which cause a 'perf test LLVM' failure like:

 $ ./perf test LLVM
 35: LLVM search and compile                    :
 35.1: Basic BPF llvm compile                    : Ok
 35.2: kbuild searching                          : Ok
 35.3: Compile source for BPF prologue generation: FAILED!
 35.4: Compile source for BPF relocation         : Skip

The only affected test case is bpf-script-test-prologue.c
because it uses kernel headers and has 'if' inside.

This patch undefines 'if' to make it passes perf test.

Signed-off-by: Wang Nan <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Thomas-Mich Richter <[email protected]>
Cc: Hendrik Brueckner <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Li Zefan <[email protected]>
---
 tools/perf/tests/bpf-script-test-prologue.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/tools/perf/tests/bpf-script-test-prologue.c 
b/tools/perf/tests/bpf-script-test-prologue.c
index 7230e62..b4ebc75 100644
--- a/tools/perf/tests/bpf-script-test-prologue.c
+++ b/tools/perf/tests/bpf-script-test-prologue.c
@@ -10,6 +10,15 @@
 
 #include <uapi/linux/fs.h>
 
+/*
+ * If CONFIG_PROFILE_ALL_BRANCHES is selected,
+ * 'if' is redefined after include kernel header.
+ * Recover 'if' for BPF object code.
+ */
+#ifdef if
+# undef if
+#endif
+
 #define FMODE_READ             0x1
 #define FMODE_WRITE            0x2
 
-- 
2.9.3

Reply via email to