[LLVMdev] Clang removes Label name

Rouxel Benjamin benjamin.rouxel at inria.fr
Fri Jun 6 01:23:21 PDT 2014


Hi,

I have some troubles to figure out why clang is removing my label name. As the simple example below shows the label "MLB" is removed and replaced by an integer as an "unnamed value".
Plus, I can see that an unconditional jump is added, as the label seems to be interpreted as the beginning of a BasicBlock. I am compiling without any optimizations (for now), what leave the produced code slower than the input one.

Anyway, the important thinks to me is to keep label name, but I can't figure out where in the code this transformation is done. My guess is, it's done by Clang while parsing, or just after. Could someone gives me some clue about the class/method where this "feature" is ?

Input:
int main() {
    int i=0;
MLB:
    return i;
}

Result:
define i32 @main() #0 {
  %1 = alloca i32, align 4
  %i = alloca i32, align 4
  store i32 0, i32* %1
  store i32 0, i32* %i, align 4
  br label %2

; <label>:2                                       ; preds = %0
  %3 = load i32* %i, align 4
  ret i32 %3
}

--------------------------------------------------- 
% clang --version
clang version 3.4 (branches/release_34)
Target: x86_64-unknown-linux-gnu
Thread model: posix

% clang -O0 -emit-llvm -mllvm -debug-pass=Structure -S -c -o /dev/stdout main.c

Thanks for you help
Benjamin Rouxel



More information about the llvm-dev mailing list